graphiql.js 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.GraphiQL = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. (function (global){
  3. 'use strict';
  4. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  5. // original notice:
  6. /*!
  7. * The buffer module from node.js, for the browser.
  8. *
  9. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  10. * @license MIT
  11. */
  12. function compare(a, b) {
  13. if (a === b) {
  14. return 0;
  15. }
  16. var x = a.length;
  17. var y = b.length;
  18. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  19. if (a[i] !== b[i]) {
  20. x = a[i];
  21. y = b[i];
  22. break;
  23. }
  24. }
  25. if (x < y) {
  26. return -1;
  27. }
  28. if (y < x) {
  29. return 1;
  30. }
  31. return 0;
  32. }
  33. function isBuffer(b) {
  34. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  35. return global.Buffer.isBuffer(b);
  36. }
  37. return !!(b != null && b._isBuffer);
  38. }
  39. // based on node assert, original notice:
  40. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  41. //
  42. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  43. //
  44. // Originally from narwhal.js (http://narwhaljs.org)
  45. // Copyright (c) 2009 Thomas Robinson <280north.com>
  46. //
  47. // Permission is hereby granted, free of charge, to any person obtaining a copy
  48. // of this software and associated documentation files (the 'Software'), to
  49. // deal in the Software without restriction, including without limitation the
  50. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  51. // sell copies of the Software, and to permit persons to whom the Software is
  52. // furnished to do so, subject to the following conditions:
  53. //
  54. // The above copyright notice and this permission notice shall be included in
  55. // all copies or substantial portions of the Software.
  56. //
  57. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  61. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  62. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  63. var util = require('util/');
  64. var hasOwn = Object.prototype.hasOwnProperty;
  65. var pSlice = Array.prototype.slice;
  66. var functionsHaveNames = (function () {
  67. return function foo() {}.name === 'foo';
  68. }());
  69. function pToString (obj) {
  70. return Object.prototype.toString.call(obj);
  71. }
  72. function isView(arrbuf) {
  73. if (isBuffer(arrbuf)) {
  74. return false;
  75. }
  76. if (typeof global.ArrayBuffer !== 'function') {
  77. return false;
  78. }
  79. if (typeof ArrayBuffer.isView === 'function') {
  80. return ArrayBuffer.isView(arrbuf);
  81. }
  82. if (!arrbuf) {
  83. return false;
  84. }
  85. if (arrbuf instanceof DataView) {
  86. return true;
  87. }
  88. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  89. return true;
  90. }
  91. return false;
  92. }
  93. // 1. The assert module provides functions that throw
  94. // AssertionError's when particular conditions are not met. The
  95. // assert module must conform to the following interface.
  96. var assert = module.exports = ok;
  97. // 2. The AssertionError is defined in assert.
  98. // new assert.AssertionError({ message: message,
  99. // actual: actual,
  100. // expected: expected })
  101. var regex = /\s*function\s+([^\(\s]*)\s*/;
  102. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  103. function getName(func) {
  104. if (!util.isFunction(func)) {
  105. return;
  106. }
  107. if (functionsHaveNames) {
  108. return func.name;
  109. }
  110. var str = func.toString();
  111. var match = str.match(regex);
  112. return match && match[1];
  113. }
  114. assert.AssertionError = function AssertionError(options) {
  115. this.name = 'AssertionError';
  116. this.actual = options.actual;
  117. this.expected = options.expected;
  118. this.operator = options.operator;
  119. if (options.message) {
  120. this.message = options.message;
  121. this.generatedMessage = false;
  122. } else {
  123. this.message = getMessage(this);
  124. this.generatedMessage = true;
  125. }
  126. var stackStartFunction = options.stackStartFunction || fail;
  127. if (Error.captureStackTrace) {
  128. Error.captureStackTrace(this, stackStartFunction);
  129. } else {
  130. // non v8 browsers so we can have a stacktrace
  131. var err = new Error();
  132. if (err.stack) {
  133. var out = err.stack;
  134. // try to strip useless frames
  135. var fn_name = getName(stackStartFunction);
  136. var idx = out.indexOf('\n' + fn_name);
  137. if (idx >= 0) {
  138. // once we have located the function frame
  139. // we need to strip out everything before it (and its line)
  140. var next_line = out.indexOf('\n', idx + 1);
  141. out = out.substring(next_line + 1);
  142. }
  143. this.stack = out;
  144. }
  145. }
  146. };
  147. // assert.AssertionError instanceof Error
  148. util.inherits(assert.AssertionError, Error);
  149. function truncate(s, n) {
  150. if (typeof s === 'string') {
  151. return s.length < n ? s : s.slice(0, n);
  152. } else {
  153. return s;
  154. }
  155. }
  156. function inspect(something) {
  157. if (functionsHaveNames || !util.isFunction(something)) {
  158. return util.inspect(something);
  159. }
  160. var rawname = getName(something);
  161. var name = rawname ? ': ' + rawname : '';
  162. return '[Function' + name + ']';
  163. }
  164. function getMessage(self) {
  165. return truncate(inspect(self.actual), 128) + ' ' +
  166. self.operator + ' ' +
  167. truncate(inspect(self.expected), 128);
  168. }
  169. // At present only the three keys mentioned above are used and
  170. // understood by the spec. Implementations or sub modules can pass
  171. // other keys to the AssertionError's constructor - they will be
  172. // ignored.
  173. // 3. All of the following functions must throw an AssertionError
  174. // when a corresponding condition is not met, with a message that
  175. // may be undefined if not provided. All assertion methods provide
  176. // both the actual and expected values to the assertion error for
  177. // display purposes.
  178. function fail(actual, expected, message, operator, stackStartFunction) {
  179. throw new assert.AssertionError({
  180. message: message,
  181. actual: actual,
  182. expected: expected,
  183. operator: operator,
  184. stackStartFunction: stackStartFunction
  185. });
  186. }
  187. // EXTENSION! allows for well behaved errors defined elsewhere.
  188. assert.fail = fail;
  189. // 4. Pure assertion tests whether a value is truthy, as determined
  190. // by !!guard.
  191. // assert.ok(guard, message_opt);
  192. // This statement is equivalent to assert.equal(true, !!guard,
  193. // message_opt);. To test strictly for the value true, use
  194. // assert.strictEqual(true, guard, message_opt);.
  195. function ok(value, message) {
  196. if (!value) fail(value, true, message, '==', assert.ok);
  197. }
  198. assert.ok = ok;
  199. // 5. The equality assertion tests shallow, coercive equality with
  200. // ==.
  201. // assert.equal(actual, expected, message_opt);
  202. assert.equal = function equal(actual, expected, message) {
  203. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  204. };
  205. // 6. The non-equality assertion tests for whether two objects are not equal
  206. // with != assert.notEqual(actual, expected, message_opt);
  207. assert.notEqual = function notEqual(actual, expected, message) {
  208. if (actual == expected) {
  209. fail(actual, expected, message, '!=', assert.notEqual);
  210. }
  211. };
  212. // 7. The equivalence assertion tests a deep equality relation.
  213. // assert.deepEqual(actual, expected, message_opt);
  214. assert.deepEqual = function deepEqual(actual, expected, message) {
  215. if (!_deepEqual(actual, expected, false)) {
  216. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  217. }
  218. };
  219. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  220. if (!_deepEqual(actual, expected, true)) {
  221. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  222. }
  223. };
  224. function _deepEqual(actual, expected, strict, memos) {
  225. // 7.1. All identical values are equivalent, as determined by ===.
  226. if (actual === expected) {
  227. return true;
  228. } else if (isBuffer(actual) && isBuffer(expected)) {
  229. return compare(actual, expected) === 0;
  230. // 7.2. If the expected value is a Date object, the actual value is
  231. // equivalent if it is also a Date object that refers to the same time.
  232. } else if (util.isDate(actual) && util.isDate(expected)) {
  233. return actual.getTime() === expected.getTime();
  234. // 7.3 If the expected value is a RegExp object, the actual value is
  235. // equivalent if it is also a RegExp object with the same source and
  236. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  237. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  238. return actual.source === expected.source &&
  239. actual.global === expected.global &&
  240. actual.multiline === expected.multiline &&
  241. actual.lastIndex === expected.lastIndex &&
  242. actual.ignoreCase === expected.ignoreCase;
  243. // 7.4. Other pairs that do not both pass typeof value == 'object',
  244. // equivalence is determined by ==.
  245. } else if ((actual === null || typeof actual !== 'object') &&
  246. (expected === null || typeof expected !== 'object')) {
  247. return strict ? actual === expected : actual == expected;
  248. // If both values are instances of typed arrays, wrap their underlying
  249. // ArrayBuffers in a Buffer each to increase performance
  250. // This optimization requires the arrays to have the same type as checked by
  251. // Object.prototype.toString (aka pToString). Never perform binary
  252. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  253. // bit patterns are not identical.
  254. } else if (isView(actual) && isView(expected) &&
  255. pToString(actual) === pToString(expected) &&
  256. !(actual instanceof Float32Array ||
  257. actual instanceof Float64Array)) {
  258. return compare(new Uint8Array(actual.buffer),
  259. new Uint8Array(expected.buffer)) === 0;
  260. // 7.5 For all other Object pairs, including Array objects, equivalence is
  261. // determined by having the same number of owned properties (as verified
  262. // with Object.prototype.hasOwnProperty.call), the same set of keys
  263. // (although not necessarily the same order), equivalent values for every
  264. // corresponding key, and an identical 'prototype' property. Note: this
  265. // accounts for both named and indexed properties on Arrays.
  266. } else if (isBuffer(actual) !== isBuffer(expected)) {
  267. return false;
  268. } else {
  269. memos = memos || {actual: [], expected: []};
  270. var actualIndex = memos.actual.indexOf(actual);
  271. if (actualIndex !== -1) {
  272. if (actualIndex === memos.expected.indexOf(expected)) {
  273. return true;
  274. }
  275. }
  276. memos.actual.push(actual);
  277. memos.expected.push(expected);
  278. return objEquiv(actual, expected, strict, memos);
  279. }
  280. }
  281. function isArguments(object) {
  282. return Object.prototype.toString.call(object) == '[object Arguments]';
  283. }
  284. function objEquiv(a, b, strict, actualVisitedObjects) {
  285. if (a === null || a === undefined || b === null || b === undefined)
  286. return false;
  287. // if one is a primitive, the other must be same
  288. if (util.isPrimitive(a) || util.isPrimitive(b))
  289. return a === b;
  290. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  291. return false;
  292. var aIsArgs = isArguments(a);
  293. var bIsArgs = isArguments(b);
  294. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  295. return false;
  296. if (aIsArgs) {
  297. a = pSlice.call(a);
  298. b = pSlice.call(b);
  299. return _deepEqual(a, b, strict);
  300. }
  301. var ka = objectKeys(a);
  302. var kb = objectKeys(b);
  303. var key, i;
  304. // having the same number of owned properties (keys incorporates
  305. // hasOwnProperty)
  306. if (ka.length !== kb.length)
  307. return false;
  308. //the same set of keys (although not necessarily the same order),
  309. ka.sort();
  310. kb.sort();
  311. //~~~cheap key test
  312. for (i = ka.length - 1; i >= 0; i--) {
  313. if (ka[i] !== kb[i])
  314. return false;
  315. }
  316. //equivalent values for every corresponding key, and
  317. //~~~possibly expensive deep test
  318. for (i = ka.length - 1; i >= 0; i--) {
  319. key = ka[i];
  320. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  321. return false;
  322. }
  323. return true;
  324. }
  325. // 8. The non-equivalence assertion tests for any deep inequality.
  326. // assert.notDeepEqual(actual, expected, message_opt);
  327. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  328. if (_deepEqual(actual, expected, false)) {
  329. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  330. }
  331. };
  332. assert.notDeepStrictEqual = notDeepStrictEqual;
  333. function notDeepStrictEqual(actual, expected, message) {
  334. if (_deepEqual(actual, expected, true)) {
  335. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  336. }
  337. }
  338. // 9. The strict equality assertion tests strict equality, as determined by ===.
  339. // assert.strictEqual(actual, expected, message_opt);
  340. assert.strictEqual = function strictEqual(actual, expected, message) {
  341. if (actual !== expected) {
  342. fail(actual, expected, message, '===', assert.strictEqual);
  343. }
  344. };
  345. // 10. The strict non-equality assertion tests for strict inequality, as
  346. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  347. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  348. if (actual === expected) {
  349. fail(actual, expected, message, '!==', assert.notStrictEqual);
  350. }
  351. };
  352. function expectedException(actual, expected) {
  353. if (!actual || !expected) {
  354. return false;
  355. }
  356. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  357. return expected.test(actual);
  358. }
  359. try {
  360. if (actual instanceof expected) {
  361. return true;
  362. }
  363. } catch (e) {
  364. // Ignore. The instanceof check doesn't work for arrow functions.
  365. }
  366. if (Error.isPrototypeOf(expected)) {
  367. return false;
  368. }
  369. return expected.call({}, actual) === true;
  370. }
  371. function _tryBlock(block) {
  372. var error;
  373. try {
  374. block();
  375. } catch (e) {
  376. error = e;
  377. }
  378. return error;
  379. }
  380. function _throws(shouldThrow, block, expected, message) {
  381. var actual;
  382. if (typeof block !== 'function') {
  383. throw new TypeError('"block" argument must be a function');
  384. }
  385. if (typeof expected === 'string') {
  386. message = expected;
  387. expected = null;
  388. }
  389. actual = _tryBlock(block);
  390. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  391. (message ? ' ' + message : '.');
  392. if (shouldThrow && !actual) {
  393. fail(actual, expected, 'Missing expected exception' + message);
  394. }
  395. var userProvidedMessage = typeof message === 'string';
  396. var isUnwantedException = !shouldThrow && util.isError(actual);
  397. var isUnexpectedException = !shouldThrow && actual && !expected;
  398. if ((isUnwantedException &&
  399. userProvidedMessage &&
  400. expectedException(actual, expected)) ||
  401. isUnexpectedException) {
  402. fail(actual, expected, 'Got unwanted exception' + message);
  403. }
  404. if ((shouldThrow && actual && expected &&
  405. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  406. throw actual;
  407. }
  408. }
  409. // 11. Expected to throw an error:
  410. // assert.throws(block, Error_opt, message_opt);
  411. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  412. _throws(true, block, error, message);
  413. };
  414. // EXTENSION! This is annoying to write outside this module.
  415. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  416. _throws(false, block, error, message);
  417. };
  418. assert.ifError = function(err) { if (err) throw err; };
  419. var objectKeys = Object.keys || function (obj) {
  420. var keys = [];
  421. for (var key in obj) {
  422. if (hasOwn.call(obj, key)) keys.push(key);
  423. }
  424. return keys;
  425. };
  426. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  427. },{"util/":216}],2:[function(require,module,exports){
  428. (function (global){
  429. /*! https://mths.be/punycode v1.4.1 by @mathias */
  430. ;(function(root) {
  431. /** Detect free variables */
  432. var freeExports = typeof exports == 'object' && exports &&
  433. !exports.nodeType && exports;
  434. var freeModule = typeof module == 'object' && module &&
  435. !module.nodeType && module;
  436. var freeGlobal = typeof global == 'object' && global;
  437. if (
  438. freeGlobal.global === freeGlobal ||
  439. freeGlobal.window === freeGlobal ||
  440. freeGlobal.self === freeGlobal
  441. ) {
  442. root = freeGlobal;
  443. }
  444. /**
  445. * The `punycode` object.
  446. * @name punycode
  447. * @type Object
  448. */
  449. var punycode,
  450. /** Highest positive signed 32-bit float value */
  451. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  452. /** Bootstring parameters */
  453. base = 36,
  454. tMin = 1,
  455. tMax = 26,
  456. skew = 38,
  457. damp = 700,
  458. initialBias = 72,
  459. initialN = 128, // 0x80
  460. delimiter = '-', // '\x2D'
  461. /** Regular expressions */
  462. regexPunycode = /^xn--/,
  463. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  464. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  465. /** Error messages */
  466. errors = {
  467. 'overflow': 'Overflow: input needs wider integers to process',
  468. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  469. 'invalid-input': 'Invalid input'
  470. },
  471. /** Convenience shortcuts */
  472. baseMinusTMin = base - tMin,
  473. floor = Math.floor,
  474. stringFromCharCode = String.fromCharCode,
  475. /** Temporary variable */
  476. key;
  477. /*--------------------------------------------------------------------------*/
  478. /**
  479. * A generic error utility function.
  480. * @private
  481. * @param {String} type The error type.
  482. * @returns {Error} Throws a `RangeError` with the applicable error message.
  483. */
  484. function error(type) {
  485. throw new RangeError(errors[type]);
  486. }
  487. /**
  488. * A generic `Array#map` utility function.
  489. * @private
  490. * @param {Array} array The array to iterate over.
  491. * @param {Function} callback The function that gets called for every array
  492. * item.
  493. * @returns {Array} A new array of values returned by the callback function.
  494. */
  495. function map(array, fn) {
  496. var length = array.length;
  497. var result = [];
  498. while (length--) {
  499. result[length] = fn(array[length]);
  500. }
  501. return result;
  502. }
  503. /**
  504. * A simple `Array#map`-like wrapper to work with domain name strings or email
  505. * addresses.
  506. * @private
  507. * @param {String} domain The domain name or email address.
  508. * @param {Function} callback The function that gets called for every
  509. * character.
  510. * @returns {Array} A new string of characters returned by the callback
  511. * function.
  512. */
  513. function mapDomain(string, fn) {
  514. var parts = string.split('@');
  515. var result = '';
  516. if (parts.length > 1) {
  517. // In email addresses, only the domain name should be punycoded. Leave
  518. // the local part (i.e. everything up to `@`) intact.
  519. result = parts[0] + '@';
  520. string = parts[1];
  521. }
  522. // Avoid `split(regex)` for IE8 compatibility. See #17.
  523. string = string.replace(regexSeparators, '\x2E');
  524. var labels = string.split('.');
  525. var encoded = map(labels, fn).join('.');
  526. return result + encoded;
  527. }
  528. /**
  529. * Creates an array containing the numeric code points of each Unicode
  530. * character in the string. While JavaScript uses UCS-2 internally,
  531. * this function will convert a pair of surrogate halves (each of which
  532. * UCS-2 exposes as separate characters) into a single code point,
  533. * matching UTF-16.
  534. * @see `punycode.ucs2.encode`
  535. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  536. * @memberOf punycode.ucs2
  537. * @name decode
  538. * @param {String} string The Unicode input string (UCS-2).
  539. * @returns {Array} The new array of code points.
  540. */
  541. function ucs2decode(string) {
  542. var output = [],
  543. counter = 0,
  544. length = string.length,
  545. value,
  546. extra;
  547. while (counter < length) {
  548. value = string.charCodeAt(counter++);
  549. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  550. // high surrogate, and there is a next character
  551. extra = string.charCodeAt(counter++);
  552. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  553. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  554. } else {
  555. // unmatched surrogate; only append this code unit, in case the next
  556. // code unit is the high surrogate of a surrogate pair
  557. output.push(value);
  558. counter--;
  559. }
  560. } else {
  561. output.push(value);
  562. }
  563. }
  564. return output;
  565. }
  566. /**
  567. * Creates a string based on an array of numeric code points.
  568. * @see `punycode.ucs2.decode`
  569. * @memberOf punycode.ucs2
  570. * @name encode
  571. * @param {Array} codePoints The array of numeric code points.
  572. * @returns {String} The new Unicode string (UCS-2).
  573. */
  574. function ucs2encode(array) {
  575. return map(array, function(value) {
  576. var output = '';
  577. if (value > 0xFFFF) {
  578. value -= 0x10000;
  579. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  580. value = 0xDC00 | value & 0x3FF;
  581. }
  582. output += stringFromCharCode(value);
  583. return output;
  584. }).join('');
  585. }
  586. /**
  587. * Converts a basic code point into a digit/integer.
  588. * @see `digitToBasic()`
  589. * @private
  590. * @param {Number} codePoint The basic numeric code point value.
  591. * @returns {Number} The numeric value of a basic code point (for use in
  592. * representing integers) in the range `0` to `base - 1`, or `base` if
  593. * the code point does not represent a value.
  594. */
  595. function basicToDigit(codePoint) {
  596. if (codePoint - 48 < 10) {
  597. return codePoint - 22;
  598. }
  599. if (codePoint - 65 < 26) {
  600. return codePoint - 65;
  601. }
  602. if (codePoint - 97 < 26) {
  603. return codePoint - 97;
  604. }
  605. return base;
  606. }
  607. /**
  608. * Converts a digit/integer into a basic code point.
  609. * @see `basicToDigit()`
  610. * @private
  611. * @param {Number} digit The numeric value of a basic code point.
  612. * @returns {Number} The basic code point whose value (when used for
  613. * representing integers) is `digit`, which needs to be in the range
  614. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  615. * used; else, the lowercase form is used. The behavior is undefined
  616. * if `flag` is non-zero and `digit` has no uppercase form.
  617. */
  618. function digitToBasic(digit, flag) {
  619. // 0..25 map to ASCII a..z or A..Z
  620. // 26..35 map to ASCII 0..9
  621. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  622. }
  623. /**
  624. * Bias adaptation function as per section 3.4 of RFC 3492.
  625. * https://tools.ietf.org/html/rfc3492#section-3.4
  626. * @private
  627. */
  628. function adapt(delta, numPoints, firstTime) {
  629. var k = 0;
  630. delta = firstTime ? floor(delta / damp) : delta >> 1;
  631. delta += floor(delta / numPoints);
  632. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  633. delta = floor(delta / baseMinusTMin);
  634. }
  635. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  636. }
  637. /**
  638. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  639. * symbols.
  640. * @memberOf punycode
  641. * @param {String} input The Punycode string of ASCII-only symbols.
  642. * @returns {String} The resulting string of Unicode symbols.
  643. */
  644. function decode(input) {
  645. // Don't use UCS-2
  646. var output = [],
  647. inputLength = input.length,
  648. out,
  649. i = 0,
  650. n = initialN,
  651. bias = initialBias,
  652. basic,
  653. j,
  654. index,
  655. oldi,
  656. w,
  657. k,
  658. digit,
  659. t,
  660. /** Cached calculation results */
  661. baseMinusT;
  662. // Handle the basic code points: let `basic` be the number of input code
  663. // points before the last delimiter, or `0` if there is none, then copy
  664. // the first basic code points to the output.
  665. basic = input.lastIndexOf(delimiter);
  666. if (basic < 0) {
  667. basic = 0;
  668. }
  669. for (j = 0; j < basic; ++j) {
  670. // if it's not a basic code point
  671. if (input.charCodeAt(j) >= 0x80) {
  672. error('not-basic');
  673. }
  674. output.push(input.charCodeAt(j));
  675. }
  676. // Main decoding loop: start just after the last delimiter if any basic code
  677. // points were copied; start at the beginning otherwise.
  678. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  679. // `index` is the index of the next character to be consumed.
  680. // Decode a generalized variable-length integer into `delta`,
  681. // which gets added to `i`. The overflow checking is easier
  682. // if we increase `i` as we go, then subtract off its starting
  683. // value at the end to obtain `delta`.
  684. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  685. if (index >= inputLength) {
  686. error('invalid-input');
  687. }
  688. digit = basicToDigit(input.charCodeAt(index++));
  689. if (digit >= base || digit > floor((maxInt - i) / w)) {
  690. error('overflow');
  691. }
  692. i += digit * w;
  693. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  694. if (digit < t) {
  695. break;
  696. }
  697. baseMinusT = base - t;
  698. if (w > floor(maxInt / baseMinusT)) {
  699. error('overflow');
  700. }
  701. w *= baseMinusT;
  702. }
  703. out = output.length + 1;
  704. bias = adapt(i - oldi, out, oldi == 0);
  705. // `i` was supposed to wrap around from `out` to `0`,
  706. // incrementing `n` each time, so we'll fix that now:
  707. if (floor(i / out) > maxInt - n) {
  708. error('overflow');
  709. }
  710. n += floor(i / out);
  711. i %= out;
  712. // Insert `n` at position `i` of the output
  713. output.splice(i++, 0, n);
  714. }
  715. return ucs2encode(output);
  716. }
  717. /**
  718. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  719. * Punycode string of ASCII-only symbols.
  720. * @memberOf punycode
  721. * @param {String} input The string of Unicode symbols.
  722. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  723. */
  724. function encode(input) {
  725. var n,
  726. delta,
  727. handledCPCount,
  728. basicLength,
  729. bias,
  730. j,
  731. m,
  732. q,
  733. k,
  734. t,
  735. currentValue,
  736. output = [],
  737. /** `inputLength` will hold the number of code points in `input`. */
  738. inputLength,
  739. /** Cached calculation results */
  740. handledCPCountPlusOne,
  741. baseMinusT,
  742. qMinusT;
  743. // Convert the input in UCS-2 to Unicode
  744. input = ucs2decode(input);
  745. // Cache the length
  746. inputLength = input.length;
  747. // Initialize the state
  748. n = initialN;
  749. delta = 0;
  750. bias = initialBias;
  751. // Handle the basic code points
  752. for (j = 0; j < inputLength; ++j) {
  753. currentValue = input[j];
  754. if (currentValue < 0x80) {
  755. output.push(stringFromCharCode(currentValue));
  756. }
  757. }
  758. handledCPCount = basicLength = output.length;
  759. // `handledCPCount` is the number of code points that have been handled;
  760. // `basicLength` is the number of basic code points.
  761. // Finish the basic string - if it is not empty - with a delimiter
  762. if (basicLength) {
  763. output.push(delimiter);
  764. }
  765. // Main encoding loop:
  766. while (handledCPCount < inputLength) {
  767. // All non-basic code points < n have been handled already. Find the next
  768. // larger one:
  769. for (m = maxInt, j = 0; j < inputLength; ++j) {
  770. currentValue = input[j];
  771. if (currentValue >= n && currentValue < m) {
  772. m = currentValue;
  773. }
  774. }
  775. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  776. // but guard against overflow
  777. handledCPCountPlusOne = handledCPCount + 1;
  778. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  779. error('overflow');
  780. }
  781. delta += (m - n) * handledCPCountPlusOne;
  782. n = m;
  783. for (j = 0; j < inputLength; ++j) {
  784. currentValue = input[j];
  785. if (currentValue < n && ++delta > maxInt) {
  786. error('overflow');
  787. }
  788. if (currentValue == n) {
  789. // Represent delta as a generalized variable-length integer
  790. for (q = delta, k = base; /* no condition */; k += base) {
  791. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  792. if (q < t) {
  793. break;
  794. }
  795. qMinusT = q - t;
  796. baseMinusT = base - t;
  797. output.push(
  798. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  799. );
  800. q = floor(qMinusT / baseMinusT);
  801. }
  802. output.push(stringFromCharCode(digitToBasic(q, 0)));
  803. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  804. delta = 0;
  805. ++handledCPCount;
  806. }
  807. }
  808. ++delta;
  809. ++n;
  810. }
  811. return output.join('');
  812. }
  813. /**
  814. * Converts a Punycode string representing a domain name or an email address
  815. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  816. * it doesn't matter if you call it on a string that has already been
  817. * converted to Unicode.
  818. * @memberOf punycode
  819. * @param {String} input The Punycoded domain name or email address to
  820. * convert to Unicode.
  821. * @returns {String} The Unicode representation of the given Punycode
  822. * string.
  823. */
  824. function toUnicode(input) {
  825. return mapDomain(input, function(string) {
  826. return regexPunycode.test(string)
  827. ? decode(string.slice(4).toLowerCase())
  828. : string;
  829. });
  830. }
  831. /**
  832. * Converts a Unicode string representing a domain name or an email address to
  833. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  834. * i.e. it doesn't matter if you call it with a domain that's already in
  835. * ASCII.
  836. * @memberOf punycode
  837. * @param {String} input The domain name or email address to convert, as a
  838. * Unicode string.
  839. * @returns {String} The Punycode representation of the given domain name or
  840. * email address.
  841. */
  842. function toASCII(input) {
  843. return mapDomain(input, function(string) {
  844. return regexNonASCII.test(string)
  845. ? 'xn--' + encode(string)
  846. : string;
  847. });
  848. }
  849. /*--------------------------------------------------------------------------*/
  850. /** Define the public API */
  851. punycode = {
  852. /**
  853. * A string representing the current Punycode.js version number.
  854. * @memberOf punycode
  855. * @type String
  856. */
  857. 'version': '1.4.1',
  858. /**
  859. * An object of methods to convert from JavaScript's internal character
  860. * representation (UCS-2) to Unicode code points, and back.
  861. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  862. * @memberOf punycode
  863. * @type Object
  864. */
  865. 'ucs2': {
  866. 'decode': ucs2decode,
  867. 'encode': ucs2encode
  868. },
  869. 'decode': decode,
  870. 'encode': encode,
  871. 'toASCII': toASCII,
  872. 'toUnicode': toUnicode
  873. };
  874. /** Expose `punycode` */
  875. // Some AMD build optimizers, like r.js, check for specific condition patterns
  876. // like the following:
  877. if (
  878. typeof define == 'function' &&
  879. typeof define.amd == 'object' &&
  880. define.amd
  881. ) {
  882. define('punycode', function() {
  883. return punycode;
  884. });
  885. } else if (freeExports && freeModule) {
  886. if (module.exports == freeExports) {
  887. // in Node.js, io.js, or RingoJS v0.8.0+
  888. freeModule.exports = punycode;
  889. } else {
  890. // in Narwhal or RingoJS v0.7.0-
  891. for (key in punycode) {
  892. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  893. }
  894. }
  895. } else {
  896. // in Rhino or a web browser
  897. root.punycode = punycode;
  898. }
  899. }(this));
  900. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  901. },{}],3:[function(require,module,exports){
  902. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  903. // Distributed under an MIT license: https://codemirror.net/LICENSE
  904. (function(mod) {
  905. if (typeof exports == "object" && typeof module == "object") // CommonJS
  906. mod(require("../../lib/codemirror"));
  907. else if (typeof define == "function" && define.amd) // AMD
  908. define(["../../lib/codemirror"], mod);
  909. else // Plain browser env
  910. mod(CodeMirror);
  911. })(function(CodeMirror) {
  912. "use strict";
  913. var noOptions = {};
  914. var nonWS = /[^\s\u00a0]/;
  915. var Pos = CodeMirror.Pos;
  916. function firstNonWS(str) {
  917. var found = str.search(nonWS);
  918. return found == -1 ? 0 : found;
  919. }
  920. CodeMirror.commands.toggleComment = function(cm) {
  921. cm.toggleComment();
  922. };
  923. CodeMirror.defineExtension("toggleComment", function(options) {
  924. if (!options) options = noOptions;
  925. var cm = this;
  926. var minLine = Infinity, ranges = this.listSelections(), mode = null;
  927. for (var i = ranges.length - 1; i >= 0; i--) {
  928. var from = ranges[i].from(), to = ranges[i].to();
  929. if (from.line >= minLine) continue;
  930. if (to.line >= minLine) to = Pos(minLine, 0);
  931. minLine = from.line;
  932. if (mode == null) {
  933. if (cm.uncomment(from, to, options)) mode = "un";
  934. else { cm.lineComment(from, to, options); mode = "line"; }
  935. } else if (mode == "un") {
  936. cm.uncomment(from, to, options);
  937. } else {
  938. cm.lineComment(from, to, options);
  939. }
  940. }
  941. });
  942. // Rough heuristic to try and detect lines that are part of multi-line string
  943. function probablyInsideString(cm, pos, line) {
  944. return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
  945. }
  946. function getMode(cm, pos) {
  947. var mode = cm.getMode()
  948. return mode.useInnerComments === false || !mode.innerMode ? mode : cm.getModeAt(pos)
  949. }
  950. CodeMirror.defineExtension("lineComment", function(from, to, options) {
  951. if (!options) options = noOptions;
  952. var self = this, mode = getMode(self, from);
  953. var firstLine = self.getLine(from.line);
  954. if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
  955. var commentString = options.lineComment || mode.lineComment;
  956. if (!commentString) {
  957. if (options.blockCommentStart || mode.blockCommentStart) {
  958. options.fullLines = true;
  959. self.blockComment(from, to, options);
  960. }
  961. return;
  962. }
  963. var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
  964. var pad = options.padding == null ? " " : options.padding;
  965. var blankLines = options.commentBlankLines || from.line == to.line;
  966. self.operation(function() {
  967. if (options.indent) {
  968. var baseString = null;
  969. for (var i = from.line; i < end; ++i) {
  970. var line = self.getLine(i);
  971. var whitespace = line.slice(0, firstNonWS(line));
  972. if (baseString == null || baseString.length > whitespace.length) {
  973. baseString = whitespace;
  974. }
  975. }
  976. for (var i = from.line; i < end; ++i) {
  977. var line = self.getLine(i), cut = baseString.length;
  978. if (!blankLines && !nonWS.test(line)) continue;
  979. if (line.slice(0, cut) != baseString) cut = firstNonWS(line);
  980. self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut));
  981. }
  982. } else {
  983. for (var i = from.line; i < end; ++i) {
  984. if (blankLines || nonWS.test(self.getLine(i)))
  985. self.replaceRange(commentString + pad, Pos(i, 0));
  986. }
  987. }
  988. });
  989. });
  990. CodeMirror.defineExtension("blockComment", function(from, to, options) {
  991. if (!options) options = noOptions;
  992. var self = this, mode = getMode(self, from);
  993. var startString = options.blockCommentStart || mode.blockCommentStart;
  994. var endString = options.blockCommentEnd || mode.blockCommentEnd;
  995. if (!startString || !endString) {
  996. if ((options.lineComment || mode.lineComment) && options.fullLines != false)
  997. self.lineComment(from, to, options);
  998. return;
  999. }
  1000. if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
  1001. var end = Math.min(to.line, self.lastLine());
  1002. if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
  1003. var pad = options.padding == null ? " " : options.padding;
  1004. if (from.line > end) return;
  1005. self.operation(function() {
  1006. if (options.fullLines != false) {
  1007. var lastLineHasText = nonWS.test(self.getLine(end));
  1008. self.replaceRange(pad + endString, Pos(end));
  1009. self.replaceRange(startString + pad, Pos(from.line, 0));
  1010. var lead = options.blockCommentLead || mode.blockCommentLead;
  1011. if (lead != null) for (var i = from.line + 1; i <= end; ++i)
  1012. if (i != end || lastLineHasText)
  1013. self.replaceRange(lead + pad, Pos(i, 0));
  1014. } else {
  1015. self.replaceRange(endString, to);
  1016. self.replaceRange(startString, from);
  1017. }
  1018. });
  1019. });
  1020. CodeMirror.defineExtension("uncomment", function(from, to, options) {
  1021. if (!options) options = noOptions;
  1022. var self = this, mode = getMode(self, from);
  1023. var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
  1024. // Try finding line comments
  1025. var lineString = options.lineComment || mode.lineComment, lines = [];
  1026. var pad = options.padding == null ? " " : options.padding, didSomething;
  1027. lineComment: {
  1028. if (!lineString) break lineComment;
  1029. for (var i = start; i <= end; ++i) {
  1030. var line = self.getLine(i);
  1031. var found = line.indexOf(lineString);
  1032. if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
  1033. if (found == -1 && nonWS.test(line)) break lineComment;
  1034. if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
  1035. lines.push(line);
  1036. }
  1037. self.operation(function() {
  1038. for (var i = start; i <= end; ++i) {
  1039. var line = lines[i - start];
  1040. var pos = line.indexOf(lineString), endPos = pos + lineString.length;
  1041. if (pos < 0) continue;
  1042. if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length;
  1043. didSomething = true;
  1044. self.replaceRange("", Pos(i, pos), Pos(i, endPos));
  1045. }
  1046. });
  1047. if (didSomething) return true;
  1048. }
  1049. // Try block comments
  1050. var startString = options.blockCommentStart || mode.blockCommentStart;
  1051. var endString = options.blockCommentEnd || mode.blockCommentEnd;
  1052. if (!startString || !endString) return false;
  1053. var lead = options.blockCommentLead || mode.blockCommentLead;
  1054. var startLine = self.getLine(start), open = startLine.indexOf(startString)
  1055. if (open == -1) return false
  1056. var endLine = end == start ? startLine : self.getLine(end)
  1057. var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
  1058. var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
  1059. if (close == -1 ||
  1060. !/comment/.test(self.getTokenTypeAt(insideStart)) ||
  1061. !/comment/.test(self.getTokenTypeAt(insideEnd)) ||
  1062. self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
  1063. return false;
  1064. // Avoid killing block comments completely outside the selection.
  1065. // Positions of the last startString before the start of the selection, and the first endString after it.
  1066. var lastStart = startLine.lastIndexOf(startString, from.ch);
  1067. var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length);
  1068. if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false;
  1069. // Positions of the first endString after the end of the selection, and the last startString before it.
  1070. firstEnd = endLine.indexOf(endString, to.ch);
  1071. var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch);
  1072. lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart;
  1073. if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false;
  1074. self.operation(function() {
  1075. self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)),
  1076. Pos(end, close + endString.length));
  1077. var openEnd = open + startString.length;
  1078. if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length;
  1079. self.replaceRange("", Pos(start, open), Pos(start, openEnd));
  1080. if (lead) for (var i = start + 1; i <= end; ++i) {
  1081. var line = self.getLine(i), found = line.indexOf(lead);
  1082. if (found == -1 || nonWS.test(line.slice(0, found))) continue;
  1083. var foundEnd = found + lead.length;
  1084. if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
  1085. self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
  1086. }
  1087. });
  1088. return true;
  1089. });
  1090. });
  1091. },{"../../lib/codemirror":16}],4:[function(require,module,exports){
  1092. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1093. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1094. // Open simple dialogs on top of an editor. Relies on dialog.css.
  1095. (function(mod) {
  1096. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1097. mod(require("../../lib/codemirror"));
  1098. else if (typeof define == "function" && define.amd) // AMD
  1099. define(["../../lib/codemirror"], mod);
  1100. else // Plain browser env
  1101. mod(CodeMirror);
  1102. })(function(CodeMirror) {
  1103. function dialogDiv(cm, template, bottom) {
  1104. var wrap = cm.getWrapperElement();
  1105. var dialog;
  1106. dialog = wrap.appendChild(document.createElement("div"));
  1107. if (bottom)
  1108. dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
  1109. else
  1110. dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
  1111. if (typeof template == "string") {
  1112. dialog.innerHTML = template;
  1113. } else { // Assuming it's a detached DOM element.
  1114. dialog.appendChild(template);
  1115. }
  1116. CodeMirror.addClass(wrap, 'dialog-opened');
  1117. return dialog;
  1118. }
  1119. function closeNotification(cm, newVal) {
  1120. if (cm.state.currentNotificationClose)
  1121. cm.state.currentNotificationClose();
  1122. cm.state.currentNotificationClose = newVal;
  1123. }
  1124. CodeMirror.defineExtension("openDialog", function(template, callback, options) {
  1125. if (!options) options = {};
  1126. closeNotification(this, null);
  1127. var dialog = dialogDiv(this, template, options.bottom);
  1128. var closed = false, me = this;
  1129. function close(newVal) {
  1130. if (typeof newVal == 'string') {
  1131. inp.value = newVal;
  1132. } else {
  1133. if (closed) return;
  1134. closed = true;
  1135. CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
  1136. dialog.parentNode.removeChild(dialog);
  1137. me.focus();
  1138. if (options.onClose) options.onClose(dialog);
  1139. }
  1140. }
  1141. var inp = dialog.getElementsByTagName("input")[0], button;
  1142. if (inp) {
  1143. inp.focus();
  1144. if (options.value) {
  1145. inp.value = options.value;
  1146. if (options.selectValueOnOpen !== false) {
  1147. inp.select();
  1148. }
  1149. }
  1150. if (options.onInput)
  1151. CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);});
  1152. if (options.onKeyUp)
  1153. CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);});
  1154. CodeMirror.on(inp, "keydown", function(e) {
  1155. if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }
  1156. if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) {
  1157. inp.blur();
  1158. CodeMirror.e_stop(e);
  1159. close();
  1160. }
  1161. if (e.keyCode == 13) callback(inp.value, e);
  1162. });
  1163. if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
  1164. } else if (button = dialog.getElementsByTagName("button")[0]) {
  1165. CodeMirror.on(button, "click", function() {
  1166. close();
  1167. me.focus();
  1168. });
  1169. if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close);
  1170. button.focus();
  1171. }
  1172. return close;
  1173. });
  1174. CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
  1175. closeNotification(this, null);
  1176. var dialog = dialogDiv(this, template, options && options.bottom);
  1177. var buttons = dialog.getElementsByTagName("button");
  1178. var closed = false, me = this, blurring = 1;
  1179. function close() {
  1180. if (closed) return;
  1181. closed = true;
  1182. CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
  1183. dialog.parentNode.removeChild(dialog);
  1184. me.focus();
  1185. }
  1186. buttons[0].focus();
  1187. for (var i = 0; i < buttons.length; ++i) {
  1188. var b = buttons[i];
  1189. (function(callback) {
  1190. CodeMirror.on(b, "click", function(e) {
  1191. CodeMirror.e_preventDefault(e);
  1192. close();
  1193. if (callback) callback(me);
  1194. });
  1195. })(callbacks[i]);
  1196. CodeMirror.on(b, "blur", function() {
  1197. --blurring;
  1198. setTimeout(function() { if (blurring <= 0) close(); }, 200);
  1199. });
  1200. CodeMirror.on(b, "focus", function() { ++blurring; });
  1201. }
  1202. });
  1203. /*
  1204. * openNotification
  1205. * Opens a notification, that can be closed with an optional timer
  1206. * (default 5000ms timer) and always closes on click.
  1207. *
  1208. * If a notification is opened while another is opened, it will close the
  1209. * currently opened one and open the new one immediately.
  1210. */
  1211. CodeMirror.defineExtension("openNotification", function(template, options) {
  1212. closeNotification(this, close);
  1213. var dialog = dialogDiv(this, template, options && options.bottom);
  1214. var closed = false, doneTimer;
  1215. var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000;
  1216. function close() {
  1217. if (closed) return;
  1218. closed = true;
  1219. clearTimeout(doneTimer);
  1220. CodeMirror.rmClass(dialog.parentNode, 'dialog-opened');
  1221. dialog.parentNode.removeChild(dialog);
  1222. }
  1223. CodeMirror.on(dialog, 'click', function(e) {
  1224. CodeMirror.e_preventDefault(e);
  1225. close();
  1226. });
  1227. if (duration)
  1228. doneTimer = setTimeout(close, duration);
  1229. return close;
  1230. });
  1231. });
  1232. },{"../../lib/codemirror":16}],5:[function(require,module,exports){
  1233. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1234. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1235. (function(mod) {
  1236. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1237. mod(require("../../lib/codemirror"));
  1238. else if (typeof define == "function" && define.amd) // AMD
  1239. define(["../../lib/codemirror"], mod);
  1240. else // Plain browser env
  1241. mod(CodeMirror);
  1242. })(function(CodeMirror) {
  1243. var defaults = {
  1244. pairs: "()[]{}''\"\"",
  1245. closeBefore: ")]}'\":;>",
  1246. triples: "",
  1247. explode: "[]{}"
  1248. };
  1249. var Pos = CodeMirror.Pos;
  1250. CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
  1251. if (old && old != CodeMirror.Init) {
  1252. cm.removeKeyMap(keyMap);
  1253. cm.state.closeBrackets = null;
  1254. }
  1255. if (val) {
  1256. ensureBound(getOption(val, "pairs"))
  1257. cm.state.closeBrackets = val;
  1258. cm.addKeyMap(keyMap);
  1259. }
  1260. });
  1261. function getOption(conf, name) {
  1262. if (name == "pairs" && typeof conf == "string") return conf;
  1263. if (typeof conf == "object" && conf[name] != null) return conf[name];
  1264. return defaults[name];
  1265. }
  1266. var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
  1267. function ensureBound(chars) {
  1268. for (var i = 0; i < chars.length; i++) {
  1269. var ch = chars.charAt(i), key = "'" + ch + "'"
  1270. if (!keyMap[key]) keyMap[key] = handler(ch)
  1271. }
  1272. }
  1273. ensureBound(defaults.pairs + "`")
  1274. function handler(ch) {
  1275. return function(cm) { return handleChar(cm, ch); };
  1276. }
  1277. function getConfig(cm) {
  1278. var deflt = cm.state.closeBrackets;
  1279. if (!deflt || deflt.override) return deflt;
  1280. var mode = cm.getModeAt(cm.getCursor());
  1281. return mode.closeBrackets || deflt;
  1282. }
  1283. function handleBackspace(cm) {
  1284. var conf = getConfig(cm);
  1285. if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
  1286. var pairs = getOption(conf, "pairs");
  1287. var ranges = cm.listSelections();
  1288. for (var i = 0; i < ranges.length; i++) {
  1289. if (!ranges[i].empty()) return CodeMirror.Pass;
  1290. var around = charsAround(cm, ranges[i].head);
  1291. if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
  1292. }
  1293. for (var i = ranges.length - 1; i >= 0; i--) {
  1294. var cur = ranges[i].head;
  1295. cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
  1296. }
  1297. }
  1298. function handleEnter(cm) {
  1299. var conf = getConfig(cm);
  1300. var explode = conf && getOption(conf, "explode");
  1301. if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
  1302. var ranges = cm.listSelections();
  1303. for (var i = 0; i < ranges.length; i++) {
  1304. if (!ranges[i].empty()) return CodeMirror.Pass;
  1305. var around = charsAround(cm, ranges[i].head);
  1306. if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
  1307. }
  1308. cm.operation(function() {
  1309. var linesep = cm.lineSeparator() || "\n";
  1310. cm.replaceSelection(linesep + linesep, null);
  1311. cm.execCommand("goCharLeft");
  1312. ranges = cm.listSelections();
  1313. for (var i = 0; i < ranges.length; i++) {
  1314. var line = ranges[i].head.line;
  1315. cm.indentLine(line, null, true);
  1316. cm.indentLine(line + 1, null, true);
  1317. }
  1318. });
  1319. }
  1320. function contractSelection(sel) {
  1321. var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
  1322. return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
  1323. head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
  1324. }
  1325. function handleChar(cm, ch) {
  1326. var conf = getConfig(cm);
  1327. if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
  1328. var pairs = getOption(conf, "pairs");
  1329. var pos = pairs.indexOf(ch);
  1330. if (pos == -1) return CodeMirror.Pass;
  1331. var closeBefore = getOption(conf,"closeBefore");
  1332. var triples = getOption(conf, "triples");
  1333. var identical = pairs.charAt(pos + 1) == ch;
  1334. var ranges = cm.listSelections();
  1335. var opening = pos % 2 == 0;
  1336. var type;
  1337. for (var i = 0; i < ranges.length; i++) {
  1338. var range = ranges[i], cur = range.head, curType;
  1339. var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
  1340. if (opening && !range.empty()) {
  1341. curType = "surround";
  1342. } else if ((identical || !opening) && next == ch) {
  1343. if (identical && stringStartsAfter(cm, cur))
  1344. curType = "both";
  1345. else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
  1346. curType = "skipThree";
  1347. else
  1348. curType = "skip";
  1349. } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
  1350. cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) {
  1351. if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass;
  1352. curType = "addFour";
  1353. } else if (identical) {
  1354. var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
  1355. if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
  1356. else return CodeMirror.Pass;
  1357. } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) {
  1358. curType = "both";
  1359. } else {
  1360. return CodeMirror.Pass;
  1361. }
  1362. if (!type) type = curType;
  1363. else if (type != curType) return CodeMirror.Pass;
  1364. }
  1365. var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
  1366. var right = pos % 2 ? ch : pairs.charAt(pos + 1);
  1367. cm.operation(function() {
  1368. if (type == "skip") {
  1369. cm.execCommand("goCharRight");
  1370. } else if (type == "skipThree") {
  1371. for (var i = 0; i < 3; i++)
  1372. cm.execCommand("goCharRight");
  1373. } else if (type == "surround") {
  1374. var sels = cm.getSelections();
  1375. for (var i = 0; i < sels.length; i++)
  1376. sels[i] = left + sels[i] + right;
  1377. cm.replaceSelections(sels, "around");
  1378. sels = cm.listSelections().slice();
  1379. for (var i = 0; i < sels.length; i++)
  1380. sels[i] = contractSelection(sels[i]);
  1381. cm.setSelections(sels);
  1382. } else if (type == "both") {
  1383. cm.replaceSelection(left + right, null);
  1384. cm.triggerElectric(left + right);
  1385. cm.execCommand("goCharLeft");
  1386. } else if (type == "addFour") {
  1387. cm.replaceSelection(left + left + left + left, "before");
  1388. cm.execCommand("goCharRight");
  1389. }
  1390. });
  1391. }
  1392. function charsAround(cm, pos) {
  1393. var str = cm.getRange(Pos(pos.line, pos.ch - 1),
  1394. Pos(pos.line, pos.ch + 1));
  1395. return str.length == 2 ? str : null;
  1396. }
  1397. function stringStartsAfter(cm, pos) {
  1398. var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
  1399. return /\bstring/.test(token.type) && token.start == pos.ch &&
  1400. (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos)))
  1401. }
  1402. });
  1403. },{"../../lib/codemirror":16}],6:[function(require,module,exports){
  1404. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1405. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1406. (function(mod) {
  1407. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1408. mod(require("../../lib/codemirror"));
  1409. else if (typeof define == "function" && define.amd) // AMD
  1410. define(["../../lib/codemirror"], mod);
  1411. else // Plain browser env
  1412. mod(CodeMirror);
  1413. })(function(CodeMirror) {
  1414. var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
  1415. (document.documentMode == null || document.documentMode < 8);
  1416. var Pos = CodeMirror.Pos;
  1417. var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"};
  1418. function bracketRegex(config) {
  1419. return config && config.bracketRegex || /[(){}[\]]/
  1420. }
  1421. function findMatchingBracket(cm, where, config) {
  1422. var line = cm.getLineHandle(where.line), pos = where.ch - 1;
  1423. var afterCursor = config && config.afterCursor
  1424. if (afterCursor == null)
  1425. afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
  1426. var re = bracketRegex(config)
  1427. // A cursor is defined as between two characters, but in in vim command mode
  1428. // (i.e. not insert mode), the cursor is visually represented as a
  1429. // highlighted box on top of the 2nd character. Otherwise, we allow matches
  1430. // from before or after the cursor.
  1431. var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) ||
  1432. re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)];
  1433. if (!match) return null;
  1434. var dir = match.charAt(1) == ">" ? 1 : -1;
  1435. if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
  1436. var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
  1437. var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
  1438. if (found == null) return null;
  1439. return {from: Pos(where.line, pos), to: found && found.pos,
  1440. match: found && found.ch == match.charAt(0), forward: dir > 0};
  1441. }
  1442. // bracketRegex is used to specify which type of bracket to scan
  1443. // should be a regexp, e.g. /[[\]]/
  1444. //
  1445. // Note: If "where" is on an open bracket, then this bracket is ignored.
  1446. //
  1447. // Returns false when no bracket was found, null when it reached
  1448. // maxScanLines and gave up
  1449. function scanForBracket(cm, where, dir, style, config) {
  1450. var maxScanLen = (config && config.maxScanLineLength) || 10000;
  1451. var maxScanLines = (config && config.maxScanLines) || 1000;
  1452. var stack = [];
  1453. var re = bracketRegex(config)
  1454. var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
  1455. : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
  1456. for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
  1457. var line = cm.getLine(lineNo);
  1458. if (!line) continue;
  1459. var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
  1460. if (line.length > maxScanLen) continue;
  1461. if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
  1462. for (; pos != end; pos += dir) {
  1463. var ch = line.charAt(pos);
  1464. if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
  1465. var match = matching[ch];
  1466. if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
  1467. else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
  1468. else stack.pop();
  1469. }
  1470. }
  1471. }
  1472. return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
  1473. }
  1474. function matchBrackets(cm, autoclear, config) {
  1475. // Disable brace matching in long lines, since it'll cause hugely slow updates
  1476. var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
  1477. var marks = [], ranges = cm.listSelections();
  1478. for (var i = 0; i < ranges.length; i++) {
  1479. var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
  1480. if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
  1481. var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
  1482. marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
  1483. if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
  1484. marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
  1485. }
  1486. }
  1487. if (marks.length) {
  1488. // Kludge to work around the IE bug from issue #1193, where text
  1489. // input stops going to the textare whever this fires.
  1490. if (ie_lt8 && cm.state.focused) cm.focus();
  1491. var clear = function() {
  1492. cm.operation(function() {
  1493. for (var i = 0; i < marks.length; i++) marks[i].clear();
  1494. });
  1495. };
  1496. if (autoclear) setTimeout(clear, 800);
  1497. else return clear;
  1498. }
  1499. }
  1500. function doMatchBrackets(cm) {
  1501. cm.operation(function() {
  1502. if (cm.state.matchBrackets.currentlyHighlighted) {
  1503. cm.state.matchBrackets.currentlyHighlighted();
  1504. cm.state.matchBrackets.currentlyHighlighted = null;
  1505. }
  1506. cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
  1507. });
  1508. }
  1509. CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
  1510. if (old && old != CodeMirror.Init) {
  1511. cm.off("cursorActivity", doMatchBrackets);
  1512. if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
  1513. cm.state.matchBrackets.currentlyHighlighted();
  1514. cm.state.matchBrackets.currentlyHighlighted = null;
  1515. }
  1516. }
  1517. if (val) {
  1518. cm.state.matchBrackets = typeof val == "object" ? val : {};
  1519. cm.on("cursorActivity", doMatchBrackets);
  1520. }
  1521. });
  1522. CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
  1523. CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
  1524. // Backwards-compatibility kludge
  1525. if (oldConfig || typeof config == "boolean") {
  1526. if (!oldConfig) {
  1527. config = config ? {strict: true} : null
  1528. } else {
  1529. oldConfig.strict = config
  1530. config = oldConfig
  1531. }
  1532. }
  1533. return findMatchingBracket(this, pos, config)
  1534. });
  1535. CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
  1536. return scanForBracket(this, pos, dir, style, config);
  1537. });
  1538. });
  1539. },{"../../lib/codemirror":16}],7:[function(require,module,exports){
  1540. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1541. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1542. (function(mod) {
  1543. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1544. mod(require("../../lib/codemirror"));
  1545. else if (typeof define == "function" && define.amd) // AMD
  1546. define(["../../lib/codemirror"], mod);
  1547. else // Plain browser env
  1548. mod(CodeMirror);
  1549. })(function(CodeMirror) {
  1550. "use strict";
  1551. CodeMirror.registerHelper("fold", "brace", function(cm, start) {
  1552. var line = start.line, lineText = cm.getLine(line);
  1553. var tokenType;
  1554. function findOpening(openCh) {
  1555. for (var at = start.ch, pass = 0;;) {
  1556. var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
  1557. if (found == -1) {
  1558. if (pass == 1) break;
  1559. pass = 1;
  1560. at = lineText.length;
  1561. continue;
  1562. }
  1563. if (pass == 1 && found < start.ch) break;
  1564. tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
  1565. if (!/^(comment|string)/.test(tokenType)) return found + 1;
  1566. at = found - 1;
  1567. }
  1568. }
  1569. var startToken = "{", endToken = "}", startCh = findOpening("{");
  1570. if (startCh == null) {
  1571. startToken = "[", endToken = "]";
  1572. startCh = findOpening("[");
  1573. }
  1574. if (startCh == null) return;
  1575. var count = 1, lastLine = cm.lastLine(), end, endCh;
  1576. outer: for (var i = line; i <= lastLine; ++i) {
  1577. var text = cm.getLine(i), pos = i == line ? startCh : 0;
  1578. for (;;) {
  1579. var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
  1580. if (nextOpen < 0) nextOpen = text.length;
  1581. if (nextClose < 0) nextClose = text.length;
  1582. pos = Math.min(nextOpen, nextClose);
  1583. if (pos == text.length) break;
  1584. if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
  1585. if (pos == nextOpen) ++count;
  1586. else if (!--count) { end = i; endCh = pos; break outer; }
  1587. }
  1588. ++pos;
  1589. }
  1590. }
  1591. if (end == null || line == end) return;
  1592. return {from: CodeMirror.Pos(line, startCh),
  1593. to: CodeMirror.Pos(end, endCh)};
  1594. });
  1595. CodeMirror.registerHelper("fold", "import", function(cm, start) {
  1596. function hasImport(line) {
  1597. if (line < cm.firstLine() || line > cm.lastLine()) return null;
  1598. var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
  1599. if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
  1600. if (start.type != "keyword" || start.string != "import") return null;
  1601. // Now find closing semicolon, return its position
  1602. for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
  1603. var text = cm.getLine(i), semi = text.indexOf(";");
  1604. if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
  1605. }
  1606. }
  1607. var startLine = start.line, has = hasImport(startLine), prev;
  1608. if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
  1609. return null;
  1610. for (var end = has.end;;) {
  1611. var next = hasImport(end.line + 1);
  1612. if (next == null) break;
  1613. end = next.end;
  1614. }
  1615. return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
  1616. });
  1617. CodeMirror.registerHelper("fold", "include", function(cm, start) {
  1618. function hasInclude(line) {
  1619. if (line < cm.firstLine() || line > cm.lastLine()) return null;
  1620. var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
  1621. if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
  1622. if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
  1623. }
  1624. var startLine = start.line, has = hasInclude(startLine);
  1625. if (has == null || hasInclude(startLine - 1) != null) return null;
  1626. for (var end = startLine;;) {
  1627. var next = hasInclude(end + 1);
  1628. if (next == null) break;
  1629. ++end;
  1630. }
  1631. return {from: CodeMirror.Pos(startLine, has + 1),
  1632. to: cm.clipPos(CodeMirror.Pos(end))};
  1633. });
  1634. });
  1635. },{"../../lib/codemirror":16}],8:[function(require,module,exports){
  1636. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1637. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1638. (function(mod) {
  1639. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1640. mod(require("../../lib/codemirror"));
  1641. else if (typeof define == "function" && define.amd) // AMD
  1642. define(["../../lib/codemirror"], mod);
  1643. else // Plain browser env
  1644. mod(CodeMirror);
  1645. })(function(CodeMirror) {
  1646. "use strict";
  1647. function doFold(cm, pos, options, force) {
  1648. if (options && options.call) {
  1649. var finder = options;
  1650. options = null;
  1651. } else {
  1652. var finder = getOption(cm, options, "rangeFinder");
  1653. }
  1654. if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
  1655. var minSize = getOption(cm, options, "minFoldSize");
  1656. function getRange(allowFolded) {
  1657. var range = finder(cm, pos);
  1658. if (!range || range.to.line - range.from.line < minSize) return null;
  1659. var marks = cm.findMarksAt(range.from);
  1660. for (var i = 0; i < marks.length; ++i) {
  1661. if (marks[i].__isFold && force !== "fold") {
  1662. if (!allowFolded) return null;
  1663. range.cleared = true;
  1664. marks[i].clear();
  1665. }
  1666. }
  1667. return range;
  1668. }
  1669. var range = getRange(true);
  1670. if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
  1671. pos = CodeMirror.Pos(pos.line - 1, 0);
  1672. range = getRange(false);
  1673. }
  1674. if (!range || range.cleared || force === "unfold") return;
  1675. var myWidget = makeWidget(cm, options);
  1676. CodeMirror.on(myWidget, "mousedown", function(e) {
  1677. myRange.clear();
  1678. CodeMirror.e_preventDefault(e);
  1679. });
  1680. var myRange = cm.markText(range.from, range.to, {
  1681. replacedWith: myWidget,
  1682. clearOnEnter: getOption(cm, options, "clearOnEnter"),
  1683. __isFold: true
  1684. });
  1685. myRange.on("clear", function(from, to) {
  1686. CodeMirror.signal(cm, "unfold", cm, from, to);
  1687. });
  1688. CodeMirror.signal(cm, "fold", cm, range.from, range.to);
  1689. }
  1690. function makeWidget(cm, options) {
  1691. var widget = getOption(cm, options, "widget");
  1692. if (typeof widget == "string") {
  1693. var text = document.createTextNode(widget);
  1694. widget = document.createElement("span");
  1695. widget.appendChild(text);
  1696. widget.className = "CodeMirror-foldmarker";
  1697. } else if (widget) {
  1698. widget = widget.cloneNode(true)
  1699. }
  1700. return widget;
  1701. }
  1702. // Clumsy backwards-compatible interface
  1703. CodeMirror.newFoldFunction = function(rangeFinder, widget) {
  1704. return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
  1705. };
  1706. // New-style interface
  1707. CodeMirror.defineExtension("foldCode", function(pos, options, force) {
  1708. doFold(this, pos, options, force);
  1709. });
  1710. CodeMirror.defineExtension("isFolded", function(pos) {
  1711. var marks = this.findMarksAt(pos);
  1712. for (var i = 0; i < marks.length; ++i)
  1713. if (marks[i].__isFold) return true;
  1714. });
  1715. CodeMirror.commands.toggleFold = function(cm) {
  1716. cm.foldCode(cm.getCursor());
  1717. };
  1718. CodeMirror.commands.fold = function(cm) {
  1719. cm.foldCode(cm.getCursor(), null, "fold");
  1720. };
  1721. CodeMirror.commands.unfold = function(cm) {
  1722. cm.foldCode(cm.getCursor(), null, "unfold");
  1723. };
  1724. CodeMirror.commands.foldAll = function(cm) {
  1725. cm.operation(function() {
  1726. for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
  1727. cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
  1728. });
  1729. };
  1730. CodeMirror.commands.unfoldAll = function(cm) {
  1731. cm.operation(function() {
  1732. for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
  1733. cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
  1734. });
  1735. };
  1736. CodeMirror.registerHelper("fold", "combine", function() {
  1737. var funcs = Array.prototype.slice.call(arguments, 0);
  1738. return function(cm, start) {
  1739. for (var i = 0; i < funcs.length; ++i) {
  1740. var found = funcs[i](cm, start);
  1741. if (found) return found;
  1742. }
  1743. };
  1744. });
  1745. CodeMirror.registerHelper("fold", "auto", function(cm, start) {
  1746. var helpers = cm.getHelpers(start, "fold");
  1747. for (var i = 0; i < helpers.length; i++) {
  1748. var cur = helpers[i](cm, start);
  1749. if (cur) return cur;
  1750. }
  1751. });
  1752. var defaultOptions = {
  1753. rangeFinder: CodeMirror.fold.auto,
  1754. widget: "\u2194",
  1755. minFoldSize: 0,
  1756. scanUp: false,
  1757. clearOnEnter: true
  1758. };
  1759. CodeMirror.defineOption("foldOptions", null);
  1760. function getOption(cm, options, name) {
  1761. if (options && options[name] !== undefined)
  1762. return options[name];
  1763. var editorOptions = cm.options.foldOptions;
  1764. if (editorOptions && editorOptions[name] !== undefined)
  1765. return editorOptions[name];
  1766. return defaultOptions[name];
  1767. }
  1768. CodeMirror.defineExtension("foldOption", function(options, name) {
  1769. return getOption(this, options, name);
  1770. });
  1771. });
  1772. },{"../../lib/codemirror":16}],9:[function(require,module,exports){
  1773. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1774. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1775. (function(mod) {
  1776. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1777. mod(require("../../lib/codemirror"), require("./foldcode"));
  1778. else if (typeof define == "function" && define.amd) // AMD
  1779. define(["../../lib/codemirror", "./foldcode"], mod);
  1780. else // Plain browser env
  1781. mod(CodeMirror);
  1782. })(function(CodeMirror) {
  1783. "use strict";
  1784. CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
  1785. if (old && old != CodeMirror.Init) {
  1786. cm.clearGutter(cm.state.foldGutter.options.gutter);
  1787. cm.state.foldGutter = null;
  1788. cm.off("gutterClick", onGutterClick);
  1789. cm.off("change", onChange);
  1790. cm.off("viewportChange", onViewportChange);
  1791. cm.off("fold", onFold);
  1792. cm.off("unfold", onFold);
  1793. cm.off("swapDoc", onChange);
  1794. }
  1795. if (val) {
  1796. cm.state.foldGutter = new State(parseOptions(val));
  1797. updateInViewport(cm);
  1798. cm.on("gutterClick", onGutterClick);
  1799. cm.on("change", onChange);
  1800. cm.on("viewportChange", onViewportChange);
  1801. cm.on("fold", onFold);
  1802. cm.on("unfold", onFold);
  1803. cm.on("swapDoc", onChange);
  1804. }
  1805. });
  1806. var Pos = CodeMirror.Pos;
  1807. function State(options) {
  1808. this.options = options;
  1809. this.from = this.to = 0;
  1810. }
  1811. function parseOptions(opts) {
  1812. if (opts === true) opts = {};
  1813. if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
  1814. if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
  1815. if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
  1816. return opts;
  1817. }
  1818. function isFolded(cm, line) {
  1819. var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
  1820. for (var i = 0; i < marks.length; ++i)
  1821. if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
  1822. }
  1823. function marker(spec) {
  1824. if (typeof spec == "string") {
  1825. var elt = document.createElement("div");
  1826. elt.className = spec + " CodeMirror-guttermarker-subtle";
  1827. return elt;
  1828. } else {
  1829. return spec.cloneNode(true);
  1830. }
  1831. }
  1832. function updateFoldInfo(cm, from, to) {
  1833. var opts = cm.state.foldGutter.options, cur = from;
  1834. var minSize = cm.foldOption(opts, "minFoldSize");
  1835. var func = cm.foldOption(opts, "rangeFinder");
  1836. cm.eachLine(from, to, function(line) {
  1837. var mark = null;
  1838. if (isFolded(cm, cur)) {
  1839. mark = marker(opts.indicatorFolded);
  1840. } else {
  1841. var pos = Pos(cur, 0);
  1842. var range = func && func(cm, pos);
  1843. if (range && range.to.line - range.from.line >= minSize)
  1844. mark = marker(opts.indicatorOpen);
  1845. }
  1846. cm.setGutterMarker(line, opts.gutter, mark);
  1847. ++cur;
  1848. });
  1849. }
  1850. function updateInViewport(cm) {
  1851. var vp = cm.getViewport(), state = cm.state.foldGutter;
  1852. if (!state) return;
  1853. cm.operation(function() {
  1854. updateFoldInfo(cm, vp.from, vp.to);
  1855. });
  1856. state.from = vp.from; state.to = vp.to;
  1857. }
  1858. function onGutterClick(cm, line, gutter) {
  1859. var state = cm.state.foldGutter;
  1860. if (!state) return;
  1861. var opts = state.options;
  1862. if (gutter != opts.gutter) return;
  1863. var folded = isFolded(cm, line);
  1864. if (folded) folded.clear();
  1865. else cm.foldCode(Pos(line, 0), opts.rangeFinder);
  1866. }
  1867. function onChange(cm) {
  1868. var state = cm.state.foldGutter;
  1869. if (!state) return;
  1870. var opts = state.options;
  1871. state.from = state.to = 0;
  1872. clearTimeout(state.changeUpdate);
  1873. state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
  1874. }
  1875. function onViewportChange(cm) {
  1876. var state = cm.state.foldGutter;
  1877. if (!state) return;
  1878. var opts = state.options;
  1879. clearTimeout(state.changeUpdate);
  1880. state.changeUpdate = setTimeout(function() {
  1881. var vp = cm.getViewport();
  1882. if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
  1883. updateInViewport(cm);
  1884. } else {
  1885. cm.operation(function() {
  1886. if (vp.from < state.from) {
  1887. updateFoldInfo(cm, vp.from, state.from);
  1888. state.from = vp.from;
  1889. }
  1890. if (vp.to > state.to) {
  1891. updateFoldInfo(cm, state.to, vp.to);
  1892. state.to = vp.to;
  1893. }
  1894. });
  1895. }
  1896. }, opts.updateViewportTimeSpan || 400);
  1897. }
  1898. function onFold(cm, from) {
  1899. var state = cm.state.foldGutter;
  1900. if (!state) return;
  1901. var line = from.line;
  1902. if (line >= state.from && line < state.to)
  1903. updateFoldInfo(cm, line, line + 1);
  1904. }
  1905. });
  1906. },{"../../lib/codemirror":16,"./foldcode":8}],10:[function(require,module,exports){
  1907. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  1908. // Distributed under an MIT license: https://codemirror.net/LICENSE
  1909. (function(mod) {
  1910. if (typeof exports == "object" && typeof module == "object") // CommonJS
  1911. mod(require("../../lib/codemirror"));
  1912. else if (typeof define == "function" && define.amd) // AMD
  1913. define(["../../lib/codemirror"], mod);
  1914. else // Plain browser env
  1915. mod(CodeMirror);
  1916. })(function(CodeMirror) {
  1917. "use strict";
  1918. var HINT_ELEMENT_CLASS = "CodeMirror-hint";
  1919. var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
  1920. // This is the old interface, kept around for now to stay
  1921. // backwards-compatible.
  1922. CodeMirror.showHint = function(cm, getHints, options) {
  1923. if (!getHints) return cm.showHint(options);
  1924. if (options && options.async) getHints.async = true;
  1925. var newOpts = {hint: getHints};
  1926. if (options) for (var prop in options) newOpts[prop] = options[prop];
  1927. return cm.showHint(newOpts);
  1928. };
  1929. CodeMirror.defineExtension("showHint", function(options) {
  1930. options = parseOptions(this, this.getCursor("start"), options);
  1931. var selections = this.listSelections()
  1932. if (selections.length > 1) return;
  1933. // By default, don't allow completion when something is selected.
  1934. // A hint function can have a `supportsSelection` property to
  1935. // indicate that it can handle selections.
  1936. if (this.somethingSelected()) {
  1937. if (!options.hint.supportsSelection) return;
  1938. // Don't try with cross-line selections
  1939. for (var i = 0; i < selections.length; i++)
  1940. if (selections[i].head.line != selections[i].anchor.line) return;
  1941. }
  1942. if (this.state.completionActive) this.state.completionActive.close();
  1943. var completion = this.state.completionActive = new Completion(this, options);
  1944. if (!completion.options.hint) return;
  1945. CodeMirror.signal(this, "startCompletion", this);
  1946. completion.update(true);
  1947. });
  1948. CodeMirror.defineExtension("closeHint", function() {
  1949. if (this.state.completionActive) this.state.completionActive.close()
  1950. })
  1951. function Completion(cm, options) {
  1952. this.cm = cm;
  1953. this.options = options;
  1954. this.widget = null;
  1955. this.debounce = 0;
  1956. this.tick = 0;
  1957. this.startPos = this.cm.getCursor("start");
  1958. this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
  1959. var self = this;
  1960. cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
  1961. }
  1962. var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
  1963. return setTimeout(fn, 1000/60);
  1964. };
  1965. var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
  1966. Completion.prototype = {
  1967. close: function() {
  1968. if (!this.active()) return;
  1969. this.cm.state.completionActive = null;
  1970. this.tick = null;
  1971. this.cm.off("cursorActivity", this.activityFunc);
  1972. if (this.widget && this.data) CodeMirror.signal(this.data, "close");
  1973. if (this.widget) this.widget.close();
  1974. CodeMirror.signal(this.cm, "endCompletion", this.cm);
  1975. },
  1976. active: function() {
  1977. return this.cm.state.completionActive == this;
  1978. },
  1979. pick: function(data, i) {
  1980. var completion = data.list[i];
  1981. if (completion.hint) completion.hint(this.cm, data, completion);
  1982. else this.cm.replaceRange(getText(completion), completion.from || data.from,
  1983. completion.to || data.to, "complete");
  1984. CodeMirror.signal(data, "pick", completion);
  1985. this.close();
  1986. },
  1987. cursorActivity: function() {
  1988. if (this.debounce) {
  1989. cancelAnimationFrame(this.debounce);
  1990. this.debounce = 0;
  1991. }
  1992. var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
  1993. if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
  1994. pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
  1995. (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
  1996. this.close();
  1997. } else {
  1998. var self = this;
  1999. this.debounce = requestAnimationFrame(function() {self.update();});
  2000. if (this.widget) this.widget.disable();
  2001. }
  2002. },
  2003. update: function(first) {
  2004. if (this.tick == null) return
  2005. var self = this, myTick = ++this.tick
  2006. fetchHints(this.options.hint, this.cm, this.options, function(data) {
  2007. if (self.tick == myTick) self.finishUpdate(data, first)
  2008. })
  2009. },
  2010. finishUpdate: function(data, first) {
  2011. if (this.data) CodeMirror.signal(this.data, "update");
  2012. var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
  2013. if (this.widget) this.widget.close();
  2014. this.data = data;
  2015. if (data && data.list.length) {
  2016. if (picked && data.list.length == 1) {
  2017. this.pick(data, 0);
  2018. } else {
  2019. this.widget = new Widget(this, data);
  2020. CodeMirror.signal(data, "shown");
  2021. }
  2022. }
  2023. }
  2024. };
  2025. function parseOptions(cm, pos, options) {
  2026. var editor = cm.options.hintOptions;
  2027. var out = {};
  2028. for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
  2029. if (editor) for (var prop in editor)
  2030. if (editor[prop] !== undefined) out[prop] = editor[prop];
  2031. if (options) for (var prop in options)
  2032. if (options[prop] !== undefined) out[prop] = options[prop];
  2033. if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
  2034. return out;
  2035. }
  2036. function getText(completion) {
  2037. if (typeof completion == "string") return completion;
  2038. else return completion.text;
  2039. }
  2040. function buildKeyMap(completion, handle) {
  2041. var baseMap = {
  2042. Up: function() {handle.moveFocus(-1);},
  2043. Down: function() {handle.moveFocus(1);},
  2044. PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
  2045. PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
  2046. Home: function() {handle.setFocus(0);},
  2047. End: function() {handle.setFocus(handle.length - 1);},
  2048. Enter: handle.pick,
  2049. Tab: handle.pick,
  2050. Esc: handle.close
  2051. };
  2052. var mac = /Mac/.test(navigator.platform);
  2053. if (mac) {
  2054. baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);};
  2055. baseMap["Ctrl-N"] = function() {handle.moveFocus(1);};
  2056. }
  2057. var custom = completion.options.customKeys;
  2058. var ourMap = custom ? {} : baseMap;
  2059. function addBinding(key, val) {
  2060. var bound;
  2061. if (typeof val != "string")
  2062. bound = function(cm) { return val(cm, handle); };
  2063. // This mechanism is deprecated
  2064. else if (baseMap.hasOwnProperty(val))
  2065. bound = baseMap[val];
  2066. else
  2067. bound = val;
  2068. ourMap[key] = bound;
  2069. }
  2070. if (custom)
  2071. for (var key in custom) if (custom.hasOwnProperty(key))
  2072. addBinding(key, custom[key]);
  2073. var extra = completion.options.extraKeys;
  2074. if (extra)
  2075. for (var key in extra) if (extra.hasOwnProperty(key))
  2076. addBinding(key, extra[key]);
  2077. return ourMap;
  2078. }
  2079. function getHintElement(hintsElement, el) {
  2080. while (el && el != hintsElement) {
  2081. if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
  2082. el = el.parentNode;
  2083. }
  2084. }
  2085. function Widget(completion, data) {
  2086. this.completion = completion;
  2087. this.data = data;
  2088. this.picked = false;
  2089. var widget = this, cm = completion.cm;
  2090. var ownerDocument = cm.getInputField().ownerDocument;
  2091. var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow;
  2092. var hints = this.hints = ownerDocument.createElement("ul");
  2093. var theme = completion.cm.options.theme;
  2094. hints.className = "CodeMirror-hints " + theme;
  2095. this.selectedHint = data.selectedHint || 0;
  2096. var completions = data.list;
  2097. for (var i = 0; i < completions.length; ++i) {
  2098. var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i];
  2099. var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
  2100. if (cur.className != null) className = cur.className + " " + className;
  2101. elt.className = className;
  2102. if (cur.render) cur.render(elt, data, cur);
  2103. else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur)));
  2104. elt.hintId = i;
  2105. }
  2106. var container = completion.options.container || ownerDocument.body;
  2107. var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
  2108. var left = pos.left, top = pos.bottom, below = true;
  2109. var offsetLeft = 0, offsetTop = 0;
  2110. if (container !== ownerDocument.body) {
  2111. // We offset the cursor position because left and top are relative to the offsetParent's top left corner.
  2112. var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1;
  2113. var offsetParent = isContainerPositioned ? container : container.offsetParent;
  2114. var offsetParentPosition = offsetParent.getBoundingClientRect();
  2115. var bodyPosition = ownerDocument.body.getBoundingClientRect();
  2116. offsetLeft = (offsetParentPosition.left - bodyPosition.left);
  2117. offsetTop = (offsetParentPosition.top - bodyPosition.top);
  2118. }
  2119. hints.style.left = (left - offsetLeft) + "px";
  2120. hints.style.top = (top - offsetTop) + "px";
  2121. // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
  2122. var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
  2123. var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
  2124. container.appendChild(hints);
  2125. var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
  2126. var scrolls = hints.scrollHeight > hints.clientHeight + 1
  2127. var startScroll = cm.getScrollInfo();
  2128. if (overlapY > 0) {
  2129. var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
  2130. if (curTop - height > 0) { // Fits above cursor
  2131. hints.style.top = (top = pos.top - height - offsetTop) + "px";
  2132. below = false;
  2133. } else if (height > winH) {
  2134. hints.style.height = (winH - 5) + "px";
  2135. hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px";
  2136. var cursor = cm.getCursor();
  2137. if (data.from.ch != cursor.ch) {
  2138. pos = cm.cursorCoords(cursor);
  2139. hints.style.left = (left = pos.left - offsetLeft) + "px";
  2140. box = hints.getBoundingClientRect();
  2141. }
  2142. }
  2143. }
  2144. var overlapX = box.right - winW;
  2145. if (overlapX > 0) {
  2146. if (box.right - box.left > winW) {
  2147. hints.style.width = (winW - 5) + "px";
  2148. overlapX -= (box.right - box.left) - winW;
  2149. }
  2150. hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px";
  2151. }
  2152. if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
  2153. node.style.paddingRight = cm.display.nativeBarWidth + "px"
  2154. cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
  2155. moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
  2156. setFocus: function(n) { widget.changeActive(n); },
  2157. menuSize: function() { return widget.screenAmount(); },
  2158. length: completions.length,
  2159. close: function() { completion.close(); },
  2160. pick: function() { widget.pick(); },
  2161. data: data
  2162. }));
  2163. if (completion.options.closeOnUnfocus) {
  2164. var closingOnBlur;
  2165. cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
  2166. cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
  2167. }
  2168. cm.on("scroll", this.onScroll = function() {
  2169. var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
  2170. var newTop = top + startScroll.top - curScroll.top;
  2171. var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
  2172. if (!below) point += hints.offsetHeight;
  2173. if (point <= editor.top || point >= editor.bottom) return completion.close();
  2174. hints.style.top = newTop + "px";
  2175. hints.style.left = (left + startScroll.left - curScroll.left) + "px";
  2176. });
  2177. CodeMirror.on(hints, "dblclick", function(e) {
  2178. var t = getHintElement(hints, e.target || e.srcElement);
  2179. if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
  2180. });
  2181. CodeMirror.on(hints, "click", function(e) {
  2182. var t = getHintElement(hints, e.target || e.srcElement);
  2183. if (t && t.hintId != null) {
  2184. widget.changeActive(t.hintId);
  2185. if (completion.options.completeOnSingleClick) widget.pick();
  2186. }
  2187. });
  2188. CodeMirror.on(hints, "mousedown", function() {
  2189. setTimeout(function(){cm.focus();}, 20);
  2190. });
  2191. CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
  2192. return true;
  2193. }
  2194. Widget.prototype = {
  2195. close: function() {
  2196. if (this.completion.widget != this) return;
  2197. this.completion.widget = null;
  2198. this.hints.parentNode.removeChild(this.hints);
  2199. this.completion.cm.removeKeyMap(this.keyMap);
  2200. var cm = this.completion.cm;
  2201. if (this.completion.options.closeOnUnfocus) {
  2202. cm.off("blur", this.onBlur);
  2203. cm.off("focus", this.onFocus);
  2204. }
  2205. cm.off("scroll", this.onScroll);
  2206. },
  2207. disable: function() {
  2208. this.completion.cm.removeKeyMap(this.keyMap);
  2209. var widget = this;
  2210. this.keyMap = {Enter: function() { widget.picked = true; }};
  2211. this.completion.cm.addKeyMap(this.keyMap);
  2212. },
  2213. pick: function() {
  2214. this.completion.pick(this.data, this.selectedHint);
  2215. },
  2216. changeActive: function(i, avoidWrap) {
  2217. if (i >= this.data.list.length)
  2218. i = avoidWrap ? this.data.list.length - 1 : 0;
  2219. else if (i < 0)
  2220. i = avoidWrap ? 0 : this.data.list.length - 1;
  2221. if (this.selectedHint == i) return;
  2222. var node = this.hints.childNodes[this.selectedHint];
  2223. if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
  2224. node = this.hints.childNodes[this.selectedHint = i];
  2225. node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
  2226. if (node.offsetTop < this.hints.scrollTop)
  2227. this.hints.scrollTop = node.offsetTop - 3;
  2228. else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
  2229. this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
  2230. CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
  2231. },
  2232. screenAmount: function() {
  2233. return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
  2234. }
  2235. };
  2236. function applicableHelpers(cm, helpers) {
  2237. if (!cm.somethingSelected()) return helpers
  2238. var result = []
  2239. for (var i = 0; i < helpers.length; i++)
  2240. if (helpers[i].supportsSelection) result.push(helpers[i])
  2241. return result
  2242. }
  2243. function fetchHints(hint, cm, options, callback) {
  2244. if (hint.async) {
  2245. hint(cm, callback, options)
  2246. } else {
  2247. var result = hint(cm, options)
  2248. if (result && result.then) result.then(callback)
  2249. else callback(result)
  2250. }
  2251. }
  2252. function resolveAutoHints(cm, pos) {
  2253. var helpers = cm.getHelpers(pos, "hint"), words
  2254. if (helpers.length) {
  2255. var resolved = function(cm, callback, options) {
  2256. var app = applicableHelpers(cm, helpers);
  2257. function run(i) {
  2258. if (i == app.length) return callback(null)
  2259. fetchHints(app[i], cm, options, function(result) {
  2260. if (result && result.list.length > 0) callback(result)
  2261. else run(i + 1)
  2262. })
  2263. }
  2264. run(0)
  2265. }
  2266. resolved.async = true
  2267. resolved.supportsSelection = true
  2268. return resolved
  2269. } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
  2270. return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
  2271. } else if (CodeMirror.hint.anyword) {
  2272. return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
  2273. } else {
  2274. return function() {}
  2275. }
  2276. }
  2277. CodeMirror.registerHelper("hint", "auto", {
  2278. resolve: resolveAutoHints
  2279. });
  2280. CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
  2281. var cur = cm.getCursor(), token = cm.getTokenAt(cur)
  2282. var term, from = CodeMirror.Pos(cur.line, token.start), to = cur
  2283. if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) {
  2284. term = token.string.substr(0, cur.ch - token.start)
  2285. } else {
  2286. term = ""
  2287. from = cur
  2288. }
  2289. var found = [];
  2290. for (var i = 0; i < options.words.length; i++) {
  2291. var word = options.words[i];
  2292. if (word.slice(0, term.length) == term)
  2293. found.push(word);
  2294. }
  2295. if (found.length) return {list: found, from: from, to: to};
  2296. });
  2297. CodeMirror.commands.autocomplete = CodeMirror.showHint;
  2298. var defaultOptions = {
  2299. hint: CodeMirror.hint.auto,
  2300. completeSingle: true,
  2301. alignWithWord: true,
  2302. closeCharacters: /[\s()\[\]{};:>,]/,
  2303. closeOnUnfocus: true,
  2304. completeOnSingleClick: true,
  2305. container: null,
  2306. customKeys: null,
  2307. extraKeys: null
  2308. };
  2309. CodeMirror.defineOption("hintOptions", null);
  2310. });
  2311. },{"../../lib/codemirror":16}],11:[function(require,module,exports){
  2312. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2313. // Distributed under an MIT license: https://codemirror.net/LICENSE
  2314. (function(mod) {
  2315. if (typeof exports == "object" && typeof module == "object") // CommonJS
  2316. mod(require("../../lib/codemirror"));
  2317. else if (typeof define == "function" && define.amd) // AMD
  2318. define(["../../lib/codemirror"], mod);
  2319. else // Plain browser env
  2320. mod(CodeMirror);
  2321. })(function(CodeMirror) {
  2322. "use strict";
  2323. var GUTTER_ID = "CodeMirror-lint-markers";
  2324. function showTooltip(e, content) {
  2325. var tt = document.createElement("div");
  2326. tt.className = "CodeMirror-lint-tooltip";
  2327. tt.appendChild(content.cloneNode(true));
  2328. document.body.appendChild(tt);
  2329. function position(e) {
  2330. if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
  2331. tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
  2332. tt.style.left = (e.clientX + 5) + "px";
  2333. }
  2334. CodeMirror.on(document, "mousemove", position);
  2335. position(e);
  2336. if (tt.style.opacity != null) tt.style.opacity = 1;
  2337. return tt;
  2338. }
  2339. function rm(elt) {
  2340. if (elt.parentNode) elt.parentNode.removeChild(elt);
  2341. }
  2342. function hideTooltip(tt) {
  2343. if (!tt.parentNode) return;
  2344. if (tt.style.opacity == null) rm(tt);
  2345. tt.style.opacity = 0;
  2346. setTimeout(function() { rm(tt); }, 600);
  2347. }
  2348. function showTooltipFor(e, content, node) {
  2349. var tooltip = showTooltip(e, content);
  2350. function hide() {
  2351. CodeMirror.off(node, "mouseout", hide);
  2352. if (tooltip) { hideTooltip(tooltip); tooltip = null; }
  2353. }
  2354. var poll = setInterval(function() {
  2355. if (tooltip) for (var n = node;; n = n.parentNode) {
  2356. if (n && n.nodeType == 11) n = n.host;
  2357. if (n == document.body) return;
  2358. if (!n) { hide(); break; }
  2359. }
  2360. if (!tooltip) return clearInterval(poll);
  2361. }, 400);
  2362. CodeMirror.on(node, "mouseout", hide);
  2363. }
  2364. function LintState(cm, options, hasGutter) {
  2365. this.marked = [];
  2366. this.options = options;
  2367. this.timeout = null;
  2368. this.hasGutter = hasGutter;
  2369. this.onMouseOver = function(e) { onMouseOver(cm, e); };
  2370. this.waitingFor = 0
  2371. }
  2372. function parseOptions(_cm, options) {
  2373. if (options instanceof Function) return {getAnnotations: options};
  2374. if (!options || options === true) options = {};
  2375. return options;
  2376. }
  2377. function clearMarks(cm) {
  2378. var state = cm.state.lint;
  2379. if (state.hasGutter) cm.clearGutter(GUTTER_ID);
  2380. for (var i = 0; i < state.marked.length; ++i)
  2381. state.marked[i].clear();
  2382. state.marked.length = 0;
  2383. }
  2384. function makeMarker(labels, severity, multiple, tooltips) {
  2385. var marker = document.createElement("div"), inner = marker;
  2386. marker.className = "CodeMirror-lint-marker-" + severity;
  2387. if (multiple) {
  2388. inner = marker.appendChild(document.createElement("div"));
  2389. inner.className = "CodeMirror-lint-marker-multiple";
  2390. }
  2391. if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
  2392. showTooltipFor(e, labels, inner);
  2393. });
  2394. return marker;
  2395. }
  2396. function getMaxSeverity(a, b) {
  2397. if (a == "error") return a;
  2398. else return b;
  2399. }
  2400. function groupByLine(annotations) {
  2401. var lines = [];
  2402. for (var i = 0; i < annotations.length; ++i) {
  2403. var ann = annotations[i], line = ann.from.line;
  2404. (lines[line] || (lines[line] = [])).push(ann);
  2405. }
  2406. return lines;
  2407. }
  2408. function annotationTooltip(ann) {
  2409. var severity = ann.severity;
  2410. if (!severity) severity = "error";
  2411. var tip = document.createElement("div");
  2412. tip.className = "CodeMirror-lint-message-" + severity;
  2413. if (typeof ann.messageHTML != 'undefined') {
  2414. tip.innerHTML = ann.messageHTML;
  2415. } else {
  2416. tip.appendChild(document.createTextNode(ann.message));
  2417. }
  2418. return tip;
  2419. }
  2420. function lintAsync(cm, getAnnotations, passOptions) {
  2421. var state = cm.state.lint
  2422. var id = ++state.waitingFor
  2423. function abort() {
  2424. id = -1
  2425. cm.off("change", abort)
  2426. }
  2427. cm.on("change", abort)
  2428. getAnnotations(cm.getValue(), function(annotations, arg2) {
  2429. cm.off("change", abort)
  2430. if (state.waitingFor != id) return
  2431. if (arg2 && annotations instanceof CodeMirror) annotations = arg2
  2432. cm.operation(function() {updateLinting(cm, annotations)})
  2433. }, passOptions, cm);
  2434. }
  2435. function startLinting(cm) {
  2436. var state = cm.state.lint, options = state.options;
  2437. /*
  2438. * Passing rules in `options` property prevents JSHint (and other linters) from complaining
  2439. * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
  2440. */
  2441. var passOptions = options.options || options;
  2442. var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
  2443. if (!getAnnotations) return;
  2444. if (options.async || getAnnotations.async) {
  2445. lintAsync(cm, getAnnotations, passOptions)
  2446. } else {
  2447. var annotations = getAnnotations(cm.getValue(), passOptions, cm);
  2448. if (!annotations) return;
  2449. if (annotations.then) annotations.then(function(issues) {
  2450. cm.operation(function() {updateLinting(cm, issues)})
  2451. });
  2452. else cm.operation(function() {updateLinting(cm, annotations)})
  2453. }
  2454. }
  2455. function updateLinting(cm, annotationsNotSorted) {
  2456. clearMarks(cm);
  2457. var state = cm.state.lint, options = state.options;
  2458. var annotations = groupByLine(annotationsNotSorted);
  2459. for (var line = 0; line < annotations.length; ++line) {
  2460. var anns = annotations[line];
  2461. if (!anns) continue;
  2462. var maxSeverity = null;
  2463. var tipLabel = state.hasGutter && document.createDocumentFragment();
  2464. for (var i = 0; i < anns.length; ++i) {
  2465. var ann = anns[i];
  2466. var severity = ann.severity;
  2467. if (!severity) severity = "error";
  2468. maxSeverity = getMaxSeverity(maxSeverity, severity);
  2469. if (options.formatAnnotation) ann = options.formatAnnotation(ann);
  2470. if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
  2471. if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
  2472. className: "CodeMirror-lint-mark-" + severity,
  2473. __annotation: ann
  2474. }));
  2475. }
  2476. if (state.hasGutter)
  2477. cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
  2478. state.options.tooltips));
  2479. }
  2480. if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
  2481. }
  2482. function onChange(cm) {
  2483. var state = cm.state.lint;
  2484. if (!state) return;
  2485. clearTimeout(state.timeout);
  2486. state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
  2487. }
  2488. function popupTooltips(annotations, e) {
  2489. var target = e.target || e.srcElement;
  2490. var tooltip = document.createDocumentFragment();
  2491. for (var i = 0; i < annotations.length; i++) {
  2492. var ann = annotations[i];
  2493. tooltip.appendChild(annotationTooltip(ann));
  2494. }
  2495. showTooltipFor(e, tooltip, target);
  2496. }
  2497. function onMouseOver(cm, e) {
  2498. var target = e.target || e.srcElement;
  2499. if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
  2500. var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
  2501. var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
  2502. var annotations = [];
  2503. for (var i = 0; i < spans.length; ++i) {
  2504. var ann = spans[i].__annotation;
  2505. if (ann) annotations.push(ann);
  2506. }
  2507. if (annotations.length) popupTooltips(annotations, e);
  2508. }
  2509. CodeMirror.defineOption("lint", false, function(cm, val, old) {
  2510. if (old && old != CodeMirror.Init) {
  2511. clearMarks(cm);
  2512. if (cm.state.lint.options.lintOnChange !== false)
  2513. cm.off("change", onChange);
  2514. CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
  2515. clearTimeout(cm.state.lint.timeout);
  2516. delete cm.state.lint;
  2517. }
  2518. if (val) {
  2519. var gutters = cm.getOption("gutters"), hasLintGutter = false;
  2520. for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
  2521. var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
  2522. if (state.options.lintOnChange !== false)
  2523. cm.on("change", onChange);
  2524. if (state.options.tooltips != false && state.options.tooltips != "gutter")
  2525. CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
  2526. startLinting(cm);
  2527. }
  2528. });
  2529. CodeMirror.defineExtension("performLint", function() {
  2530. if (this.state.lint) startLinting(this);
  2531. });
  2532. });
  2533. },{"../../lib/codemirror":16}],12:[function(require,module,exports){
  2534. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2535. // Distributed under an MIT license: https://codemirror.net/LICENSE
  2536. // Defines jumpToLine command. Uses dialog.js if present.
  2537. (function(mod) {
  2538. if (typeof exports == "object" && typeof module == "object") // CommonJS
  2539. mod(require("../../lib/codemirror"), require("../dialog/dialog"));
  2540. else if (typeof define == "function" && define.amd) // AMD
  2541. define(["../../lib/codemirror", "../dialog/dialog"], mod);
  2542. else // Plain browser env
  2543. mod(CodeMirror);
  2544. })(function(CodeMirror) {
  2545. "use strict";
  2546. function dialog(cm, text, shortText, deflt, f) {
  2547. if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
  2548. else f(prompt(shortText, deflt));
  2549. }
  2550. function getJumpDialog(cm) {
  2551. return cm.phrase("Jump to line:") + ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use line:column or scroll% syntax)") + '</span>';
  2552. }
  2553. function interpretLine(cm, string) {
  2554. var num = Number(string)
  2555. if (/^[-+]/.test(string)) return cm.getCursor().line + num
  2556. else return num - 1
  2557. }
  2558. CodeMirror.commands.jumpToLine = function(cm) {
  2559. var cur = cm.getCursor();
  2560. dialog(cm, getJumpDialog(cm), cm.phrase("Jump to line:"), (cur.line + 1) + ":" + cur.ch, function(posStr) {
  2561. if (!posStr) return;
  2562. var match;
  2563. if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
  2564. cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
  2565. } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
  2566. var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
  2567. if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
  2568. cm.setCursor(line - 1, cur.ch);
  2569. } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
  2570. cm.setCursor(interpretLine(cm, match[1]), cur.ch);
  2571. }
  2572. });
  2573. };
  2574. CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
  2575. });
  2576. },{"../../lib/codemirror":16,"../dialog/dialog":4}],13:[function(require,module,exports){
  2577. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2578. // Distributed under an MIT license: https://codemirror.net/LICENSE
  2579. // Define search commands. Depends on dialog.js or another
  2580. // implementation of the openDialog method.
  2581. // Replace works a little oddly -- it will do the replace on the next
  2582. // Ctrl-G (or whatever is bound to findNext) press. You prevent a
  2583. // replace by making sure the match is no longer selected when hitting
  2584. // Ctrl-G.
  2585. (function(mod) {
  2586. if (typeof exports == "object" && typeof module == "object") // CommonJS
  2587. mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
  2588. else if (typeof define == "function" && define.amd) // AMD
  2589. define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
  2590. else // Plain browser env
  2591. mod(CodeMirror);
  2592. })(function(CodeMirror) {
  2593. "use strict";
  2594. function searchOverlay(query, caseInsensitive) {
  2595. if (typeof query == "string")
  2596. query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
  2597. else if (!query.global)
  2598. query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
  2599. return {token: function(stream) {
  2600. query.lastIndex = stream.pos;
  2601. var match = query.exec(stream.string);
  2602. if (match && match.index == stream.pos) {
  2603. stream.pos += match[0].length || 1;
  2604. return "searching";
  2605. } else if (match) {
  2606. stream.pos = match.index;
  2607. } else {
  2608. stream.skipToEnd();
  2609. }
  2610. }};
  2611. }
  2612. function SearchState() {
  2613. this.posFrom = this.posTo = this.lastQuery = this.query = null;
  2614. this.overlay = null;
  2615. }
  2616. function getSearchState(cm) {
  2617. return cm.state.search || (cm.state.search = new SearchState());
  2618. }
  2619. function queryCaseInsensitive(query) {
  2620. return typeof query == "string" && query == query.toLowerCase();
  2621. }
  2622. function getSearchCursor(cm, query, pos) {
  2623. // Heuristic: if the query string is all lowercase, do a case insensitive search.
  2624. return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true});
  2625. }
  2626. function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
  2627. cm.openDialog(text, onEnter, {
  2628. value: deflt,
  2629. selectValueOnOpen: true,
  2630. closeOnEnter: false,
  2631. onClose: function() { clearSearch(cm); },
  2632. onKeyDown: onKeyDown
  2633. });
  2634. }
  2635. function dialog(cm, text, shortText, deflt, f) {
  2636. if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
  2637. else f(prompt(shortText, deflt));
  2638. }
  2639. function confirmDialog(cm, text, shortText, fs) {
  2640. if (cm.openConfirm) cm.openConfirm(text, fs);
  2641. else if (confirm(shortText)) fs[0]();
  2642. }
  2643. function parseString(string) {
  2644. return string.replace(/\\(.)/g, function(_, ch) {
  2645. if (ch == "n") return "\n"
  2646. if (ch == "r") return "\r"
  2647. return ch
  2648. })
  2649. }
  2650. function parseQuery(query) {
  2651. var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
  2652. if (isRE) {
  2653. try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
  2654. catch(e) {} // Not a regular expression after all, do a string search
  2655. } else {
  2656. query = parseString(query)
  2657. }
  2658. if (typeof query == "string" ? query == "" : query.test(""))
  2659. query = /x^/;
  2660. return query;
  2661. }
  2662. function startSearch(cm, state, query) {
  2663. state.queryText = query;
  2664. state.query = parseQuery(query);
  2665. cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
  2666. state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
  2667. cm.addOverlay(state.overlay);
  2668. if (cm.showMatchesOnScrollbar) {
  2669. if (state.annotate) { state.annotate.clear(); state.annotate = null; }
  2670. state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
  2671. }
  2672. }
  2673. function doSearch(cm, rev, persistent, immediate) {
  2674. var state = getSearchState(cm);
  2675. if (state.query) return findNext(cm, rev);
  2676. var q = cm.getSelection() || state.lastQuery;
  2677. if (q instanceof RegExp && q.source == "x^") q = null
  2678. if (persistent && cm.openDialog) {
  2679. var hiding = null
  2680. var searchNext = function(query, event) {
  2681. CodeMirror.e_stop(event);
  2682. if (!query) return;
  2683. if (query != state.queryText) {
  2684. startSearch(cm, state, query);
  2685. state.posFrom = state.posTo = cm.getCursor();
  2686. }
  2687. if (hiding) hiding.style.opacity = 1
  2688. findNext(cm, event.shiftKey, function(_, to) {
  2689. var dialog
  2690. if (to.line < 3 && document.querySelector &&
  2691. (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
  2692. dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
  2693. (hiding = dialog).style.opacity = .4
  2694. })
  2695. };
  2696. persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) {
  2697. var keyName = CodeMirror.keyName(event)
  2698. var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
  2699. if (cmd == "findNext" || cmd == "findPrev" ||
  2700. cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
  2701. CodeMirror.e_stop(event);
  2702. startSearch(cm, getSearchState(cm), query);
  2703. cm.execCommand(cmd);
  2704. } else if (cmd == "find" || cmd == "findPersistent") {
  2705. CodeMirror.e_stop(event);
  2706. searchNext(query, event);
  2707. }
  2708. });
  2709. if (immediate && q) {
  2710. startSearch(cm, state, q);
  2711. findNext(cm, rev);
  2712. }
  2713. } else {
  2714. dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) {
  2715. if (query && !state.query) cm.operation(function() {
  2716. startSearch(cm, state, query);
  2717. state.posFrom = state.posTo = cm.getCursor();
  2718. findNext(cm, rev);
  2719. });
  2720. });
  2721. }
  2722. }
  2723. function findNext(cm, rev, callback) {cm.operation(function() {
  2724. var state = getSearchState(cm);
  2725. var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
  2726. if (!cursor.find(rev)) {
  2727. cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
  2728. if (!cursor.find(rev)) return;
  2729. }
  2730. cm.setSelection(cursor.from(), cursor.to());
  2731. cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
  2732. state.posFrom = cursor.from(); state.posTo = cursor.to();
  2733. if (callback) callback(cursor.from(), cursor.to())
  2734. });}
  2735. function clearSearch(cm) {cm.operation(function() {
  2736. var state = getSearchState(cm);
  2737. state.lastQuery = state.query;
  2738. if (!state.query) return;
  2739. state.query = state.queryText = null;
  2740. cm.removeOverlay(state.overlay);
  2741. if (state.annotate) { state.annotate.clear(); state.annotate = null; }
  2742. });}
  2743. function getQueryDialog(cm) {
  2744. return '<span class="CodeMirror-search-label">' + cm.phrase("Search:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
  2745. }
  2746. function getReplaceQueryDialog(cm) {
  2747. return ' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">' + cm.phrase("(Use /re/ syntax for regexp search)") + '</span>';
  2748. }
  2749. function getReplacementQueryDialog(cm) {
  2750. return '<span class="CodeMirror-search-label">' + cm.phrase("With:") + '</span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>';
  2751. }
  2752. function getDoReplaceConfirm(cm) {
  2753. return '<span class="CodeMirror-search-label">' + cm.phrase("Replace?") + '</span> <button>' + cm.phrase("Yes") + '</button> <button>' + cm.phrase("No") + '</button> <button>' + cm.phrase("All") + '</button> <button>' + cm.phrase("Stop") + '</button> ';
  2754. }
  2755. function replaceAll(cm, query, text) {
  2756. cm.operation(function() {
  2757. for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
  2758. if (typeof query != "string") {
  2759. var match = cm.getRange(cursor.from(), cursor.to()).match(query);
  2760. cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
  2761. } else cursor.replace(text);
  2762. }
  2763. });
  2764. }
  2765. function replace(cm, all) {
  2766. if (cm.getOption("readOnly")) return;
  2767. var query = cm.getSelection() || getSearchState(cm).lastQuery;
  2768. var dialogText = '<span class="CodeMirror-search-label">' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + '</span>';
  2769. dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) {
  2770. if (!query) return;
  2771. query = parseQuery(query);
  2772. dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {
  2773. text = parseString(text)
  2774. if (all) {
  2775. replaceAll(cm, query, text)
  2776. } else {
  2777. clearSearch(cm);
  2778. var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
  2779. var advance = function() {
  2780. var start = cursor.from(), match;
  2781. if (!(match = cursor.findNext())) {
  2782. cursor = getSearchCursor(cm, query);
  2783. if (!(match = cursor.findNext()) ||
  2784. (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
  2785. }
  2786. cm.setSelection(cursor.from(), cursor.to());
  2787. cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
  2788. confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"),
  2789. [function() {doReplace(match);}, advance,
  2790. function() {replaceAll(cm, query, text)}]);
  2791. };
  2792. var doReplace = function(match) {
  2793. cursor.replace(typeof query == "string" ? text :
  2794. text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
  2795. advance();
  2796. };
  2797. advance();
  2798. }
  2799. });
  2800. });
  2801. }
  2802. CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
  2803. CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
  2804. CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
  2805. CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
  2806. CodeMirror.commands.findNext = doSearch;
  2807. CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
  2808. CodeMirror.commands.clearSearch = clearSearch;
  2809. CodeMirror.commands.replace = replace;
  2810. CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
  2811. });
  2812. },{"../../lib/codemirror":16,"../dialog/dialog":4,"./searchcursor":14}],14:[function(require,module,exports){
  2813. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2814. // Distributed under an MIT license: https://codemirror.net/LICENSE
  2815. (function(mod) {
  2816. if (typeof exports == "object" && typeof module == "object") // CommonJS
  2817. mod(require("../../lib/codemirror"))
  2818. else if (typeof define == "function" && define.amd) // AMD
  2819. define(["../../lib/codemirror"], mod)
  2820. else // Plain browser env
  2821. mod(CodeMirror)
  2822. })(function(CodeMirror) {
  2823. "use strict"
  2824. var Pos = CodeMirror.Pos
  2825. function regexpFlags(regexp) {
  2826. var flags = regexp.flags
  2827. return flags != null ? flags : (regexp.ignoreCase ? "i" : "")
  2828. + (regexp.global ? "g" : "")
  2829. + (regexp.multiline ? "m" : "")
  2830. }
  2831. function ensureFlags(regexp, flags) {
  2832. var current = regexpFlags(regexp), target = current
  2833. for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1)
  2834. target += flags.charAt(i)
  2835. return current == target ? regexp : new RegExp(regexp.source, target)
  2836. }
  2837. function maybeMultiline(regexp) {
  2838. return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source)
  2839. }
  2840. function searchRegexpForward(doc, regexp, start) {
  2841. regexp = ensureFlags(regexp, "g")
  2842. for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) {
  2843. regexp.lastIndex = ch
  2844. var string = doc.getLine(line), match = regexp.exec(string)
  2845. if (match)
  2846. return {from: Pos(line, match.index),
  2847. to: Pos(line, match.index + match[0].length),
  2848. match: match}
  2849. }
  2850. }
  2851. function searchRegexpForwardMultiline(doc, regexp, start) {
  2852. if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start)
  2853. regexp = ensureFlags(regexp, "gm")
  2854. var string, chunk = 1
  2855. for (var line = start.line, last = doc.lastLine(); line <= last;) {
  2856. // This grows the search buffer in exponentially-sized chunks
  2857. // between matches, so that nearby matches are fast and don't
  2858. // require concatenating the whole document (in case we're
  2859. // searching for something that has tons of matches), but at the
  2860. // same time, the amount of retries is limited.
  2861. for (var i = 0; i < chunk; i++) {
  2862. if (line > last) break
  2863. var curLine = doc.getLine(line++)
  2864. string = string == null ? curLine : string + "\n" + curLine
  2865. }
  2866. chunk = chunk * 2
  2867. regexp.lastIndex = start.ch
  2868. var match = regexp.exec(string)
  2869. if (match) {
  2870. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n")
  2871. var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length
  2872. return {from: Pos(startLine, startCh),
  2873. to: Pos(startLine + inside.length - 1,
  2874. inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  2875. match: match}
  2876. }
  2877. }
  2878. }
  2879. function lastMatchIn(string, regexp) {
  2880. var cutOff = 0, match
  2881. for (;;) {
  2882. regexp.lastIndex = cutOff
  2883. var newMatch = regexp.exec(string)
  2884. if (!newMatch) return match
  2885. match = newMatch
  2886. cutOff = match.index + (match[0].length || 1)
  2887. if (cutOff == string.length) return match
  2888. }
  2889. }
  2890. function searchRegexpBackward(doc, regexp, start) {
  2891. regexp = ensureFlags(regexp, "g")
  2892. for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) {
  2893. var string = doc.getLine(line)
  2894. if (ch > -1) string = string.slice(0, ch)
  2895. var match = lastMatchIn(string, regexp)
  2896. if (match)
  2897. return {from: Pos(line, match.index),
  2898. to: Pos(line, match.index + match[0].length),
  2899. match: match}
  2900. }
  2901. }
  2902. function searchRegexpBackwardMultiline(doc, regexp, start) {
  2903. regexp = ensureFlags(regexp, "gm")
  2904. var string, chunk = 1
  2905. for (var line = start.line, first = doc.firstLine(); line >= first;) {
  2906. for (var i = 0; i < chunk; i++) {
  2907. var curLine = doc.getLine(line--)
  2908. string = string == null ? curLine.slice(0, start.ch) : curLine + "\n" + string
  2909. }
  2910. chunk *= 2
  2911. var match = lastMatchIn(string, regexp)
  2912. if (match) {
  2913. var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n")
  2914. var startLine = line + before.length, startCh = before[before.length - 1].length
  2915. return {from: Pos(startLine, startCh),
  2916. to: Pos(startLine + inside.length - 1,
  2917. inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length),
  2918. match: match}
  2919. }
  2920. }
  2921. }
  2922. var doFold, noFold
  2923. if (String.prototype.normalize) {
  2924. doFold = function(str) { return str.normalize("NFD").toLowerCase() }
  2925. noFold = function(str) { return str.normalize("NFD") }
  2926. } else {
  2927. doFold = function(str) { return str.toLowerCase() }
  2928. noFold = function(str) { return str }
  2929. }
  2930. // Maps a position in a case-folded line back to a position in the original line
  2931. // (compensating for codepoints increasing in number during folding)
  2932. function adjustPos(orig, folded, pos, foldFunc) {
  2933. if (orig.length == folded.length) return pos
  2934. for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) {
  2935. if (min == max) return min
  2936. var mid = (min + max) >> 1
  2937. var len = foldFunc(orig.slice(0, mid)).length
  2938. if (len == pos) return mid
  2939. else if (len > pos) max = mid
  2940. else min = mid + 1
  2941. }
  2942. }
  2943. function searchStringForward(doc, query, start, caseFold) {
  2944. // Empty string would match anything and never progress, so we
  2945. // define it to match nothing instead.
  2946. if (!query.length) return null
  2947. var fold = caseFold ? doFold : noFold
  2948. var lines = fold(query).split(/\r|\n\r?/)
  2949. search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) {
  2950. var orig = doc.getLine(line).slice(ch), string = fold(orig)
  2951. if (lines.length == 1) {
  2952. var found = string.indexOf(lines[0])
  2953. if (found == -1) continue search
  2954. var start = adjustPos(orig, string, found, fold) + ch
  2955. return {from: Pos(line, adjustPos(orig, string, found, fold) + ch),
  2956. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)}
  2957. } else {
  2958. var cutFrom = string.length - lines[0].length
  2959. if (string.slice(cutFrom) != lines[0]) continue search
  2960. for (var i = 1; i < lines.length - 1; i++)
  2961. if (fold(doc.getLine(line + i)) != lines[i]) continue search
  2962. var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1]
  2963. if (endString.slice(0, lastLine.length) != lastLine) continue search
  2964. return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch),
  2965. to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))}
  2966. }
  2967. }
  2968. }
  2969. function searchStringBackward(doc, query, start, caseFold) {
  2970. if (!query.length) return null
  2971. var fold = caseFold ? doFold : noFold
  2972. var lines = fold(query).split(/\r|\n\r?/)
  2973. search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) {
  2974. var orig = doc.getLine(line)
  2975. if (ch > -1) orig = orig.slice(0, ch)
  2976. var string = fold(orig)
  2977. if (lines.length == 1) {
  2978. var found = string.lastIndexOf(lines[0])
  2979. if (found == -1) continue search
  2980. return {from: Pos(line, adjustPos(orig, string, found, fold)),
  2981. to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))}
  2982. } else {
  2983. var lastLine = lines[lines.length - 1]
  2984. if (string.slice(0, lastLine.length) != lastLine) continue search
  2985. for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++)
  2986. if (fold(doc.getLine(start + i)) != lines[i]) continue search
  2987. var top = doc.getLine(line + 1 - lines.length), topString = fold(top)
  2988. if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search
  2989. return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)),
  2990. to: Pos(line, adjustPos(orig, string, lastLine.length, fold))}
  2991. }
  2992. }
  2993. }
  2994. function SearchCursor(doc, query, pos, options) {
  2995. this.atOccurrence = false
  2996. this.doc = doc
  2997. pos = pos ? doc.clipPos(pos) : Pos(0, 0)
  2998. this.pos = {from: pos, to: pos}
  2999. var caseFold
  3000. if (typeof options == "object") {
  3001. caseFold = options.caseFold
  3002. } else { // Backwards compat for when caseFold was the 4th argument
  3003. caseFold = options
  3004. options = null
  3005. }
  3006. if (typeof query == "string") {
  3007. if (caseFold == null) caseFold = false
  3008. this.matches = function(reverse, pos) {
  3009. return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold)
  3010. }
  3011. } else {
  3012. query = ensureFlags(query, "gm")
  3013. if (!options || options.multiline !== false)
  3014. this.matches = function(reverse, pos) {
  3015. return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos)
  3016. }
  3017. else
  3018. this.matches = function(reverse, pos) {
  3019. return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos)
  3020. }
  3021. }
  3022. }
  3023. SearchCursor.prototype = {
  3024. findNext: function() {return this.find(false)},
  3025. findPrevious: function() {return this.find(true)},
  3026. find: function(reverse) {
  3027. var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to))
  3028. // Implements weird auto-growing behavior on null-matches for
  3029. // backwards-compatiblity with the vim code (unfortunately)
  3030. while (result && CodeMirror.cmpPos(result.from, result.to) == 0) {
  3031. if (reverse) {
  3032. if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1)
  3033. else if (result.from.line == this.doc.firstLine()) result = null
  3034. else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1)))
  3035. } else {
  3036. if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1)
  3037. else if (result.to.line == this.doc.lastLine()) result = null
  3038. else result = this.matches(reverse, Pos(result.to.line + 1, 0))
  3039. }
  3040. }
  3041. if (result) {
  3042. this.pos = result
  3043. this.atOccurrence = true
  3044. return this.pos.match || true
  3045. } else {
  3046. var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0)
  3047. this.pos = {from: end, to: end}
  3048. return this.atOccurrence = false
  3049. }
  3050. },
  3051. from: function() {if (this.atOccurrence) return this.pos.from},
  3052. to: function() {if (this.atOccurrence) return this.pos.to},
  3053. replace: function(newText, origin) {
  3054. if (!this.atOccurrence) return
  3055. var lines = CodeMirror.splitLines(newText)
  3056. this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin)
  3057. this.pos.to = Pos(this.pos.from.line + lines.length - 1,
  3058. lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0))
  3059. }
  3060. }
  3061. CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
  3062. return new SearchCursor(this.doc, query, pos, caseFold)
  3063. })
  3064. CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
  3065. return new SearchCursor(this, query, pos, caseFold)
  3066. })
  3067. CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
  3068. var ranges = []
  3069. var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold)
  3070. while (cur.findNext()) {
  3071. if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break
  3072. ranges.push({anchor: cur.from(), head: cur.to()})
  3073. }
  3074. if (ranges.length)
  3075. this.setSelections(ranges, 0)
  3076. })
  3077. });
  3078. },{"../../lib/codemirror":16}],15:[function(require,module,exports){
  3079. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  3080. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3081. // A rough approximation of Sublime Text's keybindings
  3082. // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js
  3083. (function(mod) {
  3084. if (typeof exports == "object" && typeof module == "object") // CommonJS
  3085. mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets"));
  3086. else if (typeof define == "function" && define.amd) // AMD
  3087. define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod);
  3088. else // Plain browser env
  3089. mod(CodeMirror);
  3090. })(function(CodeMirror) {
  3091. "use strict";
  3092. var cmds = CodeMirror.commands;
  3093. var Pos = CodeMirror.Pos;
  3094. // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.
  3095. function findPosSubword(doc, start, dir) {
  3096. if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
  3097. var line = doc.getLine(start.line);
  3098. if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
  3099. var state = "start", type;
  3100. for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {
  3101. var next = line.charAt(dir < 0 ? pos - 1 : pos);
  3102. var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o";
  3103. if (cat == "w" && next.toUpperCase() == next) cat = "W";
  3104. if (state == "start") {
  3105. if (cat != "o") { state = "in"; type = cat; }
  3106. } else if (state == "in") {
  3107. if (type != cat) {
  3108. if (type == "w" && cat == "W" && dir < 0) pos--;
  3109. if (type == "W" && cat == "w" && dir > 0) { type = "w"; continue; }
  3110. break;
  3111. }
  3112. }
  3113. }
  3114. return Pos(start.line, pos);
  3115. }
  3116. function moveSubword(cm, dir) {
  3117. cm.extendSelectionsBy(function(range) {
  3118. if (cm.display.shift || cm.doc.extend || range.empty())
  3119. return findPosSubword(cm.doc, range.head, dir);
  3120. else
  3121. return dir < 0 ? range.from() : range.to();
  3122. });
  3123. }
  3124. cmds.goSubwordLeft = function(cm) { moveSubword(cm, -1); };
  3125. cmds.goSubwordRight = function(cm) { moveSubword(cm, 1); };
  3126. cmds.scrollLineUp = function(cm) {
  3127. var info = cm.getScrollInfo();
  3128. if (!cm.somethingSelected()) {
  3129. var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
  3130. if (cm.getCursor().line >= visibleBottomLine)
  3131. cm.execCommand("goLineUp");
  3132. }
  3133. cm.scrollTo(null, info.top - cm.defaultTextHeight());
  3134. };
  3135. cmds.scrollLineDown = function(cm) {
  3136. var info = cm.getScrollInfo();
  3137. if (!cm.somethingSelected()) {
  3138. var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
  3139. if (cm.getCursor().line <= visibleTopLine)
  3140. cm.execCommand("goLineDown");
  3141. }
  3142. cm.scrollTo(null, info.top + cm.defaultTextHeight());
  3143. };
  3144. cmds.splitSelectionByLine = function(cm) {
  3145. var ranges = cm.listSelections(), lineRanges = [];
  3146. for (var i = 0; i < ranges.length; i++) {
  3147. var from = ranges[i].from(), to = ranges[i].to();
  3148. for (var line = from.line; line <= to.line; ++line)
  3149. if (!(to.line > from.line && line == to.line && to.ch == 0))
  3150. lineRanges.push({anchor: line == from.line ? from : Pos(line, 0),
  3151. head: line == to.line ? to : Pos(line)});
  3152. }
  3153. cm.setSelections(lineRanges, 0);
  3154. };
  3155. cmds.singleSelectionTop = function(cm) {
  3156. var range = cm.listSelections()[0];
  3157. cm.setSelection(range.anchor, range.head, {scroll: false});
  3158. };
  3159. cmds.selectLine = function(cm) {
  3160. var ranges = cm.listSelections(), extended = [];
  3161. for (var i = 0; i < ranges.length; i++) {
  3162. var range = ranges[i];
  3163. extended.push({anchor: Pos(range.from().line, 0),
  3164. head: Pos(range.to().line + 1, 0)});
  3165. }
  3166. cm.setSelections(extended);
  3167. };
  3168. function insertLine(cm, above) {
  3169. if (cm.isReadOnly()) return CodeMirror.Pass
  3170. cm.operation(function() {
  3171. var len = cm.listSelections().length, newSelection = [], last = -1;
  3172. for (var i = 0; i < len; i++) {
  3173. var head = cm.listSelections()[i].head;
  3174. if (head.line <= last) continue;
  3175. var at = Pos(head.line + (above ? 0 : 1), 0);
  3176. cm.replaceRange("\n", at, null, "+insertLine");
  3177. cm.indentLine(at.line, null, true);
  3178. newSelection.push({head: at, anchor: at});
  3179. last = head.line + 1;
  3180. }
  3181. cm.setSelections(newSelection);
  3182. });
  3183. cm.execCommand("indentAuto");
  3184. }
  3185. cmds.insertLineAfter = function(cm) { return insertLine(cm, false); };
  3186. cmds.insertLineBefore = function(cm) { return insertLine(cm, true); };
  3187. function wordAt(cm, pos) {
  3188. var start = pos.ch, end = start, line = cm.getLine(pos.line);
  3189. while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start;
  3190. while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end;
  3191. return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)};
  3192. }
  3193. cmds.selectNextOccurrence = function(cm) {
  3194. var from = cm.getCursor("from"), to = cm.getCursor("to");
  3195. var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;
  3196. if (CodeMirror.cmpPos(from, to) == 0) {
  3197. var word = wordAt(cm, from);
  3198. if (!word.word) return;
  3199. cm.setSelection(word.from, word.to);
  3200. fullWord = true;
  3201. } else {
  3202. var text = cm.getRange(from, to);
  3203. var query = fullWord ? new RegExp("\\b" + text + "\\b") : text;
  3204. var cur = cm.getSearchCursor(query, to);
  3205. var found = cur.findNext();
  3206. if (!found) {
  3207. cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));
  3208. found = cur.findNext();
  3209. }
  3210. if (!found || isSelectedRange(cm.listSelections(), cur.from(), cur.to()))
  3211. return CodeMirror.Pass
  3212. cm.addSelection(cur.from(), cur.to());
  3213. }
  3214. if (fullWord)
  3215. cm.state.sublimeFindFullWord = cm.doc.sel;
  3216. };
  3217. function addCursorToSelection(cm, dir) {
  3218. var ranges = cm.listSelections(), newRanges = [];
  3219. for (var i = 0; i < ranges.length; i++) {
  3220. var range = ranges[i];
  3221. var newAnchor = cm.findPosV(
  3222. range.anchor, dir, "line", range.anchor.goalColumn);
  3223. var newHead = cm.findPosV(
  3224. range.head, dir, "line", range.head.goalColumn);
  3225. newAnchor.goalColumn = range.anchor.goalColumn != null ?
  3226. range.anchor.goalColumn : cm.cursorCoords(range.anchor, "div").left;
  3227. newHead.goalColumn = range.head.goalColumn != null ?
  3228. range.head.goalColumn : cm.cursorCoords(range.head, "div").left;
  3229. var newRange = {anchor: newAnchor, head: newHead};
  3230. newRanges.push(range);
  3231. newRanges.push(newRange);
  3232. }
  3233. cm.setSelections(newRanges);
  3234. }
  3235. cmds.addCursorToPrevLine = function(cm) { addCursorToSelection(cm, -1); };
  3236. cmds.addCursorToNextLine = function(cm) { addCursorToSelection(cm, 1); };
  3237. function isSelectedRange(ranges, from, to) {
  3238. for (var i = 0; i < ranges.length; i++)
  3239. if (ranges[i].from() == from && ranges[i].to() == to) return true
  3240. return false
  3241. }
  3242. var mirror = "(){}[]";
  3243. function selectBetweenBrackets(cm) {
  3244. var ranges = cm.listSelections(), newRanges = []
  3245. for (var i = 0; i < ranges.length; i++) {
  3246. var range = ranges[i], pos = range.head, opening = cm.scanForBracket(pos, -1);
  3247. if (!opening) return false;
  3248. for (;;) {
  3249. var closing = cm.scanForBracket(pos, 1);
  3250. if (!closing) return false;
  3251. if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
  3252. var startPos = Pos(opening.pos.line, opening.pos.ch + 1);
  3253. if (CodeMirror.cmpPos(startPos, range.from()) == 0 &&
  3254. CodeMirror.cmpPos(closing.pos, range.to()) == 0) {
  3255. opening = cm.scanForBracket(opening.pos, -1);
  3256. if (!opening) return false;
  3257. } else {
  3258. newRanges.push({anchor: startPos, head: closing.pos});
  3259. break;
  3260. }
  3261. }
  3262. pos = Pos(closing.pos.line, closing.pos.ch + 1);
  3263. }
  3264. }
  3265. cm.setSelections(newRanges);
  3266. return true;
  3267. }
  3268. cmds.selectScope = function(cm) {
  3269. selectBetweenBrackets(cm) || cm.execCommand("selectAll");
  3270. };
  3271. cmds.selectBetweenBrackets = function(cm) {
  3272. if (!selectBetweenBrackets(cm)) return CodeMirror.Pass;
  3273. };
  3274. cmds.goToBracket = function(cm) {
  3275. cm.extendSelectionsBy(function(range) {
  3276. var next = cm.scanForBracket(range.head, 1);
  3277. if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos;
  3278. var prev = cm.scanForBracket(range.head, -1);
  3279. return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head;
  3280. });
  3281. };
  3282. cmds.swapLineUp = function(cm) {
  3283. if (cm.isReadOnly()) return CodeMirror.Pass
  3284. var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
  3285. for (var i = 0; i < ranges.length; i++) {
  3286. var range = ranges[i], from = range.from().line - 1, to = range.to().line;
  3287. newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch),
  3288. head: Pos(range.head.line - 1, range.head.ch)});
  3289. if (range.to().ch == 0 && !range.empty()) --to;
  3290. if (from > at) linesToMove.push(from, to);
  3291. else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
  3292. at = to;
  3293. }
  3294. cm.operation(function() {
  3295. for (var i = 0; i < linesToMove.length; i += 2) {
  3296. var from = linesToMove[i], to = linesToMove[i + 1];
  3297. var line = cm.getLine(from);
  3298. cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
  3299. if (to > cm.lastLine())
  3300. cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine");
  3301. else
  3302. cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
  3303. }
  3304. cm.setSelections(newSels);
  3305. cm.scrollIntoView();
  3306. });
  3307. };
  3308. cmds.swapLineDown = function(cm) {
  3309. if (cm.isReadOnly()) return CodeMirror.Pass
  3310. var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
  3311. for (var i = ranges.length - 1; i >= 0; i--) {
  3312. var range = ranges[i], from = range.to().line + 1, to = range.from().line;
  3313. if (range.to().ch == 0 && !range.empty()) from--;
  3314. if (from < at) linesToMove.push(from, to);
  3315. else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
  3316. at = to;
  3317. }
  3318. cm.operation(function() {
  3319. for (var i = linesToMove.length - 2; i >= 0; i -= 2) {
  3320. var from = linesToMove[i], to = linesToMove[i + 1];
  3321. var line = cm.getLine(from);
  3322. if (from == cm.lastLine())
  3323. cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine");
  3324. else
  3325. cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
  3326. cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
  3327. }
  3328. cm.scrollIntoView();
  3329. });
  3330. };
  3331. cmds.toggleCommentIndented = function(cm) {
  3332. cm.toggleComment({ indent: true });
  3333. }
  3334. cmds.joinLines = function(cm) {
  3335. var ranges = cm.listSelections(), joined = [];
  3336. for (var i = 0; i < ranges.length; i++) {
  3337. var range = ranges[i], from = range.from();
  3338. var start = from.line, end = range.to().line;
  3339. while (i < ranges.length - 1 && ranges[i + 1].from().line == end)
  3340. end = ranges[++i].to().line;
  3341. joined.push({start: start, end: end, anchor: !range.empty() && from});
  3342. }
  3343. cm.operation(function() {
  3344. var offset = 0, ranges = [];
  3345. for (var i = 0; i < joined.length; i++) {
  3346. var obj = joined[i];
  3347. var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head;
  3348. for (var line = obj.start; line <= obj.end; line++) {
  3349. var actual = line - offset;
  3350. if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);
  3351. if (actual < cm.lastLine()) {
  3352. cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length));
  3353. ++offset;
  3354. }
  3355. }
  3356. ranges.push({anchor: anchor || head, head: head});
  3357. }
  3358. cm.setSelections(ranges, 0);
  3359. });
  3360. };
  3361. cmds.duplicateLine = function(cm) {
  3362. cm.operation(function() {
  3363. var rangeCount = cm.listSelections().length;
  3364. for (var i = 0; i < rangeCount; i++) {
  3365. var range = cm.listSelections()[i];
  3366. if (range.empty())
  3367. cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0));
  3368. else
  3369. cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());
  3370. }
  3371. cm.scrollIntoView();
  3372. });
  3373. };
  3374. function sortLines(cm, caseSensitive) {
  3375. if (cm.isReadOnly()) return CodeMirror.Pass
  3376. var ranges = cm.listSelections(), toSort = [], selected;
  3377. for (var i = 0; i < ranges.length; i++) {
  3378. var range = ranges[i];
  3379. if (range.empty()) continue;
  3380. var from = range.from().line, to = range.to().line;
  3381. while (i < ranges.length - 1 && ranges[i + 1].from().line == to)
  3382. to = ranges[++i].to().line;
  3383. if (!ranges[i].to().ch) to--;
  3384. toSort.push(from, to);
  3385. }
  3386. if (toSort.length) selected = true;
  3387. else toSort.push(cm.firstLine(), cm.lastLine());
  3388. cm.operation(function() {
  3389. var ranges = [];
  3390. for (var i = 0; i < toSort.length; i += 2) {
  3391. var from = toSort[i], to = toSort[i + 1];
  3392. var start = Pos(from, 0), end = Pos(to);
  3393. var lines = cm.getRange(start, end, false);
  3394. if (caseSensitive)
  3395. lines.sort();
  3396. else
  3397. lines.sort(function(a, b) {
  3398. var au = a.toUpperCase(), bu = b.toUpperCase();
  3399. if (au != bu) { a = au; b = bu; }
  3400. return a < b ? -1 : a == b ? 0 : 1;
  3401. });
  3402. cm.replaceRange(lines, start, end);
  3403. if (selected) ranges.push({anchor: start, head: Pos(to + 1, 0)});
  3404. }
  3405. if (selected) cm.setSelections(ranges, 0);
  3406. });
  3407. }
  3408. cmds.sortLines = function(cm) { sortLines(cm, true); };
  3409. cmds.sortLinesInsensitive = function(cm) { sortLines(cm, false); };
  3410. cmds.nextBookmark = function(cm) {
  3411. var marks = cm.state.sublimeBookmarks;
  3412. if (marks) while (marks.length) {
  3413. var current = marks.shift();
  3414. var found = current.find();
  3415. if (found) {
  3416. marks.push(current);
  3417. return cm.setSelection(found.from, found.to);
  3418. }
  3419. }
  3420. };
  3421. cmds.prevBookmark = function(cm) {
  3422. var marks = cm.state.sublimeBookmarks;
  3423. if (marks) while (marks.length) {
  3424. marks.unshift(marks.pop());
  3425. var found = marks[marks.length - 1].find();
  3426. if (!found)
  3427. marks.pop();
  3428. else
  3429. return cm.setSelection(found.from, found.to);
  3430. }
  3431. };
  3432. cmds.toggleBookmark = function(cm) {
  3433. var ranges = cm.listSelections();
  3434. var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []);
  3435. for (var i = 0; i < ranges.length; i++) {
  3436. var from = ranges[i].from(), to = ranges[i].to();
  3437. var found = ranges[i].empty() ? cm.findMarksAt(from) : cm.findMarks(from, to);
  3438. for (var j = 0; j < found.length; j++) {
  3439. if (found[j].sublimeBookmark) {
  3440. found[j].clear();
  3441. for (var k = 0; k < marks.length; k++)
  3442. if (marks[k] == found[j])
  3443. marks.splice(k--, 1);
  3444. break;
  3445. }
  3446. }
  3447. if (j == found.length)
  3448. marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false}));
  3449. }
  3450. };
  3451. cmds.clearBookmarks = function(cm) {
  3452. var marks = cm.state.sublimeBookmarks;
  3453. if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear();
  3454. marks.length = 0;
  3455. };
  3456. cmds.selectBookmarks = function(cm) {
  3457. var marks = cm.state.sublimeBookmarks, ranges = [];
  3458. if (marks) for (var i = 0; i < marks.length; i++) {
  3459. var found = marks[i].find();
  3460. if (!found)
  3461. marks.splice(i--, 0);
  3462. else
  3463. ranges.push({anchor: found.from, head: found.to});
  3464. }
  3465. if (ranges.length)
  3466. cm.setSelections(ranges, 0);
  3467. };
  3468. function modifyWordOrSelection(cm, mod) {
  3469. cm.operation(function() {
  3470. var ranges = cm.listSelections(), indices = [], replacements = [];
  3471. for (var i = 0; i < ranges.length; i++) {
  3472. var range = ranges[i];
  3473. if (range.empty()) { indices.push(i); replacements.push(""); }
  3474. else replacements.push(mod(cm.getRange(range.from(), range.to())));
  3475. }
  3476. cm.replaceSelections(replacements, "around", "case");
  3477. for (var i = indices.length - 1, at; i >= 0; i--) {
  3478. var range = ranges[indices[i]];
  3479. if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;
  3480. var word = wordAt(cm, range.head);
  3481. at = word.from;
  3482. cm.replaceRange(mod(word.word), word.from, word.to);
  3483. }
  3484. });
  3485. }
  3486. cmds.smartBackspace = function(cm) {
  3487. if (cm.somethingSelected()) return CodeMirror.Pass;
  3488. cm.operation(function() {
  3489. var cursors = cm.listSelections();
  3490. var indentUnit = cm.getOption("indentUnit");
  3491. for (var i = cursors.length - 1; i >= 0; i--) {
  3492. var cursor = cursors[i].head;
  3493. var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
  3494. var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
  3495. // Delete by one character by default
  3496. var deletePos = cm.findPosH(cursor, -1, "char", false);
  3497. if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
  3498. var prevIndent = new Pos(cursor.line,
  3499. CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
  3500. // Smart delete only if we found a valid prevIndent location
  3501. if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
  3502. }
  3503. cm.replaceRange("", deletePos, cursor, "+delete");
  3504. }
  3505. });
  3506. };
  3507. cmds.delLineRight = function(cm) {
  3508. cm.operation(function() {
  3509. var ranges = cm.listSelections();
  3510. for (var i = ranges.length - 1; i >= 0; i--)
  3511. cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete");
  3512. cm.scrollIntoView();
  3513. });
  3514. };
  3515. cmds.upcaseAtCursor = function(cm) {
  3516. modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); });
  3517. };
  3518. cmds.downcaseAtCursor = function(cm) {
  3519. modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); });
  3520. };
  3521. cmds.setSublimeMark = function(cm) {
  3522. if (cm.state.sublimeMark) cm.state.sublimeMark.clear();
  3523. cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
  3524. };
  3525. cmds.selectToSublimeMark = function(cm) {
  3526. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  3527. if (found) cm.setSelection(cm.getCursor(), found);
  3528. };
  3529. cmds.deleteToSublimeMark = function(cm) {
  3530. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  3531. if (found) {
  3532. var from = cm.getCursor(), to = found;
  3533. if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }
  3534. cm.state.sublimeKilled = cm.getRange(from, to);
  3535. cm.replaceRange("", from, to);
  3536. }
  3537. };
  3538. cmds.swapWithSublimeMark = function(cm) {
  3539. var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
  3540. if (found) {
  3541. cm.state.sublimeMark.clear();
  3542. cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
  3543. cm.setCursor(found);
  3544. }
  3545. };
  3546. cmds.sublimeYank = function(cm) {
  3547. if (cm.state.sublimeKilled != null)
  3548. cm.replaceSelection(cm.state.sublimeKilled, null, "paste");
  3549. };
  3550. cmds.showInCenter = function(cm) {
  3551. var pos = cm.cursorCoords(null, "local");
  3552. cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
  3553. };
  3554. function getTarget(cm) {
  3555. var from = cm.getCursor("from"), to = cm.getCursor("to");
  3556. if (CodeMirror.cmpPos(from, to) == 0) {
  3557. var word = wordAt(cm, from);
  3558. if (!word.word) return;
  3559. from = word.from;
  3560. to = word.to;
  3561. }
  3562. return {from: from, to: to, query: cm.getRange(from, to), word: word};
  3563. }
  3564. function findAndGoTo(cm, forward) {
  3565. var target = getTarget(cm);
  3566. if (!target) return;
  3567. var query = target.query;
  3568. var cur = cm.getSearchCursor(query, forward ? target.to : target.from);
  3569. if (forward ? cur.findNext() : cur.findPrevious()) {
  3570. cm.setSelection(cur.from(), cur.to());
  3571. } else {
  3572. cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0)
  3573. : cm.clipPos(Pos(cm.lastLine())));
  3574. if (forward ? cur.findNext() : cur.findPrevious())
  3575. cm.setSelection(cur.from(), cur.to());
  3576. else if (target.word)
  3577. cm.setSelection(target.from, target.to);
  3578. }
  3579. };
  3580. cmds.findUnder = function(cm) { findAndGoTo(cm, true); };
  3581. cmds.findUnderPrevious = function(cm) { findAndGoTo(cm,false); };
  3582. cmds.findAllUnder = function(cm) {
  3583. var target = getTarget(cm);
  3584. if (!target) return;
  3585. var cur = cm.getSearchCursor(target.query);
  3586. var matches = [];
  3587. var primaryIndex = -1;
  3588. while (cur.findNext()) {
  3589. matches.push({anchor: cur.from(), head: cur.to()});
  3590. if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch)
  3591. primaryIndex++;
  3592. }
  3593. cm.setSelections(matches, primaryIndex);
  3594. };
  3595. var keyMap = CodeMirror.keyMap;
  3596. keyMap.macSublime = {
  3597. "Cmd-Left": "goLineStartSmart",
  3598. "Shift-Tab": "indentLess",
  3599. "Shift-Ctrl-K": "deleteLine",
  3600. "Alt-Q": "wrapLines",
  3601. "Ctrl-Left": "goSubwordLeft",
  3602. "Ctrl-Right": "goSubwordRight",
  3603. "Ctrl-Alt-Up": "scrollLineUp",
  3604. "Ctrl-Alt-Down": "scrollLineDown",
  3605. "Cmd-L": "selectLine",
  3606. "Shift-Cmd-L": "splitSelectionByLine",
  3607. "Esc": "singleSelectionTop",
  3608. "Cmd-Enter": "insertLineAfter",
  3609. "Shift-Cmd-Enter": "insertLineBefore",
  3610. "Cmd-D": "selectNextOccurrence",
  3611. "Shift-Cmd-Space": "selectScope",
  3612. "Shift-Cmd-M": "selectBetweenBrackets",
  3613. "Cmd-M": "goToBracket",
  3614. "Cmd-Ctrl-Up": "swapLineUp",
  3615. "Cmd-Ctrl-Down": "swapLineDown",
  3616. "Cmd-/": "toggleCommentIndented",
  3617. "Cmd-J": "joinLines",
  3618. "Shift-Cmd-D": "duplicateLine",
  3619. "F5": "sortLines",
  3620. "Cmd-F5": "sortLinesInsensitive",
  3621. "F2": "nextBookmark",
  3622. "Shift-F2": "prevBookmark",
  3623. "Cmd-F2": "toggleBookmark",
  3624. "Shift-Cmd-F2": "clearBookmarks",
  3625. "Alt-F2": "selectBookmarks",
  3626. "Backspace": "smartBackspace",
  3627. "Cmd-K Cmd-K": "delLineRight",
  3628. "Cmd-K Cmd-U": "upcaseAtCursor",
  3629. "Cmd-K Cmd-L": "downcaseAtCursor",
  3630. "Cmd-K Cmd-Space": "setSublimeMark",
  3631. "Cmd-K Cmd-A": "selectToSublimeMark",
  3632. "Cmd-K Cmd-W": "deleteToSublimeMark",
  3633. "Cmd-K Cmd-X": "swapWithSublimeMark",
  3634. "Cmd-K Cmd-Y": "sublimeYank",
  3635. "Cmd-K Cmd-C": "showInCenter",
  3636. "Cmd-K Cmd-G": "clearBookmarks",
  3637. "Cmd-K Cmd-Backspace": "delLineLeft",
  3638. "Cmd-K Cmd-0": "unfoldAll",
  3639. "Cmd-K Cmd-J": "unfoldAll",
  3640. "Ctrl-Shift-Up": "addCursorToPrevLine",
  3641. "Ctrl-Shift-Down": "addCursorToNextLine",
  3642. "Cmd-F3": "findUnder",
  3643. "Shift-Cmd-F3": "findUnderPrevious",
  3644. "Alt-F3": "findAllUnder",
  3645. "Shift-Cmd-[": "fold",
  3646. "Shift-Cmd-]": "unfold",
  3647. "Cmd-I": "findIncremental",
  3648. "Shift-Cmd-I": "findIncrementalReverse",
  3649. "Cmd-H": "replace",
  3650. "F3": "findNext",
  3651. "Shift-F3": "findPrev",
  3652. "fallthrough": "macDefault"
  3653. };
  3654. CodeMirror.normalizeKeyMap(keyMap.macSublime);
  3655. keyMap.pcSublime = {
  3656. "Shift-Tab": "indentLess",
  3657. "Shift-Ctrl-K": "deleteLine",
  3658. "Alt-Q": "wrapLines",
  3659. "Ctrl-T": "transposeChars",
  3660. "Alt-Left": "goSubwordLeft",
  3661. "Alt-Right": "goSubwordRight",
  3662. "Ctrl-Up": "scrollLineUp",
  3663. "Ctrl-Down": "scrollLineDown",
  3664. "Ctrl-L": "selectLine",
  3665. "Shift-Ctrl-L": "splitSelectionByLine",
  3666. "Esc": "singleSelectionTop",
  3667. "Ctrl-Enter": "insertLineAfter",
  3668. "Shift-Ctrl-Enter": "insertLineBefore",
  3669. "Ctrl-D": "selectNextOccurrence",
  3670. "Shift-Ctrl-Space": "selectScope",
  3671. "Shift-Ctrl-M": "selectBetweenBrackets",
  3672. "Ctrl-M": "goToBracket",
  3673. "Shift-Ctrl-Up": "swapLineUp",
  3674. "Shift-Ctrl-Down": "swapLineDown",
  3675. "Ctrl-/": "toggleCommentIndented",
  3676. "Ctrl-J": "joinLines",
  3677. "Shift-Ctrl-D": "duplicateLine",
  3678. "F9": "sortLines",
  3679. "Ctrl-F9": "sortLinesInsensitive",
  3680. "F2": "nextBookmark",
  3681. "Shift-F2": "prevBookmark",
  3682. "Ctrl-F2": "toggleBookmark",
  3683. "Shift-Ctrl-F2": "clearBookmarks",
  3684. "Alt-F2": "selectBookmarks",
  3685. "Backspace": "smartBackspace",
  3686. "Ctrl-K Ctrl-K": "delLineRight",
  3687. "Ctrl-K Ctrl-U": "upcaseAtCursor",
  3688. "Ctrl-K Ctrl-L": "downcaseAtCursor",
  3689. "Ctrl-K Ctrl-Space": "setSublimeMark",
  3690. "Ctrl-K Ctrl-A": "selectToSublimeMark",
  3691. "Ctrl-K Ctrl-W": "deleteToSublimeMark",
  3692. "Ctrl-K Ctrl-X": "swapWithSublimeMark",
  3693. "Ctrl-K Ctrl-Y": "sublimeYank",
  3694. "Ctrl-K Ctrl-C": "showInCenter",
  3695. "Ctrl-K Ctrl-G": "clearBookmarks",
  3696. "Ctrl-K Ctrl-Backspace": "delLineLeft",
  3697. "Ctrl-K Ctrl-0": "unfoldAll",
  3698. "Ctrl-K Ctrl-J": "unfoldAll",
  3699. "Ctrl-Alt-Up": "addCursorToPrevLine",
  3700. "Ctrl-Alt-Down": "addCursorToNextLine",
  3701. "Ctrl-F3": "findUnder",
  3702. "Shift-Ctrl-F3": "findUnderPrevious",
  3703. "Alt-F3": "findAllUnder",
  3704. "Shift-Ctrl-[": "fold",
  3705. "Shift-Ctrl-]": "unfold",
  3706. "Ctrl-I": "findIncremental",
  3707. "Shift-Ctrl-I": "findIncrementalReverse",
  3708. "Ctrl-H": "replace",
  3709. "F3": "findNext",
  3710. "Shift-F3": "findPrev",
  3711. "fallthrough": "pcDefault"
  3712. };
  3713. CodeMirror.normalizeKeyMap(keyMap.pcSublime);
  3714. var mac = keyMap.default == keyMap.macDefault;
  3715. keyMap.sublime = mac ? keyMap.macSublime : keyMap.pcSublime;
  3716. });
  3717. },{"../addon/edit/matchbrackets":6,"../addon/search/searchcursor":14,"../lib/codemirror":16}],16:[function(require,module,exports){
  3718. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  3719. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3720. // This is CodeMirror (https://codemirror.net), a code editor
  3721. // implemented in JavaScript on top of the browser's DOM.
  3722. //
  3723. // You can find some technical background for some of the code below
  3724. // at http://marijnhaverbeke.nl/blog/#cm-internals .
  3725. (function (global, factory) {
  3726. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3727. typeof define === 'function' && define.amd ? define(factory) :
  3728. (global.CodeMirror = factory());
  3729. }(this, (function () { 'use strict';
  3730. // Kludges for bugs and behavior differences that can't be feature
  3731. // detected are enabled based on userAgent etc sniffing.
  3732. var userAgent = navigator.userAgent;
  3733. var platform = navigator.platform;
  3734. var gecko = /gecko\/\d/i.test(userAgent);
  3735. var ie_upto10 = /MSIE \d/.test(userAgent);
  3736. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  3737. var edge = /Edge\/(\d+)/.exec(userAgent);
  3738. var ie = ie_upto10 || ie_11up || edge;
  3739. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  3740. var webkit = !edge && /WebKit\//.test(userAgent);
  3741. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  3742. var chrome = !edge && /Chrome\//.test(userAgent);
  3743. var presto = /Opera\//.test(userAgent);
  3744. var safari = /Apple Computer/.test(navigator.vendor);
  3745. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  3746. var phantom = /PhantomJS/.test(userAgent);
  3747. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  3748. var android = /Android/.test(userAgent);
  3749. // This is woefully incomplete. Suggestions for alternative methods welcome.
  3750. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  3751. var mac = ios || /Mac/.test(platform);
  3752. var chromeOS = /\bCrOS\b/.test(userAgent);
  3753. var windows = /win/i.test(platform);
  3754. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  3755. if (presto_version) { presto_version = Number(presto_version[1]); }
  3756. if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
  3757. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  3758. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  3759. var captureRightClick = gecko || (ie && ie_version >= 9);
  3760. function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
  3761. var rmClass = function(node, cls) {
  3762. var current = node.className;
  3763. var match = classTest(cls).exec(current);
  3764. if (match) {
  3765. var after = current.slice(match.index + match[0].length);
  3766. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  3767. }
  3768. };
  3769. function removeChildren(e) {
  3770. for (var count = e.childNodes.length; count > 0; --count)
  3771. { e.removeChild(e.firstChild); }
  3772. return e
  3773. }
  3774. function removeChildrenAndAdd(parent, e) {
  3775. return removeChildren(parent).appendChild(e)
  3776. }
  3777. function elt(tag, content, className, style) {
  3778. var e = document.createElement(tag);
  3779. if (className) { e.className = className; }
  3780. if (style) { e.style.cssText = style; }
  3781. if (typeof content == "string") { e.appendChild(document.createTextNode(content)); }
  3782. else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }
  3783. return e
  3784. }
  3785. // wrapper for elt, which removes the elt from the accessibility tree
  3786. function eltP(tag, content, className, style) {
  3787. var e = elt(tag, content, className, style);
  3788. e.setAttribute("role", "presentation");
  3789. return e
  3790. }
  3791. var range;
  3792. if (document.createRange) { range = function(node, start, end, endNode) {
  3793. var r = document.createRange();
  3794. r.setEnd(endNode || node, end);
  3795. r.setStart(node, start);
  3796. return r
  3797. }; }
  3798. else { range = function(node, start, end) {
  3799. var r = document.body.createTextRange();
  3800. try { r.moveToElementText(node.parentNode); }
  3801. catch(e) { return r }
  3802. r.collapse(true);
  3803. r.moveEnd("character", end);
  3804. r.moveStart("character", start);
  3805. return r
  3806. }; }
  3807. function contains(parent, child) {
  3808. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  3809. { child = child.parentNode; }
  3810. if (parent.contains)
  3811. { return parent.contains(child) }
  3812. do {
  3813. if (child.nodeType == 11) { child = child.host; }
  3814. if (child == parent) { return true }
  3815. } while (child = child.parentNode)
  3816. }
  3817. function activeElt() {
  3818. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  3819. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  3820. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  3821. var activeElement;
  3822. try {
  3823. activeElement = document.activeElement;
  3824. } catch(e) {
  3825. activeElement = document.body || null;
  3826. }
  3827. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
  3828. { activeElement = activeElement.shadowRoot.activeElement; }
  3829. return activeElement
  3830. }
  3831. function addClass(node, cls) {
  3832. var current = node.className;
  3833. if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; }
  3834. }
  3835. function joinClasses(a, b) {
  3836. var as = a.split(" ");
  3837. for (var i = 0; i < as.length; i++)
  3838. { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } }
  3839. return b
  3840. }
  3841. var selectInput = function(node) { node.select(); };
  3842. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  3843. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }
  3844. else if (ie) // Suppress mysterious IE10 errors
  3845. { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
  3846. function bind(f) {
  3847. var args = Array.prototype.slice.call(arguments, 1);
  3848. return function(){return f.apply(null, args)}
  3849. }
  3850. function copyObj(obj, target, overwrite) {
  3851. if (!target) { target = {}; }
  3852. for (var prop in obj)
  3853. { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
  3854. { target[prop] = obj[prop]; } }
  3855. return target
  3856. }
  3857. // Counts the column offset in a string, taking tabs into account.
  3858. // Used mostly to find indentation.
  3859. function countColumn(string, end, tabSize, startIndex, startValue) {
  3860. if (end == null) {
  3861. end = string.search(/[^\s\u00a0]/);
  3862. if (end == -1) { end = string.length; }
  3863. }
  3864. for (var i = startIndex || 0, n = startValue || 0;;) {
  3865. var nextTab = string.indexOf("\t", i);
  3866. if (nextTab < 0 || nextTab >= end)
  3867. { return n + (end - i) }
  3868. n += nextTab - i;
  3869. n += tabSize - (n % tabSize);
  3870. i = nextTab + 1;
  3871. }
  3872. }
  3873. var Delayed = function() {this.id = null;};
  3874. Delayed.prototype.set = function (ms, f) {
  3875. clearTimeout(this.id);
  3876. this.id = setTimeout(f, ms);
  3877. };
  3878. function indexOf(array, elt) {
  3879. for (var i = 0; i < array.length; ++i)
  3880. { if (array[i] == elt) { return i } }
  3881. return -1
  3882. }
  3883. // Number of pixels added to scroller and sizer to hide scrollbar
  3884. var scrollerGap = 30;
  3885. // Returned or thrown by various protocols to signal 'I'm not
  3886. // handling this'.
  3887. var Pass = {toString: function(){return "CodeMirror.Pass"}};
  3888. // Reused option objects for setSelection & friends
  3889. var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
  3890. // The inverse of countColumn -- find the offset that corresponds to
  3891. // a particular column.
  3892. function findColumn(string, goal, tabSize) {
  3893. for (var pos = 0, col = 0;;) {
  3894. var nextTab = string.indexOf("\t", pos);
  3895. if (nextTab == -1) { nextTab = string.length; }
  3896. var skipped = nextTab - pos;
  3897. if (nextTab == string.length || col + skipped >= goal)
  3898. { return pos + Math.min(skipped, goal - col) }
  3899. col += nextTab - pos;
  3900. col += tabSize - (col % tabSize);
  3901. pos = nextTab + 1;
  3902. if (col >= goal) { return pos }
  3903. }
  3904. }
  3905. var spaceStrs = [""];
  3906. function spaceStr(n) {
  3907. while (spaceStrs.length <= n)
  3908. { spaceStrs.push(lst(spaceStrs) + " "); }
  3909. return spaceStrs[n]
  3910. }
  3911. function lst(arr) { return arr[arr.length-1] }
  3912. function map(array, f) {
  3913. var out = [];
  3914. for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }
  3915. return out
  3916. }
  3917. function insertSorted(array, value, score) {
  3918. var pos = 0, priority = score(value);
  3919. while (pos < array.length && score(array[pos]) <= priority) { pos++; }
  3920. array.splice(pos, 0, value);
  3921. }
  3922. function nothing() {}
  3923. function createObj(base, props) {
  3924. var inst;
  3925. if (Object.create) {
  3926. inst = Object.create(base);
  3927. } else {
  3928. nothing.prototype = base;
  3929. inst = new nothing();
  3930. }
  3931. if (props) { copyObj(props, inst); }
  3932. return inst
  3933. }
  3934. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  3935. function isWordCharBasic(ch) {
  3936. return /\w/.test(ch) || ch > "\x80" &&
  3937. (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  3938. }
  3939. function isWordChar(ch, helper) {
  3940. if (!helper) { return isWordCharBasic(ch) }
  3941. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
  3942. return helper.test(ch)
  3943. }
  3944. function isEmpty(obj) {
  3945. for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
  3946. return true
  3947. }
  3948. // Extending unicode characters. A series of a non-extending char +
  3949. // any number of extending chars is treated as a single unit as far
  3950. // as editing and measuring is concerned. This is not fully correct,
  3951. // since some scripts/fonts/browsers also treat other configurations
  3952. // of code points as a group.
  3953. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
  3954. function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
  3955. // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
  3956. function skipExtendingChars(str, pos, dir) {
  3957. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }
  3958. return pos
  3959. }
  3960. // Returns the value from the range [`from`; `to`] that satisfies
  3961. // `pred` and is closest to `from`. Assumes that at least `to`
  3962. // satisfies `pred`. Supports `from` being greater than `to`.
  3963. function findFirst(pred, from, to) {
  3964. // At any point we are certain `to` satisfies `pred`, don't know
  3965. // whether `from` does.
  3966. var dir = from > to ? -1 : 1;
  3967. for (;;) {
  3968. if (from == to) { return from }
  3969. var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  3970. if (mid == from) { return pred(mid) ? from : to }
  3971. if (pred(mid)) { to = mid; }
  3972. else { from = mid + dir; }
  3973. }
  3974. }
  3975. // BIDI HELPERS
  3976. function iterateBidiSections(order, from, to, f) {
  3977. if (!order) { return f(from, to, "ltr", 0) }
  3978. var found = false;
  3979. for (var i = 0; i < order.length; ++i) {
  3980. var part = order[i];
  3981. if (part.from < to && part.to > from || from == to && part.to == from) {
  3982. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
  3983. found = true;
  3984. }
  3985. }
  3986. if (!found) { f(from, to, "ltr"); }
  3987. }
  3988. var bidiOther = null;
  3989. function getBidiPartAt(order, ch, sticky) {
  3990. var found;
  3991. bidiOther = null;
  3992. for (var i = 0; i < order.length; ++i) {
  3993. var cur = order[i];
  3994. if (cur.from < ch && cur.to > ch) { return i }
  3995. if (cur.to == ch) {
  3996. if (cur.from != cur.to && sticky == "before") { found = i; }
  3997. else { bidiOther = i; }
  3998. }
  3999. if (cur.from == ch) {
  4000. if (cur.from != cur.to && sticky != "before") { found = i; }
  4001. else { bidiOther = i; }
  4002. }
  4003. }
  4004. return found != null ? found : bidiOther
  4005. }
  4006. // Bidirectional ordering algorithm
  4007. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  4008. // that this (partially) implements.
  4009. // One-char codes used for character types:
  4010. // L (L): Left-to-Right
  4011. // R (R): Right-to-Left
  4012. // r (AL): Right-to-Left Arabic
  4013. // 1 (EN): European Number
  4014. // + (ES): European Number Separator
  4015. // % (ET): European Number Terminator
  4016. // n (AN): Arabic Number
  4017. // , (CS): Common Number Separator
  4018. // m (NSM): Non-Spacing Mark
  4019. // b (BN): Boundary Neutral
  4020. // s (B): Paragraph Separator
  4021. // t (S): Segment Separator
  4022. // w (WS): Whitespace
  4023. // N (ON): Other Neutrals
  4024. // Returns null if characters are ordered as they appear
  4025. // (left-to-right), or an array of sections ({from, to, level}
  4026. // objects) in the order in which they occur visually.
  4027. var bidiOrdering = (function() {
  4028. // Character types for codepoints 0 to 0xff
  4029. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  4030. // Character types for codepoints 0x600 to 0x6f9
  4031. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  4032. function charType(code) {
  4033. if (code <= 0xf7) { return lowTypes.charAt(code) }
  4034. else if (0x590 <= code && code <= 0x5f4) { return "R" }
  4035. else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
  4036. else if (0x6ee <= code && code <= 0x8ac) { return "r" }
  4037. else if (0x2000 <= code && code <= 0x200b) { return "w" }
  4038. else if (code == 0x200c) { return "b" }
  4039. else { return "L" }
  4040. }
  4041. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  4042. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
  4043. function BidiSpan(level, from, to) {
  4044. this.level = level;
  4045. this.from = from; this.to = to;
  4046. }
  4047. return function(str, direction) {
  4048. var outerType = direction == "ltr" ? "L" : "R";
  4049. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
  4050. var len = str.length, types = [];
  4051. for (var i = 0; i < len; ++i)
  4052. { types.push(charType(str.charCodeAt(i))); }
  4053. // W1. Examine each non-spacing mark (NSM) in the level run, and
  4054. // change the type of the NSM to the type of the previous
  4055. // character. If the NSM is at the start of the level run, it will
  4056. // get the type of sor.
  4057. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  4058. var type = types[i$1];
  4059. if (type == "m") { types[i$1] = prev; }
  4060. else { prev = type; }
  4061. }
  4062. // W2. Search backwards from each instance of a European number
  4063. // until the first strong type (R, L, AL, or sor) is found. If an
  4064. // AL is found, change the type of the European number to Arabic
  4065. // number.
  4066. // W3. Change all ALs to R.
  4067. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  4068. var type$1 = types[i$2];
  4069. if (type$1 == "1" && cur == "r") { types[i$2] = "n"; }
  4070. else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } }
  4071. }
  4072. // W4. A single European separator between two European numbers
  4073. // changes to a European number. A single common separator between
  4074. // two numbers of the same type changes to that type.
  4075. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  4076. var type$2 = types[i$3];
  4077. if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; }
  4078. else if (type$2 == "," && prev$1 == types[i$3+1] &&
  4079. (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; }
  4080. prev$1 = type$2;
  4081. }
  4082. // W5. A sequence of European terminators adjacent to European
  4083. // numbers changes to all European numbers.
  4084. // W6. Otherwise, separators and terminators change to Other
  4085. // Neutral.
  4086. for (var i$4 = 0; i$4 < len; ++i$4) {
  4087. var type$3 = types[i$4];
  4088. if (type$3 == ",") { types[i$4] = "N"; }
  4089. else if (type$3 == "%") {
  4090. var end = (void 0);
  4091. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  4092. var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
  4093. for (var j = i$4; j < end; ++j) { types[j] = replace; }
  4094. i$4 = end - 1;
  4095. }
  4096. }
  4097. // W7. Search backwards from each instance of a European number
  4098. // until the first strong type (R, L, or sor) is found. If an L is
  4099. // found, then change the type of the European number to L.
  4100. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  4101. var type$4 = types[i$5];
  4102. if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; }
  4103. else if (isStrong.test(type$4)) { cur$1 = type$4; }
  4104. }
  4105. // N1. A sequence of neutrals takes the direction of the
  4106. // surrounding strong text if the text on both sides has the same
  4107. // direction. European and Arabic numbers act as if they were R in
  4108. // terms of their influence on neutrals. Start-of-level-run (sor)
  4109. // and end-of-level-run (eor) are used at level run boundaries.
  4110. // N2. Any remaining neutrals take the embedding direction.
  4111. for (var i$6 = 0; i$6 < len; ++i$6) {
  4112. if (isNeutral.test(types[i$6])) {
  4113. var end$1 = (void 0);
  4114. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  4115. var before = (i$6 ? types[i$6-1] : outerType) == "L";
  4116. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  4117. var replace$1 = before == after ? (before ? "L" : "R") : outerType;
  4118. for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }
  4119. i$6 = end$1 - 1;
  4120. }
  4121. }
  4122. // Here we depart from the documented algorithm, in order to avoid
  4123. // building up an actual levels array. Since there are only three
  4124. // levels (0, 1, 2) in an implementation that doesn't take
  4125. // explicit embedding into account, we can build up the order on
  4126. // the fly, without following the level-based algorithm.
  4127. var order = [], m;
  4128. for (var i$7 = 0; i$7 < len;) {
  4129. if (countsAsLeft.test(types[i$7])) {
  4130. var start = i$7;
  4131. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  4132. order.push(new BidiSpan(0, start, i$7));
  4133. } else {
  4134. var pos = i$7, at = order.length;
  4135. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  4136. for (var j$2 = pos; j$2 < i$7;) {
  4137. if (countsAsNum.test(types[j$2])) {
  4138. if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
  4139. var nstart = j$2;
  4140. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  4141. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  4142. pos = j$2;
  4143. } else { ++j$2; }
  4144. }
  4145. if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }
  4146. }
  4147. }
  4148. if (direction == "ltr") {
  4149. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  4150. order[0].from = m[0].length;
  4151. order.unshift(new BidiSpan(0, 0, m[0].length));
  4152. }
  4153. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  4154. lst(order).to -= m[0].length;
  4155. order.push(new BidiSpan(0, len - m[0].length, len));
  4156. }
  4157. }
  4158. return direction == "rtl" ? order.reverse() : order
  4159. }
  4160. })();
  4161. // Get the bidi ordering for the given line (and cache it). Returns
  4162. // false for lines that are fully left-to-right, and an array of
  4163. // BidiSpan objects otherwise.
  4164. function getOrder(line, direction) {
  4165. var order = line.order;
  4166. if (order == null) { order = line.order = bidiOrdering(line.text, direction); }
  4167. return order
  4168. }
  4169. // EVENT HANDLING
  4170. // Lightweight event framework. on/off also work on DOM nodes,
  4171. // registering native DOM handlers.
  4172. var noHandlers = [];
  4173. var on = function(emitter, type, f) {
  4174. if (emitter.addEventListener) {
  4175. emitter.addEventListener(type, f, false);
  4176. } else if (emitter.attachEvent) {
  4177. emitter.attachEvent("on" + type, f);
  4178. } else {
  4179. var map$$1 = emitter._handlers || (emitter._handlers = {});
  4180. map$$1[type] = (map$$1[type] || noHandlers).concat(f);
  4181. }
  4182. };
  4183. function getHandlers(emitter, type) {
  4184. return emitter._handlers && emitter._handlers[type] || noHandlers
  4185. }
  4186. function off(emitter, type, f) {
  4187. if (emitter.removeEventListener) {
  4188. emitter.removeEventListener(type, f, false);
  4189. } else if (emitter.detachEvent) {
  4190. emitter.detachEvent("on" + type, f);
  4191. } else {
  4192. var map$$1 = emitter._handlers, arr = map$$1 && map$$1[type];
  4193. if (arr) {
  4194. var index = indexOf(arr, f);
  4195. if (index > -1)
  4196. { map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }
  4197. }
  4198. }
  4199. }
  4200. function signal(emitter, type /*, values...*/) {
  4201. var handlers = getHandlers(emitter, type);
  4202. if (!handlers.length) { return }
  4203. var args = Array.prototype.slice.call(arguments, 2);
  4204. for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }
  4205. }
  4206. // The DOM events that CodeMirror handles can be overridden by
  4207. // registering a (non-DOM) handler on the editor for the event name,
  4208. // and preventDefault-ing the event in that handler.
  4209. function signalDOMEvent(cm, e, override) {
  4210. if (typeof e == "string")
  4211. { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }
  4212. signal(cm, override || e.type, cm, e);
  4213. return e_defaultPrevented(e) || e.codemirrorIgnore
  4214. }
  4215. function signalCursorActivity(cm) {
  4216. var arr = cm._handlers && cm._handlers.cursorActivity;
  4217. if (!arr) { return }
  4218. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  4219. for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
  4220. { set.push(arr[i]); } }
  4221. }
  4222. function hasHandler(emitter, type) {
  4223. return getHandlers(emitter, type).length > 0
  4224. }
  4225. // Add on and off methods to a constructor's prototype, to make
  4226. // registering events on such objects more convenient.
  4227. function eventMixin(ctor) {
  4228. ctor.prototype.on = function(type, f) {on(this, type, f);};
  4229. ctor.prototype.off = function(type, f) {off(this, type, f);};
  4230. }
  4231. // Due to the fact that we still support jurassic IE versions, some
  4232. // compatibility wrappers are needed.
  4233. function e_preventDefault(e) {
  4234. if (e.preventDefault) { e.preventDefault(); }
  4235. else { e.returnValue = false; }
  4236. }
  4237. function e_stopPropagation(e) {
  4238. if (e.stopPropagation) { e.stopPropagation(); }
  4239. else { e.cancelBubble = true; }
  4240. }
  4241. function e_defaultPrevented(e) {
  4242. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
  4243. }
  4244. function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
  4245. function e_target(e) {return e.target || e.srcElement}
  4246. function e_button(e) {
  4247. var b = e.which;
  4248. if (b == null) {
  4249. if (e.button & 1) { b = 1; }
  4250. else if (e.button & 2) { b = 3; }
  4251. else if (e.button & 4) { b = 2; }
  4252. }
  4253. if (mac && e.ctrlKey && b == 1) { b = 3; }
  4254. return b
  4255. }
  4256. // Detect drag-and-drop
  4257. var dragAndDrop = function() {
  4258. // There is *some* kind of drag-and-drop support in IE6-8, but I
  4259. // couldn't get it to work yet.
  4260. if (ie && ie_version < 9) { return false }
  4261. var div = elt('div');
  4262. return "draggable" in div || "dragDrop" in div
  4263. }();
  4264. var zwspSupported;
  4265. function zeroWidthElement(measure) {
  4266. if (zwspSupported == null) {
  4267. var test = elt("span", "\u200b");
  4268. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  4269. if (measure.firstChild.offsetHeight != 0)
  4270. { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }
  4271. }
  4272. var node = zwspSupported ? elt("span", "\u200b") :
  4273. elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
  4274. node.setAttribute("cm-text", "");
  4275. return node
  4276. }
  4277. // Feature-detect IE's crummy client rect reporting for bidi text
  4278. var badBidiRects;
  4279. function hasBadBidiRects(measure) {
  4280. if (badBidiRects != null) { return badBidiRects }
  4281. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
  4282. var r0 = range(txt, 0, 1).getBoundingClientRect();
  4283. var r1 = range(txt, 1, 2).getBoundingClientRect();
  4284. removeChildren(measure);
  4285. if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
  4286. return badBidiRects = (r1.right - r0.right < 3)
  4287. }
  4288. // See if "".split is the broken IE version, if so, provide an
  4289. // alternative way to split lines.
  4290. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  4291. var pos = 0, result = [], l = string.length;
  4292. while (pos <= l) {
  4293. var nl = string.indexOf("\n", pos);
  4294. if (nl == -1) { nl = string.length; }
  4295. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  4296. var rt = line.indexOf("\r");
  4297. if (rt != -1) {
  4298. result.push(line.slice(0, rt));
  4299. pos += rt + 1;
  4300. } else {
  4301. result.push(line);
  4302. pos = nl + 1;
  4303. }
  4304. }
  4305. return result
  4306. } : function (string) { return string.split(/\r\n?|\n/); };
  4307. var hasSelection = window.getSelection ? function (te) {
  4308. try { return te.selectionStart != te.selectionEnd }
  4309. catch(e) { return false }
  4310. } : function (te) {
  4311. var range$$1;
  4312. try {range$$1 = te.ownerDocument.selection.createRange();}
  4313. catch(e) {}
  4314. if (!range$$1 || range$$1.parentElement() != te) { return false }
  4315. return range$$1.compareEndPoints("StartToEnd", range$$1) != 0
  4316. };
  4317. var hasCopyEvent = (function () {
  4318. var e = elt("div");
  4319. if ("oncopy" in e) { return true }
  4320. e.setAttribute("oncopy", "return;");
  4321. return typeof e.oncopy == "function"
  4322. })();
  4323. var badZoomedRects = null;
  4324. function hasBadZoomedRects(measure) {
  4325. if (badZoomedRects != null) { return badZoomedRects }
  4326. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  4327. var normal = node.getBoundingClientRect();
  4328. var fromRange = range(node, 0, 1).getBoundingClientRect();
  4329. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
  4330. }
  4331. // Known modes, by name and by MIME
  4332. var modes = {}, mimeModes = {};
  4333. // Extra arguments are stored as the mode's dependencies, which is
  4334. // used by (legacy) mechanisms like loadmode.js to automatically
  4335. // load a mode. (Preferred mechanism is the require/define calls.)
  4336. function defineMode(name, mode) {
  4337. if (arguments.length > 2)
  4338. { mode.dependencies = Array.prototype.slice.call(arguments, 2); }
  4339. modes[name] = mode;
  4340. }
  4341. function defineMIME(mime, spec) {
  4342. mimeModes[mime] = spec;
  4343. }
  4344. // Given a MIME type, a {name, ...options} config object, or a name
  4345. // string, return a mode config object.
  4346. function resolveMode(spec) {
  4347. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  4348. spec = mimeModes[spec];
  4349. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  4350. var found = mimeModes[spec.name];
  4351. if (typeof found == "string") { found = {name: found}; }
  4352. spec = createObj(found, spec);
  4353. spec.name = found.name;
  4354. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  4355. return resolveMode("application/xml")
  4356. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  4357. return resolveMode("application/json")
  4358. }
  4359. if (typeof spec == "string") { return {name: spec} }
  4360. else { return spec || {name: "null"} }
  4361. }
  4362. // Given a mode spec (anything that resolveMode accepts), find and
  4363. // initialize an actual mode object.
  4364. function getMode(options, spec) {
  4365. spec = resolveMode(spec);
  4366. var mfactory = modes[spec.name];
  4367. if (!mfactory) { return getMode(options, "text/plain") }
  4368. var modeObj = mfactory(options, spec);
  4369. if (modeExtensions.hasOwnProperty(spec.name)) {
  4370. var exts = modeExtensions[spec.name];
  4371. for (var prop in exts) {
  4372. if (!exts.hasOwnProperty(prop)) { continue }
  4373. if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; }
  4374. modeObj[prop] = exts[prop];
  4375. }
  4376. }
  4377. modeObj.name = spec.name;
  4378. if (spec.helperType) { modeObj.helperType = spec.helperType; }
  4379. if (spec.modeProps) { for (var prop$1 in spec.modeProps)
  4380. { modeObj[prop$1] = spec.modeProps[prop$1]; } }
  4381. return modeObj
  4382. }
  4383. // This can be used to attach properties to mode objects from
  4384. // outside the actual mode definition.
  4385. var modeExtensions = {};
  4386. function extendMode(mode, properties) {
  4387. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
  4388. copyObj(properties, exts);
  4389. }
  4390. function copyState(mode, state) {
  4391. if (state === true) { return state }
  4392. if (mode.copyState) { return mode.copyState(state) }
  4393. var nstate = {};
  4394. for (var n in state) {
  4395. var val = state[n];
  4396. if (val instanceof Array) { val = val.concat([]); }
  4397. nstate[n] = val;
  4398. }
  4399. return nstate
  4400. }
  4401. // Given a mode and a state (for that mode), find the inner mode and
  4402. // state at the position that the state refers to.
  4403. function innerMode(mode, state) {
  4404. var info;
  4405. while (mode.innerMode) {
  4406. info = mode.innerMode(state);
  4407. if (!info || info.mode == mode) { break }
  4408. state = info.state;
  4409. mode = info.mode;
  4410. }
  4411. return info || {mode: mode, state: state}
  4412. }
  4413. function startState(mode, a1, a2) {
  4414. return mode.startState ? mode.startState(a1, a2) : true
  4415. }
  4416. // STRING STREAM
  4417. // Fed to the mode parsers, provides helper functions to make
  4418. // parsers more succinct.
  4419. var StringStream = function(string, tabSize, lineOracle) {
  4420. this.pos = this.start = 0;
  4421. this.string = string;
  4422. this.tabSize = tabSize || 8;
  4423. this.lastColumnPos = this.lastColumnValue = 0;
  4424. this.lineStart = 0;
  4425. this.lineOracle = lineOracle;
  4426. };
  4427. StringStream.prototype.eol = function () {return this.pos >= this.string.length};
  4428. StringStream.prototype.sol = function () {return this.pos == this.lineStart};
  4429. StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
  4430. StringStream.prototype.next = function () {
  4431. if (this.pos < this.string.length)
  4432. { return this.string.charAt(this.pos++) }
  4433. };
  4434. StringStream.prototype.eat = function (match) {
  4435. var ch = this.string.charAt(this.pos);
  4436. var ok;
  4437. if (typeof match == "string") { ok = ch == match; }
  4438. else { ok = ch && (match.test ? match.test(ch) : match(ch)); }
  4439. if (ok) {++this.pos; return ch}
  4440. };
  4441. StringStream.prototype.eatWhile = function (match) {
  4442. var start = this.pos;
  4443. while (this.eat(match)){}
  4444. return this.pos > start
  4445. };
  4446. StringStream.prototype.eatSpace = function () {
  4447. var this$1 = this;
  4448. var start = this.pos;
  4449. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos; }
  4450. return this.pos > start
  4451. };
  4452. StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};
  4453. StringStream.prototype.skipTo = function (ch) {
  4454. var found = this.string.indexOf(ch, this.pos);
  4455. if (found > -1) {this.pos = found; return true}
  4456. };
  4457. StringStream.prototype.backUp = function (n) {this.pos -= n;};
  4458. StringStream.prototype.column = function () {
  4459. if (this.lastColumnPos < this.start) {
  4460. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  4461. this.lastColumnPos = this.start;
  4462. }
  4463. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  4464. };
  4465. StringStream.prototype.indentation = function () {
  4466. return countColumn(this.string, null, this.tabSize) -
  4467. (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  4468. };
  4469. StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
  4470. if (typeof pattern == "string") {
  4471. var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };
  4472. var substr = this.string.substr(this.pos, pattern.length);
  4473. if (cased(substr) == cased(pattern)) {
  4474. if (consume !== false) { this.pos += pattern.length; }
  4475. return true
  4476. }
  4477. } else {
  4478. var match = this.string.slice(this.pos).match(pattern);
  4479. if (match && match.index > 0) { return null }
  4480. if (match && consume !== false) { this.pos += match[0].length; }
  4481. return match
  4482. }
  4483. };
  4484. StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
  4485. StringStream.prototype.hideFirstChars = function (n, inner) {
  4486. this.lineStart += n;
  4487. try { return inner() }
  4488. finally { this.lineStart -= n; }
  4489. };
  4490. StringStream.prototype.lookAhead = function (n) {
  4491. var oracle = this.lineOracle;
  4492. return oracle && oracle.lookAhead(n)
  4493. };
  4494. StringStream.prototype.baseToken = function () {
  4495. var oracle = this.lineOracle;
  4496. return oracle && oracle.baseToken(this.pos)
  4497. };
  4498. // Find the line object corresponding to the given line number.
  4499. function getLine(doc, n) {
  4500. n -= doc.first;
  4501. if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
  4502. var chunk = doc;
  4503. while (!chunk.lines) {
  4504. for (var i = 0;; ++i) {
  4505. var child = chunk.children[i], sz = child.chunkSize();
  4506. if (n < sz) { chunk = child; break }
  4507. n -= sz;
  4508. }
  4509. }
  4510. return chunk.lines[n]
  4511. }
  4512. // Get the part of a document between two positions, as an array of
  4513. // strings.
  4514. function getBetween(doc, start, end) {
  4515. var out = [], n = start.line;
  4516. doc.iter(start.line, end.line + 1, function (line) {
  4517. var text = line.text;
  4518. if (n == end.line) { text = text.slice(0, end.ch); }
  4519. if (n == start.line) { text = text.slice(start.ch); }
  4520. out.push(text);
  4521. ++n;
  4522. });
  4523. return out
  4524. }
  4525. // Get the lines between from and to, as array of strings.
  4526. function getLines(doc, from, to) {
  4527. var out = [];
  4528. doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value
  4529. return out
  4530. }
  4531. // Update the height of a line, propagating the height change
  4532. // upwards to parent nodes.
  4533. function updateLineHeight(line, height) {
  4534. var diff = height - line.height;
  4535. if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }
  4536. }
  4537. // Given a line object, find its line number by walking up through
  4538. // its parent links.
  4539. function lineNo(line) {
  4540. if (line.parent == null) { return null }
  4541. var cur = line.parent, no = indexOf(cur.lines, line);
  4542. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  4543. for (var i = 0;; ++i) {
  4544. if (chunk.children[i] == cur) { break }
  4545. no += chunk.children[i].chunkSize();
  4546. }
  4547. }
  4548. return no + cur.first
  4549. }
  4550. // Find the line at the given vertical position, using the height
  4551. // information in the document tree.
  4552. function lineAtHeight(chunk, h) {
  4553. var n = chunk.first;
  4554. outer: do {
  4555. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  4556. var child = chunk.children[i$1], ch = child.height;
  4557. if (h < ch) { chunk = child; continue outer }
  4558. h -= ch;
  4559. n += child.chunkSize();
  4560. }
  4561. return n
  4562. } while (!chunk.lines)
  4563. var i = 0;
  4564. for (; i < chunk.lines.length; ++i) {
  4565. var line = chunk.lines[i], lh = line.height;
  4566. if (h < lh) { break }
  4567. h -= lh;
  4568. }
  4569. return n + i
  4570. }
  4571. function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
  4572. function lineNumberFor(options, i) {
  4573. return String(options.lineNumberFormatter(i + options.firstLineNumber))
  4574. }
  4575. // A Pos instance represents a position within the text.
  4576. function Pos(line, ch, sticky) {
  4577. if ( sticky === void 0 ) sticky = null;
  4578. if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
  4579. this.line = line;
  4580. this.ch = ch;
  4581. this.sticky = sticky;
  4582. }
  4583. // Compare two positions, return 0 if they are the same, a negative
  4584. // number when a is less, and a positive number otherwise.
  4585. function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
  4586. function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
  4587. function copyPos(x) {return Pos(x.line, x.ch)}
  4588. function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
  4589. function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
  4590. // Most of the external API clips given positions to make sure they
  4591. // actually exist within the document.
  4592. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
  4593. function clipPos(doc, pos) {
  4594. if (pos.line < doc.first) { return Pos(doc.first, 0) }
  4595. var last = doc.first + doc.size - 1;
  4596. if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
  4597. return clipToLen(pos, getLine(doc, pos.line).text.length)
  4598. }
  4599. function clipToLen(pos, linelen) {
  4600. var ch = pos.ch;
  4601. if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
  4602. else if (ch < 0) { return Pos(pos.line, 0) }
  4603. else { return pos }
  4604. }
  4605. function clipPosArray(doc, array) {
  4606. var out = [];
  4607. for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }
  4608. return out
  4609. }
  4610. var SavedContext = function(state, lookAhead) {
  4611. this.state = state;
  4612. this.lookAhead = lookAhead;
  4613. };
  4614. var Context = function(doc, state, line, lookAhead) {
  4615. this.state = state;
  4616. this.doc = doc;
  4617. this.line = line;
  4618. this.maxLookAhead = lookAhead || 0;
  4619. this.baseTokens = null;
  4620. this.baseTokenPos = 1;
  4621. };
  4622. Context.prototype.lookAhead = function (n) {
  4623. var line = this.doc.getLine(this.line + n);
  4624. if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }
  4625. return line
  4626. };
  4627. Context.prototype.baseToken = function (n) {
  4628. var this$1 = this;
  4629. if (!this.baseTokens) { return null }
  4630. while (this.baseTokens[this.baseTokenPos] <= n)
  4631. { this$1.baseTokenPos += 2; }
  4632. var type = this.baseTokens[this.baseTokenPos + 1];
  4633. return {type: type && type.replace(/( |^)overlay .*/, ""),
  4634. size: this.baseTokens[this.baseTokenPos] - n}
  4635. };
  4636. Context.prototype.nextLine = function () {
  4637. this.line++;
  4638. if (this.maxLookAhead > 0) { this.maxLookAhead--; }
  4639. };
  4640. Context.fromSaved = function (doc, saved, line) {
  4641. if (saved instanceof SavedContext)
  4642. { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
  4643. else
  4644. { return new Context(doc, copyState(doc.mode, saved), line) }
  4645. };
  4646. Context.prototype.save = function (copy) {
  4647. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  4648. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
  4649. };
  4650. // Compute a style array (an array starting with a mode generation
  4651. // -- for invalidation -- followed by pairs of end positions and
  4652. // style strings), which is used to highlight the tokens on the
  4653. // line.
  4654. function highlightLine(cm, line, context, forceToEnd) {
  4655. // A styles array always starts with a number identifying the
  4656. // mode/overlays that it is based on (for easy invalidation).
  4657. var st = [cm.state.modeGen], lineClasses = {};
  4658. // Compute the base array of styles
  4659. runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
  4660. lineClasses, forceToEnd);
  4661. var state = context.state;
  4662. // Run overlays, adjust style array.
  4663. var loop = function ( o ) {
  4664. context.baseTokens = st;
  4665. var overlay = cm.state.overlays[o], i = 1, at = 0;
  4666. context.state = true;
  4667. runMode(cm, line.text, overlay.mode, context, function (end, style) {
  4668. var start = i;
  4669. // Ensure there's a token end at the current position, and that i points at it
  4670. while (at < end) {
  4671. var i_end = st[i];
  4672. if (i_end > end)
  4673. { st.splice(i, 1, end, st[i+1], i_end); }
  4674. i += 2;
  4675. at = Math.min(end, i_end);
  4676. }
  4677. if (!style) { return }
  4678. if (overlay.opaque) {
  4679. st.splice(start, i - start, end, "overlay " + style);
  4680. i = start + 2;
  4681. } else {
  4682. for (; start < i; start += 2) {
  4683. var cur = st[start+1];
  4684. st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
  4685. }
  4686. }
  4687. }, lineClasses);
  4688. context.state = state;
  4689. context.baseTokens = null;
  4690. context.baseTokenPos = 1;
  4691. };
  4692. for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
  4693. return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
  4694. }
  4695. function getLineStyles(cm, line, updateFrontier) {
  4696. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  4697. var context = getContextBefore(cm, lineNo(line));
  4698. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  4699. var result = highlightLine(cm, line, context);
  4700. if (resetState) { context.state = resetState; }
  4701. line.stateAfter = context.save(!resetState);
  4702. line.styles = result.styles;
  4703. if (result.classes) { line.styleClasses = result.classes; }
  4704. else if (line.styleClasses) { line.styleClasses = null; }
  4705. if (updateFrontier === cm.doc.highlightFrontier)
  4706. { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
  4707. }
  4708. return line.styles
  4709. }
  4710. function getContextBefore(cm, n, precise) {
  4711. var doc = cm.doc, display = cm.display;
  4712. if (!doc.mode.startState) { return new Context(doc, true, n) }
  4713. var start = findStartLine(cm, n, precise);
  4714. var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
  4715. var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
  4716. doc.iter(start, n, function (line) {
  4717. processLine(cm, line.text, context);
  4718. var pos = context.line;
  4719. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  4720. context.nextLine();
  4721. });
  4722. if (precise) { doc.modeFrontier = context.line; }
  4723. return context
  4724. }
  4725. // Lightweight form of highlight -- proceed over this line and
  4726. // update state, but don't save a style array. Used for lines that
  4727. // aren't currently visible.
  4728. function processLine(cm, text, context, startAt) {
  4729. var mode = cm.doc.mode;
  4730. var stream = new StringStream(text, cm.options.tabSize, context);
  4731. stream.start = stream.pos = startAt || 0;
  4732. if (text == "") { callBlankLine(mode, context.state); }
  4733. while (!stream.eol()) {
  4734. readToken(mode, stream, context.state);
  4735. stream.start = stream.pos;
  4736. }
  4737. }
  4738. function callBlankLine(mode, state) {
  4739. if (mode.blankLine) { return mode.blankLine(state) }
  4740. if (!mode.innerMode) { return }
  4741. var inner = innerMode(mode, state);
  4742. if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
  4743. }
  4744. function readToken(mode, stream, state, inner) {
  4745. for (var i = 0; i < 10; i++) {
  4746. if (inner) { inner[0] = innerMode(mode, state).mode; }
  4747. var style = mode.token(stream, state);
  4748. if (stream.pos > stream.start) { return style }
  4749. }
  4750. throw new Error("Mode " + mode.name + " failed to advance stream.")
  4751. }
  4752. var Token = function(stream, type, state) {
  4753. this.start = stream.start; this.end = stream.pos;
  4754. this.string = stream.current();
  4755. this.type = type || null;
  4756. this.state = state;
  4757. };
  4758. // Utility for getTokenAt and getLineTokens
  4759. function takeToken(cm, pos, precise, asArray) {
  4760. var doc = cm.doc, mode = doc.mode, style;
  4761. pos = clipPos(doc, pos);
  4762. var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
  4763. var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
  4764. if (asArray) { tokens = []; }
  4765. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  4766. stream.start = stream.pos;
  4767. style = readToken(mode, stream, context.state);
  4768. if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
  4769. }
  4770. return asArray ? tokens : new Token(stream, style, context.state)
  4771. }
  4772. function extractLineClasses(type, output) {
  4773. if (type) { for (;;) {
  4774. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  4775. if (!lineClass) { break }
  4776. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  4777. var prop = lineClass[1] ? "bgClass" : "textClass";
  4778. if (output[prop] == null)
  4779. { output[prop] = lineClass[2]; }
  4780. else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
  4781. { output[prop] += " " + lineClass[2]; }
  4782. } }
  4783. return type
  4784. }
  4785. // Run the given mode's parser over a line, calling f for each token.
  4786. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  4787. var flattenSpans = mode.flattenSpans;
  4788. if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
  4789. var curStart = 0, curStyle = null;
  4790. var stream = new StringStream(text, cm.options.tabSize, context), style;
  4791. var inner = cm.options.addModeClass && [null];
  4792. if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
  4793. while (!stream.eol()) {
  4794. if (stream.pos > cm.options.maxHighlightLength) {
  4795. flattenSpans = false;
  4796. if (forceToEnd) { processLine(cm, text, context, stream.pos); }
  4797. stream.pos = text.length;
  4798. style = null;
  4799. } else {
  4800. style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  4801. }
  4802. if (inner) {
  4803. var mName = inner[0].name;
  4804. if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
  4805. }
  4806. if (!flattenSpans || curStyle != style) {
  4807. while (curStart < stream.start) {
  4808. curStart = Math.min(stream.start, curStart + 5000);
  4809. f(curStart, curStyle);
  4810. }
  4811. curStyle = style;
  4812. }
  4813. stream.start = stream.pos;
  4814. }
  4815. while (curStart < stream.pos) {
  4816. // Webkit seems to refuse to render text nodes longer than 57444
  4817. // characters, and returns inaccurate measurements in nodes
  4818. // starting around 5000 chars.
  4819. var pos = Math.min(stream.pos, curStart + 5000);
  4820. f(pos, curStyle);
  4821. curStart = pos;
  4822. }
  4823. }
  4824. // Finds the line to start with when starting a parse. Tries to
  4825. // find a line with a stateAfter, so that it can start with a
  4826. // valid state. If that fails, it returns the line with the
  4827. // smallest indentation, which tends to need the least context to
  4828. // parse correctly.
  4829. function findStartLine(cm, n, precise) {
  4830. var minindent, minline, doc = cm.doc;
  4831. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
  4832. for (var search = n; search > lim; --search) {
  4833. if (search <= doc.first) { return doc.first }
  4834. var line = getLine(doc, search - 1), after = line.stateAfter;
  4835. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
  4836. { return search }
  4837. var indented = countColumn(line.text, null, cm.options.tabSize);
  4838. if (minline == null || minindent > indented) {
  4839. minline = search - 1;
  4840. minindent = indented;
  4841. }
  4842. }
  4843. return minline
  4844. }
  4845. function retreatFrontier(doc, n) {
  4846. doc.modeFrontier = Math.min(doc.modeFrontier, n);
  4847. if (doc.highlightFrontier < n - 10) { return }
  4848. var start = doc.first;
  4849. for (var line = n - 1; line > start; line--) {
  4850. var saved = getLine(doc, line).stateAfter;
  4851. // change is on 3
  4852. // state on line 1 looked ahead 2 -- so saw 3
  4853. // test 1 + 2 < 3 should cover this
  4854. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  4855. start = line + 1;
  4856. break
  4857. }
  4858. }
  4859. doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
  4860. }
  4861. // Optimize some code when these features are not used.
  4862. var sawReadOnlySpans = false, sawCollapsedSpans = false;
  4863. function seeReadOnlySpans() {
  4864. sawReadOnlySpans = true;
  4865. }
  4866. function seeCollapsedSpans() {
  4867. sawCollapsedSpans = true;
  4868. }
  4869. // TEXTMARKER SPANS
  4870. function MarkedSpan(marker, from, to) {
  4871. this.marker = marker;
  4872. this.from = from; this.to = to;
  4873. }
  4874. // Search an array of spans for a span matching the given marker.
  4875. function getMarkedSpanFor(spans, marker) {
  4876. if (spans) { for (var i = 0; i < spans.length; ++i) {
  4877. var span = spans[i];
  4878. if (span.marker == marker) { return span }
  4879. } }
  4880. }
  4881. // Remove a span from an array, returning undefined if no spans are
  4882. // left (we don't store arrays for lines without spans).
  4883. function removeMarkedSpan(spans, span) {
  4884. var r;
  4885. for (var i = 0; i < spans.length; ++i)
  4886. { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
  4887. return r
  4888. }
  4889. // Add a span to a line.
  4890. function addMarkedSpan(line, span) {
  4891. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  4892. span.marker.attachLine(line);
  4893. }
  4894. // Used for the algorithm that adjusts markers for a change in the
  4895. // document. These functions cut an array of spans at a given
  4896. // character position, returning an array of remaining chunks (or
  4897. // undefined if nothing remains).
  4898. function markedSpansBefore(old, startCh, isInsert) {
  4899. var nw;
  4900. if (old) { for (var i = 0; i < old.length; ++i) {
  4901. var span = old[i], marker = span.marker;
  4902. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  4903. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  4904. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
  4905. ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  4906. }
  4907. } }
  4908. return nw
  4909. }
  4910. function markedSpansAfter(old, endCh, isInsert) {
  4911. var nw;
  4912. if (old) { for (var i = 0; i < old.length; ++i) {
  4913. var span = old[i], marker = span.marker;
  4914. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  4915. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  4916. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
  4917. ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
  4918. span.to == null ? null : span.to - endCh));
  4919. }
  4920. } }
  4921. return nw
  4922. }
  4923. // Given a change object, compute the new set of marker spans that
  4924. // cover the line in which the change took place. Removes spans
  4925. // entirely within the change, reconnects spans belonging to the
  4926. // same marker that appear on both sides of the change, and cuts off
  4927. // spans partially within the change. Returns an array of span
  4928. // arrays with one element for each line in (after) the change.
  4929. function stretchSpansOverChange(doc, change) {
  4930. if (change.full) { return null }
  4931. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
  4932. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
  4933. if (!oldFirst && !oldLast) { return null }
  4934. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
  4935. // Get the spans that 'stick out' on both sides
  4936. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  4937. var last = markedSpansAfter(oldLast, endCh, isInsert);
  4938. // Next, merge those two ends
  4939. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
  4940. if (first) {
  4941. // Fix up .to properties of first
  4942. for (var i = 0; i < first.length; ++i) {
  4943. var span = first[i];
  4944. if (span.to == null) {
  4945. var found = getMarkedSpanFor(last, span.marker);
  4946. if (!found) { span.to = startCh; }
  4947. else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }
  4948. }
  4949. }
  4950. }
  4951. if (last) {
  4952. // Fix up .from in last (or move them into first in case of sameLine)
  4953. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  4954. var span$1 = last[i$1];
  4955. if (span$1.to != null) { span$1.to += offset; }
  4956. if (span$1.from == null) {
  4957. var found$1 = getMarkedSpanFor(first, span$1.marker);
  4958. if (!found$1) {
  4959. span$1.from = offset;
  4960. if (sameLine) { (first || (first = [])).push(span$1); }
  4961. }
  4962. } else {
  4963. span$1.from += offset;
  4964. if (sameLine) { (first || (first = [])).push(span$1); }
  4965. }
  4966. }
  4967. }
  4968. // Make sure we didn't create any zero-length spans
  4969. if (first) { first = clearEmptySpans(first); }
  4970. if (last && last != first) { last = clearEmptySpans(last); }
  4971. var newMarkers = [first];
  4972. if (!sameLine) {
  4973. // Fill gap with whole-line-spans
  4974. var gap = change.text.length - 2, gapMarkers;
  4975. if (gap > 0 && first)
  4976. { for (var i$2 = 0; i$2 < first.length; ++i$2)
  4977. { if (first[i$2].to == null)
  4978. { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }
  4979. for (var i$3 = 0; i$3 < gap; ++i$3)
  4980. { newMarkers.push(gapMarkers); }
  4981. newMarkers.push(last);
  4982. }
  4983. return newMarkers
  4984. }
  4985. // Remove spans that are empty and don't have a clearWhenEmpty
  4986. // option of false.
  4987. function clearEmptySpans(spans) {
  4988. for (var i = 0; i < spans.length; ++i) {
  4989. var span = spans[i];
  4990. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
  4991. { spans.splice(i--, 1); }
  4992. }
  4993. if (!spans.length) { return null }
  4994. return spans
  4995. }
  4996. // Used to 'clip' out readOnly ranges when making a change.
  4997. function removeReadOnlyRanges(doc, from, to) {
  4998. var markers = null;
  4999. doc.iter(from.line, to.line + 1, function (line) {
  5000. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  5001. var mark = line.markedSpans[i].marker;
  5002. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
  5003. { (markers || (markers = [])).push(mark); }
  5004. } }
  5005. });
  5006. if (!markers) { return null }
  5007. var parts = [{from: from, to: to}];
  5008. for (var i = 0; i < markers.length; ++i) {
  5009. var mk = markers[i], m = mk.find(0);
  5010. for (var j = 0; j < parts.length; ++j) {
  5011. var p = parts[j];
  5012. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
  5013. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
  5014. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
  5015. { newParts.push({from: p.from, to: m.from}); }
  5016. if (dto > 0 || !mk.inclusiveRight && !dto)
  5017. { newParts.push({from: m.to, to: p.to}); }
  5018. parts.splice.apply(parts, newParts);
  5019. j += newParts.length - 3;
  5020. }
  5021. }
  5022. return parts
  5023. }
  5024. // Connect or disconnect spans from a line.
  5025. function detachMarkedSpans(line) {
  5026. var spans = line.markedSpans;
  5027. if (!spans) { return }
  5028. for (var i = 0; i < spans.length; ++i)
  5029. { spans[i].marker.detachLine(line); }
  5030. line.markedSpans = null;
  5031. }
  5032. function attachMarkedSpans(line, spans) {
  5033. if (!spans) { return }
  5034. for (var i = 0; i < spans.length; ++i)
  5035. { spans[i].marker.attachLine(line); }
  5036. line.markedSpans = spans;
  5037. }
  5038. // Helpers used when computing which overlapping collapsed span
  5039. // counts as the larger one.
  5040. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
  5041. function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
  5042. // Returns a number indicating which of two overlapping collapsed
  5043. // spans is larger (and thus includes the other). Falls back to
  5044. // comparing ids when the spans cover exactly the same range.
  5045. function compareCollapsedMarkers(a, b) {
  5046. var lenDiff = a.lines.length - b.lines.length;
  5047. if (lenDiff != 0) { return lenDiff }
  5048. var aPos = a.find(), bPos = b.find();
  5049. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  5050. if (fromCmp) { return -fromCmp }
  5051. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  5052. if (toCmp) { return toCmp }
  5053. return b.id - a.id
  5054. }
  5055. // Find out whether a line ends or starts in a collapsed span. If
  5056. // so, return the marker for that span.
  5057. function collapsedSpanAtSide(line, start) {
  5058. var sps = sawCollapsedSpans && line.markedSpans, found;
  5059. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  5060. sp = sps[i];
  5061. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
  5062. (!found || compareCollapsedMarkers(found, sp.marker) < 0))
  5063. { found = sp.marker; }
  5064. } }
  5065. return found
  5066. }
  5067. function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
  5068. function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
  5069. function collapsedSpanAround(line, ch) {
  5070. var sps = sawCollapsedSpans && line.markedSpans, found;
  5071. if (sps) { for (var i = 0; i < sps.length; ++i) {
  5072. var sp = sps[i];
  5073. if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) &&
  5074. (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; }
  5075. } }
  5076. return found
  5077. }
  5078. // Test whether there exists a collapsed span that partially
  5079. // overlaps (covers the start or end, but not both) of a new span.
  5080. // Such overlap is not allowed.
  5081. function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {
  5082. var line = getLine(doc, lineNo$$1);
  5083. var sps = sawCollapsedSpans && line.markedSpans;
  5084. if (sps) { for (var i = 0; i < sps.length; ++i) {
  5085. var sp = sps[i];
  5086. if (!sp.marker.collapsed) { continue }
  5087. var found = sp.marker.find(0);
  5088. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  5089. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  5090. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
  5091. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
  5092. fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
  5093. { return true }
  5094. } }
  5095. }
  5096. // A visual line is a line as drawn on the screen. Folding, for
  5097. // example, can cause multiple logical lines to appear on the same
  5098. // visual line. This finds the start of the visual line that the
  5099. // given line is part of (usually that is the line itself).
  5100. function visualLine(line) {
  5101. var merged;
  5102. while (merged = collapsedSpanAtStart(line))
  5103. { line = merged.find(-1, true).line; }
  5104. return line
  5105. }
  5106. function visualLineEnd(line) {
  5107. var merged;
  5108. while (merged = collapsedSpanAtEnd(line))
  5109. { line = merged.find(1, true).line; }
  5110. return line
  5111. }
  5112. // Returns an array of logical lines that continue the visual line
  5113. // started by the argument, or undefined if there are no such lines.
  5114. function visualLineContinued(line) {
  5115. var merged, lines;
  5116. while (merged = collapsedSpanAtEnd(line)) {
  5117. line = merged.find(1, true).line
  5118. ;(lines || (lines = [])).push(line);
  5119. }
  5120. return lines
  5121. }
  5122. // Get the line number of the start of the visual line that the
  5123. // given line number is part of.
  5124. function visualLineNo(doc, lineN) {
  5125. var line = getLine(doc, lineN), vis = visualLine(line);
  5126. if (line == vis) { return lineN }
  5127. return lineNo(vis)
  5128. }
  5129. // Get the line number of the start of the next visual line after
  5130. // the given line.
  5131. function visualLineEndNo(doc, lineN) {
  5132. if (lineN > doc.lastLine()) { return lineN }
  5133. var line = getLine(doc, lineN), merged;
  5134. if (!lineIsHidden(doc, line)) { return lineN }
  5135. while (merged = collapsedSpanAtEnd(line))
  5136. { line = merged.find(1, true).line; }
  5137. return lineNo(line) + 1
  5138. }
  5139. // Compute whether a line is hidden. Lines count as hidden when they
  5140. // are part of a visual line that starts with another line, or when
  5141. // they are entirely covered by collapsed, non-widget span.
  5142. function lineIsHidden(doc, line) {
  5143. var sps = sawCollapsedSpans && line.markedSpans;
  5144. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  5145. sp = sps[i];
  5146. if (!sp.marker.collapsed) { continue }
  5147. if (sp.from == null) { return true }
  5148. if (sp.marker.widgetNode) { continue }
  5149. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
  5150. { return true }
  5151. } }
  5152. }
  5153. function lineIsHiddenInner(doc, line, span) {
  5154. if (span.to == null) {
  5155. var end = span.marker.find(1, true);
  5156. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
  5157. }
  5158. if (span.marker.inclusiveRight && span.to == line.text.length)
  5159. { return true }
  5160. for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
  5161. sp = line.markedSpans[i];
  5162. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
  5163. (sp.to == null || sp.to != span.from) &&
  5164. (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
  5165. lineIsHiddenInner(doc, line, sp)) { return true }
  5166. }
  5167. }
  5168. // Find the height above the given line.
  5169. function heightAtLine(lineObj) {
  5170. lineObj = visualLine(lineObj);
  5171. var h = 0, chunk = lineObj.parent;
  5172. for (var i = 0; i < chunk.lines.length; ++i) {
  5173. var line = chunk.lines[i];
  5174. if (line == lineObj) { break }
  5175. else { h += line.height; }
  5176. }
  5177. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  5178. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  5179. var cur = p.children[i$1];
  5180. if (cur == chunk) { break }
  5181. else { h += cur.height; }
  5182. }
  5183. }
  5184. return h
  5185. }
  5186. // Compute the character length of a line, taking into account
  5187. // collapsed ranges (see markText) that might hide parts, and join
  5188. // other lines onto it.
  5189. function lineLength(line) {
  5190. if (line.height == 0) { return 0 }
  5191. var len = line.text.length, merged, cur = line;
  5192. while (merged = collapsedSpanAtStart(cur)) {
  5193. var found = merged.find(0, true);
  5194. cur = found.from.line;
  5195. len += found.from.ch - found.to.ch;
  5196. }
  5197. cur = line;
  5198. while (merged = collapsedSpanAtEnd(cur)) {
  5199. var found$1 = merged.find(0, true);
  5200. len -= cur.text.length - found$1.from.ch;
  5201. cur = found$1.to.line;
  5202. len += cur.text.length - found$1.to.ch;
  5203. }
  5204. return len
  5205. }
  5206. // Find the longest line in the document.
  5207. function findMaxLine(cm) {
  5208. var d = cm.display, doc = cm.doc;
  5209. d.maxLine = getLine(doc, doc.first);
  5210. d.maxLineLength = lineLength(d.maxLine);
  5211. d.maxLineChanged = true;
  5212. doc.iter(function (line) {
  5213. var len = lineLength(line);
  5214. if (len > d.maxLineLength) {
  5215. d.maxLineLength = len;
  5216. d.maxLine = line;
  5217. }
  5218. });
  5219. }
  5220. // LINE DATA STRUCTURE
  5221. // Line objects. These hold state related to a line, including
  5222. // highlighting info (the styles array).
  5223. var Line = function(text, markedSpans, estimateHeight) {
  5224. this.text = text;
  5225. attachMarkedSpans(this, markedSpans);
  5226. this.height = estimateHeight ? estimateHeight(this) : 1;
  5227. };
  5228. Line.prototype.lineNo = function () { return lineNo(this) };
  5229. eventMixin(Line);
  5230. // Change the content (text, markers) of a line. Automatically
  5231. // invalidates cached information and tries to re-estimate the
  5232. // line's height.
  5233. function updateLine(line, text, markedSpans, estimateHeight) {
  5234. line.text = text;
  5235. if (line.stateAfter) { line.stateAfter = null; }
  5236. if (line.styles) { line.styles = null; }
  5237. if (line.order != null) { line.order = null; }
  5238. detachMarkedSpans(line);
  5239. attachMarkedSpans(line, markedSpans);
  5240. var estHeight = estimateHeight ? estimateHeight(line) : 1;
  5241. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  5242. }
  5243. // Detach a line from the document tree and its markers.
  5244. function cleanUpLine(line) {
  5245. line.parent = null;
  5246. detachMarkedSpans(line);
  5247. }
  5248. // Convert a style as returned by a mode (either null, or a string
  5249. // containing one or more styles) to a CSS style. This is cached,
  5250. // and also looks for line-wide styles.
  5251. var styleToClassCache = {}, styleToClassCacheWithMode = {};
  5252. function interpretTokenStyle(style, options) {
  5253. if (!style || /^\s*$/.test(style)) { return null }
  5254. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  5255. return cache[style] ||
  5256. (cache[style] = style.replace(/\S+/g, "cm-$&"))
  5257. }
  5258. // Render the DOM representation of the text of a line. Also builds
  5259. // up a 'line map', which points at the DOM nodes that represent
  5260. // specific stretches of text, and is used by the measuring code.
  5261. // The returned object contains the DOM node, this map, and
  5262. // information about line-wide styles that were set by the mode.
  5263. function buildLineContent(cm, lineView) {
  5264. // The padding-right forces the element to have a 'border', which
  5265. // is needed on Webkit to be able to get line-level bounding
  5266. // rectangles for it (in measureChar).
  5267. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  5268. var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
  5269. col: 0, pos: 0, cm: cm,
  5270. trailingSpace: false,
  5271. splitSpaces: cm.getOption("lineWrapping")};
  5272. lineView.measure = {};
  5273. // Iterate over the logical lines that make up this visual line.
  5274. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  5275. var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);
  5276. builder.pos = 0;
  5277. builder.addToken = buildToken;
  5278. // Optionally wire in some hacks into the token-rendering
  5279. // algorithm, to deal with browser quirks.
  5280. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
  5281. { builder.addToken = buildTokenBadBidi(builder.addToken, order); }
  5282. builder.map = [];
  5283. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  5284. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  5285. if (line.styleClasses) {
  5286. if (line.styleClasses.bgClass)
  5287. { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); }
  5288. if (line.styleClasses.textClass)
  5289. { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); }
  5290. }
  5291. // Ensure at least a single node is present, for measuring.
  5292. if (builder.map.length == 0)
  5293. { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }
  5294. // Store the map and a cache object for the current logical line
  5295. if (i == 0) {
  5296. lineView.measure.map = builder.map;
  5297. lineView.measure.cache = {};
  5298. } else {
  5299. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
  5300. ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});
  5301. }
  5302. }
  5303. // See issue #2901
  5304. if (webkit) {
  5305. var last = builder.content.lastChild;
  5306. if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
  5307. { builder.content.className = "cm-tab-wrap-hack"; }
  5308. }
  5309. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  5310. if (builder.pre.className)
  5311. { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
  5312. return builder
  5313. }
  5314. function defaultSpecialCharPlaceholder(ch) {
  5315. var token = elt("span", "\u2022", "cm-invalidchar");
  5316. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  5317. token.setAttribute("aria-label", token.title);
  5318. return token
  5319. }
  5320. // Build up the DOM representation for a single token, and add it to
  5321. // the line map. Takes care to render special characters separately.
  5322. function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
  5323. if (!text) { return }
  5324. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  5325. var special = builder.cm.state.specialChars, mustWrap = false;
  5326. var content;
  5327. if (!special.test(text)) {
  5328. builder.col += text.length;
  5329. content = document.createTextNode(displayText);
  5330. builder.map.push(builder.pos, builder.pos + text.length, content);
  5331. if (ie && ie_version < 9) { mustWrap = true; }
  5332. builder.pos += text.length;
  5333. } else {
  5334. content = document.createDocumentFragment();
  5335. var pos = 0;
  5336. while (true) {
  5337. special.lastIndex = pos;
  5338. var m = special.exec(text);
  5339. var skipped = m ? m.index - pos : text.length - pos;
  5340. if (skipped) {
  5341. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  5342. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); }
  5343. else { content.appendChild(txt); }
  5344. builder.map.push(builder.pos, builder.pos + skipped, txt);
  5345. builder.col += skipped;
  5346. builder.pos += skipped;
  5347. }
  5348. if (!m) { break }
  5349. pos += skipped + 1;
  5350. var txt$1 = (void 0);
  5351. if (m[0] == "\t") {
  5352. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
  5353. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  5354. txt$1.setAttribute("role", "presentation");
  5355. txt$1.setAttribute("cm-text", "\t");
  5356. builder.col += tabWidth;
  5357. } else if (m[0] == "\r" || m[0] == "\n") {
  5358. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
  5359. txt$1.setAttribute("cm-text", m[0]);
  5360. builder.col += 1;
  5361. } else {
  5362. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  5363. txt$1.setAttribute("cm-text", m[0]);
  5364. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); }
  5365. else { content.appendChild(txt$1); }
  5366. builder.col += 1;
  5367. }
  5368. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  5369. builder.pos++;
  5370. }
  5371. }
  5372. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  5373. if (style || startStyle || endStyle || mustWrap || css) {
  5374. var fullStyle = style || "";
  5375. if (startStyle) { fullStyle += startStyle; }
  5376. if (endStyle) { fullStyle += endStyle; }
  5377. var token = elt("span", [content], fullStyle, css);
  5378. if (attributes) {
  5379. for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class")
  5380. { token.setAttribute(attr, attributes[attr]); } }
  5381. }
  5382. return builder.content.appendChild(token)
  5383. }
  5384. builder.content.appendChild(content);
  5385. }
  5386. // Change some spaces to NBSP to prevent the browser from collapsing
  5387. // trailing spaces at the end of a line when rendering text (issue #1362).
  5388. function splitSpaces(text, trailingBefore) {
  5389. if (text.length > 1 && !/ /.test(text)) { return text }
  5390. var spaceBefore = trailingBefore, result = "";
  5391. for (var i = 0; i < text.length; i++) {
  5392. var ch = text.charAt(i);
  5393. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
  5394. { ch = "\u00a0"; }
  5395. result += ch;
  5396. spaceBefore = ch == " ";
  5397. }
  5398. return result
  5399. }
  5400. // Work around nonsense dimensions being reported for stretches of
  5401. // right-to-left text.
  5402. function buildTokenBadBidi(inner, order) {
  5403. return function (builder, text, style, startStyle, endStyle, css, attributes) {
  5404. style = style ? style + " cm-force-border" : "cm-force-border";
  5405. var start = builder.pos, end = start + text.length;
  5406. for (;;) {
  5407. // Find the part that overlaps with the start of this text
  5408. var part = (void 0);
  5409. for (var i = 0; i < order.length; i++) {
  5410. part = order[i];
  5411. if (part.to > start && part.from <= start) { break }
  5412. }
  5413. if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, css, attributes) }
  5414. inner(builder, text.slice(0, part.to - start), style, startStyle, null, css, attributes);
  5415. startStyle = null;
  5416. text = text.slice(part.to - start);
  5417. start = part.to;
  5418. }
  5419. }
  5420. }
  5421. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  5422. var widget = !ignoreWidget && marker.widgetNode;
  5423. if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }
  5424. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  5425. if (!widget)
  5426. { widget = builder.content.appendChild(document.createElement("span")); }
  5427. widget.setAttribute("cm-marker", marker.id);
  5428. }
  5429. if (widget) {
  5430. builder.cm.display.input.setUneditable(widget);
  5431. builder.content.appendChild(widget);
  5432. }
  5433. builder.pos += size;
  5434. builder.trailingSpace = false;
  5435. }
  5436. // Outputs a number of spans to make up a line, taking highlighting
  5437. // and marked text into account.
  5438. function insertLineContent(line, builder, styles) {
  5439. var spans = line.markedSpans, allText = line.text, at = 0;
  5440. if (!spans) {
  5441. for (var i$1 = 1; i$1 < styles.length; i$1+=2)
  5442. { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }
  5443. return
  5444. }
  5445. var len = allText.length, pos = 0, i = 1, text = "", style, css;
  5446. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed, attributes;
  5447. for (;;) {
  5448. if (nextChange == pos) { // Update current marker set
  5449. spanStyle = spanEndStyle = spanStartStyle = css = "";
  5450. attributes = null;
  5451. collapsed = null; nextChange = Infinity;
  5452. var foundBookmarks = [], endStyles = (void 0);
  5453. for (var j = 0; j < spans.length; ++j) {
  5454. var sp = spans[j], m = sp.marker;
  5455. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  5456. foundBookmarks.push(m);
  5457. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  5458. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  5459. nextChange = sp.to;
  5460. spanEndStyle = "";
  5461. }
  5462. if (m.className) { spanStyle += " " + m.className; }
  5463. if (m.css) { css = (css ? css + ";" : "") + m.css; }
  5464. if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; }
  5465. if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }
  5466. // support for the old title property
  5467. // https://github.com/codemirror/CodeMirror/pull/5673
  5468. if (m.title) { (attributes || (attributes = {})).title = m.title; }
  5469. if (m.attributes) {
  5470. for (var attr in m.attributes)
  5471. { (attributes || (attributes = {}))[attr] = m.attributes[attr]; }
  5472. }
  5473. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
  5474. { collapsed = sp; }
  5475. } else if (sp.from > pos && nextChange > sp.from) {
  5476. nextChange = sp.from;
  5477. }
  5478. }
  5479. if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
  5480. { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } }
  5481. if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
  5482. { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }
  5483. if (collapsed && (collapsed.from || 0) == pos) {
  5484. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
  5485. collapsed.marker, collapsed.from == null);
  5486. if (collapsed.to == null) { return }
  5487. if (collapsed.to == pos) { collapsed = false; }
  5488. }
  5489. }
  5490. if (pos >= len) { break }
  5491. var upto = Math.min(len, nextChange);
  5492. while (true) {
  5493. if (text) {
  5494. var end = pos + text.length;
  5495. if (!collapsed) {
  5496. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  5497. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
  5498. spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", css, attributes);
  5499. }
  5500. if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
  5501. pos = end;
  5502. spanStartStyle = "";
  5503. }
  5504. text = allText.slice(at, at = styles[i++]);
  5505. style = interpretTokenStyle(styles[i++], builder.cm.options);
  5506. }
  5507. }
  5508. }
  5509. // These objects are used to represent the visible (currently drawn)
  5510. // part of the document. A LineView may correspond to multiple
  5511. // logical lines, if those are connected by collapsed ranges.
  5512. function LineView(doc, line, lineN) {
  5513. // The starting line
  5514. this.line = line;
  5515. // Continuing lines, if any
  5516. this.rest = visualLineContinued(line);
  5517. // Number of logical lines in this visual line
  5518. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  5519. this.node = this.text = null;
  5520. this.hidden = lineIsHidden(doc, line);
  5521. }
  5522. // Create a range of LineView objects for the given lines.
  5523. function buildViewArray(cm, from, to) {
  5524. var array = [], nextPos;
  5525. for (var pos = from; pos < to; pos = nextPos) {
  5526. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  5527. nextPos = pos + view.size;
  5528. array.push(view);
  5529. }
  5530. return array
  5531. }
  5532. var operationGroup = null;
  5533. function pushOperation(op) {
  5534. if (operationGroup) {
  5535. operationGroup.ops.push(op);
  5536. } else {
  5537. op.ownsGroup = operationGroup = {
  5538. ops: [op],
  5539. delayedCallbacks: []
  5540. };
  5541. }
  5542. }
  5543. function fireCallbacksForOps(group) {
  5544. // Calls delayed callbacks and cursorActivity handlers until no
  5545. // new ones appear
  5546. var callbacks = group.delayedCallbacks, i = 0;
  5547. do {
  5548. for (; i < callbacks.length; i++)
  5549. { callbacks[i].call(null); }
  5550. for (var j = 0; j < group.ops.length; j++) {
  5551. var op = group.ops[j];
  5552. if (op.cursorActivityHandlers)
  5553. { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
  5554. { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }
  5555. }
  5556. } while (i < callbacks.length)
  5557. }
  5558. function finishOperation(op, endCb) {
  5559. var group = op.ownsGroup;
  5560. if (!group) { return }
  5561. try { fireCallbacksForOps(group); }
  5562. finally {
  5563. operationGroup = null;
  5564. endCb(group);
  5565. }
  5566. }
  5567. var orphanDelayedCallbacks = null;
  5568. // Often, we want to signal events at a point where we are in the
  5569. // middle of some work, but don't want the handler to start calling
  5570. // other methods on the editor, which might be in an inconsistent
  5571. // state or simply not expect any other events to happen.
  5572. // signalLater looks whether there are any handlers, and schedules
  5573. // them to be executed when the last operation ends, or, if no
  5574. // operation is active, when a timeout fires.
  5575. function signalLater(emitter, type /*, values...*/) {
  5576. var arr = getHandlers(emitter, type);
  5577. if (!arr.length) { return }
  5578. var args = Array.prototype.slice.call(arguments, 2), list;
  5579. if (operationGroup) {
  5580. list = operationGroup.delayedCallbacks;
  5581. } else if (orphanDelayedCallbacks) {
  5582. list = orphanDelayedCallbacks;
  5583. } else {
  5584. list = orphanDelayedCallbacks = [];
  5585. setTimeout(fireOrphanDelayed, 0);
  5586. }
  5587. var loop = function ( i ) {
  5588. list.push(function () { return arr[i].apply(null, args); });
  5589. };
  5590. for (var i = 0; i < arr.length; ++i)
  5591. loop( i );
  5592. }
  5593. function fireOrphanDelayed() {
  5594. var delayed = orphanDelayedCallbacks;
  5595. orphanDelayedCallbacks = null;
  5596. for (var i = 0; i < delayed.length; ++i) { delayed[i](); }
  5597. }
  5598. // When an aspect of a line changes, a string is added to
  5599. // lineView.changes. This updates the relevant part of the line's
  5600. // DOM structure.
  5601. function updateLineForChanges(cm, lineView, lineN, dims) {
  5602. for (var j = 0; j < lineView.changes.length; j++) {
  5603. var type = lineView.changes[j];
  5604. if (type == "text") { updateLineText(cm, lineView); }
  5605. else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); }
  5606. else if (type == "class") { updateLineClasses(cm, lineView); }
  5607. else if (type == "widget") { updateLineWidgets(cm, lineView, dims); }
  5608. }
  5609. lineView.changes = null;
  5610. }
  5611. // Lines with gutter elements, widgets or a background class need to
  5612. // be wrapped, and have the extra elements added to the wrapper div
  5613. function ensureLineWrapped(lineView) {
  5614. if (lineView.node == lineView.text) {
  5615. lineView.node = elt("div", null, null, "position: relative");
  5616. if (lineView.text.parentNode)
  5617. { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }
  5618. lineView.node.appendChild(lineView.text);
  5619. if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }
  5620. }
  5621. return lineView.node
  5622. }
  5623. function updateLineBackground(cm, lineView) {
  5624. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  5625. if (cls) { cls += " CodeMirror-linebackground"; }
  5626. if (lineView.background) {
  5627. if (cls) { lineView.background.className = cls; }
  5628. else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
  5629. } else if (cls) {
  5630. var wrap = ensureLineWrapped(lineView);
  5631. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
  5632. cm.display.input.setUneditable(lineView.background);
  5633. }
  5634. }
  5635. // Wrapper around buildLineContent which will reuse the structure
  5636. // in display.externalMeasured when possible.
  5637. function getLineContent(cm, lineView) {
  5638. var ext = cm.display.externalMeasured;
  5639. if (ext && ext.line == lineView.line) {
  5640. cm.display.externalMeasured = null;
  5641. lineView.measure = ext.measure;
  5642. return ext.built
  5643. }
  5644. return buildLineContent(cm, lineView)
  5645. }
  5646. // Redraw the line's text. Interacts with the background and text
  5647. // classes because the mode may output tokens that influence these
  5648. // classes.
  5649. function updateLineText(cm, lineView) {
  5650. var cls = lineView.text.className;
  5651. var built = getLineContent(cm, lineView);
  5652. if (lineView.text == lineView.node) { lineView.node = built.pre; }
  5653. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  5654. lineView.text = built.pre;
  5655. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  5656. lineView.bgClass = built.bgClass;
  5657. lineView.textClass = built.textClass;
  5658. updateLineClasses(cm, lineView);
  5659. } else if (cls) {
  5660. lineView.text.className = cls;
  5661. }
  5662. }
  5663. function updateLineClasses(cm, lineView) {
  5664. updateLineBackground(cm, lineView);
  5665. if (lineView.line.wrapClass)
  5666. { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }
  5667. else if (lineView.node != lineView.text)
  5668. { lineView.node.className = ""; }
  5669. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  5670. lineView.text.className = textClass || "";
  5671. }
  5672. function updateLineGutter(cm, lineView, lineN, dims) {
  5673. if (lineView.gutter) {
  5674. lineView.node.removeChild(lineView.gutter);
  5675. lineView.gutter = null;
  5676. }
  5677. if (lineView.gutterBackground) {
  5678. lineView.node.removeChild(lineView.gutterBackground);
  5679. lineView.gutterBackground = null;
  5680. }
  5681. if (lineView.line.gutterClass) {
  5682. var wrap = ensureLineWrapped(lineView);
  5683. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
  5684. ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"));
  5685. cm.display.input.setUneditable(lineView.gutterBackground);
  5686. wrap.insertBefore(lineView.gutterBackground, lineView.text);
  5687. }
  5688. var markers = lineView.line.gutterMarkers;
  5689. if (cm.options.lineNumbers || markers) {
  5690. var wrap$1 = ensureLineWrapped(lineView);
  5691. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
  5692. cm.display.input.setUneditable(gutterWrap);
  5693. wrap$1.insertBefore(gutterWrap, lineView.text);
  5694. if (lineView.line.gutterClass)
  5695. { gutterWrap.className += " " + lineView.line.gutterClass; }
  5696. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
  5697. { lineView.lineNumber = gutterWrap.appendChild(
  5698. elt("div", lineNumberFor(cm.options, lineN),
  5699. "CodeMirror-linenumber CodeMirror-gutter-elt",
  5700. ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); }
  5701. if (markers) { for (var k = 0; k < cm.display.gutterSpecs.length; ++k) {
  5702. var id = cm.display.gutterSpecs[k].className, found = markers.hasOwnProperty(id) && markers[id];
  5703. if (found)
  5704. { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
  5705. ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); }
  5706. } }
  5707. }
  5708. }
  5709. function updateLineWidgets(cm, lineView, dims) {
  5710. if (lineView.alignable) { lineView.alignable = null; }
  5711. for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
  5712. next = node.nextSibling;
  5713. if (node.className == "CodeMirror-linewidget")
  5714. { lineView.node.removeChild(node); }
  5715. }
  5716. insertLineWidgets(cm, lineView, dims);
  5717. }
  5718. // Build a line's DOM representation from scratch
  5719. function buildLineElement(cm, lineView, lineN, dims) {
  5720. var built = getLineContent(cm, lineView);
  5721. lineView.text = lineView.node = built.pre;
  5722. if (built.bgClass) { lineView.bgClass = built.bgClass; }
  5723. if (built.textClass) { lineView.textClass = built.textClass; }
  5724. updateLineClasses(cm, lineView);
  5725. updateLineGutter(cm, lineView, lineN, dims);
  5726. insertLineWidgets(cm, lineView, dims);
  5727. return lineView.node
  5728. }
  5729. // A lineView may contain multiple logical lines (when merged by
  5730. // collapsed spans). The widgets for all of them need to be drawn.
  5731. function insertLineWidgets(cm, lineView, dims) {
  5732. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  5733. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  5734. { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }
  5735. }
  5736. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  5737. if (!line.widgets) { return }
  5738. var wrap = ensureLineWrapped(lineView);
  5739. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  5740. var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
  5741. if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); }
  5742. positionLineWidget(widget, node, lineView, dims);
  5743. cm.display.input.setUneditable(node);
  5744. if (allowAbove && widget.above)
  5745. { wrap.insertBefore(node, lineView.gutter || lineView.text); }
  5746. else
  5747. { wrap.appendChild(node); }
  5748. signalLater(widget, "redraw");
  5749. }
  5750. }
  5751. function positionLineWidget(widget, node, lineView, dims) {
  5752. if (widget.noHScroll) {
  5753. (lineView.alignable || (lineView.alignable = [])).push(node);
  5754. var width = dims.wrapperWidth;
  5755. node.style.left = dims.fixedPos + "px";
  5756. if (!widget.coverGutter) {
  5757. width -= dims.gutterTotalWidth;
  5758. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  5759. }
  5760. node.style.width = width + "px";
  5761. }
  5762. if (widget.coverGutter) {
  5763. node.style.zIndex = 5;
  5764. node.style.position = "relative";
  5765. if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; }
  5766. }
  5767. }
  5768. function widgetHeight(widget) {
  5769. if (widget.height != null) { return widget.height }
  5770. var cm = widget.doc.cm;
  5771. if (!cm) { return 0 }
  5772. if (!contains(document.body, widget.node)) {
  5773. var parentStyle = "position: relative;";
  5774. if (widget.coverGutter)
  5775. { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; }
  5776. if (widget.noHScroll)
  5777. { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; }
  5778. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  5779. }
  5780. return widget.height = widget.node.parentNode.offsetHeight
  5781. }
  5782. // Return true when the given mouse event happened in a widget
  5783. function eventInWidget(display, e) {
  5784. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  5785. if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
  5786. (n.parentNode == display.sizer && n != display.mover))
  5787. { return true }
  5788. }
  5789. }
  5790. // POSITION MEASUREMENT
  5791. function paddingTop(display) {return display.lineSpace.offsetTop}
  5792. function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
  5793. function paddingH(display) {
  5794. if (display.cachedPaddingH) { return display.cachedPaddingH }
  5795. var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
  5796. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  5797. var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
  5798. if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
  5799. return data
  5800. }
  5801. function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
  5802. function displayWidth(cm) {
  5803. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
  5804. }
  5805. function displayHeight(cm) {
  5806. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
  5807. }
  5808. // Ensure the lineView.wrapping.heights array is populated. This is
  5809. // an array of bottom offsets for the lines that make up a drawn
  5810. // line. When lineWrapping is on, there might be more than one
  5811. // height.
  5812. function ensureLineHeights(cm, lineView, rect) {
  5813. var wrapping = cm.options.lineWrapping;
  5814. var curWidth = wrapping && displayWidth(cm);
  5815. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  5816. var heights = lineView.measure.heights = [];
  5817. if (wrapping) {
  5818. lineView.measure.width = curWidth;
  5819. var rects = lineView.text.firstChild.getClientRects();
  5820. for (var i = 0; i < rects.length - 1; i++) {
  5821. var cur = rects[i], next = rects[i + 1];
  5822. if (Math.abs(cur.bottom - next.bottom) > 2)
  5823. { heights.push((cur.bottom + next.top) / 2 - rect.top); }
  5824. }
  5825. }
  5826. heights.push(rect.bottom - rect.top);
  5827. }
  5828. }
  5829. // Find a line map (mapping character offsets to text nodes) and a
  5830. // measurement cache for the given line number. (A line view might
  5831. // contain multiple lines when collapsed ranges are present.)
  5832. function mapFromLineView(lineView, line, lineN) {
  5833. if (lineView.line == line)
  5834. { return {map: lineView.measure.map, cache: lineView.measure.cache} }
  5835. for (var i = 0; i < lineView.rest.length; i++)
  5836. { if (lineView.rest[i] == line)
  5837. { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
  5838. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
  5839. { if (lineNo(lineView.rest[i$1]) > lineN)
  5840. { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
  5841. }
  5842. // Render a line into the hidden node display.externalMeasured. Used
  5843. // when measurement is needed for a line that's not in the viewport.
  5844. function updateExternalMeasurement(cm, line) {
  5845. line = visualLine(line);
  5846. var lineN = lineNo(line);
  5847. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  5848. view.lineN = lineN;
  5849. var built = view.built = buildLineContent(cm, view);
  5850. view.text = built.pre;
  5851. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  5852. return view
  5853. }
  5854. // Get a {top, bottom, left, right} box (in line-local coordinates)
  5855. // for a given character.
  5856. function measureChar(cm, line, ch, bias) {
  5857. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
  5858. }
  5859. // Find a line view that corresponds to the given line number.
  5860. function findViewForLine(cm, lineN) {
  5861. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
  5862. { return cm.display.view[findViewIndex(cm, lineN)] }
  5863. var ext = cm.display.externalMeasured;
  5864. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
  5865. { return ext }
  5866. }
  5867. // Measurement can be split in two steps, the set-up work that
  5868. // applies to the whole line, and the measurement of the actual
  5869. // character. Functions like coordsChar, that need to do a lot of
  5870. // measurements in a row, can thus ensure that the set-up work is
  5871. // only done once.
  5872. function prepareMeasureForLine(cm, line) {
  5873. var lineN = lineNo(line);
  5874. var view = findViewForLine(cm, lineN);
  5875. if (view && !view.text) {
  5876. view = null;
  5877. } else if (view && view.changes) {
  5878. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  5879. cm.curOp.forceUpdate = true;
  5880. }
  5881. if (!view)
  5882. { view = updateExternalMeasurement(cm, line); }
  5883. var info = mapFromLineView(view, line, lineN);
  5884. return {
  5885. line: line, view: view, rect: null,
  5886. map: info.map, cache: info.cache, before: info.before,
  5887. hasHeights: false
  5888. }
  5889. }
  5890. // Given a prepared measurement object, measures the position of an
  5891. // actual character (or fetches it from the cache).
  5892. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  5893. if (prepared.before) { ch = -1; }
  5894. var key = ch + (bias || ""), found;
  5895. if (prepared.cache.hasOwnProperty(key)) {
  5896. found = prepared.cache[key];
  5897. } else {
  5898. if (!prepared.rect)
  5899. { prepared.rect = prepared.view.text.getBoundingClientRect(); }
  5900. if (!prepared.hasHeights) {
  5901. ensureLineHeights(cm, prepared.view, prepared.rect);
  5902. prepared.hasHeights = true;
  5903. }
  5904. found = measureCharInner(cm, prepared, ch, bias);
  5905. if (!found.bogus) { prepared.cache[key] = found; }
  5906. }
  5907. return {left: found.left, right: found.right,
  5908. top: varHeight ? found.rtop : found.top,
  5909. bottom: varHeight ? found.rbottom : found.bottom}
  5910. }
  5911. var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
  5912. function nodeAndOffsetInLineMap(map$$1, ch, bias) {
  5913. var node, start, end, collapse, mStart, mEnd;
  5914. // First, search the line map for the text node corresponding to,
  5915. // or closest to, the target character.
  5916. for (var i = 0; i < map$$1.length; i += 3) {
  5917. mStart = map$$1[i];
  5918. mEnd = map$$1[i + 1];
  5919. if (ch < mStart) {
  5920. start = 0; end = 1;
  5921. collapse = "left";
  5922. } else if (ch < mEnd) {
  5923. start = ch - mStart;
  5924. end = start + 1;
  5925. } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {
  5926. end = mEnd - mStart;
  5927. start = end - 1;
  5928. if (ch >= mEnd) { collapse = "right"; }
  5929. }
  5930. if (start != null) {
  5931. node = map$$1[i + 2];
  5932. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
  5933. { collapse = bias; }
  5934. if (bias == "left" && start == 0)
  5935. { while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {
  5936. node = map$$1[(i -= 3) + 2];
  5937. collapse = "left";
  5938. } }
  5939. if (bias == "right" && start == mEnd - mStart)
  5940. { while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {
  5941. node = map$$1[(i += 3) + 2];
  5942. collapse = "right";
  5943. } }
  5944. break
  5945. }
  5946. }
  5947. return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
  5948. }
  5949. function getUsefulRect(rects, bias) {
  5950. var rect = nullRect;
  5951. if (bias == "left") { for (var i = 0; i < rects.length; i++) {
  5952. if ((rect = rects[i]).left != rect.right) { break }
  5953. } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  5954. if ((rect = rects[i$1]).left != rect.right) { break }
  5955. } }
  5956. return rect
  5957. }
  5958. function measureCharInner(cm, prepared, ch, bias) {
  5959. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  5960. var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
  5961. var rect;
  5962. if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
  5963. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
  5964. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }
  5965. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }
  5966. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
  5967. { rect = node.parentNode.getBoundingClientRect(); }
  5968. else
  5969. { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
  5970. if (rect.left || rect.right || start == 0) { break }
  5971. end = start;
  5972. start = start - 1;
  5973. collapse = "right";
  5974. }
  5975. if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }
  5976. } else { // If it is a widget, simply get the box for the whole widget.
  5977. if (start > 0) { collapse = bias = "right"; }
  5978. var rects;
  5979. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
  5980. { rect = rects[bias == "right" ? rects.length - 1 : 0]; }
  5981. else
  5982. { rect = node.getBoundingClientRect(); }
  5983. }
  5984. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  5985. var rSpan = node.parentNode.getClientRects()[0];
  5986. if (rSpan)
  5987. { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }
  5988. else
  5989. { rect = nullRect; }
  5990. }
  5991. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
  5992. var mid = (rtop + rbot) / 2;
  5993. var heights = prepared.view.measure.heights;
  5994. var i = 0;
  5995. for (; i < heights.length - 1; i++)
  5996. { if (mid < heights[i]) { break } }
  5997. var top = i ? heights[i - 1] : 0, bot = heights[i];
  5998. var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  5999. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  6000. top: top, bottom: bot};
  6001. if (!rect.left && !rect.right) { result.bogus = true; }
  6002. if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
  6003. return result
  6004. }
  6005. // Work around problem with bounding client rects on ranges being
  6006. // returned incorrectly when zoomed on IE10 and below.
  6007. function maybeUpdateRectForZooming(measure, rect) {
  6008. if (!window.screen || screen.logicalXDPI == null ||
  6009. screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
  6010. { return rect }
  6011. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  6012. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  6013. return {left: rect.left * scaleX, right: rect.right * scaleX,
  6014. top: rect.top * scaleY, bottom: rect.bottom * scaleY}
  6015. }
  6016. function clearLineMeasurementCacheFor(lineView) {
  6017. if (lineView.measure) {
  6018. lineView.measure.cache = {};
  6019. lineView.measure.heights = null;
  6020. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  6021. { lineView.measure.caches[i] = {}; } }
  6022. }
  6023. }
  6024. function clearLineMeasurementCache(cm) {
  6025. cm.display.externalMeasure = null;
  6026. removeChildren(cm.display.lineMeasure);
  6027. for (var i = 0; i < cm.display.view.length; i++)
  6028. { clearLineMeasurementCacheFor(cm.display.view[i]); }
  6029. }
  6030. function clearCaches(cm) {
  6031. clearLineMeasurementCache(cm);
  6032. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  6033. if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }
  6034. cm.display.lineNumChars = null;
  6035. }
  6036. function pageScrollX() {
  6037. // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
  6038. // which causes page_Offset and bounding client rects to use
  6039. // different reference viewports and invalidate our calculations.
  6040. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
  6041. return window.pageXOffset || (document.documentElement || document.body).scrollLeft
  6042. }
  6043. function pageScrollY() {
  6044. if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
  6045. return window.pageYOffset || (document.documentElement || document.body).scrollTop
  6046. }
  6047. function widgetTopHeight(lineObj) {
  6048. var height = 0;
  6049. if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
  6050. { height += widgetHeight(lineObj.widgets[i]); } } }
  6051. return height
  6052. }
  6053. // Converts a {top, bottom, left, right} box from line-local
  6054. // coordinates into another coordinate system. Context may be one of
  6055. // "line", "div" (display.lineDiv), "local"./null (editor), "window",
  6056. // or "page".
  6057. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  6058. if (!includeWidgets) {
  6059. var height = widgetTopHeight(lineObj);
  6060. rect.top += height; rect.bottom += height;
  6061. }
  6062. if (context == "line") { return rect }
  6063. if (!context) { context = "local"; }
  6064. var yOff = heightAtLine(lineObj);
  6065. if (context == "local") { yOff += paddingTop(cm.display); }
  6066. else { yOff -= cm.display.viewOffset; }
  6067. if (context == "page" || context == "window") {
  6068. var lOff = cm.display.lineSpace.getBoundingClientRect();
  6069. yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
  6070. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
  6071. rect.left += xOff; rect.right += xOff;
  6072. }
  6073. rect.top += yOff; rect.bottom += yOff;
  6074. return rect
  6075. }
  6076. // Coverts a box from "div" coords to another coordinate system.
  6077. // Context may be "window", "page", "div", or "local"./null.
  6078. function fromCoordSystem(cm, coords, context) {
  6079. if (context == "div") { return coords }
  6080. var left = coords.left, top = coords.top;
  6081. // First move into "page" coordinate system
  6082. if (context == "page") {
  6083. left -= pageScrollX();
  6084. top -= pageScrollY();
  6085. } else if (context == "local" || !context) {
  6086. var localBox = cm.display.sizer.getBoundingClientRect();
  6087. left += localBox.left;
  6088. top += localBox.top;
  6089. }
  6090. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  6091. return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
  6092. }
  6093. function charCoords(cm, pos, context, lineObj, bias) {
  6094. if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }
  6095. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
  6096. }
  6097. // Returns a box for a given cursor position, which may have an
  6098. // 'other' property containing the position of the secondary cursor
  6099. // on a bidi boundary.
  6100. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
  6101. // and after `char - 1` in writing order of `char - 1`
  6102. // A cursor Pos(line, char, "after") is on the same visual line as `char`
  6103. // and before `char` in writing order of `char`
  6104. // Examples (upper-case letters are RTL, lower-case are LTR):
  6105. // Pos(0, 1, ...)
  6106. // before after
  6107. // ab a|b a|b
  6108. // aB a|B aB|
  6109. // Ab |Ab A|b
  6110. // AB B|A B|A
  6111. // Every position after the last character on a line is considered to stick
  6112. // to the last character on the line.
  6113. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  6114. lineObj = lineObj || getLine(cm.doc, pos.line);
  6115. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  6116. function get(ch, right) {
  6117. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
  6118. if (right) { m.left = m.right; } else { m.right = m.left; }
  6119. return intoCoordSystem(cm, lineObj, m, context)
  6120. }
  6121. var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
  6122. if (ch >= lineObj.text.length) {
  6123. ch = lineObj.text.length;
  6124. sticky = "before";
  6125. } else if (ch <= 0) {
  6126. ch = 0;
  6127. sticky = "after";
  6128. }
  6129. if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
  6130. function getBidi(ch, partPos, invert) {
  6131. var part = order[partPos], right = part.level == 1;
  6132. return get(invert ? ch - 1 : ch, right != invert)
  6133. }
  6134. var partPos = getBidiPartAt(order, ch, sticky);
  6135. var other = bidiOther;
  6136. var val = getBidi(ch, partPos, sticky == "before");
  6137. if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
  6138. return val
  6139. }
  6140. // Used to cheaply estimate the coordinates for a position. Used for
  6141. // intermediate scroll updates.
  6142. function estimateCoords(cm, pos) {
  6143. var left = 0;
  6144. pos = clipPos(cm.doc, pos);
  6145. if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }
  6146. var lineObj = getLine(cm.doc, pos.line);
  6147. var top = heightAtLine(lineObj) + paddingTop(cm.display);
  6148. return {left: left, right: left, top: top, bottom: top + lineObj.height}
  6149. }
  6150. // Positions returned by coordsChar contain some extra information.
  6151. // xRel is the relative x position of the input coordinates compared
  6152. // to the found position (so xRel > 0 means the coordinates are to
  6153. // the right of the character position, for example). When outside
  6154. // is true, that means the coordinates lie outside the line's
  6155. // vertical range.
  6156. function PosWithInfo(line, ch, sticky, outside, xRel) {
  6157. var pos = Pos(line, ch, sticky);
  6158. pos.xRel = xRel;
  6159. if (outside) { pos.outside = true; }
  6160. return pos
  6161. }
  6162. // Compute the character position closest to the given coordinates.
  6163. // Input must be lineSpace-local ("div" coordinate system).
  6164. function coordsChar(cm, x, y) {
  6165. var doc = cm.doc;
  6166. y += cm.display.viewOffset;
  6167. if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
  6168. var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
  6169. if (lineN > last)
  6170. { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
  6171. if (x < 0) { x = 0; }
  6172. var lineObj = getLine(doc, lineN);
  6173. for (;;) {
  6174. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  6175. var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 ? 1 : 0));
  6176. if (!collapsed) { return found }
  6177. var rangeEnd = collapsed.find(1);
  6178. if (rangeEnd.line == lineN) { return rangeEnd }
  6179. lineObj = getLine(doc, lineN = rangeEnd.line);
  6180. }
  6181. }
  6182. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  6183. y -= widgetTopHeight(lineObj);
  6184. var end = lineObj.text.length;
  6185. var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);
  6186. end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);
  6187. return {begin: begin, end: end}
  6188. }
  6189. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  6190. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  6191. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  6192. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
  6193. }
  6194. // Returns true if the given side of a box is after the given
  6195. // coordinates, in top-to-bottom, left-to-right order.
  6196. function boxIsAfter(box, x, y, left) {
  6197. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
  6198. }
  6199. function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {
  6200. // Move y into line-local coordinate space
  6201. y -= heightAtLine(lineObj);
  6202. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  6203. // When directly calling `measureCharPrepared`, we have to adjust
  6204. // for the widgets at this line.
  6205. var widgetHeight$$1 = widgetTopHeight(lineObj);
  6206. var begin = 0, end = lineObj.text.length, ltr = true;
  6207. var order = getOrder(lineObj, cm.doc.direction);
  6208. // If the line isn't plain left-to-right text, first figure out
  6209. // which bidi section the coordinates fall into.
  6210. if (order) {
  6211. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
  6212. (cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);
  6213. ltr = part.level != 1;
  6214. // The awkward -1 offsets are needed because findFirst (called
  6215. // on these below) will treat its first bound as inclusive,
  6216. // second as exclusive, but we want to actually address the
  6217. // characters in the part's range
  6218. begin = ltr ? part.from : part.to - 1;
  6219. end = ltr ? part.to : part.from - 1;
  6220. }
  6221. // A binary search to find the first character whose bounding box
  6222. // starts after the coordinates. If we run across any whose box wrap
  6223. // the coordinates, store that.
  6224. var chAround = null, boxAround = null;
  6225. var ch = findFirst(function (ch) {
  6226. var box = measureCharPrepared(cm, preparedMeasure, ch);
  6227. box.top += widgetHeight$$1; box.bottom += widgetHeight$$1;
  6228. if (!boxIsAfter(box, x, y, false)) { return false }
  6229. if (box.top <= y && box.left <= x) {
  6230. chAround = ch;
  6231. boxAround = box;
  6232. }
  6233. return true
  6234. }, begin, end);
  6235. var baseX, sticky, outside = false;
  6236. // If a box around the coordinates was found, use that
  6237. if (boxAround) {
  6238. // Distinguish coordinates nearer to the left or right side of the box
  6239. var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
  6240. ch = chAround + (atStart ? 0 : 1);
  6241. sticky = atStart ? "after" : "before";
  6242. baseX = atLeft ? boxAround.left : boxAround.right;
  6243. } else {
  6244. // (Adjust for extended bound, if necessary.)
  6245. if (!ltr && (ch == end || ch == begin)) { ch++; }
  6246. // To determine which side to associate with, get the box to the
  6247. // left of the character and compare it's vertical position to the
  6248. // coordinates
  6249. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
  6250. (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y) == ltr ?
  6251. "after" : "before";
  6252. // Now get accurate coordinates for this place, in order to get a
  6253. // base X position
  6254. var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
  6255. baseX = coords.left;
  6256. outside = y < coords.top || y >= coords.bottom;
  6257. }
  6258. ch = skipExtendingChars(lineObj.text, ch, 1);
  6259. return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX)
  6260. }
  6261. function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
  6262. // Bidi parts are sorted left-to-right, and in a non-line-wrapping
  6263. // situation, we can take this ordering to correspond to the visual
  6264. // ordering. This finds the first part whose end is after the given
  6265. // coordinates.
  6266. var index = findFirst(function (i) {
  6267. var part = order[i], ltr = part.level != 1;
  6268. return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"),
  6269. "line", lineObj, preparedMeasure), x, y, true)
  6270. }, 0, order.length - 1);
  6271. var part = order[index];
  6272. // If this isn't the first part, the part's start is also after
  6273. // the coordinates, and the coordinates aren't on the same line as
  6274. // that start, move one part back.
  6275. if (index > 0) {
  6276. var ltr = part.level != 1;
  6277. var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"),
  6278. "line", lineObj, preparedMeasure);
  6279. if (boxIsAfter(start, x, y, true) && start.top > y)
  6280. { part = order[index - 1]; }
  6281. }
  6282. return part
  6283. }
  6284. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  6285. // In a wrapped line, rtl text on wrapping boundaries can do things
  6286. // that don't correspond to the ordering in our `order` array at
  6287. // all, so a binary search doesn't work, and we want to return a
  6288. // part that only spans one line so that the binary search in
  6289. // coordsCharInner is safe. As such, we first find the extent of the
  6290. // wrapped line, and then do a flat search in which we discard any
  6291. // spans that aren't on the line.
  6292. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  6293. var begin = ref.begin;
  6294. var end = ref.end;
  6295. if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; }
  6296. var part = null, closestDist = null;
  6297. for (var i = 0; i < order.length; i++) {
  6298. var p = order[i];
  6299. if (p.from >= end || p.to <= begin) { continue }
  6300. var ltr = p.level != 1;
  6301. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  6302. // Weigh against spans ending before this, so that they are only
  6303. // picked if nothing ends after
  6304. var dist = endX < x ? x - endX + 1e9 : endX - x;
  6305. if (!part || closestDist > dist) {
  6306. part = p;
  6307. closestDist = dist;
  6308. }
  6309. }
  6310. if (!part) { part = order[order.length - 1]; }
  6311. // Clip the part to the wrapped line.
  6312. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }
  6313. if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }
  6314. return part
  6315. }
  6316. var measureText;
  6317. // Compute the default text height.
  6318. function textHeight(display) {
  6319. if (display.cachedTextHeight != null) { return display.cachedTextHeight }
  6320. if (measureText == null) {
  6321. measureText = elt("pre");
  6322. // Measure a bunch of lines, for browsers that compute
  6323. // fractional heights.
  6324. for (var i = 0; i < 49; ++i) {
  6325. measureText.appendChild(document.createTextNode("x"));
  6326. measureText.appendChild(elt("br"));
  6327. }
  6328. measureText.appendChild(document.createTextNode("x"));
  6329. }
  6330. removeChildrenAndAdd(display.measure, measureText);
  6331. var height = measureText.offsetHeight / 50;
  6332. if (height > 3) { display.cachedTextHeight = height; }
  6333. removeChildren(display.measure);
  6334. return height || 1
  6335. }
  6336. // Compute the default character width.
  6337. function charWidth(display) {
  6338. if (display.cachedCharWidth != null) { return display.cachedCharWidth }
  6339. var anchor = elt("span", "xxxxxxxxxx");
  6340. var pre = elt("pre", [anchor]);
  6341. removeChildrenAndAdd(display.measure, pre);
  6342. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
  6343. if (width > 2) { display.cachedCharWidth = width; }
  6344. return width || 10
  6345. }
  6346. // Do a bulk-read of the DOM positions and sizes needed to draw the
  6347. // view, so that we don't interleave reading and writing to the DOM.
  6348. function getDimensions(cm) {
  6349. var d = cm.display, left = {}, width = {};
  6350. var gutterLeft = d.gutters.clientLeft;
  6351. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  6352. var id = cm.display.gutterSpecs[i].className;
  6353. left[id] = n.offsetLeft + n.clientLeft + gutterLeft;
  6354. width[id] = n.clientWidth;
  6355. }
  6356. return {fixedPos: compensateForHScroll(d),
  6357. gutterTotalWidth: d.gutters.offsetWidth,
  6358. gutterLeft: left,
  6359. gutterWidth: width,
  6360. wrapperWidth: d.wrapper.clientWidth}
  6361. }
  6362. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  6363. // but using getBoundingClientRect to get a sub-pixel-accurate
  6364. // result.
  6365. function compensateForHScroll(display) {
  6366. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
  6367. }
  6368. // Returns a function that estimates the height of a line, to use as
  6369. // first approximation until the line becomes visible (and is thus
  6370. // properly measurable).
  6371. function estimateHeight(cm) {
  6372. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
  6373. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  6374. return function (line) {
  6375. if (lineIsHidden(cm.doc, line)) { return 0 }
  6376. var widgetsHeight = 0;
  6377. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
  6378. if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
  6379. } }
  6380. if (wrapping)
  6381. { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
  6382. else
  6383. { return widgetsHeight + th }
  6384. }
  6385. }
  6386. function estimateLineHeights(cm) {
  6387. var doc = cm.doc, est = estimateHeight(cm);
  6388. doc.iter(function (line) {
  6389. var estHeight = est(line);
  6390. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  6391. });
  6392. }
  6393. // Given a mouse event, find the corresponding position. If liberal
  6394. // is false, it checks whether a gutter or scrollbar was clicked,
  6395. // and returns null if it was. forRect is used by rectangular
  6396. // selections, and tries to estimate a character position even for
  6397. // coordinates beyond the right of the text.
  6398. function posFromMouse(cm, e, liberal, forRect) {
  6399. var display = cm.display;
  6400. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
  6401. var x, y, space = display.lineSpace.getBoundingClientRect();
  6402. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  6403. try { x = e.clientX - space.left; y = e.clientY - space.top; }
  6404. catch (e) { return null }
  6405. var coords = coordsChar(cm, x, y), line;
  6406. if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  6407. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  6408. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  6409. }
  6410. return coords
  6411. }
  6412. // Find the view element corresponding to a given line. Return null
  6413. // when the line isn't visible.
  6414. function findViewIndex(cm, n) {
  6415. if (n >= cm.display.viewTo) { return null }
  6416. n -= cm.display.viewFrom;
  6417. if (n < 0) { return null }
  6418. var view = cm.display.view;
  6419. for (var i = 0; i < view.length; i++) {
  6420. n -= view[i].size;
  6421. if (n < 0) { return i }
  6422. }
  6423. }
  6424. // Updates the display.view data structure for a given change to the
  6425. // document. From and to are in pre-change coordinates. Lendiff is
  6426. // the amount of lines added or subtracted by the change. This is
  6427. // used for changes that span multiple lines, or change the way
  6428. // lines are divided into visual lines. regLineChange (below)
  6429. // registers single-line changes.
  6430. function regChange(cm, from, to, lendiff) {
  6431. if (from == null) { from = cm.doc.first; }
  6432. if (to == null) { to = cm.doc.first + cm.doc.size; }
  6433. if (!lendiff) { lendiff = 0; }
  6434. var display = cm.display;
  6435. if (lendiff && to < display.viewTo &&
  6436. (display.updateLineNumbers == null || display.updateLineNumbers > from))
  6437. { display.updateLineNumbers = from; }
  6438. cm.curOp.viewChanged = true;
  6439. if (from >= display.viewTo) { // Change after
  6440. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
  6441. { resetView(cm); }
  6442. } else if (to <= display.viewFrom) { // Change before
  6443. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  6444. resetView(cm);
  6445. } else {
  6446. display.viewFrom += lendiff;
  6447. display.viewTo += lendiff;
  6448. }
  6449. } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
  6450. resetView(cm);
  6451. } else if (from <= display.viewFrom) { // Top overlap
  6452. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  6453. if (cut) {
  6454. display.view = display.view.slice(cut.index);
  6455. display.viewFrom = cut.lineN;
  6456. display.viewTo += lendiff;
  6457. } else {
  6458. resetView(cm);
  6459. }
  6460. } else if (to >= display.viewTo) { // Bottom overlap
  6461. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  6462. if (cut$1) {
  6463. display.view = display.view.slice(0, cut$1.index);
  6464. display.viewTo = cut$1.lineN;
  6465. } else {
  6466. resetView(cm);
  6467. }
  6468. } else { // Gap in the middle
  6469. var cutTop = viewCuttingPoint(cm, from, from, -1);
  6470. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  6471. if (cutTop && cutBot) {
  6472. display.view = display.view.slice(0, cutTop.index)
  6473. .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
  6474. .concat(display.view.slice(cutBot.index));
  6475. display.viewTo += lendiff;
  6476. } else {
  6477. resetView(cm);
  6478. }
  6479. }
  6480. var ext = display.externalMeasured;
  6481. if (ext) {
  6482. if (to < ext.lineN)
  6483. { ext.lineN += lendiff; }
  6484. else if (from < ext.lineN + ext.size)
  6485. { display.externalMeasured = null; }
  6486. }
  6487. }
  6488. // Register a change to a single line. Type must be one of "text",
  6489. // "gutter", "class", "widget"
  6490. function regLineChange(cm, line, type) {
  6491. cm.curOp.viewChanged = true;
  6492. var display = cm.display, ext = cm.display.externalMeasured;
  6493. if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
  6494. { display.externalMeasured = null; }
  6495. if (line < display.viewFrom || line >= display.viewTo) { return }
  6496. var lineView = display.view[findViewIndex(cm, line)];
  6497. if (lineView.node == null) { return }
  6498. var arr = lineView.changes || (lineView.changes = []);
  6499. if (indexOf(arr, type) == -1) { arr.push(type); }
  6500. }
  6501. // Clear the view.
  6502. function resetView(cm) {
  6503. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  6504. cm.display.view = [];
  6505. cm.display.viewOffset = 0;
  6506. }
  6507. function viewCuttingPoint(cm, oldN, newN, dir) {
  6508. var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
  6509. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
  6510. { return {index: index, lineN: newN} }
  6511. var n = cm.display.viewFrom;
  6512. for (var i = 0; i < index; i++)
  6513. { n += view[i].size; }
  6514. if (n != oldN) {
  6515. if (dir > 0) {
  6516. if (index == view.length - 1) { return null }
  6517. diff = (n + view[index].size) - oldN;
  6518. index++;
  6519. } else {
  6520. diff = n - oldN;
  6521. }
  6522. oldN += diff; newN += diff;
  6523. }
  6524. while (visualLineNo(cm.doc, newN) != newN) {
  6525. if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
  6526. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  6527. index += dir;
  6528. }
  6529. return {index: index, lineN: newN}
  6530. }
  6531. // Force the view to cover a given range, adding empty view element
  6532. // or clipping off existing ones as needed.
  6533. function adjustView(cm, from, to) {
  6534. var display = cm.display, view = display.view;
  6535. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  6536. display.view = buildViewArray(cm, from, to);
  6537. display.viewFrom = from;
  6538. } else {
  6539. if (display.viewFrom > from)
  6540. { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
  6541. else if (display.viewFrom < from)
  6542. { display.view = display.view.slice(findViewIndex(cm, from)); }
  6543. display.viewFrom = from;
  6544. if (display.viewTo < to)
  6545. { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
  6546. else if (display.viewTo > to)
  6547. { display.view = display.view.slice(0, findViewIndex(cm, to)); }
  6548. }
  6549. display.viewTo = to;
  6550. }
  6551. // Count the number of lines in the view whose DOM representation is
  6552. // out of date (or nonexistent).
  6553. function countDirtyView(cm) {
  6554. var view = cm.display.view, dirty = 0;
  6555. for (var i = 0; i < view.length; i++) {
  6556. var lineView = view[i];
  6557. if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }
  6558. }
  6559. return dirty
  6560. }
  6561. function updateSelection(cm) {
  6562. cm.display.input.showSelection(cm.display.input.prepareSelection());
  6563. }
  6564. function prepareSelection(cm, primary) {
  6565. if ( primary === void 0 ) primary = true;
  6566. var doc = cm.doc, result = {};
  6567. var curFragment = result.cursors = document.createDocumentFragment();
  6568. var selFragment = result.selection = document.createDocumentFragment();
  6569. for (var i = 0; i < doc.sel.ranges.length; i++) {
  6570. if (!primary && i == doc.sel.primIndex) { continue }
  6571. var range$$1 = doc.sel.ranges[i];
  6572. if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) { continue }
  6573. var collapsed = range$$1.empty();
  6574. if (collapsed || cm.options.showCursorWhenSelecting)
  6575. { drawSelectionCursor(cm, range$$1.head, curFragment); }
  6576. if (!collapsed)
  6577. { drawSelectionRange(cm, range$$1, selFragment); }
  6578. }
  6579. return result
  6580. }
  6581. // Draws a cursor for the given range
  6582. function drawSelectionCursor(cm, head, output) {
  6583. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  6584. var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
  6585. cursor.style.left = pos.left + "px";
  6586. cursor.style.top = pos.top + "px";
  6587. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  6588. if (pos.other) {
  6589. // Secondary cursor, shown when on a 'jump' in bi-directional text
  6590. var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  6591. otherCursor.style.display = "";
  6592. otherCursor.style.left = pos.other.left + "px";
  6593. otherCursor.style.top = pos.other.top + "px";
  6594. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  6595. }
  6596. }
  6597. function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
  6598. // Draws the given range as a highlighted selection
  6599. function drawSelectionRange(cm, range$$1, output) {
  6600. var display = cm.display, doc = cm.doc;
  6601. var fragment = document.createDocumentFragment();
  6602. var padding = paddingH(cm.display), leftSide = padding.left;
  6603. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  6604. var docLTR = doc.direction == "ltr";
  6605. function add(left, top, width, bottom) {
  6606. if (top < 0) { top = 0; }
  6607. top = Math.round(top);
  6608. bottom = Math.round(bottom);
  6609. fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")));
  6610. }
  6611. function drawForLine(line, fromArg, toArg) {
  6612. var lineObj = getLine(doc, line);
  6613. var lineLen = lineObj.text.length;
  6614. var start, end;
  6615. function coords(ch, bias) {
  6616. return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
  6617. }
  6618. function wrapX(pos, dir, side) {
  6619. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  6620. var prop = (dir == "ltr") == (side == "after") ? "left" : "right";
  6621. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  6622. return coords(ch, prop)[prop]
  6623. }
  6624. var order = getOrder(lineObj, doc.direction);
  6625. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
  6626. var ltr = dir == "ltr";
  6627. var fromPos = coords(from, ltr ? "left" : "right");
  6628. var toPos = coords(to - 1, ltr ? "right" : "left");
  6629. var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
  6630. var first = i == 0, last = !order || i == order.length - 1;
  6631. if (toPos.top - fromPos.top <= 3) { // Single line
  6632. var openLeft = (docLTR ? openStart : openEnd) && first;
  6633. var openRight = (docLTR ? openEnd : openStart) && last;
  6634. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  6635. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  6636. add(left, fromPos.top, right - left, fromPos.bottom);
  6637. } else { // Multiple lines
  6638. var topLeft, topRight, botLeft, botRight;
  6639. if (ltr) {
  6640. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  6641. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  6642. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  6643. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  6644. } else {
  6645. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  6646. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  6647. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  6648. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  6649. }
  6650. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  6651. if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }
  6652. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  6653. }
  6654. if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }
  6655. if (cmpCoords(toPos, start) < 0) { start = toPos; }
  6656. if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }
  6657. if (cmpCoords(toPos, end) < 0) { end = toPos; }
  6658. });
  6659. return {start: start, end: end}
  6660. }
  6661. var sFrom = range$$1.from(), sTo = range$$1.to();
  6662. if (sFrom.line == sTo.line) {
  6663. drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  6664. } else {
  6665. var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
  6666. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  6667. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  6668. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  6669. if (singleVLine) {
  6670. if (leftEnd.top < rightStart.top - 2) {
  6671. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  6672. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  6673. } else {
  6674. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  6675. }
  6676. }
  6677. if (leftEnd.bottom < rightStart.top)
  6678. { add(leftSide, leftEnd.bottom, null, rightStart.top); }
  6679. }
  6680. output.appendChild(fragment);
  6681. }
  6682. // Cursor-blinking
  6683. function restartBlink(cm) {
  6684. if (!cm.state.focused) { return }
  6685. var display = cm.display;
  6686. clearInterval(display.blinker);
  6687. var on = true;
  6688. display.cursorDiv.style.visibility = "";
  6689. if (cm.options.cursorBlinkRate > 0)
  6690. { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
  6691. cm.options.cursorBlinkRate); }
  6692. else if (cm.options.cursorBlinkRate < 0)
  6693. { display.cursorDiv.style.visibility = "hidden"; }
  6694. }
  6695. function ensureFocus(cm) {
  6696. if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
  6697. }
  6698. function delayBlurEvent(cm) {
  6699. cm.state.delayingBlurEvent = true;
  6700. setTimeout(function () { if (cm.state.delayingBlurEvent) {
  6701. cm.state.delayingBlurEvent = false;
  6702. onBlur(cm);
  6703. } }, 100);
  6704. }
  6705. function onFocus(cm, e) {
  6706. if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
  6707. if (cm.options.readOnly == "nocursor") { return }
  6708. if (!cm.state.focused) {
  6709. signal(cm, "focus", cm, e);
  6710. cm.state.focused = true;
  6711. addClass(cm.display.wrapper, "CodeMirror-focused");
  6712. // This test prevents this from firing when a context
  6713. // menu is closed (since the input reset would kill the
  6714. // select-all detection hack)
  6715. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  6716. cm.display.input.reset();
  6717. if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730
  6718. }
  6719. cm.display.input.receivedFocus();
  6720. }
  6721. restartBlink(cm);
  6722. }
  6723. function onBlur(cm, e) {
  6724. if (cm.state.delayingBlurEvent) { return }
  6725. if (cm.state.focused) {
  6726. signal(cm, "blur", cm, e);
  6727. cm.state.focused = false;
  6728. rmClass(cm.display.wrapper, "CodeMirror-focused");
  6729. }
  6730. clearInterval(cm.display.blinker);
  6731. setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);
  6732. }
  6733. // Read the actual heights of the rendered lines, and update their
  6734. // stored heights to match.
  6735. function updateHeightsInViewport(cm) {
  6736. var display = cm.display;
  6737. var prevBottom = display.lineDiv.offsetTop;
  6738. for (var i = 0; i < display.view.length; i++) {
  6739. var cur = display.view[i], wrapping = cm.options.lineWrapping;
  6740. var height = (void 0), width = 0;
  6741. if (cur.hidden) { continue }
  6742. if (ie && ie_version < 8) {
  6743. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  6744. height = bot - prevBottom;
  6745. prevBottom = bot;
  6746. } else {
  6747. var box = cur.node.getBoundingClientRect();
  6748. height = box.bottom - box.top;
  6749. // Check that lines don't extend past the right of the current
  6750. // editor width
  6751. if (!wrapping && cur.text.firstChild)
  6752. { width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1; }
  6753. }
  6754. var diff = cur.line.height - height;
  6755. if (diff > .005 || diff < -.005) {
  6756. updateLineHeight(cur.line, height);
  6757. updateWidgetHeight(cur.line);
  6758. if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
  6759. { updateWidgetHeight(cur.rest[j]); } }
  6760. }
  6761. if (width > cm.display.sizerWidth) {
  6762. var chWidth = Math.ceil(width / charWidth(cm.display));
  6763. if (chWidth > cm.display.maxLineLength) {
  6764. cm.display.maxLineLength = chWidth;
  6765. cm.display.maxLine = cur.line;
  6766. cm.display.maxLineChanged = true;
  6767. }
  6768. }
  6769. }
  6770. }
  6771. // Read and store the height of line widgets associated with the
  6772. // given line.
  6773. function updateWidgetHeight(line) {
  6774. if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
  6775. var w = line.widgets[i], parent = w.node.parentNode;
  6776. if (parent) { w.height = parent.offsetHeight; }
  6777. } }
  6778. }
  6779. // Compute the lines that are visible in a given viewport (defaults
  6780. // the the current scroll position). viewport may contain top,
  6781. // height, and ensure (see op.scrollToPos) properties.
  6782. function visibleLines(display, doc, viewport) {
  6783. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  6784. top = Math.floor(top - paddingTop(display));
  6785. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  6786. var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
  6787. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  6788. // forces those lines into the viewport (if possible).
  6789. if (viewport && viewport.ensure) {
  6790. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
  6791. if (ensureFrom < from) {
  6792. from = ensureFrom;
  6793. to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
  6794. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  6795. from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
  6796. to = ensureTo;
  6797. }
  6798. }
  6799. return {from: from, to: Math.max(to, from + 1)}
  6800. }
  6801. // SCROLLING THINGS INTO VIEW
  6802. // If an editor sits on the top or bottom of the window, partially
  6803. // scrolled out of view, this ensures that the cursor is visible.
  6804. function maybeScrollWindow(cm, rect) {
  6805. if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
  6806. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
  6807. if (rect.top + box.top < 0) { doScroll = true; }
  6808. else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
  6809. if (doScroll != null && !phantom) {
  6810. var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
  6811. cm.display.lineSpace.appendChild(scrollNode);
  6812. scrollNode.scrollIntoView(doScroll);
  6813. cm.display.lineSpace.removeChild(scrollNode);
  6814. }
  6815. }
  6816. // Scroll a given position into view (immediately), verifying that
  6817. // it actually became visible (as line heights are accurately
  6818. // measured, the position of something may 'drift' during drawing).
  6819. function scrollPosIntoView(cm, pos, end, margin) {
  6820. if (margin == null) { margin = 0; }
  6821. var rect;
  6822. if (!cm.options.lineWrapping && pos == end) {
  6823. // Set pos and end to the cursor positions around the character pos sticks to
  6824. // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
  6825. // If pos == Pos(_, 0, "before"), pos and end are unchanged
  6826. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  6827. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  6828. }
  6829. for (var limit = 0; limit < 5; limit++) {
  6830. var changed = false;
  6831. var coords = cursorCoords(cm, pos);
  6832. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
  6833. rect = {left: Math.min(coords.left, endCoords.left),
  6834. top: Math.min(coords.top, endCoords.top) - margin,
  6835. right: Math.max(coords.left, endCoords.left),
  6836. bottom: Math.max(coords.bottom, endCoords.bottom) + margin};
  6837. var scrollPos = calculateScrollPos(cm, rect);
  6838. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
  6839. if (scrollPos.scrollTop != null) {
  6840. updateScrollTop(cm, scrollPos.scrollTop);
  6841. if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }
  6842. }
  6843. if (scrollPos.scrollLeft != null) {
  6844. setScrollLeft(cm, scrollPos.scrollLeft);
  6845. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }
  6846. }
  6847. if (!changed) { break }
  6848. }
  6849. return rect
  6850. }
  6851. // Scroll a given set of coordinates into view (immediately).
  6852. function scrollIntoView(cm, rect) {
  6853. var scrollPos = calculateScrollPos(cm, rect);
  6854. if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }
  6855. if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }
  6856. }
  6857. // Calculate a new scroll position needed to scroll the given
  6858. // rectangle into view. Returns an object with scrollTop and
  6859. // scrollLeft properties. When these are undefined, the
  6860. // vertical/horizontal position does not need to be adjusted.
  6861. function calculateScrollPos(cm, rect) {
  6862. var display = cm.display, snapMargin = textHeight(cm.display);
  6863. if (rect.top < 0) { rect.top = 0; }
  6864. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  6865. var screen = displayHeight(cm), result = {};
  6866. if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }
  6867. var docBottom = cm.doc.height + paddingVert(display);
  6868. var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
  6869. if (rect.top < screentop) {
  6870. result.scrollTop = atTop ? 0 : rect.top;
  6871. } else if (rect.bottom > screentop + screen) {
  6872. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
  6873. if (newTop != screentop) { result.scrollTop = newTop; }
  6874. }
  6875. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
  6876. var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
  6877. var tooWide = rect.right - rect.left > screenw;
  6878. if (tooWide) { rect.right = rect.left + screenw; }
  6879. if (rect.left < 10)
  6880. { result.scrollLeft = 0; }
  6881. else if (rect.left < screenleft)
  6882. { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
  6883. else if (rect.right > screenw + screenleft - 3)
  6884. { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
  6885. return result
  6886. }
  6887. // Store a relative adjustment to the scroll position in the current
  6888. // operation (to be applied when the operation finishes).
  6889. function addToScrollTop(cm, top) {
  6890. if (top == null) { return }
  6891. resolveScrollToPos(cm);
  6892. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  6893. }
  6894. // Make sure that at the end of the operation the current cursor is
  6895. // shown.
  6896. function ensureCursorVisible(cm) {
  6897. resolveScrollToPos(cm);
  6898. var cur = cm.getCursor();
  6899. cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};
  6900. }
  6901. function scrollToCoords(cm, x, y) {
  6902. if (x != null || y != null) { resolveScrollToPos(cm); }
  6903. if (x != null) { cm.curOp.scrollLeft = x; }
  6904. if (y != null) { cm.curOp.scrollTop = y; }
  6905. }
  6906. function scrollToRange(cm, range$$1) {
  6907. resolveScrollToPos(cm);
  6908. cm.curOp.scrollToPos = range$$1;
  6909. }
  6910. // When an operation has its scrollToPos property set, and another
  6911. // scroll action is applied before the end of the operation, this
  6912. // 'simulates' scrolling that position into view in a cheap way, so
  6913. // that the effect of intermediate scroll commands is not ignored.
  6914. function resolveScrollToPos(cm) {
  6915. var range$$1 = cm.curOp.scrollToPos;
  6916. if (range$$1) {
  6917. cm.curOp.scrollToPos = null;
  6918. var from = estimateCoords(cm, range$$1.from), to = estimateCoords(cm, range$$1.to);
  6919. scrollToCoordsRange(cm, from, to, range$$1.margin);
  6920. }
  6921. }
  6922. function scrollToCoordsRange(cm, from, to, margin) {
  6923. var sPos = calculateScrollPos(cm, {
  6924. left: Math.min(from.left, to.left),
  6925. top: Math.min(from.top, to.top) - margin,
  6926. right: Math.max(from.right, to.right),
  6927. bottom: Math.max(from.bottom, to.bottom) + margin
  6928. });
  6929. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  6930. }
  6931. // Sync the scrollable area and scrollbars, ensure the viewport
  6932. // covers the visible area.
  6933. function updateScrollTop(cm, val) {
  6934. if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
  6935. if (!gecko) { updateDisplaySimple(cm, {top: val}); }
  6936. setScrollTop(cm, val, true);
  6937. if (gecko) { updateDisplaySimple(cm); }
  6938. startWorker(cm, 100);
  6939. }
  6940. function setScrollTop(cm, val, forceScroll) {
  6941. val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
  6942. if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
  6943. cm.doc.scrollTop = val;
  6944. cm.display.scrollbars.setScrollTop(val);
  6945. if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }
  6946. }
  6947. // Sync scroller and scrollbar, ensure the gutter elements are
  6948. // aligned.
  6949. function setScrollLeft(cm, val, isScroller, forceScroll) {
  6950. val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
  6951. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
  6952. cm.doc.scrollLeft = val;
  6953. alignHorizontally(cm);
  6954. if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }
  6955. cm.display.scrollbars.setScrollLeft(val);
  6956. }
  6957. // SCROLLBARS
  6958. // Prepare DOM reads needed to update the scrollbars. Done in one
  6959. // shot to minimize update/measure roundtrips.
  6960. function measureForScrollbars(cm) {
  6961. var d = cm.display, gutterW = d.gutters.offsetWidth;
  6962. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  6963. return {
  6964. clientHeight: d.scroller.clientHeight,
  6965. viewHeight: d.wrapper.clientHeight,
  6966. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  6967. viewWidth: d.wrapper.clientWidth,
  6968. barLeft: cm.options.fixedGutter ? gutterW : 0,
  6969. docHeight: docH,
  6970. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  6971. nativeBarWidth: d.nativeBarWidth,
  6972. gutterWidth: gutterW
  6973. }
  6974. }
  6975. var NativeScrollbars = function(place, scroll, cm) {
  6976. this.cm = cm;
  6977. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  6978. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  6979. vert.tabIndex = horiz.tabIndex = -1;
  6980. place(vert); place(horiz);
  6981. on(vert, "scroll", function () {
  6982. if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); }
  6983. });
  6984. on(horiz, "scroll", function () {
  6985. if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); }
  6986. });
  6987. this.checkedZeroWidth = false;
  6988. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  6989. if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; }
  6990. };
  6991. NativeScrollbars.prototype.update = function (measure) {
  6992. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  6993. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  6994. var sWidth = measure.nativeBarWidth;
  6995. if (needsV) {
  6996. this.vert.style.display = "block";
  6997. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  6998. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  6999. // A bug in IE8 can cause this value to be negative, so guard it.
  7000. this.vert.firstChild.style.height =
  7001. Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  7002. } else {
  7003. this.vert.style.display = "";
  7004. this.vert.firstChild.style.height = "0";
  7005. }
  7006. if (needsH) {
  7007. this.horiz.style.display = "block";
  7008. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  7009. this.horiz.style.left = measure.barLeft + "px";
  7010. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  7011. this.horiz.firstChild.style.width =
  7012. Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  7013. } else {
  7014. this.horiz.style.display = "";
  7015. this.horiz.firstChild.style.width = "0";
  7016. }
  7017. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  7018. if (sWidth == 0) { this.zeroWidthHack(); }
  7019. this.checkedZeroWidth = true;
  7020. }
  7021. return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
  7022. };
  7023. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  7024. if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }
  7025. if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }
  7026. };
  7027. NativeScrollbars.prototype.setScrollTop = function (pos) {
  7028. if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }
  7029. if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }
  7030. };
  7031. NativeScrollbars.prototype.zeroWidthHack = function () {
  7032. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  7033. this.horiz.style.height = this.vert.style.width = w;
  7034. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
  7035. this.disableHoriz = new Delayed;
  7036. this.disableVert = new Delayed;
  7037. };
  7038. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
  7039. bar.style.pointerEvents = "auto";
  7040. function maybeDisable() {
  7041. // To find out whether the scrollbar is still visible, we
  7042. // check whether the element under the pixel in the bottom
  7043. // right corner of the scrollbar box is the scrollbar box
  7044. // itself (when the bar is still visible) or its filler child
  7045. // (when the bar is hidden). If it is still visible, we keep
  7046. // it enabled, if it's hidden, we disable pointer events.
  7047. var box = bar.getBoundingClientRect();
  7048. var elt$$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
  7049. : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  7050. if (elt$$1 != bar) { bar.style.pointerEvents = "none"; }
  7051. else { delay.set(1000, maybeDisable); }
  7052. }
  7053. delay.set(1000, maybeDisable);
  7054. };
  7055. NativeScrollbars.prototype.clear = function () {
  7056. var parent = this.horiz.parentNode;
  7057. parent.removeChild(this.horiz);
  7058. parent.removeChild(this.vert);
  7059. };
  7060. var NullScrollbars = function () {};
  7061. NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
  7062. NullScrollbars.prototype.setScrollLeft = function () {};
  7063. NullScrollbars.prototype.setScrollTop = function () {};
  7064. NullScrollbars.prototype.clear = function () {};
  7065. function updateScrollbars(cm, measure) {
  7066. if (!measure) { measure = measureForScrollbars(cm); }
  7067. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
  7068. updateScrollbarsInner(cm, measure);
  7069. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  7070. if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
  7071. { updateHeightsInViewport(cm); }
  7072. updateScrollbarsInner(cm, measureForScrollbars(cm));
  7073. startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
  7074. }
  7075. }
  7076. // Re-synchronize the fake scrollbars with the actual size of the
  7077. // content.
  7078. function updateScrollbarsInner(cm, measure) {
  7079. var d = cm.display;
  7080. var sizes = d.scrollbars.update(measure);
  7081. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  7082. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  7083. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  7084. if (sizes.right && sizes.bottom) {
  7085. d.scrollbarFiller.style.display = "block";
  7086. d.scrollbarFiller.style.height = sizes.bottom + "px";
  7087. d.scrollbarFiller.style.width = sizes.right + "px";
  7088. } else { d.scrollbarFiller.style.display = ""; }
  7089. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  7090. d.gutterFiller.style.display = "block";
  7091. d.gutterFiller.style.height = sizes.bottom + "px";
  7092. d.gutterFiller.style.width = measure.gutterWidth + "px";
  7093. } else { d.gutterFiller.style.display = ""; }
  7094. }
  7095. var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
  7096. function initScrollbars(cm) {
  7097. if (cm.display.scrollbars) {
  7098. cm.display.scrollbars.clear();
  7099. if (cm.display.scrollbars.addClass)
  7100. { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  7101. }
  7102. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  7103. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  7104. // Prevent clicks in the scrollbars from killing focus
  7105. on(node, "mousedown", function () {
  7106. if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }
  7107. });
  7108. node.setAttribute("cm-not-content", "true");
  7109. }, function (pos, axis) {
  7110. if (axis == "horizontal") { setScrollLeft(cm, pos); }
  7111. else { updateScrollTop(cm, pos); }
  7112. }, cm);
  7113. if (cm.display.scrollbars.addClass)
  7114. { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  7115. }
  7116. // Operations are used to wrap a series of changes to the editor
  7117. // state in such a way that each change won't have to update the
  7118. // cursor and display (which would be awkward, slow, and
  7119. // error-prone). Instead, display updates are batched and then all
  7120. // combined and executed at once.
  7121. var nextOpId = 0;
  7122. // Start a new operation.
  7123. function startOperation(cm) {
  7124. cm.curOp = {
  7125. cm: cm,
  7126. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  7127. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  7128. forceUpdate: false, // Used to force a redraw
  7129. updateInput: 0, // Whether to reset the input textarea
  7130. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  7131. changeObjs: null, // Accumulated changes, for firing change events
  7132. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  7133. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  7134. selectionChanged: false, // Whether the selection needs to be redrawn
  7135. updateMaxLine: false, // Set when the widest line needs to be determined anew
  7136. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  7137. scrollToPos: null, // Used to scroll to a specific position
  7138. focus: false,
  7139. id: ++nextOpId // Unique ID
  7140. };
  7141. pushOperation(cm.curOp);
  7142. }
  7143. // Finish an operation, updating the display and signalling delayed events
  7144. function endOperation(cm) {
  7145. var op = cm.curOp;
  7146. if (op) { finishOperation(op, function (group) {
  7147. for (var i = 0; i < group.ops.length; i++)
  7148. { group.ops[i].cm.curOp = null; }
  7149. endOperations(group);
  7150. }); }
  7151. }
  7152. // The DOM updates done when an operation finishes are batched so
  7153. // that the minimum number of relayouts are required.
  7154. function endOperations(group) {
  7155. var ops = group.ops;
  7156. for (var i = 0; i < ops.length; i++) // Read DOM
  7157. { endOperation_R1(ops[i]); }
  7158. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  7159. { endOperation_W1(ops[i$1]); }
  7160. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  7161. { endOperation_R2(ops[i$2]); }
  7162. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  7163. { endOperation_W2(ops[i$3]); }
  7164. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  7165. { endOperation_finish(ops[i$4]); }
  7166. }
  7167. function endOperation_R1(op) {
  7168. var cm = op.cm, display = cm.display;
  7169. maybeClipScrollbars(cm);
  7170. if (op.updateMaxLine) { findMaxLine(cm); }
  7171. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
  7172. op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
  7173. op.scrollToPos.to.line >= display.viewTo) ||
  7174. display.maxLineChanged && cm.options.lineWrapping;
  7175. op.update = op.mustUpdate &&
  7176. new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
  7177. }
  7178. function endOperation_W1(op) {
  7179. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  7180. }
  7181. function endOperation_R2(op) {
  7182. var cm = op.cm, display = cm.display;
  7183. if (op.updatedDisplay) { updateHeightsInViewport(cm); }
  7184. op.barMeasure = measureForScrollbars(cm);
  7185. // If the max line changed since it was last measured, measure it,
  7186. // and ensure the document's width matches it.
  7187. // updateDisplay_W2 will use these properties to do the actual resizing
  7188. if (display.maxLineChanged && !cm.options.lineWrapping) {
  7189. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  7190. cm.display.sizerWidth = op.adjustWidthTo;
  7191. op.barMeasure.scrollWidth =
  7192. Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  7193. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  7194. }
  7195. if (op.updatedDisplay || op.selectionChanged)
  7196. { op.preparedSelection = display.input.prepareSelection(); }
  7197. }
  7198. function endOperation_W2(op) {
  7199. var cm = op.cm;
  7200. if (op.adjustWidthTo != null) {
  7201. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  7202. if (op.maxScrollLeft < cm.doc.scrollLeft)
  7203. { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }
  7204. cm.display.maxLineChanged = false;
  7205. }
  7206. var takeFocus = op.focus && op.focus == activeElt();
  7207. if (op.preparedSelection)
  7208. { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
  7209. if (op.updatedDisplay || op.startHeight != cm.doc.height)
  7210. { updateScrollbars(cm, op.barMeasure); }
  7211. if (op.updatedDisplay)
  7212. { setDocumentHeight(cm, op.barMeasure); }
  7213. if (op.selectionChanged) { restartBlink(cm); }
  7214. if (cm.state.focused && op.updateInput)
  7215. { cm.display.input.reset(op.typing); }
  7216. if (takeFocus) { ensureFocus(op.cm); }
  7217. }
  7218. function endOperation_finish(op) {
  7219. var cm = op.cm, display = cm.display, doc = cm.doc;
  7220. if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }
  7221. // Abort mouse wheel delta measurement, when scrolling explicitly
  7222. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
  7223. { display.wheelStartX = display.wheelStartY = null; }
  7224. // Propagate the scroll position to the actual DOM scroller
  7225. if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }
  7226. if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }
  7227. // If we need to scroll a specific position into view, do so.
  7228. if (op.scrollToPos) {
  7229. var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
  7230. clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
  7231. maybeScrollWindow(cm, rect);
  7232. }
  7233. // Fire events for markers that are hidden/unidden by editing or
  7234. // undoing
  7235. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
  7236. if (hidden) { for (var i = 0; i < hidden.length; ++i)
  7237. { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } }
  7238. if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
  7239. { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } }
  7240. if (display.wrapper.offsetHeight)
  7241. { doc.scrollTop = cm.display.scroller.scrollTop; }
  7242. // Fire change events, and delayed event handlers
  7243. if (op.changeObjs)
  7244. { signal(cm, "changes", cm, op.changeObjs); }
  7245. if (op.update)
  7246. { op.update.finish(); }
  7247. }
  7248. // Run the given function in an operation
  7249. function runInOp(cm, f) {
  7250. if (cm.curOp) { return f() }
  7251. startOperation(cm);
  7252. try { return f() }
  7253. finally { endOperation(cm); }
  7254. }
  7255. // Wraps a function in an operation. Returns the wrapped function.
  7256. function operation(cm, f) {
  7257. return function() {
  7258. if (cm.curOp) { return f.apply(cm, arguments) }
  7259. startOperation(cm);
  7260. try { return f.apply(cm, arguments) }
  7261. finally { endOperation(cm); }
  7262. }
  7263. }
  7264. // Used to add methods to editor and doc instances, wrapping them in
  7265. // operations.
  7266. function methodOp(f) {
  7267. return function() {
  7268. if (this.curOp) { return f.apply(this, arguments) }
  7269. startOperation(this);
  7270. try { return f.apply(this, arguments) }
  7271. finally { endOperation(this); }
  7272. }
  7273. }
  7274. function docMethodOp(f) {
  7275. return function() {
  7276. var cm = this.cm;
  7277. if (!cm || cm.curOp) { return f.apply(this, arguments) }
  7278. startOperation(cm);
  7279. try { return f.apply(this, arguments) }
  7280. finally { endOperation(cm); }
  7281. }
  7282. }
  7283. // HIGHLIGHT WORKER
  7284. function startWorker(cm, time) {
  7285. if (cm.doc.highlightFrontier < cm.display.viewTo)
  7286. { cm.state.highlight.set(time, bind(highlightWorker, cm)); }
  7287. }
  7288. function highlightWorker(cm) {
  7289. var doc = cm.doc;
  7290. if (doc.highlightFrontier >= cm.display.viewTo) { return }
  7291. var end = +new Date + cm.options.workTime;
  7292. var context = getContextBefore(cm, doc.highlightFrontier);
  7293. var changedLines = [];
  7294. doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  7295. if (context.line >= cm.display.viewFrom) { // Visible
  7296. var oldStyles = line.styles;
  7297. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
  7298. var highlighted = highlightLine(cm, line, context, true);
  7299. if (resetState) { context.state = resetState; }
  7300. line.styles = highlighted.styles;
  7301. var oldCls = line.styleClasses, newCls = highlighted.classes;
  7302. if (newCls) { line.styleClasses = newCls; }
  7303. else if (oldCls) { line.styleClasses = null; }
  7304. var ischange = !oldStyles || oldStyles.length != line.styles.length ||
  7305. oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  7306. for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }
  7307. if (ischange) { changedLines.push(context.line); }
  7308. line.stateAfter = context.save();
  7309. context.nextLine();
  7310. } else {
  7311. if (line.text.length <= cm.options.maxHighlightLength)
  7312. { processLine(cm, line.text, context); }
  7313. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  7314. context.nextLine();
  7315. }
  7316. if (+new Date > end) {
  7317. startWorker(cm, cm.options.workDelay);
  7318. return true
  7319. }
  7320. });
  7321. doc.highlightFrontier = context.line;
  7322. doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
  7323. if (changedLines.length) { runInOp(cm, function () {
  7324. for (var i = 0; i < changedLines.length; i++)
  7325. { regLineChange(cm, changedLines[i], "text"); }
  7326. }); }
  7327. }
  7328. // DISPLAY DRAWING
  7329. var DisplayUpdate = function(cm, viewport, force) {
  7330. var display = cm.display;
  7331. this.viewport = viewport;
  7332. // Store some values that we'll need later (but don't want to force a relayout for)
  7333. this.visible = visibleLines(display, cm.doc, viewport);
  7334. this.editorIsHidden = !display.wrapper.offsetWidth;
  7335. this.wrapperHeight = display.wrapper.clientHeight;
  7336. this.wrapperWidth = display.wrapper.clientWidth;
  7337. this.oldDisplayWidth = displayWidth(cm);
  7338. this.force = force;
  7339. this.dims = getDimensions(cm);
  7340. this.events = [];
  7341. };
  7342. DisplayUpdate.prototype.signal = function (emitter, type) {
  7343. if (hasHandler(emitter, type))
  7344. { this.events.push(arguments); }
  7345. };
  7346. DisplayUpdate.prototype.finish = function () {
  7347. var this$1 = this;
  7348. for (var i = 0; i < this.events.length; i++)
  7349. { signal.apply(null, this$1.events[i]); }
  7350. };
  7351. function maybeClipScrollbars(cm) {
  7352. var display = cm.display;
  7353. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  7354. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  7355. display.heightForcer.style.height = scrollGap(cm) + "px";
  7356. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  7357. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  7358. display.scrollbarsClipped = true;
  7359. }
  7360. }
  7361. function selectionSnapshot(cm) {
  7362. if (cm.hasFocus()) { return null }
  7363. var active = activeElt();
  7364. if (!active || !contains(cm.display.lineDiv, active)) { return null }
  7365. var result = {activeElt: active};
  7366. if (window.getSelection) {
  7367. var sel = window.getSelection();
  7368. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  7369. result.anchorNode = sel.anchorNode;
  7370. result.anchorOffset = sel.anchorOffset;
  7371. result.focusNode = sel.focusNode;
  7372. result.focusOffset = sel.focusOffset;
  7373. }
  7374. }
  7375. return result
  7376. }
  7377. function restoreSelection(snapshot) {
  7378. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
  7379. snapshot.activeElt.focus();
  7380. if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  7381. var sel = window.getSelection(), range$$1 = document.createRange();
  7382. range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  7383. range$$1.collapse(false);
  7384. sel.removeAllRanges();
  7385. sel.addRange(range$$1);
  7386. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  7387. }
  7388. }
  7389. // Does the actual updating of the line display. Bails out
  7390. // (returning false) when there is nothing to be done and forced is
  7391. // false.
  7392. function updateDisplayIfNeeded(cm, update) {
  7393. var display = cm.display, doc = cm.doc;
  7394. if (update.editorIsHidden) {
  7395. resetView(cm);
  7396. return false
  7397. }
  7398. // Bail out if the visible area is already rendered and nothing changed.
  7399. if (!update.force &&
  7400. update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
  7401. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
  7402. display.renderedView == display.view && countDirtyView(cm) == 0)
  7403. { return false }
  7404. if (maybeUpdateLineNumberWidth(cm)) {
  7405. resetView(cm);
  7406. update.dims = getDimensions(cm);
  7407. }
  7408. // Compute a suitable new viewport (from & to)
  7409. var end = doc.first + doc.size;
  7410. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
  7411. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  7412. if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }
  7413. if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }
  7414. if (sawCollapsedSpans) {
  7415. from = visualLineNo(cm.doc, from);
  7416. to = visualLineEndNo(cm.doc, to);
  7417. }
  7418. var different = from != display.viewFrom || to != display.viewTo ||
  7419. display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  7420. adjustView(cm, from, to);
  7421. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
  7422. // Position the mover div to align with the current scroll position
  7423. cm.display.mover.style.top = display.viewOffset + "px";
  7424. var toUpdate = countDirtyView(cm);
  7425. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
  7426. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
  7427. { return false }
  7428. // For big changes, we hide the enclosing element during the
  7429. // update, since that speeds up the operations on most browsers.
  7430. var selSnapshot = selectionSnapshot(cm);
  7431. if (toUpdate > 4) { display.lineDiv.style.display = "none"; }
  7432. patchDisplay(cm, display.updateLineNumbers, update.dims);
  7433. if (toUpdate > 4) { display.lineDiv.style.display = ""; }
  7434. display.renderedView = display.view;
  7435. // There might have been a widget with a focused element that got
  7436. // hidden or updated, if so re-focus it.
  7437. restoreSelection(selSnapshot);
  7438. // Prevent selection and cursors from interfering with the scroll
  7439. // width and height.
  7440. removeChildren(display.cursorDiv);
  7441. removeChildren(display.selectionDiv);
  7442. display.gutters.style.height = display.sizer.style.minHeight = 0;
  7443. if (different) {
  7444. display.lastWrapHeight = update.wrapperHeight;
  7445. display.lastWrapWidth = update.wrapperWidth;
  7446. startWorker(cm, 400);
  7447. }
  7448. display.updateLineNumbers = null;
  7449. return true
  7450. }
  7451. function postUpdateDisplay(cm, update) {
  7452. var viewport = update.viewport;
  7453. for (var first = true;; first = false) {
  7454. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  7455. // Clip forced viewport to actual scrollable area.
  7456. if (viewport && viewport.top != null)
  7457. { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }
  7458. // Updated line heights might result in the drawn area not
  7459. // actually covering the viewport. Keep looping until it does.
  7460. update.visible = visibleLines(cm.display, cm.doc, viewport);
  7461. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
  7462. { break }
  7463. }
  7464. if (!updateDisplayIfNeeded(cm, update)) { break }
  7465. updateHeightsInViewport(cm);
  7466. var barMeasure = measureForScrollbars(cm);
  7467. updateSelection(cm);
  7468. updateScrollbars(cm, barMeasure);
  7469. setDocumentHeight(cm, barMeasure);
  7470. update.force = false;
  7471. }
  7472. update.signal(cm, "update", cm);
  7473. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  7474. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  7475. cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
  7476. }
  7477. }
  7478. function updateDisplaySimple(cm, viewport) {
  7479. var update = new DisplayUpdate(cm, viewport);
  7480. if (updateDisplayIfNeeded(cm, update)) {
  7481. updateHeightsInViewport(cm);
  7482. postUpdateDisplay(cm, update);
  7483. var barMeasure = measureForScrollbars(cm);
  7484. updateSelection(cm);
  7485. updateScrollbars(cm, barMeasure);
  7486. setDocumentHeight(cm, barMeasure);
  7487. update.finish();
  7488. }
  7489. }
  7490. // Sync the actual display DOM structure with display.view, removing
  7491. // nodes for lines that are no longer in view, and creating the ones
  7492. // that are not there yet, and updating the ones that are out of
  7493. // date.
  7494. function patchDisplay(cm, updateNumbersFrom, dims) {
  7495. var display = cm.display, lineNumbers = cm.options.lineNumbers;
  7496. var container = display.lineDiv, cur = container.firstChild;
  7497. function rm(node) {
  7498. var next = node.nextSibling;
  7499. // Works around a throw-scroll bug in OS X Webkit
  7500. if (webkit && mac && cm.display.currentWheelTarget == node)
  7501. { node.style.display = "none"; }
  7502. else
  7503. { node.parentNode.removeChild(node); }
  7504. return next
  7505. }
  7506. var view = display.view, lineN = display.viewFrom;
  7507. // Loop over the elements in the view, syncing cur (the DOM nodes
  7508. // in display.lineDiv) with the view as we go.
  7509. for (var i = 0; i < view.length; i++) {
  7510. var lineView = view[i];
  7511. if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
  7512. var node = buildLineElement(cm, lineView, lineN, dims);
  7513. container.insertBefore(node, cur);
  7514. } else { // Already drawn
  7515. while (cur != lineView.node) { cur = rm(cur); }
  7516. var updateNumber = lineNumbers && updateNumbersFrom != null &&
  7517. updateNumbersFrom <= lineN && lineView.lineNumber;
  7518. if (lineView.changes) {
  7519. if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
  7520. updateLineForChanges(cm, lineView, lineN, dims);
  7521. }
  7522. if (updateNumber) {
  7523. removeChildren(lineView.lineNumber);
  7524. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  7525. }
  7526. cur = lineView.node.nextSibling;
  7527. }
  7528. lineN += lineView.size;
  7529. }
  7530. while (cur) { cur = rm(cur); }
  7531. }
  7532. function updateGutterSpace(display) {
  7533. var width = display.gutters.offsetWidth;
  7534. display.sizer.style.marginLeft = width + "px";
  7535. }
  7536. function setDocumentHeight(cm, measure) {
  7537. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  7538. cm.display.heightForcer.style.top = measure.docHeight + "px";
  7539. cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
  7540. }
  7541. // Re-align line numbers and gutter marks to compensate for
  7542. // horizontal scrolling.
  7543. function alignHorizontally(cm) {
  7544. var display = cm.display, view = display.view;
  7545. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
  7546. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  7547. var gutterW = display.gutters.offsetWidth, left = comp + "px";
  7548. for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
  7549. if (cm.options.fixedGutter) {
  7550. if (view[i].gutter)
  7551. { view[i].gutter.style.left = left; }
  7552. if (view[i].gutterBackground)
  7553. { view[i].gutterBackground.style.left = left; }
  7554. }
  7555. var align = view[i].alignable;
  7556. if (align) { for (var j = 0; j < align.length; j++)
  7557. { align[j].style.left = left; } }
  7558. } }
  7559. if (cm.options.fixedGutter)
  7560. { display.gutters.style.left = (comp + gutterW) + "px"; }
  7561. }
  7562. // Used to ensure that the line number gutter is still the right
  7563. // size for the current document size. Returns true when an update
  7564. // is needed.
  7565. function maybeUpdateLineNumberWidth(cm) {
  7566. if (!cm.options.lineNumbers) { return false }
  7567. var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
  7568. if (last.length != display.lineNumChars) {
  7569. var test = display.measure.appendChild(elt("div", [elt("div", last)],
  7570. "CodeMirror-linenumber CodeMirror-gutter-elt"));
  7571. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
  7572. display.lineGutter.style.width = "";
  7573. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  7574. display.lineNumWidth = display.lineNumInnerWidth + padding;
  7575. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  7576. display.lineGutter.style.width = display.lineNumWidth + "px";
  7577. updateGutterSpace(cm.display);
  7578. return true
  7579. }
  7580. return false
  7581. }
  7582. function getGutters(gutters, lineNumbers) {
  7583. var result = [], sawLineNumbers = false;
  7584. for (var i = 0; i < gutters.length; i++) {
  7585. var name = gutters[i], style = null;
  7586. if (typeof name != "string") { style = name.style; name = name.className; }
  7587. if (name == "CodeMirror-linenumbers") {
  7588. if (!lineNumbers) { continue }
  7589. else { sawLineNumbers = true; }
  7590. }
  7591. result.push({className: name, style: style});
  7592. }
  7593. if (lineNumbers && !sawLineNumbers) { result.push({className: "CodeMirror-linenumbers", style: null}); }
  7594. return result
  7595. }
  7596. // Rebuild the gutter elements, ensure the margin to the left of the
  7597. // code matches their width.
  7598. function renderGutters(display) {
  7599. var gutters = display.gutters, specs = display.gutterSpecs;
  7600. removeChildren(gutters);
  7601. display.lineGutter = null;
  7602. for (var i = 0; i < specs.length; ++i) {
  7603. var ref = specs[i];
  7604. var className = ref.className;
  7605. var style = ref.style;
  7606. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + className));
  7607. if (style) { gElt.style.cssText = style; }
  7608. if (className == "CodeMirror-linenumbers") {
  7609. display.lineGutter = gElt;
  7610. gElt.style.width = (display.lineNumWidth || 1) + "px";
  7611. }
  7612. }
  7613. gutters.style.display = specs.length ? "" : "none";
  7614. updateGutterSpace(display);
  7615. }
  7616. function updateGutters(cm) {
  7617. renderGutters(cm.display);
  7618. regChange(cm);
  7619. alignHorizontally(cm);
  7620. }
  7621. // The display handles the DOM integration, both for input reading
  7622. // and content drawing. It holds references to DOM nodes and
  7623. // display-related state.
  7624. function Display(place, doc, input, options) {
  7625. var d = this;
  7626. this.input = input;
  7627. // Covers bottom-right square when both scrollbars are present.
  7628. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  7629. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  7630. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  7631. // and h scrollbar is present.
  7632. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  7633. d.gutterFiller.setAttribute("cm-not-content", "true");
  7634. // Will contain the actual code, positioned to cover the viewport.
  7635. d.lineDiv = eltP("div", null, "CodeMirror-code");
  7636. // Elements are added to these to represent selection and cursors.
  7637. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  7638. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  7639. // A visibility: hidden element used to find the size of things.
  7640. d.measure = elt("div", null, "CodeMirror-measure");
  7641. // When lines outside of the viewport are measured, they are drawn in this.
  7642. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  7643. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  7644. d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
  7645. null, "position: relative; outline: none");
  7646. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  7647. // Moved around its parent to cover visible view.
  7648. d.mover = elt("div", [lines], null, "position: relative");
  7649. // Set to the height of the document, allowing scrolling.
  7650. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  7651. d.sizerWidth = null;
  7652. // Behavior of elts with overflow: auto and padding is
  7653. // inconsistent across browsers. This is used to ensure the
  7654. // scrollable area is big enough.
  7655. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  7656. // Will contain the gutters, if any.
  7657. d.gutters = elt("div", null, "CodeMirror-gutters");
  7658. d.lineGutter = null;
  7659. // Actual scrollable element.
  7660. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
  7661. d.scroller.setAttribute("tabIndex", "-1");
  7662. // The element in which the editor lives.
  7663. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
  7664. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  7665. if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
  7666. if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
  7667. if (place) {
  7668. if (place.appendChild) { place.appendChild(d.wrapper); }
  7669. else { place(d.wrapper); }
  7670. }
  7671. // Current rendered range (may be bigger than the view window).
  7672. d.viewFrom = d.viewTo = doc.first;
  7673. d.reportedViewFrom = d.reportedViewTo = doc.first;
  7674. // Information about the rendered lines.
  7675. d.view = [];
  7676. d.renderedView = null;
  7677. // Holds info about a single rendered line when it was rendered
  7678. // for measurement, while not in view.
  7679. d.externalMeasured = null;
  7680. // Empty space (in pixels) above the view
  7681. d.viewOffset = 0;
  7682. d.lastWrapHeight = d.lastWrapWidth = 0;
  7683. d.updateLineNumbers = null;
  7684. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  7685. d.scrollbarsClipped = false;
  7686. // Used to only resize the line number gutter when necessary (when
  7687. // the amount of lines crosses a boundary that makes its width change)
  7688. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  7689. // Set to true when a non-horizontal-scrolling line widget is
  7690. // added. As an optimization, line widget aligning is skipped when
  7691. // this is false.
  7692. d.alignWidgets = false;
  7693. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  7694. // Tracks the maximum line length so that the horizontal scrollbar
  7695. // can be kept static when scrolling.
  7696. d.maxLine = null;
  7697. d.maxLineLength = 0;
  7698. d.maxLineChanged = false;
  7699. // Used for measuring wheel scrolling granularity
  7700. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  7701. // True when shift is held down.
  7702. d.shift = false;
  7703. // Used to track whether anything happened since the context menu
  7704. // was opened.
  7705. d.selForContextMenu = null;
  7706. d.activeTouch = null;
  7707. d.gutterSpecs = getGutters(options.gutters, options.lineNumbers);
  7708. renderGutters(d);
  7709. input.init(d);
  7710. }
  7711. // Since the delta values reported on mouse wheel events are
  7712. // unstandardized between browsers and even browser versions, and
  7713. // generally horribly unpredictable, this code starts by measuring
  7714. // the scroll effect that the first few mouse wheel events have,
  7715. // and, from that, detects the way it can convert deltas to pixel
  7716. // offsets afterwards.
  7717. //
  7718. // The reason we want to know the amount a wheel event will scroll
  7719. // is that it gives us a chance to update the display before the
  7720. // actual scrolling happens, reducing flickering.
  7721. var wheelSamples = 0, wheelPixelsPerUnit = null;
  7722. // Fill in a browser-detected starting value on browsers where we
  7723. // know one. These don't have to be accurate -- the result of them
  7724. // being wrong would just be a slight flicker on the first wheel
  7725. // scroll (if it is large enough).
  7726. if (ie) { wheelPixelsPerUnit = -.53; }
  7727. else if (gecko) { wheelPixelsPerUnit = 15; }
  7728. else if (chrome) { wheelPixelsPerUnit = -.7; }
  7729. else if (safari) { wheelPixelsPerUnit = -1/3; }
  7730. function wheelEventDelta(e) {
  7731. var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
  7732. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }
  7733. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }
  7734. else if (dy == null) { dy = e.wheelDelta; }
  7735. return {x: dx, y: dy}
  7736. }
  7737. function wheelEventPixels(e) {
  7738. var delta = wheelEventDelta(e);
  7739. delta.x *= wheelPixelsPerUnit;
  7740. delta.y *= wheelPixelsPerUnit;
  7741. return delta
  7742. }
  7743. function onScrollWheel(cm, e) {
  7744. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
  7745. var display = cm.display, scroll = display.scroller;
  7746. // Quit if there's nothing to scroll here
  7747. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  7748. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  7749. if (!(dx && canScrollX || dy && canScrollY)) { return }
  7750. // Webkit browsers on OS X abort momentum scrolls when the target
  7751. // of the scroll event is removed from the scrollable element.
  7752. // This hack (see related code in patchDisplay) makes sure the
  7753. // element is kept around.
  7754. if (dy && mac && webkit) {
  7755. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  7756. for (var i = 0; i < view.length; i++) {
  7757. if (view[i].node == cur) {
  7758. cm.display.currentWheelTarget = cur;
  7759. break outer
  7760. }
  7761. }
  7762. }
  7763. }
  7764. // On some browsers, horizontal scrolling will cause redraws to
  7765. // happen before the gutter has been realigned, causing it to
  7766. // wriggle around in a most unseemly way. When we have an
  7767. // estimated pixels/delta value, we just handle horizontal
  7768. // scrolling entirely here. It'll be slightly off from native, but
  7769. // better than glitching out.
  7770. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  7771. if (dy && canScrollY)
  7772. { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
  7773. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
  7774. // Only prevent default scrolling if vertical scrolling is
  7775. // actually possible. Otherwise, it causes vertical scroll
  7776. // jitter on OSX trackpads when deltaX is small and deltaY
  7777. // is large (issue #3579)
  7778. if (!dy || (dy && canScrollY))
  7779. { e_preventDefault(e); }
  7780. display.wheelStartX = null; // Abort measurement, if in progress
  7781. return
  7782. }
  7783. // 'Project' the visible viewport to cover the area that is being
  7784. // scrolled into view (if we know enough to estimate it).
  7785. if (dy && wheelPixelsPerUnit != null) {
  7786. var pixels = dy * wheelPixelsPerUnit;
  7787. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
  7788. if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
  7789. else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
  7790. updateDisplaySimple(cm, {top: top, bottom: bot});
  7791. }
  7792. if (wheelSamples < 20) {
  7793. if (display.wheelStartX == null) {
  7794. display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
  7795. display.wheelDX = dx; display.wheelDY = dy;
  7796. setTimeout(function () {
  7797. if (display.wheelStartX == null) { return }
  7798. var movedX = scroll.scrollLeft - display.wheelStartX;
  7799. var movedY = scroll.scrollTop - display.wheelStartY;
  7800. var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
  7801. (movedX && display.wheelDX && movedX / display.wheelDX);
  7802. display.wheelStartX = display.wheelStartY = null;
  7803. if (!sample) { return }
  7804. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  7805. ++wheelSamples;
  7806. }, 200);
  7807. } else {
  7808. display.wheelDX += dx; display.wheelDY += dy;
  7809. }
  7810. }
  7811. }
  7812. // Selection objects are immutable. A new one is created every time
  7813. // the selection changes. A selection is one or more non-overlapping
  7814. // (and non-touching) ranges, sorted, and an integer that indicates
  7815. // which one is the primary selection (the one that's scrolled into
  7816. // view, that getCursor returns, etc).
  7817. var Selection = function(ranges, primIndex) {
  7818. this.ranges = ranges;
  7819. this.primIndex = primIndex;
  7820. };
  7821. Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
  7822. Selection.prototype.equals = function (other) {
  7823. var this$1 = this;
  7824. if (other == this) { return true }
  7825. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
  7826. for (var i = 0; i < this.ranges.length; i++) {
  7827. var here = this$1.ranges[i], there = other.ranges[i];
  7828. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
  7829. }
  7830. return true
  7831. };
  7832. Selection.prototype.deepCopy = function () {
  7833. var this$1 = this;
  7834. var out = [];
  7835. for (var i = 0; i < this.ranges.length; i++)
  7836. { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)); }
  7837. return new Selection(out, this.primIndex)
  7838. };
  7839. Selection.prototype.somethingSelected = function () {
  7840. var this$1 = this;
  7841. for (var i = 0; i < this.ranges.length; i++)
  7842. { if (!this$1.ranges[i].empty()) { return true } }
  7843. return false
  7844. };
  7845. Selection.prototype.contains = function (pos, end) {
  7846. var this$1 = this;
  7847. if (!end) { end = pos; }
  7848. for (var i = 0; i < this.ranges.length; i++) {
  7849. var range = this$1.ranges[i];
  7850. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
  7851. { return i }
  7852. }
  7853. return -1
  7854. };
  7855. var Range = function(anchor, head) {
  7856. this.anchor = anchor; this.head = head;
  7857. };
  7858. Range.prototype.from = function () { return minPos(this.anchor, this.head) };
  7859. Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
  7860. Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
  7861. // Take an unsorted, potentially overlapping set of ranges, and
  7862. // build a selection out of it. 'Consumes' ranges array (modifying
  7863. // it).
  7864. function normalizeSelection(cm, ranges, primIndex) {
  7865. var mayTouch = cm && cm.options.selectionsMayTouch;
  7866. var prim = ranges[primIndex];
  7867. ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });
  7868. primIndex = indexOf(ranges, prim);
  7869. for (var i = 1; i < ranges.length; i++) {
  7870. var cur = ranges[i], prev = ranges[i - 1];
  7871. var diff = cmp(prev.to(), cur.from());
  7872. if (mayTouch && !cur.empty() ? diff > 0 : diff >= 0) {
  7873. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
  7874. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  7875. if (i <= primIndex) { --primIndex; }
  7876. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
  7877. }
  7878. }
  7879. return new Selection(ranges, primIndex)
  7880. }
  7881. function simpleSelection(anchor, head) {
  7882. return new Selection([new Range(anchor, head || anchor)], 0)
  7883. }
  7884. // Compute the position of the end of a change (its 'to' property
  7885. // refers to the pre-change end).
  7886. function changeEnd(change) {
  7887. if (!change.text) { return change.to }
  7888. return Pos(change.from.line + change.text.length - 1,
  7889. lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
  7890. }
  7891. // Adjust a position to refer to the post-change position of the
  7892. // same text, or the end of the change if the change covers it.
  7893. function adjustForChange(pos, change) {
  7894. if (cmp(pos, change.from) < 0) { return pos }
  7895. if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
  7896. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
  7897. if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
  7898. return Pos(line, ch)
  7899. }
  7900. function computeSelAfterChange(doc, change) {
  7901. var out = [];
  7902. for (var i = 0; i < doc.sel.ranges.length; i++) {
  7903. var range = doc.sel.ranges[i];
  7904. out.push(new Range(adjustForChange(range.anchor, change),
  7905. adjustForChange(range.head, change)));
  7906. }
  7907. return normalizeSelection(doc.cm, out, doc.sel.primIndex)
  7908. }
  7909. function offsetPos(pos, old, nw) {
  7910. if (pos.line == old.line)
  7911. { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
  7912. else
  7913. { return Pos(nw.line + (pos.line - old.line), pos.ch) }
  7914. }
  7915. // Used by replaceSelections to allow moving the selection to the
  7916. // start or around the replaced test. Hint may be "start" or "around".
  7917. function computeReplacedSel(doc, changes, hint) {
  7918. var out = [];
  7919. var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
  7920. for (var i = 0; i < changes.length; i++) {
  7921. var change = changes[i];
  7922. var from = offsetPos(change.from, oldPrev, newPrev);
  7923. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  7924. oldPrev = change.to;
  7925. newPrev = to;
  7926. if (hint == "around") {
  7927. var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
  7928. out[i] = new Range(inv ? to : from, inv ? from : to);
  7929. } else {
  7930. out[i] = new Range(from, from);
  7931. }
  7932. }
  7933. return new Selection(out, doc.sel.primIndex)
  7934. }
  7935. // Used to get the editor into a consistent state again when options change.
  7936. function loadMode(cm) {
  7937. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  7938. resetModeState(cm);
  7939. }
  7940. function resetModeState(cm) {
  7941. cm.doc.iter(function (line) {
  7942. if (line.stateAfter) { line.stateAfter = null; }
  7943. if (line.styles) { line.styles = null; }
  7944. });
  7945. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  7946. startWorker(cm, 100);
  7947. cm.state.modeGen++;
  7948. if (cm.curOp) { regChange(cm); }
  7949. }
  7950. // DOCUMENT DATA STRUCTURE
  7951. // By default, updates that start and end at the beginning of a line
  7952. // are treated specially, in order to make the association of line
  7953. // widgets and marker elements with the text behave more intuitive.
  7954. function isWholeLineUpdate(doc, change) {
  7955. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
  7956. (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
  7957. }
  7958. // Perform a change on the document data structure.
  7959. function updateDoc(doc, change, markedSpans, estimateHeight$$1) {
  7960. function spansFor(n) {return markedSpans ? markedSpans[n] : null}
  7961. function update(line, text, spans) {
  7962. updateLine(line, text, spans, estimateHeight$$1);
  7963. signalLater(line, "change", line, change);
  7964. }
  7965. function linesFor(start, end) {
  7966. var result = [];
  7967. for (var i = start; i < end; ++i)
  7968. { result.push(new Line(text[i], spansFor(i), estimateHeight$$1)); }
  7969. return result
  7970. }
  7971. var from = change.from, to = change.to, text = change.text;
  7972. var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
  7973. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
  7974. // Adjust the line structure
  7975. if (change.full) {
  7976. doc.insert(0, linesFor(0, text.length));
  7977. doc.remove(text.length, doc.size - text.length);
  7978. } else if (isWholeLineUpdate(doc, change)) {
  7979. // This is a whole-line replace. Treated specially to make
  7980. // sure line objects move the way they are supposed to.
  7981. var added = linesFor(0, text.length - 1);
  7982. update(lastLine, lastLine.text, lastSpans);
  7983. if (nlines) { doc.remove(from.line, nlines); }
  7984. if (added.length) { doc.insert(from.line, added); }
  7985. } else if (firstLine == lastLine) {
  7986. if (text.length == 1) {
  7987. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  7988. } else {
  7989. var added$1 = linesFor(1, text.length - 1);
  7990. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));
  7991. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  7992. doc.insert(from.line + 1, added$1);
  7993. }
  7994. } else if (text.length == 1) {
  7995. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  7996. doc.remove(from.line + 1, nlines);
  7997. } else {
  7998. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  7999. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  8000. var added$2 = linesFor(1, text.length - 1);
  8001. if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }
  8002. doc.insert(from.line + 1, added$2);
  8003. }
  8004. signalLater(doc, "change", doc, change);
  8005. }
  8006. // Call f for all linked documents.
  8007. function linkedDocs(doc, f, sharedHistOnly) {
  8008. function propagate(doc, skip, sharedHist) {
  8009. if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
  8010. var rel = doc.linked[i];
  8011. if (rel.doc == skip) { continue }
  8012. var shared = sharedHist && rel.sharedHist;
  8013. if (sharedHistOnly && !shared) { continue }
  8014. f(rel.doc, shared);
  8015. propagate(rel.doc, doc, shared);
  8016. } }
  8017. }
  8018. propagate(doc, null, true);
  8019. }
  8020. // Attach a document to an editor.
  8021. function attachDoc(cm, doc) {
  8022. if (doc.cm) { throw new Error("This document is already in use.") }
  8023. cm.doc = doc;
  8024. doc.cm = cm;
  8025. estimateLineHeights(cm);
  8026. loadMode(cm);
  8027. setDirectionClass(cm);
  8028. if (!cm.options.lineWrapping) { findMaxLine(cm); }
  8029. cm.options.mode = doc.modeOption;
  8030. regChange(cm);
  8031. }
  8032. function setDirectionClass(cm) {
  8033. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  8034. }
  8035. function directionChanged(cm) {
  8036. runInOp(cm, function () {
  8037. setDirectionClass(cm);
  8038. regChange(cm);
  8039. });
  8040. }
  8041. function History(startGen) {
  8042. // Arrays of change events and selections. Doing something adds an
  8043. // event to done and clears undo. Undoing moves events from done
  8044. // to undone, redoing moves them in the other direction.
  8045. this.done = []; this.undone = [];
  8046. this.undoDepth = Infinity;
  8047. // Used to track when changes can be merged into a single undo
  8048. // event
  8049. this.lastModTime = this.lastSelTime = 0;
  8050. this.lastOp = this.lastSelOp = null;
  8051. this.lastOrigin = this.lastSelOrigin = null;
  8052. // Used by the isClean() method
  8053. this.generation = this.maxGeneration = startGen || 1;
  8054. }
  8055. // Create a history change event from an updateDoc-style change
  8056. // object.
  8057. function historyChangeFromChange(doc, change) {
  8058. var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
  8059. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  8060. linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);
  8061. return histChange
  8062. }
  8063. // Pop all selection events off the end of a history array. Stop at
  8064. // a change event.
  8065. function clearSelectionEvents(array) {
  8066. while (array.length) {
  8067. var last = lst(array);
  8068. if (last.ranges) { array.pop(); }
  8069. else { break }
  8070. }
  8071. }
  8072. // Find the top change event in the history. Pop off selection
  8073. // events that are in the way.
  8074. function lastChangeEvent(hist, force) {
  8075. if (force) {
  8076. clearSelectionEvents(hist.done);
  8077. return lst(hist.done)
  8078. } else if (hist.done.length && !lst(hist.done).ranges) {
  8079. return lst(hist.done)
  8080. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  8081. hist.done.pop();
  8082. return lst(hist.done)
  8083. }
  8084. }
  8085. // Register a change in the history. Merges changes that are within
  8086. // a single operation, or are close together with an origin that
  8087. // allows merging (starting with "+") into a single event.
  8088. function addChangeToHistory(doc, change, selAfter, opId) {
  8089. var hist = doc.history;
  8090. hist.undone.length = 0;
  8091. var time = +new Date, cur;
  8092. var last;
  8093. if ((hist.lastOp == opId ||
  8094. hist.lastOrigin == change.origin && change.origin &&
  8095. ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
  8096. change.origin.charAt(0) == "*")) &&
  8097. (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  8098. // Merge this change into the last event
  8099. last = lst(cur.changes);
  8100. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  8101. // Optimized case for simple insertion -- don't want to add
  8102. // new changesets for every character typed
  8103. last.to = changeEnd(change);
  8104. } else {
  8105. // Add new sub-event
  8106. cur.changes.push(historyChangeFromChange(doc, change));
  8107. }
  8108. } else {
  8109. // Can not be merged, start a new event.
  8110. var before = lst(hist.done);
  8111. if (!before || !before.ranges)
  8112. { pushSelectionToHistory(doc.sel, hist.done); }
  8113. cur = {changes: [historyChangeFromChange(doc, change)],
  8114. generation: hist.generation};
  8115. hist.done.push(cur);
  8116. while (hist.done.length > hist.undoDepth) {
  8117. hist.done.shift();
  8118. if (!hist.done[0].ranges) { hist.done.shift(); }
  8119. }
  8120. }
  8121. hist.done.push(selAfter);
  8122. hist.generation = ++hist.maxGeneration;
  8123. hist.lastModTime = hist.lastSelTime = time;
  8124. hist.lastOp = hist.lastSelOp = opId;
  8125. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  8126. if (!last) { signal(doc, "historyAdded"); }
  8127. }
  8128. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  8129. var ch = origin.charAt(0);
  8130. return ch == "*" ||
  8131. ch == "+" &&
  8132. prev.ranges.length == sel.ranges.length &&
  8133. prev.somethingSelected() == sel.somethingSelected() &&
  8134. new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
  8135. }
  8136. // Called whenever the selection changes, sets the new selection as
  8137. // the pending selection in the history, and pushes the old pending
  8138. // selection into the 'done' array when it was significantly
  8139. // different (in number of selected ranges, emptiness, or time).
  8140. function addSelectionToHistory(doc, sel, opId, options) {
  8141. var hist = doc.history, origin = options && options.origin;
  8142. // A new event is started when the previous origin does not match
  8143. // the current, or the origins don't allow matching. Origins
  8144. // starting with * are always merged, those starting with + are
  8145. // merged when similar and close together in time.
  8146. if (opId == hist.lastSelOp ||
  8147. (origin && hist.lastSelOrigin == origin &&
  8148. (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
  8149. selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
  8150. { hist.done[hist.done.length - 1] = sel; }
  8151. else
  8152. { pushSelectionToHistory(sel, hist.done); }
  8153. hist.lastSelTime = +new Date;
  8154. hist.lastSelOrigin = origin;
  8155. hist.lastSelOp = opId;
  8156. if (options && options.clearRedo !== false)
  8157. { clearSelectionEvents(hist.undone); }
  8158. }
  8159. function pushSelectionToHistory(sel, dest) {
  8160. var top = lst(dest);
  8161. if (!(top && top.ranges && top.equals(sel)))
  8162. { dest.push(sel); }
  8163. }
  8164. // Used to store marked span information in the history.
  8165. function attachLocalSpans(doc, change, from, to) {
  8166. var existing = change["spans_" + doc.id], n = 0;
  8167. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  8168. if (line.markedSpans)
  8169. { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; }
  8170. ++n;
  8171. });
  8172. }
  8173. // When un/re-doing restores text containing marked spans, those
  8174. // that have been explicitly cleared should not be restored.
  8175. function removeClearedSpans(spans) {
  8176. if (!spans) { return null }
  8177. var out;
  8178. for (var i = 0; i < spans.length; ++i) {
  8179. if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }
  8180. else if (out) { out.push(spans[i]); }
  8181. }
  8182. return !out ? spans : out.length ? out : null
  8183. }
  8184. // Retrieve and filter the old marked spans stored in a change event.
  8185. function getOldSpans(doc, change) {
  8186. var found = change["spans_" + doc.id];
  8187. if (!found) { return null }
  8188. var nw = [];
  8189. for (var i = 0; i < change.text.length; ++i)
  8190. { nw.push(removeClearedSpans(found[i])); }
  8191. return nw
  8192. }
  8193. // Used for un/re-doing changes from the history. Combines the
  8194. // result of computing the existing spans with the set of spans that
  8195. // existed in the history (so that deleting around a span and then
  8196. // undoing brings back the span).
  8197. function mergeOldSpans(doc, change) {
  8198. var old = getOldSpans(doc, change);
  8199. var stretched = stretchSpansOverChange(doc, change);
  8200. if (!old) { return stretched }
  8201. if (!stretched) { return old }
  8202. for (var i = 0; i < old.length; ++i) {
  8203. var oldCur = old[i], stretchCur = stretched[i];
  8204. if (oldCur && stretchCur) {
  8205. spans: for (var j = 0; j < stretchCur.length; ++j) {
  8206. var span = stretchCur[j];
  8207. for (var k = 0; k < oldCur.length; ++k)
  8208. { if (oldCur[k].marker == span.marker) { continue spans } }
  8209. oldCur.push(span);
  8210. }
  8211. } else if (stretchCur) {
  8212. old[i] = stretchCur;
  8213. }
  8214. }
  8215. return old
  8216. }
  8217. // Used both to provide a JSON-safe object in .getHistory, and, when
  8218. // detaching a document, to split the history in two
  8219. function copyHistoryArray(events, newGroup, instantiateSel) {
  8220. var copy = [];
  8221. for (var i = 0; i < events.length; ++i) {
  8222. var event = events[i];
  8223. if (event.ranges) {
  8224. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  8225. continue
  8226. }
  8227. var changes = event.changes, newChanges = [];
  8228. copy.push({changes: newChanges});
  8229. for (var j = 0; j < changes.length; ++j) {
  8230. var change = changes[j], m = (void 0);
  8231. newChanges.push({from: change.from, to: change.to, text: change.text});
  8232. if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
  8233. if (indexOf(newGroup, Number(m[1])) > -1) {
  8234. lst(newChanges)[prop] = change[prop];
  8235. delete change[prop];
  8236. }
  8237. } } }
  8238. }
  8239. }
  8240. return copy
  8241. }
  8242. // The 'scroll' parameter given to many of these indicated whether
  8243. // the new cursor position should be scrolled into view after
  8244. // modifying the selection.
  8245. // If shift is held or the extend flag is set, extends a range to
  8246. // include a given position (and optionally a second position).
  8247. // Otherwise, simply returns the range between the given positions.
  8248. // Used for cursor motion and such.
  8249. function extendRange(range, head, other, extend) {
  8250. if (extend) {
  8251. var anchor = range.anchor;
  8252. if (other) {
  8253. var posBefore = cmp(head, anchor) < 0;
  8254. if (posBefore != (cmp(other, anchor) < 0)) {
  8255. anchor = head;
  8256. head = other;
  8257. } else if (posBefore != (cmp(head, other) < 0)) {
  8258. head = other;
  8259. }
  8260. }
  8261. return new Range(anchor, head)
  8262. } else {
  8263. return new Range(other || head, head)
  8264. }
  8265. }
  8266. // Extend the primary selection range, discard the rest.
  8267. function extendSelection(doc, head, other, options, extend) {
  8268. if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }
  8269. setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
  8270. }
  8271. // Extend all selections (pos is an array of selections with length
  8272. // equal the number of selections)
  8273. function extendSelections(doc, heads, options) {
  8274. var out = [];
  8275. var extend = doc.cm && (doc.cm.display.shift || doc.extend);
  8276. for (var i = 0; i < doc.sel.ranges.length; i++)
  8277. { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }
  8278. var newSel = normalizeSelection(doc.cm, out, doc.sel.primIndex);
  8279. setSelection(doc, newSel, options);
  8280. }
  8281. // Updates a single range in the selection.
  8282. function replaceOneSelection(doc, i, range, options) {
  8283. var ranges = doc.sel.ranges.slice(0);
  8284. ranges[i] = range;
  8285. setSelection(doc, normalizeSelection(doc.cm, ranges, doc.sel.primIndex), options);
  8286. }
  8287. // Reset the selection to a single range.
  8288. function setSimpleSelection(doc, anchor, head, options) {
  8289. setSelection(doc, simpleSelection(anchor, head), options);
  8290. }
  8291. // Give beforeSelectionChange handlers a change to influence a
  8292. // selection update.
  8293. function filterSelectionChange(doc, sel, options) {
  8294. var obj = {
  8295. ranges: sel.ranges,
  8296. update: function(ranges) {
  8297. var this$1 = this;
  8298. this.ranges = [];
  8299. for (var i = 0; i < ranges.length; i++)
  8300. { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
  8301. clipPos(doc, ranges[i].head)); }
  8302. },
  8303. origin: options && options.origin
  8304. };
  8305. signal(doc, "beforeSelectionChange", doc, obj);
  8306. if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); }
  8307. if (obj.ranges != sel.ranges) { return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1) }
  8308. else { return sel }
  8309. }
  8310. function setSelectionReplaceHistory(doc, sel, options) {
  8311. var done = doc.history.done, last = lst(done);
  8312. if (last && last.ranges) {
  8313. done[done.length - 1] = sel;
  8314. setSelectionNoUndo(doc, sel, options);
  8315. } else {
  8316. setSelection(doc, sel, options);
  8317. }
  8318. }
  8319. // Set a new selection.
  8320. function setSelection(doc, sel, options) {
  8321. setSelectionNoUndo(doc, sel, options);
  8322. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
  8323. }
  8324. function setSelectionNoUndo(doc, sel, options) {
  8325. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
  8326. { sel = filterSelectionChange(doc, sel, options); }
  8327. var bias = options && options.bias ||
  8328. (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
  8329. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
  8330. if (!(options && options.scroll === false) && doc.cm)
  8331. { ensureCursorVisible(doc.cm); }
  8332. }
  8333. function setSelectionInner(doc, sel) {
  8334. if (sel.equals(doc.sel)) { return }
  8335. doc.sel = sel;
  8336. if (doc.cm) {
  8337. doc.cm.curOp.updateInput = 1;
  8338. doc.cm.curOp.selectionChanged = true;
  8339. signalCursorActivity(doc.cm);
  8340. }
  8341. signalLater(doc, "cursorActivity", doc);
  8342. }
  8343. // Verify that the selection does not partially select any atomic
  8344. // marked ranges.
  8345. function reCheckSelection(doc) {
  8346. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
  8347. }
  8348. // Return a selection that does not partially select any atomic
  8349. // ranges.
  8350. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  8351. var out;
  8352. for (var i = 0; i < sel.ranges.length; i++) {
  8353. var range = sel.ranges[i];
  8354. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
  8355. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
  8356. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
  8357. if (out || newAnchor != range.anchor || newHead != range.head) {
  8358. if (!out) { out = sel.ranges.slice(0, i); }
  8359. out[i] = new Range(newAnchor, newHead);
  8360. }
  8361. }
  8362. return out ? normalizeSelection(doc.cm, out, sel.primIndex) : sel
  8363. }
  8364. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  8365. var line = getLine(doc, pos.line);
  8366. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  8367. var sp = line.markedSpans[i], m = sp.marker;
  8368. if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
  8369. (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  8370. if (mayClear) {
  8371. signal(m, "beforeCursorEnter");
  8372. if (m.explicitlyCleared) {
  8373. if (!line.markedSpans) { break }
  8374. else {--i; continue}
  8375. }
  8376. }
  8377. if (!m.atomic) { continue }
  8378. if (oldPos) {
  8379. var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
  8380. if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
  8381. { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
  8382. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
  8383. { return skipAtomicInner(doc, near, pos, dir, mayClear) }
  8384. }
  8385. var far = m.find(dir < 0 ? -1 : 1);
  8386. if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
  8387. { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
  8388. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
  8389. }
  8390. } }
  8391. return pos
  8392. }
  8393. // Ensure a given position is not inside an atomic range.
  8394. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  8395. var dir = bias || 1;
  8396. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
  8397. (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
  8398. skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
  8399. (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
  8400. if (!found) {
  8401. doc.cantEdit = true;
  8402. return Pos(doc.first, 0)
  8403. }
  8404. return found
  8405. }
  8406. function movePos(doc, pos, dir, line) {
  8407. if (dir < 0 && pos.ch == 0) {
  8408. if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
  8409. else { return null }
  8410. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  8411. if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
  8412. else { return null }
  8413. } else {
  8414. return new Pos(pos.line, pos.ch + dir)
  8415. }
  8416. }
  8417. function selectAll(cm) {
  8418. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  8419. }
  8420. // UPDATING
  8421. // Allow "beforeChange" event handlers to influence a change
  8422. function filterChange(doc, change, update) {
  8423. var obj = {
  8424. canceled: false,
  8425. from: change.from,
  8426. to: change.to,
  8427. text: change.text,
  8428. origin: change.origin,
  8429. cancel: function () { return obj.canceled = true; }
  8430. };
  8431. if (update) { obj.update = function (from, to, text, origin) {
  8432. if (from) { obj.from = clipPos(doc, from); }
  8433. if (to) { obj.to = clipPos(doc, to); }
  8434. if (text) { obj.text = text; }
  8435. if (origin !== undefined) { obj.origin = origin; }
  8436. }; }
  8437. signal(doc, "beforeChange", doc, obj);
  8438. if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
  8439. if (obj.canceled) {
  8440. if (doc.cm) { doc.cm.curOp.updateInput = 2; }
  8441. return null
  8442. }
  8443. return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
  8444. }
  8445. // Apply a change to a document, and add it to the document's
  8446. // history, and propagating it to all linked documents.
  8447. function makeChange(doc, change, ignoreReadOnly) {
  8448. if (doc.cm) {
  8449. if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
  8450. if (doc.cm.state.suppressEdits) { return }
  8451. }
  8452. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  8453. change = filterChange(doc, change, true);
  8454. if (!change) { return }
  8455. }
  8456. // Possibly split or suppress the update based on the presence
  8457. // of read-only spans in its range.
  8458. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
  8459. if (split) {
  8460. for (var i = split.length - 1; i >= 0; --i)
  8461. { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); }
  8462. } else {
  8463. makeChangeInner(doc, change);
  8464. }
  8465. }
  8466. function makeChangeInner(doc, change) {
  8467. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
  8468. var selAfter = computeSelAfterChange(doc, change);
  8469. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
  8470. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
  8471. var rebased = [];
  8472. linkedDocs(doc, function (doc, sharedHist) {
  8473. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  8474. rebaseHist(doc.history, change);
  8475. rebased.push(doc.history);
  8476. }
  8477. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
  8478. });
  8479. }
  8480. // Revert a change stored in a document's history.
  8481. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  8482. var suppress = doc.cm && doc.cm.state.suppressEdits;
  8483. if (suppress && !allowSelectionOnly) { return }
  8484. var hist = doc.history, event, selAfter = doc.sel;
  8485. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
  8486. // Verify that there is a useable event (so that ctrl-z won't
  8487. // needlessly clear selection events)
  8488. var i = 0;
  8489. for (; i < source.length; i++) {
  8490. event = source[i];
  8491. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
  8492. { break }
  8493. }
  8494. if (i == source.length) { return }
  8495. hist.lastOrigin = hist.lastSelOrigin = null;
  8496. for (;;) {
  8497. event = source.pop();
  8498. if (event.ranges) {
  8499. pushSelectionToHistory(event, dest);
  8500. if (allowSelectionOnly && !event.equals(doc.sel)) {
  8501. setSelection(doc, event, {clearRedo: false});
  8502. return
  8503. }
  8504. selAfter = event;
  8505. } else if (suppress) {
  8506. source.push(event);
  8507. return
  8508. } else { break }
  8509. }
  8510. // Build up a reverse change object to add to the opposite history
  8511. // stack (redo when undoing, and vice versa).
  8512. var antiChanges = [];
  8513. pushSelectionToHistory(selAfter, dest);
  8514. dest.push({changes: antiChanges, generation: hist.generation});
  8515. hist.generation = event.generation || ++hist.maxGeneration;
  8516. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
  8517. var loop = function ( i ) {
  8518. var change = event.changes[i];
  8519. change.origin = type;
  8520. if (filter && !filterChange(doc, change, false)) {
  8521. source.length = 0;
  8522. return {}
  8523. }
  8524. antiChanges.push(historyChangeFromChange(doc, change));
  8525. var after = i ? computeSelAfterChange(doc, change) : lst(source);
  8526. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
  8527. if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }
  8528. var rebased = [];
  8529. // Propagate to the linked documents
  8530. linkedDocs(doc, function (doc, sharedHist) {
  8531. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  8532. rebaseHist(doc.history, change);
  8533. rebased.push(doc.history);
  8534. }
  8535. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
  8536. });
  8537. };
  8538. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  8539. var returned = loop( i$1 );
  8540. if ( returned ) return returned.v;
  8541. }
  8542. }
  8543. // Sub-views need their line numbers shifted when text is added
  8544. // above or below them in the parent document.
  8545. function shiftDoc(doc, distance) {
  8546. if (distance == 0) { return }
  8547. doc.first += distance;
  8548. doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
  8549. Pos(range.anchor.line + distance, range.anchor.ch),
  8550. Pos(range.head.line + distance, range.head.ch)
  8551. ); }), doc.sel.primIndex);
  8552. if (doc.cm) {
  8553. regChange(doc.cm, doc.first, doc.first - distance, distance);
  8554. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
  8555. { regLineChange(doc.cm, l, "gutter"); }
  8556. }
  8557. }
  8558. // More lower-level change function, handling only a single document
  8559. // (not linked ones).
  8560. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  8561. if (doc.cm && !doc.cm.curOp)
  8562. { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
  8563. if (change.to.line < doc.first) {
  8564. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
  8565. return
  8566. }
  8567. if (change.from.line > doc.lastLine()) { return }
  8568. // Clip the change to the size of this doc
  8569. if (change.from.line < doc.first) {
  8570. var shift = change.text.length - 1 - (doc.first - change.from.line);
  8571. shiftDoc(doc, shift);
  8572. change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  8573. text: [lst(change.text)], origin: change.origin};
  8574. }
  8575. var last = doc.lastLine();
  8576. if (change.to.line > last) {
  8577. change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
  8578. text: [change.text[0]], origin: change.origin};
  8579. }
  8580. change.removed = getBetween(doc, change.from, change.to);
  8581. if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
  8582. if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
  8583. else { updateDoc(doc, change, spans); }
  8584. setSelectionNoUndo(doc, selAfter, sel_dontScroll);
  8585. }
  8586. // Handle the interaction of a change to a document with the editor
  8587. // that this document is part of.
  8588. function makeChangeSingleDocInEditor(cm, change, spans) {
  8589. var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
  8590. var recomputeMaxLength = false, checkWidthStart = from.line;
  8591. if (!cm.options.lineWrapping) {
  8592. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
  8593. doc.iter(checkWidthStart, to.line + 1, function (line) {
  8594. if (line == display.maxLine) {
  8595. recomputeMaxLength = true;
  8596. return true
  8597. }
  8598. });
  8599. }
  8600. if (doc.sel.contains(change.from, change.to) > -1)
  8601. { signalCursorActivity(cm); }
  8602. updateDoc(doc, change, spans, estimateHeight(cm));
  8603. if (!cm.options.lineWrapping) {
  8604. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  8605. var len = lineLength(line);
  8606. if (len > display.maxLineLength) {
  8607. display.maxLine = line;
  8608. display.maxLineLength = len;
  8609. display.maxLineChanged = true;
  8610. recomputeMaxLength = false;
  8611. }
  8612. });
  8613. if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }
  8614. }
  8615. retreatFrontier(doc, from.line);
  8616. startWorker(cm, 400);
  8617. var lendiff = change.text.length - (to.line - from.line) - 1;
  8618. // Remember that these lines changed, for updating the display
  8619. if (change.full)
  8620. { regChange(cm); }
  8621. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
  8622. { regLineChange(cm, from.line, "text"); }
  8623. else
  8624. { regChange(cm, from.line, to.line + 1, lendiff); }
  8625. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
  8626. if (changeHandler || changesHandler) {
  8627. var obj = {
  8628. from: from, to: to,
  8629. text: change.text,
  8630. removed: change.removed,
  8631. origin: change.origin
  8632. };
  8633. if (changeHandler) { signalLater(cm, "change", cm, obj); }
  8634. if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }
  8635. }
  8636. cm.display.selForContextMenu = null;
  8637. }
  8638. function replaceRange(doc, code, from, to, origin) {
  8639. var assign;
  8640. if (!to) { to = from; }
  8641. if (cmp(to, from) < 0) { (assign = [to, from], from = assign[0], to = assign[1]); }
  8642. if (typeof code == "string") { code = doc.splitLines(code); }
  8643. makeChange(doc, {from: from, to: to, text: code, origin: origin});
  8644. }
  8645. // Rebasing/resetting history to deal with externally-sourced changes
  8646. function rebaseHistSelSingle(pos, from, to, diff) {
  8647. if (to < pos.line) {
  8648. pos.line += diff;
  8649. } else if (from < pos.line) {
  8650. pos.line = from;
  8651. pos.ch = 0;
  8652. }
  8653. }
  8654. // Tries to rebase an array of history events given a change in the
  8655. // document. If the change touches the same lines as the event, the
  8656. // event, and everything 'behind' it, is discarded. If the change is
  8657. // before the event, the event's positions are updated. Uses a
  8658. // copy-on-write scheme for the positions, to avoid having to
  8659. // reallocate them all on every rebase, but also avoid problems with
  8660. // shared position objects being unsafely updated.
  8661. function rebaseHistArray(array, from, to, diff) {
  8662. for (var i = 0; i < array.length; ++i) {
  8663. var sub = array[i], ok = true;
  8664. if (sub.ranges) {
  8665. if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
  8666. for (var j = 0; j < sub.ranges.length; j++) {
  8667. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  8668. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  8669. }
  8670. continue
  8671. }
  8672. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  8673. var cur = sub.changes[j$1];
  8674. if (to < cur.from.line) {
  8675. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  8676. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  8677. } else if (from <= cur.to.line) {
  8678. ok = false;
  8679. break
  8680. }
  8681. }
  8682. if (!ok) {
  8683. array.splice(0, i + 1);
  8684. i = 0;
  8685. }
  8686. }
  8687. }
  8688. function rebaseHist(hist, change) {
  8689. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
  8690. rebaseHistArray(hist.done, from, to, diff);
  8691. rebaseHistArray(hist.undone, from, to, diff);
  8692. }
  8693. // Utility for applying a change to a line by handle or number,
  8694. // returning the number and optionally registering the line as
  8695. // changed.
  8696. function changeLine(doc, handle, changeType, op) {
  8697. var no = handle, line = handle;
  8698. if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); }
  8699. else { no = lineNo(handle); }
  8700. if (no == null) { return null }
  8701. if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }
  8702. return line
  8703. }
  8704. // The document is represented as a BTree consisting of leaves, with
  8705. // chunk of lines in them, and branches, with up to ten leaves or
  8706. // other branch nodes below them. The top node is always a branch
  8707. // node, and is the document object itself (meaning it has
  8708. // additional methods and properties).
  8709. //
  8710. // All nodes have parent links. The tree is used both to go from
  8711. // line numbers to line objects, and to go from objects to numbers.
  8712. // It also indexes by height, and is used to convert between height
  8713. // and line object, and to find the total height of the document.
  8714. //
  8715. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  8716. function LeafChunk(lines) {
  8717. var this$1 = this;
  8718. this.lines = lines;
  8719. this.parent = null;
  8720. var height = 0;
  8721. for (var i = 0; i < lines.length; ++i) {
  8722. lines[i].parent = this$1;
  8723. height += lines[i].height;
  8724. }
  8725. this.height = height;
  8726. }
  8727. LeafChunk.prototype = {
  8728. chunkSize: function() { return this.lines.length },
  8729. // Remove the n lines at offset 'at'.
  8730. removeInner: function(at, n) {
  8731. var this$1 = this;
  8732. for (var i = at, e = at + n; i < e; ++i) {
  8733. var line = this$1.lines[i];
  8734. this$1.height -= line.height;
  8735. cleanUpLine(line);
  8736. signalLater(line, "delete");
  8737. }
  8738. this.lines.splice(at, n);
  8739. },
  8740. // Helper used to collapse a small branch into a single leaf.
  8741. collapse: function(lines) {
  8742. lines.push.apply(lines, this.lines);
  8743. },
  8744. // Insert the given array of lines at offset 'at', count them as
  8745. // having the given height.
  8746. insertInner: function(at, lines, height) {
  8747. var this$1 = this;
  8748. this.height += height;
  8749. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  8750. for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1; }
  8751. },
  8752. // Used to iterate over a part of the tree.
  8753. iterN: function(at, n, op) {
  8754. var this$1 = this;
  8755. for (var e = at + n; at < e; ++at)
  8756. { if (op(this$1.lines[at])) { return true } }
  8757. }
  8758. };
  8759. function BranchChunk(children) {
  8760. var this$1 = this;
  8761. this.children = children;
  8762. var size = 0, height = 0;
  8763. for (var i = 0; i < children.length; ++i) {
  8764. var ch = children[i];
  8765. size += ch.chunkSize(); height += ch.height;
  8766. ch.parent = this$1;
  8767. }
  8768. this.size = size;
  8769. this.height = height;
  8770. this.parent = null;
  8771. }
  8772. BranchChunk.prototype = {
  8773. chunkSize: function() { return this.size },
  8774. removeInner: function(at, n) {
  8775. var this$1 = this;
  8776. this.size -= n;
  8777. for (var i = 0; i < this.children.length; ++i) {
  8778. var child = this$1.children[i], sz = child.chunkSize();
  8779. if (at < sz) {
  8780. var rm = Math.min(n, sz - at), oldHeight = child.height;
  8781. child.removeInner(at, rm);
  8782. this$1.height -= oldHeight - child.height;
  8783. if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null; }
  8784. if ((n -= rm) == 0) { break }
  8785. at = 0;
  8786. } else { at -= sz; }
  8787. }
  8788. // If the result is smaller than 25 lines, ensure that it is a
  8789. // single leaf node.
  8790. if (this.size - n < 25 &&
  8791. (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  8792. var lines = [];
  8793. this.collapse(lines);
  8794. this.children = [new LeafChunk(lines)];
  8795. this.children[0].parent = this;
  8796. }
  8797. },
  8798. collapse: function(lines) {
  8799. var this$1 = this;
  8800. for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines); }
  8801. },
  8802. insertInner: function(at, lines, height) {
  8803. var this$1 = this;
  8804. this.size += lines.length;
  8805. this.height += height;
  8806. for (var i = 0; i < this.children.length; ++i) {
  8807. var child = this$1.children[i], sz = child.chunkSize();
  8808. if (at <= sz) {
  8809. child.insertInner(at, lines, height);
  8810. if (child.lines && child.lines.length > 50) {
  8811. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  8812. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  8813. var remaining = child.lines.length % 25 + 25;
  8814. for (var pos = remaining; pos < child.lines.length;) {
  8815. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  8816. child.height -= leaf.height;
  8817. this$1.children.splice(++i, 0, leaf);
  8818. leaf.parent = this$1;
  8819. }
  8820. child.lines = child.lines.slice(0, remaining);
  8821. this$1.maybeSpill();
  8822. }
  8823. break
  8824. }
  8825. at -= sz;
  8826. }
  8827. },
  8828. // When a node has grown, check whether it should be split.
  8829. maybeSpill: function() {
  8830. if (this.children.length <= 10) { return }
  8831. var me = this;
  8832. do {
  8833. var spilled = me.children.splice(me.children.length - 5, 5);
  8834. var sibling = new BranchChunk(spilled);
  8835. if (!me.parent) { // Become the parent node
  8836. var copy = new BranchChunk(me.children);
  8837. copy.parent = me;
  8838. me.children = [copy, sibling];
  8839. me = copy;
  8840. } else {
  8841. me.size -= sibling.size;
  8842. me.height -= sibling.height;
  8843. var myIndex = indexOf(me.parent.children, me);
  8844. me.parent.children.splice(myIndex + 1, 0, sibling);
  8845. }
  8846. sibling.parent = me.parent;
  8847. } while (me.children.length > 10)
  8848. me.parent.maybeSpill();
  8849. },
  8850. iterN: function(at, n, op) {
  8851. var this$1 = this;
  8852. for (var i = 0; i < this.children.length; ++i) {
  8853. var child = this$1.children[i], sz = child.chunkSize();
  8854. if (at < sz) {
  8855. var used = Math.min(n, sz - at);
  8856. if (child.iterN(at, used, op)) { return true }
  8857. if ((n -= used) == 0) { break }
  8858. at = 0;
  8859. } else { at -= sz; }
  8860. }
  8861. }
  8862. };
  8863. // Line widgets are block elements displayed above or below a line.
  8864. var LineWidget = function(doc, node, options) {
  8865. var this$1 = this;
  8866. if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
  8867. { this$1[opt] = options[opt]; } } }
  8868. this.doc = doc;
  8869. this.node = node;
  8870. };
  8871. LineWidget.prototype.clear = function () {
  8872. var this$1 = this;
  8873. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
  8874. if (no == null || !ws) { return }
  8875. for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1); } }
  8876. if (!ws.length) { line.widgets = null; }
  8877. var height = widgetHeight(this);
  8878. updateLineHeight(line, Math.max(0, line.height - height));
  8879. if (cm) {
  8880. runInOp(cm, function () {
  8881. adjustScrollWhenAboveVisible(cm, line, -height);
  8882. regLineChange(cm, no, "widget");
  8883. });
  8884. signalLater(cm, "lineWidgetCleared", cm, this, no);
  8885. }
  8886. };
  8887. LineWidget.prototype.changed = function () {
  8888. var this$1 = this;
  8889. var oldH = this.height, cm = this.doc.cm, line = this.line;
  8890. this.height = null;
  8891. var diff = widgetHeight(this) - oldH;
  8892. if (!diff) { return }
  8893. if (!lineIsHidden(this.doc, line)) { updateLineHeight(line, line.height + diff); }
  8894. if (cm) {
  8895. runInOp(cm, function () {
  8896. cm.curOp.forceUpdate = true;
  8897. adjustScrollWhenAboveVisible(cm, line, diff);
  8898. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  8899. });
  8900. }
  8901. };
  8902. eventMixin(LineWidget);
  8903. function adjustScrollWhenAboveVisible(cm, line, diff) {
  8904. if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
  8905. { addToScrollTop(cm, diff); }
  8906. }
  8907. function addLineWidget(doc, handle, node, options) {
  8908. var widget = new LineWidget(doc, node, options);
  8909. var cm = doc.cm;
  8910. if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }
  8911. changeLine(doc, handle, "widget", function (line) {
  8912. var widgets = line.widgets || (line.widgets = []);
  8913. if (widget.insertAt == null) { widgets.push(widget); }
  8914. else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
  8915. widget.line = line;
  8916. if (cm && !lineIsHidden(doc, line)) {
  8917. var aboveVisible = heightAtLine(line) < doc.scrollTop;
  8918. updateLineHeight(line, line.height + widgetHeight(widget));
  8919. if (aboveVisible) { addToScrollTop(cm, widget.height); }
  8920. cm.curOp.forceUpdate = true;
  8921. }
  8922. return true
  8923. });
  8924. if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); }
  8925. return widget
  8926. }
  8927. // TEXTMARKERS
  8928. // Created with markText and setBookmark methods. A TextMarker is a
  8929. // handle that can be used to clear or find a marked position in the
  8930. // document. Line objects hold arrays (markedSpans) containing
  8931. // {from, to, marker} object pointing to such marker objects, and
  8932. // indicating that such a marker is present on that line. Multiple
  8933. // lines may point to the same marker when it spans across lines.
  8934. // The spans will have null for their from/to properties when the
  8935. // marker continues beyond the start/end of the line. Markers have
  8936. // links back to the lines they currently touch.
  8937. // Collapsed markers have unique ids, in order to be able to order
  8938. // them, which is needed for uniquely determining an outer marker
  8939. // when they overlap (they may nest, but not partially overlap).
  8940. var nextMarkerId = 0;
  8941. var TextMarker = function(doc, type) {
  8942. this.lines = [];
  8943. this.type = type;
  8944. this.doc = doc;
  8945. this.id = ++nextMarkerId;
  8946. };
  8947. // Clear the marker.
  8948. TextMarker.prototype.clear = function () {
  8949. var this$1 = this;
  8950. if (this.explicitlyCleared) { return }
  8951. var cm = this.doc.cm, withOp = cm && !cm.curOp;
  8952. if (withOp) { startOperation(cm); }
  8953. if (hasHandler(this, "clear")) {
  8954. var found = this.find();
  8955. if (found) { signalLater(this, "clear", found.from, found.to); }
  8956. }
  8957. var min = null, max = null;
  8958. for (var i = 0; i < this.lines.length; ++i) {
  8959. var line = this$1.lines[i];
  8960. var span = getMarkedSpanFor(line.markedSpans, this$1);
  8961. if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text"); }
  8962. else if (cm) {
  8963. if (span.to != null) { max = lineNo(line); }
  8964. if (span.from != null) { min = lineNo(line); }
  8965. }
  8966. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  8967. if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
  8968. { updateLineHeight(line, textHeight(cm.display)); }
  8969. }
  8970. if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  8971. var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual);
  8972. if (len > cm.display.maxLineLength) {
  8973. cm.display.maxLine = visual;
  8974. cm.display.maxLineLength = len;
  8975. cm.display.maxLineChanged = true;
  8976. }
  8977. } }
  8978. if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }
  8979. this.lines.length = 0;
  8980. this.explicitlyCleared = true;
  8981. if (this.atomic && this.doc.cantEdit) {
  8982. this.doc.cantEdit = false;
  8983. if (cm) { reCheckSelection(cm.doc); }
  8984. }
  8985. if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); }
  8986. if (withOp) { endOperation(cm); }
  8987. if (this.parent) { this.parent.clear(); }
  8988. };
  8989. // Find the position of the marker in the document. Returns a {from,
  8990. // to} object by default. Side can be passed to get a specific side
  8991. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  8992. // Pos objects returned contain a line object, rather than a line
  8993. // number (used to prevent looking up the same line twice).
  8994. TextMarker.prototype.find = function (side, lineObj) {
  8995. var this$1 = this;
  8996. if (side == null && this.type == "bookmark") { side = 1; }
  8997. var from, to;
  8998. for (var i = 0; i < this.lines.length; ++i) {
  8999. var line = this$1.lines[i];
  9000. var span = getMarkedSpanFor(line.markedSpans, this$1);
  9001. if (span.from != null) {
  9002. from = Pos(lineObj ? line : lineNo(line), span.from);
  9003. if (side == -1) { return from }
  9004. }
  9005. if (span.to != null) {
  9006. to = Pos(lineObj ? line : lineNo(line), span.to);
  9007. if (side == 1) { return to }
  9008. }
  9009. }
  9010. return from && {from: from, to: to}
  9011. };
  9012. // Signals that the marker's widget changed, and surrounding layout
  9013. // should be recomputed.
  9014. TextMarker.prototype.changed = function () {
  9015. var this$1 = this;
  9016. var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
  9017. if (!pos || !cm) { return }
  9018. runInOp(cm, function () {
  9019. var line = pos.line, lineN = lineNo(pos.line);
  9020. var view = findViewForLine(cm, lineN);
  9021. if (view) {
  9022. clearLineMeasurementCacheFor(view);
  9023. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  9024. }
  9025. cm.curOp.updateMaxLine = true;
  9026. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  9027. var oldHeight = widget.height;
  9028. widget.height = null;
  9029. var dHeight = widgetHeight(widget) - oldHeight;
  9030. if (dHeight)
  9031. { updateLineHeight(line, line.height + dHeight); }
  9032. }
  9033. signalLater(cm, "markerChanged", cm, this$1);
  9034. });
  9035. };
  9036. TextMarker.prototype.attachLine = function (line) {
  9037. if (!this.lines.length && this.doc.cm) {
  9038. var op = this.doc.cm.curOp;
  9039. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
  9040. { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }
  9041. }
  9042. this.lines.push(line);
  9043. };
  9044. TextMarker.prototype.detachLine = function (line) {
  9045. this.lines.splice(indexOf(this.lines, line), 1);
  9046. if (!this.lines.length && this.doc.cm) {
  9047. var op = this.doc.cm.curOp
  9048. ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  9049. }
  9050. };
  9051. eventMixin(TextMarker);
  9052. // Create a marker, wire it up to the right lines, and
  9053. function markText(doc, from, to, options, type) {
  9054. // Shared markers (across linked documents) are handled separately
  9055. // (markTextShared will call out to this again, once per
  9056. // document).
  9057. if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
  9058. // Ensure we are in an operation.
  9059. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
  9060. var marker = new TextMarker(doc, type), diff = cmp(from, to);
  9061. if (options) { copyObj(options, marker, false); }
  9062. // Don't connect empty markers unless clearWhenEmpty is false
  9063. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
  9064. { return marker }
  9065. if (marker.replacedWith) {
  9066. // Showing up as a widget implies collapsed (widget replaces text)
  9067. marker.collapsed = true;
  9068. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  9069. if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); }
  9070. if (options.insertLeft) { marker.widgetNode.insertLeft = true; }
  9071. }
  9072. if (marker.collapsed) {
  9073. if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
  9074. from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
  9075. { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
  9076. seeCollapsedSpans();
  9077. }
  9078. if (marker.addToHistory)
  9079. { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); }
  9080. var curLine = from.line, cm = doc.cm, updateMaxLine;
  9081. doc.iter(curLine, to.line + 1, function (line) {
  9082. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
  9083. { updateMaxLine = true; }
  9084. if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
  9085. addMarkedSpan(line, new MarkedSpan(marker,
  9086. curLine == from.line ? from.ch : null,
  9087. curLine == to.line ? to.ch : null));
  9088. ++curLine;
  9089. });
  9090. // lineIsHidden depends on the presence of the spans, so needs a second pass
  9091. if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
  9092. if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }
  9093. }); }
  9094. if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); }
  9095. if (marker.readOnly) {
  9096. seeReadOnlySpans();
  9097. if (doc.history.done.length || doc.history.undone.length)
  9098. { doc.clearHistory(); }
  9099. }
  9100. if (marker.collapsed) {
  9101. marker.id = ++nextMarkerId;
  9102. marker.atomic = true;
  9103. }
  9104. if (cm) {
  9105. // Sync editor state
  9106. if (updateMaxLine) { cm.curOp.updateMaxLine = true; }
  9107. if (marker.collapsed)
  9108. { regChange(cm, from.line, to.line + 1); }
  9109. else if (marker.className || marker.startStyle || marker.endStyle || marker.css ||
  9110. marker.attributes || marker.title)
  9111. { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } }
  9112. if (marker.atomic) { reCheckSelection(cm.doc); }
  9113. signalLater(cm, "markerAdded", cm, marker);
  9114. }
  9115. return marker
  9116. }
  9117. // SHARED TEXTMARKERS
  9118. // A shared marker spans multiple linked documents. It is
  9119. // implemented as a meta-marker-object controlling multiple normal
  9120. // markers.
  9121. var SharedTextMarker = function(markers, primary) {
  9122. var this$1 = this;
  9123. this.markers = markers;
  9124. this.primary = primary;
  9125. for (var i = 0; i < markers.length; ++i)
  9126. { markers[i].parent = this$1; }
  9127. };
  9128. SharedTextMarker.prototype.clear = function () {
  9129. var this$1 = this;
  9130. if (this.explicitlyCleared) { return }
  9131. this.explicitlyCleared = true;
  9132. for (var i = 0; i < this.markers.length; ++i)
  9133. { this$1.markers[i].clear(); }
  9134. signalLater(this, "clear");
  9135. };
  9136. SharedTextMarker.prototype.find = function (side, lineObj) {
  9137. return this.primary.find(side, lineObj)
  9138. };
  9139. eventMixin(SharedTextMarker);
  9140. function markTextShared(doc, from, to, options, type) {
  9141. options = copyObj(options);
  9142. options.shared = false;
  9143. var markers = [markText(doc, from, to, options, type)], primary = markers[0];
  9144. var widget = options.widgetNode;
  9145. linkedDocs(doc, function (doc) {
  9146. if (widget) { options.widgetNode = widget.cloneNode(true); }
  9147. markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
  9148. for (var i = 0; i < doc.linked.length; ++i)
  9149. { if (doc.linked[i].isParent) { return } }
  9150. primary = lst(markers);
  9151. });
  9152. return new SharedTextMarker(markers, primary)
  9153. }
  9154. function findSharedMarkers(doc) {
  9155. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
  9156. }
  9157. function copySharedMarkers(doc, markers) {
  9158. for (var i = 0; i < markers.length; i++) {
  9159. var marker = markers[i], pos = marker.find();
  9160. var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
  9161. if (cmp(mFrom, mTo)) {
  9162. var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
  9163. marker.markers.push(subMark);
  9164. subMark.parent = marker;
  9165. }
  9166. }
  9167. }
  9168. function detachSharedMarkers(markers) {
  9169. var loop = function ( i ) {
  9170. var marker = markers[i], linked = [marker.primary.doc];
  9171. linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });
  9172. for (var j = 0; j < marker.markers.length; j++) {
  9173. var subMarker = marker.markers[j];
  9174. if (indexOf(linked, subMarker.doc) == -1) {
  9175. subMarker.parent = null;
  9176. marker.markers.splice(j--, 1);
  9177. }
  9178. }
  9179. };
  9180. for (var i = 0; i < markers.length; i++) loop( i );
  9181. }
  9182. var nextDocId = 0;
  9183. var Doc = function(text, mode, firstLine, lineSep, direction) {
  9184. if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
  9185. if (firstLine == null) { firstLine = 0; }
  9186. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  9187. this.first = firstLine;
  9188. this.scrollTop = this.scrollLeft = 0;
  9189. this.cantEdit = false;
  9190. this.cleanGeneration = 1;
  9191. this.modeFrontier = this.highlightFrontier = firstLine;
  9192. var start = Pos(firstLine, 0);
  9193. this.sel = simpleSelection(start);
  9194. this.history = new History(null);
  9195. this.id = ++nextDocId;
  9196. this.modeOption = mode;
  9197. this.lineSep = lineSep;
  9198. this.direction = (direction == "rtl") ? "rtl" : "ltr";
  9199. this.extend = false;
  9200. if (typeof text == "string") { text = this.splitLines(text); }
  9201. updateDoc(this, {from: start, to: start, text: text});
  9202. setSelection(this, simpleSelection(start), sel_dontScroll);
  9203. };
  9204. Doc.prototype = createObj(BranchChunk.prototype, {
  9205. constructor: Doc,
  9206. // Iterate over the document. Supports two forms -- with only one
  9207. // argument, it calls that for each line in the document. With
  9208. // three, it iterates over the range given by the first two (with
  9209. // the second being non-inclusive).
  9210. iter: function(from, to, op) {
  9211. if (op) { this.iterN(from - this.first, to - from, op); }
  9212. else { this.iterN(this.first, this.first + this.size, from); }
  9213. },
  9214. // Non-public interface for adding and removing lines.
  9215. insert: function(at, lines) {
  9216. var height = 0;
  9217. for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }
  9218. this.insertInner(at - this.first, lines, height);
  9219. },
  9220. remove: function(at, n) { this.removeInner(at - this.first, n); },
  9221. // From here, the methods are part of the public interface. Most
  9222. // are also available from CodeMirror (editor) instances.
  9223. getValue: function(lineSep) {
  9224. var lines = getLines(this, this.first, this.first + this.size);
  9225. if (lineSep === false) { return lines }
  9226. return lines.join(lineSep || this.lineSeparator())
  9227. },
  9228. setValue: docMethodOp(function(code) {
  9229. var top = Pos(this.first, 0), last = this.first + this.size - 1;
  9230. makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
  9231. text: this.splitLines(code), origin: "setValue", full: true}, true);
  9232. if (this.cm) { scrollToCoords(this.cm, 0, 0); }
  9233. setSelection(this, simpleSelection(top), sel_dontScroll);
  9234. }),
  9235. replaceRange: function(code, from, to, origin) {
  9236. from = clipPos(this, from);
  9237. to = to ? clipPos(this, to) : from;
  9238. replaceRange(this, code, from, to, origin);
  9239. },
  9240. getRange: function(from, to, lineSep) {
  9241. var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
  9242. if (lineSep === false) { return lines }
  9243. return lines.join(lineSep || this.lineSeparator())
  9244. },
  9245. getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
  9246. getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
  9247. getLineNumber: function(line) {return lineNo(line)},
  9248. getLineHandleVisualStart: function(line) {
  9249. if (typeof line == "number") { line = getLine(this, line); }
  9250. return visualLine(line)
  9251. },
  9252. lineCount: function() {return this.size},
  9253. firstLine: function() {return this.first},
  9254. lastLine: function() {return this.first + this.size - 1},
  9255. clipPos: function(pos) {return clipPos(this, pos)},
  9256. getCursor: function(start) {
  9257. var range$$1 = this.sel.primary(), pos;
  9258. if (start == null || start == "head") { pos = range$$1.head; }
  9259. else if (start == "anchor") { pos = range$$1.anchor; }
  9260. else if (start == "end" || start == "to" || start === false) { pos = range$$1.to(); }
  9261. else { pos = range$$1.from(); }
  9262. return pos
  9263. },
  9264. listSelections: function() { return this.sel.ranges },
  9265. somethingSelected: function() {return this.sel.somethingSelected()},
  9266. setCursor: docMethodOp(function(line, ch, options) {
  9267. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  9268. }),
  9269. setSelection: docMethodOp(function(anchor, head, options) {
  9270. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
  9271. }),
  9272. extendSelection: docMethodOp(function(head, other, options) {
  9273. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
  9274. }),
  9275. extendSelections: docMethodOp(function(heads, options) {
  9276. extendSelections(this, clipPosArray(this, heads), options);
  9277. }),
  9278. extendSelectionsBy: docMethodOp(function(f, options) {
  9279. var heads = map(this.sel.ranges, f);
  9280. extendSelections(this, clipPosArray(this, heads), options);
  9281. }),
  9282. setSelections: docMethodOp(function(ranges, primary, options) {
  9283. var this$1 = this;
  9284. if (!ranges.length) { return }
  9285. var out = [];
  9286. for (var i = 0; i < ranges.length; i++)
  9287. { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
  9288. clipPos(this$1, ranges[i].head)); }
  9289. if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
  9290. setSelection(this, normalizeSelection(this.cm, out, primary), options);
  9291. }),
  9292. addSelection: docMethodOp(function(anchor, head, options) {
  9293. var ranges = this.sel.ranges.slice(0);
  9294. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
  9295. setSelection(this, normalizeSelection(this.cm, ranges, ranges.length - 1), options);
  9296. }),
  9297. getSelection: function(lineSep) {
  9298. var this$1 = this;
  9299. var ranges = this.sel.ranges, lines;
  9300. for (var i = 0; i < ranges.length; i++) {
  9301. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  9302. lines = lines ? lines.concat(sel) : sel;
  9303. }
  9304. if (lineSep === false) { return lines }
  9305. else { return lines.join(lineSep || this.lineSeparator()) }
  9306. },
  9307. getSelections: function(lineSep) {
  9308. var this$1 = this;
  9309. var parts = [], ranges = this.sel.ranges;
  9310. for (var i = 0; i < ranges.length; i++) {
  9311. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  9312. if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()); }
  9313. parts[i] = sel;
  9314. }
  9315. return parts
  9316. },
  9317. replaceSelection: function(code, collapse, origin) {
  9318. var dup = [];
  9319. for (var i = 0; i < this.sel.ranges.length; i++)
  9320. { dup[i] = code; }
  9321. this.replaceSelections(dup, collapse, origin || "+input");
  9322. },
  9323. replaceSelections: docMethodOp(function(code, collapse, origin) {
  9324. var this$1 = this;
  9325. var changes = [], sel = this.sel;
  9326. for (var i = 0; i < sel.ranges.length; i++) {
  9327. var range$$1 = sel.ranges[i];
  9328. changes[i] = {from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin};
  9329. }
  9330. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  9331. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
  9332. { makeChange(this$1, changes[i$1]); }
  9333. if (newSel) { setSelectionReplaceHistory(this, newSel); }
  9334. else if (this.cm) { ensureCursorVisible(this.cm); }
  9335. }),
  9336. undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
  9337. redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
  9338. undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
  9339. redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
  9340. setExtending: function(val) {this.extend = val;},
  9341. getExtending: function() {return this.extend},
  9342. historySize: function() {
  9343. var hist = this.history, done = 0, undone = 0;
  9344. for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }
  9345. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
  9346. return {undo: done, redo: undone}
  9347. },
  9348. clearHistory: function() {this.history = new History(this.history.maxGeneration);},
  9349. markClean: function() {
  9350. this.cleanGeneration = this.changeGeneration(true);
  9351. },
  9352. changeGeneration: function(forceSplit) {
  9353. if (forceSplit)
  9354. { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }
  9355. return this.history.generation
  9356. },
  9357. isClean: function (gen) {
  9358. return this.history.generation == (gen || this.cleanGeneration)
  9359. },
  9360. getHistory: function() {
  9361. return {done: copyHistoryArray(this.history.done),
  9362. undone: copyHistoryArray(this.history.undone)}
  9363. },
  9364. setHistory: function(histData) {
  9365. var hist = this.history = new History(this.history.maxGeneration);
  9366. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  9367. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  9368. },
  9369. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  9370. return changeLine(this, line, "gutter", function (line) {
  9371. var markers = line.gutterMarkers || (line.gutterMarkers = {});
  9372. markers[gutterID] = value;
  9373. if (!value && isEmpty(markers)) { line.gutterMarkers = null; }
  9374. return true
  9375. })
  9376. }),
  9377. clearGutter: docMethodOp(function(gutterID) {
  9378. var this$1 = this;
  9379. this.iter(function (line) {
  9380. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  9381. changeLine(this$1, line, "gutter", function () {
  9382. line.gutterMarkers[gutterID] = null;
  9383. if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }
  9384. return true
  9385. });
  9386. }
  9387. });
  9388. }),
  9389. lineInfo: function(line) {
  9390. var n;
  9391. if (typeof line == "number") {
  9392. if (!isLine(this, line)) { return null }
  9393. n = line;
  9394. line = getLine(this, line);
  9395. if (!line) { return null }
  9396. } else {
  9397. n = lineNo(line);
  9398. if (n == null) { return null }
  9399. }
  9400. return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  9401. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  9402. widgets: line.widgets}
  9403. },
  9404. addLineClass: docMethodOp(function(handle, where, cls) {
  9405. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  9406. var prop = where == "text" ? "textClass"
  9407. : where == "background" ? "bgClass"
  9408. : where == "gutter" ? "gutterClass" : "wrapClass";
  9409. if (!line[prop]) { line[prop] = cls; }
  9410. else if (classTest(cls).test(line[prop])) { return false }
  9411. else { line[prop] += " " + cls; }
  9412. return true
  9413. })
  9414. }),
  9415. removeLineClass: docMethodOp(function(handle, where, cls) {
  9416. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  9417. var prop = where == "text" ? "textClass"
  9418. : where == "background" ? "bgClass"
  9419. : where == "gutter" ? "gutterClass" : "wrapClass";
  9420. var cur = line[prop];
  9421. if (!cur) { return false }
  9422. else if (cls == null) { line[prop] = null; }
  9423. else {
  9424. var found = cur.match(classTest(cls));
  9425. if (!found) { return false }
  9426. var end = found.index + found[0].length;
  9427. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  9428. }
  9429. return true
  9430. })
  9431. }),
  9432. addLineWidget: docMethodOp(function(handle, node, options) {
  9433. return addLineWidget(this, handle, node, options)
  9434. }),
  9435. removeLineWidget: function(widget) { widget.clear(); },
  9436. markText: function(from, to, options) {
  9437. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
  9438. },
  9439. setBookmark: function(pos, options) {
  9440. var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
  9441. insertLeft: options && options.insertLeft,
  9442. clearWhenEmpty: false, shared: options && options.shared,
  9443. handleMouseEvents: options && options.handleMouseEvents};
  9444. pos = clipPos(this, pos);
  9445. return markText(this, pos, pos, realOpts, "bookmark")
  9446. },
  9447. findMarksAt: function(pos) {
  9448. pos = clipPos(this, pos);
  9449. var markers = [], spans = getLine(this, pos.line).markedSpans;
  9450. if (spans) { for (var i = 0; i < spans.length; ++i) {
  9451. var span = spans[i];
  9452. if ((span.from == null || span.from <= pos.ch) &&
  9453. (span.to == null || span.to >= pos.ch))
  9454. { markers.push(span.marker.parent || span.marker); }
  9455. } }
  9456. return markers
  9457. },
  9458. findMarks: function(from, to, filter) {
  9459. from = clipPos(this, from); to = clipPos(this, to);
  9460. var found = [], lineNo$$1 = from.line;
  9461. this.iter(from.line, to.line + 1, function (line) {
  9462. var spans = line.markedSpans;
  9463. if (spans) { for (var i = 0; i < spans.length; i++) {
  9464. var span = spans[i];
  9465. if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to ||
  9466. span.from == null && lineNo$$1 != from.line ||
  9467. span.from != null && lineNo$$1 == to.line && span.from >= to.ch) &&
  9468. (!filter || filter(span.marker)))
  9469. { found.push(span.marker.parent || span.marker); }
  9470. } }
  9471. ++lineNo$$1;
  9472. });
  9473. return found
  9474. },
  9475. getAllMarks: function() {
  9476. var markers = [];
  9477. this.iter(function (line) {
  9478. var sps = line.markedSpans;
  9479. if (sps) { for (var i = 0; i < sps.length; ++i)
  9480. { if (sps[i].from != null) { markers.push(sps[i].marker); } } }
  9481. });
  9482. return markers
  9483. },
  9484. posFromIndex: function(off) {
  9485. var ch, lineNo$$1 = this.first, sepSize = this.lineSeparator().length;
  9486. this.iter(function (line) {
  9487. var sz = line.text.length + sepSize;
  9488. if (sz > off) { ch = off; return true }
  9489. off -= sz;
  9490. ++lineNo$$1;
  9491. });
  9492. return clipPos(this, Pos(lineNo$$1, ch))
  9493. },
  9494. indexFromPos: function (coords) {
  9495. coords = clipPos(this, coords);
  9496. var index = coords.ch;
  9497. if (coords.line < this.first || coords.ch < 0) { return 0 }
  9498. var sepSize = this.lineSeparator().length;
  9499. this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
  9500. index += line.text.length + sepSize;
  9501. });
  9502. return index
  9503. },
  9504. copy: function(copyHistory) {
  9505. var doc = new Doc(getLines(this, this.first, this.first + this.size),
  9506. this.modeOption, this.first, this.lineSep, this.direction);
  9507. doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
  9508. doc.sel = this.sel;
  9509. doc.extend = false;
  9510. if (copyHistory) {
  9511. doc.history.undoDepth = this.history.undoDepth;
  9512. doc.setHistory(this.getHistory());
  9513. }
  9514. return doc
  9515. },
  9516. linkedDoc: function(options) {
  9517. if (!options) { options = {}; }
  9518. var from = this.first, to = this.first + this.size;
  9519. if (options.from != null && options.from > from) { from = options.from; }
  9520. if (options.to != null && options.to < to) { to = options.to; }
  9521. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  9522. if (options.sharedHist) { copy.history = this.history
  9523. ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
  9524. copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
  9525. copySharedMarkers(copy, findSharedMarkers(this));
  9526. return copy
  9527. },
  9528. unlinkDoc: function(other) {
  9529. var this$1 = this;
  9530. if (other instanceof CodeMirror) { other = other.doc; }
  9531. if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
  9532. var link = this$1.linked[i];
  9533. if (link.doc != other) { continue }
  9534. this$1.linked.splice(i, 1);
  9535. other.unlinkDoc(this$1);
  9536. detachSharedMarkers(findSharedMarkers(this$1));
  9537. break
  9538. } }
  9539. // If the histories were shared, split them again
  9540. if (other.history == this.history) {
  9541. var splitIds = [other.id];
  9542. linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);
  9543. other.history = new History(null);
  9544. other.history.done = copyHistoryArray(this.history.done, splitIds);
  9545. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  9546. }
  9547. },
  9548. iterLinkedDocs: function(f) {linkedDocs(this, f);},
  9549. getMode: function() {return this.mode},
  9550. getEditor: function() {return this.cm},
  9551. splitLines: function(str) {
  9552. if (this.lineSep) { return str.split(this.lineSep) }
  9553. return splitLinesAuto(str)
  9554. },
  9555. lineSeparator: function() { return this.lineSep || "\n" },
  9556. setDirection: docMethodOp(function (dir) {
  9557. if (dir != "rtl") { dir = "ltr"; }
  9558. if (dir == this.direction) { return }
  9559. this.direction = dir;
  9560. this.iter(function (line) { return line.order = null; });
  9561. if (this.cm) { directionChanged(this.cm); }
  9562. })
  9563. });
  9564. // Public alias.
  9565. Doc.prototype.eachLine = Doc.prototype.iter;
  9566. // Kludge to work around strange IE behavior where it'll sometimes
  9567. // re-fire a series of drag-related events right after the drop (#1551)
  9568. var lastDrop = 0;
  9569. function onDrop(e) {
  9570. var cm = this;
  9571. clearDragCursor(cm);
  9572. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
  9573. { return }
  9574. e_preventDefault(e);
  9575. if (ie) { lastDrop = +new Date; }
  9576. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
  9577. if (!pos || cm.isReadOnly()) { return }
  9578. // Might be a file drop, in which case we simply extract the text
  9579. // and insert it.
  9580. if (files && files.length && window.FileReader && window.File) {
  9581. var n = files.length, text = Array(n), read = 0;
  9582. var loadFile = function (file, i) {
  9583. if (cm.options.allowDropFileTypes &&
  9584. indexOf(cm.options.allowDropFileTypes, file.type) == -1)
  9585. { return }
  9586. var reader = new FileReader;
  9587. reader.onload = operation(cm, function () {
  9588. var content = reader.result;
  9589. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
  9590. text[i] = content;
  9591. if (++read == n) {
  9592. pos = clipPos(cm.doc, pos);
  9593. var change = {from: pos, to: pos,
  9594. text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
  9595. origin: "paste"};
  9596. makeChange(cm.doc, change);
  9597. setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
  9598. }
  9599. });
  9600. reader.readAsText(file);
  9601. };
  9602. for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
  9603. } else { // Normal drop
  9604. // Don't do a replace if the drop happened inside of the selected text.
  9605. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  9606. cm.state.draggingText(e);
  9607. // Ensure the editor is re-focused
  9608. setTimeout(function () { return cm.display.input.focus(); }, 20);
  9609. return
  9610. }
  9611. try {
  9612. var text$1 = e.dataTransfer.getData("Text");
  9613. if (text$1) {
  9614. var selected;
  9615. if (cm.state.draggingText && !cm.state.draggingText.copy)
  9616. { selected = cm.listSelections(); }
  9617. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  9618. if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
  9619. { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } }
  9620. cm.replaceSelection(text$1, "around", "paste");
  9621. cm.display.input.focus();
  9622. }
  9623. }
  9624. catch(e){}
  9625. }
  9626. }
  9627. function onDragStart(cm, e) {
  9628. if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
  9629. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
  9630. e.dataTransfer.setData("Text", cm.getSelection());
  9631. e.dataTransfer.effectAllowed = "copyMove";
  9632. // Use dummy image instead of default browsers image.
  9633. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  9634. if (e.dataTransfer.setDragImage && !safari) {
  9635. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  9636. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  9637. if (presto) {
  9638. img.width = img.height = 1;
  9639. cm.display.wrapper.appendChild(img);
  9640. // Force a relayout, or Opera won't use our image for some obscure reason
  9641. img._top = img.offsetTop;
  9642. }
  9643. e.dataTransfer.setDragImage(img, 0, 0);
  9644. if (presto) { img.parentNode.removeChild(img); }
  9645. }
  9646. }
  9647. function onDragOver(cm, e) {
  9648. var pos = posFromMouse(cm, e);
  9649. if (!pos) { return }
  9650. var frag = document.createDocumentFragment();
  9651. drawSelectionCursor(cm, pos, frag);
  9652. if (!cm.display.dragCursor) {
  9653. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  9654. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  9655. }
  9656. removeChildrenAndAdd(cm.display.dragCursor, frag);
  9657. }
  9658. function clearDragCursor(cm) {
  9659. if (cm.display.dragCursor) {
  9660. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  9661. cm.display.dragCursor = null;
  9662. }
  9663. }
  9664. // These must be handled carefully, because naively registering a
  9665. // handler for each editor will cause the editors to never be
  9666. // garbage collected.
  9667. function forEachCodeMirror(f) {
  9668. if (!document.getElementsByClassName) { return }
  9669. var byClass = document.getElementsByClassName("CodeMirror"), editors = [];
  9670. for (var i = 0; i < byClass.length; i++) {
  9671. var cm = byClass[i].CodeMirror;
  9672. if (cm) { editors.push(cm); }
  9673. }
  9674. if (editors.length) { editors[0].operation(function () {
  9675. for (var i = 0; i < editors.length; i++) { f(editors[i]); }
  9676. }); }
  9677. }
  9678. var globalsRegistered = false;
  9679. function ensureGlobalHandlers() {
  9680. if (globalsRegistered) { return }
  9681. registerGlobalHandlers();
  9682. globalsRegistered = true;
  9683. }
  9684. function registerGlobalHandlers() {
  9685. // When the window resizes, we need to refresh active editors.
  9686. var resizeTimer;
  9687. on(window, "resize", function () {
  9688. if (resizeTimer == null) { resizeTimer = setTimeout(function () {
  9689. resizeTimer = null;
  9690. forEachCodeMirror(onResize);
  9691. }, 100); }
  9692. });
  9693. // When the window loses focus, we want to show the editor as blurred
  9694. on(window, "blur", function () { return forEachCodeMirror(onBlur); });
  9695. }
  9696. // Called when the window resizes
  9697. function onResize(cm) {
  9698. var d = cm.display;
  9699. // Might be a text scaling operation, clear size caches.
  9700. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  9701. d.scrollbarsClipped = false;
  9702. cm.setSize();
  9703. }
  9704. var keyNames = {
  9705. 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  9706. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  9707. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  9708. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  9709. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock",
  9710. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  9711. 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  9712. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  9713. };
  9714. // Number keys
  9715. for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }
  9716. // Alphabetic keys
  9717. for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }
  9718. // Function keys
  9719. for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; }
  9720. var keyMap = {};
  9721. keyMap.basic = {
  9722. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  9723. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  9724. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  9725. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  9726. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  9727. "Esc": "singleSelection"
  9728. };
  9729. // Note that the save and find-related commands aren't defined by
  9730. // default. User code or addons can define them. Unknown commands
  9731. // are simply ignored.
  9732. keyMap.pcDefault = {
  9733. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  9734. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  9735. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  9736. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  9737. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  9738. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  9739. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  9740. "fallthrough": "basic"
  9741. };
  9742. // Very basic readline/emacs-style bindings, which are standard on Mac.
  9743. keyMap.emacsy = {
  9744. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  9745. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  9746. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  9747. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  9748. "Ctrl-O": "openLine"
  9749. };
  9750. keyMap.macDefault = {
  9751. "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
  9752. "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
  9753. "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
  9754. "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
  9755. "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
  9756. "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
  9757. "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
  9758. "fallthrough": ["basic", "emacsy"]
  9759. };
  9760. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  9761. // KEYMAP DISPATCH
  9762. function normalizeKeyName(name) {
  9763. var parts = name.split(/-(?!$)/);
  9764. name = parts[parts.length - 1];
  9765. var alt, ctrl, shift, cmd;
  9766. for (var i = 0; i < parts.length - 1; i++) {
  9767. var mod = parts[i];
  9768. if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
  9769. else if (/^a(lt)?$/i.test(mod)) { alt = true; }
  9770. else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
  9771. else if (/^s(hift)?$/i.test(mod)) { shift = true; }
  9772. else { throw new Error("Unrecognized modifier name: " + mod) }
  9773. }
  9774. if (alt) { name = "Alt-" + name; }
  9775. if (ctrl) { name = "Ctrl-" + name; }
  9776. if (cmd) { name = "Cmd-" + name; }
  9777. if (shift) { name = "Shift-" + name; }
  9778. return name
  9779. }
  9780. // This is a kludge to keep keymaps mostly working as raw objects
  9781. // (backwards compatibility) while at the same time support features
  9782. // like normalization and multi-stroke key bindings. It compiles a
  9783. // new normalized keymap, and then updates the old object to reflect
  9784. // this.
  9785. function normalizeKeyMap(keymap) {
  9786. var copy = {};
  9787. for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
  9788. var value = keymap[keyname];
  9789. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
  9790. if (value == "...") { delete keymap[keyname]; continue }
  9791. var keys = map(keyname.split(" "), normalizeKeyName);
  9792. for (var i = 0; i < keys.length; i++) {
  9793. var val = (void 0), name = (void 0);
  9794. if (i == keys.length - 1) {
  9795. name = keys.join(" ");
  9796. val = value;
  9797. } else {
  9798. name = keys.slice(0, i + 1).join(" ");
  9799. val = "...";
  9800. }
  9801. var prev = copy[name];
  9802. if (!prev) { copy[name] = val; }
  9803. else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
  9804. }
  9805. delete keymap[keyname];
  9806. } }
  9807. for (var prop in copy) { keymap[prop] = copy[prop]; }
  9808. return keymap
  9809. }
  9810. function lookupKey(key, map$$1, handle, context) {
  9811. map$$1 = getKeyMap(map$$1);
  9812. var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];
  9813. if (found === false) { return "nothing" }
  9814. if (found === "...") { return "multi" }
  9815. if (found != null && handle(found)) { return "handled" }
  9816. if (map$$1.fallthrough) {
  9817. if (Object.prototype.toString.call(map$$1.fallthrough) != "[object Array]")
  9818. { return lookupKey(key, map$$1.fallthrough, handle, context) }
  9819. for (var i = 0; i < map$$1.fallthrough.length; i++) {
  9820. var result = lookupKey(key, map$$1.fallthrough[i], handle, context);
  9821. if (result) { return result }
  9822. }
  9823. }
  9824. }
  9825. // Modifier key presses don't count as 'real' key presses for the
  9826. // purpose of keymap fallthrough.
  9827. function isModifierKey(value) {
  9828. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  9829. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
  9830. }
  9831. function addModifierNames(name, event, noShift) {
  9832. var base = name;
  9833. if (event.altKey && base != "Alt") { name = "Alt-" + name; }
  9834. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
  9835. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
  9836. if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
  9837. return name
  9838. }
  9839. // Look up the name of a key as indicated by an event object.
  9840. function keyName(event, noShift) {
  9841. if (presto && event.keyCode == 34 && event["char"]) { return false }
  9842. var name = keyNames[event.keyCode];
  9843. if (name == null || event.altGraphKey) { return false }
  9844. // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
  9845. // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
  9846. if (event.keyCode == 3 && event.code) { name = event.code; }
  9847. return addModifierNames(name, event, noShift)
  9848. }
  9849. function getKeyMap(val) {
  9850. return typeof val == "string" ? keyMap[val] : val
  9851. }
  9852. // Helper for deleting text near the selection(s), used to implement
  9853. // backspace, delete, and similar functionality.
  9854. function deleteNearSelection(cm, compute) {
  9855. var ranges = cm.doc.sel.ranges, kill = [];
  9856. // Build up a set of ranges to kill first, merging overlapping
  9857. // ranges.
  9858. for (var i = 0; i < ranges.length; i++) {
  9859. var toKill = compute(ranges[i]);
  9860. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  9861. var replaced = kill.pop();
  9862. if (cmp(replaced.from, toKill.from) < 0) {
  9863. toKill.from = replaced.from;
  9864. break
  9865. }
  9866. }
  9867. kill.push(toKill);
  9868. }
  9869. // Next, remove those actual ranges.
  9870. runInOp(cm, function () {
  9871. for (var i = kill.length - 1; i >= 0; i--)
  9872. { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
  9873. ensureCursorVisible(cm);
  9874. });
  9875. }
  9876. function moveCharLogically(line, ch, dir) {
  9877. var target = skipExtendingChars(line.text, ch + dir, dir);
  9878. return target < 0 || target > line.text.length ? null : target
  9879. }
  9880. function moveLogically(line, start, dir) {
  9881. var ch = moveCharLogically(line, start.ch, dir);
  9882. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
  9883. }
  9884. function endOfLine(visually, cm, lineObj, lineNo, dir) {
  9885. if (visually) {
  9886. var order = getOrder(lineObj, cm.doc.direction);
  9887. if (order) {
  9888. var part = dir < 0 ? lst(order) : order[0];
  9889. var moveInStorageOrder = (dir < 0) == (part.level == 1);
  9890. var sticky = moveInStorageOrder ? "after" : "before";
  9891. var ch;
  9892. // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
  9893. // it could be that the last bidi part is not on the last visual line,
  9894. // since visual lines contain content order-consecutive chunks.
  9895. // Thus, in rtl, we are looking for the first (content-order) character
  9896. // in the rtl chunk that is on the last line (that is, the same line
  9897. // as the last (content-order) character).
  9898. if (part.level > 0 || cm.doc.direction == "rtl") {
  9899. var prep = prepareMeasureForLine(cm, lineObj);
  9900. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  9901. var targetTop = measureCharPrepared(cm, prep, ch).top;
  9902. ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);
  9903. if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); }
  9904. } else { ch = dir < 0 ? part.to : part.from; }
  9905. return new Pos(lineNo, ch, sticky)
  9906. }
  9907. }
  9908. return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
  9909. }
  9910. function moveVisually(cm, line, start, dir) {
  9911. var bidi = getOrder(line, cm.doc.direction);
  9912. if (!bidi) { return moveLogically(line, start, dir) }
  9913. if (start.ch >= line.text.length) {
  9914. start.ch = line.text.length;
  9915. start.sticky = "before";
  9916. } else if (start.ch <= 0) {
  9917. start.ch = 0;
  9918. start.sticky = "after";
  9919. }
  9920. var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
  9921. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
  9922. // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
  9923. // nothing interesting happens.
  9924. return moveLogically(line, start, dir)
  9925. }
  9926. var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };
  9927. var prep;
  9928. var getWrappedLineExtent = function (ch) {
  9929. if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
  9930. prep = prep || prepareMeasureForLine(cm, line);
  9931. return wrappedLineExtentChar(cm, line, prep, ch)
  9932. };
  9933. var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  9934. if (cm.doc.direction == "rtl" || part.level == 1) {
  9935. var moveInStorageOrder = (part.level == 1) == (dir < 0);
  9936. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  9937. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
  9938. // Case 2: We move within an rtl part or in an rtl editor on the same visual line
  9939. var sticky = moveInStorageOrder ? "before" : "after";
  9940. return new Pos(start.line, ch, sticky)
  9941. }
  9942. }
  9943. // Case 3: Could not move within this bidi part in this visual line, so leave
  9944. // the current bidi part
  9945. var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
  9946. var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
  9947. ? new Pos(start.line, mv(ch, 1), "before")
  9948. : new Pos(start.line, ch, "after"); };
  9949. for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
  9950. var part = bidi[partPos];
  9951. var moveInStorageOrder = (dir > 0) == (part.level != 1);
  9952. var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
  9953. if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
  9954. ch = moveInStorageOrder ? part.from : mv(part.to, -1);
  9955. if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
  9956. }
  9957. };
  9958. // Case 3a: Look for other bidi parts on the same visual line
  9959. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
  9960. if (res) { return res }
  9961. // Case 3b: Look for other bidi parts on the next visual line
  9962. var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
  9963. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  9964. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  9965. if (res) { return res }
  9966. }
  9967. // Case 4: Nowhere to move
  9968. return null
  9969. }
  9970. // Commands are parameter-less actions that can be performed on an
  9971. // editor, mostly used for keybindings.
  9972. var commands = {
  9973. selectAll: selectAll,
  9974. singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
  9975. killLine: function (cm) { return deleteNearSelection(cm, function (range) {
  9976. if (range.empty()) {
  9977. var len = getLine(cm.doc, range.head.line).text.length;
  9978. if (range.head.ch == len && range.head.line < cm.lastLine())
  9979. { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
  9980. else
  9981. { return {from: range.head, to: Pos(range.head.line, len)} }
  9982. } else {
  9983. return {from: range.from(), to: range.to()}
  9984. }
  9985. }); },
  9986. deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  9987. from: Pos(range.from().line, 0),
  9988. to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
  9989. }); }); },
  9990. delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  9991. from: Pos(range.from().line, 0), to: range.from()
  9992. }); }); },
  9993. delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
  9994. var top = cm.charCoords(range.head, "div").top + 5;
  9995. var leftPos = cm.coordsChar({left: 0, top: top}, "div");
  9996. return {from: leftPos, to: range.from()}
  9997. }); },
  9998. delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
  9999. var top = cm.charCoords(range.head, "div").top + 5;
  10000. var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
  10001. return {from: range.from(), to: rightPos }
  10002. }); },
  10003. undo: function (cm) { return cm.undo(); },
  10004. redo: function (cm) { return cm.redo(); },
  10005. undoSelection: function (cm) { return cm.undoSelection(); },
  10006. redoSelection: function (cm) { return cm.redoSelection(); },
  10007. goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
  10008. goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
  10009. goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
  10010. {origin: "+move", bias: 1}
  10011. ); },
  10012. goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
  10013. {origin: "+move", bias: 1}
  10014. ); },
  10015. goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
  10016. {origin: "+move", bias: -1}
  10017. ); },
  10018. goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
  10019. var top = cm.cursorCoords(range.head, "div").top + 5;
  10020. return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  10021. }, sel_move); },
  10022. goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
  10023. var top = cm.cursorCoords(range.head, "div").top + 5;
  10024. return cm.coordsChar({left: 0, top: top}, "div")
  10025. }, sel_move); },
  10026. goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
  10027. var top = cm.cursorCoords(range.head, "div").top + 5;
  10028. var pos = cm.coordsChar({left: 0, top: top}, "div");
  10029. if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
  10030. return pos
  10031. }, sel_move); },
  10032. goLineUp: function (cm) { return cm.moveV(-1, "line"); },
  10033. goLineDown: function (cm) { return cm.moveV(1, "line"); },
  10034. goPageUp: function (cm) { return cm.moveV(-1, "page"); },
  10035. goPageDown: function (cm) { return cm.moveV(1, "page"); },
  10036. goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
  10037. goCharRight: function (cm) { return cm.moveH(1, "char"); },
  10038. goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
  10039. goColumnRight: function (cm) { return cm.moveH(1, "column"); },
  10040. goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
  10041. goGroupRight: function (cm) { return cm.moveH(1, "group"); },
  10042. goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
  10043. goWordRight: function (cm) { return cm.moveH(1, "word"); },
  10044. delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
  10045. delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
  10046. delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
  10047. delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
  10048. delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
  10049. delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
  10050. indentAuto: function (cm) { return cm.indentSelection("smart"); },
  10051. indentMore: function (cm) { return cm.indentSelection("add"); },
  10052. indentLess: function (cm) { return cm.indentSelection("subtract"); },
  10053. insertTab: function (cm) { return cm.replaceSelection("\t"); },
  10054. insertSoftTab: function (cm) {
  10055. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
  10056. for (var i = 0; i < ranges.length; i++) {
  10057. var pos = ranges[i].from();
  10058. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  10059. spaces.push(spaceStr(tabSize - col % tabSize));
  10060. }
  10061. cm.replaceSelections(spaces);
  10062. },
  10063. defaultTab: function (cm) {
  10064. if (cm.somethingSelected()) { cm.indentSelection("add"); }
  10065. else { cm.execCommand("insertTab"); }
  10066. },
  10067. // Swap the two chars left and right of each selection's head.
  10068. // Move cursor behind the two swapped characters afterwards.
  10069. //
  10070. // Doesn't consider line feeds a character.
  10071. // Doesn't scan more than one line above to find a character.
  10072. // Doesn't do anything on an empty line.
  10073. // Doesn't do anything with non-empty selections.
  10074. transposeChars: function (cm) { return runInOp(cm, function () {
  10075. var ranges = cm.listSelections(), newSel = [];
  10076. for (var i = 0; i < ranges.length; i++) {
  10077. if (!ranges[i].empty()) { continue }
  10078. var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
  10079. if (line) {
  10080. if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
  10081. if (cur.ch > 0) {
  10082. cur = new Pos(cur.line, cur.ch + 1);
  10083. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
  10084. Pos(cur.line, cur.ch - 2), cur, "+transpose");
  10085. } else if (cur.line > cm.doc.first) {
  10086. var prev = getLine(cm.doc, cur.line - 1).text;
  10087. if (prev) {
  10088. cur = new Pos(cur.line, 1);
  10089. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
  10090. prev.charAt(prev.length - 1),
  10091. Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  10092. }
  10093. }
  10094. }
  10095. newSel.push(new Range(cur, cur));
  10096. }
  10097. cm.setSelections(newSel);
  10098. }); },
  10099. newlineAndIndent: function (cm) { return runInOp(cm, function () {
  10100. var sels = cm.listSelections();
  10101. for (var i = sels.length - 1; i >= 0; i--)
  10102. { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); }
  10103. sels = cm.listSelections();
  10104. for (var i$1 = 0; i$1 < sels.length; i$1++)
  10105. { cm.indentLine(sels[i$1].from().line, null, true); }
  10106. ensureCursorVisible(cm);
  10107. }); },
  10108. openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
  10109. toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
  10110. };
  10111. function lineStart(cm, lineN) {
  10112. var line = getLine(cm.doc, lineN);
  10113. var visual = visualLine(line);
  10114. if (visual != line) { lineN = lineNo(visual); }
  10115. return endOfLine(true, cm, visual, lineN, 1)
  10116. }
  10117. function lineEnd(cm, lineN) {
  10118. var line = getLine(cm.doc, lineN);
  10119. var visual = visualLineEnd(line);
  10120. if (visual != line) { lineN = lineNo(visual); }
  10121. return endOfLine(true, cm, line, lineN, -1)
  10122. }
  10123. function lineStartSmart(cm, pos) {
  10124. var start = lineStart(cm, pos.line);
  10125. var line = getLine(cm.doc, start.line);
  10126. var order = getOrder(line, cm.doc.direction);
  10127. if (!order || order[0].level == 0) {
  10128. var firstNonWS = Math.max(0, line.text.search(/\S/));
  10129. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  10130. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
  10131. }
  10132. return start
  10133. }
  10134. // Run a handler that was bound to a key.
  10135. function doHandleBinding(cm, bound, dropShift) {
  10136. if (typeof bound == "string") {
  10137. bound = commands[bound];
  10138. if (!bound) { return false }
  10139. }
  10140. // Ensure previous input has been read, so that the handler sees a
  10141. // consistent view of the document
  10142. cm.display.input.ensurePolled();
  10143. var prevShift = cm.display.shift, done = false;
  10144. try {
  10145. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  10146. if (dropShift) { cm.display.shift = false; }
  10147. done = bound(cm) != Pass;
  10148. } finally {
  10149. cm.display.shift = prevShift;
  10150. cm.state.suppressEdits = false;
  10151. }
  10152. return done
  10153. }
  10154. function lookupKeyForEditor(cm, name, handle) {
  10155. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  10156. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
  10157. if (result) { return result }
  10158. }
  10159. return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
  10160. || lookupKey(name, cm.options.keyMap, handle, cm)
  10161. }
  10162. // Note that, despite the name, this function is also used to check
  10163. // for bound mouse clicks.
  10164. var stopSeq = new Delayed;
  10165. function dispatchKey(cm, name, e, handle) {
  10166. var seq = cm.state.keySeq;
  10167. if (seq) {
  10168. if (isModifierKey(name)) { return "handled" }
  10169. if (/\'$/.test(name))
  10170. { cm.state.keySeq = null; }
  10171. else
  10172. { stopSeq.set(50, function () {
  10173. if (cm.state.keySeq == seq) {
  10174. cm.state.keySeq = null;
  10175. cm.display.input.reset();
  10176. }
  10177. }); }
  10178. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
  10179. }
  10180. return dispatchKeyInner(cm, name, e, handle)
  10181. }
  10182. function dispatchKeyInner(cm, name, e, handle) {
  10183. var result = lookupKeyForEditor(cm, name, handle);
  10184. if (result == "multi")
  10185. { cm.state.keySeq = name; }
  10186. if (result == "handled")
  10187. { signalLater(cm, "keyHandled", cm, name, e); }
  10188. if (result == "handled" || result == "multi") {
  10189. e_preventDefault(e);
  10190. restartBlink(cm);
  10191. }
  10192. return !!result
  10193. }
  10194. // Handle a key from the keydown event.
  10195. function handleKeyBinding(cm, e) {
  10196. var name = keyName(e, true);
  10197. if (!name) { return false }
  10198. if (e.shiftKey && !cm.state.keySeq) {
  10199. // First try to resolve full name (including 'Shift-'). Failing
  10200. // that, see if there is a cursor-motion command (starting with
  10201. // 'go') bound to the keyname without 'Shift-'.
  10202. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
  10203. || dispatchKey(cm, name, e, function (b) {
  10204. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
  10205. { return doHandleBinding(cm, b) }
  10206. })
  10207. } else {
  10208. return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
  10209. }
  10210. }
  10211. // Handle a key from the keypress event
  10212. function handleCharBinding(cm, e, ch) {
  10213. return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
  10214. }
  10215. var lastStoppedKey = null;
  10216. function onKeyDown(e) {
  10217. var cm = this;
  10218. cm.curOp.focus = activeElt();
  10219. if (signalDOMEvent(cm, e)) { return }
  10220. // IE does strange things with escape.
  10221. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
  10222. var code = e.keyCode;
  10223. cm.display.shift = code == 16 || e.shiftKey;
  10224. var handled = handleKeyBinding(cm, e);
  10225. if (presto) {
  10226. lastStoppedKey = handled ? code : null;
  10227. // Opera has no cut event... we try to at least catch the key combo
  10228. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
  10229. { cm.replaceSelection("", null, "cut"); }
  10230. }
  10231. // Turn mouse into crosshair when Alt is held on Mac.
  10232. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
  10233. { showCrossHair(cm); }
  10234. }
  10235. function showCrossHair(cm) {
  10236. var lineDiv = cm.display.lineDiv;
  10237. addClass(lineDiv, "CodeMirror-crosshair");
  10238. function up(e) {
  10239. if (e.keyCode == 18 || !e.altKey) {
  10240. rmClass(lineDiv, "CodeMirror-crosshair");
  10241. off(document, "keyup", up);
  10242. off(document, "mouseover", up);
  10243. }
  10244. }
  10245. on(document, "keyup", up);
  10246. on(document, "mouseover", up);
  10247. }
  10248. function onKeyUp(e) {
  10249. if (e.keyCode == 16) { this.doc.sel.shift = false; }
  10250. signalDOMEvent(this, e);
  10251. }
  10252. function onKeyPress(e) {
  10253. var cm = this;
  10254. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
  10255. var keyCode = e.keyCode, charCode = e.charCode;
  10256. if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
  10257. if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
  10258. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  10259. // Some browsers fire keypress events for backspace
  10260. if (ch == "\x08") { return }
  10261. if (handleCharBinding(cm, e, ch)) { return }
  10262. cm.display.input.onKeyPress(e);
  10263. }
  10264. var DOUBLECLICK_DELAY = 400;
  10265. var PastClick = function(time, pos, button) {
  10266. this.time = time;
  10267. this.pos = pos;
  10268. this.button = button;
  10269. };
  10270. PastClick.prototype.compare = function (time, pos, button) {
  10271. return this.time + DOUBLECLICK_DELAY > time &&
  10272. cmp(pos, this.pos) == 0 && button == this.button
  10273. };
  10274. var lastClick, lastDoubleClick;
  10275. function clickRepeat(pos, button) {
  10276. var now = +new Date;
  10277. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  10278. lastClick = lastDoubleClick = null;
  10279. return "triple"
  10280. } else if (lastClick && lastClick.compare(now, pos, button)) {
  10281. lastDoubleClick = new PastClick(now, pos, button);
  10282. lastClick = null;
  10283. return "double"
  10284. } else {
  10285. lastClick = new PastClick(now, pos, button);
  10286. lastDoubleClick = null;
  10287. return "single"
  10288. }
  10289. }
  10290. // A mouse down can be a single click, double click, triple click,
  10291. // start of selection drag, start of text drag, new cursor
  10292. // (ctrl-click), rectangle drag (alt-drag), or xwin
  10293. // middle-click-paste. Or it might be a click on something we should
  10294. // not interfere with, such as a scrollbar or widget.
  10295. function onMouseDown(e) {
  10296. var cm = this, display = cm.display;
  10297. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
  10298. display.input.ensurePolled();
  10299. display.shift = e.shiftKey;
  10300. if (eventInWidget(display, e)) {
  10301. if (!webkit) {
  10302. // Briefly turn off draggability, to allow widgets to do
  10303. // normal dragging things.
  10304. display.scroller.draggable = false;
  10305. setTimeout(function () { return display.scroller.draggable = true; }, 100);
  10306. }
  10307. return
  10308. }
  10309. if (clickInGutter(cm, e)) { return }
  10310. var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
  10311. window.focus();
  10312. // #3261: make sure, that we're not starting a second selection
  10313. if (button == 1 && cm.state.selectingText)
  10314. { cm.state.selectingText(e); }
  10315. if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
  10316. if (button == 1) {
  10317. if (pos) { leftButtonDown(cm, pos, repeat, e); }
  10318. else if (e_target(e) == display.scroller) { e_preventDefault(e); }
  10319. } else if (button == 2) {
  10320. if (pos) { extendSelection(cm.doc, pos); }
  10321. setTimeout(function () { return display.input.focus(); }, 20);
  10322. } else if (button == 3) {
  10323. if (captureRightClick) { cm.display.input.onContextMenu(e); }
  10324. else { delayBlurEvent(cm); }
  10325. }
  10326. }
  10327. function handleMappedButton(cm, button, pos, repeat, event) {
  10328. var name = "Click";
  10329. if (repeat == "double") { name = "Double" + name; }
  10330. else if (repeat == "triple") { name = "Triple" + name; }
  10331. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  10332. return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
  10333. if (typeof bound == "string") { bound = commands[bound]; }
  10334. if (!bound) { return false }
  10335. var done = false;
  10336. try {
  10337. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  10338. done = bound(cm, pos) != Pass;
  10339. } finally {
  10340. cm.state.suppressEdits = false;
  10341. }
  10342. return done
  10343. })
  10344. }
  10345. function configureMouse(cm, repeat, event) {
  10346. var option = cm.getOption("configureMouse");
  10347. var value = option ? option(cm, repeat, event) : {};
  10348. if (value.unit == null) {
  10349. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  10350. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  10351. }
  10352. if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }
  10353. if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }
  10354. if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }
  10355. return value
  10356. }
  10357. function leftButtonDown(cm, pos, repeat, event) {
  10358. if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
  10359. else { cm.curOp.focus = activeElt(); }
  10360. var behavior = configureMouse(cm, repeat, event);
  10361. var sel = cm.doc.sel, contained;
  10362. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
  10363. repeat == "single" && (contained = sel.contains(pos)) > -1 &&
  10364. (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
  10365. (cmp(contained.to(), pos) > 0 || pos.xRel < 0))
  10366. { leftButtonStartDrag(cm, event, pos, behavior); }
  10367. else
  10368. { leftButtonSelect(cm, event, pos, behavior); }
  10369. }
  10370. // Start a text drag. When it ends, see if any dragging actually
  10371. // happen, and treat as a click if it didn't.
  10372. function leftButtonStartDrag(cm, event, pos, behavior) {
  10373. var display = cm.display, moved = false;
  10374. var dragEnd = operation(cm, function (e) {
  10375. if (webkit) { display.scroller.draggable = false; }
  10376. cm.state.draggingText = false;
  10377. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  10378. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  10379. off(display.scroller, "dragstart", dragStart);
  10380. off(display.scroller, "drop", dragEnd);
  10381. if (!moved) {
  10382. e_preventDefault(e);
  10383. if (!behavior.addNew)
  10384. { extendSelection(cm.doc, pos, null, null, behavior.extend); }
  10385. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  10386. if (webkit || ie && ie_version == 9)
  10387. { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
  10388. else
  10389. { display.input.focus(); }
  10390. }
  10391. });
  10392. var mouseMove = function(e2) {
  10393. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  10394. };
  10395. var dragStart = function () { return moved = true; };
  10396. // Let the drag handler handle this.
  10397. if (webkit) { display.scroller.draggable = true; }
  10398. cm.state.draggingText = dragEnd;
  10399. dragEnd.copy = !behavior.moveOnDrag;
  10400. // IE's approach to draggable
  10401. if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
  10402. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  10403. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  10404. on(display.scroller, "dragstart", dragStart);
  10405. on(display.scroller, "drop", dragEnd);
  10406. delayBlurEvent(cm);
  10407. setTimeout(function () { return display.input.focus(); }, 20);
  10408. }
  10409. function rangeForUnit(cm, pos, unit) {
  10410. if (unit == "char") { return new Range(pos, pos) }
  10411. if (unit == "word") { return cm.findWordAt(pos) }
  10412. if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
  10413. var result = unit(cm, pos);
  10414. return new Range(result.from, result.to)
  10415. }
  10416. // Normal selection, as opposed to text dragging.
  10417. function leftButtonSelect(cm, event, start, behavior) {
  10418. var display = cm.display, doc = cm.doc;
  10419. e_preventDefault(event);
  10420. var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
  10421. if (behavior.addNew && !behavior.extend) {
  10422. ourIndex = doc.sel.contains(start);
  10423. if (ourIndex > -1)
  10424. { ourRange = ranges[ourIndex]; }
  10425. else
  10426. { ourRange = new Range(start, start); }
  10427. } else {
  10428. ourRange = doc.sel.primary();
  10429. ourIndex = doc.sel.primIndex;
  10430. }
  10431. if (behavior.unit == "rectangle") {
  10432. if (!behavior.addNew) { ourRange = new Range(start, start); }
  10433. start = posFromMouse(cm, event, true, true);
  10434. ourIndex = -1;
  10435. } else {
  10436. var range$$1 = rangeForUnit(cm, start, behavior.unit);
  10437. if (behavior.extend)
  10438. { ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend); }
  10439. else
  10440. { ourRange = range$$1; }
  10441. }
  10442. if (!behavior.addNew) {
  10443. ourIndex = 0;
  10444. setSelection(doc, new Selection([ourRange], 0), sel_mouse);
  10445. startSel = doc.sel;
  10446. } else if (ourIndex == -1) {
  10447. ourIndex = ranges.length;
  10448. setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
  10449. {scroll: false, origin: "*mouse"});
  10450. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  10451. setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
  10452. {scroll: false, origin: "*mouse"});
  10453. startSel = doc.sel;
  10454. } else {
  10455. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
  10456. }
  10457. var lastPos = start;
  10458. function extendTo(pos) {
  10459. if (cmp(lastPos, pos) == 0) { return }
  10460. lastPos = pos;
  10461. if (behavior.unit == "rectangle") {
  10462. var ranges = [], tabSize = cm.options.tabSize;
  10463. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
  10464. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
  10465. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
  10466. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
  10467. line <= end; line++) {
  10468. var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
  10469. if (left == right)
  10470. { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
  10471. else if (text.length > leftPos)
  10472. { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
  10473. }
  10474. if (!ranges.length) { ranges.push(new Range(start, start)); }
  10475. setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
  10476. {origin: "*mouse", scroll: false});
  10477. cm.scrollIntoView(pos);
  10478. } else {
  10479. var oldRange = ourRange;
  10480. var range$$1 = rangeForUnit(cm, pos, behavior.unit);
  10481. var anchor = oldRange.anchor, head;
  10482. if (cmp(range$$1.anchor, anchor) > 0) {
  10483. head = range$$1.head;
  10484. anchor = minPos(oldRange.from(), range$$1.anchor);
  10485. } else {
  10486. head = range$$1.anchor;
  10487. anchor = maxPos(oldRange.to(), range$$1.head);
  10488. }
  10489. var ranges$1 = startSel.ranges.slice(0);
  10490. ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
  10491. setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
  10492. }
  10493. }
  10494. var editorSize = display.wrapper.getBoundingClientRect();
  10495. // Used to ensure timeout re-tries don't fire when another extend
  10496. // happened in the meantime (clearTimeout isn't reliable -- at
  10497. // least on Chrome, the timeouts still happen even when cleared,
  10498. // if the clear happens after their scheduled firing time).
  10499. var counter = 0;
  10500. function extend(e) {
  10501. var curCount = ++counter;
  10502. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  10503. if (!cur) { return }
  10504. if (cmp(cur, lastPos) != 0) {
  10505. cm.curOp.focus = activeElt();
  10506. extendTo(cur);
  10507. var visible = visibleLines(display, doc);
  10508. if (cur.line >= visible.to || cur.line < visible.from)
  10509. { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
  10510. } else {
  10511. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  10512. if (outside) { setTimeout(operation(cm, function () {
  10513. if (counter != curCount) { return }
  10514. display.scroller.scrollTop += outside;
  10515. extend(e);
  10516. }), 50); }
  10517. }
  10518. }
  10519. function done(e) {
  10520. cm.state.selectingText = false;
  10521. counter = Infinity;
  10522. // If e is null or undefined we interpret this as someone trying
  10523. // to explicitly cancel the selection rather than the user
  10524. // letting go of the mouse button.
  10525. if (e) {
  10526. e_preventDefault(e);
  10527. display.input.focus();
  10528. }
  10529. off(display.wrapper.ownerDocument, "mousemove", move);
  10530. off(display.wrapper.ownerDocument, "mouseup", up);
  10531. doc.history.lastSelOrigin = null;
  10532. }
  10533. var move = operation(cm, function (e) {
  10534. if (e.buttons === 0 || !e_button(e)) { done(e); }
  10535. else { extend(e); }
  10536. });
  10537. var up = operation(cm, done);
  10538. cm.state.selectingText = up;
  10539. on(display.wrapper.ownerDocument, "mousemove", move);
  10540. on(display.wrapper.ownerDocument, "mouseup", up);
  10541. }
  10542. // Used when mouse-selecting to adjust the anchor to the proper side
  10543. // of a bidi jump depending on the visual position of the head.
  10544. function bidiSimplify(cm, range$$1) {
  10545. var anchor = range$$1.anchor;
  10546. var head = range$$1.head;
  10547. var anchorLine = getLine(cm.doc, anchor.line);
  10548. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range$$1 }
  10549. var order = getOrder(anchorLine);
  10550. if (!order) { return range$$1 }
  10551. var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
  10552. if (part.from != anchor.ch && part.to != anchor.ch) { return range$$1 }
  10553. var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);
  10554. if (boundary == 0 || boundary == order.length) { return range$$1 }
  10555. // Compute the relative visual position of the head compared to the
  10556. // anchor (<0 is to the left, >0 to the right)
  10557. var leftSide;
  10558. if (head.line != anchor.line) {
  10559. leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  10560. } else {
  10561. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  10562. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  10563. if (headIndex == boundary - 1 || headIndex == boundary)
  10564. { leftSide = dir < 0; }
  10565. else
  10566. { leftSide = dir > 0; }
  10567. }
  10568. var usePart = order[boundary + (leftSide ? -1 : 0)];
  10569. var from = leftSide == (usePart.level == 1);
  10570. var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
  10571. return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head)
  10572. }
  10573. // Determines whether an event happened in the gutter, and fires the
  10574. // handlers for the corresponding event.
  10575. function gutterEvent(cm, e, type, prevent) {
  10576. var mX, mY;
  10577. if (e.touches) {
  10578. mX = e.touches[0].clientX;
  10579. mY = e.touches[0].clientY;
  10580. } else {
  10581. try { mX = e.clientX; mY = e.clientY; }
  10582. catch(e) { return false }
  10583. }
  10584. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
  10585. if (prevent) { e_preventDefault(e); }
  10586. var display = cm.display;
  10587. var lineBox = display.lineDiv.getBoundingClientRect();
  10588. if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
  10589. mY -= lineBox.top - display.viewOffset;
  10590. for (var i = 0; i < cm.display.gutterSpecs.length; ++i) {
  10591. var g = display.gutters.childNodes[i];
  10592. if (g && g.getBoundingClientRect().right >= mX) {
  10593. var line = lineAtHeight(cm.doc, mY);
  10594. var gutter = cm.display.gutterSpecs[i];
  10595. signal(cm, type, cm, line, gutter.className, e);
  10596. return e_defaultPrevented(e)
  10597. }
  10598. }
  10599. }
  10600. function clickInGutter(cm, e) {
  10601. return gutterEvent(cm, e, "gutterClick", true)
  10602. }
  10603. // CONTEXT MENU HANDLING
  10604. // To make the context menu work, we need to briefly unhide the
  10605. // textarea (making it as unobtrusive as possible) to let the
  10606. // right-click take effect on it.
  10607. function onContextMenu(cm, e) {
  10608. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
  10609. if (signalDOMEvent(cm, e, "contextmenu")) { return }
  10610. if (!captureRightClick) { cm.display.input.onContextMenu(e); }
  10611. }
  10612. function contextMenuInGutter(cm, e) {
  10613. if (!hasHandler(cm, "gutterContextMenu")) { return false }
  10614. return gutterEvent(cm, e, "gutterContextMenu", false)
  10615. }
  10616. function themeChanged(cm) {
  10617. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
  10618. cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  10619. clearCaches(cm);
  10620. }
  10621. var Init = {toString: function(){return "CodeMirror.Init"}};
  10622. var defaults = {};
  10623. var optionHandlers = {};
  10624. function defineOptions(CodeMirror) {
  10625. var optionHandlers = CodeMirror.optionHandlers;
  10626. function option(name, deflt, handle, notOnInit) {
  10627. CodeMirror.defaults[name] = deflt;
  10628. if (handle) { optionHandlers[name] =
  10629. notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }
  10630. }
  10631. CodeMirror.defineOption = option;
  10632. // Passed to option handlers when there is no old value.
  10633. CodeMirror.Init = Init;
  10634. // These two are, on init, called from the constructor because they
  10635. // have to be initialized before the editor can start at all.
  10636. option("value", "", function (cm, val) { return cm.setValue(val); }, true);
  10637. option("mode", null, function (cm, val) {
  10638. cm.doc.modeOption = val;
  10639. loadMode(cm);
  10640. }, true);
  10641. option("indentUnit", 2, loadMode, true);
  10642. option("indentWithTabs", false);
  10643. option("smartIndent", true);
  10644. option("tabSize", 4, function (cm) {
  10645. resetModeState(cm);
  10646. clearCaches(cm);
  10647. regChange(cm);
  10648. }, true);
  10649. option("lineSeparator", null, function (cm, val) {
  10650. cm.doc.lineSep = val;
  10651. if (!val) { return }
  10652. var newBreaks = [], lineNo = cm.doc.first;
  10653. cm.doc.iter(function (line) {
  10654. for (var pos = 0;;) {
  10655. var found = line.text.indexOf(val, pos);
  10656. if (found == -1) { break }
  10657. pos = found + val.length;
  10658. newBreaks.push(Pos(lineNo, found));
  10659. }
  10660. lineNo++;
  10661. });
  10662. for (var i = newBreaks.length - 1; i >= 0; i--)
  10663. { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
  10664. });
  10665. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
  10666. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
  10667. if (old != Init) { cm.refresh(); }
  10668. });
  10669. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
  10670. option("electricChars", true);
  10671. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  10672. throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
  10673. }, true);
  10674. option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
  10675. option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true);
  10676. option("autocapitalize", false, function (cm, val) { return cm.getInputField().autocapitalize = val; }, true);
  10677. option("rtlMoveVisually", !windows);
  10678. option("wholeLineUpdateBefore", true);
  10679. option("theme", "default", function (cm) {
  10680. themeChanged(cm);
  10681. updateGutters(cm);
  10682. }, true);
  10683. option("keyMap", "default", function (cm, val, old) {
  10684. var next = getKeyMap(val);
  10685. var prev = old != Init && getKeyMap(old);
  10686. if (prev && prev.detach) { prev.detach(cm, next); }
  10687. if (next.attach) { next.attach(cm, prev || null); }
  10688. });
  10689. option("extraKeys", null);
  10690. option("configureMouse", null);
  10691. option("lineWrapping", false, wrappingChanged, true);
  10692. option("gutters", [], function (cm, val) {
  10693. cm.display.gutterSpecs = getGutters(val, cm.options.lineNumbers);
  10694. updateGutters(cm);
  10695. }, true);
  10696. option("fixedGutter", true, function (cm, val) {
  10697. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  10698. cm.refresh();
  10699. }, true);
  10700. option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true);
  10701. option("scrollbarStyle", "native", function (cm) {
  10702. initScrollbars(cm);
  10703. updateScrollbars(cm);
  10704. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  10705. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  10706. }, true);
  10707. option("lineNumbers", false, function (cm, val) {
  10708. cm.display.gutterSpecs = getGutters(cm.options.gutters, val);
  10709. updateGutters(cm);
  10710. }, true);
  10711. option("firstLineNumber", 1, updateGutters, true);
  10712. option("lineNumberFormatter", function (integer) { return integer; }, updateGutters, true);
  10713. option("showCursorWhenSelecting", false, updateSelection, true);
  10714. option("resetSelectionOnContextMenu", true);
  10715. option("lineWiseCopyCut", true);
  10716. option("pasteLinesPerSelection", true);
  10717. option("selectionsMayTouch", false);
  10718. option("readOnly", false, function (cm, val) {
  10719. if (val == "nocursor") {
  10720. onBlur(cm);
  10721. cm.display.input.blur();
  10722. }
  10723. cm.display.input.readOnlyChanged(val);
  10724. });
  10725. option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
  10726. option("dragDrop", true, dragDropChanged);
  10727. option("allowDropFileTypes", null);
  10728. option("cursorBlinkRate", 530);
  10729. option("cursorScrollMargin", 0);
  10730. option("cursorHeight", 1, updateSelection, true);
  10731. option("singleCursorHeightPerLine", true, updateSelection, true);
  10732. option("workTime", 100);
  10733. option("workDelay", 100);
  10734. option("flattenSpans", true, resetModeState, true);
  10735. option("addModeClass", false, resetModeState, true);
  10736. option("pollInterval", 100);
  10737. option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });
  10738. option("historyEventDelay", 1250);
  10739. option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true);
  10740. option("maxHighlightLength", 10000, resetModeState, true);
  10741. option("moveInputWithCursor", true, function (cm, val) {
  10742. if (!val) { cm.display.input.resetPosition(); }
  10743. });
  10744. option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; });
  10745. option("autofocus", null);
  10746. option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true);
  10747. option("phrases", null);
  10748. }
  10749. function dragDropChanged(cm, value, old) {
  10750. var wasOn = old && old != Init;
  10751. if (!value != !wasOn) {
  10752. var funcs = cm.display.dragFunctions;
  10753. var toggle = value ? on : off;
  10754. toggle(cm.display.scroller, "dragstart", funcs.start);
  10755. toggle(cm.display.scroller, "dragenter", funcs.enter);
  10756. toggle(cm.display.scroller, "dragover", funcs.over);
  10757. toggle(cm.display.scroller, "dragleave", funcs.leave);
  10758. toggle(cm.display.scroller, "drop", funcs.drop);
  10759. }
  10760. }
  10761. function wrappingChanged(cm) {
  10762. if (cm.options.lineWrapping) {
  10763. addClass(cm.display.wrapper, "CodeMirror-wrap");
  10764. cm.display.sizer.style.minWidth = "";
  10765. cm.display.sizerWidth = null;
  10766. } else {
  10767. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  10768. findMaxLine(cm);
  10769. }
  10770. estimateLineHeights(cm);
  10771. regChange(cm);
  10772. clearCaches(cm);
  10773. setTimeout(function () { return updateScrollbars(cm); }, 100);
  10774. }
  10775. // A CodeMirror instance represents an editor. This is the object
  10776. // that user code is usually dealing with.
  10777. function CodeMirror(place, options) {
  10778. var this$1 = this;
  10779. if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
  10780. this.options = options = options ? copyObj(options) : {};
  10781. // Determine effective options based on given values and defaults.
  10782. copyObj(defaults, options, false);
  10783. var doc = options.value;
  10784. if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }
  10785. else if (options.mode) { doc.modeOption = options.mode; }
  10786. this.doc = doc;
  10787. var input = new CodeMirror.inputStyles[options.inputStyle](this);
  10788. var display = this.display = new Display(place, doc, input, options);
  10789. display.wrapper.CodeMirror = this;
  10790. themeChanged(this);
  10791. if (options.lineWrapping)
  10792. { this.display.wrapper.className += " CodeMirror-wrap"; }
  10793. initScrollbars(this);
  10794. this.state = {
  10795. keyMaps: [], // stores maps added by addKeyMap
  10796. overlays: [], // highlighting overlays, as added by addOverlay
  10797. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  10798. overwrite: false,
  10799. delayingBlurEvent: false,
  10800. focused: false,
  10801. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  10802. pasteIncoming: -1, cutIncoming: -1, // help recognize paste/cut edits in input.poll
  10803. selectingText: false,
  10804. draggingText: false,
  10805. highlight: new Delayed(), // stores highlight worker timeout
  10806. keySeq: null, // Unfinished key sequence
  10807. specialChars: null
  10808. };
  10809. if (options.autofocus && !mobile) { display.input.focus(); }
  10810. // Override magic textarea content restore that IE sometimes does
  10811. // on our hidden textarea on reload
  10812. if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }
  10813. registerEventHandlers(this);
  10814. ensureGlobalHandlers();
  10815. startOperation(this);
  10816. this.curOp.forceUpdate = true;
  10817. attachDoc(this, doc);
  10818. if ((options.autofocus && !mobile) || this.hasFocus())
  10819. { setTimeout(bind(onFocus, this), 20); }
  10820. else
  10821. { onBlur(this); }
  10822. for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
  10823. { optionHandlers[opt](this$1, options[opt], Init); } }
  10824. maybeUpdateLineNumberWidth(this);
  10825. if (options.finishInit) { options.finishInit(this); }
  10826. for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1); }
  10827. endOperation(this);
  10828. // Suppress optimizelegibility in Webkit, since it breaks text
  10829. // measuring on line wrapping boundaries.
  10830. if (webkit && options.lineWrapping &&
  10831. getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
  10832. { display.lineDiv.style.textRendering = "auto"; }
  10833. }
  10834. // The default configuration options.
  10835. CodeMirror.defaults = defaults;
  10836. // Functions to run when options are changed.
  10837. CodeMirror.optionHandlers = optionHandlers;
  10838. // Attach the necessary event handlers when initializing the editor
  10839. function registerEventHandlers(cm) {
  10840. var d = cm.display;
  10841. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  10842. // Older IE's will not fire a second mousedown for a double click
  10843. if (ie && ie_version < 11)
  10844. { on(d.scroller, "dblclick", operation(cm, function (e) {
  10845. if (signalDOMEvent(cm, e)) { return }
  10846. var pos = posFromMouse(cm, e);
  10847. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
  10848. e_preventDefault(e);
  10849. var word = cm.findWordAt(pos);
  10850. extendSelection(cm.doc, word.anchor, word.head);
  10851. })); }
  10852. else
  10853. { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }
  10854. // Some browsers fire contextmenu *after* opening the menu, at
  10855. // which point we can't mess with it anymore. Context menu is
  10856. // handled in onMouseDown for these browsers.
  10857. on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); });
  10858. // Used to suppress mouse event handling when a touch happens
  10859. var touchFinished, prevTouch = {end: 0};
  10860. function finishTouch() {
  10861. if (d.activeTouch) {
  10862. touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);
  10863. prevTouch = d.activeTouch;
  10864. prevTouch.end = +new Date;
  10865. }
  10866. }
  10867. function isMouseLikeTouchEvent(e) {
  10868. if (e.touches.length != 1) { return false }
  10869. var touch = e.touches[0];
  10870. return touch.radiusX <= 1 && touch.radiusY <= 1
  10871. }
  10872. function farAway(touch, other) {
  10873. if (other.left == null) { return true }
  10874. var dx = other.left - touch.left, dy = other.top - touch.top;
  10875. return dx * dx + dy * dy > 20 * 20
  10876. }
  10877. on(d.scroller, "touchstart", function (e) {
  10878. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  10879. d.input.ensurePolled();
  10880. clearTimeout(touchFinished);
  10881. var now = +new Date;
  10882. d.activeTouch = {start: now, moved: false,
  10883. prev: now - prevTouch.end <= 300 ? prevTouch : null};
  10884. if (e.touches.length == 1) {
  10885. d.activeTouch.left = e.touches[0].pageX;
  10886. d.activeTouch.top = e.touches[0].pageY;
  10887. }
  10888. }
  10889. });
  10890. on(d.scroller, "touchmove", function () {
  10891. if (d.activeTouch) { d.activeTouch.moved = true; }
  10892. });
  10893. on(d.scroller, "touchend", function (e) {
  10894. var touch = d.activeTouch;
  10895. if (touch && !eventInWidget(d, e) && touch.left != null &&
  10896. !touch.moved && new Date - touch.start < 300) {
  10897. var pos = cm.coordsChar(d.activeTouch, "page"), range;
  10898. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  10899. { range = new Range(pos, pos); }
  10900. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  10901. { range = cm.findWordAt(pos); }
  10902. else // Triple tap
  10903. { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }
  10904. cm.setSelection(range.anchor, range.head);
  10905. cm.focus();
  10906. e_preventDefault(e);
  10907. }
  10908. finishTouch();
  10909. });
  10910. on(d.scroller, "touchcancel", finishTouch);
  10911. // Sync scrolling between fake scrollbars and real scrollable
  10912. // area, ensure viewport is updated when scrolling.
  10913. on(d.scroller, "scroll", function () {
  10914. if (d.scroller.clientHeight) {
  10915. updateScrollTop(cm, d.scroller.scrollTop);
  10916. setScrollLeft(cm, d.scroller.scrollLeft, true);
  10917. signal(cm, "scroll", cm);
  10918. }
  10919. });
  10920. // Listen to wheel events in order to try and update the viewport on time.
  10921. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); });
  10922. on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); });
  10923. // Prevent wrapper from ever scrolling
  10924. on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
  10925. d.dragFunctions = {
  10926. enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},
  10927. over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
  10928. start: function (e) { return onDragStart(cm, e); },
  10929. drop: operation(cm, onDrop),
  10930. leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
  10931. };
  10932. var inp = d.input.getField();
  10933. on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); });
  10934. on(inp, "keydown", operation(cm, onKeyDown));
  10935. on(inp, "keypress", operation(cm, onKeyPress));
  10936. on(inp, "focus", function (e) { return onFocus(cm, e); });
  10937. on(inp, "blur", function (e) { return onBlur(cm, e); });
  10938. }
  10939. var initHooks = [];
  10940. CodeMirror.defineInitHook = function (f) { return initHooks.push(f); };
  10941. // Indent the given line. The how parameter can be "smart",
  10942. // "add"/null, "subtract", or "prev". When aggressive is false
  10943. // (typically set to true for forced single-line indents), empty
  10944. // lines are not indented, and places where the mode returns Pass
  10945. // are left alone.
  10946. function indentLine(cm, n, how, aggressive) {
  10947. var doc = cm.doc, state;
  10948. if (how == null) { how = "add"; }
  10949. if (how == "smart") {
  10950. // Fall back to "prev" when the mode doesn't have an indentation
  10951. // method.
  10952. if (!doc.mode.indent) { how = "prev"; }
  10953. else { state = getContextBefore(cm, n).state; }
  10954. }
  10955. var tabSize = cm.options.tabSize;
  10956. var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
  10957. if (line.stateAfter) { line.stateAfter = null; }
  10958. var curSpaceString = line.text.match(/^\s*/)[0], indentation;
  10959. if (!aggressive && !/\S/.test(line.text)) {
  10960. indentation = 0;
  10961. how = "not";
  10962. } else if (how == "smart") {
  10963. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  10964. if (indentation == Pass || indentation > 150) {
  10965. if (!aggressive) { return }
  10966. how = "prev";
  10967. }
  10968. }
  10969. if (how == "prev") {
  10970. if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }
  10971. else { indentation = 0; }
  10972. } else if (how == "add") {
  10973. indentation = curSpace + cm.options.indentUnit;
  10974. } else if (how == "subtract") {
  10975. indentation = curSpace - cm.options.indentUnit;
  10976. } else if (typeof how == "number") {
  10977. indentation = curSpace + how;
  10978. }
  10979. indentation = Math.max(0, indentation);
  10980. var indentString = "", pos = 0;
  10981. if (cm.options.indentWithTabs)
  10982. { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} }
  10983. if (pos < indentation) { indentString += spaceStr(indentation - pos); }
  10984. if (indentString != curSpaceString) {
  10985. replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  10986. line.stateAfter = null;
  10987. return true
  10988. } else {
  10989. // Ensure that, if the cursor was in the whitespace at the start
  10990. // of the line, it is moved to the end of that space.
  10991. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  10992. var range = doc.sel.ranges[i$1];
  10993. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  10994. var pos$1 = Pos(n, curSpaceString.length);
  10995. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
  10996. break
  10997. }
  10998. }
  10999. }
  11000. }
  11001. // This will be set to a {lineWise: bool, text: [string]} object, so
  11002. // that, when pasting, we know what kind of selections the copied
  11003. // text was made out of.
  11004. var lastCopied = null;
  11005. function setLastCopied(newLastCopied) {
  11006. lastCopied = newLastCopied;
  11007. }
  11008. function applyTextInput(cm, inserted, deleted, sel, origin) {
  11009. var doc = cm.doc;
  11010. cm.display.shift = false;
  11011. if (!sel) { sel = doc.sel; }
  11012. var recent = +new Date - 200;
  11013. var paste = origin == "paste" || cm.state.pasteIncoming > recent;
  11014. var textLines = splitLinesAuto(inserted), multiPaste = null;
  11015. // When pasting N lines into N selections, insert one line per selection
  11016. if (paste && sel.ranges.length > 1) {
  11017. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  11018. if (sel.ranges.length % lastCopied.text.length == 0) {
  11019. multiPaste = [];
  11020. for (var i = 0; i < lastCopied.text.length; i++)
  11021. { multiPaste.push(doc.splitLines(lastCopied.text[i])); }
  11022. }
  11023. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
  11024. multiPaste = map(textLines, function (l) { return [l]; });
  11025. }
  11026. }
  11027. var updateInput = cm.curOp.updateInput;
  11028. // Normal behavior is to insert the new text into every selection
  11029. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  11030. var range$$1 = sel.ranges[i$1];
  11031. var from = range$$1.from(), to = range$$1.to();
  11032. if (range$$1.empty()) {
  11033. if (deleted && deleted > 0) // Handle deletion
  11034. { from = Pos(from.line, from.ch - deleted); }
  11035. else if (cm.state.overwrite && !paste) // Handle overwrite
  11036. { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
  11037. else if (paste && lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
  11038. { from = to = Pos(from.line, 0); }
  11039. }
  11040. var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  11041. origin: origin || (paste ? "paste" : cm.state.cutIncoming > recent ? "cut" : "+input")};
  11042. makeChange(cm.doc, changeEvent);
  11043. signalLater(cm, "inputRead", cm, changeEvent);
  11044. }
  11045. if (inserted && !paste)
  11046. { triggerElectric(cm, inserted); }
  11047. ensureCursorVisible(cm);
  11048. if (cm.curOp.updateInput < 2) { cm.curOp.updateInput = updateInput; }
  11049. cm.curOp.typing = true;
  11050. cm.state.pasteIncoming = cm.state.cutIncoming = -1;
  11051. }
  11052. function handlePaste(e, cm) {
  11053. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  11054. if (pasted) {
  11055. e.preventDefault();
  11056. if (!cm.isReadOnly() && !cm.options.disableInput)
  11057. { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
  11058. return true
  11059. }
  11060. }
  11061. function triggerElectric(cm, inserted) {
  11062. // When an 'electric' character is inserted, immediately trigger a reindent
  11063. if (!cm.options.electricChars || !cm.options.smartIndent) { return }
  11064. var sel = cm.doc.sel;
  11065. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  11066. var range$$1 = sel.ranges[i];
  11067. if (range$$1.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range$$1.head.line)) { continue }
  11068. var mode = cm.getModeAt(range$$1.head);
  11069. var indented = false;
  11070. if (mode.electricChars) {
  11071. for (var j = 0; j < mode.electricChars.length; j++)
  11072. { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  11073. indented = indentLine(cm, range$$1.head.line, "smart");
  11074. break
  11075. } }
  11076. } else if (mode.electricInput) {
  11077. if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch)))
  11078. { indented = indentLine(cm, range$$1.head.line, "smart"); }
  11079. }
  11080. if (indented) { signalLater(cm, "electricInput", cm, range$$1.head.line); }
  11081. }
  11082. }
  11083. function copyableRanges(cm) {
  11084. var text = [], ranges = [];
  11085. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  11086. var line = cm.doc.sel.ranges[i].head.line;
  11087. var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
  11088. ranges.push(lineRange);
  11089. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  11090. }
  11091. return {text: text, ranges: ranges}
  11092. }
  11093. function disableBrowserMagic(field, spellcheck, autocorrect, autocapitalize) {
  11094. field.setAttribute("autocorrect", autocorrect ? "" : "off");
  11095. field.setAttribute("autocapitalize", autocapitalize ? "" : "off");
  11096. field.setAttribute("spellcheck", !!spellcheck);
  11097. }
  11098. function hiddenTextarea() {
  11099. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
  11100. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  11101. // The textarea is kept positioned near the cursor to prevent the
  11102. // fact that it'll be scrolled into view on input from scrolling
  11103. // our fake cursor out of view. On webkit, when wrap=off, paste is
  11104. // very slow. So make the area wide instead.
  11105. if (webkit) { te.style.width = "1000px"; }
  11106. else { te.setAttribute("wrap", "off"); }
  11107. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  11108. if (ios) { te.style.border = "1px solid black"; }
  11109. disableBrowserMagic(te);
  11110. return div
  11111. }
  11112. // The publicly visible API. Note that methodOp(f) means
  11113. // 'wrap f in an operation, performed on its `this` parameter'.
  11114. // This is not the complete set of editor methods. Most of the
  11115. // methods defined on the Doc type are also injected into
  11116. // CodeMirror.prototype, for backwards compatibility and
  11117. // convenience.
  11118. function addEditorMethods(CodeMirror) {
  11119. var optionHandlers = CodeMirror.optionHandlers;
  11120. var helpers = CodeMirror.helpers = {};
  11121. CodeMirror.prototype = {
  11122. constructor: CodeMirror,
  11123. focus: function(){window.focus(); this.display.input.focus();},
  11124. setOption: function(option, value) {
  11125. var options = this.options, old = options[option];
  11126. if (options[option] == value && option != "mode") { return }
  11127. options[option] = value;
  11128. if (optionHandlers.hasOwnProperty(option))
  11129. { operation(this, optionHandlers[option])(this, value, old); }
  11130. signal(this, "optionChange", this, option);
  11131. },
  11132. getOption: function(option) {return this.options[option]},
  11133. getDoc: function() {return this.doc},
  11134. addKeyMap: function(map$$1, bottom) {
  11135. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1));
  11136. },
  11137. removeKeyMap: function(map$$1) {
  11138. var maps = this.state.keyMaps;
  11139. for (var i = 0; i < maps.length; ++i)
  11140. { if (maps[i] == map$$1 || maps[i].name == map$$1) {
  11141. maps.splice(i, 1);
  11142. return true
  11143. } }
  11144. },
  11145. addOverlay: methodOp(function(spec, options) {
  11146. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
  11147. if (mode.startState) { throw new Error("Overlays may not be stateful.") }
  11148. insertSorted(this.state.overlays,
  11149. {mode: mode, modeSpec: spec, opaque: options && options.opaque,
  11150. priority: (options && options.priority) || 0},
  11151. function (overlay) { return overlay.priority; });
  11152. this.state.modeGen++;
  11153. regChange(this);
  11154. }),
  11155. removeOverlay: methodOp(function(spec) {
  11156. var this$1 = this;
  11157. var overlays = this.state.overlays;
  11158. for (var i = 0; i < overlays.length; ++i) {
  11159. var cur = overlays[i].modeSpec;
  11160. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  11161. overlays.splice(i, 1);
  11162. this$1.state.modeGen++;
  11163. regChange(this$1);
  11164. return
  11165. }
  11166. }
  11167. }),
  11168. indentLine: methodOp(function(n, dir, aggressive) {
  11169. if (typeof dir != "string" && typeof dir != "number") {
  11170. if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; }
  11171. else { dir = dir ? "add" : "subtract"; }
  11172. }
  11173. if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }
  11174. }),
  11175. indentSelection: methodOp(function(how) {
  11176. var this$1 = this;
  11177. var ranges = this.doc.sel.ranges, end = -1;
  11178. for (var i = 0; i < ranges.length; i++) {
  11179. var range$$1 = ranges[i];
  11180. if (!range$$1.empty()) {
  11181. var from = range$$1.from(), to = range$$1.to();
  11182. var start = Math.max(end, from.line);
  11183. end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  11184. for (var j = start; j < end; ++j)
  11185. { indentLine(this$1, j, how); }
  11186. var newRanges = this$1.doc.sel.ranges;
  11187. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
  11188. { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }
  11189. } else if (range$$1.head.line > end) {
  11190. indentLine(this$1, range$$1.head.line, how, true);
  11191. end = range$$1.head.line;
  11192. if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1); }
  11193. }
  11194. }
  11195. }),
  11196. // Fetch the parser token for a given character. Useful for hacks
  11197. // that want to inspect the mode state (say, for completion).
  11198. getTokenAt: function(pos, precise) {
  11199. return takeToken(this, pos, precise)
  11200. },
  11201. getLineTokens: function(line, precise) {
  11202. return takeToken(this, Pos(line), precise, true)
  11203. },
  11204. getTokenTypeAt: function(pos) {
  11205. pos = clipPos(this.doc, pos);
  11206. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  11207. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
  11208. var type;
  11209. if (ch == 0) { type = styles[2]; }
  11210. else { for (;;) {
  11211. var mid = (before + after) >> 1;
  11212. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }
  11213. else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }
  11214. else { type = styles[mid * 2 + 2]; break }
  11215. } }
  11216. var cut = type ? type.indexOf("overlay ") : -1;
  11217. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
  11218. },
  11219. getModeAt: function(pos) {
  11220. var mode = this.doc.mode;
  11221. if (!mode.innerMode) { return mode }
  11222. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
  11223. },
  11224. getHelper: function(pos, type) {
  11225. return this.getHelpers(pos, type)[0]
  11226. },
  11227. getHelpers: function(pos, type) {
  11228. var this$1 = this;
  11229. var found = [];
  11230. if (!helpers.hasOwnProperty(type)) { return found }
  11231. var help = helpers[type], mode = this.getModeAt(pos);
  11232. if (typeof mode[type] == "string") {
  11233. if (help[mode[type]]) { found.push(help[mode[type]]); }
  11234. } else if (mode[type]) {
  11235. for (var i = 0; i < mode[type].length; i++) {
  11236. var val = help[mode[type][i]];
  11237. if (val) { found.push(val); }
  11238. }
  11239. } else if (mode.helperType && help[mode.helperType]) {
  11240. found.push(help[mode.helperType]);
  11241. } else if (help[mode.name]) {
  11242. found.push(help[mode.name]);
  11243. }
  11244. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  11245. var cur = help._global[i$1];
  11246. if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
  11247. { found.push(cur.val); }
  11248. }
  11249. return found
  11250. },
  11251. getStateAfter: function(line, precise) {
  11252. var doc = this.doc;
  11253. line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
  11254. return getContextBefore(this, line + 1, precise).state
  11255. },
  11256. cursorCoords: function(start, mode) {
  11257. var pos, range$$1 = this.doc.sel.primary();
  11258. if (start == null) { pos = range$$1.head; }
  11259. else if (typeof start == "object") { pos = clipPos(this.doc, start); }
  11260. else { pos = start ? range$$1.from() : range$$1.to(); }
  11261. return cursorCoords(this, pos, mode || "page")
  11262. },
  11263. charCoords: function(pos, mode) {
  11264. return charCoords(this, clipPos(this.doc, pos), mode || "page")
  11265. },
  11266. coordsChar: function(coords, mode) {
  11267. coords = fromCoordSystem(this, coords, mode || "page");
  11268. return coordsChar(this, coords.left, coords.top)
  11269. },
  11270. lineAtHeight: function(height, mode) {
  11271. height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
  11272. return lineAtHeight(this.doc, height + this.display.viewOffset)
  11273. },
  11274. heightAtLine: function(line, mode, includeWidgets) {
  11275. var end = false, lineObj;
  11276. if (typeof line == "number") {
  11277. var last = this.doc.first + this.doc.size - 1;
  11278. if (line < this.doc.first) { line = this.doc.first; }
  11279. else if (line > last) { line = last; end = true; }
  11280. lineObj = getLine(this.doc, line);
  11281. } else {
  11282. lineObj = line;
  11283. }
  11284. return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
  11285. (end ? this.doc.height - heightAtLine(lineObj) : 0)
  11286. },
  11287. defaultTextHeight: function() { return textHeight(this.display) },
  11288. defaultCharWidth: function() { return charWidth(this.display) },
  11289. getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
  11290. addWidget: function(pos, node, scroll, vert, horiz) {
  11291. var display = this.display;
  11292. pos = cursorCoords(this, clipPos(this.doc, pos));
  11293. var top = pos.bottom, left = pos.left;
  11294. node.style.position = "absolute";
  11295. node.setAttribute("cm-ignore-events", "true");
  11296. this.display.input.setUneditable(node);
  11297. display.sizer.appendChild(node);
  11298. if (vert == "over") {
  11299. top = pos.top;
  11300. } else if (vert == "above" || vert == "near") {
  11301. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  11302. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  11303. // Default to positioning above (if specified and possible); otherwise default to positioning below
  11304. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
  11305. { top = pos.top - node.offsetHeight; }
  11306. else if (pos.bottom + node.offsetHeight <= vspace)
  11307. { top = pos.bottom; }
  11308. if (left + node.offsetWidth > hspace)
  11309. { left = hspace - node.offsetWidth; }
  11310. }
  11311. node.style.top = top + "px";
  11312. node.style.left = node.style.right = "";
  11313. if (horiz == "right") {
  11314. left = display.sizer.clientWidth - node.offsetWidth;
  11315. node.style.right = "0px";
  11316. } else {
  11317. if (horiz == "left") { left = 0; }
  11318. else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }
  11319. node.style.left = left + "px";
  11320. }
  11321. if (scroll)
  11322. { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }
  11323. },
  11324. triggerOnKeyDown: methodOp(onKeyDown),
  11325. triggerOnKeyPress: methodOp(onKeyPress),
  11326. triggerOnKeyUp: onKeyUp,
  11327. triggerOnMouseDown: methodOp(onMouseDown),
  11328. execCommand: function(cmd) {
  11329. if (commands.hasOwnProperty(cmd))
  11330. { return commands[cmd].call(null, this) }
  11331. },
  11332. triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
  11333. findPosH: function(from, amount, unit, visually) {
  11334. var this$1 = this;
  11335. var dir = 1;
  11336. if (amount < 0) { dir = -1; amount = -amount; }
  11337. var cur = clipPos(this.doc, from);
  11338. for (var i = 0; i < amount; ++i) {
  11339. cur = findPosH(this$1.doc, cur, dir, unit, visually);
  11340. if (cur.hitSide) { break }
  11341. }
  11342. return cur
  11343. },
  11344. moveH: methodOp(function(dir, unit) {
  11345. var this$1 = this;
  11346. this.extendSelectionsBy(function (range$$1) {
  11347. if (this$1.display.shift || this$1.doc.extend || range$$1.empty())
  11348. { return findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually) }
  11349. else
  11350. { return dir < 0 ? range$$1.from() : range$$1.to() }
  11351. }, sel_move);
  11352. }),
  11353. deleteH: methodOp(function(dir, unit) {
  11354. var sel = this.doc.sel, doc = this.doc;
  11355. if (sel.somethingSelected())
  11356. { doc.replaceSelection("", null, "+delete"); }
  11357. else
  11358. { deleteNearSelection(this, function (range$$1) {
  11359. var other = findPosH(doc, range$$1.head, dir, unit, false);
  11360. return dir < 0 ? {from: other, to: range$$1.head} : {from: range$$1.head, to: other}
  11361. }); }
  11362. }),
  11363. findPosV: function(from, amount, unit, goalColumn) {
  11364. var this$1 = this;
  11365. var dir = 1, x = goalColumn;
  11366. if (amount < 0) { dir = -1; amount = -amount; }
  11367. var cur = clipPos(this.doc, from);
  11368. for (var i = 0; i < amount; ++i) {
  11369. var coords = cursorCoords(this$1, cur, "div");
  11370. if (x == null) { x = coords.left; }
  11371. else { coords.left = x; }
  11372. cur = findPosV(this$1, coords, dir, unit);
  11373. if (cur.hitSide) { break }
  11374. }
  11375. return cur
  11376. },
  11377. moveV: methodOp(function(dir, unit) {
  11378. var this$1 = this;
  11379. var doc = this.doc, goals = [];
  11380. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
  11381. doc.extendSelectionsBy(function (range$$1) {
  11382. if (collapse)
  11383. { return dir < 0 ? range$$1.from() : range$$1.to() }
  11384. var headPos = cursorCoords(this$1, range$$1.head, "div");
  11385. if (range$$1.goalColumn != null) { headPos.left = range$$1.goalColumn; }
  11386. goals.push(headPos.left);
  11387. var pos = findPosV(this$1, headPos, dir, unit);
  11388. if (unit == "page" && range$$1 == doc.sel.primary())
  11389. { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); }
  11390. return pos
  11391. }, sel_move);
  11392. if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
  11393. { doc.sel.ranges[i].goalColumn = goals[i]; } }
  11394. }),
  11395. // Find the word at the given position (as returned by coordsChar).
  11396. findWordAt: function(pos) {
  11397. var doc = this.doc, line = getLine(doc, pos.line).text;
  11398. var start = pos.ch, end = pos.ch;
  11399. if (line) {
  11400. var helper = this.getHelper(pos, "wordChars");
  11401. if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; }
  11402. var startChar = line.charAt(start);
  11403. var check = isWordChar(startChar, helper)
  11404. ? function (ch) { return isWordChar(ch, helper); }
  11405. : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
  11406. : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); };
  11407. while (start > 0 && check(line.charAt(start - 1))) { --start; }
  11408. while (end < line.length && check(line.charAt(end))) { ++end; }
  11409. }
  11410. return new Range(Pos(pos.line, start), Pos(pos.line, end))
  11411. },
  11412. toggleOverwrite: function(value) {
  11413. if (value != null && value == this.state.overwrite) { return }
  11414. if (this.state.overwrite = !this.state.overwrite)
  11415. { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  11416. else
  11417. { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  11418. signal(this, "overwriteToggle", this, this.state.overwrite);
  11419. },
  11420. hasFocus: function() { return this.display.input.getField() == activeElt() },
  11421. isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
  11422. scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
  11423. getScrollInfo: function() {
  11424. var scroller = this.display.scroller;
  11425. return {left: scroller.scrollLeft, top: scroller.scrollTop,
  11426. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  11427. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  11428. clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
  11429. },
  11430. scrollIntoView: methodOp(function(range$$1, margin) {
  11431. if (range$$1 == null) {
  11432. range$$1 = {from: this.doc.sel.primary().head, to: null};
  11433. if (margin == null) { margin = this.options.cursorScrollMargin; }
  11434. } else if (typeof range$$1 == "number") {
  11435. range$$1 = {from: Pos(range$$1, 0), to: null};
  11436. } else if (range$$1.from == null) {
  11437. range$$1 = {from: range$$1, to: null};
  11438. }
  11439. if (!range$$1.to) { range$$1.to = range$$1.from; }
  11440. range$$1.margin = margin || 0;
  11441. if (range$$1.from.line != null) {
  11442. scrollToRange(this, range$$1);
  11443. } else {
  11444. scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);
  11445. }
  11446. }),
  11447. setSize: methodOp(function(width, height) {
  11448. var this$1 = this;
  11449. var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; };
  11450. if (width != null) { this.display.wrapper.style.width = interpret(width); }
  11451. if (height != null) { this.display.wrapper.style.height = interpret(height); }
  11452. if (this.options.lineWrapping) { clearLineMeasurementCache(this); }
  11453. var lineNo$$1 = this.display.viewFrom;
  11454. this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {
  11455. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
  11456. { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo$$1, "widget"); break } } }
  11457. ++lineNo$$1;
  11458. });
  11459. this.curOp.forceUpdate = true;
  11460. signal(this, "refresh", this);
  11461. }),
  11462. operation: function(f){return runInOp(this, f)},
  11463. startOperation: function(){return startOperation(this)},
  11464. endOperation: function(){return endOperation(this)},
  11465. refresh: methodOp(function() {
  11466. var oldHeight = this.display.cachedTextHeight;
  11467. regChange(this);
  11468. this.curOp.forceUpdate = true;
  11469. clearCaches(this);
  11470. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  11471. updateGutterSpace(this.display);
  11472. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
  11473. { estimateLineHeights(this); }
  11474. signal(this, "refresh", this);
  11475. }),
  11476. swapDoc: methodOp(function(doc) {
  11477. var old = this.doc;
  11478. old.cm = null;
  11479. // Cancel the current text selection if any (#5821)
  11480. if (this.state.selectingText) { this.state.selectingText(); }
  11481. attachDoc(this, doc);
  11482. clearCaches(this);
  11483. this.display.input.reset();
  11484. scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
  11485. this.curOp.forceScroll = true;
  11486. signalLater(this, "swapDoc", this, old);
  11487. return old
  11488. }),
  11489. phrase: function(phraseText) {
  11490. var phrases = this.options.phrases;
  11491. return phrases && Object.prototype.hasOwnProperty.call(phrases, phraseText) ? phrases[phraseText] : phraseText
  11492. },
  11493. getInputField: function(){return this.display.input.getField()},
  11494. getWrapperElement: function(){return this.display.wrapper},
  11495. getScrollerElement: function(){return this.display.scroller},
  11496. getGutterElement: function(){return this.display.gutters}
  11497. };
  11498. eventMixin(CodeMirror);
  11499. CodeMirror.registerHelper = function(type, name, value) {
  11500. if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }
  11501. helpers[type][name] = value;
  11502. };
  11503. CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
  11504. CodeMirror.registerHelper(type, name, value);
  11505. helpers[type]._global.push({pred: predicate, val: value});
  11506. };
  11507. }
  11508. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  11509. // right), unit can be "char", "column" (like char, but doesn't
  11510. // cross line boundaries), "word" (across next word), or "group" (to
  11511. // the start of next group of word or non-word-non-whitespace
  11512. // chars). The visually param controls whether, in right-to-left
  11513. // text, direction 1 means to move towards the next index in the
  11514. // string, or towards the character to the right of the current
  11515. // position. The resulting position will have a hitSide=true
  11516. // property if it reached the end of the document.
  11517. function findPosH(doc, pos, dir, unit, visually) {
  11518. var oldPos = pos;
  11519. var origDir = dir;
  11520. var lineObj = getLine(doc, pos.line);
  11521. function findNextLine() {
  11522. var l = pos.line + dir;
  11523. if (l < doc.first || l >= doc.first + doc.size) { return false }
  11524. pos = new Pos(l, pos.ch, pos.sticky);
  11525. return lineObj = getLine(doc, l)
  11526. }
  11527. function moveOnce(boundToLine) {
  11528. var next;
  11529. if (visually) {
  11530. next = moveVisually(doc.cm, lineObj, pos, dir);
  11531. } else {
  11532. next = moveLogically(lineObj, pos, dir);
  11533. }
  11534. if (next == null) {
  11535. if (!boundToLine && findNextLine())
  11536. { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
  11537. else
  11538. { return false }
  11539. } else {
  11540. pos = next;
  11541. }
  11542. return true
  11543. }
  11544. if (unit == "char") {
  11545. moveOnce();
  11546. } else if (unit == "column") {
  11547. moveOnce(true);
  11548. } else if (unit == "word" || unit == "group") {
  11549. var sawType = null, group = unit == "group";
  11550. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
  11551. for (var first = true;; first = false) {
  11552. if (dir < 0 && !moveOnce(!first)) { break }
  11553. var cur = lineObj.text.charAt(pos.ch) || "\n";
  11554. var type = isWordChar(cur, helper) ? "w"
  11555. : group && cur == "\n" ? "n"
  11556. : !group || /\s/.test(cur) ? null
  11557. : "p";
  11558. if (group && !first && !type) { type = "s"; }
  11559. if (sawType && sawType != type) {
  11560. if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";}
  11561. break
  11562. }
  11563. if (type) { sawType = type; }
  11564. if (dir > 0 && !moveOnce(!first)) { break }
  11565. }
  11566. }
  11567. var result = skipAtomic(doc, pos, oldPos, origDir, true);
  11568. if (equalCursorPos(oldPos, result)) { result.hitSide = true; }
  11569. return result
  11570. }
  11571. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  11572. // "page" or "line". The resulting position will have a hitSide=true
  11573. // property if it reached the end of the document.
  11574. function findPosV(cm, pos, dir, unit) {
  11575. var doc = cm.doc, x = pos.left, y;
  11576. if (unit == "page") {
  11577. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
  11578. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  11579. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  11580. } else if (unit == "line") {
  11581. y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  11582. }
  11583. var target;
  11584. for (;;) {
  11585. target = coordsChar(cm, x, y);
  11586. if (!target.outside) { break }
  11587. if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
  11588. y += dir * 5;
  11589. }
  11590. return target
  11591. }
  11592. // CONTENTEDITABLE INPUT STYLE
  11593. var ContentEditableInput = function(cm) {
  11594. this.cm = cm;
  11595. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  11596. this.polling = new Delayed();
  11597. this.composing = null;
  11598. this.gracePeriod = false;
  11599. this.readDOMTimeout = null;
  11600. };
  11601. ContentEditableInput.prototype.init = function (display) {
  11602. var this$1 = this;
  11603. var input = this, cm = input.cm;
  11604. var div = input.div = display.lineDiv;
  11605. disableBrowserMagic(div, cm.options.spellcheck, cm.options.autocorrect, cm.options.autocapitalize);
  11606. on(div, "paste", function (e) {
  11607. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  11608. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  11609. if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
  11610. });
  11611. on(div, "compositionstart", function (e) {
  11612. this$1.composing = {data: e.data, done: false};
  11613. });
  11614. on(div, "compositionupdate", function (e) {
  11615. if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }
  11616. });
  11617. on(div, "compositionend", function (e) {
  11618. if (this$1.composing) {
  11619. if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }
  11620. this$1.composing.done = true;
  11621. }
  11622. });
  11623. on(div, "touchstart", function () { return input.forceCompositionEnd(); });
  11624. on(div, "input", function () {
  11625. if (!this$1.composing) { this$1.readFromDOMSoon(); }
  11626. });
  11627. function onCopyCut(e) {
  11628. if (signalDOMEvent(cm, e)) { return }
  11629. if (cm.somethingSelected()) {
  11630. setLastCopied({lineWise: false, text: cm.getSelections()});
  11631. if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
  11632. } else if (!cm.options.lineWiseCopyCut) {
  11633. return
  11634. } else {
  11635. var ranges = copyableRanges(cm);
  11636. setLastCopied({lineWise: true, text: ranges.text});
  11637. if (e.type == "cut") {
  11638. cm.operation(function () {
  11639. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  11640. cm.replaceSelection("", null, "cut");
  11641. });
  11642. }
  11643. }
  11644. if (e.clipboardData) {
  11645. e.clipboardData.clearData();
  11646. var content = lastCopied.text.join("\n");
  11647. // iOS exposes the clipboard API, but seems to discard content inserted into it
  11648. e.clipboardData.setData("Text", content);
  11649. if (e.clipboardData.getData("Text") == content) {
  11650. e.preventDefault();
  11651. return
  11652. }
  11653. }
  11654. // Old-fashioned briefly-focus-a-textarea hack
  11655. var kludge = hiddenTextarea(), te = kludge.firstChild;
  11656. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  11657. te.value = lastCopied.text.join("\n");
  11658. var hadFocus = document.activeElement;
  11659. selectInput(te);
  11660. setTimeout(function () {
  11661. cm.display.lineSpace.removeChild(kludge);
  11662. hadFocus.focus();
  11663. if (hadFocus == div) { input.showPrimarySelection(); }
  11664. }, 50);
  11665. }
  11666. on(div, "copy", onCopyCut);
  11667. on(div, "cut", onCopyCut);
  11668. };
  11669. ContentEditableInput.prototype.prepareSelection = function () {
  11670. var result = prepareSelection(this.cm, false);
  11671. result.focus = this.cm.state.focused;
  11672. return result
  11673. };
  11674. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  11675. if (!info || !this.cm.display.view.length) { return }
  11676. if (info.focus || takeFocus) { this.showPrimarySelection(); }
  11677. this.showMultipleSelections(info);
  11678. };
  11679. ContentEditableInput.prototype.getSelection = function () {
  11680. return this.cm.display.wrapper.ownerDocument.getSelection()
  11681. };
  11682. ContentEditableInput.prototype.showPrimarySelection = function () {
  11683. var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
  11684. var from = prim.from(), to = prim.to();
  11685. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  11686. sel.removeAllRanges();
  11687. return
  11688. }
  11689. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  11690. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  11691. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
  11692. cmp(minPos(curAnchor, curFocus), from) == 0 &&
  11693. cmp(maxPos(curAnchor, curFocus), to) == 0)
  11694. { return }
  11695. var view = cm.display.view;
  11696. var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
  11697. {node: view[0].measure.map[2], offset: 0};
  11698. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  11699. if (!end) {
  11700. var measure = view[view.length - 1].measure;
  11701. var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  11702. end = {node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3]};
  11703. }
  11704. if (!start || !end) {
  11705. sel.removeAllRanges();
  11706. return
  11707. }
  11708. var old = sel.rangeCount && sel.getRangeAt(0), rng;
  11709. try { rng = range(start.node, start.offset, end.offset, end.node); }
  11710. catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  11711. if (rng) {
  11712. if (!gecko && cm.state.focused) {
  11713. sel.collapse(start.node, start.offset);
  11714. if (!rng.collapsed) {
  11715. sel.removeAllRanges();
  11716. sel.addRange(rng);
  11717. }
  11718. } else {
  11719. sel.removeAllRanges();
  11720. sel.addRange(rng);
  11721. }
  11722. if (old && sel.anchorNode == null) { sel.addRange(old); }
  11723. else if (gecko) { this.startGracePeriod(); }
  11724. }
  11725. this.rememberSelection();
  11726. };
  11727. ContentEditableInput.prototype.startGracePeriod = function () {
  11728. var this$1 = this;
  11729. clearTimeout(this.gracePeriod);
  11730. this.gracePeriod = setTimeout(function () {
  11731. this$1.gracePeriod = false;
  11732. if (this$1.selectionChanged())
  11733. { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }
  11734. }, 20);
  11735. };
  11736. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  11737. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  11738. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  11739. };
  11740. ContentEditableInput.prototype.rememberSelection = function () {
  11741. var sel = this.getSelection();
  11742. this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
  11743. this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
  11744. };
  11745. ContentEditableInput.prototype.selectionInEditor = function () {
  11746. var sel = this.getSelection();
  11747. if (!sel.rangeCount) { return false }
  11748. var node = sel.getRangeAt(0).commonAncestorContainer;
  11749. return contains(this.div, node)
  11750. };
  11751. ContentEditableInput.prototype.focus = function () {
  11752. if (this.cm.options.readOnly != "nocursor") {
  11753. if (!this.selectionInEditor())
  11754. { this.showSelection(this.prepareSelection(), true); }
  11755. this.div.focus();
  11756. }
  11757. };
  11758. ContentEditableInput.prototype.blur = function () { this.div.blur(); };
  11759. ContentEditableInput.prototype.getField = function () { return this.div };
  11760. ContentEditableInput.prototype.supportsTouch = function () { return true };
  11761. ContentEditableInput.prototype.receivedFocus = function () {
  11762. var input = this;
  11763. if (this.selectionInEditor())
  11764. { this.pollSelection(); }
  11765. else
  11766. { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
  11767. function poll() {
  11768. if (input.cm.state.focused) {
  11769. input.pollSelection();
  11770. input.polling.set(input.cm.options.pollInterval, poll);
  11771. }
  11772. }
  11773. this.polling.set(this.cm.options.pollInterval, poll);
  11774. };
  11775. ContentEditableInput.prototype.selectionChanged = function () {
  11776. var sel = this.getSelection();
  11777. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
  11778. sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
  11779. };
  11780. ContentEditableInput.prototype.pollSelection = function () {
  11781. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
  11782. var sel = this.getSelection(), cm = this.cm;
  11783. // On Android Chrome (version 56, at least), backspacing into an
  11784. // uneditable block element will put the cursor in that element,
  11785. // and then, because it's not editable, hide the virtual keyboard.
  11786. // Because Android doesn't allow us to actually detect backspace
  11787. // presses in a sane way, this code checks for when that happens
  11788. // and simulates a backspace press in this case.
  11789. if (android && chrome && this.cm.display.gutterSpecs.length && isInGutter(sel.anchorNode)) {
  11790. this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs});
  11791. this.blur();
  11792. this.focus();
  11793. return
  11794. }
  11795. if (this.composing) { return }
  11796. this.rememberSelection();
  11797. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  11798. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  11799. if (anchor && head) { runInOp(cm, function () {
  11800. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  11801. if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }
  11802. }); }
  11803. };
  11804. ContentEditableInput.prototype.pollContent = function () {
  11805. if (this.readDOMTimeout != null) {
  11806. clearTimeout(this.readDOMTimeout);
  11807. this.readDOMTimeout = null;
  11808. }
  11809. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
  11810. var from = sel.from(), to = sel.to();
  11811. if (from.ch == 0 && from.line > cm.firstLine())
  11812. { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
  11813. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
  11814. { to = Pos(to.line + 1, 0); }
  11815. if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
  11816. var fromIndex, fromLine, fromNode;
  11817. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  11818. fromLine = lineNo(display.view[0].line);
  11819. fromNode = display.view[0].node;
  11820. } else {
  11821. fromLine = lineNo(display.view[fromIndex].line);
  11822. fromNode = display.view[fromIndex - 1].node.nextSibling;
  11823. }
  11824. var toIndex = findViewIndex(cm, to.line);
  11825. var toLine, toNode;
  11826. if (toIndex == display.view.length - 1) {
  11827. toLine = display.viewTo - 1;
  11828. toNode = display.lineDiv.lastChild;
  11829. } else {
  11830. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  11831. toNode = display.view[toIndex + 1].node.previousSibling;
  11832. }
  11833. if (!fromNode) { return false }
  11834. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  11835. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  11836. while (newText.length > 1 && oldText.length > 1) {
  11837. if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
  11838. else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
  11839. else { break }
  11840. }
  11841. var cutFront = 0, cutEnd = 0;
  11842. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
  11843. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
  11844. { ++cutFront; }
  11845. var newBot = lst(newText), oldBot = lst(oldText);
  11846. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
  11847. oldBot.length - (oldText.length == 1 ? cutFront : 0));
  11848. while (cutEnd < maxCutEnd &&
  11849. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
  11850. { ++cutEnd; }
  11851. // Try to move start of change to start of selection if ambiguous
  11852. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
  11853. while (cutFront && cutFront > from.ch &&
  11854. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  11855. cutFront--;
  11856. cutEnd++;
  11857. }
  11858. }
  11859. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  11860. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  11861. var chFrom = Pos(fromLine, cutFront);
  11862. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  11863. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  11864. replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  11865. return true
  11866. }
  11867. };
  11868. ContentEditableInput.prototype.ensurePolled = function () {
  11869. this.forceCompositionEnd();
  11870. };
  11871. ContentEditableInput.prototype.reset = function () {
  11872. this.forceCompositionEnd();
  11873. };
  11874. ContentEditableInput.prototype.forceCompositionEnd = function () {
  11875. if (!this.composing) { return }
  11876. clearTimeout(this.readDOMTimeout);
  11877. this.composing = null;
  11878. this.updateFromDOM();
  11879. this.div.blur();
  11880. this.div.focus();
  11881. };
  11882. ContentEditableInput.prototype.readFromDOMSoon = function () {
  11883. var this$1 = this;
  11884. if (this.readDOMTimeout != null) { return }
  11885. this.readDOMTimeout = setTimeout(function () {
  11886. this$1.readDOMTimeout = null;
  11887. if (this$1.composing) {
  11888. if (this$1.composing.done) { this$1.composing = null; }
  11889. else { return }
  11890. }
  11891. this$1.updateFromDOM();
  11892. }, 80);
  11893. };
  11894. ContentEditableInput.prototype.updateFromDOM = function () {
  11895. var this$1 = this;
  11896. if (this.cm.isReadOnly() || !this.pollContent())
  11897. { runInOp(this.cm, function () { return regChange(this$1.cm); }); }
  11898. };
  11899. ContentEditableInput.prototype.setUneditable = function (node) {
  11900. node.contentEditable = "false";
  11901. };
  11902. ContentEditableInput.prototype.onKeyPress = function (e) {
  11903. if (e.charCode == 0 || this.composing) { return }
  11904. e.preventDefault();
  11905. if (!this.cm.isReadOnly())
  11906. { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }
  11907. };
  11908. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  11909. this.div.contentEditable = String(val != "nocursor");
  11910. };
  11911. ContentEditableInput.prototype.onContextMenu = function () {};
  11912. ContentEditableInput.prototype.resetPosition = function () {};
  11913. ContentEditableInput.prototype.needsContentAttribute = true;
  11914. function posToDOM(cm, pos) {
  11915. var view = findViewForLine(cm, pos.line);
  11916. if (!view || view.hidden) { return null }
  11917. var line = getLine(cm.doc, pos.line);
  11918. var info = mapFromLineView(view, line, pos.line);
  11919. var order = getOrder(line, cm.doc.direction), side = "left";
  11920. if (order) {
  11921. var partPos = getBidiPartAt(order, pos.ch);
  11922. side = partPos % 2 ? "right" : "left";
  11923. }
  11924. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  11925. result.offset = result.collapse == "right" ? result.end : result.start;
  11926. return result
  11927. }
  11928. function isInGutter(node) {
  11929. for (var scan = node; scan; scan = scan.parentNode)
  11930. { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
  11931. return false
  11932. }
  11933. function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
  11934. function domTextBetween(cm, from, to, fromLine, toLine) {
  11935. var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false;
  11936. function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
  11937. function close() {
  11938. if (closing) {
  11939. text += lineSep;
  11940. if (extraLinebreak) { text += lineSep; }
  11941. closing = extraLinebreak = false;
  11942. }
  11943. }
  11944. function addText(str) {
  11945. if (str) {
  11946. close();
  11947. text += str;
  11948. }
  11949. }
  11950. function walk(node) {
  11951. if (node.nodeType == 1) {
  11952. var cmText = node.getAttribute("cm-text");
  11953. if (cmText) {
  11954. addText(cmText);
  11955. return
  11956. }
  11957. var markerID = node.getAttribute("cm-marker"), range$$1;
  11958. if (markerID) {
  11959. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  11960. if (found.length && (range$$1 = found[0].find(0)))
  11961. { addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep)); }
  11962. return
  11963. }
  11964. if (node.getAttribute("contenteditable") == "false") { return }
  11965. var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName);
  11966. if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return }
  11967. if (isBlock) { close(); }
  11968. for (var i = 0; i < node.childNodes.length; i++)
  11969. { walk(node.childNodes[i]); }
  11970. if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; }
  11971. if (isBlock) { closing = true; }
  11972. } else if (node.nodeType == 3) {
  11973. addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
  11974. }
  11975. }
  11976. for (;;) {
  11977. walk(from);
  11978. if (from == to) { break }
  11979. from = from.nextSibling;
  11980. extraLinebreak = false;
  11981. }
  11982. return text
  11983. }
  11984. function domToPos(cm, node, offset) {
  11985. var lineNode;
  11986. if (node == cm.display.lineDiv) {
  11987. lineNode = cm.display.lineDiv.childNodes[offset];
  11988. if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
  11989. node = null; offset = 0;
  11990. } else {
  11991. for (lineNode = node;; lineNode = lineNode.parentNode) {
  11992. if (!lineNode || lineNode == cm.display.lineDiv) { return null }
  11993. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
  11994. }
  11995. }
  11996. for (var i = 0; i < cm.display.view.length; i++) {
  11997. var lineView = cm.display.view[i];
  11998. if (lineView.node == lineNode)
  11999. { return locateNodeInLineView(lineView, node, offset) }
  12000. }
  12001. }
  12002. function locateNodeInLineView(lineView, node, offset) {
  12003. var wrapper = lineView.text.firstChild, bad = false;
  12004. if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
  12005. if (node == wrapper) {
  12006. bad = true;
  12007. node = wrapper.childNodes[offset];
  12008. offset = 0;
  12009. if (!node) {
  12010. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  12011. return badPos(Pos(lineNo(line), line.text.length), bad)
  12012. }
  12013. }
  12014. var textNode = node.nodeType == 3 ? node : null, topNode = node;
  12015. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  12016. textNode = node.firstChild;
  12017. if (offset) { offset = textNode.nodeValue.length; }
  12018. }
  12019. while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }
  12020. var measure = lineView.measure, maps = measure.maps;
  12021. function find(textNode, topNode, offset) {
  12022. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  12023. var map$$1 = i < 0 ? measure.map : maps[i];
  12024. for (var j = 0; j < map$$1.length; j += 3) {
  12025. var curNode = map$$1[j + 2];
  12026. if (curNode == textNode || curNode == topNode) {
  12027. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
  12028. var ch = map$$1[j] + offset;
  12029. if (offset < 0 || curNode != textNode) { ch = map$$1[j + (offset ? 1 : 0)]; }
  12030. return Pos(line, ch)
  12031. }
  12032. }
  12033. }
  12034. }
  12035. var found = find(textNode, topNode, offset);
  12036. if (found) { return badPos(found, bad) }
  12037. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  12038. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  12039. found = find(after, after.firstChild, 0);
  12040. if (found)
  12041. { return badPos(Pos(found.line, found.ch - dist), bad) }
  12042. else
  12043. { dist += after.textContent.length; }
  12044. }
  12045. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  12046. found = find(before, before.firstChild, -1);
  12047. if (found)
  12048. { return badPos(Pos(found.line, found.ch + dist$1), bad) }
  12049. else
  12050. { dist$1 += before.textContent.length; }
  12051. }
  12052. }
  12053. // TEXTAREA INPUT STYLE
  12054. var TextareaInput = function(cm) {
  12055. this.cm = cm;
  12056. // See input.poll and input.reset
  12057. this.prevInput = "";
  12058. // Flag that indicates whether we expect input to appear real soon
  12059. // now (after some event like 'keypress' or 'input') and are
  12060. // polling intensively.
  12061. this.pollingFast = false;
  12062. // Self-resetting timeout for the poller
  12063. this.polling = new Delayed();
  12064. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  12065. this.hasSelection = false;
  12066. this.composing = null;
  12067. };
  12068. TextareaInput.prototype.init = function (display) {
  12069. var this$1 = this;
  12070. var input = this, cm = this.cm;
  12071. this.createField(display);
  12072. var te = this.textarea;
  12073. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  12074. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  12075. if (ios) { te.style.width = "0px"; }
  12076. on(te, "input", function () {
  12077. if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }
  12078. input.poll();
  12079. });
  12080. on(te, "paste", function (e) {
  12081. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  12082. cm.state.pasteIncoming = +new Date;
  12083. input.fastPoll();
  12084. });
  12085. function prepareCopyCut(e) {
  12086. if (signalDOMEvent(cm, e)) { return }
  12087. if (cm.somethingSelected()) {
  12088. setLastCopied({lineWise: false, text: cm.getSelections()});
  12089. } else if (!cm.options.lineWiseCopyCut) {
  12090. return
  12091. } else {
  12092. var ranges = copyableRanges(cm);
  12093. setLastCopied({lineWise: true, text: ranges.text});
  12094. if (e.type == "cut") {
  12095. cm.setSelections(ranges.ranges, null, sel_dontScroll);
  12096. } else {
  12097. input.prevInput = "";
  12098. te.value = ranges.text.join("\n");
  12099. selectInput(te);
  12100. }
  12101. }
  12102. if (e.type == "cut") { cm.state.cutIncoming = +new Date; }
  12103. }
  12104. on(te, "cut", prepareCopyCut);
  12105. on(te, "copy", prepareCopyCut);
  12106. on(display.scroller, "paste", function (e) {
  12107. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
  12108. if (!te.dispatchEvent) {
  12109. cm.state.pasteIncoming = +new Date;
  12110. input.focus();
  12111. return
  12112. }
  12113. // Pass the `paste` event to the textarea so it's handled by its event listener.
  12114. var event = new Event("paste");
  12115. event.clipboardData = e.clipboardData;
  12116. te.dispatchEvent(event);
  12117. });
  12118. // Prevent normal selection in the editor (we handle our own)
  12119. on(display.lineSpace, "selectstart", function (e) {
  12120. if (!eventInWidget(display, e)) { e_preventDefault(e); }
  12121. });
  12122. on(te, "compositionstart", function () {
  12123. var start = cm.getCursor("from");
  12124. if (input.composing) { input.composing.range.clear(); }
  12125. input.composing = {
  12126. start: start,
  12127. range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
  12128. };
  12129. });
  12130. on(te, "compositionend", function () {
  12131. if (input.composing) {
  12132. input.poll();
  12133. input.composing.range.clear();
  12134. input.composing = null;
  12135. }
  12136. });
  12137. };
  12138. TextareaInput.prototype.createField = function (_display) {
  12139. // Wraps and hides input textarea
  12140. this.wrapper = hiddenTextarea();
  12141. // The semihidden textarea that is focused when the editor is
  12142. // focused, and receives input.
  12143. this.textarea = this.wrapper.firstChild;
  12144. };
  12145. TextareaInput.prototype.prepareSelection = function () {
  12146. // Redraw the selection and/or cursor
  12147. var cm = this.cm, display = cm.display, doc = cm.doc;
  12148. var result = prepareSelection(cm);
  12149. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  12150. if (cm.options.moveInputWithCursor) {
  12151. var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
  12152. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
  12153. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
  12154. headPos.top + lineOff.top - wrapOff.top));
  12155. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
  12156. headPos.left + lineOff.left - wrapOff.left));
  12157. }
  12158. return result
  12159. };
  12160. TextareaInput.prototype.showSelection = function (drawn) {
  12161. var cm = this.cm, display = cm.display;
  12162. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  12163. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  12164. if (drawn.teTop != null) {
  12165. this.wrapper.style.top = drawn.teTop + "px";
  12166. this.wrapper.style.left = drawn.teLeft + "px";
  12167. }
  12168. };
  12169. // Reset the input to correspond to the selection (or to be empty,
  12170. // when not typing and nothing is selected)
  12171. TextareaInput.prototype.reset = function (typing) {
  12172. if (this.contextMenuPending || this.composing) { return }
  12173. var cm = this.cm;
  12174. if (cm.somethingSelected()) {
  12175. this.prevInput = "";
  12176. var content = cm.getSelection();
  12177. this.textarea.value = content;
  12178. if (cm.state.focused) { selectInput(this.textarea); }
  12179. if (ie && ie_version >= 9) { this.hasSelection = content; }
  12180. } else if (!typing) {
  12181. this.prevInput = this.textarea.value = "";
  12182. if (ie && ie_version >= 9) { this.hasSelection = null; }
  12183. }
  12184. };
  12185. TextareaInput.prototype.getField = function () { return this.textarea };
  12186. TextareaInput.prototype.supportsTouch = function () { return false };
  12187. TextareaInput.prototype.focus = function () {
  12188. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  12189. try { this.textarea.focus(); }
  12190. catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  12191. }
  12192. };
  12193. TextareaInput.prototype.blur = function () { this.textarea.blur(); };
  12194. TextareaInput.prototype.resetPosition = function () {
  12195. this.wrapper.style.top = this.wrapper.style.left = 0;
  12196. };
  12197. TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };
  12198. // Poll for input changes, using the normal rate of polling. This
  12199. // runs as long as the editor is focused.
  12200. TextareaInput.prototype.slowPoll = function () {
  12201. var this$1 = this;
  12202. if (this.pollingFast) { return }
  12203. this.polling.set(this.cm.options.pollInterval, function () {
  12204. this$1.poll();
  12205. if (this$1.cm.state.focused) { this$1.slowPoll(); }
  12206. });
  12207. };
  12208. // When an event has just come in that is likely to add or change
  12209. // something in the input textarea, we poll faster, to ensure that
  12210. // the change appears on the screen quickly.
  12211. TextareaInput.prototype.fastPoll = function () {
  12212. var missed = false, input = this;
  12213. input.pollingFast = true;
  12214. function p() {
  12215. var changed = input.poll();
  12216. if (!changed && !missed) {missed = true; input.polling.set(60, p);}
  12217. else {input.pollingFast = false; input.slowPoll();}
  12218. }
  12219. input.polling.set(20, p);
  12220. };
  12221. // Read input from the textarea, and update the document to match.
  12222. // When something is selected, it is present in the textarea, and
  12223. // selected (unless it is huge, in which case a placeholder is
  12224. // used). When nothing is selected, the cursor sits after previously
  12225. // seen text (can be empty), which is stored in prevInput (we must
  12226. // not reset the textarea when typing, because that breaks IME).
  12227. TextareaInput.prototype.poll = function () {
  12228. var this$1 = this;
  12229. var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
  12230. // Since this is called a *lot*, try to bail out as cheaply as
  12231. // possible when it is clear that nothing happened. hasSelection
  12232. // will be the case when there is a lot of text in the textarea,
  12233. // in which case reading its value would be expensive.
  12234. if (this.contextMenuPending || !cm.state.focused ||
  12235. (hasSelection(input) && !prevInput && !this.composing) ||
  12236. cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
  12237. { return false }
  12238. var text = input.value;
  12239. // If nothing changed, bail.
  12240. if (text == prevInput && !cm.somethingSelected()) { return false }
  12241. // Work around nonsensical selection resetting in IE9/10, and
  12242. // inexplicable appearance of private area unicode characters on
  12243. // some key combos in Mac (#2689).
  12244. if (ie && ie_version >= 9 && this.hasSelection === text ||
  12245. mac && /[\uf700-\uf7ff]/.test(text)) {
  12246. cm.display.input.reset();
  12247. return false
  12248. }
  12249. if (cm.doc.sel == cm.display.selForContextMenu) {
  12250. var first = text.charCodeAt(0);
  12251. if (first == 0x200b && !prevInput) { prevInput = "\u200b"; }
  12252. if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
  12253. }
  12254. // Find the part of the input that is actually new
  12255. var same = 0, l = Math.min(prevInput.length, text.length);
  12256. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }
  12257. runInOp(cm, function () {
  12258. applyTextInput(cm, text.slice(same), prevInput.length - same,
  12259. null, this$1.composing ? "*compose" : null);
  12260. // Don't leave long text in the textarea, since it makes further polling slow
  12261. if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; }
  12262. else { this$1.prevInput = text; }
  12263. if (this$1.composing) {
  12264. this$1.composing.range.clear();
  12265. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
  12266. {className: "CodeMirror-composing"});
  12267. }
  12268. });
  12269. return true
  12270. };
  12271. TextareaInput.prototype.ensurePolled = function () {
  12272. if (this.pollingFast && this.poll()) { this.pollingFast = false; }
  12273. };
  12274. TextareaInput.prototype.onKeyPress = function () {
  12275. if (ie && ie_version >= 9) { this.hasSelection = null; }
  12276. this.fastPoll();
  12277. };
  12278. TextareaInput.prototype.onContextMenu = function (e) {
  12279. var input = this, cm = input.cm, display = cm.display, te = input.textarea;
  12280. if (input.contextMenuPending) { input.contextMenuPending(); }
  12281. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
  12282. if (!pos || presto) { return } // Opera is difficult.
  12283. // Reset the current text selection only if the click is done outside of the selection
  12284. // and 'resetSelectionOnContextMenu' option is true.
  12285. var reset = cm.options.resetSelectionOnContextMenu;
  12286. if (reset && cm.doc.sel.contains(pos) == -1)
  12287. { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
  12288. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
  12289. var wrapperBox = input.wrapper.offsetParent.getBoundingClientRect();
  12290. input.wrapper.style.cssText = "position: static";
  12291. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
  12292. var oldScrollY;
  12293. if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
  12294. display.input.focus();
  12295. if (webkit) { window.scrollTo(null, oldScrollY); }
  12296. display.input.reset();
  12297. // Adds "Select all" to context menu in FF
  12298. if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
  12299. input.contextMenuPending = rehide;
  12300. display.selForContextMenu = cm.doc.sel;
  12301. clearTimeout(display.detectingSelectAll);
  12302. // Select-all will be greyed out if there's nothing to select, so
  12303. // this adds a zero-width space so that we can later check whether
  12304. // it got selected.
  12305. function prepareSelectAllHack() {
  12306. if (te.selectionStart != null) {
  12307. var selected = cm.somethingSelected();
  12308. var extval = "\u200b" + (selected ? te.value : "");
  12309. te.value = "\u21da"; // Used to catch context-menu undo
  12310. te.value = extval;
  12311. input.prevInput = selected ? "" : "\u200b";
  12312. te.selectionStart = 1; te.selectionEnd = extval.length;
  12313. // Re-set this, in case some other handler touched the
  12314. // selection in the meantime.
  12315. display.selForContextMenu = cm.doc.sel;
  12316. }
  12317. }
  12318. function rehide() {
  12319. if (input.contextMenuPending != rehide) { return }
  12320. input.contextMenuPending = false;
  12321. input.wrapper.style.cssText = oldWrapperCSS;
  12322. te.style.cssText = oldCSS;
  12323. if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }
  12324. // Try to detect the user choosing select-all
  12325. if (te.selectionStart != null) {
  12326. if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }
  12327. var i = 0, poll = function () {
  12328. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
  12329. te.selectionEnd > 0 && input.prevInput == "\u200b") {
  12330. operation(cm, selectAll)(cm);
  12331. } else if (i++ < 10) {
  12332. display.detectingSelectAll = setTimeout(poll, 500);
  12333. } else {
  12334. display.selForContextMenu = null;
  12335. display.input.reset();
  12336. }
  12337. };
  12338. display.detectingSelectAll = setTimeout(poll, 200);
  12339. }
  12340. }
  12341. if (ie && ie_version >= 9) { prepareSelectAllHack(); }
  12342. if (captureRightClick) {
  12343. e_stop(e);
  12344. var mouseup = function () {
  12345. off(window, "mouseup", mouseup);
  12346. setTimeout(rehide, 20);
  12347. };
  12348. on(window, "mouseup", mouseup);
  12349. } else {
  12350. setTimeout(rehide, 50);
  12351. }
  12352. };
  12353. TextareaInput.prototype.readOnlyChanged = function (val) {
  12354. if (!val) { this.reset(); }
  12355. this.textarea.disabled = val == "nocursor";
  12356. };
  12357. TextareaInput.prototype.setUneditable = function () {};
  12358. TextareaInput.prototype.needsContentAttribute = false;
  12359. function fromTextArea(textarea, options) {
  12360. options = options ? copyObj(options) : {};
  12361. options.value = textarea.value;
  12362. if (!options.tabindex && textarea.tabIndex)
  12363. { options.tabindex = textarea.tabIndex; }
  12364. if (!options.placeholder && textarea.placeholder)
  12365. { options.placeholder = textarea.placeholder; }
  12366. // Set autofocus to true if this textarea is focused, or if it has
  12367. // autofocus and no other element is focused.
  12368. if (options.autofocus == null) {
  12369. var hasFocus = activeElt();
  12370. options.autofocus = hasFocus == textarea ||
  12371. textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  12372. }
  12373. function save() {textarea.value = cm.getValue();}
  12374. var realSubmit;
  12375. if (textarea.form) {
  12376. on(textarea.form, "submit", save);
  12377. // Deplorable hack to make the submit method do the right thing.
  12378. if (!options.leaveSubmitMethodAlone) {
  12379. var form = textarea.form;
  12380. realSubmit = form.submit;
  12381. try {
  12382. var wrappedSubmit = form.submit = function () {
  12383. save();
  12384. form.submit = realSubmit;
  12385. form.submit();
  12386. form.submit = wrappedSubmit;
  12387. };
  12388. } catch(e) {}
  12389. }
  12390. }
  12391. options.finishInit = function (cm) {
  12392. cm.save = save;
  12393. cm.getTextArea = function () { return textarea; };
  12394. cm.toTextArea = function () {
  12395. cm.toTextArea = isNaN; // Prevent this from being ran twice
  12396. save();
  12397. textarea.parentNode.removeChild(cm.getWrapperElement());
  12398. textarea.style.display = "";
  12399. if (textarea.form) {
  12400. off(textarea.form, "submit", save);
  12401. if (typeof textarea.form.submit == "function")
  12402. { textarea.form.submit = realSubmit; }
  12403. }
  12404. };
  12405. };
  12406. textarea.style.display = "none";
  12407. var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
  12408. options);
  12409. return cm
  12410. }
  12411. function addLegacyProps(CodeMirror) {
  12412. CodeMirror.off = off;
  12413. CodeMirror.on = on;
  12414. CodeMirror.wheelEventPixels = wheelEventPixels;
  12415. CodeMirror.Doc = Doc;
  12416. CodeMirror.splitLines = splitLinesAuto;
  12417. CodeMirror.countColumn = countColumn;
  12418. CodeMirror.findColumn = findColumn;
  12419. CodeMirror.isWordChar = isWordCharBasic;
  12420. CodeMirror.Pass = Pass;
  12421. CodeMirror.signal = signal;
  12422. CodeMirror.Line = Line;
  12423. CodeMirror.changeEnd = changeEnd;
  12424. CodeMirror.scrollbarModel = scrollbarModel;
  12425. CodeMirror.Pos = Pos;
  12426. CodeMirror.cmpPos = cmp;
  12427. CodeMirror.modes = modes;
  12428. CodeMirror.mimeModes = mimeModes;
  12429. CodeMirror.resolveMode = resolveMode;
  12430. CodeMirror.getMode = getMode;
  12431. CodeMirror.modeExtensions = modeExtensions;
  12432. CodeMirror.extendMode = extendMode;
  12433. CodeMirror.copyState = copyState;
  12434. CodeMirror.startState = startState;
  12435. CodeMirror.innerMode = innerMode;
  12436. CodeMirror.commands = commands;
  12437. CodeMirror.keyMap = keyMap;
  12438. CodeMirror.keyName = keyName;
  12439. CodeMirror.isModifierKey = isModifierKey;
  12440. CodeMirror.lookupKey = lookupKey;
  12441. CodeMirror.normalizeKeyMap = normalizeKeyMap;
  12442. CodeMirror.StringStream = StringStream;
  12443. CodeMirror.SharedTextMarker = SharedTextMarker;
  12444. CodeMirror.TextMarker = TextMarker;
  12445. CodeMirror.LineWidget = LineWidget;
  12446. CodeMirror.e_preventDefault = e_preventDefault;
  12447. CodeMirror.e_stopPropagation = e_stopPropagation;
  12448. CodeMirror.e_stop = e_stop;
  12449. CodeMirror.addClass = addClass;
  12450. CodeMirror.contains = contains;
  12451. CodeMirror.rmClass = rmClass;
  12452. CodeMirror.keyNames = keyNames;
  12453. }
  12454. // EDITOR CONSTRUCTOR
  12455. defineOptions(CodeMirror);
  12456. addEditorMethods(CodeMirror);
  12457. // Set up methods on CodeMirror's prototype to redirect to the editor's document.
  12458. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  12459. for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
  12460. { CodeMirror.prototype[prop] = (function(method) {
  12461. return function() {return method.apply(this.doc, arguments)}
  12462. })(Doc.prototype[prop]); } }
  12463. eventMixin(Doc);
  12464. CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
  12465. // Extra arguments are stored as the mode's dependencies, which is
  12466. // used by (legacy) mechanisms like loadmode.js to automatically
  12467. // load a mode. (Preferred mechanism is the require/define calls.)
  12468. CodeMirror.defineMode = function(name/*, mode, …*/) {
  12469. if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name; }
  12470. defineMode.apply(this, arguments);
  12471. };
  12472. CodeMirror.defineMIME = defineMIME;
  12473. // Minimal default mode.
  12474. CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
  12475. CodeMirror.defineMIME("text/plain", "null");
  12476. // EXTENSIONS
  12477. CodeMirror.defineExtension = function (name, func) {
  12478. CodeMirror.prototype[name] = func;
  12479. };
  12480. CodeMirror.defineDocExtension = function (name, func) {
  12481. Doc.prototype[name] = func;
  12482. };
  12483. CodeMirror.fromTextArea = fromTextArea;
  12484. addLegacyProps(CodeMirror);
  12485. CodeMirror.version = "5.47.0";
  12486. return CodeMirror;
  12487. })));
  12488. },{}],17:[function(require,module,exports){
  12489. "use strict";
  12490. var deselectCurrent = require("toggle-selection");
  12491. var defaultMessage = "Copy to clipboard: #{key}, Enter";
  12492. function format(message) {
  12493. var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
  12494. return message.replace(/#{\s*key\s*}/g, copyKey);
  12495. }
  12496. function copy(text, options) {
  12497. var debug,
  12498. message,
  12499. reselectPrevious,
  12500. range,
  12501. selection,
  12502. mark,
  12503. success = false;
  12504. if (!options) {
  12505. options = {};
  12506. }
  12507. debug = options.debug || false;
  12508. try {
  12509. reselectPrevious = deselectCurrent();
  12510. range = document.createRange();
  12511. selection = document.getSelection();
  12512. mark = document.createElement("span");
  12513. mark.textContent = text;
  12514. // reset user styles for span element
  12515. mark.style.all = "unset";
  12516. // prevents scrolling to the end of the page
  12517. mark.style.position = "fixed";
  12518. mark.style.top = 0;
  12519. mark.style.clip = "rect(0, 0, 0, 0)";
  12520. // used to preserve spaces and line breaks
  12521. mark.style.whiteSpace = "pre";
  12522. // do not inherit user-select (it may be `none`)
  12523. mark.style.webkitUserSelect = "text";
  12524. mark.style.MozUserSelect = "text";
  12525. mark.style.msUserSelect = "text";
  12526. mark.style.userSelect = "text";
  12527. mark.addEventListener("copy", function(e) {
  12528. e.stopPropagation();
  12529. if (options.format) {
  12530. e.preventDefault();
  12531. e.clipboardData.clearData();
  12532. e.clipboardData.setData(options.format, text);
  12533. }
  12534. });
  12535. document.body.appendChild(mark);
  12536. range.selectNodeContents(mark);
  12537. selection.addRange(range);
  12538. var successful = document.execCommand("copy");
  12539. if (!successful) {
  12540. throw new Error("copy command was unsuccessful");
  12541. }
  12542. success = true;
  12543. } catch (err) {
  12544. debug && console.error("unable to copy using execCommand: ", err);
  12545. debug && console.warn("trying IE specific stuff");
  12546. try {
  12547. window.clipboardData.setData(options.format || "text", text);
  12548. success = true;
  12549. } catch (err) {
  12550. debug && console.error("unable to copy using clipboardData: ", err);
  12551. debug && console.error("falling back to prompt");
  12552. message = format("message" in options ? options.message : defaultMessage);
  12553. window.prompt(message, text);
  12554. }
  12555. } finally {
  12556. if (selection) {
  12557. if (typeof selection.removeRange == "function") {
  12558. selection.removeRange(range);
  12559. } else {
  12560. selection.removeAllRanges();
  12561. }
  12562. }
  12563. if (mark) {
  12564. document.body.removeChild(mark);
  12565. }
  12566. reselectPrevious();
  12567. }
  12568. return success;
  12569. }
  12570. module.exports = copy;
  12571. },{"toggle-selection":207}],18:[function(require,module,exports){
  12572. module.exports={"Aacute":"\u00C1","aacute":"\u00E1","Abreve":"\u0102","abreve":"\u0103","ac":"\u223E","acd":"\u223F","acE":"\u223E\u0333","Acirc":"\u00C2","acirc":"\u00E2","acute":"\u00B4","Acy":"\u0410","acy":"\u0430","AElig":"\u00C6","aelig":"\u00E6","af":"\u2061","Afr":"\uD835\uDD04","afr":"\uD835\uDD1E","Agrave":"\u00C0","agrave":"\u00E0","alefsym":"\u2135","aleph":"\u2135","Alpha":"\u0391","alpha":"\u03B1","Amacr":"\u0100","amacr":"\u0101","amalg":"\u2A3F","amp":"&","AMP":"&","andand":"\u2A55","And":"\u2A53","and":"\u2227","andd":"\u2A5C","andslope":"\u2A58","andv":"\u2A5A","ang":"\u2220","ange":"\u29A4","angle":"\u2220","angmsdaa":"\u29A8","angmsdab":"\u29A9","angmsdac":"\u29AA","angmsdad":"\u29AB","angmsdae":"\u29AC","angmsdaf":"\u29AD","angmsdag":"\u29AE","angmsdah":"\u29AF","angmsd":"\u2221","angrt":"\u221F","angrtvb":"\u22BE","angrtvbd":"\u299D","angsph":"\u2222","angst":"\u00C5","angzarr":"\u237C","Aogon":"\u0104","aogon":"\u0105","Aopf":"\uD835\uDD38","aopf":"\uD835\uDD52","apacir":"\u2A6F","ap":"\u2248","apE":"\u2A70","ape":"\u224A","apid":"\u224B","apos":"'","ApplyFunction":"\u2061","approx":"\u2248","approxeq":"\u224A","Aring":"\u00C5","aring":"\u00E5","Ascr":"\uD835\uDC9C","ascr":"\uD835\uDCB6","Assign":"\u2254","ast":"*","asymp":"\u2248","asympeq":"\u224D","Atilde":"\u00C3","atilde":"\u00E3","Auml":"\u00C4","auml":"\u00E4","awconint":"\u2233","awint":"\u2A11","backcong":"\u224C","backepsilon":"\u03F6","backprime":"\u2035","backsim":"\u223D","backsimeq":"\u22CD","Backslash":"\u2216","Barv":"\u2AE7","barvee":"\u22BD","barwed":"\u2305","Barwed":"\u2306","barwedge":"\u2305","bbrk":"\u23B5","bbrktbrk":"\u23B6","bcong":"\u224C","Bcy":"\u0411","bcy":"\u0431","bdquo":"\u201E","becaus":"\u2235","because":"\u2235","Because":"\u2235","bemptyv":"\u29B0","bepsi":"\u03F6","bernou":"\u212C","Bernoullis":"\u212C","Beta":"\u0392","beta":"\u03B2","beth":"\u2136","between":"\u226C","Bfr":"\uD835\uDD05","bfr":"\uD835\uDD1F","bigcap":"\u22C2","bigcirc":"\u25EF","bigcup":"\u22C3","bigodot":"\u2A00","bigoplus":"\u2A01","bigotimes":"\u2A02","bigsqcup":"\u2A06","bigstar":"\u2605","bigtriangledown":"\u25BD","bigtriangleup":"\u25B3","biguplus":"\u2A04","bigvee":"\u22C1","bigwedge":"\u22C0","bkarow":"\u290D","blacklozenge":"\u29EB","blacksquare":"\u25AA","blacktriangle":"\u25B4","blacktriangledown":"\u25BE","blacktriangleleft":"\u25C2","blacktriangleright":"\u25B8","blank":"\u2423","blk12":"\u2592","blk14":"\u2591","blk34":"\u2593","block":"\u2588","bne":"=\u20E5","bnequiv":"\u2261\u20E5","bNot":"\u2AED","bnot":"\u2310","Bopf":"\uD835\uDD39","bopf":"\uD835\uDD53","bot":"\u22A5","bottom":"\u22A5","bowtie":"\u22C8","boxbox":"\u29C9","boxdl":"\u2510","boxdL":"\u2555","boxDl":"\u2556","boxDL":"\u2557","boxdr":"\u250C","boxdR":"\u2552","boxDr":"\u2553","boxDR":"\u2554","boxh":"\u2500","boxH":"\u2550","boxhd":"\u252C","boxHd":"\u2564","boxhD":"\u2565","boxHD":"\u2566","boxhu":"\u2534","boxHu":"\u2567","boxhU":"\u2568","boxHU":"\u2569","boxminus":"\u229F","boxplus":"\u229E","boxtimes":"\u22A0","boxul":"\u2518","boxuL":"\u255B","boxUl":"\u255C","boxUL":"\u255D","boxur":"\u2514","boxuR":"\u2558","boxUr":"\u2559","boxUR":"\u255A","boxv":"\u2502","boxV":"\u2551","boxvh":"\u253C","boxvH":"\u256A","boxVh":"\u256B","boxVH":"\u256C","boxvl":"\u2524","boxvL":"\u2561","boxVl":"\u2562","boxVL":"\u2563","boxvr":"\u251C","boxvR":"\u255E","boxVr":"\u255F","boxVR":"\u2560","bprime":"\u2035","breve":"\u02D8","Breve":"\u02D8","brvbar":"\u00A6","bscr":"\uD835\uDCB7","Bscr":"\u212C","bsemi":"\u204F","bsim":"\u223D","bsime":"\u22CD","bsolb":"\u29C5","bsol":"\\","bsolhsub":"\u27C8","bull":"\u2022","bullet":"\u2022","bump":"\u224E","bumpE":"\u2AAE","bumpe":"\u224F","Bumpeq":"\u224E","bumpeq":"\u224F","Cacute":"\u0106","cacute":"\u0107","capand":"\u2A44","capbrcup":"\u2A49","capcap":"\u2A4B","cap":"\u2229","Cap":"\u22D2","capcup":"\u2A47","capdot":"\u2A40","CapitalDifferentialD":"\u2145","caps":"\u2229\uFE00","caret":"\u2041","caron":"\u02C7","Cayleys":"\u212D","ccaps":"\u2A4D","Ccaron":"\u010C","ccaron":"\u010D","Ccedil":"\u00C7","ccedil":"\u00E7","Ccirc":"\u0108","ccirc":"\u0109","Cconint":"\u2230","ccups":"\u2A4C","ccupssm":"\u2A50","Cdot":"\u010A","cdot":"\u010B","cedil":"\u00B8","Cedilla":"\u00B8","cemptyv":"\u29B2","cent":"\u00A2","centerdot":"\u00B7","CenterDot":"\u00B7","cfr":"\uD835\uDD20","Cfr":"\u212D","CHcy":"\u0427","chcy":"\u0447","check":"\u2713","checkmark":"\u2713","Chi":"\u03A7","chi":"\u03C7","circ":"\u02C6","circeq":"\u2257","circlearrowleft":"\u21BA","circlearrowright":"\u21BB","circledast":"\u229B","circledcirc":"\u229A","circleddash":"\u229D","CircleDot":"\u2299","circledR":"\u00AE","circledS":"\u24C8","CircleMinus":"\u2296","CirclePlus":"\u2295","CircleTimes":"\u2297","cir":"\u25CB","cirE":"\u29C3","cire":"\u2257","cirfnint":"\u2A10","cirmid":"\u2AEF","cirscir":"\u29C2","ClockwiseContourIntegral":"\u2232","CloseCurlyDoubleQuote":"\u201D","CloseCurlyQuote":"\u2019","clubs":"\u2663","clubsuit":"\u2663","colon":":","Colon":"\u2237","Colone":"\u2A74","colone":"\u2254","coloneq":"\u2254","comma":",","commat":"@","comp":"\u2201","compfn":"\u2218","complement":"\u2201","complexes":"\u2102","cong":"\u2245","congdot":"\u2A6D","Congruent":"\u2261","conint":"\u222E","Conint":"\u222F","ContourIntegral":"\u222E","copf":"\uD835\uDD54","Copf":"\u2102","coprod":"\u2210","Coproduct":"\u2210","copy":"\u00A9","COPY":"\u00A9","copysr":"\u2117","CounterClockwiseContourIntegral":"\u2233","crarr":"\u21B5","cross":"\u2717","Cross":"\u2A2F","Cscr":"\uD835\uDC9E","cscr":"\uD835\uDCB8","csub":"\u2ACF","csube":"\u2AD1","csup":"\u2AD0","csupe":"\u2AD2","ctdot":"\u22EF","cudarrl":"\u2938","cudarrr":"\u2935","cuepr":"\u22DE","cuesc":"\u22DF","cularr":"\u21B6","cularrp":"\u293D","cupbrcap":"\u2A48","cupcap":"\u2A46","CupCap":"\u224D","cup":"\u222A","Cup":"\u22D3","cupcup":"\u2A4A","cupdot":"\u228D","cupor":"\u2A45","cups":"\u222A\uFE00","curarr":"\u21B7","curarrm":"\u293C","curlyeqprec":"\u22DE","curlyeqsucc":"\u22DF","curlyvee":"\u22CE","curlywedge":"\u22CF","curren":"\u00A4","curvearrowleft":"\u21B6","curvearrowright":"\u21B7","cuvee":"\u22CE","cuwed":"\u22CF","cwconint":"\u2232","cwint":"\u2231","cylcty":"\u232D","dagger":"\u2020","Dagger":"\u2021","daleth":"\u2138","darr":"\u2193","Darr":"\u21A1","dArr":"\u21D3","dash":"\u2010","Dashv":"\u2AE4","dashv":"\u22A3","dbkarow":"\u290F","dblac":"\u02DD","Dcaron":"\u010E","dcaron":"\u010F","Dcy":"\u0414","dcy":"\u0434","ddagger":"\u2021","ddarr":"\u21CA","DD":"\u2145","dd":"\u2146","DDotrahd":"\u2911","ddotseq":"\u2A77","deg":"\u00B0","Del":"\u2207","Delta":"\u0394","delta":"\u03B4","demptyv":"\u29B1","dfisht":"\u297F","Dfr":"\uD835\uDD07","dfr":"\uD835\uDD21","dHar":"\u2965","dharl":"\u21C3","dharr":"\u21C2","DiacriticalAcute":"\u00B4","DiacriticalDot":"\u02D9","DiacriticalDoubleAcute":"\u02DD","DiacriticalGrave":"`","DiacriticalTilde":"\u02DC","diam":"\u22C4","diamond":"\u22C4","Diamond":"\u22C4","diamondsuit":"\u2666","diams":"\u2666","die":"\u00A8","DifferentialD":"\u2146","digamma":"\u03DD","disin":"\u22F2","div":"\u00F7","divide":"\u00F7","divideontimes":"\u22C7","divonx":"\u22C7","DJcy":"\u0402","djcy":"\u0452","dlcorn":"\u231E","dlcrop":"\u230D","dollar":"$","Dopf":"\uD835\uDD3B","dopf":"\uD835\uDD55","Dot":"\u00A8","dot":"\u02D9","DotDot":"\u20DC","doteq":"\u2250","doteqdot":"\u2251","DotEqual":"\u2250","dotminus":"\u2238","dotplus":"\u2214","dotsquare":"\u22A1","doublebarwedge":"\u2306","DoubleContourIntegral":"\u222F","DoubleDot":"\u00A8","DoubleDownArrow":"\u21D3","DoubleLeftArrow":"\u21D0","DoubleLeftRightArrow":"\u21D4","DoubleLeftTee":"\u2AE4","DoubleLongLeftArrow":"\u27F8","DoubleLongLeftRightArrow":"\u27FA","DoubleLongRightArrow":"\u27F9","DoubleRightArrow":"\u21D2","DoubleRightTee":"\u22A8","DoubleUpArrow":"\u21D1","DoubleUpDownArrow":"\u21D5","DoubleVerticalBar":"\u2225","DownArrowBar":"\u2913","downarrow":"\u2193","DownArrow":"\u2193","Downarrow":"\u21D3","DownArrowUpArrow":"\u21F5","DownBreve":"\u0311","downdownarrows":"\u21CA","downharpoonleft":"\u21C3","downharpoonright":"\u21C2","DownLeftRightVector":"\u2950","DownLeftTeeVector":"\u295E","DownLeftVectorBar":"\u2956","DownLeftVector":"\u21BD","DownRightTeeVector":"\u295F","DownRightVectorBar":"\u2957","DownRightVector":"\u21C1","DownTeeArrow":"\u21A7","DownTee":"\u22A4","drbkarow":"\u2910","drcorn":"\u231F","drcrop":"\u230C","Dscr":"\uD835\uDC9F","dscr":"\uD835\uDCB9","DScy":"\u0405","dscy":"\u0455","dsol":"\u29F6","Dstrok":"\u0110","dstrok":"\u0111","dtdot":"\u22F1","dtri":"\u25BF","dtrif":"\u25BE","duarr":"\u21F5","duhar":"\u296F","dwangle":"\u29A6","DZcy":"\u040F","dzcy":"\u045F","dzigrarr":"\u27FF","Eacute":"\u00C9","eacute":"\u00E9","easter":"\u2A6E","Ecaron":"\u011A","ecaron":"\u011B","Ecirc":"\u00CA","ecirc":"\u00EA","ecir":"\u2256","ecolon":"\u2255","Ecy":"\u042D","ecy":"\u044D","eDDot":"\u2A77","Edot":"\u0116","edot":"\u0117","eDot":"\u2251","ee":"\u2147","efDot":"\u2252","Efr":"\uD835\uDD08","efr":"\uD835\uDD22","eg":"\u2A9A","Egrave":"\u00C8","egrave":"\u00E8","egs":"\u2A96","egsdot":"\u2A98","el":"\u2A99","Element":"\u2208","elinters":"\u23E7","ell":"\u2113","els":"\u2A95","elsdot":"\u2A97","Emacr":"\u0112","emacr":"\u0113","empty":"\u2205","emptyset":"\u2205","EmptySmallSquare":"\u25FB","emptyv":"\u2205","EmptyVerySmallSquare":"\u25AB","emsp13":"\u2004","emsp14":"\u2005","emsp":"\u2003","ENG":"\u014A","eng":"\u014B","ensp":"\u2002","Eogon":"\u0118","eogon":"\u0119","Eopf":"\uD835\uDD3C","eopf":"\uD835\uDD56","epar":"\u22D5","eparsl":"\u29E3","eplus":"\u2A71","epsi":"\u03B5","Epsilon":"\u0395","epsilon":"\u03B5","epsiv":"\u03F5","eqcirc":"\u2256","eqcolon":"\u2255","eqsim":"\u2242","eqslantgtr":"\u2A96","eqslantless":"\u2A95","Equal":"\u2A75","equals":"=","EqualTilde":"\u2242","equest":"\u225F","Equilibrium":"\u21CC","equiv":"\u2261","equivDD":"\u2A78","eqvparsl":"\u29E5","erarr":"\u2971","erDot":"\u2253","escr":"\u212F","Escr":"\u2130","esdot":"\u2250","Esim":"\u2A73","esim":"\u2242","Eta":"\u0397","eta":"\u03B7","ETH":"\u00D0","eth":"\u00F0","Euml":"\u00CB","euml":"\u00EB","euro":"\u20AC","excl":"!","exist":"\u2203","Exists":"\u2203","expectation":"\u2130","exponentiale":"\u2147","ExponentialE":"\u2147","fallingdotseq":"\u2252","Fcy":"\u0424","fcy":"\u0444","female":"\u2640","ffilig":"\uFB03","fflig":"\uFB00","ffllig":"\uFB04","Ffr":"\uD835\uDD09","ffr":"\uD835\uDD23","filig":"\uFB01","FilledSmallSquare":"\u25FC","FilledVerySmallSquare":"\u25AA","fjlig":"fj","flat":"\u266D","fllig":"\uFB02","fltns":"\u25B1","fnof":"\u0192","Fopf":"\uD835\uDD3D","fopf":"\uD835\uDD57","forall":"\u2200","ForAll":"\u2200","fork":"\u22D4","forkv":"\u2AD9","Fouriertrf":"\u2131","fpartint":"\u2A0D","frac12":"\u00BD","frac13":"\u2153","frac14":"\u00BC","frac15":"\u2155","frac16":"\u2159","frac18":"\u215B","frac23":"\u2154","frac25":"\u2156","frac34":"\u00BE","frac35":"\u2157","frac38":"\u215C","frac45":"\u2158","frac56":"\u215A","frac58":"\u215D","frac78":"\u215E","frasl":"\u2044","frown":"\u2322","fscr":"\uD835\uDCBB","Fscr":"\u2131","gacute":"\u01F5","Gamma":"\u0393","gamma":"\u03B3","Gammad":"\u03DC","gammad":"\u03DD","gap":"\u2A86","Gbreve":"\u011E","gbreve":"\u011F","Gcedil":"\u0122","Gcirc":"\u011C","gcirc":"\u011D","Gcy":"\u0413","gcy":"\u0433","Gdot":"\u0120","gdot":"\u0121","ge":"\u2265","gE":"\u2267","gEl":"\u2A8C","gel":"\u22DB","geq":"\u2265","geqq":"\u2267","geqslant":"\u2A7E","gescc":"\u2AA9","ges":"\u2A7E","gesdot":"\u2A80","gesdoto":"\u2A82","gesdotol":"\u2A84","gesl":"\u22DB\uFE00","gesles":"\u2A94","Gfr":"\uD835\uDD0A","gfr":"\uD835\uDD24","gg":"\u226B","Gg":"\u22D9","ggg":"\u22D9","gimel":"\u2137","GJcy":"\u0403","gjcy":"\u0453","gla":"\u2AA5","gl":"\u2277","glE":"\u2A92","glj":"\u2AA4","gnap":"\u2A8A","gnapprox":"\u2A8A","gne":"\u2A88","gnE":"\u2269","gneq":"\u2A88","gneqq":"\u2269","gnsim":"\u22E7","Gopf":"\uD835\uDD3E","gopf":"\uD835\uDD58","grave":"`","GreaterEqual":"\u2265","GreaterEqualLess":"\u22DB","GreaterFullEqual":"\u2267","GreaterGreater":"\u2AA2","GreaterLess":"\u2277","GreaterSlantEqual":"\u2A7E","GreaterTilde":"\u2273","Gscr":"\uD835\uDCA2","gscr":"\u210A","gsim":"\u2273","gsime":"\u2A8E","gsiml":"\u2A90","gtcc":"\u2AA7","gtcir":"\u2A7A","gt":">","GT":">","Gt":"\u226B","gtdot":"\u22D7","gtlPar":"\u2995","gtquest":"\u2A7C","gtrapprox":"\u2A86","gtrarr":"\u2978","gtrdot":"\u22D7","gtreqless":"\u22DB","gtreqqless":"\u2A8C","gtrless":"\u2277","gtrsim":"\u2273","gvertneqq":"\u2269\uFE00","gvnE":"\u2269\uFE00","Hacek":"\u02C7","hairsp":"\u200A","half":"\u00BD","hamilt":"\u210B","HARDcy":"\u042A","hardcy":"\u044A","harrcir":"\u2948","harr":"\u2194","hArr":"\u21D4","harrw":"\u21AD","Hat":"^","hbar":"\u210F","Hcirc":"\u0124","hcirc":"\u0125","hearts":"\u2665","heartsuit":"\u2665","hellip":"\u2026","hercon":"\u22B9","hfr":"\uD835\uDD25","Hfr":"\u210C","HilbertSpace":"\u210B","hksearow":"\u2925","hkswarow":"\u2926","hoarr":"\u21FF","homtht":"\u223B","hookleftarrow":"\u21A9","hookrightarrow":"\u21AA","hopf":"\uD835\uDD59","Hopf":"\u210D","horbar":"\u2015","HorizontalLine":"\u2500","hscr":"\uD835\uDCBD","Hscr":"\u210B","hslash":"\u210F","Hstrok":"\u0126","hstrok":"\u0127","HumpDownHump":"\u224E","HumpEqual":"\u224F","hybull":"\u2043","hyphen":"\u2010","Iacute":"\u00CD","iacute":"\u00ED","ic":"\u2063","Icirc":"\u00CE","icirc":"\u00EE","Icy":"\u0418","icy":"\u0438","Idot":"\u0130","IEcy":"\u0415","iecy":"\u0435","iexcl":"\u00A1","iff":"\u21D4","ifr":"\uD835\uDD26","Ifr":"\u2111","Igrave":"\u00CC","igrave":"\u00EC","ii":"\u2148","iiiint":"\u2A0C","iiint":"\u222D","iinfin":"\u29DC","iiota":"\u2129","IJlig":"\u0132","ijlig":"\u0133","Imacr":"\u012A","imacr":"\u012B","image":"\u2111","ImaginaryI":"\u2148","imagline":"\u2110","imagpart":"\u2111","imath":"\u0131","Im":"\u2111","imof":"\u22B7","imped":"\u01B5","Implies":"\u21D2","incare":"\u2105","in":"\u2208","infin":"\u221E","infintie":"\u29DD","inodot":"\u0131","intcal":"\u22BA","int":"\u222B","Int":"\u222C","integers":"\u2124","Integral":"\u222B","intercal":"\u22BA","Intersection":"\u22C2","intlarhk":"\u2A17","intprod":"\u2A3C","InvisibleComma":"\u2063","InvisibleTimes":"\u2062","IOcy":"\u0401","iocy":"\u0451","Iogon":"\u012E","iogon":"\u012F","Iopf":"\uD835\uDD40","iopf":"\uD835\uDD5A","Iota":"\u0399","iota":"\u03B9","iprod":"\u2A3C","iquest":"\u00BF","iscr":"\uD835\uDCBE","Iscr":"\u2110","isin":"\u2208","isindot":"\u22F5","isinE":"\u22F9","isins":"\u22F4","isinsv":"\u22F3","isinv":"\u2208","it":"\u2062","Itilde":"\u0128","itilde":"\u0129","Iukcy":"\u0406","iukcy":"\u0456","Iuml":"\u00CF","iuml":"\u00EF","Jcirc":"\u0134","jcirc":"\u0135","Jcy":"\u0419","jcy":"\u0439","Jfr":"\uD835\uDD0D","jfr":"\uD835\uDD27","jmath":"\u0237","Jopf":"\uD835\uDD41","jopf":"\uD835\uDD5B","Jscr":"\uD835\uDCA5","jscr":"\uD835\uDCBF","Jsercy":"\u0408","jsercy":"\u0458","Jukcy":"\u0404","jukcy":"\u0454","Kappa":"\u039A","kappa":"\u03BA","kappav":"\u03F0","Kcedil":"\u0136","kcedil":"\u0137","Kcy":"\u041A","kcy":"\u043A","Kfr":"\uD835\uDD0E","kfr":"\uD835\uDD28","kgreen":"\u0138","KHcy":"\u0425","khcy":"\u0445","KJcy":"\u040C","kjcy":"\u045C","Kopf":"\uD835\uDD42","kopf":"\uD835\uDD5C","Kscr":"\uD835\uDCA6","kscr":"\uD835\uDCC0","lAarr":"\u21DA","Lacute":"\u0139","lacute":"\u013A","laemptyv":"\u29B4","lagran":"\u2112","Lambda":"\u039B","lambda":"\u03BB","lang":"\u27E8","Lang":"\u27EA","langd":"\u2991","langle":"\u27E8","lap":"\u2A85","Laplacetrf":"\u2112","laquo":"\u00AB","larrb":"\u21E4","larrbfs":"\u291F","larr":"\u2190","Larr":"\u219E","lArr":"\u21D0","larrfs":"\u291D","larrhk":"\u21A9","larrlp":"\u21AB","larrpl":"\u2939","larrsim":"\u2973","larrtl":"\u21A2","latail":"\u2919","lAtail":"\u291B","lat":"\u2AAB","late":"\u2AAD","lates":"\u2AAD\uFE00","lbarr":"\u290C","lBarr":"\u290E","lbbrk":"\u2772","lbrace":"{","lbrack":"[","lbrke":"\u298B","lbrksld":"\u298F","lbrkslu":"\u298D","Lcaron":"\u013D","lcaron":"\u013E","Lcedil":"\u013B","lcedil":"\u013C","lceil":"\u2308","lcub":"{","Lcy":"\u041B","lcy":"\u043B","ldca":"\u2936","ldquo":"\u201C","ldquor":"\u201E","ldrdhar":"\u2967","ldrushar":"\u294B","ldsh":"\u21B2","le":"\u2264","lE":"\u2266","LeftAngleBracket":"\u27E8","LeftArrowBar":"\u21E4","leftarrow":"\u2190","LeftArrow":"\u2190","Leftarrow":"\u21D0","LeftArrowRightArrow":"\u21C6","leftarrowtail":"\u21A2","LeftCeiling":"\u2308","LeftDoubleBracket":"\u27E6","LeftDownTeeVector":"\u2961","LeftDownVectorBar":"\u2959","LeftDownVector":"\u21C3","LeftFloor":"\u230A","leftharpoondown":"\u21BD","leftharpoonup":"\u21BC","leftleftarrows":"\u21C7","leftrightarrow":"\u2194","LeftRightArrow":"\u2194","Leftrightarrow":"\u21D4","leftrightarrows":"\u21C6","leftrightharpoons":"\u21CB","leftrightsquigarrow":"\u21AD","LeftRightVector":"\u294E","LeftTeeArrow":"\u21A4","LeftTee":"\u22A3","LeftTeeVector":"\u295A","leftthreetimes":"\u22CB","LeftTriangleBar":"\u29CF","LeftTriangle":"\u22B2","LeftTriangleEqual":"\u22B4","LeftUpDownVector":"\u2951","LeftUpTeeVector":"\u2960","LeftUpVectorBar":"\u2958","LeftUpVector":"\u21BF","LeftVectorBar":"\u2952","LeftVector":"\u21BC","lEg":"\u2A8B","leg":"\u22DA","leq":"\u2264","leqq":"\u2266","leqslant":"\u2A7D","lescc":"\u2AA8","les":"\u2A7D","lesdot":"\u2A7F","lesdoto":"\u2A81","lesdotor":"\u2A83","lesg":"\u22DA\uFE00","lesges":"\u2A93","lessapprox":"\u2A85","lessdot":"\u22D6","lesseqgtr":"\u22DA","lesseqqgtr":"\u2A8B","LessEqualGreater":"\u22DA","LessFullEqual":"\u2266","LessGreater":"\u2276","lessgtr":"\u2276","LessLess":"\u2AA1","lesssim":"\u2272","LessSlantEqual":"\u2A7D","LessTilde":"\u2272","lfisht":"\u297C","lfloor":"\u230A","Lfr":"\uD835\uDD0F","lfr":"\uD835\uDD29","lg":"\u2276","lgE":"\u2A91","lHar":"\u2962","lhard":"\u21BD","lharu":"\u21BC","lharul":"\u296A","lhblk":"\u2584","LJcy":"\u0409","ljcy":"\u0459","llarr":"\u21C7","ll":"\u226A","Ll":"\u22D8","llcorner":"\u231E","Lleftarrow":"\u21DA","llhard":"\u296B","lltri":"\u25FA","Lmidot":"\u013F","lmidot":"\u0140","lmoustache":"\u23B0","lmoust":"\u23B0","lnap":"\u2A89","lnapprox":"\u2A89","lne":"\u2A87","lnE":"\u2268","lneq":"\u2A87","lneqq":"\u2268","lnsim":"\u22E6","loang":"\u27EC","loarr":"\u21FD","lobrk":"\u27E6","longleftarrow":"\u27F5","LongLeftArrow":"\u27F5","Longleftarrow":"\u27F8","longleftrightarrow":"\u27F7","LongLeftRightArrow":"\u27F7","Longleftrightarrow":"\u27FA","longmapsto":"\u27FC","longrightarrow":"\u27F6","LongRightArrow":"\u27F6","Longrightarrow":"\u27F9","looparrowleft":"\u21AB","looparrowright":"\u21AC","lopar":"\u2985","Lopf":"\uD835\uDD43","lopf":"\uD835\uDD5D","loplus":"\u2A2D","lotimes":"\u2A34","lowast":"\u2217","lowbar":"_","LowerLeftArrow":"\u2199","LowerRightArrow":"\u2198","loz":"\u25CA","lozenge":"\u25CA","lozf":"\u29EB","lpar":"(","lparlt":"\u2993","lrarr":"\u21C6","lrcorner":"\u231F","lrhar":"\u21CB","lrhard":"\u296D","lrm":"\u200E","lrtri":"\u22BF","lsaquo":"\u2039","lscr":"\uD835\uDCC1","Lscr":"\u2112","lsh":"\u21B0","Lsh":"\u21B0","lsim":"\u2272","lsime":"\u2A8D","lsimg":"\u2A8F","lsqb":"[","lsquo":"\u2018","lsquor":"\u201A","Lstrok":"\u0141","lstrok":"\u0142","ltcc":"\u2AA6","ltcir":"\u2A79","lt":"<","LT":"<","Lt":"\u226A","ltdot":"\u22D6","lthree":"\u22CB","ltimes":"\u22C9","ltlarr":"\u2976","ltquest":"\u2A7B","ltri":"\u25C3","ltrie":"\u22B4","ltrif":"\u25C2","ltrPar":"\u2996","lurdshar":"\u294A","luruhar":"\u2966","lvertneqq":"\u2268\uFE00","lvnE":"\u2268\uFE00","macr":"\u00AF","male":"\u2642","malt":"\u2720","maltese":"\u2720","Map":"\u2905","map":"\u21A6","mapsto":"\u21A6","mapstodown":"\u21A7","mapstoleft":"\u21A4","mapstoup":"\u21A5","marker":"\u25AE","mcomma":"\u2A29","Mcy":"\u041C","mcy":"\u043C","mdash":"\u2014","mDDot":"\u223A","measuredangle":"\u2221","MediumSpace":"\u205F","Mellintrf":"\u2133","Mfr":"\uD835\uDD10","mfr":"\uD835\uDD2A","mho":"\u2127","micro":"\u00B5","midast":"*","midcir":"\u2AF0","mid":"\u2223","middot":"\u00B7","minusb":"\u229F","minus":"\u2212","minusd":"\u2238","minusdu":"\u2A2A","MinusPlus":"\u2213","mlcp":"\u2ADB","mldr":"\u2026","mnplus":"\u2213","models":"\u22A7","Mopf":"\uD835\uDD44","mopf":"\uD835\uDD5E","mp":"\u2213","mscr":"\uD835\uDCC2","Mscr":"\u2133","mstpos":"\u223E","Mu":"\u039C","mu":"\u03BC","multimap":"\u22B8","mumap":"\u22B8","nabla":"\u2207","Nacute":"\u0143","nacute":"\u0144","nang":"\u2220\u20D2","nap":"\u2249","napE":"\u2A70\u0338","napid":"\u224B\u0338","napos":"\u0149","napprox":"\u2249","natural":"\u266E","naturals":"\u2115","natur":"\u266E","nbsp":"\u00A0","nbump":"\u224E\u0338","nbumpe":"\u224F\u0338","ncap":"\u2A43","Ncaron":"\u0147","ncaron":"\u0148","Ncedil":"\u0145","ncedil":"\u0146","ncong":"\u2247","ncongdot":"\u2A6D\u0338","ncup":"\u2A42","Ncy":"\u041D","ncy":"\u043D","ndash":"\u2013","nearhk":"\u2924","nearr":"\u2197","neArr":"\u21D7","nearrow":"\u2197","ne":"\u2260","nedot":"\u2250\u0338","NegativeMediumSpace":"\u200B","NegativeThickSpace":"\u200B","NegativeThinSpace":"\u200B","NegativeVeryThinSpace":"\u200B","nequiv":"\u2262","nesear":"\u2928","nesim":"\u2242\u0338","NestedGreaterGreater":"\u226B","NestedLessLess":"\u226A","NewLine":"\n","nexist":"\u2204","nexists":"\u2204","Nfr":"\uD835\uDD11","nfr":"\uD835\uDD2B","ngE":"\u2267\u0338","nge":"\u2271","ngeq":"\u2271","ngeqq":"\u2267\u0338","ngeqslant":"\u2A7E\u0338","nges":"\u2A7E\u0338","nGg":"\u22D9\u0338","ngsim":"\u2275","nGt":"\u226B\u20D2","ngt":"\u226F","ngtr":"\u226F","nGtv":"\u226B\u0338","nharr":"\u21AE","nhArr":"\u21CE","nhpar":"\u2AF2","ni":"\u220B","nis":"\u22FC","nisd":"\u22FA","niv":"\u220B","NJcy":"\u040A","njcy":"\u045A","nlarr":"\u219A","nlArr":"\u21CD","nldr":"\u2025","nlE":"\u2266\u0338","nle":"\u2270","nleftarrow":"\u219A","nLeftarrow":"\u21CD","nleftrightarrow":"\u21AE","nLeftrightarrow":"\u21CE","nleq":"\u2270","nleqq":"\u2266\u0338","nleqslant":"\u2A7D\u0338","nles":"\u2A7D\u0338","nless":"\u226E","nLl":"\u22D8\u0338","nlsim":"\u2274","nLt":"\u226A\u20D2","nlt":"\u226E","nltri":"\u22EA","nltrie":"\u22EC","nLtv":"\u226A\u0338","nmid":"\u2224","NoBreak":"\u2060","NonBreakingSpace":"\u00A0","nopf":"\uD835\uDD5F","Nopf":"\u2115","Not":"\u2AEC","not":"\u00AC","NotCongruent":"\u2262","NotCupCap":"\u226D","NotDoubleVerticalBar":"\u2226","NotElement":"\u2209","NotEqual":"\u2260","NotEqualTilde":"\u2242\u0338","NotExists":"\u2204","NotGreater":"\u226F","NotGreaterEqual":"\u2271","NotGreaterFullEqual":"\u2267\u0338","NotGreaterGreater":"\u226B\u0338","NotGreaterLess":"\u2279","NotGreaterSlantEqual":"\u2A7E\u0338","NotGreaterTilde":"\u2275","NotHumpDownHump":"\u224E\u0338","NotHumpEqual":"\u224F\u0338","notin":"\u2209","notindot":"\u22F5\u0338","notinE":"\u22F9\u0338","notinva":"\u2209","notinvb":"\u22F7","notinvc":"\u22F6","NotLeftTriangleBar":"\u29CF\u0338","NotLeftTriangle":"\u22EA","NotLeftTriangleEqual":"\u22EC","NotLess":"\u226E","NotLessEqual":"\u2270","NotLessGreater":"\u2278","NotLessLess":"\u226A\u0338","NotLessSlantEqual":"\u2A7D\u0338","NotLessTilde":"\u2274","NotNestedGreaterGreater":"\u2AA2\u0338","NotNestedLessLess":"\u2AA1\u0338","notni":"\u220C","notniva":"\u220C","notnivb":"\u22FE","notnivc":"\u22FD","NotPrecedes":"\u2280","NotPrecedesEqual":"\u2AAF\u0338","NotPrecedesSlantEqual":"\u22E0","NotReverseElement":"\u220C","NotRightTriangleBar":"\u29D0\u0338","NotRightTriangle":"\u22EB","NotRightTriangleEqual":"\u22ED","NotSquareSubset":"\u228F\u0338","NotSquareSubsetEqual":"\u22E2","NotSquareSuperset":"\u2290\u0338","NotSquareSupersetEqual":"\u22E3","NotSubset":"\u2282\u20D2","NotSubsetEqual":"\u2288","NotSucceeds":"\u2281","NotSucceedsEqual":"\u2AB0\u0338","NotSucceedsSlantEqual":"\u22E1","NotSucceedsTilde":"\u227F\u0338","NotSuperset":"\u2283\u20D2","NotSupersetEqual":"\u2289","NotTilde":"\u2241","NotTildeEqual":"\u2244","NotTildeFullEqual":"\u2247","NotTildeTilde":"\u2249","NotVerticalBar":"\u2224","nparallel":"\u2226","npar":"\u2226","nparsl":"\u2AFD\u20E5","npart":"\u2202\u0338","npolint":"\u2A14","npr":"\u2280","nprcue":"\u22E0","nprec":"\u2280","npreceq":"\u2AAF\u0338","npre":"\u2AAF\u0338","nrarrc":"\u2933\u0338","nrarr":"\u219B","nrArr":"\u21CF","nrarrw":"\u219D\u0338","nrightarrow":"\u219B","nRightarrow":"\u21CF","nrtri":"\u22EB","nrtrie":"\u22ED","nsc":"\u2281","nsccue":"\u22E1","nsce":"\u2AB0\u0338","Nscr":"\uD835\uDCA9","nscr":"\uD835\uDCC3","nshortmid":"\u2224","nshortparallel":"\u2226","nsim":"\u2241","nsime":"\u2244","nsimeq":"\u2244","nsmid":"\u2224","nspar":"\u2226","nsqsube":"\u22E2","nsqsupe":"\u22E3","nsub":"\u2284","nsubE":"\u2AC5\u0338","nsube":"\u2288","nsubset":"\u2282\u20D2","nsubseteq":"\u2288","nsubseteqq":"\u2AC5\u0338","nsucc":"\u2281","nsucceq":"\u2AB0\u0338","nsup":"\u2285","nsupE":"\u2AC6\u0338","nsupe":"\u2289","nsupset":"\u2283\u20D2","nsupseteq":"\u2289","nsupseteqq":"\u2AC6\u0338","ntgl":"\u2279","Ntilde":"\u00D1","ntilde":"\u00F1","ntlg":"\u2278","ntriangleleft":"\u22EA","ntrianglelefteq":"\u22EC","ntriangleright":"\u22EB","ntrianglerighteq":"\u22ED","Nu":"\u039D","nu":"\u03BD","num":"#","numero":"\u2116","numsp":"\u2007","nvap":"\u224D\u20D2","nvdash":"\u22AC","nvDash":"\u22AD","nVdash":"\u22AE","nVDash":"\u22AF","nvge":"\u2265\u20D2","nvgt":">\u20D2","nvHarr":"\u2904","nvinfin":"\u29DE","nvlArr":"\u2902","nvle":"\u2264\u20D2","nvlt":"<\u20D2","nvltrie":"\u22B4\u20D2","nvrArr":"\u2903","nvrtrie":"\u22B5\u20D2","nvsim":"\u223C\u20D2","nwarhk":"\u2923","nwarr":"\u2196","nwArr":"\u21D6","nwarrow":"\u2196","nwnear":"\u2927","Oacute":"\u00D3","oacute":"\u00F3","oast":"\u229B","Ocirc":"\u00D4","ocirc":"\u00F4","ocir":"\u229A","Ocy":"\u041E","ocy":"\u043E","odash":"\u229D","Odblac":"\u0150","odblac":"\u0151","odiv":"\u2A38","odot":"\u2299","odsold":"\u29BC","OElig":"\u0152","oelig":"\u0153","ofcir":"\u29BF","Ofr":"\uD835\uDD12","ofr":"\uD835\uDD2C","ogon":"\u02DB","Ograve":"\u00D2","ograve":"\u00F2","ogt":"\u29C1","ohbar":"\u29B5","ohm":"\u03A9","oint":"\u222E","olarr":"\u21BA","olcir":"\u29BE","olcross":"\u29BB","oline":"\u203E","olt":"\u29C0","Omacr":"\u014C","omacr":"\u014D","Omega":"\u03A9","omega":"\u03C9","Omicron":"\u039F","omicron":"\u03BF","omid":"\u29B6","ominus":"\u2296","Oopf":"\uD835\uDD46","oopf":"\uD835\uDD60","opar":"\u29B7","OpenCurlyDoubleQuote":"\u201C","OpenCurlyQuote":"\u2018","operp":"\u29B9","oplus":"\u2295","orarr":"\u21BB","Or":"\u2A54","or":"\u2228","ord":"\u2A5D","order":"\u2134","orderof":"\u2134","ordf":"\u00AA","ordm":"\u00BA","origof":"\u22B6","oror":"\u2A56","orslope":"\u2A57","orv":"\u2A5B","oS":"\u24C8","Oscr":"\uD835\uDCAA","oscr":"\u2134","Oslash":"\u00D8","oslash":"\u00F8","osol":"\u2298","Otilde":"\u00D5","otilde":"\u00F5","otimesas":"\u2A36","Otimes":"\u2A37","otimes":"\u2297","Ouml":"\u00D6","ouml":"\u00F6","ovbar":"\u233D","OverBar":"\u203E","OverBrace":"\u23DE","OverBracket":"\u23B4","OverParenthesis":"\u23DC","para":"\u00B6","parallel":"\u2225","par":"\u2225","parsim":"\u2AF3","parsl":"\u2AFD","part":"\u2202","PartialD":"\u2202","Pcy":"\u041F","pcy":"\u043F","percnt":"%","period":".","permil":"\u2030","perp":"\u22A5","pertenk":"\u2031","Pfr":"\uD835\uDD13","pfr":"\uD835\uDD2D","Phi":"\u03A6","phi":"\u03C6","phiv":"\u03D5","phmmat":"\u2133","phone":"\u260E","Pi":"\u03A0","pi":"\u03C0","pitchfork":"\u22D4","piv":"\u03D6","planck":"\u210F","planckh":"\u210E","plankv":"\u210F","plusacir":"\u2A23","plusb":"\u229E","pluscir":"\u2A22","plus":"+","plusdo":"\u2214","plusdu":"\u2A25","pluse":"\u2A72","PlusMinus":"\u00B1","plusmn":"\u00B1","plussim":"\u2A26","plustwo":"\u2A27","pm":"\u00B1","Poincareplane":"\u210C","pointint":"\u2A15","popf":"\uD835\uDD61","Popf":"\u2119","pound":"\u00A3","prap":"\u2AB7","Pr":"\u2ABB","pr":"\u227A","prcue":"\u227C","precapprox":"\u2AB7","prec":"\u227A","preccurlyeq":"\u227C","Precedes":"\u227A","PrecedesEqual":"\u2AAF","PrecedesSlantEqual":"\u227C","PrecedesTilde":"\u227E","preceq":"\u2AAF","precnapprox":"\u2AB9","precneqq":"\u2AB5","precnsim":"\u22E8","pre":"\u2AAF","prE":"\u2AB3","precsim":"\u227E","prime":"\u2032","Prime":"\u2033","primes":"\u2119","prnap":"\u2AB9","prnE":"\u2AB5","prnsim":"\u22E8","prod":"\u220F","Product":"\u220F","profalar":"\u232E","profline":"\u2312","profsurf":"\u2313","prop":"\u221D","Proportional":"\u221D","Proportion":"\u2237","propto":"\u221D","prsim":"\u227E","prurel":"\u22B0","Pscr":"\uD835\uDCAB","pscr":"\uD835\uDCC5","Psi":"\u03A8","psi":"\u03C8","puncsp":"\u2008","Qfr":"\uD835\uDD14","qfr":"\uD835\uDD2E","qint":"\u2A0C","qopf":"\uD835\uDD62","Qopf":"\u211A","qprime":"\u2057","Qscr":"\uD835\uDCAC","qscr":"\uD835\uDCC6","quaternions":"\u210D","quatint":"\u2A16","quest":"?","questeq":"\u225F","quot":"\"","QUOT":"\"","rAarr":"\u21DB","race":"\u223D\u0331","Racute":"\u0154","racute":"\u0155","radic":"\u221A","raemptyv":"\u29B3","rang":"\u27E9","Rang":"\u27EB","rangd":"\u2992","range":"\u29A5","rangle":"\u27E9","raquo":"\u00BB","rarrap":"\u2975","rarrb":"\u21E5","rarrbfs":"\u2920","rarrc":"\u2933","rarr":"\u2192","Rarr":"\u21A0","rArr":"\u21D2","rarrfs":"\u291E","rarrhk":"\u21AA","rarrlp":"\u21AC","rarrpl":"\u2945","rarrsim":"\u2974","Rarrtl":"\u2916","rarrtl":"\u21A3","rarrw":"\u219D","ratail":"\u291A","rAtail":"\u291C","ratio":"\u2236","rationals":"\u211A","rbarr":"\u290D","rBarr":"\u290F","RBarr":"\u2910","rbbrk":"\u2773","rbrace":"}","rbrack":"]","rbrke":"\u298C","rbrksld":"\u298E","rbrkslu":"\u2990","Rcaron":"\u0158","rcaron":"\u0159","Rcedil":"\u0156","rcedil":"\u0157","rceil":"\u2309","rcub":"}","Rcy":"\u0420","rcy":"\u0440","rdca":"\u2937","rdldhar":"\u2969","rdquo":"\u201D","rdquor":"\u201D","rdsh":"\u21B3","real":"\u211C","realine":"\u211B","realpart":"\u211C","reals":"\u211D","Re":"\u211C","rect":"\u25AD","reg":"\u00AE","REG":"\u00AE","ReverseElement":"\u220B","ReverseEquilibrium":"\u21CB","ReverseUpEquilibrium":"\u296F","rfisht":"\u297D","rfloor":"\u230B","rfr":"\uD835\uDD2F","Rfr":"\u211C","rHar":"\u2964","rhard":"\u21C1","rharu":"\u21C0","rharul":"\u296C","Rho":"\u03A1","rho":"\u03C1","rhov":"\u03F1","RightAngleBracket":"\u27E9","RightArrowBar":"\u21E5","rightarrow":"\u2192","RightArrow":"\u2192","Rightarrow":"\u21D2","RightArrowLeftArrow":"\u21C4","rightarrowtail":"\u21A3","RightCeiling":"\u2309","RightDoubleBracket":"\u27E7","RightDownTeeVector":"\u295D","RightDownVectorBar":"\u2955","RightDownVector":"\u21C2","RightFloor":"\u230B","rightharpoondown":"\u21C1","rightharpoonup":"\u21C0","rightleftarrows":"\u21C4","rightleftharpoons":"\u21CC","rightrightarrows":"\u21C9","rightsquigarrow":"\u219D","RightTeeArrow":"\u21A6","RightTee":"\u22A2","RightTeeVector":"\u295B","rightthreetimes":"\u22CC","RightTriangleBar":"\u29D0","RightTriangle":"\u22B3","RightTriangleEqual":"\u22B5","RightUpDownVector":"\u294F","RightUpTeeVector":"\u295C","RightUpVectorBar":"\u2954","RightUpVector":"\u21BE","RightVectorBar":"\u2953","RightVector":"\u21C0","ring":"\u02DA","risingdotseq":"\u2253","rlarr":"\u21C4","rlhar":"\u21CC","rlm":"\u200F","rmoustache":"\u23B1","rmoust":"\u23B1","rnmid":"\u2AEE","roang":"\u27ED","roarr":"\u21FE","robrk":"\u27E7","ropar":"\u2986","ropf":"\uD835\uDD63","Ropf":"\u211D","roplus":"\u2A2E","rotimes":"\u2A35","RoundImplies":"\u2970","rpar":")","rpargt":"\u2994","rppolint":"\u2A12","rrarr":"\u21C9","Rrightarrow":"\u21DB","rsaquo":"\u203A","rscr":"\uD835\uDCC7","Rscr":"\u211B","rsh":"\u21B1","Rsh":"\u21B1","rsqb":"]","rsquo":"\u2019","rsquor":"\u2019","rthree":"\u22CC","rtimes":"\u22CA","rtri":"\u25B9","rtrie":"\u22B5","rtrif":"\u25B8","rtriltri":"\u29CE","RuleDelayed":"\u29F4","ruluhar":"\u2968","rx":"\u211E","Sacute":"\u015A","sacute":"\u015B","sbquo":"\u201A","scap":"\u2AB8","Scaron":"\u0160","scaron":"\u0161","Sc":"\u2ABC","sc":"\u227B","sccue":"\u227D","sce":"\u2AB0","scE":"\u2AB4","Scedil":"\u015E","scedil":"\u015F","Scirc":"\u015C","scirc":"\u015D","scnap":"\u2ABA","scnE":"\u2AB6","scnsim":"\u22E9","scpolint":"\u2A13","scsim":"\u227F","Scy":"\u0421","scy":"\u0441","sdotb":"\u22A1","sdot":"\u22C5","sdote":"\u2A66","searhk":"\u2925","searr":"\u2198","seArr":"\u21D8","searrow":"\u2198","sect":"\u00A7","semi":";","seswar":"\u2929","setminus":"\u2216","setmn":"\u2216","sext":"\u2736","Sfr":"\uD835\uDD16","sfr":"\uD835\uDD30","sfrown":"\u2322","sharp":"\u266F","SHCHcy":"\u0429","shchcy":"\u0449","SHcy":"\u0428","shcy":"\u0448","ShortDownArrow":"\u2193","ShortLeftArrow":"\u2190","shortmid":"\u2223","shortparallel":"\u2225","ShortRightArrow":"\u2192","ShortUpArrow":"\u2191","shy":"\u00AD","Sigma":"\u03A3","sigma":"\u03C3","sigmaf":"\u03C2","sigmav":"\u03C2","sim":"\u223C","simdot":"\u2A6A","sime":"\u2243","simeq":"\u2243","simg":"\u2A9E","simgE":"\u2AA0","siml":"\u2A9D","simlE":"\u2A9F","simne":"\u2246","simplus":"\u2A24","simrarr":"\u2972","slarr":"\u2190","SmallCircle":"\u2218","smallsetminus":"\u2216","smashp":"\u2A33","smeparsl":"\u29E4","smid":"\u2223","smile":"\u2323","smt":"\u2AAA","smte":"\u2AAC","smtes":"\u2AAC\uFE00","SOFTcy":"\u042C","softcy":"\u044C","solbar":"\u233F","solb":"\u29C4","sol":"/","Sopf":"\uD835\uDD4A","sopf":"\uD835\uDD64","spades":"\u2660","spadesuit":"\u2660","spar":"\u2225","sqcap":"\u2293","sqcaps":"\u2293\uFE00","sqcup":"\u2294","sqcups":"\u2294\uFE00","Sqrt":"\u221A","sqsub":"\u228F","sqsube":"\u2291","sqsubset":"\u228F","sqsubseteq":"\u2291","sqsup":"\u2290","sqsupe":"\u2292","sqsupset":"\u2290","sqsupseteq":"\u2292","square":"\u25A1","Square":"\u25A1","SquareIntersection":"\u2293","SquareSubset":"\u228F","SquareSubsetEqual":"\u2291","SquareSuperset":"\u2290","SquareSupersetEqual":"\u2292","SquareUnion":"\u2294","squarf":"\u25AA","squ":"\u25A1","squf":"\u25AA","srarr":"\u2192","Sscr":"\uD835\uDCAE","sscr":"\uD835\uDCC8","ssetmn":"\u2216","ssmile":"\u2323","sstarf":"\u22C6","Star":"\u22C6","star":"\u2606","starf":"\u2605","straightepsilon":"\u03F5","straightphi":"\u03D5","strns":"\u00AF","sub":"\u2282","Sub":"\u22D0","subdot":"\u2ABD","subE":"\u2AC5","sube":"\u2286","subedot":"\u2AC3","submult":"\u2AC1","subnE":"\u2ACB","subne":"\u228A","subplus":"\u2ABF","subrarr":"\u2979","subset":"\u2282","Subset":"\u22D0","subseteq":"\u2286","subseteqq":"\u2AC5","SubsetEqual":"\u2286","subsetneq":"\u228A","subsetneqq":"\u2ACB","subsim":"\u2AC7","subsub":"\u2AD5","subsup":"\u2AD3","succapprox":"\u2AB8","succ":"\u227B","succcurlyeq":"\u227D","Succeeds":"\u227B","SucceedsEqual":"\u2AB0","SucceedsSlantEqual":"\u227D","SucceedsTilde":"\u227F","succeq":"\u2AB0","succnapprox":"\u2ABA","succneqq":"\u2AB6","succnsim":"\u22E9","succsim":"\u227F","SuchThat":"\u220B","sum":"\u2211","Sum":"\u2211","sung":"\u266A","sup1":"\u00B9","sup2":"\u00B2","sup3":"\u00B3","sup":"\u2283","Sup":"\u22D1","supdot":"\u2ABE","supdsub":"\u2AD8","supE":"\u2AC6","supe":"\u2287","supedot":"\u2AC4","Superset":"\u2283","SupersetEqual":"\u2287","suphsol":"\u27C9","suphsub":"\u2AD7","suplarr":"\u297B","supmult":"\u2AC2","supnE":"\u2ACC","supne":"\u228B","supplus":"\u2AC0","supset":"\u2283","Supset":"\u22D1","supseteq":"\u2287","supseteqq":"\u2AC6","supsetneq":"\u228B","supsetneqq":"\u2ACC","supsim":"\u2AC8","supsub":"\u2AD4","supsup":"\u2AD6","swarhk":"\u2926","swarr":"\u2199","swArr":"\u21D9","swarrow":"\u2199","swnwar":"\u292A","szlig":"\u00DF","Tab":"\t","target":"\u2316","Tau":"\u03A4","tau":"\u03C4","tbrk":"\u23B4","Tcaron":"\u0164","tcaron":"\u0165","Tcedil":"\u0162","tcedil":"\u0163","Tcy":"\u0422","tcy":"\u0442","tdot":"\u20DB","telrec":"\u2315","Tfr":"\uD835\uDD17","tfr":"\uD835\uDD31","there4":"\u2234","therefore":"\u2234","Therefore":"\u2234","Theta":"\u0398","theta":"\u03B8","thetasym":"\u03D1","thetav":"\u03D1","thickapprox":"\u2248","thicksim":"\u223C","ThickSpace":"\u205F\u200A","ThinSpace":"\u2009","thinsp":"\u2009","thkap":"\u2248","thksim":"\u223C","THORN":"\u00DE","thorn":"\u00FE","tilde":"\u02DC","Tilde":"\u223C","TildeEqual":"\u2243","TildeFullEqual":"\u2245","TildeTilde":"\u2248","timesbar":"\u2A31","timesb":"\u22A0","times":"\u00D7","timesd":"\u2A30","tint":"\u222D","toea":"\u2928","topbot":"\u2336","topcir":"\u2AF1","top":"\u22A4","Topf":"\uD835\uDD4B","topf":"\uD835\uDD65","topfork":"\u2ADA","tosa":"\u2929","tprime":"\u2034","trade":"\u2122","TRADE":"\u2122","triangle":"\u25B5","triangledown":"\u25BF","triangleleft":"\u25C3","trianglelefteq":"\u22B4","triangleq":"\u225C","triangleright":"\u25B9","trianglerighteq":"\u22B5","tridot":"\u25EC","trie":"\u225C","triminus":"\u2A3A","TripleDot":"\u20DB","triplus":"\u2A39","trisb":"\u29CD","tritime":"\u2A3B","trpezium":"\u23E2","Tscr":"\uD835\uDCAF","tscr":"\uD835\uDCC9","TScy":"\u0426","tscy":"\u0446","TSHcy":"\u040B","tshcy":"\u045B","Tstrok":"\u0166","tstrok":"\u0167","twixt":"\u226C","twoheadleftarrow":"\u219E","twoheadrightarrow":"\u21A0","Uacute":"\u00DA","uacute":"\u00FA","uarr":"\u2191","Uarr":"\u219F","uArr":"\u21D1","Uarrocir":"\u2949","Ubrcy":"\u040E","ubrcy":"\u045E","Ubreve":"\u016C","ubreve":"\u016D","Ucirc":"\u00DB","ucirc":"\u00FB","Ucy":"\u0423","ucy":"\u0443","udarr":"\u21C5","Udblac":"\u0170","udblac":"\u0171","udhar":"\u296E","ufisht":"\u297E","Ufr":"\uD835\uDD18","ufr":"\uD835\uDD32","Ugrave":"\u00D9","ugrave":"\u00F9","uHar":"\u2963","uharl":"\u21BF","uharr":"\u21BE","uhblk":"\u2580","ulcorn":"\u231C","ulcorner":"\u231C","ulcrop":"\u230F","ultri":"\u25F8","Umacr":"\u016A","umacr":"\u016B","uml":"\u00A8","UnderBar":"_","UnderBrace":"\u23DF","UnderBracket":"\u23B5","UnderParenthesis":"\u23DD","Union":"\u22C3","UnionPlus":"\u228E","Uogon":"\u0172","uogon":"\u0173","Uopf":"\uD835\uDD4C","uopf":"\uD835\uDD66","UpArrowBar":"\u2912","uparrow":"\u2191","UpArrow":"\u2191","Uparrow":"\u21D1","UpArrowDownArrow":"\u21C5","updownarrow":"\u2195","UpDownArrow":"\u2195","Updownarrow":"\u21D5","UpEquilibrium":"\u296E","upharpoonleft":"\u21BF","upharpoonright":"\u21BE","uplus":"\u228E","UpperLeftArrow":"\u2196","UpperRightArrow":"\u2197","upsi":"\u03C5","Upsi":"\u03D2","upsih":"\u03D2","Upsilon":"\u03A5","upsilon":"\u03C5","UpTeeArrow":"\u21A5","UpTee":"\u22A5","upuparrows":"\u21C8","urcorn":"\u231D","urcorner":"\u231D","urcrop":"\u230E","Uring":"\u016E","uring":"\u016F","urtri":"\u25F9","Uscr":"\uD835\uDCB0","uscr":"\uD835\uDCCA","utdot":"\u22F0","Utilde":"\u0168","utilde":"\u0169","utri":"\u25B5","utrif":"\u25B4","uuarr":"\u21C8","Uuml":"\u00DC","uuml":"\u00FC","uwangle":"\u29A7","vangrt":"\u299C","varepsilon":"\u03F5","varkappa":"\u03F0","varnothing":"\u2205","varphi":"\u03D5","varpi":"\u03D6","varpropto":"\u221D","varr":"\u2195","vArr":"\u21D5","varrho":"\u03F1","varsigma":"\u03C2","varsubsetneq":"\u228A\uFE00","varsubsetneqq":"\u2ACB\uFE00","varsupsetneq":"\u228B\uFE00","varsupsetneqq":"\u2ACC\uFE00","vartheta":"\u03D1","vartriangleleft":"\u22B2","vartriangleright":"\u22B3","vBar":"\u2AE8","Vbar":"\u2AEB","vBarv":"\u2AE9","Vcy":"\u0412","vcy":"\u0432","vdash":"\u22A2","vDash":"\u22A8","Vdash":"\u22A9","VDash":"\u22AB","Vdashl":"\u2AE6","veebar":"\u22BB","vee":"\u2228","Vee":"\u22C1","veeeq":"\u225A","vellip":"\u22EE","verbar":"|","Verbar":"\u2016","vert":"|","Vert":"\u2016","VerticalBar":"\u2223","VerticalLine":"|","VerticalSeparator":"\u2758","VerticalTilde":"\u2240","VeryThinSpace":"\u200A","Vfr":"\uD835\uDD19","vfr":"\uD835\uDD33","vltri":"\u22B2","vnsub":"\u2282\u20D2","vnsup":"\u2283\u20D2","Vopf":"\uD835\uDD4D","vopf":"\uD835\uDD67","vprop":"\u221D","vrtri":"\u22B3","Vscr":"\uD835\uDCB1","vscr":"\uD835\uDCCB","vsubnE":"\u2ACB\uFE00","vsubne":"\u228A\uFE00","vsupnE":"\u2ACC\uFE00","vsupne":"\u228B\uFE00","Vvdash":"\u22AA","vzigzag":"\u299A","Wcirc":"\u0174","wcirc":"\u0175","wedbar":"\u2A5F","wedge":"\u2227","Wedge":"\u22C0","wedgeq":"\u2259","weierp":"\u2118","Wfr":"\uD835\uDD1A","wfr":"\uD835\uDD34","Wopf":"\uD835\uDD4E","wopf":"\uD835\uDD68","wp":"\u2118","wr":"\u2240","wreath":"\u2240","Wscr":"\uD835\uDCB2","wscr":"\uD835\uDCCC","xcap":"\u22C2","xcirc":"\u25EF","xcup":"\u22C3","xdtri":"\u25BD","Xfr":"\uD835\uDD1B","xfr":"\uD835\uDD35","xharr":"\u27F7","xhArr":"\u27FA","Xi":"\u039E","xi":"\u03BE","xlarr":"\u27F5","xlArr":"\u27F8","xmap":"\u27FC","xnis":"\u22FB","xodot":"\u2A00","Xopf":"\uD835\uDD4F","xopf":"\uD835\uDD69","xoplus":"\u2A01","xotime":"\u2A02","xrarr":"\u27F6","xrArr":"\u27F9","Xscr":"\uD835\uDCB3","xscr":"\uD835\uDCCD","xsqcup":"\u2A06","xuplus":"\u2A04","xutri":"\u25B3","xvee":"\u22C1","xwedge":"\u22C0","Yacute":"\u00DD","yacute":"\u00FD","YAcy":"\u042F","yacy":"\u044F","Ycirc":"\u0176","ycirc":"\u0177","Ycy":"\u042B","ycy":"\u044B","yen":"\u00A5","Yfr":"\uD835\uDD1C","yfr":"\uD835\uDD36","YIcy":"\u0407","yicy":"\u0457","Yopf":"\uD835\uDD50","yopf":"\uD835\uDD6A","Yscr":"\uD835\uDCB4","yscr":"\uD835\uDCCE","YUcy":"\u042E","yucy":"\u044E","yuml":"\u00FF","Yuml":"\u0178","Zacute":"\u0179","zacute":"\u017A","Zcaron":"\u017D","zcaron":"\u017E","Zcy":"\u0417","zcy":"\u0437","Zdot":"\u017B","zdot":"\u017C","zeetrf":"\u2128","ZeroWidthSpace":"\u200B","Zeta":"\u0396","zeta":"\u03B6","zfr":"\uD835\uDD37","Zfr":"\u2128","ZHcy":"\u0416","zhcy":"\u0436","zigrarr":"\u21DD","zopf":"\uD835\uDD6B","Zopf":"\u2124","Zscr":"\uD835\uDCB5","zscr":"\uD835\uDCCF","zwj":"\u200D","zwnj":"\u200C"}
  12573. },{}],19:[function(require,module,exports){
  12574. "use strict";
  12575. Object.defineProperty(exports, "__esModule", {
  12576. value: true
  12577. });
  12578. exports.GraphQLError = GraphQLError;
  12579. var _printError = require("./printError");
  12580. var _location = require("../language/location");
  12581. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12582. function GraphQLError( // eslint-disable-line no-redeclare
  12583. message, nodes, source, positions, path, originalError, extensions) {
  12584. // Compute list of blame nodes.
  12585. var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
  12586. var _source = source;
  12587. if (!_source && _nodes) {
  12588. var node = _nodes[0];
  12589. _source = node && node.loc && node.loc.source;
  12590. }
  12591. var _positions = positions;
  12592. if (!_positions && _nodes) {
  12593. _positions = _nodes.reduce(function (list, node) {
  12594. if (node.loc) {
  12595. list.push(node.loc.start);
  12596. }
  12597. return list;
  12598. }, []);
  12599. }
  12600. if (_positions && _positions.length === 0) {
  12601. _positions = undefined;
  12602. }
  12603. var _locations;
  12604. if (positions && source) {
  12605. _locations = positions.map(function (pos) {
  12606. return (0, _location.getLocation)(source, pos);
  12607. });
  12608. } else if (_nodes) {
  12609. _locations = _nodes.reduce(function (list, node) {
  12610. if (node.loc) {
  12611. list.push((0, _location.getLocation)(node.loc.source, node.loc.start));
  12612. }
  12613. return list;
  12614. }, []);
  12615. }
  12616. var _extensions = extensions;
  12617. if (_extensions == null && originalError != null) {
  12618. var originalExtensions = originalError.extensions;
  12619. if (originalExtensions != null && _typeof(originalExtensions) === 'object') {
  12620. _extensions = originalExtensions;
  12621. }
  12622. }
  12623. Object.defineProperties(this, {
  12624. message: {
  12625. value: message,
  12626. // By being enumerable, JSON.stringify will include `message` in the
  12627. // resulting output. This ensures that the simplest possible GraphQL
  12628. // service adheres to the spec.
  12629. enumerable: true,
  12630. writable: true
  12631. },
  12632. locations: {
  12633. // Coercing falsey values to undefined ensures they will not be included
  12634. // in JSON.stringify() when not provided.
  12635. value: _locations || undefined,
  12636. // By being enumerable, JSON.stringify will include `locations` in the
  12637. // resulting output. This ensures that the simplest possible GraphQL
  12638. // service adheres to the spec.
  12639. enumerable: Boolean(_locations)
  12640. },
  12641. path: {
  12642. // Coercing falsey values to undefined ensures they will not be included
  12643. // in JSON.stringify() when not provided.
  12644. value: path || undefined,
  12645. // By being enumerable, JSON.stringify will include `path` in the
  12646. // resulting output. This ensures that the simplest possible GraphQL
  12647. // service adheres to the spec.
  12648. enumerable: Boolean(path)
  12649. },
  12650. nodes: {
  12651. value: _nodes || undefined
  12652. },
  12653. source: {
  12654. value: _source || undefined
  12655. },
  12656. positions: {
  12657. value: _positions || undefined
  12658. },
  12659. originalError: {
  12660. value: originalError
  12661. },
  12662. extensions: {
  12663. // Coercing falsey values to undefined ensures they will not be included
  12664. // in JSON.stringify() when not provided.
  12665. value: _extensions || undefined,
  12666. // By being enumerable, JSON.stringify will include `path` in the
  12667. // resulting output. This ensures that the simplest possible GraphQL
  12668. // service adheres to the spec.
  12669. enumerable: Boolean(_extensions)
  12670. }
  12671. }); // Include (non-enumerable) stack trace.
  12672. if (originalError && originalError.stack) {
  12673. Object.defineProperty(this, 'stack', {
  12674. value: originalError.stack,
  12675. writable: true,
  12676. configurable: true
  12677. });
  12678. } else if (Error.captureStackTrace) {
  12679. Error.captureStackTrace(this, GraphQLError);
  12680. } else {
  12681. Object.defineProperty(this, 'stack', {
  12682. value: Error().stack,
  12683. writable: true,
  12684. configurable: true
  12685. });
  12686. }
  12687. }
  12688. GraphQLError.prototype = Object.create(Error.prototype, {
  12689. constructor: {
  12690. value: GraphQLError
  12691. },
  12692. name: {
  12693. value: 'GraphQLError'
  12694. },
  12695. toString: {
  12696. value: function toString() {
  12697. return (0, _printError.printError)(this);
  12698. }
  12699. }
  12700. });
  12701. },{"../language/location":53,"./printError":23}],20:[function(require,module,exports){
  12702. "use strict";
  12703. Object.defineProperty(exports, "__esModule", {
  12704. value: true
  12705. });
  12706. exports.formatError = formatError;
  12707. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  12708. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12709. /**
  12710. * Copyright (c) Facebook, Inc. and its affiliates.
  12711. *
  12712. * This source code is licensed under the MIT license found in the
  12713. * LICENSE file in the root directory of this source tree.
  12714. *
  12715. *
  12716. */
  12717. /**
  12718. * Given a GraphQLError, format it according to the rules described by the
  12719. * Response Format, Errors section of the GraphQL Specification.
  12720. */
  12721. function formatError(error) {
  12722. !error ? (0, _invariant.default)(0, 'Received null or undefined error.') : void 0;
  12723. var message = error.message || 'An unknown error occurred.';
  12724. var locations = error.locations;
  12725. var path = error.path;
  12726. var extensions = error.extensions;
  12727. return extensions ? {
  12728. message: message,
  12729. locations: locations,
  12730. path: path,
  12731. extensions: extensions
  12732. } : {
  12733. message: message,
  12734. locations: locations,
  12735. path: path
  12736. };
  12737. }
  12738. },{"../jsutils/invariant":34}],21:[function(require,module,exports){
  12739. "use strict";
  12740. Object.defineProperty(exports, "__esModule", {
  12741. value: true
  12742. });
  12743. Object.defineProperty(exports, "GraphQLError", {
  12744. enumerable: true,
  12745. get: function get() {
  12746. return _GraphQLError.GraphQLError;
  12747. }
  12748. });
  12749. Object.defineProperty(exports, "syntaxError", {
  12750. enumerable: true,
  12751. get: function get() {
  12752. return _syntaxError.syntaxError;
  12753. }
  12754. });
  12755. Object.defineProperty(exports, "locatedError", {
  12756. enumerable: true,
  12757. get: function get() {
  12758. return _locatedError.locatedError;
  12759. }
  12760. });
  12761. Object.defineProperty(exports, "printError", {
  12762. enumerable: true,
  12763. get: function get() {
  12764. return _printError.printError;
  12765. }
  12766. });
  12767. Object.defineProperty(exports, "formatError", {
  12768. enumerable: true,
  12769. get: function get() {
  12770. return _formatError.formatError;
  12771. }
  12772. });
  12773. var _GraphQLError = require("./GraphQLError");
  12774. var _syntaxError = require("./syntaxError");
  12775. var _locatedError = require("./locatedError");
  12776. var _printError = require("./printError");
  12777. var _formatError = require("./formatError");
  12778. },{"./GraphQLError":19,"./formatError":20,"./locatedError":22,"./printError":23,"./syntaxError":24}],22:[function(require,module,exports){
  12779. "use strict";
  12780. Object.defineProperty(exports, "__esModule", {
  12781. value: true
  12782. });
  12783. exports.locatedError = locatedError;
  12784. var _GraphQLError = require("./GraphQLError");
  12785. /**
  12786. * Copyright (c) Facebook, Inc. and its affiliates.
  12787. *
  12788. * This source code is licensed under the MIT license found in the
  12789. * LICENSE file in the root directory of this source tree.
  12790. *
  12791. *
  12792. */
  12793. /**
  12794. * Given an arbitrary Error, presumably thrown while attempting to execute a
  12795. * GraphQL operation, produce a new GraphQLError aware of the location in the
  12796. * document responsible for the original Error.
  12797. */
  12798. function locatedError(originalError, nodes, path) {
  12799. // Note: this uses a brand-check to support GraphQL errors originating from
  12800. // other contexts.
  12801. if (originalError && Array.isArray(originalError.path)) {
  12802. return originalError;
  12803. }
  12804. return new _GraphQLError.GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
  12805. }
  12806. },{"./GraphQLError":19}],23:[function(require,module,exports){
  12807. "use strict";
  12808. Object.defineProperty(exports, "__esModule", {
  12809. value: true
  12810. });
  12811. exports.printError = printError;
  12812. var _location = require("../language/location");
  12813. /**
  12814. * Copyright (c) Facebook, Inc. and its affiliates.
  12815. *
  12816. * This source code is licensed under the MIT license found in the
  12817. * LICENSE file in the root directory of this source tree.
  12818. *
  12819. *
  12820. */
  12821. /**
  12822. * Prints a GraphQLError to a string, representing useful location information
  12823. * about the error's position in the source.
  12824. */
  12825. function printError(error) {
  12826. var printedLocations = [];
  12827. if (error.nodes) {
  12828. var _iteratorNormalCompletion = true;
  12829. var _didIteratorError = false;
  12830. var _iteratorError = undefined;
  12831. try {
  12832. for (var _iterator = error.nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  12833. var node = _step.value;
  12834. if (node.loc) {
  12835. printedLocations.push(highlightSourceAtLocation(node.loc.source, (0, _location.getLocation)(node.loc.source, node.loc.start)));
  12836. }
  12837. }
  12838. } catch (err) {
  12839. _didIteratorError = true;
  12840. _iteratorError = err;
  12841. } finally {
  12842. try {
  12843. if (!_iteratorNormalCompletion && _iterator.return != null) {
  12844. _iterator.return();
  12845. }
  12846. } finally {
  12847. if (_didIteratorError) {
  12848. throw _iteratorError;
  12849. }
  12850. }
  12851. }
  12852. } else if (error.source && error.locations) {
  12853. var source = error.source;
  12854. var _iteratorNormalCompletion2 = true;
  12855. var _didIteratorError2 = false;
  12856. var _iteratorError2 = undefined;
  12857. try {
  12858. for (var _iterator2 = error.locations[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  12859. var location = _step2.value;
  12860. printedLocations.push(highlightSourceAtLocation(source, location));
  12861. }
  12862. } catch (err) {
  12863. _didIteratorError2 = true;
  12864. _iteratorError2 = err;
  12865. } finally {
  12866. try {
  12867. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  12868. _iterator2.return();
  12869. }
  12870. } finally {
  12871. if (_didIteratorError2) {
  12872. throw _iteratorError2;
  12873. }
  12874. }
  12875. }
  12876. }
  12877. return printedLocations.length === 0 ? error.message : [error.message].concat(printedLocations).join('\n\n') + '\n';
  12878. }
  12879. /**
  12880. * Render a helpful description of the location of the error in the GraphQL
  12881. * Source document.
  12882. */
  12883. function highlightSourceAtLocation(source, location) {
  12884. var firstLineColumnOffset = source.locationOffset.column - 1;
  12885. var body = whitespace(firstLineColumnOffset) + source.body;
  12886. var lineIndex = location.line - 1;
  12887. var lineOffset = source.locationOffset.line - 1;
  12888. var lineNum = location.line + lineOffset;
  12889. var columnOffset = location.line === 1 ? firstLineColumnOffset : 0;
  12890. var columnNum = location.column + columnOffset;
  12891. var lines = body.split(/\r\n|[\n\r]/g);
  12892. return "".concat(source.name, " (").concat(lineNum, ":").concat(columnNum, ")\n") + printPrefixedLines([// Lines specified like this: ["prefix", "string"],
  12893. ["".concat(lineNum - 1, ": "), lines[lineIndex - 1]], ["".concat(lineNum, ": "), lines[lineIndex]], ['', whitespace(columnNum - 1) + '^'], ["".concat(lineNum + 1, ": "), lines[lineIndex + 1]]]);
  12894. }
  12895. function printPrefixedLines(lines) {
  12896. var existingLines = lines.filter(function (_ref) {
  12897. var _ = _ref[0],
  12898. line = _ref[1];
  12899. return line !== undefined;
  12900. });
  12901. var padLen = 0;
  12902. var _iteratorNormalCompletion3 = true;
  12903. var _didIteratorError3 = false;
  12904. var _iteratorError3 = undefined;
  12905. try {
  12906. for (var _iterator3 = existingLines[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  12907. var _ref4 = _step3.value;
  12908. var prefix = _ref4[0];
  12909. padLen = Math.max(padLen, prefix.length);
  12910. }
  12911. } catch (err) {
  12912. _didIteratorError3 = true;
  12913. _iteratorError3 = err;
  12914. } finally {
  12915. try {
  12916. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  12917. _iterator3.return();
  12918. }
  12919. } finally {
  12920. if (_didIteratorError3) {
  12921. throw _iteratorError3;
  12922. }
  12923. }
  12924. }
  12925. return existingLines.map(function (_ref3) {
  12926. var prefix = _ref3[0],
  12927. line = _ref3[1];
  12928. return lpad(padLen, prefix) + line;
  12929. }).join('\n');
  12930. }
  12931. function whitespace(len) {
  12932. return Array(len + 1).join(' ');
  12933. }
  12934. function lpad(len, str) {
  12935. return whitespace(len - str.length) + str;
  12936. }
  12937. },{"../language/location":53}],24:[function(require,module,exports){
  12938. "use strict";
  12939. Object.defineProperty(exports, "__esModule", {
  12940. value: true
  12941. });
  12942. exports.syntaxError = syntaxError;
  12943. var _GraphQLError = require("./GraphQLError");
  12944. /**
  12945. * Copyright (c) Facebook, Inc. and its affiliates.
  12946. *
  12947. * This source code is licensed under the MIT license found in the
  12948. * LICENSE file in the root directory of this source tree.
  12949. *
  12950. *
  12951. */
  12952. /**
  12953. * Produces a GraphQLError representing a syntax error, containing useful
  12954. * descriptive information about the syntax error's position in the source.
  12955. */
  12956. function syntaxError(source, position, description) {
  12957. return new _GraphQLError.GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
  12958. }
  12959. },{"./GraphQLError":19}],25:[function(require,module,exports){
  12960. "use strict";
  12961. Object.defineProperty(exports, "__esModule", {
  12962. value: true
  12963. });
  12964. exports.execute = execute;
  12965. exports.responsePathAsArray = responsePathAsArray;
  12966. exports.addPath = addPath;
  12967. exports.assertValidExecutionArguments = assertValidExecutionArguments;
  12968. exports.buildExecutionContext = buildExecutionContext;
  12969. exports.collectFields = collectFields;
  12970. exports.buildResolveInfo = buildResolveInfo;
  12971. exports.resolveFieldValueOrError = resolveFieldValueOrError;
  12972. exports.getFieldDef = getFieldDef;
  12973. exports.defaultFieldResolver = exports.defaultTypeResolver = void 0;
  12974. var _iterall = require("iterall");
  12975. var _GraphQLError = require("../error/GraphQLError");
  12976. var _locatedError = require("../error/locatedError");
  12977. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  12978. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  12979. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  12980. var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
  12981. var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
  12982. var _memoize = _interopRequireDefault(require("../jsutils/memoize3"));
  12983. var _promiseForObject = _interopRequireDefault(require("../jsutils/promiseForObject"));
  12984. var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce"));
  12985. var _getOperationRootType = require("../utilities/getOperationRootType");
  12986. var _typeFromAST = require("../utilities/typeFromAST");
  12987. var _kinds = require("../language/kinds");
  12988. var _values = require("./values");
  12989. var _definition = require("../type/definition");
  12990. var _introspection = require("../type/introspection");
  12991. var _directives = require("../type/directives");
  12992. var _validate = require("../type/validate");
  12993. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12994. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12995. function execute(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
  12996. /* eslint-enable no-redeclare */
  12997. // Extract arguments from object args if provided.
  12998. return arguments.length === 1 ? executeImpl(argsOrSchema.schema, argsOrSchema.document, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : executeImpl(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
  12999. }
  13000. function executeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
  13001. // If arguments are missing or incorrect, throw an error.
  13002. assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
  13003. // a "Response" with only errors is returned.
  13004. var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Return early errors if execution context failed.
  13005. if (Array.isArray(exeContext)) {
  13006. return {
  13007. errors: exeContext
  13008. };
  13009. } // Return a Promise that will eventually resolve to the data described by
  13010. // The "Response" section of the GraphQL specification.
  13011. //
  13012. // If errors are encountered while executing a GraphQL field, only that
  13013. // field and its descendants will be omitted, and sibling fields will still
  13014. // be executed. An execution which encounters errors will still result in a
  13015. // resolved Promise.
  13016. var data = executeOperation(exeContext, exeContext.operation, rootValue);
  13017. return buildResponse(exeContext, data);
  13018. }
  13019. /**
  13020. * Given a completed execution context and data, build the { errors, data }
  13021. * response defined by the "Response" section of the GraphQL specification.
  13022. */
  13023. function buildResponse(exeContext, data) {
  13024. if ((0, _isPromise.default)(data)) {
  13025. return data.then(function (resolved) {
  13026. return buildResponse(exeContext, resolved);
  13027. });
  13028. }
  13029. return exeContext.errors.length === 0 ? {
  13030. data: data
  13031. } : {
  13032. errors: exeContext.errors,
  13033. data: data
  13034. };
  13035. }
  13036. /**
  13037. * Given a ResponsePath (found in the `path` entry in the information provided
  13038. * as the last argument to a field resolver), return an Array of the path keys.
  13039. */
  13040. function responsePathAsArray(path) {
  13041. var flattened = [];
  13042. var curr = path;
  13043. while (curr) {
  13044. flattened.push(curr.key);
  13045. curr = curr.prev;
  13046. }
  13047. return flattened.reverse();
  13048. }
  13049. /**
  13050. * Given a ResponsePath and a key, return a new ResponsePath containing the
  13051. * new key.
  13052. */
  13053. function addPath(prev, key) {
  13054. return {
  13055. prev: prev,
  13056. key: key
  13057. };
  13058. }
  13059. /**
  13060. * Essential assertions before executing to provide developer feedback for
  13061. * improper use of the GraphQL library.
  13062. */
  13063. function assertValidExecutionArguments(schema, document, rawVariableValues) {
  13064. !document ? (0, _invariant.default)(0, 'Must provide document') : void 0; // If the schema used for execution is invalid, throw an error.
  13065. (0, _validate.assertValidSchema)(schema); // Variables, if provided, must be an object.
  13066. !(!rawVariableValues || _typeof(rawVariableValues) === 'object') ? (0, _invariant.default)(0, 'Variables must be provided as an Object where each property is a ' + 'variable value. Perhaps look to see if an unparsed JSON string ' + 'was provided.') : void 0;
  13067. }
  13068. /**
  13069. * Constructs a ExecutionContext object from the arguments passed to
  13070. * execute, which we will pass throughout the other execution methods.
  13071. *
  13072. * Throws a GraphQLError if a valid execution context cannot be created.
  13073. */
  13074. function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver, typeResolver) {
  13075. var errors = [];
  13076. var operation;
  13077. var hasMultipleAssumedOperations = false;
  13078. var fragments = Object.create(null);
  13079. for (var i = 0; i < document.definitions.length; i++) {
  13080. var definition = document.definitions[i];
  13081. switch (definition.kind) {
  13082. case _kinds.Kind.OPERATION_DEFINITION:
  13083. if (!operationName && operation) {
  13084. hasMultipleAssumedOperations = true;
  13085. } else if (!operationName || definition.name && definition.name.value === operationName) {
  13086. operation = definition;
  13087. }
  13088. break;
  13089. case _kinds.Kind.FRAGMENT_DEFINITION:
  13090. fragments[definition.name.value] = definition;
  13091. break;
  13092. }
  13093. }
  13094. if (!operation) {
  13095. if (operationName) {
  13096. errors.push(new _GraphQLError.GraphQLError("Unknown operation named \"".concat(operationName, "\".")));
  13097. } else {
  13098. errors.push(new _GraphQLError.GraphQLError('Must provide an operation.'));
  13099. }
  13100. } else if (hasMultipleAssumedOperations) {
  13101. errors.push(new _GraphQLError.GraphQLError('Must provide operation name if query contains multiple operations.'));
  13102. }
  13103. var variableValues;
  13104. if (operation) {
  13105. var coercedVariableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {});
  13106. if (coercedVariableValues.errors) {
  13107. errors.push.apply(errors, coercedVariableValues.errors);
  13108. } else {
  13109. variableValues = coercedVariableValues.coerced;
  13110. }
  13111. }
  13112. if (errors.length !== 0) {
  13113. return errors;
  13114. }
  13115. !operation ? (0, _invariant.default)(0, 'Has operation if no errors.') : void 0;
  13116. !variableValues ? (0, _invariant.default)(0, 'Has variables if no errors.') : void 0;
  13117. return {
  13118. schema: schema,
  13119. fragments: fragments,
  13120. rootValue: rootValue,
  13121. contextValue: contextValue,
  13122. operation: operation,
  13123. variableValues: variableValues,
  13124. fieldResolver: fieldResolver || defaultFieldResolver,
  13125. typeResolver: typeResolver || defaultTypeResolver,
  13126. errors: errors
  13127. };
  13128. }
  13129. /**
  13130. * Implements the "Evaluating operations" section of the spec.
  13131. */
  13132. function executeOperation(exeContext, operation, rootValue) {
  13133. var type = (0, _getOperationRootType.getOperationRootType)(exeContext.schema, operation);
  13134. var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
  13135. var path = undefined; // Errors from sub-fields of a NonNull type may propagate to the top level,
  13136. // at which point we still log the error and null the parent field, which
  13137. // in this case is the entire response.
  13138. //
  13139. // Similar to completeValueCatchingError.
  13140. try {
  13141. var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
  13142. if ((0, _isPromise.default)(result)) {
  13143. return result.then(undefined, function (error) {
  13144. exeContext.errors.push(error);
  13145. return Promise.resolve(null);
  13146. });
  13147. }
  13148. return result;
  13149. } catch (error) {
  13150. exeContext.errors.push(error);
  13151. return null;
  13152. }
  13153. }
  13154. /**
  13155. * Implements the "Evaluating selection sets" section of the spec
  13156. * for "write" mode.
  13157. */
  13158. function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
  13159. return (0, _promiseReduce.default)(Object.keys(fields), function (results, responseName) {
  13160. var fieldNodes = fields[responseName];
  13161. var fieldPath = addPath(path, responseName);
  13162. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  13163. if (result === undefined) {
  13164. return results;
  13165. }
  13166. if ((0, _isPromise.default)(result)) {
  13167. return result.then(function (resolvedResult) {
  13168. results[responseName] = resolvedResult;
  13169. return results;
  13170. });
  13171. }
  13172. results[responseName] = result;
  13173. return results;
  13174. }, Object.create(null));
  13175. }
  13176. /**
  13177. * Implements the "Evaluating selection sets" section of the spec
  13178. * for "read" mode.
  13179. */
  13180. function executeFields(exeContext, parentType, sourceValue, path, fields) {
  13181. var results = Object.create(null);
  13182. var containsPromise = false;
  13183. for (var i = 0, keys = Object.keys(fields); i < keys.length; ++i) {
  13184. var responseName = keys[i];
  13185. var fieldNodes = fields[responseName];
  13186. var fieldPath = addPath(path, responseName);
  13187. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  13188. if (result !== undefined) {
  13189. results[responseName] = result;
  13190. if (!containsPromise && (0, _isPromise.default)(result)) {
  13191. containsPromise = true;
  13192. }
  13193. }
  13194. } // If there are no promises, we can just return the object
  13195. if (!containsPromise) {
  13196. return results;
  13197. } // Otherwise, results is a map from field name to the result of resolving that
  13198. // field, which is possibly a promise. Return a promise that will return this
  13199. // same map, but with any promises replaced with the values they resolved to.
  13200. return (0, _promiseForObject.default)(results);
  13201. }
  13202. /**
  13203. * Given a selectionSet, adds all of the fields in that selection to
  13204. * the passed in map of fields, and returns it at the end.
  13205. *
  13206. * CollectFields requires the "runtime type" of an object. For a field which
  13207. * returns an Interface or Union type, the "runtime type" will be the actual
  13208. * Object type returned by that field.
  13209. */
  13210. function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
  13211. for (var i = 0; i < selectionSet.selections.length; i++) {
  13212. var selection = selectionSet.selections[i];
  13213. switch (selection.kind) {
  13214. case _kinds.Kind.FIELD:
  13215. {
  13216. if (!shouldIncludeNode(exeContext, selection)) {
  13217. continue;
  13218. }
  13219. var name = getFieldEntryKey(selection);
  13220. if (!fields[name]) {
  13221. fields[name] = [];
  13222. }
  13223. fields[name].push(selection);
  13224. break;
  13225. }
  13226. case _kinds.Kind.INLINE_FRAGMENT:
  13227. {
  13228. if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
  13229. continue;
  13230. }
  13231. collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
  13232. break;
  13233. }
  13234. case _kinds.Kind.FRAGMENT_SPREAD:
  13235. {
  13236. var fragName = selection.name.value;
  13237. if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
  13238. continue;
  13239. }
  13240. visitedFragmentNames[fragName] = true;
  13241. var fragment = exeContext.fragments[fragName];
  13242. if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
  13243. continue;
  13244. }
  13245. collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
  13246. break;
  13247. }
  13248. }
  13249. }
  13250. return fields;
  13251. }
  13252. /**
  13253. * Determines if a field should be included based on the @include and @skip
  13254. * directives, where @skip has higher precedence than @include.
  13255. */
  13256. function shouldIncludeNode(exeContext, node) {
  13257. var skip = (0, _values.getDirectiveValues)(_directives.GraphQLSkipDirective, node, exeContext.variableValues);
  13258. if (skip && skip.if === true) {
  13259. return false;
  13260. }
  13261. var include = (0, _values.getDirectiveValues)(_directives.GraphQLIncludeDirective, node, exeContext.variableValues);
  13262. if (include && include.if === false) {
  13263. return false;
  13264. }
  13265. return true;
  13266. }
  13267. /**
  13268. * Determines if a fragment is applicable to the given type.
  13269. */
  13270. function doesFragmentConditionMatch(exeContext, fragment, type) {
  13271. var typeConditionNode = fragment.typeCondition;
  13272. if (!typeConditionNode) {
  13273. return true;
  13274. }
  13275. var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
  13276. if (conditionalType === type) {
  13277. return true;
  13278. }
  13279. if ((0, _definition.isAbstractType)(conditionalType)) {
  13280. return exeContext.schema.isPossibleType(conditionalType, type);
  13281. }
  13282. return false;
  13283. }
  13284. /**
  13285. * Implements the logic to compute the key of a given field's entry
  13286. */
  13287. function getFieldEntryKey(node) {
  13288. return node.alias ? node.alias.value : node.name.value;
  13289. }
  13290. /**
  13291. * Resolves the field on the given source object. In particular, this
  13292. * figures out the value that the field returns by calling its resolve function,
  13293. * then calls completeValue to complete promises, serialize scalars, or execute
  13294. * the sub-selection-set for objects.
  13295. */
  13296. function resolveField(exeContext, parentType, source, fieldNodes, path) {
  13297. var fieldNode = fieldNodes[0];
  13298. var fieldName = fieldNode.name.value;
  13299. var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
  13300. if (!fieldDef) {
  13301. return;
  13302. }
  13303. var resolveFn = fieldDef.resolve || exeContext.fieldResolver;
  13304. var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
  13305. // or abrupt (error).
  13306. var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
  13307. return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
  13308. }
  13309. function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
  13310. // The resolve function's optional fourth argument is a collection of
  13311. // information about the current execution state.
  13312. return {
  13313. fieldName: fieldDef.name,
  13314. fieldNodes: fieldNodes,
  13315. returnType: fieldDef.type,
  13316. parentType: parentType,
  13317. path: path,
  13318. schema: exeContext.schema,
  13319. fragments: exeContext.fragments,
  13320. rootValue: exeContext.rootValue,
  13321. operation: exeContext.operation,
  13322. variableValues: exeContext.variableValues
  13323. };
  13324. } // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
  13325. // function. Returns the result of resolveFn or the abrupt-return Error object.
  13326. function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
  13327. try {
  13328. // Build a JS object of arguments from the field.arguments AST, using the
  13329. // variables scope to fulfill any variable references.
  13330. // TODO: find a way to memoize, in case this field is within a List type.
  13331. var args = (0, _values.getArgumentValues)(fieldDef, fieldNodes[0], exeContext.variableValues); // The resolve function's optional third argument is a context value that
  13332. // is provided to every resolve function within an execution. It is commonly
  13333. // used to represent an authenticated user, or request-specific caches.
  13334. var _contextValue = exeContext.contextValue;
  13335. var result = resolveFn(source, args, _contextValue, info);
  13336. return (0, _isPromise.default)(result) ? result.then(undefined, asErrorInstance) : result;
  13337. } catch (error) {
  13338. return asErrorInstance(error);
  13339. }
  13340. } // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
  13341. // consistent Error interface.
  13342. function asErrorInstance(error) {
  13343. if (error instanceof Error) {
  13344. return error;
  13345. }
  13346. return new Error('Unexpected error value: ' + (0, _inspect.default)(error));
  13347. } // This is a small wrapper around completeValue which detects and logs errors
  13348. // in the execution context.
  13349. function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
  13350. try {
  13351. var completed;
  13352. if ((0, _isPromise.default)(result)) {
  13353. completed = result.then(function (resolved) {
  13354. return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
  13355. });
  13356. } else {
  13357. completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
  13358. }
  13359. if ((0, _isPromise.default)(completed)) {
  13360. // Note: we don't rely on a `catch` method, but we do expect "thenable"
  13361. // to take a second callback for the error case.
  13362. return completed.then(undefined, function (error) {
  13363. return handleFieldError(error, fieldNodes, path, returnType, exeContext);
  13364. });
  13365. }
  13366. return completed;
  13367. } catch (error) {
  13368. return handleFieldError(error, fieldNodes, path, returnType, exeContext);
  13369. }
  13370. }
  13371. function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
  13372. var error = (0, _locatedError.locatedError)(asErrorInstance(rawError), fieldNodes, responsePathAsArray(path)); // If the field type is non-nullable, then it is resolved without any
  13373. // protection from errors, however it still properly locates the error.
  13374. if ((0, _definition.isNonNullType)(returnType)) {
  13375. throw error;
  13376. } // Otherwise, error protection is applied, logging the error and resolving
  13377. // a null value for this field if one is encountered.
  13378. exeContext.errors.push(error);
  13379. return null;
  13380. }
  13381. /**
  13382. * Implements the instructions for completeValue as defined in the
  13383. * "Field entries" section of the spec.
  13384. *
  13385. * If the field type is Non-Null, then this recursively completes the value
  13386. * for the inner type. It throws a field error if that completion returns null,
  13387. * as per the "Nullability" section of the spec.
  13388. *
  13389. * If the field type is a List, then this recursively completes the value
  13390. * for the inner type on each item in the list.
  13391. *
  13392. * If the field type is a Scalar or Enum, ensures the completed value is a legal
  13393. * value of the type by calling the `serialize` method of GraphQL type
  13394. * definition.
  13395. *
  13396. * If the field is an abstract type, determine the runtime type of the value
  13397. * and then complete based on that type
  13398. *
  13399. * Otherwise, the field type expects a sub-selection set, and will complete the
  13400. * value by evaluating all sub-selections.
  13401. */
  13402. function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
  13403. // If result is an Error, throw a located error.
  13404. if (result instanceof Error) {
  13405. throw result;
  13406. } // If field type is NonNull, complete for inner type, and throw field error
  13407. // if result is null.
  13408. if ((0, _definition.isNonNullType)(returnType)) {
  13409. var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
  13410. if (completed === null) {
  13411. throw new Error("Cannot return null for non-nullable field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
  13412. }
  13413. return completed;
  13414. } // If result value is null-ish (null, undefined, or NaN) then return null.
  13415. if ((0, _isNullish.default)(result)) {
  13416. return null;
  13417. } // If field type is List, complete each item in the list with the inner type
  13418. if ((0, _definition.isListType)(returnType)) {
  13419. return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
  13420. } // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
  13421. // returning null if serialization is not possible.
  13422. if ((0, _definition.isLeafType)(returnType)) {
  13423. return completeLeafValue(returnType, result);
  13424. } // If field type is an abstract type, Interface or Union, determine the
  13425. // runtime Object type and complete for that type.
  13426. if ((0, _definition.isAbstractType)(returnType)) {
  13427. return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
  13428. } // If field type is Object, execute and complete all sub-selections.
  13429. if ((0, _definition.isObjectType)(returnType)) {
  13430. return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
  13431. } // Not reachable. All possible output types have been considered.
  13432. /* istanbul ignore next */
  13433. throw new Error("Cannot complete value of unexpected output type: \"".concat((0, _inspect.default)(returnType), "\"."));
  13434. }
  13435. /**
  13436. * Complete a list value by completing each item in the list with the
  13437. * inner type
  13438. */
  13439. function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
  13440. !(0, _iterall.isCollection)(result) ? (0, _invariant.default)(0, "Expected Iterable, but did not find one for field ".concat(info.parentType.name, ".").concat(info.fieldName, ".")) : void 0; // This is specified as a simple map, however we're optimizing the path
  13441. // where the list contains no Promises by avoiding creating another Promise.
  13442. var itemType = returnType.ofType;
  13443. var containsPromise = false;
  13444. var completedResults = [];
  13445. (0, _iterall.forEach)(result, function (item, index) {
  13446. // No need to modify the info object containing the path,
  13447. // since from here on it is not ever accessed by resolver functions.
  13448. var fieldPath = addPath(path, index);
  13449. var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
  13450. if (!containsPromise && (0, _isPromise.default)(completedItem)) {
  13451. containsPromise = true;
  13452. }
  13453. completedResults.push(completedItem);
  13454. });
  13455. return containsPromise ? Promise.all(completedResults) : completedResults;
  13456. }
  13457. /**
  13458. * Complete a Scalar or Enum by serializing to a valid value, returning
  13459. * null if serialization is not possible.
  13460. */
  13461. function completeLeafValue(returnType, result) {
  13462. !returnType.serialize ? (0, _invariant.default)(0, 'Missing serialize method on type') : void 0;
  13463. var serializedResult = returnType.serialize(result);
  13464. if ((0, _isInvalid.default)(serializedResult)) {
  13465. throw new Error("Expected a value of type \"".concat((0, _inspect.default)(returnType), "\" but ") + "received: ".concat((0, _inspect.default)(result)));
  13466. }
  13467. return serializedResult;
  13468. }
  13469. /**
  13470. * Complete a value of an abstract type by determining the runtime object type
  13471. * of that value, then complete the value for that type.
  13472. */
  13473. function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
  13474. var resolveTypeFn = returnType.resolveType || exeContext.typeResolver;
  13475. var contextValue = exeContext.contextValue;
  13476. var runtimeType = resolveTypeFn(result, contextValue, info, returnType);
  13477. if ((0, _isPromise.default)(runtimeType)) {
  13478. return runtimeType.then(function (resolvedRuntimeType) {
  13479. return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  13480. });
  13481. }
  13482. return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  13483. }
  13484. function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
  13485. var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
  13486. if (!(0, _definition.isObjectType)(runtimeType)) {
  13487. throw new _GraphQLError.GraphQLError("Abstract type ".concat(returnType.name, " must resolve to an Object type at ") + "runtime for field ".concat(info.parentType.name, ".").concat(info.fieldName, " with ") + "value ".concat((0, _inspect.default)(result), ", received \"").concat((0, _inspect.default)(runtimeType), "\". ") + "Either the ".concat(returnType.name, " type should provide a \"resolveType\" ") + 'function or each possible type should provide an "isTypeOf" function.', fieldNodes);
  13488. }
  13489. if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
  13490. throw new _GraphQLError.GraphQLError("Runtime Object type \"".concat(runtimeType.name, "\" is not a possible type ") + "for \"".concat(returnType.name, "\"."), fieldNodes);
  13491. }
  13492. return runtimeType;
  13493. }
  13494. /**
  13495. * Complete an Object value by executing all sub-selections.
  13496. */
  13497. function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
  13498. // If there is an isTypeOf predicate function, call it with the
  13499. // current result. If isTypeOf returns false, then raise an error rather
  13500. // than continuing execution.
  13501. if (returnType.isTypeOf) {
  13502. var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
  13503. if ((0, _isPromise.default)(isTypeOf)) {
  13504. return isTypeOf.then(function (resolvedIsTypeOf) {
  13505. if (!resolvedIsTypeOf) {
  13506. throw invalidReturnTypeError(returnType, result, fieldNodes);
  13507. }
  13508. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
  13509. });
  13510. }
  13511. if (!isTypeOf) {
  13512. throw invalidReturnTypeError(returnType, result, fieldNodes);
  13513. }
  13514. }
  13515. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
  13516. }
  13517. function invalidReturnTypeError(returnType, result, fieldNodes) {
  13518. return new _GraphQLError.GraphQLError("Expected value of type \"".concat(returnType.name, "\" but got: ").concat((0, _inspect.default)(result), "."), fieldNodes);
  13519. }
  13520. function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result) {
  13521. // Collect sub-fields to execute to complete this value.
  13522. var subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
  13523. return executeFields(exeContext, returnType, result, path, subFieldNodes);
  13524. }
  13525. /**
  13526. * A memoized collection of relevant subfields with regard to the return
  13527. * type. Memoizing ensures the subfields are not repeatedly calculated, which
  13528. * saves overhead when resolving lists of values.
  13529. */
  13530. var collectSubfields = (0, _memoize.default)(_collectSubfields);
  13531. function _collectSubfields(exeContext, returnType, fieldNodes) {
  13532. var subFieldNodes = Object.create(null);
  13533. var visitedFragmentNames = Object.create(null);
  13534. for (var i = 0; i < fieldNodes.length; i++) {
  13535. var selectionSet = fieldNodes[i].selectionSet;
  13536. if (selectionSet) {
  13537. subFieldNodes = collectFields(exeContext, returnType, selectionSet, subFieldNodes, visitedFragmentNames);
  13538. }
  13539. }
  13540. return subFieldNodes;
  13541. }
  13542. /**
  13543. * If a resolveType function is not given, then a default resolve behavior is
  13544. * used which attempts two strategies:
  13545. *
  13546. * First, See if the provided value has a `__typename` field defined, if so, use
  13547. * that value as name of the resolved type.
  13548. *
  13549. * Otherwise, test each possible type for the abstract type by calling
  13550. * isTypeOf for the object being coerced, returning the first type that matches.
  13551. */
  13552. var defaultTypeResolver = function defaultTypeResolver(value, contextValue, info, abstractType) {
  13553. // First, look for `__typename`.
  13554. if (value !== null && _typeof(value) === 'object' && typeof value.__typename === 'string') {
  13555. return value.__typename;
  13556. } // Otherwise, test each possible type.
  13557. var possibleTypes = info.schema.getPossibleTypes(abstractType);
  13558. var promisedIsTypeOfResults = [];
  13559. for (var i = 0; i < possibleTypes.length; i++) {
  13560. var type = possibleTypes[i];
  13561. if (type.isTypeOf) {
  13562. var isTypeOfResult = type.isTypeOf(value, contextValue, info);
  13563. if ((0, _isPromise.default)(isTypeOfResult)) {
  13564. promisedIsTypeOfResults[i] = isTypeOfResult;
  13565. } else if (isTypeOfResult) {
  13566. return type;
  13567. }
  13568. }
  13569. }
  13570. if (promisedIsTypeOfResults.length) {
  13571. return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
  13572. for (var _i = 0; _i < isTypeOfResults.length; _i++) {
  13573. if (isTypeOfResults[_i]) {
  13574. return possibleTypes[_i];
  13575. }
  13576. }
  13577. });
  13578. }
  13579. };
  13580. /**
  13581. * If a resolve function is not given, then a default resolve behavior is used
  13582. * which takes the property of the source object of the same name as the field
  13583. * and returns it as the result, or if it's a function, returns the result
  13584. * of calling that function while passing along args and context value.
  13585. */
  13586. exports.defaultTypeResolver = defaultTypeResolver;
  13587. var defaultFieldResolver = function defaultFieldResolver(source, args, contextValue, info) {
  13588. // ensure source is a value for which property access is acceptable.
  13589. if (_typeof(source) === 'object' || typeof source === 'function') {
  13590. var property = source[info.fieldName];
  13591. if (typeof property === 'function') {
  13592. return source[info.fieldName](args, contextValue, info);
  13593. }
  13594. return property;
  13595. }
  13596. };
  13597. /**
  13598. * This method looks up the field on the given type definition.
  13599. * It has special casing for the two introspection fields, __schema
  13600. * and __typename. __typename is special because it can always be
  13601. * queried as a field, even in situations where no other fields
  13602. * are allowed, like on a Union. __schema could get automatically
  13603. * added to the query type, but that would require mutating type
  13604. * definitions, which would cause issues.
  13605. */
  13606. exports.defaultFieldResolver = defaultFieldResolver;
  13607. function getFieldDef(schema, parentType, fieldName) {
  13608. if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  13609. return _introspection.SchemaMetaFieldDef;
  13610. } else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  13611. return _introspection.TypeMetaFieldDef;
  13612. } else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
  13613. return _introspection.TypeNameMetaFieldDef;
  13614. }
  13615. return parentType.getFields()[fieldName];
  13616. }
  13617. },{"../error/GraphQLError":19,"../error/locatedError":22,"../jsutils/inspect":32,"../jsutils/invariant":34,"../jsutils/isInvalid":35,"../jsutils/isNullish":36,"../jsutils/isPromise":37,"../jsutils/memoize3":41,"../jsutils/promiseForObject":44,"../jsutils/promiseReduce":45,"../language/kinds":51,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/validate":74,"../utilities/getOperationRootType":86,"../utilities/typeFromAST":97,"./values":27,"iterall":137}],26:[function(require,module,exports){
  13618. "use strict";
  13619. Object.defineProperty(exports, "__esModule", {
  13620. value: true
  13621. });
  13622. Object.defineProperty(exports, "execute", {
  13623. enumerable: true,
  13624. get: function get() {
  13625. return _execute.execute;
  13626. }
  13627. });
  13628. Object.defineProperty(exports, "defaultFieldResolver", {
  13629. enumerable: true,
  13630. get: function get() {
  13631. return _execute.defaultFieldResolver;
  13632. }
  13633. });
  13634. Object.defineProperty(exports, "defaultTypeResolver", {
  13635. enumerable: true,
  13636. get: function get() {
  13637. return _execute.defaultTypeResolver;
  13638. }
  13639. });
  13640. Object.defineProperty(exports, "responsePathAsArray", {
  13641. enumerable: true,
  13642. get: function get() {
  13643. return _execute.responsePathAsArray;
  13644. }
  13645. });
  13646. Object.defineProperty(exports, "getDirectiveValues", {
  13647. enumerable: true,
  13648. get: function get() {
  13649. return _values.getDirectiveValues;
  13650. }
  13651. });
  13652. var _execute = require("./execute");
  13653. var _values = require("./values");
  13654. },{"./execute":25,"./values":27}],27:[function(require,module,exports){
  13655. "use strict";
  13656. Object.defineProperty(exports, "__esModule", {
  13657. value: true
  13658. });
  13659. exports.getVariableValues = getVariableValues;
  13660. exports.getArgumentValues = getArgumentValues;
  13661. exports.getDirectiveValues = getDirectiveValues;
  13662. var _find = _interopRequireDefault(require("../polyfills/find"));
  13663. var _GraphQLError = require("../error/GraphQLError");
  13664. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  13665. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  13666. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  13667. var _coerceValue = require("../utilities/coerceValue");
  13668. var _typeFromAST = require("../utilities/typeFromAST");
  13669. var _valueFromAST = require("../utilities/valueFromAST");
  13670. var _kinds = require("../language/kinds");
  13671. var _printer = require("../language/printer");
  13672. var _definition = require("../type/definition");
  13673. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13674. /**
  13675. * Copyright (c) Facebook, Inc. and its affiliates.
  13676. *
  13677. * This source code is licensed under the MIT license found in the
  13678. * LICENSE file in the root directory of this source tree.
  13679. *
  13680. *
  13681. */
  13682. /**
  13683. * Prepares an object map of variableValues of the correct type based on the
  13684. * provided variable definitions and arbitrary input. If the input cannot be
  13685. * parsed to match the variable definitions, a GraphQLError will be thrown.
  13686. *
  13687. * Note: The returned value is a plain Object with a prototype, since it is
  13688. * exposed to user code. Care should be taken to not pull values from the
  13689. * Object prototype.
  13690. */
  13691. function getVariableValues(schema, varDefNodes, inputs) {
  13692. var errors = [];
  13693. var coercedValues = {};
  13694. for (var i = 0; i < varDefNodes.length; i++) {
  13695. var varDefNode = varDefNodes[i];
  13696. var varName = varDefNode.variable.name.value;
  13697. var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
  13698. if (!(0, _definition.isInputType)(varType)) {
  13699. // Must use input types for variables. This should be caught during
  13700. // validation, however is checked again here for safety.
  13701. errors.push(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" expected value of type ") + "\"".concat((0, _printer.print)(varDefNode.type), "\" which cannot be used as an input type."), varDefNode.type));
  13702. } else {
  13703. var hasValue = hasOwnProperty(inputs, varName);
  13704. var value = hasValue ? inputs[varName] : undefined;
  13705. if (!hasValue && varDefNode.defaultValue) {
  13706. // If no value was provided to a variable with a default value,
  13707. // use the default value.
  13708. coercedValues[varName] = (0, _valueFromAST.valueFromAST)(varDefNode.defaultValue, varType);
  13709. } else if ((!hasValue || value === null) && (0, _definition.isNonNullType)(varType)) {
  13710. // If no value or a nullish value was provided to a variable with a
  13711. // non-null type (required), produce an error.
  13712. errors.push(new _GraphQLError.GraphQLError(hasValue ? "Variable \"$".concat(varName, "\" of non-null type ") + "\"".concat((0, _inspect.default)(varType), "\" must not be null.") : "Variable \"$".concat(varName, "\" of required type ") + "\"".concat((0, _inspect.default)(varType), "\" was not provided."), varDefNode));
  13713. } else if (hasValue) {
  13714. if (value === null) {
  13715. // If the explicit value `null` was provided, an entry in the coerced
  13716. // values must exist as the value `null`.
  13717. coercedValues[varName] = null;
  13718. } else {
  13719. // Otherwise, a non-null value was provided, coerce it to the expected
  13720. // type or report an error if coercion fails.
  13721. var coerced = (0, _coerceValue.coerceValue)(value, varType, varDefNode);
  13722. var coercionErrors = coerced.errors;
  13723. if (coercionErrors) {
  13724. var _iteratorNormalCompletion = true;
  13725. var _didIteratorError = false;
  13726. var _iteratorError = undefined;
  13727. try {
  13728. for (var _iterator = coercionErrors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13729. var error = _step.value;
  13730. error.message = "Variable \"$".concat(varName, "\" got invalid value ").concat((0, _inspect.default)(value), "; ") + error.message;
  13731. }
  13732. } catch (err) {
  13733. _didIteratorError = true;
  13734. _iteratorError = err;
  13735. } finally {
  13736. try {
  13737. if (!_iteratorNormalCompletion && _iterator.return != null) {
  13738. _iterator.return();
  13739. }
  13740. } finally {
  13741. if (_didIteratorError) {
  13742. throw _iteratorError;
  13743. }
  13744. }
  13745. }
  13746. errors.push.apply(errors, coercionErrors);
  13747. } else {
  13748. coercedValues[varName] = coerced.value;
  13749. }
  13750. }
  13751. }
  13752. }
  13753. }
  13754. return errors.length === 0 ? {
  13755. errors: undefined,
  13756. coerced: coercedValues
  13757. } : {
  13758. errors: errors,
  13759. coerced: undefined
  13760. };
  13761. }
  13762. /**
  13763. * Prepares an object map of argument values given a list of argument
  13764. * definitions and list of argument AST nodes.
  13765. *
  13766. * Note: The returned value is a plain Object with a prototype, since it is
  13767. * exposed to user code. Care should be taken to not pull values from the
  13768. * Object prototype.
  13769. */
  13770. function getArgumentValues(def, node, variableValues) {
  13771. var coercedValues = {};
  13772. var argDefs = def.args;
  13773. var argNodes = node.arguments;
  13774. if (!argDefs || !argNodes) {
  13775. return coercedValues;
  13776. }
  13777. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  13778. return arg.name.value;
  13779. });
  13780. for (var i = 0; i < argDefs.length; i++) {
  13781. var argDef = argDefs[i];
  13782. var name = argDef.name;
  13783. var argType = argDef.type;
  13784. var argumentNode = argNodeMap[name];
  13785. var hasValue = void 0;
  13786. var isNull = void 0;
  13787. if (argumentNode && argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  13788. var variableName = argumentNode.value.name.value;
  13789. hasValue = variableValues != null && hasOwnProperty(variableValues, variableName);
  13790. isNull = variableValues != null && variableValues[variableName] === null;
  13791. } else {
  13792. hasValue = argumentNode != null;
  13793. isNull = argumentNode != null && argumentNode.value.kind === _kinds.Kind.NULL;
  13794. }
  13795. if (!hasValue && argDef.defaultValue !== undefined) {
  13796. // If no argument was provided where the definition has a default value,
  13797. // use the default value.
  13798. coercedValues[name] = argDef.defaultValue;
  13799. } else if ((!hasValue || isNull) && (0, _definition.isNonNullType)(argType)) {
  13800. // If no argument or a null value was provided to an argument with a
  13801. // non-null type (required), produce a field error.
  13802. if (isNull) {
  13803. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat((0, _inspect.default)(argType), "\" ") + 'must not be null.', argumentNode.value);
  13804. } else if (argumentNode && argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  13805. var _variableName = argumentNode.value.name.value;
  13806. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + "was provided the variable \"$".concat(_variableName, "\" ") + 'which was not provided a runtime value.', argumentNode.value);
  13807. } else {
  13808. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + 'was not provided.', node);
  13809. }
  13810. } else if (hasValue) {
  13811. if (argumentNode.value.kind === _kinds.Kind.NULL) {
  13812. // If the explicit value `null` was provided, an entry in the coerced
  13813. // values must exist as the value `null`.
  13814. coercedValues[name] = null;
  13815. } else if (argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  13816. var _variableName2 = argumentNode.value.name.value;
  13817. !variableValues ? (0, _invariant.default)(0, 'Must exist for hasValue to be true.') : void 0; // Note: This does no further checking that this variable is correct.
  13818. // This assumes that this query has been validated and the variable
  13819. // usage here is of the correct type.
  13820. coercedValues[name] = variableValues[_variableName2];
  13821. } else {
  13822. var valueNode = argumentNode.value;
  13823. var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
  13824. if (coercedValue === undefined) {
  13825. // Note: ValuesOfCorrectType validation should catch this before
  13826. // execution. This is a runtime check to ensure execution does not
  13827. // continue with an invalid argument value.
  13828. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat((0, _printer.print)(valueNode), "."), argumentNode.value);
  13829. }
  13830. coercedValues[name] = coercedValue;
  13831. }
  13832. }
  13833. }
  13834. return coercedValues;
  13835. }
  13836. /**
  13837. * Prepares an object map of argument values given a directive definition
  13838. * and a AST node which may contain directives. Optionally also accepts a map
  13839. * of variable values.
  13840. *
  13841. * If the directive does not exist on the node, returns undefined.
  13842. *
  13843. * Note: The returned value is a plain Object with a prototype, since it is
  13844. * exposed to user code. Care should be taken to not pull values from the
  13845. * Object prototype.
  13846. */
  13847. function getDirectiveValues(directiveDef, node, variableValues) {
  13848. var directiveNode = node.directives && (0, _find.default)(node.directives, function (directive) {
  13849. return directive.name.value === directiveDef.name;
  13850. });
  13851. if (directiveNode) {
  13852. return getArgumentValues(directiveDef, directiveNode, variableValues);
  13853. }
  13854. }
  13855. function hasOwnProperty(obj, prop) {
  13856. return Object.prototype.hasOwnProperty.call(obj, prop);
  13857. }
  13858. },{"../error/GraphQLError":19,"../jsutils/inspect":32,"../jsutils/invariant":34,"../jsutils/keyMap":38,"../language/kinds":51,"../language/printer":56,"../polyfills/find":59,"../type/definition":68,"../utilities/coerceValue":80,"../utilities/typeFromAST":97,"../utilities/valueFromAST":98}],28:[function(require,module,exports){
  13859. "use strict";
  13860. Object.defineProperty(exports, "__esModule", {
  13861. value: true
  13862. });
  13863. exports.graphql = graphql;
  13864. exports.graphqlSync = graphqlSync;
  13865. var _isPromise = _interopRequireDefault(require("./jsutils/isPromise"));
  13866. var _validate = require("./type/validate");
  13867. var _parser = require("./language/parser");
  13868. var _validate2 = require("./validation/validate");
  13869. var _execute = require("./execution/execute");
  13870. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13871. /**
  13872. * Copyright (c) Facebook, Inc. and its affiliates.
  13873. *
  13874. * This source code is licensed under the MIT license found in the
  13875. * LICENSE file in the root directory of this source tree.
  13876. *
  13877. *
  13878. */
  13879. function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
  13880. var _arguments = arguments;
  13881. /* eslint-enable no-redeclare */
  13882. // Always return a Promise for a consistent API.
  13883. return new Promise(function (resolve) {
  13884. return resolve( // Extract arguments from object args if provided.
  13885. _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver));
  13886. });
  13887. }
  13888. /**
  13889. * The graphqlSync function also fulfills GraphQL operations by parsing,
  13890. * validating, and executing a GraphQL document along side a GraphQL schema.
  13891. * However, it guarantees to complete synchronously (or throw an error) assuming
  13892. * that all field resolvers are also synchronous.
  13893. */
  13894. function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
  13895. /* eslint-enable no-redeclare */
  13896. // Extract arguments from object args if provided.
  13897. var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Assert that the execution was synchronous.
  13898. if ((0, _isPromise.default)(result)) {
  13899. throw new Error('GraphQL execution failed to complete synchronously.');
  13900. }
  13901. return result;
  13902. }
  13903. function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
  13904. // Validate Schema
  13905. var schemaValidationErrors = (0, _validate.validateSchema)(schema);
  13906. if (schemaValidationErrors.length > 0) {
  13907. return {
  13908. errors: schemaValidationErrors
  13909. };
  13910. } // Parse
  13911. var document;
  13912. try {
  13913. document = (0, _parser.parse)(source);
  13914. } catch (syntaxError) {
  13915. return {
  13916. errors: [syntaxError]
  13917. };
  13918. } // Validate
  13919. var validationErrors = (0, _validate2.validate)(schema, document);
  13920. if (validationErrors.length > 0) {
  13921. return {
  13922. errors: validationErrors
  13923. };
  13924. } // Execute
  13925. return (0, _execute.execute)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
  13926. }
  13927. },{"./execution/execute":25,"./jsutils/isPromise":37,"./language/parser":54,"./type/validate":74,"./validation/validate":136}],29:[function(require,module,exports){
  13928. "use strict";
  13929. Object.defineProperty(exports, "__esModule", {
  13930. value: true
  13931. });
  13932. Object.defineProperty(exports, "graphql", {
  13933. enumerable: true,
  13934. get: function get() {
  13935. return _graphql.graphql;
  13936. }
  13937. });
  13938. Object.defineProperty(exports, "graphqlSync", {
  13939. enumerable: true,
  13940. get: function get() {
  13941. return _graphql.graphqlSync;
  13942. }
  13943. });
  13944. Object.defineProperty(exports, "GraphQLSchema", {
  13945. enumerable: true,
  13946. get: function get() {
  13947. return _type.GraphQLSchema;
  13948. }
  13949. });
  13950. Object.defineProperty(exports, "GraphQLDirective", {
  13951. enumerable: true,
  13952. get: function get() {
  13953. return _type.GraphQLDirective;
  13954. }
  13955. });
  13956. Object.defineProperty(exports, "GraphQLScalarType", {
  13957. enumerable: true,
  13958. get: function get() {
  13959. return _type.GraphQLScalarType;
  13960. }
  13961. });
  13962. Object.defineProperty(exports, "GraphQLObjectType", {
  13963. enumerable: true,
  13964. get: function get() {
  13965. return _type.GraphQLObjectType;
  13966. }
  13967. });
  13968. Object.defineProperty(exports, "GraphQLInterfaceType", {
  13969. enumerable: true,
  13970. get: function get() {
  13971. return _type.GraphQLInterfaceType;
  13972. }
  13973. });
  13974. Object.defineProperty(exports, "GraphQLUnionType", {
  13975. enumerable: true,
  13976. get: function get() {
  13977. return _type.GraphQLUnionType;
  13978. }
  13979. });
  13980. Object.defineProperty(exports, "GraphQLEnumType", {
  13981. enumerable: true,
  13982. get: function get() {
  13983. return _type.GraphQLEnumType;
  13984. }
  13985. });
  13986. Object.defineProperty(exports, "GraphQLInputObjectType", {
  13987. enumerable: true,
  13988. get: function get() {
  13989. return _type.GraphQLInputObjectType;
  13990. }
  13991. });
  13992. Object.defineProperty(exports, "GraphQLList", {
  13993. enumerable: true,
  13994. get: function get() {
  13995. return _type.GraphQLList;
  13996. }
  13997. });
  13998. Object.defineProperty(exports, "GraphQLNonNull", {
  13999. enumerable: true,
  14000. get: function get() {
  14001. return _type.GraphQLNonNull;
  14002. }
  14003. });
  14004. Object.defineProperty(exports, "specifiedScalarTypes", {
  14005. enumerable: true,
  14006. get: function get() {
  14007. return _type.specifiedScalarTypes;
  14008. }
  14009. });
  14010. Object.defineProperty(exports, "GraphQLInt", {
  14011. enumerable: true,
  14012. get: function get() {
  14013. return _type.GraphQLInt;
  14014. }
  14015. });
  14016. Object.defineProperty(exports, "GraphQLFloat", {
  14017. enumerable: true,
  14018. get: function get() {
  14019. return _type.GraphQLFloat;
  14020. }
  14021. });
  14022. Object.defineProperty(exports, "GraphQLString", {
  14023. enumerable: true,
  14024. get: function get() {
  14025. return _type.GraphQLString;
  14026. }
  14027. });
  14028. Object.defineProperty(exports, "GraphQLBoolean", {
  14029. enumerable: true,
  14030. get: function get() {
  14031. return _type.GraphQLBoolean;
  14032. }
  14033. });
  14034. Object.defineProperty(exports, "GraphQLID", {
  14035. enumerable: true,
  14036. get: function get() {
  14037. return _type.GraphQLID;
  14038. }
  14039. });
  14040. Object.defineProperty(exports, "specifiedDirectives", {
  14041. enumerable: true,
  14042. get: function get() {
  14043. return _type.specifiedDirectives;
  14044. }
  14045. });
  14046. Object.defineProperty(exports, "GraphQLIncludeDirective", {
  14047. enumerable: true,
  14048. get: function get() {
  14049. return _type.GraphQLIncludeDirective;
  14050. }
  14051. });
  14052. Object.defineProperty(exports, "GraphQLSkipDirective", {
  14053. enumerable: true,
  14054. get: function get() {
  14055. return _type.GraphQLSkipDirective;
  14056. }
  14057. });
  14058. Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
  14059. enumerable: true,
  14060. get: function get() {
  14061. return _type.GraphQLDeprecatedDirective;
  14062. }
  14063. });
  14064. Object.defineProperty(exports, "TypeKind", {
  14065. enumerable: true,
  14066. get: function get() {
  14067. return _type.TypeKind;
  14068. }
  14069. });
  14070. Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", {
  14071. enumerable: true,
  14072. get: function get() {
  14073. return _type.DEFAULT_DEPRECATION_REASON;
  14074. }
  14075. });
  14076. Object.defineProperty(exports, "introspectionTypes", {
  14077. enumerable: true,
  14078. get: function get() {
  14079. return _type.introspectionTypes;
  14080. }
  14081. });
  14082. Object.defineProperty(exports, "__Schema", {
  14083. enumerable: true,
  14084. get: function get() {
  14085. return _type.__Schema;
  14086. }
  14087. });
  14088. Object.defineProperty(exports, "__Directive", {
  14089. enumerable: true,
  14090. get: function get() {
  14091. return _type.__Directive;
  14092. }
  14093. });
  14094. Object.defineProperty(exports, "__DirectiveLocation", {
  14095. enumerable: true,
  14096. get: function get() {
  14097. return _type.__DirectiveLocation;
  14098. }
  14099. });
  14100. Object.defineProperty(exports, "__Type", {
  14101. enumerable: true,
  14102. get: function get() {
  14103. return _type.__Type;
  14104. }
  14105. });
  14106. Object.defineProperty(exports, "__Field", {
  14107. enumerable: true,
  14108. get: function get() {
  14109. return _type.__Field;
  14110. }
  14111. });
  14112. Object.defineProperty(exports, "__InputValue", {
  14113. enumerable: true,
  14114. get: function get() {
  14115. return _type.__InputValue;
  14116. }
  14117. });
  14118. Object.defineProperty(exports, "__EnumValue", {
  14119. enumerable: true,
  14120. get: function get() {
  14121. return _type.__EnumValue;
  14122. }
  14123. });
  14124. Object.defineProperty(exports, "__TypeKind", {
  14125. enumerable: true,
  14126. get: function get() {
  14127. return _type.__TypeKind;
  14128. }
  14129. });
  14130. Object.defineProperty(exports, "SchemaMetaFieldDef", {
  14131. enumerable: true,
  14132. get: function get() {
  14133. return _type.SchemaMetaFieldDef;
  14134. }
  14135. });
  14136. Object.defineProperty(exports, "TypeMetaFieldDef", {
  14137. enumerable: true,
  14138. get: function get() {
  14139. return _type.TypeMetaFieldDef;
  14140. }
  14141. });
  14142. Object.defineProperty(exports, "TypeNameMetaFieldDef", {
  14143. enumerable: true,
  14144. get: function get() {
  14145. return _type.TypeNameMetaFieldDef;
  14146. }
  14147. });
  14148. Object.defineProperty(exports, "isSchema", {
  14149. enumerable: true,
  14150. get: function get() {
  14151. return _type.isSchema;
  14152. }
  14153. });
  14154. Object.defineProperty(exports, "isDirective", {
  14155. enumerable: true,
  14156. get: function get() {
  14157. return _type.isDirective;
  14158. }
  14159. });
  14160. Object.defineProperty(exports, "isType", {
  14161. enumerable: true,
  14162. get: function get() {
  14163. return _type.isType;
  14164. }
  14165. });
  14166. Object.defineProperty(exports, "isScalarType", {
  14167. enumerable: true,
  14168. get: function get() {
  14169. return _type.isScalarType;
  14170. }
  14171. });
  14172. Object.defineProperty(exports, "isObjectType", {
  14173. enumerable: true,
  14174. get: function get() {
  14175. return _type.isObjectType;
  14176. }
  14177. });
  14178. Object.defineProperty(exports, "isInterfaceType", {
  14179. enumerable: true,
  14180. get: function get() {
  14181. return _type.isInterfaceType;
  14182. }
  14183. });
  14184. Object.defineProperty(exports, "isUnionType", {
  14185. enumerable: true,
  14186. get: function get() {
  14187. return _type.isUnionType;
  14188. }
  14189. });
  14190. Object.defineProperty(exports, "isEnumType", {
  14191. enumerable: true,
  14192. get: function get() {
  14193. return _type.isEnumType;
  14194. }
  14195. });
  14196. Object.defineProperty(exports, "isInputObjectType", {
  14197. enumerable: true,
  14198. get: function get() {
  14199. return _type.isInputObjectType;
  14200. }
  14201. });
  14202. Object.defineProperty(exports, "isListType", {
  14203. enumerable: true,
  14204. get: function get() {
  14205. return _type.isListType;
  14206. }
  14207. });
  14208. Object.defineProperty(exports, "isNonNullType", {
  14209. enumerable: true,
  14210. get: function get() {
  14211. return _type.isNonNullType;
  14212. }
  14213. });
  14214. Object.defineProperty(exports, "isInputType", {
  14215. enumerable: true,
  14216. get: function get() {
  14217. return _type.isInputType;
  14218. }
  14219. });
  14220. Object.defineProperty(exports, "isOutputType", {
  14221. enumerable: true,
  14222. get: function get() {
  14223. return _type.isOutputType;
  14224. }
  14225. });
  14226. Object.defineProperty(exports, "isLeafType", {
  14227. enumerable: true,
  14228. get: function get() {
  14229. return _type.isLeafType;
  14230. }
  14231. });
  14232. Object.defineProperty(exports, "isCompositeType", {
  14233. enumerable: true,
  14234. get: function get() {
  14235. return _type.isCompositeType;
  14236. }
  14237. });
  14238. Object.defineProperty(exports, "isAbstractType", {
  14239. enumerable: true,
  14240. get: function get() {
  14241. return _type.isAbstractType;
  14242. }
  14243. });
  14244. Object.defineProperty(exports, "isWrappingType", {
  14245. enumerable: true,
  14246. get: function get() {
  14247. return _type.isWrappingType;
  14248. }
  14249. });
  14250. Object.defineProperty(exports, "isNullableType", {
  14251. enumerable: true,
  14252. get: function get() {
  14253. return _type.isNullableType;
  14254. }
  14255. });
  14256. Object.defineProperty(exports, "isNamedType", {
  14257. enumerable: true,
  14258. get: function get() {
  14259. return _type.isNamedType;
  14260. }
  14261. });
  14262. Object.defineProperty(exports, "isRequiredArgument", {
  14263. enumerable: true,
  14264. get: function get() {
  14265. return _type.isRequiredArgument;
  14266. }
  14267. });
  14268. Object.defineProperty(exports, "isRequiredInputField", {
  14269. enumerable: true,
  14270. get: function get() {
  14271. return _type.isRequiredInputField;
  14272. }
  14273. });
  14274. Object.defineProperty(exports, "isSpecifiedScalarType", {
  14275. enumerable: true,
  14276. get: function get() {
  14277. return _type.isSpecifiedScalarType;
  14278. }
  14279. });
  14280. Object.defineProperty(exports, "isIntrospectionType", {
  14281. enumerable: true,
  14282. get: function get() {
  14283. return _type.isIntrospectionType;
  14284. }
  14285. });
  14286. Object.defineProperty(exports, "isSpecifiedDirective", {
  14287. enumerable: true,
  14288. get: function get() {
  14289. return _type.isSpecifiedDirective;
  14290. }
  14291. });
  14292. Object.defineProperty(exports, "assertSchema", {
  14293. enumerable: true,
  14294. get: function get() {
  14295. return _type.assertSchema;
  14296. }
  14297. });
  14298. Object.defineProperty(exports, "assertDirective", {
  14299. enumerable: true,
  14300. get: function get() {
  14301. return _type.assertDirective;
  14302. }
  14303. });
  14304. Object.defineProperty(exports, "assertType", {
  14305. enumerable: true,
  14306. get: function get() {
  14307. return _type.assertType;
  14308. }
  14309. });
  14310. Object.defineProperty(exports, "assertScalarType", {
  14311. enumerable: true,
  14312. get: function get() {
  14313. return _type.assertScalarType;
  14314. }
  14315. });
  14316. Object.defineProperty(exports, "assertObjectType", {
  14317. enumerable: true,
  14318. get: function get() {
  14319. return _type.assertObjectType;
  14320. }
  14321. });
  14322. Object.defineProperty(exports, "assertInterfaceType", {
  14323. enumerable: true,
  14324. get: function get() {
  14325. return _type.assertInterfaceType;
  14326. }
  14327. });
  14328. Object.defineProperty(exports, "assertUnionType", {
  14329. enumerable: true,
  14330. get: function get() {
  14331. return _type.assertUnionType;
  14332. }
  14333. });
  14334. Object.defineProperty(exports, "assertEnumType", {
  14335. enumerable: true,
  14336. get: function get() {
  14337. return _type.assertEnumType;
  14338. }
  14339. });
  14340. Object.defineProperty(exports, "assertInputObjectType", {
  14341. enumerable: true,
  14342. get: function get() {
  14343. return _type.assertInputObjectType;
  14344. }
  14345. });
  14346. Object.defineProperty(exports, "assertListType", {
  14347. enumerable: true,
  14348. get: function get() {
  14349. return _type.assertListType;
  14350. }
  14351. });
  14352. Object.defineProperty(exports, "assertNonNullType", {
  14353. enumerable: true,
  14354. get: function get() {
  14355. return _type.assertNonNullType;
  14356. }
  14357. });
  14358. Object.defineProperty(exports, "assertInputType", {
  14359. enumerable: true,
  14360. get: function get() {
  14361. return _type.assertInputType;
  14362. }
  14363. });
  14364. Object.defineProperty(exports, "assertOutputType", {
  14365. enumerable: true,
  14366. get: function get() {
  14367. return _type.assertOutputType;
  14368. }
  14369. });
  14370. Object.defineProperty(exports, "assertLeafType", {
  14371. enumerable: true,
  14372. get: function get() {
  14373. return _type.assertLeafType;
  14374. }
  14375. });
  14376. Object.defineProperty(exports, "assertCompositeType", {
  14377. enumerable: true,
  14378. get: function get() {
  14379. return _type.assertCompositeType;
  14380. }
  14381. });
  14382. Object.defineProperty(exports, "assertAbstractType", {
  14383. enumerable: true,
  14384. get: function get() {
  14385. return _type.assertAbstractType;
  14386. }
  14387. });
  14388. Object.defineProperty(exports, "assertWrappingType", {
  14389. enumerable: true,
  14390. get: function get() {
  14391. return _type.assertWrappingType;
  14392. }
  14393. });
  14394. Object.defineProperty(exports, "assertNullableType", {
  14395. enumerable: true,
  14396. get: function get() {
  14397. return _type.assertNullableType;
  14398. }
  14399. });
  14400. Object.defineProperty(exports, "assertNamedType", {
  14401. enumerable: true,
  14402. get: function get() {
  14403. return _type.assertNamedType;
  14404. }
  14405. });
  14406. Object.defineProperty(exports, "getNullableType", {
  14407. enumerable: true,
  14408. get: function get() {
  14409. return _type.getNullableType;
  14410. }
  14411. });
  14412. Object.defineProperty(exports, "getNamedType", {
  14413. enumerable: true,
  14414. get: function get() {
  14415. return _type.getNamedType;
  14416. }
  14417. });
  14418. Object.defineProperty(exports, "validateSchema", {
  14419. enumerable: true,
  14420. get: function get() {
  14421. return _type.validateSchema;
  14422. }
  14423. });
  14424. Object.defineProperty(exports, "assertValidSchema", {
  14425. enumerable: true,
  14426. get: function get() {
  14427. return _type.assertValidSchema;
  14428. }
  14429. });
  14430. Object.defineProperty(exports, "Source", {
  14431. enumerable: true,
  14432. get: function get() {
  14433. return _language.Source;
  14434. }
  14435. });
  14436. Object.defineProperty(exports, "getLocation", {
  14437. enumerable: true,
  14438. get: function get() {
  14439. return _language.getLocation;
  14440. }
  14441. });
  14442. Object.defineProperty(exports, "createLexer", {
  14443. enumerable: true,
  14444. get: function get() {
  14445. return _language.createLexer;
  14446. }
  14447. });
  14448. Object.defineProperty(exports, "TokenKind", {
  14449. enumerable: true,
  14450. get: function get() {
  14451. return _language.TokenKind;
  14452. }
  14453. });
  14454. Object.defineProperty(exports, "parse", {
  14455. enumerable: true,
  14456. get: function get() {
  14457. return _language.parse;
  14458. }
  14459. });
  14460. Object.defineProperty(exports, "parseValue", {
  14461. enumerable: true,
  14462. get: function get() {
  14463. return _language.parseValue;
  14464. }
  14465. });
  14466. Object.defineProperty(exports, "parseType", {
  14467. enumerable: true,
  14468. get: function get() {
  14469. return _language.parseType;
  14470. }
  14471. });
  14472. Object.defineProperty(exports, "print", {
  14473. enumerable: true,
  14474. get: function get() {
  14475. return _language.print;
  14476. }
  14477. });
  14478. Object.defineProperty(exports, "visit", {
  14479. enumerable: true,
  14480. get: function get() {
  14481. return _language.visit;
  14482. }
  14483. });
  14484. Object.defineProperty(exports, "visitInParallel", {
  14485. enumerable: true,
  14486. get: function get() {
  14487. return _language.visitInParallel;
  14488. }
  14489. });
  14490. Object.defineProperty(exports, "visitWithTypeInfo", {
  14491. enumerable: true,
  14492. get: function get() {
  14493. return _language.visitWithTypeInfo;
  14494. }
  14495. });
  14496. Object.defineProperty(exports, "getVisitFn", {
  14497. enumerable: true,
  14498. get: function get() {
  14499. return _language.getVisitFn;
  14500. }
  14501. });
  14502. Object.defineProperty(exports, "BREAK", {
  14503. enumerable: true,
  14504. get: function get() {
  14505. return _language.BREAK;
  14506. }
  14507. });
  14508. Object.defineProperty(exports, "Kind", {
  14509. enumerable: true,
  14510. get: function get() {
  14511. return _language.Kind;
  14512. }
  14513. });
  14514. Object.defineProperty(exports, "DirectiveLocation", {
  14515. enumerable: true,
  14516. get: function get() {
  14517. return _language.DirectiveLocation;
  14518. }
  14519. });
  14520. Object.defineProperty(exports, "isDefinitionNode", {
  14521. enumerable: true,
  14522. get: function get() {
  14523. return _language.isDefinitionNode;
  14524. }
  14525. });
  14526. Object.defineProperty(exports, "isExecutableDefinitionNode", {
  14527. enumerable: true,
  14528. get: function get() {
  14529. return _language.isExecutableDefinitionNode;
  14530. }
  14531. });
  14532. Object.defineProperty(exports, "isSelectionNode", {
  14533. enumerable: true,
  14534. get: function get() {
  14535. return _language.isSelectionNode;
  14536. }
  14537. });
  14538. Object.defineProperty(exports, "isValueNode", {
  14539. enumerable: true,
  14540. get: function get() {
  14541. return _language.isValueNode;
  14542. }
  14543. });
  14544. Object.defineProperty(exports, "isTypeNode", {
  14545. enumerable: true,
  14546. get: function get() {
  14547. return _language.isTypeNode;
  14548. }
  14549. });
  14550. Object.defineProperty(exports, "isTypeSystemDefinitionNode", {
  14551. enumerable: true,
  14552. get: function get() {
  14553. return _language.isTypeSystemDefinitionNode;
  14554. }
  14555. });
  14556. Object.defineProperty(exports, "isTypeDefinitionNode", {
  14557. enumerable: true,
  14558. get: function get() {
  14559. return _language.isTypeDefinitionNode;
  14560. }
  14561. });
  14562. Object.defineProperty(exports, "isTypeSystemExtensionNode", {
  14563. enumerable: true,
  14564. get: function get() {
  14565. return _language.isTypeSystemExtensionNode;
  14566. }
  14567. });
  14568. Object.defineProperty(exports, "isTypeExtensionNode", {
  14569. enumerable: true,
  14570. get: function get() {
  14571. return _language.isTypeExtensionNode;
  14572. }
  14573. });
  14574. Object.defineProperty(exports, "execute", {
  14575. enumerable: true,
  14576. get: function get() {
  14577. return _execution.execute;
  14578. }
  14579. });
  14580. Object.defineProperty(exports, "defaultFieldResolver", {
  14581. enumerable: true,
  14582. get: function get() {
  14583. return _execution.defaultFieldResolver;
  14584. }
  14585. });
  14586. Object.defineProperty(exports, "defaultTypeResolver", {
  14587. enumerable: true,
  14588. get: function get() {
  14589. return _execution.defaultTypeResolver;
  14590. }
  14591. });
  14592. Object.defineProperty(exports, "responsePathAsArray", {
  14593. enumerable: true,
  14594. get: function get() {
  14595. return _execution.responsePathAsArray;
  14596. }
  14597. });
  14598. Object.defineProperty(exports, "getDirectiveValues", {
  14599. enumerable: true,
  14600. get: function get() {
  14601. return _execution.getDirectiveValues;
  14602. }
  14603. });
  14604. Object.defineProperty(exports, "subscribe", {
  14605. enumerable: true,
  14606. get: function get() {
  14607. return _subscription.subscribe;
  14608. }
  14609. });
  14610. Object.defineProperty(exports, "createSourceEventStream", {
  14611. enumerable: true,
  14612. get: function get() {
  14613. return _subscription.createSourceEventStream;
  14614. }
  14615. });
  14616. Object.defineProperty(exports, "validate", {
  14617. enumerable: true,
  14618. get: function get() {
  14619. return _validation.validate;
  14620. }
  14621. });
  14622. Object.defineProperty(exports, "ValidationContext", {
  14623. enumerable: true,
  14624. get: function get() {
  14625. return _validation.ValidationContext;
  14626. }
  14627. });
  14628. Object.defineProperty(exports, "specifiedRules", {
  14629. enumerable: true,
  14630. get: function get() {
  14631. return _validation.specifiedRules;
  14632. }
  14633. });
  14634. Object.defineProperty(exports, "FieldsOnCorrectTypeRule", {
  14635. enumerable: true,
  14636. get: function get() {
  14637. return _validation.FieldsOnCorrectTypeRule;
  14638. }
  14639. });
  14640. Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", {
  14641. enumerable: true,
  14642. get: function get() {
  14643. return _validation.FragmentsOnCompositeTypesRule;
  14644. }
  14645. });
  14646. Object.defineProperty(exports, "KnownArgumentNamesRule", {
  14647. enumerable: true,
  14648. get: function get() {
  14649. return _validation.KnownArgumentNamesRule;
  14650. }
  14651. });
  14652. Object.defineProperty(exports, "KnownDirectivesRule", {
  14653. enumerable: true,
  14654. get: function get() {
  14655. return _validation.KnownDirectivesRule;
  14656. }
  14657. });
  14658. Object.defineProperty(exports, "KnownFragmentNamesRule", {
  14659. enumerable: true,
  14660. get: function get() {
  14661. return _validation.KnownFragmentNamesRule;
  14662. }
  14663. });
  14664. Object.defineProperty(exports, "KnownTypeNamesRule", {
  14665. enumerable: true,
  14666. get: function get() {
  14667. return _validation.KnownTypeNamesRule;
  14668. }
  14669. });
  14670. Object.defineProperty(exports, "LoneAnonymousOperationRule", {
  14671. enumerable: true,
  14672. get: function get() {
  14673. return _validation.LoneAnonymousOperationRule;
  14674. }
  14675. });
  14676. Object.defineProperty(exports, "NoFragmentCyclesRule", {
  14677. enumerable: true,
  14678. get: function get() {
  14679. return _validation.NoFragmentCyclesRule;
  14680. }
  14681. });
  14682. Object.defineProperty(exports, "NoUndefinedVariablesRule", {
  14683. enumerable: true,
  14684. get: function get() {
  14685. return _validation.NoUndefinedVariablesRule;
  14686. }
  14687. });
  14688. Object.defineProperty(exports, "NoUnusedFragmentsRule", {
  14689. enumerable: true,
  14690. get: function get() {
  14691. return _validation.NoUnusedFragmentsRule;
  14692. }
  14693. });
  14694. Object.defineProperty(exports, "NoUnusedVariablesRule", {
  14695. enumerable: true,
  14696. get: function get() {
  14697. return _validation.NoUnusedVariablesRule;
  14698. }
  14699. });
  14700. Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", {
  14701. enumerable: true,
  14702. get: function get() {
  14703. return _validation.OverlappingFieldsCanBeMergedRule;
  14704. }
  14705. });
  14706. Object.defineProperty(exports, "PossibleFragmentSpreadsRule", {
  14707. enumerable: true,
  14708. get: function get() {
  14709. return _validation.PossibleFragmentSpreadsRule;
  14710. }
  14711. });
  14712. Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", {
  14713. enumerable: true,
  14714. get: function get() {
  14715. return _validation.ProvidedRequiredArgumentsRule;
  14716. }
  14717. });
  14718. Object.defineProperty(exports, "ScalarLeafsRule", {
  14719. enumerable: true,
  14720. get: function get() {
  14721. return _validation.ScalarLeafsRule;
  14722. }
  14723. });
  14724. Object.defineProperty(exports, "SingleFieldSubscriptionsRule", {
  14725. enumerable: true,
  14726. get: function get() {
  14727. return _validation.SingleFieldSubscriptionsRule;
  14728. }
  14729. });
  14730. Object.defineProperty(exports, "UniqueArgumentNamesRule", {
  14731. enumerable: true,
  14732. get: function get() {
  14733. return _validation.UniqueArgumentNamesRule;
  14734. }
  14735. });
  14736. Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", {
  14737. enumerable: true,
  14738. get: function get() {
  14739. return _validation.UniqueDirectivesPerLocationRule;
  14740. }
  14741. });
  14742. Object.defineProperty(exports, "UniqueFragmentNamesRule", {
  14743. enumerable: true,
  14744. get: function get() {
  14745. return _validation.UniqueFragmentNamesRule;
  14746. }
  14747. });
  14748. Object.defineProperty(exports, "UniqueInputFieldNamesRule", {
  14749. enumerable: true,
  14750. get: function get() {
  14751. return _validation.UniqueInputFieldNamesRule;
  14752. }
  14753. });
  14754. Object.defineProperty(exports, "UniqueOperationNamesRule", {
  14755. enumerable: true,
  14756. get: function get() {
  14757. return _validation.UniqueOperationNamesRule;
  14758. }
  14759. });
  14760. Object.defineProperty(exports, "UniqueVariableNamesRule", {
  14761. enumerable: true,
  14762. get: function get() {
  14763. return _validation.UniqueVariableNamesRule;
  14764. }
  14765. });
  14766. Object.defineProperty(exports, "ValuesOfCorrectTypeRule", {
  14767. enumerable: true,
  14768. get: function get() {
  14769. return _validation.ValuesOfCorrectTypeRule;
  14770. }
  14771. });
  14772. Object.defineProperty(exports, "VariablesAreInputTypesRule", {
  14773. enumerable: true,
  14774. get: function get() {
  14775. return _validation.VariablesAreInputTypesRule;
  14776. }
  14777. });
  14778. Object.defineProperty(exports, "VariablesInAllowedPositionRule", {
  14779. enumerable: true,
  14780. get: function get() {
  14781. return _validation.VariablesInAllowedPositionRule;
  14782. }
  14783. });
  14784. Object.defineProperty(exports, "GraphQLError", {
  14785. enumerable: true,
  14786. get: function get() {
  14787. return _error.GraphQLError;
  14788. }
  14789. });
  14790. Object.defineProperty(exports, "syntaxError", {
  14791. enumerable: true,
  14792. get: function get() {
  14793. return _error.syntaxError;
  14794. }
  14795. });
  14796. Object.defineProperty(exports, "locatedError", {
  14797. enumerable: true,
  14798. get: function get() {
  14799. return _error.locatedError;
  14800. }
  14801. });
  14802. Object.defineProperty(exports, "printError", {
  14803. enumerable: true,
  14804. get: function get() {
  14805. return _error.printError;
  14806. }
  14807. });
  14808. Object.defineProperty(exports, "formatError", {
  14809. enumerable: true,
  14810. get: function get() {
  14811. return _error.formatError;
  14812. }
  14813. });
  14814. Object.defineProperty(exports, "getIntrospectionQuery", {
  14815. enumerable: true,
  14816. get: function get() {
  14817. return _utilities.getIntrospectionQuery;
  14818. }
  14819. });
  14820. Object.defineProperty(exports, "introspectionQuery", {
  14821. enumerable: true,
  14822. get: function get() {
  14823. return _utilities.introspectionQuery;
  14824. }
  14825. });
  14826. Object.defineProperty(exports, "getOperationAST", {
  14827. enumerable: true,
  14828. get: function get() {
  14829. return _utilities.getOperationAST;
  14830. }
  14831. });
  14832. Object.defineProperty(exports, "getOperationRootType", {
  14833. enumerable: true,
  14834. get: function get() {
  14835. return _utilities.getOperationRootType;
  14836. }
  14837. });
  14838. Object.defineProperty(exports, "introspectionFromSchema", {
  14839. enumerable: true,
  14840. get: function get() {
  14841. return _utilities.introspectionFromSchema;
  14842. }
  14843. });
  14844. Object.defineProperty(exports, "buildClientSchema", {
  14845. enumerable: true,
  14846. get: function get() {
  14847. return _utilities.buildClientSchema;
  14848. }
  14849. });
  14850. Object.defineProperty(exports, "buildASTSchema", {
  14851. enumerable: true,
  14852. get: function get() {
  14853. return _utilities.buildASTSchema;
  14854. }
  14855. });
  14856. Object.defineProperty(exports, "buildSchema", {
  14857. enumerable: true,
  14858. get: function get() {
  14859. return _utilities.buildSchema;
  14860. }
  14861. });
  14862. Object.defineProperty(exports, "getDescription", {
  14863. enumerable: true,
  14864. get: function get() {
  14865. return _utilities.getDescription;
  14866. }
  14867. });
  14868. Object.defineProperty(exports, "extendSchema", {
  14869. enumerable: true,
  14870. get: function get() {
  14871. return _utilities.extendSchema;
  14872. }
  14873. });
  14874. Object.defineProperty(exports, "lexicographicSortSchema", {
  14875. enumerable: true,
  14876. get: function get() {
  14877. return _utilities.lexicographicSortSchema;
  14878. }
  14879. });
  14880. Object.defineProperty(exports, "printSchema", {
  14881. enumerable: true,
  14882. get: function get() {
  14883. return _utilities.printSchema;
  14884. }
  14885. });
  14886. Object.defineProperty(exports, "printType", {
  14887. enumerable: true,
  14888. get: function get() {
  14889. return _utilities.printType;
  14890. }
  14891. });
  14892. Object.defineProperty(exports, "printIntrospectionSchema", {
  14893. enumerable: true,
  14894. get: function get() {
  14895. return _utilities.printIntrospectionSchema;
  14896. }
  14897. });
  14898. Object.defineProperty(exports, "typeFromAST", {
  14899. enumerable: true,
  14900. get: function get() {
  14901. return _utilities.typeFromAST;
  14902. }
  14903. });
  14904. Object.defineProperty(exports, "valueFromAST", {
  14905. enumerable: true,
  14906. get: function get() {
  14907. return _utilities.valueFromAST;
  14908. }
  14909. });
  14910. Object.defineProperty(exports, "valueFromASTUntyped", {
  14911. enumerable: true,
  14912. get: function get() {
  14913. return _utilities.valueFromASTUntyped;
  14914. }
  14915. });
  14916. Object.defineProperty(exports, "astFromValue", {
  14917. enumerable: true,
  14918. get: function get() {
  14919. return _utilities.astFromValue;
  14920. }
  14921. });
  14922. Object.defineProperty(exports, "TypeInfo", {
  14923. enumerable: true,
  14924. get: function get() {
  14925. return _utilities.TypeInfo;
  14926. }
  14927. });
  14928. Object.defineProperty(exports, "coerceValue", {
  14929. enumerable: true,
  14930. get: function get() {
  14931. return _utilities.coerceValue;
  14932. }
  14933. });
  14934. Object.defineProperty(exports, "isValidJSValue", {
  14935. enumerable: true,
  14936. get: function get() {
  14937. return _utilities.isValidJSValue;
  14938. }
  14939. });
  14940. Object.defineProperty(exports, "isValidLiteralValue", {
  14941. enumerable: true,
  14942. get: function get() {
  14943. return _utilities.isValidLiteralValue;
  14944. }
  14945. });
  14946. Object.defineProperty(exports, "concatAST", {
  14947. enumerable: true,
  14948. get: function get() {
  14949. return _utilities.concatAST;
  14950. }
  14951. });
  14952. Object.defineProperty(exports, "separateOperations", {
  14953. enumerable: true,
  14954. get: function get() {
  14955. return _utilities.separateOperations;
  14956. }
  14957. });
  14958. Object.defineProperty(exports, "stripIgnoredCharacters", {
  14959. enumerable: true,
  14960. get: function get() {
  14961. return _utilities.stripIgnoredCharacters;
  14962. }
  14963. });
  14964. Object.defineProperty(exports, "isEqualType", {
  14965. enumerable: true,
  14966. get: function get() {
  14967. return _utilities.isEqualType;
  14968. }
  14969. });
  14970. Object.defineProperty(exports, "isTypeSubTypeOf", {
  14971. enumerable: true,
  14972. get: function get() {
  14973. return _utilities.isTypeSubTypeOf;
  14974. }
  14975. });
  14976. Object.defineProperty(exports, "doTypesOverlap", {
  14977. enumerable: true,
  14978. get: function get() {
  14979. return _utilities.doTypesOverlap;
  14980. }
  14981. });
  14982. Object.defineProperty(exports, "assertValidName", {
  14983. enumerable: true,
  14984. get: function get() {
  14985. return _utilities.assertValidName;
  14986. }
  14987. });
  14988. Object.defineProperty(exports, "isValidNameError", {
  14989. enumerable: true,
  14990. get: function get() {
  14991. return _utilities.isValidNameError;
  14992. }
  14993. });
  14994. Object.defineProperty(exports, "BreakingChangeType", {
  14995. enumerable: true,
  14996. get: function get() {
  14997. return _utilities.BreakingChangeType;
  14998. }
  14999. });
  15000. Object.defineProperty(exports, "DangerousChangeType", {
  15001. enumerable: true,
  15002. get: function get() {
  15003. return _utilities.DangerousChangeType;
  15004. }
  15005. });
  15006. Object.defineProperty(exports, "findBreakingChanges", {
  15007. enumerable: true,
  15008. get: function get() {
  15009. return _utilities.findBreakingChanges;
  15010. }
  15011. });
  15012. Object.defineProperty(exports, "findDangerousChanges", {
  15013. enumerable: true,
  15014. get: function get() {
  15015. return _utilities.findDangerousChanges;
  15016. }
  15017. });
  15018. Object.defineProperty(exports, "findDeprecatedUsages", {
  15019. enumerable: true,
  15020. get: function get() {
  15021. return _utilities.findDeprecatedUsages;
  15022. }
  15023. });
  15024. var _graphql = require("./graphql");
  15025. var _type = require("./type");
  15026. var _language = require("./language");
  15027. var _execution = require("./execution");
  15028. var _subscription = require("./subscription");
  15029. var _validation = require("./validation");
  15030. var _error = require("./error");
  15031. var _utilities = require("./utilities");
  15032. },{"./error":21,"./execution":26,"./graphql":28,"./language":50,"./subscription":65,"./type":70,"./utilities":87,"./validation":101}],30:[function(require,module,exports){
  15033. "use strict";
  15034. Object.defineProperty(exports, "__esModule", {
  15035. value: true
  15036. });
  15037. exports.default = defineToJSON;
  15038. var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
  15039. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15040. /**
  15041. * Copyright (c) Facebook, Inc. and its affiliates.
  15042. *
  15043. * This source code is licensed under the MIT license found in the
  15044. * LICENSE file in the root directory of this source tree.
  15045. *
  15046. *
  15047. */
  15048. /**
  15049. * The `defineToJSON()` function defines toJSON() and inspect() prototype
  15050. * methods, if no function provided they become aliases for toString().
  15051. */
  15052. function defineToJSON( // eslint-disable-next-line flowtype/no-weak-types
  15053. classObject) {
  15054. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : classObject.prototype.toString;
  15055. classObject.prototype.toJSON = fn;
  15056. classObject.prototype.inspect = fn;
  15057. if (_nodejsCustomInspectSymbol.default) {
  15058. classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
  15059. }
  15060. }
  15061. },{"./nodejsCustomInspectSymbol":42}],31:[function(require,module,exports){
  15062. "use strict";
  15063. Object.defineProperty(exports, "__esModule", {
  15064. value: true
  15065. });
  15066. exports.default = defineToStringTag;
  15067. /**
  15068. * Copyright (c) Facebook, Inc. and its affiliates.
  15069. *
  15070. * This source code is licensed under the MIT license found in the
  15071. * LICENSE file in the root directory of this source tree.
  15072. *
  15073. *
  15074. */
  15075. /**
  15076. * The `defineToStringTag()` function checks first to see if the runtime
  15077. * supports the `Symbol` class and then if the `Symbol.toStringTag` constant
  15078. * is defined as a `Symbol` instance. If both conditions are met, the
  15079. * Symbol.toStringTag property is defined as a getter that returns the
  15080. * supplied class constructor's name.
  15081. *
  15082. * @method defineToStringTag
  15083. *
  15084. * @param {Class<any>} classObject a class such as Object, String, Number but
  15085. * typically one of your own creation through the class keyword; `class A {}`,
  15086. * for example.
  15087. */
  15088. function defineToStringTag(classObject) {
  15089. if (typeof Symbol === 'function' && Symbol.toStringTag) {
  15090. Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
  15091. get: function get() {
  15092. return this.constructor.name;
  15093. }
  15094. });
  15095. }
  15096. }
  15097. },{}],32:[function(require,module,exports){
  15098. "use strict";
  15099. Object.defineProperty(exports, "__esModule", {
  15100. value: true
  15101. });
  15102. exports.default = inspect;
  15103. var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
  15104. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15105. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15106. var MAX_ARRAY_LENGTH = 10;
  15107. var MAX_RECURSIVE_DEPTH = 2;
  15108. /**
  15109. * Used to print values in error messages.
  15110. */
  15111. function inspect(value) {
  15112. return formatValue(value, []);
  15113. }
  15114. function formatValue(value, seenValues) {
  15115. switch (_typeof(value)) {
  15116. case 'string':
  15117. return JSON.stringify(value);
  15118. case 'function':
  15119. return value.name ? "[function ".concat(value.name, "]") : '[function]';
  15120. case 'object':
  15121. return formatObjectValue(value, seenValues);
  15122. default:
  15123. return String(value);
  15124. }
  15125. }
  15126. function formatObjectValue(value, previouslySeenValues) {
  15127. if (previouslySeenValues.indexOf(value) !== -1) {
  15128. return '[Circular]';
  15129. }
  15130. var seenValues = [].concat(previouslySeenValues, [value]);
  15131. if (value) {
  15132. var customInspectFn = getCustomFn(value);
  15133. if (customInspectFn !== undefined) {
  15134. // $FlowFixMe(>=0.90.0)
  15135. var customValue = customInspectFn.call(value); // check for infinite recursion
  15136. if (customValue !== value) {
  15137. return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
  15138. }
  15139. } else if (Array.isArray(value)) {
  15140. return formatArray(value, seenValues);
  15141. }
  15142. return formatObject(value, seenValues);
  15143. }
  15144. return String(value);
  15145. }
  15146. function formatObject(object, seenValues) {
  15147. var keys = Object.keys(object);
  15148. if (keys.length === 0) {
  15149. return '{}';
  15150. }
  15151. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  15152. return '[' + getObjectTag(object) + ']';
  15153. }
  15154. var properties = keys.map(function (key) {
  15155. var value = formatValue(object[key], seenValues);
  15156. return key + ': ' + value;
  15157. });
  15158. return '{ ' + properties.join(', ') + ' }';
  15159. }
  15160. function formatArray(array, seenValues) {
  15161. if (array.length === 0) {
  15162. return '[]';
  15163. }
  15164. if (seenValues.length > MAX_RECURSIVE_DEPTH) {
  15165. return '[Array]';
  15166. }
  15167. var len = Math.min(MAX_ARRAY_LENGTH, array.length);
  15168. var remaining = array.length - len;
  15169. var items = [];
  15170. for (var i = 0; i < len; ++i) {
  15171. items.push(formatValue(array[i], seenValues));
  15172. }
  15173. if (remaining === 1) {
  15174. items.push('... 1 more item');
  15175. } else if (remaining > 1) {
  15176. items.push("... ".concat(remaining, " more items"));
  15177. }
  15178. return '[' + items.join(', ') + ']';
  15179. }
  15180. function getCustomFn(object) {
  15181. var customInspectFn = object[String(_nodejsCustomInspectSymbol.default)];
  15182. if (typeof customInspectFn === 'function') {
  15183. return customInspectFn;
  15184. }
  15185. if (typeof object.inspect === 'function') {
  15186. return object.inspect;
  15187. }
  15188. }
  15189. function getObjectTag(object) {
  15190. var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
  15191. if (tag === 'Object' && typeof object.constructor === 'function') {
  15192. var name = object.constructor.name;
  15193. if (typeof name === 'string') {
  15194. return name;
  15195. }
  15196. }
  15197. return tag;
  15198. }
  15199. },{"./nodejsCustomInspectSymbol":42}],33:[function(require,module,exports){
  15200. (function (process){
  15201. "use strict";
  15202. Object.defineProperty(exports, "__esModule", {
  15203. value: true
  15204. });
  15205. exports.default = void 0;
  15206. /**
  15207. * Copyright (c) Facebook, Inc. and its affiliates.
  15208. *
  15209. * This source code is licensed under the MIT license found in the
  15210. * LICENSE file in the root directory of this source tree.
  15211. *
  15212. *
  15213. */
  15214. /**
  15215. * A replacement for instanceof which includes an error warning when multi-realm
  15216. * constructors are detected.
  15217. */
  15218. // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
  15219. // See: https://webpack.js.org/guides/production/
  15220. var _default = process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
  15221. function instanceOf(value, constructor) {
  15222. return value instanceof constructor;
  15223. } : // eslint-disable-next-line no-shadow
  15224. function instanceOf(value, constructor) {
  15225. if (value instanceof constructor) {
  15226. return true;
  15227. }
  15228. if (value) {
  15229. var valueClass = value.constructor;
  15230. var className = constructor.name;
  15231. if (className && valueClass && valueClass.name === className) {
  15232. throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
  15233. }
  15234. }
  15235. return false;
  15236. };
  15237. exports.default = _default;
  15238. }).call(this,require('_process'))
  15239. },{"_process":198}],34:[function(require,module,exports){
  15240. "use strict";
  15241. Object.defineProperty(exports, "__esModule", {
  15242. value: true
  15243. });
  15244. exports.default = invariant;
  15245. /**
  15246. * Copyright (c) Facebook, Inc. and its affiliates.
  15247. *
  15248. * This source code is licensed under the MIT license found in the
  15249. * LICENSE file in the root directory of this source tree.
  15250. *
  15251. *
  15252. */
  15253. function invariant(condition, message) {
  15254. var booleanCondition = Boolean(condition);
  15255. /* istanbul ignore else */
  15256. if (!booleanCondition) {
  15257. throw new Error(message);
  15258. }
  15259. }
  15260. },{}],35:[function(require,module,exports){
  15261. "use strict";
  15262. Object.defineProperty(exports, "__esModule", {
  15263. value: true
  15264. });
  15265. exports.default = isInvalid;
  15266. /**
  15267. * Copyright (c) Facebook, Inc. and its affiliates.
  15268. *
  15269. * This source code is licensed under the MIT license found in the
  15270. * LICENSE file in the root directory of this source tree.
  15271. *
  15272. *
  15273. */
  15274. /**
  15275. * Returns true if a value is undefined, or NaN.
  15276. */
  15277. function isInvalid(value) {
  15278. return value === undefined || value !== value;
  15279. }
  15280. },{}],36:[function(require,module,exports){
  15281. "use strict";
  15282. Object.defineProperty(exports, "__esModule", {
  15283. value: true
  15284. });
  15285. exports.default = isNullish;
  15286. /**
  15287. * Copyright (c) Facebook, Inc. and its affiliates.
  15288. *
  15289. * This source code is licensed under the MIT license found in the
  15290. * LICENSE file in the root directory of this source tree.
  15291. *
  15292. *
  15293. */
  15294. /**
  15295. * Returns true if a value is null, undefined, or NaN.
  15296. */
  15297. function isNullish(value) {
  15298. return value === null || value === undefined || value !== value;
  15299. }
  15300. },{}],37:[function(require,module,exports){
  15301. "use strict";
  15302. Object.defineProperty(exports, "__esModule", {
  15303. value: true
  15304. });
  15305. exports.default = isPromise;
  15306. /**
  15307. * Copyright (c) Facebook, Inc. and its affiliates.
  15308. *
  15309. * This source code is licensed under the MIT license found in the
  15310. * LICENSE file in the root directory of this source tree.
  15311. *
  15312. *
  15313. */
  15314. /**
  15315. * Returns true if the value acts like a Promise, i.e. has a "then" function,
  15316. * otherwise returns false.
  15317. */
  15318. // eslint-disable-next-line no-redeclare
  15319. function isPromise(value) {
  15320. return Boolean(value && typeof value.then === 'function');
  15321. }
  15322. },{}],38:[function(require,module,exports){
  15323. "use strict";
  15324. Object.defineProperty(exports, "__esModule", {
  15325. value: true
  15326. });
  15327. exports.default = keyMap;
  15328. /**
  15329. * Copyright (c) Facebook, Inc. and its affiliates.
  15330. *
  15331. * This source code is licensed under the MIT license found in the
  15332. * LICENSE file in the root directory of this source tree.
  15333. *
  15334. *
  15335. */
  15336. /**
  15337. * Creates a keyed JS object from an array, given a function to produce the keys
  15338. * for each value in the array.
  15339. *
  15340. * This provides a convenient lookup for the array items if the key function
  15341. * produces unique results.
  15342. *
  15343. * const phoneBook = [
  15344. * { name: 'Jon', num: '555-1234' },
  15345. * { name: 'Jenny', num: '867-5309' }
  15346. * ]
  15347. *
  15348. * // { Jon: { name: 'Jon', num: '555-1234' },
  15349. * // Jenny: { name: 'Jenny', num: '867-5309' } }
  15350. * const entriesByName = keyMap(
  15351. * phoneBook,
  15352. * entry => entry.name
  15353. * )
  15354. *
  15355. * // { name: 'Jenny', num: '857-6309' }
  15356. * const jennyEntry = entriesByName['Jenny']
  15357. *
  15358. */
  15359. function keyMap(list, keyFn) {
  15360. return list.reduce(function (map, item) {
  15361. map[keyFn(item)] = item;
  15362. return map;
  15363. }, Object.create(null));
  15364. }
  15365. },{}],39:[function(require,module,exports){
  15366. "use strict";
  15367. Object.defineProperty(exports, "__esModule", {
  15368. value: true
  15369. });
  15370. exports.default = keyValMap;
  15371. /**
  15372. * Copyright (c) Facebook, Inc. and its affiliates.
  15373. *
  15374. * This source code is licensed under the MIT license found in the
  15375. * LICENSE file in the root directory of this source tree.
  15376. *
  15377. *
  15378. */
  15379. /**
  15380. * Creates a keyed JS object from an array, given a function to produce the keys
  15381. * and a function to produce the values from each item in the array.
  15382. *
  15383. * const phoneBook = [
  15384. * { name: 'Jon', num: '555-1234' },
  15385. * { name: 'Jenny', num: '867-5309' }
  15386. * ]
  15387. *
  15388. * // { Jon: '555-1234', Jenny: '867-5309' }
  15389. * const phonesByName = keyValMap(
  15390. * phoneBook,
  15391. * entry => entry.name,
  15392. * entry => entry.num
  15393. * )
  15394. *
  15395. */
  15396. function keyValMap(list, keyFn, valFn) {
  15397. return list.reduce(function (map, item) {
  15398. map[keyFn(item)] = valFn(item);
  15399. return map;
  15400. }, Object.create(null));
  15401. }
  15402. },{}],40:[function(require,module,exports){
  15403. "use strict";
  15404. Object.defineProperty(exports, "__esModule", {
  15405. value: true
  15406. });
  15407. exports.default = mapValue;
  15408. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  15409. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15410. /**
  15411. * Copyright (c) Facebook, Inc. and its affiliates.
  15412. *
  15413. * This source code is licensed under the MIT license found in the
  15414. * LICENSE file in the root directory of this source tree.
  15415. *
  15416. *
  15417. */
  15418. /**
  15419. * Creates an object map with the same keys as `map` and values generated by
  15420. * running each value of `map` thru `fn`.
  15421. */
  15422. function mapValue(map, fn) {
  15423. var result = Object.create(null);
  15424. var _iteratorNormalCompletion = true;
  15425. var _didIteratorError = false;
  15426. var _iteratorError = undefined;
  15427. try {
  15428. for (var _iterator = (0, _objectEntries.default)(map)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  15429. var _ref2 = _step.value;
  15430. var _key = _ref2[0];
  15431. var _value = _ref2[1];
  15432. result[_key] = fn(_value, _key);
  15433. }
  15434. } catch (err) {
  15435. _didIteratorError = true;
  15436. _iteratorError = err;
  15437. } finally {
  15438. try {
  15439. if (!_iteratorNormalCompletion && _iterator.return != null) {
  15440. _iterator.return();
  15441. }
  15442. } finally {
  15443. if (_didIteratorError) {
  15444. throw _iteratorError;
  15445. }
  15446. }
  15447. }
  15448. return result;
  15449. }
  15450. },{"../polyfills/objectEntries":63}],41:[function(require,module,exports){
  15451. "use strict";
  15452. Object.defineProperty(exports, "__esModule", {
  15453. value: true
  15454. });
  15455. exports.default = memoize3;
  15456. /**
  15457. * Copyright (c) Facebook, Inc. and its affiliates.
  15458. *
  15459. * This source code is licensed under the MIT license found in the
  15460. * LICENSE file in the root directory of this source tree.
  15461. *
  15462. *
  15463. */
  15464. /**
  15465. * Memoizes the provided three-argument function.
  15466. */
  15467. function memoize3(fn) {
  15468. var cache0;
  15469. function memoized(a1, a2, a3) {
  15470. if (!cache0) {
  15471. cache0 = new WeakMap();
  15472. }
  15473. var cache1 = cache0.get(a1);
  15474. var cache2;
  15475. if (cache1) {
  15476. cache2 = cache1.get(a2);
  15477. if (cache2) {
  15478. var cachedValue = cache2.get(a3);
  15479. if (cachedValue !== undefined) {
  15480. return cachedValue;
  15481. }
  15482. }
  15483. } else {
  15484. cache1 = new WeakMap();
  15485. cache0.set(a1, cache1);
  15486. }
  15487. if (!cache2) {
  15488. cache2 = new WeakMap();
  15489. cache1.set(a2, cache2);
  15490. }
  15491. var newValue = fn(a1, a2, a3);
  15492. cache2.set(a3, newValue);
  15493. return newValue;
  15494. }
  15495. return memoized;
  15496. }
  15497. },{}],42:[function(require,module,exports){
  15498. "use strict";
  15499. Object.defineProperty(exports, "__esModule", {
  15500. value: true
  15501. });
  15502. exports.default = void 0;
  15503. /**
  15504. * Copyright (c) Facebook, Inc. and its affiliates.
  15505. *
  15506. * This source code is licensed under the MIT license found in the
  15507. * LICENSE file in the root directory of this source tree.
  15508. *
  15509. *
  15510. */
  15511. var nodejsCustomInspectSymbol = typeof Symbol === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
  15512. var _default = nodejsCustomInspectSymbol;
  15513. exports.default = _default;
  15514. },{}],43:[function(require,module,exports){
  15515. "use strict";
  15516. Object.defineProperty(exports, "__esModule", {
  15517. value: true
  15518. });
  15519. exports.default = orList;
  15520. var _invariant = _interopRequireDefault(require("./invariant"));
  15521. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15522. /**
  15523. * Copyright (c) Facebook, Inc. and its affiliates.
  15524. *
  15525. * This source code is licensed under the MIT license found in the
  15526. * LICENSE file in the root directory of this source tree.
  15527. *
  15528. *
  15529. */
  15530. var MAX_LENGTH = 5;
  15531. /**
  15532. * Given [ A, B, C ] return 'A, B, or C'.
  15533. */
  15534. function orList(items) {
  15535. !(items.length !== 0) ? (0, _invariant.default)(0) : void 0;
  15536. if (items.length === 1) {
  15537. return items[0];
  15538. }
  15539. if (items.length === 2) {
  15540. return items[0] + ' or ' + items[1];
  15541. }
  15542. var selected = items.slice(0, MAX_LENGTH);
  15543. var lastItem = selected.pop();
  15544. return selected.join(', ') + ', or ' + lastItem;
  15545. }
  15546. },{"./invariant":34}],44:[function(require,module,exports){
  15547. "use strict";
  15548. Object.defineProperty(exports, "__esModule", {
  15549. value: true
  15550. });
  15551. exports.default = promiseForObject;
  15552. /**
  15553. * Copyright (c) Facebook, Inc. and its affiliates.
  15554. *
  15555. * This source code is licensed under the MIT license found in the
  15556. * LICENSE file in the root directory of this source tree.
  15557. *
  15558. *
  15559. */
  15560. /**
  15561. * This function transforms a JS object `ObjMap<Promise<T>>` into
  15562. * a `Promise<ObjMap<T>>`
  15563. *
  15564. * This is akin to bluebird's `Promise.props`, but implemented only using
  15565. * `Promise.all` so it will work with any implementation of ES6 promises.
  15566. */
  15567. function promiseForObject(object) {
  15568. var keys = Object.keys(object);
  15569. var valuesAndPromises = keys.map(function (name) {
  15570. return object[name];
  15571. });
  15572. return Promise.all(valuesAndPromises).then(function (values) {
  15573. return values.reduce(function (resolvedObject, value, i) {
  15574. resolvedObject[keys[i]] = value;
  15575. return resolvedObject;
  15576. }, Object.create(null));
  15577. });
  15578. }
  15579. },{}],45:[function(require,module,exports){
  15580. "use strict";
  15581. Object.defineProperty(exports, "__esModule", {
  15582. value: true
  15583. });
  15584. exports.default = promiseReduce;
  15585. var _isPromise = _interopRequireDefault(require("./isPromise"));
  15586. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15587. /**
  15588. * Copyright (c) Facebook, Inc. and its affiliates.
  15589. *
  15590. * This source code is licensed under the MIT license found in the
  15591. * LICENSE file in the root directory of this source tree.
  15592. *
  15593. *
  15594. */
  15595. /**
  15596. * Similar to Array.prototype.reduce(), however the reducing callback may return
  15597. * a Promise, in which case reduction will continue after each promise resolves.
  15598. *
  15599. * If the callback does not return a Promise, then this function will also not
  15600. * return a Promise.
  15601. */
  15602. function promiseReduce(values, callback, initialValue) {
  15603. return values.reduce(function (previous, value) {
  15604. return (0, _isPromise.default)(previous) ? previous.then(function (resolved) {
  15605. return callback(resolved, value);
  15606. }) : callback(previous, value);
  15607. }, initialValue);
  15608. }
  15609. },{"./isPromise":37}],46:[function(require,module,exports){
  15610. "use strict";
  15611. Object.defineProperty(exports, "__esModule", {
  15612. value: true
  15613. });
  15614. exports.default = quotedOrList;
  15615. var _orList = _interopRequireDefault(require("./orList"));
  15616. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15617. /**
  15618. * Copyright (c) Facebook, Inc. and its affiliates.
  15619. *
  15620. * This source code is licensed under the MIT license found in the
  15621. * LICENSE file in the root directory of this source tree.
  15622. *
  15623. *
  15624. */
  15625. /**
  15626. * Given [ A, B, C ] return '"A", "B", or "C"'.
  15627. */
  15628. function quotedOrList(items) {
  15629. return (0, _orList.default)(items.map(function (item) {
  15630. return "\"".concat(item, "\"");
  15631. }));
  15632. }
  15633. },{"./orList":43}],47:[function(require,module,exports){
  15634. "use strict";
  15635. Object.defineProperty(exports, "__esModule", {
  15636. value: true
  15637. });
  15638. exports.default = suggestionList;
  15639. /**
  15640. * Copyright (c) Facebook, Inc. and its affiliates.
  15641. *
  15642. * This source code is licensed under the MIT license found in the
  15643. * LICENSE file in the root directory of this source tree.
  15644. *
  15645. *
  15646. */
  15647. /**
  15648. * Given an invalid input string and a list of valid options, returns a filtered
  15649. * list of valid options sorted based on their similarity with the input.
  15650. */
  15651. function suggestionList(input, options) {
  15652. var optionsByDistance = Object.create(null);
  15653. var oLength = options.length;
  15654. var inputThreshold = input.length / 2;
  15655. for (var i = 0; i < oLength; i++) {
  15656. var distance = lexicalDistance(input, options[i]);
  15657. var threshold = Math.max(inputThreshold, options[i].length / 2, 1);
  15658. if (distance <= threshold) {
  15659. optionsByDistance[options[i]] = distance;
  15660. }
  15661. }
  15662. return Object.keys(optionsByDistance).sort(function (a, b) {
  15663. return optionsByDistance[a] - optionsByDistance[b];
  15664. });
  15665. }
  15666. /**
  15667. * Computes the lexical distance between strings A and B.
  15668. *
  15669. * The "distance" between two strings is given by counting the minimum number
  15670. * of edits needed to transform string A into string B. An edit can be an
  15671. * insertion, deletion, or substitution of a single character, or a swap of two
  15672. * adjacent characters.
  15673. *
  15674. * Includes a custom alteration from Damerau-Levenshtein to treat case changes
  15675. * as a single edit which helps identify mis-cased values with an edit distance
  15676. * of 1.
  15677. *
  15678. * This distance can be useful for detecting typos in input or sorting
  15679. *
  15680. * @param {string} a
  15681. * @param {string} b
  15682. * @return {int} distance in number of edits
  15683. */
  15684. function lexicalDistance(aStr, bStr) {
  15685. if (aStr === bStr) {
  15686. return 0;
  15687. }
  15688. var i;
  15689. var j;
  15690. var d = [];
  15691. var a = aStr.toLowerCase();
  15692. var b = bStr.toLowerCase();
  15693. var aLength = a.length;
  15694. var bLength = b.length; // Any case change counts as a single edit
  15695. if (a === b) {
  15696. return 1;
  15697. }
  15698. for (i = 0; i <= aLength; i++) {
  15699. d[i] = [i];
  15700. }
  15701. for (j = 1; j <= bLength; j++) {
  15702. d[0][j] = j;
  15703. }
  15704. for (i = 1; i <= aLength; i++) {
  15705. for (j = 1; j <= bLength; j++) {
  15706. var cost = a[i - 1] === b[j - 1] ? 0 : 1;
  15707. d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
  15708. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  15709. d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
  15710. }
  15711. }
  15712. }
  15713. return d[aLength][bLength];
  15714. }
  15715. },{}],48:[function(require,module,exports){
  15716. "use strict";
  15717. Object.defineProperty(exports, "__esModule", {
  15718. value: true
  15719. });
  15720. exports.dedentBlockStringValue = dedentBlockStringValue;
  15721. exports.getBlockStringIndentation = getBlockStringIndentation;
  15722. exports.printBlockString = printBlockString;
  15723. /**
  15724. * Copyright (c) Facebook, Inc. and its affiliates.
  15725. *
  15726. * This source code is licensed under the MIT license found in the
  15727. * LICENSE file in the root directory of this source tree.
  15728. *
  15729. *
  15730. */
  15731. /**
  15732. * Produces the value of a block string from its parsed raw value, similar to
  15733. * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
  15734. *
  15735. * This implements the GraphQL spec's BlockStringValue() static algorithm.
  15736. */
  15737. function dedentBlockStringValue(rawString) {
  15738. // Expand a block string's raw value into independent lines.
  15739. var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
  15740. var commonIndent = getBlockStringIndentation(lines);
  15741. if (commonIndent !== 0) {
  15742. for (var i = 1; i < lines.length; i++) {
  15743. lines[i] = lines[i].slice(commonIndent);
  15744. }
  15745. } // Remove leading and trailing blank lines.
  15746. while (lines.length > 0 && isBlank(lines[0])) {
  15747. lines.shift();
  15748. }
  15749. while (lines.length > 0 && isBlank(lines[lines.length - 1])) {
  15750. lines.pop();
  15751. } // Return a string of the lines joined with U+000A.
  15752. return lines.join('\n');
  15753. } // @internal
  15754. function getBlockStringIndentation(lines) {
  15755. var commonIndent = null;
  15756. for (var i = 1; i < lines.length; i++) {
  15757. var line = lines[i];
  15758. var indent = leadingWhitespace(line);
  15759. if (indent === line.length) {
  15760. continue; // skip empty lines
  15761. }
  15762. if (commonIndent === null || indent < commonIndent) {
  15763. commonIndent = indent;
  15764. if (commonIndent === 0) {
  15765. break;
  15766. }
  15767. }
  15768. }
  15769. return commonIndent === null ? 0 : commonIndent;
  15770. }
  15771. function leadingWhitespace(str) {
  15772. var i = 0;
  15773. while (i < str.length && (str[i] === ' ' || str[i] === '\t')) {
  15774. i++;
  15775. }
  15776. return i;
  15777. }
  15778. function isBlank(str) {
  15779. return leadingWhitespace(str) === str.length;
  15780. }
  15781. /**
  15782. * Print a block string in the indented block form by adding a leading and
  15783. * trailing blank line. However, if a block string starts with whitespace and is
  15784. * a single-line, adding a leading blank line would strip that whitespace.
  15785. */
  15786. function printBlockString(value) {
  15787. var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  15788. var preferMultipleLines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15789. var isSingleLine = value.indexOf('\n') === -1;
  15790. var hasLeadingSpace = value[0] === ' ' || value[0] === '\t';
  15791. var hasTrailingQuote = value[value.length - 1] === '"';
  15792. var printAsMultipleLines = !isSingleLine || hasTrailingQuote || preferMultipleLines;
  15793. var result = ''; // Format a multi-line block quote to account for leading space.
  15794. if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) {
  15795. result += '\n' + indentation;
  15796. }
  15797. result += indentation ? value.replace(/\n/g, '\n' + indentation) : value;
  15798. if (printAsMultipleLines) {
  15799. result += '\n';
  15800. }
  15801. return '"""' + result.replace(/"""/g, '\\"""') + '"""';
  15802. }
  15803. },{}],49:[function(require,module,exports){
  15804. "use strict";
  15805. Object.defineProperty(exports, "__esModule", {
  15806. value: true
  15807. });
  15808. exports.DirectiveLocation = void 0;
  15809. /**
  15810. * Copyright (c) Facebook, Inc. and its affiliates.
  15811. *
  15812. * This source code is licensed under the MIT license found in the
  15813. * LICENSE file in the root directory of this source tree.
  15814. *
  15815. *
  15816. */
  15817. /**
  15818. * The set of allowed directive location values.
  15819. */
  15820. var DirectiveLocation = Object.freeze({
  15821. // Request Definitions
  15822. QUERY: 'QUERY',
  15823. MUTATION: 'MUTATION',
  15824. SUBSCRIPTION: 'SUBSCRIPTION',
  15825. FIELD: 'FIELD',
  15826. FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
  15827. FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
  15828. INLINE_FRAGMENT: 'INLINE_FRAGMENT',
  15829. VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
  15830. // Type System Definitions
  15831. SCHEMA: 'SCHEMA',
  15832. SCALAR: 'SCALAR',
  15833. OBJECT: 'OBJECT',
  15834. FIELD_DEFINITION: 'FIELD_DEFINITION',
  15835. ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
  15836. INTERFACE: 'INTERFACE',
  15837. UNION: 'UNION',
  15838. ENUM: 'ENUM',
  15839. ENUM_VALUE: 'ENUM_VALUE',
  15840. INPUT_OBJECT: 'INPUT_OBJECT',
  15841. INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
  15842. });
  15843. /**
  15844. * The enum type representing the directive location values.
  15845. */
  15846. exports.DirectiveLocation = DirectiveLocation;
  15847. },{}],50:[function(require,module,exports){
  15848. "use strict";
  15849. Object.defineProperty(exports, "__esModule", {
  15850. value: true
  15851. });
  15852. Object.defineProperty(exports, "Source", {
  15853. enumerable: true,
  15854. get: function get() {
  15855. return _source.Source;
  15856. }
  15857. });
  15858. Object.defineProperty(exports, "getLocation", {
  15859. enumerable: true,
  15860. get: function get() {
  15861. return _location.getLocation;
  15862. }
  15863. });
  15864. Object.defineProperty(exports, "Kind", {
  15865. enumerable: true,
  15866. get: function get() {
  15867. return _kinds.Kind;
  15868. }
  15869. });
  15870. Object.defineProperty(exports, "createLexer", {
  15871. enumerable: true,
  15872. get: function get() {
  15873. return _lexer.createLexer;
  15874. }
  15875. });
  15876. Object.defineProperty(exports, "TokenKind", {
  15877. enumerable: true,
  15878. get: function get() {
  15879. return _lexer.TokenKind;
  15880. }
  15881. });
  15882. Object.defineProperty(exports, "parse", {
  15883. enumerable: true,
  15884. get: function get() {
  15885. return _parser.parse;
  15886. }
  15887. });
  15888. Object.defineProperty(exports, "parseValue", {
  15889. enumerable: true,
  15890. get: function get() {
  15891. return _parser.parseValue;
  15892. }
  15893. });
  15894. Object.defineProperty(exports, "parseType", {
  15895. enumerable: true,
  15896. get: function get() {
  15897. return _parser.parseType;
  15898. }
  15899. });
  15900. Object.defineProperty(exports, "print", {
  15901. enumerable: true,
  15902. get: function get() {
  15903. return _printer.print;
  15904. }
  15905. });
  15906. Object.defineProperty(exports, "visit", {
  15907. enumerable: true,
  15908. get: function get() {
  15909. return _visitor.visit;
  15910. }
  15911. });
  15912. Object.defineProperty(exports, "visitInParallel", {
  15913. enumerable: true,
  15914. get: function get() {
  15915. return _visitor.visitInParallel;
  15916. }
  15917. });
  15918. Object.defineProperty(exports, "visitWithTypeInfo", {
  15919. enumerable: true,
  15920. get: function get() {
  15921. return _visitor.visitWithTypeInfo;
  15922. }
  15923. });
  15924. Object.defineProperty(exports, "getVisitFn", {
  15925. enumerable: true,
  15926. get: function get() {
  15927. return _visitor.getVisitFn;
  15928. }
  15929. });
  15930. Object.defineProperty(exports, "BREAK", {
  15931. enumerable: true,
  15932. get: function get() {
  15933. return _visitor.BREAK;
  15934. }
  15935. });
  15936. Object.defineProperty(exports, "isDefinitionNode", {
  15937. enumerable: true,
  15938. get: function get() {
  15939. return _predicates.isDefinitionNode;
  15940. }
  15941. });
  15942. Object.defineProperty(exports, "isExecutableDefinitionNode", {
  15943. enumerable: true,
  15944. get: function get() {
  15945. return _predicates.isExecutableDefinitionNode;
  15946. }
  15947. });
  15948. Object.defineProperty(exports, "isSelectionNode", {
  15949. enumerable: true,
  15950. get: function get() {
  15951. return _predicates.isSelectionNode;
  15952. }
  15953. });
  15954. Object.defineProperty(exports, "isValueNode", {
  15955. enumerable: true,
  15956. get: function get() {
  15957. return _predicates.isValueNode;
  15958. }
  15959. });
  15960. Object.defineProperty(exports, "isTypeNode", {
  15961. enumerable: true,
  15962. get: function get() {
  15963. return _predicates.isTypeNode;
  15964. }
  15965. });
  15966. Object.defineProperty(exports, "isTypeSystemDefinitionNode", {
  15967. enumerable: true,
  15968. get: function get() {
  15969. return _predicates.isTypeSystemDefinitionNode;
  15970. }
  15971. });
  15972. Object.defineProperty(exports, "isTypeDefinitionNode", {
  15973. enumerable: true,
  15974. get: function get() {
  15975. return _predicates.isTypeDefinitionNode;
  15976. }
  15977. });
  15978. Object.defineProperty(exports, "isTypeSystemExtensionNode", {
  15979. enumerable: true,
  15980. get: function get() {
  15981. return _predicates.isTypeSystemExtensionNode;
  15982. }
  15983. });
  15984. Object.defineProperty(exports, "isTypeExtensionNode", {
  15985. enumerable: true,
  15986. get: function get() {
  15987. return _predicates.isTypeExtensionNode;
  15988. }
  15989. });
  15990. Object.defineProperty(exports, "DirectiveLocation", {
  15991. enumerable: true,
  15992. get: function get() {
  15993. return _directiveLocation.DirectiveLocation;
  15994. }
  15995. });
  15996. var _source = require("./source");
  15997. var _location = require("./location");
  15998. var _kinds = require("./kinds");
  15999. var _lexer = require("./lexer");
  16000. var _parser = require("./parser");
  16001. var _printer = require("./printer");
  16002. var _visitor = require("./visitor");
  16003. var _predicates = require("./predicates");
  16004. var _directiveLocation = require("./directiveLocation");
  16005. },{"./directiveLocation":49,"./kinds":51,"./lexer":52,"./location":53,"./parser":54,"./predicates":55,"./printer":56,"./source":57,"./visitor":58}],51:[function(require,module,exports){
  16006. "use strict";
  16007. Object.defineProperty(exports, "__esModule", {
  16008. value: true
  16009. });
  16010. exports.Kind = void 0;
  16011. /**
  16012. * Copyright (c) Facebook, Inc. and its affiliates.
  16013. *
  16014. * This source code is licensed under the MIT license found in the
  16015. * LICENSE file in the root directory of this source tree.
  16016. *
  16017. *
  16018. */
  16019. /**
  16020. * The set of allowed kind values for AST nodes.
  16021. */
  16022. var Kind = Object.freeze({
  16023. // Name
  16024. NAME: 'Name',
  16025. // Document
  16026. DOCUMENT: 'Document',
  16027. OPERATION_DEFINITION: 'OperationDefinition',
  16028. VARIABLE_DEFINITION: 'VariableDefinition',
  16029. SELECTION_SET: 'SelectionSet',
  16030. FIELD: 'Field',
  16031. ARGUMENT: 'Argument',
  16032. // Fragments
  16033. FRAGMENT_SPREAD: 'FragmentSpread',
  16034. INLINE_FRAGMENT: 'InlineFragment',
  16035. FRAGMENT_DEFINITION: 'FragmentDefinition',
  16036. // Values
  16037. VARIABLE: 'Variable',
  16038. INT: 'IntValue',
  16039. FLOAT: 'FloatValue',
  16040. STRING: 'StringValue',
  16041. BOOLEAN: 'BooleanValue',
  16042. NULL: 'NullValue',
  16043. ENUM: 'EnumValue',
  16044. LIST: 'ListValue',
  16045. OBJECT: 'ObjectValue',
  16046. OBJECT_FIELD: 'ObjectField',
  16047. // Directives
  16048. DIRECTIVE: 'Directive',
  16049. // Types
  16050. NAMED_TYPE: 'NamedType',
  16051. LIST_TYPE: 'ListType',
  16052. NON_NULL_TYPE: 'NonNullType',
  16053. // Type System Definitions
  16054. SCHEMA_DEFINITION: 'SchemaDefinition',
  16055. OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
  16056. // Type Definitions
  16057. SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
  16058. OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
  16059. FIELD_DEFINITION: 'FieldDefinition',
  16060. INPUT_VALUE_DEFINITION: 'InputValueDefinition',
  16061. INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
  16062. UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
  16063. ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
  16064. ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
  16065. INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
  16066. // Directive Definitions
  16067. DIRECTIVE_DEFINITION: 'DirectiveDefinition',
  16068. // Type System Extensions
  16069. SCHEMA_EXTENSION: 'SchemaExtension',
  16070. // Type Extensions
  16071. SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
  16072. OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
  16073. INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
  16074. UNION_TYPE_EXTENSION: 'UnionTypeExtension',
  16075. ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
  16076. INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
  16077. });
  16078. /**
  16079. * The enum type representing the possible kind values of AST nodes.
  16080. */
  16081. exports.Kind = Kind;
  16082. },{}],52:[function(require,module,exports){
  16083. "use strict";
  16084. Object.defineProperty(exports, "__esModule", {
  16085. value: true
  16086. });
  16087. exports.createLexer = createLexer;
  16088. exports.isPunctuatorToken = isPunctuatorToken;
  16089. exports.getTokenDesc = getTokenDesc;
  16090. exports.TokenKind = void 0;
  16091. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  16092. var _error = require("../error");
  16093. var _blockString = require("./blockString");
  16094. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16095. /**
  16096. * Copyright (c) Facebook, Inc. and its affiliates.
  16097. *
  16098. * This source code is licensed under the MIT license found in the
  16099. * LICENSE file in the root directory of this source tree.
  16100. *
  16101. *
  16102. */
  16103. /**
  16104. * Given a Source object, this returns a Lexer for that source.
  16105. * A Lexer is a stateful stream generator in that every time
  16106. * it is advanced, it returns the next token in the Source. Assuming the
  16107. * source lexes, the final Token emitted by the lexer will be of kind
  16108. * EOF, after which the lexer will repeatedly return the same EOF token
  16109. * whenever called.
  16110. */
  16111. function createLexer(source, options) {
  16112. var startOfFileToken = new Tok(TokenKind.SOF, 0, 0, 0, 0, null);
  16113. var lexer = {
  16114. source: source,
  16115. options: options,
  16116. lastToken: startOfFileToken,
  16117. token: startOfFileToken,
  16118. line: 1,
  16119. lineStart: 0,
  16120. advance: advanceLexer,
  16121. lookahead: lookahead
  16122. };
  16123. return lexer;
  16124. }
  16125. function advanceLexer() {
  16126. this.lastToken = this.token;
  16127. var token = this.token = this.lookahead();
  16128. return token;
  16129. }
  16130. function lookahead() {
  16131. var token = this.token;
  16132. if (token.kind !== TokenKind.EOF) {
  16133. do {
  16134. // Note: next is only mutable during parsing, so we cast to allow this.
  16135. token = token.next || (token.next = readToken(this, token));
  16136. } while (token.kind === TokenKind.COMMENT);
  16137. }
  16138. return token;
  16139. }
  16140. /**
  16141. * The return type of createLexer.
  16142. */
  16143. /**
  16144. * An exported enum describing the different kinds of tokens that the
  16145. * lexer emits.
  16146. */
  16147. var TokenKind = Object.freeze({
  16148. SOF: '<SOF>',
  16149. EOF: '<EOF>',
  16150. BANG: '!',
  16151. DOLLAR: '$',
  16152. AMP: '&',
  16153. PAREN_L: '(',
  16154. PAREN_R: ')',
  16155. SPREAD: '...',
  16156. COLON: ':',
  16157. EQUALS: '=',
  16158. AT: '@',
  16159. BRACKET_L: '[',
  16160. BRACKET_R: ']',
  16161. BRACE_L: '{',
  16162. PIPE: '|',
  16163. BRACE_R: '}',
  16164. NAME: 'Name',
  16165. INT: 'Int',
  16166. FLOAT: 'Float',
  16167. STRING: 'String',
  16168. BLOCK_STRING: 'BlockString',
  16169. COMMENT: 'Comment'
  16170. });
  16171. /**
  16172. * The enum type representing the token kinds values.
  16173. */
  16174. exports.TokenKind = TokenKind;
  16175. // @internal
  16176. function isPunctuatorToken(token) {
  16177. var kind = token.kind;
  16178. return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
  16179. }
  16180. /**
  16181. * A helper function to describe a token as a string for debugging
  16182. */
  16183. function getTokenDesc(token) {
  16184. var value = token.value;
  16185. return value ? "".concat(token.kind, " \"").concat(value, "\"") : token.kind;
  16186. }
  16187. /**
  16188. * Helper function for constructing the Token object.
  16189. */
  16190. function Tok(kind, start, end, line, column, prev, value) {
  16191. this.kind = kind;
  16192. this.start = start;
  16193. this.end = end;
  16194. this.line = line;
  16195. this.column = column;
  16196. this.value = value;
  16197. this.prev = prev;
  16198. this.next = null;
  16199. } // Print a simplified form when appearing in JSON/util.inspect.
  16200. (0, _defineToJSON.default)(Tok, function () {
  16201. return {
  16202. kind: this.kind,
  16203. value: this.value,
  16204. line: this.line,
  16205. column: this.column
  16206. };
  16207. });
  16208. function printCharCode(code) {
  16209. return (// NaN/undefined represents access beyond the end of the file.
  16210. isNaN(code) ? TokenKind.EOF : // Trust JSON for ASCII.
  16211. code < 0x007f ? JSON.stringify(String.fromCharCode(code)) : // Otherwise print the escaped form.
  16212. "\"\\u".concat(('00' + code.toString(16).toUpperCase()).slice(-4), "\"")
  16213. );
  16214. }
  16215. /**
  16216. * Gets the next token from the source starting at the given position.
  16217. *
  16218. * This skips over whitespace until it finds the next lexable token, then lexes
  16219. * punctuators immediately or calls the appropriate helper function for more
  16220. * complicated tokens.
  16221. */
  16222. function readToken(lexer, prev) {
  16223. var source = lexer.source;
  16224. var body = source.body;
  16225. var bodyLength = body.length;
  16226. var pos = positionAfterWhitespace(body, prev.end, lexer);
  16227. var line = lexer.line;
  16228. var col = 1 + pos - lexer.lineStart;
  16229. if (pos >= bodyLength) {
  16230. return new Tok(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
  16231. }
  16232. var code = body.charCodeAt(pos); // SourceCharacter
  16233. switch (code) {
  16234. // !
  16235. case 33:
  16236. return new Tok(TokenKind.BANG, pos, pos + 1, line, col, prev);
  16237. // #
  16238. case 35:
  16239. return readComment(source, pos, line, col, prev);
  16240. // $
  16241. case 36:
  16242. return new Tok(TokenKind.DOLLAR, pos, pos + 1, line, col, prev);
  16243. // &
  16244. case 38:
  16245. return new Tok(TokenKind.AMP, pos, pos + 1, line, col, prev);
  16246. // (
  16247. case 40:
  16248. return new Tok(TokenKind.PAREN_L, pos, pos + 1, line, col, prev);
  16249. // )
  16250. case 41:
  16251. return new Tok(TokenKind.PAREN_R, pos, pos + 1, line, col, prev);
  16252. // .
  16253. case 46:
  16254. if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {
  16255. return new Tok(TokenKind.SPREAD, pos, pos + 3, line, col, prev);
  16256. }
  16257. break;
  16258. // :
  16259. case 58:
  16260. return new Tok(TokenKind.COLON, pos, pos + 1, line, col, prev);
  16261. // =
  16262. case 61:
  16263. return new Tok(TokenKind.EQUALS, pos, pos + 1, line, col, prev);
  16264. // @
  16265. case 64:
  16266. return new Tok(TokenKind.AT, pos, pos + 1, line, col, prev);
  16267. // [
  16268. case 91:
  16269. return new Tok(TokenKind.BRACKET_L, pos, pos + 1, line, col, prev);
  16270. // ]
  16271. case 93:
  16272. return new Tok(TokenKind.BRACKET_R, pos, pos + 1, line, col, prev);
  16273. // {
  16274. case 123:
  16275. return new Tok(TokenKind.BRACE_L, pos, pos + 1, line, col, prev);
  16276. // |
  16277. case 124:
  16278. return new Tok(TokenKind.PIPE, pos, pos + 1, line, col, prev);
  16279. // }
  16280. case 125:
  16281. return new Tok(TokenKind.BRACE_R, pos, pos + 1, line, col, prev);
  16282. // A-Z _ a-z
  16283. case 65:
  16284. case 66:
  16285. case 67:
  16286. case 68:
  16287. case 69:
  16288. case 70:
  16289. case 71:
  16290. case 72:
  16291. case 73:
  16292. case 74:
  16293. case 75:
  16294. case 76:
  16295. case 77:
  16296. case 78:
  16297. case 79:
  16298. case 80:
  16299. case 81:
  16300. case 82:
  16301. case 83:
  16302. case 84:
  16303. case 85:
  16304. case 86:
  16305. case 87:
  16306. case 88:
  16307. case 89:
  16308. case 90:
  16309. case 95:
  16310. case 97:
  16311. case 98:
  16312. case 99:
  16313. case 100:
  16314. case 101:
  16315. case 102:
  16316. case 103:
  16317. case 104:
  16318. case 105:
  16319. case 106:
  16320. case 107:
  16321. case 108:
  16322. case 109:
  16323. case 110:
  16324. case 111:
  16325. case 112:
  16326. case 113:
  16327. case 114:
  16328. case 115:
  16329. case 116:
  16330. case 117:
  16331. case 118:
  16332. case 119:
  16333. case 120:
  16334. case 121:
  16335. case 122:
  16336. return readName(source, pos, line, col, prev);
  16337. // - 0-9
  16338. case 45:
  16339. case 48:
  16340. case 49:
  16341. case 50:
  16342. case 51:
  16343. case 52:
  16344. case 53:
  16345. case 54:
  16346. case 55:
  16347. case 56:
  16348. case 57:
  16349. return readNumber(source, pos, code, line, col, prev);
  16350. // "
  16351. case 34:
  16352. if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {
  16353. return readBlockString(source, pos, line, col, prev, lexer);
  16354. }
  16355. return readString(source, pos, line, col, prev);
  16356. }
  16357. throw (0, _error.syntaxError)(source, pos, unexpectedCharacterMessage(code));
  16358. }
  16359. /**
  16360. * Report a message that an unexpected character was encountered.
  16361. */
  16362. function unexpectedCharacterMessage(code) {
  16363. if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
  16364. return "Cannot contain the invalid character ".concat(printCharCode(code), ".");
  16365. }
  16366. if (code === 39) {
  16367. // '
  16368. return "Unexpected single quote character ('), did you mean to use " + 'a double quote (")?';
  16369. }
  16370. return "Cannot parse the unexpected character ".concat(printCharCode(code), ".");
  16371. }
  16372. /**
  16373. * Reads from body starting at startPosition until it finds a non-whitespace
  16374. * character, then returns the position of that character for lexing.
  16375. */
  16376. function positionAfterWhitespace(body, startPosition, lexer) {
  16377. var bodyLength = body.length;
  16378. var position = startPosition;
  16379. while (position < bodyLength) {
  16380. var code = body.charCodeAt(position); // tab | space | comma | BOM
  16381. if (code === 9 || code === 32 || code === 44 || code === 0xfeff) {
  16382. ++position;
  16383. } else if (code === 10) {
  16384. // new line
  16385. ++position;
  16386. ++lexer.line;
  16387. lexer.lineStart = position;
  16388. } else if (code === 13) {
  16389. // carriage return
  16390. if (body.charCodeAt(position + 1) === 10) {
  16391. position += 2;
  16392. } else {
  16393. ++position;
  16394. }
  16395. ++lexer.line;
  16396. lexer.lineStart = position;
  16397. } else {
  16398. break;
  16399. }
  16400. }
  16401. return position;
  16402. }
  16403. /**
  16404. * Reads a comment token from the source file.
  16405. *
  16406. * #[\u0009\u0020-\uFFFF]*
  16407. */
  16408. function readComment(source, start, line, col, prev) {
  16409. var body = source.body;
  16410. var code;
  16411. var position = start;
  16412. do {
  16413. code = body.charCodeAt(++position);
  16414. } while (!isNaN(code) && ( // SourceCharacter but not LineTerminator
  16415. code > 0x001f || code === 0x0009));
  16416. return new Tok(TokenKind.COMMENT, start, position, line, col, prev, body.slice(start + 1, position));
  16417. }
  16418. /**
  16419. * Reads a number token from the source file, either a float
  16420. * or an int depending on whether a decimal point appears.
  16421. *
  16422. * Int: -?(0|[1-9][0-9]*)
  16423. * Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
  16424. */
  16425. function readNumber(source, start, firstCode, line, col, prev) {
  16426. var body = source.body;
  16427. var code = firstCode;
  16428. var position = start;
  16429. var isFloat = false;
  16430. if (code === 45) {
  16431. // -
  16432. code = body.charCodeAt(++position);
  16433. }
  16434. if (code === 48) {
  16435. // 0
  16436. code = body.charCodeAt(++position);
  16437. if (code >= 48 && code <= 57) {
  16438. throw (0, _error.syntaxError)(source, position, "Invalid number, unexpected digit after 0: ".concat(printCharCode(code), "."));
  16439. }
  16440. } else {
  16441. position = readDigits(source, position, code);
  16442. code = body.charCodeAt(position);
  16443. }
  16444. if (code === 46) {
  16445. // .
  16446. isFloat = true;
  16447. code = body.charCodeAt(++position);
  16448. position = readDigits(source, position, code);
  16449. code = body.charCodeAt(position);
  16450. }
  16451. if (code === 69 || code === 101) {
  16452. // E e
  16453. isFloat = true;
  16454. code = body.charCodeAt(++position);
  16455. if (code === 43 || code === 45) {
  16456. // + -
  16457. code = body.charCodeAt(++position);
  16458. }
  16459. position = readDigits(source, position, code);
  16460. }
  16461. return new Tok(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, body.slice(start, position));
  16462. }
  16463. /**
  16464. * Returns the new position in the source after reading digits.
  16465. */
  16466. function readDigits(source, start, firstCode) {
  16467. var body = source.body;
  16468. var position = start;
  16469. var code = firstCode;
  16470. if (code >= 48 && code <= 57) {
  16471. // 0 - 9
  16472. do {
  16473. code = body.charCodeAt(++position);
  16474. } while (code >= 48 && code <= 57); // 0 - 9
  16475. return position;
  16476. }
  16477. throw (0, _error.syntaxError)(source, position, "Invalid number, expected digit but got: ".concat(printCharCode(code), "."));
  16478. }
  16479. /**
  16480. * Reads a string token from the source file.
  16481. *
  16482. * "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
  16483. */
  16484. function readString(source, start, line, col, prev) {
  16485. var body = source.body;
  16486. var position = start + 1;
  16487. var chunkStart = position;
  16488. var code = 0;
  16489. var value = '';
  16490. while (position < body.length && !isNaN(code = body.charCodeAt(position)) && // not LineTerminator
  16491. code !== 0x000a && code !== 0x000d) {
  16492. // Closing Quote (")
  16493. if (code === 34) {
  16494. value += body.slice(chunkStart, position);
  16495. return new Tok(TokenKind.STRING, start, position + 1, line, col, prev, value);
  16496. } // SourceCharacter
  16497. if (code < 0x0020 && code !== 0x0009) {
  16498. throw (0, _error.syntaxError)(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
  16499. }
  16500. ++position;
  16501. if (code === 92) {
  16502. // \
  16503. value += body.slice(chunkStart, position - 1);
  16504. code = body.charCodeAt(position);
  16505. switch (code) {
  16506. case 34:
  16507. value += '"';
  16508. break;
  16509. case 47:
  16510. value += '/';
  16511. break;
  16512. case 92:
  16513. value += '\\';
  16514. break;
  16515. case 98:
  16516. value += '\b';
  16517. break;
  16518. case 102:
  16519. value += '\f';
  16520. break;
  16521. case 110:
  16522. value += '\n';
  16523. break;
  16524. case 114:
  16525. value += '\r';
  16526. break;
  16527. case 116:
  16528. value += '\t';
  16529. break;
  16530. case 117:
  16531. {
  16532. // uXXXX
  16533. var charCode = uniCharCode(body.charCodeAt(position + 1), body.charCodeAt(position + 2), body.charCodeAt(position + 3), body.charCodeAt(position + 4));
  16534. if (charCode < 0) {
  16535. throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + "\\u".concat(body.slice(position + 1, position + 5), "."));
  16536. }
  16537. value += String.fromCharCode(charCode);
  16538. position += 4;
  16539. break;
  16540. }
  16541. default:
  16542. throw (0, _error.syntaxError)(source, position, "Invalid character escape sequence: \\".concat(String.fromCharCode(code), "."));
  16543. }
  16544. ++position;
  16545. chunkStart = position;
  16546. }
  16547. }
  16548. throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
  16549. }
  16550. /**
  16551. * Reads a block string token from the source file.
  16552. *
  16553. * """("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
  16554. */
  16555. function readBlockString(source, start, line, col, prev, lexer) {
  16556. var body = source.body;
  16557. var position = start + 3;
  16558. var chunkStart = position;
  16559. var code = 0;
  16560. var rawValue = '';
  16561. while (position < body.length && !isNaN(code = body.charCodeAt(position))) {
  16562. // Closing Triple-Quote (""")
  16563. if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
  16564. rawValue += body.slice(chunkStart, position);
  16565. return new Tok(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, (0, _blockString.dedentBlockStringValue)(rawValue));
  16566. } // SourceCharacter
  16567. if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
  16568. throw (0, _error.syntaxError)(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
  16569. }
  16570. if (code === 10) {
  16571. // new line
  16572. ++position;
  16573. ++lexer.line;
  16574. lexer.lineStart = position;
  16575. } else if (code === 13) {
  16576. // carriage return
  16577. if (body.charCodeAt(position + 1) === 10) {
  16578. position += 2;
  16579. } else {
  16580. ++position;
  16581. }
  16582. ++lexer.line;
  16583. lexer.lineStart = position;
  16584. } else if ( // Escape Triple-Quote (\""")
  16585. code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
  16586. rawValue += body.slice(chunkStart, position) + '"""';
  16587. position += 4;
  16588. chunkStart = position;
  16589. } else {
  16590. ++position;
  16591. }
  16592. }
  16593. throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
  16594. }
  16595. /**
  16596. * Converts four hexadecimal chars to the integer that the
  16597. * string represents. For example, uniCharCode('0','0','0','f')
  16598. * will return 15, and uniCharCode('0','0','f','f') returns 255.
  16599. *
  16600. * Returns a negative number on error, if a char was invalid.
  16601. *
  16602. * This is implemented by noting that char2hex() returns -1 on error,
  16603. * which means the result of ORing the char2hex() will also be negative.
  16604. */
  16605. function uniCharCode(a, b, c, d) {
  16606. return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
  16607. }
  16608. /**
  16609. * Converts a hex character to its integer value.
  16610. * '0' becomes 0, '9' becomes 9
  16611. * 'A' becomes 10, 'F' becomes 15
  16612. * 'a' becomes 10, 'f' becomes 15
  16613. *
  16614. * Returns -1 on error.
  16615. */
  16616. function char2hex(a) {
  16617. return a >= 48 && a <= 57 ? a - 48 // 0-9
  16618. : a >= 65 && a <= 70 ? a - 55 // A-F
  16619. : a >= 97 && a <= 102 ? a - 87 // a-f
  16620. : -1;
  16621. }
  16622. /**
  16623. * Reads an alphanumeric + underscore name from the source.
  16624. *
  16625. * [_A-Za-z][_0-9A-Za-z]*
  16626. */
  16627. function readName(source, start, line, col, prev) {
  16628. var body = source.body;
  16629. var bodyLength = body.length;
  16630. var position = start + 1;
  16631. var code = 0;
  16632. while (position !== bodyLength && !isNaN(code = body.charCodeAt(position)) && (code === 95 || // _
  16633. code >= 48 && code <= 57 || // 0-9
  16634. code >= 65 && code <= 90 || // A-Z
  16635. code >= 97 && code <= 122) // a-z
  16636. ) {
  16637. ++position;
  16638. }
  16639. return new Tok(TokenKind.NAME, start, position, line, col, prev, body.slice(start, position));
  16640. }
  16641. },{"../error":21,"../jsutils/defineToJSON":30,"./blockString":48}],53:[function(require,module,exports){
  16642. "use strict";
  16643. Object.defineProperty(exports, "__esModule", {
  16644. value: true
  16645. });
  16646. exports.getLocation = getLocation;
  16647. /**
  16648. * Copyright (c) Facebook, Inc. and its affiliates.
  16649. *
  16650. * This source code is licensed under the MIT license found in the
  16651. * LICENSE file in the root directory of this source tree.
  16652. *
  16653. *
  16654. */
  16655. /**
  16656. * Represents a location in a Source.
  16657. */
  16658. /**
  16659. * Takes a Source and a UTF-8 character offset, and returns the corresponding
  16660. * line and column as a SourceLocation.
  16661. */
  16662. function getLocation(source, position) {
  16663. var lineRegexp = /\r\n|[\n\r]/g;
  16664. var line = 1;
  16665. var column = position + 1;
  16666. var match;
  16667. while ((match = lineRegexp.exec(source.body)) && match.index < position) {
  16668. line += 1;
  16669. column = position + 1 - (match.index + match[0].length);
  16670. }
  16671. return {
  16672. line: line,
  16673. column: column
  16674. };
  16675. }
  16676. },{}],54:[function(require,module,exports){
  16677. "use strict";
  16678. Object.defineProperty(exports, "__esModule", {
  16679. value: true
  16680. });
  16681. exports.parse = parse;
  16682. exports.parseValue = parseValue;
  16683. exports.parseType = parseType;
  16684. exports.parseConstValue = parseConstValue;
  16685. exports.parseTypeReference = parseTypeReference;
  16686. exports.parseNamedType = parseNamedType;
  16687. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  16688. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  16689. var _source = require("./source");
  16690. var _error = require("../error");
  16691. var _lexer = require("./lexer");
  16692. var _kinds = require("./kinds");
  16693. var _directiveLocation = require("./directiveLocation");
  16694. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16695. /**
  16696. * Copyright (c) Facebook, Inc. and its affiliates.
  16697. *
  16698. * This source code is licensed under the MIT license found in the
  16699. * LICENSE file in the root directory of this source tree.
  16700. *
  16701. *
  16702. */
  16703. /**
  16704. * Given a GraphQL source, parses it into a Document.
  16705. * Throws GraphQLError if a syntax error is encountered.
  16706. */
  16707. function parse(source, options) {
  16708. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  16709. if (!(sourceObj instanceof _source.Source)) {
  16710. throw new TypeError("Must provide Source. Received: ".concat((0, _inspect.default)(sourceObj)));
  16711. }
  16712. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  16713. return parseDocument(lexer);
  16714. }
  16715. /**
  16716. * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
  16717. * that value.
  16718. * Throws GraphQLError if a syntax error is encountered.
  16719. *
  16720. * This is useful within tools that operate upon GraphQL Values directly and
  16721. * in isolation of complete GraphQL documents.
  16722. *
  16723. * Consider providing the results to the utility function: valueFromAST().
  16724. */
  16725. function parseValue(source, options) {
  16726. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  16727. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  16728. expectToken(lexer, _lexer.TokenKind.SOF);
  16729. var value = parseValueLiteral(lexer, false);
  16730. expectToken(lexer, _lexer.TokenKind.EOF);
  16731. return value;
  16732. }
  16733. /**
  16734. * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
  16735. * that type.
  16736. * Throws GraphQLError if a syntax error is encountered.
  16737. *
  16738. * This is useful within tools that operate upon GraphQL Types directly and
  16739. * in isolation of complete GraphQL documents.
  16740. *
  16741. * Consider providing the results to the utility function: typeFromAST().
  16742. */
  16743. function parseType(source, options) {
  16744. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  16745. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  16746. expectToken(lexer, _lexer.TokenKind.SOF);
  16747. var type = parseTypeReference(lexer);
  16748. expectToken(lexer, _lexer.TokenKind.EOF);
  16749. return type;
  16750. }
  16751. /**
  16752. * Converts a name lex token into a name parse node.
  16753. */
  16754. function parseName(lexer) {
  16755. var token = expectToken(lexer, _lexer.TokenKind.NAME);
  16756. return {
  16757. kind: _kinds.Kind.NAME,
  16758. value: token.value,
  16759. loc: loc(lexer, token)
  16760. };
  16761. } // Implements the parsing rules in the Document section.
  16762. /**
  16763. * Document : Definition+
  16764. */
  16765. function parseDocument(lexer) {
  16766. var start = lexer.token;
  16767. return {
  16768. kind: _kinds.Kind.DOCUMENT,
  16769. definitions: many(lexer, _lexer.TokenKind.SOF, parseDefinition, _lexer.TokenKind.EOF),
  16770. loc: loc(lexer, start)
  16771. };
  16772. }
  16773. /**
  16774. * Definition :
  16775. * - ExecutableDefinition
  16776. * - TypeSystemDefinition
  16777. * - TypeSystemExtension
  16778. */
  16779. function parseDefinition(lexer) {
  16780. if (peek(lexer, _lexer.TokenKind.NAME)) {
  16781. switch (lexer.token.value) {
  16782. case 'query':
  16783. case 'mutation':
  16784. case 'subscription':
  16785. case 'fragment':
  16786. return parseExecutableDefinition(lexer);
  16787. case 'schema':
  16788. case 'scalar':
  16789. case 'type':
  16790. case 'interface':
  16791. case 'union':
  16792. case 'enum':
  16793. case 'input':
  16794. case 'directive':
  16795. return parseTypeSystemDefinition(lexer);
  16796. case 'extend':
  16797. return parseTypeSystemExtension(lexer);
  16798. }
  16799. } else if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  16800. return parseExecutableDefinition(lexer);
  16801. } else if (peekDescription(lexer)) {
  16802. return parseTypeSystemDefinition(lexer);
  16803. }
  16804. throw unexpected(lexer);
  16805. }
  16806. /**
  16807. * ExecutableDefinition :
  16808. * - OperationDefinition
  16809. * - FragmentDefinition
  16810. */
  16811. function parseExecutableDefinition(lexer) {
  16812. if (peek(lexer, _lexer.TokenKind.NAME)) {
  16813. switch (lexer.token.value) {
  16814. case 'query':
  16815. case 'mutation':
  16816. case 'subscription':
  16817. return parseOperationDefinition(lexer);
  16818. case 'fragment':
  16819. return parseFragmentDefinition(lexer);
  16820. }
  16821. } else if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  16822. return parseOperationDefinition(lexer);
  16823. }
  16824. throw unexpected(lexer);
  16825. } // Implements the parsing rules in the Operations section.
  16826. /**
  16827. * OperationDefinition :
  16828. * - SelectionSet
  16829. * - OperationType Name? VariableDefinitions? Directives? SelectionSet
  16830. */
  16831. function parseOperationDefinition(lexer) {
  16832. var start = lexer.token;
  16833. if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  16834. return {
  16835. kind: _kinds.Kind.OPERATION_DEFINITION,
  16836. operation: 'query',
  16837. name: undefined,
  16838. variableDefinitions: [],
  16839. directives: [],
  16840. selectionSet: parseSelectionSet(lexer),
  16841. loc: loc(lexer, start)
  16842. };
  16843. }
  16844. var operation = parseOperationType(lexer);
  16845. var name;
  16846. if (peek(lexer, _lexer.TokenKind.NAME)) {
  16847. name = parseName(lexer);
  16848. }
  16849. return {
  16850. kind: _kinds.Kind.OPERATION_DEFINITION,
  16851. operation: operation,
  16852. name: name,
  16853. variableDefinitions: parseVariableDefinitions(lexer),
  16854. directives: parseDirectives(lexer, false),
  16855. selectionSet: parseSelectionSet(lexer),
  16856. loc: loc(lexer, start)
  16857. };
  16858. }
  16859. /**
  16860. * OperationType : one of query mutation subscription
  16861. */
  16862. function parseOperationType(lexer) {
  16863. var operationToken = expectToken(lexer, _lexer.TokenKind.NAME);
  16864. switch (operationToken.value) {
  16865. case 'query':
  16866. return 'query';
  16867. case 'mutation':
  16868. return 'mutation';
  16869. case 'subscription':
  16870. return 'subscription';
  16871. }
  16872. throw unexpected(lexer, operationToken);
  16873. }
  16874. /**
  16875. * VariableDefinitions : ( VariableDefinition+ )
  16876. */
  16877. function parseVariableDefinitions(lexer) {
  16878. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : [];
  16879. }
  16880. /**
  16881. * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
  16882. */
  16883. function parseVariableDefinition(lexer) {
  16884. var start = lexer.token;
  16885. return {
  16886. kind: _kinds.Kind.VARIABLE_DEFINITION,
  16887. variable: parseVariable(lexer),
  16888. type: (expectToken(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
  16889. defaultValue: expectOptionalToken(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : undefined,
  16890. directives: parseDirectives(lexer, true),
  16891. loc: loc(lexer, start)
  16892. };
  16893. }
  16894. /**
  16895. * Variable : $ Name
  16896. */
  16897. function parseVariable(lexer) {
  16898. var start = lexer.token;
  16899. expectToken(lexer, _lexer.TokenKind.DOLLAR);
  16900. return {
  16901. kind: _kinds.Kind.VARIABLE,
  16902. name: parseName(lexer),
  16903. loc: loc(lexer, start)
  16904. };
  16905. }
  16906. /**
  16907. * SelectionSet : { Selection+ }
  16908. */
  16909. function parseSelectionSet(lexer) {
  16910. var start = lexer.token;
  16911. return {
  16912. kind: _kinds.Kind.SELECTION_SET,
  16913. selections: many(lexer, _lexer.TokenKind.BRACE_L, parseSelection, _lexer.TokenKind.BRACE_R),
  16914. loc: loc(lexer, start)
  16915. };
  16916. }
  16917. /**
  16918. * Selection :
  16919. * - Field
  16920. * - FragmentSpread
  16921. * - InlineFragment
  16922. */
  16923. function parseSelection(lexer) {
  16924. return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);
  16925. }
  16926. /**
  16927. * Field : Alias? Name Arguments? Directives? SelectionSet?
  16928. *
  16929. * Alias : Name :
  16930. */
  16931. function parseField(lexer) {
  16932. var start = lexer.token;
  16933. var nameOrAlias = parseName(lexer);
  16934. var alias;
  16935. var name;
  16936. if (expectOptionalToken(lexer, _lexer.TokenKind.COLON)) {
  16937. alias = nameOrAlias;
  16938. name = parseName(lexer);
  16939. } else {
  16940. name = nameOrAlias;
  16941. }
  16942. return {
  16943. kind: _kinds.Kind.FIELD,
  16944. alias: alias,
  16945. name: name,
  16946. arguments: parseArguments(lexer, false),
  16947. directives: parseDirectives(lexer, false),
  16948. selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : undefined,
  16949. loc: loc(lexer, start)
  16950. };
  16951. }
  16952. /**
  16953. * Arguments[Const] : ( Argument[?Const]+ )
  16954. */
  16955. function parseArguments(lexer, isConst) {
  16956. var item = isConst ? parseConstArgument : parseArgument;
  16957. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, item, _lexer.TokenKind.PAREN_R) : [];
  16958. }
  16959. /**
  16960. * Argument[Const] : Name : Value[?Const]
  16961. */
  16962. function parseArgument(lexer) {
  16963. var start = lexer.token;
  16964. var name = parseName(lexer);
  16965. expectToken(lexer, _lexer.TokenKind.COLON);
  16966. return {
  16967. kind: _kinds.Kind.ARGUMENT,
  16968. name: name,
  16969. value: parseValueLiteral(lexer, false),
  16970. loc: loc(lexer, start)
  16971. };
  16972. }
  16973. function parseConstArgument(lexer) {
  16974. var start = lexer.token;
  16975. return {
  16976. kind: _kinds.Kind.ARGUMENT,
  16977. name: parseName(lexer),
  16978. value: (expectToken(lexer, _lexer.TokenKind.COLON), parseConstValue(lexer)),
  16979. loc: loc(lexer, start)
  16980. };
  16981. } // Implements the parsing rules in the Fragments section.
  16982. /**
  16983. * Corresponds to both FragmentSpread and InlineFragment in the spec.
  16984. *
  16985. * FragmentSpread : ... FragmentName Directives?
  16986. *
  16987. * InlineFragment : ... TypeCondition? Directives? SelectionSet
  16988. */
  16989. function parseFragment(lexer) {
  16990. var start = lexer.token;
  16991. expectToken(lexer, _lexer.TokenKind.SPREAD);
  16992. var hasTypeCondition = expectOptionalKeyword(lexer, 'on');
  16993. if (!hasTypeCondition && peek(lexer, _lexer.TokenKind.NAME)) {
  16994. return {
  16995. kind: _kinds.Kind.FRAGMENT_SPREAD,
  16996. name: parseFragmentName(lexer),
  16997. directives: parseDirectives(lexer, false),
  16998. loc: loc(lexer, start)
  16999. };
  17000. }
  17001. return {
  17002. kind: _kinds.Kind.INLINE_FRAGMENT,
  17003. typeCondition: hasTypeCondition ? parseNamedType(lexer) : undefined,
  17004. directives: parseDirectives(lexer, false),
  17005. selectionSet: parseSelectionSet(lexer),
  17006. loc: loc(lexer, start)
  17007. };
  17008. }
  17009. /**
  17010. * FragmentDefinition :
  17011. * - fragment FragmentName on TypeCondition Directives? SelectionSet
  17012. *
  17013. * TypeCondition : NamedType
  17014. */
  17015. function parseFragmentDefinition(lexer) {
  17016. var start = lexer.token;
  17017. expectKeyword(lexer, 'fragment'); // Experimental support for defining variables within fragments changes
  17018. // the grammar of FragmentDefinition:
  17019. // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
  17020. if (lexer.options.experimentalFragmentVariables) {
  17021. return {
  17022. kind: _kinds.Kind.FRAGMENT_DEFINITION,
  17023. name: parseFragmentName(lexer),
  17024. variableDefinitions: parseVariableDefinitions(lexer),
  17025. typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
  17026. directives: parseDirectives(lexer, false),
  17027. selectionSet: parseSelectionSet(lexer),
  17028. loc: loc(lexer, start)
  17029. };
  17030. }
  17031. return {
  17032. kind: _kinds.Kind.FRAGMENT_DEFINITION,
  17033. name: parseFragmentName(lexer),
  17034. typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
  17035. directives: parseDirectives(lexer, false),
  17036. selectionSet: parseSelectionSet(lexer),
  17037. loc: loc(lexer, start)
  17038. };
  17039. }
  17040. /**
  17041. * FragmentName : Name but not `on`
  17042. */
  17043. function parseFragmentName(lexer) {
  17044. if (lexer.token.value === 'on') {
  17045. throw unexpected(lexer);
  17046. }
  17047. return parseName(lexer);
  17048. } // Implements the parsing rules in the Values section.
  17049. /**
  17050. * Value[Const] :
  17051. * - [~Const] Variable
  17052. * - IntValue
  17053. * - FloatValue
  17054. * - StringValue
  17055. * - BooleanValue
  17056. * - NullValue
  17057. * - EnumValue
  17058. * - ListValue[?Const]
  17059. * - ObjectValue[?Const]
  17060. *
  17061. * BooleanValue : one of `true` `false`
  17062. *
  17063. * NullValue : `null`
  17064. *
  17065. * EnumValue : Name but not `true`, `false` or `null`
  17066. */
  17067. function parseValueLiteral(lexer, isConst) {
  17068. var token = lexer.token;
  17069. switch (token.kind) {
  17070. case _lexer.TokenKind.BRACKET_L:
  17071. return parseList(lexer, isConst);
  17072. case _lexer.TokenKind.BRACE_L:
  17073. return parseObject(lexer, isConst);
  17074. case _lexer.TokenKind.INT:
  17075. lexer.advance();
  17076. return {
  17077. kind: _kinds.Kind.INT,
  17078. value: token.value,
  17079. loc: loc(lexer, token)
  17080. };
  17081. case _lexer.TokenKind.FLOAT:
  17082. lexer.advance();
  17083. return {
  17084. kind: _kinds.Kind.FLOAT,
  17085. value: token.value,
  17086. loc: loc(lexer, token)
  17087. };
  17088. case _lexer.TokenKind.STRING:
  17089. case _lexer.TokenKind.BLOCK_STRING:
  17090. return parseStringLiteral(lexer);
  17091. case _lexer.TokenKind.NAME:
  17092. if (token.value === 'true' || token.value === 'false') {
  17093. lexer.advance();
  17094. return {
  17095. kind: _kinds.Kind.BOOLEAN,
  17096. value: token.value === 'true',
  17097. loc: loc(lexer, token)
  17098. };
  17099. } else if (token.value === 'null') {
  17100. lexer.advance();
  17101. return {
  17102. kind: _kinds.Kind.NULL,
  17103. loc: loc(lexer, token)
  17104. };
  17105. }
  17106. lexer.advance();
  17107. return {
  17108. kind: _kinds.Kind.ENUM,
  17109. value: token.value,
  17110. loc: loc(lexer, token)
  17111. };
  17112. case _lexer.TokenKind.DOLLAR:
  17113. if (!isConst) {
  17114. return parseVariable(lexer);
  17115. }
  17116. break;
  17117. }
  17118. throw unexpected(lexer);
  17119. }
  17120. function parseStringLiteral(lexer) {
  17121. var token = lexer.token;
  17122. lexer.advance();
  17123. return {
  17124. kind: _kinds.Kind.STRING,
  17125. value: token.value,
  17126. block: token.kind === _lexer.TokenKind.BLOCK_STRING,
  17127. loc: loc(lexer, token)
  17128. };
  17129. }
  17130. function parseConstValue(lexer) {
  17131. return parseValueLiteral(lexer, true);
  17132. }
  17133. function parseValueValue(lexer) {
  17134. return parseValueLiteral(lexer, false);
  17135. }
  17136. /**
  17137. * ListValue[Const] :
  17138. * - [ ]
  17139. * - [ Value[?Const]+ ]
  17140. */
  17141. function parseList(lexer, isConst) {
  17142. var start = lexer.token;
  17143. var item = isConst ? parseConstValue : parseValueValue;
  17144. return {
  17145. kind: _kinds.Kind.LIST,
  17146. values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R),
  17147. loc: loc(lexer, start)
  17148. };
  17149. }
  17150. /**
  17151. * ObjectValue[Const] :
  17152. * - { }
  17153. * - { ObjectField[?Const]+ }
  17154. */
  17155. function parseObject(lexer, isConst) {
  17156. var start = lexer.token;
  17157. var item = function item() {
  17158. return parseObjectField(lexer, isConst);
  17159. };
  17160. return {
  17161. kind: _kinds.Kind.OBJECT,
  17162. fields: any(lexer, _lexer.TokenKind.BRACE_L, item, _lexer.TokenKind.BRACE_R),
  17163. loc: loc(lexer, start)
  17164. };
  17165. }
  17166. /**
  17167. * ObjectField[Const] : Name : Value[?Const]
  17168. */
  17169. function parseObjectField(lexer, isConst) {
  17170. var start = lexer.token;
  17171. var name = parseName(lexer);
  17172. expectToken(lexer, _lexer.TokenKind.COLON);
  17173. return {
  17174. kind: _kinds.Kind.OBJECT_FIELD,
  17175. name: name,
  17176. value: parseValueLiteral(lexer, isConst),
  17177. loc: loc(lexer, start)
  17178. };
  17179. } // Implements the parsing rules in the Directives section.
  17180. /**
  17181. * Directives[Const] : Directive[?Const]+
  17182. */
  17183. function parseDirectives(lexer, isConst) {
  17184. var directives = [];
  17185. while (peek(lexer, _lexer.TokenKind.AT)) {
  17186. directives.push(parseDirective(lexer, isConst));
  17187. }
  17188. return directives;
  17189. }
  17190. /**
  17191. * Directive[Const] : @ Name Arguments[?Const]?
  17192. */
  17193. function parseDirective(lexer, isConst) {
  17194. var start = lexer.token;
  17195. expectToken(lexer, _lexer.TokenKind.AT);
  17196. return {
  17197. kind: _kinds.Kind.DIRECTIVE,
  17198. name: parseName(lexer),
  17199. arguments: parseArguments(lexer, isConst),
  17200. loc: loc(lexer, start)
  17201. };
  17202. } // Implements the parsing rules in the Types section.
  17203. /**
  17204. * Type :
  17205. * - NamedType
  17206. * - ListType
  17207. * - NonNullType
  17208. */
  17209. function parseTypeReference(lexer) {
  17210. var start = lexer.token;
  17211. var type;
  17212. if (expectOptionalToken(lexer, _lexer.TokenKind.BRACKET_L)) {
  17213. type = parseTypeReference(lexer);
  17214. expectToken(lexer, _lexer.TokenKind.BRACKET_R);
  17215. type = {
  17216. kind: _kinds.Kind.LIST_TYPE,
  17217. type: type,
  17218. loc: loc(lexer, start)
  17219. };
  17220. } else {
  17221. type = parseNamedType(lexer);
  17222. }
  17223. if (expectOptionalToken(lexer, _lexer.TokenKind.BANG)) {
  17224. return {
  17225. kind: _kinds.Kind.NON_NULL_TYPE,
  17226. type: type,
  17227. loc: loc(lexer, start)
  17228. };
  17229. }
  17230. return type;
  17231. }
  17232. /**
  17233. * NamedType : Name
  17234. */
  17235. function parseNamedType(lexer) {
  17236. var start = lexer.token;
  17237. return {
  17238. kind: _kinds.Kind.NAMED_TYPE,
  17239. name: parseName(lexer),
  17240. loc: loc(lexer, start)
  17241. };
  17242. } // Implements the parsing rules in the Type Definition section.
  17243. /**
  17244. * TypeSystemDefinition :
  17245. * - SchemaDefinition
  17246. * - TypeDefinition
  17247. * - DirectiveDefinition
  17248. *
  17249. * TypeDefinition :
  17250. * - ScalarTypeDefinition
  17251. * - ObjectTypeDefinition
  17252. * - InterfaceTypeDefinition
  17253. * - UnionTypeDefinition
  17254. * - EnumTypeDefinition
  17255. * - InputObjectTypeDefinition
  17256. */
  17257. function parseTypeSystemDefinition(lexer) {
  17258. // Many definitions begin with a description and require a lookahead.
  17259. var keywordToken = peekDescription(lexer) ? lexer.lookahead() : lexer.token;
  17260. if (keywordToken.kind === _lexer.TokenKind.NAME) {
  17261. switch (keywordToken.value) {
  17262. case 'schema':
  17263. return parseSchemaDefinition(lexer);
  17264. case 'scalar':
  17265. return parseScalarTypeDefinition(lexer);
  17266. case 'type':
  17267. return parseObjectTypeDefinition(lexer);
  17268. case 'interface':
  17269. return parseInterfaceTypeDefinition(lexer);
  17270. case 'union':
  17271. return parseUnionTypeDefinition(lexer);
  17272. case 'enum':
  17273. return parseEnumTypeDefinition(lexer);
  17274. case 'input':
  17275. return parseInputObjectTypeDefinition(lexer);
  17276. case 'directive':
  17277. return parseDirectiveDefinition(lexer);
  17278. }
  17279. }
  17280. throw unexpected(lexer, keywordToken);
  17281. }
  17282. function peekDescription(lexer) {
  17283. return peek(lexer, _lexer.TokenKind.STRING) || peek(lexer, _lexer.TokenKind.BLOCK_STRING);
  17284. }
  17285. /**
  17286. * Description : StringValue
  17287. */
  17288. function parseDescription(lexer) {
  17289. if (peekDescription(lexer)) {
  17290. return parseStringLiteral(lexer);
  17291. }
  17292. }
  17293. /**
  17294. * SchemaDefinition : schema Directives[Const]? { OperationTypeDefinition+ }
  17295. */
  17296. function parseSchemaDefinition(lexer) {
  17297. var start = lexer.token;
  17298. expectKeyword(lexer, 'schema');
  17299. var directives = parseDirectives(lexer, true);
  17300. var operationTypes = many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R);
  17301. return {
  17302. kind: _kinds.Kind.SCHEMA_DEFINITION,
  17303. directives: directives,
  17304. operationTypes: operationTypes,
  17305. loc: loc(lexer, start)
  17306. };
  17307. }
  17308. /**
  17309. * OperationTypeDefinition : OperationType : NamedType
  17310. */
  17311. function parseOperationTypeDefinition(lexer) {
  17312. var start = lexer.token;
  17313. var operation = parseOperationType(lexer);
  17314. expectToken(lexer, _lexer.TokenKind.COLON);
  17315. var type = parseNamedType(lexer);
  17316. return {
  17317. kind: _kinds.Kind.OPERATION_TYPE_DEFINITION,
  17318. operation: operation,
  17319. type: type,
  17320. loc: loc(lexer, start)
  17321. };
  17322. }
  17323. /**
  17324. * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
  17325. */
  17326. function parseScalarTypeDefinition(lexer) {
  17327. var start = lexer.token;
  17328. var description = parseDescription(lexer);
  17329. expectKeyword(lexer, 'scalar');
  17330. var name = parseName(lexer);
  17331. var directives = parseDirectives(lexer, true);
  17332. return {
  17333. kind: _kinds.Kind.SCALAR_TYPE_DEFINITION,
  17334. description: description,
  17335. name: name,
  17336. directives: directives,
  17337. loc: loc(lexer, start)
  17338. };
  17339. }
  17340. /**
  17341. * ObjectTypeDefinition :
  17342. * Description?
  17343. * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
  17344. */
  17345. function parseObjectTypeDefinition(lexer) {
  17346. var start = lexer.token;
  17347. var description = parseDescription(lexer);
  17348. expectKeyword(lexer, 'type');
  17349. var name = parseName(lexer);
  17350. var interfaces = parseImplementsInterfaces(lexer);
  17351. var directives = parseDirectives(lexer, true);
  17352. var fields = parseFieldsDefinition(lexer);
  17353. return {
  17354. kind: _kinds.Kind.OBJECT_TYPE_DEFINITION,
  17355. description: description,
  17356. name: name,
  17357. interfaces: interfaces,
  17358. directives: directives,
  17359. fields: fields,
  17360. loc: loc(lexer, start)
  17361. };
  17362. }
  17363. /**
  17364. * ImplementsInterfaces :
  17365. * - implements `&`? NamedType
  17366. * - ImplementsInterfaces & NamedType
  17367. */
  17368. function parseImplementsInterfaces(lexer) {
  17369. var types = [];
  17370. if (expectOptionalKeyword(lexer, 'implements')) {
  17371. // Optional leading ampersand
  17372. expectOptionalToken(lexer, _lexer.TokenKind.AMP);
  17373. do {
  17374. types.push(parseNamedType(lexer));
  17375. } while (expectOptionalToken(lexer, _lexer.TokenKind.AMP) || // Legacy support for the SDL?
  17376. lexer.options.allowLegacySDLImplementsInterfaces && peek(lexer, _lexer.TokenKind.NAME));
  17377. }
  17378. return types;
  17379. }
  17380. /**
  17381. * FieldsDefinition : { FieldDefinition+ }
  17382. */
  17383. function parseFieldsDefinition(lexer) {
  17384. // Legacy support for the SDL?
  17385. if (lexer.options.allowLegacySDLEmptyFields && peek(lexer, _lexer.TokenKind.BRACE_L) && lexer.lookahead().kind === _lexer.TokenKind.BRACE_R) {
  17386. lexer.advance();
  17387. lexer.advance();
  17388. return [];
  17389. }
  17390. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R) : [];
  17391. }
  17392. /**
  17393. * FieldDefinition :
  17394. * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
  17395. */
  17396. function parseFieldDefinition(lexer) {
  17397. var start = lexer.token;
  17398. var description = parseDescription(lexer);
  17399. var name = parseName(lexer);
  17400. var args = parseArgumentDefs(lexer);
  17401. expectToken(lexer, _lexer.TokenKind.COLON);
  17402. var type = parseTypeReference(lexer);
  17403. var directives = parseDirectives(lexer, true);
  17404. return {
  17405. kind: _kinds.Kind.FIELD_DEFINITION,
  17406. description: description,
  17407. name: name,
  17408. arguments: args,
  17409. type: type,
  17410. directives: directives,
  17411. loc: loc(lexer, start)
  17412. };
  17413. }
  17414. /**
  17415. * ArgumentsDefinition : ( InputValueDefinition+ )
  17416. */
  17417. function parseArgumentDefs(lexer) {
  17418. if (!peek(lexer, _lexer.TokenKind.PAREN_L)) {
  17419. return [];
  17420. }
  17421. return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R);
  17422. }
  17423. /**
  17424. * InputValueDefinition :
  17425. * - Description? Name : Type DefaultValue? Directives[Const]?
  17426. */
  17427. function parseInputValueDef(lexer) {
  17428. var start = lexer.token;
  17429. var description = parseDescription(lexer);
  17430. var name = parseName(lexer);
  17431. expectToken(lexer, _lexer.TokenKind.COLON);
  17432. var type = parseTypeReference(lexer);
  17433. var defaultValue;
  17434. if (expectOptionalToken(lexer, _lexer.TokenKind.EQUALS)) {
  17435. defaultValue = parseConstValue(lexer);
  17436. }
  17437. var directives = parseDirectives(lexer, true);
  17438. return {
  17439. kind: _kinds.Kind.INPUT_VALUE_DEFINITION,
  17440. description: description,
  17441. name: name,
  17442. type: type,
  17443. defaultValue: defaultValue,
  17444. directives: directives,
  17445. loc: loc(lexer, start)
  17446. };
  17447. }
  17448. /**
  17449. * InterfaceTypeDefinition :
  17450. * - Description? interface Name Directives[Const]? FieldsDefinition?
  17451. */
  17452. function parseInterfaceTypeDefinition(lexer) {
  17453. var start = lexer.token;
  17454. var description = parseDescription(lexer);
  17455. expectKeyword(lexer, 'interface');
  17456. var name = parseName(lexer);
  17457. var directives = parseDirectives(lexer, true);
  17458. var fields = parseFieldsDefinition(lexer);
  17459. return {
  17460. kind: _kinds.Kind.INTERFACE_TYPE_DEFINITION,
  17461. description: description,
  17462. name: name,
  17463. directives: directives,
  17464. fields: fields,
  17465. loc: loc(lexer, start)
  17466. };
  17467. }
  17468. /**
  17469. * UnionTypeDefinition :
  17470. * - Description? union Name Directives[Const]? UnionMemberTypes?
  17471. */
  17472. function parseUnionTypeDefinition(lexer) {
  17473. var start = lexer.token;
  17474. var description = parseDescription(lexer);
  17475. expectKeyword(lexer, 'union');
  17476. var name = parseName(lexer);
  17477. var directives = parseDirectives(lexer, true);
  17478. var types = parseUnionMemberTypes(lexer);
  17479. return {
  17480. kind: _kinds.Kind.UNION_TYPE_DEFINITION,
  17481. description: description,
  17482. name: name,
  17483. directives: directives,
  17484. types: types,
  17485. loc: loc(lexer, start)
  17486. };
  17487. }
  17488. /**
  17489. * UnionMemberTypes :
  17490. * - = `|`? NamedType
  17491. * - UnionMemberTypes | NamedType
  17492. */
  17493. function parseUnionMemberTypes(lexer) {
  17494. var types = [];
  17495. if (expectOptionalToken(lexer, _lexer.TokenKind.EQUALS)) {
  17496. // Optional leading pipe
  17497. expectOptionalToken(lexer, _lexer.TokenKind.PIPE);
  17498. do {
  17499. types.push(parseNamedType(lexer));
  17500. } while (expectOptionalToken(lexer, _lexer.TokenKind.PIPE));
  17501. }
  17502. return types;
  17503. }
  17504. /**
  17505. * EnumTypeDefinition :
  17506. * - Description? enum Name Directives[Const]? EnumValuesDefinition?
  17507. */
  17508. function parseEnumTypeDefinition(lexer) {
  17509. var start = lexer.token;
  17510. var description = parseDescription(lexer);
  17511. expectKeyword(lexer, 'enum');
  17512. var name = parseName(lexer);
  17513. var directives = parseDirectives(lexer, true);
  17514. var values = parseEnumValuesDefinition(lexer);
  17515. return {
  17516. kind: _kinds.Kind.ENUM_TYPE_DEFINITION,
  17517. description: description,
  17518. name: name,
  17519. directives: directives,
  17520. values: values,
  17521. loc: loc(lexer, start)
  17522. };
  17523. }
  17524. /**
  17525. * EnumValuesDefinition : { EnumValueDefinition+ }
  17526. */
  17527. function parseEnumValuesDefinition(lexer) {
  17528. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseEnumValueDefinition, _lexer.TokenKind.BRACE_R) : [];
  17529. }
  17530. /**
  17531. * EnumValueDefinition : Description? EnumValue Directives[Const]?
  17532. *
  17533. * EnumValue : Name
  17534. */
  17535. function parseEnumValueDefinition(lexer) {
  17536. var start = lexer.token;
  17537. var description = parseDescription(lexer);
  17538. var name = parseName(lexer);
  17539. var directives = parseDirectives(lexer, true);
  17540. return {
  17541. kind: _kinds.Kind.ENUM_VALUE_DEFINITION,
  17542. description: description,
  17543. name: name,
  17544. directives: directives,
  17545. loc: loc(lexer, start)
  17546. };
  17547. }
  17548. /**
  17549. * InputObjectTypeDefinition :
  17550. * - Description? input Name Directives[Const]? InputFieldsDefinition?
  17551. */
  17552. function parseInputObjectTypeDefinition(lexer) {
  17553. var start = lexer.token;
  17554. var description = parseDescription(lexer);
  17555. expectKeyword(lexer, 'input');
  17556. var name = parseName(lexer);
  17557. var directives = parseDirectives(lexer, true);
  17558. var fields = parseInputFieldsDefinition(lexer);
  17559. return {
  17560. kind: _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION,
  17561. description: description,
  17562. name: name,
  17563. directives: directives,
  17564. fields: fields,
  17565. loc: loc(lexer, start)
  17566. };
  17567. }
  17568. /**
  17569. * InputFieldsDefinition : { InputValueDefinition+ }
  17570. */
  17571. function parseInputFieldsDefinition(lexer) {
  17572. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseInputValueDef, _lexer.TokenKind.BRACE_R) : [];
  17573. }
  17574. /**
  17575. * TypeSystemExtension :
  17576. * - SchemaExtension
  17577. * - TypeExtension
  17578. *
  17579. * TypeExtension :
  17580. * - ScalarTypeExtension
  17581. * - ObjectTypeExtension
  17582. * - InterfaceTypeExtension
  17583. * - UnionTypeExtension
  17584. * - EnumTypeExtension
  17585. * - InputObjectTypeDefinition
  17586. */
  17587. function parseTypeSystemExtension(lexer) {
  17588. var keywordToken = lexer.lookahead();
  17589. if (keywordToken.kind === _lexer.TokenKind.NAME) {
  17590. switch (keywordToken.value) {
  17591. case 'schema':
  17592. return parseSchemaExtension(lexer);
  17593. case 'scalar':
  17594. return parseScalarTypeExtension(lexer);
  17595. case 'type':
  17596. return parseObjectTypeExtension(lexer);
  17597. case 'interface':
  17598. return parseInterfaceTypeExtension(lexer);
  17599. case 'union':
  17600. return parseUnionTypeExtension(lexer);
  17601. case 'enum':
  17602. return parseEnumTypeExtension(lexer);
  17603. case 'input':
  17604. return parseInputObjectTypeExtension(lexer);
  17605. }
  17606. }
  17607. throw unexpected(lexer, keywordToken);
  17608. }
  17609. /**
  17610. * SchemaExtension :
  17611. * - extend schema Directives[Const]? { OperationTypeDefinition+ }
  17612. * - extend schema Directives[Const]
  17613. */
  17614. function parseSchemaExtension(lexer) {
  17615. var start = lexer.token;
  17616. expectKeyword(lexer, 'extend');
  17617. expectKeyword(lexer, 'schema');
  17618. var directives = parseDirectives(lexer, true);
  17619. var operationTypes = peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R) : [];
  17620. if (directives.length === 0 && operationTypes.length === 0) {
  17621. throw unexpected(lexer);
  17622. }
  17623. return {
  17624. kind: _kinds.Kind.SCHEMA_EXTENSION,
  17625. directives: directives,
  17626. operationTypes: operationTypes,
  17627. loc: loc(lexer, start)
  17628. };
  17629. }
  17630. /**
  17631. * ScalarTypeExtension :
  17632. * - extend scalar Name Directives[Const]
  17633. */
  17634. function parseScalarTypeExtension(lexer) {
  17635. var start = lexer.token;
  17636. expectKeyword(lexer, 'extend');
  17637. expectKeyword(lexer, 'scalar');
  17638. var name = parseName(lexer);
  17639. var directives = parseDirectives(lexer, true);
  17640. if (directives.length === 0) {
  17641. throw unexpected(lexer);
  17642. }
  17643. return {
  17644. kind: _kinds.Kind.SCALAR_TYPE_EXTENSION,
  17645. name: name,
  17646. directives: directives,
  17647. loc: loc(lexer, start)
  17648. };
  17649. }
  17650. /**
  17651. * ObjectTypeExtension :
  17652. * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
  17653. * - extend type Name ImplementsInterfaces? Directives[Const]
  17654. * - extend type Name ImplementsInterfaces
  17655. */
  17656. function parseObjectTypeExtension(lexer) {
  17657. var start = lexer.token;
  17658. expectKeyword(lexer, 'extend');
  17659. expectKeyword(lexer, 'type');
  17660. var name = parseName(lexer);
  17661. var interfaces = parseImplementsInterfaces(lexer);
  17662. var directives = parseDirectives(lexer, true);
  17663. var fields = parseFieldsDefinition(lexer);
  17664. if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
  17665. throw unexpected(lexer);
  17666. }
  17667. return {
  17668. kind: _kinds.Kind.OBJECT_TYPE_EXTENSION,
  17669. name: name,
  17670. interfaces: interfaces,
  17671. directives: directives,
  17672. fields: fields,
  17673. loc: loc(lexer, start)
  17674. };
  17675. }
  17676. /**
  17677. * InterfaceTypeExtension :
  17678. * - extend interface Name Directives[Const]? FieldsDefinition
  17679. * - extend interface Name Directives[Const]
  17680. */
  17681. function parseInterfaceTypeExtension(lexer) {
  17682. var start = lexer.token;
  17683. expectKeyword(lexer, 'extend');
  17684. expectKeyword(lexer, 'interface');
  17685. var name = parseName(lexer);
  17686. var directives = parseDirectives(lexer, true);
  17687. var fields = parseFieldsDefinition(lexer);
  17688. if (directives.length === 0 && fields.length === 0) {
  17689. throw unexpected(lexer);
  17690. }
  17691. return {
  17692. kind: _kinds.Kind.INTERFACE_TYPE_EXTENSION,
  17693. name: name,
  17694. directives: directives,
  17695. fields: fields,
  17696. loc: loc(lexer, start)
  17697. };
  17698. }
  17699. /**
  17700. * UnionTypeExtension :
  17701. * - extend union Name Directives[Const]? UnionMemberTypes
  17702. * - extend union Name Directives[Const]
  17703. */
  17704. function parseUnionTypeExtension(lexer) {
  17705. var start = lexer.token;
  17706. expectKeyword(lexer, 'extend');
  17707. expectKeyword(lexer, 'union');
  17708. var name = parseName(lexer);
  17709. var directives = parseDirectives(lexer, true);
  17710. var types = parseUnionMemberTypes(lexer);
  17711. if (directives.length === 0 && types.length === 0) {
  17712. throw unexpected(lexer);
  17713. }
  17714. return {
  17715. kind: _kinds.Kind.UNION_TYPE_EXTENSION,
  17716. name: name,
  17717. directives: directives,
  17718. types: types,
  17719. loc: loc(lexer, start)
  17720. };
  17721. }
  17722. /**
  17723. * EnumTypeExtension :
  17724. * - extend enum Name Directives[Const]? EnumValuesDefinition
  17725. * - extend enum Name Directives[Const]
  17726. */
  17727. function parseEnumTypeExtension(lexer) {
  17728. var start = lexer.token;
  17729. expectKeyword(lexer, 'extend');
  17730. expectKeyword(lexer, 'enum');
  17731. var name = parseName(lexer);
  17732. var directives = parseDirectives(lexer, true);
  17733. var values = parseEnumValuesDefinition(lexer);
  17734. if (directives.length === 0 && values.length === 0) {
  17735. throw unexpected(lexer);
  17736. }
  17737. return {
  17738. kind: _kinds.Kind.ENUM_TYPE_EXTENSION,
  17739. name: name,
  17740. directives: directives,
  17741. values: values,
  17742. loc: loc(lexer, start)
  17743. };
  17744. }
  17745. /**
  17746. * InputObjectTypeExtension :
  17747. * - extend input Name Directives[Const]? InputFieldsDefinition
  17748. * - extend input Name Directives[Const]
  17749. */
  17750. function parseInputObjectTypeExtension(lexer) {
  17751. var start = lexer.token;
  17752. expectKeyword(lexer, 'extend');
  17753. expectKeyword(lexer, 'input');
  17754. var name = parseName(lexer);
  17755. var directives = parseDirectives(lexer, true);
  17756. var fields = parseInputFieldsDefinition(lexer);
  17757. if (directives.length === 0 && fields.length === 0) {
  17758. throw unexpected(lexer);
  17759. }
  17760. return {
  17761. kind: _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION,
  17762. name: name,
  17763. directives: directives,
  17764. fields: fields,
  17765. loc: loc(lexer, start)
  17766. };
  17767. }
  17768. /**
  17769. * DirectiveDefinition :
  17770. * - Description? directive @ Name ArgumentsDefinition? on DirectiveLocations
  17771. */
  17772. function parseDirectiveDefinition(lexer) {
  17773. var start = lexer.token;
  17774. var description = parseDescription(lexer);
  17775. expectKeyword(lexer, 'directive');
  17776. expectToken(lexer, _lexer.TokenKind.AT);
  17777. var name = parseName(lexer);
  17778. var args = parseArgumentDefs(lexer);
  17779. expectKeyword(lexer, 'on');
  17780. var locations = parseDirectiveLocations(lexer);
  17781. return {
  17782. kind: _kinds.Kind.DIRECTIVE_DEFINITION,
  17783. description: description,
  17784. name: name,
  17785. arguments: args,
  17786. locations: locations,
  17787. loc: loc(lexer, start)
  17788. };
  17789. }
  17790. /**
  17791. * DirectiveLocations :
  17792. * - `|`? DirectiveLocation
  17793. * - DirectiveLocations | DirectiveLocation
  17794. */
  17795. function parseDirectiveLocations(lexer) {
  17796. // Optional leading pipe
  17797. expectOptionalToken(lexer, _lexer.TokenKind.PIPE);
  17798. var locations = [];
  17799. do {
  17800. locations.push(parseDirectiveLocation(lexer));
  17801. } while (expectOptionalToken(lexer, _lexer.TokenKind.PIPE));
  17802. return locations;
  17803. }
  17804. /*
  17805. * DirectiveLocation :
  17806. * - ExecutableDirectiveLocation
  17807. * - TypeSystemDirectiveLocation
  17808. *
  17809. * ExecutableDirectiveLocation : one of
  17810. * `QUERY`
  17811. * `MUTATION`
  17812. * `SUBSCRIPTION`
  17813. * `FIELD`
  17814. * `FRAGMENT_DEFINITION`
  17815. * `FRAGMENT_SPREAD`
  17816. * `INLINE_FRAGMENT`
  17817. *
  17818. * TypeSystemDirectiveLocation : one of
  17819. * `SCHEMA`
  17820. * `SCALAR`
  17821. * `OBJECT`
  17822. * `FIELD_DEFINITION`
  17823. * `ARGUMENT_DEFINITION`
  17824. * `INTERFACE`
  17825. * `UNION`
  17826. * `ENUM`
  17827. * `ENUM_VALUE`
  17828. * `INPUT_OBJECT`
  17829. * `INPUT_FIELD_DEFINITION`
  17830. */
  17831. function parseDirectiveLocation(lexer) {
  17832. var start = lexer.token;
  17833. var name = parseName(lexer);
  17834. if (_directiveLocation.DirectiveLocation[name.value] !== undefined) {
  17835. return name;
  17836. }
  17837. throw unexpected(lexer, start);
  17838. } // Core parsing utility functions
  17839. /**
  17840. * Returns a location object, used to identify the place in
  17841. * the source that created a given parsed object.
  17842. */
  17843. function loc(lexer, startToken) {
  17844. if (!lexer.options.noLocation) {
  17845. return new Loc(startToken, lexer.lastToken, lexer.source);
  17846. }
  17847. }
  17848. function Loc(startToken, endToken, source) {
  17849. this.start = startToken.start;
  17850. this.end = endToken.end;
  17851. this.startToken = startToken;
  17852. this.endToken = endToken;
  17853. this.source = source;
  17854. } // Print a simplified form when appearing in JSON/util.inspect.
  17855. (0, _defineToJSON.default)(Loc, function () {
  17856. return {
  17857. start: this.start,
  17858. end: this.end
  17859. };
  17860. });
  17861. /**
  17862. * Determines if the next token is of a given kind
  17863. */
  17864. function peek(lexer, kind) {
  17865. return lexer.token.kind === kind;
  17866. }
  17867. /**
  17868. * If the next token is of the given kind, return that token after advancing
  17869. * the lexer. Otherwise, do not change the parser state and throw an error.
  17870. */
  17871. function expectToken(lexer, kind) {
  17872. var token = lexer.token;
  17873. if (token.kind === kind) {
  17874. lexer.advance();
  17875. return token;
  17876. }
  17877. throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
  17878. }
  17879. /**
  17880. * If the next token is of the given kind, return that token after advancing
  17881. * the lexer. Otherwise, do not change the parser state and return undefined.
  17882. */
  17883. function expectOptionalToken(lexer, kind) {
  17884. var token = lexer.token;
  17885. if (token.kind === kind) {
  17886. lexer.advance();
  17887. return token;
  17888. }
  17889. return undefined;
  17890. }
  17891. /**
  17892. * If the next token is a given keyword, return that token after advancing
  17893. * the lexer. Otherwise, do not change the parser state and throw an error.
  17894. */
  17895. function expectKeyword(lexer, value) {
  17896. var token = lexer.token;
  17897. if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
  17898. lexer.advance();
  17899. return token;
  17900. }
  17901. throw (0, _error.syntaxError)(lexer.source, token.start, "Expected \"".concat(value, "\", found ").concat((0, _lexer.getTokenDesc)(token)));
  17902. }
  17903. /**
  17904. * If the next token is a given keyword, return that token after advancing
  17905. * the lexer. Otherwise, do not change the parser state and return undefined.
  17906. */
  17907. function expectOptionalKeyword(lexer, value) {
  17908. var token = lexer.token;
  17909. if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
  17910. lexer.advance();
  17911. return token;
  17912. }
  17913. return undefined;
  17914. }
  17915. /**
  17916. * Helper function for creating an error when an unexpected lexed token
  17917. * is encountered.
  17918. */
  17919. function unexpected(lexer, atToken) {
  17920. var token = atToken || lexer.token;
  17921. return (0, _error.syntaxError)(lexer.source, token.start, "Unexpected ".concat((0, _lexer.getTokenDesc)(token)));
  17922. }
  17923. /**
  17924. * Returns a possibly empty list of parse nodes, determined by
  17925. * the parseFn. This list begins with a lex token of openKind
  17926. * and ends with a lex token of closeKind. Advances the parser
  17927. * to the next lex token after the closing token.
  17928. */
  17929. function any(lexer, openKind, parseFn, closeKind) {
  17930. expectToken(lexer, openKind);
  17931. var nodes = [];
  17932. while (!expectOptionalToken(lexer, closeKind)) {
  17933. nodes.push(parseFn(lexer));
  17934. }
  17935. return nodes;
  17936. }
  17937. /**
  17938. * Returns a non-empty list of parse nodes, determined by
  17939. * the parseFn. This list begins with a lex token of openKind
  17940. * and ends with a lex token of closeKind. Advances the parser
  17941. * to the next lex token after the closing token.
  17942. */
  17943. function many(lexer, openKind, parseFn, closeKind) {
  17944. expectToken(lexer, openKind);
  17945. var nodes = [parseFn(lexer)];
  17946. while (!expectOptionalToken(lexer, closeKind)) {
  17947. nodes.push(parseFn(lexer));
  17948. }
  17949. return nodes;
  17950. }
  17951. },{"../error":21,"../jsutils/defineToJSON":30,"../jsutils/inspect":32,"./directiveLocation":49,"./kinds":51,"./lexer":52,"./source":57}],55:[function(require,module,exports){
  17952. "use strict";
  17953. Object.defineProperty(exports, "__esModule", {
  17954. value: true
  17955. });
  17956. exports.isDefinitionNode = isDefinitionNode;
  17957. exports.isExecutableDefinitionNode = isExecutableDefinitionNode;
  17958. exports.isSelectionNode = isSelectionNode;
  17959. exports.isValueNode = isValueNode;
  17960. exports.isTypeNode = isTypeNode;
  17961. exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode;
  17962. exports.isTypeDefinitionNode = isTypeDefinitionNode;
  17963. exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode;
  17964. exports.isTypeExtensionNode = isTypeExtensionNode;
  17965. var _kinds = require("./kinds");
  17966. /**
  17967. * Copyright (c) Facebook, Inc. and its affiliates.
  17968. *
  17969. * This source code is licensed under the MIT license found in the
  17970. * LICENSE file in the root directory of this source tree.
  17971. *
  17972. *
  17973. */
  17974. function isDefinitionNode(node) {
  17975. return isExecutableDefinitionNode(node) || isTypeSystemDefinitionNode(node) || isTypeSystemExtensionNode(node);
  17976. }
  17977. function isExecutableDefinitionNode(node) {
  17978. return node.kind === _kinds.Kind.OPERATION_DEFINITION || node.kind === _kinds.Kind.FRAGMENT_DEFINITION;
  17979. }
  17980. function isSelectionNode(node) {
  17981. return node.kind === _kinds.Kind.FIELD || node.kind === _kinds.Kind.FRAGMENT_SPREAD || node.kind === _kinds.Kind.INLINE_FRAGMENT;
  17982. }
  17983. function isValueNode(node) {
  17984. return node.kind === _kinds.Kind.VARIABLE || node.kind === _kinds.Kind.INT || node.kind === _kinds.Kind.FLOAT || node.kind === _kinds.Kind.STRING || node.kind === _kinds.Kind.BOOLEAN || node.kind === _kinds.Kind.NULL || node.kind === _kinds.Kind.ENUM || node.kind === _kinds.Kind.LIST || node.kind === _kinds.Kind.OBJECT;
  17985. }
  17986. function isTypeNode(node) {
  17987. return node.kind === _kinds.Kind.NAMED_TYPE || node.kind === _kinds.Kind.LIST_TYPE || node.kind === _kinds.Kind.NON_NULL_TYPE;
  17988. }
  17989. function isTypeSystemDefinitionNode(node) {
  17990. return node.kind === _kinds.Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === _kinds.Kind.DIRECTIVE_DEFINITION;
  17991. }
  17992. function isTypeDefinitionNode(node) {
  17993. return node.kind === _kinds.Kind.SCALAR_TYPE_DEFINITION || node.kind === _kinds.Kind.OBJECT_TYPE_DEFINITION || node.kind === _kinds.Kind.INTERFACE_TYPE_DEFINITION || node.kind === _kinds.Kind.UNION_TYPE_DEFINITION || node.kind === _kinds.Kind.ENUM_TYPE_DEFINITION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION;
  17994. }
  17995. function isTypeSystemExtensionNode(node) {
  17996. return node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
  17997. }
  17998. function isTypeExtensionNode(node) {
  17999. return node.kind === _kinds.Kind.SCALAR_TYPE_EXTENSION || node.kind === _kinds.Kind.OBJECT_TYPE_EXTENSION || node.kind === _kinds.Kind.INTERFACE_TYPE_EXTENSION || node.kind === _kinds.Kind.UNION_TYPE_EXTENSION || node.kind === _kinds.Kind.ENUM_TYPE_EXTENSION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION;
  18000. }
  18001. },{"./kinds":51}],56:[function(require,module,exports){
  18002. "use strict";
  18003. Object.defineProperty(exports, "__esModule", {
  18004. value: true
  18005. });
  18006. exports.print = print;
  18007. var _visitor = require("./visitor");
  18008. var _blockString = require("./blockString");
  18009. /**
  18010. * Copyright (c) Facebook, Inc. and its affiliates.
  18011. *
  18012. * This source code is licensed under the MIT license found in the
  18013. * LICENSE file in the root directory of this source tree.
  18014. *
  18015. *
  18016. */
  18017. /**
  18018. * Converts an AST into a string, using one set of reasonable
  18019. * formatting rules.
  18020. */
  18021. function print(ast) {
  18022. return (0, _visitor.visit)(ast, {
  18023. leave: printDocASTReducer
  18024. });
  18025. } // TODO: provide better type coverage in future
  18026. var printDocASTReducer = {
  18027. Name: function Name(node) {
  18028. return node.value;
  18029. },
  18030. Variable: function Variable(node) {
  18031. return '$' + node.name;
  18032. },
  18033. // Document
  18034. Document: function Document(node) {
  18035. return join(node.definitions, '\n\n') + '\n';
  18036. },
  18037. OperationDefinition: function OperationDefinition(node) {
  18038. var op = node.operation;
  18039. var name = node.name;
  18040. var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
  18041. var directives = join(node.directives, ' ');
  18042. var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
  18043. // the query short form.
  18044. return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
  18045. },
  18046. VariableDefinition: function VariableDefinition(_ref) {
  18047. var variable = _ref.variable,
  18048. type = _ref.type,
  18049. defaultValue = _ref.defaultValue,
  18050. directives = _ref.directives;
  18051. return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
  18052. },
  18053. SelectionSet: function SelectionSet(_ref2) {
  18054. var selections = _ref2.selections;
  18055. return block(selections);
  18056. },
  18057. Field: function Field(_ref3) {
  18058. var alias = _ref3.alias,
  18059. name = _ref3.name,
  18060. args = _ref3.arguments,
  18061. directives = _ref3.directives,
  18062. selectionSet = _ref3.selectionSet;
  18063. return join([wrap('', alias, ': ') + name + wrap('(', join(args, ', '), ')'), join(directives, ' '), selectionSet], ' ');
  18064. },
  18065. Argument: function Argument(_ref4) {
  18066. var name = _ref4.name,
  18067. value = _ref4.value;
  18068. return name + ': ' + value;
  18069. },
  18070. // Fragments
  18071. FragmentSpread: function FragmentSpread(_ref5) {
  18072. var name = _ref5.name,
  18073. directives = _ref5.directives;
  18074. return '...' + name + wrap(' ', join(directives, ' '));
  18075. },
  18076. InlineFragment: function InlineFragment(_ref6) {
  18077. var typeCondition = _ref6.typeCondition,
  18078. directives = _ref6.directives,
  18079. selectionSet = _ref6.selectionSet;
  18080. return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
  18081. },
  18082. FragmentDefinition: function FragmentDefinition(_ref7) {
  18083. var name = _ref7.name,
  18084. typeCondition = _ref7.typeCondition,
  18085. variableDefinitions = _ref7.variableDefinitions,
  18086. directives = _ref7.directives,
  18087. selectionSet = _ref7.selectionSet;
  18088. return (// Note: fragment variable definitions are experimental and may be changed
  18089. // or removed in the future.
  18090. "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
  18091. );
  18092. },
  18093. // Value
  18094. IntValue: function IntValue(_ref8) {
  18095. var value = _ref8.value;
  18096. return value;
  18097. },
  18098. FloatValue: function FloatValue(_ref9) {
  18099. var value = _ref9.value;
  18100. return value;
  18101. },
  18102. StringValue: function StringValue(_ref10, key) {
  18103. var value = _ref10.value,
  18104. isBlockString = _ref10.block;
  18105. return isBlockString ? (0, _blockString.printBlockString)(value, key === 'description' ? '' : ' ') : JSON.stringify(value);
  18106. },
  18107. BooleanValue: function BooleanValue(_ref11) {
  18108. var value = _ref11.value;
  18109. return value ? 'true' : 'false';
  18110. },
  18111. NullValue: function NullValue() {
  18112. return 'null';
  18113. },
  18114. EnumValue: function EnumValue(_ref12) {
  18115. var value = _ref12.value;
  18116. return value;
  18117. },
  18118. ListValue: function ListValue(_ref13) {
  18119. var values = _ref13.values;
  18120. return '[' + join(values, ', ') + ']';
  18121. },
  18122. ObjectValue: function ObjectValue(_ref14) {
  18123. var fields = _ref14.fields;
  18124. return '{' + join(fields, ', ') + '}';
  18125. },
  18126. ObjectField: function ObjectField(_ref15) {
  18127. var name = _ref15.name,
  18128. value = _ref15.value;
  18129. return name + ': ' + value;
  18130. },
  18131. // Directive
  18132. Directive: function Directive(_ref16) {
  18133. var name = _ref16.name,
  18134. args = _ref16.arguments;
  18135. return '@' + name + wrap('(', join(args, ', '), ')');
  18136. },
  18137. // Type
  18138. NamedType: function NamedType(_ref17) {
  18139. var name = _ref17.name;
  18140. return name;
  18141. },
  18142. ListType: function ListType(_ref18) {
  18143. var type = _ref18.type;
  18144. return '[' + type + ']';
  18145. },
  18146. NonNullType: function NonNullType(_ref19) {
  18147. var type = _ref19.type;
  18148. return type + '!';
  18149. },
  18150. // Type System Definitions
  18151. SchemaDefinition: function SchemaDefinition(_ref20) {
  18152. var directives = _ref20.directives,
  18153. operationTypes = _ref20.operationTypes;
  18154. return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
  18155. },
  18156. OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
  18157. var operation = _ref21.operation,
  18158. type = _ref21.type;
  18159. return operation + ': ' + type;
  18160. },
  18161. ScalarTypeDefinition: addDescription(function (_ref22) {
  18162. var name = _ref22.name,
  18163. directives = _ref22.directives;
  18164. return join(['scalar', name, join(directives, ' ')], ' ');
  18165. }),
  18166. ObjectTypeDefinition: addDescription(function (_ref23) {
  18167. var name = _ref23.name,
  18168. interfaces = _ref23.interfaces,
  18169. directives = _ref23.directives,
  18170. fields = _ref23.fields;
  18171. return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  18172. }),
  18173. FieldDefinition: addDescription(function (_ref24) {
  18174. var name = _ref24.name,
  18175. args = _ref24.arguments,
  18176. type = _ref24.type,
  18177. directives = _ref24.directives;
  18178. return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
  18179. }),
  18180. InputValueDefinition: addDescription(function (_ref25) {
  18181. var name = _ref25.name,
  18182. type = _ref25.type,
  18183. defaultValue = _ref25.defaultValue,
  18184. directives = _ref25.directives;
  18185. return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
  18186. }),
  18187. InterfaceTypeDefinition: addDescription(function (_ref26) {
  18188. var name = _ref26.name,
  18189. directives = _ref26.directives,
  18190. fields = _ref26.fields;
  18191. return join(['interface', name, join(directives, ' '), block(fields)], ' ');
  18192. }),
  18193. UnionTypeDefinition: addDescription(function (_ref27) {
  18194. var name = _ref27.name,
  18195. directives = _ref27.directives,
  18196. types = _ref27.types;
  18197. return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  18198. }),
  18199. EnumTypeDefinition: addDescription(function (_ref28) {
  18200. var name = _ref28.name,
  18201. directives = _ref28.directives,
  18202. values = _ref28.values;
  18203. return join(['enum', name, join(directives, ' '), block(values)], ' ');
  18204. }),
  18205. EnumValueDefinition: addDescription(function (_ref29) {
  18206. var name = _ref29.name,
  18207. directives = _ref29.directives;
  18208. return join([name, join(directives, ' ')], ' ');
  18209. }),
  18210. InputObjectTypeDefinition: addDescription(function (_ref30) {
  18211. var name = _ref30.name,
  18212. directives = _ref30.directives,
  18213. fields = _ref30.fields;
  18214. return join(['input', name, join(directives, ' '), block(fields)], ' ');
  18215. }),
  18216. DirectiveDefinition: addDescription(function (_ref31) {
  18217. var name = _ref31.name,
  18218. args = _ref31.arguments,
  18219. locations = _ref31.locations;
  18220. return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ' on ' + join(locations, ' | ');
  18221. }),
  18222. SchemaExtension: function SchemaExtension(_ref32) {
  18223. var directives = _ref32.directives,
  18224. operationTypes = _ref32.operationTypes;
  18225. return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
  18226. },
  18227. ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
  18228. var name = _ref33.name,
  18229. directives = _ref33.directives;
  18230. return join(['extend scalar', name, join(directives, ' ')], ' ');
  18231. },
  18232. ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
  18233. var name = _ref34.name,
  18234. interfaces = _ref34.interfaces,
  18235. directives = _ref34.directives,
  18236. fields = _ref34.fields;
  18237. return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  18238. },
  18239. InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
  18240. var name = _ref35.name,
  18241. directives = _ref35.directives,
  18242. fields = _ref35.fields;
  18243. return join(['extend interface', name, join(directives, ' '), block(fields)], ' ');
  18244. },
  18245. UnionTypeExtension: function UnionTypeExtension(_ref36) {
  18246. var name = _ref36.name,
  18247. directives = _ref36.directives,
  18248. types = _ref36.types;
  18249. return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  18250. },
  18251. EnumTypeExtension: function EnumTypeExtension(_ref37) {
  18252. var name = _ref37.name,
  18253. directives = _ref37.directives,
  18254. values = _ref37.values;
  18255. return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
  18256. },
  18257. InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
  18258. var name = _ref38.name,
  18259. directives = _ref38.directives,
  18260. fields = _ref38.fields;
  18261. return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
  18262. }
  18263. };
  18264. function addDescription(cb) {
  18265. return function (node) {
  18266. return join([node.description, cb(node)], '\n');
  18267. };
  18268. }
  18269. /**
  18270. * Given maybeArray, print an empty string if it is null or empty, otherwise
  18271. * print all items together separated by separator if provided
  18272. */
  18273. function join(maybeArray, separator) {
  18274. return maybeArray ? maybeArray.filter(function (x) {
  18275. return x;
  18276. }).join(separator || '') : '';
  18277. }
  18278. /**
  18279. * Given array, print each item on its own line, wrapped in an
  18280. * indented "{ }" block.
  18281. */
  18282. function block(array) {
  18283. return array && array.length !== 0 ? '{\n' + indent(join(array, '\n')) + '\n}' : '';
  18284. }
  18285. /**
  18286. * If maybeString is not null or empty, then wrap with start and end, otherwise
  18287. * print an empty string.
  18288. */
  18289. function wrap(start, maybeString, end) {
  18290. return maybeString ? start + maybeString + (end || '') : '';
  18291. }
  18292. function indent(maybeString) {
  18293. return maybeString && ' ' + maybeString.replace(/\n/g, '\n ');
  18294. }
  18295. function isMultiline(string) {
  18296. return string.indexOf('\n') !== -1;
  18297. }
  18298. function hasMultilineItems(maybeArray) {
  18299. return maybeArray && maybeArray.some(isMultiline);
  18300. }
  18301. },{"./blockString":48,"./visitor":58}],57:[function(require,module,exports){
  18302. "use strict";
  18303. Object.defineProperty(exports, "__esModule", {
  18304. value: true
  18305. });
  18306. exports.Source = void 0;
  18307. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  18308. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  18309. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18310. /**
  18311. * Copyright (c) Facebook, Inc. and its affiliates.
  18312. *
  18313. * This source code is licensed under the MIT license found in the
  18314. * LICENSE file in the root directory of this source tree.
  18315. *
  18316. *
  18317. */
  18318. /**
  18319. * A representation of source input to GraphQL.
  18320. * `name` and `locationOffset` are optional. They are useful for clients who
  18321. * store GraphQL documents in source files; for example, if the GraphQL input
  18322. * starts at line 40 in a file named Foo.graphql, it might be useful for name to
  18323. * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
  18324. * line and column in locationOffset are 1-indexed
  18325. */
  18326. var Source = function Source(body, name, locationOffset) {
  18327. this.body = body;
  18328. this.name = name || 'GraphQL request';
  18329. this.locationOffset = locationOffset || {
  18330. line: 1,
  18331. column: 1
  18332. };
  18333. !(this.locationOffset.line > 0) ? (0, _invariant.default)(0, 'line in locationOffset is 1-indexed and must be positive') : void 0;
  18334. !(this.locationOffset.column > 0) ? (0, _invariant.default)(0, 'column in locationOffset is 1-indexed and must be positive') : void 0;
  18335. }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  18336. exports.Source = Source;
  18337. (0, _defineToStringTag.default)(Source);
  18338. },{"../jsutils/defineToStringTag":31,"../jsutils/invariant":34}],58:[function(require,module,exports){
  18339. "use strict";
  18340. Object.defineProperty(exports, "__esModule", {
  18341. value: true
  18342. });
  18343. exports.visit = visit;
  18344. exports.visitInParallel = visitInParallel;
  18345. exports.visitWithTypeInfo = visitWithTypeInfo;
  18346. exports.getVisitFn = getVisitFn;
  18347. exports.BREAK = exports.QueryDocumentKeys = void 0;
  18348. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  18349. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18350. /**
  18351. * Copyright (c) Facebook, Inc. and its affiliates.
  18352. *
  18353. * This source code is licensed under the MIT license found in the
  18354. * LICENSE file in the root directory of this source tree.
  18355. *
  18356. *
  18357. */
  18358. var QueryDocumentKeys = {
  18359. Name: [],
  18360. Document: ['definitions'],
  18361. OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
  18362. VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
  18363. Variable: ['name'],
  18364. SelectionSet: ['selections'],
  18365. Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
  18366. Argument: ['name', 'value'],
  18367. FragmentSpread: ['name', 'directives'],
  18368. InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
  18369. FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed
  18370. // or removed in the future.
  18371. 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],
  18372. IntValue: [],
  18373. FloatValue: [],
  18374. StringValue: [],
  18375. BooleanValue: [],
  18376. NullValue: [],
  18377. EnumValue: [],
  18378. ListValue: ['values'],
  18379. ObjectValue: ['fields'],
  18380. ObjectField: ['name', 'value'],
  18381. Directive: ['name', 'arguments'],
  18382. NamedType: ['name'],
  18383. ListType: ['type'],
  18384. NonNullType: ['type'],
  18385. SchemaDefinition: ['directives', 'operationTypes'],
  18386. OperationTypeDefinition: ['type'],
  18387. ScalarTypeDefinition: ['description', 'name', 'directives'],
  18388. ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
  18389. FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
  18390. InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],
  18391. InterfaceTypeDefinition: ['description', 'name', 'directives', 'fields'],
  18392. UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
  18393. EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
  18394. EnumValueDefinition: ['description', 'name', 'directives'],
  18395. InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
  18396. DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
  18397. SchemaExtension: ['directives', 'operationTypes'],
  18398. ScalarTypeExtension: ['name', 'directives'],
  18399. ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  18400. InterfaceTypeExtension: ['name', 'directives', 'fields'],
  18401. UnionTypeExtension: ['name', 'directives', 'types'],
  18402. EnumTypeExtension: ['name', 'directives', 'values'],
  18403. InputObjectTypeExtension: ['name', 'directives', 'fields']
  18404. };
  18405. exports.QueryDocumentKeys = QueryDocumentKeys;
  18406. var BREAK = {};
  18407. /**
  18408. * visit() will walk through an AST using a depth first traversal, calling
  18409. * the visitor's enter function at each node in the traversal, and calling the
  18410. * leave function after visiting that node and all of its child nodes.
  18411. *
  18412. * By returning different values from the enter and leave functions, the
  18413. * behavior of the visitor can be altered, including skipping over a sub-tree of
  18414. * the AST (by returning false), editing the AST by returning a value or null
  18415. * to remove the value, or to stop the whole traversal by returning BREAK.
  18416. *
  18417. * When using visit() to edit an AST, the original AST will not be modified, and
  18418. * a new version of the AST with the changes applied will be returned from the
  18419. * visit function.
  18420. *
  18421. * const editedAST = visit(ast, {
  18422. * enter(node, key, parent, path, ancestors) {
  18423. * // @return
  18424. * // undefined: no action
  18425. * // false: skip visiting this node
  18426. * // visitor.BREAK: stop visiting altogether
  18427. * // null: delete this node
  18428. * // any value: replace this node with the returned value
  18429. * },
  18430. * leave(node, key, parent, path, ancestors) {
  18431. * // @return
  18432. * // undefined: no action
  18433. * // false: no action
  18434. * // visitor.BREAK: stop visiting altogether
  18435. * // null: delete this node
  18436. * // any value: replace this node with the returned value
  18437. * }
  18438. * });
  18439. *
  18440. * Alternatively to providing enter() and leave() functions, a visitor can
  18441. * instead provide functions named the same as the kinds of AST nodes, or
  18442. * enter/leave visitors at a named key, leading to four permutations of
  18443. * visitor API:
  18444. *
  18445. * 1) Named visitors triggered when entering a node a specific kind.
  18446. *
  18447. * visit(ast, {
  18448. * Kind(node) {
  18449. * // enter the "Kind" node
  18450. * }
  18451. * })
  18452. *
  18453. * 2) Named visitors that trigger upon entering and leaving a node of
  18454. * a specific kind.
  18455. *
  18456. * visit(ast, {
  18457. * Kind: {
  18458. * enter(node) {
  18459. * // enter the "Kind" node
  18460. * }
  18461. * leave(node) {
  18462. * // leave the "Kind" node
  18463. * }
  18464. * }
  18465. * })
  18466. *
  18467. * 3) Generic visitors that trigger upon entering and leaving any node.
  18468. *
  18469. * visit(ast, {
  18470. * enter(node) {
  18471. * // enter any node
  18472. * },
  18473. * leave(node) {
  18474. * // leave any node
  18475. * }
  18476. * })
  18477. *
  18478. * 4) Parallel visitors for entering and leaving nodes of a specific kind.
  18479. *
  18480. * visit(ast, {
  18481. * enter: {
  18482. * Kind(node) {
  18483. * // enter the "Kind" node
  18484. * }
  18485. * },
  18486. * leave: {
  18487. * Kind(node) {
  18488. * // leave the "Kind" node
  18489. * }
  18490. * }
  18491. * })
  18492. */
  18493. exports.BREAK = BREAK;
  18494. function visit(root, visitor) {
  18495. var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
  18496. /* eslint-disable no-undef-init */
  18497. var stack = undefined;
  18498. var inArray = Array.isArray(root);
  18499. var keys = [root];
  18500. var index = -1;
  18501. var edits = [];
  18502. var node = undefined;
  18503. var key = undefined;
  18504. var parent = undefined;
  18505. var path = [];
  18506. var ancestors = [];
  18507. var newRoot = root;
  18508. /* eslint-enable no-undef-init */
  18509. do {
  18510. index++;
  18511. var isLeaving = index === keys.length;
  18512. var isEdited = isLeaving && edits.length !== 0;
  18513. if (isLeaving) {
  18514. key = ancestors.length === 0 ? undefined : path[path.length - 1];
  18515. node = parent;
  18516. parent = ancestors.pop();
  18517. if (isEdited) {
  18518. if (inArray) {
  18519. node = node.slice();
  18520. } else {
  18521. var clone = {};
  18522. for (var _i = 0, _Object$keys = Object.keys(node); _i < _Object$keys.length; _i++) {
  18523. var k = _Object$keys[_i];
  18524. clone[k] = node[k];
  18525. }
  18526. node = clone;
  18527. }
  18528. var editOffset = 0;
  18529. for (var ii = 0; ii < edits.length; ii++) {
  18530. var editKey = edits[ii][0];
  18531. var editValue = edits[ii][1];
  18532. if (inArray) {
  18533. editKey -= editOffset;
  18534. }
  18535. if (inArray && editValue === null) {
  18536. node.splice(editKey, 1);
  18537. editOffset++;
  18538. } else {
  18539. node[editKey] = editValue;
  18540. }
  18541. }
  18542. }
  18543. index = stack.index;
  18544. keys = stack.keys;
  18545. edits = stack.edits;
  18546. inArray = stack.inArray;
  18547. stack = stack.prev;
  18548. } else {
  18549. key = parent ? inArray ? index : keys[index] : undefined;
  18550. node = parent ? parent[key] : newRoot;
  18551. if (node === null || node === undefined) {
  18552. continue;
  18553. }
  18554. if (parent) {
  18555. path.push(key);
  18556. }
  18557. }
  18558. var result = void 0;
  18559. if (!Array.isArray(node)) {
  18560. if (!isNode(node)) {
  18561. throw new Error('Invalid AST Node: ' + (0, _inspect.default)(node));
  18562. }
  18563. var visitFn = getVisitFn(visitor, node.kind, isLeaving);
  18564. if (visitFn) {
  18565. result = visitFn.call(visitor, node, key, parent, path, ancestors);
  18566. if (result === BREAK) {
  18567. break;
  18568. }
  18569. if (result === false) {
  18570. if (!isLeaving) {
  18571. path.pop();
  18572. continue;
  18573. }
  18574. } else if (result !== undefined) {
  18575. edits.push([key, result]);
  18576. if (!isLeaving) {
  18577. if (isNode(result)) {
  18578. node = result;
  18579. } else {
  18580. path.pop();
  18581. continue;
  18582. }
  18583. }
  18584. }
  18585. }
  18586. }
  18587. if (result === undefined && isEdited) {
  18588. edits.push([key, node]);
  18589. }
  18590. if (isLeaving) {
  18591. path.pop();
  18592. } else {
  18593. stack = {
  18594. inArray: inArray,
  18595. index: index,
  18596. keys: keys,
  18597. edits: edits,
  18598. prev: stack
  18599. };
  18600. inArray = Array.isArray(node);
  18601. keys = inArray ? node : visitorKeys[node.kind] || [];
  18602. index = -1;
  18603. edits = [];
  18604. if (parent) {
  18605. ancestors.push(parent);
  18606. }
  18607. parent = node;
  18608. }
  18609. } while (stack !== undefined);
  18610. if (edits.length !== 0) {
  18611. newRoot = edits[edits.length - 1][1];
  18612. }
  18613. return newRoot;
  18614. }
  18615. function isNode(maybeNode) {
  18616. return Boolean(maybeNode && typeof maybeNode.kind === 'string');
  18617. }
  18618. /**
  18619. * Creates a new visitor instance which delegates to many visitors to run in
  18620. * parallel. Each visitor will be visited for each node before moving on.
  18621. *
  18622. * If a prior visitor edits a node, no following visitors will see that node.
  18623. */
  18624. function visitInParallel(visitors) {
  18625. var skipping = new Array(visitors.length);
  18626. return {
  18627. enter: function enter(node) {
  18628. for (var i = 0; i < visitors.length; i++) {
  18629. if (!skipping[i]) {
  18630. var fn = getVisitFn(visitors[i], node.kind,
  18631. /* isLeaving */
  18632. false);
  18633. if (fn) {
  18634. var result = fn.apply(visitors[i], arguments);
  18635. if (result === false) {
  18636. skipping[i] = node;
  18637. } else if (result === BREAK) {
  18638. skipping[i] = BREAK;
  18639. } else if (result !== undefined) {
  18640. return result;
  18641. }
  18642. }
  18643. }
  18644. }
  18645. },
  18646. leave: function leave(node) {
  18647. for (var i = 0; i < visitors.length; i++) {
  18648. if (!skipping[i]) {
  18649. var fn = getVisitFn(visitors[i], node.kind,
  18650. /* isLeaving */
  18651. true);
  18652. if (fn) {
  18653. var result = fn.apply(visitors[i], arguments);
  18654. if (result === BREAK) {
  18655. skipping[i] = BREAK;
  18656. } else if (result !== undefined && result !== false) {
  18657. return result;
  18658. }
  18659. }
  18660. } else if (skipping[i] === node) {
  18661. skipping[i] = null;
  18662. }
  18663. }
  18664. }
  18665. };
  18666. }
  18667. /**
  18668. * Creates a new visitor instance which maintains a provided TypeInfo instance
  18669. * along with visiting visitor.
  18670. */
  18671. function visitWithTypeInfo(typeInfo, visitor) {
  18672. return {
  18673. enter: function enter(node) {
  18674. typeInfo.enter(node);
  18675. var fn = getVisitFn(visitor, node.kind,
  18676. /* isLeaving */
  18677. false);
  18678. if (fn) {
  18679. var result = fn.apply(visitor, arguments);
  18680. if (result !== undefined) {
  18681. typeInfo.leave(node);
  18682. if (isNode(result)) {
  18683. typeInfo.enter(result);
  18684. }
  18685. }
  18686. return result;
  18687. }
  18688. },
  18689. leave: function leave(node) {
  18690. var fn = getVisitFn(visitor, node.kind,
  18691. /* isLeaving */
  18692. true);
  18693. var result;
  18694. if (fn) {
  18695. result = fn.apply(visitor, arguments);
  18696. }
  18697. typeInfo.leave(node);
  18698. return result;
  18699. }
  18700. };
  18701. }
  18702. /**
  18703. * Given a visitor instance, if it is leaving or not, and a node kind, return
  18704. * the function the visitor runtime should call.
  18705. */
  18706. function getVisitFn(visitor, kind, isLeaving) {
  18707. var kindVisitor = visitor[kind];
  18708. if (kindVisitor) {
  18709. if (!isLeaving && typeof kindVisitor === 'function') {
  18710. // { Kind() {} }
  18711. return kindVisitor;
  18712. }
  18713. var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
  18714. if (typeof kindSpecificVisitor === 'function') {
  18715. // { Kind: { enter() {}, leave() {} } }
  18716. return kindSpecificVisitor;
  18717. }
  18718. } else {
  18719. var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
  18720. if (specificVisitor) {
  18721. if (typeof specificVisitor === 'function') {
  18722. // { enter() {}, leave() {} }
  18723. return specificVisitor;
  18724. }
  18725. var specificKindVisitor = specificVisitor[kind];
  18726. if (typeof specificKindVisitor === 'function') {
  18727. // { enter: { Kind() {} }, leave: { Kind() {} } }
  18728. return specificKindVisitor;
  18729. }
  18730. }
  18731. }
  18732. }
  18733. },{"../jsutils/inspect":32}],59:[function(require,module,exports){
  18734. "use strict";
  18735. Object.defineProperty(exports, "__esModule", {
  18736. value: true
  18737. });
  18738. exports.default = void 0;
  18739. /**
  18740. * Copyright (c) Facebook, Inc. and its affiliates.
  18741. *
  18742. * This source code is licensed under the MIT license found in the
  18743. * LICENSE file in the root directory of this source tree.
  18744. *
  18745. *
  18746. */
  18747. /* eslint-disable no-redeclare */
  18748. // $FlowFixMe
  18749. var find = Array.prototype.find ? function (list, predicate) {
  18750. return Array.prototype.find.call(list, predicate);
  18751. } : function (list, predicate) {
  18752. for (var i = 0; i < list.length; i++) {
  18753. var value = list[i];
  18754. if (predicate(value)) {
  18755. return value;
  18756. }
  18757. }
  18758. };
  18759. var _default = find;
  18760. exports.default = _default;
  18761. },{}],60:[function(require,module,exports){
  18762. "use strict";
  18763. Object.defineProperty(exports, "__esModule", {
  18764. value: true
  18765. });
  18766. exports.default = void 0;
  18767. /**
  18768. * Copyright (c) Facebook, Inc. and its affiliates.
  18769. *
  18770. * This source code is licensed under the MIT license found in the
  18771. * LICENSE file in the root directory of this source tree.
  18772. *
  18773. *
  18774. */
  18775. /* eslint-disable no-redeclare */
  18776. // $FlowFixMe
  18777. var flatMap = Array.prototype.flatMap ? function (list, fn) {
  18778. // $FlowFixMe
  18779. return Array.prototype.flatMap.call(list, fn);
  18780. } : function (list, fn) {
  18781. var result = [];
  18782. for (var i = 0; i < list.length; i++) {
  18783. var value = fn(list[i]);
  18784. if (Array.isArray(value)) {
  18785. result = result.concat(value);
  18786. } else {
  18787. result.push(value);
  18788. }
  18789. }
  18790. return result;
  18791. };
  18792. var _default = flatMap;
  18793. exports.default = _default;
  18794. },{}],61:[function(require,module,exports){
  18795. "use strict";
  18796. Object.defineProperty(exports, "__esModule", {
  18797. value: true
  18798. });
  18799. exports.default = void 0;
  18800. /**
  18801. * Copyright (c) Facebook, Inc. and its affiliates.
  18802. *
  18803. * This source code is licensed under the MIT license found in the
  18804. * LICENSE file in the root directory of this source tree.
  18805. *
  18806. *
  18807. */
  18808. /* eslint-disable no-redeclare */
  18809. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
  18810. var isFinite = Number.isFinite || function (value) {
  18811. return typeof value === 'number' && isFinite(value);
  18812. };
  18813. var _default = isFinite;
  18814. exports.default = _default;
  18815. },{}],62:[function(require,module,exports){
  18816. "use strict";
  18817. Object.defineProperty(exports, "__esModule", {
  18818. value: true
  18819. });
  18820. exports.default = void 0;
  18821. /**
  18822. * Copyright (c) Facebook, Inc. and its affiliates.
  18823. *
  18824. * This source code is licensed under the MIT license found in the
  18825. * LICENSE file in the root directory of this source tree.
  18826. *
  18827. *
  18828. */
  18829. /* eslint-disable no-redeclare */
  18830. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
  18831. var isInteger = Number.isInteger || function (value) {
  18832. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  18833. };
  18834. var _default = isInteger;
  18835. exports.default = _default;
  18836. },{}],63:[function(require,module,exports){
  18837. "use strict";
  18838. Object.defineProperty(exports, "__esModule", {
  18839. value: true
  18840. });
  18841. exports.default = void 0;
  18842. /**
  18843. * Copyright (c) Facebook, Inc. and its affiliates.
  18844. *
  18845. * This source code is licensed under the MIT license found in the
  18846. * LICENSE file in the root directory of this source tree.
  18847. *
  18848. *
  18849. */
  18850. /* eslint-disable no-redeclare */
  18851. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/5838
  18852. var objectEntries = Object.entries || function (obj) {
  18853. return Object.keys(obj).map(function (key) {
  18854. return [key, obj[key]];
  18855. });
  18856. };
  18857. var _default = objectEntries;
  18858. exports.default = _default;
  18859. },{}],64:[function(require,module,exports){
  18860. "use strict";
  18861. Object.defineProperty(exports, "__esModule", {
  18862. value: true
  18863. });
  18864. exports.default = void 0;
  18865. /**
  18866. * Copyright (c) Facebook, Inc. and its affiliates.
  18867. *
  18868. * This source code is licensed under the MIT license found in the
  18869. * LICENSE file in the root directory of this source tree.
  18870. *
  18871. *
  18872. */
  18873. /* eslint-disable no-redeclare */
  18874. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/2221
  18875. var objectValues = Object.values || function (obj) {
  18876. return Object.keys(obj).map(function (key) {
  18877. return obj[key];
  18878. });
  18879. };
  18880. var _default = objectValues;
  18881. exports.default = _default;
  18882. },{}],65:[function(require,module,exports){
  18883. "use strict";
  18884. Object.defineProperty(exports, "__esModule", {
  18885. value: true
  18886. });
  18887. Object.defineProperty(exports, "subscribe", {
  18888. enumerable: true,
  18889. get: function get() {
  18890. return _subscribe.subscribe;
  18891. }
  18892. });
  18893. Object.defineProperty(exports, "createSourceEventStream", {
  18894. enumerable: true,
  18895. get: function get() {
  18896. return _subscribe.createSourceEventStream;
  18897. }
  18898. });
  18899. var _subscribe = require("./subscribe");
  18900. },{"./subscribe":67}],66:[function(require,module,exports){
  18901. "use strict";
  18902. Object.defineProperty(exports, "__esModule", {
  18903. value: true
  18904. });
  18905. exports.default = mapAsyncIterator;
  18906. var _iterall = require("iterall");
  18907. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  18908. /**
  18909. * Given an AsyncIterable and a callback function, return an AsyncIterator
  18910. * which produces values mapped via calling the callback function.
  18911. */
  18912. function mapAsyncIterator(iterable, callback, rejectCallback) {
  18913. var iterator = (0, _iterall.getAsyncIterator)(iterable);
  18914. var $return;
  18915. var abruptClose; // $FlowFixMe(>=0.68.0)
  18916. if (typeof iterator.return === 'function') {
  18917. $return = iterator.return;
  18918. abruptClose = function abruptClose(error) {
  18919. var rethrow = function rethrow() {
  18920. return Promise.reject(error);
  18921. };
  18922. return $return.call(iterator).then(rethrow, rethrow);
  18923. };
  18924. }
  18925. function mapResult(result) {
  18926. return result.done ? result : asyncMapValue(result.value, callback).then(iteratorResult, abruptClose);
  18927. }
  18928. var mapReject;
  18929. if (rejectCallback) {
  18930. // Capture rejectCallback to ensure it cannot be null.
  18931. var reject = rejectCallback;
  18932. mapReject = function mapReject(error) {
  18933. return asyncMapValue(error, reject).then(iteratorResult, abruptClose);
  18934. };
  18935. }
  18936. /* TODO: Flow doesn't support symbols as keys:
  18937. https://github.com/facebook/flow/issues/3258 */
  18938. return _defineProperty({
  18939. next: function next() {
  18940. return iterator.next().then(mapResult, mapReject);
  18941. },
  18942. return: function _return() {
  18943. return $return ? $return.call(iterator).then(mapResult, mapReject) : Promise.resolve({
  18944. value: undefined,
  18945. done: true
  18946. });
  18947. },
  18948. throw: function _throw(error) {
  18949. // $FlowFixMe(>=0.68.0)
  18950. if (typeof iterator.throw === 'function') {
  18951. return iterator.throw(error).then(mapResult, mapReject);
  18952. }
  18953. return Promise.reject(error).catch(abruptClose);
  18954. }
  18955. }, _iterall.$$asyncIterator, function () {
  18956. return this;
  18957. });
  18958. }
  18959. function asyncMapValue(value, callback) {
  18960. return new Promise(function (resolve) {
  18961. return resolve(callback(value));
  18962. });
  18963. }
  18964. function iteratorResult(value) {
  18965. return {
  18966. value: value,
  18967. done: false
  18968. };
  18969. }
  18970. },{"iterall":137}],67:[function(require,module,exports){
  18971. "use strict";
  18972. Object.defineProperty(exports, "__esModule", {
  18973. value: true
  18974. });
  18975. exports.subscribe = subscribe;
  18976. exports.createSourceEventStream = createSourceEventStream;
  18977. var _iterall = require("iterall");
  18978. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  18979. var _GraphQLError = require("../error/GraphQLError");
  18980. var _locatedError = require("../error/locatedError");
  18981. var _execute = require("../execution/execute");
  18982. var _mapAsyncIterator = _interopRequireDefault(require("./mapAsyncIterator"));
  18983. var _getOperationRootType = require("../utilities/getOperationRootType");
  18984. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18985. /**
  18986. * Copyright (c) Facebook, Inc. and its affiliates.
  18987. *
  18988. * This source code is licensed under the MIT license found in the
  18989. * LICENSE file in the root directory of this source tree.
  18990. *
  18991. *
  18992. */
  18993. function subscribe(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {
  18994. /* eslint-enable no-redeclare */
  18995. // Extract arguments from object args if provided.
  18996. return arguments.length === 1 ? subscribeImpl(argsOrSchema.schema, argsOrSchema.document, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.subscribeFieldResolver) : subscribeImpl(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver);
  18997. }
  18998. /**
  18999. * This function checks if the error is a GraphQLError. If it is, report it as
  19000. * an ExecutionResult, containing only errors and no data. Otherwise treat the
  19001. * error as a system-class error and re-throw it.
  19002. */
  19003. function reportGraphQLError(error) {
  19004. if (error instanceof _GraphQLError.GraphQLError) {
  19005. return {
  19006. errors: [error]
  19007. };
  19008. }
  19009. throw error;
  19010. }
  19011. function subscribeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {
  19012. var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); // For each payload yielded from a subscription, map it over the normal
  19013. // GraphQL `execute` function, with `payload` as the rootValue.
  19014. // This implements the "MapSourceToResponseEvent" algorithm described in
  19015. // the GraphQL specification. The `execute` function provides the
  19016. // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the
  19017. // "ExecuteQuery" algorithm, for which `execute` is also used.
  19018. var mapSourceToResponse = function mapSourceToResponse(payload) {
  19019. return (0, _execute.execute)(schema, document, payload, contextValue, variableValues, operationName, fieldResolver);
  19020. }; // Resolve the Source Stream, then map every source value to a
  19021. // ExecutionResult value as described above.
  19022. return sourcePromise.then(function (resultOrStream) {
  19023. return (// Note: Flow can't refine isAsyncIterable, so explicit casts are used.
  19024. (0, _iterall.isAsyncIterable)(resultOrStream) ? (0, _mapAsyncIterator.default)(resultOrStream, mapSourceToResponse, reportGraphQLError) : resultOrStream
  19025. );
  19026. }, reportGraphQLError);
  19027. }
  19028. /**
  19029. * Implements the "CreateSourceEventStream" algorithm described in the
  19030. * GraphQL specification, resolving the subscription source event stream.
  19031. *
  19032. * Returns a Promise<AsyncIterable>.
  19033. *
  19034. * If the client-provided invalid arguments, the source stream could not be
  19035. * created, or the resolver did not return an AsyncIterable, this function will
  19036. * will throw an error, which should be caught and handled by the caller.
  19037. *
  19038. * A Source Event Stream represents a sequence of events, each of which triggers
  19039. * a GraphQL execution for that event.
  19040. *
  19041. * This may be useful when hosting the stateful subscription service in a
  19042. * different process or machine than the stateless GraphQL execution engine,
  19043. * or otherwise separating these two steps. For more on this, see the
  19044. * "Supporting Subscriptions at Scale" information in the GraphQL specification.
  19045. */
  19046. function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  19047. // If arguments are missing or incorrectly typed, this is an internal
  19048. // developer mistake which should throw an early error.
  19049. (0, _execute.assertValidExecutionArguments)(schema, document, variableValues);
  19050. try {
  19051. // If a valid context cannot be created due to incorrect arguments,
  19052. // this will throw an error.
  19053. var exeContext = (0, _execute.buildExecutionContext)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver); // Return early errors if execution context failed.
  19054. if (Array.isArray(exeContext)) {
  19055. return Promise.resolve({
  19056. errors: exeContext
  19057. });
  19058. }
  19059. var type = (0, _getOperationRootType.getOperationRootType)(schema, exeContext.operation);
  19060. var fields = (0, _execute.collectFields)(exeContext, type, exeContext.operation.selectionSet, Object.create(null), Object.create(null));
  19061. var responseNames = Object.keys(fields);
  19062. var responseName = responseNames[0];
  19063. var fieldNodes = fields[responseName];
  19064. var fieldNode = fieldNodes[0];
  19065. var fieldName = fieldNode.name.value;
  19066. var fieldDef = (0, _execute.getFieldDef)(schema, type, fieldName);
  19067. if (!fieldDef) {
  19068. throw new _GraphQLError.GraphQLError("The subscription field \"".concat(fieldName, "\" is not defined."), fieldNodes);
  19069. } // Call the `subscribe()` resolver or the default resolver to produce an
  19070. // AsyncIterable yielding raw payloads.
  19071. var resolveFn = fieldDef.subscribe || exeContext.fieldResolver;
  19072. var path = (0, _execute.addPath)(undefined, responseName);
  19073. var info = (0, _execute.buildResolveInfo)(exeContext, fieldDef, fieldNodes, type, path); // resolveFieldValueOrError implements the "ResolveFieldEventStream"
  19074. // algorithm from GraphQL specification. It differs from
  19075. // "ResolveFieldValue" due to providing a different `resolveFn`.
  19076. var result = (0, _execute.resolveFieldValueOrError)(exeContext, fieldDef, fieldNodes, resolveFn, rootValue, info); // Coerce to Promise for easier error handling and consistent return type.
  19077. return Promise.resolve(result).then(function (eventStream) {
  19078. // If eventStream is an Error, rethrow a located error.
  19079. if (eventStream instanceof Error) {
  19080. throw (0, _locatedError.locatedError)(eventStream, fieldNodes, (0, _execute.responsePathAsArray)(path));
  19081. } // Assert field returned an event stream, otherwise yield an error.
  19082. if ((0, _iterall.isAsyncIterable)(eventStream)) {
  19083. // Note: isAsyncIterable above ensures this will be correct.
  19084. return eventStream;
  19085. }
  19086. throw new Error('Subscription field must return Async Iterable. Received: ' + (0, _inspect.default)(eventStream));
  19087. });
  19088. } catch (error) {
  19089. return Promise.reject(error);
  19090. }
  19091. }
  19092. },{"../error/GraphQLError":19,"../error/locatedError":22,"../execution/execute":25,"../jsutils/inspect":32,"../utilities/getOperationRootType":86,"./mapAsyncIterator":66,"iterall":137}],68:[function(require,module,exports){
  19093. "use strict";
  19094. Object.defineProperty(exports, "__esModule", {
  19095. value: true
  19096. });
  19097. exports.isType = isType;
  19098. exports.assertType = assertType;
  19099. exports.isScalarType = isScalarType;
  19100. exports.assertScalarType = assertScalarType;
  19101. exports.isObjectType = isObjectType;
  19102. exports.assertObjectType = assertObjectType;
  19103. exports.isInterfaceType = isInterfaceType;
  19104. exports.assertInterfaceType = assertInterfaceType;
  19105. exports.isUnionType = isUnionType;
  19106. exports.assertUnionType = assertUnionType;
  19107. exports.isEnumType = isEnumType;
  19108. exports.assertEnumType = assertEnumType;
  19109. exports.isInputObjectType = isInputObjectType;
  19110. exports.assertInputObjectType = assertInputObjectType;
  19111. exports.isListType = isListType;
  19112. exports.assertListType = assertListType;
  19113. exports.isNonNullType = isNonNullType;
  19114. exports.assertNonNullType = assertNonNullType;
  19115. exports.isInputType = isInputType;
  19116. exports.assertInputType = assertInputType;
  19117. exports.isOutputType = isOutputType;
  19118. exports.assertOutputType = assertOutputType;
  19119. exports.isLeafType = isLeafType;
  19120. exports.assertLeafType = assertLeafType;
  19121. exports.isCompositeType = isCompositeType;
  19122. exports.assertCompositeType = assertCompositeType;
  19123. exports.isAbstractType = isAbstractType;
  19124. exports.assertAbstractType = assertAbstractType;
  19125. exports.GraphQLList = GraphQLList;
  19126. exports.GraphQLNonNull = GraphQLNonNull;
  19127. exports.isWrappingType = isWrappingType;
  19128. exports.assertWrappingType = assertWrappingType;
  19129. exports.isNullableType = isNullableType;
  19130. exports.assertNullableType = assertNullableType;
  19131. exports.getNullableType = getNullableType;
  19132. exports.isNamedType = isNamedType;
  19133. exports.assertNamedType = assertNamedType;
  19134. exports.getNamedType = getNamedType;
  19135. exports.argsToArgsConfig = argsToArgsConfig;
  19136. exports.isRequiredArgument = isRequiredArgument;
  19137. exports.isRequiredInputField = isRequiredInputField;
  19138. exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = void 0;
  19139. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  19140. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  19141. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  19142. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  19143. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  19144. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  19145. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  19146. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  19147. var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
  19148. var _kinds = require("../language/kinds");
  19149. var _valueFromASTUntyped = require("../utilities/valueFromASTUntyped");
  19150. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19151. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  19152. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  19153. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  19154. function isType(type) {
  19155. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);
  19156. }
  19157. function assertType(type) {
  19158. !isType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL type.")) : void 0;
  19159. return type;
  19160. }
  19161. /**
  19162. * There are predicates for each kind of GraphQL type.
  19163. */
  19164. // eslint-disable-next-line no-redeclare
  19165. function isScalarType(type) {
  19166. return (0, _instanceOf.default)(type, GraphQLScalarType);
  19167. }
  19168. function assertScalarType(type) {
  19169. !isScalarType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Scalar type.")) : void 0;
  19170. return type;
  19171. }
  19172. // eslint-disable-next-line no-redeclare
  19173. function isObjectType(type) {
  19174. return (0, _instanceOf.default)(type, GraphQLObjectType);
  19175. }
  19176. function assertObjectType(type) {
  19177. !isObjectType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Object type.")) : void 0;
  19178. return type;
  19179. }
  19180. // eslint-disable-next-line no-redeclare
  19181. function isInterfaceType(type) {
  19182. return (0, _instanceOf.default)(type, GraphQLInterfaceType);
  19183. }
  19184. function assertInterfaceType(type) {
  19185. !isInterfaceType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Interface type.")) : void 0;
  19186. return type;
  19187. }
  19188. // eslint-disable-next-line no-redeclare
  19189. function isUnionType(type) {
  19190. return (0, _instanceOf.default)(type, GraphQLUnionType);
  19191. }
  19192. function assertUnionType(type) {
  19193. !isUnionType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type.")) : void 0;
  19194. return type;
  19195. }
  19196. // eslint-disable-next-line no-redeclare
  19197. function isEnumType(type) {
  19198. return (0, _instanceOf.default)(type, GraphQLEnumType);
  19199. }
  19200. function assertEnumType(type) {
  19201. !isEnumType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type.")) : void 0;
  19202. return type;
  19203. }
  19204. // eslint-disable-next-line no-redeclare
  19205. function isInputObjectType(type) {
  19206. return (0, _instanceOf.default)(type, GraphQLInputObjectType);
  19207. }
  19208. function assertInputObjectType(type) {
  19209. !isInputObjectType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Input Object type.")) : void 0;
  19210. return type;
  19211. }
  19212. // eslint-disable-next-line no-redeclare
  19213. function isListType(type) {
  19214. return (0, _instanceOf.default)(type, GraphQLList);
  19215. }
  19216. function assertListType(type) {
  19217. !isListType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL List type.")) : void 0;
  19218. return type;
  19219. }
  19220. // eslint-disable-next-line no-redeclare
  19221. function isNonNullType(type) {
  19222. return (0, _instanceOf.default)(type, GraphQLNonNull);
  19223. }
  19224. function assertNonNullType(type) {
  19225. !isNonNullType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Non-Null type.")) : void 0;
  19226. return type;
  19227. }
  19228. /**
  19229. * These types may be used as input types for arguments and directives.
  19230. */
  19231. function isInputType(type) {
  19232. return isScalarType(type) || isEnumType(type) || isInputObjectType(type) || isWrappingType(type) && isInputType(type.ofType);
  19233. }
  19234. function assertInputType(type) {
  19235. !isInputType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL input type.")) : void 0;
  19236. return type;
  19237. }
  19238. /**
  19239. * These types may be used as output types as the result of fields.
  19240. */
  19241. function isOutputType(type) {
  19242. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isWrappingType(type) && isOutputType(type.ofType);
  19243. }
  19244. function assertOutputType(type) {
  19245. !isOutputType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL output type.")) : void 0;
  19246. return type;
  19247. }
  19248. /**
  19249. * These types may describe types which may be leaf values.
  19250. */
  19251. function isLeafType(type) {
  19252. return isScalarType(type) || isEnumType(type);
  19253. }
  19254. function assertLeafType(type) {
  19255. !isLeafType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL leaf type.")) : void 0;
  19256. return type;
  19257. }
  19258. /**
  19259. * These types may describe the parent context of a selection set.
  19260. */
  19261. function isCompositeType(type) {
  19262. return isObjectType(type) || isInterfaceType(type) || isUnionType(type);
  19263. }
  19264. function assertCompositeType(type) {
  19265. !isCompositeType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL composite type.")) : void 0;
  19266. return type;
  19267. }
  19268. /**
  19269. * These types may describe the parent context of a selection set.
  19270. */
  19271. function isAbstractType(type) {
  19272. return isInterfaceType(type) || isUnionType(type);
  19273. }
  19274. function assertAbstractType(type) {
  19275. !isAbstractType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type.")) : void 0;
  19276. return type;
  19277. }
  19278. /**
  19279. * List Type Wrapper
  19280. *
  19281. * A list is a wrapping type which points to another type.
  19282. * Lists are often created within the context of defining the fields of
  19283. * an object type.
  19284. *
  19285. * Example:
  19286. *
  19287. * const PersonType = new GraphQLObjectType({
  19288. * name: 'Person',
  19289. * fields: () => ({
  19290. * parents: { type: GraphQLList(PersonType) },
  19291. * children: { type: GraphQLList(PersonType) },
  19292. * })
  19293. * })
  19294. *
  19295. */
  19296. // eslint-disable-next-line no-redeclare
  19297. function GraphQLList(ofType) {
  19298. if (this instanceof GraphQLList) {
  19299. this.ofType = assertType(ofType);
  19300. } else {
  19301. return new GraphQLList(ofType);
  19302. }
  19303. } // Need to cast through any to alter the prototype.
  19304. GraphQLList.prototype.toString = function toString() {
  19305. return '[' + String(this.ofType) + ']';
  19306. }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19307. (0, _defineToStringTag.default)(GraphQLList);
  19308. (0, _defineToJSON.default)(GraphQLList);
  19309. /**
  19310. * Non-Null Type Wrapper
  19311. *
  19312. * A non-null is a wrapping type which points to another type.
  19313. * Non-null types enforce that their values are never null and can ensure
  19314. * an error is raised if this ever occurs during a request. It is useful for
  19315. * fields which you can make a strong guarantee on non-nullability, for example
  19316. * usually the id field of a database row will never be null.
  19317. *
  19318. * Example:
  19319. *
  19320. * const RowType = new GraphQLObjectType({
  19321. * name: 'Row',
  19322. * fields: () => ({
  19323. * id: { type: GraphQLNonNull(GraphQLString) },
  19324. * })
  19325. * })
  19326. *
  19327. * Note: the enforcement of non-nullability occurs within the executor.
  19328. */
  19329. // eslint-disable-next-line no-redeclare
  19330. function GraphQLNonNull(ofType) {
  19331. if (this instanceof GraphQLNonNull) {
  19332. this.ofType = assertNullableType(ofType);
  19333. } else {
  19334. return new GraphQLNonNull(ofType);
  19335. }
  19336. } // Need to cast through any to alter the prototype.
  19337. GraphQLNonNull.prototype.toString = function toString() {
  19338. return String(this.ofType) + '!';
  19339. }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19340. (0, _defineToStringTag.default)(GraphQLNonNull);
  19341. (0, _defineToJSON.default)(GraphQLNonNull);
  19342. /**
  19343. * These types wrap and modify other types
  19344. */
  19345. function isWrappingType(type) {
  19346. return isListType(type) || isNonNullType(type);
  19347. }
  19348. function assertWrappingType(type) {
  19349. !isWrappingType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL wrapping type.")) : void 0;
  19350. return type;
  19351. }
  19352. /**
  19353. * These types can all accept null as a value.
  19354. */
  19355. function isNullableType(type) {
  19356. return isType(type) && !isNonNullType(type);
  19357. }
  19358. function assertNullableType(type) {
  19359. !isNullableType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL nullable type.")) : void 0;
  19360. return type;
  19361. }
  19362. /* eslint-disable no-redeclare */
  19363. function getNullableType(type) {
  19364. /* eslint-enable no-redeclare */
  19365. if (type) {
  19366. return isNonNullType(type) ? type.ofType : type;
  19367. }
  19368. }
  19369. /**
  19370. * These named types do not include modifiers like List or NonNull.
  19371. */
  19372. function isNamedType(type) {
  19373. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type);
  19374. }
  19375. function assertNamedType(type) {
  19376. !isNamedType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL named type.")) : void 0;
  19377. return type;
  19378. }
  19379. /* eslint-disable no-redeclare */
  19380. function getNamedType(type) {
  19381. /* eslint-enable no-redeclare */
  19382. if (type) {
  19383. var unwrappedType = type;
  19384. while (isWrappingType(unwrappedType)) {
  19385. unwrappedType = unwrappedType.ofType;
  19386. }
  19387. return unwrappedType;
  19388. }
  19389. }
  19390. /**
  19391. * Used while defining GraphQL types to allow for circular references in
  19392. * otherwise immutable type definitions.
  19393. */
  19394. function resolveThunk(thunk) {
  19395. // $FlowFixMe(>=0.90.0)
  19396. return typeof thunk === 'function' ? thunk() : thunk;
  19397. }
  19398. function undefineIfEmpty(arr) {
  19399. return arr && arr.length > 0 ? arr : undefined;
  19400. }
  19401. /**
  19402. * Scalar Type Definition
  19403. *
  19404. * The leaf values of any request and input values to arguments are
  19405. * Scalars (or Enums) and are defined with a name and a series of functions
  19406. * used to parse input from ast or variables and to ensure validity.
  19407. *
  19408. * If a type's serialize function does not return a value (i.e. it returns
  19409. * `undefined`) then an error will be raised and a `null` value will be returned
  19410. * in the response. If the serialize function returns `null`, then no error will
  19411. * be included in the response.
  19412. *
  19413. * Example:
  19414. *
  19415. * const OddType = new GraphQLScalarType({
  19416. * name: 'Odd',
  19417. * serialize(value) {
  19418. * if (value % 2 === 1) {
  19419. * return value;
  19420. * }
  19421. * }
  19422. * });
  19423. *
  19424. */
  19425. var GraphQLScalarType =
  19426. /*#__PURE__*/
  19427. function () {
  19428. function GraphQLScalarType(config) {
  19429. this.name = config.name;
  19430. this.description = config.description;
  19431. this.serialize = config.serialize;
  19432. this.parseValue = config.parseValue || function (value) {
  19433. return value;
  19434. };
  19435. this.parseLiteral = config.parseLiteral || _valueFromASTUntyped.valueFromASTUntyped;
  19436. this.astNode = config.astNode;
  19437. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19438. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19439. !(typeof config.serialize === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"serialize\" function. If this custom Scalar ") + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.') : void 0;
  19440. if (config.parseValue || config.parseLiteral) {
  19441. !(typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide both \"parseValue\" and \"parseLiteral\" ") + 'functions.') : void 0;
  19442. }
  19443. }
  19444. var _proto = GraphQLScalarType.prototype;
  19445. _proto.toConfig = function toConfig() {
  19446. return {
  19447. name: this.name,
  19448. description: this.description,
  19449. serialize: this.serialize,
  19450. parseValue: this.parseValue,
  19451. parseLiteral: this.parseLiteral,
  19452. astNode: this.astNode,
  19453. extensionASTNodes: this.extensionASTNodes || []
  19454. };
  19455. };
  19456. _proto.toString = function toString() {
  19457. return this.name;
  19458. };
  19459. return GraphQLScalarType;
  19460. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19461. exports.GraphQLScalarType = GraphQLScalarType;
  19462. (0, _defineToStringTag.default)(GraphQLScalarType);
  19463. (0, _defineToJSON.default)(GraphQLScalarType);
  19464. /**
  19465. * Object Type Definition
  19466. *
  19467. * Almost all of the GraphQL types you define will be object types. Object types
  19468. * have a name, but most importantly describe their fields.
  19469. *
  19470. * Example:
  19471. *
  19472. * const AddressType = new GraphQLObjectType({
  19473. * name: 'Address',
  19474. * fields: {
  19475. * street: { type: GraphQLString },
  19476. * number: { type: GraphQLInt },
  19477. * formatted: {
  19478. * type: GraphQLString,
  19479. * resolve(obj) {
  19480. * return obj.number + ' ' + obj.street
  19481. * }
  19482. * }
  19483. * }
  19484. * });
  19485. *
  19486. * When two types need to refer to each other, or a type needs to refer to
  19487. * itself in a field, you can use a function expression (aka a closure or a
  19488. * thunk) to supply the fields lazily.
  19489. *
  19490. * Example:
  19491. *
  19492. * const PersonType = new GraphQLObjectType({
  19493. * name: 'Person',
  19494. * fields: () => ({
  19495. * name: { type: GraphQLString },
  19496. * bestFriend: { type: PersonType },
  19497. * })
  19498. * });
  19499. *
  19500. */
  19501. var GraphQLObjectType =
  19502. /*#__PURE__*/
  19503. function () {
  19504. function GraphQLObjectType(config) {
  19505. this.name = config.name;
  19506. this.description = config.description;
  19507. this.astNode = config.astNode;
  19508. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19509. this.isTypeOf = config.isTypeOf;
  19510. this._fields = defineFieldMap.bind(undefined, config);
  19511. this._interfaces = defineInterfaces.bind(undefined, config);
  19512. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19513. !(config.isTypeOf == null || typeof config.isTypeOf === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"isTypeOf\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.isTypeOf), ".")) : void 0;
  19514. }
  19515. var _proto2 = GraphQLObjectType.prototype;
  19516. _proto2.getFields = function getFields() {
  19517. if (typeof this._fields === 'function') {
  19518. this._fields = this._fields();
  19519. }
  19520. return this._fields;
  19521. };
  19522. _proto2.getInterfaces = function getInterfaces() {
  19523. if (typeof this._interfaces === 'function') {
  19524. this._interfaces = this._interfaces();
  19525. }
  19526. return this._interfaces;
  19527. };
  19528. _proto2.toConfig = function toConfig() {
  19529. return {
  19530. name: this.name,
  19531. description: this.description,
  19532. isTypeOf: this.isTypeOf,
  19533. interfaces: this.getInterfaces(),
  19534. fields: fieldsToFieldsConfig(this.getFields()),
  19535. astNode: this.astNode,
  19536. extensionASTNodes: this.extensionASTNodes || []
  19537. };
  19538. };
  19539. _proto2.toString = function toString() {
  19540. return this.name;
  19541. };
  19542. return GraphQLObjectType;
  19543. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19544. exports.GraphQLObjectType = GraphQLObjectType;
  19545. (0, _defineToStringTag.default)(GraphQLObjectType);
  19546. (0, _defineToJSON.default)(GraphQLObjectType);
  19547. function defineInterfaces(config) {
  19548. var interfaces = resolveThunk(config.interfaces) || [];
  19549. !Array.isArray(interfaces) ? (0, _invariant.default)(0, "".concat(config.name, " interfaces must be an Array or a function which returns ") + 'an Array.') : void 0;
  19550. return interfaces;
  19551. }
  19552. function defineFieldMap(config) {
  19553. var fieldMap = resolveThunk(config.fields) || {};
  19554. !isPlainObj(fieldMap) ? (0, _invariant.default)(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
  19555. return (0, _mapValue.default)(fieldMap, function (fieldConfig, fieldName) {
  19556. !isPlainObj(fieldConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field config must be an object")) : void 0;
  19557. !!('isDeprecated' in fieldConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " should provide \"deprecationReason\" ") + 'instead of "isDeprecated".') : void 0;
  19558. !(fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function') ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field resolver must be a function if ") + "provided, but got: ".concat((0, _inspect.default)(fieldConfig.resolve), ".")) : void 0;
  19559. var argsConfig = fieldConfig.args || {};
  19560. !isPlainObj(argsConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " args must be an object with argument ") + 'names as keys.') : void 0;
  19561. var args = (0, _objectEntries.default)(argsConfig).map(function (_ref) {
  19562. var argName = _ref[0],
  19563. arg = _ref[1];
  19564. return {
  19565. name: argName,
  19566. description: arg.description === undefined ? null : arg.description,
  19567. type: arg.type,
  19568. defaultValue: arg.defaultValue,
  19569. astNode: arg.astNode
  19570. };
  19571. });
  19572. return _objectSpread({}, fieldConfig, {
  19573. isDeprecated: Boolean(fieldConfig.deprecationReason),
  19574. name: fieldName,
  19575. args: args
  19576. });
  19577. });
  19578. }
  19579. function isPlainObj(obj) {
  19580. return obj && _typeof(obj) === 'object' && !Array.isArray(obj);
  19581. }
  19582. function fieldsToFieldsConfig(fields) {
  19583. return (0, _mapValue.default)(fields, function (field) {
  19584. return {
  19585. type: field.type,
  19586. args: argsToArgsConfig(field.args),
  19587. resolve: field.resolve,
  19588. subscribe: field.subscribe,
  19589. deprecationReason: field.deprecationReason,
  19590. description: field.description,
  19591. astNode: field.astNode
  19592. };
  19593. });
  19594. }
  19595. function argsToArgsConfig(args) {
  19596. return (0, _keyValMap.default)(args, function (arg) {
  19597. return arg.name;
  19598. }, function (arg) {
  19599. return {
  19600. type: arg.type,
  19601. defaultValue: arg.defaultValue,
  19602. description: arg.description,
  19603. astNode: arg.astNode
  19604. };
  19605. });
  19606. }
  19607. function isRequiredArgument(arg) {
  19608. return isNonNullType(arg.type) && arg.defaultValue === undefined;
  19609. }
  19610. /**
  19611. * Interface Type Definition
  19612. *
  19613. * When a field can return one of a heterogeneous set of types, a Interface type
  19614. * is used to describe what types are possible, what fields are in common across
  19615. * all types, as well as a function to determine which type is actually used
  19616. * when the field is resolved.
  19617. *
  19618. * Example:
  19619. *
  19620. * const EntityType = new GraphQLInterfaceType({
  19621. * name: 'Entity',
  19622. * fields: {
  19623. * name: { type: GraphQLString }
  19624. * }
  19625. * });
  19626. *
  19627. */
  19628. var GraphQLInterfaceType =
  19629. /*#__PURE__*/
  19630. function () {
  19631. function GraphQLInterfaceType(config) {
  19632. this.name = config.name;
  19633. this.description = config.description;
  19634. this.astNode = config.astNode;
  19635. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19636. this.resolveType = config.resolveType;
  19637. this._fields = defineFieldMap.bind(undefined, config);
  19638. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19639. !(config.resolveType == null || typeof config.resolveType === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"resolveType\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.resolveType), ".")) : void 0;
  19640. }
  19641. var _proto3 = GraphQLInterfaceType.prototype;
  19642. _proto3.getFields = function getFields() {
  19643. if (typeof this._fields === 'function') {
  19644. this._fields = this._fields();
  19645. }
  19646. return this._fields;
  19647. };
  19648. _proto3.toConfig = function toConfig() {
  19649. return {
  19650. name: this.name,
  19651. description: this.description,
  19652. resolveType: this.resolveType,
  19653. fields: fieldsToFieldsConfig(this.getFields()),
  19654. astNode: this.astNode,
  19655. extensionASTNodes: this.extensionASTNodes || []
  19656. };
  19657. };
  19658. _proto3.toString = function toString() {
  19659. return this.name;
  19660. };
  19661. return GraphQLInterfaceType;
  19662. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19663. exports.GraphQLInterfaceType = GraphQLInterfaceType;
  19664. (0, _defineToStringTag.default)(GraphQLInterfaceType);
  19665. (0, _defineToJSON.default)(GraphQLInterfaceType);
  19666. /**
  19667. * Union Type Definition
  19668. *
  19669. * When a field can return one of a heterogeneous set of types, a Union type
  19670. * is used to describe what types are possible as well as providing a function
  19671. * to determine which type is actually used when the field is resolved.
  19672. *
  19673. * Example:
  19674. *
  19675. * const PetType = new GraphQLUnionType({
  19676. * name: 'Pet',
  19677. * types: [ DogType, CatType ],
  19678. * resolveType(value) {
  19679. * if (value instanceof Dog) {
  19680. * return DogType;
  19681. * }
  19682. * if (value instanceof Cat) {
  19683. * return CatType;
  19684. * }
  19685. * }
  19686. * });
  19687. *
  19688. */
  19689. var GraphQLUnionType =
  19690. /*#__PURE__*/
  19691. function () {
  19692. function GraphQLUnionType(config) {
  19693. this.name = config.name;
  19694. this.description = config.description;
  19695. this.astNode = config.astNode;
  19696. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19697. this.resolveType = config.resolveType;
  19698. this._types = defineTypes.bind(undefined, config);
  19699. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19700. !(config.resolveType == null || typeof config.resolveType === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"resolveType\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.resolveType), ".")) : void 0;
  19701. }
  19702. var _proto4 = GraphQLUnionType.prototype;
  19703. _proto4.getTypes = function getTypes() {
  19704. if (typeof this._types === 'function') {
  19705. this._types = this._types();
  19706. }
  19707. return this._types;
  19708. };
  19709. _proto4.toConfig = function toConfig() {
  19710. return {
  19711. name: this.name,
  19712. description: this.description,
  19713. resolveType: this.resolveType,
  19714. types: this.getTypes(),
  19715. astNode: this.astNode,
  19716. extensionASTNodes: this.extensionASTNodes || []
  19717. };
  19718. };
  19719. _proto4.toString = function toString() {
  19720. return this.name;
  19721. };
  19722. return GraphQLUnionType;
  19723. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19724. exports.GraphQLUnionType = GraphQLUnionType;
  19725. (0, _defineToStringTag.default)(GraphQLUnionType);
  19726. (0, _defineToJSON.default)(GraphQLUnionType);
  19727. function defineTypes(config) {
  19728. var types = resolveThunk(config.types) || [];
  19729. !Array.isArray(types) ? (0, _invariant.default)(0, 'Must provide Array of types or a function which returns ' + "such an array for Union ".concat(config.name, ".")) : void 0;
  19730. return types;
  19731. }
  19732. /**
  19733. * Enum Type Definition
  19734. *
  19735. * Some leaf values of requests and input values are Enums. GraphQL serializes
  19736. * Enum values as strings, however internally Enums can be represented by any
  19737. * kind of type, often integers.
  19738. *
  19739. * Example:
  19740. *
  19741. * const RGBType = new GraphQLEnumType({
  19742. * name: 'RGB',
  19743. * values: {
  19744. * RED: { value: 0 },
  19745. * GREEN: { value: 1 },
  19746. * BLUE: { value: 2 }
  19747. * }
  19748. * });
  19749. *
  19750. * Note: If a value is not provided in a definition, the name of the enum value
  19751. * will be used as its internal value.
  19752. */
  19753. var GraphQLEnumType
  19754. /* <T> */
  19755. =
  19756. /*#__PURE__*/
  19757. function () {
  19758. function GraphQLEnumType(config) {
  19759. this.name = config.name;
  19760. this.description = config.description;
  19761. this.astNode = config.astNode;
  19762. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19763. this._values = defineEnumValues(this, config.values);
  19764. this._valueLookup = new Map(this._values.map(function (enumValue) {
  19765. return [enumValue.value, enumValue];
  19766. }));
  19767. this._nameLookup = (0, _keyMap.default)(this._values, function (value) {
  19768. return value.name;
  19769. });
  19770. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19771. }
  19772. var _proto5 = GraphQLEnumType.prototype;
  19773. _proto5.getValues = function getValues() {
  19774. return this._values;
  19775. };
  19776. _proto5.getValue = function getValue(name) {
  19777. return this._nameLookup[name];
  19778. };
  19779. _proto5.serialize = function serialize(value) {
  19780. var enumValue = this._valueLookup.get(value);
  19781. if (enumValue) {
  19782. return enumValue.name;
  19783. }
  19784. };
  19785. _proto5.parseValue = function parseValue(value)
  19786. /* T */
  19787. {
  19788. if (typeof value === 'string') {
  19789. var enumValue = this.getValue(value);
  19790. if (enumValue) {
  19791. return enumValue.value;
  19792. }
  19793. }
  19794. };
  19795. _proto5.parseLiteral = function parseLiteral(valueNode, _variables)
  19796. /* T */
  19797. {
  19798. // Note: variables will be resolved to a value before calling this function.
  19799. if (valueNode.kind === _kinds.Kind.ENUM) {
  19800. var enumValue = this.getValue(valueNode.value);
  19801. if (enumValue) {
  19802. return enumValue.value;
  19803. }
  19804. }
  19805. };
  19806. _proto5.toConfig = function toConfig() {
  19807. var values = (0, _keyValMap.default)(this.getValues(), function (value) {
  19808. return value.name;
  19809. }, function (value) {
  19810. return {
  19811. description: value.description,
  19812. value: value.value,
  19813. deprecationReason: value.deprecationReason,
  19814. astNode: value.astNode
  19815. };
  19816. });
  19817. return {
  19818. name: this.name,
  19819. description: this.description,
  19820. values: values,
  19821. astNode: this.astNode,
  19822. extensionASTNodes: this.extensionASTNodes || []
  19823. };
  19824. };
  19825. _proto5.toString = function toString() {
  19826. return this.name;
  19827. };
  19828. return GraphQLEnumType;
  19829. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19830. exports.GraphQLEnumType = GraphQLEnumType;
  19831. (0, _defineToStringTag.default)(GraphQLEnumType);
  19832. (0, _defineToJSON.default)(GraphQLEnumType);
  19833. function defineEnumValues(type, valueMap) {
  19834. !isPlainObj(valueMap) ? (0, _invariant.default)(0, "".concat(type.name, " values must be an object with value names as keys.")) : void 0;
  19835. return (0, _objectEntries.default)(valueMap).map(function (_ref2) {
  19836. var valueName = _ref2[0],
  19837. value = _ref2[1];
  19838. !isPlainObj(value) ? (0, _invariant.default)(0, "".concat(type.name, ".").concat(valueName, " must refer to an object with a \"value\" key ") + "representing an internal value but got: ".concat((0, _inspect.default)(value), ".")) : void 0;
  19839. !!('isDeprecated' in value) ? (0, _invariant.default)(0, "".concat(type.name, ".").concat(valueName, " should provide \"deprecationReason\" instead ") + 'of "isDeprecated".') : void 0;
  19840. return {
  19841. name: valueName,
  19842. description: value.description,
  19843. isDeprecated: Boolean(value.deprecationReason),
  19844. deprecationReason: value.deprecationReason,
  19845. astNode: value.astNode,
  19846. value: 'value' in value ? value.value : valueName
  19847. };
  19848. });
  19849. }
  19850. /**
  19851. * Input Object Type Definition
  19852. *
  19853. * An input object defines a structured collection of fields which may be
  19854. * supplied to a field argument.
  19855. *
  19856. * Using `NonNull` will ensure that a value must be provided by the query
  19857. *
  19858. * Example:
  19859. *
  19860. * const GeoPoint = new GraphQLInputObjectType({
  19861. * name: 'GeoPoint',
  19862. * fields: {
  19863. * lat: { type: GraphQLNonNull(GraphQLFloat) },
  19864. * lon: { type: GraphQLNonNull(GraphQLFloat) },
  19865. * alt: { type: GraphQLFloat, defaultValue: 0 },
  19866. * }
  19867. * });
  19868. *
  19869. */
  19870. var GraphQLInputObjectType =
  19871. /*#__PURE__*/
  19872. function () {
  19873. function GraphQLInputObjectType(config) {
  19874. this.name = config.name;
  19875. this.description = config.description;
  19876. this.astNode = config.astNode;
  19877. this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
  19878. this._fields = defineInputFieldMap.bind(undefined, config);
  19879. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  19880. }
  19881. var _proto6 = GraphQLInputObjectType.prototype;
  19882. _proto6.getFields = function getFields() {
  19883. if (typeof this._fields === 'function') {
  19884. this._fields = this._fields();
  19885. }
  19886. return this._fields;
  19887. };
  19888. _proto6.toConfig = function toConfig() {
  19889. var fields = (0, _mapValue.default)(this.getFields(), function (field) {
  19890. return {
  19891. description: field.description,
  19892. type: field.type,
  19893. defaultValue: field.defaultValue,
  19894. astNode: field.astNode
  19895. };
  19896. });
  19897. return {
  19898. name: this.name,
  19899. description: this.description,
  19900. fields: fields,
  19901. astNode: this.astNode,
  19902. extensionASTNodes: this.extensionASTNodes || []
  19903. };
  19904. };
  19905. _proto6.toString = function toString() {
  19906. return this.name;
  19907. };
  19908. return GraphQLInputObjectType;
  19909. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19910. exports.GraphQLInputObjectType = GraphQLInputObjectType;
  19911. (0, _defineToStringTag.default)(GraphQLInputObjectType);
  19912. (0, _defineToJSON.default)(GraphQLInputObjectType);
  19913. function defineInputFieldMap(config) {
  19914. var fieldMap = resolveThunk(config.fields) || {};
  19915. !isPlainObj(fieldMap) ? (0, _invariant.default)(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
  19916. return (0, _mapValue.default)(fieldMap, function (fieldConfig, fieldName) {
  19917. !!('resolve' in fieldConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
  19918. return _objectSpread({}, fieldConfig, {
  19919. name: fieldName
  19920. });
  19921. });
  19922. }
  19923. function isRequiredInputField(field) {
  19924. return isNonNullType(field.type) && field.defaultValue === undefined;
  19925. }
  19926. },{"../jsutils/defineToJSON":30,"../jsutils/defineToStringTag":31,"../jsutils/inspect":32,"../jsutils/instanceOf":33,"../jsutils/invariant":34,"../jsutils/keyMap":38,"../jsutils/keyValMap":39,"../jsutils/mapValue":40,"../language/kinds":51,"../polyfills/objectEntries":63,"../utilities/valueFromASTUntyped":99}],69:[function(require,module,exports){
  19927. "use strict";
  19928. Object.defineProperty(exports, "__esModule", {
  19929. value: true
  19930. });
  19931. exports.isDirective = isDirective;
  19932. exports.assertDirective = assertDirective;
  19933. exports.isSpecifiedDirective = isSpecifiedDirective;
  19934. exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0;
  19935. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  19936. var _definition = require("./definition");
  19937. var _scalars = require("./scalars");
  19938. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  19939. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  19940. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  19941. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  19942. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  19943. var _directiveLocation = require("../language/directiveLocation");
  19944. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19945. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  19946. // eslint-disable-next-line no-redeclare
  19947. function isDirective(directive) {
  19948. return (0, _instanceOf.default)(directive, GraphQLDirective);
  19949. }
  19950. function assertDirective(directive) {
  19951. !isDirective(directive) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(directive), " to be a GraphQL directive.")) : void 0;
  19952. return directive;
  19953. }
  19954. /**
  19955. * Directives are used by the GraphQL runtime as a way of modifying execution
  19956. * behavior. Type system creators will usually not create these directly.
  19957. */
  19958. var GraphQLDirective =
  19959. /*#__PURE__*/
  19960. function () {
  19961. function GraphQLDirective(config) {
  19962. this.name = config.name;
  19963. this.description = config.description;
  19964. this.locations = config.locations;
  19965. this.astNode = config.astNode;
  19966. !config.name ? (0, _invariant.default)(0, 'Directive must be named.') : void 0;
  19967. !Array.isArray(config.locations) ? (0, _invariant.default)(0, "@".concat(config.name, " locations must be an Array.")) : void 0;
  19968. var args = config.args || {};
  19969. !(_typeof(args) === 'object' && !Array.isArray(args)) ? (0, _invariant.default)(0, "@".concat(config.name, " args must be an object with argument names as keys.")) : void 0;
  19970. this.args = (0, _objectEntries.default)(args).map(function (_ref) {
  19971. var argName = _ref[0],
  19972. arg = _ref[1];
  19973. return {
  19974. name: argName,
  19975. description: arg.description === undefined ? null : arg.description,
  19976. type: arg.type,
  19977. defaultValue: arg.defaultValue,
  19978. astNode: arg.astNode
  19979. };
  19980. });
  19981. }
  19982. var _proto = GraphQLDirective.prototype;
  19983. _proto.toString = function toString() {
  19984. return '@' + this.name;
  19985. };
  19986. _proto.toConfig = function toConfig() {
  19987. return {
  19988. name: this.name,
  19989. description: this.description,
  19990. locations: this.locations,
  19991. args: (0, _definition.argsToArgsConfig)(this.args),
  19992. astNode: this.astNode
  19993. };
  19994. };
  19995. return GraphQLDirective;
  19996. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  19997. exports.GraphQLDirective = GraphQLDirective;
  19998. (0, _defineToStringTag.default)(GraphQLDirective);
  19999. (0, _defineToJSON.default)(GraphQLDirective);
  20000. /**
  20001. * Used to conditionally include fields or fragments.
  20002. */
  20003. var GraphQLIncludeDirective = new GraphQLDirective({
  20004. name: 'include',
  20005. description: 'Directs the executor to include this field or fragment only when ' + 'the `if` argument is true.',
  20006. locations: [_directiveLocation.DirectiveLocation.FIELD, _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, _directiveLocation.DirectiveLocation.INLINE_FRAGMENT],
  20007. args: {
  20008. if: {
  20009. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  20010. description: 'Included when true.'
  20011. }
  20012. }
  20013. });
  20014. /**
  20015. * Used to conditionally skip (exclude) fields or fragments.
  20016. */
  20017. exports.GraphQLIncludeDirective = GraphQLIncludeDirective;
  20018. var GraphQLSkipDirective = new GraphQLDirective({
  20019. name: 'skip',
  20020. description: 'Directs the executor to skip this field or fragment when the `if` ' + 'argument is true.',
  20021. locations: [_directiveLocation.DirectiveLocation.FIELD, _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, _directiveLocation.DirectiveLocation.INLINE_FRAGMENT],
  20022. args: {
  20023. if: {
  20024. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  20025. description: 'Skipped when true.'
  20026. }
  20027. }
  20028. });
  20029. /**
  20030. * Constant string used for default reason for a deprecation.
  20031. */
  20032. exports.GraphQLSkipDirective = GraphQLSkipDirective;
  20033. var DEFAULT_DEPRECATION_REASON = 'No longer supported';
  20034. /**
  20035. * Used to declare element of a GraphQL schema as deprecated.
  20036. */
  20037. exports.DEFAULT_DEPRECATION_REASON = DEFAULT_DEPRECATION_REASON;
  20038. var GraphQLDeprecatedDirective = new GraphQLDirective({
  20039. name: 'deprecated',
  20040. description: 'Marks an element of a GraphQL schema as no longer supported.',
  20041. locations: [_directiveLocation.DirectiveLocation.FIELD_DEFINITION, _directiveLocation.DirectiveLocation.ENUM_VALUE],
  20042. args: {
  20043. reason: {
  20044. type: _scalars.GraphQLString,
  20045. description: 'Explains why this element was deprecated, usually also including a ' + 'suggestion for how to access supported similar data. Formatted using ' + 'the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).',
  20046. defaultValue: DEFAULT_DEPRECATION_REASON
  20047. }
  20048. }
  20049. });
  20050. /**
  20051. * The full list of specified directives.
  20052. */
  20053. exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective;
  20054. var specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
  20055. exports.specifiedDirectives = specifiedDirectives;
  20056. function isSpecifiedDirective(directive) {
  20057. return isDirective(directive) && specifiedDirectives.some(function (_ref2) {
  20058. var name = _ref2.name;
  20059. return name === directive.name;
  20060. });
  20061. }
  20062. },{"../jsutils/defineToJSON":30,"../jsutils/defineToStringTag":31,"../jsutils/inspect":32,"../jsutils/instanceOf":33,"../jsutils/invariant":34,"../language/directiveLocation":49,"../polyfills/objectEntries":63,"./definition":68,"./scalars":72}],70:[function(require,module,exports){
  20063. "use strict";
  20064. Object.defineProperty(exports, "__esModule", {
  20065. value: true
  20066. });
  20067. Object.defineProperty(exports, "isSchema", {
  20068. enumerable: true,
  20069. get: function get() {
  20070. return _schema.isSchema;
  20071. }
  20072. });
  20073. Object.defineProperty(exports, "assertSchema", {
  20074. enumerable: true,
  20075. get: function get() {
  20076. return _schema.assertSchema;
  20077. }
  20078. });
  20079. Object.defineProperty(exports, "GraphQLSchema", {
  20080. enumerable: true,
  20081. get: function get() {
  20082. return _schema.GraphQLSchema;
  20083. }
  20084. });
  20085. Object.defineProperty(exports, "isType", {
  20086. enumerable: true,
  20087. get: function get() {
  20088. return _definition.isType;
  20089. }
  20090. });
  20091. Object.defineProperty(exports, "isScalarType", {
  20092. enumerable: true,
  20093. get: function get() {
  20094. return _definition.isScalarType;
  20095. }
  20096. });
  20097. Object.defineProperty(exports, "isObjectType", {
  20098. enumerable: true,
  20099. get: function get() {
  20100. return _definition.isObjectType;
  20101. }
  20102. });
  20103. Object.defineProperty(exports, "isInterfaceType", {
  20104. enumerable: true,
  20105. get: function get() {
  20106. return _definition.isInterfaceType;
  20107. }
  20108. });
  20109. Object.defineProperty(exports, "isUnionType", {
  20110. enumerable: true,
  20111. get: function get() {
  20112. return _definition.isUnionType;
  20113. }
  20114. });
  20115. Object.defineProperty(exports, "isEnumType", {
  20116. enumerable: true,
  20117. get: function get() {
  20118. return _definition.isEnumType;
  20119. }
  20120. });
  20121. Object.defineProperty(exports, "isInputObjectType", {
  20122. enumerable: true,
  20123. get: function get() {
  20124. return _definition.isInputObjectType;
  20125. }
  20126. });
  20127. Object.defineProperty(exports, "isListType", {
  20128. enumerable: true,
  20129. get: function get() {
  20130. return _definition.isListType;
  20131. }
  20132. });
  20133. Object.defineProperty(exports, "isNonNullType", {
  20134. enumerable: true,
  20135. get: function get() {
  20136. return _definition.isNonNullType;
  20137. }
  20138. });
  20139. Object.defineProperty(exports, "isInputType", {
  20140. enumerable: true,
  20141. get: function get() {
  20142. return _definition.isInputType;
  20143. }
  20144. });
  20145. Object.defineProperty(exports, "isOutputType", {
  20146. enumerable: true,
  20147. get: function get() {
  20148. return _definition.isOutputType;
  20149. }
  20150. });
  20151. Object.defineProperty(exports, "isLeafType", {
  20152. enumerable: true,
  20153. get: function get() {
  20154. return _definition.isLeafType;
  20155. }
  20156. });
  20157. Object.defineProperty(exports, "isCompositeType", {
  20158. enumerable: true,
  20159. get: function get() {
  20160. return _definition.isCompositeType;
  20161. }
  20162. });
  20163. Object.defineProperty(exports, "isAbstractType", {
  20164. enumerable: true,
  20165. get: function get() {
  20166. return _definition.isAbstractType;
  20167. }
  20168. });
  20169. Object.defineProperty(exports, "isWrappingType", {
  20170. enumerable: true,
  20171. get: function get() {
  20172. return _definition.isWrappingType;
  20173. }
  20174. });
  20175. Object.defineProperty(exports, "isNullableType", {
  20176. enumerable: true,
  20177. get: function get() {
  20178. return _definition.isNullableType;
  20179. }
  20180. });
  20181. Object.defineProperty(exports, "isNamedType", {
  20182. enumerable: true,
  20183. get: function get() {
  20184. return _definition.isNamedType;
  20185. }
  20186. });
  20187. Object.defineProperty(exports, "isRequiredArgument", {
  20188. enumerable: true,
  20189. get: function get() {
  20190. return _definition.isRequiredArgument;
  20191. }
  20192. });
  20193. Object.defineProperty(exports, "isRequiredInputField", {
  20194. enumerable: true,
  20195. get: function get() {
  20196. return _definition.isRequiredInputField;
  20197. }
  20198. });
  20199. Object.defineProperty(exports, "assertType", {
  20200. enumerable: true,
  20201. get: function get() {
  20202. return _definition.assertType;
  20203. }
  20204. });
  20205. Object.defineProperty(exports, "assertScalarType", {
  20206. enumerable: true,
  20207. get: function get() {
  20208. return _definition.assertScalarType;
  20209. }
  20210. });
  20211. Object.defineProperty(exports, "assertObjectType", {
  20212. enumerable: true,
  20213. get: function get() {
  20214. return _definition.assertObjectType;
  20215. }
  20216. });
  20217. Object.defineProperty(exports, "assertInterfaceType", {
  20218. enumerable: true,
  20219. get: function get() {
  20220. return _definition.assertInterfaceType;
  20221. }
  20222. });
  20223. Object.defineProperty(exports, "assertUnionType", {
  20224. enumerable: true,
  20225. get: function get() {
  20226. return _definition.assertUnionType;
  20227. }
  20228. });
  20229. Object.defineProperty(exports, "assertEnumType", {
  20230. enumerable: true,
  20231. get: function get() {
  20232. return _definition.assertEnumType;
  20233. }
  20234. });
  20235. Object.defineProperty(exports, "assertInputObjectType", {
  20236. enumerable: true,
  20237. get: function get() {
  20238. return _definition.assertInputObjectType;
  20239. }
  20240. });
  20241. Object.defineProperty(exports, "assertListType", {
  20242. enumerable: true,
  20243. get: function get() {
  20244. return _definition.assertListType;
  20245. }
  20246. });
  20247. Object.defineProperty(exports, "assertNonNullType", {
  20248. enumerable: true,
  20249. get: function get() {
  20250. return _definition.assertNonNullType;
  20251. }
  20252. });
  20253. Object.defineProperty(exports, "assertInputType", {
  20254. enumerable: true,
  20255. get: function get() {
  20256. return _definition.assertInputType;
  20257. }
  20258. });
  20259. Object.defineProperty(exports, "assertOutputType", {
  20260. enumerable: true,
  20261. get: function get() {
  20262. return _definition.assertOutputType;
  20263. }
  20264. });
  20265. Object.defineProperty(exports, "assertLeafType", {
  20266. enumerable: true,
  20267. get: function get() {
  20268. return _definition.assertLeafType;
  20269. }
  20270. });
  20271. Object.defineProperty(exports, "assertCompositeType", {
  20272. enumerable: true,
  20273. get: function get() {
  20274. return _definition.assertCompositeType;
  20275. }
  20276. });
  20277. Object.defineProperty(exports, "assertAbstractType", {
  20278. enumerable: true,
  20279. get: function get() {
  20280. return _definition.assertAbstractType;
  20281. }
  20282. });
  20283. Object.defineProperty(exports, "assertWrappingType", {
  20284. enumerable: true,
  20285. get: function get() {
  20286. return _definition.assertWrappingType;
  20287. }
  20288. });
  20289. Object.defineProperty(exports, "assertNullableType", {
  20290. enumerable: true,
  20291. get: function get() {
  20292. return _definition.assertNullableType;
  20293. }
  20294. });
  20295. Object.defineProperty(exports, "assertNamedType", {
  20296. enumerable: true,
  20297. get: function get() {
  20298. return _definition.assertNamedType;
  20299. }
  20300. });
  20301. Object.defineProperty(exports, "getNullableType", {
  20302. enumerable: true,
  20303. get: function get() {
  20304. return _definition.getNullableType;
  20305. }
  20306. });
  20307. Object.defineProperty(exports, "getNamedType", {
  20308. enumerable: true,
  20309. get: function get() {
  20310. return _definition.getNamedType;
  20311. }
  20312. });
  20313. Object.defineProperty(exports, "GraphQLScalarType", {
  20314. enumerable: true,
  20315. get: function get() {
  20316. return _definition.GraphQLScalarType;
  20317. }
  20318. });
  20319. Object.defineProperty(exports, "GraphQLObjectType", {
  20320. enumerable: true,
  20321. get: function get() {
  20322. return _definition.GraphQLObjectType;
  20323. }
  20324. });
  20325. Object.defineProperty(exports, "GraphQLInterfaceType", {
  20326. enumerable: true,
  20327. get: function get() {
  20328. return _definition.GraphQLInterfaceType;
  20329. }
  20330. });
  20331. Object.defineProperty(exports, "GraphQLUnionType", {
  20332. enumerable: true,
  20333. get: function get() {
  20334. return _definition.GraphQLUnionType;
  20335. }
  20336. });
  20337. Object.defineProperty(exports, "GraphQLEnumType", {
  20338. enumerable: true,
  20339. get: function get() {
  20340. return _definition.GraphQLEnumType;
  20341. }
  20342. });
  20343. Object.defineProperty(exports, "GraphQLInputObjectType", {
  20344. enumerable: true,
  20345. get: function get() {
  20346. return _definition.GraphQLInputObjectType;
  20347. }
  20348. });
  20349. Object.defineProperty(exports, "GraphQLList", {
  20350. enumerable: true,
  20351. get: function get() {
  20352. return _definition.GraphQLList;
  20353. }
  20354. });
  20355. Object.defineProperty(exports, "GraphQLNonNull", {
  20356. enumerable: true,
  20357. get: function get() {
  20358. return _definition.GraphQLNonNull;
  20359. }
  20360. });
  20361. Object.defineProperty(exports, "isDirective", {
  20362. enumerable: true,
  20363. get: function get() {
  20364. return _directives.isDirective;
  20365. }
  20366. });
  20367. Object.defineProperty(exports, "assertDirective", {
  20368. enumerable: true,
  20369. get: function get() {
  20370. return _directives.assertDirective;
  20371. }
  20372. });
  20373. Object.defineProperty(exports, "GraphQLDirective", {
  20374. enumerable: true,
  20375. get: function get() {
  20376. return _directives.GraphQLDirective;
  20377. }
  20378. });
  20379. Object.defineProperty(exports, "isSpecifiedDirective", {
  20380. enumerable: true,
  20381. get: function get() {
  20382. return _directives.isSpecifiedDirective;
  20383. }
  20384. });
  20385. Object.defineProperty(exports, "specifiedDirectives", {
  20386. enumerable: true,
  20387. get: function get() {
  20388. return _directives.specifiedDirectives;
  20389. }
  20390. });
  20391. Object.defineProperty(exports, "GraphQLIncludeDirective", {
  20392. enumerable: true,
  20393. get: function get() {
  20394. return _directives.GraphQLIncludeDirective;
  20395. }
  20396. });
  20397. Object.defineProperty(exports, "GraphQLSkipDirective", {
  20398. enumerable: true,
  20399. get: function get() {
  20400. return _directives.GraphQLSkipDirective;
  20401. }
  20402. });
  20403. Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
  20404. enumerable: true,
  20405. get: function get() {
  20406. return _directives.GraphQLDeprecatedDirective;
  20407. }
  20408. });
  20409. Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", {
  20410. enumerable: true,
  20411. get: function get() {
  20412. return _directives.DEFAULT_DEPRECATION_REASON;
  20413. }
  20414. });
  20415. Object.defineProperty(exports, "isSpecifiedScalarType", {
  20416. enumerable: true,
  20417. get: function get() {
  20418. return _scalars.isSpecifiedScalarType;
  20419. }
  20420. });
  20421. Object.defineProperty(exports, "specifiedScalarTypes", {
  20422. enumerable: true,
  20423. get: function get() {
  20424. return _scalars.specifiedScalarTypes;
  20425. }
  20426. });
  20427. Object.defineProperty(exports, "GraphQLInt", {
  20428. enumerable: true,
  20429. get: function get() {
  20430. return _scalars.GraphQLInt;
  20431. }
  20432. });
  20433. Object.defineProperty(exports, "GraphQLFloat", {
  20434. enumerable: true,
  20435. get: function get() {
  20436. return _scalars.GraphQLFloat;
  20437. }
  20438. });
  20439. Object.defineProperty(exports, "GraphQLString", {
  20440. enumerable: true,
  20441. get: function get() {
  20442. return _scalars.GraphQLString;
  20443. }
  20444. });
  20445. Object.defineProperty(exports, "GraphQLBoolean", {
  20446. enumerable: true,
  20447. get: function get() {
  20448. return _scalars.GraphQLBoolean;
  20449. }
  20450. });
  20451. Object.defineProperty(exports, "GraphQLID", {
  20452. enumerable: true,
  20453. get: function get() {
  20454. return _scalars.GraphQLID;
  20455. }
  20456. });
  20457. Object.defineProperty(exports, "isIntrospectionType", {
  20458. enumerable: true,
  20459. get: function get() {
  20460. return _introspection.isIntrospectionType;
  20461. }
  20462. });
  20463. Object.defineProperty(exports, "introspectionTypes", {
  20464. enumerable: true,
  20465. get: function get() {
  20466. return _introspection.introspectionTypes;
  20467. }
  20468. });
  20469. Object.defineProperty(exports, "__Schema", {
  20470. enumerable: true,
  20471. get: function get() {
  20472. return _introspection.__Schema;
  20473. }
  20474. });
  20475. Object.defineProperty(exports, "__Directive", {
  20476. enumerable: true,
  20477. get: function get() {
  20478. return _introspection.__Directive;
  20479. }
  20480. });
  20481. Object.defineProperty(exports, "__DirectiveLocation", {
  20482. enumerable: true,
  20483. get: function get() {
  20484. return _introspection.__DirectiveLocation;
  20485. }
  20486. });
  20487. Object.defineProperty(exports, "__Type", {
  20488. enumerable: true,
  20489. get: function get() {
  20490. return _introspection.__Type;
  20491. }
  20492. });
  20493. Object.defineProperty(exports, "__Field", {
  20494. enumerable: true,
  20495. get: function get() {
  20496. return _introspection.__Field;
  20497. }
  20498. });
  20499. Object.defineProperty(exports, "__InputValue", {
  20500. enumerable: true,
  20501. get: function get() {
  20502. return _introspection.__InputValue;
  20503. }
  20504. });
  20505. Object.defineProperty(exports, "__EnumValue", {
  20506. enumerable: true,
  20507. get: function get() {
  20508. return _introspection.__EnumValue;
  20509. }
  20510. });
  20511. Object.defineProperty(exports, "__TypeKind", {
  20512. enumerable: true,
  20513. get: function get() {
  20514. return _introspection.__TypeKind;
  20515. }
  20516. });
  20517. Object.defineProperty(exports, "TypeKind", {
  20518. enumerable: true,
  20519. get: function get() {
  20520. return _introspection.TypeKind;
  20521. }
  20522. });
  20523. Object.defineProperty(exports, "SchemaMetaFieldDef", {
  20524. enumerable: true,
  20525. get: function get() {
  20526. return _introspection.SchemaMetaFieldDef;
  20527. }
  20528. });
  20529. Object.defineProperty(exports, "TypeMetaFieldDef", {
  20530. enumerable: true,
  20531. get: function get() {
  20532. return _introspection.TypeMetaFieldDef;
  20533. }
  20534. });
  20535. Object.defineProperty(exports, "TypeNameMetaFieldDef", {
  20536. enumerable: true,
  20537. get: function get() {
  20538. return _introspection.TypeNameMetaFieldDef;
  20539. }
  20540. });
  20541. Object.defineProperty(exports, "validateSchema", {
  20542. enumerable: true,
  20543. get: function get() {
  20544. return _validate.validateSchema;
  20545. }
  20546. });
  20547. Object.defineProperty(exports, "assertValidSchema", {
  20548. enumerable: true,
  20549. get: function get() {
  20550. return _validate.assertValidSchema;
  20551. }
  20552. });
  20553. var _schema = require("./schema");
  20554. var _definition = require("./definition");
  20555. var _directives = require("./directives");
  20556. var _scalars = require("./scalars");
  20557. var _introspection = require("./introspection");
  20558. var _validate = require("./validate");
  20559. },{"./definition":68,"./directives":69,"./introspection":71,"./scalars":72,"./schema":73,"./validate":74}],71:[function(require,module,exports){
  20560. "use strict";
  20561. Object.defineProperty(exports, "__esModule", {
  20562. value: true
  20563. });
  20564. exports.isIntrospectionType = isIntrospectionType;
  20565. exports.introspectionTypes = exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = void 0;
  20566. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  20567. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  20568. var _astFromValue = require("../utilities/astFromValue");
  20569. var _printer = require("../language/printer");
  20570. var _definition = require("./definition");
  20571. var _scalars = require("./scalars");
  20572. var _directiveLocation = require("../language/directiveLocation");
  20573. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20574. /**
  20575. * Copyright (c) Facebook, Inc. and its affiliates.
  20576. *
  20577. * This source code is licensed under the MIT license found in the
  20578. * LICENSE file in the root directory of this source tree.
  20579. *
  20580. *
  20581. */
  20582. var __Schema = new _definition.GraphQLObjectType({
  20583. name: '__Schema',
  20584. description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' + 'exposes all available types and directives on the server, as well as ' + 'the entry points for query, mutation, and subscription operations.',
  20585. fields: function fields() {
  20586. return {
  20587. types: {
  20588. description: 'A list of all types supported by this server.',
  20589. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type))),
  20590. resolve: function resolve(schema) {
  20591. return (0, _objectValues.default)(schema.getTypeMap());
  20592. }
  20593. },
  20594. queryType: {
  20595. description: 'The type that query operations will be rooted at.',
  20596. type: (0, _definition.GraphQLNonNull)(__Type),
  20597. resolve: function resolve(schema) {
  20598. return schema.getQueryType();
  20599. }
  20600. },
  20601. mutationType: {
  20602. description: 'If this server supports mutation, the type that ' + 'mutation operations will be rooted at.',
  20603. type: __Type,
  20604. resolve: function resolve(schema) {
  20605. return schema.getMutationType();
  20606. }
  20607. },
  20608. subscriptionType: {
  20609. description: 'If this server support subscription, the type that ' + 'subscription operations will be rooted at.',
  20610. type: __Type,
  20611. resolve: function resolve(schema) {
  20612. return schema.getSubscriptionType();
  20613. }
  20614. },
  20615. directives: {
  20616. description: 'A list of all directives supported by this server.',
  20617. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Directive))),
  20618. resolve: function resolve(schema) {
  20619. return schema.getDirectives();
  20620. }
  20621. }
  20622. };
  20623. }
  20624. });
  20625. exports.__Schema = __Schema;
  20626. var __Directive = new _definition.GraphQLObjectType({
  20627. name: '__Directive',
  20628. description: 'A Directive provides a way to describe alternate runtime execution and ' + 'type validation behavior in a GraphQL document.' + "\n\nIn some cases, you need to provide options to alter GraphQL's " + 'execution behavior in ways field arguments will not suffice, such as ' + 'conditionally including or skipping a field. Directives provide this by ' + 'describing additional information to the executor.',
  20629. fields: function fields() {
  20630. return {
  20631. name: {
  20632. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  20633. resolve: function resolve(obj) {
  20634. return obj.name;
  20635. }
  20636. },
  20637. description: {
  20638. type: _scalars.GraphQLString,
  20639. resolve: function resolve(obj) {
  20640. return obj.description;
  20641. }
  20642. },
  20643. locations: {
  20644. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__DirectiveLocation))),
  20645. resolve: function resolve(obj) {
  20646. return obj.locations;
  20647. }
  20648. },
  20649. args: {
  20650. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue))),
  20651. resolve: function resolve(directive) {
  20652. return directive.args || [];
  20653. }
  20654. }
  20655. };
  20656. }
  20657. });
  20658. exports.__Directive = __Directive;
  20659. var __DirectiveLocation = new _definition.GraphQLEnumType({
  20660. name: '__DirectiveLocation',
  20661. description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.',
  20662. values: {
  20663. QUERY: {
  20664. value: _directiveLocation.DirectiveLocation.QUERY,
  20665. description: 'Location adjacent to a query operation.'
  20666. },
  20667. MUTATION: {
  20668. value: _directiveLocation.DirectiveLocation.MUTATION,
  20669. description: 'Location adjacent to a mutation operation.'
  20670. },
  20671. SUBSCRIPTION: {
  20672. value: _directiveLocation.DirectiveLocation.SUBSCRIPTION,
  20673. description: 'Location adjacent to a subscription operation.'
  20674. },
  20675. FIELD: {
  20676. value: _directiveLocation.DirectiveLocation.FIELD,
  20677. description: 'Location adjacent to a field.'
  20678. },
  20679. FRAGMENT_DEFINITION: {
  20680. value: _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION,
  20681. description: 'Location adjacent to a fragment definition.'
  20682. },
  20683. FRAGMENT_SPREAD: {
  20684. value: _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD,
  20685. description: 'Location adjacent to a fragment spread.'
  20686. },
  20687. INLINE_FRAGMENT: {
  20688. value: _directiveLocation.DirectiveLocation.INLINE_FRAGMENT,
  20689. description: 'Location adjacent to an inline fragment.'
  20690. },
  20691. VARIABLE_DEFINITION: {
  20692. value: _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION,
  20693. description: 'Location adjacent to a variable definition.'
  20694. },
  20695. SCHEMA: {
  20696. value: _directiveLocation.DirectiveLocation.SCHEMA,
  20697. description: 'Location adjacent to a schema definition.'
  20698. },
  20699. SCALAR: {
  20700. value: _directiveLocation.DirectiveLocation.SCALAR,
  20701. description: 'Location adjacent to a scalar definition.'
  20702. },
  20703. OBJECT: {
  20704. value: _directiveLocation.DirectiveLocation.OBJECT,
  20705. description: 'Location adjacent to an object type definition.'
  20706. },
  20707. FIELD_DEFINITION: {
  20708. value: _directiveLocation.DirectiveLocation.FIELD_DEFINITION,
  20709. description: 'Location adjacent to a field definition.'
  20710. },
  20711. ARGUMENT_DEFINITION: {
  20712. value: _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION,
  20713. description: 'Location adjacent to an argument definition.'
  20714. },
  20715. INTERFACE: {
  20716. value: _directiveLocation.DirectiveLocation.INTERFACE,
  20717. description: 'Location adjacent to an interface definition.'
  20718. },
  20719. UNION: {
  20720. value: _directiveLocation.DirectiveLocation.UNION,
  20721. description: 'Location adjacent to a union definition.'
  20722. },
  20723. ENUM: {
  20724. value: _directiveLocation.DirectiveLocation.ENUM,
  20725. description: 'Location adjacent to an enum definition.'
  20726. },
  20727. ENUM_VALUE: {
  20728. value: _directiveLocation.DirectiveLocation.ENUM_VALUE,
  20729. description: 'Location adjacent to an enum value definition.'
  20730. },
  20731. INPUT_OBJECT: {
  20732. value: _directiveLocation.DirectiveLocation.INPUT_OBJECT,
  20733. description: 'Location adjacent to an input object type definition.'
  20734. },
  20735. INPUT_FIELD_DEFINITION: {
  20736. value: _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION,
  20737. description: 'Location adjacent to an input object field definition.'
  20738. }
  20739. }
  20740. });
  20741. exports.__DirectiveLocation = __DirectiveLocation;
  20742. var __Type = new _definition.GraphQLObjectType({
  20743. name: '__Type',
  20744. description: 'The fundamental unit of any GraphQL Schema is the type. There are ' + 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' + '\n\nDepending on the kind of a type, certain fields describe ' + 'information about that type. Scalar types provide no information ' + 'beyond a name and description, while Enum types provide their values. ' + 'Object and Interface types provide the fields they describe. Abstract ' + 'types, Union and Interface, provide the Object types possible ' + 'at runtime. List and NonNull types compose other types.',
  20745. fields: function fields() {
  20746. return {
  20747. kind: {
  20748. type: (0, _definition.GraphQLNonNull)(__TypeKind),
  20749. resolve: function resolve(type) {
  20750. if ((0, _definition.isScalarType)(type)) {
  20751. return TypeKind.SCALAR;
  20752. } else if ((0, _definition.isObjectType)(type)) {
  20753. return TypeKind.OBJECT;
  20754. } else if ((0, _definition.isInterfaceType)(type)) {
  20755. return TypeKind.INTERFACE;
  20756. } else if ((0, _definition.isUnionType)(type)) {
  20757. return TypeKind.UNION;
  20758. } else if ((0, _definition.isEnumType)(type)) {
  20759. return TypeKind.ENUM;
  20760. } else if ((0, _definition.isInputObjectType)(type)) {
  20761. return TypeKind.INPUT_OBJECT;
  20762. } else if ((0, _definition.isListType)(type)) {
  20763. return TypeKind.LIST;
  20764. } else if ((0, _definition.isNonNullType)(type)) {
  20765. return TypeKind.NON_NULL;
  20766. } // Not reachable. All possible types have been considered.
  20767. /* istanbul ignore next */
  20768. throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
  20769. }
  20770. },
  20771. name: {
  20772. type: _scalars.GraphQLString,
  20773. resolve: function resolve(obj) {
  20774. return obj.name;
  20775. }
  20776. },
  20777. description: {
  20778. type: _scalars.GraphQLString,
  20779. resolve: function resolve(obj) {
  20780. return obj.description;
  20781. }
  20782. },
  20783. fields: {
  20784. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Field)),
  20785. args: {
  20786. includeDeprecated: {
  20787. type: _scalars.GraphQLBoolean,
  20788. defaultValue: false
  20789. }
  20790. },
  20791. resolve: function resolve(type, _ref) {
  20792. var includeDeprecated = _ref.includeDeprecated;
  20793. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  20794. var fields = (0, _objectValues.default)(type.getFields());
  20795. if (!includeDeprecated) {
  20796. fields = fields.filter(function (field) {
  20797. return !field.deprecationReason;
  20798. });
  20799. }
  20800. return fields;
  20801. }
  20802. return null;
  20803. }
  20804. },
  20805. interfaces: {
  20806. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type)),
  20807. resolve: function resolve(type) {
  20808. if ((0, _definition.isObjectType)(type)) {
  20809. return type.getInterfaces();
  20810. }
  20811. }
  20812. },
  20813. possibleTypes: {
  20814. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type)),
  20815. resolve: function resolve(type, args, context, _ref2) {
  20816. var schema = _ref2.schema;
  20817. if ((0, _definition.isAbstractType)(type)) {
  20818. return schema.getPossibleTypes(type);
  20819. }
  20820. }
  20821. },
  20822. enumValues: {
  20823. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__EnumValue)),
  20824. args: {
  20825. includeDeprecated: {
  20826. type: _scalars.GraphQLBoolean,
  20827. defaultValue: false
  20828. }
  20829. },
  20830. resolve: function resolve(type, _ref3) {
  20831. var includeDeprecated = _ref3.includeDeprecated;
  20832. if ((0, _definition.isEnumType)(type)) {
  20833. var values = type.getValues();
  20834. if (!includeDeprecated) {
  20835. values = values.filter(function (value) {
  20836. return !value.deprecationReason;
  20837. });
  20838. }
  20839. return values;
  20840. }
  20841. }
  20842. },
  20843. inputFields: {
  20844. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue)),
  20845. resolve: function resolve(type) {
  20846. if ((0, _definition.isInputObjectType)(type)) {
  20847. return (0, _objectValues.default)(type.getFields());
  20848. }
  20849. }
  20850. },
  20851. ofType: {
  20852. type: __Type,
  20853. resolve: function resolve(obj) {
  20854. return obj.ofType;
  20855. }
  20856. }
  20857. };
  20858. }
  20859. });
  20860. exports.__Type = __Type;
  20861. var __Field = new _definition.GraphQLObjectType({
  20862. name: '__Field',
  20863. description: 'Object and Interface types are described by a list of Fields, each of ' + 'which has a name, potentially a list of arguments, and a return type.',
  20864. fields: function fields() {
  20865. return {
  20866. name: {
  20867. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  20868. resolve: function resolve(obj) {
  20869. return obj.name;
  20870. }
  20871. },
  20872. description: {
  20873. type: _scalars.GraphQLString,
  20874. resolve: function resolve(obj) {
  20875. return obj.description;
  20876. }
  20877. },
  20878. args: {
  20879. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue))),
  20880. resolve: function resolve(field) {
  20881. return field.args || [];
  20882. }
  20883. },
  20884. type: {
  20885. type: (0, _definition.GraphQLNonNull)(__Type),
  20886. resolve: function resolve(obj) {
  20887. return obj.type;
  20888. }
  20889. },
  20890. isDeprecated: {
  20891. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  20892. resolve: function resolve(obj) {
  20893. return obj.isDeprecated;
  20894. }
  20895. },
  20896. deprecationReason: {
  20897. type: _scalars.GraphQLString,
  20898. resolve: function resolve(obj) {
  20899. return obj.deprecationReason;
  20900. }
  20901. }
  20902. };
  20903. }
  20904. });
  20905. exports.__Field = __Field;
  20906. var __InputValue = new _definition.GraphQLObjectType({
  20907. name: '__InputValue',
  20908. description: 'Arguments provided to Fields or Directives and the input fields of an ' + 'InputObject are represented as Input Values which describe their type ' + 'and optionally a default value.',
  20909. fields: function fields() {
  20910. return {
  20911. name: {
  20912. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  20913. resolve: function resolve(obj) {
  20914. return obj.name;
  20915. }
  20916. },
  20917. description: {
  20918. type: _scalars.GraphQLString,
  20919. resolve: function resolve(obj) {
  20920. return obj.description;
  20921. }
  20922. },
  20923. type: {
  20924. type: (0, _definition.GraphQLNonNull)(__Type),
  20925. resolve: function resolve(obj) {
  20926. return obj.type;
  20927. }
  20928. },
  20929. defaultValue: {
  20930. type: _scalars.GraphQLString,
  20931. description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
  20932. resolve: function resolve(inputVal) {
  20933. var valueAST = (0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type);
  20934. return valueAST ? (0, _printer.print)(valueAST) : null;
  20935. }
  20936. }
  20937. };
  20938. }
  20939. });
  20940. exports.__InputValue = __InputValue;
  20941. var __EnumValue = new _definition.GraphQLObjectType({
  20942. name: '__EnumValue',
  20943. description: 'One possible value for a given Enum. Enum values are unique values, not ' + 'a placeholder for a string or numeric value. However an Enum value is ' + 'returned in a JSON response as a string.',
  20944. fields: function fields() {
  20945. return {
  20946. name: {
  20947. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  20948. resolve: function resolve(obj) {
  20949. return obj.name;
  20950. }
  20951. },
  20952. description: {
  20953. type: _scalars.GraphQLString,
  20954. resolve: function resolve(obj) {
  20955. return obj.description;
  20956. }
  20957. },
  20958. isDeprecated: {
  20959. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  20960. resolve: function resolve(obj) {
  20961. return obj.isDeprecated;
  20962. }
  20963. },
  20964. deprecationReason: {
  20965. type: _scalars.GraphQLString,
  20966. resolve: function resolve(obj) {
  20967. return obj.deprecationReason;
  20968. }
  20969. }
  20970. };
  20971. }
  20972. });
  20973. exports.__EnumValue = __EnumValue;
  20974. var TypeKind = {
  20975. SCALAR: 'SCALAR',
  20976. OBJECT: 'OBJECT',
  20977. INTERFACE: 'INTERFACE',
  20978. UNION: 'UNION',
  20979. ENUM: 'ENUM',
  20980. INPUT_OBJECT: 'INPUT_OBJECT',
  20981. LIST: 'LIST',
  20982. NON_NULL: 'NON_NULL'
  20983. };
  20984. exports.TypeKind = TypeKind;
  20985. var __TypeKind = new _definition.GraphQLEnumType({
  20986. name: '__TypeKind',
  20987. description: 'An enum describing what kind of type a given `__Type` is.',
  20988. values: {
  20989. SCALAR: {
  20990. value: TypeKind.SCALAR,
  20991. description: 'Indicates this type is a scalar.'
  20992. },
  20993. OBJECT: {
  20994. value: TypeKind.OBJECT,
  20995. description: 'Indicates this type is an object. ' + '`fields` and `interfaces` are valid fields.'
  20996. },
  20997. INTERFACE: {
  20998. value: TypeKind.INTERFACE,
  20999. description: 'Indicates this type is an interface. ' + '`fields` and `possibleTypes` are valid fields.'
  21000. },
  21001. UNION: {
  21002. value: TypeKind.UNION,
  21003. description: 'Indicates this type is a union. `possibleTypes` is a valid field.'
  21004. },
  21005. ENUM: {
  21006. value: TypeKind.ENUM,
  21007. description: 'Indicates this type is an enum. `enumValues` is a valid field.'
  21008. },
  21009. INPUT_OBJECT: {
  21010. value: TypeKind.INPUT_OBJECT,
  21011. description: 'Indicates this type is an input object. ' + '`inputFields` is a valid field.'
  21012. },
  21013. LIST: {
  21014. value: TypeKind.LIST,
  21015. description: 'Indicates this type is a list. `ofType` is a valid field.'
  21016. },
  21017. NON_NULL: {
  21018. value: TypeKind.NON_NULL,
  21019. description: 'Indicates this type is a non-null. `ofType` is a valid field.'
  21020. }
  21021. }
  21022. });
  21023. /**
  21024. * Note that these are GraphQLField and not GraphQLFieldConfig,
  21025. * so the format for args is different.
  21026. */
  21027. exports.__TypeKind = __TypeKind;
  21028. var SchemaMetaFieldDef = {
  21029. name: '__schema',
  21030. type: (0, _definition.GraphQLNonNull)(__Schema),
  21031. description: 'Access the current type schema of this server.',
  21032. args: [],
  21033. resolve: function resolve(source, args, context, _ref4) {
  21034. var schema = _ref4.schema;
  21035. return schema;
  21036. }
  21037. };
  21038. exports.SchemaMetaFieldDef = SchemaMetaFieldDef;
  21039. var TypeMetaFieldDef = {
  21040. name: '__type',
  21041. type: __Type,
  21042. description: 'Request the type information of a single type.',
  21043. args: [{
  21044. name: 'name',
  21045. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString)
  21046. }],
  21047. resolve: function resolve(source, _ref5, context, _ref6) {
  21048. var name = _ref5.name;
  21049. var schema = _ref6.schema;
  21050. return schema.getType(name);
  21051. }
  21052. };
  21053. exports.TypeMetaFieldDef = TypeMetaFieldDef;
  21054. var TypeNameMetaFieldDef = {
  21055. name: '__typename',
  21056. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  21057. description: 'The name of the current Object type at runtime.',
  21058. args: [],
  21059. resolve: function resolve(source, args, context, _ref7) {
  21060. var parentType = _ref7.parentType;
  21061. return parentType.name;
  21062. }
  21063. };
  21064. exports.TypeNameMetaFieldDef = TypeNameMetaFieldDef;
  21065. var introspectionTypes = [__Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind];
  21066. exports.introspectionTypes = introspectionTypes;
  21067. function isIntrospectionType(type) {
  21068. return (0, _definition.isNamedType)(type) && introspectionTypes.some(function (_ref8) {
  21069. var name = _ref8.name;
  21070. return type.name === name;
  21071. });
  21072. }
  21073. },{"../jsutils/inspect":32,"../language/directiveLocation":49,"../language/printer":56,"../polyfills/objectValues":64,"../utilities/astFromValue":77,"./definition":68,"./scalars":72}],72:[function(require,module,exports){
  21074. "use strict";
  21075. Object.defineProperty(exports, "__esModule", {
  21076. value: true
  21077. });
  21078. exports.isSpecifiedScalarType = isSpecifiedScalarType;
  21079. exports.specifiedScalarTypes = exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = void 0;
  21080. var _isFinite = _interopRequireDefault(require("../polyfills/isFinite"));
  21081. var _isInteger = _interopRequireDefault(require("../polyfills/isInteger"));
  21082. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  21083. var _definition = require("./definition");
  21084. var _kinds = require("../language/kinds");
  21085. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21086. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  21087. // As per the GraphQL Spec, Integers are only treated as valid when a valid
  21088. // 32-bit signed integer, providing the broadest support across platforms.
  21089. //
  21090. // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
  21091. // they are internally represented as IEEE 754 doubles.
  21092. var MAX_INT = 2147483647;
  21093. var MIN_INT = -2147483648;
  21094. function serializeInt(value) {
  21095. if (typeof value === 'boolean') {
  21096. return value ? 1 : 0;
  21097. }
  21098. var num = value;
  21099. if (typeof value === 'string' && value !== '') {
  21100. num = Number(value);
  21101. }
  21102. if (!(0, _isInteger.default)(num)) {
  21103. throw new TypeError("Int cannot represent non-integer value: ".concat((0, _inspect.default)(value)));
  21104. }
  21105. if (num > MAX_INT || num < MIN_INT) {
  21106. throw new TypeError("Int cannot represent non 32-bit signed integer value: ".concat((0, _inspect.default)(value)));
  21107. }
  21108. return num;
  21109. }
  21110. function coerceInt(value) {
  21111. if (!(0, _isInteger.default)(value)) {
  21112. throw new TypeError("Int cannot represent non-integer value: ".concat((0, _inspect.default)(value)));
  21113. }
  21114. if (value > MAX_INT || value < MIN_INT) {
  21115. throw new TypeError("Int cannot represent non 32-bit signed integer value: ".concat((0, _inspect.default)(value)));
  21116. }
  21117. return value;
  21118. }
  21119. var GraphQLInt = new _definition.GraphQLScalarType({
  21120. name: 'Int',
  21121. description: 'The `Int` scalar type represents non-fractional signed whole numeric ' + 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
  21122. serialize: serializeInt,
  21123. parseValue: coerceInt,
  21124. parseLiteral: function parseLiteral(ast) {
  21125. if (ast.kind === _kinds.Kind.INT) {
  21126. var num = parseInt(ast.value, 10);
  21127. if (num <= MAX_INT && num >= MIN_INT) {
  21128. return num;
  21129. }
  21130. }
  21131. return undefined;
  21132. }
  21133. });
  21134. exports.GraphQLInt = GraphQLInt;
  21135. function serializeFloat(value) {
  21136. if (typeof value === 'boolean') {
  21137. return value ? 1 : 0;
  21138. }
  21139. var num = value;
  21140. if (typeof value === 'string' && value !== '') {
  21141. num = Number(value);
  21142. }
  21143. if (!(0, _isFinite.default)(num)) {
  21144. throw new TypeError("Float cannot represent non numeric value: ".concat((0, _inspect.default)(value)));
  21145. }
  21146. return num;
  21147. }
  21148. function coerceFloat(value) {
  21149. if (!(0, _isFinite.default)(value)) {
  21150. throw new TypeError("Float cannot represent non numeric value: ".concat((0, _inspect.default)(value)));
  21151. }
  21152. return value;
  21153. }
  21154. var GraphQLFloat = new _definition.GraphQLScalarType({
  21155. name: 'Float',
  21156. description: 'The `Float` scalar type represents signed double-precision fractional ' + 'values as specified by ' + '[IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point). ',
  21157. serialize: serializeFloat,
  21158. parseValue: coerceFloat,
  21159. parseLiteral: function parseLiteral(ast) {
  21160. return ast.kind === _kinds.Kind.FLOAT || ast.kind === _kinds.Kind.INT ? parseFloat(ast.value) : undefined;
  21161. }
  21162. }); // Support serializing objects with custom valueOf() or toJSON() functions -
  21163. // a common way to represent a complex value which can be represented as
  21164. // a string (ex: MongoDB id objects).
  21165. exports.GraphQLFloat = GraphQLFloat;
  21166. function serializeObject(value) {
  21167. if (_typeof(value) === 'object' && value !== null) {
  21168. if (typeof value.valueOf === 'function') {
  21169. var valueOfResult = value.valueOf();
  21170. if (_typeof(valueOfResult) !== 'object') {
  21171. return valueOfResult;
  21172. }
  21173. }
  21174. if (typeof value.toJSON === 'function') {
  21175. // $FlowFixMe(>=0.90.0)
  21176. return value.toJSON();
  21177. }
  21178. }
  21179. return value;
  21180. }
  21181. function serializeString(rawValue) {
  21182. var value = serializeObject(rawValue); // Serialize string, boolean and number values to a string, but do not
  21183. // attempt to coerce object, function, symbol, or other types as strings.
  21184. if (typeof value === 'string') {
  21185. return value;
  21186. }
  21187. if (typeof value === 'boolean') {
  21188. return value ? 'true' : 'false';
  21189. }
  21190. if ((0, _isFinite.default)(value)) {
  21191. return value.toString();
  21192. }
  21193. throw new TypeError("String cannot represent value: ".concat((0, _inspect.default)(rawValue)));
  21194. }
  21195. function coerceString(value) {
  21196. if (typeof value !== 'string') {
  21197. throw new TypeError("String cannot represent a non string value: ".concat((0, _inspect.default)(value)));
  21198. }
  21199. return value;
  21200. }
  21201. var GraphQLString = new _definition.GraphQLScalarType({
  21202. name: 'String',
  21203. description: 'The `String` scalar type represents textual data, represented as UTF-8 ' + 'character sequences. The String type is most often used by GraphQL to ' + 'represent free-form human-readable text.',
  21204. serialize: serializeString,
  21205. parseValue: coerceString,
  21206. parseLiteral: function parseLiteral(ast) {
  21207. return ast.kind === _kinds.Kind.STRING ? ast.value : undefined;
  21208. }
  21209. });
  21210. exports.GraphQLString = GraphQLString;
  21211. function serializeBoolean(value) {
  21212. if (typeof value === 'boolean') {
  21213. return value;
  21214. }
  21215. if ((0, _isFinite.default)(value)) {
  21216. return value !== 0;
  21217. }
  21218. throw new TypeError("Boolean cannot represent a non boolean value: ".concat((0, _inspect.default)(value)));
  21219. }
  21220. function coerceBoolean(value) {
  21221. if (typeof value !== 'boolean') {
  21222. throw new TypeError("Boolean cannot represent a non boolean value: ".concat((0, _inspect.default)(value)));
  21223. }
  21224. return value;
  21225. }
  21226. var GraphQLBoolean = new _definition.GraphQLScalarType({
  21227. name: 'Boolean',
  21228. description: 'The `Boolean` scalar type represents `true` or `false`.',
  21229. serialize: serializeBoolean,
  21230. parseValue: coerceBoolean,
  21231. parseLiteral: function parseLiteral(ast) {
  21232. return ast.kind === _kinds.Kind.BOOLEAN ? ast.value : undefined;
  21233. }
  21234. });
  21235. exports.GraphQLBoolean = GraphQLBoolean;
  21236. function serializeID(rawValue) {
  21237. var value = serializeObject(rawValue);
  21238. if (typeof value === 'string') {
  21239. return value;
  21240. }
  21241. if ((0, _isInteger.default)(value)) {
  21242. return String(value);
  21243. }
  21244. throw new TypeError("ID cannot represent value: ".concat((0, _inspect.default)(rawValue)));
  21245. }
  21246. function coerceID(value) {
  21247. if (typeof value === 'string') {
  21248. return value;
  21249. }
  21250. if ((0, _isInteger.default)(value)) {
  21251. return value.toString();
  21252. }
  21253. throw new TypeError("ID cannot represent value: ".concat((0, _inspect.default)(value)));
  21254. }
  21255. var GraphQLID = new _definition.GraphQLScalarType({
  21256. name: 'ID',
  21257. description: 'The `ID` scalar type represents a unique identifier, often used to ' + 'refetch an object or as key for a cache. The ID type appears in a JSON ' + 'response as a String; however, it is not intended to be human-readable. ' + 'When expected as an input type, any string (such as `"4"`) or integer ' + '(such as `4`) input value will be accepted as an ID.',
  21258. serialize: serializeID,
  21259. parseValue: coerceID,
  21260. parseLiteral: function parseLiteral(ast) {
  21261. return ast.kind === _kinds.Kind.STRING || ast.kind === _kinds.Kind.INT ? ast.value : undefined;
  21262. }
  21263. });
  21264. exports.GraphQLID = GraphQLID;
  21265. var specifiedScalarTypes = [GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID];
  21266. exports.specifiedScalarTypes = specifiedScalarTypes;
  21267. function isSpecifiedScalarType(type) {
  21268. return (0, _definition.isScalarType)(type) && specifiedScalarTypes.some(function (_ref) {
  21269. var name = _ref.name;
  21270. return type.name === name;
  21271. });
  21272. }
  21273. },{"../jsutils/inspect":32,"../language/kinds":51,"../polyfills/isFinite":61,"../polyfills/isInteger":62,"./definition":68}],73:[function(require,module,exports){
  21274. "use strict";
  21275. Object.defineProperty(exports, "__esModule", {
  21276. value: true
  21277. });
  21278. exports.isSchema = isSchema;
  21279. exports.assertSchema = assertSchema;
  21280. exports.GraphQLSchema = void 0;
  21281. var _find = _interopRequireDefault(require("../polyfills/find"));
  21282. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  21283. var _definition = require("./definition");
  21284. var _directives = require("./directives");
  21285. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  21286. var _introspection = require("./introspection");
  21287. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  21288. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  21289. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  21290. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21291. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  21292. // eslint-disable-next-line no-redeclare
  21293. function isSchema(schema) {
  21294. return (0, _instanceOf.default)(schema, GraphQLSchema);
  21295. }
  21296. function assertSchema(schema) {
  21297. !isSchema(schema) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(schema), " to be a GraphQL schema.")) : void 0;
  21298. return schema;
  21299. }
  21300. /**
  21301. * Schema Definition
  21302. *
  21303. * A Schema is created by supplying the root types of each type of operation,
  21304. * query and mutation (optional). A schema definition is then supplied to the
  21305. * validator and executor.
  21306. *
  21307. * Example:
  21308. *
  21309. * const MyAppSchema = new GraphQLSchema({
  21310. * query: MyAppQueryRootType,
  21311. * mutation: MyAppMutationRootType,
  21312. * })
  21313. *
  21314. * Note: When the schema is constructed, by default only the types that are
  21315. * reachable by traversing the root types are included, other types must be
  21316. * explicitly referenced.
  21317. *
  21318. * Example:
  21319. *
  21320. * const characterInterface = new GraphQLInterfaceType({
  21321. * name: 'Character',
  21322. * ...
  21323. * });
  21324. *
  21325. * const humanType = new GraphQLObjectType({
  21326. * name: 'Human',
  21327. * interfaces: [characterInterface],
  21328. * ...
  21329. * });
  21330. *
  21331. * const droidType = new GraphQLObjectType({
  21332. * name: 'Droid',
  21333. * interfaces: [characterInterface],
  21334. * ...
  21335. * });
  21336. *
  21337. * const schema = new GraphQLSchema({
  21338. * query: new GraphQLObjectType({
  21339. * name: 'Query',
  21340. * fields: {
  21341. * hero: { type: characterInterface, ... },
  21342. * }
  21343. * }),
  21344. * ...
  21345. * // Since this schema references only the `Character` interface it's
  21346. * // necessary to explicitly list the types that implement it if
  21347. * // you want them to be included in the final schema.
  21348. * types: [humanType, droidType],
  21349. * })
  21350. *
  21351. * Note: If an array of `directives` are provided to GraphQLSchema, that will be
  21352. * the exact list of directives represented and allowed. If `directives` is not
  21353. * provided then a default set of the specified directives (e.g. @include and
  21354. * @skip) will be used. If you wish to provide *additional* directives to these
  21355. * specified directives, you must explicitly declare them. Example:
  21356. *
  21357. * const MyAppSchema = new GraphQLSchema({
  21358. * ...
  21359. * directives: specifiedDirectives.concat([ myCustomDirective ]),
  21360. * })
  21361. *
  21362. */
  21363. var GraphQLSchema =
  21364. /*#__PURE__*/
  21365. function () {
  21366. // Used as a cache for validateSchema().
  21367. // Referenced by validateSchema().
  21368. function GraphQLSchema(config) {
  21369. // If this schema was built from a source known to be valid, then it may be
  21370. // marked with assumeValid to avoid an additional type system validation.
  21371. if (config && config.assumeValid) {
  21372. this.__validationErrors = [];
  21373. } else {
  21374. this.__validationErrors = undefined; // Otherwise check for common mistakes during construction to produce
  21375. // clear and early error messages.
  21376. !(_typeof(config) === 'object') ? (0, _invariant.default)(0, 'Must provide configuration object.') : void 0;
  21377. !(!config.types || Array.isArray(config.types)) ? (0, _invariant.default)(0, "\"types\" must be Array if provided but got: ".concat((0, _inspect.default)(config.types), ".")) : void 0;
  21378. !(!config.directives || Array.isArray(config.directives)) ? (0, _invariant.default)(0, '"directives" must be Array if provided but got: ' + "".concat((0, _inspect.default)(config.directives), ".")) : void 0;
  21379. !(!config.allowedLegacyNames || Array.isArray(config.allowedLegacyNames)) ? (0, _invariant.default)(0, '"allowedLegacyNames" must be Array if provided but got: ' + "".concat((0, _inspect.default)(config.allowedLegacyNames), ".")) : void 0;
  21380. }
  21381. this.__allowedLegacyNames = config.allowedLegacyNames || [];
  21382. this._queryType = config.query;
  21383. this._mutationType = config.mutation;
  21384. this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default.
  21385. this._directives = config.directives || _directives.specifiedDirectives;
  21386. this.astNode = config.astNode;
  21387. this.extensionASTNodes = config.extensionASTNodes; // Build type map now to detect any errors within this schema.
  21388. var initialTypes = [this.getQueryType(), this.getMutationType(), this.getSubscriptionType(), _introspection.__Schema];
  21389. var types = config.types;
  21390. if (types) {
  21391. initialTypes = initialTypes.concat(types);
  21392. } // Keep track of all types referenced within the schema.
  21393. var typeMap = Object.create(null); // First by deeply visiting all initial types.
  21394. typeMap = initialTypes.reduce(typeMapReducer, typeMap); // Then by deeply visiting all directive types.
  21395. typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap); // Storing the resulting map for reference by the schema.
  21396. this._typeMap = typeMap;
  21397. this._possibleTypeMap = Object.create(null); // Keep track of all implementations by interface name.
  21398. this._implementations = Object.create(null);
  21399. var _iteratorNormalCompletion = true;
  21400. var _didIteratorError = false;
  21401. var _iteratorError = undefined;
  21402. try {
  21403. for (var _iterator = (0, _objectValues.default)(this._typeMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  21404. var type = _step.value;
  21405. if ((0, _definition.isObjectType)(type)) {
  21406. var _iteratorNormalCompletion2 = true;
  21407. var _didIteratorError2 = false;
  21408. var _iteratorError2 = undefined;
  21409. try {
  21410. for (var _iterator2 = type.getInterfaces()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  21411. var iface = _step2.value;
  21412. if ((0, _definition.isInterfaceType)(iface)) {
  21413. var impls = this._implementations[iface.name];
  21414. if (impls) {
  21415. impls.push(type);
  21416. } else {
  21417. this._implementations[iface.name] = [type];
  21418. }
  21419. }
  21420. }
  21421. } catch (err) {
  21422. _didIteratorError2 = true;
  21423. _iteratorError2 = err;
  21424. } finally {
  21425. try {
  21426. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  21427. _iterator2.return();
  21428. }
  21429. } finally {
  21430. if (_didIteratorError2) {
  21431. throw _iteratorError2;
  21432. }
  21433. }
  21434. }
  21435. } else if ((0, _definition.isAbstractType)(type) && !this._implementations[type.name]) {
  21436. this._implementations[type.name] = [];
  21437. }
  21438. }
  21439. } catch (err) {
  21440. _didIteratorError = true;
  21441. _iteratorError = err;
  21442. } finally {
  21443. try {
  21444. if (!_iteratorNormalCompletion && _iterator.return != null) {
  21445. _iterator.return();
  21446. }
  21447. } finally {
  21448. if (_didIteratorError) {
  21449. throw _iteratorError;
  21450. }
  21451. }
  21452. }
  21453. }
  21454. var _proto = GraphQLSchema.prototype;
  21455. _proto.getQueryType = function getQueryType() {
  21456. return this._queryType;
  21457. };
  21458. _proto.getMutationType = function getMutationType() {
  21459. return this._mutationType;
  21460. };
  21461. _proto.getSubscriptionType = function getSubscriptionType() {
  21462. return this._subscriptionType;
  21463. };
  21464. _proto.getTypeMap = function getTypeMap() {
  21465. return this._typeMap;
  21466. };
  21467. _proto.getType = function getType(name) {
  21468. return this.getTypeMap()[name];
  21469. };
  21470. _proto.getPossibleTypes = function getPossibleTypes(abstractType) {
  21471. if ((0, _definition.isUnionType)(abstractType)) {
  21472. return abstractType.getTypes();
  21473. }
  21474. return this._implementations[abstractType.name];
  21475. };
  21476. _proto.isPossibleType = function isPossibleType(abstractType, possibleType) {
  21477. var possibleTypeMap = this._possibleTypeMap;
  21478. if (!possibleTypeMap[abstractType.name]) {
  21479. var possibleTypes = this.getPossibleTypes(abstractType);
  21480. possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
  21481. map[type.name] = true;
  21482. return map;
  21483. }, Object.create(null));
  21484. }
  21485. return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
  21486. };
  21487. _proto.getDirectives = function getDirectives() {
  21488. return this._directives;
  21489. };
  21490. _proto.getDirective = function getDirective(name) {
  21491. return (0, _find.default)(this.getDirectives(), function (directive) {
  21492. return directive.name === name;
  21493. });
  21494. };
  21495. _proto.toConfig = function toConfig() {
  21496. return {
  21497. types: (0, _objectValues.default)(this.getTypeMap()),
  21498. directives: this.getDirectives().slice(),
  21499. query: this.getQueryType(),
  21500. mutation: this.getMutationType(),
  21501. subscription: this.getSubscriptionType(),
  21502. astNode: this.astNode,
  21503. extensionASTNodes: this.extensionASTNodes || [],
  21504. assumeValid: this.__validationErrors !== undefined,
  21505. allowedLegacyNames: this.__allowedLegacyNames
  21506. };
  21507. };
  21508. return GraphQLSchema;
  21509. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  21510. exports.GraphQLSchema = GraphQLSchema;
  21511. (0, _defineToStringTag.default)(GraphQLSchema);
  21512. function typeMapReducer(map, type) {
  21513. if (!type) {
  21514. return map;
  21515. }
  21516. if ((0, _definition.isWrappingType)(type)) {
  21517. return typeMapReducer(map, type.ofType);
  21518. }
  21519. if (map[type.name]) {
  21520. !(map[type.name] === type) ? (0, _invariant.default)(0, 'Schema must contain uniquely named types but contains multiple ' + "types named \"".concat(type.name, "\".")) : void 0;
  21521. return map;
  21522. }
  21523. map[type.name] = type;
  21524. var reducedMap = map;
  21525. if ((0, _definition.isUnionType)(type)) {
  21526. reducedMap = type.getTypes().reduce(typeMapReducer, reducedMap);
  21527. }
  21528. if ((0, _definition.isObjectType)(type)) {
  21529. reducedMap = type.getInterfaces().reduce(typeMapReducer, reducedMap);
  21530. }
  21531. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  21532. var _iteratorNormalCompletion3 = true;
  21533. var _didIteratorError3 = false;
  21534. var _iteratorError3 = undefined;
  21535. try {
  21536. for (var _iterator3 = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  21537. var field = _step3.value;
  21538. if (field.args) {
  21539. var fieldArgTypes = field.args.map(function (arg) {
  21540. return arg.type;
  21541. });
  21542. reducedMap = fieldArgTypes.reduce(typeMapReducer, reducedMap);
  21543. }
  21544. reducedMap = typeMapReducer(reducedMap, field.type);
  21545. }
  21546. } catch (err) {
  21547. _didIteratorError3 = true;
  21548. _iteratorError3 = err;
  21549. } finally {
  21550. try {
  21551. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  21552. _iterator3.return();
  21553. }
  21554. } finally {
  21555. if (_didIteratorError3) {
  21556. throw _iteratorError3;
  21557. }
  21558. }
  21559. }
  21560. }
  21561. if ((0, _definition.isInputObjectType)(type)) {
  21562. var _iteratorNormalCompletion4 = true;
  21563. var _didIteratorError4 = false;
  21564. var _iteratorError4 = undefined;
  21565. try {
  21566. for (var _iterator4 = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  21567. var _field = _step4.value;
  21568. reducedMap = typeMapReducer(reducedMap, _field.type);
  21569. }
  21570. } catch (err) {
  21571. _didIteratorError4 = true;
  21572. _iteratorError4 = err;
  21573. } finally {
  21574. try {
  21575. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  21576. _iterator4.return();
  21577. }
  21578. } finally {
  21579. if (_didIteratorError4) {
  21580. throw _iteratorError4;
  21581. }
  21582. }
  21583. }
  21584. }
  21585. return reducedMap;
  21586. }
  21587. function typeMapDirectiveReducer(map, directive) {
  21588. // Directives are not validated until validateSchema() is called.
  21589. if (!(0, _directives.isDirective)(directive)) {
  21590. return map;
  21591. }
  21592. return directive.args.reduce(function (_map, arg) {
  21593. return typeMapReducer(_map, arg.type);
  21594. }, map);
  21595. }
  21596. },{"../jsutils/defineToStringTag":31,"../jsutils/inspect":32,"../jsutils/instanceOf":33,"../jsutils/invariant":34,"../polyfills/find":59,"../polyfills/objectValues":64,"./definition":68,"./directives":69,"./introspection":71}],74:[function(require,module,exports){
  21597. "use strict";
  21598. Object.defineProperty(exports, "__esModule", {
  21599. value: true
  21600. });
  21601. exports.validateSchema = validateSchema;
  21602. exports.assertValidSchema = assertValidSchema;
  21603. var _find = _interopRequireDefault(require("../polyfills/find"));
  21604. var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
  21605. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  21606. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  21607. var _definition = require("./definition");
  21608. var _directives = require("./directives");
  21609. var _introspection = require("./introspection");
  21610. var _schema = require("./schema");
  21611. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  21612. var _GraphQLError = require("../error/GraphQLError");
  21613. var _assertValidName = require("../utilities/assertValidName");
  21614. var _typeComparators = require("../utilities/typeComparators");
  21615. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21616. /**
  21617. * Copyright (c) Facebook, Inc. and its affiliates.
  21618. *
  21619. * This source code is licensed under the MIT license found in the
  21620. * LICENSE file in the root directory of this source tree.
  21621. *
  21622. *
  21623. */
  21624. /**
  21625. * Implements the "Type Validation" sub-sections of the specification's
  21626. * "Type System" section.
  21627. *
  21628. * Validation runs synchronously, returning an array of encountered errors, or
  21629. * an empty array if no errors were encountered and the Schema is valid.
  21630. */
  21631. function validateSchema(schema) {
  21632. // First check to ensure the provided value is in fact a GraphQLSchema.
  21633. (0, _schema.assertSchema)(schema); // If this Schema has already been validated, return the previous results.
  21634. if (schema.__validationErrors) {
  21635. return schema.__validationErrors;
  21636. } // Validate the schema, producing a list of errors.
  21637. var context = new SchemaValidationContext(schema);
  21638. validateRootTypes(context);
  21639. validateDirectives(context);
  21640. validateTypes(context); // Persist the results of validation before returning to ensure validation
  21641. // does not run multiple times for this schema.
  21642. var errors = context.getErrors();
  21643. schema.__validationErrors = errors;
  21644. return errors;
  21645. }
  21646. /**
  21647. * Utility function which asserts a schema is valid by throwing an error if
  21648. * it is invalid.
  21649. */
  21650. function assertValidSchema(schema) {
  21651. var errors = validateSchema(schema);
  21652. if (errors.length !== 0) {
  21653. throw new Error(errors.map(function (error) {
  21654. return error.message;
  21655. }).join('\n\n'));
  21656. }
  21657. }
  21658. var SchemaValidationContext =
  21659. /*#__PURE__*/
  21660. function () {
  21661. function SchemaValidationContext(schema) {
  21662. this._errors = [];
  21663. this.schema = schema;
  21664. }
  21665. var _proto = SchemaValidationContext.prototype;
  21666. _proto.reportError = function reportError(message, nodes) {
  21667. var _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes;
  21668. this.addError(new _GraphQLError.GraphQLError(message, _nodes));
  21669. };
  21670. _proto.addError = function addError(error) {
  21671. this._errors.push(error);
  21672. };
  21673. _proto.getErrors = function getErrors() {
  21674. return this._errors;
  21675. };
  21676. return SchemaValidationContext;
  21677. }();
  21678. function validateRootTypes(context) {
  21679. var schema = context.schema;
  21680. var queryType = schema.getQueryType();
  21681. if (!queryType) {
  21682. context.reportError("Query root type must be provided.", schema.astNode);
  21683. } else if (!(0, _definition.isObjectType)(queryType)) {
  21684. context.reportError("Query root type must be Object type, it cannot be ".concat((0, _inspect.default)(queryType), "."), getOperationTypeNode(schema, queryType, 'query'));
  21685. }
  21686. var mutationType = schema.getMutationType();
  21687. if (mutationType && !(0, _definition.isObjectType)(mutationType)) {
  21688. context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(mutationType), "."), getOperationTypeNode(schema, mutationType, 'mutation'));
  21689. }
  21690. var subscriptionType = schema.getSubscriptionType();
  21691. if (subscriptionType && !(0, _definition.isObjectType)(subscriptionType)) {
  21692. context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(subscriptionType), "."), getOperationTypeNode(schema, subscriptionType, 'subscription'));
  21693. }
  21694. }
  21695. function getOperationTypeNode(schema, type, operation) {
  21696. var operationNodes = getAllSubNodes(schema, function (node) {
  21697. return node.operationTypes;
  21698. });
  21699. var _iteratorNormalCompletion = true;
  21700. var _didIteratorError = false;
  21701. var _iteratorError = undefined;
  21702. try {
  21703. for (var _iterator = operationNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  21704. var node = _step.value;
  21705. if (node.operation === operation) {
  21706. return node.type;
  21707. }
  21708. }
  21709. } catch (err) {
  21710. _didIteratorError = true;
  21711. _iteratorError = err;
  21712. } finally {
  21713. try {
  21714. if (!_iteratorNormalCompletion && _iterator.return != null) {
  21715. _iterator.return();
  21716. }
  21717. } finally {
  21718. if (_didIteratorError) {
  21719. throw _iteratorError;
  21720. }
  21721. }
  21722. }
  21723. return type.astNode;
  21724. }
  21725. function validateDirectives(context) {
  21726. var _iteratorNormalCompletion2 = true;
  21727. var _didIteratorError2 = false;
  21728. var _iteratorError2 = undefined;
  21729. try {
  21730. for (var _iterator2 = context.schema.getDirectives()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  21731. var directive = _step2.value;
  21732. // Ensure all directives are in fact GraphQL directives.
  21733. if (!(0, _directives.isDirective)(directive)) {
  21734. context.reportError("Expected directive but got: ".concat((0, _inspect.default)(directive), "."), directive && directive.astNode);
  21735. continue;
  21736. } // Ensure they are named correctly.
  21737. validateName(context, directive); // TODO: Ensure proper locations.
  21738. // Ensure the arguments are valid.
  21739. var argNames = Object.create(null);
  21740. var _iteratorNormalCompletion3 = true;
  21741. var _didIteratorError3 = false;
  21742. var _iteratorError3 = undefined;
  21743. try {
  21744. for (var _iterator3 = directive.args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  21745. var arg = _step3.value;
  21746. var argName = arg.name; // Ensure they are named correctly.
  21747. validateName(context, arg); // Ensure they are unique per directive.
  21748. if (argNames[argName]) {
  21749. context.reportError("Argument @".concat(directive.name, "(").concat(argName, ":) can only be defined once."), getAllDirectiveArgNodes(directive, argName));
  21750. continue;
  21751. }
  21752. argNames[argName] = true; // Ensure the type is an input type.
  21753. if (!(0, _definition.isInputType)(arg.type)) {
  21754. context.reportError("The type of @".concat(directive.name, "(").concat(argName, ":) must be Input Type ") + "but got: ".concat((0, _inspect.default)(arg.type), "."), getDirectiveArgTypeNode(directive, argName));
  21755. }
  21756. }
  21757. } catch (err) {
  21758. _didIteratorError3 = true;
  21759. _iteratorError3 = err;
  21760. } finally {
  21761. try {
  21762. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  21763. _iterator3.return();
  21764. }
  21765. } finally {
  21766. if (_didIteratorError3) {
  21767. throw _iteratorError3;
  21768. }
  21769. }
  21770. }
  21771. }
  21772. } catch (err) {
  21773. _didIteratorError2 = true;
  21774. _iteratorError2 = err;
  21775. } finally {
  21776. try {
  21777. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  21778. _iterator2.return();
  21779. }
  21780. } finally {
  21781. if (_didIteratorError2) {
  21782. throw _iteratorError2;
  21783. }
  21784. }
  21785. }
  21786. }
  21787. function validateName(context, node) {
  21788. // If a schema explicitly allows some legacy name which is no longer valid,
  21789. // allow it to be assumed valid.
  21790. if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
  21791. return;
  21792. } // Ensure names are valid, however introspection types opt out.
  21793. var error = (0, _assertValidName.isValidNameError)(node.name, node.astNode || undefined);
  21794. if (error) {
  21795. context.addError(error);
  21796. }
  21797. }
  21798. function validateTypes(context) {
  21799. var typeMap = context.schema.getTypeMap();
  21800. var _iteratorNormalCompletion4 = true;
  21801. var _didIteratorError4 = false;
  21802. var _iteratorError4 = undefined;
  21803. try {
  21804. for (var _iterator4 = (0, _objectValues.default)(typeMap)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  21805. var type = _step4.value;
  21806. // Ensure all provided types are in fact GraphQL type.
  21807. if (!(0, _definition.isNamedType)(type)) {
  21808. context.reportError("Expected GraphQL named type but got: ".concat((0, _inspect.default)(type), "."), type && type.astNode);
  21809. continue;
  21810. } // Ensure it is named correctly (excluding introspection types).
  21811. if (!(0, _introspection.isIntrospectionType)(type)) {
  21812. validateName(context, type);
  21813. }
  21814. if ((0, _definition.isObjectType)(type)) {
  21815. // Ensure fields are valid
  21816. validateFields(context, type); // Ensure objects implement the interfaces they claim to.
  21817. validateObjectInterfaces(context, type);
  21818. } else if ((0, _definition.isInterfaceType)(type)) {
  21819. // Ensure fields are valid.
  21820. validateFields(context, type);
  21821. } else if ((0, _definition.isUnionType)(type)) {
  21822. // Ensure Unions include valid member types.
  21823. validateUnionMembers(context, type);
  21824. } else if ((0, _definition.isEnumType)(type)) {
  21825. // Ensure Enums have valid values.
  21826. validateEnumValues(context, type);
  21827. } else if ((0, _definition.isInputObjectType)(type)) {
  21828. // Ensure Input Object fields are valid.
  21829. validateInputFields(context, type);
  21830. }
  21831. }
  21832. } catch (err) {
  21833. _didIteratorError4 = true;
  21834. _iteratorError4 = err;
  21835. } finally {
  21836. try {
  21837. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  21838. _iterator4.return();
  21839. }
  21840. } finally {
  21841. if (_didIteratorError4) {
  21842. throw _iteratorError4;
  21843. }
  21844. }
  21845. }
  21846. }
  21847. function validateFields(context, type) {
  21848. var fields = (0, _objectValues.default)(type.getFields()); // Objects and Interfaces both must define one or more fields.
  21849. if (fields.length === 0) {
  21850. context.reportError("Type ".concat(type.name, " must define one or more fields."), getAllNodes(type));
  21851. }
  21852. var _iteratorNormalCompletion5 = true;
  21853. var _didIteratorError5 = false;
  21854. var _iteratorError5 = undefined;
  21855. try {
  21856. for (var _iterator5 = fields[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  21857. var field = _step5.value;
  21858. // Ensure they are named correctly.
  21859. validateName(context, field); // Ensure the type is an output type
  21860. if (!(0, _definition.isOutputType)(field.type)) {
  21861. context.reportError("The type of ".concat(type.name, ".").concat(field.name, " must be Output Type ") + "but got: ".concat((0, _inspect.default)(field.type), "."), getFieldTypeNode(type, field.name));
  21862. } // Ensure the arguments are valid
  21863. var argNames = Object.create(null);
  21864. var _iteratorNormalCompletion6 = true;
  21865. var _didIteratorError6 = false;
  21866. var _iteratorError6 = undefined;
  21867. try {
  21868. for (var _iterator6 = field.args[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  21869. var arg = _step6.value;
  21870. var argName = arg.name; // Ensure they are named correctly.
  21871. validateName(context, arg); // Ensure they are unique per field.
  21872. if (argNames[argName]) {
  21873. context.reportError("Field argument ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) can only ") + 'be defined once.', getAllFieldArgNodes(type, field.name, argName));
  21874. }
  21875. argNames[argName] = true; // Ensure the type is an input type
  21876. if (!(0, _definition.isInputType)(arg.type)) {
  21877. context.reportError("The type of ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) must be Input ") + "Type but got: ".concat((0, _inspect.default)(arg.type), "."), getFieldArgTypeNode(type, field.name, argName));
  21878. }
  21879. }
  21880. } catch (err) {
  21881. _didIteratorError6 = true;
  21882. _iteratorError6 = err;
  21883. } finally {
  21884. try {
  21885. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  21886. _iterator6.return();
  21887. }
  21888. } finally {
  21889. if (_didIteratorError6) {
  21890. throw _iteratorError6;
  21891. }
  21892. }
  21893. }
  21894. }
  21895. } catch (err) {
  21896. _didIteratorError5 = true;
  21897. _iteratorError5 = err;
  21898. } finally {
  21899. try {
  21900. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  21901. _iterator5.return();
  21902. }
  21903. } finally {
  21904. if (_didIteratorError5) {
  21905. throw _iteratorError5;
  21906. }
  21907. }
  21908. }
  21909. }
  21910. function validateObjectInterfaces(context, object) {
  21911. var implementedTypeNames = Object.create(null);
  21912. var _iteratorNormalCompletion7 = true;
  21913. var _didIteratorError7 = false;
  21914. var _iteratorError7 = undefined;
  21915. try {
  21916. for (var _iterator7 = object.getInterfaces()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  21917. var iface = _step7.value;
  21918. if (!(0, _definition.isInterfaceType)(iface)) {
  21919. context.reportError("Type ".concat((0, _inspect.default)(object), " must only implement Interface types, ") + "it cannot implement ".concat((0, _inspect.default)(iface), "."), getImplementsInterfaceNode(object, iface));
  21920. continue;
  21921. }
  21922. if (implementedTypeNames[iface.name]) {
  21923. context.reportError("Type ".concat(object.name, " can only implement ").concat(iface.name, " once."), getAllImplementsInterfaceNodes(object, iface));
  21924. continue;
  21925. }
  21926. implementedTypeNames[iface.name] = true;
  21927. validateObjectImplementsInterface(context, object, iface);
  21928. }
  21929. } catch (err) {
  21930. _didIteratorError7 = true;
  21931. _iteratorError7 = err;
  21932. } finally {
  21933. try {
  21934. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  21935. _iterator7.return();
  21936. }
  21937. } finally {
  21938. if (_didIteratorError7) {
  21939. throw _iteratorError7;
  21940. }
  21941. }
  21942. }
  21943. }
  21944. function validateObjectImplementsInterface(context, object, iface) {
  21945. var objectFieldMap = object.getFields();
  21946. var ifaceFieldMap = iface.getFields(); // Assert each interface field is implemented.
  21947. var _iteratorNormalCompletion8 = true;
  21948. var _didIteratorError8 = false;
  21949. var _iteratorError8 = undefined;
  21950. try {
  21951. for (var _iterator8 = (0, _objectEntries.default)(ifaceFieldMap)[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  21952. var _ref2 = _step8.value;
  21953. var fieldName = _ref2[0];
  21954. var ifaceField = _ref2[1];
  21955. var objectField = objectFieldMap[fieldName]; // Assert interface field exists on object.
  21956. if (!objectField) {
  21957. context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expected but ") + "".concat(object.name, " does not provide it."), [getFieldNode(iface, fieldName)].concat(getAllNodes(object)));
  21958. continue;
  21959. } // Assert interface field type is satisfied by object field type, by being
  21960. // a valid subtype. (covariant)
  21961. if (!(0, _typeComparators.isTypeSubTypeOf)(context.schema, objectField.type, ifaceField.type)) {
  21962. context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat((0, _inspect.default)(ifaceField.type), " but ").concat(object.name, ".").concat(fieldName, " ") + "is type ".concat((0, _inspect.default)(objectField.type), "."), [getFieldTypeNode(iface, fieldName), getFieldTypeNode(object, fieldName)]);
  21963. } // Assert each interface field arg is implemented.
  21964. var _iteratorNormalCompletion9 = true;
  21965. var _didIteratorError9 = false;
  21966. var _iteratorError9 = undefined;
  21967. try {
  21968. var _loop = function _loop() {
  21969. var ifaceArg = _step9.value;
  21970. var argName = ifaceArg.name;
  21971. var objectArg = (0, _find.default)(objectField.args, function (arg) {
  21972. return arg.name === argName;
  21973. }); // Assert interface field arg exists on object field.
  21974. if (!objectArg) {
  21975. context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expected but ".concat(object.name, ".").concat(fieldName, " does not provide it."), [getFieldArgNode(iface, fieldName, argName), getFieldNode(object, fieldName)]);
  21976. return "continue";
  21977. } // Assert interface field arg type matches object field arg type.
  21978. // (invariant)
  21979. // TODO: change to contravariant?
  21980. if (!(0, _typeComparators.isEqualType)(ifaceArg.type, objectArg.type)) {
  21981. context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat((0, _inspect.default)(ifaceArg.type), " but ") + "".concat(object.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat((0, _inspect.default)(objectArg.type), "."), [getFieldArgTypeNode(iface, fieldName, argName), getFieldArgTypeNode(object, fieldName, argName)]);
  21982. } // TODO: validate default values?
  21983. };
  21984. for (var _iterator9 = ifaceField.args[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  21985. var _ret = _loop();
  21986. if (_ret === "continue") continue;
  21987. } // Assert additional arguments must not be required.
  21988. } catch (err) {
  21989. _didIteratorError9 = true;
  21990. _iteratorError9 = err;
  21991. } finally {
  21992. try {
  21993. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  21994. _iterator9.return();
  21995. }
  21996. } finally {
  21997. if (_didIteratorError9) {
  21998. throw _iteratorError9;
  21999. }
  22000. }
  22001. }
  22002. var _iteratorNormalCompletion10 = true;
  22003. var _didIteratorError10 = false;
  22004. var _iteratorError10 = undefined;
  22005. try {
  22006. var _loop2 = function _loop2() {
  22007. var objectArg = _step10.value;
  22008. var argName = objectArg.name;
  22009. var ifaceArg = (0, _find.default)(ifaceField.args, function (arg) {
  22010. return arg.name === argName;
  22011. });
  22012. if (!ifaceArg && (0, _definition.isRequiredArgument)(objectArg)) {
  22013. context.reportError("Object field ".concat(object.name, ".").concat(fieldName, " includes required ") + "argument ".concat(argName, " that is missing from the Interface field ") + "".concat(iface.name, ".").concat(fieldName, "."), [getFieldArgNode(object, fieldName, argName), getFieldNode(iface, fieldName)]);
  22014. }
  22015. };
  22016. for (var _iterator10 = objectField.args[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  22017. _loop2();
  22018. }
  22019. } catch (err) {
  22020. _didIteratorError10 = true;
  22021. _iteratorError10 = err;
  22022. } finally {
  22023. try {
  22024. if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
  22025. _iterator10.return();
  22026. }
  22027. } finally {
  22028. if (_didIteratorError10) {
  22029. throw _iteratorError10;
  22030. }
  22031. }
  22032. }
  22033. }
  22034. } catch (err) {
  22035. _didIteratorError8 = true;
  22036. _iteratorError8 = err;
  22037. } finally {
  22038. try {
  22039. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  22040. _iterator8.return();
  22041. }
  22042. } finally {
  22043. if (_didIteratorError8) {
  22044. throw _iteratorError8;
  22045. }
  22046. }
  22047. }
  22048. }
  22049. function validateUnionMembers(context, union) {
  22050. var memberTypes = union.getTypes();
  22051. if (memberTypes.length === 0) {
  22052. context.reportError("Union type ".concat(union.name, " must define one or more member types."), getAllNodes(union));
  22053. }
  22054. var includedTypeNames = Object.create(null);
  22055. var _iteratorNormalCompletion11 = true;
  22056. var _didIteratorError11 = false;
  22057. var _iteratorError11 = undefined;
  22058. try {
  22059. for (var _iterator11 = memberTypes[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  22060. var memberType = _step11.value;
  22061. if (includedTypeNames[memberType.name]) {
  22062. context.reportError("Union type ".concat(union.name, " can only include type ") + "".concat(memberType.name, " once."), getUnionMemberTypeNodes(union, memberType.name));
  22063. continue;
  22064. }
  22065. includedTypeNames[memberType.name] = true;
  22066. if (!(0, _definition.isObjectType)(memberType)) {
  22067. context.reportError("Union type ".concat(union.name, " can only include Object types, ") + "it cannot include ".concat((0, _inspect.default)(memberType), "."), getUnionMemberTypeNodes(union, String(memberType)));
  22068. }
  22069. }
  22070. } catch (err) {
  22071. _didIteratorError11 = true;
  22072. _iteratorError11 = err;
  22073. } finally {
  22074. try {
  22075. if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
  22076. _iterator11.return();
  22077. }
  22078. } finally {
  22079. if (_didIteratorError11) {
  22080. throw _iteratorError11;
  22081. }
  22082. }
  22083. }
  22084. }
  22085. function validateEnumValues(context, enumType) {
  22086. var enumValues = enumType.getValues();
  22087. if (enumValues.length === 0) {
  22088. context.reportError("Enum type ".concat(enumType.name, " must define one or more values."), getAllNodes(enumType));
  22089. }
  22090. var _iteratorNormalCompletion12 = true;
  22091. var _didIteratorError12 = false;
  22092. var _iteratorError12 = undefined;
  22093. try {
  22094. for (var _iterator12 = enumValues[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  22095. var enumValue = _step12.value;
  22096. var valueName = enumValue.name; // Ensure valid name.
  22097. validateName(context, enumValue);
  22098. if (valueName === 'true' || valueName === 'false' || valueName === 'null') {
  22099. context.reportError("Enum type ".concat(enumType.name, " cannot include value: ").concat(valueName, "."), enumValue.astNode);
  22100. }
  22101. }
  22102. } catch (err) {
  22103. _didIteratorError12 = true;
  22104. _iteratorError12 = err;
  22105. } finally {
  22106. try {
  22107. if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
  22108. _iterator12.return();
  22109. }
  22110. } finally {
  22111. if (_didIteratorError12) {
  22112. throw _iteratorError12;
  22113. }
  22114. }
  22115. }
  22116. }
  22117. function validateInputFields(context, inputObj) {
  22118. var fields = (0, _objectValues.default)(inputObj.getFields());
  22119. if (fields.length === 0) {
  22120. context.reportError("Input Object type ".concat(inputObj.name, " must define one or more fields."), getAllNodes(inputObj));
  22121. } // Ensure the arguments are valid
  22122. var _iteratorNormalCompletion13 = true;
  22123. var _didIteratorError13 = false;
  22124. var _iteratorError13 = undefined;
  22125. try {
  22126. for (var _iterator13 = fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  22127. var field = _step13.value;
  22128. // Ensure they are named correctly.
  22129. validateName(context, field); // Ensure the type is an input type
  22130. if (!(0, _definition.isInputType)(field.type)) {
  22131. context.reportError("The type of ".concat(inputObj.name, ".").concat(field.name, " must be Input Type ") + "but got: ".concat((0, _inspect.default)(field.type), "."), field.astNode && field.astNode.type);
  22132. }
  22133. }
  22134. } catch (err) {
  22135. _didIteratorError13 = true;
  22136. _iteratorError13 = err;
  22137. } finally {
  22138. try {
  22139. if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
  22140. _iterator13.return();
  22141. }
  22142. } finally {
  22143. if (_didIteratorError13) {
  22144. throw _iteratorError13;
  22145. }
  22146. }
  22147. }
  22148. }
  22149. function getAllNodes(object) {
  22150. var astNode = object.astNode,
  22151. extensionASTNodes = object.extensionASTNodes;
  22152. return astNode ? extensionASTNodes ? [astNode].concat(extensionASTNodes) : [astNode] : extensionASTNodes || [];
  22153. }
  22154. function getAllSubNodes(object, getter) {
  22155. return (0, _flatMap.default)(getAllNodes(object), function (item) {
  22156. return getter(item) || [];
  22157. });
  22158. }
  22159. function getImplementsInterfaceNode(type, iface) {
  22160. return getAllImplementsInterfaceNodes(type, iface)[0];
  22161. }
  22162. function getAllImplementsInterfaceNodes(type, iface) {
  22163. return getAllSubNodes(type, function (typeNode) {
  22164. return typeNode.interfaces;
  22165. }).filter(function (ifaceNode) {
  22166. return ifaceNode.name.value === iface.name;
  22167. });
  22168. }
  22169. function getFieldNode(type, fieldName) {
  22170. return (0, _find.default)(getAllSubNodes(type, function (typeNode) {
  22171. return typeNode.fields;
  22172. }), function (fieldNode) {
  22173. return fieldNode.name.value === fieldName;
  22174. });
  22175. }
  22176. function getFieldTypeNode(type, fieldName) {
  22177. var fieldNode = getFieldNode(type, fieldName);
  22178. return fieldNode && fieldNode.type;
  22179. }
  22180. function getFieldArgNode(type, fieldName, argName) {
  22181. return getAllFieldArgNodes(type, fieldName, argName)[0];
  22182. }
  22183. function getAllFieldArgNodes(type, fieldName, argName) {
  22184. var argNodes = [];
  22185. var fieldNode = getFieldNode(type, fieldName);
  22186. if (fieldNode && fieldNode.arguments) {
  22187. var _iteratorNormalCompletion14 = true;
  22188. var _didIteratorError14 = false;
  22189. var _iteratorError14 = undefined;
  22190. try {
  22191. for (var _iterator14 = fieldNode.arguments[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  22192. var node = _step14.value;
  22193. if (node.name.value === argName) {
  22194. argNodes.push(node);
  22195. }
  22196. }
  22197. } catch (err) {
  22198. _didIteratorError14 = true;
  22199. _iteratorError14 = err;
  22200. } finally {
  22201. try {
  22202. if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
  22203. _iterator14.return();
  22204. }
  22205. } finally {
  22206. if (_didIteratorError14) {
  22207. throw _iteratorError14;
  22208. }
  22209. }
  22210. }
  22211. }
  22212. return argNodes;
  22213. }
  22214. function getFieldArgTypeNode(type, fieldName, argName) {
  22215. var fieldArgNode = getFieldArgNode(type, fieldName, argName);
  22216. return fieldArgNode && fieldArgNode.type;
  22217. }
  22218. function getAllDirectiveArgNodes(directive, argName) {
  22219. return getAllSubNodes(directive, function (directiveNode) {
  22220. return directiveNode.arguments;
  22221. }).filter(function (argNode) {
  22222. return argNode.name.value === argName;
  22223. });
  22224. }
  22225. function getDirectiveArgTypeNode(directive, argName) {
  22226. var argNode = getAllDirectiveArgNodes(directive, argName)[0];
  22227. return argNode && argNode.type;
  22228. }
  22229. function getUnionMemberTypeNodes(union, typeName) {
  22230. return getAllSubNodes(union, function (unionNode) {
  22231. return unionNode.types;
  22232. }).filter(function (typeNode) {
  22233. return typeNode.name.value === typeName;
  22234. });
  22235. }
  22236. },{"../error/GraphQLError":19,"../jsutils/inspect":32,"../polyfills/find":59,"../polyfills/flatMap":60,"../polyfills/objectEntries":63,"../polyfills/objectValues":64,"../utilities/assertValidName":76,"../utilities/typeComparators":96,"./definition":68,"./directives":69,"./introspection":71,"./schema":73}],75:[function(require,module,exports){
  22237. "use strict";
  22238. Object.defineProperty(exports, "__esModule", {
  22239. value: true
  22240. });
  22241. exports.TypeInfo = void 0;
  22242. var _find = _interopRequireDefault(require("../polyfills/find"));
  22243. var _kinds = require("../language/kinds");
  22244. var _definition = require("../type/definition");
  22245. var _introspection = require("../type/introspection");
  22246. var _typeFromAST = require("./typeFromAST");
  22247. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22248. /**
  22249. * Copyright (c) Facebook, Inc. and its affiliates.
  22250. *
  22251. * This source code is licensed under the MIT license found in the
  22252. * LICENSE file in the root directory of this source tree.
  22253. *
  22254. *
  22255. */
  22256. /**
  22257. * TypeInfo is a utility class which, given a GraphQL schema, can keep track
  22258. * of the current field and type definitions at any point in a GraphQL document
  22259. * AST during a recursive descent by calling `enter(node)` and `leave(node)`.
  22260. */
  22261. var TypeInfo =
  22262. /*#__PURE__*/
  22263. function () {
  22264. function TypeInfo(schema, // NOTE: this experimental optional second parameter is only needed in order
  22265. // to support non-spec-compliant codebases. You should never need to use it.
  22266. // It may disappear in the future.
  22267. getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals
  22268. // beginning somewhere other than documents.
  22269. initialType) {
  22270. this._schema = schema;
  22271. this._typeStack = [];
  22272. this._parentTypeStack = [];
  22273. this._inputTypeStack = [];
  22274. this._fieldDefStack = [];
  22275. this._defaultValueStack = [];
  22276. this._directive = null;
  22277. this._argument = null;
  22278. this._enumValue = null;
  22279. this._getFieldDef = getFieldDefFn || getFieldDef;
  22280. if (initialType) {
  22281. if ((0, _definition.isInputType)(initialType)) {
  22282. this._inputTypeStack.push(initialType);
  22283. }
  22284. if ((0, _definition.isCompositeType)(initialType)) {
  22285. this._parentTypeStack.push(initialType);
  22286. }
  22287. if ((0, _definition.isOutputType)(initialType)) {
  22288. this._typeStack.push(initialType);
  22289. }
  22290. }
  22291. }
  22292. var _proto = TypeInfo.prototype;
  22293. _proto.getType = function getType() {
  22294. if (this._typeStack.length > 0) {
  22295. return this._typeStack[this._typeStack.length - 1];
  22296. }
  22297. };
  22298. _proto.getParentType = function getParentType() {
  22299. if (this._parentTypeStack.length > 0) {
  22300. return this._parentTypeStack[this._parentTypeStack.length - 1];
  22301. }
  22302. };
  22303. _proto.getInputType = function getInputType() {
  22304. if (this._inputTypeStack.length > 0) {
  22305. return this._inputTypeStack[this._inputTypeStack.length - 1];
  22306. }
  22307. };
  22308. _proto.getParentInputType = function getParentInputType() {
  22309. if (this._inputTypeStack.length > 1) {
  22310. return this._inputTypeStack[this._inputTypeStack.length - 2];
  22311. }
  22312. };
  22313. _proto.getFieldDef = function getFieldDef() {
  22314. if (this._fieldDefStack.length > 0) {
  22315. return this._fieldDefStack[this._fieldDefStack.length - 1];
  22316. }
  22317. };
  22318. _proto.getDefaultValue = function getDefaultValue() {
  22319. if (this._defaultValueStack.length > 0) {
  22320. return this._defaultValueStack[this._defaultValueStack.length - 1];
  22321. }
  22322. };
  22323. _proto.getDirective = function getDirective() {
  22324. return this._directive;
  22325. };
  22326. _proto.getArgument = function getArgument() {
  22327. return this._argument;
  22328. };
  22329. _proto.getEnumValue = function getEnumValue() {
  22330. return this._enumValue;
  22331. };
  22332. _proto.enter = function enter(node) {
  22333. var schema = this._schema; // Note: many of the types below are explicitly typed as "mixed" to drop
  22334. // any assumptions of a valid schema to ensure runtime types are properly
  22335. // checked before continuing since TypeInfo is used as part of validation
  22336. // which occurs before guarantees of schema and document validity.
  22337. switch (node.kind) {
  22338. case _kinds.Kind.SELECTION_SET:
  22339. {
  22340. var namedType = (0, _definition.getNamedType)(this.getType());
  22341. this._parentTypeStack.push((0, _definition.isCompositeType)(namedType) ? namedType : undefined);
  22342. break;
  22343. }
  22344. case _kinds.Kind.FIELD:
  22345. {
  22346. var parentType = this.getParentType();
  22347. var fieldDef;
  22348. var fieldType;
  22349. if (parentType) {
  22350. fieldDef = this._getFieldDef(schema, parentType, node);
  22351. if (fieldDef) {
  22352. fieldType = fieldDef.type;
  22353. }
  22354. }
  22355. this._fieldDefStack.push(fieldDef);
  22356. this._typeStack.push((0, _definition.isOutputType)(fieldType) ? fieldType : undefined);
  22357. break;
  22358. }
  22359. case _kinds.Kind.DIRECTIVE:
  22360. this._directive = schema.getDirective(node.name.value);
  22361. break;
  22362. case _kinds.Kind.OPERATION_DEFINITION:
  22363. {
  22364. var type;
  22365. if (node.operation === 'query') {
  22366. type = schema.getQueryType();
  22367. } else if (node.operation === 'mutation') {
  22368. type = schema.getMutationType();
  22369. } else if (node.operation === 'subscription') {
  22370. type = schema.getSubscriptionType();
  22371. }
  22372. this._typeStack.push((0, _definition.isObjectType)(type) ? type : undefined);
  22373. break;
  22374. }
  22375. case _kinds.Kind.INLINE_FRAGMENT:
  22376. case _kinds.Kind.FRAGMENT_DEFINITION:
  22377. {
  22378. var typeConditionAST = node.typeCondition;
  22379. var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : (0, _definition.getNamedType)(this.getType());
  22380. this._typeStack.push((0, _definition.isOutputType)(outputType) ? outputType : undefined);
  22381. break;
  22382. }
  22383. case _kinds.Kind.VARIABLE_DEFINITION:
  22384. {
  22385. var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
  22386. this._inputTypeStack.push((0, _definition.isInputType)(inputType) ? inputType : undefined);
  22387. break;
  22388. }
  22389. case _kinds.Kind.ARGUMENT:
  22390. {
  22391. var argDef;
  22392. var argType;
  22393. var fieldOrDirective = this.getDirective() || this.getFieldDef();
  22394. if (fieldOrDirective) {
  22395. argDef = (0, _find.default)(fieldOrDirective.args, function (arg) {
  22396. return arg.name === node.name.value;
  22397. });
  22398. if (argDef) {
  22399. argType = argDef.type;
  22400. }
  22401. }
  22402. this._argument = argDef;
  22403. this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined);
  22404. this._inputTypeStack.push((0, _definition.isInputType)(argType) ? argType : undefined);
  22405. break;
  22406. }
  22407. case _kinds.Kind.LIST:
  22408. {
  22409. var listType = (0, _definition.getNullableType)(this.getInputType());
  22410. var itemType = (0, _definition.isListType)(listType) ? listType.ofType : listType; // List positions never have a default value.
  22411. this._defaultValueStack.push(undefined);
  22412. this._inputTypeStack.push((0, _definition.isInputType)(itemType) ? itemType : undefined);
  22413. break;
  22414. }
  22415. case _kinds.Kind.OBJECT_FIELD:
  22416. {
  22417. var objectType = (0, _definition.getNamedType)(this.getInputType());
  22418. var inputFieldType;
  22419. var inputField;
  22420. if ((0, _definition.isInputObjectType)(objectType)) {
  22421. inputField = objectType.getFields()[node.name.value];
  22422. if (inputField) {
  22423. inputFieldType = inputField.type;
  22424. }
  22425. }
  22426. this._defaultValueStack.push(inputField ? inputField.defaultValue : undefined);
  22427. this._inputTypeStack.push((0, _definition.isInputType)(inputFieldType) ? inputFieldType : undefined);
  22428. break;
  22429. }
  22430. case _kinds.Kind.ENUM:
  22431. {
  22432. var enumType = (0, _definition.getNamedType)(this.getInputType());
  22433. var enumValue;
  22434. if ((0, _definition.isEnumType)(enumType)) {
  22435. enumValue = enumType.getValue(node.value);
  22436. }
  22437. this._enumValue = enumValue;
  22438. break;
  22439. }
  22440. }
  22441. };
  22442. _proto.leave = function leave(node) {
  22443. switch (node.kind) {
  22444. case _kinds.Kind.SELECTION_SET:
  22445. this._parentTypeStack.pop();
  22446. break;
  22447. case _kinds.Kind.FIELD:
  22448. this._fieldDefStack.pop();
  22449. this._typeStack.pop();
  22450. break;
  22451. case _kinds.Kind.DIRECTIVE:
  22452. this._directive = null;
  22453. break;
  22454. case _kinds.Kind.OPERATION_DEFINITION:
  22455. case _kinds.Kind.INLINE_FRAGMENT:
  22456. case _kinds.Kind.FRAGMENT_DEFINITION:
  22457. this._typeStack.pop();
  22458. break;
  22459. case _kinds.Kind.VARIABLE_DEFINITION:
  22460. this._inputTypeStack.pop();
  22461. break;
  22462. case _kinds.Kind.ARGUMENT:
  22463. this._argument = null;
  22464. this._defaultValueStack.pop();
  22465. this._inputTypeStack.pop();
  22466. break;
  22467. case _kinds.Kind.LIST:
  22468. case _kinds.Kind.OBJECT_FIELD:
  22469. this._defaultValueStack.pop();
  22470. this._inputTypeStack.pop();
  22471. break;
  22472. case _kinds.Kind.ENUM:
  22473. this._enumValue = null;
  22474. break;
  22475. }
  22476. };
  22477. return TypeInfo;
  22478. }();
  22479. /**
  22480. * Not exactly the same as the executor's definition of getFieldDef, in this
  22481. * statically evaluated environment we do not always have an Object type,
  22482. * and need to handle Interface and Union types.
  22483. */
  22484. exports.TypeInfo = TypeInfo;
  22485. function getFieldDef(schema, parentType, fieldNode) {
  22486. var name = fieldNode.name.value;
  22487. if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  22488. return _introspection.SchemaMetaFieldDef;
  22489. }
  22490. if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  22491. return _introspection.TypeMetaFieldDef;
  22492. }
  22493. if (name === _introspection.TypeNameMetaFieldDef.name && (0, _definition.isCompositeType)(parentType)) {
  22494. return _introspection.TypeNameMetaFieldDef;
  22495. }
  22496. if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
  22497. return parentType.getFields()[name];
  22498. }
  22499. }
  22500. },{"../language/kinds":51,"../polyfills/find":59,"../type/definition":68,"../type/introspection":71,"./typeFromAST":97}],76:[function(require,module,exports){
  22501. "use strict";
  22502. Object.defineProperty(exports, "__esModule", {
  22503. value: true
  22504. });
  22505. exports.assertValidName = assertValidName;
  22506. exports.isValidNameError = isValidNameError;
  22507. var _GraphQLError = require("../error/GraphQLError");
  22508. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  22509. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22510. /**
  22511. * Copyright (c) Facebook, Inc. and its affiliates.
  22512. *
  22513. * This source code is licensed under the MIT license found in the
  22514. * LICENSE file in the root directory of this source tree.
  22515. *
  22516. *
  22517. */
  22518. var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
  22519. /**
  22520. * Upholds the spec rules about naming.
  22521. */
  22522. function assertValidName(name) {
  22523. var error = isValidNameError(name);
  22524. if (error) {
  22525. throw error;
  22526. }
  22527. return name;
  22528. }
  22529. /**
  22530. * Returns an Error if a name is invalid.
  22531. */
  22532. function isValidNameError(name, node) {
  22533. !(typeof name === 'string') ? (0, _invariant.default)(0, 'Expected string') : void 0;
  22534. if (name.length > 1 && name[0] === '_' && name[1] === '_') {
  22535. return new _GraphQLError.GraphQLError("Name \"".concat(name, "\" must not begin with \"__\", which is reserved by ") + 'GraphQL introspection.', node);
  22536. }
  22537. if (!NAME_RX.test(name)) {
  22538. return new _GraphQLError.GraphQLError("Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"".concat(name, "\" does not."), node);
  22539. }
  22540. }
  22541. },{"../error/GraphQLError":19,"../jsutils/invariant":34}],77:[function(require,module,exports){
  22542. "use strict";
  22543. Object.defineProperty(exports, "__esModule", {
  22544. value: true
  22545. });
  22546. exports.astFromValue = astFromValue;
  22547. var _iterall = require("iterall");
  22548. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  22549. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  22550. var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
  22551. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  22552. var _kinds = require("../language/kinds");
  22553. var _definition = require("../type/definition");
  22554. var _scalars = require("../type/scalars");
  22555. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22556. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  22557. /**
  22558. * Produces a GraphQL Value AST given a JavaScript value.
  22559. *
  22560. * A GraphQL type must be provided, which will be used to interpret different
  22561. * JavaScript values.
  22562. *
  22563. * | JSON Value | GraphQL Value |
  22564. * | ------------- | -------------------- |
  22565. * | Object | Input Object |
  22566. * | Array | List |
  22567. * | Boolean | Boolean |
  22568. * | String | String / Enum Value |
  22569. * | Number | Int / Float |
  22570. * | Mixed | Enum Value |
  22571. * | null | NullValue |
  22572. *
  22573. */
  22574. function astFromValue(value, type) {
  22575. if ((0, _definition.isNonNullType)(type)) {
  22576. var astValue = astFromValue(value, type.ofType);
  22577. if (astValue && astValue.kind === _kinds.Kind.NULL) {
  22578. return null;
  22579. }
  22580. return astValue;
  22581. } // only explicit null, not undefined, NaN
  22582. if (value === null) {
  22583. return {
  22584. kind: _kinds.Kind.NULL
  22585. };
  22586. } // undefined, NaN
  22587. if ((0, _isInvalid.default)(value)) {
  22588. return null;
  22589. } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
  22590. // the value is not an array, convert the value using the list's item type.
  22591. if ((0, _definition.isListType)(type)) {
  22592. var itemType = type.ofType;
  22593. if ((0, _iterall.isCollection)(value)) {
  22594. var valuesNodes = [];
  22595. (0, _iterall.forEach)(value, function (item) {
  22596. var itemNode = astFromValue(item, itemType);
  22597. if (itemNode) {
  22598. valuesNodes.push(itemNode);
  22599. }
  22600. });
  22601. return {
  22602. kind: _kinds.Kind.LIST,
  22603. values: valuesNodes
  22604. };
  22605. }
  22606. return astFromValue(value, itemType);
  22607. } // Populate the fields of the input object by creating ASTs from each value
  22608. // in the JavaScript object according to the fields in the input type.
  22609. if ((0, _definition.isInputObjectType)(type)) {
  22610. if (value === null || _typeof(value) !== 'object') {
  22611. return null;
  22612. }
  22613. var fields = (0, _objectValues.default)(type.getFields());
  22614. var fieldNodes = [];
  22615. var _iteratorNormalCompletion = true;
  22616. var _didIteratorError = false;
  22617. var _iteratorError = undefined;
  22618. try {
  22619. for (var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  22620. var field = _step.value;
  22621. var fieldValue = astFromValue(value[field.name], field.type);
  22622. if (fieldValue) {
  22623. fieldNodes.push({
  22624. kind: _kinds.Kind.OBJECT_FIELD,
  22625. name: {
  22626. kind: _kinds.Kind.NAME,
  22627. value: field.name
  22628. },
  22629. value: fieldValue
  22630. });
  22631. }
  22632. }
  22633. } catch (err) {
  22634. _didIteratorError = true;
  22635. _iteratorError = err;
  22636. } finally {
  22637. try {
  22638. if (!_iteratorNormalCompletion && _iterator.return != null) {
  22639. _iterator.return();
  22640. }
  22641. } finally {
  22642. if (_didIteratorError) {
  22643. throw _iteratorError;
  22644. }
  22645. }
  22646. }
  22647. return {
  22648. kind: _kinds.Kind.OBJECT,
  22649. fields: fieldNodes
  22650. };
  22651. }
  22652. if ((0, _definition.isLeafType)(type)) {
  22653. // Since value is an internally represented value, it must be serialized
  22654. // to an externally represented value before converting into an AST.
  22655. var serialized = type.serialize(value);
  22656. if ((0, _isNullish.default)(serialized)) {
  22657. return null;
  22658. } // Others serialize based on their corresponding JavaScript scalar types.
  22659. if (typeof serialized === 'boolean') {
  22660. return {
  22661. kind: _kinds.Kind.BOOLEAN,
  22662. value: serialized
  22663. };
  22664. } // JavaScript numbers can be Int or Float values.
  22665. if (typeof serialized === 'number') {
  22666. var stringNum = String(serialized);
  22667. return integerStringRegExp.test(stringNum) ? {
  22668. kind: _kinds.Kind.INT,
  22669. value: stringNum
  22670. } : {
  22671. kind: _kinds.Kind.FLOAT,
  22672. value: stringNum
  22673. };
  22674. }
  22675. if (typeof serialized === 'string') {
  22676. // Enum types use Enum literals.
  22677. if ((0, _definition.isEnumType)(type)) {
  22678. return {
  22679. kind: _kinds.Kind.ENUM,
  22680. value: serialized
  22681. };
  22682. } // ID types can use Int literals.
  22683. if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) {
  22684. return {
  22685. kind: _kinds.Kind.INT,
  22686. value: serialized
  22687. };
  22688. }
  22689. return {
  22690. kind: _kinds.Kind.STRING,
  22691. value: serialized
  22692. };
  22693. }
  22694. throw new TypeError("Cannot convert value to AST: ".concat((0, _inspect.default)(serialized)));
  22695. } // Not reachable. All possible input types have been considered.
  22696. /* istanbul ignore next */
  22697. throw new Error("Unexpected input type: \"".concat((0, _inspect.default)(type), "\"."));
  22698. }
  22699. /**
  22700. * IntValue:
  22701. * - NegativeSign? 0
  22702. * - NegativeSign? NonZeroDigit ( Digit+ )?
  22703. */
  22704. var integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;
  22705. },{"../jsutils/inspect":32,"../jsutils/isInvalid":35,"../jsutils/isNullish":36,"../language/kinds":51,"../polyfills/objectValues":64,"../type/definition":68,"../type/scalars":72,"iterall":137}],78:[function(require,module,exports){
  22706. "use strict";
  22707. Object.defineProperty(exports, "__esModule", {
  22708. value: true
  22709. });
  22710. exports.buildASTSchema = buildASTSchema;
  22711. exports.getDescription = getDescription;
  22712. exports.buildSchema = buildSchema;
  22713. exports.ASTDefinitionBuilder = void 0;
  22714. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  22715. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  22716. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  22717. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  22718. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  22719. var _valueFromAST = require("./valueFromAST");
  22720. var _validate = require("../validation/validate");
  22721. var _blockString = require("../language/blockString");
  22722. var _lexer = require("../language/lexer");
  22723. var _parser = require("../language/parser");
  22724. var _values = require("../execution/values");
  22725. var _kinds = require("../language/kinds");
  22726. var _predicates = require("../language/predicates");
  22727. var _definition = require("../type/definition");
  22728. var _directives = require("../type/directives");
  22729. var _introspection = require("../type/introspection");
  22730. var _scalars = require("../type/scalars");
  22731. var _schema = require("../type/schema");
  22732. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22733. /**
  22734. * Copyright (c) Facebook, Inc. and its affiliates.
  22735. *
  22736. * This source code is licensed under the MIT license found in the
  22737. * LICENSE file in the root directory of this source tree.
  22738. *
  22739. *
  22740. */
  22741. /**
  22742. * This takes the ast of a schema document produced by the parse function in
  22743. * src/language/parser.js.
  22744. *
  22745. * If no schema definition is provided, then it will look for types named Query
  22746. * and Mutation.
  22747. *
  22748. * Given that AST it constructs a GraphQLSchema. The resulting schema
  22749. * has no resolve methods, so execution will use default resolvers.
  22750. *
  22751. * Accepts options as a second argument:
  22752. *
  22753. * - commentDescriptions:
  22754. * Provide true to use preceding comments as the description.
  22755. *
  22756. */
  22757. function buildASTSchema(documentAST, options) {
  22758. !(documentAST && documentAST.kind === _kinds.Kind.DOCUMENT) ? (0, _invariant.default)(0, 'Must provide valid Document AST') : void 0;
  22759. if (!options || !(options.assumeValid || options.assumeValidSDL)) {
  22760. (0, _validate.assertValidSDL)(documentAST);
  22761. }
  22762. var schemaDef;
  22763. var typeDefs = [];
  22764. var directiveDefs = [];
  22765. var _iteratorNormalCompletion = true;
  22766. var _didIteratorError = false;
  22767. var _iteratorError = undefined;
  22768. try {
  22769. for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  22770. var def = _step.value;
  22771. if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
  22772. schemaDef = def;
  22773. } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
  22774. typeDefs.push(def);
  22775. } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  22776. directiveDefs.push(def);
  22777. }
  22778. }
  22779. } catch (err) {
  22780. _didIteratorError = true;
  22781. _iteratorError = err;
  22782. } finally {
  22783. try {
  22784. if (!_iteratorNormalCompletion && _iterator.return != null) {
  22785. _iterator.return();
  22786. }
  22787. } finally {
  22788. if (_didIteratorError) {
  22789. throw _iteratorError;
  22790. }
  22791. }
  22792. }
  22793. var astBuilder = new ASTDefinitionBuilder(options, function (typeName) {
  22794. var type = typeMap[typeName];
  22795. !type ? (0, _invariant.default)(0, "Type \"".concat(typeName, "\" not found in document.")) : void 0;
  22796. return type;
  22797. });
  22798. var typeMap = keyByNameNode(typeDefs, function (node) {
  22799. return astBuilder.buildType(node);
  22800. });
  22801. var operationTypes = schemaDef ? getOperationTypes(schemaDef) : {
  22802. query: 'Query',
  22803. mutation: 'Mutation',
  22804. subscription: 'Subscription'
  22805. };
  22806. var directives = directiveDefs.map(function (def) {
  22807. return astBuilder.buildDirective(def);
  22808. }); // If specified directives were not explicitly declared, add them.
  22809. if (!directives.some(function (directive) {
  22810. return directive.name === 'skip';
  22811. })) {
  22812. directives.push(_directives.GraphQLSkipDirective);
  22813. }
  22814. if (!directives.some(function (directive) {
  22815. return directive.name === 'include';
  22816. })) {
  22817. directives.push(_directives.GraphQLIncludeDirective);
  22818. }
  22819. if (!directives.some(function (directive) {
  22820. return directive.name === 'deprecated';
  22821. })) {
  22822. directives.push(_directives.GraphQLDeprecatedDirective);
  22823. }
  22824. return new _schema.GraphQLSchema({
  22825. // Note: While this could make early assertions to get the correctly
  22826. // typed values below, that would throw immediately while type system
  22827. // validation with validateSchema() will produce more actionable results.
  22828. query: operationTypes.query ? typeMap[operationTypes.query] : null,
  22829. mutation: operationTypes.mutation ? typeMap[operationTypes.mutation] : null,
  22830. subscription: operationTypes.subscription ? typeMap[operationTypes.subscription] : null,
  22831. types: (0, _objectValues.default)(typeMap),
  22832. directives: directives,
  22833. astNode: schemaDef,
  22834. assumeValid: options && options.assumeValid,
  22835. allowedLegacyNames: options && options.allowedLegacyNames
  22836. });
  22837. function getOperationTypes(schema) {
  22838. var opTypes = {};
  22839. var _iteratorNormalCompletion2 = true;
  22840. var _didIteratorError2 = false;
  22841. var _iteratorError2 = undefined;
  22842. try {
  22843. for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  22844. var operationType = _step2.value;
  22845. opTypes[operationType.operation] = operationType.type.name.value;
  22846. }
  22847. } catch (err) {
  22848. _didIteratorError2 = true;
  22849. _iteratorError2 = err;
  22850. } finally {
  22851. try {
  22852. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  22853. _iterator2.return();
  22854. }
  22855. } finally {
  22856. if (_didIteratorError2) {
  22857. throw _iteratorError2;
  22858. }
  22859. }
  22860. }
  22861. return opTypes;
  22862. }
  22863. }
  22864. var stdTypeMap = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
  22865. return type.name;
  22866. });
  22867. var ASTDefinitionBuilder =
  22868. /*#__PURE__*/
  22869. function () {
  22870. function ASTDefinitionBuilder(options, resolveType) {
  22871. this._options = options;
  22872. this._resolveType = resolveType;
  22873. }
  22874. var _proto = ASTDefinitionBuilder.prototype;
  22875. _proto.getNamedType = function getNamedType(node) {
  22876. var name = node.name.value;
  22877. return stdTypeMap[name] || this._resolveType(name);
  22878. };
  22879. _proto.getWrappedType = function getWrappedType(node) {
  22880. if (node.kind === _kinds.Kind.LIST_TYPE) {
  22881. return new _definition.GraphQLList(this.getWrappedType(node.type));
  22882. }
  22883. if (node.kind === _kinds.Kind.NON_NULL_TYPE) {
  22884. return new _definition.GraphQLNonNull(this.getWrappedType(node.type));
  22885. }
  22886. return this.getNamedType(node);
  22887. };
  22888. _proto.buildDirective = function buildDirective(directive) {
  22889. var _this = this;
  22890. var locations = directive.locations.map(function (_ref) {
  22891. var value = _ref.value;
  22892. return value;
  22893. });
  22894. return new _directives.GraphQLDirective({
  22895. name: directive.name.value,
  22896. description: getDescription(directive, this._options),
  22897. locations: locations,
  22898. args: keyByNameNode(directive.arguments || [], function (arg) {
  22899. return _this.buildArg(arg);
  22900. }),
  22901. astNode: directive
  22902. });
  22903. };
  22904. _proto.buildField = function buildField(field) {
  22905. var _this2 = this;
  22906. return {
  22907. // Note: While this could make assertions to get the correctly typed
  22908. // value, that would throw immediately while type system validation
  22909. // with validateSchema() will produce more actionable results.
  22910. type: this.getWrappedType(field.type),
  22911. description: getDescription(field, this._options),
  22912. args: keyByNameNode(field.arguments || [], function (arg) {
  22913. return _this2.buildArg(arg);
  22914. }),
  22915. deprecationReason: getDeprecationReason(field),
  22916. astNode: field
  22917. };
  22918. };
  22919. _proto.buildArg = function buildArg(value) {
  22920. // Note: While this could make assertions to get the correctly typed
  22921. // value, that would throw immediately while type system validation
  22922. // with validateSchema() will produce more actionable results.
  22923. var type = this.getWrappedType(value.type);
  22924. return {
  22925. type: type,
  22926. description: getDescription(value, this._options),
  22927. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
  22928. astNode: value
  22929. };
  22930. };
  22931. _proto.buildInputField = function buildInputField(value) {
  22932. // Note: While this could make assertions to get the correctly typed
  22933. // value, that would throw immediately while type system validation
  22934. // with validateSchema() will produce more actionable results.
  22935. var type = this.getWrappedType(value.type);
  22936. return {
  22937. type: type,
  22938. description: getDescription(value, this._options),
  22939. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
  22940. astNode: value
  22941. };
  22942. };
  22943. _proto.buildEnumValue = function buildEnumValue(value) {
  22944. return {
  22945. description: getDescription(value, this._options),
  22946. deprecationReason: getDeprecationReason(value),
  22947. astNode: value
  22948. };
  22949. };
  22950. _proto.buildType = function buildType(astNode) {
  22951. var name = astNode.name.value;
  22952. if (stdTypeMap[name]) {
  22953. return stdTypeMap[name];
  22954. }
  22955. switch (astNode.kind) {
  22956. case _kinds.Kind.OBJECT_TYPE_DEFINITION:
  22957. return this._makeTypeDef(astNode);
  22958. case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
  22959. return this._makeInterfaceDef(astNode);
  22960. case _kinds.Kind.ENUM_TYPE_DEFINITION:
  22961. return this._makeEnumDef(astNode);
  22962. case _kinds.Kind.UNION_TYPE_DEFINITION:
  22963. return this._makeUnionDef(astNode);
  22964. case _kinds.Kind.SCALAR_TYPE_DEFINITION:
  22965. return this._makeScalarDef(astNode);
  22966. case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
  22967. return this._makeInputObjectDef(astNode);
  22968. } // Not reachable. All possible type definition nodes have been considered.
  22969. /* istanbul ignore next */
  22970. throw new Error("Unexpected type definition node: \"".concat((0, _inspect.default)(astNode), "\"."));
  22971. };
  22972. _proto._makeTypeDef = function _makeTypeDef(astNode) {
  22973. var _this3 = this;
  22974. var interfaceNodes = astNode.interfaces;
  22975. var fieldNodes = astNode.fields; // Note: While this could make assertions to get the correctly typed
  22976. // values below, that would throw immediately while type system
  22977. // validation with validateSchema() will produce more actionable results.
  22978. var interfaces = interfaceNodes && interfaceNodes.length > 0 ? function () {
  22979. return interfaceNodes.map(function (ref) {
  22980. return _this3.getNamedType(ref);
  22981. });
  22982. } : [];
  22983. var fields = fieldNodes && fieldNodes.length > 0 ? function () {
  22984. return keyByNameNode(fieldNodes, function (field) {
  22985. return _this3.buildField(field);
  22986. });
  22987. } : Object.create(null);
  22988. return new _definition.GraphQLObjectType({
  22989. name: astNode.name.value,
  22990. description: getDescription(astNode, this._options),
  22991. interfaces: interfaces,
  22992. fields: fields,
  22993. astNode: astNode
  22994. });
  22995. };
  22996. _proto._makeInterfaceDef = function _makeInterfaceDef(astNode) {
  22997. var _this4 = this;
  22998. var fieldNodes = astNode.fields;
  22999. var fields = fieldNodes && fieldNodes.length > 0 ? function () {
  23000. return keyByNameNode(fieldNodes, function (field) {
  23001. return _this4.buildField(field);
  23002. });
  23003. } : Object.create(null);
  23004. return new _definition.GraphQLInterfaceType({
  23005. name: astNode.name.value,
  23006. description: getDescription(astNode, this._options),
  23007. fields: fields,
  23008. astNode: astNode
  23009. });
  23010. };
  23011. _proto._makeEnumDef = function _makeEnumDef(astNode) {
  23012. var _this5 = this;
  23013. var valueNodes = astNode.values || [];
  23014. return new _definition.GraphQLEnumType({
  23015. name: astNode.name.value,
  23016. description: getDescription(astNode, this._options),
  23017. values: keyByNameNode(valueNodes, function (value) {
  23018. return _this5.buildEnumValue(value);
  23019. }),
  23020. astNode: astNode
  23021. });
  23022. };
  23023. _proto._makeUnionDef = function _makeUnionDef(astNode) {
  23024. var _this6 = this;
  23025. var typeNodes = astNode.types; // Note: While this could make assertions to get the correctly typed
  23026. // values below, that would throw immediately while type system
  23027. // validation with validateSchema() will produce more actionable results.
  23028. var types = typeNodes && typeNodes.length > 0 ? function () {
  23029. return typeNodes.map(function (ref) {
  23030. return _this6.getNamedType(ref);
  23031. });
  23032. } : [];
  23033. return new _definition.GraphQLUnionType({
  23034. name: astNode.name.value,
  23035. description: getDescription(astNode, this._options),
  23036. types: types,
  23037. astNode: astNode
  23038. });
  23039. };
  23040. _proto._makeScalarDef = function _makeScalarDef(astNode) {
  23041. return new _definition.GraphQLScalarType({
  23042. name: astNode.name.value,
  23043. description: getDescription(astNode, this._options),
  23044. astNode: astNode,
  23045. serialize: function serialize(value) {
  23046. return value;
  23047. }
  23048. });
  23049. };
  23050. _proto._makeInputObjectDef = function _makeInputObjectDef(def) {
  23051. var _this7 = this;
  23052. var fields = def.fields;
  23053. return new _definition.GraphQLInputObjectType({
  23054. name: def.name.value,
  23055. description: getDescription(def, this._options),
  23056. fields: fields ? function () {
  23057. return keyByNameNode(fields, function (field) {
  23058. return _this7.buildInputField(field);
  23059. });
  23060. } : Object.create(null),
  23061. astNode: def
  23062. });
  23063. };
  23064. return ASTDefinitionBuilder;
  23065. }();
  23066. exports.ASTDefinitionBuilder = ASTDefinitionBuilder;
  23067. function keyByNameNode(list, valFn) {
  23068. return (0, _keyValMap.default)(list, function (_ref2) {
  23069. var name = _ref2.name;
  23070. return name.value;
  23071. }, valFn);
  23072. }
  23073. /**
  23074. * Given a field or enum value node, returns the string value for the
  23075. * deprecation reason.
  23076. */
  23077. function getDeprecationReason(node) {
  23078. var deprecated = (0, _values.getDirectiveValues)(_directives.GraphQLDeprecatedDirective, node);
  23079. return deprecated && deprecated.reason;
  23080. }
  23081. /**
  23082. * Given an ast node, returns its string description.
  23083. * @deprecated: provided to ease adoption and will be removed in v16.
  23084. *
  23085. * Accepts options as a second argument:
  23086. *
  23087. * - commentDescriptions:
  23088. * Provide true to use preceding comments as the description.
  23089. *
  23090. */
  23091. function getDescription(node, options) {
  23092. if (node.description) {
  23093. return node.description.value;
  23094. }
  23095. if (options && options.commentDescriptions) {
  23096. var rawValue = getLeadingCommentBlock(node);
  23097. if (rawValue !== undefined) {
  23098. return (0, _blockString.dedentBlockStringValue)('\n' + rawValue);
  23099. }
  23100. }
  23101. }
  23102. function getLeadingCommentBlock(node) {
  23103. var loc = node.loc;
  23104. if (!loc) {
  23105. return;
  23106. }
  23107. var comments = [];
  23108. var token = loc.startToken.prev;
  23109. while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) {
  23110. var value = String(token.value);
  23111. comments.push(value);
  23112. token = token.prev;
  23113. }
  23114. return comments.reverse().join('\n');
  23115. }
  23116. /**
  23117. * A helper function to build a GraphQLSchema directly from a source
  23118. * document.
  23119. */
  23120. function buildSchema(source, options) {
  23121. return buildASTSchema((0, _parser.parse)(source, options), options);
  23122. }
  23123. },{"../execution/values":27,"../jsutils/inspect":32,"../jsutils/invariant":34,"../jsutils/keyMap":38,"../jsutils/keyValMap":39,"../language/blockString":48,"../language/kinds":51,"../language/lexer":52,"../language/parser":54,"../language/predicates":55,"../polyfills/objectValues":64,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/scalars":72,"../type/schema":73,"../validation/validate":136,"./valueFromAST":98}],79:[function(require,module,exports){
  23124. "use strict";
  23125. Object.defineProperty(exports, "__esModule", {
  23126. value: true
  23127. });
  23128. exports.buildClientSchema = buildClientSchema;
  23129. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  23130. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  23131. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  23132. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  23133. var _valueFromAST = require("./valueFromAST");
  23134. var _parser = require("../language/parser");
  23135. var _schema = require("../type/schema");
  23136. var _definition = require("../type/definition");
  23137. var _directives = require("../type/directives");
  23138. var _introspection = require("../type/introspection");
  23139. var _scalars = require("../type/scalars");
  23140. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23141. /**
  23142. * Copyright (c) Facebook, Inc. and its affiliates.
  23143. *
  23144. * This source code is licensed under the MIT license found in the
  23145. * LICENSE file in the root directory of this source tree.
  23146. *
  23147. *
  23148. */
  23149. /**
  23150. * Build a GraphQLSchema for use by client tools.
  23151. *
  23152. * Given the result of a client running the introspection query, creates and
  23153. * returns a GraphQLSchema instance which can be then used with all graphql-js
  23154. * tools, but cannot be used to execute a query, as introspection does not
  23155. * represent the "resolver", "parse" or "serialize" functions or any other
  23156. * server-internal mechanisms.
  23157. *
  23158. * This function expects a complete introspection result. Don't forget to check
  23159. * the "errors" field of a server response before calling this function.
  23160. */
  23161. function buildClientSchema(introspection, options) {
  23162. // Get the schema from the introspection result.
  23163. var schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each.
  23164. var typeMap = (0, _keyValMap.default)(schemaIntrospection.types, function (typeIntrospection) {
  23165. return typeIntrospection.name;
  23166. }, function (typeIntrospection) {
  23167. return buildType(typeIntrospection);
  23168. });
  23169. for (var _i = 0, _arr = [].concat(_scalars.specifiedScalarTypes, _introspection.introspectionTypes); _i < _arr.length; _i++) {
  23170. var stdType = _arr[_i];
  23171. if (typeMap[stdType.name]) {
  23172. typeMap[stdType.name] = stdType;
  23173. }
  23174. } // Get the root Query, Mutation, and Subscription types.
  23175. var queryType = schemaIntrospection.queryType ? getObjectType(schemaIntrospection.queryType) : null;
  23176. var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;
  23177. var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null; // Get the directives supported by Introspection, assuming empty-set if
  23178. // directives were not queried for.
  23179. var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : []; // Then produce and return a Schema with these types.
  23180. return new _schema.GraphQLSchema({
  23181. query: queryType,
  23182. mutation: mutationType,
  23183. subscription: subscriptionType,
  23184. types: (0, _objectValues.default)(typeMap),
  23185. directives: directives,
  23186. assumeValid: options && options.assumeValid,
  23187. allowedLegacyNames: options && options.allowedLegacyNames
  23188. }); // Given a type reference in introspection, return the GraphQLType instance.
  23189. // preferring cached instances before building new instances.
  23190. function getType(typeRef) {
  23191. if (typeRef.kind === _introspection.TypeKind.LIST) {
  23192. var itemRef = typeRef.ofType;
  23193. if (!itemRef) {
  23194. throw new Error('Decorated type deeper than introspection query.');
  23195. }
  23196. return (0, _definition.GraphQLList)(getType(itemRef));
  23197. }
  23198. if (typeRef.kind === _introspection.TypeKind.NON_NULL) {
  23199. var nullableRef = typeRef.ofType;
  23200. if (!nullableRef) {
  23201. throw new Error('Decorated type deeper than introspection query.');
  23202. }
  23203. var nullableType = getType(nullableRef);
  23204. return (0, _definition.GraphQLNonNull)((0, _definition.assertNullableType)(nullableType));
  23205. }
  23206. if (!typeRef.name) {
  23207. throw new Error('Unknown type reference: ' + (0, _inspect.default)(typeRef));
  23208. }
  23209. return getNamedType(typeRef.name);
  23210. }
  23211. function getNamedType(typeName) {
  23212. var type = typeMap[typeName];
  23213. if (!type) {
  23214. throw new Error("Invalid or incomplete schema, unknown type: ".concat(typeName, ". Ensure ") + 'that a full introspection query is used in order to build a ' + 'client schema.');
  23215. }
  23216. return type;
  23217. }
  23218. function getInputType(typeRef) {
  23219. var type = getType(typeRef);
  23220. !(0, _definition.isInputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide input type for arguments, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
  23221. return type;
  23222. }
  23223. function getOutputType(typeRef) {
  23224. var type = getType(typeRef);
  23225. !(0, _definition.isOutputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide output type for fields, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
  23226. return type;
  23227. }
  23228. function getObjectType(typeRef) {
  23229. var type = getType(typeRef);
  23230. return (0, _definition.assertObjectType)(type);
  23231. }
  23232. function getInterfaceType(typeRef) {
  23233. var type = getType(typeRef);
  23234. return (0, _definition.assertInterfaceType)(type);
  23235. } // Given a type's introspection result, construct the correct
  23236. // GraphQLType instance.
  23237. function buildType(type) {
  23238. if (type && type.name && type.kind) {
  23239. switch (type.kind) {
  23240. case _introspection.TypeKind.SCALAR:
  23241. return buildScalarDef(type);
  23242. case _introspection.TypeKind.OBJECT:
  23243. return buildObjectDef(type);
  23244. case _introspection.TypeKind.INTERFACE:
  23245. return buildInterfaceDef(type);
  23246. case _introspection.TypeKind.UNION:
  23247. return buildUnionDef(type);
  23248. case _introspection.TypeKind.ENUM:
  23249. return buildEnumDef(type);
  23250. case _introspection.TypeKind.INPUT_OBJECT:
  23251. return buildInputObjectDef(type);
  23252. }
  23253. }
  23254. throw new Error('Invalid or incomplete introspection result. Ensure that a full ' + 'introspection query is used in order to build a client schema:' + (0, _inspect.default)(type));
  23255. }
  23256. function buildScalarDef(scalarIntrospection) {
  23257. return new _definition.GraphQLScalarType({
  23258. name: scalarIntrospection.name,
  23259. description: scalarIntrospection.description,
  23260. serialize: function serialize(value) {
  23261. return value;
  23262. }
  23263. });
  23264. }
  23265. function buildObjectDef(objectIntrospection) {
  23266. if (!objectIntrospection.interfaces) {
  23267. throw new Error('Introspection result missing interfaces: ' + (0, _inspect.default)(objectIntrospection));
  23268. }
  23269. return new _definition.GraphQLObjectType({
  23270. name: objectIntrospection.name,
  23271. description: objectIntrospection.description,
  23272. interfaces: function interfaces() {
  23273. return objectIntrospection.interfaces.map(getInterfaceType);
  23274. },
  23275. fields: function fields() {
  23276. return buildFieldDefMap(objectIntrospection);
  23277. }
  23278. });
  23279. }
  23280. function buildInterfaceDef(interfaceIntrospection) {
  23281. return new _definition.GraphQLInterfaceType({
  23282. name: interfaceIntrospection.name,
  23283. description: interfaceIntrospection.description,
  23284. fields: function fields() {
  23285. return buildFieldDefMap(interfaceIntrospection);
  23286. }
  23287. });
  23288. }
  23289. function buildUnionDef(unionIntrospection) {
  23290. if (!unionIntrospection.possibleTypes) {
  23291. throw new Error('Introspection result missing possibleTypes: ' + (0, _inspect.default)(unionIntrospection));
  23292. }
  23293. return new _definition.GraphQLUnionType({
  23294. name: unionIntrospection.name,
  23295. description: unionIntrospection.description,
  23296. types: function types() {
  23297. return unionIntrospection.possibleTypes.map(getObjectType);
  23298. }
  23299. });
  23300. }
  23301. function buildEnumDef(enumIntrospection) {
  23302. if (!enumIntrospection.enumValues) {
  23303. throw new Error('Introspection result missing enumValues: ' + (0, _inspect.default)(enumIntrospection));
  23304. }
  23305. return new _definition.GraphQLEnumType({
  23306. name: enumIntrospection.name,
  23307. description: enumIntrospection.description,
  23308. values: (0, _keyValMap.default)(enumIntrospection.enumValues, function (valueIntrospection) {
  23309. return valueIntrospection.name;
  23310. }, function (valueIntrospection) {
  23311. return {
  23312. description: valueIntrospection.description,
  23313. deprecationReason: valueIntrospection.deprecationReason
  23314. };
  23315. })
  23316. });
  23317. }
  23318. function buildInputObjectDef(inputObjectIntrospection) {
  23319. if (!inputObjectIntrospection.inputFields) {
  23320. throw new Error('Introspection result missing inputFields: ' + (0, _inspect.default)(inputObjectIntrospection));
  23321. }
  23322. return new _definition.GraphQLInputObjectType({
  23323. name: inputObjectIntrospection.name,
  23324. description: inputObjectIntrospection.description,
  23325. fields: function fields() {
  23326. return buildInputValueDefMap(inputObjectIntrospection.inputFields);
  23327. }
  23328. });
  23329. }
  23330. function buildFieldDefMap(typeIntrospection) {
  23331. if (!typeIntrospection.fields) {
  23332. throw new Error('Introspection result missing fields: ' + (0, _inspect.default)(typeIntrospection));
  23333. }
  23334. return (0, _keyValMap.default)(typeIntrospection.fields, function (fieldIntrospection) {
  23335. return fieldIntrospection.name;
  23336. }, function (fieldIntrospection) {
  23337. if (!fieldIntrospection.args) {
  23338. throw new Error('Introspection result missing field args: ' + (0, _inspect.default)(fieldIntrospection));
  23339. }
  23340. return {
  23341. description: fieldIntrospection.description,
  23342. deprecationReason: fieldIntrospection.deprecationReason,
  23343. type: getOutputType(fieldIntrospection.type),
  23344. args: buildInputValueDefMap(fieldIntrospection.args)
  23345. };
  23346. });
  23347. }
  23348. function buildInputValueDefMap(inputValueIntrospections) {
  23349. return (0, _keyValMap.default)(inputValueIntrospections, function (inputValue) {
  23350. return inputValue.name;
  23351. }, buildInputValue);
  23352. }
  23353. function buildInputValue(inputValueIntrospection) {
  23354. var type = getInputType(inputValueIntrospection.type);
  23355. var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined;
  23356. return {
  23357. description: inputValueIntrospection.description,
  23358. type: type,
  23359. defaultValue: defaultValue
  23360. };
  23361. }
  23362. function buildDirective(directiveIntrospection) {
  23363. if (!directiveIntrospection.args) {
  23364. throw new Error('Introspection result missing directive args: ' + (0, _inspect.default)(directiveIntrospection));
  23365. }
  23366. if (!directiveIntrospection.locations) {
  23367. throw new Error('Introspection result missing directive locations: ' + (0, _inspect.default)(directiveIntrospection));
  23368. }
  23369. return new _directives.GraphQLDirective({
  23370. name: directiveIntrospection.name,
  23371. description: directiveIntrospection.description,
  23372. locations: directiveIntrospection.locations.slice(),
  23373. args: buildInputValueDefMap(directiveIntrospection.args)
  23374. });
  23375. }
  23376. }
  23377. },{"../jsutils/inspect":32,"../jsutils/invariant":34,"../jsutils/keyValMap":39,"../language/parser":54,"../polyfills/objectValues":64,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/scalars":72,"../type/schema":73,"./valueFromAST":98}],80:[function(require,module,exports){
  23378. "use strict";
  23379. Object.defineProperty(exports, "__esModule", {
  23380. value: true
  23381. });
  23382. exports.coerceValue = coerceValue;
  23383. var _iterall = require("iterall");
  23384. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  23385. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  23386. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  23387. var _orList = _interopRequireDefault(require("../jsutils/orList"));
  23388. var _suggestionList = _interopRequireDefault(require("../jsutils/suggestionList"));
  23389. var _GraphQLError = require("../error/GraphQLError");
  23390. var _definition = require("../type/definition");
  23391. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23392. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  23393. /**
  23394. * Coerces a JavaScript value given a GraphQL Type.
  23395. *
  23396. * Returns either a value which is valid for the provided type or a list of
  23397. * encountered coercion errors.
  23398. *
  23399. */
  23400. function coerceValue(value, type, blameNode, path) {
  23401. // A value must be provided if the type is non-null.
  23402. if ((0, _definition.isNonNullType)(type)) {
  23403. if (value == null) {
  23404. return ofErrors([coercionError("Expected non-nullable type ".concat((0, _inspect.default)(type), " not to be null"), blameNode, path)]);
  23405. }
  23406. return coerceValue(value, type.ofType, blameNode, path);
  23407. }
  23408. if (value == null) {
  23409. // Explicitly return the value null.
  23410. return ofValue(null);
  23411. }
  23412. if ((0, _definition.isScalarType)(type)) {
  23413. // Scalars determine if a value is valid via parseValue(), which can
  23414. // throw to indicate failure. If it throws, maintain a reference to
  23415. // the original error.
  23416. try {
  23417. var parseResult = type.parseValue(value);
  23418. if ((0, _isInvalid.default)(parseResult)) {
  23419. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path)]);
  23420. }
  23421. return ofValue(parseResult);
  23422. } catch (error) {
  23423. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path, error.message, error)]);
  23424. }
  23425. }
  23426. if ((0, _definition.isEnumType)(type)) {
  23427. if (typeof value === 'string') {
  23428. var enumValue = type.getValue(value);
  23429. if (enumValue) {
  23430. return ofValue(enumValue.value);
  23431. }
  23432. }
  23433. var suggestions = (0, _suggestionList.default)(String(value), type.getValues().map(function (enumValue) {
  23434. return enumValue.name;
  23435. }));
  23436. var didYouMean = suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(suggestions), "?") : undefined;
  23437. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path, didYouMean)]);
  23438. }
  23439. if ((0, _definition.isListType)(type)) {
  23440. var itemType = type.ofType;
  23441. if ((0, _iterall.isCollection)(value)) {
  23442. var errors;
  23443. var coercedValue = [];
  23444. (0, _iterall.forEach)(value, function (itemValue, index) {
  23445. var coercedItem = coerceValue(itemValue, itemType, blameNode, atPath(path, index));
  23446. if (coercedItem.errors) {
  23447. errors = add(errors, coercedItem.errors);
  23448. } else if (!errors) {
  23449. coercedValue.push(coercedItem.value);
  23450. }
  23451. });
  23452. return errors ? ofErrors(errors) : ofValue(coercedValue);
  23453. } // Lists accept a non-list value as a list of one.
  23454. var coercedItem = coerceValue(value, itemType, blameNode);
  23455. return coercedItem.errors ? coercedItem : ofValue([coercedItem.value]);
  23456. }
  23457. if ((0, _definition.isInputObjectType)(type)) {
  23458. if (_typeof(value) !== 'object') {
  23459. return ofErrors([coercionError("Expected type ".concat(type.name, " to be an object"), blameNode, path)]);
  23460. }
  23461. var _errors;
  23462. var _coercedValue = {};
  23463. var fields = type.getFields(); // Ensure every defined field is valid.
  23464. var _iteratorNormalCompletion = true;
  23465. var _didIteratorError = false;
  23466. var _iteratorError = undefined;
  23467. try {
  23468. for (var _iterator = (0, _objectValues.default)(fields)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  23469. var field = _step.value;
  23470. var fieldValue = value[field.name];
  23471. if ((0, _isInvalid.default)(fieldValue)) {
  23472. if (!(0, _isInvalid.default)(field.defaultValue)) {
  23473. _coercedValue[field.name] = field.defaultValue;
  23474. } else if ((0, _definition.isNonNullType)(field.type)) {
  23475. _errors = add(_errors, coercionError("Field ".concat(printPath(atPath(path, field.name)), " of required ") + "type ".concat((0, _inspect.default)(field.type), " was not provided"), blameNode));
  23476. }
  23477. } else {
  23478. var coercedField = coerceValue(fieldValue, field.type, blameNode, atPath(path, field.name));
  23479. if (coercedField.errors) {
  23480. _errors = add(_errors, coercedField.errors);
  23481. } else if (!_errors) {
  23482. _coercedValue[field.name] = coercedField.value;
  23483. }
  23484. }
  23485. } // Ensure every provided field is defined.
  23486. } catch (err) {
  23487. _didIteratorError = true;
  23488. _iteratorError = err;
  23489. } finally {
  23490. try {
  23491. if (!_iteratorNormalCompletion && _iterator.return != null) {
  23492. _iterator.return();
  23493. }
  23494. } finally {
  23495. if (_didIteratorError) {
  23496. throw _iteratorError;
  23497. }
  23498. }
  23499. }
  23500. for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
  23501. var fieldName = _Object$keys[_i];
  23502. if (!fields[fieldName]) {
  23503. var _suggestions = (0, _suggestionList.default)(fieldName, Object.keys(fields));
  23504. var _didYouMean = _suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(_suggestions), "?") : undefined;
  23505. _errors = add(_errors, coercionError("Field \"".concat(fieldName, "\" is not defined by type ").concat(type.name), blameNode, path, _didYouMean));
  23506. }
  23507. }
  23508. return _errors ? ofErrors(_errors) : ofValue(_coercedValue);
  23509. } // Not reachable. All possible input types have been considered.
  23510. /* istanbul ignore next */
  23511. throw new Error("Unexpected input type: \"".concat((0, _inspect.default)(type), "\"."));
  23512. }
  23513. function ofValue(value) {
  23514. return {
  23515. errors: undefined,
  23516. value: value
  23517. };
  23518. }
  23519. function ofErrors(errors) {
  23520. return {
  23521. errors: errors,
  23522. value: undefined
  23523. };
  23524. }
  23525. function add(errors, moreErrors) {
  23526. return (errors || []).concat(moreErrors);
  23527. }
  23528. function atPath(prev, key) {
  23529. return {
  23530. prev: prev,
  23531. key: key
  23532. };
  23533. }
  23534. function coercionError(message, blameNode, path, subMessage, originalError) {
  23535. var pathStr = printPath(path); // Return a GraphQLError instance
  23536. return new _GraphQLError.GraphQLError(message + (pathStr ? ' at ' + pathStr : '') + (subMessage ? '; ' + subMessage : '.'), blameNode, undefined, undefined, undefined, originalError);
  23537. } // Build a string describing the path into the value where the error was found
  23538. function printPath(path) {
  23539. var pathStr = '';
  23540. var currentPath = path;
  23541. while (currentPath) {
  23542. pathStr = (typeof currentPath.key === 'string' ? '.' + currentPath.key : '[' + String(currentPath.key) + ']') + pathStr;
  23543. currentPath = currentPath.prev;
  23544. }
  23545. return pathStr ? 'value' + pathStr : '';
  23546. }
  23547. },{"../error/GraphQLError":19,"../jsutils/inspect":32,"../jsutils/isInvalid":35,"../jsutils/orList":43,"../jsutils/suggestionList":47,"../polyfills/objectValues":64,"../type/definition":68,"iterall":137}],81:[function(require,module,exports){
  23548. "use strict";
  23549. Object.defineProperty(exports, "__esModule", {
  23550. value: true
  23551. });
  23552. exports.concatAST = concatAST;
  23553. var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
  23554. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23555. /**
  23556. * Copyright (c) Facebook, Inc. and its affiliates.
  23557. *
  23558. * This source code is licensed under the MIT license found in the
  23559. * LICENSE file in the root directory of this source tree.
  23560. *
  23561. *
  23562. */
  23563. /**
  23564. * Provided a collection of ASTs, presumably each from different files,
  23565. * concatenate the ASTs together into batched AST, useful for validating many
  23566. * GraphQL source files which together represent one conceptual application.
  23567. */
  23568. function concatAST(asts) {
  23569. return {
  23570. kind: 'Document',
  23571. definitions: (0, _flatMap.default)(asts, function (ast) {
  23572. return ast.definitions;
  23573. })
  23574. };
  23575. }
  23576. },{"../polyfills/flatMap":60}],82:[function(require,module,exports){
  23577. "use strict";
  23578. Object.defineProperty(exports, "__esModule", {
  23579. value: true
  23580. });
  23581. exports.extendSchema = extendSchema;
  23582. var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
  23583. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  23584. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  23585. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  23586. var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
  23587. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  23588. var _buildASTSchema = require("./buildASTSchema");
  23589. var _validate = require("../validation/validate");
  23590. var _schema = require("../type/schema");
  23591. var _introspection = require("../type/introspection");
  23592. var _scalars = require("../type/scalars");
  23593. var _definition = require("../type/definition");
  23594. var _directives = require("../type/directives");
  23595. var _kinds = require("../language/kinds");
  23596. var _predicates = require("../language/predicates");
  23597. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23598. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  23599. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  23600. /**
  23601. * Produces a new schema given an existing schema and a document which may
  23602. * contain GraphQL type extensions and definitions. The original schema will
  23603. * remain unaltered.
  23604. *
  23605. * Because a schema represents a graph of references, a schema cannot be
  23606. * extended without effectively making an entire copy. We do not know until it's
  23607. * too late if subgraphs remain unchanged.
  23608. *
  23609. * This algorithm copies the provided schema, applying extensions while
  23610. * producing the copy. The original schema remains unaltered.
  23611. *
  23612. * Accepts options as a third argument:
  23613. *
  23614. * - commentDescriptions:
  23615. * Provide true to use preceding comments as the description.
  23616. *
  23617. */
  23618. function extendSchema(schema, documentAST, options) {
  23619. (0, _schema.assertSchema)(schema);
  23620. !(documentAST && documentAST.kind === _kinds.Kind.DOCUMENT) ? (0, _invariant.default)(0, 'Must provide valid Document AST') : void 0;
  23621. if (!options || !(options.assumeValid || options.assumeValidSDL)) {
  23622. (0, _validate.assertValidSDLExtension)(documentAST, schema);
  23623. } // Collect the type definitions and extensions found in the document.
  23624. var typeDefs = [];
  23625. var typeExtsMap = Object.create(null); // New directives and types are separate because a directives and types can
  23626. // have the same name. For example, a type named "skip".
  23627. var directiveDefs = [];
  23628. var schemaDef; // Schema extensions are collected which may add additional operation types.
  23629. var schemaExts = [];
  23630. var _iteratorNormalCompletion = true;
  23631. var _didIteratorError = false;
  23632. var _iteratorError = undefined;
  23633. try {
  23634. for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  23635. var def = _step.value;
  23636. if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
  23637. schemaDef = def;
  23638. } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) {
  23639. schemaExts.push(def);
  23640. } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
  23641. typeDefs.push(def);
  23642. } else if ((0, _predicates.isTypeExtensionNode)(def)) {
  23643. var extendedTypeName = def.name.value;
  23644. var existingTypeExts = typeExtsMap[extendedTypeName];
  23645. typeExtsMap[extendedTypeName] = existingTypeExts ? existingTypeExts.concat([def]) : [def];
  23646. } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  23647. directiveDefs.push(def);
  23648. }
  23649. } // If this document contains no new types, extensions, or directives then
  23650. // return the same unmodified GraphQLSchema instance.
  23651. } catch (err) {
  23652. _didIteratorError = true;
  23653. _iteratorError = err;
  23654. } finally {
  23655. try {
  23656. if (!_iteratorNormalCompletion && _iterator.return != null) {
  23657. _iterator.return();
  23658. }
  23659. } finally {
  23660. if (_didIteratorError) {
  23661. throw _iteratorError;
  23662. }
  23663. }
  23664. }
  23665. if (Object.keys(typeExtsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExts.length === 0 && !schemaDef) {
  23666. return schema;
  23667. }
  23668. var schemaConfig = schema.toConfig();
  23669. var astBuilder = new _buildASTSchema.ASTDefinitionBuilder(options, function (typeName) {
  23670. var type = typeMap[typeName];
  23671. !type ? (0, _invariant.default)(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
  23672. return type;
  23673. });
  23674. var typeMap = (0, _keyValMap.default)(typeDefs, function (node) {
  23675. return node.name.value;
  23676. }, function (node) {
  23677. return astBuilder.buildType(node);
  23678. });
  23679. var _iteratorNormalCompletion2 = true;
  23680. var _didIteratorError2 = false;
  23681. var _iteratorError2 = undefined;
  23682. try {
  23683. for (var _iterator2 = schemaConfig.types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  23684. var existingType = _step2.value;
  23685. typeMap[existingType.name] = extendNamedType(existingType);
  23686. } // Get the extended root operation types.
  23687. } catch (err) {
  23688. _didIteratorError2 = true;
  23689. _iteratorError2 = err;
  23690. } finally {
  23691. try {
  23692. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  23693. _iterator2.return();
  23694. }
  23695. } finally {
  23696. if (_didIteratorError2) {
  23697. throw _iteratorError2;
  23698. }
  23699. }
  23700. }
  23701. var operationTypes = {
  23702. query: schemaConfig.query && schemaConfig.query.name,
  23703. mutation: schemaConfig.mutation && schemaConfig.mutation.name,
  23704. subscription: schemaConfig.subscription && schemaConfig.subscription.name
  23705. };
  23706. if (schemaDef) {
  23707. var _iteratorNormalCompletion3 = true;
  23708. var _didIteratorError3 = false;
  23709. var _iteratorError3 = undefined;
  23710. try {
  23711. for (var _iterator3 = schemaDef.operationTypes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  23712. var _ref2 = _step3.value;
  23713. var operation = _ref2.operation;
  23714. var type = _ref2.type;
  23715. operationTypes[operation] = type.name.value;
  23716. }
  23717. } catch (err) {
  23718. _didIteratorError3 = true;
  23719. _iteratorError3 = err;
  23720. } finally {
  23721. try {
  23722. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  23723. _iterator3.return();
  23724. }
  23725. } finally {
  23726. if (_didIteratorError3) {
  23727. throw _iteratorError3;
  23728. }
  23729. }
  23730. }
  23731. } // Then, incorporate schema definition and all schema extensions.
  23732. for (var _i = 0, _schemaExts = schemaExts; _i < _schemaExts.length; _i++) {
  23733. var schemaExt = _schemaExts[_i];
  23734. if (schemaExt.operationTypes) {
  23735. var _iteratorNormalCompletion4 = true;
  23736. var _didIteratorError4 = false;
  23737. var _iteratorError4 = undefined;
  23738. try {
  23739. for (var _iterator4 = schemaExt.operationTypes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  23740. var _ref4 = _step4.value;
  23741. var _operation = _ref4.operation;
  23742. var _type = _ref4.type;
  23743. operationTypes[_operation] = _type.name.value;
  23744. }
  23745. } catch (err) {
  23746. _didIteratorError4 = true;
  23747. _iteratorError4 = err;
  23748. } finally {
  23749. try {
  23750. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  23751. _iterator4.return();
  23752. }
  23753. } finally {
  23754. if (_didIteratorError4) {
  23755. throw _iteratorError4;
  23756. }
  23757. }
  23758. }
  23759. }
  23760. } // Support both original legacy names and extended legacy names.
  23761. var allowedLegacyNames = schemaConfig.allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
  23762. return new _schema.GraphQLSchema({
  23763. // Note: While this could make early assertions to get the correctly
  23764. // typed values, that would throw immediately while type system
  23765. // validation with validateSchema() will produce more actionable results.
  23766. query: getMaybeTypeByName(operationTypes.query),
  23767. mutation: getMaybeTypeByName(operationTypes.mutation),
  23768. subscription: getMaybeTypeByName(operationTypes.subscription),
  23769. types: (0, _objectValues.default)(typeMap),
  23770. directives: getMergedDirectives(),
  23771. astNode: schemaDef || schemaConfig.astNode,
  23772. extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
  23773. allowedLegacyNames: allowedLegacyNames
  23774. }); // Below are functions used for producing this schema that have closed over
  23775. // this scope and have access to the schema, cache, and newly defined types.
  23776. function replaceType(type) {
  23777. if ((0, _definition.isListType)(type)) {
  23778. return new _definition.GraphQLList(replaceType(type.ofType));
  23779. } else if ((0, _definition.isNonNullType)(type)) {
  23780. return new _definition.GraphQLNonNull(replaceType(type.ofType));
  23781. }
  23782. return replaceNamedType(type);
  23783. }
  23784. function replaceNamedType(type) {
  23785. return typeMap[type.name];
  23786. }
  23787. function getMaybeTypeByName(typeName) {
  23788. return typeName ? typeMap[typeName] : null;
  23789. }
  23790. function getMergedDirectives() {
  23791. var existingDirectives = schema.getDirectives().map(extendDirective);
  23792. !existingDirectives ? (0, _invariant.default)(0, 'schema must have default directives') : void 0;
  23793. return existingDirectives.concat(directiveDefs.map(function (node) {
  23794. return astBuilder.buildDirective(node);
  23795. }));
  23796. }
  23797. function extendNamedType(type) {
  23798. if ((0, _introspection.isIntrospectionType)(type) || (0, _scalars.isSpecifiedScalarType)(type)) {
  23799. // Builtin types are not extended.
  23800. return type;
  23801. } else if ((0, _definition.isScalarType)(type)) {
  23802. return extendScalarType(type);
  23803. } else if ((0, _definition.isObjectType)(type)) {
  23804. return extendObjectType(type);
  23805. } else if ((0, _definition.isInterfaceType)(type)) {
  23806. return extendInterfaceType(type);
  23807. } else if ((0, _definition.isUnionType)(type)) {
  23808. return extendUnionType(type);
  23809. } else if ((0, _definition.isEnumType)(type)) {
  23810. return extendEnumType(type);
  23811. } else if ((0, _definition.isInputObjectType)(type)) {
  23812. return extendInputObjectType(type);
  23813. } // Not reachable. All possible types have been considered.
  23814. /* istanbul ignore next */
  23815. throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
  23816. }
  23817. function extendDirective(directive) {
  23818. var config = directive.toConfig();
  23819. return new _directives.GraphQLDirective(_objectSpread({}, config, {
  23820. args: (0, _mapValue.default)(config.args, extendArg)
  23821. }));
  23822. }
  23823. function extendInputObjectType(type) {
  23824. var config = type.toConfig();
  23825. var extensions = typeExtsMap[config.name] || [];
  23826. var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
  23827. return node.fields || [];
  23828. });
  23829. return new _definition.GraphQLInputObjectType(_objectSpread({}, config, {
  23830. fields: function fields() {
  23831. return _objectSpread({}, (0, _mapValue.default)(config.fields, function (field) {
  23832. return _objectSpread({}, field, {
  23833. type: replaceType(field.type)
  23834. });
  23835. }), (0, _keyValMap.default)(fieldNodes, function (field) {
  23836. return field.name.value;
  23837. }, function (field) {
  23838. return astBuilder.buildInputField(field);
  23839. }));
  23840. },
  23841. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23842. }));
  23843. }
  23844. function extendEnumType(type) {
  23845. var config = type.toConfig();
  23846. var extensions = typeExtsMap[type.name] || [];
  23847. var valueNodes = (0, _flatMap.default)(extensions, function (node) {
  23848. return node.values || [];
  23849. });
  23850. return new _definition.GraphQLEnumType(_objectSpread({}, config, {
  23851. values: _objectSpread({}, config.values, (0, _keyValMap.default)(valueNodes, function (value) {
  23852. return value.name.value;
  23853. }, function (value) {
  23854. return astBuilder.buildEnumValue(value);
  23855. })),
  23856. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23857. }));
  23858. }
  23859. function extendScalarType(type) {
  23860. var config = type.toConfig();
  23861. var extensions = typeExtsMap[config.name] || [];
  23862. return new _definition.GraphQLScalarType(_objectSpread({}, config, {
  23863. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23864. }));
  23865. }
  23866. function extendObjectType(type) {
  23867. var config = type.toConfig();
  23868. var extensions = typeExtsMap[config.name] || [];
  23869. var interfaceNodes = (0, _flatMap.default)(extensions, function (node) {
  23870. return node.interfaces || [];
  23871. });
  23872. var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
  23873. return node.fields || [];
  23874. });
  23875. return new _definition.GraphQLObjectType(_objectSpread({}, config, {
  23876. interfaces: function interfaces() {
  23877. return [].concat(type.getInterfaces().map(replaceNamedType), interfaceNodes.map(function (node) {
  23878. return astBuilder.getNamedType(node);
  23879. }));
  23880. },
  23881. fields: function fields() {
  23882. return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
  23883. return node.name.value;
  23884. }, function (node) {
  23885. return astBuilder.buildField(node);
  23886. }));
  23887. },
  23888. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23889. }));
  23890. }
  23891. function extendInterfaceType(type) {
  23892. var config = type.toConfig();
  23893. var extensions = typeExtsMap[config.name] || [];
  23894. var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
  23895. return node.fields || [];
  23896. });
  23897. return new _definition.GraphQLInterfaceType(_objectSpread({}, config, {
  23898. fields: function fields() {
  23899. return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
  23900. return node.name.value;
  23901. }, function (node) {
  23902. return astBuilder.buildField(node);
  23903. }));
  23904. },
  23905. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23906. }));
  23907. }
  23908. function extendUnionType(type) {
  23909. var config = type.toConfig();
  23910. var extensions = typeExtsMap[config.name] || [];
  23911. var typeNodes = (0, _flatMap.default)(extensions, function (node) {
  23912. return node.types || [];
  23913. });
  23914. return new _definition.GraphQLUnionType(_objectSpread({}, config, {
  23915. types: function types() {
  23916. return [].concat(type.getTypes().map(replaceNamedType), typeNodes.map(function (node) {
  23917. return astBuilder.getNamedType(node);
  23918. }));
  23919. },
  23920. extensionASTNodes: config.extensionASTNodes.concat(extensions)
  23921. }));
  23922. }
  23923. function extendField(field) {
  23924. return _objectSpread({}, field, {
  23925. type: replaceType(field.type),
  23926. args: (0, _mapValue.default)(field.args, extendArg)
  23927. });
  23928. }
  23929. function extendArg(arg) {
  23930. return _objectSpread({}, arg, {
  23931. type: replaceType(arg.type)
  23932. });
  23933. }
  23934. }
  23935. },{"../jsutils/inspect":32,"../jsutils/invariant":34,"../jsutils/keyValMap":39,"../jsutils/mapValue":40,"../language/kinds":51,"../language/predicates":55,"../polyfills/flatMap":60,"../polyfills/objectValues":64,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/scalars":72,"../type/schema":73,"../validation/validate":136,"./buildASTSchema":78}],83:[function(require,module,exports){
  23936. "use strict";
  23937. Object.defineProperty(exports, "__esModule", {
  23938. value: true
  23939. });
  23940. exports.findBreakingChanges = findBreakingChanges;
  23941. exports.findDangerousChanges = findDangerousChanges;
  23942. exports.DangerousChangeType = exports.BreakingChangeType = void 0;
  23943. var _find = _interopRequireDefault(require("../polyfills/find"));
  23944. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  23945. var _definition = require("../type/definition");
  23946. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  23947. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23948. /**
  23949. * Copyright (c) Facebook, Inc. and its affiliates.
  23950. *
  23951. * This source code is licensed under the MIT license found in the
  23952. * LICENSE file in the root directory of this source tree.
  23953. *
  23954. *
  23955. */
  23956. var BreakingChangeType = {
  23957. FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND',
  23958. FIELD_REMOVED: 'FIELD_REMOVED',
  23959. TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND',
  23960. TYPE_REMOVED: 'TYPE_REMOVED',
  23961. TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION',
  23962. VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM',
  23963. ARG_REMOVED: 'ARG_REMOVED',
  23964. ARG_CHANGED_KIND: 'ARG_CHANGED_KIND',
  23965. REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED',
  23966. REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED',
  23967. INTERFACE_REMOVED_FROM_OBJECT: 'INTERFACE_REMOVED_FROM_OBJECT',
  23968. DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED',
  23969. DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED',
  23970. DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED',
  23971. REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED'
  23972. };
  23973. exports.BreakingChangeType = BreakingChangeType;
  23974. var DangerousChangeType = {
  23975. ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE',
  23976. VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM',
  23977. INTERFACE_ADDED_TO_OBJECT: 'INTERFACE_ADDED_TO_OBJECT',
  23978. TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION',
  23979. OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED',
  23980. OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED'
  23981. };
  23982. exports.DangerousChangeType = DangerousChangeType;
  23983. /**
  23984. * Given two schemas, returns an Array containing descriptions of all the types
  23985. * of breaking changes covered by the other functions down below.
  23986. */
  23987. function findBreakingChanges(oldSchema, newSchema) {
  23988. return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedTypeOnObjectOrInterfaceTypes(oldSchema, newSchema), findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema).breakingChanges, findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema), findArgChanges(oldSchema, newSchema).breakingChanges, findInterfacesRemovedFromObjectTypes(oldSchema, newSchema), findRemovedDirectives(oldSchema, newSchema), findRemovedDirectiveArgs(oldSchema, newSchema), findAddedNonNullDirectiveArgs(oldSchema, newSchema), findRemovedDirectiveLocations(oldSchema, newSchema));
  23989. }
  23990. /**
  23991. * Given two schemas, returns an Array containing descriptions of all the types
  23992. * of potentially dangerous changes covered by the other functions down below.
  23993. */
  23994. function findDangerousChanges(oldSchema, newSchema) {
  23995. return [].concat(findArgChanges(oldSchema, newSchema).dangerousChanges, findValuesAddedToEnums(oldSchema, newSchema), findInterfacesAddedToObjectTypes(oldSchema, newSchema), findTypesAddedToUnions(oldSchema, newSchema), findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema).dangerousChanges);
  23996. }
  23997. /**
  23998. * Given two schemas, returns an Array containing descriptions of any breaking
  23999. * changes in the newSchema related to removing an entire type.
  24000. */
  24001. function findRemovedTypes(oldSchema, newSchema) {
  24002. var oldTypeMap = oldSchema.getTypeMap();
  24003. var newTypeMap = newSchema.getTypeMap();
  24004. var breakingChanges = [];
  24005. for (var _i = 0, _Object$keys = Object.keys(oldTypeMap); _i < _Object$keys.length; _i++) {
  24006. var typeName = _Object$keys[_i];
  24007. if (!newTypeMap[typeName]) {
  24008. breakingChanges.push({
  24009. type: BreakingChangeType.TYPE_REMOVED,
  24010. description: "".concat(typeName, " was removed.")
  24011. });
  24012. }
  24013. }
  24014. return breakingChanges;
  24015. }
  24016. /**
  24017. * Given two schemas, returns an Array containing descriptions of any breaking
  24018. * changes in the newSchema related to changing the type of a type.
  24019. */
  24020. function findTypesThatChangedKind(oldSchema, newSchema) {
  24021. var oldTypeMap = oldSchema.getTypeMap();
  24022. var newTypeMap = newSchema.getTypeMap();
  24023. var breakingChanges = [];
  24024. for (var _i2 = 0, _Object$keys2 = Object.keys(oldTypeMap); _i2 < _Object$keys2.length; _i2++) {
  24025. var typeName = _Object$keys2[_i2];
  24026. if (!newTypeMap[typeName]) {
  24027. continue;
  24028. }
  24029. var oldType = oldTypeMap[typeName];
  24030. var newType = newTypeMap[typeName];
  24031. if (oldType.constructor !== newType.constructor) {
  24032. breakingChanges.push({
  24033. type: BreakingChangeType.TYPE_CHANGED_KIND,
  24034. description: "".concat(typeName, " changed from ") + "".concat(typeKindName(oldType), " to ").concat(typeKindName(newType), ".")
  24035. });
  24036. }
  24037. }
  24038. return breakingChanges;
  24039. }
  24040. /**
  24041. * Given two schemas, returns an Array containing descriptions of any
  24042. * breaking or dangerous changes in the newSchema related to arguments
  24043. * (such as removal or change of type of an argument, or a change in an
  24044. * argument's default value).
  24045. */
  24046. function findArgChanges(oldSchema, newSchema) {
  24047. var oldTypeMap = oldSchema.getTypeMap();
  24048. var newTypeMap = newSchema.getTypeMap();
  24049. var breakingChanges = [];
  24050. var dangerousChanges = [];
  24051. for (var _i3 = 0, _Object$keys3 = Object.keys(oldTypeMap); _i3 < _Object$keys3.length; _i3++) {
  24052. var typeName = _Object$keys3[_i3];
  24053. var oldType = oldTypeMap[typeName];
  24054. var newType = newTypeMap[typeName];
  24055. if (!((0, _definition.isObjectType)(oldType) || (0, _definition.isInterfaceType)(oldType)) || !((0, _definition.isObjectType)(newType) || (0, _definition.isInterfaceType)(newType)) || newType.constructor !== oldType.constructor) {
  24056. continue;
  24057. }
  24058. var oldTypeFields = oldType.getFields();
  24059. var newTypeFields = newType.getFields();
  24060. for (var _i4 = 0, _Object$keys4 = Object.keys(oldTypeFields); _i4 < _Object$keys4.length; _i4++) {
  24061. var fieldName = _Object$keys4[_i4];
  24062. if (!newTypeFields[fieldName]) {
  24063. continue;
  24064. }
  24065. var _iteratorNormalCompletion = true;
  24066. var _didIteratorError = false;
  24067. var _iteratorError = undefined;
  24068. try {
  24069. var _loop = function _loop() {
  24070. var oldArgDef = _step.value;
  24071. var newArgs = newTypeFields[fieldName].args;
  24072. var newArgDef = (0, _find.default)(newArgs, function (arg) {
  24073. return arg.name === oldArgDef.name;
  24074. }); // Arg not present
  24075. if (!newArgDef) {
  24076. breakingChanges.push({
  24077. type: BreakingChangeType.ARG_REMOVED,
  24078. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " was removed")
  24079. });
  24080. } else {
  24081. var isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArgDef.type, newArgDef.type);
  24082. if (!isSafe) {
  24083. breakingChanges.push({
  24084. type: BreakingChangeType.ARG_CHANGED_KIND,
  24085. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " has changed type from ") + "".concat(oldArgDef.type.toString(), " to ").concat(newArgDef.type.toString())
  24086. });
  24087. } else if (oldArgDef.defaultValue !== undefined && oldArgDef.defaultValue !== newArgDef.defaultValue) {
  24088. dangerousChanges.push({
  24089. type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
  24090. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " has changed defaultValue")
  24091. });
  24092. }
  24093. }
  24094. };
  24095. for (var _iterator = oldTypeFields[fieldName].args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  24096. _loop();
  24097. } // Check if arg was added to the field
  24098. } catch (err) {
  24099. _didIteratorError = true;
  24100. _iteratorError = err;
  24101. } finally {
  24102. try {
  24103. if (!_iteratorNormalCompletion && _iterator.return != null) {
  24104. _iterator.return();
  24105. }
  24106. } finally {
  24107. if (_didIteratorError) {
  24108. throw _iteratorError;
  24109. }
  24110. }
  24111. }
  24112. var _iteratorNormalCompletion2 = true;
  24113. var _didIteratorError2 = false;
  24114. var _iteratorError2 = undefined;
  24115. try {
  24116. var _loop2 = function _loop2() {
  24117. var newArgDef = _step2.value;
  24118. var oldArgs = oldTypeFields[fieldName].args;
  24119. var oldArgDef = (0, _find.default)(oldArgs, function (arg) {
  24120. return arg.name === newArgDef.name;
  24121. });
  24122. if (!oldArgDef) {
  24123. var argName = newArgDef.name;
  24124. if ((0, _definition.isRequiredArgument)(newArgDef)) {
  24125. breakingChanges.push({
  24126. type: BreakingChangeType.REQUIRED_ARG_ADDED,
  24127. description: "A required arg ".concat(argName, " on ") + "".concat(typeName, ".").concat(fieldName, " was added")
  24128. });
  24129. } else {
  24130. dangerousChanges.push({
  24131. type: DangerousChangeType.OPTIONAL_ARG_ADDED,
  24132. description: "An optional arg ".concat(argName, " on ") + "".concat(typeName, ".").concat(fieldName, " was added")
  24133. });
  24134. }
  24135. }
  24136. };
  24137. for (var _iterator2 = newTypeFields[fieldName].args[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  24138. _loop2();
  24139. }
  24140. } catch (err) {
  24141. _didIteratorError2 = true;
  24142. _iteratorError2 = err;
  24143. } finally {
  24144. try {
  24145. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  24146. _iterator2.return();
  24147. }
  24148. } finally {
  24149. if (_didIteratorError2) {
  24150. throw _iteratorError2;
  24151. }
  24152. }
  24153. }
  24154. }
  24155. }
  24156. return {
  24157. breakingChanges: breakingChanges,
  24158. dangerousChanges: dangerousChanges
  24159. };
  24160. }
  24161. function typeKindName(type) {
  24162. if ((0, _definition.isScalarType)(type)) {
  24163. return 'a Scalar type';
  24164. }
  24165. if ((0, _definition.isObjectType)(type)) {
  24166. return 'an Object type';
  24167. }
  24168. if ((0, _definition.isInterfaceType)(type)) {
  24169. return 'an Interface type';
  24170. }
  24171. if ((0, _definition.isUnionType)(type)) {
  24172. return 'a Union type';
  24173. }
  24174. if ((0, _definition.isEnumType)(type)) {
  24175. return 'an Enum type';
  24176. }
  24177. if ((0, _definition.isInputObjectType)(type)) {
  24178. return 'an Input type';
  24179. } // Not reachable. All possible named types have been considered.
  24180. /* istanbul ignore next */
  24181. throw new TypeError("Unexpected type: ".concat((0, _inspect.default)(type), "."));
  24182. }
  24183. function findFieldsThatChangedTypeOnObjectOrInterfaceTypes(oldSchema, newSchema) {
  24184. var oldTypeMap = oldSchema.getTypeMap();
  24185. var newTypeMap = newSchema.getTypeMap();
  24186. var breakingChanges = [];
  24187. for (var _i5 = 0, _Object$keys5 = Object.keys(oldTypeMap); _i5 < _Object$keys5.length; _i5++) {
  24188. var typeName = _Object$keys5[_i5];
  24189. var oldType = oldTypeMap[typeName];
  24190. var newType = newTypeMap[typeName];
  24191. if (!((0, _definition.isObjectType)(oldType) || (0, _definition.isInterfaceType)(oldType)) || !((0, _definition.isObjectType)(newType) || (0, _definition.isInterfaceType)(newType)) || newType.constructor !== oldType.constructor) {
  24192. continue;
  24193. }
  24194. var oldTypeFieldsDef = oldType.getFields();
  24195. var newTypeFieldsDef = newType.getFields();
  24196. for (var _i6 = 0, _Object$keys6 = Object.keys(oldTypeFieldsDef); _i6 < _Object$keys6.length; _i6++) {
  24197. var fieldName = _Object$keys6[_i6];
  24198. // Check if the field is missing on the type in the new schema.
  24199. if (!(fieldName in newTypeFieldsDef)) {
  24200. breakingChanges.push({
  24201. type: BreakingChangeType.FIELD_REMOVED,
  24202. description: "".concat(typeName, ".").concat(fieldName, " was removed.")
  24203. });
  24204. } else {
  24205. var oldFieldType = oldTypeFieldsDef[fieldName].type;
  24206. var newFieldType = newTypeFieldsDef[fieldName].type;
  24207. var isSafe = isChangeSafeForObjectOrInterfaceField(oldFieldType, newFieldType);
  24208. if (!isSafe) {
  24209. var oldFieldTypeString = (0, _definition.isNamedType)(oldFieldType) ? oldFieldType.name : oldFieldType.toString();
  24210. var newFieldTypeString = (0, _definition.isNamedType)(newFieldType) ? newFieldType.name : newFieldType.toString();
  24211. breakingChanges.push({
  24212. type: BreakingChangeType.FIELD_CHANGED_KIND,
  24213. description: "".concat(typeName, ".").concat(fieldName, " changed type from ") + "".concat(oldFieldTypeString, " to ").concat(newFieldTypeString, ".")
  24214. });
  24215. }
  24216. }
  24217. }
  24218. }
  24219. return breakingChanges;
  24220. }
  24221. function findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema) {
  24222. var oldTypeMap = oldSchema.getTypeMap();
  24223. var newTypeMap = newSchema.getTypeMap();
  24224. var breakingChanges = [];
  24225. var dangerousChanges = [];
  24226. for (var _i7 = 0, _Object$keys7 = Object.keys(oldTypeMap); _i7 < _Object$keys7.length; _i7++) {
  24227. var typeName = _Object$keys7[_i7];
  24228. var oldType = oldTypeMap[typeName];
  24229. var newType = newTypeMap[typeName];
  24230. if (!(0, _definition.isInputObjectType)(oldType) || !(0, _definition.isInputObjectType)(newType)) {
  24231. continue;
  24232. }
  24233. var oldTypeFieldsDef = oldType.getFields();
  24234. var newTypeFieldsDef = newType.getFields();
  24235. for (var _i8 = 0, _Object$keys8 = Object.keys(oldTypeFieldsDef); _i8 < _Object$keys8.length; _i8++) {
  24236. var fieldName = _Object$keys8[_i8];
  24237. // Check if the field is missing on the type in the new schema.
  24238. if (!(fieldName in newTypeFieldsDef)) {
  24239. breakingChanges.push({
  24240. type: BreakingChangeType.FIELD_REMOVED,
  24241. description: "".concat(typeName, ".").concat(fieldName, " was removed.")
  24242. });
  24243. } else {
  24244. var oldFieldType = oldTypeFieldsDef[fieldName].type;
  24245. var newFieldType = newTypeFieldsDef[fieldName].type;
  24246. var isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldFieldType, newFieldType);
  24247. if (!isSafe) {
  24248. var oldFieldTypeString = (0, _definition.isNamedType)(oldFieldType) ? oldFieldType.name : oldFieldType.toString();
  24249. var newFieldTypeString = (0, _definition.isNamedType)(newFieldType) ? newFieldType.name : newFieldType.toString();
  24250. breakingChanges.push({
  24251. type: BreakingChangeType.FIELD_CHANGED_KIND,
  24252. description: "".concat(typeName, ".").concat(fieldName, " changed type from ") + "".concat(oldFieldTypeString, " to ").concat(newFieldTypeString, ".")
  24253. });
  24254. }
  24255. }
  24256. } // Check if a field was added to the input object type
  24257. for (var _i9 = 0, _Object$keys9 = Object.keys(newTypeFieldsDef); _i9 < _Object$keys9.length; _i9++) {
  24258. var _fieldName = _Object$keys9[_i9];
  24259. if (!(_fieldName in oldTypeFieldsDef)) {
  24260. if ((0, _definition.isRequiredInputField)(newTypeFieldsDef[_fieldName])) {
  24261. breakingChanges.push({
  24262. type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED,
  24263. description: "A required field ".concat(_fieldName, " on ") + "input type ".concat(typeName, " was added.")
  24264. });
  24265. } else {
  24266. dangerousChanges.push({
  24267. type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED,
  24268. description: "An optional field ".concat(_fieldName, " on ") + "input type ".concat(typeName, " was added.")
  24269. });
  24270. }
  24271. }
  24272. }
  24273. }
  24274. return {
  24275. breakingChanges: breakingChanges,
  24276. dangerousChanges: dangerousChanges
  24277. };
  24278. }
  24279. function isChangeSafeForObjectOrInterfaceField(oldType, newType) {
  24280. if ((0, _definition.isListType)(oldType)) {
  24281. return (// if they're both lists, make sure the underlying types are compatible
  24282. (0, _definition.isListType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) || // moving from nullable to non-null of the same underlying type is safe
  24283. (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)
  24284. );
  24285. }
  24286. if ((0, _definition.isNonNullType)(oldType)) {
  24287. // if they're both non-null, make sure the underlying types are compatible
  24288. return (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType);
  24289. }
  24290. return (// if they're both named types, see if their names are equivalent
  24291. (0, _definition.isNamedType)(newType) && oldType.name === newType.name || // moving from nullable to non-null of the same underlying type is safe
  24292. (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)
  24293. );
  24294. }
  24295. function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) {
  24296. if ((0, _definition.isListType)(oldType)) {
  24297. // if they're both lists, make sure the underlying types are compatible
  24298. return (0, _definition.isListType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType);
  24299. }
  24300. if ((0, _definition.isNonNullType)(oldType)) {
  24301. return (// if they're both non-null, make sure the underlying types are
  24302. // compatible
  24303. (0, _definition.isNonNullType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) || // moving from non-null to nullable of the same underlying type is safe
  24304. !(0, _definition.isNonNullType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)
  24305. );
  24306. } // if they're both named types, see if their names are equivalent
  24307. return (0, _definition.isNamedType)(newType) && oldType.name === newType.name;
  24308. }
  24309. /**
  24310. * Given two schemas, returns an Array containing descriptions of any breaking
  24311. * changes in the newSchema related to removing types from a union type.
  24312. */
  24313. function findTypesRemovedFromUnions(oldSchema, newSchema) {
  24314. var oldTypeMap = oldSchema.getTypeMap();
  24315. var newTypeMap = newSchema.getTypeMap();
  24316. var typesRemovedFromUnion = [];
  24317. for (var _i10 = 0, _Object$keys10 = Object.keys(oldTypeMap); _i10 < _Object$keys10.length; _i10++) {
  24318. var typeName = _Object$keys10[_i10];
  24319. var oldType = oldTypeMap[typeName];
  24320. var newType = newTypeMap[typeName];
  24321. if (!(0, _definition.isUnionType)(oldType) || !(0, _definition.isUnionType)(newType)) {
  24322. continue;
  24323. }
  24324. var typeNamesInNewUnion = Object.create(null);
  24325. var _iteratorNormalCompletion3 = true;
  24326. var _didIteratorError3 = false;
  24327. var _iteratorError3 = undefined;
  24328. try {
  24329. for (var _iterator3 = newType.getTypes()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  24330. var type = _step3.value;
  24331. typeNamesInNewUnion[type.name] = true;
  24332. }
  24333. } catch (err) {
  24334. _didIteratorError3 = true;
  24335. _iteratorError3 = err;
  24336. } finally {
  24337. try {
  24338. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  24339. _iterator3.return();
  24340. }
  24341. } finally {
  24342. if (_didIteratorError3) {
  24343. throw _iteratorError3;
  24344. }
  24345. }
  24346. }
  24347. var _iteratorNormalCompletion4 = true;
  24348. var _didIteratorError4 = false;
  24349. var _iteratorError4 = undefined;
  24350. try {
  24351. for (var _iterator4 = oldType.getTypes()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  24352. var _type = _step4.value;
  24353. if (!typeNamesInNewUnion[_type.name]) {
  24354. typesRemovedFromUnion.push({
  24355. type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,
  24356. description: "".concat(_type.name, " was removed from union type ").concat(typeName, ".")
  24357. });
  24358. }
  24359. }
  24360. } catch (err) {
  24361. _didIteratorError4 = true;
  24362. _iteratorError4 = err;
  24363. } finally {
  24364. try {
  24365. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  24366. _iterator4.return();
  24367. }
  24368. } finally {
  24369. if (_didIteratorError4) {
  24370. throw _iteratorError4;
  24371. }
  24372. }
  24373. }
  24374. }
  24375. return typesRemovedFromUnion;
  24376. }
  24377. /**
  24378. * Given two schemas, returns an Array containing descriptions of any dangerous
  24379. * changes in the newSchema related to adding types to a union type.
  24380. */
  24381. function findTypesAddedToUnions(oldSchema, newSchema) {
  24382. var oldTypeMap = oldSchema.getTypeMap();
  24383. var newTypeMap = newSchema.getTypeMap();
  24384. var typesAddedToUnion = [];
  24385. for (var _i11 = 0, _Object$keys11 = Object.keys(newTypeMap); _i11 < _Object$keys11.length; _i11++) {
  24386. var typeName = _Object$keys11[_i11];
  24387. var oldType = oldTypeMap[typeName];
  24388. var newType = newTypeMap[typeName];
  24389. if (!(0, _definition.isUnionType)(oldType) || !(0, _definition.isUnionType)(newType)) {
  24390. continue;
  24391. }
  24392. var typeNamesInOldUnion = Object.create(null);
  24393. var _iteratorNormalCompletion5 = true;
  24394. var _didIteratorError5 = false;
  24395. var _iteratorError5 = undefined;
  24396. try {
  24397. for (var _iterator5 = oldType.getTypes()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  24398. var type = _step5.value;
  24399. typeNamesInOldUnion[type.name] = true;
  24400. }
  24401. } catch (err) {
  24402. _didIteratorError5 = true;
  24403. _iteratorError5 = err;
  24404. } finally {
  24405. try {
  24406. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  24407. _iterator5.return();
  24408. }
  24409. } finally {
  24410. if (_didIteratorError5) {
  24411. throw _iteratorError5;
  24412. }
  24413. }
  24414. }
  24415. var _iteratorNormalCompletion6 = true;
  24416. var _didIteratorError6 = false;
  24417. var _iteratorError6 = undefined;
  24418. try {
  24419. for (var _iterator6 = newType.getTypes()[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  24420. var _type2 = _step6.value;
  24421. if (!typeNamesInOldUnion[_type2.name]) {
  24422. typesAddedToUnion.push({
  24423. type: DangerousChangeType.TYPE_ADDED_TO_UNION,
  24424. description: "".concat(_type2.name, " was added to union type ").concat(typeName, ".")
  24425. });
  24426. }
  24427. }
  24428. } catch (err) {
  24429. _didIteratorError6 = true;
  24430. _iteratorError6 = err;
  24431. } finally {
  24432. try {
  24433. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  24434. _iterator6.return();
  24435. }
  24436. } finally {
  24437. if (_didIteratorError6) {
  24438. throw _iteratorError6;
  24439. }
  24440. }
  24441. }
  24442. }
  24443. return typesAddedToUnion;
  24444. }
  24445. /**
  24446. * Given two schemas, returns an Array containing descriptions of any breaking
  24447. * changes in the newSchema related to removing values from an enum type.
  24448. */
  24449. function findValuesRemovedFromEnums(oldSchema, newSchema) {
  24450. var oldTypeMap = oldSchema.getTypeMap();
  24451. var newTypeMap = newSchema.getTypeMap();
  24452. var valuesRemovedFromEnums = [];
  24453. for (var _i12 = 0, _Object$keys12 = Object.keys(oldTypeMap); _i12 < _Object$keys12.length; _i12++) {
  24454. var typeName = _Object$keys12[_i12];
  24455. var oldType = oldTypeMap[typeName];
  24456. var newType = newTypeMap[typeName];
  24457. if (!(0, _definition.isEnumType)(oldType) || !(0, _definition.isEnumType)(newType)) {
  24458. continue;
  24459. }
  24460. var valuesInNewEnum = Object.create(null);
  24461. var _iteratorNormalCompletion7 = true;
  24462. var _didIteratorError7 = false;
  24463. var _iteratorError7 = undefined;
  24464. try {
  24465. for (var _iterator7 = newType.getValues()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  24466. var value = _step7.value;
  24467. valuesInNewEnum[value.name] = true;
  24468. }
  24469. } catch (err) {
  24470. _didIteratorError7 = true;
  24471. _iteratorError7 = err;
  24472. } finally {
  24473. try {
  24474. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  24475. _iterator7.return();
  24476. }
  24477. } finally {
  24478. if (_didIteratorError7) {
  24479. throw _iteratorError7;
  24480. }
  24481. }
  24482. }
  24483. var _iteratorNormalCompletion8 = true;
  24484. var _didIteratorError8 = false;
  24485. var _iteratorError8 = undefined;
  24486. try {
  24487. for (var _iterator8 = oldType.getValues()[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  24488. var _value = _step8.value;
  24489. if (!valuesInNewEnum[_value.name]) {
  24490. valuesRemovedFromEnums.push({
  24491. type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,
  24492. description: "".concat(_value.name, " was removed from enum type ").concat(typeName, ".")
  24493. });
  24494. }
  24495. }
  24496. } catch (err) {
  24497. _didIteratorError8 = true;
  24498. _iteratorError8 = err;
  24499. } finally {
  24500. try {
  24501. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  24502. _iterator8.return();
  24503. }
  24504. } finally {
  24505. if (_didIteratorError8) {
  24506. throw _iteratorError8;
  24507. }
  24508. }
  24509. }
  24510. }
  24511. return valuesRemovedFromEnums;
  24512. }
  24513. /**
  24514. * Given two schemas, returns an Array containing descriptions of any dangerous
  24515. * changes in the newSchema related to adding values to an enum type.
  24516. */
  24517. function findValuesAddedToEnums(oldSchema, newSchema) {
  24518. var oldTypeMap = oldSchema.getTypeMap();
  24519. var newTypeMap = newSchema.getTypeMap();
  24520. var valuesAddedToEnums = [];
  24521. for (var _i13 = 0, _Object$keys13 = Object.keys(oldTypeMap); _i13 < _Object$keys13.length; _i13++) {
  24522. var typeName = _Object$keys13[_i13];
  24523. var oldType = oldTypeMap[typeName];
  24524. var newType = newTypeMap[typeName];
  24525. if (!(0, _definition.isEnumType)(oldType) || !(0, _definition.isEnumType)(newType)) {
  24526. continue;
  24527. }
  24528. var valuesInOldEnum = Object.create(null);
  24529. var _iteratorNormalCompletion9 = true;
  24530. var _didIteratorError9 = false;
  24531. var _iteratorError9 = undefined;
  24532. try {
  24533. for (var _iterator9 = oldType.getValues()[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  24534. var value = _step9.value;
  24535. valuesInOldEnum[value.name] = true;
  24536. }
  24537. } catch (err) {
  24538. _didIteratorError9 = true;
  24539. _iteratorError9 = err;
  24540. } finally {
  24541. try {
  24542. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  24543. _iterator9.return();
  24544. }
  24545. } finally {
  24546. if (_didIteratorError9) {
  24547. throw _iteratorError9;
  24548. }
  24549. }
  24550. }
  24551. var _iteratorNormalCompletion10 = true;
  24552. var _didIteratorError10 = false;
  24553. var _iteratorError10 = undefined;
  24554. try {
  24555. for (var _iterator10 = newType.getValues()[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  24556. var _value2 = _step10.value;
  24557. if (!valuesInOldEnum[_value2.name]) {
  24558. valuesAddedToEnums.push({
  24559. type: DangerousChangeType.VALUE_ADDED_TO_ENUM,
  24560. description: "".concat(_value2.name, " was added to enum type ").concat(typeName, ".")
  24561. });
  24562. }
  24563. }
  24564. } catch (err) {
  24565. _didIteratorError10 = true;
  24566. _iteratorError10 = err;
  24567. } finally {
  24568. try {
  24569. if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
  24570. _iterator10.return();
  24571. }
  24572. } finally {
  24573. if (_didIteratorError10) {
  24574. throw _iteratorError10;
  24575. }
  24576. }
  24577. }
  24578. }
  24579. return valuesAddedToEnums;
  24580. }
  24581. function findInterfacesRemovedFromObjectTypes(oldSchema, newSchema) {
  24582. var oldTypeMap = oldSchema.getTypeMap();
  24583. var newTypeMap = newSchema.getTypeMap();
  24584. var breakingChanges = [];
  24585. for (var _i14 = 0, _Object$keys14 = Object.keys(oldTypeMap); _i14 < _Object$keys14.length; _i14++) {
  24586. var typeName = _Object$keys14[_i14];
  24587. var oldType = oldTypeMap[typeName];
  24588. var newType = newTypeMap[typeName];
  24589. if (!(0, _definition.isObjectType)(oldType) || !(0, _definition.isObjectType)(newType)) {
  24590. continue;
  24591. }
  24592. var oldInterfaces = oldType.getInterfaces();
  24593. var newInterfaces = newType.getInterfaces();
  24594. var _iteratorNormalCompletion11 = true;
  24595. var _didIteratorError11 = false;
  24596. var _iteratorError11 = undefined;
  24597. try {
  24598. var _loop3 = function _loop3() {
  24599. var oldInterface = _step11.value;
  24600. if (!newInterfaces.some(function (int) {
  24601. return int.name === oldInterface.name;
  24602. })) {
  24603. breakingChanges.push({
  24604. type: BreakingChangeType.INTERFACE_REMOVED_FROM_OBJECT,
  24605. description: "".concat(typeName, " no longer implements interface ") + "".concat(oldInterface.name, ".")
  24606. });
  24607. }
  24608. };
  24609. for (var _iterator11 = oldInterfaces[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  24610. _loop3();
  24611. }
  24612. } catch (err) {
  24613. _didIteratorError11 = true;
  24614. _iteratorError11 = err;
  24615. } finally {
  24616. try {
  24617. if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
  24618. _iterator11.return();
  24619. }
  24620. } finally {
  24621. if (_didIteratorError11) {
  24622. throw _iteratorError11;
  24623. }
  24624. }
  24625. }
  24626. }
  24627. return breakingChanges;
  24628. }
  24629. function findInterfacesAddedToObjectTypes(oldSchema, newSchema) {
  24630. var oldTypeMap = oldSchema.getTypeMap();
  24631. var newTypeMap = newSchema.getTypeMap();
  24632. var interfacesAddedToObjectTypes = [];
  24633. for (var _i15 = 0, _Object$keys15 = Object.keys(newTypeMap); _i15 < _Object$keys15.length; _i15++) {
  24634. var typeName = _Object$keys15[_i15];
  24635. var oldType = oldTypeMap[typeName];
  24636. var newType = newTypeMap[typeName];
  24637. if (!(0, _definition.isObjectType)(oldType) || !(0, _definition.isObjectType)(newType)) {
  24638. continue;
  24639. }
  24640. var oldInterfaces = oldType.getInterfaces();
  24641. var newInterfaces = newType.getInterfaces();
  24642. var _iteratorNormalCompletion12 = true;
  24643. var _didIteratorError12 = false;
  24644. var _iteratorError12 = undefined;
  24645. try {
  24646. var _loop4 = function _loop4() {
  24647. var newInterface = _step12.value;
  24648. if (!oldInterfaces.some(function (int) {
  24649. return int.name === newInterface.name;
  24650. })) {
  24651. interfacesAddedToObjectTypes.push({
  24652. type: DangerousChangeType.INTERFACE_ADDED_TO_OBJECT,
  24653. description: "".concat(newInterface.name, " added to interfaces implemented ") + "by ".concat(typeName, ".")
  24654. });
  24655. }
  24656. };
  24657. for (var _iterator12 = newInterfaces[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  24658. _loop4();
  24659. }
  24660. } catch (err) {
  24661. _didIteratorError12 = true;
  24662. _iteratorError12 = err;
  24663. } finally {
  24664. try {
  24665. if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
  24666. _iterator12.return();
  24667. }
  24668. } finally {
  24669. if (_didIteratorError12) {
  24670. throw _iteratorError12;
  24671. }
  24672. }
  24673. }
  24674. }
  24675. return interfacesAddedToObjectTypes;
  24676. }
  24677. function findRemovedDirectives(oldSchema, newSchema) {
  24678. var removedDirectives = [];
  24679. var newSchemaDirectiveMap = getDirectiveMapForSchema(newSchema);
  24680. var _iteratorNormalCompletion13 = true;
  24681. var _didIteratorError13 = false;
  24682. var _iteratorError13 = undefined;
  24683. try {
  24684. for (var _iterator13 = oldSchema.getDirectives()[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  24685. var directive = _step13.value;
  24686. if (!newSchemaDirectiveMap[directive.name]) {
  24687. removedDirectives.push({
  24688. type: BreakingChangeType.DIRECTIVE_REMOVED,
  24689. description: "".concat(directive.name, " was removed")
  24690. });
  24691. }
  24692. }
  24693. } catch (err) {
  24694. _didIteratorError13 = true;
  24695. _iteratorError13 = err;
  24696. } finally {
  24697. try {
  24698. if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
  24699. _iterator13.return();
  24700. }
  24701. } finally {
  24702. if (_didIteratorError13) {
  24703. throw _iteratorError13;
  24704. }
  24705. }
  24706. }
  24707. return removedDirectives;
  24708. }
  24709. function findRemovedArgsForDirective(oldDirective, newDirective) {
  24710. var removedArgs = [];
  24711. var newArgMap = getArgumentMapForDirective(newDirective);
  24712. var _iteratorNormalCompletion14 = true;
  24713. var _didIteratorError14 = false;
  24714. var _iteratorError14 = undefined;
  24715. try {
  24716. for (var _iterator14 = oldDirective.args[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  24717. var arg = _step14.value;
  24718. if (!newArgMap[arg.name]) {
  24719. removedArgs.push(arg);
  24720. }
  24721. }
  24722. } catch (err) {
  24723. _didIteratorError14 = true;
  24724. _iteratorError14 = err;
  24725. } finally {
  24726. try {
  24727. if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
  24728. _iterator14.return();
  24729. }
  24730. } finally {
  24731. if (_didIteratorError14) {
  24732. throw _iteratorError14;
  24733. }
  24734. }
  24735. }
  24736. return removedArgs;
  24737. }
  24738. function findRemovedDirectiveArgs(oldSchema, newSchema) {
  24739. var removedDirectiveArgs = [];
  24740. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  24741. var _iteratorNormalCompletion15 = true;
  24742. var _didIteratorError15 = false;
  24743. var _iteratorError15 = undefined;
  24744. try {
  24745. for (var _iterator15 = newSchema.getDirectives()[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
  24746. var newDirective = _step15.value;
  24747. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  24748. if (!oldDirective) {
  24749. continue;
  24750. }
  24751. var _iteratorNormalCompletion16 = true;
  24752. var _didIteratorError16 = false;
  24753. var _iteratorError16 = undefined;
  24754. try {
  24755. for (var _iterator16 = findRemovedArgsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
  24756. var arg = _step16.value;
  24757. removedDirectiveArgs.push({
  24758. type: BreakingChangeType.DIRECTIVE_ARG_REMOVED,
  24759. description: "".concat(arg.name, " was removed from ").concat(newDirective.name)
  24760. });
  24761. }
  24762. } catch (err) {
  24763. _didIteratorError16 = true;
  24764. _iteratorError16 = err;
  24765. } finally {
  24766. try {
  24767. if (!_iteratorNormalCompletion16 && _iterator16.return != null) {
  24768. _iterator16.return();
  24769. }
  24770. } finally {
  24771. if (_didIteratorError16) {
  24772. throw _iteratorError16;
  24773. }
  24774. }
  24775. }
  24776. }
  24777. } catch (err) {
  24778. _didIteratorError15 = true;
  24779. _iteratorError15 = err;
  24780. } finally {
  24781. try {
  24782. if (!_iteratorNormalCompletion15 && _iterator15.return != null) {
  24783. _iterator15.return();
  24784. }
  24785. } finally {
  24786. if (_didIteratorError15) {
  24787. throw _iteratorError15;
  24788. }
  24789. }
  24790. }
  24791. return removedDirectiveArgs;
  24792. }
  24793. function findAddedArgsForDirective(oldDirective, newDirective) {
  24794. var addedArgs = [];
  24795. var oldArgMap = getArgumentMapForDirective(oldDirective);
  24796. var _iteratorNormalCompletion17 = true;
  24797. var _didIteratorError17 = false;
  24798. var _iteratorError17 = undefined;
  24799. try {
  24800. for (var _iterator17 = newDirective.args[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
  24801. var arg = _step17.value;
  24802. if (!oldArgMap[arg.name]) {
  24803. addedArgs.push(arg);
  24804. }
  24805. }
  24806. } catch (err) {
  24807. _didIteratorError17 = true;
  24808. _iteratorError17 = err;
  24809. } finally {
  24810. try {
  24811. if (!_iteratorNormalCompletion17 && _iterator17.return != null) {
  24812. _iterator17.return();
  24813. }
  24814. } finally {
  24815. if (_didIteratorError17) {
  24816. throw _iteratorError17;
  24817. }
  24818. }
  24819. }
  24820. return addedArgs;
  24821. }
  24822. function findAddedNonNullDirectiveArgs(oldSchema, newSchema) {
  24823. var addedNonNullableArgs = [];
  24824. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  24825. var _iteratorNormalCompletion18 = true;
  24826. var _didIteratorError18 = false;
  24827. var _iteratorError18 = undefined;
  24828. try {
  24829. for (var _iterator18 = newSchema.getDirectives()[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
  24830. var newDirective = _step18.value;
  24831. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  24832. if (!oldDirective) {
  24833. continue;
  24834. }
  24835. var _iteratorNormalCompletion19 = true;
  24836. var _didIteratorError19 = false;
  24837. var _iteratorError19 = undefined;
  24838. try {
  24839. for (var _iterator19 = findAddedArgsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
  24840. var arg = _step19.value;
  24841. if ((0, _definition.isRequiredArgument)(arg)) {
  24842. addedNonNullableArgs.push({
  24843. type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED,
  24844. description: "A required arg ".concat(arg.name, " on directive ") + "".concat(newDirective.name, " was added")
  24845. });
  24846. }
  24847. }
  24848. } catch (err) {
  24849. _didIteratorError19 = true;
  24850. _iteratorError19 = err;
  24851. } finally {
  24852. try {
  24853. if (!_iteratorNormalCompletion19 && _iterator19.return != null) {
  24854. _iterator19.return();
  24855. }
  24856. } finally {
  24857. if (_didIteratorError19) {
  24858. throw _iteratorError19;
  24859. }
  24860. }
  24861. }
  24862. }
  24863. } catch (err) {
  24864. _didIteratorError18 = true;
  24865. _iteratorError18 = err;
  24866. } finally {
  24867. try {
  24868. if (!_iteratorNormalCompletion18 && _iterator18.return != null) {
  24869. _iterator18.return();
  24870. }
  24871. } finally {
  24872. if (_didIteratorError18) {
  24873. throw _iteratorError18;
  24874. }
  24875. }
  24876. }
  24877. return addedNonNullableArgs;
  24878. }
  24879. function findRemovedLocationsForDirective(oldDirective, newDirective) {
  24880. var removedLocations = [];
  24881. var newLocationSet = new Set(newDirective.locations);
  24882. var _iteratorNormalCompletion20 = true;
  24883. var _didIteratorError20 = false;
  24884. var _iteratorError20 = undefined;
  24885. try {
  24886. for (var _iterator20 = oldDirective.locations[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
  24887. var oldLocation = _step20.value;
  24888. if (!newLocationSet.has(oldLocation)) {
  24889. removedLocations.push(oldLocation);
  24890. }
  24891. }
  24892. } catch (err) {
  24893. _didIteratorError20 = true;
  24894. _iteratorError20 = err;
  24895. } finally {
  24896. try {
  24897. if (!_iteratorNormalCompletion20 && _iterator20.return != null) {
  24898. _iterator20.return();
  24899. }
  24900. } finally {
  24901. if (_didIteratorError20) {
  24902. throw _iteratorError20;
  24903. }
  24904. }
  24905. }
  24906. return removedLocations;
  24907. }
  24908. function findRemovedDirectiveLocations(oldSchema, newSchema) {
  24909. var removedLocations = [];
  24910. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  24911. var _iteratorNormalCompletion21 = true;
  24912. var _didIteratorError21 = false;
  24913. var _iteratorError21 = undefined;
  24914. try {
  24915. for (var _iterator21 = newSchema.getDirectives()[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
  24916. var newDirective = _step21.value;
  24917. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  24918. if (!oldDirective) {
  24919. continue;
  24920. }
  24921. var _iteratorNormalCompletion22 = true;
  24922. var _didIteratorError22 = false;
  24923. var _iteratorError22 = undefined;
  24924. try {
  24925. for (var _iterator22 = findRemovedLocationsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
  24926. var location = _step22.value;
  24927. removedLocations.push({
  24928. type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED,
  24929. description: "".concat(location, " was removed from ").concat(newDirective.name)
  24930. });
  24931. }
  24932. } catch (err) {
  24933. _didIteratorError22 = true;
  24934. _iteratorError22 = err;
  24935. } finally {
  24936. try {
  24937. if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
  24938. _iterator22.return();
  24939. }
  24940. } finally {
  24941. if (_didIteratorError22) {
  24942. throw _iteratorError22;
  24943. }
  24944. }
  24945. }
  24946. }
  24947. } catch (err) {
  24948. _didIteratorError21 = true;
  24949. _iteratorError21 = err;
  24950. } finally {
  24951. try {
  24952. if (!_iteratorNormalCompletion21 && _iterator21.return != null) {
  24953. _iterator21.return();
  24954. }
  24955. } finally {
  24956. if (_didIteratorError21) {
  24957. throw _iteratorError21;
  24958. }
  24959. }
  24960. }
  24961. return removedLocations;
  24962. }
  24963. function getDirectiveMapForSchema(schema) {
  24964. return (0, _keyMap.default)(schema.getDirectives(), function (dir) {
  24965. return dir.name;
  24966. });
  24967. }
  24968. function getArgumentMapForDirective(directive) {
  24969. return (0, _keyMap.default)(directive.args, function (arg) {
  24970. return arg.name;
  24971. });
  24972. }
  24973. },{"../jsutils/inspect":32,"../jsutils/keyMap":38,"../polyfills/find":59,"../type/definition":68}],84:[function(require,module,exports){
  24974. "use strict";
  24975. Object.defineProperty(exports, "__esModule", {
  24976. value: true
  24977. });
  24978. exports.findDeprecatedUsages = findDeprecatedUsages;
  24979. var _GraphQLError = require("../error/GraphQLError");
  24980. var _visitor = require("../language/visitor");
  24981. var _definition = require("../type/definition");
  24982. var _TypeInfo = require("./TypeInfo");
  24983. /**
  24984. * Copyright (c) Facebook, Inc. and its affiliates.
  24985. *
  24986. * This source code is licensed under the MIT license found in the
  24987. * LICENSE file in the root directory of this source tree.
  24988. *
  24989. *
  24990. */
  24991. /**
  24992. * A validation rule which reports deprecated usages.
  24993. *
  24994. * Returns a list of GraphQLError instances describing each deprecated use.
  24995. */
  24996. function findDeprecatedUsages(schema, ast) {
  24997. var errors = [];
  24998. var typeInfo = new _TypeInfo.TypeInfo(schema);
  24999. (0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  25000. Field: function Field(node) {
  25001. var fieldDef = typeInfo.getFieldDef();
  25002. if (fieldDef && fieldDef.isDeprecated) {
  25003. var parentType = typeInfo.getParentType();
  25004. if (parentType) {
  25005. var reason = fieldDef.deprecationReason;
  25006. errors.push(new _GraphQLError.GraphQLError("The field ".concat(parentType.name, ".").concat(fieldDef.name, " is deprecated.") + (reason ? ' ' + reason : ''), node));
  25007. }
  25008. }
  25009. },
  25010. EnumValue: function EnumValue(node) {
  25011. var enumVal = typeInfo.getEnumValue();
  25012. if (enumVal && enumVal.isDeprecated) {
  25013. var type = (0, _definition.getNamedType)(typeInfo.getInputType());
  25014. if (type) {
  25015. var reason = enumVal.deprecationReason;
  25016. errors.push(new _GraphQLError.GraphQLError("The enum value ".concat(type.name, ".").concat(enumVal.name, " is deprecated.") + (reason ? ' ' + reason : ''), node));
  25017. }
  25018. }
  25019. }
  25020. }));
  25021. return errors;
  25022. }
  25023. },{"../error/GraphQLError":19,"../language/visitor":58,"../type/definition":68,"./TypeInfo":75}],85:[function(require,module,exports){
  25024. "use strict";
  25025. Object.defineProperty(exports, "__esModule", {
  25026. value: true
  25027. });
  25028. exports.getOperationAST = getOperationAST;
  25029. var _kinds = require("../language/kinds");
  25030. /**
  25031. * Copyright (c) Facebook, Inc. and its affiliates.
  25032. *
  25033. * This source code is licensed under the MIT license found in the
  25034. * LICENSE file in the root directory of this source tree.
  25035. *
  25036. *
  25037. */
  25038. /**
  25039. * Returns an operation AST given a document AST and optionally an operation
  25040. * name. If a name is not provided, an operation is only returned if only one is
  25041. * provided in the document.
  25042. */
  25043. function getOperationAST(documentAST, operationName) {
  25044. var operation = null;
  25045. for (var i = 0; i < documentAST.definitions.length; i++) {
  25046. var definition = documentAST.definitions[i];
  25047. if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
  25048. if (!operationName) {
  25049. // If no operation name was provided, only return an Operation if there
  25050. // is one defined in the document. Upon encountering the second, return
  25051. // null.
  25052. if (operation) {
  25053. return null;
  25054. }
  25055. operation = definition;
  25056. } else if (definition.name && definition.name.value === operationName) {
  25057. return definition;
  25058. }
  25059. }
  25060. }
  25061. return operation;
  25062. }
  25063. },{"../language/kinds":51}],86:[function(require,module,exports){
  25064. "use strict";
  25065. Object.defineProperty(exports, "__esModule", {
  25066. value: true
  25067. });
  25068. exports.getOperationRootType = getOperationRootType;
  25069. var _GraphQLError = require("../error/GraphQLError");
  25070. /**
  25071. * Copyright (c) Facebook, Inc. and its affiliates.
  25072. *
  25073. * This source code is licensed under the MIT license found in the
  25074. * LICENSE file in the root directory of this source tree.
  25075. *
  25076. *
  25077. */
  25078. /**
  25079. * Extracts the root type of the operation from the schema.
  25080. */
  25081. function getOperationRootType(schema, operation) {
  25082. if (operation.operation === 'query') {
  25083. var queryType = schema.getQueryType();
  25084. if (!queryType) {
  25085. throw new _GraphQLError.GraphQLError('Schema does not define the required query root type.', operation);
  25086. }
  25087. return queryType;
  25088. }
  25089. if (operation.operation === 'mutation') {
  25090. var mutationType = schema.getMutationType();
  25091. if (!mutationType) {
  25092. throw new _GraphQLError.GraphQLError('Schema is not configured for mutations.', operation);
  25093. }
  25094. return mutationType;
  25095. }
  25096. if (operation.operation === 'subscription') {
  25097. var subscriptionType = schema.getSubscriptionType();
  25098. if (!subscriptionType) {
  25099. throw new _GraphQLError.GraphQLError('Schema is not configured for subscriptions.', operation);
  25100. }
  25101. return subscriptionType;
  25102. }
  25103. throw new _GraphQLError.GraphQLError('Can only have query, mutation and subscription operations.', operation);
  25104. }
  25105. },{"../error/GraphQLError":19}],87:[function(require,module,exports){
  25106. "use strict";
  25107. Object.defineProperty(exports, "__esModule", {
  25108. value: true
  25109. });
  25110. Object.defineProperty(exports, "getIntrospectionQuery", {
  25111. enumerable: true,
  25112. get: function get() {
  25113. return _introspectionQuery.getIntrospectionQuery;
  25114. }
  25115. });
  25116. Object.defineProperty(exports, "introspectionQuery", {
  25117. enumerable: true,
  25118. get: function get() {
  25119. return _introspectionQuery.introspectionQuery;
  25120. }
  25121. });
  25122. Object.defineProperty(exports, "getOperationAST", {
  25123. enumerable: true,
  25124. get: function get() {
  25125. return _getOperationAST.getOperationAST;
  25126. }
  25127. });
  25128. Object.defineProperty(exports, "getOperationRootType", {
  25129. enumerable: true,
  25130. get: function get() {
  25131. return _getOperationRootType.getOperationRootType;
  25132. }
  25133. });
  25134. Object.defineProperty(exports, "introspectionFromSchema", {
  25135. enumerable: true,
  25136. get: function get() {
  25137. return _introspectionFromSchema.introspectionFromSchema;
  25138. }
  25139. });
  25140. Object.defineProperty(exports, "buildClientSchema", {
  25141. enumerable: true,
  25142. get: function get() {
  25143. return _buildClientSchema.buildClientSchema;
  25144. }
  25145. });
  25146. Object.defineProperty(exports, "buildASTSchema", {
  25147. enumerable: true,
  25148. get: function get() {
  25149. return _buildASTSchema.buildASTSchema;
  25150. }
  25151. });
  25152. Object.defineProperty(exports, "buildSchema", {
  25153. enumerable: true,
  25154. get: function get() {
  25155. return _buildASTSchema.buildSchema;
  25156. }
  25157. });
  25158. Object.defineProperty(exports, "getDescription", {
  25159. enumerable: true,
  25160. get: function get() {
  25161. return _buildASTSchema.getDescription;
  25162. }
  25163. });
  25164. Object.defineProperty(exports, "extendSchema", {
  25165. enumerable: true,
  25166. get: function get() {
  25167. return _extendSchema.extendSchema;
  25168. }
  25169. });
  25170. Object.defineProperty(exports, "lexicographicSortSchema", {
  25171. enumerable: true,
  25172. get: function get() {
  25173. return _lexicographicSortSchema.lexicographicSortSchema;
  25174. }
  25175. });
  25176. Object.defineProperty(exports, "printSchema", {
  25177. enumerable: true,
  25178. get: function get() {
  25179. return _schemaPrinter.printSchema;
  25180. }
  25181. });
  25182. Object.defineProperty(exports, "printType", {
  25183. enumerable: true,
  25184. get: function get() {
  25185. return _schemaPrinter.printType;
  25186. }
  25187. });
  25188. Object.defineProperty(exports, "printIntrospectionSchema", {
  25189. enumerable: true,
  25190. get: function get() {
  25191. return _schemaPrinter.printIntrospectionSchema;
  25192. }
  25193. });
  25194. Object.defineProperty(exports, "typeFromAST", {
  25195. enumerable: true,
  25196. get: function get() {
  25197. return _typeFromAST.typeFromAST;
  25198. }
  25199. });
  25200. Object.defineProperty(exports, "valueFromAST", {
  25201. enumerable: true,
  25202. get: function get() {
  25203. return _valueFromAST.valueFromAST;
  25204. }
  25205. });
  25206. Object.defineProperty(exports, "valueFromASTUntyped", {
  25207. enumerable: true,
  25208. get: function get() {
  25209. return _valueFromASTUntyped.valueFromASTUntyped;
  25210. }
  25211. });
  25212. Object.defineProperty(exports, "astFromValue", {
  25213. enumerable: true,
  25214. get: function get() {
  25215. return _astFromValue.astFromValue;
  25216. }
  25217. });
  25218. Object.defineProperty(exports, "TypeInfo", {
  25219. enumerable: true,
  25220. get: function get() {
  25221. return _TypeInfo.TypeInfo;
  25222. }
  25223. });
  25224. Object.defineProperty(exports, "coerceValue", {
  25225. enumerable: true,
  25226. get: function get() {
  25227. return _coerceValue.coerceValue;
  25228. }
  25229. });
  25230. Object.defineProperty(exports, "isValidJSValue", {
  25231. enumerable: true,
  25232. get: function get() {
  25233. return _isValidJSValue.isValidJSValue;
  25234. }
  25235. });
  25236. Object.defineProperty(exports, "isValidLiteralValue", {
  25237. enumerable: true,
  25238. get: function get() {
  25239. return _isValidLiteralValue.isValidLiteralValue;
  25240. }
  25241. });
  25242. Object.defineProperty(exports, "concatAST", {
  25243. enumerable: true,
  25244. get: function get() {
  25245. return _concatAST.concatAST;
  25246. }
  25247. });
  25248. Object.defineProperty(exports, "separateOperations", {
  25249. enumerable: true,
  25250. get: function get() {
  25251. return _separateOperations.separateOperations;
  25252. }
  25253. });
  25254. Object.defineProperty(exports, "stripIgnoredCharacters", {
  25255. enumerable: true,
  25256. get: function get() {
  25257. return _stripIgnoredCharacters.stripIgnoredCharacters;
  25258. }
  25259. });
  25260. Object.defineProperty(exports, "isEqualType", {
  25261. enumerable: true,
  25262. get: function get() {
  25263. return _typeComparators.isEqualType;
  25264. }
  25265. });
  25266. Object.defineProperty(exports, "isTypeSubTypeOf", {
  25267. enumerable: true,
  25268. get: function get() {
  25269. return _typeComparators.isTypeSubTypeOf;
  25270. }
  25271. });
  25272. Object.defineProperty(exports, "doTypesOverlap", {
  25273. enumerable: true,
  25274. get: function get() {
  25275. return _typeComparators.doTypesOverlap;
  25276. }
  25277. });
  25278. Object.defineProperty(exports, "assertValidName", {
  25279. enumerable: true,
  25280. get: function get() {
  25281. return _assertValidName.assertValidName;
  25282. }
  25283. });
  25284. Object.defineProperty(exports, "isValidNameError", {
  25285. enumerable: true,
  25286. get: function get() {
  25287. return _assertValidName.isValidNameError;
  25288. }
  25289. });
  25290. Object.defineProperty(exports, "BreakingChangeType", {
  25291. enumerable: true,
  25292. get: function get() {
  25293. return _findBreakingChanges.BreakingChangeType;
  25294. }
  25295. });
  25296. Object.defineProperty(exports, "DangerousChangeType", {
  25297. enumerable: true,
  25298. get: function get() {
  25299. return _findBreakingChanges.DangerousChangeType;
  25300. }
  25301. });
  25302. Object.defineProperty(exports, "findBreakingChanges", {
  25303. enumerable: true,
  25304. get: function get() {
  25305. return _findBreakingChanges.findBreakingChanges;
  25306. }
  25307. });
  25308. Object.defineProperty(exports, "findDangerousChanges", {
  25309. enumerable: true,
  25310. get: function get() {
  25311. return _findBreakingChanges.findDangerousChanges;
  25312. }
  25313. });
  25314. Object.defineProperty(exports, "findDeprecatedUsages", {
  25315. enumerable: true,
  25316. get: function get() {
  25317. return _findDeprecatedUsages.findDeprecatedUsages;
  25318. }
  25319. });
  25320. var _introspectionQuery = require("./introspectionQuery");
  25321. var _getOperationAST = require("./getOperationAST");
  25322. var _getOperationRootType = require("./getOperationRootType");
  25323. var _introspectionFromSchema = require("./introspectionFromSchema");
  25324. var _buildClientSchema = require("./buildClientSchema");
  25325. var _buildASTSchema = require("./buildASTSchema");
  25326. var _extendSchema = require("./extendSchema");
  25327. var _lexicographicSortSchema = require("./lexicographicSortSchema");
  25328. var _schemaPrinter = require("./schemaPrinter");
  25329. var _typeFromAST = require("./typeFromAST");
  25330. var _valueFromAST = require("./valueFromAST");
  25331. var _valueFromASTUntyped = require("./valueFromASTUntyped");
  25332. var _astFromValue = require("./astFromValue");
  25333. var _TypeInfo = require("./TypeInfo");
  25334. var _coerceValue = require("./coerceValue");
  25335. var _isValidJSValue = require("./isValidJSValue");
  25336. var _isValidLiteralValue = require("./isValidLiteralValue");
  25337. var _concatAST = require("./concatAST");
  25338. var _separateOperations = require("./separateOperations");
  25339. var _stripIgnoredCharacters = require("./stripIgnoredCharacters");
  25340. var _typeComparators = require("./typeComparators");
  25341. var _assertValidName = require("./assertValidName");
  25342. var _findBreakingChanges = require("./findBreakingChanges");
  25343. var _findDeprecatedUsages = require("./findDeprecatedUsages");
  25344. },{"./TypeInfo":75,"./assertValidName":76,"./astFromValue":77,"./buildASTSchema":78,"./buildClientSchema":79,"./coerceValue":80,"./concatAST":81,"./extendSchema":82,"./findBreakingChanges":83,"./findDeprecatedUsages":84,"./getOperationAST":85,"./getOperationRootType":86,"./introspectionFromSchema":88,"./introspectionQuery":89,"./isValidJSValue":90,"./isValidLiteralValue":91,"./lexicographicSortSchema":92,"./schemaPrinter":93,"./separateOperations":94,"./stripIgnoredCharacters":95,"./typeComparators":96,"./typeFromAST":97,"./valueFromAST":98,"./valueFromASTUntyped":99}],88:[function(require,module,exports){
  25345. "use strict";
  25346. Object.defineProperty(exports, "__esModule", {
  25347. value: true
  25348. });
  25349. exports.introspectionFromSchema = introspectionFromSchema;
  25350. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  25351. var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
  25352. var _execute = require("../execution/execute");
  25353. var _parser = require("../language/parser");
  25354. var _introspectionQuery = require("./introspectionQuery");
  25355. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25356. /**
  25357. * Copyright (c) Facebook, Inc. and its affiliates.
  25358. *
  25359. * This source code is licensed under the MIT license found in the
  25360. * LICENSE file in the root directory of this source tree.
  25361. *
  25362. *
  25363. */
  25364. /**
  25365. * Build an IntrospectionQuery from a GraphQLSchema
  25366. *
  25367. * IntrospectionQuery is useful for utilities that care about type and field
  25368. * relationships, but do not need to traverse through those relationships.
  25369. *
  25370. * This is the inverse of buildClientSchema. The primary use case is outside
  25371. * of the server context, for instance when doing schema comparisons.
  25372. */
  25373. function introspectionFromSchema(schema, options) {
  25374. var queryAST = (0, _parser.parse)((0, _introspectionQuery.getIntrospectionQuery)(options));
  25375. var result = (0, _execute.execute)(schema, queryAST);
  25376. !(!(0, _isPromise.default)(result) && !result.errors && result.data) ? (0, _invariant.default)(0) : void 0;
  25377. return result.data;
  25378. }
  25379. },{"../execution/execute":25,"../jsutils/invariant":34,"../jsutils/isPromise":37,"../language/parser":54,"./introspectionQuery":89}],89:[function(require,module,exports){
  25380. "use strict";
  25381. Object.defineProperty(exports, "__esModule", {
  25382. value: true
  25383. });
  25384. exports.getIntrospectionQuery = getIntrospectionQuery;
  25385. exports.introspectionQuery = void 0;
  25386. /**
  25387. * Copyright (c) Facebook, Inc. and its affiliates.
  25388. *
  25389. * This source code is licensed under the MIT license found in the
  25390. * LICENSE file in the root directory of this source tree.
  25391. *
  25392. *
  25393. */
  25394. function getIntrospectionQuery(options) {
  25395. var descriptions = !(options && options.descriptions === false);
  25396. return "\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n ".concat(descriptions ? 'description' : '', "\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ").concat(descriptions ? 'description' : '', "\n fields(includeDeprecated: true) {\n name\n ").concat(descriptions ? 'description' : '', "\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ").concat(descriptions ? 'description' : '', "\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ").concat(descriptions ? 'description' : '', "\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n ");
  25397. }
  25398. /**
  25399. * Deprecated, call getIntrospectionQuery directly.
  25400. *
  25401. * This function will be removed in v15
  25402. */
  25403. var introspectionQuery = getIntrospectionQuery();
  25404. exports.introspectionQuery = introspectionQuery;
  25405. },{}],90:[function(require,module,exports){
  25406. "use strict";
  25407. Object.defineProperty(exports, "__esModule", {
  25408. value: true
  25409. });
  25410. exports.isValidJSValue = isValidJSValue;
  25411. var _coerceValue = require("./coerceValue");
  25412. /**
  25413. * Copyright (c) Facebook, Inc. and its affiliates.
  25414. *
  25415. * This source code is licensed under the MIT license found in the
  25416. * LICENSE file in the root directory of this source tree.
  25417. *
  25418. *
  25419. */
  25420. /* istanbul ignore file */
  25421. /**
  25422. * Deprecated. Use coerceValue() directly for richer information.
  25423. *
  25424. * This function will be removed in v15
  25425. */
  25426. function isValidJSValue(value, type) {
  25427. var errors = (0, _coerceValue.coerceValue)(value, type).errors;
  25428. return errors ? errors.map(function (error) {
  25429. return error.message;
  25430. }) : [];
  25431. }
  25432. },{"./coerceValue":80}],91:[function(require,module,exports){
  25433. "use strict";
  25434. Object.defineProperty(exports, "__esModule", {
  25435. value: true
  25436. });
  25437. exports.isValidLiteralValue = isValidLiteralValue;
  25438. var _TypeInfo = require("./TypeInfo");
  25439. var _kinds = require("../language/kinds");
  25440. var _visitor = require("../language/visitor");
  25441. var _schema = require("../type/schema");
  25442. var _ValuesOfCorrectType = require("../validation/rules/ValuesOfCorrectType");
  25443. var _ValidationContext = require("../validation/ValidationContext");
  25444. /**
  25445. * Copyright (c) Facebook, Inc. and its affiliates.
  25446. *
  25447. * This source code is licensed under the MIT license found in the
  25448. * LICENSE file in the root directory of this source tree.
  25449. *
  25450. *
  25451. */
  25452. /**
  25453. * Utility which determines if a value literal node is valid for an input type.
  25454. *
  25455. * Deprecated. Rely on validation for documents containing literal values.
  25456. *
  25457. * This function will be removed in v15
  25458. */
  25459. function isValidLiteralValue(type, valueNode) {
  25460. var emptySchema = new _schema.GraphQLSchema({});
  25461. var emptyDoc = {
  25462. kind: _kinds.Kind.DOCUMENT,
  25463. definitions: []
  25464. };
  25465. var typeInfo = new _TypeInfo.TypeInfo(emptySchema, undefined, type);
  25466. var context = new _ValidationContext.ValidationContext(emptySchema, emptyDoc, typeInfo);
  25467. var visitor = (0, _ValuesOfCorrectType.ValuesOfCorrectType)(context);
  25468. (0, _visitor.visit)(valueNode, (0, _visitor.visitWithTypeInfo)(typeInfo, visitor));
  25469. return context.getErrors();
  25470. }
  25471. },{"../language/kinds":51,"../language/visitor":58,"../type/schema":73,"../validation/ValidationContext":100,"../validation/rules/ValuesOfCorrectType":132,"./TypeInfo":75}],92:[function(require,module,exports){
  25472. "use strict";
  25473. Object.defineProperty(exports, "__esModule", {
  25474. value: true
  25475. });
  25476. exports.lexicographicSortSchema = lexicographicSortSchema;
  25477. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  25478. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  25479. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  25480. var _schema = require("../type/schema");
  25481. var _directives = require("../type/directives");
  25482. var _definition = require("../type/definition");
  25483. var _introspection = require("../type/introspection");
  25484. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25485. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  25486. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  25487. /**
  25488. * Sort GraphQLSchema.
  25489. */
  25490. function lexicographicSortSchema(schema) {
  25491. var schemaConfig = schema.toConfig();
  25492. var typeMap = (0, _keyValMap.default)(sortByName(schemaConfig.types), function (type) {
  25493. return type.name;
  25494. }, sortNamedType);
  25495. return new _schema.GraphQLSchema(_objectSpread({}, schemaConfig, {
  25496. types: (0, _objectValues.default)(typeMap),
  25497. directives: sortByName(schemaConfig.directives).map(sortDirective),
  25498. query: replaceMaybeType(schemaConfig.query),
  25499. mutation: replaceMaybeType(schemaConfig.mutation),
  25500. subscription: replaceMaybeType(schemaConfig.subscription)
  25501. }));
  25502. function replaceType(type) {
  25503. if ((0, _definition.isListType)(type)) {
  25504. return new _definition.GraphQLList(replaceType(type.ofType));
  25505. } else if ((0, _definition.isNonNullType)(type)) {
  25506. return new _definition.GraphQLNonNull(replaceType(type.ofType));
  25507. }
  25508. return replaceNamedType(type);
  25509. }
  25510. function replaceNamedType(type) {
  25511. return typeMap[type.name];
  25512. }
  25513. function replaceMaybeType(maybeType) {
  25514. return maybeType && replaceNamedType(maybeType);
  25515. }
  25516. function sortDirective(directive) {
  25517. var config = directive.toConfig();
  25518. return new _directives.GraphQLDirective(_objectSpread({}, config, {
  25519. locations: sortBy(config.locations, function (x) {
  25520. return x;
  25521. }),
  25522. args: sortArgs(config.args)
  25523. }));
  25524. }
  25525. function sortArgs(args) {
  25526. return sortObjMap(args, function (arg) {
  25527. return _objectSpread({}, arg, {
  25528. type: replaceType(arg.type)
  25529. });
  25530. });
  25531. }
  25532. function sortFields(fieldsMap) {
  25533. return sortObjMap(fieldsMap, function (field) {
  25534. return _objectSpread({}, field, {
  25535. type: replaceType(field.type),
  25536. args: sortArgs(field.args)
  25537. });
  25538. });
  25539. }
  25540. function sortInputFields(fieldsMap) {
  25541. return sortObjMap(fieldsMap, function (field) {
  25542. return _objectSpread({}, field, {
  25543. type: replaceType(field.type)
  25544. });
  25545. });
  25546. }
  25547. function sortTypes(arr) {
  25548. return sortByName(arr).map(replaceNamedType);
  25549. }
  25550. function sortNamedType(type) {
  25551. if ((0, _definition.isScalarType)(type) || (0, _introspection.isIntrospectionType)(type)) {
  25552. return type;
  25553. } else if ((0, _definition.isObjectType)(type)) {
  25554. var config = type.toConfig();
  25555. return new _definition.GraphQLObjectType(_objectSpread({}, config, {
  25556. interfaces: function interfaces() {
  25557. return sortTypes(config.interfaces);
  25558. },
  25559. fields: function fields() {
  25560. return sortFields(config.fields);
  25561. }
  25562. }));
  25563. } else if ((0, _definition.isInterfaceType)(type)) {
  25564. var _config = type.toConfig();
  25565. return new _definition.GraphQLInterfaceType(_objectSpread({}, _config, {
  25566. fields: function fields() {
  25567. return sortFields(_config.fields);
  25568. }
  25569. }));
  25570. } else if ((0, _definition.isUnionType)(type)) {
  25571. var _config2 = type.toConfig();
  25572. return new _definition.GraphQLUnionType(_objectSpread({}, _config2, {
  25573. types: function types() {
  25574. return sortTypes(_config2.types);
  25575. }
  25576. }));
  25577. } else if ((0, _definition.isEnumType)(type)) {
  25578. var _config3 = type.toConfig();
  25579. return new _definition.GraphQLEnumType(_objectSpread({}, _config3, {
  25580. values: sortObjMap(_config3.values)
  25581. }));
  25582. } else if ((0, _definition.isInputObjectType)(type)) {
  25583. var _config4 = type.toConfig();
  25584. return new _definition.GraphQLInputObjectType(_objectSpread({}, _config4, {
  25585. fields: function fields() {
  25586. return sortInputFields(_config4.fields);
  25587. }
  25588. }));
  25589. } // Not reachable. All possible types have been considered.
  25590. /* istanbul ignore next */
  25591. throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
  25592. }
  25593. }
  25594. function sortObjMap(map, sortValueFn) {
  25595. var sortedMap = Object.create(null);
  25596. var sortedKeys = sortBy(Object.keys(map), function (x) {
  25597. return x;
  25598. });
  25599. for (var _i = 0, _sortedKeys = sortedKeys; _i < _sortedKeys.length; _i++) {
  25600. var key = _sortedKeys[_i];
  25601. var value = map[key];
  25602. sortedMap[key] = sortValueFn ? sortValueFn(value) : value;
  25603. }
  25604. return sortedMap;
  25605. }
  25606. function sortByName(array) {
  25607. return sortBy(array, function (obj) {
  25608. return obj.name;
  25609. });
  25610. }
  25611. function sortBy(array, mapToKey) {
  25612. return array.slice().sort(function (obj1, obj2) {
  25613. var key1 = mapToKey(obj1);
  25614. var key2 = mapToKey(obj2);
  25615. return key1.localeCompare(key2);
  25616. });
  25617. }
  25618. },{"../jsutils/inspect":32,"../jsutils/keyValMap":39,"../polyfills/objectValues":64,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/schema":73}],93:[function(require,module,exports){
  25619. "use strict";
  25620. Object.defineProperty(exports, "__esModule", {
  25621. value: true
  25622. });
  25623. exports.printSchema = printSchema;
  25624. exports.printIntrospectionSchema = printIntrospectionSchema;
  25625. exports.printType = printType;
  25626. var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
  25627. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  25628. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  25629. var _astFromValue = require("../utilities/astFromValue");
  25630. var _printer = require("../language/printer");
  25631. var _blockString = require("../language/blockString");
  25632. var _definition = require("../type/definition");
  25633. var _scalars = require("../type/scalars");
  25634. var _directives = require("../type/directives");
  25635. var _introspection = require("../type/introspection");
  25636. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25637. /**
  25638. * Copyright (c) Facebook, Inc. and its affiliates.
  25639. *
  25640. * This source code is licensed under the MIT license found in the
  25641. * LICENSE file in the root directory of this source tree.
  25642. *
  25643. *
  25644. */
  25645. /**
  25646. * Accepts options as a second argument:
  25647. *
  25648. * - commentDescriptions:
  25649. * Provide true to use preceding comments as the description.
  25650. *
  25651. */
  25652. function printSchema(schema, options) {
  25653. return printFilteredSchema(schema, function (n) {
  25654. return !(0, _directives.isSpecifiedDirective)(n);
  25655. }, isDefinedType, options);
  25656. }
  25657. function printIntrospectionSchema(schema, options) {
  25658. return printFilteredSchema(schema, _directives.isSpecifiedDirective, _introspection.isIntrospectionType, options);
  25659. }
  25660. function isDefinedType(type) {
  25661. return !(0, _scalars.isSpecifiedScalarType)(type) && !(0, _introspection.isIntrospectionType)(type);
  25662. }
  25663. function printFilteredSchema(schema, directiveFilter, typeFilter, options) {
  25664. var directives = schema.getDirectives().filter(directiveFilter);
  25665. var typeMap = schema.getTypeMap();
  25666. var types = (0, _objectValues.default)(typeMap).sort(function (type1, type2) {
  25667. return type1.name.localeCompare(type2.name);
  25668. }).filter(typeFilter);
  25669. return [printSchemaDefinition(schema)].concat(directives.map(function (directive) {
  25670. return printDirective(directive, options);
  25671. }), types.map(function (type) {
  25672. return printType(type, options);
  25673. })).filter(Boolean).join('\n\n') + '\n';
  25674. }
  25675. function printSchemaDefinition(schema) {
  25676. if (isSchemaOfCommonNames(schema)) {
  25677. return;
  25678. }
  25679. var operationTypes = [];
  25680. var queryType = schema.getQueryType();
  25681. if (queryType) {
  25682. operationTypes.push(" query: ".concat(queryType.name));
  25683. }
  25684. var mutationType = schema.getMutationType();
  25685. if (mutationType) {
  25686. operationTypes.push(" mutation: ".concat(mutationType.name));
  25687. }
  25688. var subscriptionType = schema.getSubscriptionType();
  25689. if (subscriptionType) {
  25690. operationTypes.push(" subscription: ".concat(subscriptionType.name));
  25691. }
  25692. return "schema {\n".concat(operationTypes.join('\n'), "\n}");
  25693. }
  25694. /**
  25695. * GraphQL schema define root types for each type of operation. These types are
  25696. * the same as any other type and can be named in any manner, however there is
  25697. * a common naming convention:
  25698. *
  25699. * schema {
  25700. * query: Query
  25701. * mutation: Mutation
  25702. * }
  25703. *
  25704. * When using this naming convention, the schema description can be omitted.
  25705. */
  25706. function isSchemaOfCommonNames(schema) {
  25707. var queryType = schema.getQueryType();
  25708. if (queryType && queryType.name !== 'Query') {
  25709. return false;
  25710. }
  25711. var mutationType = schema.getMutationType();
  25712. if (mutationType && mutationType.name !== 'Mutation') {
  25713. return false;
  25714. }
  25715. var subscriptionType = schema.getSubscriptionType();
  25716. if (subscriptionType && subscriptionType.name !== 'Subscription') {
  25717. return false;
  25718. }
  25719. return true;
  25720. }
  25721. function printType(type, options) {
  25722. if ((0, _definition.isScalarType)(type)) {
  25723. return printScalar(type, options);
  25724. } else if ((0, _definition.isObjectType)(type)) {
  25725. return printObject(type, options);
  25726. } else if ((0, _definition.isInterfaceType)(type)) {
  25727. return printInterface(type, options);
  25728. } else if ((0, _definition.isUnionType)(type)) {
  25729. return printUnion(type, options);
  25730. } else if ((0, _definition.isEnumType)(type)) {
  25731. return printEnum(type, options);
  25732. } else if ((0, _definition.isInputObjectType)(type)) {
  25733. return printInputObject(type, options);
  25734. } // Not reachable. All possible types have been considered.
  25735. /* istanbul ignore next */
  25736. throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
  25737. }
  25738. function printScalar(type, options) {
  25739. return printDescription(options, type) + "scalar ".concat(type.name);
  25740. }
  25741. function printObject(type, options) {
  25742. var interfaces = type.getInterfaces();
  25743. var implementedInterfaces = interfaces.length ? ' implements ' + interfaces.map(function (i) {
  25744. return i.name;
  25745. }).join(' & ') : '';
  25746. return printDescription(options, type) + "type ".concat(type.name).concat(implementedInterfaces) + printFields(options, type);
  25747. }
  25748. function printInterface(type, options) {
  25749. return printDescription(options, type) + "interface ".concat(type.name) + printFields(options, type);
  25750. }
  25751. function printUnion(type, options) {
  25752. var types = type.getTypes();
  25753. var possibleTypes = types.length ? ' = ' + types.join(' | ') : '';
  25754. return printDescription(options, type) + 'union ' + type.name + possibleTypes;
  25755. }
  25756. function printEnum(type, options) {
  25757. var values = type.getValues().map(function (value, i) {
  25758. return printDescription(options, value, ' ', !i) + ' ' + value.name + printDeprecated(value);
  25759. });
  25760. return printDescription(options, type) + "enum ".concat(type.name) + printBlock(values);
  25761. }
  25762. function printInputObject(type, options) {
  25763. var fields = (0, _objectValues.default)(type.getFields()).map(function (f, i) {
  25764. return printDescription(options, f, ' ', !i) + ' ' + printInputValue(f);
  25765. });
  25766. return printDescription(options, type) + "input ".concat(type.name) + printBlock(fields);
  25767. }
  25768. function printFields(options, type) {
  25769. var fields = (0, _objectValues.default)(type.getFields()).map(function (f, i) {
  25770. return printDescription(options, f, ' ', !i) + ' ' + f.name + printArgs(options, f.args, ' ') + ': ' + String(f.type) + printDeprecated(f);
  25771. });
  25772. return printBlock(fields);
  25773. }
  25774. function printBlock(items) {
  25775. return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : '';
  25776. }
  25777. function printArgs(options, args) {
  25778. var indentation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  25779. if (args.length === 0) {
  25780. return '';
  25781. } // If every arg does not have a description, print them on one line.
  25782. if (args.every(function (arg) {
  25783. return !arg.description;
  25784. })) {
  25785. return '(' + args.map(printInputValue).join(', ') + ')';
  25786. }
  25787. return '(\n' + args.map(function (arg, i) {
  25788. return printDescription(options, arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg);
  25789. }).join('\n') + '\n' + indentation + ')';
  25790. }
  25791. function printInputValue(arg) {
  25792. var defaultAST = (0, _astFromValue.astFromValue)(arg.defaultValue, arg.type);
  25793. var argDecl = arg.name + ': ' + String(arg.type);
  25794. if (defaultAST) {
  25795. argDecl += " = ".concat((0, _printer.print)(defaultAST));
  25796. }
  25797. return argDecl;
  25798. }
  25799. function printDirective(directive, options) {
  25800. return printDescription(options, directive) + 'directive @' + directive.name + printArgs(options, directive.args) + ' on ' + directive.locations.join(' | ');
  25801. }
  25802. function printDeprecated(fieldOrEnumVal) {
  25803. if (!fieldOrEnumVal.isDeprecated) {
  25804. return '';
  25805. }
  25806. var reason = fieldOrEnumVal.deprecationReason;
  25807. var reasonAST = (0, _astFromValue.astFromValue)(reason, _scalars.GraphQLString);
  25808. if (reasonAST && reason !== '' && reason !== _directives.DEFAULT_DEPRECATION_REASON) {
  25809. return ' @deprecated(reason: ' + (0, _printer.print)(reasonAST) + ')';
  25810. }
  25811. return ' @deprecated';
  25812. }
  25813. function printDescription(options, def) {
  25814. var indentation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  25815. var firstInBlock = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  25816. if (!def.description) {
  25817. return '';
  25818. }
  25819. var lines = descriptionLines(def.description, 120 - indentation.length);
  25820. if (options && options.commentDescriptions) {
  25821. return printDescriptionWithComments(lines, indentation, firstInBlock);
  25822. }
  25823. var text = lines.join('\n');
  25824. var preferMultipleLines = text.length > 70;
  25825. var blockString = (0, _blockString.printBlockString)(text, '', preferMultipleLines);
  25826. var prefix = indentation && !firstInBlock ? '\n' + indentation : indentation;
  25827. return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n';
  25828. }
  25829. function printDescriptionWithComments(lines, indentation, firstInBlock) {
  25830. var description = indentation && !firstInBlock ? '\n' : '';
  25831. for (var i = 0; i < lines.length; i++) {
  25832. if (lines[i] === '') {
  25833. description += indentation + '#\n';
  25834. } else {
  25835. description += indentation + '# ' + lines[i] + '\n';
  25836. }
  25837. }
  25838. return description;
  25839. }
  25840. function descriptionLines(description, maxLen) {
  25841. var rawLines = description.split('\n');
  25842. return (0, _flatMap.default)(rawLines, function (line) {
  25843. if (line.length < maxLen + 5) {
  25844. return line;
  25845. } // For > 120 character long lines, cut at space boundaries into sublines
  25846. // of ~80 chars.
  25847. return breakLine(line, maxLen);
  25848. });
  25849. }
  25850. function breakLine(line, maxLen) {
  25851. var parts = line.split(new RegExp("((?: |^).{15,".concat(maxLen - 40, "}(?= |$))")));
  25852. if (parts.length < 4) {
  25853. return [line];
  25854. }
  25855. var sublines = [parts[0] + parts[1] + parts[2]];
  25856. for (var i = 3; i < parts.length; i += 2) {
  25857. sublines.push(parts[i].slice(1) + parts[i + 1]);
  25858. }
  25859. return sublines;
  25860. }
  25861. },{"../jsutils/inspect":32,"../language/blockString":48,"../language/printer":56,"../polyfills/flatMap":60,"../polyfills/objectValues":64,"../type/definition":68,"../type/directives":69,"../type/introspection":71,"../type/scalars":72,"../utilities/astFromValue":77}],94:[function(require,module,exports){
  25862. "use strict";
  25863. Object.defineProperty(exports, "__esModule", {
  25864. value: true
  25865. });
  25866. exports.separateOperations = separateOperations;
  25867. var _visitor = require("../language/visitor");
  25868. /**
  25869. * Copyright (c) Facebook, Inc. and its affiliates.
  25870. *
  25871. * This source code is licensed under the MIT license found in the
  25872. * LICENSE file in the root directory of this source tree.
  25873. *
  25874. *
  25875. */
  25876. /**
  25877. * separateOperations accepts a single AST document which may contain many
  25878. * operations and fragments and returns a collection of AST documents each of
  25879. * which contains a single operation as well the fragment definitions it
  25880. * refers to.
  25881. */
  25882. function separateOperations(documentAST) {
  25883. var operations = [];
  25884. var fragments = Object.create(null);
  25885. var positions = new Map();
  25886. var depGraph = Object.create(null);
  25887. var fromName;
  25888. var idx = 0; // Populate metadata and build a dependency graph.
  25889. (0, _visitor.visit)(documentAST, {
  25890. OperationDefinition: function OperationDefinition(node) {
  25891. fromName = opName(node);
  25892. operations.push(node);
  25893. positions.set(node, idx++);
  25894. },
  25895. FragmentDefinition: function FragmentDefinition(node) {
  25896. fromName = node.name.value;
  25897. fragments[fromName] = node;
  25898. positions.set(node, idx++);
  25899. },
  25900. FragmentSpread: function FragmentSpread(node) {
  25901. var toName = node.name.value;
  25902. (depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true;
  25903. }
  25904. }); // For each operation, produce a new synthesized AST which includes only what
  25905. // is necessary for completing that operation.
  25906. var separatedDocumentASTs = Object.create(null);
  25907. for (var _i = 0, _operations = operations; _i < _operations.length; _i++) {
  25908. var operation = _operations[_i];
  25909. var operationName = opName(operation);
  25910. var dependencies = Object.create(null);
  25911. collectTransitiveDependencies(dependencies, depGraph, operationName); // The list of definition nodes to be included for this operation, sorted
  25912. // to retain the same order as the original document.
  25913. var definitions = [operation];
  25914. for (var _i2 = 0, _Object$keys = Object.keys(dependencies); _i2 < _Object$keys.length; _i2++) {
  25915. var name = _Object$keys[_i2];
  25916. definitions.push(fragments[name]);
  25917. }
  25918. definitions.sort(function (n1, n2) {
  25919. return (positions.get(n1) || 0) - (positions.get(n2) || 0);
  25920. });
  25921. separatedDocumentASTs[operationName] = {
  25922. kind: 'Document',
  25923. definitions: definitions
  25924. };
  25925. }
  25926. return separatedDocumentASTs;
  25927. }
  25928. // Provides the empty string for anonymous operations.
  25929. function opName(operation) {
  25930. return operation.name ? operation.name.value : '';
  25931. } // From a dependency graph, collects a list of transitive dependencies by
  25932. // recursing through a dependency graph.
  25933. function collectTransitiveDependencies(collected, depGraph, fromName) {
  25934. var immediateDeps = depGraph[fromName];
  25935. if (immediateDeps) {
  25936. for (var _i3 = 0, _Object$keys2 = Object.keys(immediateDeps); _i3 < _Object$keys2.length; _i3++) {
  25937. var toName = _Object$keys2[_i3];
  25938. if (!collected[toName]) {
  25939. collected[toName] = true;
  25940. collectTransitiveDependencies(collected, depGraph, toName);
  25941. }
  25942. }
  25943. }
  25944. }
  25945. },{"../language/visitor":58}],95:[function(require,module,exports){
  25946. "use strict";
  25947. Object.defineProperty(exports, "__esModule", {
  25948. value: true
  25949. });
  25950. exports.stripIgnoredCharacters = stripIgnoredCharacters;
  25951. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  25952. var _source = require("../language/source");
  25953. var _lexer = require("../language/lexer");
  25954. var _blockString = require("../language/blockString");
  25955. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25956. /**
  25957. * Copyright (c) Facebook, Inc. and its affiliates.
  25958. *
  25959. * This source code is licensed under the MIT license found in the
  25960. * LICENSE file in the root directory of this source tree.
  25961. *
  25962. *
  25963. */
  25964. /**
  25965. * Strips characters that are not significant to the validity or execution
  25966. * of a GraphQL document:
  25967. * - UnicodeBOM
  25968. * - WhiteSpace
  25969. * - LineTerminator
  25970. * - Comment
  25971. * - Comma
  25972. * - BlockString indentation
  25973. *
  25974. * Note: It is required to have a delimiter character between neighboring
  25975. * non-punctuator tokens and this function always uses single space as delimiter.
  25976. *
  25977. * It is guaranteed that both input and output documents if parsed would result
  25978. * in the exact same AST except for nodes location.
  25979. *
  25980. * Warning: It is guaranteed that this function will always produce stable results.
  25981. * However, it's not guaranteed that it will stay the same between different
  25982. * releases due to bugfixes or changes in the GraphQL specification.
  25983. *
  25984. * Query example:
  25985. *
  25986. * query SomeQuery($foo: String!, $bar: String) {
  25987. * someField(foo: $foo, bar: $bar) {
  25988. * a
  25989. * b {
  25990. * c
  25991. * d
  25992. * }
  25993. * }
  25994. * }
  25995. *
  25996. * Becomes:
  25997. *
  25998. * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
  25999. *
  26000. * SDL example:
  26001. *
  26002. * """
  26003. * Type description
  26004. * """
  26005. * type Foo {
  26006. * """
  26007. * Field description
  26008. * """
  26009. * bar: String
  26010. * }
  26011. *
  26012. * Becomes:
  26013. *
  26014. * """Type description""" type Foo{"""Field description""" bar:String}
  26015. */
  26016. function stripIgnoredCharacters(source) {
  26017. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  26018. if (!(sourceObj instanceof _source.Source)) {
  26019. throw new TypeError("Must provide string or Source. Received: ".concat((0, _inspect.default)(sourceObj)));
  26020. }
  26021. var body = sourceObj.body;
  26022. var lexer = (0, _lexer.createLexer)(sourceObj);
  26023. var strippedBody = '';
  26024. var wasLastAddedTokenNonPunctuator = false;
  26025. while (lexer.advance().kind !== _lexer.TokenKind.EOF) {
  26026. var currentToken = lexer.token;
  26027. var tokenKind = currentToken.kind;
  26028. /**
  26029. * Every two non-punctuator tokens should have space between them.
  26030. * Also prevent case of non-punctuator token following by spread resulting
  26031. * in invalid token (e.g. `1...` is invalid Float token).
  26032. */
  26033. var isNonPunctuator = !(0, _lexer.isPunctuatorToken)(currentToken);
  26034. if (wasLastAddedTokenNonPunctuator) {
  26035. if (isNonPunctuator || currentToken.kind === _lexer.TokenKind.SPREAD) {
  26036. strippedBody += ' ';
  26037. }
  26038. }
  26039. var tokenBody = body.slice(currentToken.start, currentToken.end);
  26040. if (tokenKind === _lexer.TokenKind.BLOCK_STRING) {
  26041. strippedBody += dedentBlockString(tokenBody);
  26042. } else {
  26043. strippedBody += tokenBody;
  26044. }
  26045. wasLastAddedTokenNonPunctuator = isNonPunctuator;
  26046. }
  26047. return strippedBody;
  26048. }
  26049. function dedentBlockString(blockStr) {
  26050. // skip leading and trailing triple quotations
  26051. var rawStr = blockStr.slice(3, -3);
  26052. var body = (0, _blockString.dedentBlockStringValue)(rawStr);
  26053. var lines = body.split(/\r\n|[\n\r]/g);
  26054. if ((0, _blockString.getBlockStringIndentation)(lines) > 0) {
  26055. body = '\n' + body;
  26056. }
  26057. var lastChar = body[body.length - 1];
  26058. var hasTrailingQuote = lastChar === '"' && body.slice(-4) !== '\\"""';
  26059. if (hasTrailingQuote || lastChar === '\\') {
  26060. body += '\n';
  26061. }
  26062. return '"""' + body + '"""';
  26063. }
  26064. },{"../jsutils/inspect":32,"../language/blockString":48,"../language/lexer":52,"../language/source":57}],96:[function(require,module,exports){
  26065. "use strict";
  26066. Object.defineProperty(exports, "__esModule", {
  26067. value: true
  26068. });
  26069. exports.isEqualType = isEqualType;
  26070. exports.isTypeSubTypeOf = isTypeSubTypeOf;
  26071. exports.doTypesOverlap = doTypesOverlap;
  26072. var _definition = require("../type/definition");
  26073. /**
  26074. * Copyright (c) Facebook, Inc. and its affiliates.
  26075. *
  26076. * This source code is licensed under the MIT license found in the
  26077. * LICENSE file in the root directory of this source tree.
  26078. *
  26079. *
  26080. */
  26081. /**
  26082. * Provided two types, return true if the types are equal (invariant).
  26083. */
  26084. function isEqualType(typeA, typeB) {
  26085. // Equivalent types are equal.
  26086. if (typeA === typeB) {
  26087. return true;
  26088. } // If either type is non-null, the other must also be non-null.
  26089. if ((0, _definition.isNonNullType)(typeA) && (0, _definition.isNonNullType)(typeB)) {
  26090. return isEqualType(typeA.ofType, typeB.ofType);
  26091. } // If either type is a list, the other must also be a list.
  26092. if ((0, _definition.isListType)(typeA) && (0, _definition.isListType)(typeB)) {
  26093. return isEqualType(typeA.ofType, typeB.ofType);
  26094. } // Otherwise the types are not equal.
  26095. return false;
  26096. }
  26097. /**
  26098. * Provided a type and a super type, return true if the first type is either
  26099. * equal or a subset of the second super type (covariant).
  26100. */
  26101. function isTypeSubTypeOf(schema, maybeSubType, superType) {
  26102. // Equivalent type is a valid subtype
  26103. if (maybeSubType === superType) {
  26104. return true;
  26105. } // If superType is non-null, maybeSubType must also be non-null.
  26106. if ((0, _definition.isNonNullType)(superType)) {
  26107. if ((0, _definition.isNonNullType)(maybeSubType)) {
  26108. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  26109. }
  26110. return false;
  26111. }
  26112. if ((0, _definition.isNonNullType)(maybeSubType)) {
  26113. // If superType is nullable, maybeSubType may be non-null or nullable.
  26114. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
  26115. } // If superType type is a list, maybeSubType type must also be a list.
  26116. if ((0, _definition.isListType)(superType)) {
  26117. if ((0, _definition.isListType)(maybeSubType)) {
  26118. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  26119. }
  26120. return false;
  26121. }
  26122. if ((0, _definition.isListType)(maybeSubType)) {
  26123. // If superType is not a list, maybeSubType must also be not a list.
  26124. return false;
  26125. } // If superType type is an abstract type, maybeSubType type may be a currently
  26126. // possible object type.
  26127. if ((0, _definition.isAbstractType)(superType) && (0, _definition.isObjectType)(maybeSubType) && schema.isPossibleType(superType, maybeSubType)) {
  26128. return true;
  26129. } // Otherwise, the child type is not a valid subtype of the parent type.
  26130. return false;
  26131. }
  26132. /**
  26133. * Provided two composite types, determine if they "overlap". Two composite
  26134. * types overlap when the Sets of possible concrete types for each intersect.
  26135. *
  26136. * This is often used to determine if a fragment of a given type could possibly
  26137. * be visited in a context of another type.
  26138. *
  26139. * This function is commutative.
  26140. */
  26141. function doTypesOverlap(schema, typeA, typeB) {
  26142. // Equivalent types overlap
  26143. if (typeA === typeB) {
  26144. return true;
  26145. }
  26146. if ((0, _definition.isAbstractType)(typeA)) {
  26147. if ((0, _definition.isAbstractType)(typeB)) {
  26148. // If both types are abstract, then determine if there is any intersection
  26149. // between possible concrete types of each.
  26150. return schema.getPossibleTypes(typeA).some(function (type) {
  26151. return schema.isPossibleType(typeB, type);
  26152. });
  26153. } // Determine if the latter type is a possible concrete type of the former.
  26154. return schema.isPossibleType(typeA, typeB);
  26155. }
  26156. if ((0, _definition.isAbstractType)(typeB)) {
  26157. // Determine if the former type is a possible concrete type of the latter.
  26158. return schema.isPossibleType(typeB, typeA);
  26159. } // Otherwise the types do not overlap.
  26160. return false;
  26161. }
  26162. },{"../type/definition":68}],97:[function(require,module,exports){
  26163. "use strict";
  26164. Object.defineProperty(exports, "__esModule", {
  26165. value: true
  26166. });
  26167. exports.typeFromAST = typeFromAST;
  26168. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  26169. var _kinds = require("../language/kinds");
  26170. var _definition = require("../type/definition");
  26171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26172. /**
  26173. * Copyright (c) Facebook, Inc. and its affiliates.
  26174. *
  26175. * This source code is licensed under the MIT license found in the
  26176. * LICENSE file in the root directory of this source tree.
  26177. *
  26178. *
  26179. */
  26180. function typeFromAST(schema, typeNode) {
  26181. /* eslint-enable no-redeclare */
  26182. var innerType;
  26183. if (typeNode.kind === _kinds.Kind.LIST_TYPE) {
  26184. innerType = typeFromAST(schema, typeNode.type);
  26185. return innerType && (0, _definition.GraphQLList)(innerType);
  26186. }
  26187. if (typeNode.kind === _kinds.Kind.NON_NULL_TYPE) {
  26188. innerType = typeFromAST(schema, typeNode.type);
  26189. return innerType && (0, _definition.GraphQLNonNull)(innerType);
  26190. }
  26191. if (typeNode.kind === _kinds.Kind.NAMED_TYPE) {
  26192. return schema.getType(typeNode.name.value);
  26193. } // Not reachable. All possible type nodes have been considered.
  26194. /* istanbul ignore next */
  26195. throw new Error("Unexpected type node: \"".concat((0, _inspect.default)(typeNode), "\"."));
  26196. }
  26197. },{"../jsutils/inspect":32,"../language/kinds":51,"../type/definition":68}],98:[function(require,module,exports){
  26198. "use strict";
  26199. Object.defineProperty(exports, "__esModule", {
  26200. value: true
  26201. });
  26202. exports.valueFromAST = valueFromAST;
  26203. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  26204. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  26205. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  26206. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  26207. var _kinds = require("../language/kinds");
  26208. var _definition = require("../type/definition");
  26209. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26210. /**
  26211. * Copyright (c) Facebook, Inc. and its affiliates.
  26212. *
  26213. * This source code is licensed under the MIT license found in the
  26214. * LICENSE file in the root directory of this source tree.
  26215. *
  26216. *
  26217. */
  26218. /**
  26219. * Produces a JavaScript value given a GraphQL Value AST.
  26220. *
  26221. * A GraphQL type must be provided, which will be used to interpret different
  26222. * GraphQL Value literals.
  26223. *
  26224. * Returns `undefined` when the value could not be validly coerced according to
  26225. * the provided type.
  26226. *
  26227. * | GraphQL Value | JSON Value |
  26228. * | -------------------- | ------------- |
  26229. * | Input Object | Object |
  26230. * | List | Array |
  26231. * | Boolean | Boolean |
  26232. * | String | String |
  26233. * | Int / Float | Number |
  26234. * | Enum Value | Mixed |
  26235. * | NullValue | null |
  26236. *
  26237. */
  26238. function valueFromAST(valueNode, type, variables) {
  26239. if (!valueNode) {
  26240. // When there is no node, then there is also no value.
  26241. // Importantly, this is different from returning the value null.
  26242. return;
  26243. }
  26244. if ((0, _definition.isNonNullType)(type)) {
  26245. if (valueNode.kind === _kinds.Kind.NULL) {
  26246. return; // Invalid: intentionally return no value.
  26247. }
  26248. return valueFromAST(valueNode, type.ofType, variables);
  26249. }
  26250. if (valueNode.kind === _kinds.Kind.NULL) {
  26251. // This is explicitly returning the value null.
  26252. return null;
  26253. }
  26254. if (valueNode.kind === _kinds.Kind.VARIABLE) {
  26255. var variableName = valueNode.name.value;
  26256. if (!variables || (0, _isInvalid.default)(variables[variableName])) {
  26257. // No valid return value.
  26258. return;
  26259. }
  26260. var variableValue = variables[variableName];
  26261. if (variableValue === null && (0, _definition.isNonNullType)(type)) {
  26262. return; // Invalid: intentionally return no value.
  26263. } // Note: This does no further checking that this variable is correct.
  26264. // This assumes that this query has been validated and the variable
  26265. // usage here is of the correct type.
  26266. return variableValue;
  26267. }
  26268. if ((0, _definition.isListType)(type)) {
  26269. var itemType = type.ofType;
  26270. if (valueNode.kind === _kinds.Kind.LIST) {
  26271. var coercedValues = [];
  26272. var itemNodes = valueNode.values;
  26273. for (var i = 0; i < itemNodes.length; i++) {
  26274. if (isMissingVariable(itemNodes[i], variables)) {
  26275. // If an array contains a missing variable, it is either coerced to
  26276. // null or if the item type is non-null, it considered invalid.
  26277. if ((0, _definition.isNonNullType)(itemType)) {
  26278. return; // Invalid: intentionally return no value.
  26279. }
  26280. coercedValues.push(null);
  26281. } else {
  26282. var itemValue = valueFromAST(itemNodes[i], itemType, variables);
  26283. if ((0, _isInvalid.default)(itemValue)) {
  26284. return; // Invalid: intentionally return no value.
  26285. }
  26286. coercedValues.push(itemValue);
  26287. }
  26288. }
  26289. return coercedValues;
  26290. }
  26291. var coercedValue = valueFromAST(valueNode, itemType, variables);
  26292. if ((0, _isInvalid.default)(coercedValue)) {
  26293. return; // Invalid: intentionally return no value.
  26294. }
  26295. return [coercedValue];
  26296. }
  26297. if ((0, _definition.isInputObjectType)(type)) {
  26298. if (valueNode.kind !== _kinds.Kind.OBJECT) {
  26299. return; // Invalid: intentionally return no value.
  26300. }
  26301. var coercedObj = Object.create(null);
  26302. var fieldNodes = (0, _keyMap.default)(valueNode.fields, function (field) {
  26303. return field.name.value;
  26304. });
  26305. var fields = (0, _objectValues.default)(type.getFields());
  26306. for (var _i = 0; _i < fields.length; _i++) {
  26307. var field = fields[_i];
  26308. var fieldNode = fieldNodes[field.name];
  26309. if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
  26310. if (field.defaultValue !== undefined) {
  26311. coercedObj[field.name] = field.defaultValue;
  26312. } else if ((0, _definition.isNonNullType)(field.type)) {
  26313. return; // Invalid: intentionally return no value.
  26314. }
  26315. continue;
  26316. }
  26317. var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
  26318. if ((0, _isInvalid.default)(fieldValue)) {
  26319. return; // Invalid: intentionally return no value.
  26320. }
  26321. coercedObj[field.name] = fieldValue;
  26322. }
  26323. return coercedObj;
  26324. }
  26325. if ((0, _definition.isEnumType)(type)) {
  26326. if (valueNode.kind !== _kinds.Kind.ENUM) {
  26327. return; // Invalid: intentionally return no value.
  26328. }
  26329. var enumValue = type.getValue(valueNode.value);
  26330. if (!enumValue) {
  26331. return; // Invalid: intentionally return no value.
  26332. }
  26333. return enumValue.value;
  26334. }
  26335. if ((0, _definition.isScalarType)(type)) {
  26336. // Scalars fulfill parsing a literal value via parseLiteral().
  26337. // Invalid values represent a failure to parse correctly, in which case
  26338. // no value is returned.
  26339. var result;
  26340. try {
  26341. result = type.parseLiteral(valueNode, variables);
  26342. } catch (_error) {
  26343. return; // Invalid: intentionally return no value.
  26344. }
  26345. if ((0, _isInvalid.default)(result)) {
  26346. return; // Invalid: intentionally return no value.
  26347. }
  26348. return result;
  26349. } // Not reachable. All possible input types have been considered.
  26350. /* istanbul ignore next */
  26351. throw new Error("Unexpected input type: \"".concat((0, _inspect.default)(type), "\"."));
  26352. } // Returns true if the provided valueNode is a variable which is not defined
  26353. // in the set of variables.
  26354. function isMissingVariable(valueNode, variables) {
  26355. return valueNode.kind === _kinds.Kind.VARIABLE && (!variables || (0, _isInvalid.default)(variables[valueNode.name.value]));
  26356. }
  26357. },{"../jsutils/inspect":32,"../jsutils/isInvalid":35,"../jsutils/keyMap":38,"../language/kinds":51,"../polyfills/objectValues":64,"../type/definition":68}],99:[function(require,module,exports){
  26358. "use strict";
  26359. Object.defineProperty(exports, "__esModule", {
  26360. value: true
  26361. });
  26362. exports.valueFromASTUntyped = valueFromASTUntyped;
  26363. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  26364. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  26365. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  26366. var _kinds = require("../language/kinds");
  26367. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26368. /**
  26369. * Copyright (c) Facebook, Inc. and its affiliates.
  26370. *
  26371. * This source code is licensed under the MIT license found in the
  26372. * LICENSE file in the root directory of this source tree.
  26373. *
  26374. *
  26375. */
  26376. /**
  26377. * Produces a JavaScript value given a GraphQL Value AST.
  26378. *
  26379. * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value
  26380. * will reflect the provided GraphQL value AST.
  26381. *
  26382. * | GraphQL Value | JavaScript Value |
  26383. * | -------------------- | ---------------- |
  26384. * | Input Object | Object |
  26385. * | List | Array |
  26386. * | Boolean | Boolean |
  26387. * | String / Enum | String |
  26388. * | Int / Float | Number |
  26389. * | Null | null |
  26390. *
  26391. */
  26392. function valueFromASTUntyped(valueNode, variables) {
  26393. switch (valueNode.kind) {
  26394. case _kinds.Kind.NULL:
  26395. return null;
  26396. case _kinds.Kind.INT:
  26397. return parseInt(valueNode.value, 10);
  26398. case _kinds.Kind.FLOAT:
  26399. return parseFloat(valueNode.value);
  26400. case _kinds.Kind.STRING:
  26401. case _kinds.Kind.ENUM:
  26402. case _kinds.Kind.BOOLEAN:
  26403. return valueNode.value;
  26404. case _kinds.Kind.LIST:
  26405. return valueNode.values.map(function (node) {
  26406. return valueFromASTUntyped(node, variables);
  26407. });
  26408. case _kinds.Kind.OBJECT:
  26409. return (0, _keyValMap.default)(valueNode.fields, function (field) {
  26410. return field.name.value;
  26411. }, function (field) {
  26412. return valueFromASTUntyped(field.value, variables);
  26413. });
  26414. case _kinds.Kind.VARIABLE:
  26415. {
  26416. var variableName = valueNode.name.value;
  26417. return variables && !(0, _isInvalid.default)(variables[variableName]) ? variables[variableName] : undefined;
  26418. }
  26419. } // Not reachable. All possible value nodes have been considered.
  26420. /* istanbul ignore next */
  26421. throw new Error("Unexpected value node: \"".concat((0, _inspect.default)(valueNode), "\"."));
  26422. }
  26423. },{"../jsutils/inspect":32,"../jsutils/isInvalid":35,"../jsutils/keyValMap":39,"../language/kinds":51}],100:[function(require,module,exports){
  26424. "use strict";
  26425. Object.defineProperty(exports, "__esModule", {
  26426. value: true
  26427. });
  26428. exports.ValidationContext = exports.SDLValidationContext = exports.ASTValidationContext = void 0;
  26429. var _visitor = require("../language/visitor");
  26430. var _kinds = require("../language/kinds");
  26431. var _TypeInfo = require("../utilities/TypeInfo");
  26432. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  26433. /**
  26434. * An instance of this class is passed as the "this" context to all validators,
  26435. * allowing access to commonly useful contextual information from within a
  26436. * validation rule.
  26437. */
  26438. var ASTValidationContext =
  26439. /*#__PURE__*/
  26440. function () {
  26441. function ASTValidationContext(ast) {
  26442. this._ast = ast;
  26443. this._errors = [];
  26444. this._fragments = undefined;
  26445. this._fragmentSpreads = new Map();
  26446. this._recursivelyReferencedFragments = new Map();
  26447. }
  26448. var _proto = ASTValidationContext.prototype;
  26449. _proto.reportError = function reportError(error) {
  26450. this._errors.push(error);
  26451. };
  26452. _proto.getErrors = function getErrors() {
  26453. return this._errors;
  26454. };
  26455. _proto.getDocument = function getDocument() {
  26456. return this._ast;
  26457. };
  26458. _proto.getFragment = function getFragment(name) {
  26459. var fragments = this._fragments;
  26460. if (!fragments) {
  26461. this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
  26462. if (statement.kind === _kinds.Kind.FRAGMENT_DEFINITION) {
  26463. frags[statement.name.value] = statement;
  26464. }
  26465. return frags;
  26466. }, Object.create(null));
  26467. }
  26468. return fragments[name];
  26469. };
  26470. _proto.getFragmentSpreads = function getFragmentSpreads(node) {
  26471. var spreads = this._fragmentSpreads.get(node);
  26472. if (!spreads) {
  26473. spreads = [];
  26474. var setsToVisit = [node];
  26475. while (setsToVisit.length !== 0) {
  26476. var set = setsToVisit.pop();
  26477. for (var i = 0; i < set.selections.length; i++) {
  26478. var selection = set.selections[i];
  26479. if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
  26480. spreads.push(selection);
  26481. } else if (selection.selectionSet) {
  26482. setsToVisit.push(selection.selectionSet);
  26483. }
  26484. }
  26485. }
  26486. this._fragmentSpreads.set(node, spreads);
  26487. }
  26488. return spreads;
  26489. };
  26490. _proto.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
  26491. var fragments = this._recursivelyReferencedFragments.get(operation);
  26492. if (!fragments) {
  26493. fragments = [];
  26494. var collectedNames = Object.create(null);
  26495. var nodesToVisit = [operation.selectionSet];
  26496. while (nodesToVisit.length !== 0) {
  26497. var node = nodesToVisit.pop();
  26498. var spreads = this.getFragmentSpreads(node);
  26499. for (var i = 0; i < spreads.length; i++) {
  26500. var fragName = spreads[i].name.value;
  26501. if (collectedNames[fragName] !== true) {
  26502. collectedNames[fragName] = true;
  26503. var fragment = this.getFragment(fragName);
  26504. if (fragment) {
  26505. fragments.push(fragment);
  26506. nodesToVisit.push(fragment.selectionSet);
  26507. }
  26508. }
  26509. }
  26510. }
  26511. this._recursivelyReferencedFragments.set(operation, fragments);
  26512. }
  26513. return fragments;
  26514. };
  26515. return ASTValidationContext;
  26516. }();
  26517. exports.ASTValidationContext = ASTValidationContext;
  26518. var SDLValidationContext =
  26519. /*#__PURE__*/
  26520. function (_ASTValidationContext) {
  26521. _inheritsLoose(SDLValidationContext, _ASTValidationContext);
  26522. function SDLValidationContext(ast, schema) {
  26523. var _this;
  26524. _this = _ASTValidationContext.call(this, ast) || this;
  26525. _this._schema = schema;
  26526. return _this;
  26527. }
  26528. var _proto2 = SDLValidationContext.prototype;
  26529. _proto2.getSchema = function getSchema() {
  26530. return this._schema;
  26531. };
  26532. return SDLValidationContext;
  26533. }(ASTValidationContext);
  26534. exports.SDLValidationContext = SDLValidationContext;
  26535. var ValidationContext =
  26536. /*#__PURE__*/
  26537. function (_ASTValidationContext2) {
  26538. _inheritsLoose(ValidationContext, _ASTValidationContext2);
  26539. function ValidationContext(schema, ast, typeInfo) {
  26540. var _this2;
  26541. _this2 = _ASTValidationContext2.call(this, ast) || this;
  26542. _this2._schema = schema;
  26543. _this2._typeInfo = typeInfo;
  26544. _this2._variableUsages = new Map();
  26545. _this2._recursiveVariableUsages = new Map();
  26546. return _this2;
  26547. }
  26548. var _proto3 = ValidationContext.prototype;
  26549. _proto3.getSchema = function getSchema() {
  26550. return this._schema;
  26551. };
  26552. _proto3.getVariableUsages = function getVariableUsages(node) {
  26553. var usages = this._variableUsages.get(node);
  26554. if (!usages) {
  26555. var newUsages = [];
  26556. var typeInfo = new _TypeInfo.TypeInfo(this._schema);
  26557. (0, _visitor.visit)(node, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  26558. VariableDefinition: function VariableDefinition() {
  26559. return false;
  26560. },
  26561. Variable: function Variable(variable) {
  26562. newUsages.push({
  26563. node: variable,
  26564. type: typeInfo.getInputType(),
  26565. defaultValue: typeInfo.getDefaultValue()
  26566. });
  26567. }
  26568. }));
  26569. usages = newUsages;
  26570. this._variableUsages.set(node, usages);
  26571. }
  26572. return usages;
  26573. };
  26574. _proto3.getRecursiveVariableUsages = function getRecursiveVariableUsages(operation) {
  26575. var usages = this._recursiveVariableUsages.get(operation);
  26576. if (!usages) {
  26577. usages = this.getVariableUsages(operation);
  26578. var fragments = this.getRecursivelyReferencedFragments(operation);
  26579. for (var i = 0; i < fragments.length; i++) {
  26580. Array.prototype.push.apply(usages, this.getVariableUsages(fragments[i]));
  26581. }
  26582. this._recursiveVariableUsages.set(operation, usages);
  26583. }
  26584. return usages;
  26585. };
  26586. _proto3.getType = function getType() {
  26587. return this._typeInfo.getType();
  26588. };
  26589. _proto3.getParentType = function getParentType() {
  26590. return this._typeInfo.getParentType();
  26591. };
  26592. _proto3.getInputType = function getInputType() {
  26593. return this._typeInfo.getInputType();
  26594. };
  26595. _proto3.getParentInputType = function getParentInputType() {
  26596. return this._typeInfo.getParentInputType();
  26597. };
  26598. _proto3.getFieldDef = function getFieldDef() {
  26599. return this._typeInfo.getFieldDef();
  26600. };
  26601. _proto3.getDirective = function getDirective() {
  26602. return this._typeInfo.getDirective();
  26603. };
  26604. _proto3.getArgument = function getArgument() {
  26605. return this._typeInfo.getArgument();
  26606. };
  26607. return ValidationContext;
  26608. }(ASTValidationContext);
  26609. exports.ValidationContext = ValidationContext;
  26610. },{"../language/kinds":51,"../language/visitor":58,"../utilities/TypeInfo":75}],101:[function(require,module,exports){
  26611. "use strict";
  26612. Object.defineProperty(exports, "__esModule", {
  26613. value: true
  26614. });
  26615. Object.defineProperty(exports, "validate", {
  26616. enumerable: true,
  26617. get: function get() {
  26618. return _validate.validate;
  26619. }
  26620. });
  26621. Object.defineProperty(exports, "ValidationContext", {
  26622. enumerable: true,
  26623. get: function get() {
  26624. return _ValidationContext.ValidationContext;
  26625. }
  26626. });
  26627. Object.defineProperty(exports, "specifiedRules", {
  26628. enumerable: true,
  26629. get: function get() {
  26630. return _specifiedRules.specifiedRules;
  26631. }
  26632. });
  26633. Object.defineProperty(exports, "FieldsOnCorrectTypeRule", {
  26634. enumerable: true,
  26635. get: function get() {
  26636. return _FieldsOnCorrectType.FieldsOnCorrectType;
  26637. }
  26638. });
  26639. Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", {
  26640. enumerable: true,
  26641. get: function get() {
  26642. return _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes;
  26643. }
  26644. });
  26645. Object.defineProperty(exports, "KnownArgumentNamesRule", {
  26646. enumerable: true,
  26647. get: function get() {
  26648. return _KnownArgumentNames.KnownArgumentNames;
  26649. }
  26650. });
  26651. Object.defineProperty(exports, "KnownDirectivesRule", {
  26652. enumerable: true,
  26653. get: function get() {
  26654. return _KnownDirectives.KnownDirectives;
  26655. }
  26656. });
  26657. Object.defineProperty(exports, "KnownFragmentNamesRule", {
  26658. enumerable: true,
  26659. get: function get() {
  26660. return _KnownFragmentNames.KnownFragmentNames;
  26661. }
  26662. });
  26663. Object.defineProperty(exports, "KnownTypeNamesRule", {
  26664. enumerable: true,
  26665. get: function get() {
  26666. return _KnownTypeNames.KnownTypeNames;
  26667. }
  26668. });
  26669. Object.defineProperty(exports, "LoneAnonymousOperationRule", {
  26670. enumerable: true,
  26671. get: function get() {
  26672. return _LoneAnonymousOperation.LoneAnonymousOperation;
  26673. }
  26674. });
  26675. Object.defineProperty(exports, "NoFragmentCyclesRule", {
  26676. enumerable: true,
  26677. get: function get() {
  26678. return _NoFragmentCycles.NoFragmentCycles;
  26679. }
  26680. });
  26681. Object.defineProperty(exports, "NoUndefinedVariablesRule", {
  26682. enumerable: true,
  26683. get: function get() {
  26684. return _NoUndefinedVariables.NoUndefinedVariables;
  26685. }
  26686. });
  26687. Object.defineProperty(exports, "NoUnusedFragmentsRule", {
  26688. enumerable: true,
  26689. get: function get() {
  26690. return _NoUnusedFragments.NoUnusedFragments;
  26691. }
  26692. });
  26693. Object.defineProperty(exports, "NoUnusedVariablesRule", {
  26694. enumerable: true,
  26695. get: function get() {
  26696. return _NoUnusedVariables.NoUnusedVariables;
  26697. }
  26698. });
  26699. Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", {
  26700. enumerable: true,
  26701. get: function get() {
  26702. return _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged;
  26703. }
  26704. });
  26705. Object.defineProperty(exports, "PossibleFragmentSpreadsRule", {
  26706. enumerable: true,
  26707. get: function get() {
  26708. return _PossibleFragmentSpreads.PossibleFragmentSpreads;
  26709. }
  26710. });
  26711. Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", {
  26712. enumerable: true,
  26713. get: function get() {
  26714. return _ProvidedRequiredArguments.ProvidedRequiredArguments;
  26715. }
  26716. });
  26717. Object.defineProperty(exports, "ScalarLeafsRule", {
  26718. enumerable: true,
  26719. get: function get() {
  26720. return _ScalarLeafs.ScalarLeafs;
  26721. }
  26722. });
  26723. Object.defineProperty(exports, "SingleFieldSubscriptionsRule", {
  26724. enumerable: true,
  26725. get: function get() {
  26726. return _SingleFieldSubscriptions.SingleFieldSubscriptions;
  26727. }
  26728. });
  26729. Object.defineProperty(exports, "UniqueArgumentNamesRule", {
  26730. enumerable: true,
  26731. get: function get() {
  26732. return _UniqueArgumentNames.UniqueArgumentNames;
  26733. }
  26734. });
  26735. Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", {
  26736. enumerable: true,
  26737. get: function get() {
  26738. return _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation;
  26739. }
  26740. });
  26741. Object.defineProperty(exports, "UniqueFragmentNamesRule", {
  26742. enumerable: true,
  26743. get: function get() {
  26744. return _UniqueFragmentNames.UniqueFragmentNames;
  26745. }
  26746. });
  26747. Object.defineProperty(exports, "UniqueInputFieldNamesRule", {
  26748. enumerable: true,
  26749. get: function get() {
  26750. return _UniqueInputFieldNames.UniqueInputFieldNames;
  26751. }
  26752. });
  26753. Object.defineProperty(exports, "UniqueOperationNamesRule", {
  26754. enumerable: true,
  26755. get: function get() {
  26756. return _UniqueOperationNames.UniqueOperationNames;
  26757. }
  26758. });
  26759. Object.defineProperty(exports, "UniqueVariableNamesRule", {
  26760. enumerable: true,
  26761. get: function get() {
  26762. return _UniqueVariableNames.UniqueVariableNames;
  26763. }
  26764. });
  26765. Object.defineProperty(exports, "ValuesOfCorrectTypeRule", {
  26766. enumerable: true,
  26767. get: function get() {
  26768. return _ValuesOfCorrectType.ValuesOfCorrectType;
  26769. }
  26770. });
  26771. Object.defineProperty(exports, "VariablesAreInputTypesRule", {
  26772. enumerable: true,
  26773. get: function get() {
  26774. return _VariablesAreInputTypes.VariablesAreInputTypes;
  26775. }
  26776. });
  26777. Object.defineProperty(exports, "VariablesInAllowedPositionRule", {
  26778. enumerable: true,
  26779. get: function get() {
  26780. return _VariablesInAllowedPosition.VariablesInAllowedPosition;
  26781. }
  26782. });
  26783. var _validate = require("./validate");
  26784. var _ValidationContext = require("./ValidationContext");
  26785. var _specifiedRules = require("./specifiedRules");
  26786. var _FieldsOnCorrectType = require("./rules/FieldsOnCorrectType");
  26787. var _FragmentsOnCompositeTypes = require("./rules/FragmentsOnCompositeTypes");
  26788. var _KnownArgumentNames = require("./rules/KnownArgumentNames");
  26789. var _KnownDirectives = require("./rules/KnownDirectives");
  26790. var _KnownFragmentNames = require("./rules/KnownFragmentNames");
  26791. var _KnownTypeNames = require("./rules/KnownTypeNames");
  26792. var _LoneAnonymousOperation = require("./rules/LoneAnonymousOperation");
  26793. var _NoFragmentCycles = require("./rules/NoFragmentCycles");
  26794. var _NoUndefinedVariables = require("./rules/NoUndefinedVariables");
  26795. var _NoUnusedFragments = require("./rules/NoUnusedFragments");
  26796. var _NoUnusedVariables = require("./rules/NoUnusedVariables");
  26797. var _OverlappingFieldsCanBeMerged = require("./rules/OverlappingFieldsCanBeMerged");
  26798. var _PossibleFragmentSpreads = require("./rules/PossibleFragmentSpreads");
  26799. var _ProvidedRequiredArguments = require("./rules/ProvidedRequiredArguments");
  26800. var _ScalarLeafs = require("./rules/ScalarLeafs");
  26801. var _SingleFieldSubscriptions = require("./rules/SingleFieldSubscriptions");
  26802. var _UniqueArgumentNames = require("./rules/UniqueArgumentNames");
  26803. var _UniqueDirectivesPerLocation = require("./rules/UniqueDirectivesPerLocation");
  26804. var _UniqueFragmentNames = require("./rules/UniqueFragmentNames");
  26805. var _UniqueInputFieldNames = require("./rules/UniqueInputFieldNames");
  26806. var _UniqueOperationNames = require("./rules/UniqueOperationNames");
  26807. var _UniqueVariableNames = require("./rules/UniqueVariableNames");
  26808. var _ValuesOfCorrectType = require("./rules/ValuesOfCorrectType");
  26809. var _VariablesAreInputTypes = require("./rules/VariablesAreInputTypes");
  26810. var _VariablesInAllowedPosition = require("./rules/VariablesInAllowedPosition");
  26811. },{"./ValidationContext":100,"./rules/FieldsOnCorrectType":103,"./rules/FragmentsOnCompositeTypes":104,"./rules/KnownArgumentNames":105,"./rules/KnownDirectives":106,"./rules/KnownFragmentNames":107,"./rules/KnownTypeNames":108,"./rules/LoneAnonymousOperation":109,"./rules/NoFragmentCycles":111,"./rules/NoUndefinedVariables":112,"./rules/NoUnusedFragments":113,"./rules/NoUnusedVariables":114,"./rules/OverlappingFieldsCanBeMerged":115,"./rules/PossibleFragmentSpreads":116,"./rules/ProvidedRequiredArguments":118,"./rules/ScalarLeafs":119,"./rules/SingleFieldSubscriptions":120,"./rules/UniqueArgumentNames":121,"./rules/UniqueDirectivesPerLocation":123,"./rules/UniqueFragmentNames":126,"./rules/UniqueInputFieldNames":127,"./rules/UniqueOperationNames":128,"./rules/UniqueVariableNames":131,"./rules/ValuesOfCorrectType":132,"./rules/VariablesAreInputTypes":133,"./rules/VariablesInAllowedPosition":134,"./specifiedRules":135,"./validate":136}],102:[function(require,module,exports){
  26812. "use strict";
  26813. Object.defineProperty(exports, "__esModule", {
  26814. value: true
  26815. });
  26816. exports.nonExecutableDefinitionMessage = nonExecutableDefinitionMessage;
  26817. exports.ExecutableDefinitions = ExecutableDefinitions;
  26818. var _GraphQLError = require("../../error/GraphQLError");
  26819. var _kinds = require("../../language/kinds");
  26820. var _predicates = require("../../language/predicates");
  26821. /**
  26822. * Copyright (c) Facebook, Inc. and its affiliates.
  26823. *
  26824. * This source code is licensed under the MIT license found in the
  26825. * LICENSE file in the root directory of this source tree.
  26826. *
  26827. *
  26828. */
  26829. function nonExecutableDefinitionMessage(defName) {
  26830. return "The ".concat(defName, " definition is not executable.");
  26831. }
  26832. /**
  26833. * Executable definitions
  26834. *
  26835. * A GraphQL document is only valid for execution if all definitions are either
  26836. * operation or fragment definitions.
  26837. */
  26838. function ExecutableDefinitions(context) {
  26839. return {
  26840. Document: function Document(node) {
  26841. var _iteratorNormalCompletion = true;
  26842. var _didIteratorError = false;
  26843. var _iteratorError = undefined;
  26844. try {
  26845. for (var _iterator = node.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26846. var definition = _step.value;
  26847. if (!(0, _predicates.isExecutableDefinitionNode)(definition)) {
  26848. context.reportError(new _GraphQLError.GraphQLError(nonExecutableDefinitionMessage(definition.kind === _kinds.Kind.SCHEMA_DEFINITION || definition.kind === _kinds.Kind.SCHEMA_EXTENSION ? 'schema' : definition.name.value), definition));
  26849. }
  26850. }
  26851. } catch (err) {
  26852. _didIteratorError = true;
  26853. _iteratorError = err;
  26854. } finally {
  26855. try {
  26856. if (!_iteratorNormalCompletion && _iterator.return != null) {
  26857. _iterator.return();
  26858. }
  26859. } finally {
  26860. if (_didIteratorError) {
  26861. throw _iteratorError;
  26862. }
  26863. }
  26864. }
  26865. return false;
  26866. }
  26867. };
  26868. }
  26869. },{"../../error/GraphQLError":19,"../../language/kinds":51,"../../language/predicates":55}],103:[function(require,module,exports){
  26870. "use strict";
  26871. Object.defineProperty(exports, "__esModule", {
  26872. value: true
  26873. });
  26874. exports.undefinedFieldMessage = undefinedFieldMessage;
  26875. exports.FieldsOnCorrectType = FieldsOnCorrectType;
  26876. var _GraphQLError = require("../../error/GraphQLError");
  26877. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  26878. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  26879. var _definition = require("../../type/definition");
  26880. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26881. /**
  26882. * Copyright (c) Facebook, Inc. and its affiliates.
  26883. *
  26884. * This source code is licensed under the MIT license found in the
  26885. * LICENSE file in the root directory of this source tree.
  26886. *
  26887. *
  26888. */
  26889. function undefinedFieldMessage(fieldName, type, suggestedTypeNames, suggestedFieldNames) {
  26890. var message = "Cannot query field \"".concat(fieldName, "\" on type \"").concat(type, "\".");
  26891. if (suggestedTypeNames.length !== 0) {
  26892. var suggestions = (0, _quotedOrList.default)(suggestedTypeNames);
  26893. message += " Did you mean to use an inline fragment on ".concat(suggestions, "?");
  26894. } else if (suggestedFieldNames.length !== 0) {
  26895. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedFieldNames), "?");
  26896. }
  26897. return message;
  26898. }
  26899. /**
  26900. * Fields on correct type
  26901. *
  26902. * A GraphQL document is only valid if all fields selected are defined by the
  26903. * parent type, or are an allowed meta field such as __typename.
  26904. */
  26905. function FieldsOnCorrectType(context) {
  26906. return {
  26907. Field: function Field(node) {
  26908. var type = context.getParentType();
  26909. if (type) {
  26910. var fieldDef = context.getFieldDef();
  26911. if (!fieldDef) {
  26912. // This field doesn't exist, lets look for suggestions.
  26913. var schema = context.getSchema();
  26914. var fieldName = node.name.value; // First determine if there are any suggested types to condition on.
  26915. var suggestedTypeNames = getSuggestedTypeNames(schema, type, fieldName); // If there are no suggested types, then perhaps this was a typo?
  26916. var suggestedFieldNames = suggestedTypeNames.length !== 0 ? [] : getSuggestedFieldNames(schema, type, fieldName); // Report an error, including helpful suggestions.
  26917. context.reportError(new _GraphQLError.GraphQLError(undefinedFieldMessage(fieldName, type.name, suggestedTypeNames, suggestedFieldNames), node));
  26918. }
  26919. }
  26920. }
  26921. };
  26922. }
  26923. /**
  26924. * Go through all of the implementations of type, as well as the interfaces that
  26925. * they implement. If any of those types include the provided field, suggest
  26926. * them, sorted by how often the type is referenced, starting with Interfaces.
  26927. */
  26928. function getSuggestedTypeNames(schema, type, fieldName) {
  26929. if ((0, _definition.isAbstractType)(type)) {
  26930. var suggestedObjectTypes = [];
  26931. var interfaceUsageCount = Object.create(null);
  26932. var _iteratorNormalCompletion = true;
  26933. var _didIteratorError = false;
  26934. var _iteratorError = undefined;
  26935. try {
  26936. for (var _iterator = schema.getPossibleTypes(type)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26937. var possibleType = _step.value;
  26938. if (!possibleType.getFields()[fieldName]) {
  26939. continue;
  26940. } // This object type defines this field.
  26941. suggestedObjectTypes.push(possibleType.name);
  26942. var _iteratorNormalCompletion2 = true;
  26943. var _didIteratorError2 = false;
  26944. var _iteratorError2 = undefined;
  26945. try {
  26946. for (var _iterator2 = possibleType.getInterfaces()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  26947. var possibleInterface = _step2.value;
  26948. if (!possibleInterface.getFields()[fieldName]) {
  26949. continue;
  26950. } // This interface type defines this field.
  26951. interfaceUsageCount[possibleInterface.name] = (interfaceUsageCount[possibleInterface.name] || 0) + 1;
  26952. }
  26953. } catch (err) {
  26954. _didIteratorError2 = true;
  26955. _iteratorError2 = err;
  26956. } finally {
  26957. try {
  26958. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  26959. _iterator2.return();
  26960. }
  26961. } finally {
  26962. if (_didIteratorError2) {
  26963. throw _iteratorError2;
  26964. }
  26965. }
  26966. }
  26967. } // Suggest interface types based on how common they are.
  26968. } catch (err) {
  26969. _didIteratorError = true;
  26970. _iteratorError = err;
  26971. } finally {
  26972. try {
  26973. if (!_iteratorNormalCompletion && _iterator.return != null) {
  26974. _iterator.return();
  26975. }
  26976. } finally {
  26977. if (_didIteratorError) {
  26978. throw _iteratorError;
  26979. }
  26980. }
  26981. }
  26982. var suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(function (a, b) {
  26983. return interfaceUsageCount[b] - interfaceUsageCount[a];
  26984. }); // Suggest both interface and object types.
  26985. return suggestedInterfaceTypes.concat(suggestedObjectTypes);
  26986. } // Otherwise, must be an Object type, which does not have possible fields.
  26987. return [];
  26988. }
  26989. /**
  26990. * For the field name provided, determine if there are any similar field names
  26991. * that may be the result of a typo.
  26992. */
  26993. function getSuggestedFieldNames(schema, type, fieldName) {
  26994. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  26995. var possibleFieldNames = Object.keys(type.getFields());
  26996. return (0, _suggestionList.default)(fieldName, possibleFieldNames);
  26997. } // Otherwise, must be a Union type, which does not define fields.
  26998. return [];
  26999. }
  27000. },{"../../error/GraphQLError":19,"../../jsutils/quotedOrList":46,"../../jsutils/suggestionList":47,"../../type/definition":68}],104:[function(require,module,exports){
  27001. "use strict";
  27002. Object.defineProperty(exports, "__esModule", {
  27003. value: true
  27004. });
  27005. exports.inlineFragmentOnNonCompositeErrorMessage = inlineFragmentOnNonCompositeErrorMessage;
  27006. exports.fragmentOnNonCompositeErrorMessage = fragmentOnNonCompositeErrorMessage;
  27007. exports.FragmentsOnCompositeTypes = FragmentsOnCompositeTypes;
  27008. var _GraphQLError = require("../../error/GraphQLError");
  27009. var _printer = require("../../language/printer");
  27010. var _definition = require("../../type/definition");
  27011. var _typeFromAST = require("../../utilities/typeFromAST");
  27012. /**
  27013. * Copyright (c) Facebook, Inc. and its affiliates.
  27014. *
  27015. * This source code is licensed under the MIT license found in the
  27016. * LICENSE file in the root directory of this source tree.
  27017. *
  27018. *
  27019. */
  27020. function inlineFragmentOnNonCompositeErrorMessage(type) {
  27021. return "Fragment cannot condition on non composite type \"".concat(type, "\".");
  27022. }
  27023. function fragmentOnNonCompositeErrorMessage(fragName, type) {
  27024. return "Fragment \"".concat(fragName, "\" cannot condition on non composite ") + "type \"".concat(type, "\".");
  27025. }
  27026. /**
  27027. * Fragments on composite type
  27028. *
  27029. * Fragments use a type condition to determine if they apply, since fragments
  27030. * can only be spread into a composite type (object, interface, or union), the
  27031. * type condition must also be a composite type.
  27032. */
  27033. function FragmentsOnCompositeTypes(context) {
  27034. return {
  27035. InlineFragment: function InlineFragment(node) {
  27036. var typeCondition = node.typeCondition;
  27037. if (typeCondition) {
  27038. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition);
  27039. if (type && !(0, _definition.isCompositeType)(type)) {
  27040. context.reportError(new _GraphQLError.GraphQLError(inlineFragmentOnNonCompositeErrorMessage((0, _printer.print)(typeCondition)), typeCondition));
  27041. }
  27042. }
  27043. },
  27044. FragmentDefinition: function FragmentDefinition(node) {
  27045. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.typeCondition);
  27046. if (type && !(0, _definition.isCompositeType)(type)) {
  27047. context.reportError(new _GraphQLError.GraphQLError(fragmentOnNonCompositeErrorMessage(node.name.value, (0, _printer.print)(node.typeCondition)), node.typeCondition));
  27048. }
  27049. }
  27050. };
  27051. }
  27052. },{"../../error/GraphQLError":19,"../../language/printer":56,"../../type/definition":68,"../../utilities/typeFromAST":97}],105:[function(require,module,exports){
  27053. "use strict";
  27054. Object.defineProperty(exports, "__esModule", {
  27055. value: true
  27056. });
  27057. exports.unknownArgMessage = unknownArgMessage;
  27058. exports.unknownDirectiveArgMessage = unknownDirectiveArgMessage;
  27059. exports.KnownArgumentNames = KnownArgumentNames;
  27060. exports.KnownArgumentNamesOnDirectives = KnownArgumentNamesOnDirectives;
  27061. var _GraphQLError = require("../../error/GraphQLError");
  27062. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  27063. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  27064. var _kinds = require("../../language/kinds");
  27065. var _directives = require("../../type/directives");
  27066. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27067. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  27068. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  27069. function unknownArgMessage(argName, fieldName, typeName, suggestedArgs) {
  27070. var message = "Unknown argument \"".concat(argName, "\" on field \"").concat(fieldName, "\" of ") + "type \"".concat(typeName, "\".");
  27071. if (suggestedArgs.length) {
  27072. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedArgs), "?");
  27073. }
  27074. return message;
  27075. }
  27076. function unknownDirectiveArgMessage(argName, directiveName, suggestedArgs) {
  27077. var message = "Unknown argument \"".concat(argName, "\" on directive \"@").concat(directiveName, "\".");
  27078. if (suggestedArgs.length) {
  27079. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedArgs), "?");
  27080. }
  27081. return message;
  27082. }
  27083. /**
  27084. * Known argument names
  27085. *
  27086. * A GraphQL field is only valid if all supplied arguments are defined by
  27087. * that field.
  27088. */
  27089. function KnownArgumentNames(context) {
  27090. return _objectSpread({}, KnownArgumentNamesOnDirectives(context), {
  27091. Argument: function Argument(argNode) {
  27092. var argDef = context.getArgument();
  27093. var fieldDef = context.getFieldDef();
  27094. var parentType = context.getParentType();
  27095. if (!argDef && fieldDef && parentType) {
  27096. var argName = argNode.name.value;
  27097. var knownArgsNames = fieldDef.args.map(function (arg) {
  27098. return arg.name;
  27099. });
  27100. context.reportError(new _GraphQLError.GraphQLError(unknownArgMessage(argName, fieldDef.name, parentType.name, (0, _suggestionList.default)(argName, knownArgsNames)), argNode));
  27101. }
  27102. }
  27103. });
  27104. } // @internal
  27105. function KnownArgumentNamesOnDirectives(context) {
  27106. var directiveArgs = Object.create(null);
  27107. var schema = context.getSchema();
  27108. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  27109. var _iteratorNormalCompletion = true;
  27110. var _didIteratorError = false;
  27111. var _iteratorError = undefined;
  27112. try {
  27113. for (var _iterator = definedDirectives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27114. var directive = _step.value;
  27115. directiveArgs[directive.name] = directive.args.map(function (arg) {
  27116. return arg.name;
  27117. });
  27118. }
  27119. } catch (err) {
  27120. _didIteratorError = true;
  27121. _iteratorError = err;
  27122. } finally {
  27123. try {
  27124. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27125. _iterator.return();
  27126. }
  27127. } finally {
  27128. if (_didIteratorError) {
  27129. throw _iteratorError;
  27130. }
  27131. }
  27132. }
  27133. var astDefinitions = context.getDocument().definitions;
  27134. var _iteratorNormalCompletion2 = true;
  27135. var _didIteratorError2 = false;
  27136. var _iteratorError2 = undefined;
  27137. try {
  27138. for (var _iterator2 = astDefinitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  27139. var def = _step2.value;
  27140. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  27141. directiveArgs[def.name.value] = def.arguments ? def.arguments.map(function (arg) {
  27142. return arg.name.value;
  27143. }) : [];
  27144. }
  27145. }
  27146. } catch (err) {
  27147. _didIteratorError2 = true;
  27148. _iteratorError2 = err;
  27149. } finally {
  27150. try {
  27151. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  27152. _iterator2.return();
  27153. }
  27154. } finally {
  27155. if (_didIteratorError2) {
  27156. throw _iteratorError2;
  27157. }
  27158. }
  27159. }
  27160. return {
  27161. Directive: function Directive(directiveNode) {
  27162. var directiveName = directiveNode.name.value;
  27163. var knownArgs = directiveArgs[directiveName];
  27164. if (directiveNode.arguments && knownArgs) {
  27165. var _iteratorNormalCompletion3 = true;
  27166. var _didIteratorError3 = false;
  27167. var _iteratorError3 = undefined;
  27168. try {
  27169. for (var _iterator3 = directiveNode.arguments[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  27170. var argNode = _step3.value;
  27171. var argName = argNode.name.value;
  27172. if (knownArgs.indexOf(argName) === -1) {
  27173. var suggestions = (0, _suggestionList.default)(argName, knownArgs);
  27174. context.reportError(new _GraphQLError.GraphQLError(unknownDirectiveArgMessage(argName, directiveName, suggestions), argNode));
  27175. }
  27176. }
  27177. } catch (err) {
  27178. _didIteratorError3 = true;
  27179. _iteratorError3 = err;
  27180. } finally {
  27181. try {
  27182. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  27183. _iterator3.return();
  27184. }
  27185. } finally {
  27186. if (_didIteratorError3) {
  27187. throw _iteratorError3;
  27188. }
  27189. }
  27190. }
  27191. }
  27192. return false;
  27193. }
  27194. };
  27195. }
  27196. },{"../../error/GraphQLError":19,"../../jsutils/quotedOrList":46,"../../jsutils/suggestionList":47,"../../language/kinds":51,"../../type/directives":69}],106:[function(require,module,exports){
  27197. "use strict";
  27198. Object.defineProperty(exports, "__esModule", {
  27199. value: true
  27200. });
  27201. exports.unknownDirectiveMessage = unknownDirectiveMessage;
  27202. exports.misplacedDirectiveMessage = misplacedDirectiveMessage;
  27203. exports.KnownDirectives = KnownDirectives;
  27204. var _GraphQLError = require("../../error/GraphQLError");
  27205. var _kinds = require("../../language/kinds");
  27206. var _directiveLocation = require("../../language/directiveLocation");
  27207. var _directives = require("../../type/directives");
  27208. /**
  27209. * Copyright (c) Facebook, Inc. and its affiliates.
  27210. *
  27211. * This source code is licensed under the MIT license found in the
  27212. * LICENSE file in the root directory of this source tree.
  27213. *
  27214. *
  27215. */
  27216. function unknownDirectiveMessage(directiveName) {
  27217. return "Unknown directive \"".concat(directiveName, "\".");
  27218. }
  27219. function misplacedDirectiveMessage(directiveName, location) {
  27220. return "Directive \"".concat(directiveName, "\" may not be used on ").concat(location, ".");
  27221. }
  27222. /**
  27223. * Known directives
  27224. *
  27225. * A GraphQL document is only valid if all `@directives` are known by the
  27226. * schema and legally positioned.
  27227. */
  27228. function KnownDirectives(context) {
  27229. var locationsMap = Object.create(null);
  27230. var schema = context.getSchema();
  27231. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  27232. var _iteratorNormalCompletion = true;
  27233. var _didIteratorError = false;
  27234. var _iteratorError = undefined;
  27235. try {
  27236. for (var _iterator = definedDirectives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27237. var directive = _step.value;
  27238. locationsMap[directive.name] = directive.locations;
  27239. }
  27240. } catch (err) {
  27241. _didIteratorError = true;
  27242. _iteratorError = err;
  27243. } finally {
  27244. try {
  27245. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27246. _iterator.return();
  27247. }
  27248. } finally {
  27249. if (_didIteratorError) {
  27250. throw _iteratorError;
  27251. }
  27252. }
  27253. }
  27254. var astDefinitions = context.getDocument().definitions;
  27255. var _iteratorNormalCompletion2 = true;
  27256. var _didIteratorError2 = false;
  27257. var _iteratorError2 = undefined;
  27258. try {
  27259. for (var _iterator2 = astDefinitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  27260. var def = _step2.value;
  27261. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  27262. locationsMap[def.name.value] = def.locations.map(function (name) {
  27263. return name.value;
  27264. });
  27265. }
  27266. }
  27267. } catch (err) {
  27268. _didIteratorError2 = true;
  27269. _iteratorError2 = err;
  27270. } finally {
  27271. try {
  27272. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  27273. _iterator2.return();
  27274. }
  27275. } finally {
  27276. if (_didIteratorError2) {
  27277. throw _iteratorError2;
  27278. }
  27279. }
  27280. }
  27281. return {
  27282. Directive: function Directive(node, key, parent, path, ancestors) {
  27283. var name = node.name.value;
  27284. var locations = locationsMap[name];
  27285. if (!locations) {
  27286. context.reportError(new _GraphQLError.GraphQLError(unknownDirectiveMessage(name), node));
  27287. return;
  27288. }
  27289. var candidateLocation = getDirectiveLocationForASTPath(ancestors);
  27290. if (candidateLocation && locations.indexOf(candidateLocation) === -1) {
  27291. context.reportError(new _GraphQLError.GraphQLError(misplacedDirectiveMessage(name, candidateLocation), node));
  27292. }
  27293. }
  27294. };
  27295. }
  27296. function getDirectiveLocationForASTPath(ancestors) {
  27297. var appliedTo = ancestors[ancestors.length - 1];
  27298. if (!Array.isArray(appliedTo)) {
  27299. switch (appliedTo.kind) {
  27300. case _kinds.Kind.OPERATION_DEFINITION:
  27301. switch (appliedTo.operation) {
  27302. case 'query':
  27303. return _directiveLocation.DirectiveLocation.QUERY;
  27304. case 'mutation':
  27305. return _directiveLocation.DirectiveLocation.MUTATION;
  27306. case 'subscription':
  27307. return _directiveLocation.DirectiveLocation.SUBSCRIPTION;
  27308. }
  27309. break;
  27310. case _kinds.Kind.FIELD:
  27311. return _directiveLocation.DirectiveLocation.FIELD;
  27312. case _kinds.Kind.FRAGMENT_SPREAD:
  27313. return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD;
  27314. case _kinds.Kind.INLINE_FRAGMENT:
  27315. return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT;
  27316. case _kinds.Kind.FRAGMENT_DEFINITION:
  27317. return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION;
  27318. case _kinds.Kind.VARIABLE_DEFINITION:
  27319. return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION;
  27320. case _kinds.Kind.SCHEMA_DEFINITION:
  27321. case _kinds.Kind.SCHEMA_EXTENSION:
  27322. return _directiveLocation.DirectiveLocation.SCHEMA;
  27323. case _kinds.Kind.SCALAR_TYPE_DEFINITION:
  27324. case _kinds.Kind.SCALAR_TYPE_EXTENSION:
  27325. return _directiveLocation.DirectiveLocation.SCALAR;
  27326. case _kinds.Kind.OBJECT_TYPE_DEFINITION:
  27327. case _kinds.Kind.OBJECT_TYPE_EXTENSION:
  27328. return _directiveLocation.DirectiveLocation.OBJECT;
  27329. case _kinds.Kind.FIELD_DEFINITION:
  27330. return _directiveLocation.DirectiveLocation.FIELD_DEFINITION;
  27331. case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
  27332. case _kinds.Kind.INTERFACE_TYPE_EXTENSION:
  27333. return _directiveLocation.DirectiveLocation.INTERFACE;
  27334. case _kinds.Kind.UNION_TYPE_DEFINITION:
  27335. case _kinds.Kind.UNION_TYPE_EXTENSION:
  27336. return _directiveLocation.DirectiveLocation.UNION;
  27337. case _kinds.Kind.ENUM_TYPE_DEFINITION:
  27338. case _kinds.Kind.ENUM_TYPE_EXTENSION:
  27339. return _directiveLocation.DirectiveLocation.ENUM;
  27340. case _kinds.Kind.ENUM_VALUE_DEFINITION:
  27341. return _directiveLocation.DirectiveLocation.ENUM_VALUE;
  27342. case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
  27343. case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION:
  27344. return _directiveLocation.DirectiveLocation.INPUT_OBJECT;
  27345. case _kinds.Kind.INPUT_VALUE_DEFINITION:
  27346. {
  27347. var parentNode = ancestors[ancestors.length - 3];
  27348. return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION;
  27349. }
  27350. }
  27351. }
  27352. }
  27353. },{"../../error/GraphQLError":19,"../../language/directiveLocation":49,"../../language/kinds":51,"../../type/directives":69}],107:[function(require,module,exports){
  27354. "use strict";
  27355. Object.defineProperty(exports, "__esModule", {
  27356. value: true
  27357. });
  27358. exports.unknownFragmentMessage = unknownFragmentMessage;
  27359. exports.KnownFragmentNames = KnownFragmentNames;
  27360. var _GraphQLError = require("../../error/GraphQLError");
  27361. /**
  27362. * Copyright (c) Facebook, Inc. and its affiliates.
  27363. *
  27364. * This source code is licensed under the MIT license found in the
  27365. * LICENSE file in the root directory of this source tree.
  27366. *
  27367. *
  27368. */
  27369. function unknownFragmentMessage(fragName) {
  27370. return "Unknown fragment \"".concat(fragName, "\".");
  27371. }
  27372. /**
  27373. * Known fragment names
  27374. *
  27375. * A GraphQL document is only valid if all `...Fragment` fragment spreads refer
  27376. * to fragments defined in the same document.
  27377. */
  27378. function KnownFragmentNames(context) {
  27379. return {
  27380. FragmentSpread: function FragmentSpread(node) {
  27381. var fragmentName = node.name.value;
  27382. var fragment = context.getFragment(fragmentName);
  27383. if (!fragment) {
  27384. context.reportError(new _GraphQLError.GraphQLError(unknownFragmentMessage(fragmentName), node.name));
  27385. }
  27386. }
  27387. };
  27388. }
  27389. },{"../../error/GraphQLError":19}],108:[function(require,module,exports){
  27390. "use strict";
  27391. Object.defineProperty(exports, "__esModule", {
  27392. value: true
  27393. });
  27394. exports.unknownTypeMessage = unknownTypeMessage;
  27395. exports.KnownTypeNames = KnownTypeNames;
  27396. var _GraphQLError = require("../../error/GraphQLError");
  27397. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  27398. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  27399. var _predicates = require("../../language/predicates");
  27400. var _scalars = require("../../type/scalars");
  27401. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27402. /**
  27403. * Copyright (c) Facebook, Inc. and its affiliates.
  27404. *
  27405. * This source code is licensed under the MIT license found in the
  27406. * LICENSE file in the root directory of this source tree.
  27407. *
  27408. *
  27409. */
  27410. function unknownTypeMessage(typeName, suggestedTypes) {
  27411. var message = "Unknown type \"".concat(typeName, "\".");
  27412. if (suggestedTypes.length) {
  27413. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedTypes), "?");
  27414. }
  27415. return message;
  27416. }
  27417. /**
  27418. * Known type names
  27419. *
  27420. * A GraphQL document is only valid if referenced types (specifically
  27421. * variable definitions and fragment conditions) are defined by the type schema.
  27422. */
  27423. function KnownTypeNames(context) {
  27424. var schema = context.getSchema();
  27425. var existingTypesMap = schema ? schema.getTypeMap() : Object.create(null);
  27426. var definedTypes = Object.create(null);
  27427. var _iteratorNormalCompletion = true;
  27428. var _didIteratorError = false;
  27429. var _iteratorError = undefined;
  27430. try {
  27431. for (var _iterator = context.getDocument().definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27432. var def = _step.value;
  27433. if ((0, _predicates.isTypeDefinitionNode)(def)) {
  27434. definedTypes[def.name.value] = true;
  27435. }
  27436. }
  27437. } catch (err) {
  27438. _didIteratorError = true;
  27439. _iteratorError = err;
  27440. } finally {
  27441. try {
  27442. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27443. _iterator.return();
  27444. }
  27445. } finally {
  27446. if (_didIteratorError) {
  27447. throw _iteratorError;
  27448. }
  27449. }
  27450. }
  27451. var typeNames = Object.keys(existingTypesMap).concat(Object.keys(definedTypes));
  27452. return {
  27453. NamedType: function NamedType(node, _1, parent, _2, ancestors) {
  27454. var typeName = node.name.value;
  27455. if (!existingTypesMap[typeName] && !definedTypes[typeName]) {
  27456. var definitionNode = ancestors[2] || parent;
  27457. var isSDL = isSDLNode(definitionNode);
  27458. if (isSDL && isSpecifiedScalarName(typeName)) {
  27459. return;
  27460. }
  27461. var suggestedTypes = (0, _suggestionList.default)(typeName, isSDL ? specifiedScalarsNames.concat(typeNames) : typeNames);
  27462. context.reportError(new _GraphQLError.GraphQLError(unknownTypeMessage(typeName, suggestedTypes), node));
  27463. }
  27464. }
  27465. };
  27466. }
  27467. var specifiedScalarsNames = _scalars.specifiedScalarTypes.map(function (type) {
  27468. return type.name;
  27469. });
  27470. function isSpecifiedScalarName(typeName) {
  27471. return specifiedScalarsNames.indexOf(typeName) !== -1;
  27472. }
  27473. function isSDLNode(value) {
  27474. return Boolean(value && !Array.isArray(value) && ((0, _predicates.isTypeSystemDefinitionNode)(value) || (0, _predicates.isTypeSystemExtensionNode)(value)));
  27475. }
  27476. },{"../../error/GraphQLError":19,"../../jsutils/quotedOrList":46,"../../jsutils/suggestionList":47,"../../language/predicates":55,"../../type/scalars":72}],109:[function(require,module,exports){
  27477. "use strict";
  27478. Object.defineProperty(exports, "__esModule", {
  27479. value: true
  27480. });
  27481. exports.anonOperationNotAloneMessage = anonOperationNotAloneMessage;
  27482. exports.LoneAnonymousOperation = LoneAnonymousOperation;
  27483. var _GraphQLError = require("../../error/GraphQLError");
  27484. var _kinds = require("../../language/kinds");
  27485. /**
  27486. * Copyright (c) Facebook, Inc. and its affiliates.
  27487. *
  27488. * This source code is licensed under the MIT license found in the
  27489. * LICENSE file in the root directory of this source tree.
  27490. *
  27491. *
  27492. */
  27493. function anonOperationNotAloneMessage() {
  27494. return 'This anonymous operation must be the only defined operation.';
  27495. }
  27496. /**
  27497. * Lone anonymous operation
  27498. *
  27499. * A GraphQL document is only valid if when it contains an anonymous operation
  27500. * (the query short-hand) that it contains only that one operation definition.
  27501. */
  27502. function LoneAnonymousOperation(context) {
  27503. var operationCount = 0;
  27504. return {
  27505. Document: function Document(node) {
  27506. operationCount = node.definitions.filter(function (definition) {
  27507. return definition.kind === _kinds.Kind.OPERATION_DEFINITION;
  27508. }).length;
  27509. },
  27510. OperationDefinition: function OperationDefinition(node) {
  27511. if (!node.name && operationCount > 1) {
  27512. context.reportError(new _GraphQLError.GraphQLError(anonOperationNotAloneMessage(), node));
  27513. }
  27514. }
  27515. };
  27516. }
  27517. },{"../../error/GraphQLError":19,"../../language/kinds":51}],110:[function(require,module,exports){
  27518. "use strict";
  27519. Object.defineProperty(exports, "__esModule", {
  27520. value: true
  27521. });
  27522. exports.schemaDefinitionNotAloneMessage = schemaDefinitionNotAloneMessage;
  27523. exports.canNotDefineSchemaWithinExtensionMessage = canNotDefineSchemaWithinExtensionMessage;
  27524. exports.LoneSchemaDefinition = LoneSchemaDefinition;
  27525. var _GraphQLError = require("../../error/GraphQLError");
  27526. /**
  27527. * Copyright (c) Facebook, Inc. and its affiliates.
  27528. *
  27529. * This source code is licensed under the MIT license found in the
  27530. * LICENSE file in the root directory of this source tree.
  27531. *
  27532. *
  27533. */
  27534. function schemaDefinitionNotAloneMessage() {
  27535. return 'Must provide only one schema definition.';
  27536. }
  27537. function canNotDefineSchemaWithinExtensionMessage() {
  27538. return 'Cannot define a new schema within a schema extension.';
  27539. }
  27540. /**
  27541. * Lone Schema definition
  27542. *
  27543. * A GraphQL document is only valid if it contains only one schema definition.
  27544. */
  27545. function LoneSchemaDefinition(context) {
  27546. var oldSchema = context.getSchema();
  27547. var alreadyDefined = oldSchema && (oldSchema.astNode || oldSchema.getQueryType() || oldSchema.getMutationType() || oldSchema.getSubscriptionType());
  27548. var schemaDefinitionsCount = 0;
  27549. return {
  27550. SchemaDefinition: function SchemaDefinition(node) {
  27551. if (alreadyDefined) {
  27552. context.reportError(new _GraphQLError.GraphQLError(canNotDefineSchemaWithinExtensionMessage(), node));
  27553. return;
  27554. }
  27555. if (schemaDefinitionsCount > 0) {
  27556. context.reportError(new _GraphQLError.GraphQLError(schemaDefinitionNotAloneMessage(), node));
  27557. }
  27558. ++schemaDefinitionsCount;
  27559. }
  27560. };
  27561. }
  27562. },{"../../error/GraphQLError":19}],111:[function(require,module,exports){
  27563. "use strict";
  27564. Object.defineProperty(exports, "__esModule", {
  27565. value: true
  27566. });
  27567. exports.cycleErrorMessage = cycleErrorMessage;
  27568. exports.NoFragmentCycles = NoFragmentCycles;
  27569. var _GraphQLError = require("../../error/GraphQLError");
  27570. /**
  27571. * Copyright (c) Facebook, Inc. and its affiliates.
  27572. *
  27573. * This source code is licensed under the MIT license found in the
  27574. * LICENSE file in the root directory of this source tree.
  27575. *
  27576. *
  27577. */
  27578. function cycleErrorMessage(fragName, spreadNames) {
  27579. var via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
  27580. return "Cannot spread fragment \"".concat(fragName, "\" within itself").concat(via, ".");
  27581. }
  27582. function NoFragmentCycles(context) {
  27583. // Tracks already visited fragments to maintain O(N) and to ensure that cycles
  27584. // are not redundantly reported.
  27585. var visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors
  27586. var spreadPath = []; // Position in the spread path
  27587. var spreadPathIndexByName = Object.create(null);
  27588. return {
  27589. OperationDefinition: function OperationDefinition() {
  27590. return false;
  27591. },
  27592. FragmentDefinition: function FragmentDefinition(node) {
  27593. detectCycleRecursive(node);
  27594. return false;
  27595. }
  27596. }; // This does a straight-forward DFS to find cycles.
  27597. // It does not terminate when a cycle was found but continues to explore
  27598. // the graph to find all possible cycles.
  27599. function detectCycleRecursive(fragment) {
  27600. if (visitedFrags[fragment.name.value]) {
  27601. return;
  27602. }
  27603. var fragmentName = fragment.name.value;
  27604. visitedFrags[fragmentName] = true;
  27605. var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
  27606. if (spreadNodes.length === 0) {
  27607. return;
  27608. }
  27609. spreadPathIndexByName[fragmentName] = spreadPath.length;
  27610. for (var i = 0; i < spreadNodes.length; i++) {
  27611. var spreadNode = spreadNodes[i];
  27612. var spreadName = spreadNode.name.value;
  27613. var cycleIndex = spreadPathIndexByName[spreadName];
  27614. spreadPath.push(spreadNode);
  27615. if (cycleIndex === undefined) {
  27616. var spreadFragment = context.getFragment(spreadName);
  27617. if (spreadFragment) {
  27618. detectCycleRecursive(spreadFragment);
  27619. }
  27620. } else {
  27621. var cyclePath = spreadPath.slice(cycleIndex);
  27622. var fragmentNames = cyclePath.slice(0, -1).map(function (s) {
  27623. return s.name.value;
  27624. });
  27625. context.reportError(new _GraphQLError.GraphQLError(cycleErrorMessage(spreadName, fragmentNames), cyclePath));
  27626. }
  27627. spreadPath.pop();
  27628. }
  27629. spreadPathIndexByName[fragmentName] = undefined;
  27630. }
  27631. }
  27632. },{"../../error/GraphQLError":19}],112:[function(require,module,exports){
  27633. "use strict";
  27634. Object.defineProperty(exports, "__esModule", {
  27635. value: true
  27636. });
  27637. exports.undefinedVarMessage = undefinedVarMessage;
  27638. exports.NoUndefinedVariables = NoUndefinedVariables;
  27639. var _GraphQLError = require("../../error/GraphQLError");
  27640. /**
  27641. * Copyright (c) Facebook, Inc. and its affiliates.
  27642. *
  27643. * This source code is licensed under the MIT license found in the
  27644. * LICENSE file in the root directory of this source tree.
  27645. *
  27646. *
  27647. */
  27648. function undefinedVarMessage(varName, opName) {
  27649. return opName ? "Variable \"$".concat(varName, "\" is not defined by operation \"").concat(opName, "\".") : "Variable \"$".concat(varName, "\" is not defined.");
  27650. }
  27651. /**
  27652. * No undefined variables
  27653. *
  27654. * A GraphQL operation is only valid if all variables encountered, both directly
  27655. * and via fragment spreads, are defined by that operation.
  27656. */
  27657. function NoUndefinedVariables(context) {
  27658. var variableNameDefined = Object.create(null);
  27659. return {
  27660. OperationDefinition: {
  27661. enter: function enter() {
  27662. variableNameDefined = Object.create(null);
  27663. },
  27664. leave: function leave(operation) {
  27665. var usages = context.getRecursiveVariableUsages(operation);
  27666. var _iteratorNormalCompletion = true;
  27667. var _didIteratorError = false;
  27668. var _iteratorError = undefined;
  27669. try {
  27670. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27671. var _ref2 = _step.value;
  27672. var node = _ref2.node;
  27673. var varName = node.name.value;
  27674. if (variableNameDefined[varName] !== true) {
  27675. context.reportError(new _GraphQLError.GraphQLError(undefinedVarMessage(varName, operation.name && operation.name.value), [node, operation]));
  27676. }
  27677. }
  27678. } catch (err) {
  27679. _didIteratorError = true;
  27680. _iteratorError = err;
  27681. } finally {
  27682. try {
  27683. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27684. _iterator.return();
  27685. }
  27686. } finally {
  27687. if (_didIteratorError) {
  27688. throw _iteratorError;
  27689. }
  27690. }
  27691. }
  27692. }
  27693. },
  27694. VariableDefinition: function VariableDefinition(node) {
  27695. variableNameDefined[node.variable.name.value] = true;
  27696. }
  27697. };
  27698. }
  27699. },{"../../error/GraphQLError":19}],113:[function(require,module,exports){
  27700. "use strict";
  27701. Object.defineProperty(exports, "__esModule", {
  27702. value: true
  27703. });
  27704. exports.unusedFragMessage = unusedFragMessage;
  27705. exports.NoUnusedFragments = NoUnusedFragments;
  27706. var _GraphQLError = require("../../error/GraphQLError");
  27707. /**
  27708. * Copyright (c) Facebook, Inc. and its affiliates.
  27709. *
  27710. * This source code is licensed under the MIT license found in the
  27711. * LICENSE file in the root directory of this source tree.
  27712. *
  27713. *
  27714. */
  27715. function unusedFragMessage(fragName) {
  27716. return "Fragment \"".concat(fragName, "\" is never used.");
  27717. }
  27718. /**
  27719. * No unused fragments
  27720. *
  27721. * A GraphQL document is only valid if all fragment definitions are spread
  27722. * within operations, or spread within other fragments spread within operations.
  27723. */
  27724. function NoUnusedFragments(context) {
  27725. var operationDefs = [];
  27726. var fragmentDefs = [];
  27727. return {
  27728. OperationDefinition: function OperationDefinition(node) {
  27729. operationDefs.push(node);
  27730. return false;
  27731. },
  27732. FragmentDefinition: function FragmentDefinition(node) {
  27733. fragmentDefs.push(node);
  27734. return false;
  27735. },
  27736. Document: {
  27737. leave: function leave() {
  27738. var fragmentNameUsed = Object.create(null);
  27739. for (var _i = 0, _operationDefs = operationDefs; _i < _operationDefs.length; _i++) {
  27740. var operation = _operationDefs[_i];
  27741. var _iteratorNormalCompletion = true;
  27742. var _didIteratorError = false;
  27743. var _iteratorError = undefined;
  27744. try {
  27745. for (var _iterator = context.getRecursivelyReferencedFragments(operation)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27746. var fragment = _step.value;
  27747. fragmentNameUsed[fragment.name.value] = true;
  27748. }
  27749. } catch (err) {
  27750. _didIteratorError = true;
  27751. _iteratorError = err;
  27752. } finally {
  27753. try {
  27754. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27755. _iterator.return();
  27756. }
  27757. } finally {
  27758. if (_didIteratorError) {
  27759. throw _iteratorError;
  27760. }
  27761. }
  27762. }
  27763. }
  27764. for (var _i2 = 0, _fragmentDefs = fragmentDefs; _i2 < _fragmentDefs.length; _i2++) {
  27765. var fragmentDef = _fragmentDefs[_i2];
  27766. var fragName = fragmentDef.name.value;
  27767. if (fragmentNameUsed[fragName] !== true) {
  27768. context.reportError(new _GraphQLError.GraphQLError(unusedFragMessage(fragName), fragmentDef));
  27769. }
  27770. }
  27771. }
  27772. }
  27773. };
  27774. }
  27775. },{"../../error/GraphQLError":19}],114:[function(require,module,exports){
  27776. "use strict";
  27777. Object.defineProperty(exports, "__esModule", {
  27778. value: true
  27779. });
  27780. exports.unusedVariableMessage = unusedVariableMessage;
  27781. exports.NoUnusedVariables = NoUnusedVariables;
  27782. var _GraphQLError = require("../../error/GraphQLError");
  27783. /**
  27784. * Copyright (c) Facebook, Inc. and its affiliates.
  27785. *
  27786. * This source code is licensed under the MIT license found in the
  27787. * LICENSE file in the root directory of this source tree.
  27788. *
  27789. *
  27790. */
  27791. function unusedVariableMessage(varName, opName) {
  27792. return opName ? "Variable \"$".concat(varName, "\" is never used in operation \"").concat(opName, "\".") : "Variable \"$".concat(varName, "\" is never used.");
  27793. }
  27794. /**
  27795. * No unused variables
  27796. *
  27797. * A GraphQL operation is only valid if all variables defined by an operation
  27798. * are used, either directly or within a spread fragment.
  27799. */
  27800. function NoUnusedVariables(context) {
  27801. var variableDefs = [];
  27802. return {
  27803. OperationDefinition: {
  27804. enter: function enter() {
  27805. variableDefs = [];
  27806. },
  27807. leave: function leave(operation) {
  27808. var variableNameUsed = Object.create(null);
  27809. var usages = context.getRecursiveVariableUsages(operation);
  27810. var opName = operation.name ? operation.name.value : null;
  27811. var _iteratorNormalCompletion = true;
  27812. var _didIteratorError = false;
  27813. var _iteratorError = undefined;
  27814. try {
  27815. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27816. var _ref2 = _step.value;
  27817. var node = _ref2.node;
  27818. variableNameUsed[node.name.value] = true;
  27819. }
  27820. } catch (err) {
  27821. _didIteratorError = true;
  27822. _iteratorError = err;
  27823. } finally {
  27824. try {
  27825. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27826. _iterator.return();
  27827. }
  27828. } finally {
  27829. if (_didIteratorError) {
  27830. throw _iteratorError;
  27831. }
  27832. }
  27833. }
  27834. for (var _i = 0, _variableDefs = variableDefs; _i < _variableDefs.length; _i++) {
  27835. var variableDef = _variableDefs[_i];
  27836. var variableName = variableDef.variable.name.value;
  27837. if (variableNameUsed[variableName] !== true) {
  27838. context.reportError(new _GraphQLError.GraphQLError(unusedVariableMessage(variableName, opName), variableDef));
  27839. }
  27840. }
  27841. }
  27842. },
  27843. VariableDefinition: function VariableDefinition(def) {
  27844. variableDefs.push(def);
  27845. }
  27846. };
  27847. }
  27848. },{"../../error/GraphQLError":19}],115:[function(require,module,exports){
  27849. "use strict";
  27850. Object.defineProperty(exports, "__esModule", {
  27851. value: true
  27852. });
  27853. exports.fieldsConflictMessage = fieldsConflictMessage;
  27854. exports.OverlappingFieldsCanBeMerged = OverlappingFieldsCanBeMerged;
  27855. var _find = _interopRequireDefault(require("../../polyfills/find"));
  27856. var _objectEntries = _interopRequireDefault(require("../../polyfills/objectEntries"));
  27857. var _GraphQLError = require("../../error/GraphQLError");
  27858. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  27859. var _kinds = require("../../language/kinds");
  27860. var _printer = require("../../language/printer");
  27861. var _definition = require("../../type/definition");
  27862. var _typeFromAST = require("../../utilities/typeFromAST");
  27863. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27864. /**
  27865. * Copyright (c) Facebook, Inc. and its affiliates.
  27866. *
  27867. * This source code is licensed under the MIT license found in the
  27868. * LICENSE file in the root directory of this source tree.
  27869. *
  27870. *
  27871. */
  27872. function fieldsConflictMessage(responseName, reason) {
  27873. return "Fields \"".concat(responseName, "\" conflict because ").concat(reasonMessage(reason), ". ") + 'Use different aliases on the fields to fetch both if this was intentional.';
  27874. }
  27875. function reasonMessage(reason) {
  27876. if (Array.isArray(reason)) {
  27877. return reason.map(function (_ref) {
  27878. var responseName = _ref[0],
  27879. subreason = _ref[1];
  27880. return "subfields \"".concat(responseName, "\" conflict because ").concat(reasonMessage(subreason));
  27881. }).join(' and ');
  27882. }
  27883. return reason;
  27884. }
  27885. /**
  27886. * Overlapping fields can be merged
  27887. *
  27888. * A selection set is only valid if all fields (including spreading any
  27889. * fragments) either correspond to distinct response names or can be merged
  27890. * without ambiguity.
  27891. */
  27892. function OverlappingFieldsCanBeMerged(context) {
  27893. // A memoization for when two fragments are compared "between" each other for
  27894. // conflicts. Two fragments may be compared many times, so memoizing this can
  27895. // dramatically improve the performance of this validator.
  27896. var comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given
  27897. // selection set. Selection sets may be asked for this information multiple
  27898. // times, so this improves the performance of this validator.
  27899. var cachedFieldsAndFragmentNames = new Map();
  27900. return {
  27901. SelectionSet: function SelectionSet(selectionSet) {
  27902. var conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.getParentType(), selectionSet);
  27903. for (var _i = 0, _conflicts = conflicts; _i < _conflicts.length; _i++) {
  27904. var _ref3 = _conflicts[_i];
  27905. var _ref2$ = _ref3[0];
  27906. var responseName = _ref2$[0];
  27907. var reason = _ref2$[1];
  27908. var fields1 = _ref3[1];
  27909. var fields2 = _ref3[2];
  27910. context.reportError(new _GraphQLError.GraphQLError(fieldsConflictMessage(responseName, reason), fields1.concat(fields2)));
  27911. }
  27912. }
  27913. };
  27914. }
  27915. /**
  27916. * Algorithm:
  27917. *
  27918. * Conflicts occur when two fields exist in a query which will produce the same
  27919. * response name, but represent differing values, thus creating a conflict.
  27920. * The algorithm below finds all conflicts via making a series of comparisons
  27921. * between fields. In order to compare as few fields as possible, this makes
  27922. * a series of comparisons "within" sets of fields and "between" sets of fields.
  27923. *
  27924. * Given any selection set, a collection produces both a set of fields by
  27925. * also including all inline fragments, as well as a list of fragments
  27926. * referenced by fragment spreads.
  27927. *
  27928. * A) Each selection set represented in the document first compares "within" its
  27929. * collected set of fields, finding any conflicts between every pair of
  27930. * overlapping fields.
  27931. * Note: This is the *only time* that a the fields "within" a set are compared
  27932. * to each other. After this only fields "between" sets are compared.
  27933. *
  27934. * B) Also, if any fragment is referenced in a selection set, then a
  27935. * comparison is made "between" the original set of fields and the
  27936. * referenced fragment.
  27937. *
  27938. * C) Also, if multiple fragments are referenced, then comparisons
  27939. * are made "between" each referenced fragment.
  27940. *
  27941. * D) When comparing "between" a set of fields and a referenced fragment, first
  27942. * a comparison is made between each field in the original set of fields and
  27943. * each field in the the referenced set of fields.
  27944. *
  27945. * E) Also, if any fragment is referenced in the referenced selection set,
  27946. * then a comparison is made "between" the original set of fields and the
  27947. * referenced fragment (recursively referring to step D).
  27948. *
  27949. * F) When comparing "between" two fragments, first a comparison is made between
  27950. * each field in the first referenced set of fields and each field in the the
  27951. * second referenced set of fields.
  27952. *
  27953. * G) Also, any fragments referenced by the first must be compared to the
  27954. * second, and any fragments referenced by the second must be compared to the
  27955. * first (recursively referring to step F).
  27956. *
  27957. * H) When comparing two fields, if both have selection sets, then a comparison
  27958. * is made "between" both selection sets, first comparing the set of fields in
  27959. * the first selection set with the set of fields in the second.
  27960. *
  27961. * I) Also, if any fragment is referenced in either selection set, then a
  27962. * comparison is made "between" the other set of fields and the
  27963. * referenced fragment.
  27964. *
  27965. * J) Also, if two fragments are referenced in both selection sets, then a
  27966. * comparison is made "between" the two fragments.
  27967. *
  27968. */
  27969. // Find all conflicts found "within" a selection set, including those found
  27970. // via spreading in fragments. Called when visiting each SelectionSet in the
  27971. // GraphQL Document.
  27972. function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentType, selectionSet) {
  27973. var conflicts = [];
  27974. var _getFieldsAndFragment = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet),
  27975. fieldMap = _getFieldsAndFragment[0],
  27976. fragmentNames = _getFieldsAndFragment[1]; // (A) Find find all conflicts "within" the fields of this selection set.
  27977. // Note: this is the *only place* `collectConflictsWithin` is called.
  27978. collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap);
  27979. if (fragmentNames.length !== 0) {
  27980. // (B) Then collect conflicts between these fields and those represented by
  27981. // each spread fragment name found.
  27982. var comparedFragments = Object.create(null);
  27983. for (var i = 0; i < fragmentNames.length; i++) {
  27984. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, false, fieldMap, fragmentNames[i]); // (C) Then compare this fragment with all other fragments found in this
  27985. // selection set to collect conflicts between fragments spread together.
  27986. // This compares each item in the list of fragment names to every other
  27987. // item in that same list (except for itself).
  27988. for (var j = i + 1; j < fragmentNames.length; j++) {
  27989. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fragmentNames[i], fragmentNames[j]);
  27990. }
  27991. }
  27992. }
  27993. return conflicts;
  27994. } // Collect all conflicts found between a set of fields and a fragment reference
  27995. // including via spreading in any nested fragments.
  27996. function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
  27997. // Memoize so a fragment is not compared for conflicts more than once.
  27998. if (comparedFragments[fragmentName]) {
  27999. return;
  28000. }
  28001. comparedFragments[fragmentName] = true;
  28002. var fragment = context.getFragment(fragmentName);
  28003. if (!fragment) {
  28004. return;
  28005. }
  28006. var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment),
  28007. fieldMap2 = _getReferencedFieldsA[0],
  28008. fragmentNames2 = _getReferencedFieldsA[1]; // Do not compare a fragment's fieldMap to itself.
  28009. if (fieldMap === fieldMap2) {
  28010. return;
  28011. } // (D) First collect any conflicts between the provided collection of fields
  28012. // and the collection of fields represented by the given fragment.
  28013. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fieldMap2); // (E) Then collect any conflicts between the provided collection of fields
  28014. // and any fragment names found in the given fragment.
  28015. for (var i = 0; i < fragmentNames2.length; i++) {
  28016. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentNames2[i]);
  28017. }
  28018. } // Collect all conflicts found between two fragments, including via spreading in
  28019. // any nested fragments.
  28020. function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentName2) {
  28021. // No need to compare a fragment to itself.
  28022. if (fragmentName1 === fragmentName2) {
  28023. return;
  28024. } // Memoize so two fragments are not compared for conflicts more than once.
  28025. if (comparedFragmentPairs.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {
  28026. return;
  28027. }
  28028. comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive);
  28029. var fragment1 = context.getFragment(fragmentName1);
  28030. var fragment2 = context.getFragment(fragmentName2);
  28031. if (!fragment1 || !fragment2) {
  28032. return;
  28033. }
  28034. var _getReferencedFieldsA2 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1),
  28035. fieldMap1 = _getReferencedFieldsA2[0],
  28036. fragmentNames1 = _getReferencedFieldsA2[1];
  28037. var _getReferencedFieldsA3 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2),
  28038. fieldMap2 = _getReferencedFieldsA3[0],
  28039. fragmentNames2 = _getReferencedFieldsA3[1]; // (F) First, collect all conflicts between these two collections of fields
  28040. // (not including any nested fragments).
  28041. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (G) Then collect conflicts between the first fragment and any nested
  28042. // fragments spread in the second fragment.
  28043. for (var j = 0; j < fragmentNames2.length; j++) {
  28044. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);
  28045. } // (G) Then collect conflicts between the second fragment and any nested
  28046. // fragments spread in the first fragment.
  28047. for (var i = 0; i < fragmentNames1.length; i++) {
  28048. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentName2);
  28049. }
  28050. } // Find all conflicts found between two selection sets, including those found
  28051. // via spreading in fragments. Called when determining if conflicts exist
  28052. // between the sub-fields of two overlapping fields.
  28053. function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {
  28054. var conflicts = [];
  28055. var _getFieldsAndFragment2 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1),
  28056. fieldMap1 = _getFieldsAndFragment2[0],
  28057. fragmentNames1 = _getFieldsAndFragment2[1];
  28058. var _getFieldsAndFragment3 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2),
  28059. fieldMap2 = _getFieldsAndFragment3[0],
  28060. fragmentNames2 = _getFieldsAndFragment3[1]; // (H) First, collect all conflicts between these two collections of field.
  28061. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (I) Then collect conflicts between the first collection of fields and
  28062. // those referenced by each fragment name associated with the second.
  28063. if (fragmentNames2.length !== 0) {
  28064. var comparedFragments = Object.create(null);
  28065. for (var j = 0; j < fragmentNames2.length; j++) {
  28066. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);
  28067. }
  28068. } // (I) Then collect conflicts between the second collection of fields and
  28069. // those referenced by each fragment name associated with the first.
  28070. if (fragmentNames1.length !== 0) {
  28071. var _comparedFragments = Object.create(null);
  28072. for (var i = 0; i < fragmentNames1.length; i++) {
  28073. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, _comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);
  28074. }
  28075. } // (J) Also collect conflicts between any fragment names by the first and
  28076. // fragment names by the second. This compares each item in the first set of
  28077. // names to each item in the second set of names.
  28078. for (var _i2 = 0; _i2 < fragmentNames1.length; _i2++) {
  28079. for (var _j = 0; _j < fragmentNames2.length; _j++) {
  28080. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[_i2], fragmentNames2[_j]);
  28081. }
  28082. }
  28083. return conflicts;
  28084. } // Collect all Conflicts "within" one collection of fields.
  28085. function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap) {
  28086. // A field map is a keyed collection, where each key represents a response
  28087. // name and the value at that key is a list of all fields which provide that
  28088. // response name. For every response name, if there are multiple fields, they
  28089. // must be compared to find a potential conflict.
  28090. var _iteratorNormalCompletion = true;
  28091. var _didIteratorError = false;
  28092. var _iteratorError = undefined;
  28093. try {
  28094. for (var _iterator = (0, _objectEntries.default)(fieldMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28095. var _ref5 = _step.value;
  28096. var responseName = _ref5[0];
  28097. var fields = _ref5[1];
  28098. // This compares every field in the list to every other field in this list
  28099. // (except to itself). If the list only has one item, nothing needs to
  28100. // be compared.
  28101. if (fields.length > 1) {
  28102. for (var i = 0; i < fields.length; i++) {
  28103. for (var j = i + 1; j < fields.length; j++) {
  28104. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, // within one collection is never mutually exclusive
  28105. responseName, fields[i], fields[j]);
  28106. if (conflict) {
  28107. conflicts.push(conflict);
  28108. }
  28109. }
  28110. }
  28111. }
  28112. }
  28113. } catch (err) {
  28114. _didIteratorError = true;
  28115. _iteratorError = err;
  28116. } finally {
  28117. try {
  28118. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28119. _iterator.return();
  28120. }
  28121. } finally {
  28122. if (_didIteratorError) {
  28123. throw _iteratorError;
  28124. }
  28125. }
  28126. }
  28127. } // Collect all Conflicts between two collections of fields. This is similar to,
  28128. // but different from the `collectConflictsWithin` function above. This check
  28129. // assumes that `collectConflictsWithin` has already been called on each
  28130. // provided collection of fields. This is true because this validator traverses
  28131. // each individual selection set.
  28132. function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {
  28133. // A field map is a keyed collection, where each key represents a response
  28134. // name and the value at that key is a list of all fields which provide that
  28135. // response name. For any response name which appears in both provided field
  28136. // maps, each field from the first field map must be compared to every field
  28137. // in the second field map to find potential conflicts.
  28138. for (var _i3 = 0, _Object$keys = Object.keys(fieldMap1); _i3 < _Object$keys.length; _i3++) {
  28139. var responseName = _Object$keys[_i3];
  28140. var fields2 = fieldMap2[responseName];
  28141. if (fields2) {
  28142. var fields1 = fieldMap1[responseName];
  28143. for (var i = 0; i < fields1.length; i++) {
  28144. for (var j = 0; j < fields2.length; j++) {
  28145. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);
  28146. if (conflict) {
  28147. conflicts.push(conflict);
  28148. }
  28149. }
  28150. }
  28151. }
  28152. }
  28153. } // Determines if there is a conflict between two particular fields, including
  28154. // comparing their sub-fields.
  28155. function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {
  28156. var parentType1 = field1[0],
  28157. node1 = field1[1],
  28158. def1 = field1[2];
  28159. var parentType2 = field2[0],
  28160. node2 = field2[1],
  28161. def2 = field2[2]; // If it is known that two fields could not possibly apply at the same
  28162. // time, due to the parent types, then it is safe to permit them to diverge
  28163. // in aliased field or arguments used as they will not present any ambiguity
  28164. // by differing.
  28165. // It is known that two parent types could never overlap if they are
  28166. // different Object types. Interface or Union types might overlap - if not
  28167. // in the current state of the schema, then perhaps in some future version,
  28168. // thus may not safely diverge.
  28169. var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && (0, _definition.isObjectType)(parentType1) && (0, _definition.isObjectType)(parentType2); // The return type for each field.
  28170. var type1 = def1 && def1.type;
  28171. var type2 = def2 && def2.type;
  28172. if (!areMutuallyExclusive) {
  28173. // Two aliases must refer to the same field.
  28174. var name1 = node1.name.value;
  28175. var name2 = node2.name.value;
  28176. if (name1 !== name2) {
  28177. return [[responseName, "".concat(name1, " and ").concat(name2, " are different fields")], [node1], [node2]];
  28178. } // Two field calls must have the same arguments.
  28179. if (!sameArguments(node1.arguments || [], node2.arguments || [])) {
  28180. return [[responseName, 'they have differing arguments'], [node1], [node2]];
  28181. }
  28182. }
  28183. if (type1 && type2 && doTypesConflict(type1, type2)) {
  28184. return [[responseName, "they return conflicting types ".concat((0, _inspect.default)(type1), " and ").concat((0, _inspect.default)(type2))], [node1], [node2]];
  28185. } // Collect and compare sub-fields. Use the same "visited fragment names" list
  28186. // for both collections so fields in a fragment reference are never
  28187. // compared to themselves.
  28188. var selectionSet1 = node1.selectionSet;
  28189. var selectionSet2 = node2.selectionSet;
  28190. if (selectionSet1 && selectionSet2) {
  28191. var conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, (0, _definition.getNamedType)(type1), selectionSet1, (0, _definition.getNamedType)(type2), selectionSet2);
  28192. return subfieldConflicts(conflicts, responseName, node1, node2);
  28193. }
  28194. }
  28195. function sameArguments(arguments1, arguments2) {
  28196. if (arguments1.length !== arguments2.length) {
  28197. return false;
  28198. }
  28199. return arguments1.every(function (argument1) {
  28200. var argument2 = (0, _find.default)(arguments2, function (argument) {
  28201. return argument.name.value === argument1.name.value;
  28202. });
  28203. if (!argument2) {
  28204. return false;
  28205. }
  28206. return sameValue(argument1.value, argument2.value);
  28207. });
  28208. }
  28209. function sameValue(value1, value2) {
  28210. return !value1 && !value2 || (0, _printer.print)(value1) === (0, _printer.print)(value2);
  28211. } // Two types conflict if both types could not apply to a value simultaneously.
  28212. // Composite types are ignored as their individual field types will be compared
  28213. // later recursively. However List and Non-Null types must match.
  28214. function doTypesConflict(type1, type2) {
  28215. if ((0, _definition.isListType)(type1)) {
  28216. return (0, _definition.isListType)(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;
  28217. }
  28218. if ((0, _definition.isListType)(type2)) {
  28219. return true;
  28220. }
  28221. if ((0, _definition.isNonNullType)(type1)) {
  28222. return (0, _definition.isNonNullType)(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;
  28223. }
  28224. if ((0, _definition.isNonNullType)(type2)) {
  28225. return true;
  28226. }
  28227. if ((0, _definition.isLeafType)(type1) || (0, _definition.isLeafType)(type2)) {
  28228. return type1 !== type2;
  28229. }
  28230. return false;
  28231. } // Given a selection set, return the collection of fields (a mapping of response
  28232. // name to field nodes and definitions) as well as a list of fragment names
  28233. // referenced via fragment spreads.
  28234. function getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {
  28235. var cached = cachedFieldsAndFragmentNames.get(selectionSet);
  28236. if (!cached) {
  28237. var nodeAndDefs = Object.create(null);
  28238. var fragmentNames = Object.create(null);
  28239. _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);
  28240. cached = [nodeAndDefs, Object.keys(fragmentNames)];
  28241. cachedFieldsAndFragmentNames.set(selectionSet, cached);
  28242. }
  28243. return cached;
  28244. } // Given a reference to a fragment, return the represented collection of fields
  28245. // as well as a list of nested fragment names referenced via fragment spreads.
  28246. function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
  28247. // Short-circuit building a type from the node if possible.
  28248. var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
  28249. if (cached) {
  28250. return cached;
  28251. }
  28252. var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
  28253. return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
  28254. }
  28255. function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
  28256. for (var i = 0; i < selectionSet.selections.length; i++) {
  28257. var selection = selectionSet.selections[i];
  28258. switch (selection.kind) {
  28259. case _kinds.Kind.FIELD:
  28260. {
  28261. var fieldName = selection.name.value;
  28262. var fieldDef = void 0;
  28263. if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
  28264. fieldDef = parentType.getFields()[fieldName];
  28265. }
  28266. var responseName = selection.alias ? selection.alias.value : fieldName;
  28267. if (!nodeAndDefs[responseName]) {
  28268. nodeAndDefs[responseName] = [];
  28269. }
  28270. nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
  28271. break;
  28272. }
  28273. case _kinds.Kind.FRAGMENT_SPREAD:
  28274. fragmentNames[selection.name.value] = true;
  28275. break;
  28276. case _kinds.Kind.INLINE_FRAGMENT:
  28277. {
  28278. var typeCondition = selection.typeCondition;
  28279. var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
  28280. _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
  28281. break;
  28282. }
  28283. }
  28284. }
  28285. } // Given a series of Conflicts which occurred between two sub-fields, generate
  28286. // a single Conflict.
  28287. function subfieldConflicts(conflicts, responseName, node1, node2) {
  28288. if (conflicts.length > 0) {
  28289. return [[responseName, conflicts.map(function (_ref6) {
  28290. var reason = _ref6[0];
  28291. return reason;
  28292. })], conflicts.reduce(function (allFields, _ref7) {
  28293. var fields1 = _ref7[1];
  28294. return allFields.concat(fields1);
  28295. }, [node1]), conflicts.reduce(function (allFields, _ref8) {
  28296. var fields2 = _ref8[2];
  28297. return allFields.concat(fields2);
  28298. }, [node2])];
  28299. }
  28300. }
  28301. /**
  28302. * A way to keep track of pairs of things when the ordering of the pair does
  28303. * not matter. We do this by maintaining a sort of double adjacency sets.
  28304. */
  28305. var PairSet =
  28306. /*#__PURE__*/
  28307. function () {
  28308. function PairSet() {
  28309. this._data = Object.create(null);
  28310. }
  28311. var _proto = PairSet.prototype;
  28312. _proto.has = function has(a, b, areMutuallyExclusive) {
  28313. var first = this._data[a];
  28314. var result = first && first[b];
  28315. if (result === undefined) {
  28316. return false;
  28317. } // areMutuallyExclusive being false is a superset of being true,
  28318. // hence if we want to know if this PairSet "has" these two with no
  28319. // exclusivity, we have to ensure it was added as such.
  28320. if (areMutuallyExclusive === false) {
  28321. return result === false;
  28322. }
  28323. return true;
  28324. };
  28325. _proto.add = function add(a, b, areMutuallyExclusive) {
  28326. _pairSetAdd(this._data, a, b, areMutuallyExclusive);
  28327. _pairSetAdd(this._data, b, a, areMutuallyExclusive);
  28328. };
  28329. return PairSet;
  28330. }();
  28331. function _pairSetAdd(data, a, b, areMutuallyExclusive) {
  28332. var map = data[a];
  28333. if (!map) {
  28334. map = Object.create(null);
  28335. data[a] = map;
  28336. }
  28337. map[b] = areMutuallyExclusive;
  28338. }
  28339. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../language/kinds":51,"../../language/printer":56,"../../polyfills/find":59,"../../polyfills/objectEntries":63,"../../type/definition":68,"../../utilities/typeFromAST":97}],116:[function(require,module,exports){
  28340. "use strict";
  28341. Object.defineProperty(exports, "__esModule", {
  28342. value: true
  28343. });
  28344. exports.typeIncompatibleSpreadMessage = typeIncompatibleSpreadMessage;
  28345. exports.typeIncompatibleAnonSpreadMessage = typeIncompatibleAnonSpreadMessage;
  28346. exports.PossibleFragmentSpreads = PossibleFragmentSpreads;
  28347. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  28348. var _GraphQLError = require("../../error/GraphQLError");
  28349. var _typeComparators = require("../../utilities/typeComparators");
  28350. var _typeFromAST = require("../../utilities/typeFromAST");
  28351. var _definition = require("../../type/definition");
  28352. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28353. /**
  28354. * Copyright (c) Facebook, Inc. and its affiliates.
  28355. *
  28356. * This source code is licensed under the MIT license found in the
  28357. * LICENSE file in the root directory of this source tree.
  28358. *
  28359. *
  28360. */
  28361. function typeIncompatibleSpreadMessage(fragName, parentType, fragType) {
  28362. return "Fragment \"".concat(fragName, "\" cannot be spread here as objects of ") + "type \"".concat(parentType, "\" can never be of type \"").concat(fragType, "\".");
  28363. }
  28364. function typeIncompatibleAnonSpreadMessage(parentType, fragType) {
  28365. return 'Fragment cannot be spread here as objects of ' + "type \"".concat(parentType, "\" can never be of type \"").concat(fragType, "\".");
  28366. }
  28367. /**
  28368. * Possible fragment spread
  28369. *
  28370. * A fragment spread is only valid if the type condition could ever possibly
  28371. * be true: if there is a non-empty intersection of the possible parent types,
  28372. * and possible types which pass the type condition.
  28373. */
  28374. function PossibleFragmentSpreads(context) {
  28375. return {
  28376. InlineFragment: function InlineFragment(node) {
  28377. var fragType = context.getType();
  28378. var parentType = context.getParentType();
  28379. if ((0, _definition.isCompositeType)(fragType) && (0, _definition.isCompositeType)(parentType) && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  28380. context.reportError(new _GraphQLError.GraphQLError(typeIncompatibleAnonSpreadMessage((0, _inspect.default)(parentType), (0, _inspect.default)(fragType)), node));
  28381. }
  28382. },
  28383. FragmentSpread: function FragmentSpread(node) {
  28384. var fragName = node.name.value;
  28385. var fragType = getFragmentType(context, fragName);
  28386. var parentType = context.getParentType();
  28387. if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  28388. context.reportError(new _GraphQLError.GraphQLError(typeIncompatibleSpreadMessage(fragName, (0, _inspect.default)(parentType), (0, _inspect.default)(fragType)), node));
  28389. }
  28390. }
  28391. };
  28392. }
  28393. function getFragmentType(context, name) {
  28394. var frag = context.getFragment(name);
  28395. if (frag) {
  28396. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition);
  28397. if ((0, _definition.isCompositeType)(type)) {
  28398. return type;
  28399. }
  28400. }
  28401. }
  28402. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../type/definition":68,"../../utilities/typeComparators":96,"../../utilities/typeFromAST":97}],117:[function(require,module,exports){
  28403. "use strict";
  28404. Object.defineProperty(exports, "__esModule", {
  28405. value: true
  28406. });
  28407. exports.extendingUnknownTypeMessage = extendingUnknownTypeMessage;
  28408. exports.extendingDifferentTypeKindMessage = extendingDifferentTypeKindMessage;
  28409. exports.PossibleTypeExtensions = PossibleTypeExtensions;
  28410. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  28411. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  28412. var _GraphQLError = require("../../error/GraphQLError");
  28413. var _kinds = require("../../language/kinds");
  28414. var _predicates = require("../../language/predicates");
  28415. var _definition = require("../../type/definition");
  28416. var _defKindToExtKind;
  28417. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28418. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  28419. function extendingUnknownTypeMessage(typeName, suggestedTypes) {
  28420. var message = "Cannot extend type \"".concat(typeName, "\" because it is not defined.");
  28421. if (suggestedTypes.length) {
  28422. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedTypes), "?");
  28423. }
  28424. return message;
  28425. }
  28426. function extendingDifferentTypeKindMessage(typeName, kind) {
  28427. return "Cannot extend non-".concat(kind, " type \"").concat(typeName, "\".");
  28428. }
  28429. /**
  28430. * Possible type extension
  28431. *
  28432. * A type extension is only valid if the type is defined and has the same kind.
  28433. */
  28434. function PossibleTypeExtensions(context) {
  28435. var schema = context.getSchema();
  28436. var definedTypes = Object.create(null);
  28437. var _iteratorNormalCompletion = true;
  28438. var _didIteratorError = false;
  28439. var _iteratorError = undefined;
  28440. try {
  28441. for (var _iterator = context.getDocument().definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28442. var def = _step.value;
  28443. if ((0, _predicates.isTypeDefinitionNode)(def)) {
  28444. definedTypes[def.name.value] = def;
  28445. }
  28446. }
  28447. } catch (err) {
  28448. _didIteratorError = true;
  28449. _iteratorError = err;
  28450. } finally {
  28451. try {
  28452. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28453. _iterator.return();
  28454. }
  28455. } finally {
  28456. if (_didIteratorError) {
  28457. throw _iteratorError;
  28458. }
  28459. }
  28460. }
  28461. return {
  28462. ScalarTypeExtension: checkExtension,
  28463. ObjectTypeExtension: checkExtension,
  28464. InterfaceTypeExtension: checkExtension,
  28465. UnionTypeExtension: checkExtension,
  28466. EnumTypeExtension: checkExtension,
  28467. InputObjectTypeExtension: checkExtension
  28468. };
  28469. function checkExtension(node) {
  28470. var typeName = node.name.value;
  28471. var defNode = definedTypes[typeName];
  28472. var existingType = schema && schema.getType(typeName);
  28473. if (defNode) {
  28474. var expectedKind = defKindToExtKind[defNode.kind];
  28475. if (expectedKind !== node.kind) {
  28476. context.reportError(new _GraphQLError.GraphQLError(extendingDifferentTypeKindMessage(typeName, extensionKindToTypeName(expectedKind)), [defNode, node]));
  28477. }
  28478. } else if (existingType) {
  28479. var _expectedKind = typeToExtKind(existingType);
  28480. if (_expectedKind !== node.kind) {
  28481. context.reportError(new _GraphQLError.GraphQLError(extendingDifferentTypeKindMessage(typeName, extensionKindToTypeName(_expectedKind)), node));
  28482. }
  28483. } else {
  28484. var allTypeNames = Object.keys(definedTypes);
  28485. if (schema) {
  28486. allTypeNames = allTypeNames.concat(Object.keys(schema.getTypeMap()));
  28487. }
  28488. var suggestedTypes = (0, _suggestionList.default)(typeName, allTypeNames);
  28489. context.reportError(new _GraphQLError.GraphQLError(extendingUnknownTypeMessage(typeName, suggestedTypes), node.name));
  28490. }
  28491. }
  28492. }
  28493. var defKindToExtKind = (_defKindToExtKind = {}, _defineProperty(_defKindToExtKind, _kinds.Kind.SCALAR_TYPE_DEFINITION, _kinds.Kind.SCALAR_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.OBJECT_TYPE_DEFINITION, _kinds.Kind.OBJECT_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.INTERFACE_TYPE_DEFINITION, _kinds.Kind.INTERFACE_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.UNION_TYPE_DEFINITION, _kinds.Kind.UNION_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.ENUM_TYPE_DEFINITION, _kinds.Kind.ENUM_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION, _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION), _defKindToExtKind);
  28494. function typeToExtKind(type) {
  28495. if ((0, _definition.isScalarType)(type)) {
  28496. return _kinds.Kind.SCALAR_TYPE_EXTENSION;
  28497. } else if ((0, _definition.isObjectType)(type)) {
  28498. return _kinds.Kind.OBJECT_TYPE_EXTENSION;
  28499. } else if ((0, _definition.isInterfaceType)(type)) {
  28500. return _kinds.Kind.INTERFACE_TYPE_EXTENSION;
  28501. } else if ((0, _definition.isUnionType)(type)) {
  28502. return _kinds.Kind.UNION_TYPE_EXTENSION;
  28503. } else if ((0, _definition.isEnumType)(type)) {
  28504. return _kinds.Kind.ENUM_TYPE_EXTENSION;
  28505. } else if ((0, _definition.isInputObjectType)(type)) {
  28506. return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION;
  28507. }
  28508. }
  28509. function extensionKindToTypeName(kind) {
  28510. switch (kind) {
  28511. case _kinds.Kind.SCALAR_TYPE_EXTENSION:
  28512. return 'scalar';
  28513. case _kinds.Kind.OBJECT_TYPE_EXTENSION:
  28514. return 'object';
  28515. case _kinds.Kind.INTERFACE_TYPE_EXTENSION:
  28516. return 'interface';
  28517. case _kinds.Kind.UNION_TYPE_EXTENSION:
  28518. return 'union';
  28519. case _kinds.Kind.ENUM_TYPE_EXTENSION:
  28520. return 'enum';
  28521. case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION:
  28522. return 'input object';
  28523. default:
  28524. return 'unknown type';
  28525. }
  28526. }
  28527. },{"../../error/GraphQLError":19,"../../jsutils/quotedOrList":46,"../../jsutils/suggestionList":47,"../../language/kinds":51,"../../language/predicates":55,"../../type/definition":68}],118:[function(require,module,exports){
  28528. "use strict";
  28529. Object.defineProperty(exports, "__esModule", {
  28530. value: true
  28531. });
  28532. exports.missingFieldArgMessage = missingFieldArgMessage;
  28533. exports.missingDirectiveArgMessage = missingDirectiveArgMessage;
  28534. exports.ProvidedRequiredArguments = ProvidedRequiredArguments;
  28535. exports.ProvidedRequiredArgumentsOnDirectives = ProvidedRequiredArgumentsOnDirectives;
  28536. var _GraphQLError = require("../../error/GraphQLError");
  28537. var _kinds = require("../../language/kinds");
  28538. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  28539. var _keyMap = _interopRequireDefault(require("../../jsutils/keyMap"));
  28540. var _definition = require("../../type/definition");
  28541. var _printer = require("../../language/printer");
  28542. var _directives = require("../../type/directives");
  28543. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28544. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  28545. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  28546. function missingFieldArgMessage(fieldName, argName, type) {
  28547. return "Field \"".concat(fieldName, "\" argument \"").concat(argName, "\" of type ") + "\"".concat(type, "\" is required, but it was not provided.");
  28548. }
  28549. function missingDirectiveArgMessage(directiveName, argName, type) {
  28550. return "Directive \"@".concat(directiveName, "\" argument \"").concat(argName, "\" of type ") + "\"".concat(type, "\" is required, but it was not provided.");
  28551. }
  28552. /**
  28553. * Provided required arguments
  28554. *
  28555. * A field or directive is only valid if all required (non-null without a
  28556. * default value) field arguments have been provided.
  28557. */
  28558. function ProvidedRequiredArguments(context) {
  28559. return _objectSpread({}, ProvidedRequiredArgumentsOnDirectives(context), {
  28560. Field: {
  28561. // Validate on leave to allow for deeper errors to appear first.
  28562. leave: function leave(fieldNode) {
  28563. var fieldDef = context.getFieldDef();
  28564. if (!fieldDef) {
  28565. return false;
  28566. }
  28567. var argNodes = fieldNode.arguments || [];
  28568. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  28569. return arg.name.value;
  28570. });
  28571. var _iteratorNormalCompletion = true;
  28572. var _didIteratorError = false;
  28573. var _iteratorError = undefined;
  28574. try {
  28575. for (var _iterator = fieldDef.args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28576. var argDef = _step.value;
  28577. var argNode = argNodeMap[argDef.name];
  28578. if (!argNode && (0, _definition.isRequiredArgument)(argDef)) {
  28579. context.reportError(new _GraphQLError.GraphQLError(missingFieldArgMessage(fieldDef.name, argDef.name, (0, _inspect.default)(argDef.type)), fieldNode));
  28580. }
  28581. }
  28582. } catch (err) {
  28583. _didIteratorError = true;
  28584. _iteratorError = err;
  28585. } finally {
  28586. try {
  28587. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28588. _iterator.return();
  28589. }
  28590. } finally {
  28591. if (_didIteratorError) {
  28592. throw _iteratorError;
  28593. }
  28594. }
  28595. }
  28596. }
  28597. }
  28598. });
  28599. } // @internal
  28600. function ProvidedRequiredArgumentsOnDirectives(context) {
  28601. var requiredArgsMap = Object.create(null);
  28602. var schema = context.getSchema();
  28603. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  28604. var _iteratorNormalCompletion2 = true;
  28605. var _didIteratorError2 = false;
  28606. var _iteratorError2 = undefined;
  28607. try {
  28608. for (var _iterator2 = definedDirectives[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  28609. var directive = _step2.value;
  28610. requiredArgsMap[directive.name] = (0, _keyMap.default)(directive.args.filter(_definition.isRequiredArgument), function (arg) {
  28611. return arg.name;
  28612. });
  28613. }
  28614. } catch (err) {
  28615. _didIteratorError2 = true;
  28616. _iteratorError2 = err;
  28617. } finally {
  28618. try {
  28619. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  28620. _iterator2.return();
  28621. }
  28622. } finally {
  28623. if (_didIteratorError2) {
  28624. throw _iteratorError2;
  28625. }
  28626. }
  28627. }
  28628. var astDefinitions = context.getDocument().definitions;
  28629. var _iteratorNormalCompletion3 = true;
  28630. var _didIteratorError3 = false;
  28631. var _iteratorError3 = undefined;
  28632. try {
  28633. for (var _iterator3 = astDefinitions[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  28634. var def = _step3.value;
  28635. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  28636. requiredArgsMap[def.name.value] = (0, _keyMap.default)(def.arguments ? def.arguments.filter(isRequiredArgumentNode) : [], function (arg) {
  28637. return arg.name.value;
  28638. });
  28639. }
  28640. }
  28641. } catch (err) {
  28642. _didIteratorError3 = true;
  28643. _iteratorError3 = err;
  28644. } finally {
  28645. try {
  28646. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  28647. _iterator3.return();
  28648. }
  28649. } finally {
  28650. if (_didIteratorError3) {
  28651. throw _iteratorError3;
  28652. }
  28653. }
  28654. }
  28655. return {
  28656. Directive: {
  28657. // Validate on leave to allow for deeper errors to appear first.
  28658. leave: function leave(directiveNode) {
  28659. var directiveName = directiveNode.name.value;
  28660. var requiredArgs = requiredArgsMap[directiveName];
  28661. if (requiredArgs) {
  28662. var argNodes = directiveNode.arguments || [];
  28663. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  28664. return arg.name.value;
  28665. });
  28666. for (var _i = 0, _Object$keys = Object.keys(requiredArgs); _i < _Object$keys.length; _i++) {
  28667. var argName = _Object$keys[_i];
  28668. if (!argNodeMap[argName]) {
  28669. var argType = requiredArgs[argName].type;
  28670. context.reportError(new _GraphQLError.GraphQLError(missingDirectiveArgMessage(directiveName, argName, (0, _definition.isType)(argType) ? (0, _inspect.default)(argType) : (0, _printer.print)(argType)), directiveNode));
  28671. }
  28672. }
  28673. }
  28674. }
  28675. }
  28676. };
  28677. }
  28678. function isRequiredArgumentNode(arg) {
  28679. return arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null;
  28680. }
  28681. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../jsutils/keyMap":38,"../../language/kinds":51,"../../language/printer":56,"../../type/definition":68,"../../type/directives":69}],119:[function(require,module,exports){
  28682. "use strict";
  28683. Object.defineProperty(exports, "__esModule", {
  28684. value: true
  28685. });
  28686. exports.noSubselectionAllowedMessage = noSubselectionAllowedMessage;
  28687. exports.requiredSubselectionMessage = requiredSubselectionMessage;
  28688. exports.ScalarLeafs = ScalarLeafs;
  28689. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  28690. var _GraphQLError = require("../../error/GraphQLError");
  28691. var _definition = require("../../type/definition");
  28692. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28693. /**
  28694. * Copyright (c) Facebook, Inc. and its affiliates.
  28695. *
  28696. * This source code is licensed under the MIT license found in the
  28697. * LICENSE file in the root directory of this source tree.
  28698. *
  28699. *
  28700. */
  28701. function noSubselectionAllowedMessage(fieldName, type) {
  28702. return "Field \"".concat(fieldName, "\" must not have a selection since ") + "type \"".concat(type, "\" has no subfields.");
  28703. }
  28704. function requiredSubselectionMessage(fieldName, type) {
  28705. return "Field \"".concat(fieldName, "\" of type \"").concat(type, "\" must have a ") + "selection of subfields. Did you mean \"".concat(fieldName, " { ... }\"?");
  28706. }
  28707. /**
  28708. * Scalar leafs
  28709. *
  28710. * A GraphQL document is valid only if all leaf fields (fields without
  28711. * sub selections) are of scalar or enum types.
  28712. */
  28713. function ScalarLeafs(context) {
  28714. return {
  28715. Field: function Field(node) {
  28716. var type = context.getType();
  28717. var selectionSet = node.selectionSet;
  28718. if (type) {
  28719. if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) {
  28720. if (selectionSet) {
  28721. context.reportError(new _GraphQLError.GraphQLError(noSubselectionAllowedMessage(node.name.value, (0, _inspect.default)(type)), selectionSet));
  28722. }
  28723. } else if (!selectionSet) {
  28724. context.reportError(new _GraphQLError.GraphQLError(requiredSubselectionMessage(node.name.value, (0, _inspect.default)(type)), node));
  28725. }
  28726. }
  28727. }
  28728. };
  28729. }
  28730. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../type/definition":68}],120:[function(require,module,exports){
  28731. "use strict";
  28732. Object.defineProperty(exports, "__esModule", {
  28733. value: true
  28734. });
  28735. exports.singleFieldOnlyMessage = singleFieldOnlyMessage;
  28736. exports.SingleFieldSubscriptions = SingleFieldSubscriptions;
  28737. var _GraphQLError = require("../../error/GraphQLError");
  28738. /**
  28739. * Copyright (c) Facebook, Inc. and its affiliates.
  28740. *
  28741. * This source code is licensed under the MIT license found in the
  28742. * LICENSE file in the root directory of this source tree.
  28743. *
  28744. *
  28745. */
  28746. function singleFieldOnlyMessage(name) {
  28747. return (name ? "Subscription \"".concat(name, "\" ") : 'Anonymous Subscription ') + 'must select only one top level field.';
  28748. }
  28749. /**
  28750. * Subscriptions must only include one field.
  28751. *
  28752. * A GraphQL subscription is valid only if it contains a single root field.
  28753. */
  28754. function SingleFieldSubscriptions(context) {
  28755. return {
  28756. OperationDefinition: function OperationDefinition(node) {
  28757. if (node.operation === 'subscription') {
  28758. if (node.selectionSet.selections.length !== 1) {
  28759. context.reportError(new _GraphQLError.GraphQLError(singleFieldOnlyMessage(node.name && node.name.value), node.selectionSet.selections.slice(1)));
  28760. }
  28761. }
  28762. }
  28763. };
  28764. }
  28765. },{"../../error/GraphQLError":19}],121:[function(require,module,exports){
  28766. "use strict";
  28767. Object.defineProperty(exports, "__esModule", {
  28768. value: true
  28769. });
  28770. exports.duplicateArgMessage = duplicateArgMessage;
  28771. exports.UniqueArgumentNames = UniqueArgumentNames;
  28772. var _GraphQLError = require("../../error/GraphQLError");
  28773. /**
  28774. * Copyright (c) Facebook, Inc. and its affiliates.
  28775. *
  28776. * This source code is licensed under the MIT license found in the
  28777. * LICENSE file in the root directory of this source tree.
  28778. *
  28779. *
  28780. */
  28781. function duplicateArgMessage(argName) {
  28782. return "There can be only one argument named \"".concat(argName, "\".");
  28783. }
  28784. /**
  28785. * Unique argument names
  28786. *
  28787. * A GraphQL field or directive is only valid if all supplied arguments are
  28788. * uniquely named.
  28789. */
  28790. function UniqueArgumentNames(context) {
  28791. var knownArgNames = Object.create(null);
  28792. return {
  28793. Field: function Field() {
  28794. knownArgNames = Object.create(null);
  28795. },
  28796. Directive: function Directive() {
  28797. knownArgNames = Object.create(null);
  28798. },
  28799. Argument: function Argument(node) {
  28800. var argName = node.name.value;
  28801. if (knownArgNames[argName]) {
  28802. context.reportError(new _GraphQLError.GraphQLError(duplicateArgMessage(argName), [knownArgNames[argName], node.name]));
  28803. } else {
  28804. knownArgNames[argName] = node.name;
  28805. }
  28806. return false;
  28807. }
  28808. };
  28809. }
  28810. },{"../../error/GraphQLError":19}],122:[function(require,module,exports){
  28811. "use strict";
  28812. Object.defineProperty(exports, "__esModule", {
  28813. value: true
  28814. });
  28815. exports.duplicateDirectiveNameMessage = duplicateDirectiveNameMessage;
  28816. exports.existedDirectiveNameMessage = existedDirectiveNameMessage;
  28817. exports.UniqueDirectiveNames = UniqueDirectiveNames;
  28818. var _GraphQLError = require("../../error/GraphQLError");
  28819. /**
  28820. * Copyright (c) Facebook, Inc. and its affiliates.
  28821. *
  28822. * This source code is licensed under the MIT license found in the
  28823. * LICENSE file in the root directory of this source tree.
  28824. *
  28825. *
  28826. */
  28827. function duplicateDirectiveNameMessage(directiveName) {
  28828. return "There can be only one directive named \"".concat(directiveName, "\".");
  28829. }
  28830. function existedDirectiveNameMessage(directiveName) {
  28831. return "Directive \"".concat(directiveName, "\" already exists in the schema. ") + 'It cannot be redefined.';
  28832. }
  28833. /**
  28834. * Unique directive names
  28835. *
  28836. * A GraphQL document is only valid if all defined directives have unique names.
  28837. */
  28838. function UniqueDirectiveNames(context) {
  28839. var knownDirectiveNames = Object.create(null);
  28840. var schema = context.getSchema();
  28841. return {
  28842. DirectiveDefinition: function DirectiveDefinition(node) {
  28843. var directiveName = node.name.value;
  28844. if (schema && schema.getDirective(directiveName)) {
  28845. context.reportError(new _GraphQLError.GraphQLError(existedDirectiveNameMessage(directiveName), node.name));
  28846. return;
  28847. }
  28848. if (knownDirectiveNames[directiveName]) {
  28849. context.reportError(new _GraphQLError.GraphQLError(duplicateDirectiveNameMessage(directiveName), [knownDirectiveNames[directiveName], node.name]));
  28850. } else {
  28851. knownDirectiveNames[directiveName] = node.name;
  28852. }
  28853. return false;
  28854. }
  28855. };
  28856. }
  28857. },{"../../error/GraphQLError":19}],123:[function(require,module,exports){
  28858. "use strict";
  28859. Object.defineProperty(exports, "__esModule", {
  28860. value: true
  28861. });
  28862. exports.duplicateDirectiveMessage = duplicateDirectiveMessage;
  28863. exports.UniqueDirectivesPerLocation = UniqueDirectivesPerLocation;
  28864. var _GraphQLError = require("../../error/GraphQLError");
  28865. /**
  28866. * Copyright (c) Facebook, Inc. and its affiliates.
  28867. *
  28868. * This source code is licensed under the MIT license found in the
  28869. * LICENSE file in the root directory of this source tree.
  28870. *
  28871. *
  28872. */
  28873. function duplicateDirectiveMessage(directiveName) {
  28874. return "The directive \"".concat(directiveName, "\" can only be used once at ") + 'this location.';
  28875. }
  28876. /**
  28877. * Unique directive names per location
  28878. *
  28879. * A GraphQL document is only valid if all directives at a given location
  28880. * are uniquely named.
  28881. */
  28882. function UniqueDirectivesPerLocation(context) {
  28883. return {
  28884. // Many different AST nodes may contain directives. Rather than listing
  28885. // them all, just listen for entering any node, and check to see if it
  28886. // defines any directives.
  28887. enter: function enter(node) {
  28888. // Flow can't refine that node.directives will only contain directives,
  28889. // so we cast so the rest of the code is well typed.
  28890. var directives = node.directives;
  28891. if (directives) {
  28892. var knownDirectives = Object.create(null);
  28893. var _iteratorNormalCompletion = true;
  28894. var _didIteratorError = false;
  28895. var _iteratorError = undefined;
  28896. try {
  28897. for (var _iterator = directives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28898. var directive = _step.value;
  28899. var directiveName = directive.name.value;
  28900. if (knownDirectives[directiveName]) {
  28901. context.reportError(new _GraphQLError.GraphQLError(duplicateDirectiveMessage(directiveName), [knownDirectives[directiveName], directive]));
  28902. } else {
  28903. knownDirectives[directiveName] = directive;
  28904. }
  28905. }
  28906. } catch (err) {
  28907. _didIteratorError = true;
  28908. _iteratorError = err;
  28909. } finally {
  28910. try {
  28911. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28912. _iterator.return();
  28913. }
  28914. } finally {
  28915. if (_didIteratorError) {
  28916. throw _iteratorError;
  28917. }
  28918. }
  28919. }
  28920. }
  28921. }
  28922. };
  28923. }
  28924. },{"../../error/GraphQLError":19}],124:[function(require,module,exports){
  28925. "use strict";
  28926. Object.defineProperty(exports, "__esModule", {
  28927. value: true
  28928. });
  28929. exports.duplicateEnumValueNameMessage = duplicateEnumValueNameMessage;
  28930. exports.existedEnumValueNameMessage = existedEnumValueNameMessage;
  28931. exports.UniqueEnumValueNames = UniqueEnumValueNames;
  28932. var _GraphQLError = require("../../error/GraphQLError");
  28933. var _definition = require("../../type/definition");
  28934. /**
  28935. * Copyright (c) Facebook, Inc. and its affiliates.
  28936. *
  28937. * This source code is licensed under the MIT license found in the
  28938. * LICENSE file in the root directory of this source tree.
  28939. *
  28940. *
  28941. */
  28942. function duplicateEnumValueNameMessage(typeName, valueName) {
  28943. return "Enum value \"".concat(typeName, ".").concat(valueName, "\" can only be defined once.");
  28944. }
  28945. function existedEnumValueNameMessage(typeName, valueName) {
  28946. return "Enum value \"".concat(typeName, ".").concat(valueName, "\" already exists in the schema. ") + 'It cannot also be defined in this type extension.';
  28947. }
  28948. /**
  28949. * Unique enum value names
  28950. *
  28951. * A GraphQL enum type is only valid if all its values are uniquely named.
  28952. */
  28953. function UniqueEnumValueNames(context) {
  28954. var schema = context.getSchema();
  28955. var existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);
  28956. var knownValueNames = Object.create(null);
  28957. return {
  28958. EnumTypeDefinition: checkValueUniqueness,
  28959. EnumTypeExtension: checkValueUniqueness
  28960. };
  28961. function checkValueUniqueness(node) {
  28962. var typeName = node.name.value;
  28963. if (!knownValueNames[typeName]) {
  28964. knownValueNames[typeName] = Object.create(null);
  28965. }
  28966. if (node.values) {
  28967. var valueNames = knownValueNames[typeName];
  28968. var _iteratorNormalCompletion = true;
  28969. var _didIteratorError = false;
  28970. var _iteratorError = undefined;
  28971. try {
  28972. for (var _iterator = node.values[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28973. var valueDef = _step.value;
  28974. var valueName = valueDef.name.value;
  28975. var existingType = existingTypeMap[typeName];
  28976. if ((0, _definition.isEnumType)(existingType) && existingType.getValue(valueName)) {
  28977. context.reportError(new _GraphQLError.GraphQLError(existedEnumValueNameMessage(typeName, valueName), valueDef.name));
  28978. } else if (valueNames[valueName]) {
  28979. context.reportError(new _GraphQLError.GraphQLError(duplicateEnumValueNameMessage(typeName, valueName), [valueNames[valueName], valueDef.name]));
  28980. } else {
  28981. valueNames[valueName] = valueDef.name;
  28982. }
  28983. }
  28984. } catch (err) {
  28985. _didIteratorError = true;
  28986. _iteratorError = err;
  28987. } finally {
  28988. try {
  28989. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28990. _iterator.return();
  28991. }
  28992. } finally {
  28993. if (_didIteratorError) {
  28994. throw _iteratorError;
  28995. }
  28996. }
  28997. }
  28998. }
  28999. return false;
  29000. }
  29001. }
  29002. },{"../../error/GraphQLError":19,"../../type/definition":68}],125:[function(require,module,exports){
  29003. "use strict";
  29004. Object.defineProperty(exports, "__esModule", {
  29005. value: true
  29006. });
  29007. exports.duplicateFieldDefinitionNameMessage = duplicateFieldDefinitionNameMessage;
  29008. exports.existedFieldDefinitionNameMessage = existedFieldDefinitionNameMessage;
  29009. exports.UniqueFieldDefinitionNames = UniqueFieldDefinitionNames;
  29010. var _GraphQLError = require("../../error/GraphQLError");
  29011. var _definition = require("../../type/definition");
  29012. /**
  29013. * Copyright (c) Facebook, Inc. and its affiliates.
  29014. *
  29015. * This source code is licensed under the MIT license found in the
  29016. * LICENSE file in the root directory of this source tree.
  29017. *
  29018. *
  29019. */
  29020. function duplicateFieldDefinitionNameMessage(typeName, fieldName) {
  29021. return "Field \"".concat(typeName, ".").concat(fieldName, "\" can only be defined once.");
  29022. }
  29023. function existedFieldDefinitionNameMessage(typeName, fieldName) {
  29024. return "Field \"".concat(typeName, ".").concat(fieldName, "\" already exists in the schema. ") + 'It cannot also be defined in this type extension.';
  29025. }
  29026. /**
  29027. * Unique field definition names
  29028. *
  29029. * A GraphQL complex type is only valid if all its fields are uniquely named.
  29030. */
  29031. function UniqueFieldDefinitionNames(context) {
  29032. var schema = context.getSchema();
  29033. var existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);
  29034. var knownFieldNames = Object.create(null);
  29035. return {
  29036. InputObjectTypeDefinition: checkFieldUniqueness,
  29037. InputObjectTypeExtension: checkFieldUniqueness,
  29038. InterfaceTypeDefinition: checkFieldUniqueness,
  29039. InterfaceTypeExtension: checkFieldUniqueness,
  29040. ObjectTypeDefinition: checkFieldUniqueness,
  29041. ObjectTypeExtension: checkFieldUniqueness
  29042. };
  29043. function checkFieldUniqueness(node) {
  29044. var typeName = node.name.value;
  29045. if (!knownFieldNames[typeName]) {
  29046. knownFieldNames[typeName] = Object.create(null);
  29047. }
  29048. if (node.fields) {
  29049. var fieldNames = knownFieldNames[typeName];
  29050. var _iteratorNormalCompletion = true;
  29051. var _didIteratorError = false;
  29052. var _iteratorError = undefined;
  29053. try {
  29054. for (var _iterator = node.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29055. var fieldDef = _step.value;
  29056. var fieldName = fieldDef.name.value;
  29057. if (hasField(existingTypeMap[typeName], fieldName)) {
  29058. context.reportError(new _GraphQLError.GraphQLError(existedFieldDefinitionNameMessage(typeName, fieldName), fieldDef.name));
  29059. } else if (fieldNames[fieldName]) {
  29060. context.reportError(new _GraphQLError.GraphQLError(duplicateFieldDefinitionNameMessage(typeName, fieldName), [fieldNames[fieldName], fieldDef.name]));
  29061. } else {
  29062. fieldNames[fieldName] = fieldDef.name;
  29063. }
  29064. }
  29065. } catch (err) {
  29066. _didIteratorError = true;
  29067. _iteratorError = err;
  29068. } finally {
  29069. try {
  29070. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29071. _iterator.return();
  29072. }
  29073. } finally {
  29074. if (_didIteratorError) {
  29075. throw _iteratorError;
  29076. }
  29077. }
  29078. }
  29079. }
  29080. return false;
  29081. }
  29082. }
  29083. function hasField(type, fieldName) {
  29084. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type) || (0, _definition.isInputObjectType)(type)) {
  29085. return type.getFields()[fieldName];
  29086. }
  29087. return false;
  29088. }
  29089. },{"../../error/GraphQLError":19,"../../type/definition":68}],126:[function(require,module,exports){
  29090. "use strict";
  29091. Object.defineProperty(exports, "__esModule", {
  29092. value: true
  29093. });
  29094. exports.duplicateFragmentNameMessage = duplicateFragmentNameMessage;
  29095. exports.UniqueFragmentNames = UniqueFragmentNames;
  29096. var _GraphQLError = require("../../error/GraphQLError");
  29097. /**
  29098. * Copyright (c) Facebook, Inc. and its affiliates.
  29099. *
  29100. * This source code is licensed under the MIT license found in the
  29101. * LICENSE file in the root directory of this source tree.
  29102. *
  29103. *
  29104. */
  29105. function duplicateFragmentNameMessage(fragName) {
  29106. return "There can be only one fragment named \"".concat(fragName, "\".");
  29107. }
  29108. /**
  29109. * Unique fragment names
  29110. *
  29111. * A GraphQL document is only valid if all defined fragments have unique names.
  29112. */
  29113. function UniqueFragmentNames(context) {
  29114. var knownFragmentNames = Object.create(null);
  29115. return {
  29116. OperationDefinition: function OperationDefinition() {
  29117. return false;
  29118. },
  29119. FragmentDefinition: function FragmentDefinition(node) {
  29120. var fragmentName = node.name.value;
  29121. if (knownFragmentNames[fragmentName]) {
  29122. context.reportError(new _GraphQLError.GraphQLError(duplicateFragmentNameMessage(fragmentName), [knownFragmentNames[fragmentName], node.name]));
  29123. } else {
  29124. knownFragmentNames[fragmentName] = node.name;
  29125. }
  29126. return false;
  29127. }
  29128. };
  29129. }
  29130. },{"../../error/GraphQLError":19}],127:[function(require,module,exports){
  29131. "use strict";
  29132. Object.defineProperty(exports, "__esModule", {
  29133. value: true
  29134. });
  29135. exports.duplicateInputFieldMessage = duplicateInputFieldMessage;
  29136. exports.UniqueInputFieldNames = UniqueInputFieldNames;
  29137. var _GraphQLError = require("../../error/GraphQLError");
  29138. /**
  29139. * Copyright (c) Facebook, Inc. and its affiliates.
  29140. *
  29141. * This source code is licensed under the MIT license found in the
  29142. * LICENSE file in the root directory of this source tree.
  29143. *
  29144. *
  29145. */
  29146. function duplicateInputFieldMessage(fieldName) {
  29147. return "There can be only one input field named \"".concat(fieldName, "\".");
  29148. }
  29149. /**
  29150. * Unique input field names
  29151. *
  29152. * A GraphQL input object value is only valid if all supplied fields are
  29153. * uniquely named.
  29154. */
  29155. function UniqueInputFieldNames(context) {
  29156. var knownNameStack = [];
  29157. var knownNames = Object.create(null);
  29158. return {
  29159. ObjectValue: {
  29160. enter: function enter() {
  29161. knownNameStack.push(knownNames);
  29162. knownNames = Object.create(null);
  29163. },
  29164. leave: function leave() {
  29165. knownNames = knownNameStack.pop();
  29166. }
  29167. },
  29168. ObjectField: function ObjectField(node) {
  29169. var fieldName = node.name.value;
  29170. if (knownNames[fieldName]) {
  29171. context.reportError(new _GraphQLError.GraphQLError(duplicateInputFieldMessage(fieldName), [knownNames[fieldName], node.name]));
  29172. } else {
  29173. knownNames[fieldName] = node.name;
  29174. }
  29175. }
  29176. };
  29177. }
  29178. },{"../../error/GraphQLError":19}],128:[function(require,module,exports){
  29179. "use strict";
  29180. Object.defineProperty(exports, "__esModule", {
  29181. value: true
  29182. });
  29183. exports.duplicateOperationNameMessage = duplicateOperationNameMessage;
  29184. exports.UniqueOperationNames = UniqueOperationNames;
  29185. var _GraphQLError = require("../../error/GraphQLError");
  29186. /**
  29187. * Copyright (c) Facebook, Inc. and its affiliates.
  29188. *
  29189. * This source code is licensed under the MIT license found in the
  29190. * LICENSE file in the root directory of this source tree.
  29191. *
  29192. *
  29193. */
  29194. function duplicateOperationNameMessage(operationName) {
  29195. return "There can be only one operation named \"".concat(operationName, "\".");
  29196. }
  29197. /**
  29198. * Unique operation names
  29199. *
  29200. * A GraphQL document is only valid if all defined operations have unique names.
  29201. */
  29202. function UniqueOperationNames(context) {
  29203. var knownOperationNames = Object.create(null);
  29204. return {
  29205. OperationDefinition: function OperationDefinition(node) {
  29206. var operationName = node.name;
  29207. if (operationName) {
  29208. if (knownOperationNames[operationName.value]) {
  29209. context.reportError(new _GraphQLError.GraphQLError(duplicateOperationNameMessage(operationName.value), [knownOperationNames[operationName.value], operationName]));
  29210. } else {
  29211. knownOperationNames[operationName.value] = operationName;
  29212. }
  29213. }
  29214. return false;
  29215. },
  29216. FragmentDefinition: function FragmentDefinition() {
  29217. return false;
  29218. }
  29219. };
  29220. }
  29221. },{"../../error/GraphQLError":19}],129:[function(require,module,exports){
  29222. "use strict";
  29223. Object.defineProperty(exports, "__esModule", {
  29224. value: true
  29225. });
  29226. exports.duplicateOperationTypeMessage = duplicateOperationTypeMessage;
  29227. exports.existedOperationTypeMessage = existedOperationTypeMessage;
  29228. exports.UniqueOperationTypes = UniqueOperationTypes;
  29229. var _GraphQLError = require("../../error/GraphQLError");
  29230. /**
  29231. * Copyright (c) Facebook, Inc. and its affiliates.
  29232. *
  29233. * This source code is licensed under the MIT license found in the
  29234. * LICENSE file in the root directory of this source tree.
  29235. *
  29236. *
  29237. */
  29238. function duplicateOperationTypeMessage(operation) {
  29239. return "There can be only one ".concat(operation, " type in schema.");
  29240. }
  29241. function existedOperationTypeMessage(operation) {
  29242. return "Type for ".concat(operation, " already defined in the schema. ") + 'It cannot be redefined.';
  29243. }
  29244. /**
  29245. * Unique operation types
  29246. *
  29247. * A GraphQL document is only valid if it has only one type per operation.
  29248. */
  29249. function UniqueOperationTypes(context) {
  29250. var schema = context.getSchema();
  29251. var definedOperationTypes = Object.create(null);
  29252. var existingOperationTypes = schema ? {
  29253. query: schema.getQueryType(),
  29254. mutation: schema.getMutationType(),
  29255. subscription: schema.getSubscriptionType()
  29256. } : {};
  29257. return {
  29258. SchemaDefinition: checkOperationTypes,
  29259. SchemaExtension: checkOperationTypes
  29260. };
  29261. function checkOperationTypes(node) {
  29262. if (node.operationTypes) {
  29263. var _iteratorNormalCompletion = true;
  29264. var _didIteratorError = false;
  29265. var _iteratorError = undefined;
  29266. try {
  29267. for (var _iterator = (node.operationTypes || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29268. var operationType = _step.value;
  29269. var operation = operationType.operation;
  29270. var alreadyDefinedOperationType = definedOperationTypes[operation];
  29271. if (existingOperationTypes[operation]) {
  29272. context.reportError(new _GraphQLError.GraphQLError(existedOperationTypeMessage(operation), operationType));
  29273. } else if (alreadyDefinedOperationType) {
  29274. context.reportError(new _GraphQLError.GraphQLError(duplicateOperationTypeMessage(operation), [alreadyDefinedOperationType, operationType]));
  29275. } else {
  29276. definedOperationTypes[operation] = operationType;
  29277. }
  29278. }
  29279. } catch (err) {
  29280. _didIteratorError = true;
  29281. _iteratorError = err;
  29282. } finally {
  29283. try {
  29284. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29285. _iterator.return();
  29286. }
  29287. } finally {
  29288. if (_didIteratorError) {
  29289. throw _iteratorError;
  29290. }
  29291. }
  29292. }
  29293. }
  29294. return false;
  29295. }
  29296. }
  29297. },{"../../error/GraphQLError":19}],130:[function(require,module,exports){
  29298. "use strict";
  29299. Object.defineProperty(exports, "__esModule", {
  29300. value: true
  29301. });
  29302. exports.duplicateTypeNameMessage = duplicateTypeNameMessage;
  29303. exports.existedTypeNameMessage = existedTypeNameMessage;
  29304. exports.UniqueTypeNames = UniqueTypeNames;
  29305. var _GraphQLError = require("../../error/GraphQLError");
  29306. /**
  29307. * Copyright (c) Facebook, Inc. and its affiliates.
  29308. *
  29309. * This source code is licensed under the MIT license found in the
  29310. * LICENSE file in the root directory of this source tree.
  29311. *
  29312. *
  29313. */
  29314. function duplicateTypeNameMessage(typeName) {
  29315. return "There can be only one type named \"".concat(typeName, "\".");
  29316. }
  29317. function existedTypeNameMessage(typeName) {
  29318. return "Type \"".concat(typeName, "\" already exists in the schema. ") + 'It cannot also be defined in this type definition.';
  29319. }
  29320. /**
  29321. * Unique type names
  29322. *
  29323. * A GraphQL document is only valid if all defined types have unique names.
  29324. */
  29325. function UniqueTypeNames(context) {
  29326. var knownTypeNames = Object.create(null);
  29327. var schema = context.getSchema();
  29328. return {
  29329. ScalarTypeDefinition: checkTypeName,
  29330. ObjectTypeDefinition: checkTypeName,
  29331. InterfaceTypeDefinition: checkTypeName,
  29332. UnionTypeDefinition: checkTypeName,
  29333. EnumTypeDefinition: checkTypeName,
  29334. InputObjectTypeDefinition: checkTypeName
  29335. };
  29336. function checkTypeName(node) {
  29337. var typeName = node.name.value;
  29338. if (schema && schema.getType(typeName)) {
  29339. context.reportError(new _GraphQLError.GraphQLError(existedTypeNameMessage(typeName), node.name));
  29340. return;
  29341. }
  29342. if (knownTypeNames[typeName]) {
  29343. context.reportError(new _GraphQLError.GraphQLError(duplicateTypeNameMessage(typeName), [knownTypeNames[typeName], node.name]));
  29344. } else {
  29345. knownTypeNames[typeName] = node.name;
  29346. }
  29347. return false;
  29348. }
  29349. }
  29350. },{"../../error/GraphQLError":19}],131:[function(require,module,exports){
  29351. "use strict";
  29352. Object.defineProperty(exports, "__esModule", {
  29353. value: true
  29354. });
  29355. exports.duplicateVariableMessage = duplicateVariableMessage;
  29356. exports.UniqueVariableNames = UniqueVariableNames;
  29357. var _GraphQLError = require("../../error/GraphQLError");
  29358. /**
  29359. * Copyright (c) Facebook, Inc. and its affiliates.
  29360. *
  29361. * This source code is licensed under the MIT license found in the
  29362. * LICENSE file in the root directory of this source tree.
  29363. *
  29364. *
  29365. */
  29366. function duplicateVariableMessage(variableName) {
  29367. return "There can be only one variable named \"".concat(variableName, "\".");
  29368. }
  29369. /**
  29370. * Unique variable names
  29371. *
  29372. * A GraphQL operation is only valid if all its variables are uniquely named.
  29373. */
  29374. function UniqueVariableNames(context) {
  29375. var knownVariableNames = Object.create(null);
  29376. return {
  29377. OperationDefinition: function OperationDefinition() {
  29378. knownVariableNames = Object.create(null);
  29379. },
  29380. VariableDefinition: function VariableDefinition(node) {
  29381. var variableName = node.variable.name.value;
  29382. if (knownVariableNames[variableName]) {
  29383. context.reportError(new _GraphQLError.GraphQLError(duplicateVariableMessage(variableName), [knownVariableNames[variableName], node.variable.name]));
  29384. } else {
  29385. knownVariableNames[variableName] = node.variable.name;
  29386. }
  29387. }
  29388. };
  29389. }
  29390. },{"../../error/GraphQLError":19}],132:[function(require,module,exports){
  29391. "use strict";
  29392. Object.defineProperty(exports, "__esModule", {
  29393. value: true
  29394. });
  29395. exports.badValueMessage = badValueMessage;
  29396. exports.requiredFieldMessage = requiredFieldMessage;
  29397. exports.unknownFieldMessage = unknownFieldMessage;
  29398. exports.ValuesOfCorrectType = ValuesOfCorrectType;
  29399. var _objectValues = _interopRequireDefault(require("../../polyfills/objectValues"));
  29400. var _GraphQLError = require("../../error/GraphQLError");
  29401. var _printer = require("../../language/printer");
  29402. var _definition = require("../../type/definition");
  29403. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  29404. var _isInvalid = _interopRequireDefault(require("../../jsutils/isInvalid"));
  29405. var _keyMap = _interopRequireDefault(require("../../jsutils/keyMap"));
  29406. var _orList = _interopRequireDefault(require("../../jsutils/orList"));
  29407. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  29408. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29409. /**
  29410. * Copyright (c) Facebook, Inc. and its affiliates.
  29411. *
  29412. * This source code is licensed under the MIT license found in the
  29413. * LICENSE file in the root directory of this source tree.
  29414. *
  29415. *
  29416. */
  29417. function badValueMessage(typeName, valueName, message) {
  29418. return "Expected type ".concat(typeName, ", found ").concat(valueName) + (message ? "; ".concat(message) : '.');
  29419. }
  29420. function requiredFieldMessage(typeName, fieldName, fieldTypeName) {
  29421. return "Field ".concat(typeName, ".").concat(fieldName, " of required type ") + "".concat(fieldTypeName, " was not provided.");
  29422. }
  29423. function unknownFieldMessage(typeName, fieldName, message) {
  29424. return "Field \"".concat(fieldName, "\" is not defined by type ").concat(typeName) + (message ? "; ".concat(message) : '.');
  29425. }
  29426. /**
  29427. * Value literals of correct type
  29428. *
  29429. * A GraphQL document is only valid if all value literals are of the type
  29430. * expected at their position.
  29431. */
  29432. function ValuesOfCorrectType(context) {
  29433. return {
  29434. NullValue: function NullValue(node) {
  29435. var type = context.getInputType();
  29436. if ((0, _definition.isNonNullType)(type)) {
  29437. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(type), (0, _printer.print)(node)), node));
  29438. }
  29439. },
  29440. ListValue: function ListValue(node) {
  29441. // Note: TypeInfo will traverse into a list's item type, so look to the
  29442. // parent input type to check if it is a list.
  29443. var type = (0, _definition.getNullableType)(context.getParentInputType());
  29444. if (!(0, _definition.isListType)(type)) {
  29445. isValidScalar(context, node);
  29446. return false; // Don't traverse further.
  29447. }
  29448. },
  29449. ObjectValue: function ObjectValue(node) {
  29450. var type = (0, _definition.getNamedType)(context.getInputType());
  29451. if (!(0, _definition.isInputObjectType)(type)) {
  29452. isValidScalar(context, node);
  29453. return false; // Don't traverse further.
  29454. } // Ensure every required field exists.
  29455. var fieldNodeMap = (0, _keyMap.default)(node.fields, function (field) {
  29456. return field.name.value;
  29457. });
  29458. var _iteratorNormalCompletion = true;
  29459. var _didIteratorError = false;
  29460. var _iteratorError = undefined;
  29461. try {
  29462. for (var _iterator = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29463. var fieldDef = _step.value;
  29464. var fieldNode = fieldNodeMap[fieldDef.name];
  29465. if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) {
  29466. var typeStr = (0, _inspect.default)(fieldDef.type);
  29467. context.reportError(new _GraphQLError.GraphQLError(requiredFieldMessage(type.name, fieldDef.name, typeStr), node));
  29468. }
  29469. }
  29470. } catch (err) {
  29471. _didIteratorError = true;
  29472. _iteratorError = err;
  29473. } finally {
  29474. try {
  29475. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29476. _iterator.return();
  29477. }
  29478. } finally {
  29479. if (_didIteratorError) {
  29480. throw _iteratorError;
  29481. }
  29482. }
  29483. }
  29484. },
  29485. ObjectField: function ObjectField(node) {
  29486. var parentType = (0, _definition.getNamedType)(context.getParentInputType());
  29487. var fieldType = context.getInputType();
  29488. if (!fieldType && (0, _definition.isInputObjectType)(parentType)) {
  29489. var suggestions = (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
  29490. var didYouMean = suggestions.length !== 0 ? "Did you mean ".concat((0, _orList.default)(suggestions), "?") : undefined;
  29491. context.reportError(new _GraphQLError.GraphQLError(unknownFieldMessage(parentType.name, node.name.value, didYouMean), node));
  29492. }
  29493. },
  29494. EnumValue: function EnumValue(node) {
  29495. var type = (0, _definition.getNamedType)(context.getInputType());
  29496. if (!(0, _definition.isEnumType)(type)) {
  29497. isValidScalar(context, node);
  29498. } else if (!type.getValue(node.value)) {
  29499. context.reportError(new _GraphQLError.GraphQLError(badValueMessage(type.name, (0, _printer.print)(node), enumTypeSuggestion(type, node)), node));
  29500. }
  29501. },
  29502. IntValue: function IntValue(node) {
  29503. return isValidScalar(context, node);
  29504. },
  29505. FloatValue: function FloatValue(node) {
  29506. return isValidScalar(context, node);
  29507. },
  29508. StringValue: function StringValue(node) {
  29509. return isValidScalar(context, node);
  29510. },
  29511. BooleanValue: function BooleanValue(node) {
  29512. return isValidScalar(context, node);
  29513. }
  29514. };
  29515. }
  29516. /**
  29517. * Any value literal may be a valid representation of a Scalar, depending on
  29518. * that scalar type.
  29519. */
  29520. function isValidScalar(context, node) {
  29521. // Report any error at the full type expected by the location.
  29522. var locationType = context.getInputType();
  29523. if (!locationType) {
  29524. return;
  29525. }
  29526. var type = (0, _definition.getNamedType)(locationType);
  29527. if (!(0, _definition.isScalarType)(type)) {
  29528. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node), enumTypeSuggestion(type, node)), node));
  29529. return;
  29530. } // Scalars determine if a literal value is valid via parseLiteral() which
  29531. // may throw or return an invalid value to indicate failure.
  29532. try {
  29533. var parseResult = type.parseLiteral(node, undefined
  29534. /* variables */
  29535. );
  29536. if ((0, _isInvalid.default)(parseResult)) {
  29537. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node)), node));
  29538. }
  29539. } catch (error) {
  29540. // Ensure a reference to the original error is maintained.
  29541. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node), error.message), node, undefined, undefined, undefined, error));
  29542. }
  29543. }
  29544. function enumTypeSuggestion(type, node) {
  29545. if ((0, _definition.isEnumType)(type)) {
  29546. var suggestions = (0, _suggestionList.default)((0, _printer.print)(node), type.getValues().map(function (value) {
  29547. return value.name;
  29548. }));
  29549. if (suggestions.length !== 0) {
  29550. return "Did you mean the enum value ".concat((0, _orList.default)(suggestions), "?");
  29551. }
  29552. }
  29553. }
  29554. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../jsutils/isInvalid":35,"../../jsutils/keyMap":38,"../../jsutils/orList":43,"../../jsutils/suggestionList":47,"../../language/printer":56,"../../polyfills/objectValues":64,"../../type/definition":68}],133:[function(require,module,exports){
  29555. "use strict";
  29556. Object.defineProperty(exports, "__esModule", {
  29557. value: true
  29558. });
  29559. exports.nonInputTypeOnVarMessage = nonInputTypeOnVarMessage;
  29560. exports.VariablesAreInputTypes = VariablesAreInputTypes;
  29561. var _GraphQLError = require("../../error/GraphQLError");
  29562. var _printer = require("../../language/printer");
  29563. var _definition = require("../../type/definition");
  29564. var _typeFromAST = require("../../utilities/typeFromAST");
  29565. /**
  29566. * Copyright (c) Facebook, Inc. and its affiliates.
  29567. *
  29568. * This source code is licensed under the MIT license found in the
  29569. * LICENSE file in the root directory of this source tree.
  29570. *
  29571. *
  29572. */
  29573. function nonInputTypeOnVarMessage(variableName, typeName) {
  29574. return "Variable \"$".concat(variableName, "\" cannot be non-input type \"").concat(typeName, "\".");
  29575. }
  29576. /**
  29577. * Variables are input types
  29578. *
  29579. * A GraphQL operation is only valid if all the variables it defines are of
  29580. * input types (scalar, enum, or input object).
  29581. */
  29582. function VariablesAreInputTypes(context) {
  29583. return {
  29584. VariableDefinition: function VariableDefinition(node) {
  29585. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type); // If the variable type is not an input type, return an error.
  29586. if (type && !(0, _definition.isInputType)(type)) {
  29587. var variableName = node.variable.name.value;
  29588. context.reportError(new _GraphQLError.GraphQLError(nonInputTypeOnVarMessage(variableName, (0, _printer.print)(node.type)), node.type));
  29589. }
  29590. }
  29591. };
  29592. }
  29593. },{"../../error/GraphQLError":19,"../../language/printer":56,"../../type/definition":68,"../../utilities/typeFromAST":97}],134:[function(require,module,exports){
  29594. "use strict";
  29595. Object.defineProperty(exports, "__esModule", {
  29596. value: true
  29597. });
  29598. exports.badVarPosMessage = badVarPosMessage;
  29599. exports.VariablesInAllowedPosition = VariablesInAllowedPosition;
  29600. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  29601. var _GraphQLError = require("../../error/GraphQLError");
  29602. var _kinds = require("../../language/kinds");
  29603. var _definition = require("../../type/definition");
  29604. var _typeComparators = require("../../utilities/typeComparators");
  29605. var _typeFromAST = require("../../utilities/typeFromAST");
  29606. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29607. /**
  29608. * Copyright (c) Facebook, Inc. and its affiliates.
  29609. *
  29610. * This source code is licensed under the MIT license found in the
  29611. * LICENSE file in the root directory of this source tree.
  29612. *
  29613. *
  29614. */
  29615. function badVarPosMessage(varName, varType, expectedType) {
  29616. return "Variable \"$".concat(varName, "\" of type \"").concat(varType, "\" used in ") + "position expecting type \"".concat(expectedType, "\".");
  29617. }
  29618. /**
  29619. * Variables passed to field arguments conform to type
  29620. */
  29621. function VariablesInAllowedPosition(context) {
  29622. var varDefMap = Object.create(null);
  29623. return {
  29624. OperationDefinition: {
  29625. enter: function enter() {
  29626. varDefMap = Object.create(null);
  29627. },
  29628. leave: function leave(operation) {
  29629. var usages = context.getRecursiveVariableUsages(operation);
  29630. var _iteratorNormalCompletion = true;
  29631. var _didIteratorError = false;
  29632. var _iteratorError = undefined;
  29633. try {
  29634. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29635. var _ref2 = _step.value;
  29636. var node = _ref2.node;
  29637. var type = _ref2.type;
  29638. var defaultValue = _ref2.defaultValue;
  29639. var varName = node.name.value;
  29640. var varDef = varDefMap[varName];
  29641. if (varDef && type) {
  29642. // A var type is allowed if it is the same or more strict (e.g. is
  29643. // a subtype of) than the expected type. It can be more strict if
  29644. // the variable type is non-null when the expected type is nullable.
  29645. // If both are list types, the variable item type can be more strict
  29646. // than the expected item type (contravariant).
  29647. var schema = context.getSchema();
  29648. var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type);
  29649. if (varType && !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) {
  29650. context.reportError(new _GraphQLError.GraphQLError(badVarPosMessage(varName, (0, _inspect.default)(varType), (0, _inspect.default)(type)), [varDef, node]));
  29651. }
  29652. }
  29653. }
  29654. } catch (err) {
  29655. _didIteratorError = true;
  29656. _iteratorError = err;
  29657. } finally {
  29658. try {
  29659. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29660. _iterator.return();
  29661. }
  29662. } finally {
  29663. if (_didIteratorError) {
  29664. throw _iteratorError;
  29665. }
  29666. }
  29667. }
  29668. }
  29669. },
  29670. VariableDefinition: function VariableDefinition(node) {
  29671. varDefMap[node.variable.name.value] = node;
  29672. }
  29673. };
  29674. }
  29675. /**
  29676. * Returns true if the variable is allowed in the location it was found,
  29677. * which includes considering if default values exist for either the variable
  29678. * or the location at which it is located.
  29679. */
  29680. function allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) {
  29681. if ((0, _definition.isNonNullType)(locationType) && !(0, _definition.isNonNullType)(varType)) {
  29682. var hasNonNullVariableDefaultValue = varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL;
  29683. var hasLocationDefaultValue = locationDefaultValue !== undefined;
  29684. if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
  29685. return false;
  29686. }
  29687. var nullableLocationType = locationType.ofType;
  29688. return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, nullableLocationType);
  29689. }
  29690. return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType);
  29691. }
  29692. },{"../../error/GraphQLError":19,"../../jsutils/inspect":32,"../../language/kinds":51,"../../type/definition":68,"../../utilities/typeComparators":96,"../../utilities/typeFromAST":97}],135:[function(require,module,exports){
  29693. "use strict";
  29694. Object.defineProperty(exports, "__esModule", {
  29695. value: true
  29696. });
  29697. exports.specifiedSDLRules = exports.specifiedRules = void 0;
  29698. var _ExecutableDefinitions = require("./rules/ExecutableDefinitions");
  29699. var _UniqueOperationNames = require("./rules/UniqueOperationNames");
  29700. var _LoneAnonymousOperation = require("./rules/LoneAnonymousOperation");
  29701. var _SingleFieldSubscriptions = require("./rules/SingleFieldSubscriptions");
  29702. var _KnownTypeNames = require("./rules/KnownTypeNames");
  29703. var _FragmentsOnCompositeTypes = require("./rules/FragmentsOnCompositeTypes");
  29704. var _VariablesAreInputTypes = require("./rules/VariablesAreInputTypes");
  29705. var _ScalarLeafs = require("./rules/ScalarLeafs");
  29706. var _FieldsOnCorrectType = require("./rules/FieldsOnCorrectType");
  29707. var _UniqueFragmentNames = require("./rules/UniqueFragmentNames");
  29708. var _KnownFragmentNames = require("./rules/KnownFragmentNames");
  29709. var _NoUnusedFragments = require("./rules/NoUnusedFragments");
  29710. var _PossibleFragmentSpreads = require("./rules/PossibleFragmentSpreads");
  29711. var _NoFragmentCycles = require("./rules/NoFragmentCycles");
  29712. var _UniqueVariableNames = require("./rules/UniqueVariableNames");
  29713. var _NoUndefinedVariables = require("./rules/NoUndefinedVariables");
  29714. var _NoUnusedVariables = require("./rules/NoUnusedVariables");
  29715. var _KnownDirectives = require("./rules/KnownDirectives");
  29716. var _UniqueDirectivesPerLocation = require("./rules/UniqueDirectivesPerLocation");
  29717. var _KnownArgumentNames = require("./rules/KnownArgumentNames");
  29718. var _UniqueArgumentNames = require("./rules/UniqueArgumentNames");
  29719. var _ValuesOfCorrectType = require("./rules/ValuesOfCorrectType");
  29720. var _ProvidedRequiredArguments = require("./rules/ProvidedRequiredArguments");
  29721. var _VariablesInAllowedPosition = require("./rules/VariablesInAllowedPosition");
  29722. var _OverlappingFieldsCanBeMerged = require("./rules/OverlappingFieldsCanBeMerged");
  29723. var _UniqueInputFieldNames = require("./rules/UniqueInputFieldNames");
  29724. var _LoneSchemaDefinition = require("./rules/LoneSchemaDefinition");
  29725. var _UniqueOperationTypes = require("./rules/UniqueOperationTypes");
  29726. var _UniqueTypeNames = require("./rules/UniqueTypeNames");
  29727. var _UniqueEnumValueNames = require("./rules/UniqueEnumValueNames");
  29728. var _UniqueFieldDefinitionNames = require("./rules/UniqueFieldDefinitionNames");
  29729. var _UniqueDirectiveNames = require("./rules/UniqueDirectiveNames");
  29730. var _PossibleTypeExtensions = require("./rules/PossibleTypeExtensions");
  29731. /**
  29732. * Copyright (c) Facebook, Inc. and its affiliates.
  29733. *
  29734. * This source code is licensed under the MIT license found in the
  29735. * LICENSE file in the root directory of this source tree.
  29736. *
  29737. *
  29738. */
  29739. // Spec Section: "Executable Definitions"
  29740. // Spec Section: "Operation Name Uniqueness"
  29741. // Spec Section: "Lone Anonymous Operation"
  29742. // Spec Section: "Subscriptions with Single Root Field"
  29743. // Spec Section: "Fragment Spread Type Existence"
  29744. // Spec Section: "Fragments on Composite Types"
  29745. // Spec Section: "Variables are Input Types"
  29746. // Spec Section: "Leaf Field Selections"
  29747. // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
  29748. // Spec Section: "Fragment Name Uniqueness"
  29749. // Spec Section: "Fragment spread target defined"
  29750. // Spec Section: "Fragments must be used"
  29751. // Spec Section: "Fragment spread is possible"
  29752. // Spec Section: "Fragments must not form cycles"
  29753. // Spec Section: "Variable Uniqueness"
  29754. // Spec Section: "All Variable Used Defined"
  29755. // Spec Section: "All Variables Used"
  29756. // Spec Section: "Directives Are Defined"
  29757. // Spec Section: "Directives Are Unique Per Location"
  29758. // Spec Section: "Argument Names"
  29759. // Spec Section: "Argument Uniqueness"
  29760. // Spec Section: "Value Type Correctness"
  29761. // Spec Section: "Argument Optionality"
  29762. // Spec Section: "All Variable Usages Are Allowed"
  29763. // Spec Section: "Field Selection Merging"
  29764. // Spec Section: "Input Object Field Uniqueness"
  29765. /**
  29766. * This set includes all validation rules defined by the GraphQL spec.
  29767. *
  29768. * The order of the rules in this list has been adjusted to lead to the
  29769. * most clear output when encountering multiple validation errors.
  29770. */
  29771. var specifiedRules = [_ExecutableDefinitions.ExecutableDefinitions, _UniqueOperationNames.UniqueOperationNames, _LoneAnonymousOperation.LoneAnonymousOperation, _SingleFieldSubscriptions.SingleFieldSubscriptions, _KnownTypeNames.KnownTypeNames, _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes, _VariablesAreInputTypes.VariablesAreInputTypes, _ScalarLeafs.ScalarLeafs, _FieldsOnCorrectType.FieldsOnCorrectType, _UniqueFragmentNames.UniqueFragmentNames, _KnownFragmentNames.KnownFragmentNames, _NoUnusedFragments.NoUnusedFragments, _PossibleFragmentSpreads.PossibleFragmentSpreads, _NoFragmentCycles.NoFragmentCycles, _UniqueVariableNames.UniqueVariableNames, _NoUndefinedVariables.NoUndefinedVariables, _NoUnusedVariables.NoUnusedVariables, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _KnownArgumentNames.KnownArgumentNames, _UniqueArgumentNames.UniqueArgumentNames, _ValuesOfCorrectType.ValuesOfCorrectType, _ProvidedRequiredArguments.ProvidedRequiredArguments, _VariablesInAllowedPosition.VariablesInAllowedPosition, _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged, _UniqueInputFieldNames.UniqueInputFieldNames];
  29772. exports.specifiedRules = specifiedRules;
  29773. // @internal
  29774. var specifiedSDLRules = [_LoneSchemaDefinition.LoneSchemaDefinition, _UniqueOperationTypes.UniqueOperationTypes, _UniqueTypeNames.UniqueTypeNames, _UniqueEnumValueNames.UniqueEnumValueNames, _UniqueFieldDefinitionNames.UniqueFieldDefinitionNames, _UniqueDirectiveNames.UniqueDirectiveNames, _KnownTypeNames.KnownTypeNames, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _PossibleTypeExtensions.PossibleTypeExtensions, _KnownArgumentNames.KnownArgumentNamesOnDirectives, _UniqueArgumentNames.UniqueArgumentNames, _UniqueInputFieldNames.UniqueInputFieldNames, _ProvidedRequiredArguments.ProvidedRequiredArgumentsOnDirectives];
  29775. exports.specifiedSDLRules = specifiedSDLRules;
  29776. },{"./rules/ExecutableDefinitions":102,"./rules/FieldsOnCorrectType":103,"./rules/FragmentsOnCompositeTypes":104,"./rules/KnownArgumentNames":105,"./rules/KnownDirectives":106,"./rules/KnownFragmentNames":107,"./rules/KnownTypeNames":108,"./rules/LoneAnonymousOperation":109,"./rules/LoneSchemaDefinition":110,"./rules/NoFragmentCycles":111,"./rules/NoUndefinedVariables":112,"./rules/NoUnusedFragments":113,"./rules/NoUnusedVariables":114,"./rules/OverlappingFieldsCanBeMerged":115,"./rules/PossibleFragmentSpreads":116,"./rules/PossibleTypeExtensions":117,"./rules/ProvidedRequiredArguments":118,"./rules/ScalarLeafs":119,"./rules/SingleFieldSubscriptions":120,"./rules/UniqueArgumentNames":121,"./rules/UniqueDirectiveNames":122,"./rules/UniqueDirectivesPerLocation":123,"./rules/UniqueEnumValueNames":124,"./rules/UniqueFieldDefinitionNames":125,"./rules/UniqueFragmentNames":126,"./rules/UniqueInputFieldNames":127,"./rules/UniqueOperationNames":128,"./rules/UniqueOperationTypes":129,"./rules/UniqueTypeNames":130,"./rules/UniqueVariableNames":131,"./rules/ValuesOfCorrectType":132,"./rules/VariablesAreInputTypes":133,"./rules/VariablesInAllowedPosition":134}],136:[function(require,module,exports){
  29777. "use strict";
  29778. Object.defineProperty(exports, "__esModule", {
  29779. value: true
  29780. });
  29781. exports.validate = validate;
  29782. exports.validateSDL = validateSDL;
  29783. exports.assertValidSDL = assertValidSDL;
  29784. exports.assertValidSDLExtension = assertValidSDLExtension;
  29785. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  29786. var _visitor = require("../language/visitor");
  29787. var _validate = require("../type/validate");
  29788. var _TypeInfo = require("../utilities/TypeInfo");
  29789. var _specifiedRules = require("./specifiedRules");
  29790. var _ValidationContext = require("./ValidationContext");
  29791. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29792. /**
  29793. * Copyright (c) Facebook, Inc. and its affiliates.
  29794. *
  29795. * This source code is licensed under the MIT license found in the
  29796. * LICENSE file in the root directory of this source tree.
  29797. *
  29798. *
  29799. */
  29800. /**
  29801. * Implements the "Validation" section of the spec.
  29802. *
  29803. * Validation runs synchronously, returning an array of encountered errors, or
  29804. * an empty array if no errors were encountered and the document is valid.
  29805. *
  29806. * A list of specific validation rules may be provided. If not provided, the
  29807. * default list of rules defined by the GraphQL specification will be used.
  29808. *
  29809. * Each validation rules is a function which returns a visitor
  29810. * (see the language/visitor API). Visitor methods are expected to return
  29811. * GraphQLErrors, or Arrays of GraphQLErrors when invalid.
  29812. *
  29813. * Optionally a custom TypeInfo instance may be provided. If not provided, one
  29814. * will be created from the provided schema.
  29815. */
  29816. function validate(schema, documentAST) {
  29817. var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _specifiedRules.specifiedRules;
  29818. var typeInfo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _TypeInfo.TypeInfo(schema);
  29819. !documentAST ? (0, _invariant.default)(0, 'Must provide document') : void 0; // If the schema used for validation is invalid, throw an error.
  29820. (0, _validate.assertValidSchema)(schema);
  29821. var context = new _ValidationContext.ValidationContext(schema, documentAST, typeInfo); // This uses a specialized visitor which runs multiple visitors in parallel,
  29822. // while maintaining the visitor skip and break API.
  29823. var visitor = (0, _visitor.visitInParallel)(rules.map(function (rule) {
  29824. return rule(context);
  29825. })); // Visit the whole document with each instance of all provided rules.
  29826. (0, _visitor.visit)(documentAST, (0, _visitor.visitWithTypeInfo)(typeInfo, visitor));
  29827. return context.getErrors();
  29828. } // @internal
  29829. function validateSDL(documentAST, schemaToExtend) {
  29830. var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _specifiedRules.specifiedSDLRules;
  29831. var context = new _ValidationContext.SDLValidationContext(documentAST, schemaToExtend);
  29832. var visitors = rules.map(function (rule) {
  29833. return rule(context);
  29834. });
  29835. (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors));
  29836. return context.getErrors();
  29837. }
  29838. /**
  29839. * Utility function which asserts a SDL document is valid by throwing an error
  29840. * if it is invalid.
  29841. *
  29842. * @internal
  29843. */
  29844. function assertValidSDL(documentAST) {
  29845. var errors = validateSDL(documentAST);
  29846. if (errors.length !== 0) {
  29847. throw new Error(errors.map(function (error) {
  29848. return error.message;
  29849. }).join('\n\n'));
  29850. }
  29851. }
  29852. /**
  29853. * Utility function which asserts a SDL document is valid by throwing an error
  29854. * if it is invalid.
  29855. *
  29856. * @internal
  29857. */
  29858. function assertValidSDLExtension(documentAST, schema) {
  29859. var errors = validateSDL(documentAST, schema);
  29860. if (errors.length !== 0) {
  29861. throw new Error(errors.map(function (error) {
  29862. return error.message;
  29863. }).join('\n\n'));
  29864. }
  29865. }
  29866. },{"../jsutils/invariant":34,"../language/visitor":58,"../type/validate":74,"../utilities/TypeInfo":75,"./ValidationContext":100,"./specifiedRules":135}],137:[function(require,module,exports){
  29867. 'use strict';
  29868. exports.isIterable = isIterable;
  29869. exports.isArrayLike = isArrayLike;
  29870. exports.isCollection = isCollection;
  29871. exports.getIterator = getIterator;
  29872. exports.getIteratorMethod = getIteratorMethod;
  29873. exports.createIterator = createIterator;
  29874. exports.forEach = forEach;
  29875. exports.isAsyncIterable = isAsyncIterable;
  29876. exports.getAsyncIterator = getAsyncIterator;
  29877. exports.getAsyncIteratorMethod = getAsyncIteratorMethod;
  29878. exports.createAsyncIterator = createAsyncIterator;
  29879. exports.forAwaitEach = forAwaitEach;
  29880. var SYMBOL = typeof Symbol === 'function' ? Symbol : void 0;
  29881. var SYMBOL_ITERATOR = SYMBOL && SYMBOL.iterator;
  29882. var $$iterator = exports.$$iterator = SYMBOL_ITERATOR || '@@iterator';
  29883. function isIterable(obj) {
  29884. return !!getIteratorMethod(obj);
  29885. }
  29886. function isArrayLike(obj) {
  29887. var length = obj != null && obj.length;
  29888. return typeof length === 'number' && length >= 0 && length % 1 === 0;
  29889. }
  29890. function isCollection(obj) {
  29891. return Object(obj) === obj && (isArrayLike(obj) || isIterable(obj));
  29892. }
  29893. function getIterator(iterable) {
  29894. var method = getIteratorMethod(iterable);
  29895. if (method) {
  29896. return method.call(iterable);
  29897. }
  29898. }
  29899. function getIteratorMethod(iterable) {
  29900. if (iterable != null) {
  29901. var method = SYMBOL_ITERATOR && iterable[SYMBOL_ITERATOR] || iterable['@@iterator'];
  29902. if (typeof method === 'function') {
  29903. return method;
  29904. }
  29905. }
  29906. }
  29907. function createIterator(collection) {
  29908. if (collection != null) {
  29909. var iterator = getIterator(collection);
  29910. if (iterator) {
  29911. return iterator;
  29912. }
  29913. if (isArrayLike(collection)) {
  29914. return new ArrayLikeIterator(collection);
  29915. }
  29916. }
  29917. }
  29918. function ArrayLikeIterator(obj) {
  29919. this._o = obj;
  29920. this._i = 0;
  29921. }
  29922. ArrayLikeIterator.prototype[$$iterator] = function () {
  29923. return this;
  29924. };
  29925. ArrayLikeIterator.prototype.next = function () {
  29926. if (this._o === void 0 || this._i >= this._o.length) {
  29927. this._o = void 0;
  29928. return { value: void 0, done: true };
  29929. }
  29930. return { value: this._o[this._i++], done: false };
  29931. };
  29932. function forEach(collection, callback, thisArg) {
  29933. if (collection != null) {
  29934. if (typeof collection.forEach === 'function') {
  29935. return collection.forEach(callback, thisArg);
  29936. }
  29937. var i = 0;
  29938. var iterator = getIterator(collection);
  29939. if (iterator) {
  29940. var step;
  29941. while (!(step = iterator.next()).done) {
  29942. callback.call(thisArg, step.value, i++, collection);
  29943. if (i > 9999999) {
  29944. throw new TypeError('Near-infinite iteration.');
  29945. }
  29946. }
  29947. } else if (isArrayLike(collection)) {
  29948. for (; i < collection.length; i++) {
  29949. if (collection.hasOwnProperty(i)) {
  29950. callback.call(thisArg, collection[i], i, collection);
  29951. }
  29952. }
  29953. }
  29954. }
  29955. }
  29956. var SYMBOL_ASYNC_ITERATOR = SYMBOL && SYMBOL.asyncIterator;
  29957. var $$asyncIterator = exports.$$asyncIterator = SYMBOL_ASYNC_ITERATOR || '@@asyncIterator';
  29958. function isAsyncIterable(obj) {
  29959. return !!getAsyncIteratorMethod(obj);
  29960. }
  29961. function getAsyncIterator(asyncIterable) {
  29962. var method = getAsyncIteratorMethod(asyncIterable);
  29963. if (method) {
  29964. return method.call(asyncIterable);
  29965. }
  29966. }
  29967. function getAsyncIteratorMethod(asyncIterable) {
  29968. if (asyncIterable != null) {
  29969. var method = SYMBOL_ASYNC_ITERATOR && asyncIterable[SYMBOL_ASYNC_ITERATOR] || asyncIterable['@@asyncIterator'];
  29970. if (typeof method === 'function') {
  29971. return method;
  29972. }
  29973. }
  29974. }
  29975. function createAsyncIterator(source) {
  29976. if (source != null) {
  29977. var asyncIterator = getAsyncIterator(source);
  29978. if (asyncIterator) {
  29979. return asyncIterator;
  29980. }
  29981. var iterator = createIterator(source);
  29982. if (iterator) {
  29983. return new AsyncFromSyncIterator(iterator);
  29984. }
  29985. }
  29986. }
  29987. function AsyncFromSyncIterator(iterator) {
  29988. this._i = iterator;
  29989. }
  29990. AsyncFromSyncIterator.prototype[$$asyncIterator] = function () {
  29991. return this;
  29992. };
  29993. AsyncFromSyncIterator.prototype.next = function () {
  29994. var step = this._i.next();
  29995. return Promise.resolve(step.value).then(function (value) {
  29996. return { value: value, done: step.done };
  29997. });
  29998. };
  29999. function forAwaitEach(source, callback, thisArg) {
  30000. var asyncIterator = createAsyncIterator(source);
  30001. if (asyncIterator) {
  30002. var i = 0;
  30003. return new Promise(function (resolve, reject) {
  30004. function next() {
  30005. asyncIterator.next().then(function (step) {
  30006. if (!step.done) {
  30007. Promise.resolve(callback.call(thisArg, step.value, i++, source)).then(next).catch(reject);
  30008. } else {
  30009. resolve();
  30010. }
  30011. return null;
  30012. }).catch(reject);
  30013. return null;
  30014. }
  30015. next();
  30016. });
  30017. }
  30018. }
  30019. },{}],138:[function(require,module,exports){
  30020. 'use strict';
  30021. ////////////////////////////////////////////////////////////////////////////////
  30022. // Helpers
  30023. // Merge objects
  30024. //
  30025. function assign(obj /*from1, from2, from3, ...*/) {
  30026. var sources = Array.prototype.slice.call(arguments, 1);
  30027. sources.forEach(function (source) {
  30028. if (!source) { return; }
  30029. Object.keys(source).forEach(function (key) {
  30030. obj[key] = source[key];
  30031. });
  30032. });
  30033. return obj;
  30034. }
  30035. function _class(obj) { return Object.prototype.toString.call(obj); }
  30036. function isString(obj) { return _class(obj) === '[object String]'; }
  30037. function isObject(obj) { return _class(obj) === '[object Object]'; }
  30038. function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }
  30039. function isFunction(obj) { return _class(obj) === '[object Function]'; }
  30040. function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }
  30041. ////////////////////////////////////////////////////////////////////////////////
  30042. var defaultOptions = {
  30043. fuzzyLink: true,
  30044. fuzzyEmail: true,
  30045. fuzzyIP: false
  30046. };
  30047. function isOptionsObj(obj) {
  30048. return Object.keys(obj || {}).reduce(function (acc, k) {
  30049. return acc || defaultOptions.hasOwnProperty(k);
  30050. }, false);
  30051. }
  30052. var defaultSchemas = {
  30053. 'http:': {
  30054. validate: function (text, pos, self) {
  30055. var tail = text.slice(pos);
  30056. if (!self.re.http) {
  30057. // compile lazily, because "host"-containing variables can change on tlds update.
  30058. self.re.http = new RegExp(
  30059. '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
  30060. );
  30061. }
  30062. if (self.re.http.test(tail)) {
  30063. return tail.match(self.re.http)[0].length;
  30064. }
  30065. return 0;
  30066. }
  30067. },
  30068. 'https:': 'http:',
  30069. 'ftp:': 'http:',
  30070. '//': {
  30071. validate: function (text, pos, self) {
  30072. var tail = text.slice(pos);
  30073. if (!self.re.no_http) {
  30074. // compile lazily, because "host"-containing variables can change on tlds update.
  30075. self.re.no_http = new RegExp(
  30076. '^' +
  30077. self.re.src_auth +
  30078. // Don't allow single-level domains, because of false positives like '//test'
  30079. // with code comments
  30080. '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
  30081. self.re.src_port +
  30082. self.re.src_host_terminator +
  30083. self.re.src_path,
  30084. 'i'
  30085. );
  30086. }
  30087. if (self.re.no_http.test(tail)) {
  30088. // should not be `://` & `///`, that protects from errors in protocol name
  30089. if (pos >= 3 && text[pos - 3] === ':') { return 0; }
  30090. if (pos >= 3 && text[pos - 3] === '/') { return 0; }
  30091. return tail.match(self.re.no_http)[0].length;
  30092. }
  30093. return 0;
  30094. }
  30095. },
  30096. 'mailto:': {
  30097. validate: function (text, pos, self) {
  30098. var tail = text.slice(pos);
  30099. if (!self.re.mailto) {
  30100. self.re.mailto = new RegExp(
  30101. '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
  30102. );
  30103. }
  30104. if (self.re.mailto.test(tail)) {
  30105. return tail.match(self.re.mailto)[0].length;
  30106. }
  30107. return 0;
  30108. }
  30109. }
  30110. };
  30111. /*eslint-disable max-len*/
  30112. // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
  30113. var tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
  30114. // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
  30115. var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
  30116. /*eslint-enable max-len*/
  30117. ////////////////////////////////////////////////////////////////////////////////
  30118. function resetScanCache(self) {
  30119. self.__index__ = -1;
  30120. self.__text_cache__ = '';
  30121. }
  30122. function createValidator(re) {
  30123. return function (text, pos) {
  30124. var tail = text.slice(pos);
  30125. if (re.test(tail)) {
  30126. return tail.match(re)[0].length;
  30127. }
  30128. return 0;
  30129. };
  30130. }
  30131. function createNormalizer() {
  30132. return function (match, self) {
  30133. self.normalize(match);
  30134. };
  30135. }
  30136. // Schemas compiler. Build regexps.
  30137. //
  30138. function compile(self) {
  30139. // Load & clone RE patterns.
  30140. var re = self.re = require('./lib/re')(self.__opts__);
  30141. // Define dynamic patterns
  30142. var tlds = self.__tlds__.slice();
  30143. self.onCompile();
  30144. if (!self.__tlds_replaced__) {
  30145. tlds.push(tlds_2ch_src_re);
  30146. }
  30147. tlds.push(re.src_xn);
  30148. re.src_tlds = tlds.join('|');
  30149. function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }
  30150. re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
  30151. re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
  30152. re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
  30153. re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
  30154. //
  30155. // Compile each schema
  30156. //
  30157. var aliases = [];
  30158. self.__compiled__ = {}; // Reset compiled data
  30159. function schemaError(name, val) {
  30160. throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
  30161. }
  30162. Object.keys(self.__schemas__).forEach(function (name) {
  30163. var val = self.__schemas__[name];
  30164. // skip disabled methods
  30165. if (val === null) { return; }
  30166. var compiled = { validate: null, link: null };
  30167. self.__compiled__[name] = compiled;
  30168. if (isObject(val)) {
  30169. if (isRegExp(val.validate)) {
  30170. compiled.validate = createValidator(val.validate);
  30171. } else if (isFunction(val.validate)) {
  30172. compiled.validate = val.validate;
  30173. } else {
  30174. schemaError(name, val);
  30175. }
  30176. if (isFunction(val.normalize)) {
  30177. compiled.normalize = val.normalize;
  30178. } else if (!val.normalize) {
  30179. compiled.normalize = createNormalizer();
  30180. } else {
  30181. schemaError(name, val);
  30182. }
  30183. return;
  30184. }
  30185. if (isString(val)) {
  30186. aliases.push(name);
  30187. return;
  30188. }
  30189. schemaError(name, val);
  30190. });
  30191. //
  30192. // Compile postponed aliases
  30193. //
  30194. aliases.forEach(function (alias) {
  30195. if (!self.__compiled__[self.__schemas__[alias]]) {
  30196. // Silently fail on missed schemas to avoid errons on disable.
  30197. // schemaError(alias, self.__schemas__[alias]);
  30198. return;
  30199. }
  30200. self.__compiled__[alias].validate =
  30201. self.__compiled__[self.__schemas__[alias]].validate;
  30202. self.__compiled__[alias].normalize =
  30203. self.__compiled__[self.__schemas__[alias]].normalize;
  30204. });
  30205. //
  30206. // Fake record for guessed links
  30207. //
  30208. self.__compiled__[''] = { validate: null, normalize: createNormalizer() };
  30209. //
  30210. // Build schema condition
  30211. //
  30212. var slist = Object.keys(self.__compiled__)
  30213. .filter(function (name) {
  30214. // Filter disabled & fake schemas
  30215. return name.length > 0 && self.__compiled__[name];
  30216. })
  30217. .map(escapeRE)
  30218. .join('|');
  30219. // (?!_) cause 1.5x slowdown
  30220. self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
  30221. self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
  30222. self.re.pretest = RegExp(
  30223. '(' + self.re.schema_test.source + ')|' +
  30224. '(' + self.re.host_fuzzy_test.source + ')|' +
  30225. '@',
  30226. 'i');
  30227. //
  30228. // Cleanup
  30229. //
  30230. resetScanCache(self);
  30231. }
  30232. /**
  30233. * class Match
  30234. *
  30235. * Match result. Single element of array, returned by [[LinkifyIt#match]]
  30236. **/
  30237. function Match(self, shift) {
  30238. var start = self.__index__,
  30239. end = self.__last_index__,
  30240. text = self.__text_cache__.slice(start, end);
  30241. /**
  30242. * Match#schema -> String
  30243. *
  30244. * Prefix (protocol) for matched string.
  30245. **/
  30246. this.schema = self.__schema__.toLowerCase();
  30247. /**
  30248. * Match#index -> Number
  30249. *
  30250. * First position of matched string.
  30251. **/
  30252. this.index = start + shift;
  30253. /**
  30254. * Match#lastIndex -> Number
  30255. *
  30256. * Next position after matched string.
  30257. **/
  30258. this.lastIndex = end + shift;
  30259. /**
  30260. * Match#raw -> String
  30261. *
  30262. * Matched string.
  30263. **/
  30264. this.raw = text;
  30265. /**
  30266. * Match#text -> String
  30267. *
  30268. * Notmalized text of matched string.
  30269. **/
  30270. this.text = text;
  30271. /**
  30272. * Match#url -> String
  30273. *
  30274. * Normalized url of matched string.
  30275. **/
  30276. this.url = text;
  30277. }
  30278. function createMatch(self, shift) {
  30279. var match = new Match(self, shift);
  30280. self.__compiled__[match.schema].normalize(match, self);
  30281. return match;
  30282. }
  30283. /**
  30284. * class LinkifyIt
  30285. **/
  30286. /**
  30287. * new LinkifyIt(schemas, options)
  30288. * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
  30289. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  30290. *
  30291. * Creates new linkifier instance with optional additional schemas.
  30292. * Can be called without `new` keyword for convenience.
  30293. *
  30294. * By default understands:
  30295. *
  30296. * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
  30297. * - "fuzzy" links and emails (example.com, foo@bar.com).
  30298. *
  30299. * `schemas` is an object, where each key/value describes protocol/rule:
  30300. *
  30301. * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
  30302. * for example). `linkify-it` makes shure that prefix is not preceeded with
  30303. * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
  30304. * - __value__ - rule to check tail after link prefix
  30305. * - _String_ - just alias to existing rule
  30306. * - _Object_
  30307. * - _validate_ - validator function (should return matched length on success),
  30308. * or `RegExp`.
  30309. * - _normalize_ - optional function to normalize text & url of matched result
  30310. * (for example, for @twitter mentions).
  30311. *
  30312. * `options`:
  30313. *
  30314. * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
  30315. * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
  30316. * like version numbers. Default `false`.
  30317. * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
  30318. *
  30319. **/
  30320. function LinkifyIt(schemas, options) {
  30321. if (!(this instanceof LinkifyIt)) {
  30322. return new LinkifyIt(schemas, options);
  30323. }
  30324. if (!options) {
  30325. if (isOptionsObj(schemas)) {
  30326. options = schemas;
  30327. schemas = {};
  30328. }
  30329. }
  30330. this.__opts__ = assign({}, defaultOptions, options);
  30331. // Cache last tested result. Used to skip repeating steps on next `match` call.
  30332. this.__index__ = -1;
  30333. this.__last_index__ = -1; // Next scan position
  30334. this.__schema__ = '';
  30335. this.__text_cache__ = '';
  30336. this.__schemas__ = assign({}, defaultSchemas, schemas);
  30337. this.__compiled__ = {};
  30338. this.__tlds__ = tlds_default;
  30339. this.__tlds_replaced__ = false;
  30340. this.re = {};
  30341. compile(this);
  30342. }
  30343. /** chainable
  30344. * LinkifyIt#add(schema, definition)
  30345. * - schema (String): rule name (fixed pattern prefix)
  30346. * - definition (String|RegExp|Object): schema definition
  30347. *
  30348. * Add new rule definition. See constructor description for details.
  30349. **/
  30350. LinkifyIt.prototype.add = function add(schema, definition) {
  30351. this.__schemas__[schema] = definition;
  30352. compile(this);
  30353. return this;
  30354. };
  30355. /** chainable
  30356. * LinkifyIt#set(options)
  30357. * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
  30358. *
  30359. * Set recognition options for links without schema.
  30360. **/
  30361. LinkifyIt.prototype.set = function set(options) {
  30362. this.__opts__ = assign(this.__opts__, options);
  30363. return this;
  30364. };
  30365. /**
  30366. * LinkifyIt#test(text) -> Boolean
  30367. *
  30368. * Searches linkifiable pattern and returns `true` on success or `false` on fail.
  30369. **/
  30370. LinkifyIt.prototype.test = function test(text) {
  30371. // Reset scan cache
  30372. this.__text_cache__ = text;
  30373. this.__index__ = -1;
  30374. if (!text.length) { return false; }
  30375. var m, ml, me, len, shift, next, re, tld_pos, at_pos;
  30376. // try to scan for link with schema - that's the most simple rule
  30377. if (this.re.schema_test.test(text)) {
  30378. re = this.re.schema_search;
  30379. re.lastIndex = 0;
  30380. while ((m = re.exec(text)) !== null) {
  30381. len = this.testSchemaAt(text, m[2], re.lastIndex);
  30382. if (len) {
  30383. this.__schema__ = m[2];
  30384. this.__index__ = m.index + m[1].length;
  30385. this.__last_index__ = m.index + m[0].length + len;
  30386. break;
  30387. }
  30388. }
  30389. }
  30390. if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
  30391. // guess schemaless links
  30392. tld_pos = text.search(this.re.host_fuzzy_test);
  30393. if (tld_pos >= 0) {
  30394. // if tld is located after found link - no need to check fuzzy pattern
  30395. if (this.__index__ < 0 || tld_pos < this.__index__) {
  30396. if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
  30397. shift = ml.index + ml[1].length;
  30398. if (this.__index__ < 0 || shift < this.__index__) {
  30399. this.__schema__ = '';
  30400. this.__index__ = shift;
  30401. this.__last_index__ = ml.index + ml[0].length;
  30402. }
  30403. }
  30404. }
  30405. }
  30406. }
  30407. if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
  30408. // guess schemaless emails
  30409. at_pos = text.indexOf('@');
  30410. if (at_pos >= 0) {
  30411. // We can't skip this check, because this cases are possible:
  30412. // 192.168.1.1@gmail.com, my.in@example.com
  30413. if ((me = text.match(this.re.email_fuzzy)) !== null) {
  30414. shift = me.index + me[1].length;
  30415. next = me.index + me[0].length;
  30416. if (this.__index__ < 0 || shift < this.__index__ ||
  30417. (shift === this.__index__ && next > this.__last_index__)) {
  30418. this.__schema__ = 'mailto:';
  30419. this.__index__ = shift;
  30420. this.__last_index__ = next;
  30421. }
  30422. }
  30423. }
  30424. }
  30425. return this.__index__ >= 0;
  30426. };
  30427. /**
  30428. * LinkifyIt#pretest(text) -> Boolean
  30429. *
  30430. * Very quick check, that can give false positives. Returns true if link MAY BE
  30431. * can exists. Can be used for speed optimization, when you need to check that
  30432. * link NOT exists.
  30433. **/
  30434. LinkifyIt.prototype.pretest = function pretest(text) {
  30435. return this.re.pretest.test(text);
  30436. };
  30437. /**
  30438. * LinkifyIt#testSchemaAt(text, name, position) -> Number
  30439. * - text (String): text to scan
  30440. * - name (String): rule (schema) name
  30441. * - position (Number): text offset to check from
  30442. *
  30443. * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
  30444. * at given position. Returns length of found pattern (0 on fail).
  30445. **/
  30446. LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
  30447. // If not supported schema check requested - terminate
  30448. if (!this.__compiled__[schema.toLowerCase()]) {
  30449. return 0;
  30450. }
  30451. return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
  30452. };
  30453. /**
  30454. * LinkifyIt#match(text) -> Array|null
  30455. *
  30456. * Returns array of found link descriptions or `null` on fail. We strongly
  30457. * recommend to use [[LinkifyIt#test]] first, for best speed.
  30458. *
  30459. * ##### Result match description
  30460. *
  30461. * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
  30462. * protocol-neutral links.
  30463. * - __index__ - offset of matched text
  30464. * - __lastIndex__ - index of next char after mathch end
  30465. * - __raw__ - matched text
  30466. * - __text__ - normalized text
  30467. * - __url__ - link, generated from matched text
  30468. **/
  30469. LinkifyIt.prototype.match = function match(text) {
  30470. var shift = 0, result = [];
  30471. // Try to take previous element from cache, if .test() called before
  30472. if (this.__index__ >= 0 && this.__text_cache__ === text) {
  30473. result.push(createMatch(this, shift));
  30474. shift = this.__last_index__;
  30475. }
  30476. // Cut head if cache was used
  30477. var tail = shift ? text.slice(shift) : text;
  30478. // Scan string until end reached
  30479. while (this.test(tail)) {
  30480. result.push(createMatch(this, shift));
  30481. tail = tail.slice(this.__last_index__);
  30482. shift += this.__last_index__;
  30483. }
  30484. if (result.length) {
  30485. return result;
  30486. }
  30487. return null;
  30488. };
  30489. /** chainable
  30490. * LinkifyIt#tlds(list [, keepOld]) -> this
  30491. * - list (Array): list of tlds
  30492. * - keepOld (Boolean): merge with current list if `true` (`false` by default)
  30493. *
  30494. * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
  30495. * to avoid false positives. By default this algorythm used:
  30496. *
  30497. * - hostname with any 2-letter root zones are ok.
  30498. * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
  30499. * are ok.
  30500. * - encoded (`xn--...`) root zones are ok.
  30501. *
  30502. * If list is replaced, then exact match for 2-chars root zones will be checked.
  30503. **/
  30504. LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
  30505. list = Array.isArray(list) ? list : [ list ];
  30506. if (!keepOld) {
  30507. this.__tlds__ = list.slice();
  30508. this.__tlds_replaced__ = true;
  30509. compile(this);
  30510. return this;
  30511. }
  30512. this.__tlds__ = this.__tlds__.concat(list)
  30513. .sort()
  30514. .filter(function (el, idx, arr) {
  30515. return el !== arr[idx - 1];
  30516. })
  30517. .reverse();
  30518. compile(this);
  30519. return this;
  30520. };
  30521. /**
  30522. * LinkifyIt#normalize(match)
  30523. *
  30524. * Default normalizer (if schema does not define it's own).
  30525. **/
  30526. LinkifyIt.prototype.normalize = function normalize(match) {
  30527. // Do minimal possible changes by default. Need to collect feedback prior
  30528. // to move forward https://github.com/markdown-it/linkify-it/issues/1
  30529. if (!match.schema) { match.url = 'http://' + match.url; }
  30530. if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
  30531. match.url = 'mailto:' + match.url;
  30532. }
  30533. };
  30534. /**
  30535. * LinkifyIt#onCompile()
  30536. *
  30537. * Override to modify basic RegExp-s.
  30538. **/
  30539. LinkifyIt.prototype.onCompile = function onCompile() {
  30540. };
  30541. module.exports = LinkifyIt;
  30542. },{"./lib/re":139}],139:[function(require,module,exports){
  30543. 'use strict';
  30544. module.exports = function (opts) {
  30545. var re = {};
  30546. // Use direct extract instead of `regenerate` to reduse browserified size
  30547. re.src_Any = require('uc.micro/properties/Any/regex').source;
  30548. re.src_Cc = require('uc.micro/categories/Cc/regex').source;
  30549. re.src_Z = require('uc.micro/categories/Z/regex').source;
  30550. re.src_P = require('uc.micro/categories/P/regex').source;
  30551. // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
  30552. re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');
  30553. // \p{\Z\Cc} (white spaces + control)
  30554. re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');
  30555. // Experimental. List of chars, completely prohibited in links
  30556. // because can separate it from other part of text
  30557. var text_separators = '[><\uff5c]';
  30558. // All possible word characters (everything without punctuation, spaces & controls)
  30559. // Defined via punctuation & spaces to save space
  30560. // Should be something like \p{\L\N\S\M} (\w but without `_`)
  30561. re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
  30562. // The same as abothe but without [0-9]
  30563. // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
  30564. ////////////////////////////////////////////////////////////////////////////////
  30565. re.src_ip4 =
  30566. '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
  30567. // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
  30568. re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
  30569. re.src_port =
  30570. '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
  30571. re.src_host_terminator =
  30572. '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
  30573. re.src_path =
  30574. '(?:' +
  30575. '[/?#]' +
  30576. '(?:' +
  30577. '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
  30578. '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
  30579. '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
  30580. '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
  30581. '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
  30582. "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
  30583. "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
  30584. '\\.{2,3}[a-zA-Z0-9%/]|' + // github has ... in commit range links. Restrict to
  30585. // - english
  30586. // - percent-encoded
  30587. // - parts of file path
  30588. // until more examples found.
  30589. '\\.(?!' + re.src_ZCc + '|[.]).|' +
  30590. (opts && opts['---'] ?
  30591. '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
  30592. :
  30593. '\\-+|'
  30594. ) +
  30595. '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
  30596. '\\!(?!' + re.src_ZCc + '|[!]).|' +
  30597. '\\?(?!' + re.src_ZCc + '|[?]).' +
  30598. ')+' +
  30599. '|\\/' +
  30600. ')?';
  30601. re.src_email_name =
  30602. '[\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]+';
  30603. re.src_xn =
  30604. 'xn--[a-z0-9\\-]{1,59}';
  30605. // More to read about domain names
  30606. // http://serverfault.com/questions/638260/
  30607. re.src_domain_root =
  30608. // Allow letters & digits (http://test1)
  30609. '(?:' +
  30610. re.src_xn +
  30611. '|' +
  30612. re.src_pseudo_letter + '{1,63}' +
  30613. ')';
  30614. re.src_domain =
  30615. '(?:' +
  30616. re.src_xn +
  30617. '|' +
  30618. '(?:' + re.src_pseudo_letter + ')' +
  30619. '|' +
  30620. // don't allow `--` in domain names, because:
  30621. // - that can conflict with markdown &mdash; / &ndash;
  30622. // - nobody use those anyway
  30623. '(?:' + re.src_pseudo_letter + '(?:-(?!-)|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
  30624. ')';
  30625. re.src_host =
  30626. '(?:' +
  30627. // Don't need IP check, because digits are already allowed in normal domain names
  30628. // src_ip4 +
  30629. // '|' +
  30630. '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
  30631. ')';
  30632. re.tpl_host_fuzzy =
  30633. '(?:' +
  30634. re.src_ip4 +
  30635. '|' +
  30636. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
  30637. ')';
  30638. re.tpl_host_no_ip_fuzzy =
  30639. '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
  30640. re.src_host_strict =
  30641. re.src_host + re.src_host_terminator;
  30642. re.tpl_host_fuzzy_strict =
  30643. re.tpl_host_fuzzy + re.src_host_terminator;
  30644. re.src_host_port_strict =
  30645. re.src_host + re.src_port + re.src_host_terminator;
  30646. re.tpl_host_port_fuzzy_strict =
  30647. re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
  30648. re.tpl_host_port_no_ip_fuzzy_strict =
  30649. re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
  30650. ////////////////////////////////////////////////////////////////////////////////
  30651. // Main rules
  30652. // Rude test fuzzy links by host, for quick deny
  30653. re.tpl_host_fuzzy_test =
  30654. 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
  30655. re.tpl_email_fuzzy =
  30656. '(^|' + text_separators + '|\\(|' + re.src_ZCc + ')(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
  30657. re.tpl_link_fuzzy =
  30658. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  30659. // but can start with > (markdown blockquote)
  30660. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  30661. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
  30662. re.tpl_link_no_ip_fuzzy =
  30663. // Fuzzy link can't be prepended with .:/\- and non punctuation.
  30664. // but can start with > (markdown blockquote)
  30665. '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
  30666. '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
  30667. return re;
  30668. };
  30669. },{"uc.micro/categories/Cc/regex":208,"uc.micro/categories/P/regex":210,"uc.micro/categories/Z/regex":211,"uc.micro/properties/Any/regex":213}],140:[function(require,module,exports){
  30670. 'use strict';
  30671. module.exports = require('./lib/');
  30672. },{"./lib/":149}],141:[function(require,module,exports){
  30673. // HTML5 entities map: { name -> utf16string }
  30674. //
  30675. 'use strict';
  30676. /*eslint quotes:0*/
  30677. module.exports = require('entities/maps/entities.json');
  30678. },{"entities/maps/entities.json":18}],142:[function(require,module,exports){
  30679. // List of valid html blocks names, accorting to commonmark spec
  30680. // http://jgm.github.io/CommonMark/spec.html#html-blocks
  30681. 'use strict';
  30682. module.exports = [
  30683. 'address',
  30684. 'article',
  30685. 'aside',
  30686. 'base',
  30687. 'basefont',
  30688. 'blockquote',
  30689. 'body',
  30690. 'caption',
  30691. 'center',
  30692. 'col',
  30693. 'colgroup',
  30694. 'dd',
  30695. 'details',
  30696. 'dialog',
  30697. 'dir',
  30698. 'div',
  30699. 'dl',
  30700. 'dt',
  30701. 'fieldset',
  30702. 'figcaption',
  30703. 'figure',
  30704. 'footer',
  30705. 'form',
  30706. 'frame',
  30707. 'frameset',
  30708. 'h1',
  30709. 'h2',
  30710. 'h3',
  30711. 'h4',
  30712. 'h5',
  30713. 'h6',
  30714. 'head',
  30715. 'header',
  30716. 'hr',
  30717. 'html',
  30718. 'iframe',
  30719. 'legend',
  30720. 'li',
  30721. 'link',
  30722. 'main',
  30723. 'menu',
  30724. 'menuitem',
  30725. 'meta',
  30726. 'nav',
  30727. 'noframes',
  30728. 'ol',
  30729. 'optgroup',
  30730. 'option',
  30731. 'p',
  30732. 'param',
  30733. 'section',
  30734. 'source',
  30735. 'summary',
  30736. 'table',
  30737. 'tbody',
  30738. 'td',
  30739. 'tfoot',
  30740. 'th',
  30741. 'thead',
  30742. 'title',
  30743. 'tr',
  30744. 'track',
  30745. 'ul'
  30746. ];
  30747. },{}],143:[function(require,module,exports){
  30748. // Regexps to match html elements
  30749. 'use strict';
  30750. var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
  30751. var unquoted = '[^"\'=<>`\\x00-\\x20]+';
  30752. var single_quoted = "'[^']*'";
  30753. var double_quoted = '"[^"]*"';
  30754. var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';
  30755. var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
  30756. var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
  30757. var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
  30758. var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
  30759. var processing = '<[?].*?[?]>';
  30760. var declaration = '<![A-Z]+\\s+[^>]*>';
  30761. var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
  30762. var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
  30763. '|' + processing + '|' + declaration + '|' + cdata + ')');
  30764. var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
  30765. module.exports.HTML_TAG_RE = HTML_TAG_RE;
  30766. module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;
  30767. },{}],144:[function(require,module,exports){
  30768. // Utilities
  30769. //
  30770. 'use strict';
  30771. function _class(obj) { return Object.prototype.toString.call(obj); }
  30772. function isString(obj) { return _class(obj) === '[object String]'; }
  30773. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  30774. function has(object, key) {
  30775. return _hasOwnProperty.call(object, key);
  30776. }
  30777. // Merge objects
  30778. //
  30779. function assign(obj /*from1, from2, from3, ...*/) {
  30780. var sources = Array.prototype.slice.call(arguments, 1);
  30781. sources.forEach(function (source) {
  30782. if (!source) { return; }
  30783. if (typeof source !== 'object') {
  30784. throw new TypeError(source + 'must be object');
  30785. }
  30786. Object.keys(source).forEach(function (key) {
  30787. obj[key] = source[key];
  30788. });
  30789. });
  30790. return obj;
  30791. }
  30792. // Remove element from array and put another array at those position.
  30793. // Useful for some operations with tokens
  30794. function arrayReplaceAt(src, pos, newElements) {
  30795. return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
  30796. }
  30797. ////////////////////////////////////////////////////////////////////////////////
  30798. function isValidEntityCode(c) {
  30799. /*eslint no-bitwise:0*/
  30800. // broken sequence
  30801. if (c >= 0xD800 && c <= 0xDFFF) { return false; }
  30802. // never used
  30803. if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
  30804. if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
  30805. // control codes
  30806. if (c >= 0x00 && c <= 0x08) { return false; }
  30807. if (c === 0x0B) { return false; }
  30808. if (c >= 0x0E && c <= 0x1F) { return false; }
  30809. if (c >= 0x7F && c <= 0x9F) { return false; }
  30810. // out of range
  30811. if (c > 0x10FFFF) { return false; }
  30812. return true;
  30813. }
  30814. function fromCodePoint(c) {
  30815. /*eslint no-bitwise:0*/
  30816. if (c > 0xffff) {
  30817. c -= 0x10000;
  30818. var surrogate1 = 0xd800 + (c >> 10),
  30819. surrogate2 = 0xdc00 + (c & 0x3ff);
  30820. return String.fromCharCode(surrogate1, surrogate2);
  30821. }
  30822. return String.fromCharCode(c);
  30823. }
  30824. var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
  30825. var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
  30826. var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');
  30827. var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
  30828. var entities = require('./entities');
  30829. function replaceEntityPattern(match, name) {
  30830. var code = 0;
  30831. if (has(entities, name)) {
  30832. return entities[name];
  30833. }
  30834. if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
  30835. code = name[1].toLowerCase() === 'x' ?
  30836. parseInt(name.slice(2), 16)
  30837. :
  30838. parseInt(name.slice(1), 10);
  30839. if (isValidEntityCode(code)) {
  30840. return fromCodePoint(code);
  30841. }
  30842. }
  30843. return match;
  30844. }
  30845. /*function replaceEntities(str) {
  30846. if (str.indexOf('&') < 0) { return str; }
  30847. return str.replace(ENTITY_RE, replaceEntityPattern);
  30848. }*/
  30849. function unescapeMd(str) {
  30850. if (str.indexOf('\\') < 0) { return str; }
  30851. return str.replace(UNESCAPE_MD_RE, '$1');
  30852. }
  30853. function unescapeAll(str) {
  30854. if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; }
  30855. return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {
  30856. if (escaped) { return escaped; }
  30857. return replaceEntityPattern(match, entity);
  30858. });
  30859. }
  30860. ////////////////////////////////////////////////////////////////////////////////
  30861. var HTML_ESCAPE_TEST_RE = /[&<>"]/;
  30862. var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
  30863. var HTML_REPLACEMENTS = {
  30864. '&': '&amp;',
  30865. '<': '&lt;',
  30866. '>': '&gt;',
  30867. '"': '&quot;'
  30868. };
  30869. function replaceUnsafeChar(ch) {
  30870. return HTML_REPLACEMENTS[ch];
  30871. }
  30872. function escapeHtml(str) {
  30873. if (HTML_ESCAPE_TEST_RE.test(str)) {
  30874. return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
  30875. }
  30876. return str;
  30877. }
  30878. ////////////////////////////////////////////////////////////////////////////////
  30879. var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
  30880. function escapeRE(str) {
  30881. return str.replace(REGEXP_ESCAPE_RE, '\\$&');
  30882. }
  30883. ////////////////////////////////////////////////////////////////////////////////
  30884. function isSpace(code) {
  30885. switch (code) {
  30886. case 0x09:
  30887. case 0x20:
  30888. return true;
  30889. }
  30890. return false;
  30891. }
  30892. // Zs (unicode class) || [\t\f\v\r\n]
  30893. function isWhiteSpace(code) {
  30894. if (code >= 0x2000 && code <= 0x200A) { return true; }
  30895. switch (code) {
  30896. case 0x09: // \t
  30897. case 0x0A: // \n
  30898. case 0x0B: // \v
  30899. case 0x0C: // \f
  30900. case 0x0D: // \r
  30901. case 0x20:
  30902. case 0xA0:
  30903. case 0x1680:
  30904. case 0x202F:
  30905. case 0x205F:
  30906. case 0x3000:
  30907. return true;
  30908. }
  30909. return false;
  30910. }
  30911. ////////////////////////////////////////////////////////////////////////////////
  30912. /*eslint-disable max-len*/
  30913. var UNICODE_PUNCT_RE = require('uc.micro/categories/P/regex');
  30914. // Currently without astral characters support.
  30915. function isPunctChar(ch) {
  30916. return UNICODE_PUNCT_RE.test(ch);
  30917. }
  30918. // Markdown ASCII punctuation characters.
  30919. //
  30920. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  30921. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  30922. //
  30923. // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
  30924. //
  30925. function isMdAsciiPunct(ch) {
  30926. switch (ch) {
  30927. case 0x21/* ! */:
  30928. case 0x22/* " */:
  30929. case 0x23/* # */:
  30930. case 0x24/* $ */:
  30931. case 0x25/* % */:
  30932. case 0x26/* & */:
  30933. case 0x27/* ' */:
  30934. case 0x28/* ( */:
  30935. case 0x29/* ) */:
  30936. case 0x2A/* * */:
  30937. case 0x2B/* + */:
  30938. case 0x2C/* , */:
  30939. case 0x2D/* - */:
  30940. case 0x2E/* . */:
  30941. case 0x2F/* / */:
  30942. case 0x3A/* : */:
  30943. case 0x3B/* ; */:
  30944. case 0x3C/* < */:
  30945. case 0x3D/* = */:
  30946. case 0x3E/* > */:
  30947. case 0x3F/* ? */:
  30948. case 0x40/* @ */:
  30949. case 0x5B/* [ */:
  30950. case 0x5C/* \ */:
  30951. case 0x5D/* ] */:
  30952. case 0x5E/* ^ */:
  30953. case 0x5F/* _ */:
  30954. case 0x60/* ` */:
  30955. case 0x7B/* { */:
  30956. case 0x7C/* | */:
  30957. case 0x7D/* } */:
  30958. case 0x7E/* ~ */:
  30959. return true;
  30960. default:
  30961. return false;
  30962. }
  30963. }
  30964. // Hepler to unify [reference labels].
  30965. //
  30966. function normalizeReference(str) {
  30967. // use .toUpperCase() instead of .toLowerCase()
  30968. // here to avoid a conflict with Object.prototype
  30969. // members (most notably, `__proto__`)
  30970. return str.trim().replace(/\s+/g, ' ').toUpperCase();
  30971. }
  30972. ////////////////////////////////////////////////////////////////////////////////
  30973. // Re-export libraries commonly used in both markdown-it and its plugins,
  30974. // so plugins won't have to depend on them explicitly, which reduces their
  30975. // bundled size (e.g. a browser build).
  30976. //
  30977. exports.lib = {};
  30978. exports.lib.mdurl = require('mdurl');
  30979. exports.lib.ucmicro = require('uc.micro');
  30980. exports.assign = assign;
  30981. exports.isString = isString;
  30982. exports.has = has;
  30983. exports.unescapeMd = unescapeMd;
  30984. exports.unescapeAll = unescapeAll;
  30985. exports.isValidEntityCode = isValidEntityCode;
  30986. exports.fromCodePoint = fromCodePoint;
  30987. // exports.replaceEntities = replaceEntities;
  30988. exports.escapeHtml = escapeHtml;
  30989. exports.arrayReplaceAt = arrayReplaceAt;
  30990. exports.isSpace = isSpace;
  30991. exports.isWhiteSpace = isWhiteSpace;
  30992. exports.isMdAsciiPunct = isMdAsciiPunct;
  30993. exports.isPunctChar = isPunctChar;
  30994. exports.escapeRE = escapeRE;
  30995. exports.normalizeReference = normalizeReference;
  30996. },{"./entities":141,"mdurl":195,"uc.micro":212,"uc.micro/categories/P/regex":210}],145:[function(require,module,exports){
  30997. // Just a shortcut for bulk export
  30998. 'use strict';
  30999. exports.parseLinkLabel = require('./parse_link_label');
  31000. exports.parseLinkDestination = require('./parse_link_destination');
  31001. exports.parseLinkTitle = require('./parse_link_title');
  31002. },{"./parse_link_destination":146,"./parse_link_label":147,"./parse_link_title":148}],146:[function(require,module,exports){
  31003. // Parse link destination
  31004. //
  31005. 'use strict';
  31006. var isSpace = require('../common/utils').isSpace;
  31007. var unescapeAll = require('../common/utils').unescapeAll;
  31008. module.exports = function parseLinkDestination(str, pos, max) {
  31009. var code, level,
  31010. lines = 0,
  31011. start = pos,
  31012. result = {
  31013. ok: false,
  31014. pos: 0,
  31015. lines: 0,
  31016. str: ''
  31017. };
  31018. if (str.charCodeAt(pos) === 0x3C /* < */) {
  31019. pos++;
  31020. while (pos < max) {
  31021. code = str.charCodeAt(pos);
  31022. if (code === 0x0A /* \n */ || isSpace(code)) { return result; }
  31023. if (code === 0x3E /* > */) {
  31024. result.pos = pos + 1;
  31025. result.str = unescapeAll(str.slice(start + 1, pos));
  31026. result.ok = true;
  31027. return result;
  31028. }
  31029. if (code === 0x5C /* \ */ && pos + 1 < max) {
  31030. pos += 2;
  31031. continue;
  31032. }
  31033. pos++;
  31034. }
  31035. // no closing '>'
  31036. return result;
  31037. }
  31038. // this should be ... } else { ... branch
  31039. level = 0;
  31040. while (pos < max) {
  31041. code = str.charCodeAt(pos);
  31042. if (code === 0x20) { break; }
  31043. // ascii control characters
  31044. if (code < 0x20 || code === 0x7F) { break; }
  31045. if (code === 0x5C /* \ */ && pos + 1 < max) {
  31046. pos += 2;
  31047. continue;
  31048. }
  31049. if (code === 0x28 /* ( */) {
  31050. level++;
  31051. }
  31052. if (code === 0x29 /* ) */) {
  31053. if (level === 0) { break; }
  31054. level--;
  31055. }
  31056. pos++;
  31057. }
  31058. if (start === pos) { return result; }
  31059. if (level !== 0) { return result; }
  31060. result.str = unescapeAll(str.slice(start, pos));
  31061. result.lines = lines;
  31062. result.pos = pos;
  31063. result.ok = true;
  31064. return result;
  31065. };
  31066. },{"../common/utils":144}],147:[function(require,module,exports){
  31067. // Parse link label
  31068. //
  31069. // this function assumes that first character ("[") already matches;
  31070. // returns the end of the label
  31071. //
  31072. 'use strict';
  31073. module.exports = function parseLinkLabel(state, start, disableNested) {
  31074. var level, found, marker, prevPos,
  31075. labelEnd = -1,
  31076. max = state.posMax,
  31077. oldPos = state.pos;
  31078. state.pos = start + 1;
  31079. level = 1;
  31080. while (state.pos < max) {
  31081. marker = state.src.charCodeAt(state.pos);
  31082. if (marker === 0x5D /* ] */) {
  31083. level--;
  31084. if (level === 0) {
  31085. found = true;
  31086. break;
  31087. }
  31088. }
  31089. prevPos = state.pos;
  31090. state.md.inline.skipToken(state);
  31091. if (marker === 0x5B /* [ */) {
  31092. if (prevPos === state.pos - 1) {
  31093. // increase level if we find text `[`, which is not a part of any token
  31094. level++;
  31095. } else if (disableNested) {
  31096. state.pos = oldPos;
  31097. return -1;
  31098. }
  31099. }
  31100. }
  31101. if (found) {
  31102. labelEnd = state.pos;
  31103. }
  31104. // restore old state
  31105. state.pos = oldPos;
  31106. return labelEnd;
  31107. };
  31108. },{}],148:[function(require,module,exports){
  31109. // Parse link title
  31110. //
  31111. 'use strict';
  31112. var unescapeAll = require('../common/utils').unescapeAll;
  31113. module.exports = function parseLinkTitle(str, pos, max) {
  31114. var code,
  31115. marker,
  31116. lines = 0,
  31117. start = pos,
  31118. result = {
  31119. ok: false,
  31120. pos: 0,
  31121. lines: 0,
  31122. str: ''
  31123. };
  31124. if (pos >= max) { return result; }
  31125. marker = str.charCodeAt(pos);
  31126. if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }
  31127. pos++;
  31128. // if opening marker is "(", switch it to closing marker ")"
  31129. if (marker === 0x28) { marker = 0x29; }
  31130. while (pos < max) {
  31131. code = str.charCodeAt(pos);
  31132. if (code === marker) {
  31133. result.pos = pos + 1;
  31134. result.lines = lines;
  31135. result.str = unescapeAll(str.slice(start + 1, pos));
  31136. result.ok = true;
  31137. return result;
  31138. } else if (code === 0x0A) {
  31139. lines++;
  31140. } else if (code === 0x5C /* \ */ && pos + 1 < max) {
  31141. pos++;
  31142. if (str.charCodeAt(pos) === 0x0A) {
  31143. lines++;
  31144. }
  31145. }
  31146. pos++;
  31147. }
  31148. return result;
  31149. };
  31150. },{"../common/utils":144}],149:[function(require,module,exports){
  31151. // Main parser class
  31152. 'use strict';
  31153. var utils = require('./common/utils');
  31154. var helpers = require('./helpers');
  31155. var Renderer = require('./renderer');
  31156. var ParserCore = require('./parser_core');
  31157. var ParserBlock = require('./parser_block');
  31158. var ParserInline = require('./parser_inline');
  31159. var LinkifyIt = require('linkify-it');
  31160. var mdurl = require('mdurl');
  31161. var punycode = require('punycode');
  31162. var config = {
  31163. 'default': require('./presets/default'),
  31164. zero: require('./presets/zero'),
  31165. commonmark: require('./presets/commonmark')
  31166. };
  31167. ////////////////////////////////////////////////////////////////////////////////
  31168. //
  31169. // This validator can prohibit more than really needed to prevent XSS. It's a
  31170. // tradeoff to keep code simple and to be secure by default.
  31171. //
  31172. // If you need different setup - override validator method as you wish. Or
  31173. // replace it with dummy function and use external sanitizer.
  31174. //
  31175. var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
  31176. var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
  31177. function validateLink(url) {
  31178. // url should be normalized at this point, and existing entities are decoded
  31179. var str = url.trim().toLowerCase();
  31180. return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
  31181. }
  31182. ////////////////////////////////////////////////////////////////////////////////
  31183. var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];
  31184. function normalizeLink(url) {
  31185. var parsed = mdurl.parse(url, true);
  31186. if (parsed.hostname) {
  31187. // Encode hostnames in urls like:
  31188. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  31189. //
  31190. // We don't encode unknown schemas, because it's likely that we encode
  31191. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  31192. //
  31193. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  31194. try {
  31195. parsed.hostname = punycode.toASCII(parsed.hostname);
  31196. } catch (er) { /**/ }
  31197. }
  31198. }
  31199. return mdurl.encode(mdurl.format(parsed));
  31200. }
  31201. function normalizeLinkText(url) {
  31202. var parsed = mdurl.parse(url, true);
  31203. if (parsed.hostname) {
  31204. // Encode hostnames in urls like:
  31205. // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
  31206. //
  31207. // We don't encode unknown schemas, because it's likely that we encode
  31208. // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
  31209. //
  31210. if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
  31211. try {
  31212. parsed.hostname = punycode.toUnicode(parsed.hostname);
  31213. } catch (er) { /**/ }
  31214. }
  31215. }
  31216. return mdurl.decode(mdurl.format(parsed));
  31217. }
  31218. /**
  31219. * class MarkdownIt
  31220. *
  31221. * Main parser/renderer class.
  31222. *
  31223. * ##### Usage
  31224. *
  31225. * ```javascript
  31226. * // node.js, "classic" way:
  31227. * var MarkdownIt = require('markdown-it'),
  31228. * md = new MarkdownIt();
  31229. * var result = md.render('# markdown-it rulezz!');
  31230. *
  31231. * // node.js, the same, but with sugar:
  31232. * var md = require('markdown-it')();
  31233. * var result = md.render('# markdown-it rulezz!');
  31234. *
  31235. * // browser without AMD, added to "window" on script load
  31236. * // Note, there are no dash.
  31237. * var md = window.markdownit();
  31238. * var result = md.render('# markdown-it rulezz!');
  31239. * ```
  31240. *
  31241. * Single line rendering, without paragraph wrap:
  31242. *
  31243. * ```javascript
  31244. * var md = require('markdown-it')();
  31245. * var result = md.renderInline('__markdown-it__ rulezz!');
  31246. * ```
  31247. **/
  31248. /**
  31249. * new MarkdownIt([presetName, options])
  31250. * - presetName (String): optional, `commonmark` / `zero`
  31251. * - options (Object)
  31252. *
  31253. * Creates parser instanse with given config. Can be called without `new`.
  31254. *
  31255. * ##### presetName
  31256. *
  31257. * MarkdownIt provides named presets as a convenience to quickly
  31258. * enable/disable active syntax rules and options for common use cases.
  31259. *
  31260. * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
  31261. * configures parser to strict [CommonMark](http://commonmark.org/) mode.
  31262. * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
  31263. * similar to GFM, used when no preset name given. Enables all available rules,
  31264. * but still without html, typographer & autolinker.
  31265. * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
  31266. * all rules disabled. Useful to quickly setup your config via `.enable()`.
  31267. * For example, when you need only `bold` and `italic` markup and nothing else.
  31268. *
  31269. * ##### options:
  31270. *
  31271. * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
  31272. * That's not safe! You may need external sanitizer to protect output from XSS.
  31273. * It's better to extend features via plugins, instead of enabling HTML.
  31274. * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
  31275. * (`<br />`). This is needed only for full CommonMark compatibility. In real
  31276. * world you will need HTML output.
  31277. * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
  31278. * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
  31279. * Can be useful for external highlighters.
  31280. * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
  31281. * - __typographer__ - `false`. Set `true` to enable [some language-neutral
  31282. * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
  31283. * quotes beautification (smartquotes).
  31284. * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
  31285. * pairs, when typographer enabled and smartquotes on. For example, you can
  31286. * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
  31287. * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
  31288. * - __highlight__ - `null`. Highlighter function for fenced code blocks.
  31289. * Highlighter `function (str, lang)` should return escaped HTML. It can also
  31290. * return empty string if the source was not changed and should be escaped
  31291. * externaly. If result starts with <pre... internal wrapper is skipped.
  31292. *
  31293. * ##### Example
  31294. *
  31295. * ```javascript
  31296. * // commonmark mode
  31297. * var md = require('markdown-it')('commonmark');
  31298. *
  31299. * // default mode
  31300. * var md = require('markdown-it')();
  31301. *
  31302. * // enable everything
  31303. * var md = require('markdown-it')({
  31304. * html: true,
  31305. * linkify: true,
  31306. * typographer: true
  31307. * });
  31308. * ```
  31309. *
  31310. * ##### Syntax highlighting
  31311. *
  31312. * ```js
  31313. * var hljs = require('highlight.js') // https://highlightjs.org/
  31314. *
  31315. * var md = require('markdown-it')({
  31316. * highlight: function (str, lang) {
  31317. * if (lang && hljs.getLanguage(lang)) {
  31318. * try {
  31319. * return hljs.highlight(lang, str, true).value;
  31320. * } catch (__) {}
  31321. * }
  31322. *
  31323. * return ''; // use external default escaping
  31324. * }
  31325. * });
  31326. * ```
  31327. *
  31328. * Or with full wrapper override (if you need assign class to `<pre>`):
  31329. *
  31330. * ```javascript
  31331. * var hljs = require('highlight.js') // https://highlightjs.org/
  31332. *
  31333. * // Actual default values
  31334. * var md = require('markdown-it')({
  31335. * highlight: function (str, lang) {
  31336. * if (lang && hljs.getLanguage(lang)) {
  31337. * try {
  31338. * return '<pre class="hljs"><code>' +
  31339. * hljs.highlight(lang, str, true).value +
  31340. * '</code></pre>';
  31341. * } catch (__) {}
  31342. * }
  31343. *
  31344. * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
  31345. * }
  31346. * });
  31347. * ```
  31348. *
  31349. **/
  31350. function MarkdownIt(presetName, options) {
  31351. if (!(this instanceof MarkdownIt)) {
  31352. return new MarkdownIt(presetName, options);
  31353. }
  31354. if (!options) {
  31355. if (!utils.isString(presetName)) {
  31356. options = presetName || {};
  31357. presetName = 'default';
  31358. }
  31359. }
  31360. /**
  31361. * MarkdownIt#inline -> ParserInline
  31362. *
  31363. * Instance of [[ParserInline]]. You may need it to add new rules when
  31364. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  31365. * [[MarkdownIt.enable]].
  31366. **/
  31367. this.inline = new ParserInline();
  31368. /**
  31369. * MarkdownIt#block -> ParserBlock
  31370. *
  31371. * Instance of [[ParserBlock]]. You may need it to add new rules when
  31372. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  31373. * [[MarkdownIt.enable]].
  31374. **/
  31375. this.block = new ParserBlock();
  31376. /**
  31377. * MarkdownIt#core -> Core
  31378. *
  31379. * Instance of [[Core]] chain executor. You may need it to add new rules when
  31380. * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
  31381. * [[MarkdownIt.enable]].
  31382. **/
  31383. this.core = new ParserCore();
  31384. /**
  31385. * MarkdownIt#renderer -> Renderer
  31386. *
  31387. * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
  31388. * rules for new token types, generated by plugins.
  31389. *
  31390. * ##### Example
  31391. *
  31392. * ```javascript
  31393. * var md = require('markdown-it')();
  31394. *
  31395. * function myToken(tokens, idx, options, env, self) {
  31396. * //...
  31397. * return result;
  31398. * };
  31399. *
  31400. * md.renderer.rules['my_token'] = myToken
  31401. * ```
  31402. *
  31403. * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
  31404. **/
  31405. this.renderer = new Renderer();
  31406. /**
  31407. * MarkdownIt#linkify -> LinkifyIt
  31408. *
  31409. * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
  31410. * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
  31411. * rule.
  31412. **/
  31413. this.linkify = new LinkifyIt();
  31414. /**
  31415. * MarkdownIt#validateLink(url) -> Boolean
  31416. *
  31417. * Link validation function. CommonMark allows too much in links. By default
  31418. * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
  31419. * except some embedded image types.
  31420. *
  31421. * You can change this behaviour:
  31422. *
  31423. * ```javascript
  31424. * var md = require('markdown-it')();
  31425. * // enable everything
  31426. * md.validateLink = function () { return true; }
  31427. * ```
  31428. **/
  31429. this.validateLink = validateLink;
  31430. /**
  31431. * MarkdownIt#normalizeLink(url) -> String
  31432. *
  31433. * Function used to encode link url to a machine-readable format,
  31434. * which includes url-encoding, punycode, etc.
  31435. **/
  31436. this.normalizeLink = normalizeLink;
  31437. /**
  31438. * MarkdownIt#normalizeLinkText(url) -> String
  31439. *
  31440. * Function used to decode link url to a human-readable format`
  31441. **/
  31442. this.normalizeLinkText = normalizeLinkText;
  31443. // Expose utils & helpers for easy acces from plugins
  31444. /**
  31445. * MarkdownIt#utils -> utils
  31446. *
  31447. * Assorted utility functions, useful to write plugins. See details
  31448. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
  31449. **/
  31450. this.utils = utils;
  31451. /**
  31452. * MarkdownIt#helpers -> helpers
  31453. *
  31454. * Link components parser functions, useful to write plugins. See details
  31455. * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
  31456. **/
  31457. this.helpers = utils.assign({}, helpers);
  31458. this.options = {};
  31459. this.configure(presetName);
  31460. if (options) { this.set(options); }
  31461. }
  31462. /** chainable
  31463. * MarkdownIt.set(options)
  31464. *
  31465. * Set parser options (in the same format as in constructor). Probably, you
  31466. * will never need it, but you can change options after constructor call.
  31467. *
  31468. * ##### Example
  31469. *
  31470. * ```javascript
  31471. * var md = require('markdown-it')()
  31472. * .set({ html: true, breaks: true })
  31473. * .set({ typographer, true });
  31474. * ```
  31475. *
  31476. * __Note:__ To achieve the best possible performance, don't modify a
  31477. * `markdown-it` instance options on the fly. If you need multiple configurations
  31478. * it's best to create multiple instances and initialize each with separate
  31479. * config.
  31480. **/
  31481. MarkdownIt.prototype.set = function (options) {
  31482. utils.assign(this.options, options);
  31483. return this;
  31484. };
  31485. /** chainable, internal
  31486. * MarkdownIt.configure(presets)
  31487. *
  31488. * Batch load of all options and compenent settings. This is internal method,
  31489. * and you probably will not need it. But if you with - see available presets
  31490. * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
  31491. *
  31492. * We strongly recommend to use presets instead of direct config loads. That
  31493. * will give better compatibility with next versions.
  31494. **/
  31495. MarkdownIt.prototype.configure = function (presets) {
  31496. var self = this, presetName;
  31497. if (utils.isString(presets)) {
  31498. presetName = presets;
  31499. presets = config[presetName];
  31500. if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); }
  31501. }
  31502. if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); }
  31503. if (presets.options) { self.set(presets.options); }
  31504. if (presets.components) {
  31505. Object.keys(presets.components).forEach(function (name) {
  31506. if (presets.components[name].rules) {
  31507. self[name].ruler.enableOnly(presets.components[name].rules);
  31508. }
  31509. if (presets.components[name].rules2) {
  31510. self[name].ruler2.enableOnly(presets.components[name].rules2);
  31511. }
  31512. });
  31513. }
  31514. return this;
  31515. };
  31516. /** chainable
  31517. * MarkdownIt.enable(list, ignoreInvalid)
  31518. * - list (String|Array): rule name or list of rule names to enable
  31519. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  31520. *
  31521. * Enable list or rules. It will automatically find appropriate components,
  31522. * containing rules with given names. If rule not found, and `ignoreInvalid`
  31523. * not set - throws exception.
  31524. *
  31525. * ##### Example
  31526. *
  31527. * ```javascript
  31528. * var md = require('markdown-it')()
  31529. * .enable(['sub', 'sup'])
  31530. * .disable('smartquotes');
  31531. * ```
  31532. **/
  31533. MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
  31534. var result = [];
  31535. if (!Array.isArray(list)) { list = [ list ]; }
  31536. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  31537. result = result.concat(this[chain].ruler.enable(list, true));
  31538. }, this);
  31539. result = result.concat(this.inline.ruler2.enable(list, true));
  31540. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  31541. if (missed.length && !ignoreInvalid) {
  31542. throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);
  31543. }
  31544. return this;
  31545. };
  31546. /** chainable
  31547. * MarkdownIt.disable(list, ignoreInvalid)
  31548. * - list (String|Array): rule name or list of rule names to disable.
  31549. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  31550. *
  31551. * The same as [[MarkdownIt.enable]], but turn specified rules off.
  31552. **/
  31553. MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
  31554. var result = [];
  31555. if (!Array.isArray(list)) { list = [ list ]; }
  31556. [ 'core', 'block', 'inline' ].forEach(function (chain) {
  31557. result = result.concat(this[chain].ruler.disable(list, true));
  31558. }, this);
  31559. result = result.concat(this.inline.ruler2.disable(list, true));
  31560. var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
  31561. if (missed.length && !ignoreInvalid) {
  31562. throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);
  31563. }
  31564. return this;
  31565. };
  31566. /** chainable
  31567. * MarkdownIt.use(plugin, params)
  31568. *
  31569. * Load specified plugin with given params into current parser instance.
  31570. * It's just a sugar to call `plugin(md, params)` with curring.
  31571. *
  31572. * ##### Example
  31573. *
  31574. * ```javascript
  31575. * var iterator = require('markdown-it-for-inline');
  31576. * var md = require('markdown-it')()
  31577. * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
  31578. * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
  31579. * });
  31580. * ```
  31581. **/
  31582. MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
  31583. var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
  31584. plugin.apply(plugin, args);
  31585. return this;
  31586. };
  31587. /** internal
  31588. * MarkdownIt.parse(src, env) -> Array
  31589. * - src (String): source string
  31590. * - env (Object): environment sandbox
  31591. *
  31592. * Parse input string and returns list of block tokens (special token type
  31593. * "inline" will contain list of inline tokens). You should not call this
  31594. * method directly, until you write custom renderer (for example, to produce
  31595. * AST).
  31596. *
  31597. * `env` is used to pass data between "distributed" rules and return additional
  31598. * metadata like reference info, needed for the renderer. It also can be used to
  31599. * inject data in specific cases. Usually, you will be ok to pass `{}`,
  31600. * and then pass updated object to renderer.
  31601. **/
  31602. MarkdownIt.prototype.parse = function (src, env) {
  31603. if (typeof src !== 'string') {
  31604. throw new Error('Input data should be a String');
  31605. }
  31606. var state = new this.core.State(src, this, env);
  31607. this.core.process(state);
  31608. return state.tokens;
  31609. };
  31610. /**
  31611. * MarkdownIt.render(src [, env]) -> String
  31612. * - src (String): source string
  31613. * - env (Object): environment sandbox
  31614. *
  31615. * Render markdown string into html. It does all magic for you :).
  31616. *
  31617. * `env` can be used to inject additional metadata (`{}` by default).
  31618. * But you will not need it with high probability. See also comment
  31619. * in [[MarkdownIt.parse]].
  31620. **/
  31621. MarkdownIt.prototype.render = function (src, env) {
  31622. env = env || {};
  31623. return this.renderer.render(this.parse(src, env), this.options, env);
  31624. };
  31625. /** internal
  31626. * MarkdownIt.parseInline(src, env) -> Array
  31627. * - src (String): source string
  31628. * - env (Object): environment sandbox
  31629. *
  31630. * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
  31631. * block tokens list with the single `inline` element, containing parsed inline
  31632. * tokens in `children` property. Also updates `env` object.
  31633. **/
  31634. MarkdownIt.prototype.parseInline = function (src, env) {
  31635. var state = new this.core.State(src, this, env);
  31636. state.inlineMode = true;
  31637. this.core.process(state);
  31638. return state.tokens;
  31639. };
  31640. /**
  31641. * MarkdownIt.renderInline(src [, env]) -> String
  31642. * - src (String): source string
  31643. * - env (Object): environment sandbox
  31644. *
  31645. * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
  31646. * will NOT be wrapped into `<p>` tags.
  31647. **/
  31648. MarkdownIt.prototype.renderInline = function (src, env) {
  31649. env = env || {};
  31650. return this.renderer.render(this.parseInline(src, env), this.options, env);
  31651. };
  31652. module.exports = MarkdownIt;
  31653. },{"./common/utils":144,"./helpers":145,"./parser_block":150,"./parser_core":151,"./parser_inline":152,"./presets/commonmark":153,"./presets/default":154,"./presets/zero":155,"./renderer":156,"linkify-it":138,"mdurl":195,"punycode":2}],150:[function(require,module,exports){
  31654. /** internal
  31655. * class ParserBlock
  31656. *
  31657. * Block-level tokenizer.
  31658. **/
  31659. 'use strict';
  31660. var Ruler = require('./ruler');
  31661. var _rules = [
  31662. // First 2 params - rule name & source. Secondary array - list of rules,
  31663. // which can be terminated by this one.
  31664. [ 'table', require('./rules_block/table'), [ 'paragraph', 'reference' ] ],
  31665. [ 'code', require('./rules_block/code') ],
  31666. [ 'fence', require('./rules_block/fence'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  31667. [ 'blockquote', require('./rules_block/blockquote'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  31668. [ 'hr', require('./rules_block/hr'), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
  31669. [ 'list', require('./rules_block/list'), [ 'paragraph', 'reference', 'blockquote' ] ],
  31670. [ 'reference', require('./rules_block/reference') ],
  31671. [ 'heading', require('./rules_block/heading'), [ 'paragraph', 'reference', 'blockquote' ] ],
  31672. [ 'lheading', require('./rules_block/lheading') ],
  31673. [ 'html_block', require('./rules_block/html_block'), [ 'paragraph', 'reference', 'blockquote' ] ],
  31674. [ 'paragraph', require('./rules_block/paragraph') ]
  31675. ];
  31676. /**
  31677. * new ParserBlock()
  31678. **/
  31679. function ParserBlock() {
  31680. /**
  31681. * ParserBlock#ruler -> Ruler
  31682. *
  31683. * [[Ruler]] instance. Keep configuration of block rules.
  31684. **/
  31685. this.ruler = new Ruler();
  31686. for (var i = 0; i < _rules.length; i++) {
  31687. this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
  31688. }
  31689. }
  31690. // Generate tokens for input range
  31691. //
  31692. ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
  31693. var ok, i,
  31694. rules = this.ruler.getRules(''),
  31695. len = rules.length,
  31696. line = startLine,
  31697. hasEmptyLines = false,
  31698. maxNesting = state.md.options.maxNesting;
  31699. while (line < endLine) {
  31700. state.line = line = state.skipEmptyLines(line);
  31701. if (line >= endLine) { break; }
  31702. // Termination condition for nested calls.
  31703. // Nested calls currently used for blockquotes & lists
  31704. if (state.sCount[line] < state.blkIndent) { break; }
  31705. // If nesting level exceeded - skip tail to the end. That's not ordinary
  31706. // situation and we should not care about content.
  31707. if (state.level >= maxNesting) {
  31708. state.line = endLine;
  31709. break;
  31710. }
  31711. // Try all possible rules.
  31712. // On success, rule should:
  31713. //
  31714. // - update `state.line`
  31715. // - update `state.tokens`
  31716. // - return true
  31717. for (i = 0; i < len; i++) {
  31718. ok = rules[i](state, line, endLine, false);
  31719. if (ok) { break; }
  31720. }
  31721. // set state.tight if we had an empty line before current tag
  31722. // i.e. latest empty line should not count
  31723. state.tight = !hasEmptyLines;
  31724. // paragraph might "eat" one newline after it in nested lists
  31725. if (state.isEmpty(state.line - 1)) {
  31726. hasEmptyLines = true;
  31727. }
  31728. line = state.line;
  31729. if (line < endLine && state.isEmpty(line)) {
  31730. hasEmptyLines = true;
  31731. line++;
  31732. state.line = line;
  31733. }
  31734. }
  31735. };
  31736. /**
  31737. * ParserBlock.parse(str, md, env, outTokens)
  31738. *
  31739. * Process input string and push block tokens into `outTokens`
  31740. **/
  31741. ParserBlock.prototype.parse = function (src, md, env, outTokens) {
  31742. var state;
  31743. if (!src) { return; }
  31744. state = new this.State(src, md, env, outTokens);
  31745. this.tokenize(state, state.line, state.lineMax);
  31746. };
  31747. ParserBlock.prototype.State = require('./rules_block/state_block');
  31748. module.exports = ParserBlock;
  31749. },{"./ruler":157,"./rules_block/blockquote":158,"./rules_block/code":159,"./rules_block/fence":160,"./rules_block/heading":161,"./rules_block/hr":162,"./rules_block/html_block":163,"./rules_block/lheading":164,"./rules_block/list":165,"./rules_block/paragraph":166,"./rules_block/reference":167,"./rules_block/state_block":168,"./rules_block/table":169}],151:[function(require,module,exports){
  31750. /** internal
  31751. * class Core
  31752. *
  31753. * Top-level rules executor. Glues block/inline parsers and does intermediate
  31754. * transformations.
  31755. **/
  31756. 'use strict';
  31757. var Ruler = require('./ruler');
  31758. var _rules = [
  31759. [ 'normalize', require('./rules_core/normalize') ],
  31760. [ 'block', require('./rules_core/block') ],
  31761. [ 'inline', require('./rules_core/inline') ],
  31762. [ 'linkify', require('./rules_core/linkify') ],
  31763. [ 'replacements', require('./rules_core/replacements') ],
  31764. [ 'smartquotes', require('./rules_core/smartquotes') ]
  31765. ];
  31766. /**
  31767. * new Core()
  31768. **/
  31769. function Core() {
  31770. /**
  31771. * Core#ruler -> Ruler
  31772. *
  31773. * [[Ruler]] instance. Keep configuration of core rules.
  31774. **/
  31775. this.ruler = new Ruler();
  31776. for (var i = 0; i < _rules.length; i++) {
  31777. this.ruler.push(_rules[i][0], _rules[i][1]);
  31778. }
  31779. }
  31780. /**
  31781. * Core.process(state)
  31782. *
  31783. * Executes core chain rules.
  31784. **/
  31785. Core.prototype.process = function (state) {
  31786. var i, l, rules;
  31787. rules = this.ruler.getRules('');
  31788. for (i = 0, l = rules.length; i < l; i++) {
  31789. rules[i](state);
  31790. }
  31791. };
  31792. Core.prototype.State = require('./rules_core/state_core');
  31793. module.exports = Core;
  31794. },{"./ruler":157,"./rules_core/block":170,"./rules_core/inline":171,"./rules_core/linkify":172,"./rules_core/normalize":173,"./rules_core/replacements":174,"./rules_core/smartquotes":175,"./rules_core/state_core":176}],152:[function(require,module,exports){
  31795. /** internal
  31796. * class ParserInline
  31797. *
  31798. * Tokenizes paragraph content.
  31799. **/
  31800. 'use strict';
  31801. var Ruler = require('./ruler');
  31802. ////////////////////////////////////////////////////////////////////////////////
  31803. // Parser rules
  31804. var _rules = [
  31805. [ 'text', require('./rules_inline/text') ],
  31806. [ 'newline', require('./rules_inline/newline') ],
  31807. [ 'escape', require('./rules_inline/escape') ],
  31808. [ 'backticks', require('./rules_inline/backticks') ],
  31809. [ 'strikethrough', require('./rules_inline/strikethrough').tokenize ],
  31810. [ 'emphasis', require('./rules_inline/emphasis').tokenize ],
  31811. [ 'link', require('./rules_inline/link') ],
  31812. [ 'image', require('./rules_inline/image') ],
  31813. [ 'autolink', require('./rules_inline/autolink') ],
  31814. [ 'html_inline', require('./rules_inline/html_inline') ],
  31815. [ 'entity', require('./rules_inline/entity') ]
  31816. ];
  31817. var _rules2 = [
  31818. [ 'balance_pairs', require('./rules_inline/balance_pairs') ],
  31819. [ 'strikethrough', require('./rules_inline/strikethrough').postProcess ],
  31820. [ 'emphasis', require('./rules_inline/emphasis').postProcess ],
  31821. [ 'text_collapse', require('./rules_inline/text_collapse') ]
  31822. ];
  31823. /**
  31824. * new ParserInline()
  31825. **/
  31826. function ParserInline() {
  31827. var i;
  31828. /**
  31829. * ParserInline#ruler -> Ruler
  31830. *
  31831. * [[Ruler]] instance. Keep configuration of inline rules.
  31832. **/
  31833. this.ruler = new Ruler();
  31834. for (i = 0; i < _rules.length; i++) {
  31835. this.ruler.push(_rules[i][0], _rules[i][1]);
  31836. }
  31837. /**
  31838. * ParserInline#ruler2 -> Ruler
  31839. *
  31840. * [[Ruler]] instance. Second ruler used for post-processing
  31841. * (e.g. in emphasis-like rules).
  31842. **/
  31843. this.ruler2 = new Ruler();
  31844. for (i = 0; i < _rules2.length; i++) {
  31845. this.ruler2.push(_rules2[i][0], _rules2[i][1]);
  31846. }
  31847. }
  31848. // Skip single token by running all rules in validation mode;
  31849. // returns `true` if any rule reported success
  31850. //
  31851. ParserInline.prototype.skipToken = function (state) {
  31852. var ok, i, pos = state.pos,
  31853. rules = this.ruler.getRules(''),
  31854. len = rules.length,
  31855. maxNesting = state.md.options.maxNesting,
  31856. cache = state.cache;
  31857. if (typeof cache[pos] !== 'undefined') {
  31858. state.pos = cache[pos];
  31859. return;
  31860. }
  31861. if (state.level < maxNesting) {
  31862. for (i = 0; i < len; i++) {
  31863. // Increment state.level and decrement it later to limit recursion.
  31864. // It's harmless to do here, because no tokens are created. But ideally,
  31865. // we'd need a separate private state variable for this purpose.
  31866. //
  31867. state.level++;
  31868. ok = rules[i](state, true);
  31869. state.level--;
  31870. if (ok) { break; }
  31871. }
  31872. } else {
  31873. // Too much nesting, just skip until the end of the paragraph.
  31874. //
  31875. // NOTE: this will cause links to behave incorrectly in the following case,
  31876. // when an amount of `[` is exactly equal to `maxNesting + 1`:
  31877. //
  31878. // [[[[[[[[[[[[[[[[[[[[[foo]()
  31879. //
  31880. // TODO: remove this workaround when CM standard will allow nested links
  31881. // (we can replace it by preventing links from being parsed in
  31882. // validation mode)
  31883. //
  31884. state.pos = state.posMax;
  31885. }
  31886. if (!ok) { state.pos++; }
  31887. cache[pos] = state.pos;
  31888. };
  31889. // Generate tokens for input range
  31890. //
  31891. ParserInline.prototype.tokenize = function (state) {
  31892. var ok, i,
  31893. rules = this.ruler.getRules(''),
  31894. len = rules.length,
  31895. end = state.posMax,
  31896. maxNesting = state.md.options.maxNesting;
  31897. while (state.pos < end) {
  31898. // Try all possible rules.
  31899. // On success, rule should:
  31900. //
  31901. // - update `state.pos`
  31902. // - update `state.tokens`
  31903. // - return true
  31904. if (state.level < maxNesting) {
  31905. for (i = 0; i < len; i++) {
  31906. ok = rules[i](state, false);
  31907. if (ok) { break; }
  31908. }
  31909. }
  31910. if (ok) {
  31911. if (state.pos >= end) { break; }
  31912. continue;
  31913. }
  31914. state.pending += state.src[state.pos++];
  31915. }
  31916. if (state.pending) {
  31917. state.pushPending();
  31918. }
  31919. };
  31920. /**
  31921. * ParserInline.parse(str, md, env, outTokens)
  31922. *
  31923. * Process input string and push inline tokens into `outTokens`
  31924. **/
  31925. ParserInline.prototype.parse = function (str, md, env, outTokens) {
  31926. var i, rules, len;
  31927. var state = new this.State(str, md, env, outTokens);
  31928. this.tokenize(state);
  31929. rules = this.ruler2.getRules('');
  31930. len = rules.length;
  31931. for (i = 0; i < len; i++) {
  31932. rules[i](state);
  31933. }
  31934. };
  31935. ParserInline.prototype.State = require('./rules_inline/state_inline');
  31936. module.exports = ParserInline;
  31937. },{"./ruler":157,"./rules_inline/autolink":177,"./rules_inline/backticks":178,"./rules_inline/balance_pairs":179,"./rules_inline/emphasis":180,"./rules_inline/entity":181,"./rules_inline/escape":182,"./rules_inline/html_inline":183,"./rules_inline/image":184,"./rules_inline/link":185,"./rules_inline/newline":186,"./rules_inline/state_inline":187,"./rules_inline/strikethrough":188,"./rules_inline/text":189,"./rules_inline/text_collapse":190}],153:[function(require,module,exports){
  31938. // Commonmark default options
  31939. 'use strict';
  31940. module.exports = {
  31941. options: {
  31942. html: true, // Enable HTML tags in source
  31943. xhtmlOut: true, // Use '/' to close single tags (<br />)
  31944. breaks: false, // Convert '\n' in paragraphs into <br>
  31945. langPrefix: 'language-', // CSS language prefix for fenced blocks
  31946. linkify: false, // autoconvert URL-like texts to links
  31947. // Enable some language-neutral replacements + quotes beautification
  31948. typographer: false,
  31949. // Double + single quotes replacement pairs, when typographer enabled,
  31950. // and smartquotes on. Could be either a String or an Array.
  31951. //
  31952. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  31953. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  31954. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  31955. // Highlighter function. Should return escaped HTML,
  31956. // or '' if the source string is not changed and should be escaped externaly.
  31957. // If result starts with <pre... internal wrapper is skipped.
  31958. //
  31959. // function (/*str, lang*/) { return ''; }
  31960. //
  31961. highlight: null,
  31962. maxNesting: 20 // Internal protection, recursion limit
  31963. },
  31964. components: {
  31965. core: {
  31966. rules: [
  31967. 'normalize',
  31968. 'block',
  31969. 'inline'
  31970. ]
  31971. },
  31972. block: {
  31973. rules: [
  31974. 'blockquote',
  31975. 'code',
  31976. 'fence',
  31977. 'heading',
  31978. 'hr',
  31979. 'html_block',
  31980. 'lheading',
  31981. 'list',
  31982. 'reference',
  31983. 'paragraph'
  31984. ]
  31985. },
  31986. inline: {
  31987. rules: [
  31988. 'autolink',
  31989. 'backticks',
  31990. 'emphasis',
  31991. 'entity',
  31992. 'escape',
  31993. 'html_inline',
  31994. 'image',
  31995. 'link',
  31996. 'newline',
  31997. 'text'
  31998. ],
  31999. rules2: [
  32000. 'balance_pairs',
  32001. 'emphasis',
  32002. 'text_collapse'
  32003. ]
  32004. }
  32005. }
  32006. };
  32007. },{}],154:[function(require,module,exports){
  32008. // markdown-it default options
  32009. 'use strict';
  32010. module.exports = {
  32011. options: {
  32012. html: false, // Enable HTML tags in source
  32013. xhtmlOut: false, // Use '/' to close single tags (<br />)
  32014. breaks: false, // Convert '\n' in paragraphs into <br>
  32015. langPrefix: 'language-', // CSS language prefix for fenced blocks
  32016. linkify: false, // autoconvert URL-like texts to links
  32017. // Enable some language-neutral replacements + quotes beautification
  32018. typographer: false,
  32019. // Double + single quotes replacement pairs, when typographer enabled,
  32020. // and smartquotes on. Could be either a String or an Array.
  32021. //
  32022. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  32023. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  32024. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  32025. // Highlighter function. Should return escaped HTML,
  32026. // or '' if the source string is not changed and should be escaped externaly.
  32027. // If result starts with <pre... internal wrapper is skipped.
  32028. //
  32029. // function (/*str, lang*/) { return ''; }
  32030. //
  32031. highlight: null,
  32032. maxNesting: 100 // Internal protection, recursion limit
  32033. },
  32034. components: {
  32035. core: {},
  32036. block: {},
  32037. inline: {}
  32038. }
  32039. };
  32040. },{}],155:[function(require,module,exports){
  32041. // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
  32042. // modes. For example, to parse bold/italic only.
  32043. 'use strict';
  32044. module.exports = {
  32045. options: {
  32046. html: false, // Enable HTML tags in source
  32047. xhtmlOut: false, // Use '/' to close single tags (<br />)
  32048. breaks: false, // Convert '\n' in paragraphs into <br>
  32049. langPrefix: 'language-', // CSS language prefix for fenced blocks
  32050. linkify: false, // autoconvert URL-like texts to links
  32051. // Enable some language-neutral replacements + quotes beautification
  32052. typographer: false,
  32053. // Double + single quotes replacement pairs, when typographer enabled,
  32054. // and smartquotes on. Could be either a String or an Array.
  32055. //
  32056. // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  32057. // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  32058. quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
  32059. // Highlighter function. Should return escaped HTML,
  32060. // or '' if the source string is not changed and should be escaped externaly.
  32061. // If result starts with <pre... internal wrapper is skipped.
  32062. //
  32063. // function (/*str, lang*/) { return ''; }
  32064. //
  32065. highlight: null,
  32066. maxNesting: 20 // Internal protection, recursion limit
  32067. },
  32068. components: {
  32069. core: {
  32070. rules: [
  32071. 'normalize',
  32072. 'block',
  32073. 'inline'
  32074. ]
  32075. },
  32076. block: {
  32077. rules: [
  32078. 'paragraph'
  32079. ]
  32080. },
  32081. inline: {
  32082. rules: [
  32083. 'text'
  32084. ],
  32085. rules2: [
  32086. 'balance_pairs',
  32087. 'text_collapse'
  32088. ]
  32089. }
  32090. }
  32091. };
  32092. },{}],156:[function(require,module,exports){
  32093. /**
  32094. * class Renderer
  32095. *
  32096. * Generates HTML from parsed token stream. Each instance has independent
  32097. * copy of rules. Those can be rewritten with ease. Also, you can add new
  32098. * rules if you create plugin and adds new token types.
  32099. **/
  32100. 'use strict';
  32101. var assign = require('./common/utils').assign;
  32102. var unescapeAll = require('./common/utils').unescapeAll;
  32103. var escapeHtml = require('./common/utils').escapeHtml;
  32104. ////////////////////////////////////////////////////////////////////////////////
  32105. var default_rules = {};
  32106. default_rules.code_inline = function (tokens, idx, options, env, slf) {
  32107. var token = tokens[idx];
  32108. return '<code' + slf.renderAttrs(token) + '>' +
  32109. escapeHtml(tokens[idx].content) +
  32110. '</code>';
  32111. };
  32112. default_rules.code_block = function (tokens, idx, options, env, slf) {
  32113. var token = tokens[idx];
  32114. return '<pre' + slf.renderAttrs(token) + '><code>' +
  32115. escapeHtml(tokens[idx].content) +
  32116. '</code></pre>\n';
  32117. };
  32118. default_rules.fence = function (tokens, idx, options, env, slf) {
  32119. var token = tokens[idx],
  32120. info = token.info ? unescapeAll(token.info).trim() : '',
  32121. langName = '',
  32122. highlighted, i, tmpAttrs, tmpToken;
  32123. if (info) {
  32124. langName = info.split(/\s+/g)[0];
  32125. }
  32126. if (options.highlight) {
  32127. highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
  32128. } else {
  32129. highlighted = escapeHtml(token.content);
  32130. }
  32131. if (highlighted.indexOf('<pre') === 0) {
  32132. return highlighted + '\n';
  32133. }
  32134. // If language exists, inject class gently, without modifying original token.
  32135. // May be, one day we will add .clone() for token and simplify this part, but
  32136. // now we prefer to keep things local.
  32137. if (info) {
  32138. i = token.attrIndex('class');
  32139. tmpAttrs = token.attrs ? token.attrs.slice() : [];
  32140. if (i < 0) {
  32141. tmpAttrs.push([ 'class', options.langPrefix + langName ]);
  32142. } else {
  32143. tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
  32144. }
  32145. // Fake token just to render attributes
  32146. tmpToken = {
  32147. attrs: tmpAttrs
  32148. };
  32149. return '<pre><code' + slf.renderAttrs(tmpToken) + '>'
  32150. + highlighted
  32151. + '</code></pre>\n';
  32152. }
  32153. return '<pre><code' + slf.renderAttrs(token) + '>'
  32154. + highlighted
  32155. + '</code></pre>\n';
  32156. };
  32157. default_rules.image = function (tokens, idx, options, env, slf) {
  32158. var token = tokens[idx];
  32159. // "alt" attr MUST be set, even if empty. Because it's mandatory and
  32160. // should be placed on proper position for tests.
  32161. //
  32162. // Replace content with actual value
  32163. token.attrs[token.attrIndex('alt')][1] =
  32164. slf.renderInlineAsText(token.children, options, env);
  32165. return slf.renderToken(tokens, idx, options);
  32166. };
  32167. default_rules.hardbreak = function (tokens, idx, options /*, env */) {
  32168. return options.xhtmlOut ? '<br />\n' : '<br>\n';
  32169. };
  32170. default_rules.softbreak = function (tokens, idx, options /*, env */) {
  32171. return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
  32172. };
  32173. default_rules.text = function (tokens, idx /*, options, env */) {
  32174. return escapeHtml(tokens[idx].content);
  32175. };
  32176. default_rules.html_block = function (tokens, idx /*, options, env */) {
  32177. return tokens[idx].content;
  32178. };
  32179. default_rules.html_inline = function (tokens, idx /*, options, env */) {
  32180. return tokens[idx].content;
  32181. };
  32182. /**
  32183. * new Renderer()
  32184. *
  32185. * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
  32186. **/
  32187. function Renderer() {
  32188. /**
  32189. * Renderer#rules -> Object
  32190. *
  32191. * Contains render rules for tokens. Can be updated and extended.
  32192. *
  32193. * ##### Example
  32194. *
  32195. * ```javascript
  32196. * var md = require('markdown-it')();
  32197. *
  32198. * md.renderer.rules.strong_open = function () { return '<b>'; };
  32199. * md.renderer.rules.strong_close = function () { return '</b>'; };
  32200. *
  32201. * var result = md.renderInline(...);
  32202. * ```
  32203. *
  32204. * Each rule is called as independent static function with fixed signature:
  32205. *
  32206. * ```javascript
  32207. * function my_token_render(tokens, idx, options, env, renderer) {
  32208. * // ...
  32209. * return renderedHTML;
  32210. * }
  32211. * ```
  32212. *
  32213. * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
  32214. * for more details and examples.
  32215. **/
  32216. this.rules = assign({}, default_rules);
  32217. }
  32218. /**
  32219. * Renderer.renderAttrs(token) -> String
  32220. *
  32221. * Render token attributes to string.
  32222. **/
  32223. Renderer.prototype.renderAttrs = function renderAttrs(token) {
  32224. var i, l, result;
  32225. if (!token.attrs) { return ''; }
  32226. result = '';
  32227. for (i = 0, l = token.attrs.length; i < l; i++) {
  32228. result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
  32229. }
  32230. return result;
  32231. };
  32232. /**
  32233. * Renderer.renderToken(tokens, idx, options) -> String
  32234. * - tokens (Array): list of tokens
  32235. * - idx (Numbed): token index to render
  32236. * - options (Object): params of parser instance
  32237. *
  32238. * Default token renderer. Can be overriden by custom function
  32239. * in [[Renderer#rules]].
  32240. **/
  32241. Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
  32242. var nextToken,
  32243. result = '',
  32244. needLf = false,
  32245. token = tokens[idx];
  32246. // Tight list paragraphs
  32247. if (token.hidden) {
  32248. return '';
  32249. }
  32250. // Insert a newline between hidden paragraph and subsequent opening
  32251. // block-level tag.
  32252. //
  32253. // For example, here we should insert a newline before blockquote:
  32254. // - a
  32255. // >
  32256. //
  32257. if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
  32258. result += '\n';
  32259. }
  32260. // Add token name, e.g. `<img`
  32261. result += (token.nesting === -1 ? '</' : '<') + token.tag;
  32262. // Encode attributes, e.g. `<img src="foo"`
  32263. result += this.renderAttrs(token);
  32264. // Add a slash for self-closing tags, e.g. `<img src="foo" /`
  32265. if (token.nesting === 0 && options.xhtmlOut) {
  32266. result += ' /';
  32267. }
  32268. // Check if we need to add a newline after this tag
  32269. if (token.block) {
  32270. needLf = true;
  32271. if (token.nesting === 1) {
  32272. if (idx + 1 < tokens.length) {
  32273. nextToken = tokens[idx + 1];
  32274. if (nextToken.type === 'inline' || nextToken.hidden) {
  32275. // Block-level tag containing an inline tag.
  32276. //
  32277. needLf = false;
  32278. } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
  32279. // Opening tag + closing tag of the same type. E.g. `<li></li>`.
  32280. //
  32281. needLf = false;
  32282. }
  32283. }
  32284. }
  32285. }
  32286. result += needLf ? '>\n' : '>';
  32287. return result;
  32288. };
  32289. /**
  32290. * Renderer.renderInline(tokens, options, env) -> String
  32291. * - tokens (Array): list on block tokens to renter
  32292. * - options (Object): params of parser instance
  32293. * - env (Object): additional data from parsed input (references, for example)
  32294. *
  32295. * The same as [[Renderer.render]], but for single token of `inline` type.
  32296. **/
  32297. Renderer.prototype.renderInline = function (tokens, options, env) {
  32298. var type,
  32299. result = '',
  32300. rules = this.rules;
  32301. for (var i = 0, len = tokens.length; i < len; i++) {
  32302. type = tokens[i].type;
  32303. if (typeof rules[type] !== 'undefined') {
  32304. result += rules[type](tokens, i, options, env, this);
  32305. } else {
  32306. result += this.renderToken(tokens, i, options);
  32307. }
  32308. }
  32309. return result;
  32310. };
  32311. /** internal
  32312. * Renderer.renderInlineAsText(tokens, options, env) -> String
  32313. * - tokens (Array): list on block tokens to renter
  32314. * - options (Object): params of parser instance
  32315. * - env (Object): additional data from parsed input (references, for example)
  32316. *
  32317. * Special kludge for image `alt` attributes to conform CommonMark spec.
  32318. * Don't try to use it! Spec requires to show `alt` content with stripped markup,
  32319. * instead of simple escaping.
  32320. **/
  32321. Renderer.prototype.renderInlineAsText = function (tokens, options, env) {
  32322. var result = '';
  32323. for (var i = 0, len = tokens.length; i < len; i++) {
  32324. if (tokens[i].type === 'text') {
  32325. result += tokens[i].content;
  32326. } else if (tokens[i].type === 'image') {
  32327. result += this.renderInlineAsText(tokens[i].children, options, env);
  32328. }
  32329. }
  32330. return result;
  32331. };
  32332. /**
  32333. * Renderer.render(tokens, options, env) -> String
  32334. * - tokens (Array): list on block tokens to renter
  32335. * - options (Object): params of parser instance
  32336. * - env (Object): additional data from parsed input (references, for example)
  32337. *
  32338. * Takes token stream and generates HTML. Probably, you will never need to call
  32339. * this method directly.
  32340. **/
  32341. Renderer.prototype.render = function (tokens, options, env) {
  32342. var i, len, type,
  32343. result = '',
  32344. rules = this.rules;
  32345. for (i = 0, len = tokens.length; i < len; i++) {
  32346. type = tokens[i].type;
  32347. if (type === 'inline') {
  32348. result += this.renderInline(tokens[i].children, options, env);
  32349. } else if (typeof rules[type] !== 'undefined') {
  32350. result += rules[tokens[i].type](tokens, i, options, env, this);
  32351. } else {
  32352. result += this.renderToken(tokens, i, options, env);
  32353. }
  32354. }
  32355. return result;
  32356. };
  32357. module.exports = Renderer;
  32358. },{"./common/utils":144}],157:[function(require,module,exports){
  32359. /**
  32360. * class Ruler
  32361. *
  32362. * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
  32363. * [[MarkdownIt#inline]] to manage sequences of functions (rules):
  32364. *
  32365. * - keep rules in defined order
  32366. * - assign the name to each rule
  32367. * - enable/disable rules
  32368. * - add/replace rules
  32369. * - allow assign rules to additional named chains (in the same)
  32370. * - cacheing lists of active rules
  32371. *
  32372. * You will not need use this class directly until write plugins. For simple
  32373. * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
  32374. * [[MarkdownIt.use]].
  32375. **/
  32376. 'use strict';
  32377. /**
  32378. * new Ruler()
  32379. **/
  32380. function Ruler() {
  32381. // List of added rules. Each element is:
  32382. //
  32383. // {
  32384. // name: XXX,
  32385. // enabled: Boolean,
  32386. // fn: Function(),
  32387. // alt: [ name2, name3 ]
  32388. // }
  32389. //
  32390. this.__rules__ = [];
  32391. // Cached rule chains.
  32392. //
  32393. // First level - chain name, '' for default.
  32394. // Second level - diginal anchor for fast filtering by charcodes.
  32395. //
  32396. this.__cache__ = null;
  32397. }
  32398. ////////////////////////////////////////////////////////////////////////////////
  32399. // Helper methods, should not be used directly
  32400. // Find rule index by name
  32401. //
  32402. Ruler.prototype.__find__ = function (name) {
  32403. for (var i = 0; i < this.__rules__.length; i++) {
  32404. if (this.__rules__[i].name === name) {
  32405. return i;
  32406. }
  32407. }
  32408. return -1;
  32409. };
  32410. // Build rules lookup cache
  32411. //
  32412. Ruler.prototype.__compile__ = function () {
  32413. var self = this;
  32414. var chains = [ '' ];
  32415. // collect unique names
  32416. self.__rules__.forEach(function (rule) {
  32417. if (!rule.enabled) { return; }
  32418. rule.alt.forEach(function (altName) {
  32419. if (chains.indexOf(altName) < 0) {
  32420. chains.push(altName);
  32421. }
  32422. });
  32423. });
  32424. self.__cache__ = {};
  32425. chains.forEach(function (chain) {
  32426. self.__cache__[chain] = [];
  32427. self.__rules__.forEach(function (rule) {
  32428. if (!rule.enabled) { return; }
  32429. if (chain && rule.alt.indexOf(chain) < 0) { return; }
  32430. self.__cache__[chain].push(rule.fn);
  32431. });
  32432. });
  32433. };
  32434. /**
  32435. * Ruler.at(name, fn [, options])
  32436. * - name (String): rule name to replace.
  32437. * - fn (Function): new rule function.
  32438. * - options (Object): new rule options (not mandatory).
  32439. *
  32440. * Replace rule by name with new function & options. Throws error if name not
  32441. * found.
  32442. *
  32443. * ##### Options:
  32444. *
  32445. * - __alt__ - array with names of "alternate" chains.
  32446. *
  32447. * ##### Example
  32448. *
  32449. * Replace existing typographer replacement rule with new one:
  32450. *
  32451. * ```javascript
  32452. * var md = require('markdown-it')();
  32453. *
  32454. * md.core.ruler.at('replacements', function replace(state) {
  32455. * //...
  32456. * });
  32457. * ```
  32458. **/
  32459. Ruler.prototype.at = function (name, fn, options) {
  32460. var index = this.__find__(name);
  32461. var opt = options || {};
  32462. if (index === -1) { throw new Error('Parser rule not found: ' + name); }
  32463. this.__rules__[index].fn = fn;
  32464. this.__rules__[index].alt = opt.alt || [];
  32465. this.__cache__ = null;
  32466. };
  32467. /**
  32468. * Ruler.before(beforeName, ruleName, fn [, options])
  32469. * - beforeName (String): new rule will be added before this one.
  32470. * - ruleName (String): name of added rule.
  32471. * - fn (Function): rule function.
  32472. * - options (Object): rule options (not mandatory).
  32473. *
  32474. * Add new rule to chain before one with given name. See also
  32475. * [[Ruler.after]], [[Ruler.push]].
  32476. *
  32477. * ##### Options:
  32478. *
  32479. * - __alt__ - array with names of "alternate" chains.
  32480. *
  32481. * ##### Example
  32482. *
  32483. * ```javascript
  32484. * var md = require('markdown-it')();
  32485. *
  32486. * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
  32487. * //...
  32488. * });
  32489. * ```
  32490. **/
  32491. Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
  32492. var index = this.__find__(beforeName);
  32493. var opt = options || {};
  32494. if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }
  32495. this.__rules__.splice(index, 0, {
  32496. name: ruleName,
  32497. enabled: true,
  32498. fn: fn,
  32499. alt: opt.alt || []
  32500. });
  32501. this.__cache__ = null;
  32502. };
  32503. /**
  32504. * Ruler.after(afterName, ruleName, fn [, options])
  32505. * - afterName (String): new rule will be added after this one.
  32506. * - ruleName (String): name of added rule.
  32507. * - fn (Function): rule function.
  32508. * - options (Object): rule options (not mandatory).
  32509. *
  32510. * Add new rule to chain after one with given name. See also
  32511. * [[Ruler.before]], [[Ruler.push]].
  32512. *
  32513. * ##### Options:
  32514. *
  32515. * - __alt__ - array with names of "alternate" chains.
  32516. *
  32517. * ##### Example
  32518. *
  32519. * ```javascript
  32520. * var md = require('markdown-it')();
  32521. *
  32522. * md.inline.ruler.after('text', 'my_rule', function replace(state) {
  32523. * //...
  32524. * });
  32525. * ```
  32526. **/
  32527. Ruler.prototype.after = function (afterName, ruleName, fn, options) {
  32528. var index = this.__find__(afterName);
  32529. var opt = options || {};
  32530. if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }
  32531. this.__rules__.splice(index + 1, 0, {
  32532. name: ruleName,
  32533. enabled: true,
  32534. fn: fn,
  32535. alt: opt.alt || []
  32536. });
  32537. this.__cache__ = null;
  32538. };
  32539. /**
  32540. * Ruler.push(ruleName, fn [, options])
  32541. * - ruleName (String): name of added rule.
  32542. * - fn (Function): rule function.
  32543. * - options (Object): rule options (not mandatory).
  32544. *
  32545. * Push new rule to the end of chain. See also
  32546. * [[Ruler.before]], [[Ruler.after]].
  32547. *
  32548. * ##### Options:
  32549. *
  32550. * - __alt__ - array with names of "alternate" chains.
  32551. *
  32552. * ##### Example
  32553. *
  32554. * ```javascript
  32555. * var md = require('markdown-it')();
  32556. *
  32557. * md.core.ruler.push('my_rule', function replace(state) {
  32558. * //...
  32559. * });
  32560. * ```
  32561. **/
  32562. Ruler.prototype.push = function (ruleName, fn, options) {
  32563. var opt = options || {};
  32564. this.__rules__.push({
  32565. name: ruleName,
  32566. enabled: true,
  32567. fn: fn,
  32568. alt: opt.alt || []
  32569. });
  32570. this.__cache__ = null;
  32571. };
  32572. /**
  32573. * Ruler.enable(list [, ignoreInvalid]) -> Array
  32574. * - list (String|Array): list of rule names to enable.
  32575. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  32576. *
  32577. * Enable rules with given names. If any rule name not found - throw Error.
  32578. * Errors can be disabled by second param.
  32579. *
  32580. * Returns list of found rule names (if no exception happened).
  32581. *
  32582. * See also [[Ruler.disable]], [[Ruler.enableOnly]].
  32583. **/
  32584. Ruler.prototype.enable = function (list, ignoreInvalid) {
  32585. if (!Array.isArray(list)) { list = [ list ]; }
  32586. var result = [];
  32587. // Search by name and enable
  32588. list.forEach(function (name) {
  32589. var idx = this.__find__(name);
  32590. if (idx < 0) {
  32591. if (ignoreInvalid) { return; }
  32592. throw new Error('Rules manager: invalid rule name ' + name);
  32593. }
  32594. this.__rules__[idx].enabled = true;
  32595. result.push(name);
  32596. }, this);
  32597. this.__cache__ = null;
  32598. return result;
  32599. };
  32600. /**
  32601. * Ruler.enableOnly(list [, ignoreInvalid])
  32602. * - list (String|Array): list of rule names to enable (whitelist).
  32603. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  32604. *
  32605. * Enable rules with given names, and disable everything else. If any rule name
  32606. * not found - throw Error. Errors can be disabled by second param.
  32607. *
  32608. * See also [[Ruler.disable]], [[Ruler.enable]].
  32609. **/
  32610. Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
  32611. if (!Array.isArray(list)) { list = [ list ]; }
  32612. this.__rules__.forEach(function (rule) { rule.enabled = false; });
  32613. this.enable(list, ignoreInvalid);
  32614. };
  32615. /**
  32616. * Ruler.disable(list [, ignoreInvalid]) -> Array
  32617. * - list (String|Array): list of rule names to disable.
  32618. * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
  32619. *
  32620. * Disable rules with given names. If any rule name not found - throw Error.
  32621. * Errors can be disabled by second param.
  32622. *
  32623. * Returns list of found rule names (if no exception happened).
  32624. *
  32625. * See also [[Ruler.enable]], [[Ruler.enableOnly]].
  32626. **/
  32627. Ruler.prototype.disable = function (list, ignoreInvalid) {
  32628. if (!Array.isArray(list)) { list = [ list ]; }
  32629. var result = [];
  32630. // Search by name and disable
  32631. list.forEach(function (name) {
  32632. var idx = this.__find__(name);
  32633. if (idx < 0) {
  32634. if (ignoreInvalid) { return; }
  32635. throw new Error('Rules manager: invalid rule name ' + name);
  32636. }
  32637. this.__rules__[idx].enabled = false;
  32638. result.push(name);
  32639. }, this);
  32640. this.__cache__ = null;
  32641. return result;
  32642. };
  32643. /**
  32644. * Ruler.getRules(chainName) -> Array
  32645. *
  32646. * Return array of active functions (rules) for given chain name. It analyzes
  32647. * rules configuration, compiles caches if not exists and returns result.
  32648. *
  32649. * Default chain name is `''` (empty string). It can't be skipped. That's
  32650. * done intentionally, to keep signature monomorphic for high speed.
  32651. **/
  32652. Ruler.prototype.getRules = function (chainName) {
  32653. if (this.__cache__ === null) {
  32654. this.__compile__();
  32655. }
  32656. // Chain can be empty, if rules disabled. But we still have to return Array.
  32657. return this.__cache__[chainName] || [];
  32658. };
  32659. module.exports = Ruler;
  32660. },{}],158:[function(require,module,exports){
  32661. // Block quotes
  32662. 'use strict';
  32663. var isSpace = require('../common/utils').isSpace;
  32664. module.exports = function blockquote(state, startLine, endLine, silent) {
  32665. var adjustTab,
  32666. ch,
  32667. i,
  32668. initial,
  32669. l,
  32670. lastLineEmpty,
  32671. lines,
  32672. nextLine,
  32673. offset,
  32674. oldBMarks,
  32675. oldBSCount,
  32676. oldIndent,
  32677. oldParentType,
  32678. oldSCount,
  32679. oldTShift,
  32680. spaceAfterMarker,
  32681. terminate,
  32682. terminatorRules,
  32683. token,
  32684. wasOutdented,
  32685. oldLineMax = state.lineMax,
  32686. pos = state.bMarks[startLine] + state.tShift[startLine],
  32687. max = state.eMarks[startLine];
  32688. // if it's indented more than 3 spaces, it should be a code block
  32689. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  32690. // check the block quote marker
  32691. if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
  32692. // we know that it's going to be a valid blockquote,
  32693. // so no point trying to find the end of it in silent mode
  32694. if (silent) { return true; }
  32695. // skip spaces after ">" and re-calculate offset
  32696. initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
  32697. // skip one optional space after '>'
  32698. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  32699. // ' > test '
  32700. // ^ -- position start of line here:
  32701. pos++;
  32702. initial++;
  32703. offset++;
  32704. adjustTab = false;
  32705. spaceAfterMarker = true;
  32706. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  32707. spaceAfterMarker = true;
  32708. if ((state.bsCount[startLine] + offset) % 4 === 3) {
  32709. // ' >\t test '
  32710. // ^ -- position start of line here (tab has width===1)
  32711. pos++;
  32712. initial++;
  32713. offset++;
  32714. adjustTab = false;
  32715. } else {
  32716. // ' >\t test '
  32717. // ^ -- position start of line here + shift bsCount slightly
  32718. // to make extra space appear
  32719. adjustTab = true;
  32720. }
  32721. } else {
  32722. spaceAfterMarker = false;
  32723. }
  32724. oldBMarks = [ state.bMarks[startLine] ];
  32725. state.bMarks[startLine] = pos;
  32726. while (pos < max) {
  32727. ch = state.src.charCodeAt(pos);
  32728. if (isSpace(ch)) {
  32729. if (ch === 0x09) {
  32730. offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
  32731. } else {
  32732. offset++;
  32733. }
  32734. } else {
  32735. break;
  32736. }
  32737. pos++;
  32738. }
  32739. oldBSCount = [ state.bsCount[startLine] ];
  32740. state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
  32741. lastLineEmpty = pos >= max;
  32742. oldSCount = [ state.sCount[startLine] ];
  32743. state.sCount[startLine] = offset - initial;
  32744. oldTShift = [ state.tShift[startLine] ];
  32745. state.tShift[startLine] = pos - state.bMarks[startLine];
  32746. terminatorRules = state.md.block.ruler.getRules('blockquote');
  32747. oldParentType = state.parentType;
  32748. state.parentType = 'blockquote';
  32749. wasOutdented = false;
  32750. // Search the end of the block
  32751. //
  32752. // Block ends with either:
  32753. // 1. an empty line outside:
  32754. // ```
  32755. // > test
  32756. //
  32757. // ```
  32758. // 2. an empty line inside:
  32759. // ```
  32760. // >
  32761. // test
  32762. // ```
  32763. // 3. another tag:
  32764. // ```
  32765. // > test
  32766. // - - -
  32767. // ```
  32768. for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
  32769. // check if it's outdented, i.e. it's inside list item and indented
  32770. // less than said list item:
  32771. //
  32772. // ```
  32773. // 1. anything
  32774. // > current blockquote
  32775. // 2. checking this line
  32776. // ```
  32777. if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true;
  32778. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  32779. max = state.eMarks[nextLine];
  32780. if (pos >= max) {
  32781. // Case 1: line is not inside the blockquote, and this line is empty.
  32782. break;
  32783. }
  32784. if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) {
  32785. // This line is inside the blockquote.
  32786. // skip spaces after ">" and re-calculate offset
  32787. initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]);
  32788. // skip one optional space after '>'
  32789. if (state.src.charCodeAt(pos) === 0x20 /* space */) {
  32790. // ' > test '
  32791. // ^ -- position start of line here:
  32792. pos++;
  32793. initial++;
  32794. offset++;
  32795. adjustTab = false;
  32796. spaceAfterMarker = true;
  32797. } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
  32798. spaceAfterMarker = true;
  32799. if ((state.bsCount[nextLine] + offset) % 4 === 3) {
  32800. // ' >\t test '
  32801. // ^ -- position start of line here (tab has width===1)
  32802. pos++;
  32803. initial++;
  32804. offset++;
  32805. adjustTab = false;
  32806. } else {
  32807. // ' >\t test '
  32808. // ^ -- position start of line here + shift bsCount slightly
  32809. // to make extra space appear
  32810. adjustTab = true;
  32811. }
  32812. } else {
  32813. spaceAfterMarker = false;
  32814. }
  32815. oldBMarks.push(state.bMarks[nextLine]);
  32816. state.bMarks[nextLine] = pos;
  32817. while (pos < max) {
  32818. ch = state.src.charCodeAt(pos);
  32819. if (isSpace(ch)) {
  32820. if (ch === 0x09) {
  32821. offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
  32822. } else {
  32823. offset++;
  32824. }
  32825. } else {
  32826. break;
  32827. }
  32828. pos++;
  32829. }
  32830. lastLineEmpty = pos >= max;
  32831. oldBSCount.push(state.bsCount[nextLine]);
  32832. state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
  32833. oldSCount.push(state.sCount[nextLine]);
  32834. state.sCount[nextLine] = offset - initial;
  32835. oldTShift.push(state.tShift[nextLine]);
  32836. state.tShift[nextLine] = pos - state.bMarks[nextLine];
  32837. continue;
  32838. }
  32839. // Case 2: line is not inside the blockquote, and the last line was empty.
  32840. if (lastLineEmpty) { break; }
  32841. // Case 3: another tag found.
  32842. terminate = false;
  32843. for (i = 0, l = terminatorRules.length; i < l; i++) {
  32844. if (terminatorRules[i](state, nextLine, endLine, true)) {
  32845. terminate = true;
  32846. break;
  32847. }
  32848. }
  32849. if (terminate) {
  32850. // Quirk to enforce "hard termination mode" for paragraphs;
  32851. // normally if you call `tokenize(state, startLine, nextLine)`,
  32852. // paragraphs will look below nextLine for paragraph continuation,
  32853. // but if blockquote is terminated by another tag, they shouldn't
  32854. state.lineMax = nextLine;
  32855. if (state.blkIndent !== 0) {
  32856. // state.blkIndent was non-zero, we now set it to zero,
  32857. // so we need to re-calculate all offsets to appear as
  32858. // if indent wasn't changed
  32859. oldBMarks.push(state.bMarks[nextLine]);
  32860. oldBSCount.push(state.bsCount[nextLine]);
  32861. oldTShift.push(state.tShift[nextLine]);
  32862. oldSCount.push(state.sCount[nextLine]);
  32863. state.sCount[nextLine] -= state.blkIndent;
  32864. }
  32865. break;
  32866. }
  32867. oldBMarks.push(state.bMarks[nextLine]);
  32868. oldBSCount.push(state.bsCount[nextLine]);
  32869. oldTShift.push(state.tShift[nextLine]);
  32870. oldSCount.push(state.sCount[nextLine]);
  32871. // A negative indentation means that this is a paragraph continuation
  32872. //
  32873. state.sCount[nextLine] = -1;
  32874. }
  32875. oldIndent = state.blkIndent;
  32876. state.blkIndent = 0;
  32877. token = state.push('blockquote_open', 'blockquote', 1);
  32878. token.markup = '>';
  32879. token.map = lines = [ startLine, 0 ];
  32880. state.md.block.tokenize(state, startLine, nextLine);
  32881. token = state.push('blockquote_close', 'blockquote', -1);
  32882. token.markup = '>';
  32883. state.lineMax = oldLineMax;
  32884. state.parentType = oldParentType;
  32885. lines[1] = state.line;
  32886. // Restore original tShift; this might not be necessary since the parser
  32887. // has already been here, but just to make sure we can do that.
  32888. for (i = 0; i < oldTShift.length; i++) {
  32889. state.bMarks[i + startLine] = oldBMarks[i];
  32890. state.tShift[i + startLine] = oldTShift[i];
  32891. state.sCount[i + startLine] = oldSCount[i];
  32892. state.bsCount[i + startLine] = oldBSCount[i];
  32893. }
  32894. state.blkIndent = oldIndent;
  32895. return true;
  32896. };
  32897. },{"../common/utils":144}],159:[function(require,module,exports){
  32898. // Code block (4 spaces padded)
  32899. 'use strict';
  32900. module.exports = function code(state, startLine, endLine/*, silent*/) {
  32901. var nextLine, last, token;
  32902. if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
  32903. last = nextLine = startLine + 1;
  32904. while (nextLine < endLine) {
  32905. if (state.isEmpty(nextLine)) {
  32906. nextLine++;
  32907. continue;
  32908. }
  32909. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  32910. nextLine++;
  32911. last = nextLine;
  32912. continue;
  32913. }
  32914. break;
  32915. }
  32916. state.line = last;
  32917. token = state.push('code_block', 'code', 0);
  32918. token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
  32919. token.map = [ startLine, state.line ];
  32920. return true;
  32921. };
  32922. },{}],160:[function(require,module,exports){
  32923. // fences (``` lang, ~~~ lang)
  32924. 'use strict';
  32925. module.exports = function fence(state, startLine, endLine, silent) {
  32926. var marker, len, params, nextLine, mem, token, markup,
  32927. haveEndMarker = false,
  32928. pos = state.bMarks[startLine] + state.tShift[startLine],
  32929. max = state.eMarks[startLine];
  32930. // if it's indented more than 3 spaces, it should be a code block
  32931. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  32932. if (pos + 3 > max) { return false; }
  32933. marker = state.src.charCodeAt(pos);
  32934. if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
  32935. return false;
  32936. }
  32937. // scan marker length
  32938. mem = pos;
  32939. pos = state.skipChars(pos, marker);
  32940. len = pos - mem;
  32941. if (len < 3) { return false; }
  32942. markup = state.src.slice(mem, pos);
  32943. params = state.src.slice(pos, max);
  32944. if (params.indexOf(String.fromCharCode(marker)) >= 0) { return false; }
  32945. // Since start is found, we can report success here in validation mode
  32946. if (silent) { return true; }
  32947. // search end of block
  32948. nextLine = startLine;
  32949. for (;;) {
  32950. nextLine++;
  32951. if (nextLine >= endLine) {
  32952. // unclosed block should be autoclosed by end of document.
  32953. // also block seems to be autoclosed by end of parent
  32954. break;
  32955. }
  32956. pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
  32957. max = state.eMarks[nextLine];
  32958. if (pos < max && state.sCount[nextLine] < state.blkIndent) {
  32959. // non-empty line with negative indent should stop the list:
  32960. // - ```
  32961. // test
  32962. break;
  32963. }
  32964. if (state.src.charCodeAt(pos) !== marker) { continue; }
  32965. if (state.sCount[nextLine] - state.blkIndent >= 4) {
  32966. // closing fence should be indented less than 4 spaces
  32967. continue;
  32968. }
  32969. pos = state.skipChars(pos, marker);
  32970. // closing code fence must be at least as long as the opening one
  32971. if (pos - mem < len) { continue; }
  32972. // make sure tail has spaces only
  32973. pos = state.skipSpaces(pos);
  32974. if (pos < max) { continue; }
  32975. haveEndMarker = true;
  32976. // found!
  32977. break;
  32978. }
  32979. // If a fence has heading spaces, they should be removed from its inner block
  32980. len = state.sCount[startLine];
  32981. state.line = nextLine + (haveEndMarker ? 1 : 0);
  32982. token = state.push('fence', 'code', 0);
  32983. token.info = params;
  32984. token.content = state.getLines(startLine + 1, nextLine, len, true);
  32985. token.markup = markup;
  32986. token.map = [ startLine, state.line ];
  32987. return true;
  32988. };
  32989. },{}],161:[function(require,module,exports){
  32990. // heading (#, ##, ...)
  32991. 'use strict';
  32992. var isSpace = require('../common/utils').isSpace;
  32993. module.exports = function heading(state, startLine, endLine, silent) {
  32994. var ch, level, tmp, token,
  32995. pos = state.bMarks[startLine] + state.tShift[startLine],
  32996. max = state.eMarks[startLine];
  32997. // if it's indented more than 3 spaces, it should be a code block
  32998. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  32999. ch = state.src.charCodeAt(pos);
  33000. if (ch !== 0x23/* # */ || pos >= max) { return false; }
  33001. // count heading level
  33002. level = 1;
  33003. ch = state.src.charCodeAt(++pos);
  33004. while (ch === 0x23/* # */ && pos < max && level <= 6) {
  33005. level++;
  33006. ch = state.src.charCodeAt(++pos);
  33007. }
  33008. if (level > 6 || (pos < max && !isSpace(ch))) { return false; }
  33009. if (silent) { return true; }
  33010. // Let's cut tails like ' ### ' from the end of string
  33011. max = state.skipSpacesBack(max, pos);
  33012. tmp = state.skipCharsBack(max, 0x23, pos); // #
  33013. if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {
  33014. max = tmp;
  33015. }
  33016. state.line = startLine + 1;
  33017. token = state.push('heading_open', 'h' + String(level), 1);
  33018. token.markup = '########'.slice(0, level);
  33019. token.map = [ startLine, state.line ];
  33020. token = state.push('inline', '', 0);
  33021. token.content = state.src.slice(pos, max).trim();
  33022. token.map = [ startLine, state.line ];
  33023. token.children = [];
  33024. token = state.push('heading_close', 'h' + String(level), -1);
  33025. token.markup = '########'.slice(0, level);
  33026. return true;
  33027. };
  33028. },{"../common/utils":144}],162:[function(require,module,exports){
  33029. // Horizontal rule
  33030. 'use strict';
  33031. var isSpace = require('../common/utils').isSpace;
  33032. module.exports = function hr(state, startLine, endLine, silent) {
  33033. var marker, cnt, ch, token,
  33034. pos = state.bMarks[startLine] + state.tShift[startLine],
  33035. max = state.eMarks[startLine];
  33036. // if it's indented more than 3 spaces, it should be a code block
  33037. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33038. marker = state.src.charCodeAt(pos++);
  33039. // Check hr marker
  33040. if (marker !== 0x2A/* * */ &&
  33041. marker !== 0x2D/* - */ &&
  33042. marker !== 0x5F/* _ */) {
  33043. return false;
  33044. }
  33045. // markers can be mixed with spaces, but there should be at least 3 of them
  33046. cnt = 1;
  33047. while (pos < max) {
  33048. ch = state.src.charCodeAt(pos++);
  33049. if (ch !== marker && !isSpace(ch)) { return false; }
  33050. if (ch === marker) { cnt++; }
  33051. }
  33052. if (cnt < 3) { return false; }
  33053. if (silent) { return true; }
  33054. state.line = startLine + 1;
  33055. token = state.push('hr', 'hr', 0);
  33056. token.map = [ startLine, state.line ];
  33057. token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
  33058. return true;
  33059. };
  33060. },{"../common/utils":144}],163:[function(require,module,exports){
  33061. // HTML block
  33062. 'use strict';
  33063. var block_names = require('../common/html_blocks');
  33064. var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE;
  33065. // An array of opening and corresponding closing sequences for html tags,
  33066. // last argument defines whether it can terminate a paragraph or not
  33067. //
  33068. var HTML_SEQUENCES = [
  33069. [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],
  33070. [ /^<!--/, /-->/, true ],
  33071. [ /^<\?/, /\?>/, true ],
  33072. [ /^<![A-Z]/, />/, true ],
  33073. [ /^<!\[CDATA\[/, /\]\]>/, true ],
  33074. [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
  33075. [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
  33076. ];
  33077. module.exports = function html_block(state, startLine, endLine, silent) {
  33078. var i, nextLine, token, lineText,
  33079. pos = state.bMarks[startLine] + state.tShift[startLine],
  33080. max = state.eMarks[startLine];
  33081. // if it's indented more than 3 spaces, it should be a code block
  33082. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33083. if (!state.md.options.html) { return false; }
  33084. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  33085. lineText = state.src.slice(pos, max);
  33086. for (i = 0; i < HTML_SEQUENCES.length; i++) {
  33087. if (HTML_SEQUENCES[i][0].test(lineText)) { break; }
  33088. }
  33089. if (i === HTML_SEQUENCES.length) { return false; }
  33090. if (silent) {
  33091. // true if this sequence can be a terminator, false otherwise
  33092. return HTML_SEQUENCES[i][2];
  33093. }
  33094. nextLine = startLine + 1;
  33095. // If we are here - we detected HTML block.
  33096. // Let's roll down till block end.
  33097. if (!HTML_SEQUENCES[i][1].test(lineText)) {
  33098. for (; nextLine < endLine; nextLine++) {
  33099. if (state.sCount[nextLine] < state.blkIndent) { break; }
  33100. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  33101. max = state.eMarks[nextLine];
  33102. lineText = state.src.slice(pos, max);
  33103. if (HTML_SEQUENCES[i][1].test(lineText)) {
  33104. if (lineText.length !== 0) { nextLine++; }
  33105. break;
  33106. }
  33107. }
  33108. }
  33109. state.line = nextLine;
  33110. token = state.push('html_block', '', 0);
  33111. token.map = [ startLine, nextLine ];
  33112. token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
  33113. return true;
  33114. };
  33115. },{"../common/html_blocks":142,"../common/html_re":143}],164:[function(require,module,exports){
  33116. // lheading (---, ===)
  33117. 'use strict';
  33118. module.exports = function lheading(state, startLine, endLine/*, silent*/) {
  33119. var content, terminate, i, l, token, pos, max, level, marker,
  33120. nextLine = startLine + 1, oldParentType,
  33121. terminatorRules = state.md.block.ruler.getRules('paragraph');
  33122. // if it's indented more than 3 spaces, it should be a code block
  33123. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33124. oldParentType = state.parentType;
  33125. state.parentType = 'paragraph'; // use paragraph to match terminatorRules
  33126. // jump line-by-line until empty one or EOF
  33127. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  33128. // this would be a code block normally, but after paragraph
  33129. // it's considered a lazy continuation regardless of what's there
  33130. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  33131. //
  33132. // Check for underline in setext header
  33133. //
  33134. if (state.sCount[nextLine] >= state.blkIndent) {
  33135. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  33136. max = state.eMarks[nextLine];
  33137. if (pos < max) {
  33138. marker = state.src.charCodeAt(pos);
  33139. if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {
  33140. pos = state.skipChars(pos, marker);
  33141. pos = state.skipSpaces(pos);
  33142. if (pos >= max) {
  33143. level = (marker === 0x3D/* = */ ? 1 : 2);
  33144. break;
  33145. }
  33146. }
  33147. }
  33148. }
  33149. // quirk for blockquotes, this line should already be checked by that rule
  33150. if (state.sCount[nextLine] < 0) { continue; }
  33151. // Some tags can terminate paragraph without empty line.
  33152. terminate = false;
  33153. for (i = 0, l = terminatorRules.length; i < l; i++) {
  33154. if (terminatorRules[i](state, nextLine, endLine, true)) {
  33155. terminate = true;
  33156. break;
  33157. }
  33158. }
  33159. if (terminate) { break; }
  33160. }
  33161. if (!level) {
  33162. // Didn't find valid underline
  33163. return false;
  33164. }
  33165. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  33166. state.line = nextLine + 1;
  33167. token = state.push('heading_open', 'h' + String(level), 1);
  33168. token.markup = String.fromCharCode(marker);
  33169. token.map = [ startLine, state.line ];
  33170. token = state.push('inline', '', 0);
  33171. token.content = content;
  33172. token.map = [ startLine, state.line - 1 ];
  33173. token.children = [];
  33174. token = state.push('heading_close', 'h' + String(level), -1);
  33175. token.markup = String.fromCharCode(marker);
  33176. state.parentType = oldParentType;
  33177. return true;
  33178. };
  33179. },{}],165:[function(require,module,exports){
  33180. // Lists
  33181. 'use strict';
  33182. var isSpace = require('../common/utils').isSpace;
  33183. // Search `[-+*][\n ]`, returns next pos after marker on success
  33184. // or -1 on fail.
  33185. function skipBulletListMarker(state, startLine) {
  33186. var marker, pos, max, ch;
  33187. pos = state.bMarks[startLine] + state.tShift[startLine];
  33188. max = state.eMarks[startLine];
  33189. marker = state.src.charCodeAt(pos++);
  33190. // Check bullet
  33191. if (marker !== 0x2A/* * */ &&
  33192. marker !== 0x2D/* - */ &&
  33193. marker !== 0x2B/* + */) {
  33194. return -1;
  33195. }
  33196. if (pos < max) {
  33197. ch = state.src.charCodeAt(pos);
  33198. if (!isSpace(ch)) {
  33199. // " -test " - is not a list item
  33200. return -1;
  33201. }
  33202. }
  33203. return pos;
  33204. }
  33205. // Search `\d+[.)][\n ]`, returns next pos after marker on success
  33206. // or -1 on fail.
  33207. function skipOrderedListMarker(state, startLine) {
  33208. var ch,
  33209. start = state.bMarks[startLine] + state.tShift[startLine],
  33210. pos = start,
  33211. max = state.eMarks[startLine];
  33212. // List marker should have at least 2 chars (digit + dot)
  33213. if (pos + 1 >= max) { return -1; }
  33214. ch = state.src.charCodeAt(pos++);
  33215. if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
  33216. for (;;) {
  33217. // EOL -> fail
  33218. if (pos >= max) { return -1; }
  33219. ch = state.src.charCodeAt(pos++);
  33220. if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
  33221. // List marker should have no more than 9 digits
  33222. // (prevents integer overflow in browsers)
  33223. if (pos - start >= 10) { return -1; }
  33224. continue;
  33225. }
  33226. // found valid marker
  33227. if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
  33228. break;
  33229. }
  33230. return -1;
  33231. }
  33232. if (pos < max) {
  33233. ch = state.src.charCodeAt(pos);
  33234. if (!isSpace(ch)) {
  33235. // " 1.test " - is not a list item
  33236. return -1;
  33237. }
  33238. }
  33239. return pos;
  33240. }
  33241. function markTightParagraphs(state, idx) {
  33242. var i, l,
  33243. level = state.level + 2;
  33244. for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
  33245. if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
  33246. state.tokens[i + 2].hidden = true;
  33247. state.tokens[i].hidden = true;
  33248. i += 2;
  33249. }
  33250. }
  33251. }
  33252. module.exports = function list(state, startLine, endLine, silent) {
  33253. var ch,
  33254. contentStart,
  33255. i,
  33256. indent,
  33257. indentAfterMarker,
  33258. initial,
  33259. isOrdered,
  33260. itemLines,
  33261. l,
  33262. listLines,
  33263. listTokIdx,
  33264. markerCharCode,
  33265. markerValue,
  33266. max,
  33267. nextLine,
  33268. offset,
  33269. oldIndent,
  33270. oldLIndent,
  33271. oldParentType,
  33272. oldTShift,
  33273. oldTight,
  33274. pos,
  33275. posAfterMarker,
  33276. prevEmptyEnd,
  33277. start,
  33278. terminate,
  33279. terminatorRules,
  33280. token,
  33281. isTerminatingParagraph = false,
  33282. tight = true;
  33283. // if it's indented more than 3 spaces, it should be a code block
  33284. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33285. // limit conditions when list can interrupt
  33286. // a paragraph (validation mode only)
  33287. if (silent && state.parentType === 'paragraph') {
  33288. // Next list item should still terminate previous list item;
  33289. //
  33290. // This code can fail if plugins use blkIndent as well as lists,
  33291. // but I hope the spec gets fixed long before that happens.
  33292. //
  33293. if (state.tShift[startLine] >= state.blkIndent) {
  33294. isTerminatingParagraph = true;
  33295. }
  33296. }
  33297. // Detect list type and position after marker
  33298. if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
  33299. isOrdered = true;
  33300. start = state.bMarks[startLine] + state.tShift[startLine];
  33301. markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
  33302. // If we're starting a new ordered list right after
  33303. // a paragraph, it should start with 1.
  33304. if (isTerminatingParagraph && markerValue !== 1) return false;
  33305. } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
  33306. isOrdered = false;
  33307. } else {
  33308. return false;
  33309. }
  33310. // If we're starting a new unordered list right after
  33311. // a paragraph, first line should not be empty.
  33312. if (isTerminatingParagraph) {
  33313. if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
  33314. }
  33315. // We should terminate list on style change. Remember first one to compare.
  33316. markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
  33317. // For validation mode we can terminate immediately
  33318. if (silent) { return true; }
  33319. // Start list
  33320. listTokIdx = state.tokens.length;
  33321. if (isOrdered) {
  33322. token = state.push('ordered_list_open', 'ol', 1);
  33323. if (markerValue !== 1) {
  33324. token.attrs = [ [ 'start', markerValue ] ];
  33325. }
  33326. } else {
  33327. token = state.push('bullet_list_open', 'ul', 1);
  33328. }
  33329. token.map = listLines = [ startLine, 0 ];
  33330. token.markup = String.fromCharCode(markerCharCode);
  33331. //
  33332. // Iterate list items
  33333. //
  33334. nextLine = startLine;
  33335. prevEmptyEnd = false;
  33336. terminatorRules = state.md.block.ruler.getRules('list');
  33337. oldParentType = state.parentType;
  33338. state.parentType = 'list';
  33339. while (nextLine < endLine) {
  33340. pos = posAfterMarker;
  33341. max = state.eMarks[nextLine];
  33342. initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
  33343. while (pos < max) {
  33344. ch = state.src.charCodeAt(pos);
  33345. if (ch === 0x09) {
  33346. offset += 4 - (offset + state.bsCount[nextLine]) % 4;
  33347. } else if (ch === 0x20) {
  33348. offset++;
  33349. } else {
  33350. break;
  33351. }
  33352. pos++;
  33353. }
  33354. contentStart = pos;
  33355. if (contentStart >= max) {
  33356. // trimming space in "- \n 3" case, indent is 1 here
  33357. indentAfterMarker = 1;
  33358. } else {
  33359. indentAfterMarker = offset - initial;
  33360. }
  33361. // If we have more than 4 spaces, the indent is 1
  33362. // (the rest is just indented code block)
  33363. if (indentAfterMarker > 4) { indentAfterMarker = 1; }
  33364. // " - test"
  33365. // ^^^^^ - calculating total length of this thing
  33366. indent = initial + indentAfterMarker;
  33367. // Run subparser & write tokens
  33368. token = state.push('list_item_open', 'li', 1);
  33369. token.markup = String.fromCharCode(markerCharCode);
  33370. token.map = itemLines = [ startLine, 0 ];
  33371. oldIndent = state.blkIndent;
  33372. oldTight = state.tight;
  33373. oldTShift = state.tShift[startLine];
  33374. oldLIndent = state.sCount[startLine];
  33375. state.blkIndent = indent;
  33376. state.tight = true;
  33377. state.tShift[startLine] = contentStart - state.bMarks[startLine];
  33378. state.sCount[startLine] = offset;
  33379. if (contentStart >= max && state.isEmpty(startLine + 1)) {
  33380. // workaround for this case
  33381. // (list item is empty, list terminates before "foo"):
  33382. // ~~~~~~~~
  33383. // -
  33384. //
  33385. // foo
  33386. // ~~~~~~~~
  33387. state.line = Math.min(state.line + 2, endLine);
  33388. } else {
  33389. state.md.block.tokenize(state, startLine, endLine, true);
  33390. }
  33391. // If any of list item is tight, mark list as tight
  33392. if (!state.tight || prevEmptyEnd) {
  33393. tight = false;
  33394. }
  33395. // Item become loose if finish with empty line,
  33396. // but we should filter last element, because it means list finish
  33397. prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
  33398. state.blkIndent = oldIndent;
  33399. state.tShift[startLine] = oldTShift;
  33400. state.sCount[startLine] = oldLIndent;
  33401. state.tight = oldTight;
  33402. token = state.push('list_item_close', 'li', -1);
  33403. token.markup = String.fromCharCode(markerCharCode);
  33404. nextLine = startLine = state.line;
  33405. itemLines[1] = nextLine;
  33406. contentStart = state.bMarks[startLine];
  33407. if (nextLine >= endLine) { break; }
  33408. //
  33409. // Try to check if list is terminated or continued.
  33410. //
  33411. if (state.sCount[nextLine] < state.blkIndent) { break; }
  33412. // fail if terminating block found
  33413. terminate = false;
  33414. for (i = 0, l = terminatorRules.length; i < l; i++) {
  33415. if (terminatorRules[i](state, nextLine, endLine, true)) {
  33416. terminate = true;
  33417. break;
  33418. }
  33419. }
  33420. if (terminate) { break; }
  33421. // fail if list has another type
  33422. if (isOrdered) {
  33423. posAfterMarker = skipOrderedListMarker(state, nextLine);
  33424. if (posAfterMarker < 0) { break; }
  33425. } else {
  33426. posAfterMarker = skipBulletListMarker(state, nextLine);
  33427. if (posAfterMarker < 0) { break; }
  33428. }
  33429. if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
  33430. }
  33431. // Finalize list
  33432. if (isOrdered) {
  33433. token = state.push('ordered_list_close', 'ol', -1);
  33434. } else {
  33435. token = state.push('bullet_list_close', 'ul', -1);
  33436. }
  33437. token.markup = String.fromCharCode(markerCharCode);
  33438. listLines[1] = nextLine;
  33439. state.line = nextLine;
  33440. state.parentType = oldParentType;
  33441. // mark paragraphs tight if needed
  33442. if (tight) {
  33443. markTightParagraphs(state, listTokIdx);
  33444. }
  33445. return true;
  33446. };
  33447. },{"../common/utils":144}],166:[function(require,module,exports){
  33448. // Paragraph
  33449. 'use strict';
  33450. module.exports = function paragraph(state, startLine/*, endLine*/) {
  33451. var content, terminate, i, l, token, oldParentType,
  33452. nextLine = startLine + 1,
  33453. terminatorRules = state.md.block.ruler.getRules('paragraph'),
  33454. endLine = state.lineMax;
  33455. oldParentType = state.parentType;
  33456. state.parentType = 'paragraph';
  33457. // jump line-by-line until empty one or EOF
  33458. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  33459. // this would be a code block normally, but after paragraph
  33460. // it's considered a lazy continuation regardless of what's there
  33461. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  33462. // quirk for blockquotes, this line should already be checked by that rule
  33463. if (state.sCount[nextLine] < 0) { continue; }
  33464. // Some tags can terminate paragraph without empty line.
  33465. terminate = false;
  33466. for (i = 0, l = terminatorRules.length; i < l; i++) {
  33467. if (terminatorRules[i](state, nextLine, endLine, true)) {
  33468. terminate = true;
  33469. break;
  33470. }
  33471. }
  33472. if (terminate) { break; }
  33473. }
  33474. content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  33475. state.line = nextLine;
  33476. token = state.push('paragraph_open', 'p', 1);
  33477. token.map = [ startLine, state.line ];
  33478. token = state.push('inline', '', 0);
  33479. token.content = content;
  33480. token.map = [ startLine, state.line ];
  33481. token.children = [];
  33482. token = state.push('paragraph_close', 'p', -1);
  33483. state.parentType = oldParentType;
  33484. return true;
  33485. };
  33486. },{}],167:[function(require,module,exports){
  33487. 'use strict';
  33488. var normalizeReference = require('../common/utils').normalizeReference;
  33489. var isSpace = require('../common/utils').isSpace;
  33490. module.exports = function reference(state, startLine, _endLine, silent) {
  33491. var ch,
  33492. destEndPos,
  33493. destEndLineNo,
  33494. endLine,
  33495. href,
  33496. i,
  33497. l,
  33498. label,
  33499. labelEnd,
  33500. oldParentType,
  33501. res,
  33502. start,
  33503. str,
  33504. terminate,
  33505. terminatorRules,
  33506. title,
  33507. lines = 0,
  33508. pos = state.bMarks[startLine] + state.tShift[startLine],
  33509. max = state.eMarks[startLine],
  33510. nextLine = startLine + 1;
  33511. // if it's indented more than 3 spaces, it should be a code block
  33512. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33513. if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
  33514. // Simple check to quickly interrupt scan on [link](url) at the start of line.
  33515. // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
  33516. while (++pos < max) {
  33517. if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
  33518. state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
  33519. if (pos + 1 === max) { return false; }
  33520. if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }
  33521. break;
  33522. }
  33523. }
  33524. endLine = state.lineMax;
  33525. // jump line-by-line until empty one or EOF
  33526. terminatorRules = state.md.block.ruler.getRules('reference');
  33527. oldParentType = state.parentType;
  33528. state.parentType = 'reference';
  33529. for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
  33530. // this would be a code block normally, but after paragraph
  33531. // it's considered a lazy continuation regardless of what's there
  33532. if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
  33533. // quirk for blockquotes, this line should already be checked by that rule
  33534. if (state.sCount[nextLine] < 0) { continue; }
  33535. // Some tags can terminate paragraph without empty line.
  33536. terminate = false;
  33537. for (i = 0, l = terminatorRules.length; i < l; i++) {
  33538. if (terminatorRules[i](state, nextLine, endLine, true)) {
  33539. terminate = true;
  33540. break;
  33541. }
  33542. }
  33543. if (terminate) { break; }
  33544. }
  33545. str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
  33546. max = str.length;
  33547. for (pos = 1; pos < max; pos++) {
  33548. ch = str.charCodeAt(pos);
  33549. if (ch === 0x5B /* [ */) {
  33550. return false;
  33551. } else if (ch === 0x5D /* ] */) {
  33552. labelEnd = pos;
  33553. break;
  33554. } else if (ch === 0x0A /* \n */) {
  33555. lines++;
  33556. } else if (ch === 0x5C /* \ */) {
  33557. pos++;
  33558. if (pos < max && str.charCodeAt(pos) === 0x0A) {
  33559. lines++;
  33560. }
  33561. }
  33562. }
  33563. if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }
  33564. // [label]: destination 'title'
  33565. // ^^^ skip optional whitespace here
  33566. for (pos = labelEnd + 2; pos < max; pos++) {
  33567. ch = str.charCodeAt(pos);
  33568. if (ch === 0x0A) {
  33569. lines++;
  33570. } else if (isSpace(ch)) {
  33571. /*eslint no-empty:0*/
  33572. } else {
  33573. break;
  33574. }
  33575. }
  33576. // [label]: destination 'title'
  33577. // ^^^^^^^^^^^ parse this
  33578. res = state.md.helpers.parseLinkDestination(str, pos, max);
  33579. if (!res.ok) { return false; }
  33580. href = state.md.normalizeLink(res.str);
  33581. if (!state.md.validateLink(href)) { return false; }
  33582. pos = res.pos;
  33583. lines += res.lines;
  33584. // save cursor state, we could require to rollback later
  33585. destEndPos = pos;
  33586. destEndLineNo = lines;
  33587. // [label]: destination 'title'
  33588. // ^^^ skipping those spaces
  33589. start = pos;
  33590. for (; pos < max; pos++) {
  33591. ch = str.charCodeAt(pos);
  33592. if (ch === 0x0A) {
  33593. lines++;
  33594. } else if (isSpace(ch)) {
  33595. /*eslint no-empty:0*/
  33596. } else {
  33597. break;
  33598. }
  33599. }
  33600. // [label]: destination 'title'
  33601. // ^^^^^^^ parse this
  33602. res = state.md.helpers.parseLinkTitle(str, pos, max);
  33603. if (pos < max && start !== pos && res.ok) {
  33604. title = res.str;
  33605. pos = res.pos;
  33606. lines += res.lines;
  33607. } else {
  33608. title = '';
  33609. pos = destEndPos;
  33610. lines = destEndLineNo;
  33611. }
  33612. // skip trailing spaces until the rest of the line
  33613. while (pos < max) {
  33614. ch = str.charCodeAt(pos);
  33615. if (!isSpace(ch)) { break; }
  33616. pos++;
  33617. }
  33618. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  33619. if (title) {
  33620. // garbage at the end of the line after title,
  33621. // but it could still be a valid reference if we roll back
  33622. title = '';
  33623. pos = destEndPos;
  33624. lines = destEndLineNo;
  33625. while (pos < max) {
  33626. ch = str.charCodeAt(pos);
  33627. if (!isSpace(ch)) { break; }
  33628. pos++;
  33629. }
  33630. }
  33631. }
  33632. if (pos < max && str.charCodeAt(pos) !== 0x0A) {
  33633. // garbage at the end of the line
  33634. return false;
  33635. }
  33636. label = normalizeReference(str.slice(1, labelEnd));
  33637. if (!label) {
  33638. // CommonMark 0.20 disallows empty labels
  33639. return false;
  33640. }
  33641. // Reference can not terminate anything. This check is for safety only.
  33642. /*istanbul ignore if*/
  33643. if (silent) { return true; }
  33644. if (typeof state.env.references === 'undefined') {
  33645. state.env.references = {};
  33646. }
  33647. if (typeof state.env.references[label] === 'undefined') {
  33648. state.env.references[label] = { title: title, href: href };
  33649. }
  33650. state.parentType = oldParentType;
  33651. state.line = startLine + lines + 1;
  33652. return true;
  33653. };
  33654. },{"../common/utils":144}],168:[function(require,module,exports){
  33655. // Parser state class
  33656. 'use strict';
  33657. var Token = require('../token');
  33658. var isSpace = require('../common/utils').isSpace;
  33659. function StateBlock(src, md, env, tokens) {
  33660. var ch, s, start, pos, len, indent, offset, indent_found;
  33661. this.src = src;
  33662. // link to parser instance
  33663. this.md = md;
  33664. this.env = env;
  33665. //
  33666. // Internal state vartiables
  33667. //
  33668. this.tokens = tokens;
  33669. this.bMarks = []; // line begin offsets for fast jumps
  33670. this.eMarks = []; // line end offsets for fast jumps
  33671. this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
  33672. this.sCount = []; // indents for each line (tabs expanded)
  33673. // An amount of virtual spaces (tabs expanded) between beginning
  33674. // of each line (bMarks) and real beginning of that line.
  33675. //
  33676. // It exists only as a hack because blockquotes override bMarks
  33677. // losing information in the process.
  33678. //
  33679. // It's used only when expanding tabs, you can think about it as
  33680. // an initial tab length, e.g. bsCount=21 applied to string `\t123`
  33681. // means first tab should be expanded to 4-21%4 === 3 spaces.
  33682. //
  33683. this.bsCount = [];
  33684. // block parser variables
  33685. this.blkIndent = 0; // required block content indent
  33686. // (for example, if we are in list)
  33687. this.line = 0; // line index in src
  33688. this.lineMax = 0; // lines count
  33689. this.tight = false; // loose/tight mode for lists
  33690. this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
  33691. // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
  33692. // used in lists to determine if they interrupt a paragraph
  33693. this.parentType = 'root';
  33694. this.level = 0;
  33695. // renderer
  33696. this.result = '';
  33697. // Create caches
  33698. // Generate markers.
  33699. s = this.src;
  33700. indent_found = false;
  33701. for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
  33702. ch = s.charCodeAt(pos);
  33703. if (!indent_found) {
  33704. if (isSpace(ch)) {
  33705. indent++;
  33706. if (ch === 0x09) {
  33707. offset += 4 - offset % 4;
  33708. } else {
  33709. offset++;
  33710. }
  33711. continue;
  33712. } else {
  33713. indent_found = true;
  33714. }
  33715. }
  33716. if (ch === 0x0A || pos === len - 1) {
  33717. if (ch !== 0x0A) { pos++; }
  33718. this.bMarks.push(start);
  33719. this.eMarks.push(pos);
  33720. this.tShift.push(indent);
  33721. this.sCount.push(offset);
  33722. this.bsCount.push(0);
  33723. indent_found = false;
  33724. indent = 0;
  33725. offset = 0;
  33726. start = pos + 1;
  33727. }
  33728. }
  33729. // Push fake entry to simplify cache bounds checks
  33730. this.bMarks.push(s.length);
  33731. this.eMarks.push(s.length);
  33732. this.tShift.push(0);
  33733. this.sCount.push(0);
  33734. this.bsCount.push(0);
  33735. this.lineMax = this.bMarks.length - 1; // don't count last fake line
  33736. }
  33737. // Push new token to "stream".
  33738. //
  33739. StateBlock.prototype.push = function (type, tag, nesting) {
  33740. var token = new Token(type, tag, nesting);
  33741. token.block = true;
  33742. if (nesting < 0) { this.level--; }
  33743. token.level = this.level;
  33744. if (nesting > 0) { this.level++; }
  33745. this.tokens.push(token);
  33746. return token;
  33747. };
  33748. StateBlock.prototype.isEmpty = function isEmpty(line) {
  33749. return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
  33750. };
  33751. StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
  33752. for (var max = this.lineMax; from < max; from++) {
  33753. if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
  33754. break;
  33755. }
  33756. }
  33757. return from;
  33758. };
  33759. // Skip spaces from given position.
  33760. StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
  33761. var ch;
  33762. for (var max = this.src.length; pos < max; pos++) {
  33763. ch = this.src.charCodeAt(pos);
  33764. if (!isSpace(ch)) { break; }
  33765. }
  33766. return pos;
  33767. };
  33768. // Skip spaces from given position in reverse.
  33769. StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
  33770. if (pos <= min) { return pos; }
  33771. while (pos > min) {
  33772. if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }
  33773. }
  33774. return pos;
  33775. };
  33776. // Skip char codes from given position
  33777. StateBlock.prototype.skipChars = function skipChars(pos, code) {
  33778. for (var max = this.src.length; pos < max; pos++) {
  33779. if (this.src.charCodeAt(pos) !== code) { break; }
  33780. }
  33781. return pos;
  33782. };
  33783. // Skip char codes reverse from given position - 1
  33784. StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
  33785. if (pos <= min) { return pos; }
  33786. while (pos > min) {
  33787. if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
  33788. }
  33789. return pos;
  33790. };
  33791. // cut lines range from source.
  33792. StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
  33793. var i, lineIndent, ch, first, last, queue, lineStart,
  33794. line = begin;
  33795. if (begin >= end) {
  33796. return '';
  33797. }
  33798. queue = new Array(end - begin);
  33799. for (i = 0; line < end; line++, i++) {
  33800. lineIndent = 0;
  33801. lineStart = first = this.bMarks[line];
  33802. if (line + 1 < end || keepLastLF) {
  33803. // No need for bounds check because we have fake entry on tail.
  33804. last = this.eMarks[line] + 1;
  33805. } else {
  33806. last = this.eMarks[line];
  33807. }
  33808. while (first < last && lineIndent < indent) {
  33809. ch = this.src.charCodeAt(first);
  33810. if (isSpace(ch)) {
  33811. if (ch === 0x09) {
  33812. lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
  33813. } else {
  33814. lineIndent++;
  33815. }
  33816. } else if (first - lineStart < this.tShift[line]) {
  33817. // patched tShift masked characters to look like spaces (blockquotes, list markers)
  33818. lineIndent++;
  33819. } else {
  33820. break;
  33821. }
  33822. first++;
  33823. }
  33824. if (lineIndent > indent) {
  33825. // partially expanding tabs in code blocks, e.g '\t\tfoobar'
  33826. // with indent=2 becomes ' \tfoobar'
  33827. queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);
  33828. } else {
  33829. queue[i] = this.src.slice(first, last);
  33830. }
  33831. }
  33832. return queue.join('');
  33833. };
  33834. // re-export Token class to use in block rules
  33835. StateBlock.prototype.Token = Token;
  33836. module.exports = StateBlock;
  33837. },{"../common/utils":144,"../token":191}],169:[function(require,module,exports){
  33838. // GFM table, non-standard
  33839. 'use strict';
  33840. var isSpace = require('../common/utils').isSpace;
  33841. function getLine(state, line) {
  33842. var pos = state.bMarks[line] + state.blkIndent,
  33843. max = state.eMarks[line];
  33844. return state.src.substr(pos, max - pos);
  33845. }
  33846. function escapedSplit(str) {
  33847. var result = [],
  33848. pos = 0,
  33849. max = str.length,
  33850. ch,
  33851. escapes = 0,
  33852. lastPos = 0,
  33853. backTicked = false,
  33854. lastBackTick = 0;
  33855. ch = str.charCodeAt(pos);
  33856. while (pos < max) {
  33857. if (ch === 0x60/* ` */) {
  33858. if (backTicked) {
  33859. // make \` close code sequence, but not open it;
  33860. // the reason is: `\` is correct code block
  33861. backTicked = false;
  33862. lastBackTick = pos;
  33863. } else if (escapes % 2 === 0) {
  33864. backTicked = true;
  33865. lastBackTick = pos;
  33866. }
  33867. } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) {
  33868. result.push(str.substring(lastPos, pos));
  33869. lastPos = pos + 1;
  33870. }
  33871. if (ch === 0x5c/* \ */) {
  33872. escapes++;
  33873. } else {
  33874. escapes = 0;
  33875. }
  33876. pos++;
  33877. // If there was an un-closed backtick, go back to just after
  33878. // the last backtick, but as if it was a normal character
  33879. if (pos === max && backTicked) {
  33880. backTicked = false;
  33881. pos = lastBackTick + 1;
  33882. }
  33883. ch = str.charCodeAt(pos);
  33884. }
  33885. result.push(str.substring(lastPos));
  33886. return result;
  33887. }
  33888. module.exports = function table(state, startLine, endLine, silent) {
  33889. var ch, lineText, pos, i, nextLine, columns, columnCount, token,
  33890. aligns, t, tableLines, tbodyLines;
  33891. // should have at least two lines
  33892. if (startLine + 2 > endLine) { return false; }
  33893. nextLine = startLine + 1;
  33894. if (state.sCount[nextLine] < state.blkIndent) { return false; }
  33895. // if it's indented more than 3 spaces, it should be a code block
  33896. if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
  33897. // first character of the second line should be '|', '-', ':',
  33898. // and no other characters are allowed but spaces;
  33899. // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
  33900. pos = state.bMarks[nextLine] + state.tShift[nextLine];
  33901. if (pos >= state.eMarks[nextLine]) { return false; }
  33902. ch = state.src.charCodeAt(pos++);
  33903. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
  33904. while (pos < state.eMarks[nextLine]) {
  33905. ch = state.src.charCodeAt(pos);
  33906. if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }
  33907. pos++;
  33908. }
  33909. lineText = getLine(state, startLine + 1);
  33910. columns = lineText.split('|');
  33911. aligns = [];
  33912. for (i = 0; i < columns.length; i++) {
  33913. t = columns[i].trim();
  33914. if (!t) {
  33915. // allow empty columns before and after table, but not in between columns;
  33916. // e.g. allow ` |---| `, disallow ` ---||--- `
  33917. if (i === 0 || i === columns.length - 1) {
  33918. continue;
  33919. } else {
  33920. return false;
  33921. }
  33922. }
  33923. if (!/^:?-+:?$/.test(t)) { return false; }
  33924. if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
  33925. aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
  33926. } else if (t.charCodeAt(0) === 0x3A/* : */) {
  33927. aligns.push('left');
  33928. } else {
  33929. aligns.push('');
  33930. }
  33931. }
  33932. lineText = getLine(state, startLine).trim();
  33933. if (lineText.indexOf('|') === -1) { return false; }
  33934. if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
  33935. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  33936. // header row will define an amount of columns in the entire table,
  33937. // and align row shouldn't be smaller than that (the rest of the rows can)
  33938. columnCount = columns.length;
  33939. if (columnCount > aligns.length) { return false; }
  33940. if (silent) { return true; }
  33941. token = state.push('table_open', 'table', 1);
  33942. token.map = tableLines = [ startLine, 0 ];
  33943. token = state.push('thead_open', 'thead', 1);
  33944. token.map = [ startLine, startLine + 1 ];
  33945. token = state.push('tr_open', 'tr', 1);
  33946. token.map = [ startLine, startLine + 1 ];
  33947. for (i = 0; i < columns.length; i++) {
  33948. token = state.push('th_open', 'th', 1);
  33949. token.map = [ startLine, startLine + 1 ];
  33950. if (aligns[i]) {
  33951. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  33952. }
  33953. token = state.push('inline', '', 0);
  33954. token.content = columns[i].trim();
  33955. token.map = [ startLine, startLine + 1 ];
  33956. token.children = [];
  33957. token = state.push('th_close', 'th', -1);
  33958. }
  33959. token = state.push('tr_close', 'tr', -1);
  33960. token = state.push('thead_close', 'thead', -1);
  33961. token = state.push('tbody_open', 'tbody', 1);
  33962. token.map = tbodyLines = [ startLine + 2, 0 ];
  33963. for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
  33964. if (state.sCount[nextLine] < state.blkIndent) { break; }
  33965. lineText = getLine(state, nextLine).trim();
  33966. if (lineText.indexOf('|') === -1) { break; }
  33967. if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
  33968. columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
  33969. token = state.push('tr_open', 'tr', 1);
  33970. for (i = 0; i < columnCount; i++) {
  33971. token = state.push('td_open', 'td', 1);
  33972. if (aligns[i]) {
  33973. token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
  33974. }
  33975. token = state.push('inline', '', 0);
  33976. token.content = columns[i] ? columns[i].trim() : '';
  33977. token.children = [];
  33978. token = state.push('td_close', 'td', -1);
  33979. }
  33980. token = state.push('tr_close', 'tr', -1);
  33981. }
  33982. token = state.push('tbody_close', 'tbody', -1);
  33983. token = state.push('table_close', 'table', -1);
  33984. tableLines[1] = tbodyLines[1] = nextLine;
  33985. state.line = nextLine;
  33986. return true;
  33987. };
  33988. },{"../common/utils":144}],170:[function(require,module,exports){
  33989. 'use strict';
  33990. module.exports = function block(state) {
  33991. var token;
  33992. if (state.inlineMode) {
  33993. token = new state.Token('inline', '', 0);
  33994. token.content = state.src;
  33995. token.map = [ 0, 1 ];
  33996. token.children = [];
  33997. state.tokens.push(token);
  33998. } else {
  33999. state.md.block.parse(state.src, state.md, state.env, state.tokens);
  34000. }
  34001. };
  34002. },{}],171:[function(require,module,exports){
  34003. 'use strict';
  34004. module.exports = function inline(state) {
  34005. var tokens = state.tokens, tok, i, l;
  34006. // Parse inlines
  34007. for (i = 0, l = tokens.length; i < l; i++) {
  34008. tok = tokens[i];
  34009. if (tok.type === 'inline') {
  34010. state.md.inline.parse(tok.content, state.md, state.env, tok.children);
  34011. }
  34012. }
  34013. };
  34014. },{}],172:[function(require,module,exports){
  34015. // Replace link-like texts with link nodes.
  34016. //
  34017. // Currently restricted by `md.validateLink()` to http/https/ftp
  34018. //
  34019. 'use strict';
  34020. var arrayReplaceAt = require('../common/utils').arrayReplaceAt;
  34021. function isLinkOpen(str) {
  34022. return /^<a[>\s]/i.test(str);
  34023. }
  34024. function isLinkClose(str) {
  34025. return /^<\/a\s*>/i.test(str);
  34026. }
  34027. module.exports = function linkify(state) {
  34028. var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,
  34029. level, htmlLinkLevel, url, fullUrl, urlText,
  34030. blockTokens = state.tokens,
  34031. links;
  34032. if (!state.md.options.linkify) { return; }
  34033. for (j = 0, l = blockTokens.length; j < l; j++) {
  34034. if (blockTokens[j].type !== 'inline' ||
  34035. !state.md.linkify.pretest(blockTokens[j].content)) {
  34036. continue;
  34037. }
  34038. tokens = blockTokens[j].children;
  34039. htmlLinkLevel = 0;
  34040. // We scan from the end, to keep position when new tags added.
  34041. // Use reversed logic in links start/end match
  34042. for (i = tokens.length - 1; i >= 0; i--) {
  34043. currentToken = tokens[i];
  34044. // Skip content of markdown links
  34045. if (currentToken.type === 'link_close') {
  34046. i--;
  34047. while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
  34048. i--;
  34049. }
  34050. continue;
  34051. }
  34052. // Skip content of html tag links
  34053. if (currentToken.type === 'html_inline') {
  34054. if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
  34055. htmlLinkLevel--;
  34056. }
  34057. if (isLinkClose(currentToken.content)) {
  34058. htmlLinkLevel++;
  34059. }
  34060. }
  34061. if (htmlLinkLevel > 0) { continue; }
  34062. if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {
  34063. text = currentToken.content;
  34064. links = state.md.linkify.match(text);
  34065. // Now split string to nodes
  34066. nodes = [];
  34067. level = currentToken.level;
  34068. lastPos = 0;
  34069. for (ln = 0; ln < links.length; ln++) {
  34070. url = links[ln].url;
  34071. fullUrl = state.md.normalizeLink(url);
  34072. if (!state.md.validateLink(fullUrl)) { continue; }
  34073. urlText = links[ln].text;
  34074. // Linkifier might send raw hostnames like "example.com", where url
  34075. // starts with domain name. So we prepend http:// in those cases,
  34076. // and remove it afterwards.
  34077. //
  34078. if (!links[ln].schema) {
  34079. urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
  34080. } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
  34081. urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
  34082. } else {
  34083. urlText = state.md.normalizeLinkText(urlText);
  34084. }
  34085. pos = links[ln].index;
  34086. if (pos > lastPos) {
  34087. token = new state.Token('text', '', 0);
  34088. token.content = text.slice(lastPos, pos);
  34089. token.level = level;
  34090. nodes.push(token);
  34091. }
  34092. token = new state.Token('link_open', 'a', 1);
  34093. token.attrs = [ [ 'href', fullUrl ] ];
  34094. token.level = level++;
  34095. token.markup = 'linkify';
  34096. token.info = 'auto';
  34097. nodes.push(token);
  34098. token = new state.Token('text', '', 0);
  34099. token.content = urlText;
  34100. token.level = level;
  34101. nodes.push(token);
  34102. token = new state.Token('link_close', 'a', -1);
  34103. token.level = --level;
  34104. token.markup = 'linkify';
  34105. token.info = 'auto';
  34106. nodes.push(token);
  34107. lastPos = links[ln].lastIndex;
  34108. }
  34109. if (lastPos < text.length) {
  34110. token = new state.Token('text', '', 0);
  34111. token.content = text.slice(lastPos);
  34112. token.level = level;
  34113. nodes.push(token);
  34114. }
  34115. // replace current node
  34116. blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
  34117. }
  34118. }
  34119. }
  34120. };
  34121. },{"../common/utils":144}],173:[function(require,module,exports){
  34122. // Normalize input string
  34123. 'use strict';
  34124. var NEWLINES_RE = /\r[\n\u0085]?|[\u2424\u2028\u0085]/g;
  34125. var NULL_RE = /\u0000/g;
  34126. module.exports = function inline(state) {
  34127. var str;
  34128. // Normalize newlines
  34129. str = state.src.replace(NEWLINES_RE, '\n');
  34130. // Replace NULL characters
  34131. str = str.replace(NULL_RE, '\uFFFD');
  34132. state.src = str;
  34133. };
  34134. },{}],174:[function(require,module,exports){
  34135. // Simple typographyc replacements
  34136. //
  34137. // (c) (C) → ©
  34138. // (tm) (TM) → ™
  34139. // (r) (R) → ®
  34140. // +- → ±
  34141. // (p) (P) -> §
  34142. // ... → … (also ?.... → ?.., !.... → !..)
  34143. // ???????? → ???, !!!!! → !!!, `,,` → `,`
  34144. // -- → &ndash;, --- → &mdash;
  34145. //
  34146. 'use strict';
  34147. // TODO:
  34148. // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
  34149. // - miltiplication 2 x 4 -> 2 × 4
  34150. var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
  34151. // Workaround for phantomjs - need regex without /g flag,
  34152. // or root check will fail every second time
  34153. var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;
  34154. var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
  34155. var SCOPED_ABBR = {
  34156. c: '©',
  34157. r: '®',
  34158. p: '§',
  34159. tm: '™'
  34160. };
  34161. function replaceFn(match, name) {
  34162. return SCOPED_ABBR[name.toLowerCase()];
  34163. }
  34164. function replace_scoped(inlineTokens) {
  34165. var i, token, inside_autolink = 0;
  34166. for (i = inlineTokens.length - 1; i >= 0; i--) {
  34167. token = inlineTokens[i];
  34168. if (token.type === 'text' && !inside_autolink) {
  34169. token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
  34170. }
  34171. if (token.type === 'link_open' && token.info === 'auto') {
  34172. inside_autolink--;
  34173. }
  34174. if (token.type === 'link_close' && token.info === 'auto') {
  34175. inside_autolink++;
  34176. }
  34177. }
  34178. }
  34179. function replace_rare(inlineTokens) {
  34180. var i, token, inside_autolink = 0;
  34181. for (i = inlineTokens.length - 1; i >= 0; i--) {
  34182. token = inlineTokens[i];
  34183. if (token.type === 'text' && !inside_autolink) {
  34184. if (RARE_RE.test(token.content)) {
  34185. token.content = token.content
  34186. .replace(/\+-/g, '±')
  34187. // .., ..., ....... -> …
  34188. // but ?..... & !..... -> ?.. & !..
  34189. .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
  34190. .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
  34191. // em-dash
  34192. .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
  34193. // en-dash
  34194. .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
  34195. .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
  34196. }
  34197. }
  34198. if (token.type === 'link_open' && token.info === 'auto') {
  34199. inside_autolink--;
  34200. }
  34201. if (token.type === 'link_close' && token.info === 'auto') {
  34202. inside_autolink++;
  34203. }
  34204. }
  34205. }
  34206. module.exports = function replace(state) {
  34207. var blkIdx;
  34208. if (!state.md.options.typographer) { return; }
  34209. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  34210. if (state.tokens[blkIdx].type !== 'inline') { continue; }
  34211. if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
  34212. replace_scoped(state.tokens[blkIdx].children);
  34213. }
  34214. if (RARE_RE.test(state.tokens[blkIdx].content)) {
  34215. replace_rare(state.tokens[blkIdx].children);
  34216. }
  34217. }
  34218. };
  34219. },{}],175:[function(require,module,exports){
  34220. // Convert straight quotation marks to typographic ones
  34221. //
  34222. 'use strict';
  34223. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  34224. var isPunctChar = require('../common/utils').isPunctChar;
  34225. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  34226. var QUOTE_TEST_RE = /['"]/;
  34227. var QUOTE_RE = /['"]/g;
  34228. var APOSTROPHE = '\u2019'; /* ’ */
  34229. function replaceAt(str, index, ch) {
  34230. return str.substr(0, index) + ch + str.substr(index + 1);
  34231. }
  34232. function process_inlines(tokens, state) {
  34233. var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
  34234. isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
  34235. canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
  34236. stack = [];
  34237. for (i = 0; i < tokens.length; i++) {
  34238. token = tokens[i];
  34239. thisLevel = tokens[i].level;
  34240. for (j = stack.length - 1; j >= 0; j--) {
  34241. if (stack[j].level <= thisLevel) { break; }
  34242. }
  34243. stack.length = j + 1;
  34244. if (token.type !== 'text') { continue; }
  34245. text = token.content;
  34246. pos = 0;
  34247. max = text.length;
  34248. /*eslint no-labels:0,block-scoped-var:0*/
  34249. OUTER:
  34250. while (pos < max) {
  34251. QUOTE_RE.lastIndex = pos;
  34252. t = QUOTE_RE.exec(text);
  34253. if (!t) { break; }
  34254. canOpen = canClose = true;
  34255. pos = t.index + 1;
  34256. isSingle = (t[0] === "'");
  34257. // Find previous character,
  34258. // default to space if it's the beginning of the line
  34259. //
  34260. lastChar = 0x20;
  34261. if (t.index - 1 >= 0) {
  34262. lastChar = text.charCodeAt(t.index - 1);
  34263. } else {
  34264. for (j = i - 1; j >= 0; j--) {
  34265. if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
  34266. if (tokens[j].type !== 'text') continue;
  34267. lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
  34268. break;
  34269. }
  34270. }
  34271. // Find next character,
  34272. // default to space if it's the end of the line
  34273. //
  34274. nextChar = 0x20;
  34275. if (pos < max) {
  34276. nextChar = text.charCodeAt(pos);
  34277. } else {
  34278. for (j = i + 1; j < tokens.length; j++) {
  34279. if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
  34280. if (tokens[j].type !== 'text') continue;
  34281. nextChar = tokens[j].content.charCodeAt(0);
  34282. break;
  34283. }
  34284. }
  34285. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  34286. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  34287. isLastWhiteSpace = isWhiteSpace(lastChar);
  34288. isNextWhiteSpace = isWhiteSpace(nextChar);
  34289. if (isNextWhiteSpace) {
  34290. canOpen = false;
  34291. } else if (isNextPunctChar) {
  34292. if (!(isLastWhiteSpace || isLastPunctChar)) {
  34293. canOpen = false;
  34294. }
  34295. }
  34296. if (isLastWhiteSpace) {
  34297. canClose = false;
  34298. } else if (isLastPunctChar) {
  34299. if (!(isNextWhiteSpace || isNextPunctChar)) {
  34300. canClose = false;
  34301. }
  34302. }
  34303. if (nextChar === 0x22 /* " */ && t[0] === '"') {
  34304. if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
  34305. // special case: 1"" - count first quote as an inch
  34306. canClose = canOpen = false;
  34307. }
  34308. }
  34309. if (canOpen && canClose) {
  34310. // treat this as the middle of the word
  34311. canOpen = false;
  34312. canClose = isNextPunctChar;
  34313. }
  34314. if (!canOpen && !canClose) {
  34315. // middle of word
  34316. if (isSingle) {
  34317. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  34318. }
  34319. continue;
  34320. }
  34321. if (canClose) {
  34322. // this could be a closing quote, rewind the stack to get a match
  34323. for (j = stack.length - 1; j >= 0; j--) {
  34324. item = stack[j];
  34325. if (stack[j].level < thisLevel) { break; }
  34326. if (item.single === isSingle && stack[j].level === thisLevel) {
  34327. item = stack[j];
  34328. if (isSingle) {
  34329. openQuote = state.md.options.quotes[2];
  34330. closeQuote = state.md.options.quotes[3];
  34331. } else {
  34332. openQuote = state.md.options.quotes[0];
  34333. closeQuote = state.md.options.quotes[1];
  34334. }
  34335. // replace token.content *before* tokens[item.token].content,
  34336. // because, if they are pointing at the same token, replaceAt
  34337. // could mess up indices when quote length != 1
  34338. token.content = replaceAt(token.content, t.index, closeQuote);
  34339. tokens[item.token].content = replaceAt(
  34340. tokens[item.token].content, item.pos, openQuote);
  34341. pos += closeQuote.length - 1;
  34342. if (item.token === i) { pos += openQuote.length - 1; }
  34343. text = token.content;
  34344. max = text.length;
  34345. stack.length = j;
  34346. continue OUTER;
  34347. }
  34348. }
  34349. }
  34350. if (canOpen) {
  34351. stack.push({
  34352. token: i,
  34353. pos: t.index,
  34354. single: isSingle,
  34355. level: thisLevel
  34356. });
  34357. } else if (canClose && isSingle) {
  34358. token.content = replaceAt(token.content, t.index, APOSTROPHE);
  34359. }
  34360. }
  34361. }
  34362. }
  34363. module.exports = function smartquotes(state) {
  34364. /*eslint max-depth:0*/
  34365. var blkIdx;
  34366. if (!state.md.options.typographer) { return; }
  34367. for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
  34368. if (state.tokens[blkIdx].type !== 'inline' ||
  34369. !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
  34370. continue;
  34371. }
  34372. process_inlines(state.tokens[blkIdx].children, state);
  34373. }
  34374. };
  34375. },{"../common/utils":144}],176:[function(require,module,exports){
  34376. // Core state object
  34377. //
  34378. 'use strict';
  34379. var Token = require('../token');
  34380. function StateCore(src, md, env) {
  34381. this.src = src;
  34382. this.env = env;
  34383. this.tokens = [];
  34384. this.inlineMode = false;
  34385. this.md = md; // link to parser instance
  34386. }
  34387. // re-export Token class to use in core rules
  34388. StateCore.prototype.Token = Token;
  34389. module.exports = StateCore;
  34390. },{"../token":191}],177:[function(require,module,exports){
  34391. // Process autolinks '<protocol:...>'
  34392. 'use strict';
  34393. /*eslint max-len:0*/
  34394. var EMAIL_RE = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/;
  34395. var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;
  34396. module.exports = function autolink(state, silent) {
  34397. var tail, linkMatch, emailMatch, url, fullUrl, token,
  34398. pos = state.pos;
  34399. if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
  34400. tail = state.src.slice(pos);
  34401. if (tail.indexOf('>') < 0) { return false; }
  34402. if (AUTOLINK_RE.test(tail)) {
  34403. linkMatch = tail.match(AUTOLINK_RE);
  34404. url = linkMatch[0].slice(1, -1);
  34405. fullUrl = state.md.normalizeLink(url);
  34406. if (!state.md.validateLink(fullUrl)) { return false; }
  34407. if (!silent) {
  34408. token = state.push('link_open', 'a', 1);
  34409. token.attrs = [ [ 'href', fullUrl ] ];
  34410. token.markup = 'autolink';
  34411. token.info = 'auto';
  34412. token = state.push('text', '', 0);
  34413. token.content = state.md.normalizeLinkText(url);
  34414. token = state.push('link_close', 'a', -1);
  34415. token.markup = 'autolink';
  34416. token.info = 'auto';
  34417. }
  34418. state.pos += linkMatch[0].length;
  34419. return true;
  34420. }
  34421. if (EMAIL_RE.test(tail)) {
  34422. emailMatch = tail.match(EMAIL_RE);
  34423. url = emailMatch[0].slice(1, -1);
  34424. fullUrl = state.md.normalizeLink('mailto:' + url);
  34425. if (!state.md.validateLink(fullUrl)) { return false; }
  34426. if (!silent) {
  34427. token = state.push('link_open', 'a', 1);
  34428. token.attrs = [ [ 'href', fullUrl ] ];
  34429. token.markup = 'autolink';
  34430. token.info = 'auto';
  34431. token = state.push('text', '', 0);
  34432. token.content = state.md.normalizeLinkText(url);
  34433. token = state.push('link_close', 'a', -1);
  34434. token.markup = 'autolink';
  34435. token.info = 'auto';
  34436. }
  34437. state.pos += emailMatch[0].length;
  34438. return true;
  34439. }
  34440. return false;
  34441. };
  34442. },{}],178:[function(require,module,exports){
  34443. // Parse backticks
  34444. 'use strict';
  34445. module.exports = function backtick(state, silent) {
  34446. var start, max, marker, matchStart, matchEnd, token,
  34447. pos = state.pos,
  34448. ch = state.src.charCodeAt(pos);
  34449. if (ch !== 0x60/* ` */) { return false; }
  34450. start = pos;
  34451. pos++;
  34452. max = state.posMax;
  34453. while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
  34454. marker = state.src.slice(start, pos);
  34455. matchStart = matchEnd = pos;
  34456. while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
  34457. matchEnd = matchStart + 1;
  34458. while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
  34459. if (matchEnd - matchStart === marker.length) {
  34460. if (!silent) {
  34461. token = state.push('code_inline', 'code', 0);
  34462. token.markup = marker;
  34463. token.content = state.src.slice(pos, matchStart)
  34464. .replace(/[ \n]+/g, ' ')
  34465. .trim();
  34466. }
  34467. state.pos = matchEnd;
  34468. return true;
  34469. }
  34470. }
  34471. if (!silent) { state.pending += marker; }
  34472. state.pos += marker.length;
  34473. return true;
  34474. };
  34475. },{}],179:[function(require,module,exports){
  34476. // For each opening emphasis-like marker find a matching closing one
  34477. //
  34478. 'use strict';
  34479. module.exports = function link_pairs(state) {
  34480. var i, j, lastDelim, currDelim,
  34481. delimiters = state.delimiters,
  34482. max = state.delimiters.length;
  34483. for (i = 0; i < max; i++) {
  34484. lastDelim = delimiters[i];
  34485. if (!lastDelim.close) { continue; }
  34486. j = i - lastDelim.jump - 1;
  34487. while (j >= 0) {
  34488. currDelim = delimiters[j];
  34489. if (currDelim.open &&
  34490. currDelim.marker === lastDelim.marker &&
  34491. currDelim.end < 0 &&
  34492. currDelim.level === lastDelim.level) {
  34493. // typeofs are for backward compatibility with plugins
  34494. var odd_match = (currDelim.close || lastDelim.open) &&
  34495. typeof currDelim.length !== 'undefined' &&
  34496. typeof lastDelim.length !== 'undefined' &&
  34497. (currDelim.length + lastDelim.length) % 3 === 0;
  34498. if (!odd_match) {
  34499. lastDelim.jump = i - j;
  34500. lastDelim.open = false;
  34501. currDelim.end = i;
  34502. currDelim.jump = 0;
  34503. break;
  34504. }
  34505. }
  34506. j -= currDelim.jump + 1;
  34507. }
  34508. }
  34509. };
  34510. },{}],180:[function(require,module,exports){
  34511. // Process *this* and _that_
  34512. //
  34513. 'use strict';
  34514. // Insert each marker as a separate text token, and add it to delimiter list
  34515. //
  34516. module.exports.tokenize = function emphasis(state, silent) {
  34517. var i, scanned, token,
  34518. start = state.pos,
  34519. marker = state.src.charCodeAt(start);
  34520. if (silent) { return false; }
  34521. if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }
  34522. scanned = state.scanDelims(state.pos, marker === 0x2A);
  34523. for (i = 0; i < scanned.length; i++) {
  34524. token = state.push('text', '', 0);
  34525. token.content = String.fromCharCode(marker);
  34526. state.delimiters.push({
  34527. // Char code of the starting marker (number).
  34528. //
  34529. marker: marker,
  34530. // Total length of these series of delimiters.
  34531. //
  34532. length: scanned.length,
  34533. // An amount of characters before this one that's equivalent to
  34534. // current one. In plain English: if this delimiter does not open
  34535. // an emphasis, neither do previous `jump` characters.
  34536. //
  34537. // Used to skip sequences like "*****" in one step, for 1st asterisk
  34538. // value will be 0, for 2nd it's 1 and so on.
  34539. //
  34540. jump: i,
  34541. // A position of the token this delimiter corresponds to.
  34542. //
  34543. token: state.tokens.length - 1,
  34544. // Token level.
  34545. //
  34546. level: state.level,
  34547. // If this delimiter is matched as a valid opener, `end` will be
  34548. // equal to its position, otherwise it's `-1`.
  34549. //
  34550. end: -1,
  34551. // Boolean flags that determine if this delimiter could open or close
  34552. // an emphasis.
  34553. //
  34554. open: scanned.can_open,
  34555. close: scanned.can_close
  34556. });
  34557. }
  34558. state.pos += scanned.length;
  34559. return true;
  34560. };
  34561. // Walk through delimiter list and replace text tokens with tags
  34562. //
  34563. module.exports.postProcess = function emphasis(state) {
  34564. var i,
  34565. startDelim,
  34566. endDelim,
  34567. token,
  34568. ch,
  34569. isStrong,
  34570. delimiters = state.delimiters,
  34571. max = state.delimiters.length;
  34572. for (i = max - 1; i >= 0; i--) {
  34573. startDelim = delimiters[i];
  34574. if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
  34575. continue;
  34576. }
  34577. // Process only opening markers
  34578. if (startDelim.end === -1) {
  34579. continue;
  34580. }
  34581. endDelim = delimiters[startDelim.end];
  34582. // If the previous delimiter has the same marker and is adjacent to this one,
  34583. // merge those into one strong delimiter.
  34584. //
  34585. // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
  34586. //
  34587. isStrong = i > 0 &&
  34588. delimiters[i - 1].end === startDelim.end + 1 &&
  34589. delimiters[i - 1].token === startDelim.token - 1 &&
  34590. delimiters[startDelim.end + 1].token === endDelim.token + 1 &&
  34591. delimiters[i - 1].marker === startDelim.marker;
  34592. ch = String.fromCharCode(startDelim.marker);
  34593. token = state.tokens[startDelim.token];
  34594. token.type = isStrong ? 'strong_open' : 'em_open';
  34595. token.tag = isStrong ? 'strong' : 'em';
  34596. token.nesting = 1;
  34597. token.markup = isStrong ? ch + ch : ch;
  34598. token.content = '';
  34599. token = state.tokens[endDelim.token];
  34600. token.type = isStrong ? 'strong_close' : 'em_close';
  34601. token.tag = isStrong ? 'strong' : 'em';
  34602. token.nesting = -1;
  34603. token.markup = isStrong ? ch + ch : ch;
  34604. token.content = '';
  34605. if (isStrong) {
  34606. state.tokens[delimiters[i - 1].token].content = '';
  34607. state.tokens[delimiters[startDelim.end + 1].token].content = '';
  34608. i--;
  34609. }
  34610. }
  34611. };
  34612. },{}],181:[function(require,module,exports){
  34613. // Process html entity - &#123;, &#xAF;, &quot;, ...
  34614. 'use strict';
  34615. var entities = require('../common/entities');
  34616. var has = require('../common/utils').has;
  34617. var isValidEntityCode = require('../common/utils').isValidEntityCode;
  34618. var fromCodePoint = require('../common/utils').fromCodePoint;
  34619. var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i;
  34620. var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
  34621. module.exports = function entity(state, silent) {
  34622. var ch, code, match, pos = state.pos, max = state.posMax;
  34623. if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
  34624. if (pos + 1 < max) {
  34625. ch = state.src.charCodeAt(pos + 1);
  34626. if (ch === 0x23 /* # */) {
  34627. match = state.src.slice(pos).match(DIGITAL_RE);
  34628. if (match) {
  34629. if (!silent) {
  34630. code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
  34631. state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
  34632. }
  34633. state.pos += match[0].length;
  34634. return true;
  34635. }
  34636. } else {
  34637. match = state.src.slice(pos).match(NAMED_RE);
  34638. if (match) {
  34639. if (has(entities, match[1])) {
  34640. if (!silent) { state.pending += entities[match[1]]; }
  34641. state.pos += match[0].length;
  34642. return true;
  34643. }
  34644. }
  34645. }
  34646. }
  34647. if (!silent) { state.pending += '&'; }
  34648. state.pos++;
  34649. return true;
  34650. };
  34651. },{"../common/entities":141,"../common/utils":144}],182:[function(require,module,exports){
  34652. // Process escaped chars and hardbreaks
  34653. 'use strict';
  34654. var isSpace = require('../common/utils').isSpace;
  34655. var ESCAPED = [];
  34656. for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
  34657. '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
  34658. .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
  34659. module.exports = function escape(state, silent) {
  34660. var ch, pos = state.pos, max = state.posMax;
  34661. if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
  34662. pos++;
  34663. if (pos < max) {
  34664. ch = state.src.charCodeAt(pos);
  34665. if (ch < 256 && ESCAPED[ch] !== 0) {
  34666. if (!silent) { state.pending += state.src[pos]; }
  34667. state.pos += 2;
  34668. return true;
  34669. }
  34670. if (ch === 0x0A) {
  34671. if (!silent) {
  34672. state.push('hardbreak', 'br', 0);
  34673. }
  34674. pos++;
  34675. // skip leading whitespaces from next line
  34676. while (pos < max) {
  34677. ch = state.src.charCodeAt(pos);
  34678. if (!isSpace(ch)) { break; }
  34679. pos++;
  34680. }
  34681. state.pos = pos;
  34682. return true;
  34683. }
  34684. }
  34685. if (!silent) { state.pending += '\\'; }
  34686. state.pos++;
  34687. return true;
  34688. };
  34689. },{"../common/utils":144}],183:[function(require,module,exports){
  34690. // Process html tags
  34691. 'use strict';
  34692. var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE;
  34693. function isLetter(ch) {
  34694. /*eslint no-bitwise:0*/
  34695. var lc = ch | 0x20; // to lower case
  34696. return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
  34697. }
  34698. module.exports = function html_inline(state, silent) {
  34699. var ch, match, max, token,
  34700. pos = state.pos;
  34701. if (!state.md.options.html) { return false; }
  34702. // Check start
  34703. max = state.posMax;
  34704. if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
  34705. pos + 2 >= max) {
  34706. return false;
  34707. }
  34708. // Quick fail on second char
  34709. ch = state.src.charCodeAt(pos + 1);
  34710. if (ch !== 0x21/* ! */ &&
  34711. ch !== 0x3F/* ? */ &&
  34712. ch !== 0x2F/* / */ &&
  34713. !isLetter(ch)) {
  34714. return false;
  34715. }
  34716. match = state.src.slice(pos).match(HTML_TAG_RE);
  34717. if (!match) { return false; }
  34718. if (!silent) {
  34719. token = state.push('html_inline', '', 0);
  34720. token.content = state.src.slice(pos, pos + match[0].length);
  34721. }
  34722. state.pos += match[0].length;
  34723. return true;
  34724. };
  34725. },{"../common/html_re":143}],184:[function(require,module,exports){
  34726. // Process ![image](<src> "title")
  34727. 'use strict';
  34728. var normalizeReference = require('../common/utils').normalizeReference;
  34729. var isSpace = require('../common/utils').isSpace;
  34730. module.exports = function image(state, silent) {
  34731. var attrs,
  34732. code,
  34733. content,
  34734. label,
  34735. labelEnd,
  34736. labelStart,
  34737. pos,
  34738. ref,
  34739. res,
  34740. title,
  34741. token,
  34742. tokens,
  34743. start,
  34744. href = '',
  34745. oldPos = state.pos,
  34746. max = state.posMax;
  34747. if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }
  34748. if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }
  34749. labelStart = state.pos + 2;
  34750. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
  34751. // parser failed to find ']', so it's not a valid link
  34752. if (labelEnd < 0) { return false; }
  34753. pos = labelEnd + 1;
  34754. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  34755. //
  34756. // Inline link
  34757. //
  34758. // [link]( <href> "title" )
  34759. // ^^ skipping these spaces
  34760. pos++;
  34761. for (; pos < max; pos++) {
  34762. code = state.src.charCodeAt(pos);
  34763. if (!isSpace(code) && code !== 0x0A) { break; }
  34764. }
  34765. if (pos >= max) { return false; }
  34766. // [link]( <href> "title" )
  34767. // ^^^^^^ parsing link destination
  34768. start = pos;
  34769. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  34770. if (res.ok) {
  34771. href = state.md.normalizeLink(res.str);
  34772. if (state.md.validateLink(href)) {
  34773. pos = res.pos;
  34774. } else {
  34775. href = '';
  34776. }
  34777. }
  34778. // [link]( <href> "title" )
  34779. // ^^ skipping these spaces
  34780. start = pos;
  34781. for (; pos < max; pos++) {
  34782. code = state.src.charCodeAt(pos);
  34783. if (!isSpace(code) && code !== 0x0A) { break; }
  34784. }
  34785. // [link]( <href> "title" )
  34786. // ^^^^^^^ parsing link title
  34787. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  34788. if (pos < max && start !== pos && res.ok) {
  34789. title = res.str;
  34790. pos = res.pos;
  34791. // [link]( <href> "title" )
  34792. // ^^ skipping these spaces
  34793. for (; pos < max; pos++) {
  34794. code = state.src.charCodeAt(pos);
  34795. if (!isSpace(code) && code !== 0x0A) { break; }
  34796. }
  34797. } else {
  34798. title = '';
  34799. }
  34800. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  34801. state.pos = oldPos;
  34802. return false;
  34803. }
  34804. pos++;
  34805. } else {
  34806. //
  34807. // Link reference
  34808. //
  34809. if (typeof state.env.references === 'undefined') { return false; }
  34810. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  34811. start = pos + 1;
  34812. pos = state.md.helpers.parseLinkLabel(state, pos);
  34813. if (pos >= 0) {
  34814. label = state.src.slice(start, pos++);
  34815. } else {
  34816. pos = labelEnd + 1;
  34817. }
  34818. } else {
  34819. pos = labelEnd + 1;
  34820. }
  34821. // covers label === '' and label === undefined
  34822. // (collapsed reference link and shortcut reference link respectively)
  34823. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  34824. ref = state.env.references[normalizeReference(label)];
  34825. if (!ref) {
  34826. state.pos = oldPos;
  34827. return false;
  34828. }
  34829. href = ref.href;
  34830. title = ref.title;
  34831. }
  34832. //
  34833. // We found the end of the link, and know for a fact it's a valid link;
  34834. // so all that's left to do is to call tokenizer.
  34835. //
  34836. if (!silent) {
  34837. content = state.src.slice(labelStart, labelEnd);
  34838. state.md.inline.parse(
  34839. content,
  34840. state.md,
  34841. state.env,
  34842. tokens = []
  34843. );
  34844. token = state.push('image', 'img', 0);
  34845. token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
  34846. token.children = tokens;
  34847. token.content = content;
  34848. if (title) {
  34849. attrs.push([ 'title', title ]);
  34850. }
  34851. }
  34852. state.pos = pos;
  34853. state.posMax = max;
  34854. return true;
  34855. };
  34856. },{"../common/utils":144}],185:[function(require,module,exports){
  34857. // Process [link](<to> "stuff")
  34858. 'use strict';
  34859. var normalizeReference = require('../common/utils').normalizeReference;
  34860. var isSpace = require('../common/utils').isSpace;
  34861. module.exports = function link(state, silent) {
  34862. var attrs,
  34863. code,
  34864. label,
  34865. labelEnd,
  34866. labelStart,
  34867. pos,
  34868. res,
  34869. ref,
  34870. title,
  34871. token,
  34872. href = '',
  34873. oldPos = state.pos,
  34874. max = state.posMax,
  34875. start = state.pos,
  34876. parseReference = true;
  34877. if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }
  34878. labelStart = state.pos + 1;
  34879. labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
  34880. // parser failed to find ']', so it's not a valid link
  34881. if (labelEnd < 0) { return false; }
  34882. pos = labelEnd + 1;
  34883. if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
  34884. //
  34885. // Inline link
  34886. //
  34887. // might have found a valid shortcut link, disable reference parsing
  34888. parseReference = false;
  34889. // [link]( <href> "title" )
  34890. // ^^ skipping these spaces
  34891. pos++;
  34892. for (; pos < max; pos++) {
  34893. code = state.src.charCodeAt(pos);
  34894. if (!isSpace(code) && code !== 0x0A) { break; }
  34895. }
  34896. if (pos >= max) { return false; }
  34897. // [link]( <href> "title" )
  34898. // ^^^^^^ parsing link destination
  34899. start = pos;
  34900. res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
  34901. if (res.ok) {
  34902. href = state.md.normalizeLink(res.str);
  34903. if (state.md.validateLink(href)) {
  34904. pos = res.pos;
  34905. } else {
  34906. href = '';
  34907. }
  34908. }
  34909. // [link]( <href> "title" )
  34910. // ^^ skipping these spaces
  34911. start = pos;
  34912. for (; pos < max; pos++) {
  34913. code = state.src.charCodeAt(pos);
  34914. if (!isSpace(code) && code !== 0x0A) { break; }
  34915. }
  34916. // [link]( <href> "title" )
  34917. // ^^^^^^^ parsing link title
  34918. res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
  34919. if (pos < max && start !== pos && res.ok) {
  34920. title = res.str;
  34921. pos = res.pos;
  34922. // [link]( <href> "title" )
  34923. // ^^ skipping these spaces
  34924. for (; pos < max; pos++) {
  34925. code = state.src.charCodeAt(pos);
  34926. if (!isSpace(code) && code !== 0x0A) { break; }
  34927. }
  34928. } else {
  34929. title = '';
  34930. }
  34931. if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
  34932. // parsing a valid shortcut link failed, fallback to reference
  34933. parseReference = true;
  34934. }
  34935. pos++;
  34936. }
  34937. if (parseReference) {
  34938. //
  34939. // Link reference
  34940. //
  34941. if (typeof state.env.references === 'undefined') { return false; }
  34942. if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
  34943. start = pos + 1;
  34944. pos = state.md.helpers.parseLinkLabel(state, pos);
  34945. if (pos >= 0) {
  34946. label = state.src.slice(start, pos++);
  34947. } else {
  34948. pos = labelEnd + 1;
  34949. }
  34950. } else {
  34951. pos = labelEnd + 1;
  34952. }
  34953. // covers label === '' and label === undefined
  34954. // (collapsed reference link and shortcut reference link respectively)
  34955. if (!label) { label = state.src.slice(labelStart, labelEnd); }
  34956. ref = state.env.references[normalizeReference(label)];
  34957. if (!ref) {
  34958. state.pos = oldPos;
  34959. return false;
  34960. }
  34961. href = ref.href;
  34962. title = ref.title;
  34963. }
  34964. //
  34965. // We found the end of the link, and know for a fact it's a valid link;
  34966. // so all that's left to do is to call tokenizer.
  34967. //
  34968. if (!silent) {
  34969. state.pos = labelStart;
  34970. state.posMax = labelEnd;
  34971. token = state.push('link_open', 'a', 1);
  34972. token.attrs = attrs = [ [ 'href', href ] ];
  34973. if (title) {
  34974. attrs.push([ 'title', title ]);
  34975. }
  34976. state.md.inline.tokenize(state);
  34977. token = state.push('link_close', 'a', -1);
  34978. }
  34979. state.pos = pos;
  34980. state.posMax = max;
  34981. return true;
  34982. };
  34983. },{"../common/utils":144}],186:[function(require,module,exports){
  34984. // Proceess '\n'
  34985. 'use strict';
  34986. var isSpace = require('../common/utils').isSpace;
  34987. module.exports = function newline(state, silent) {
  34988. var pmax, max, pos = state.pos;
  34989. if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
  34990. pmax = state.pending.length - 1;
  34991. max = state.posMax;
  34992. // ' \n' -> hardbreak
  34993. // Lookup in pending chars is bad practice! Don't copy to other rules!
  34994. // Pending string is stored in concat mode, indexed lookups will cause
  34995. // convertion to flat mode.
  34996. if (!silent) {
  34997. if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
  34998. if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
  34999. state.pending = state.pending.replace(/ +$/, '');
  35000. state.push('hardbreak', 'br', 0);
  35001. } else {
  35002. state.pending = state.pending.slice(0, -1);
  35003. state.push('softbreak', 'br', 0);
  35004. }
  35005. } else {
  35006. state.push('softbreak', 'br', 0);
  35007. }
  35008. }
  35009. pos++;
  35010. // skip heading spaces for next line
  35011. while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }
  35012. state.pos = pos;
  35013. return true;
  35014. };
  35015. },{"../common/utils":144}],187:[function(require,module,exports){
  35016. // Inline parser state
  35017. 'use strict';
  35018. var Token = require('../token');
  35019. var isWhiteSpace = require('../common/utils').isWhiteSpace;
  35020. var isPunctChar = require('../common/utils').isPunctChar;
  35021. var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct;
  35022. function StateInline(src, md, env, outTokens) {
  35023. this.src = src;
  35024. this.env = env;
  35025. this.md = md;
  35026. this.tokens = outTokens;
  35027. this.pos = 0;
  35028. this.posMax = this.src.length;
  35029. this.level = 0;
  35030. this.pending = '';
  35031. this.pendingLevel = 0;
  35032. this.cache = {}; // Stores { start: end } pairs. Useful for backtrack
  35033. // optimization of pairs parse (emphasis, strikes).
  35034. this.delimiters = []; // Emphasis-like delimiters
  35035. }
  35036. // Flush pending text
  35037. //
  35038. StateInline.prototype.pushPending = function () {
  35039. var token = new Token('text', '', 0);
  35040. token.content = this.pending;
  35041. token.level = this.pendingLevel;
  35042. this.tokens.push(token);
  35043. this.pending = '';
  35044. return token;
  35045. };
  35046. // Push new token to "stream".
  35047. // If pending text exists - flush it as text token
  35048. //
  35049. StateInline.prototype.push = function (type, tag, nesting) {
  35050. if (this.pending) {
  35051. this.pushPending();
  35052. }
  35053. var token = new Token(type, tag, nesting);
  35054. if (nesting < 0) { this.level--; }
  35055. token.level = this.level;
  35056. if (nesting > 0) { this.level++; }
  35057. this.pendingLevel = this.level;
  35058. this.tokens.push(token);
  35059. return token;
  35060. };
  35061. // Scan a sequence of emphasis-like markers, and determine whether
  35062. // it can start an emphasis sequence or end an emphasis sequence.
  35063. //
  35064. // - start - position to scan from (it should point at a valid marker);
  35065. // - canSplitWord - determine if these markers can be found inside a word
  35066. //
  35067. StateInline.prototype.scanDelims = function (start, canSplitWord) {
  35068. var pos = start, lastChar, nextChar, count, can_open, can_close,
  35069. isLastWhiteSpace, isLastPunctChar,
  35070. isNextWhiteSpace, isNextPunctChar,
  35071. left_flanking = true,
  35072. right_flanking = true,
  35073. max = this.posMax,
  35074. marker = this.src.charCodeAt(start);
  35075. // treat beginning of the line as a whitespace
  35076. lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
  35077. while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
  35078. count = pos - start;
  35079. // treat end of the line as a whitespace
  35080. nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
  35081. isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
  35082. isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
  35083. isLastWhiteSpace = isWhiteSpace(lastChar);
  35084. isNextWhiteSpace = isWhiteSpace(nextChar);
  35085. if (isNextWhiteSpace) {
  35086. left_flanking = false;
  35087. } else if (isNextPunctChar) {
  35088. if (!(isLastWhiteSpace || isLastPunctChar)) {
  35089. left_flanking = false;
  35090. }
  35091. }
  35092. if (isLastWhiteSpace) {
  35093. right_flanking = false;
  35094. } else if (isLastPunctChar) {
  35095. if (!(isNextWhiteSpace || isNextPunctChar)) {
  35096. right_flanking = false;
  35097. }
  35098. }
  35099. if (!canSplitWord) {
  35100. can_open = left_flanking && (!right_flanking || isLastPunctChar);
  35101. can_close = right_flanking && (!left_flanking || isNextPunctChar);
  35102. } else {
  35103. can_open = left_flanking;
  35104. can_close = right_flanking;
  35105. }
  35106. return {
  35107. can_open: can_open,
  35108. can_close: can_close,
  35109. length: count
  35110. };
  35111. };
  35112. // re-export Token class to use in block rules
  35113. StateInline.prototype.Token = Token;
  35114. module.exports = StateInline;
  35115. },{"../common/utils":144,"../token":191}],188:[function(require,module,exports){
  35116. // ~~strike through~~
  35117. //
  35118. 'use strict';
  35119. // Insert each marker as a separate text token, and add it to delimiter list
  35120. //
  35121. module.exports.tokenize = function strikethrough(state, silent) {
  35122. var i, scanned, token, len, ch,
  35123. start = state.pos,
  35124. marker = state.src.charCodeAt(start);
  35125. if (silent) { return false; }
  35126. if (marker !== 0x7E/* ~ */) { return false; }
  35127. scanned = state.scanDelims(state.pos, true);
  35128. len = scanned.length;
  35129. ch = String.fromCharCode(marker);
  35130. if (len < 2) { return false; }
  35131. if (len % 2) {
  35132. token = state.push('text', '', 0);
  35133. token.content = ch;
  35134. len--;
  35135. }
  35136. for (i = 0; i < len; i += 2) {
  35137. token = state.push('text', '', 0);
  35138. token.content = ch + ch;
  35139. state.delimiters.push({
  35140. marker: marker,
  35141. jump: i,
  35142. token: state.tokens.length - 1,
  35143. level: state.level,
  35144. end: -1,
  35145. open: scanned.can_open,
  35146. close: scanned.can_close
  35147. });
  35148. }
  35149. state.pos += scanned.length;
  35150. return true;
  35151. };
  35152. // Walk through delimiter list and replace text tokens with tags
  35153. //
  35154. module.exports.postProcess = function strikethrough(state) {
  35155. var i, j,
  35156. startDelim,
  35157. endDelim,
  35158. token,
  35159. loneMarkers = [],
  35160. delimiters = state.delimiters,
  35161. max = state.delimiters.length;
  35162. for (i = 0; i < max; i++) {
  35163. startDelim = delimiters[i];
  35164. if (startDelim.marker !== 0x7E/* ~ */) {
  35165. continue;
  35166. }
  35167. if (startDelim.end === -1) {
  35168. continue;
  35169. }
  35170. endDelim = delimiters[startDelim.end];
  35171. token = state.tokens[startDelim.token];
  35172. token.type = 's_open';
  35173. token.tag = 's';
  35174. token.nesting = 1;
  35175. token.markup = '~~';
  35176. token.content = '';
  35177. token = state.tokens[endDelim.token];
  35178. token.type = 's_close';
  35179. token.tag = 's';
  35180. token.nesting = -1;
  35181. token.markup = '~~';
  35182. token.content = '';
  35183. if (state.tokens[endDelim.token - 1].type === 'text' &&
  35184. state.tokens[endDelim.token - 1].content === '~') {
  35185. loneMarkers.push(endDelim.token - 1);
  35186. }
  35187. }
  35188. // If a marker sequence has an odd number of characters, it's splitted
  35189. // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
  35190. // start of the sequence.
  35191. //
  35192. // So, we have to move all those markers after subsequent s_close tags.
  35193. //
  35194. while (loneMarkers.length) {
  35195. i = loneMarkers.pop();
  35196. j = i + 1;
  35197. while (j < state.tokens.length && state.tokens[j].type === 's_close') {
  35198. j++;
  35199. }
  35200. j--;
  35201. if (i !== j) {
  35202. token = state.tokens[j];
  35203. state.tokens[j] = state.tokens[i];
  35204. state.tokens[i] = token;
  35205. }
  35206. }
  35207. };
  35208. },{}],189:[function(require,module,exports){
  35209. // Skip text characters for text token, place those to pending buffer
  35210. // and increment current pos
  35211. 'use strict';
  35212. // Rule to skip pure text
  35213. // '{}$%@~+=:' reserved for extentions
  35214. // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
  35215. // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
  35216. // http://spec.commonmark.org/0.15/#ascii-punctuation-character
  35217. function isTerminatorChar(ch) {
  35218. switch (ch) {
  35219. case 0x0A/* \n */:
  35220. case 0x21/* ! */:
  35221. case 0x23/* # */:
  35222. case 0x24/* $ */:
  35223. case 0x25/* % */:
  35224. case 0x26/* & */:
  35225. case 0x2A/* * */:
  35226. case 0x2B/* + */:
  35227. case 0x2D/* - */:
  35228. case 0x3A/* : */:
  35229. case 0x3C/* < */:
  35230. case 0x3D/* = */:
  35231. case 0x3E/* > */:
  35232. case 0x40/* @ */:
  35233. case 0x5B/* [ */:
  35234. case 0x5C/* \ */:
  35235. case 0x5D/* ] */:
  35236. case 0x5E/* ^ */:
  35237. case 0x5F/* _ */:
  35238. case 0x60/* ` */:
  35239. case 0x7B/* { */:
  35240. case 0x7D/* } */:
  35241. case 0x7E/* ~ */:
  35242. return true;
  35243. default:
  35244. return false;
  35245. }
  35246. }
  35247. module.exports = function text(state, silent) {
  35248. var pos = state.pos;
  35249. while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
  35250. pos++;
  35251. }
  35252. if (pos === state.pos) { return false; }
  35253. if (!silent) { state.pending += state.src.slice(state.pos, pos); }
  35254. state.pos = pos;
  35255. return true;
  35256. };
  35257. // Alternative implementation, for memory.
  35258. //
  35259. // It costs 10% of performance, but allows extend terminators list, if place it
  35260. // to `ParcerInline` property. Probably, will switch to it sometime, such
  35261. // flexibility required.
  35262. /*
  35263. var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/;
  35264. module.exports = function text(state, silent) {
  35265. var pos = state.pos,
  35266. idx = state.src.slice(pos).search(TERMINATOR_RE);
  35267. // first char is terminator -> empty text
  35268. if (idx === 0) { return false; }
  35269. // no terminator -> text till end of string
  35270. if (idx < 0) {
  35271. if (!silent) { state.pending += state.src.slice(pos); }
  35272. state.pos = state.src.length;
  35273. return true;
  35274. }
  35275. if (!silent) { state.pending += state.src.slice(pos, pos + idx); }
  35276. state.pos += idx;
  35277. return true;
  35278. };*/
  35279. },{}],190:[function(require,module,exports){
  35280. // Merge adjacent text nodes into one, and re-calculate all token levels
  35281. //
  35282. 'use strict';
  35283. module.exports = function text_collapse(state) {
  35284. var curr, last,
  35285. level = 0,
  35286. tokens = state.tokens,
  35287. max = state.tokens.length;
  35288. for (curr = last = 0; curr < max; curr++) {
  35289. // re-calculate levels
  35290. level += tokens[curr].nesting;
  35291. tokens[curr].level = level;
  35292. if (tokens[curr].type === 'text' &&
  35293. curr + 1 < max &&
  35294. tokens[curr + 1].type === 'text') {
  35295. // collapse two adjacent text nodes
  35296. tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
  35297. } else {
  35298. if (curr !== last) { tokens[last] = tokens[curr]; }
  35299. last++;
  35300. }
  35301. }
  35302. if (curr !== last) {
  35303. tokens.length = last;
  35304. }
  35305. };
  35306. },{}],191:[function(require,module,exports){
  35307. // Token class
  35308. 'use strict';
  35309. /**
  35310. * class Token
  35311. **/
  35312. /**
  35313. * new Token(type, tag, nesting)
  35314. *
  35315. * Create new token and fill passed properties.
  35316. **/
  35317. function Token(type, tag, nesting) {
  35318. /**
  35319. * Token#type -> String
  35320. *
  35321. * Type of the token (string, e.g. "paragraph_open")
  35322. **/
  35323. this.type = type;
  35324. /**
  35325. * Token#tag -> String
  35326. *
  35327. * html tag name, e.g. "p"
  35328. **/
  35329. this.tag = tag;
  35330. /**
  35331. * Token#attrs -> Array
  35332. *
  35333. * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
  35334. **/
  35335. this.attrs = null;
  35336. /**
  35337. * Token#map -> Array
  35338. *
  35339. * Source map info. Format: `[ line_begin, line_end ]`
  35340. **/
  35341. this.map = null;
  35342. /**
  35343. * Token#nesting -> Number
  35344. *
  35345. * Level change (number in {-1, 0, 1} set), where:
  35346. *
  35347. * - `1` means the tag is opening
  35348. * - `0` means the tag is self-closing
  35349. * - `-1` means the tag is closing
  35350. **/
  35351. this.nesting = nesting;
  35352. /**
  35353. * Token#level -> Number
  35354. *
  35355. * nesting level, the same as `state.level`
  35356. **/
  35357. this.level = 0;
  35358. /**
  35359. * Token#children -> Array
  35360. *
  35361. * An array of child nodes (inline and img tokens)
  35362. **/
  35363. this.children = null;
  35364. /**
  35365. * Token#content -> String
  35366. *
  35367. * In a case of self-closing tag (code, html, fence, etc.),
  35368. * it has contents of this tag.
  35369. **/
  35370. this.content = '';
  35371. /**
  35372. * Token#markup -> String
  35373. *
  35374. * '*' or '_' for emphasis, fence string for fence, etc.
  35375. **/
  35376. this.markup = '';
  35377. /**
  35378. * Token#info -> String
  35379. *
  35380. * fence infostring
  35381. **/
  35382. this.info = '';
  35383. /**
  35384. * Token#meta -> Object
  35385. *
  35386. * A place for plugins to store an arbitrary data
  35387. **/
  35388. this.meta = null;
  35389. /**
  35390. * Token#block -> Boolean
  35391. *
  35392. * True for block-level tokens, false for inline tokens.
  35393. * Used in renderer to calculate line breaks
  35394. **/
  35395. this.block = false;
  35396. /**
  35397. * Token#hidden -> Boolean
  35398. *
  35399. * If it's true, ignore this element when rendering. Used for tight lists
  35400. * to hide paragraphs.
  35401. **/
  35402. this.hidden = false;
  35403. }
  35404. /**
  35405. * Token.attrIndex(name) -> Number
  35406. *
  35407. * Search attribute index by name.
  35408. **/
  35409. Token.prototype.attrIndex = function attrIndex(name) {
  35410. var attrs, i, len;
  35411. if (!this.attrs) { return -1; }
  35412. attrs = this.attrs;
  35413. for (i = 0, len = attrs.length; i < len; i++) {
  35414. if (attrs[i][0] === name) { return i; }
  35415. }
  35416. return -1;
  35417. };
  35418. /**
  35419. * Token.attrPush(attrData)
  35420. *
  35421. * Add `[ name, value ]` attribute to list. Init attrs if necessary
  35422. **/
  35423. Token.prototype.attrPush = function attrPush(attrData) {
  35424. if (this.attrs) {
  35425. this.attrs.push(attrData);
  35426. } else {
  35427. this.attrs = [ attrData ];
  35428. }
  35429. };
  35430. /**
  35431. * Token.attrSet(name, value)
  35432. *
  35433. * Set `name` attribute to `value`. Override old value if exists.
  35434. **/
  35435. Token.prototype.attrSet = function attrSet(name, value) {
  35436. var idx = this.attrIndex(name),
  35437. attrData = [ name, value ];
  35438. if (idx < 0) {
  35439. this.attrPush(attrData);
  35440. } else {
  35441. this.attrs[idx] = attrData;
  35442. }
  35443. };
  35444. /**
  35445. * Token.attrGet(name)
  35446. *
  35447. * Get the value of attribute `name`, or null if it does not exist.
  35448. **/
  35449. Token.prototype.attrGet = function attrGet(name) {
  35450. var idx = this.attrIndex(name), value = null;
  35451. if (idx >= 0) {
  35452. value = this.attrs[idx][1];
  35453. }
  35454. return value;
  35455. };
  35456. /**
  35457. * Token.attrJoin(name, value)
  35458. *
  35459. * Join value to existing attribute via space. Or create new attribute if not
  35460. * exists. Useful to operate with token classes.
  35461. **/
  35462. Token.prototype.attrJoin = function attrJoin(name, value) {
  35463. var idx = this.attrIndex(name);
  35464. if (idx < 0) {
  35465. this.attrPush([ name, value ]);
  35466. } else {
  35467. this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;
  35468. }
  35469. };
  35470. module.exports = Token;
  35471. },{}],192:[function(require,module,exports){
  35472. 'use strict';
  35473. /* eslint-disable no-bitwise */
  35474. var decodeCache = {};
  35475. function getDecodeCache(exclude) {
  35476. var i, ch, cache = decodeCache[exclude];
  35477. if (cache) { return cache; }
  35478. cache = decodeCache[exclude] = [];
  35479. for (i = 0; i < 128; i++) {
  35480. ch = String.fromCharCode(i);
  35481. cache.push(ch);
  35482. }
  35483. for (i = 0; i < exclude.length; i++) {
  35484. ch = exclude.charCodeAt(i);
  35485. cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);
  35486. }
  35487. return cache;
  35488. }
  35489. // Decode percent-encoded string.
  35490. //
  35491. function decode(string, exclude) {
  35492. var cache;
  35493. if (typeof exclude !== 'string') {
  35494. exclude = decode.defaultChars;
  35495. }
  35496. cache = getDecodeCache(exclude);
  35497. return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {
  35498. var i, l, b1, b2, b3, b4, chr,
  35499. result = '';
  35500. for (i = 0, l = seq.length; i < l; i += 3) {
  35501. b1 = parseInt(seq.slice(i + 1, i + 3), 16);
  35502. if (b1 < 0x80) {
  35503. result += cache[b1];
  35504. continue;
  35505. }
  35506. if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {
  35507. // 110xxxxx 10xxxxxx
  35508. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  35509. if ((b2 & 0xC0) === 0x80) {
  35510. chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);
  35511. if (chr < 0x80) {
  35512. result += '\ufffd\ufffd';
  35513. } else {
  35514. result += String.fromCharCode(chr);
  35515. }
  35516. i += 3;
  35517. continue;
  35518. }
  35519. }
  35520. if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {
  35521. // 1110xxxx 10xxxxxx 10xxxxxx
  35522. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  35523. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  35524. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
  35525. chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);
  35526. if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {
  35527. result += '\ufffd\ufffd\ufffd';
  35528. } else {
  35529. result += String.fromCharCode(chr);
  35530. }
  35531. i += 6;
  35532. continue;
  35533. }
  35534. }
  35535. if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {
  35536. // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
  35537. b2 = parseInt(seq.slice(i + 4, i + 6), 16);
  35538. b3 = parseInt(seq.slice(i + 7, i + 9), 16);
  35539. b4 = parseInt(seq.slice(i + 10, i + 12), 16);
  35540. if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {
  35541. chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);
  35542. if (chr < 0x10000 || chr > 0x10FFFF) {
  35543. result += '\ufffd\ufffd\ufffd\ufffd';
  35544. } else {
  35545. chr -= 0x10000;
  35546. result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));
  35547. }
  35548. i += 9;
  35549. continue;
  35550. }
  35551. }
  35552. result += '\ufffd';
  35553. }
  35554. return result;
  35555. });
  35556. }
  35557. decode.defaultChars = ';/?:@&=+$,#';
  35558. decode.componentChars = '';
  35559. module.exports = decode;
  35560. },{}],193:[function(require,module,exports){
  35561. 'use strict';
  35562. var encodeCache = {};
  35563. // Create a lookup array where anything but characters in `chars` string
  35564. // and alphanumeric chars is percent-encoded.
  35565. //
  35566. function getEncodeCache(exclude) {
  35567. var i, ch, cache = encodeCache[exclude];
  35568. if (cache) { return cache; }
  35569. cache = encodeCache[exclude] = [];
  35570. for (i = 0; i < 128; i++) {
  35571. ch = String.fromCharCode(i);
  35572. if (/^[0-9a-z]$/i.test(ch)) {
  35573. // always allow unencoded alphanumeric characters
  35574. cache.push(ch);
  35575. } else {
  35576. cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));
  35577. }
  35578. }
  35579. for (i = 0; i < exclude.length; i++) {
  35580. cache[exclude.charCodeAt(i)] = exclude[i];
  35581. }
  35582. return cache;
  35583. }
  35584. // Encode unsafe characters with percent-encoding, skipping already
  35585. // encoded sequences.
  35586. //
  35587. // - string - string to encode
  35588. // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
  35589. // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
  35590. //
  35591. function encode(string, exclude, keepEscaped) {
  35592. var i, l, code, nextCode, cache,
  35593. result = '';
  35594. if (typeof exclude !== 'string') {
  35595. // encode(string, keepEscaped)
  35596. keepEscaped = exclude;
  35597. exclude = encode.defaultChars;
  35598. }
  35599. if (typeof keepEscaped === 'undefined') {
  35600. keepEscaped = true;
  35601. }
  35602. cache = getEncodeCache(exclude);
  35603. for (i = 0, l = string.length; i < l; i++) {
  35604. code = string.charCodeAt(i);
  35605. if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {
  35606. if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
  35607. result += string.slice(i, i + 3);
  35608. i += 2;
  35609. continue;
  35610. }
  35611. }
  35612. if (code < 128) {
  35613. result += cache[code];
  35614. continue;
  35615. }
  35616. if (code >= 0xD800 && code <= 0xDFFF) {
  35617. if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {
  35618. nextCode = string.charCodeAt(i + 1);
  35619. if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
  35620. result += encodeURIComponent(string[i] + string[i + 1]);
  35621. i++;
  35622. continue;
  35623. }
  35624. }
  35625. result += '%EF%BF%BD';
  35626. continue;
  35627. }
  35628. result += encodeURIComponent(string[i]);
  35629. }
  35630. return result;
  35631. }
  35632. encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
  35633. encode.componentChars = "-_.!~*'()";
  35634. module.exports = encode;
  35635. },{}],194:[function(require,module,exports){
  35636. 'use strict';
  35637. module.exports = function format(url) {
  35638. var result = '';
  35639. result += url.protocol || '';
  35640. result += url.slashes ? '//' : '';
  35641. result += url.auth ? url.auth + '@' : '';
  35642. if (url.hostname && url.hostname.indexOf(':') !== -1) {
  35643. // ipv6 address
  35644. result += '[' + url.hostname + ']';
  35645. } else {
  35646. result += url.hostname || '';
  35647. }
  35648. result += url.port ? ':' + url.port : '';
  35649. result += url.pathname || '';
  35650. result += url.search || '';
  35651. result += url.hash || '';
  35652. return result;
  35653. };
  35654. },{}],195:[function(require,module,exports){
  35655. 'use strict';
  35656. module.exports.encode = require('./encode');
  35657. module.exports.decode = require('./decode');
  35658. module.exports.format = require('./format');
  35659. module.exports.parse = require('./parse');
  35660. },{"./decode":192,"./encode":193,"./format":194,"./parse":196}],196:[function(require,module,exports){
  35661. // Copyright Joyent, Inc. and other Node contributors.
  35662. //
  35663. // Permission is hereby granted, free of charge, to any person obtaining a
  35664. // copy of this software and associated documentation files (the
  35665. // "Software"), to deal in the Software without restriction, including
  35666. // without limitation the rights to use, copy, modify, merge, publish,
  35667. // distribute, sublicense, and/or sell copies of the Software, and to permit
  35668. // persons to whom the Software is furnished to do so, subject to the
  35669. // following conditions:
  35670. //
  35671. // The above copyright notice and this permission notice shall be included
  35672. // in all copies or substantial portions of the Software.
  35673. //
  35674. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  35675. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  35676. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  35677. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  35678. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  35679. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  35680. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  35681. 'use strict';
  35682. //
  35683. // Changes from joyent/node:
  35684. //
  35685. // 1. No leading slash in paths,
  35686. // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
  35687. //
  35688. // 2. Backslashes are not replaced with slashes,
  35689. // so `http:\\example.org\` is treated like a relative path
  35690. //
  35691. // 3. Trailing colon is treated like a part of the path,
  35692. // i.e. in `http://example.org:foo` pathname is `:foo`
  35693. //
  35694. // 4. Nothing is URL-encoded in the resulting object,
  35695. // (in joyent/node some chars in auth and paths are encoded)
  35696. //
  35697. // 5. `url.parse()` does not have `parseQueryString` argument
  35698. //
  35699. // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
  35700. // which can be constructed using other parts of the url.
  35701. //
  35702. function Url() {
  35703. this.protocol = null;
  35704. this.slashes = null;
  35705. this.auth = null;
  35706. this.port = null;
  35707. this.hostname = null;
  35708. this.hash = null;
  35709. this.search = null;
  35710. this.pathname = null;
  35711. }
  35712. // Reference: RFC 3986, RFC 1808, RFC 2396
  35713. // define these here so at least they only have to be
  35714. // compiled once on the first module load.
  35715. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  35716. portPattern = /:[0-9]*$/,
  35717. // Special case for a simple path URL
  35718. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  35719. // RFC 2396: characters reserved for delimiting URLs.
  35720. // We actually just auto-escape these.
  35721. delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ],
  35722. // RFC 2396: characters not allowed for various reasons.
  35723. unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims),
  35724. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  35725. autoEscape = [ '\'' ].concat(unwise),
  35726. // Characters that are never ever allowed in a hostname.
  35727. // Note that any invalid chars are also handled, but these
  35728. // are the ones that are *expected* to be seen, so we fast-path
  35729. // them.
  35730. nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),
  35731. hostEndingChars = [ '/', '?', '#' ],
  35732. hostnameMaxLen = 255,
  35733. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  35734. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  35735. // protocols that can allow "unsafe" and "unwise" chars.
  35736. /* eslint-disable no-script-url */
  35737. // protocols that never have a hostname.
  35738. hostlessProtocol = {
  35739. 'javascript': true,
  35740. 'javascript:': true
  35741. },
  35742. // protocols that always contain a // bit.
  35743. slashedProtocol = {
  35744. 'http': true,
  35745. 'https': true,
  35746. 'ftp': true,
  35747. 'gopher': true,
  35748. 'file': true,
  35749. 'http:': true,
  35750. 'https:': true,
  35751. 'ftp:': true,
  35752. 'gopher:': true,
  35753. 'file:': true
  35754. };
  35755. /* eslint-enable no-script-url */
  35756. function urlParse(url, slashesDenoteHost) {
  35757. if (url && url instanceof Url) { return url; }
  35758. var u = new Url();
  35759. u.parse(url, slashesDenoteHost);
  35760. return u;
  35761. }
  35762. Url.prototype.parse = function(url, slashesDenoteHost) {
  35763. var i, l, lowerProto, hec, slashes,
  35764. rest = url;
  35765. // trim before proceeding.
  35766. // This is to support parse stuff like " http://foo.com \n"
  35767. rest = rest.trim();
  35768. if (!slashesDenoteHost && url.split('#').length === 1) {
  35769. // Try fast path regexp
  35770. var simplePath = simplePathPattern.exec(rest);
  35771. if (simplePath) {
  35772. this.pathname = simplePath[1];
  35773. if (simplePath[2]) {
  35774. this.search = simplePath[2];
  35775. }
  35776. return this;
  35777. }
  35778. }
  35779. var proto = protocolPattern.exec(rest);
  35780. if (proto) {
  35781. proto = proto[0];
  35782. lowerProto = proto.toLowerCase();
  35783. this.protocol = proto;
  35784. rest = rest.substr(proto.length);
  35785. }
  35786. // figure out if it's got a host
  35787. // user@server is *always* interpreted as a hostname, and url
  35788. // resolution will treat //foo/bar as host=foo,path=bar because that's
  35789. // how the browser resolves relative URLs.
  35790. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  35791. slashes = rest.substr(0, 2) === '//';
  35792. if (slashes && !(proto && hostlessProtocol[proto])) {
  35793. rest = rest.substr(2);
  35794. this.slashes = true;
  35795. }
  35796. }
  35797. if (!hostlessProtocol[proto] &&
  35798. (slashes || (proto && !slashedProtocol[proto]))) {
  35799. // there's a hostname.
  35800. // the first instance of /, ?, ;, or # ends the host.
  35801. //
  35802. // If there is an @ in the hostname, then non-host chars *are* allowed
  35803. // to the left of the last @ sign, unless some host-ending character
  35804. // comes *before* the @-sign.
  35805. // URLs are obnoxious.
  35806. //
  35807. // ex:
  35808. // http://a@b@c/ => user:a@b host:c
  35809. // http://a@b?@c => user:a host:c path:/?@c
  35810. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  35811. // Review our test case against browsers more comprehensively.
  35812. // find the first instance of any hostEndingChars
  35813. var hostEnd = -1;
  35814. for (i = 0; i < hostEndingChars.length; i++) {
  35815. hec = rest.indexOf(hostEndingChars[i]);
  35816. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  35817. hostEnd = hec;
  35818. }
  35819. }
  35820. // at this point, either we have an explicit point where the
  35821. // auth portion cannot go past, or the last @ char is the decider.
  35822. var auth, atSign;
  35823. if (hostEnd === -1) {
  35824. // atSign can be anywhere.
  35825. atSign = rest.lastIndexOf('@');
  35826. } else {
  35827. // atSign must be in auth portion.
  35828. // http://a@b/c@d => host:b auth:a path:/c@d
  35829. atSign = rest.lastIndexOf('@', hostEnd);
  35830. }
  35831. // Now we have a portion which is definitely the auth.
  35832. // Pull that off.
  35833. if (atSign !== -1) {
  35834. auth = rest.slice(0, atSign);
  35835. rest = rest.slice(atSign + 1);
  35836. this.auth = auth;
  35837. }
  35838. // the host is the remaining to the left of the first non-host char
  35839. hostEnd = -1;
  35840. for (i = 0; i < nonHostChars.length; i++) {
  35841. hec = rest.indexOf(nonHostChars[i]);
  35842. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  35843. hostEnd = hec;
  35844. }
  35845. }
  35846. // if we still have not hit it, then the entire thing is a host.
  35847. if (hostEnd === -1) {
  35848. hostEnd = rest.length;
  35849. }
  35850. if (rest[hostEnd - 1] === ':') { hostEnd--; }
  35851. var host = rest.slice(0, hostEnd);
  35852. rest = rest.slice(hostEnd);
  35853. // pull out port.
  35854. this.parseHost(host);
  35855. // we've indicated that there is a hostname,
  35856. // so even if it's empty, it has to be present.
  35857. this.hostname = this.hostname || '';
  35858. // if hostname begins with [ and ends with ]
  35859. // assume that it's an IPv6 address.
  35860. var ipv6Hostname = this.hostname[0] === '[' &&
  35861. this.hostname[this.hostname.length - 1] === ']';
  35862. // validate a little.
  35863. if (!ipv6Hostname) {
  35864. var hostparts = this.hostname.split(/\./);
  35865. for (i = 0, l = hostparts.length; i < l; i++) {
  35866. var part = hostparts[i];
  35867. if (!part) { continue; }
  35868. if (!part.match(hostnamePartPattern)) {
  35869. var newpart = '';
  35870. for (var j = 0, k = part.length; j < k; j++) {
  35871. if (part.charCodeAt(j) > 127) {
  35872. // we replace non-ASCII char with a temporary placeholder
  35873. // we need this to make sure size of hostname is not
  35874. // broken by replacing non-ASCII by nothing
  35875. newpart += 'x';
  35876. } else {
  35877. newpart += part[j];
  35878. }
  35879. }
  35880. // we test again with ASCII char only
  35881. if (!newpart.match(hostnamePartPattern)) {
  35882. var validParts = hostparts.slice(0, i);
  35883. var notHost = hostparts.slice(i + 1);
  35884. var bit = part.match(hostnamePartStart);
  35885. if (bit) {
  35886. validParts.push(bit[1]);
  35887. notHost.unshift(bit[2]);
  35888. }
  35889. if (notHost.length) {
  35890. rest = notHost.join('.') + rest;
  35891. }
  35892. this.hostname = validParts.join('.');
  35893. break;
  35894. }
  35895. }
  35896. }
  35897. }
  35898. if (this.hostname.length > hostnameMaxLen) {
  35899. this.hostname = '';
  35900. }
  35901. // strip [ and ] from the hostname
  35902. // the host field still retains them, though
  35903. if (ipv6Hostname) {
  35904. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  35905. }
  35906. }
  35907. // chop off from the tail first.
  35908. var hash = rest.indexOf('#');
  35909. if (hash !== -1) {
  35910. // got a fragment string.
  35911. this.hash = rest.substr(hash);
  35912. rest = rest.slice(0, hash);
  35913. }
  35914. var qm = rest.indexOf('?');
  35915. if (qm !== -1) {
  35916. this.search = rest.substr(qm);
  35917. rest = rest.slice(0, qm);
  35918. }
  35919. if (rest) { this.pathname = rest; }
  35920. if (slashedProtocol[lowerProto] &&
  35921. this.hostname && !this.pathname) {
  35922. this.pathname = '';
  35923. }
  35924. return this;
  35925. };
  35926. Url.prototype.parseHost = function(host) {
  35927. var port = portPattern.exec(host);
  35928. if (port) {
  35929. port = port[0];
  35930. if (port !== ':') {
  35931. this.port = port.substr(1);
  35932. }
  35933. host = host.substr(0, host.length - port.length);
  35934. }
  35935. if (host) { this.hostname = host; }
  35936. };
  35937. module.exports = urlParse;
  35938. },{}],197:[function(require,module,exports){
  35939. /*
  35940. object-assign
  35941. (c) Sindre Sorhus
  35942. @license MIT
  35943. */
  35944. 'use strict';
  35945. /* eslint-disable no-unused-vars */
  35946. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  35947. var hasOwnProperty = Object.prototype.hasOwnProperty;
  35948. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  35949. function toObject(val) {
  35950. if (val === null || val === undefined) {
  35951. throw new TypeError('Object.assign cannot be called with null or undefined');
  35952. }
  35953. return Object(val);
  35954. }
  35955. function shouldUseNative() {
  35956. try {
  35957. if (!Object.assign) {
  35958. return false;
  35959. }
  35960. // Detect buggy property enumeration order in older V8 versions.
  35961. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  35962. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  35963. test1[5] = 'de';
  35964. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  35965. return false;
  35966. }
  35967. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  35968. var test2 = {};
  35969. for (var i = 0; i < 10; i++) {
  35970. test2['_' + String.fromCharCode(i)] = i;
  35971. }
  35972. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  35973. return test2[n];
  35974. });
  35975. if (order2.join('') !== '0123456789') {
  35976. return false;
  35977. }
  35978. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  35979. var test3 = {};
  35980. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  35981. test3[letter] = letter;
  35982. });
  35983. if (Object.keys(Object.assign({}, test3)).join('') !==
  35984. 'abcdefghijklmnopqrst') {
  35985. return false;
  35986. }
  35987. return true;
  35988. } catch (err) {
  35989. // We don't expect any of the above to throw, but better to be safe.
  35990. return false;
  35991. }
  35992. }
  35993. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  35994. var from;
  35995. var to = toObject(target);
  35996. var symbols;
  35997. for (var s = 1; s < arguments.length; s++) {
  35998. from = Object(arguments[s]);
  35999. for (var key in from) {
  36000. if (hasOwnProperty.call(from, key)) {
  36001. to[key] = from[key];
  36002. }
  36003. }
  36004. if (getOwnPropertySymbols) {
  36005. symbols = getOwnPropertySymbols(from);
  36006. for (var i = 0; i < symbols.length; i++) {
  36007. if (propIsEnumerable.call(from, symbols[i])) {
  36008. to[symbols[i]] = from[symbols[i]];
  36009. }
  36010. }
  36011. }
  36012. }
  36013. return to;
  36014. };
  36015. },{}],198:[function(require,module,exports){
  36016. // shim for using process in browser
  36017. var process = module.exports = {};
  36018. // cached from whatever global is present so that test runners that stub it
  36019. // don't break things. But we need to wrap it in a try catch in case it is
  36020. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36021. // function because try/catches deoptimize in certain engines.
  36022. var cachedSetTimeout;
  36023. var cachedClearTimeout;
  36024. function defaultSetTimout() {
  36025. throw new Error('setTimeout has not been defined');
  36026. }
  36027. function defaultClearTimeout () {
  36028. throw new Error('clearTimeout has not been defined');
  36029. }
  36030. (function () {
  36031. try {
  36032. if (typeof setTimeout === 'function') {
  36033. cachedSetTimeout = setTimeout;
  36034. } else {
  36035. cachedSetTimeout = defaultSetTimout;
  36036. }
  36037. } catch (e) {
  36038. cachedSetTimeout = defaultSetTimout;
  36039. }
  36040. try {
  36041. if (typeof clearTimeout === 'function') {
  36042. cachedClearTimeout = clearTimeout;
  36043. } else {
  36044. cachedClearTimeout = defaultClearTimeout;
  36045. }
  36046. } catch (e) {
  36047. cachedClearTimeout = defaultClearTimeout;
  36048. }
  36049. } ())
  36050. function runTimeout(fun) {
  36051. if (cachedSetTimeout === setTimeout) {
  36052. //normal enviroments in sane situations
  36053. return setTimeout(fun, 0);
  36054. }
  36055. // if setTimeout wasn't available but was latter defined
  36056. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36057. cachedSetTimeout = setTimeout;
  36058. return setTimeout(fun, 0);
  36059. }
  36060. try {
  36061. // when when somebody has screwed with setTimeout but no I.E. maddness
  36062. return cachedSetTimeout(fun, 0);
  36063. } catch(e){
  36064. try {
  36065. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36066. return cachedSetTimeout.call(null, fun, 0);
  36067. } catch(e){
  36068. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  36069. return cachedSetTimeout.call(this, fun, 0);
  36070. }
  36071. }
  36072. }
  36073. function runClearTimeout(marker) {
  36074. if (cachedClearTimeout === clearTimeout) {
  36075. //normal enviroments in sane situations
  36076. return clearTimeout(marker);
  36077. }
  36078. // if clearTimeout wasn't available but was latter defined
  36079. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36080. cachedClearTimeout = clearTimeout;
  36081. return clearTimeout(marker);
  36082. }
  36083. try {
  36084. // when when somebody has screwed with setTimeout but no I.E. maddness
  36085. return cachedClearTimeout(marker);
  36086. } catch (e){
  36087. try {
  36088. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36089. return cachedClearTimeout.call(null, marker);
  36090. } catch (e){
  36091. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  36092. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36093. return cachedClearTimeout.call(this, marker);
  36094. }
  36095. }
  36096. }
  36097. var queue = [];
  36098. var draining = false;
  36099. var currentQueue;
  36100. var queueIndex = -1;
  36101. function cleanUpNextTick() {
  36102. if (!draining || !currentQueue) {
  36103. return;
  36104. }
  36105. draining = false;
  36106. if (currentQueue.length) {
  36107. queue = currentQueue.concat(queue);
  36108. } else {
  36109. queueIndex = -1;
  36110. }
  36111. if (queue.length) {
  36112. drainQueue();
  36113. }
  36114. }
  36115. function drainQueue() {
  36116. if (draining) {
  36117. return;
  36118. }
  36119. var timeout = runTimeout(cleanUpNextTick);
  36120. draining = true;
  36121. var len = queue.length;
  36122. while(len) {
  36123. currentQueue = queue;
  36124. queue = [];
  36125. while (++queueIndex < len) {
  36126. if (currentQueue) {
  36127. currentQueue[queueIndex].run();
  36128. }
  36129. }
  36130. queueIndex = -1;
  36131. len = queue.length;
  36132. }
  36133. currentQueue = null;
  36134. draining = false;
  36135. runClearTimeout(timeout);
  36136. }
  36137. process.nextTick = function (fun) {
  36138. var args = new Array(arguments.length - 1);
  36139. if (arguments.length > 1) {
  36140. for (var i = 1; i < arguments.length; i++) {
  36141. args[i - 1] = arguments[i];
  36142. }
  36143. }
  36144. queue.push(new Item(fun, args));
  36145. if (queue.length === 1 && !draining) {
  36146. runTimeout(drainQueue);
  36147. }
  36148. };
  36149. // v8 likes predictible objects
  36150. function Item(fun, array) {
  36151. this.fun = fun;
  36152. this.array = array;
  36153. }
  36154. Item.prototype.run = function () {
  36155. this.fun.apply(null, this.array);
  36156. };
  36157. process.title = 'browser';
  36158. process.browser = true;
  36159. process.env = {};
  36160. process.argv = [];
  36161. process.version = ''; // empty string to avoid regexp issues
  36162. process.versions = {};
  36163. function noop() {}
  36164. process.on = noop;
  36165. process.addListener = noop;
  36166. process.once = noop;
  36167. process.off = noop;
  36168. process.removeListener = noop;
  36169. process.removeAllListeners = noop;
  36170. process.emit = noop;
  36171. process.prependListener = noop;
  36172. process.prependOnceListener = noop;
  36173. process.listeners = function (name) { return [] }
  36174. process.binding = function (name) {
  36175. throw new Error('process.binding is not supported');
  36176. };
  36177. process.cwd = function () { return '/' };
  36178. process.chdir = function (dir) {
  36179. throw new Error('process.chdir is not supported');
  36180. };
  36181. process.umask = function() { return 0; };
  36182. },{}],199:[function(require,module,exports){
  36183. (function (process){
  36184. /**
  36185. * Copyright (c) 2013-present, Facebook, Inc.
  36186. *
  36187. * This source code is licensed under the MIT license found in the
  36188. * LICENSE file in the root directory of this source tree.
  36189. */
  36190. 'use strict';
  36191. var printWarning = function() {};
  36192. if (process.env.NODE_ENV !== 'production') {
  36193. var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
  36194. var loggedTypeFailures = {};
  36195. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  36196. printWarning = function(text) {
  36197. var message = 'Warning: ' + text;
  36198. if (typeof console !== 'undefined') {
  36199. console.error(message);
  36200. }
  36201. try {
  36202. // --- Welcome to debugging React ---
  36203. // This error was thrown as a convenience so that you can use this stack
  36204. // to find the callsite that caused this warning to fire.
  36205. throw new Error(message);
  36206. } catch (x) {}
  36207. };
  36208. }
  36209. /**
  36210. * Assert that the values match with the type specs.
  36211. * Error messages are memorized and will only be shown once.
  36212. *
  36213. * @param {object} typeSpecs Map of name to a ReactPropType
  36214. * @param {object} values Runtime values that need to be type-checked
  36215. * @param {string} location e.g. "prop", "context", "child context"
  36216. * @param {string} componentName Name of the component for error messages.
  36217. * @param {?Function} getStack Returns the component stack.
  36218. * @private
  36219. */
  36220. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  36221. if (process.env.NODE_ENV !== 'production') {
  36222. for (var typeSpecName in typeSpecs) {
  36223. if (has(typeSpecs, typeSpecName)) {
  36224. var error;
  36225. // Prop type validation may throw. In case they do, we don't want to
  36226. // fail the render phase where it didn't fail before. So we log it.
  36227. // After these have been cleaned up, we'll let them throw.
  36228. try {
  36229. // This is intentionally an invariant that gets caught. It's the same
  36230. // behavior as without this statement except with a better message.
  36231. if (typeof typeSpecs[typeSpecName] !== 'function') {
  36232. var err = Error(
  36233. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  36234. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  36235. );
  36236. err.name = 'Invariant Violation';
  36237. throw err;
  36238. }
  36239. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  36240. } catch (ex) {
  36241. error = ex;
  36242. }
  36243. if (error && !(error instanceof Error)) {
  36244. printWarning(
  36245. (componentName || 'React class') + ': type specification of ' +
  36246. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  36247. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  36248. 'You may have forgotten to pass an argument to the type checker ' +
  36249. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  36250. 'shape all require an argument).'
  36251. );
  36252. }
  36253. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  36254. // Only monitor this failure once because there tends to be a lot of the
  36255. // same error.
  36256. loggedTypeFailures[error.message] = true;
  36257. var stack = getStack ? getStack() : '';
  36258. printWarning(
  36259. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  36260. );
  36261. }
  36262. }
  36263. }
  36264. }
  36265. }
  36266. /**
  36267. * Resets warning cache when testing.
  36268. *
  36269. * @private
  36270. */
  36271. checkPropTypes.resetWarningCache = function() {
  36272. if (process.env.NODE_ENV !== 'production') {
  36273. loggedTypeFailures = {};
  36274. }
  36275. }
  36276. module.exports = checkPropTypes;
  36277. }).call(this,require('_process'))
  36278. },{"./lib/ReactPropTypesSecret":203,"_process":198}],200:[function(require,module,exports){
  36279. /**
  36280. * Copyright (c) 2013-present, Facebook, Inc.
  36281. *
  36282. * This source code is licensed under the MIT license found in the
  36283. * LICENSE file in the root directory of this source tree.
  36284. */
  36285. 'use strict';
  36286. var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
  36287. function emptyFunction() {}
  36288. function emptyFunctionWithReset() {}
  36289. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  36290. module.exports = function() {
  36291. function shim(props, propName, componentName, location, propFullName, secret) {
  36292. if (secret === ReactPropTypesSecret) {
  36293. // It is still safe when called from React.
  36294. return;
  36295. }
  36296. var err = new Error(
  36297. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  36298. 'Use PropTypes.checkPropTypes() to call them. ' +
  36299. 'Read more at http://fb.me/use-check-prop-types'
  36300. );
  36301. err.name = 'Invariant Violation';
  36302. throw err;
  36303. };
  36304. shim.isRequired = shim;
  36305. function getShim() {
  36306. return shim;
  36307. };
  36308. // Important!
  36309. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  36310. var ReactPropTypes = {
  36311. array: shim,
  36312. bool: shim,
  36313. func: shim,
  36314. number: shim,
  36315. object: shim,
  36316. string: shim,
  36317. symbol: shim,
  36318. any: shim,
  36319. arrayOf: getShim,
  36320. element: shim,
  36321. elementType: shim,
  36322. instanceOf: getShim,
  36323. node: shim,
  36324. objectOf: getShim,
  36325. oneOf: getShim,
  36326. oneOfType: getShim,
  36327. shape: getShim,
  36328. exact: getShim,
  36329. checkPropTypes: emptyFunctionWithReset,
  36330. resetWarningCache: emptyFunction
  36331. };
  36332. ReactPropTypes.PropTypes = ReactPropTypes;
  36333. return ReactPropTypes;
  36334. };
  36335. },{"./lib/ReactPropTypesSecret":203}],201:[function(require,module,exports){
  36336. (function (process){
  36337. /**
  36338. * Copyright (c) 2013-present, Facebook, Inc.
  36339. *
  36340. * This source code is licensed under the MIT license found in the
  36341. * LICENSE file in the root directory of this source tree.
  36342. */
  36343. 'use strict';
  36344. var ReactIs = require('react-is');
  36345. var assign = require('object-assign');
  36346. var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
  36347. var checkPropTypes = require('./checkPropTypes');
  36348. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  36349. var printWarning = function() {};
  36350. if (process.env.NODE_ENV !== 'production') {
  36351. printWarning = function(text) {
  36352. var message = 'Warning: ' + text;
  36353. if (typeof console !== 'undefined') {
  36354. console.error(message);
  36355. }
  36356. try {
  36357. // --- Welcome to debugging React ---
  36358. // This error was thrown as a convenience so that you can use this stack
  36359. // to find the callsite that caused this warning to fire.
  36360. throw new Error(message);
  36361. } catch (x) {}
  36362. };
  36363. }
  36364. function emptyFunctionThatReturnsNull() {
  36365. return null;
  36366. }
  36367. module.exports = function(isValidElement, throwOnDirectAccess) {
  36368. /* global Symbol */
  36369. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  36370. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  36371. /**
  36372. * Returns the iterator method function contained on the iterable object.
  36373. *
  36374. * Be sure to invoke the function with the iterable as context:
  36375. *
  36376. * var iteratorFn = getIteratorFn(myIterable);
  36377. * if (iteratorFn) {
  36378. * var iterator = iteratorFn.call(myIterable);
  36379. * ...
  36380. * }
  36381. *
  36382. * @param {?object} maybeIterable
  36383. * @return {?function}
  36384. */
  36385. function getIteratorFn(maybeIterable) {
  36386. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  36387. if (typeof iteratorFn === 'function') {
  36388. return iteratorFn;
  36389. }
  36390. }
  36391. /**
  36392. * Collection of methods that allow declaration and validation of props that are
  36393. * supplied to React components. Example usage:
  36394. *
  36395. * var Props = require('ReactPropTypes');
  36396. * var MyArticle = React.createClass({
  36397. * propTypes: {
  36398. * // An optional string prop named "description".
  36399. * description: Props.string,
  36400. *
  36401. * // A required enum prop named "category".
  36402. * category: Props.oneOf(['News','Photos']).isRequired,
  36403. *
  36404. * // A prop named "dialog" that requires an instance of Dialog.
  36405. * dialog: Props.instanceOf(Dialog).isRequired
  36406. * },
  36407. * render: function() { ... }
  36408. * });
  36409. *
  36410. * A more formal specification of how these methods are used:
  36411. *
  36412. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  36413. * decl := ReactPropTypes.{type}(.isRequired)?
  36414. *
  36415. * Each and every declaration produces a function with the same signature. This
  36416. * allows the creation of custom validation functions. For example:
  36417. *
  36418. * var MyLink = React.createClass({
  36419. * propTypes: {
  36420. * // An optional string or URI prop named "href".
  36421. * href: function(props, propName, componentName) {
  36422. * var propValue = props[propName];
  36423. * if (propValue != null && typeof propValue !== 'string' &&
  36424. * !(propValue instanceof URI)) {
  36425. * return new Error(
  36426. * 'Expected a string or an URI for ' + propName + ' in ' +
  36427. * componentName
  36428. * );
  36429. * }
  36430. * }
  36431. * },
  36432. * render: function() {...}
  36433. * });
  36434. *
  36435. * @internal
  36436. */
  36437. var ANONYMOUS = '<<anonymous>>';
  36438. // Important!
  36439. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  36440. var ReactPropTypes = {
  36441. array: createPrimitiveTypeChecker('array'),
  36442. bool: createPrimitiveTypeChecker('boolean'),
  36443. func: createPrimitiveTypeChecker('function'),
  36444. number: createPrimitiveTypeChecker('number'),
  36445. object: createPrimitiveTypeChecker('object'),
  36446. string: createPrimitiveTypeChecker('string'),
  36447. symbol: createPrimitiveTypeChecker('symbol'),
  36448. any: createAnyTypeChecker(),
  36449. arrayOf: createArrayOfTypeChecker,
  36450. element: createElementTypeChecker(),
  36451. elementType: createElementTypeTypeChecker(),
  36452. instanceOf: createInstanceTypeChecker,
  36453. node: createNodeChecker(),
  36454. objectOf: createObjectOfTypeChecker,
  36455. oneOf: createEnumTypeChecker,
  36456. oneOfType: createUnionTypeChecker,
  36457. shape: createShapeTypeChecker,
  36458. exact: createStrictShapeTypeChecker,
  36459. };
  36460. /**
  36461. * inlined Object.is polyfill to avoid requiring consumers ship their own
  36462. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  36463. */
  36464. /*eslint-disable no-self-compare*/
  36465. function is(x, y) {
  36466. // SameValue algorithm
  36467. if (x === y) {
  36468. // Steps 1-5, 7-10
  36469. // Steps 6.b-6.e: +0 != -0
  36470. return x !== 0 || 1 / x === 1 / y;
  36471. } else {
  36472. // Step 6.a: NaN == NaN
  36473. return x !== x && y !== y;
  36474. }
  36475. }
  36476. /*eslint-enable no-self-compare*/
  36477. /**
  36478. * We use an Error-like object for backward compatibility as people may call
  36479. * PropTypes directly and inspect their output. However, we don't use real
  36480. * Errors anymore. We don't inspect their stack anyway, and creating them
  36481. * is prohibitively expensive if they are created too often, such as what
  36482. * happens in oneOfType() for any type before the one that matched.
  36483. */
  36484. function PropTypeError(message) {
  36485. this.message = message;
  36486. this.stack = '';
  36487. }
  36488. // Make `instanceof Error` still work for returned errors.
  36489. PropTypeError.prototype = Error.prototype;
  36490. function createChainableTypeChecker(validate) {
  36491. if (process.env.NODE_ENV !== 'production') {
  36492. var manualPropTypeCallCache = {};
  36493. var manualPropTypeWarningCount = 0;
  36494. }
  36495. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  36496. componentName = componentName || ANONYMOUS;
  36497. propFullName = propFullName || propName;
  36498. if (secret !== ReactPropTypesSecret) {
  36499. if (throwOnDirectAccess) {
  36500. // New behavior only for users of `prop-types` package
  36501. var err = new Error(
  36502. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  36503. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  36504. 'Read more at http://fb.me/use-check-prop-types'
  36505. );
  36506. err.name = 'Invariant Violation';
  36507. throw err;
  36508. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  36509. // Old behavior for people using React.PropTypes
  36510. var cacheKey = componentName + ':' + propName;
  36511. if (
  36512. !manualPropTypeCallCache[cacheKey] &&
  36513. // Avoid spamming the console because they are often not actionable except for lib authors
  36514. manualPropTypeWarningCount < 3
  36515. ) {
  36516. printWarning(
  36517. 'You are manually calling a React.PropTypes validation ' +
  36518. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  36519. 'and will throw in the standalone `prop-types` package. ' +
  36520. 'You may be seeing this warning due to a third-party PropTypes ' +
  36521. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  36522. );
  36523. manualPropTypeCallCache[cacheKey] = true;
  36524. manualPropTypeWarningCount++;
  36525. }
  36526. }
  36527. }
  36528. if (props[propName] == null) {
  36529. if (isRequired) {
  36530. if (props[propName] === null) {
  36531. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  36532. }
  36533. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  36534. }
  36535. return null;
  36536. } else {
  36537. return validate(props, propName, componentName, location, propFullName);
  36538. }
  36539. }
  36540. var chainedCheckType = checkType.bind(null, false);
  36541. chainedCheckType.isRequired = checkType.bind(null, true);
  36542. return chainedCheckType;
  36543. }
  36544. function createPrimitiveTypeChecker(expectedType) {
  36545. function validate(props, propName, componentName, location, propFullName, secret) {
  36546. var propValue = props[propName];
  36547. var propType = getPropType(propValue);
  36548. if (propType !== expectedType) {
  36549. // `propValue` being instance of, say, date/regexp, pass the 'object'
  36550. // check, but we can offer a more precise error message here rather than
  36551. // 'of type `object`'.
  36552. var preciseType = getPreciseType(propValue);
  36553. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  36554. }
  36555. return null;
  36556. }
  36557. return createChainableTypeChecker(validate);
  36558. }
  36559. function createAnyTypeChecker() {
  36560. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  36561. }
  36562. function createArrayOfTypeChecker(typeChecker) {
  36563. function validate(props, propName, componentName, location, propFullName) {
  36564. if (typeof typeChecker !== 'function') {
  36565. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  36566. }
  36567. var propValue = props[propName];
  36568. if (!Array.isArray(propValue)) {
  36569. var propType = getPropType(propValue);
  36570. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  36571. }
  36572. for (var i = 0; i < propValue.length; i++) {
  36573. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
  36574. if (error instanceof Error) {
  36575. return error;
  36576. }
  36577. }
  36578. return null;
  36579. }
  36580. return createChainableTypeChecker(validate);
  36581. }
  36582. function createElementTypeChecker() {
  36583. function validate(props, propName, componentName, location, propFullName) {
  36584. var propValue = props[propName];
  36585. if (!isValidElement(propValue)) {
  36586. var propType = getPropType(propValue);
  36587. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  36588. }
  36589. return null;
  36590. }
  36591. return createChainableTypeChecker(validate);
  36592. }
  36593. function createElementTypeTypeChecker() {
  36594. function validate(props, propName, componentName, location, propFullName) {
  36595. var propValue = props[propName];
  36596. if (!ReactIs.isValidElementType(propValue)) {
  36597. var propType = getPropType(propValue);
  36598. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  36599. }
  36600. return null;
  36601. }
  36602. return createChainableTypeChecker(validate);
  36603. }
  36604. function createInstanceTypeChecker(expectedClass) {
  36605. function validate(props, propName, componentName, location, propFullName) {
  36606. if (!(props[propName] instanceof expectedClass)) {
  36607. var expectedClassName = expectedClass.name || ANONYMOUS;
  36608. var actualClassName = getClassName(props[propName]);
  36609. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  36610. }
  36611. return null;
  36612. }
  36613. return createChainableTypeChecker(validate);
  36614. }
  36615. function createEnumTypeChecker(expectedValues) {
  36616. if (!Array.isArray(expectedValues)) {
  36617. if (process.env.NODE_ENV !== 'production') {
  36618. if (arguments.length > 1) {
  36619. printWarning(
  36620. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  36621. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  36622. );
  36623. } else {
  36624. printWarning('Invalid argument supplied to oneOf, expected an array.');
  36625. }
  36626. }
  36627. return emptyFunctionThatReturnsNull;
  36628. }
  36629. function validate(props, propName, componentName, location, propFullName) {
  36630. var propValue = props[propName];
  36631. for (var i = 0; i < expectedValues.length; i++) {
  36632. if (is(propValue, expectedValues[i])) {
  36633. return null;
  36634. }
  36635. }
  36636. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  36637. var type = getPreciseType(value);
  36638. if (type === 'symbol') {
  36639. return String(value);
  36640. }
  36641. return value;
  36642. });
  36643. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  36644. }
  36645. return createChainableTypeChecker(validate);
  36646. }
  36647. function createObjectOfTypeChecker(typeChecker) {
  36648. function validate(props, propName, componentName, location, propFullName) {
  36649. if (typeof typeChecker !== 'function') {
  36650. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  36651. }
  36652. var propValue = props[propName];
  36653. var propType = getPropType(propValue);
  36654. if (propType !== 'object') {
  36655. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  36656. }
  36657. for (var key in propValue) {
  36658. if (has(propValue, key)) {
  36659. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  36660. if (error instanceof Error) {
  36661. return error;
  36662. }
  36663. }
  36664. }
  36665. return null;
  36666. }
  36667. return createChainableTypeChecker(validate);
  36668. }
  36669. function createUnionTypeChecker(arrayOfTypeCheckers) {
  36670. if (!Array.isArray(arrayOfTypeCheckers)) {
  36671. process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  36672. return emptyFunctionThatReturnsNull;
  36673. }
  36674. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  36675. var checker = arrayOfTypeCheckers[i];
  36676. if (typeof checker !== 'function') {
  36677. printWarning(
  36678. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  36679. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  36680. );
  36681. return emptyFunctionThatReturnsNull;
  36682. }
  36683. }
  36684. function validate(props, propName, componentName, location, propFullName) {
  36685. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  36686. var checker = arrayOfTypeCheckers[i];
  36687. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
  36688. return null;
  36689. }
  36690. }
  36691. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  36692. }
  36693. return createChainableTypeChecker(validate);
  36694. }
  36695. function createNodeChecker() {
  36696. function validate(props, propName, componentName, location, propFullName) {
  36697. if (!isNode(props[propName])) {
  36698. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  36699. }
  36700. return null;
  36701. }
  36702. return createChainableTypeChecker(validate);
  36703. }
  36704. function createShapeTypeChecker(shapeTypes) {
  36705. function validate(props, propName, componentName, location, propFullName) {
  36706. var propValue = props[propName];
  36707. var propType = getPropType(propValue);
  36708. if (propType !== 'object') {
  36709. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  36710. }
  36711. for (var key in shapeTypes) {
  36712. var checker = shapeTypes[key];
  36713. if (!checker) {
  36714. continue;
  36715. }
  36716. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  36717. if (error) {
  36718. return error;
  36719. }
  36720. }
  36721. return null;
  36722. }
  36723. return createChainableTypeChecker(validate);
  36724. }
  36725. function createStrictShapeTypeChecker(shapeTypes) {
  36726. function validate(props, propName, componentName, location, propFullName) {
  36727. var propValue = props[propName];
  36728. var propType = getPropType(propValue);
  36729. if (propType !== 'object') {
  36730. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  36731. }
  36732. // We need to check all keys in case some are required but missing from
  36733. // props.
  36734. var allKeys = assign({}, props[propName], shapeTypes);
  36735. for (var key in allKeys) {
  36736. var checker = shapeTypes[key];
  36737. if (!checker) {
  36738. return new PropTypeError(
  36739. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  36740. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  36741. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  36742. );
  36743. }
  36744. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  36745. if (error) {
  36746. return error;
  36747. }
  36748. }
  36749. return null;
  36750. }
  36751. return createChainableTypeChecker(validate);
  36752. }
  36753. function isNode(propValue) {
  36754. switch (typeof propValue) {
  36755. case 'number':
  36756. case 'string':
  36757. case 'undefined':
  36758. return true;
  36759. case 'boolean':
  36760. return !propValue;
  36761. case 'object':
  36762. if (Array.isArray(propValue)) {
  36763. return propValue.every(isNode);
  36764. }
  36765. if (propValue === null || isValidElement(propValue)) {
  36766. return true;
  36767. }
  36768. var iteratorFn = getIteratorFn(propValue);
  36769. if (iteratorFn) {
  36770. var iterator = iteratorFn.call(propValue);
  36771. var step;
  36772. if (iteratorFn !== propValue.entries) {
  36773. while (!(step = iterator.next()).done) {
  36774. if (!isNode(step.value)) {
  36775. return false;
  36776. }
  36777. }
  36778. } else {
  36779. // Iterator will provide entry [k,v] tuples rather than values.
  36780. while (!(step = iterator.next()).done) {
  36781. var entry = step.value;
  36782. if (entry) {
  36783. if (!isNode(entry[1])) {
  36784. return false;
  36785. }
  36786. }
  36787. }
  36788. }
  36789. } else {
  36790. return false;
  36791. }
  36792. return true;
  36793. default:
  36794. return false;
  36795. }
  36796. }
  36797. function isSymbol(propType, propValue) {
  36798. // Native Symbol.
  36799. if (propType === 'symbol') {
  36800. return true;
  36801. }
  36802. // falsy value can't be a Symbol
  36803. if (!propValue) {
  36804. return false;
  36805. }
  36806. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  36807. if (propValue['@@toStringTag'] === 'Symbol') {
  36808. return true;
  36809. }
  36810. // Fallback for non-spec compliant Symbols which are polyfilled.
  36811. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  36812. return true;
  36813. }
  36814. return false;
  36815. }
  36816. // Equivalent of `typeof` but with special handling for array and regexp.
  36817. function getPropType(propValue) {
  36818. var propType = typeof propValue;
  36819. if (Array.isArray(propValue)) {
  36820. return 'array';
  36821. }
  36822. if (propValue instanceof RegExp) {
  36823. // Old webkits (at least until Android 4.0) return 'function' rather than
  36824. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  36825. // passes PropTypes.object.
  36826. return 'object';
  36827. }
  36828. if (isSymbol(propType, propValue)) {
  36829. return 'symbol';
  36830. }
  36831. return propType;
  36832. }
  36833. // This handles more types than `getPropType`. Only used for error messages.
  36834. // See `createPrimitiveTypeChecker`.
  36835. function getPreciseType(propValue) {
  36836. if (typeof propValue === 'undefined' || propValue === null) {
  36837. return '' + propValue;
  36838. }
  36839. var propType = getPropType(propValue);
  36840. if (propType === 'object') {
  36841. if (propValue instanceof Date) {
  36842. return 'date';
  36843. } else if (propValue instanceof RegExp) {
  36844. return 'regexp';
  36845. }
  36846. }
  36847. return propType;
  36848. }
  36849. // Returns a string that is postfixed to a warning about an invalid type.
  36850. // For example, "undefined" or "of type array"
  36851. function getPostfixForTypeWarning(value) {
  36852. var type = getPreciseType(value);
  36853. switch (type) {
  36854. case 'array':
  36855. case 'object':
  36856. return 'an ' + type;
  36857. case 'boolean':
  36858. case 'date':
  36859. case 'regexp':
  36860. return 'a ' + type;
  36861. default:
  36862. return type;
  36863. }
  36864. }
  36865. // Returns class name of the object, if any.
  36866. function getClassName(propValue) {
  36867. if (!propValue.constructor || !propValue.constructor.name) {
  36868. return ANONYMOUS;
  36869. }
  36870. return propValue.constructor.name;
  36871. }
  36872. ReactPropTypes.checkPropTypes = checkPropTypes;
  36873. ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
  36874. ReactPropTypes.PropTypes = ReactPropTypes;
  36875. return ReactPropTypes;
  36876. };
  36877. }).call(this,require('_process'))
  36878. },{"./checkPropTypes":199,"./lib/ReactPropTypesSecret":203,"_process":198,"object-assign":197,"react-is":206}],202:[function(require,module,exports){
  36879. (function (process){
  36880. /**
  36881. * Copyright (c) 2013-present, Facebook, Inc.
  36882. *
  36883. * This source code is licensed under the MIT license found in the
  36884. * LICENSE file in the root directory of this source tree.
  36885. */
  36886. if (process.env.NODE_ENV !== 'production') {
  36887. var ReactIs = require('react-is');
  36888. // By explicitly using `prop-types` you are opting into new development behavior.
  36889. // http://fb.me/prop-types-in-prod
  36890. var throwOnDirectAccess = true;
  36891. module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);
  36892. } else {
  36893. // By explicitly using `prop-types` you are opting into new production behavior.
  36894. // http://fb.me/prop-types-in-prod
  36895. module.exports = require('./factoryWithThrowingShims')();
  36896. }
  36897. }).call(this,require('_process'))
  36898. },{"./factoryWithThrowingShims":200,"./factoryWithTypeCheckers":201,"_process":198,"react-is":206}],203:[function(require,module,exports){
  36899. /**
  36900. * Copyright (c) 2013-present, Facebook, Inc.
  36901. *
  36902. * This source code is licensed under the MIT license found in the
  36903. * LICENSE file in the root directory of this source tree.
  36904. */
  36905. 'use strict';
  36906. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  36907. module.exports = ReactPropTypesSecret;
  36908. },{}],204:[function(require,module,exports){
  36909. (function (process){
  36910. /** @license React v16.8.6
  36911. * react-is.development.js
  36912. *
  36913. * Copyright (c) Facebook, Inc. and its affiliates.
  36914. *
  36915. * This source code is licensed under the MIT license found in the
  36916. * LICENSE file in the root directory of this source tree.
  36917. */
  36918. 'use strict';
  36919. if (process.env.NODE_ENV !== "production") {
  36920. (function() {
  36921. 'use strict';
  36922. Object.defineProperty(exports, '__esModule', { value: true });
  36923. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  36924. // nor polyfill, then a plain number is used for performance.
  36925. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  36926. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  36927. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  36928. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  36929. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  36930. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  36931. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  36932. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  36933. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  36934. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  36935. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  36936. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  36937. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  36938. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  36939. function isValidElementType(type) {
  36940. return typeof type === 'string' || typeof type === 'function' ||
  36941. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  36942. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
  36943. }
  36944. /**
  36945. * Forked from fbjs/warning:
  36946. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  36947. *
  36948. * Only change is we use console.warn instead of console.error,
  36949. * and do nothing when 'console' is not supported.
  36950. * This really simplifies the code.
  36951. * ---
  36952. * Similar to invariant but only logs a warning if the condition is not met.
  36953. * This can be used to log issues in development environments in critical
  36954. * paths. Removing the logging code for production environments will keep the
  36955. * same logic and follow the same code paths.
  36956. */
  36957. var lowPriorityWarning = function () {};
  36958. {
  36959. var printWarning = function (format) {
  36960. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  36961. args[_key - 1] = arguments[_key];
  36962. }
  36963. var argIndex = 0;
  36964. var message = 'Warning: ' + format.replace(/%s/g, function () {
  36965. return args[argIndex++];
  36966. });
  36967. if (typeof console !== 'undefined') {
  36968. console.warn(message);
  36969. }
  36970. try {
  36971. // --- Welcome to debugging React ---
  36972. // This error was thrown as a convenience so that you can use this stack
  36973. // to find the callsite that caused this warning to fire.
  36974. throw new Error(message);
  36975. } catch (x) {}
  36976. };
  36977. lowPriorityWarning = function (condition, format) {
  36978. if (format === undefined) {
  36979. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  36980. }
  36981. if (!condition) {
  36982. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  36983. args[_key2 - 2] = arguments[_key2];
  36984. }
  36985. printWarning.apply(undefined, [format].concat(args));
  36986. }
  36987. };
  36988. }
  36989. var lowPriorityWarning$1 = lowPriorityWarning;
  36990. function typeOf(object) {
  36991. if (typeof object === 'object' && object !== null) {
  36992. var $$typeof = object.$$typeof;
  36993. switch ($$typeof) {
  36994. case REACT_ELEMENT_TYPE:
  36995. var type = object.type;
  36996. switch (type) {
  36997. case REACT_ASYNC_MODE_TYPE:
  36998. case REACT_CONCURRENT_MODE_TYPE:
  36999. case REACT_FRAGMENT_TYPE:
  37000. case REACT_PROFILER_TYPE:
  37001. case REACT_STRICT_MODE_TYPE:
  37002. case REACT_SUSPENSE_TYPE:
  37003. return type;
  37004. default:
  37005. var $$typeofType = type && type.$$typeof;
  37006. switch ($$typeofType) {
  37007. case REACT_CONTEXT_TYPE:
  37008. case REACT_FORWARD_REF_TYPE:
  37009. case REACT_PROVIDER_TYPE:
  37010. return $$typeofType;
  37011. default:
  37012. return $$typeof;
  37013. }
  37014. }
  37015. case REACT_LAZY_TYPE:
  37016. case REACT_MEMO_TYPE:
  37017. case REACT_PORTAL_TYPE:
  37018. return $$typeof;
  37019. }
  37020. }
  37021. return undefined;
  37022. }
  37023. // AsyncMode is deprecated along with isAsyncMode
  37024. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  37025. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  37026. var ContextConsumer = REACT_CONTEXT_TYPE;
  37027. var ContextProvider = REACT_PROVIDER_TYPE;
  37028. var Element = REACT_ELEMENT_TYPE;
  37029. var ForwardRef = REACT_FORWARD_REF_TYPE;
  37030. var Fragment = REACT_FRAGMENT_TYPE;
  37031. var Lazy = REACT_LAZY_TYPE;
  37032. var Memo = REACT_MEMO_TYPE;
  37033. var Portal = REACT_PORTAL_TYPE;
  37034. var Profiler = REACT_PROFILER_TYPE;
  37035. var StrictMode = REACT_STRICT_MODE_TYPE;
  37036. var Suspense = REACT_SUSPENSE_TYPE;
  37037. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  37038. // AsyncMode should be deprecated
  37039. function isAsyncMode(object) {
  37040. {
  37041. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  37042. hasWarnedAboutDeprecatedIsAsyncMode = true;
  37043. lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  37044. }
  37045. }
  37046. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  37047. }
  37048. function isConcurrentMode(object) {
  37049. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  37050. }
  37051. function isContextConsumer(object) {
  37052. return typeOf(object) === REACT_CONTEXT_TYPE;
  37053. }
  37054. function isContextProvider(object) {
  37055. return typeOf(object) === REACT_PROVIDER_TYPE;
  37056. }
  37057. function isElement(object) {
  37058. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  37059. }
  37060. function isForwardRef(object) {
  37061. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  37062. }
  37063. function isFragment(object) {
  37064. return typeOf(object) === REACT_FRAGMENT_TYPE;
  37065. }
  37066. function isLazy(object) {
  37067. return typeOf(object) === REACT_LAZY_TYPE;
  37068. }
  37069. function isMemo(object) {
  37070. return typeOf(object) === REACT_MEMO_TYPE;
  37071. }
  37072. function isPortal(object) {
  37073. return typeOf(object) === REACT_PORTAL_TYPE;
  37074. }
  37075. function isProfiler(object) {
  37076. return typeOf(object) === REACT_PROFILER_TYPE;
  37077. }
  37078. function isStrictMode(object) {
  37079. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  37080. }
  37081. function isSuspense(object) {
  37082. return typeOf(object) === REACT_SUSPENSE_TYPE;
  37083. }
  37084. exports.typeOf = typeOf;
  37085. exports.AsyncMode = AsyncMode;
  37086. exports.ConcurrentMode = ConcurrentMode;
  37087. exports.ContextConsumer = ContextConsumer;
  37088. exports.ContextProvider = ContextProvider;
  37089. exports.Element = Element;
  37090. exports.ForwardRef = ForwardRef;
  37091. exports.Fragment = Fragment;
  37092. exports.Lazy = Lazy;
  37093. exports.Memo = Memo;
  37094. exports.Portal = Portal;
  37095. exports.Profiler = Profiler;
  37096. exports.StrictMode = StrictMode;
  37097. exports.Suspense = Suspense;
  37098. exports.isValidElementType = isValidElementType;
  37099. exports.isAsyncMode = isAsyncMode;
  37100. exports.isConcurrentMode = isConcurrentMode;
  37101. exports.isContextConsumer = isContextConsumer;
  37102. exports.isContextProvider = isContextProvider;
  37103. exports.isElement = isElement;
  37104. exports.isForwardRef = isForwardRef;
  37105. exports.isFragment = isFragment;
  37106. exports.isLazy = isLazy;
  37107. exports.isMemo = isMemo;
  37108. exports.isPortal = isPortal;
  37109. exports.isProfiler = isProfiler;
  37110. exports.isStrictMode = isStrictMode;
  37111. exports.isSuspense = isSuspense;
  37112. })();
  37113. }
  37114. }).call(this,require('_process'))
  37115. },{"_process":198}],205:[function(require,module,exports){
  37116. /** @license React v16.8.6
  37117. * react-is.production.min.js
  37118. *
  37119. * Copyright (c) Facebook, Inc. and its affiliates.
  37120. *
  37121. * This source code is licensed under the MIT license found in the
  37122. * LICENSE file in the root directory of this source tree.
  37123. */
  37124. 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});
  37125. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):
  37126. 60115,r=b?Symbol.for("react.lazy"):60116;function t(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case r:case q:case d:return u}}}function v(a){return t(a)===m}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;
  37127. exports.Fragment=e;exports.Lazy=r;exports.Memo=q;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||t(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return t(a)===k};
  37128. exports.isContextProvider=function(a){return t(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===n};exports.isFragment=function(a){return t(a)===e};exports.isLazy=function(a){return t(a)===r};exports.isMemo=function(a){return t(a)===q};exports.isPortal=function(a){return t(a)===d};exports.isProfiler=function(a){return t(a)===g};exports.isStrictMode=function(a){return t(a)===f};
  37129. exports.isSuspense=function(a){return t(a)===p};
  37130. },{}],206:[function(require,module,exports){
  37131. (function (process){
  37132. 'use strict';
  37133. if (process.env.NODE_ENV === 'production') {
  37134. module.exports = require('./cjs/react-is.production.min.js');
  37135. } else {
  37136. module.exports = require('./cjs/react-is.development.js');
  37137. }
  37138. }).call(this,require('_process'))
  37139. },{"./cjs/react-is.development.js":204,"./cjs/react-is.production.min.js":205,"_process":198}],207:[function(require,module,exports){
  37140. module.exports = function () {
  37141. var selection = document.getSelection();
  37142. if (!selection.rangeCount) {
  37143. return function () {};
  37144. }
  37145. var active = document.activeElement;
  37146. var ranges = [];
  37147. for (var i = 0; i < selection.rangeCount; i++) {
  37148. ranges.push(selection.getRangeAt(i));
  37149. }
  37150. switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML
  37151. case 'INPUT':
  37152. case 'TEXTAREA':
  37153. active.blur();
  37154. break;
  37155. default:
  37156. active = null;
  37157. break;
  37158. }
  37159. selection.removeAllRanges();
  37160. return function () {
  37161. selection.type === 'Caret' &&
  37162. selection.removeAllRanges();
  37163. if (!selection.rangeCount) {
  37164. ranges.forEach(function(range) {
  37165. selection.addRange(range);
  37166. });
  37167. }
  37168. active &&
  37169. active.focus();
  37170. };
  37171. };
  37172. },{}],208:[function(require,module,exports){
  37173. module.exports=/[\0-\x1F\x7F-\x9F]/
  37174. },{}],209:[function(require,module,exports){
  37175. module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/
  37176. },{}],210:[function(require,module,exports){
  37177. module.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/
  37178. },{}],211:[function(require,module,exports){
  37179. module.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
  37180. },{}],212:[function(require,module,exports){
  37181. 'use strict';
  37182. exports.Any = require('./properties/Any/regex');
  37183. exports.Cc = require('./categories/Cc/regex');
  37184. exports.Cf = require('./categories/Cf/regex');
  37185. exports.P = require('./categories/P/regex');
  37186. exports.Z = require('./categories/Z/regex');
  37187. },{"./categories/Cc/regex":208,"./categories/Cf/regex":209,"./categories/P/regex":210,"./categories/Z/regex":211,"./properties/Any/regex":213}],213:[function(require,module,exports){
  37188. module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
  37189. },{}],214:[function(require,module,exports){
  37190. if (typeof Object.create === 'function') {
  37191. // implementation from standard node.js 'util' module
  37192. module.exports = function inherits(ctor, superCtor) {
  37193. ctor.super_ = superCtor
  37194. ctor.prototype = Object.create(superCtor.prototype, {
  37195. constructor: {
  37196. value: ctor,
  37197. enumerable: false,
  37198. writable: true,
  37199. configurable: true
  37200. }
  37201. });
  37202. };
  37203. } else {
  37204. // old school shim for old browsers
  37205. module.exports = function inherits(ctor, superCtor) {
  37206. ctor.super_ = superCtor
  37207. var TempCtor = function () {}
  37208. TempCtor.prototype = superCtor.prototype
  37209. ctor.prototype = new TempCtor()
  37210. ctor.prototype.constructor = ctor
  37211. }
  37212. }
  37213. },{}],215:[function(require,module,exports){
  37214. module.exports = function isBuffer(arg) {
  37215. return arg && typeof arg === 'object'
  37216. && typeof arg.copy === 'function'
  37217. && typeof arg.fill === 'function'
  37218. && typeof arg.readUInt8 === 'function';
  37219. }
  37220. },{}],216:[function(require,module,exports){
  37221. (function (process,global){
  37222. // Copyright Joyent, Inc. and other Node contributors.
  37223. //
  37224. // Permission is hereby granted, free of charge, to any person obtaining a
  37225. // copy of this software and associated documentation files (the
  37226. // "Software"), to deal in the Software without restriction, including
  37227. // without limitation the rights to use, copy, modify, merge, publish,
  37228. // distribute, sublicense, and/or sell copies of the Software, and to permit
  37229. // persons to whom the Software is furnished to do so, subject to the
  37230. // following conditions:
  37231. //
  37232. // The above copyright notice and this permission notice shall be included
  37233. // in all copies or substantial portions of the Software.
  37234. //
  37235. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  37236. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  37237. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  37238. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  37239. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  37240. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  37241. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  37242. var formatRegExp = /%[sdj%]/g;
  37243. exports.format = function(f) {
  37244. if (!isString(f)) {
  37245. var objects = [];
  37246. for (var i = 0; i < arguments.length; i++) {
  37247. objects.push(inspect(arguments[i]));
  37248. }
  37249. return objects.join(' ');
  37250. }
  37251. var i = 1;
  37252. var args = arguments;
  37253. var len = args.length;
  37254. var str = String(f).replace(formatRegExp, function(x) {
  37255. if (x === '%%') return '%';
  37256. if (i >= len) return x;
  37257. switch (x) {
  37258. case '%s': return String(args[i++]);
  37259. case '%d': return Number(args[i++]);
  37260. case '%j':
  37261. try {
  37262. return JSON.stringify(args[i++]);
  37263. } catch (_) {
  37264. return '[Circular]';
  37265. }
  37266. default:
  37267. return x;
  37268. }
  37269. });
  37270. for (var x = args[i]; i < len; x = args[++i]) {
  37271. if (isNull(x) || !isObject(x)) {
  37272. str += ' ' + x;
  37273. } else {
  37274. str += ' ' + inspect(x);
  37275. }
  37276. }
  37277. return str;
  37278. };
  37279. // Mark that a method should not be used.
  37280. // Returns a modified function which warns once by default.
  37281. // If --no-deprecation is set, then it is a no-op.
  37282. exports.deprecate = function(fn, msg) {
  37283. // Allow for deprecating things in the process of starting up.
  37284. if (isUndefined(global.process)) {
  37285. return function() {
  37286. return exports.deprecate(fn, msg).apply(this, arguments);
  37287. };
  37288. }
  37289. if (process.noDeprecation === true) {
  37290. return fn;
  37291. }
  37292. var warned = false;
  37293. function deprecated() {
  37294. if (!warned) {
  37295. if (process.throwDeprecation) {
  37296. throw new Error(msg);
  37297. } else if (process.traceDeprecation) {
  37298. console.trace(msg);
  37299. } else {
  37300. console.error(msg);
  37301. }
  37302. warned = true;
  37303. }
  37304. return fn.apply(this, arguments);
  37305. }
  37306. return deprecated;
  37307. };
  37308. var debugs = {};
  37309. var debugEnviron;
  37310. exports.debuglog = function(set) {
  37311. if (isUndefined(debugEnviron))
  37312. debugEnviron = process.env.NODE_DEBUG || '';
  37313. set = set.toUpperCase();
  37314. if (!debugs[set]) {
  37315. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  37316. var pid = process.pid;
  37317. debugs[set] = function() {
  37318. var msg = exports.format.apply(exports, arguments);
  37319. console.error('%s %d: %s', set, pid, msg);
  37320. };
  37321. } else {
  37322. debugs[set] = function() {};
  37323. }
  37324. }
  37325. return debugs[set];
  37326. };
  37327. /**
  37328. * Echos the value of a value. Trys to print the value out
  37329. * in the best way possible given the different types.
  37330. *
  37331. * @param {Object} obj The object to print out.
  37332. * @param {Object} opts Optional options object that alters the output.
  37333. */
  37334. /* legacy: obj, showHidden, depth, colors*/
  37335. function inspect(obj, opts) {
  37336. // default options
  37337. var ctx = {
  37338. seen: [],
  37339. stylize: stylizeNoColor
  37340. };
  37341. // legacy...
  37342. if (arguments.length >= 3) ctx.depth = arguments[2];
  37343. if (arguments.length >= 4) ctx.colors = arguments[3];
  37344. if (isBoolean(opts)) {
  37345. // legacy...
  37346. ctx.showHidden = opts;
  37347. } else if (opts) {
  37348. // got an "options" object
  37349. exports._extend(ctx, opts);
  37350. }
  37351. // set default options
  37352. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  37353. if (isUndefined(ctx.depth)) ctx.depth = 2;
  37354. if (isUndefined(ctx.colors)) ctx.colors = false;
  37355. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  37356. if (ctx.colors) ctx.stylize = stylizeWithColor;
  37357. return formatValue(ctx, obj, ctx.depth);
  37358. }
  37359. exports.inspect = inspect;
  37360. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  37361. inspect.colors = {
  37362. 'bold' : [1, 22],
  37363. 'italic' : [3, 23],
  37364. 'underline' : [4, 24],
  37365. 'inverse' : [7, 27],
  37366. 'white' : [37, 39],
  37367. 'grey' : [90, 39],
  37368. 'black' : [30, 39],
  37369. 'blue' : [34, 39],
  37370. 'cyan' : [36, 39],
  37371. 'green' : [32, 39],
  37372. 'magenta' : [35, 39],
  37373. 'red' : [31, 39],
  37374. 'yellow' : [33, 39]
  37375. };
  37376. // Don't use 'blue' not visible on cmd.exe
  37377. inspect.styles = {
  37378. 'special': 'cyan',
  37379. 'number': 'yellow',
  37380. 'boolean': 'yellow',
  37381. 'undefined': 'grey',
  37382. 'null': 'bold',
  37383. 'string': 'green',
  37384. 'date': 'magenta',
  37385. // "name": intentionally not styling
  37386. 'regexp': 'red'
  37387. };
  37388. function stylizeWithColor(str, styleType) {
  37389. var style = inspect.styles[styleType];
  37390. if (style) {
  37391. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  37392. '\u001b[' + inspect.colors[style][1] + 'm';
  37393. } else {
  37394. return str;
  37395. }
  37396. }
  37397. function stylizeNoColor(str, styleType) {
  37398. return str;
  37399. }
  37400. function arrayToHash(array) {
  37401. var hash = {};
  37402. array.forEach(function(val, idx) {
  37403. hash[val] = true;
  37404. });
  37405. return hash;
  37406. }
  37407. function formatValue(ctx, value, recurseTimes) {
  37408. // Provide a hook for user-specified inspect functions.
  37409. // Check that value is an object with an inspect function on it
  37410. if (ctx.customInspect &&
  37411. value &&
  37412. isFunction(value.inspect) &&
  37413. // Filter out the util module, it's inspect function is special
  37414. value.inspect !== exports.inspect &&
  37415. // Also filter out any prototype objects using the circular check.
  37416. !(value.constructor && value.constructor.prototype === value)) {
  37417. var ret = value.inspect(recurseTimes, ctx);
  37418. if (!isString(ret)) {
  37419. ret = formatValue(ctx, ret, recurseTimes);
  37420. }
  37421. return ret;
  37422. }
  37423. // Primitive types cannot have properties
  37424. var primitive = formatPrimitive(ctx, value);
  37425. if (primitive) {
  37426. return primitive;
  37427. }
  37428. // Look up the keys of the object.
  37429. var keys = Object.keys(value);
  37430. var visibleKeys = arrayToHash(keys);
  37431. if (ctx.showHidden) {
  37432. keys = Object.getOwnPropertyNames(value);
  37433. }
  37434. // IE doesn't make error fields non-enumerable
  37435. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  37436. if (isError(value)
  37437. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  37438. return formatError(value);
  37439. }
  37440. // Some type of object without properties can be shortcutted.
  37441. if (keys.length === 0) {
  37442. if (isFunction(value)) {
  37443. var name = value.name ? ': ' + value.name : '';
  37444. return ctx.stylize('[Function' + name + ']', 'special');
  37445. }
  37446. if (isRegExp(value)) {
  37447. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  37448. }
  37449. if (isDate(value)) {
  37450. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  37451. }
  37452. if (isError(value)) {
  37453. return formatError(value);
  37454. }
  37455. }
  37456. var base = '', array = false, braces = ['{', '}'];
  37457. // Make Array say that they are Array
  37458. if (isArray(value)) {
  37459. array = true;
  37460. braces = ['[', ']'];
  37461. }
  37462. // Make functions say that they are functions
  37463. if (isFunction(value)) {
  37464. var n = value.name ? ': ' + value.name : '';
  37465. base = ' [Function' + n + ']';
  37466. }
  37467. // Make RegExps say that they are RegExps
  37468. if (isRegExp(value)) {
  37469. base = ' ' + RegExp.prototype.toString.call(value);
  37470. }
  37471. // Make dates with properties first say the date
  37472. if (isDate(value)) {
  37473. base = ' ' + Date.prototype.toUTCString.call(value);
  37474. }
  37475. // Make error with message first say the error
  37476. if (isError(value)) {
  37477. base = ' ' + formatError(value);
  37478. }
  37479. if (keys.length === 0 && (!array || value.length == 0)) {
  37480. return braces[0] + base + braces[1];
  37481. }
  37482. if (recurseTimes < 0) {
  37483. if (isRegExp(value)) {
  37484. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  37485. } else {
  37486. return ctx.stylize('[Object]', 'special');
  37487. }
  37488. }
  37489. ctx.seen.push(value);
  37490. var output;
  37491. if (array) {
  37492. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  37493. } else {
  37494. output = keys.map(function(key) {
  37495. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  37496. });
  37497. }
  37498. ctx.seen.pop();
  37499. return reduceToSingleString(output, base, braces);
  37500. }
  37501. function formatPrimitive(ctx, value) {
  37502. if (isUndefined(value))
  37503. return ctx.stylize('undefined', 'undefined');
  37504. if (isString(value)) {
  37505. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  37506. .replace(/'/g, "\\'")
  37507. .replace(/\\"/g, '"') + '\'';
  37508. return ctx.stylize(simple, 'string');
  37509. }
  37510. if (isNumber(value))
  37511. return ctx.stylize('' + value, 'number');
  37512. if (isBoolean(value))
  37513. return ctx.stylize('' + value, 'boolean');
  37514. // For some reason typeof null is "object", so special case here.
  37515. if (isNull(value))
  37516. return ctx.stylize('null', 'null');
  37517. }
  37518. function formatError(value) {
  37519. return '[' + Error.prototype.toString.call(value) + ']';
  37520. }
  37521. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  37522. var output = [];
  37523. for (var i = 0, l = value.length; i < l; ++i) {
  37524. if (hasOwnProperty(value, String(i))) {
  37525. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  37526. String(i), true));
  37527. } else {
  37528. output.push('');
  37529. }
  37530. }
  37531. keys.forEach(function(key) {
  37532. if (!key.match(/^\d+$/)) {
  37533. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  37534. key, true));
  37535. }
  37536. });
  37537. return output;
  37538. }
  37539. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  37540. var name, str, desc;
  37541. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  37542. if (desc.get) {
  37543. if (desc.set) {
  37544. str = ctx.stylize('[Getter/Setter]', 'special');
  37545. } else {
  37546. str = ctx.stylize('[Getter]', 'special');
  37547. }
  37548. } else {
  37549. if (desc.set) {
  37550. str = ctx.stylize('[Setter]', 'special');
  37551. }
  37552. }
  37553. if (!hasOwnProperty(visibleKeys, key)) {
  37554. name = '[' + key + ']';
  37555. }
  37556. if (!str) {
  37557. if (ctx.seen.indexOf(desc.value) < 0) {
  37558. if (isNull(recurseTimes)) {
  37559. str = formatValue(ctx, desc.value, null);
  37560. } else {
  37561. str = formatValue(ctx, desc.value, recurseTimes - 1);
  37562. }
  37563. if (str.indexOf('\n') > -1) {
  37564. if (array) {
  37565. str = str.split('\n').map(function(line) {
  37566. return ' ' + line;
  37567. }).join('\n').substr(2);
  37568. } else {
  37569. str = '\n' + str.split('\n').map(function(line) {
  37570. return ' ' + line;
  37571. }).join('\n');
  37572. }
  37573. }
  37574. } else {
  37575. str = ctx.stylize('[Circular]', 'special');
  37576. }
  37577. }
  37578. if (isUndefined(name)) {
  37579. if (array && key.match(/^\d+$/)) {
  37580. return str;
  37581. }
  37582. name = JSON.stringify('' + key);
  37583. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  37584. name = name.substr(1, name.length - 2);
  37585. name = ctx.stylize(name, 'name');
  37586. } else {
  37587. name = name.replace(/'/g, "\\'")
  37588. .replace(/\\"/g, '"')
  37589. .replace(/(^"|"$)/g, "'");
  37590. name = ctx.stylize(name, 'string');
  37591. }
  37592. }
  37593. return name + ': ' + str;
  37594. }
  37595. function reduceToSingleString(output, base, braces) {
  37596. var numLinesEst = 0;
  37597. var length = output.reduce(function(prev, cur) {
  37598. numLinesEst++;
  37599. if (cur.indexOf('\n') >= 0) numLinesEst++;
  37600. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  37601. }, 0);
  37602. if (length > 60) {
  37603. return braces[0] +
  37604. (base === '' ? '' : base + '\n ') +
  37605. ' ' +
  37606. output.join(',\n ') +
  37607. ' ' +
  37608. braces[1];
  37609. }
  37610. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  37611. }
  37612. // NOTE: These type checking functions intentionally don't use `instanceof`
  37613. // because it is fragile and can be easily faked with `Object.create()`.
  37614. function isArray(ar) {
  37615. return Array.isArray(ar);
  37616. }
  37617. exports.isArray = isArray;
  37618. function isBoolean(arg) {
  37619. return typeof arg === 'boolean';
  37620. }
  37621. exports.isBoolean = isBoolean;
  37622. function isNull(arg) {
  37623. return arg === null;
  37624. }
  37625. exports.isNull = isNull;
  37626. function isNullOrUndefined(arg) {
  37627. return arg == null;
  37628. }
  37629. exports.isNullOrUndefined = isNullOrUndefined;
  37630. function isNumber(arg) {
  37631. return typeof arg === 'number';
  37632. }
  37633. exports.isNumber = isNumber;
  37634. function isString(arg) {
  37635. return typeof arg === 'string';
  37636. }
  37637. exports.isString = isString;
  37638. function isSymbol(arg) {
  37639. return typeof arg === 'symbol';
  37640. }
  37641. exports.isSymbol = isSymbol;
  37642. function isUndefined(arg) {
  37643. return arg === void 0;
  37644. }
  37645. exports.isUndefined = isUndefined;
  37646. function isRegExp(re) {
  37647. return isObject(re) && objectToString(re) === '[object RegExp]';
  37648. }
  37649. exports.isRegExp = isRegExp;
  37650. function isObject(arg) {
  37651. return typeof arg === 'object' && arg !== null;
  37652. }
  37653. exports.isObject = isObject;
  37654. function isDate(d) {
  37655. return isObject(d) && objectToString(d) === '[object Date]';
  37656. }
  37657. exports.isDate = isDate;
  37658. function isError(e) {
  37659. return isObject(e) &&
  37660. (objectToString(e) === '[object Error]' || e instanceof Error);
  37661. }
  37662. exports.isError = isError;
  37663. function isFunction(arg) {
  37664. return typeof arg === 'function';
  37665. }
  37666. exports.isFunction = isFunction;
  37667. function isPrimitive(arg) {
  37668. return arg === null ||
  37669. typeof arg === 'boolean' ||
  37670. typeof arg === 'number' ||
  37671. typeof arg === 'string' ||
  37672. typeof arg === 'symbol' || // ES6 symbol
  37673. typeof arg === 'undefined';
  37674. }
  37675. exports.isPrimitive = isPrimitive;
  37676. exports.isBuffer = require('./support/isBuffer');
  37677. function objectToString(o) {
  37678. return Object.prototype.toString.call(o);
  37679. }
  37680. function pad(n) {
  37681. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  37682. }
  37683. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  37684. 'Oct', 'Nov', 'Dec'];
  37685. // 26 Feb 16:19:34
  37686. function timestamp() {
  37687. var d = new Date();
  37688. var time = [pad(d.getHours()),
  37689. pad(d.getMinutes()),
  37690. pad(d.getSeconds())].join(':');
  37691. return [d.getDate(), months[d.getMonth()], time].join(' ');
  37692. }
  37693. // log is just a thin wrapper to console.log that prepends a timestamp
  37694. exports.log = function() {
  37695. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  37696. };
  37697. /**
  37698. * Inherit the prototype methods from one constructor into another.
  37699. *
  37700. * The Function.prototype.inherits from lang.js rewritten as a standalone
  37701. * function (not on Function.prototype). NOTE: If this file is to be loaded
  37702. * during bootstrapping this function needs to be rewritten using some native
  37703. * functions as prototype setup using normal JavaScript does not work as
  37704. * expected during bootstrapping (see mirror.js in r114903).
  37705. *
  37706. * @param {function} ctor Constructor function which needs to inherit the
  37707. * prototype.
  37708. * @param {function} superCtor Constructor function to inherit prototype from.
  37709. */
  37710. exports.inherits = require('inherits');
  37711. exports._extend = function(origin, add) {
  37712. // Don't do anything if add isn't an object
  37713. if (!add || !isObject(add)) return origin;
  37714. var keys = Object.keys(add);
  37715. var i = keys.length;
  37716. while (i--) {
  37717. origin[keys[i]] = add[keys[i]];
  37718. }
  37719. return origin;
  37720. };
  37721. function hasOwnProperty(obj, prop) {
  37722. return Object.prototype.hasOwnProperty.call(obj, prop);
  37723. }
  37724. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37725. },{"./support/isBuffer":215,"_process":198,"inherits":214}],217:[function(require,module,exports){
  37726. (function (global){
  37727. "use strict";
  37728. Object.defineProperty(exports, "__esModule", {
  37729. value: true
  37730. });
  37731. exports.DocExplorer = void 0;
  37732. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  37733. var _propTypes = _interopRequireDefault(require("prop-types"));
  37734. var _graphql = require("graphql");
  37735. var _FieldDoc = _interopRequireDefault(require("./DocExplorer/FieldDoc"));
  37736. var _SchemaDoc = _interopRequireDefault(require("./DocExplorer/SchemaDoc"));
  37737. var _SearchBox = _interopRequireDefault(require("./DocExplorer/SearchBox"));
  37738. var _SearchResults = _interopRequireDefault(require("./DocExplorer/SearchResults"));
  37739. var _TypeDoc = _interopRequireDefault(require("./DocExplorer/TypeDoc"));
  37740. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37741. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  37742. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  37743. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  37744. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  37745. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  37746. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  37747. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  37748. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  37749. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  37750. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  37751. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  37752. var initialNav = {
  37753. name: 'Schema',
  37754. title: 'Documentation Explorer'
  37755. };
  37756. /**
  37757. * DocExplorer
  37758. *
  37759. * Shows documentations for GraphQL definitions from the schema.
  37760. *
  37761. * Props:
  37762. *
  37763. * - schema: A required GraphQLSchema instance that provides GraphQL document
  37764. * definitions.
  37765. *
  37766. * Children:
  37767. *
  37768. * - Any provided children will be positioned in the right-hand-side of the
  37769. * top bar. Typically this will be a "close" button for temporary explorer.
  37770. *
  37771. */
  37772. var DocExplorer =
  37773. /*#__PURE__*/
  37774. function (_React$Component) {
  37775. _inherits(DocExplorer, _React$Component);
  37776. function DocExplorer() {
  37777. var _this;
  37778. _classCallCheck(this, DocExplorer);
  37779. _this = _possibleConstructorReturn(this, _getPrototypeOf(DocExplorer).call(this));
  37780. _defineProperty(_assertThisInitialized(_this), "handleNavBackClick", function () {
  37781. if (_this.state.navStack.length > 1) {
  37782. _this.setState({
  37783. navStack: _this.state.navStack.slice(0, -1)
  37784. });
  37785. }
  37786. });
  37787. _defineProperty(_assertThisInitialized(_this), "handleClickTypeOrField", function (typeOrField) {
  37788. _this.showDoc(typeOrField);
  37789. });
  37790. _defineProperty(_assertThisInitialized(_this), "handleSearch", function (value) {
  37791. _this.showSearch(value);
  37792. });
  37793. _this.state = {
  37794. navStack: [initialNav]
  37795. };
  37796. return _this;
  37797. }
  37798. _createClass(DocExplorer, [{
  37799. key: "shouldComponentUpdate",
  37800. value: function shouldComponentUpdate(nextProps, nextState) {
  37801. return this.props.schema !== nextProps.schema || this.state.navStack !== nextState.navStack;
  37802. }
  37803. }, {
  37804. key: "render",
  37805. value: function render() {
  37806. var schema = this.props.schema;
  37807. var navStack = this.state.navStack;
  37808. var navItem = navStack[navStack.length - 1];
  37809. var content;
  37810. if (schema === undefined) {
  37811. // Schema is undefined when it is being loaded via introspection.
  37812. content = _react.default.createElement("div", {
  37813. className: "spinner-container"
  37814. }, _react.default.createElement("div", {
  37815. className: "spinner"
  37816. }));
  37817. } else if (!schema) {
  37818. // Schema is null when it explicitly does not exist, typically due to
  37819. // an error during introspection.
  37820. content = _react.default.createElement("div", {
  37821. className: "error-container"
  37822. }, 'No Schema Available');
  37823. } else if (navItem.search) {
  37824. content = _react.default.createElement(_SearchResults.default, {
  37825. searchValue: navItem.search,
  37826. withinType: navItem.def,
  37827. schema: schema,
  37828. onClickType: this.handleClickTypeOrField,
  37829. onClickField: this.handleClickTypeOrField
  37830. });
  37831. } else if (navStack.length === 1) {
  37832. content = _react.default.createElement(_SchemaDoc.default, {
  37833. schema: schema,
  37834. onClickType: this.handleClickTypeOrField
  37835. });
  37836. } else if ((0, _graphql.isType)(navItem.def)) {
  37837. content = _react.default.createElement(_TypeDoc.default, {
  37838. schema: schema,
  37839. type: navItem.def,
  37840. onClickType: this.handleClickTypeOrField,
  37841. onClickField: this.handleClickTypeOrField
  37842. });
  37843. } else {
  37844. content = _react.default.createElement(_FieldDoc.default, {
  37845. field: navItem.def,
  37846. onClickType: this.handleClickTypeOrField
  37847. });
  37848. }
  37849. var shouldSearchBoxAppear = navStack.length === 1 || (0, _graphql.isType)(navItem.def) && navItem.def.getFields;
  37850. var prevName;
  37851. if (navStack.length > 1) {
  37852. prevName = navStack[navStack.length - 2].name;
  37853. }
  37854. return _react.default.createElement("div", {
  37855. className: "doc-explorer",
  37856. key: navItem.name
  37857. }, _react.default.createElement("div", {
  37858. className: "doc-explorer-title-bar"
  37859. }, prevName && _react.default.createElement("div", {
  37860. className: "doc-explorer-back",
  37861. onClick: this.handleNavBackClick
  37862. }, prevName), _react.default.createElement("div", {
  37863. className: "doc-explorer-title"
  37864. }, navItem.title || navItem.name), _react.default.createElement("div", {
  37865. className: "doc-explorer-rhs"
  37866. }, this.props.children)), _react.default.createElement("div", {
  37867. className: "doc-explorer-contents"
  37868. }, shouldSearchBoxAppear && _react.default.createElement(_SearchBox.default, {
  37869. value: navItem.search,
  37870. placeholder: "Search ".concat(navItem.name, "..."),
  37871. onSearch: this.handleSearch
  37872. }), content));
  37873. } // Public API
  37874. }, {
  37875. key: "showDoc",
  37876. value: function showDoc(typeOrField) {
  37877. var navStack = this.state.navStack;
  37878. var topNav = navStack[navStack.length - 1];
  37879. if (topNav.def !== typeOrField) {
  37880. this.setState({
  37881. navStack: navStack.concat([{
  37882. name: typeOrField.name,
  37883. def: typeOrField
  37884. }])
  37885. });
  37886. }
  37887. } // Public API
  37888. }, {
  37889. key: "showDocForReference",
  37890. value: function showDocForReference(reference) {
  37891. if (reference.kind === 'Type') {
  37892. this.showDoc(reference.type);
  37893. } else if (reference.kind === 'Field') {
  37894. this.showDoc(reference.field);
  37895. } else if (reference.kind === 'Argument' && reference.field) {
  37896. this.showDoc(reference.field);
  37897. } else if (reference.kind === 'EnumValue' && reference.type) {
  37898. this.showDoc(reference.type);
  37899. }
  37900. } // Public API
  37901. }, {
  37902. key: "showSearch",
  37903. value: function showSearch(search) {
  37904. var navStack = this.state.navStack.slice();
  37905. var topNav = navStack[navStack.length - 1];
  37906. navStack[navStack.length - 1] = _objectSpread({}, topNav, {
  37907. search: search
  37908. });
  37909. this.setState({
  37910. navStack: navStack
  37911. });
  37912. }
  37913. }, {
  37914. key: "reset",
  37915. value: function reset() {
  37916. this.setState({
  37917. navStack: [initialNav]
  37918. });
  37919. }
  37920. }]);
  37921. return DocExplorer;
  37922. }(_react.default.Component);
  37923. exports.DocExplorer = DocExplorer;
  37924. _defineProperty(DocExplorer, "propTypes", {
  37925. schema: _propTypes.default.instanceOf(_graphql.GraphQLSchema)
  37926. });
  37927. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37928. },{"./DocExplorer/FieldDoc":220,"./DocExplorer/SchemaDoc":222,"./DocExplorer/SearchBox":223,"./DocExplorer/SearchResults":224,"./DocExplorer/TypeDoc":225,"graphql":29,"prop-types":202}],218:[function(require,module,exports){
  37929. (function (global){
  37930. "use strict";
  37931. Object.defineProperty(exports, "__esModule", {
  37932. value: true
  37933. });
  37934. exports.default = Argument;
  37935. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  37936. var _propTypes = _interopRequireDefault(require("prop-types"));
  37937. var _TypeLink = _interopRequireDefault(require("./TypeLink"));
  37938. var _DefaultValue = _interopRequireDefault(require("./DefaultValue"));
  37939. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37940. /**
  37941. * Copyright (c) 2019 GraphQL Contributors.
  37942. *
  37943. * This source code is licensed under the MIT license found in the
  37944. * LICENSE file in the root directory of this source tree.
  37945. */
  37946. function Argument(_ref) {
  37947. var arg = _ref.arg,
  37948. onClickType = _ref.onClickType,
  37949. showDefaultValue = _ref.showDefaultValue;
  37950. return _react.default.createElement("span", {
  37951. className: "arg"
  37952. }, _react.default.createElement("span", {
  37953. className: "arg-name"
  37954. }, arg.name), ': ', _react.default.createElement(_TypeLink.default, {
  37955. type: arg.type,
  37956. onClick: onClickType
  37957. }), showDefaultValue !== false && _react.default.createElement(_DefaultValue.default, {
  37958. field: arg
  37959. }));
  37960. }
  37961. Argument.propTypes = {
  37962. arg: _propTypes.default.object.isRequired,
  37963. onClickType: _propTypes.default.func.isRequired,
  37964. showDefaultValue: _propTypes.default.bool
  37965. };
  37966. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37967. },{"./DefaultValue":219,"./TypeLink":226,"prop-types":202}],219:[function(require,module,exports){
  37968. (function (global){
  37969. "use strict";
  37970. Object.defineProperty(exports, "__esModule", {
  37971. value: true
  37972. });
  37973. exports.default = DefaultValue;
  37974. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  37975. var _propTypes = _interopRequireDefault(require("prop-types"));
  37976. var _graphql = require("graphql");
  37977. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37978. /**
  37979. * Copyright (c) 2019 GraphQL Contributors.
  37980. *
  37981. * This source code is licensed under the MIT license found in the
  37982. * LICENSE file in the root directory of this source tree.
  37983. */
  37984. function DefaultValue(_ref) {
  37985. var field = _ref.field;
  37986. var type = field.type,
  37987. defaultValue = field.defaultValue;
  37988. if (defaultValue !== undefined) {
  37989. return _react.default.createElement("span", null, ' = ', _react.default.createElement("span", {
  37990. className: "arg-default-value"
  37991. }, (0, _graphql.print)((0, _graphql.astFromValue)(defaultValue, type))));
  37992. }
  37993. return null;
  37994. }
  37995. DefaultValue.propTypes = {
  37996. field: _propTypes.default.object.isRequired
  37997. };
  37998. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  37999. },{"graphql":29,"prop-types":202}],220:[function(require,module,exports){
  38000. (function (global){
  38001. "use strict";
  38002. Object.defineProperty(exports, "__esModule", {
  38003. value: true
  38004. });
  38005. exports.default = void 0;
  38006. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38007. var _propTypes = _interopRequireDefault(require("prop-types"));
  38008. var _Argument = _interopRequireDefault(require("./Argument"));
  38009. var _MarkdownContent = _interopRequireDefault(require("./MarkdownContent"));
  38010. var _TypeLink = _interopRequireDefault(require("./TypeLink"));
  38011. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38012. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38013. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38014. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38015. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38016. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38017. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38018. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38019. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38020. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38021. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38022. var FieldDoc =
  38023. /*#__PURE__*/
  38024. function (_React$Component) {
  38025. _inherits(FieldDoc, _React$Component);
  38026. function FieldDoc() {
  38027. _classCallCheck(this, FieldDoc);
  38028. return _possibleConstructorReturn(this, _getPrototypeOf(FieldDoc).apply(this, arguments));
  38029. }
  38030. _createClass(FieldDoc, [{
  38031. key: "shouldComponentUpdate",
  38032. value: function shouldComponentUpdate(nextProps) {
  38033. return this.props.field !== nextProps.field;
  38034. }
  38035. }, {
  38036. key: "render",
  38037. value: function render() {
  38038. var _this = this;
  38039. var field = this.props.field;
  38040. var argsDef;
  38041. if (field.args && field.args.length > 0) {
  38042. argsDef = _react.default.createElement("div", {
  38043. className: "doc-category"
  38044. }, _react.default.createElement("div", {
  38045. className: "doc-category-title"
  38046. }, 'arguments'), field.args.map(function (arg) {
  38047. return _react.default.createElement("div", {
  38048. key: arg.name,
  38049. className: "doc-category-item"
  38050. }, _react.default.createElement("div", null, _react.default.createElement(_Argument.default, {
  38051. arg: arg,
  38052. onClickType: _this.props.onClickType
  38053. })), _react.default.createElement(_MarkdownContent.default, {
  38054. className: "doc-value-description",
  38055. markdown: arg.description
  38056. }));
  38057. }));
  38058. }
  38059. return _react.default.createElement("div", null, _react.default.createElement(_MarkdownContent.default, {
  38060. className: "doc-type-description",
  38061. markdown: field.description || 'No Description'
  38062. }), field.deprecationReason && _react.default.createElement(_MarkdownContent.default, {
  38063. className: "doc-deprecation",
  38064. markdown: field.deprecationReason
  38065. }), _react.default.createElement("div", {
  38066. className: "doc-category"
  38067. }, _react.default.createElement("div", {
  38068. className: "doc-category-title"
  38069. }, 'type'), _react.default.createElement(_TypeLink.default, {
  38070. type: field.type,
  38071. onClick: this.props.onClickType
  38072. })), argsDef);
  38073. }
  38074. }]);
  38075. return FieldDoc;
  38076. }(_react.default.Component);
  38077. exports.default = FieldDoc;
  38078. _defineProperty(FieldDoc, "propTypes", {
  38079. field: _propTypes.default.object,
  38080. onClickType: _propTypes.default.func
  38081. });
  38082. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38083. },{"./Argument":218,"./MarkdownContent":221,"./TypeLink":226,"prop-types":202}],221:[function(require,module,exports){
  38084. (function (global){
  38085. "use strict";
  38086. Object.defineProperty(exports, "__esModule", {
  38087. value: true
  38088. });
  38089. exports.default = void 0;
  38090. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38091. var _propTypes = _interopRequireDefault(require("prop-types"));
  38092. var _markdownIt = _interopRequireDefault(require("markdown-it"));
  38093. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38094. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38095. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38096. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38097. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38098. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38099. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38100. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38101. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38102. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38103. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38104. var md = new _markdownIt.default();
  38105. var MarkdownContent =
  38106. /*#__PURE__*/
  38107. function (_React$Component) {
  38108. _inherits(MarkdownContent, _React$Component);
  38109. function MarkdownContent() {
  38110. _classCallCheck(this, MarkdownContent);
  38111. return _possibleConstructorReturn(this, _getPrototypeOf(MarkdownContent).apply(this, arguments));
  38112. }
  38113. _createClass(MarkdownContent, [{
  38114. key: "shouldComponentUpdate",
  38115. value: function shouldComponentUpdate(nextProps) {
  38116. return this.props.markdown !== nextProps.markdown;
  38117. }
  38118. }, {
  38119. key: "render",
  38120. value: function render() {
  38121. var markdown = this.props.markdown;
  38122. if (!markdown) {
  38123. return _react.default.createElement("div", null);
  38124. }
  38125. return _react.default.createElement("div", {
  38126. className: this.props.className,
  38127. dangerouslySetInnerHTML: {
  38128. __html: md.render(markdown)
  38129. }
  38130. });
  38131. }
  38132. }]);
  38133. return MarkdownContent;
  38134. }(_react.default.Component);
  38135. exports.default = MarkdownContent;
  38136. _defineProperty(MarkdownContent, "propTypes", {
  38137. markdown: _propTypes.default.string,
  38138. className: _propTypes.default.string
  38139. });
  38140. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38141. },{"markdown-it":140,"prop-types":202}],222:[function(require,module,exports){
  38142. (function (global){
  38143. "use strict";
  38144. Object.defineProperty(exports, "__esModule", {
  38145. value: true
  38146. });
  38147. exports.default = void 0;
  38148. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38149. var _propTypes = _interopRequireDefault(require("prop-types"));
  38150. var _TypeLink = _interopRequireDefault(require("./TypeLink"));
  38151. var _MarkdownContent = _interopRequireDefault(require("./MarkdownContent"));
  38152. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38153. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38154. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38155. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38156. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38157. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38158. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38159. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38160. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38161. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38162. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38163. // Render the top level Schema
  38164. var SchemaDoc =
  38165. /*#__PURE__*/
  38166. function (_React$Component) {
  38167. _inherits(SchemaDoc, _React$Component);
  38168. function SchemaDoc() {
  38169. _classCallCheck(this, SchemaDoc);
  38170. return _possibleConstructorReturn(this, _getPrototypeOf(SchemaDoc).apply(this, arguments));
  38171. }
  38172. _createClass(SchemaDoc, [{
  38173. key: "shouldComponentUpdate",
  38174. value: function shouldComponentUpdate(nextProps) {
  38175. return this.props.schema !== nextProps.schema;
  38176. }
  38177. }, {
  38178. key: "render",
  38179. value: function render() {
  38180. var schema = this.props.schema;
  38181. var queryType = schema.getQueryType();
  38182. var mutationType = schema.getMutationType && schema.getMutationType();
  38183. var subscriptionType = schema.getSubscriptionType && schema.getSubscriptionType();
  38184. return _react.default.createElement("div", null, _react.default.createElement(_MarkdownContent.default, {
  38185. className: "doc-type-description",
  38186. markdown: 'A GraphQL schema provides a root type for each kind of operation.'
  38187. }), _react.default.createElement("div", {
  38188. className: "doc-category"
  38189. }, _react.default.createElement("div", {
  38190. className: "doc-category-title"
  38191. }, 'root types'), _react.default.createElement("div", {
  38192. className: "doc-category-item"
  38193. }, _react.default.createElement("span", {
  38194. className: "keyword"
  38195. }, 'query'), ': ', _react.default.createElement(_TypeLink.default, {
  38196. type: queryType,
  38197. onClick: this.props.onClickType
  38198. })), mutationType && _react.default.createElement("div", {
  38199. className: "doc-category-item"
  38200. }, _react.default.createElement("span", {
  38201. className: "keyword"
  38202. }, 'mutation'), ': ', _react.default.createElement(_TypeLink.default, {
  38203. type: mutationType,
  38204. onClick: this.props.onClickType
  38205. })), subscriptionType && _react.default.createElement("div", {
  38206. className: "doc-category-item"
  38207. }, _react.default.createElement("span", {
  38208. className: "keyword"
  38209. }, 'subscription'), ': ', _react.default.createElement(_TypeLink.default, {
  38210. type: subscriptionType,
  38211. onClick: this.props.onClickType
  38212. }))));
  38213. }
  38214. }]);
  38215. return SchemaDoc;
  38216. }(_react.default.Component);
  38217. exports.default = SchemaDoc;
  38218. _defineProperty(SchemaDoc, "propTypes", {
  38219. schema: _propTypes.default.object,
  38220. onClickType: _propTypes.default.func
  38221. });
  38222. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38223. },{"./MarkdownContent":221,"./TypeLink":226,"prop-types":202}],223:[function(require,module,exports){
  38224. (function (global){
  38225. "use strict";
  38226. Object.defineProperty(exports, "__esModule", {
  38227. value: true
  38228. });
  38229. exports.default = void 0;
  38230. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38231. var _propTypes = _interopRequireDefault(require("prop-types"));
  38232. var _debounce = _interopRequireDefault(require("../../utility/debounce"));
  38233. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38234. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38235. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38236. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38237. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38238. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38239. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38240. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38241. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38242. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38243. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38244. var SearchBox =
  38245. /*#__PURE__*/
  38246. function (_React$Component) {
  38247. _inherits(SearchBox, _React$Component);
  38248. function SearchBox(props) {
  38249. var _this;
  38250. _classCallCheck(this, SearchBox);
  38251. _this = _possibleConstructorReturn(this, _getPrototypeOf(SearchBox).call(this, props));
  38252. _defineProperty(_assertThisInitialized(_this), "handleChange", function (event) {
  38253. var value = event.target.value;
  38254. _this.setState({
  38255. value: value
  38256. });
  38257. _this.debouncedOnSearch(value);
  38258. });
  38259. _defineProperty(_assertThisInitialized(_this), "handleClear", function () {
  38260. _this.setState({
  38261. value: ''
  38262. });
  38263. _this.props.onSearch('');
  38264. });
  38265. _this.state = {
  38266. value: props.value || ''
  38267. };
  38268. _this.debouncedOnSearch = (0, _debounce.default)(200, _this.props.onSearch);
  38269. return _this;
  38270. }
  38271. _createClass(SearchBox, [{
  38272. key: "render",
  38273. value: function render() {
  38274. return _react.default.createElement("label", {
  38275. className: "search-box"
  38276. }, _react.default.createElement("input", {
  38277. value: this.state.value,
  38278. onChange: this.handleChange,
  38279. type: "text",
  38280. placeholder: this.props.placeholder
  38281. }), this.state.value && _react.default.createElement("div", {
  38282. className: "search-box-clear",
  38283. onClick: this.handleClear
  38284. }, "\u2715"));
  38285. }
  38286. }]);
  38287. return SearchBox;
  38288. }(_react.default.Component);
  38289. exports.default = SearchBox;
  38290. _defineProperty(SearchBox, "propTypes", {
  38291. value: _propTypes.default.string,
  38292. placeholder: _propTypes.default.string,
  38293. onSearch: _propTypes.default.func
  38294. });
  38295. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38296. },{"../../utility/debounce":243,"prop-types":202}],224:[function(require,module,exports){
  38297. (function (global){
  38298. "use strict";
  38299. Object.defineProperty(exports, "__esModule", {
  38300. value: true
  38301. });
  38302. exports.default = void 0;
  38303. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38304. var _propTypes = _interopRequireDefault(require("prop-types"));
  38305. var _Argument = _interopRequireDefault(require("./Argument"));
  38306. var _TypeLink = _interopRequireDefault(require("./TypeLink"));
  38307. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38308. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38309. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38310. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38311. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38312. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38313. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38314. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38315. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38316. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38317. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38318. var SearchResults =
  38319. /*#__PURE__*/
  38320. function (_React$Component) {
  38321. _inherits(SearchResults, _React$Component);
  38322. function SearchResults() {
  38323. _classCallCheck(this, SearchResults);
  38324. return _possibleConstructorReturn(this, _getPrototypeOf(SearchResults).apply(this, arguments));
  38325. }
  38326. _createClass(SearchResults, [{
  38327. key: "shouldComponentUpdate",
  38328. value: function shouldComponentUpdate(nextProps) {
  38329. return this.props.schema !== nextProps.schema || this.props.searchValue !== nextProps.searchValue;
  38330. }
  38331. }, {
  38332. key: "render",
  38333. value: function render() {
  38334. var searchValue = this.props.searchValue;
  38335. var withinType = this.props.withinType;
  38336. var schema = this.props.schema;
  38337. var onClickType = this.props.onClickType;
  38338. var onClickField = this.props.onClickField;
  38339. var matchedWithin = [];
  38340. var matchedTypes = [];
  38341. var matchedFields = [];
  38342. var typeMap = schema.getTypeMap();
  38343. var typeNames = Object.keys(typeMap); // Move the within type name to be the first searched.
  38344. if (withinType) {
  38345. typeNames = typeNames.filter(function (n) {
  38346. return n !== withinType.name;
  38347. });
  38348. typeNames.unshift(withinType.name);
  38349. }
  38350. var _iteratorNormalCompletion = true;
  38351. var _didIteratorError = false;
  38352. var _iteratorError = undefined;
  38353. try {
  38354. var _loop = function _loop() {
  38355. var typeName = _step.value;
  38356. if (matchedWithin.length + matchedTypes.length + matchedFields.length >= 100) {
  38357. return "break";
  38358. }
  38359. var type = typeMap[typeName];
  38360. if (withinType !== type && isMatch(typeName, searchValue)) {
  38361. matchedTypes.push(_react.default.createElement("div", {
  38362. className: "doc-category-item",
  38363. key: typeName
  38364. }, _react.default.createElement(_TypeLink.default, {
  38365. type: type,
  38366. onClick: onClickType
  38367. })));
  38368. }
  38369. if (type.getFields) {
  38370. var fields = type.getFields();
  38371. Object.keys(fields).forEach(function (fieldName) {
  38372. var field = fields[fieldName];
  38373. var matchingArgs;
  38374. if (!isMatch(fieldName, searchValue)) {
  38375. if (field.args && field.args.length) {
  38376. matchingArgs = field.args.filter(function (arg) {
  38377. return isMatch(arg.name, searchValue);
  38378. });
  38379. if (matchingArgs.length === 0) {
  38380. return;
  38381. }
  38382. } else {
  38383. return;
  38384. }
  38385. }
  38386. var match = _react.default.createElement("div", {
  38387. className: "doc-category-item",
  38388. key: typeName + '.' + fieldName
  38389. }, withinType !== type && [_react.default.createElement(_TypeLink.default, {
  38390. key: "type",
  38391. type: type,
  38392. onClick: onClickType
  38393. }), '.'], _react.default.createElement("a", {
  38394. className: "field-name",
  38395. onClick: function onClick(event) {
  38396. return onClickField(field, type, event);
  38397. }
  38398. }, field.name), matchingArgs && ['(', _react.default.createElement("span", {
  38399. key: "args"
  38400. }, matchingArgs.map(function (arg) {
  38401. return _react.default.createElement(_Argument.default, {
  38402. key: arg.name,
  38403. arg: arg,
  38404. onClickType: onClickType,
  38405. showDefaultValue: false
  38406. });
  38407. })), ')']);
  38408. if (withinType === type) {
  38409. matchedWithin.push(match);
  38410. } else {
  38411. matchedFields.push(match);
  38412. }
  38413. });
  38414. }
  38415. };
  38416. for (var _iterator = typeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  38417. var _ret = _loop();
  38418. if (_ret === "break") break;
  38419. }
  38420. } catch (err) {
  38421. _didIteratorError = true;
  38422. _iteratorError = err;
  38423. } finally {
  38424. try {
  38425. if (!_iteratorNormalCompletion && _iterator.return != null) {
  38426. _iterator.return();
  38427. }
  38428. } finally {
  38429. if (_didIteratorError) {
  38430. throw _iteratorError;
  38431. }
  38432. }
  38433. }
  38434. if (matchedWithin.length + matchedTypes.length + matchedFields.length === 0) {
  38435. return _react.default.createElement("span", {
  38436. className: "doc-alert-text"
  38437. }, 'No results found.');
  38438. }
  38439. if (withinType && matchedTypes.length + matchedFields.length > 0) {
  38440. return _react.default.createElement("div", null, matchedWithin, _react.default.createElement("div", {
  38441. className: "doc-category"
  38442. }, _react.default.createElement("div", {
  38443. className: "doc-category-title"
  38444. }, 'other results'), matchedTypes, matchedFields));
  38445. }
  38446. return _react.default.createElement("div", null, matchedWithin, matchedTypes, matchedFields);
  38447. }
  38448. }]);
  38449. return SearchResults;
  38450. }(_react.default.Component);
  38451. exports.default = SearchResults;
  38452. _defineProperty(SearchResults, "propTypes", {
  38453. schema: _propTypes.default.object,
  38454. withinType: _propTypes.default.object,
  38455. searchValue: _propTypes.default.string,
  38456. onClickType: _propTypes.default.func,
  38457. onClickField: _propTypes.default.func
  38458. });
  38459. function isMatch(sourceText, searchValue) {
  38460. try {
  38461. var escaped = searchValue.replace(/[^_0-9A-Za-z]/g, function (ch) {
  38462. return '\\' + ch;
  38463. });
  38464. return sourceText.search(new RegExp(escaped, 'i')) !== -1;
  38465. } catch (e) {
  38466. return sourceText.toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
  38467. }
  38468. }
  38469. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38470. },{"./Argument":218,"./TypeLink":226,"prop-types":202}],225:[function(require,module,exports){
  38471. (function (global){
  38472. "use strict";
  38473. Object.defineProperty(exports, "__esModule", {
  38474. value: true
  38475. });
  38476. exports.default = void 0;
  38477. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38478. var _propTypes = _interopRequireDefault(require("prop-types"));
  38479. var _graphql = require("graphql");
  38480. var _Argument = _interopRequireDefault(require("./Argument"));
  38481. var _MarkdownContent = _interopRequireDefault(require("./MarkdownContent"));
  38482. var _TypeLink = _interopRequireDefault(require("./TypeLink"));
  38483. var _DefaultValue = _interopRequireDefault(require("./DefaultValue"));
  38484. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38485. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38486. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38487. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38488. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38489. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38490. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38491. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38492. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38493. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38494. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38495. var TypeDoc =
  38496. /*#__PURE__*/
  38497. function (_React$Component) {
  38498. _inherits(TypeDoc, _React$Component);
  38499. function TypeDoc(props) {
  38500. var _this;
  38501. _classCallCheck(this, TypeDoc);
  38502. _this = _possibleConstructorReturn(this, _getPrototypeOf(TypeDoc).call(this, props));
  38503. _defineProperty(_assertThisInitialized(_this), "handleShowDeprecated", function () {
  38504. return _this.setState({
  38505. showDeprecated: true
  38506. });
  38507. });
  38508. _this.state = {
  38509. showDeprecated: false
  38510. };
  38511. return _this;
  38512. }
  38513. _createClass(TypeDoc, [{
  38514. key: "shouldComponentUpdate",
  38515. value: function shouldComponentUpdate(nextProps, nextState) {
  38516. return this.props.type !== nextProps.type || this.props.schema !== nextProps.schema || this.state.showDeprecated !== nextState.showDeprecated;
  38517. }
  38518. }, {
  38519. key: "render",
  38520. value: function render() {
  38521. var schema = this.props.schema;
  38522. var type = this.props.type;
  38523. var onClickType = this.props.onClickType;
  38524. var onClickField = this.props.onClickField;
  38525. var typesTitle;
  38526. var types;
  38527. if (type instanceof _graphql.GraphQLUnionType) {
  38528. typesTitle = 'possible types';
  38529. types = schema.getPossibleTypes(type);
  38530. } else if (type instanceof _graphql.GraphQLInterfaceType) {
  38531. typesTitle = 'implementations';
  38532. types = schema.getPossibleTypes(type);
  38533. } else if (type instanceof _graphql.GraphQLObjectType) {
  38534. typesTitle = 'implements';
  38535. types = type.getInterfaces();
  38536. }
  38537. var typesDef;
  38538. if (types && types.length > 0) {
  38539. typesDef = _react.default.createElement("div", {
  38540. className: "doc-category"
  38541. }, _react.default.createElement("div", {
  38542. className: "doc-category-title"
  38543. }, typesTitle), types.map(function (subtype) {
  38544. return _react.default.createElement("div", {
  38545. key: subtype.name,
  38546. className: "doc-category-item"
  38547. }, _react.default.createElement(_TypeLink.default, {
  38548. type: subtype,
  38549. onClick: onClickType
  38550. }));
  38551. }));
  38552. } // InputObject and Object
  38553. var fieldsDef;
  38554. var deprecatedFieldsDef;
  38555. if (type.getFields) {
  38556. var fieldMap = type.getFields();
  38557. var fields = Object.keys(fieldMap).map(function (name) {
  38558. return fieldMap[name];
  38559. });
  38560. fieldsDef = _react.default.createElement("div", {
  38561. className: "doc-category"
  38562. }, _react.default.createElement("div", {
  38563. className: "doc-category-title"
  38564. }, 'fields'), fields.filter(function (field) {
  38565. return !field.isDeprecated;
  38566. }).map(function (field) {
  38567. return _react.default.createElement(Field, {
  38568. key: field.name,
  38569. type: type,
  38570. field: field,
  38571. onClickType: onClickType,
  38572. onClickField: onClickField
  38573. });
  38574. }));
  38575. var deprecatedFields = fields.filter(function (field) {
  38576. return field.isDeprecated;
  38577. });
  38578. if (deprecatedFields.length > 0) {
  38579. deprecatedFieldsDef = _react.default.createElement("div", {
  38580. className: "doc-category"
  38581. }, _react.default.createElement("div", {
  38582. className: "doc-category-title"
  38583. }, 'deprecated fields'), !this.state.showDeprecated ? _react.default.createElement("button", {
  38584. className: "show-btn",
  38585. onClick: this.handleShowDeprecated
  38586. }, 'Show deprecated fields...') : deprecatedFields.map(function (field) {
  38587. return _react.default.createElement(Field, {
  38588. key: field.name,
  38589. type: type,
  38590. field: field,
  38591. onClickType: onClickType,
  38592. onClickField: onClickField
  38593. });
  38594. }));
  38595. }
  38596. }
  38597. var valuesDef;
  38598. var deprecatedValuesDef;
  38599. if (type instanceof _graphql.GraphQLEnumType) {
  38600. var values = type.getValues();
  38601. valuesDef = _react.default.createElement("div", {
  38602. className: "doc-category"
  38603. }, _react.default.createElement("div", {
  38604. className: "doc-category-title"
  38605. }, 'values'), values.filter(function (value) {
  38606. return !value.isDeprecated;
  38607. }).map(function (value) {
  38608. return _react.default.createElement(EnumValue, {
  38609. key: value.name,
  38610. value: value
  38611. });
  38612. }));
  38613. var deprecatedValues = values.filter(function (value) {
  38614. return value.isDeprecated;
  38615. });
  38616. if (deprecatedValues.length > 0) {
  38617. deprecatedValuesDef = _react.default.createElement("div", {
  38618. className: "doc-category"
  38619. }, _react.default.createElement("div", {
  38620. className: "doc-category-title"
  38621. }, 'deprecated values'), !this.state.showDeprecated ? _react.default.createElement("button", {
  38622. className: "show-btn",
  38623. onClick: this.handleShowDeprecated
  38624. }, 'Show deprecated values...') : deprecatedValues.map(function (value) {
  38625. return _react.default.createElement(EnumValue, {
  38626. key: value.name,
  38627. value: value
  38628. });
  38629. }));
  38630. }
  38631. }
  38632. return _react.default.createElement("div", null, _react.default.createElement(_MarkdownContent.default, {
  38633. className: "doc-type-description",
  38634. markdown: type.description || 'No Description'
  38635. }), type instanceof _graphql.GraphQLObjectType && typesDef, fieldsDef, deprecatedFieldsDef, valuesDef, deprecatedValuesDef, !(type instanceof _graphql.GraphQLObjectType) && typesDef);
  38636. }
  38637. }]);
  38638. return TypeDoc;
  38639. }(_react.default.Component);
  38640. exports.default = TypeDoc;
  38641. _defineProperty(TypeDoc, "propTypes", {
  38642. schema: _propTypes.default.instanceOf(_graphql.GraphQLSchema),
  38643. type: _propTypes.default.object,
  38644. onClickType: _propTypes.default.func,
  38645. onClickField: _propTypes.default.func
  38646. });
  38647. function Field(_ref) {
  38648. var type = _ref.type,
  38649. field = _ref.field,
  38650. onClickType = _ref.onClickType,
  38651. onClickField = _ref.onClickField;
  38652. return _react.default.createElement("div", {
  38653. className: "doc-category-item"
  38654. }, _react.default.createElement("a", {
  38655. className: "field-name",
  38656. onClick: function onClick(event) {
  38657. return onClickField(field, type, event);
  38658. }
  38659. }, field.name), field.args && field.args.length > 0 && ['(', _react.default.createElement("span", {
  38660. key: "args"
  38661. }, field.args.map(function (arg) {
  38662. return _react.default.createElement(_Argument.default, {
  38663. key: arg.name,
  38664. arg: arg,
  38665. onClickType: onClickType
  38666. });
  38667. })), ')'], ': ', _react.default.createElement(_TypeLink.default, {
  38668. type: field.type,
  38669. onClick: onClickType
  38670. }), _react.default.createElement(_DefaultValue.default, {
  38671. field: field
  38672. }), field.description && _react.default.createElement(_MarkdownContent.default, {
  38673. className: "field-short-description",
  38674. markdown: field.description
  38675. }), field.deprecationReason && _react.default.createElement(_MarkdownContent.default, {
  38676. className: "doc-deprecation",
  38677. markdown: field.deprecationReason
  38678. }));
  38679. }
  38680. Field.propTypes = {
  38681. type: _propTypes.default.object,
  38682. field: _propTypes.default.object,
  38683. onClickType: _propTypes.default.func,
  38684. onClickField: _propTypes.default.func
  38685. };
  38686. function EnumValue(_ref2) {
  38687. var value = _ref2.value;
  38688. return _react.default.createElement("div", {
  38689. className: "doc-category-item"
  38690. }, _react.default.createElement("div", {
  38691. className: "enum-value"
  38692. }, value.name), _react.default.createElement(_MarkdownContent.default, {
  38693. className: "doc-value-description",
  38694. markdown: value.description
  38695. }), value.deprecationReason && _react.default.createElement(_MarkdownContent.default, {
  38696. className: "doc-deprecation",
  38697. markdown: value.deprecationReason
  38698. }));
  38699. }
  38700. EnumValue.propTypes = {
  38701. value: _propTypes.default.object
  38702. };
  38703. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38704. },{"./Argument":218,"./DefaultValue":219,"./MarkdownContent":221,"./TypeLink":226,"graphql":29,"prop-types":202}],226:[function(require,module,exports){
  38705. (function (global){
  38706. "use strict";
  38707. Object.defineProperty(exports, "__esModule", {
  38708. value: true
  38709. });
  38710. exports.default = void 0;
  38711. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38712. var _propTypes = _interopRequireDefault(require("prop-types"));
  38713. var _graphql = require("graphql");
  38714. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38715. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38716. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38717. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38718. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38719. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38720. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38721. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38722. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38723. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38724. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38725. var TypeLink =
  38726. /*#__PURE__*/
  38727. function (_React$Component) {
  38728. _inherits(TypeLink, _React$Component);
  38729. function TypeLink() {
  38730. _classCallCheck(this, TypeLink);
  38731. return _possibleConstructorReturn(this, _getPrototypeOf(TypeLink).apply(this, arguments));
  38732. }
  38733. _createClass(TypeLink, [{
  38734. key: "shouldComponentUpdate",
  38735. value: function shouldComponentUpdate(nextProps) {
  38736. return this.props.type !== nextProps.type;
  38737. }
  38738. }, {
  38739. key: "render",
  38740. value: function render() {
  38741. return renderType(this.props.type, this.props.onClick);
  38742. }
  38743. }]);
  38744. return TypeLink;
  38745. }(_react.default.Component);
  38746. exports.default = TypeLink;
  38747. _defineProperty(TypeLink, "propTypes", {
  38748. type: _propTypes.default.object,
  38749. onClick: _propTypes.default.func
  38750. });
  38751. function renderType(type, _onClick) {
  38752. if (type instanceof _graphql.GraphQLNonNull) {
  38753. return _react.default.createElement("span", null, renderType(type.ofType, _onClick), '!');
  38754. }
  38755. if (type instanceof _graphql.GraphQLList) {
  38756. return _react.default.createElement("span", null, '[', renderType(type.ofType, _onClick), ']');
  38757. }
  38758. return _react.default.createElement("a", {
  38759. className: "type-name",
  38760. onClick: function onClick(event) {
  38761. return _onClick(type, event);
  38762. }
  38763. }, type.name);
  38764. }
  38765. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38766. },{"graphql":29,"prop-types":202}],227:[function(require,module,exports){
  38767. (function (global){
  38768. "use strict";
  38769. Object.defineProperty(exports, "__esModule", {
  38770. value: true
  38771. });
  38772. exports.ExecuteButton = void 0;
  38773. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38774. var _propTypes = _interopRequireDefault(require("prop-types"));
  38775. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38776. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38777. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38778. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38779. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38780. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38781. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38782. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38783. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38784. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38785. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38786. /**
  38787. * ExecuteButton
  38788. *
  38789. * What a nice round shiny button. Shows a drop-down when there are multiple
  38790. * queries to run.
  38791. */
  38792. var ExecuteButton =
  38793. /*#__PURE__*/
  38794. function (_React$Component) {
  38795. _inherits(ExecuteButton, _React$Component);
  38796. function ExecuteButton(props) {
  38797. var _this;
  38798. _classCallCheck(this, ExecuteButton);
  38799. _this = _possibleConstructorReturn(this, _getPrototypeOf(ExecuteButton).call(this, props));
  38800. _defineProperty(_assertThisInitialized(_this), "_onClick", function () {
  38801. if (_this.props.isRunning) {
  38802. _this.props.onStop();
  38803. } else {
  38804. _this.props.onRun();
  38805. }
  38806. });
  38807. _defineProperty(_assertThisInitialized(_this), "_onOptionSelected", function (operation) {
  38808. _this.setState({
  38809. optionsOpen: false
  38810. });
  38811. _this.props.onRun(operation.name && operation.name.value);
  38812. });
  38813. _defineProperty(_assertThisInitialized(_this), "_onOptionsOpen", function (downEvent) {
  38814. var initialPress = true;
  38815. var downTarget = downEvent.target;
  38816. _this.setState({
  38817. highlight: null,
  38818. optionsOpen: true
  38819. });
  38820. var _onMouseUp = function onMouseUp(upEvent) {
  38821. if (initialPress && upEvent.target === downTarget) {
  38822. initialPress = false;
  38823. } else {
  38824. document.removeEventListener('mouseup', _onMouseUp);
  38825. _onMouseUp = null;
  38826. var isOptionsMenuClicked = downTarget.parentNode.compareDocumentPosition(upEvent.target) & Node.DOCUMENT_POSITION_CONTAINED_BY;
  38827. if (!isOptionsMenuClicked) {
  38828. // menu calls setState if it was clicked
  38829. _this.setState({
  38830. optionsOpen: false
  38831. });
  38832. }
  38833. }
  38834. };
  38835. document.addEventListener('mouseup', _onMouseUp);
  38836. });
  38837. _this.state = {
  38838. optionsOpen: false,
  38839. highlight: null
  38840. };
  38841. return _this;
  38842. }
  38843. _createClass(ExecuteButton, [{
  38844. key: "render",
  38845. value: function render() {
  38846. var _this2 = this;
  38847. var operations = this.props.operations;
  38848. var optionsOpen = this.state.optionsOpen;
  38849. var hasOptions = operations && operations.length > 1;
  38850. var options = null;
  38851. if (hasOptions && optionsOpen) {
  38852. var highlight = this.state.highlight;
  38853. options = _react.default.createElement("ul", {
  38854. className: "execute-options"
  38855. }, operations.map(function (operation) {
  38856. return _react.default.createElement("li", {
  38857. key: operation.name ? operation.name.value : '*',
  38858. className: operation === highlight ? 'selected' : undefined,
  38859. onMouseOver: function onMouseOver() {
  38860. return _this2.setState({
  38861. highlight: operation
  38862. });
  38863. },
  38864. onMouseOut: function onMouseOut() {
  38865. return _this2.setState({
  38866. highlight: null
  38867. });
  38868. },
  38869. onMouseUp: function onMouseUp() {
  38870. return _this2._onOptionSelected(operation);
  38871. }
  38872. }, operation.name ? operation.name.value : '<Unnamed>');
  38873. }));
  38874. } // Allow click event if there is a running query or if there are not options
  38875. // for which operation to run.
  38876. var onClick;
  38877. if (this.props.isRunning || !hasOptions) {
  38878. onClick = this._onClick;
  38879. } // Allow mouse down if there is no running query, there are options for
  38880. // which operation to run, and the dropdown is currently closed.
  38881. var onMouseDown;
  38882. if (!this.props.isRunning && hasOptions && !optionsOpen) {
  38883. onMouseDown = this._onOptionsOpen;
  38884. }
  38885. var pathJSX = this.props.isRunning ? _react.default.createElement("path", {
  38886. d: "M 10 10 L 23 10 L 23 23 L 10 23 z"
  38887. }) : _react.default.createElement("path", {
  38888. d: "M 11 9 L 24 16 L 11 23 z"
  38889. });
  38890. return _react.default.createElement("div", {
  38891. className: "execute-button-wrap"
  38892. }, _react.default.createElement("button", {
  38893. type: "button",
  38894. className: "execute-button",
  38895. onMouseDown: onMouseDown,
  38896. onClick: onClick,
  38897. title: "Execute Query (Ctrl-Enter)"
  38898. }, _react.default.createElement("svg", {
  38899. width: "34",
  38900. height: "34"
  38901. }, pathJSX)), options);
  38902. }
  38903. }]);
  38904. return ExecuteButton;
  38905. }(_react.default.Component);
  38906. exports.ExecuteButton = ExecuteButton;
  38907. _defineProperty(ExecuteButton, "propTypes", {
  38908. onRun: _propTypes.default.func,
  38909. onStop: _propTypes.default.func,
  38910. isRunning: _propTypes.default.bool,
  38911. operations: _propTypes.default.array
  38912. });
  38913. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  38914. },{"prop-types":202}],228:[function(require,module,exports){
  38915. (function (global){
  38916. "use strict";
  38917. Object.defineProperty(exports, "__esModule", {
  38918. value: true
  38919. });
  38920. exports.GraphiQL = void 0;
  38921. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  38922. var _propTypes = _interopRequireDefault(require("prop-types"));
  38923. var _reactDom = _interopRequireDefault((typeof window !== "undefined" ? window['ReactDOM'] : typeof global !== "undefined" ? global['ReactDOM'] : null));
  38924. var _graphql = require("graphql");
  38925. var _copyToClipboard = _interopRequireDefault(require("copy-to-clipboard"));
  38926. var _ExecuteButton = require("./ExecuteButton");
  38927. var _ImagePreview = require("./ImagePreview");
  38928. var _ToolbarButton = require("./ToolbarButton");
  38929. var _ToolbarGroup = require("./ToolbarGroup");
  38930. var _ToolbarMenu = require("./ToolbarMenu");
  38931. var _ToolbarSelect = require("./ToolbarSelect");
  38932. var _QueryEditor = require("./QueryEditor");
  38933. var _VariableEditor = require("./VariableEditor");
  38934. var _ResultViewer = require("./ResultViewer");
  38935. var _DocExplorer = require("./DocExplorer");
  38936. var _QueryHistory = require("./QueryHistory");
  38937. var _CodeMirrorSizer = _interopRequireDefault(require("../utility/CodeMirrorSizer"));
  38938. var _StorageAPI = _interopRequireDefault(require("../utility/StorageAPI"));
  38939. var _getQueryFacts = _interopRequireDefault(require("../utility/getQueryFacts"));
  38940. var _getSelectedOperationName = _interopRequireDefault(require("../utility/getSelectedOperationName"));
  38941. var _debounce = _interopRequireDefault(require("../utility/debounce"));
  38942. var _find = _interopRequireDefault(require("../utility/find"));
  38943. var _fillLeafs2 = require("../utility/fillLeafs");
  38944. var _elementPosition = require("../utility/elementPosition");
  38945. var _mergeAst = require("../utility/mergeAst");
  38946. var _introspectionQueries = require("../utility/introspectionQueries");
  38947. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38948. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  38949. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  38950. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38951. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  38952. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  38953. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  38954. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  38955. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  38956. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  38957. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  38958. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  38959. var DEFAULT_DOC_EXPLORER_WIDTH = 350;
  38960. /**
  38961. * The top-level React component for GraphiQL, intended to encompass the entire
  38962. * browser viewport.
  38963. *
  38964. * @see https://github.com/graphql/graphiql#usage
  38965. */
  38966. var GraphiQL =
  38967. /*#__PURE__*/
  38968. function (_React$Component) {
  38969. _inherits(GraphiQL, _React$Component);
  38970. function GraphiQL(props) {
  38971. var _this;
  38972. _classCallCheck(this, GraphiQL);
  38973. _this = _possibleConstructorReturn(this, _getPrototypeOf(GraphiQL).call(this, props)); // Ensure props are correct
  38974. _defineProperty(_assertThisInitialized(_this), "handleClickReference", function (reference) {
  38975. _this.setState({
  38976. docExplorerOpen: true
  38977. }, function () {
  38978. _this.docExplorerComponent.showDocForReference(reference);
  38979. });
  38980. });
  38981. _defineProperty(_assertThisInitialized(_this), "handleRunQuery", function (selectedOperationName) {
  38982. _this._editorQueryID++;
  38983. var queryID = _this._editorQueryID; // Use the edited query after autoCompleteLeafs() runs or,
  38984. // in case autoCompletion fails (the function returns undefined),
  38985. // the current query from the editor.
  38986. var editedQuery = _this.autoCompleteLeafs() || _this.state.query;
  38987. var variables = _this.state.variables;
  38988. var operationName = _this.state.operationName; // If an operation was explicitly provided, different from the current
  38989. // operation name, then report that it changed.
  38990. if (selectedOperationName && selectedOperationName !== operationName) {
  38991. operationName = selectedOperationName;
  38992. _this.handleEditOperationName(operationName);
  38993. }
  38994. try {
  38995. _this.setState({
  38996. isWaitingForResponse: true,
  38997. response: null,
  38998. operationName: operationName
  38999. }); // _fetchQuery may return a subscription.
  39000. var subscription = _this._fetchQuery(editedQuery, variables, operationName, function (result) {
  39001. if (queryID === _this._editorQueryID) {
  39002. _this.setState({
  39003. isWaitingForResponse: false,
  39004. response: JSON.stringify(result, null, 2)
  39005. });
  39006. }
  39007. });
  39008. _this.setState({
  39009. subscription: subscription
  39010. });
  39011. } catch (error) {
  39012. _this.setState({
  39013. isWaitingForResponse: false,
  39014. response: error.message
  39015. });
  39016. }
  39017. });
  39018. _defineProperty(_assertThisInitialized(_this), "handleStopQuery", function () {
  39019. var subscription = _this.state.subscription;
  39020. _this.setState({
  39021. isWaitingForResponse: false,
  39022. subscription: null
  39023. });
  39024. if (subscription) {
  39025. subscription.unsubscribe();
  39026. }
  39027. });
  39028. _defineProperty(_assertThisInitialized(_this), "handlePrettifyQuery", function () {
  39029. var editor = _this.getQueryEditor();
  39030. editor.setValue((0, _graphql.print)((0, _graphql.parse)(editor.getValue())));
  39031. });
  39032. _defineProperty(_assertThisInitialized(_this), "handleMergeQuery", function () {
  39033. var editor = _this.getQueryEditor();
  39034. var query = editor.getValue();
  39035. if (!query) {
  39036. return;
  39037. }
  39038. var ast = (0, _graphql.parse)(query);
  39039. editor.setValue((0, _graphql.print)((0, _mergeAst.mergeAst)(ast)));
  39040. });
  39041. _defineProperty(_assertThisInitialized(_this), "handleEditQuery", (0, _debounce.default)(100, function (value) {
  39042. var queryFacts = _this._updateQueryFacts(value, _this.state.operationName, _this.state.operations, _this.state.schema);
  39043. _this.setState(_objectSpread({
  39044. query: value
  39045. }, queryFacts));
  39046. if (_this.props.onEditQuery) {
  39047. return _this.props.onEditQuery(value);
  39048. }
  39049. }));
  39050. _defineProperty(_assertThisInitialized(_this), "handleCopyQuery", function () {
  39051. var editor = _this.getQueryEditor();
  39052. var query = editor.getValue();
  39053. if (!query) {
  39054. return;
  39055. }
  39056. (0, _copyToClipboard.default)(query);
  39057. if (_this.props.onCopyQuery) {
  39058. return _this.props.onCopyQuery(query);
  39059. }
  39060. });
  39061. _defineProperty(_assertThisInitialized(_this), "_updateQueryFacts", function (query, operationName, prevOperations, schema) {
  39062. var queryFacts = (0, _getQueryFacts.default)(schema, query);
  39063. if (queryFacts) {
  39064. // Update operation name should any query names change.
  39065. var updatedOperationName = (0, _getSelectedOperationName.default)(prevOperations, operationName, queryFacts.operations); // Report changing of operationName if it changed.
  39066. var onEditOperationName = _this.props.onEditOperationName;
  39067. if (onEditOperationName && operationName !== updatedOperationName) {
  39068. onEditOperationName(updatedOperationName);
  39069. }
  39070. return _objectSpread({
  39071. operationName: updatedOperationName
  39072. }, queryFacts);
  39073. }
  39074. });
  39075. _defineProperty(_assertThisInitialized(_this), "handleEditVariables", function (value) {
  39076. _this.setState({
  39077. variables: value
  39078. });
  39079. if (_this.props.onEditVariables) {
  39080. _this.props.onEditVariables(value);
  39081. }
  39082. });
  39083. _defineProperty(_assertThisInitialized(_this), "handleEditOperationName", function (operationName) {
  39084. var onEditOperationName = _this.props.onEditOperationName;
  39085. if (onEditOperationName) {
  39086. onEditOperationName(operationName);
  39087. }
  39088. });
  39089. _defineProperty(_assertThisInitialized(_this), "handleHintInformationRender", function (elem) {
  39090. elem.addEventListener('click', _this._onClickHintInformation);
  39091. var _onRemoveFn;
  39092. elem.addEventListener('DOMNodeRemoved', _onRemoveFn = function onRemoveFn() {
  39093. elem.removeEventListener('DOMNodeRemoved', _onRemoveFn);
  39094. elem.removeEventListener('click', _this._onClickHintInformation);
  39095. });
  39096. });
  39097. _defineProperty(_assertThisInitialized(_this), "handleEditorRunQuery", function () {
  39098. _this._runQueryAtCursor();
  39099. });
  39100. _defineProperty(_assertThisInitialized(_this), "_onClickHintInformation", function (event) {
  39101. if (event.target.className === 'typeName') {
  39102. var typeName = event.target.innerHTML;
  39103. var schema = _this.state.schema;
  39104. if (schema) {
  39105. var type = schema.getType(typeName);
  39106. if (type) {
  39107. _this.setState({
  39108. docExplorerOpen: true
  39109. }, function () {
  39110. _this.docExplorerComponent.showDoc(type);
  39111. });
  39112. }
  39113. }
  39114. }
  39115. });
  39116. _defineProperty(_assertThisInitialized(_this), "handleToggleDocs", function () {
  39117. if (typeof _this.props.onToggleDocs === 'function') {
  39118. _this.props.onToggleDocs(!_this.state.docExplorerOpen);
  39119. }
  39120. _this.setState({
  39121. docExplorerOpen: !_this.state.docExplorerOpen
  39122. });
  39123. });
  39124. _defineProperty(_assertThisInitialized(_this), "handleToggleHistory", function () {
  39125. if (typeof _this.props.onToggleHistory === 'function') {
  39126. _this.props.onToggleHistory(!_this.state.historyPaneOpen);
  39127. }
  39128. _this.setState({
  39129. historyPaneOpen: !_this.state.historyPaneOpen
  39130. });
  39131. });
  39132. _defineProperty(_assertThisInitialized(_this), "handleSelectHistoryQuery", function (query, variables, operationName) {
  39133. _this.handleEditQuery(query);
  39134. _this.handleEditVariables(variables);
  39135. _this.handleEditOperationName(operationName);
  39136. });
  39137. _defineProperty(_assertThisInitialized(_this), "handleResizeStart", function (downEvent) {
  39138. if (!_this._didClickDragBar(downEvent)) {
  39139. return;
  39140. }
  39141. downEvent.preventDefault();
  39142. var offset = downEvent.clientX - (0, _elementPosition.getLeft)(downEvent.target);
  39143. var onMouseMove = function onMouseMove(moveEvent) {
  39144. if (moveEvent.buttons === 0) {
  39145. return _onMouseUp();
  39146. }
  39147. var editorBar = _reactDom.default.findDOMNode(_this.editorBarComponent);
  39148. var leftSize = moveEvent.clientX - (0, _elementPosition.getLeft)(editorBar) - offset;
  39149. var rightSize = editorBar.clientWidth - leftSize;
  39150. _this.setState({
  39151. editorFlex: leftSize / rightSize
  39152. });
  39153. };
  39154. var _onMouseUp = function onMouseUp() {
  39155. document.removeEventListener('mousemove', onMouseMove);
  39156. document.removeEventListener('mouseup', _onMouseUp);
  39157. onMouseMove = null;
  39158. _onMouseUp = null;
  39159. };
  39160. document.addEventListener('mousemove', onMouseMove);
  39161. document.addEventListener('mouseup', _onMouseUp);
  39162. });
  39163. _defineProperty(_assertThisInitialized(_this), "handleResetResize", function () {
  39164. _this.setState({
  39165. editorFlex: 1
  39166. });
  39167. });
  39168. _defineProperty(_assertThisInitialized(_this), "handleDocsResizeStart", function (downEvent) {
  39169. downEvent.preventDefault();
  39170. var hadWidth = _this.state.docExplorerWidth;
  39171. var offset = downEvent.clientX - (0, _elementPosition.getLeft)(downEvent.target);
  39172. var onMouseMove = function onMouseMove(moveEvent) {
  39173. if (moveEvent.buttons === 0) {
  39174. return _onMouseUp2();
  39175. }
  39176. var app = _reactDom.default.findDOMNode(_assertThisInitialized(_this));
  39177. var cursorPos = moveEvent.clientX - (0, _elementPosition.getLeft)(app) - offset;
  39178. var docsSize = app.clientWidth - cursorPos;
  39179. if (docsSize < 100) {
  39180. _this.setState({
  39181. docExplorerOpen: false
  39182. });
  39183. } else {
  39184. _this.setState({
  39185. docExplorerOpen: true,
  39186. docExplorerWidth: Math.min(docsSize, 650)
  39187. });
  39188. }
  39189. };
  39190. var _onMouseUp2 = function onMouseUp() {
  39191. if (!_this.state.docExplorerOpen) {
  39192. _this.setState({
  39193. docExplorerWidth: hadWidth
  39194. });
  39195. }
  39196. document.removeEventListener('mousemove', onMouseMove);
  39197. document.removeEventListener('mouseup', _onMouseUp2);
  39198. onMouseMove = null;
  39199. _onMouseUp2 = null;
  39200. };
  39201. document.addEventListener('mousemove', onMouseMove);
  39202. document.addEventListener('mouseup', _onMouseUp2);
  39203. });
  39204. _defineProperty(_assertThisInitialized(_this), "handleDocsResetResize", function () {
  39205. _this.setState({
  39206. docExplorerWidth: DEFAULT_DOC_EXPLORER_WIDTH
  39207. });
  39208. });
  39209. _defineProperty(_assertThisInitialized(_this), "handleVariableResizeStart", function (downEvent) {
  39210. downEvent.preventDefault();
  39211. var didMove = false;
  39212. var wasOpen = _this.state.variableEditorOpen;
  39213. var hadHeight = _this.state.variableEditorHeight;
  39214. var offset = downEvent.clientY - (0, _elementPosition.getTop)(downEvent.target);
  39215. var onMouseMove = function onMouseMove(moveEvent) {
  39216. if (moveEvent.buttons === 0) {
  39217. return _onMouseUp3();
  39218. }
  39219. didMove = true;
  39220. var editorBar = _reactDom.default.findDOMNode(_this.editorBarComponent);
  39221. var topSize = moveEvent.clientY - (0, _elementPosition.getTop)(editorBar) - offset;
  39222. var bottomSize = editorBar.clientHeight - topSize;
  39223. if (bottomSize < 60) {
  39224. _this.setState({
  39225. variableEditorOpen: false,
  39226. variableEditorHeight: hadHeight
  39227. });
  39228. } else {
  39229. _this.setState({
  39230. variableEditorOpen: true,
  39231. variableEditorHeight: bottomSize
  39232. });
  39233. }
  39234. };
  39235. var _onMouseUp3 = function onMouseUp() {
  39236. if (!didMove) {
  39237. _this.setState({
  39238. variableEditorOpen: !wasOpen
  39239. });
  39240. }
  39241. document.removeEventListener('mousemove', onMouseMove);
  39242. document.removeEventListener('mouseup', _onMouseUp3);
  39243. onMouseMove = null;
  39244. _onMouseUp3 = null;
  39245. };
  39246. document.addEventListener('mousemove', onMouseMove);
  39247. document.addEventListener('mouseup', _onMouseUp3);
  39248. });
  39249. if (typeof props.fetcher !== 'function') {
  39250. throw new TypeError('GraphiQL requires a fetcher function.');
  39251. } // Cache the storage instance
  39252. _this._storage = new _StorageAPI.default(props.storage); // Determine the initial query to display.
  39253. var _query = props.query !== undefined ? props.query : _this._storage.get('query') !== null ? _this._storage.get('query') : props.defaultQuery !== undefined ? props.defaultQuery : defaultQuery; // Get the initial query facts.
  39254. var _queryFacts = (0, _getQueryFacts.default)(props.schema, _query); // Determine the initial variables to display.
  39255. var _variables = props.variables !== undefined ? props.variables : _this._storage.get('variables'); // Determine the initial operationName to use.
  39256. var _operationName = props.operationName !== undefined ? props.operationName : (0, _getSelectedOperationName.default)(null, _this._storage.get('operationName'), _queryFacts && _queryFacts.operations); // prop can be supplied to open docExplorer initially
  39257. var docExplorerOpen = props.docExplorerOpen || false; // but then local storage state overrides it
  39258. if (_this._storage.get('docExplorerOpen')) {
  39259. docExplorerOpen = _this._storage.get('docExplorerOpen') === 'true';
  39260. } // Initialize state
  39261. _this.state = _objectSpread({
  39262. schema: props.schema,
  39263. query: _query,
  39264. variables: _variables,
  39265. operationName: _operationName,
  39266. docExplorerOpen: docExplorerOpen,
  39267. response: props.response,
  39268. editorFlex: Number(_this._storage.get('editorFlex')) || 1,
  39269. variableEditorOpen: Boolean(_variables),
  39270. variableEditorHeight: Number(_this._storage.get('variableEditorHeight')) || 200,
  39271. historyPaneOpen: _this._storage.get('historyPaneOpen') === 'true' || false,
  39272. docExplorerWidth: Number(_this._storage.get('docExplorerWidth')) || DEFAULT_DOC_EXPLORER_WIDTH,
  39273. isWaitingForResponse: false,
  39274. subscription: null
  39275. }, _queryFacts); // Ensure only the last executed editor query is rendered.
  39276. _this._editorQueryID = 0; // Subscribe to the browser window closing, treating it as an unmount.
  39277. if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
  39278. window.addEventListener('beforeunload', function () {
  39279. return _this.componentWillUnmount();
  39280. });
  39281. }
  39282. return _this;
  39283. }
  39284. _createClass(GraphiQL, [{
  39285. key: "componentDidMount",
  39286. value: function componentDidMount() {
  39287. // Only fetch schema via introspection if a schema has not been
  39288. // provided, including if `null` was provided.
  39289. if (this.state.schema === undefined) {
  39290. this._fetchSchema();
  39291. } // Utility for keeping CodeMirror correctly sized.
  39292. this.codeMirrorSizer = new _CodeMirrorSizer.default();
  39293. global.g = this;
  39294. }
  39295. }, {
  39296. key: "componentWillReceiveProps",
  39297. value: function componentWillReceiveProps(nextProps) {
  39298. var _this2 = this;
  39299. var nextSchema = this.state.schema;
  39300. var nextQuery = this.state.query;
  39301. var nextVariables = this.state.variables;
  39302. var nextOperationName = this.state.operationName;
  39303. var nextResponse = this.state.response;
  39304. if (nextProps.schema !== undefined) {
  39305. nextSchema = nextProps.schema;
  39306. }
  39307. if (nextProps.query !== undefined) {
  39308. nextQuery = nextProps.query;
  39309. }
  39310. if (nextProps.variables !== undefined) {
  39311. nextVariables = nextProps.variables;
  39312. }
  39313. if (nextProps.operationName !== undefined) {
  39314. nextOperationName = nextProps.operationName;
  39315. }
  39316. if (nextProps.response !== undefined) {
  39317. nextResponse = nextProps.response;
  39318. }
  39319. if (nextSchema !== this.state.schema || nextQuery !== this.state.query || nextOperationName !== this.state.operationName) {
  39320. var updatedQueryAttributes = this._updateQueryFacts(nextQuery, nextOperationName, this.state.operations, nextSchema);
  39321. if (updatedQueryAttributes !== undefined) {
  39322. nextOperationName = updatedQueryAttributes.operationName;
  39323. this.setState(updatedQueryAttributes);
  39324. }
  39325. } // If schema is not supplied via props and the fetcher changed, then
  39326. // remove the schema so fetchSchema() will be called with the new fetcher.
  39327. if (nextProps.schema === undefined && nextProps.fetcher !== this.props.fetcher) {
  39328. nextSchema = undefined;
  39329. }
  39330. this.setState({
  39331. schema: nextSchema,
  39332. query: nextQuery,
  39333. variables: nextVariables,
  39334. operationName: nextOperationName,
  39335. response: nextResponse
  39336. }, function () {
  39337. if (_this2.state.schema === undefined) {
  39338. _this2.docExplorerComponent.reset();
  39339. _this2._fetchSchema();
  39340. }
  39341. });
  39342. }
  39343. }, {
  39344. key: "componentDidUpdate",
  39345. value: function componentDidUpdate() {
  39346. // If this update caused DOM nodes to have changed sizes, update the
  39347. // corresponding CodeMirror instance sizes to match.
  39348. this.codeMirrorSizer.updateSizes([this.queryEditorComponent, this.variableEditorComponent, this.resultComponent]);
  39349. } // When the component is about to unmount, store any persistable state, such
  39350. // that when the component is remounted, it will use the last used values.
  39351. }, {
  39352. key: "componentWillUnmount",
  39353. value: function componentWillUnmount() {
  39354. this._storage.set('query', this.state.query);
  39355. this._storage.set('variables', this.state.variables);
  39356. this._storage.set('operationName', this.state.operationName);
  39357. this._storage.set('editorFlex', this.state.editorFlex);
  39358. this._storage.set('variableEditorHeight', this.state.variableEditorHeight);
  39359. this._storage.set('docExplorerWidth', this.state.docExplorerWidth);
  39360. this._storage.set('docExplorerOpen', this.state.docExplorerOpen);
  39361. this._storage.set('historyPaneOpen', this.state.historyPaneOpen);
  39362. }
  39363. }, {
  39364. key: "render",
  39365. value: function render() {
  39366. var _this3 = this;
  39367. var children = _react.default.Children.toArray(this.props.children);
  39368. var logo = (0, _find.default)(children, function (child) {
  39369. return child.type === GraphiQL.Logo;
  39370. }) || _react.default.createElement(GraphiQL.Logo, null);
  39371. var toolbar = (0, _find.default)(children, function (child) {
  39372. return child.type === GraphiQL.Toolbar;
  39373. }) || _react.default.createElement(GraphiQL.Toolbar, null, _react.default.createElement(_ToolbarButton.ToolbarButton, {
  39374. onClick: this.handlePrettifyQuery,
  39375. title: "Prettify Query (Shift-Ctrl-P)",
  39376. label: "Prettify"
  39377. }), _react.default.createElement(_ToolbarButton.ToolbarButton, {
  39378. onClick: this.handleMergeQuery,
  39379. title: "Merge Query (Shift-Ctrl-M)",
  39380. label: "Merge"
  39381. }), _react.default.createElement(_ToolbarButton.ToolbarButton, {
  39382. onClick: this.handleCopyQuery,
  39383. title: "Copy Query (Shift-Ctrl-C)",
  39384. label: "Copy"
  39385. }), _react.default.createElement(_ToolbarButton.ToolbarButton, {
  39386. onClick: this.handleToggleHistory,
  39387. title: "Show History",
  39388. label: "History"
  39389. }));
  39390. var footer = (0, _find.default)(children, function (child) {
  39391. return child.type === GraphiQL.Footer;
  39392. });
  39393. var queryWrapStyle = {
  39394. WebkitFlex: this.state.editorFlex,
  39395. flex: this.state.editorFlex
  39396. };
  39397. var docWrapStyle = {
  39398. display: this.state.docExplorerOpen ? 'block' : 'none',
  39399. width: this.state.docExplorerWidth
  39400. };
  39401. var docExplorerWrapClasses = 'docExplorerWrap' + (this.state.docExplorerWidth < 200 ? ' doc-explorer-narrow' : '');
  39402. var historyPaneStyle = {
  39403. display: this.state.historyPaneOpen ? 'block' : 'none',
  39404. width: '230px',
  39405. zIndex: '7'
  39406. };
  39407. var variableOpen = this.state.variableEditorOpen;
  39408. var variableStyle = {
  39409. height: variableOpen ? this.state.variableEditorHeight : null
  39410. };
  39411. return _react.default.createElement("div", {
  39412. className: "graphiql-container"
  39413. }, _react.default.createElement("div", {
  39414. className: "historyPaneWrap",
  39415. style: historyPaneStyle
  39416. }, _react.default.createElement(_QueryHistory.QueryHistory, {
  39417. operationName: this.state.operationName,
  39418. query: this.state.query,
  39419. variables: this.state.variables,
  39420. onSelectQuery: this.handleSelectHistoryQuery,
  39421. storage: this._storage,
  39422. queryID: this._editorQueryID
  39423. }, _react.default.createElement("div", {
  39424. className: "docExplorerHide",
  39425. onClick: this.handleToggleHistory
  39426. }, "\u2715"))), _react.default.createElement("div", {
  39427. className: "editorWrap"
  39428. }, _react.default.createElement("div", {
  39429. className: "topBarWrap"
  39430. }, _react.default.createElement("div", {
  39431. className: "topBar"
  39432. }, logo, _react.default.createElement(_ExecuteButton.ExecuteButton, {
  39433. isRunning: Boolean(this.state.subscription),
  39434. onRun: this.handleRunQuery,
  39435. onStop: this.handleStopQuery,
  39436. operations: this.state.operations
  39437. }), toolbar), !this.state.docExplorerOpen && _react.default.createElement("button", {
  39438. className: "docExplorerShow",
  39439. onClick: this.handleToggleDocs
  39440. }, 'Docs')), _react.default.createElement("div", {
  39441. ref: function ref(n) {
  39442. _this3.editorBarComponent = n;
  39443. },
  39444. className: "editorBar",
  39445. onDoubleClick: this.handleResetResize,
  39446. onMouseDown: this.handleResizeStart
  39447. }, _react.default.createElement("div", {
  39448. className: "queryWrap",
  39449. style: queryWrapStyle
  39450. }, _react.default.createElement(_QueryEditor.QueryEditor, {
  39451. ref: function ref(n) {
  39452. _this3.queryEditorComponent = n;
  39453. },
  39454. schema: this.state.schema,
  39455. value: this.state.query,
  39456. onEdit: this.handleEditQuery,
  39457. onHintInformationRender: this.handleHintInformationRender,
  39458. onClickReference: this.handleClickReference,
  39459. onCopyQuery: this.handleCopyQuery,
  39460. onPrettifyQuery: this.handlePrettifyQuery,
  39461. onMergeQuery: this.handleMergeQuery,
  39462. onRunQuery: this.handleEditorRunQuery,
  39463. editorTheme: this.props.editorTheme,
  39464. readOnly: this.props.readOnly
  39465. }), _react.default.createElement("div", {
  39466. className: "variable-editor",
  39467. style: variableStyle
  39468. }, _react.default.createElement("div", {
  39469. className: "variable-editor-title",
  39470. style: {
  39471. cursor: variableOpen ? 'row-resize' : 'n-resize'
  39472. },
  39473. onMouseDown: this.handleVariableResizeStart
  39474. }, 'Query Variables'), _react.default.createElement(_VariableEditor.VariableEditor, {
  39475. ref: function ref(n) {
  39476. _this3.variableEditorComponent = n;
  39477. },
  39478. value: this.state.variables,
  39479. variableToType: this.state.variableToType,
  39480. onEdit: this.handleEditVariables,
  39481. onHintInformationRender: this.handleHintInformationRender,
  39482. onPrettifyQuery: this.handlePrettifyQuery,
  39483. onMergeQuery: this.handleMergeQuery,
  39484. onRunQuery: this.handleEditorRunQuery,
  39485. editorTheme: this.props.editorTheme,
  39486. readOnly: this.props.readOnly
  39487. }))), _react.default.createElement("div", {
  39488. className: "resultWrap"
  39489. }, this.state.isWaitingForResponse && _react.default.createElement("div", {
  39490. className: "spinner-container"
  39491. }, _react.default.createElement("div", {
  39492. className: "spinner"
  39493. })), _react.default.createElement(_ResultViewer.ResultViewer, {
  39494. ref: function ref(c) {
  39495. _this3.resultComponent = c;
  39496. },
  39497. value: this.state.response,
  39498. editorTheme: this.props.editorTheme,
  39499. ResultsTooltip: this.props.ResultsTooltip,
  39500. ImagePreview: _ImagePreview.ImagePreview
  39501. }), footer))), _react.default.createElement("div", {
  39502. className: docExplorerWrapClasses,
  39503. style: docWrapStyle
  39504. }, _react.default.createElement("div", {
  39505. className: "docExplorerResizer",
  39506. onDoubleClick: this.handleDocsResetResize,
  39507. onMouseDown: this.handleDocsResizeStart
  39508. }), _react.default.createElement(_DocExplorer.DocExplorer, {
  39509. ref: function ref(c) {
  39510. _this3.docExplorerComponent = c;
  39511. },
  39512. schema: this.state.schema
  39513. }, _react.default.createElement("div", {
  39514. className: "docExplorerHide",
  39515. onClick: this.handleToggleDocs
  39516. }, "\u2715"))));
  39517. }
  39518. /**
  39519. * Get the query editor CodeMirror instance.
  39520. *
  39521. * @public
  39522. */
  39523. }, {
  39524. key: "getQueryEditor",
  39525. value: function getQueryEditor() {
  39526. return this.queryEditorComponent.getCodeMirror();
  39527. }
  39528. /**
  39529. * Get the variable editor CodeMirror instance.
  39530. *
  39531. * @public
  39532. */
  39533. }, {
  39534. key: "getVariableEditor",
  39535. value: function getVariableEditor() {
  39536. return this.variableEditorComponent.getCodeMirror();
  39537. }
  39538. /**
  39539. * Refresh all CodeMirror instances.
  39540. *
  39541. * @public
  39542. */
  39543. }, {
  39544. key: "refresh",
  39545. value: function refresh() {
  39546. this.queryEditorComponent.getCodeMirror().refresh();
  39547. this.variableEditorComponent.getCodeMirror().refresh();
  39548. this.resultComponent.getCodeMirror().refresh();
  39549. }
  39550. /**
  39551. * Inspect the query, automatically filling in selection sets for non-leaf
  39552. * fields which do not yet have them.
  39553. *
  39554. * @public
  39555. */
  39556. }, {
  39557. key: "autoCompleteLeafs",
  39558. value: function autoCompleteLeafs() {
  39559. var _fillLeafs = (0, _fillLeafs2.fillLeafs)(this.state.schema, this.state.query, this.props.getDefaultFieldNames),
  39560. insertions = _fillLeafs.insertions,
  39561. result = _fillLeafs.result;
  39562. if (insertions && insertions.length > 0) {
  39563. var editor = this.getQueryEditor();
  39564. editor.operation(function () {
  39565. var cursor = editor.getCursor();
  39566. var cursorIndex = editor.indexFromPos(cursor);
  39567. editor.setValue(result);
  39568. var added = 0;
  39569. var markers = insertions.map(function (_ref) {
  39570. var index = _ref.index,
  39571. string = _ref.string;
  39572. return editor.markText(editor.posFromIndex(index + added), editor.posFromIndex(index + (added += string.length)), {
  39573. className: 'autoInsertedLeaf',
  39574. clearOnEnter: true,
  39575. title: 'Automatically added leaf fields'
  39576. });
  39577. });
  39578. setTimeout(function () {
  39579. return markers.forEach(function (marker) {
  39580. return marker.clear();
  39581. });
  39582. }, 7000);
  39583. var newCursorIndex = cursorIndex;
  39584. insertions.forEach(function (_ref2) {
  39585. var index = _ref2.index,
  39586. string = _ref2.string;
  39587. if (index < cursorIndex) {
  39588. newCursorIndex += string.length;
  39589. }
  39590. });
  39591. editor.setCursor(editor.posFromIndex(newCursorIndex));
  39592. });
  39593. }
  39594. return result;
  39595. } // Private methods
  39596. }, {
  39597. key: "_fetchSchema",
  39598. value: function _fetchSchema() {
  39599. var _this4 = this;
  39600. var fetcher = this.props.fetcher;
  39601. var fetch = observableToPromise(fetcher({
  39602. query: _introspectionQueries.introspectionQuery,
  39603. operationName: _introspectionQueries.introspectionQueryName
  39604. }));
  39605. if (!isPromise(fetch)) {
  39606. this.setState({
  39607. response: 'Fetcher did not return a Promise for introspection.'
  39608. });
  39609. return;
  39610. }
  39611. fetch.then(function (result) {
  39612. if (result.data) {
  39613. return result;
  39614. } // Try the stock introspection query first, falling back on the
  39615. // sans-subscriptions query for services which do not yet support it.
  39616. var fetch2 = observableToPromise(fetcher({
  39617. query: _introspectionQueries.introspectionQuerySansSubscriptions,
  39618. operationName: _introspectionQueries.introspectionQueryName
  39619. }));
  39620. if (!isPromise(fetch)) {
  39621. throw new Error('Fetcher did not return a Promise for introspection.');
  39622. }
  39623. return fetch2;
  39624. }).then(function (result) {
  39625. // If a schema was provided while this fetch was underway, then
  39626. // satisfy the race condition by respecting the already
  39627. // provided schema.
  39628. if (_this4.state.schema !== undefined) {
  39629. return;
  39630. }
  39631. if (result && result.data) {
  39632. var schema = (0, _graphql.buildClientSchema)(result.data);
  39633. var queryFacts = (0, _getQueryFacts.default)(schema, _this4.state.query);
  39634. _this4.setState(_objectSpread({
  39635. schema: schema
  39636. }, queryFacts));
  39637. } else {
  39638. var responseString = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
  39639. _this4.setState({
  39640. // Set schema to `null` to explicitly indicate that no schema exists.
  39641. schema: null,
  39642. response: responseString
  39643. });
  39644. }
  39645. }).catch(function (error) {
  39646. console.error("ERROR:", error);
  39647. _this4.setState({
  39648. schema: null,
  39649. response: error && String(error.stack || error)
  39650. });
  39651. });
  39652. }
  39653. }, {
  39654. key: "_fetchQuery",
  39655. value: function _fetchQuery(query, variables, operationName, cb) {
  39656. var _this5 = this;
  39657. var fetcher = this.props.fetcher;
  39658. var jsonVariables = null;
  39659. try {
  39660. jsonVariables = variables && variables.trim() !== '' ? JSON.parse(variables) : null;
  39661. } catch (error) {
  39662. throw new Error("Variables are invalid JSON: ".concat(error.message, "."));
  39663. }
  39664. if (_typeof(jsonVariables) !== 'object') {
  39665. throw new Error('Variables are not a JSON object.');
  39666. }
  39667. var fetch = fetcher({
  39668. query: query,
  39669. variables: jsonVariables,
  39670. operationName: operationName
  39671. });
  39672. if (isPromise(fetch)) {
  39673. // If fetcher returned a Promise, then call the callback when the promise
  39674. // resolves, otherwise handle the error.
  39675. fetch.then(cb).catch(function (error) {
  39676. _this5.setState({
  39677. isWaitingForResponse: false,
  39678. response: error && String(error.stack || error)
  39679. });
  39680. });
  39681. } else if (isObservable(fetch)) {
  39682. // If the fetcher returned an Observable, then subscribe to it, calling
  39683. // the callback on each next value, and handling both errors and the
  39684. // completion of the Observable. Returns a Subscription object.
  39685. var subscription = fetch.subscribe({
  39686. next: cb,
  39687. error: function error(_error) {
  39688. _this5.setState({
  39689. isWaitingForResponse: false,
  39690. response: _error && String(_error.stack || _error),
  39691. subscription: null
  39692. });
  39693. },
  39694. complete: function complete() {
  39695. _this5.setState({
  39696. isWaitingForResponse: false,
  39697. subscription: null
  39698. });
  39699. }
  39700. });
  39701. return subscription;
  39702. } else {
  39703. throw new Error('Fetcher did not return Promise or Observable.');
  39704. }
  39705. }
  39706. }, {
  39707. key: "_runQueryAtCursor",
  39708. value: function _runQueryAtCursor() {
  39709. if (this.state.subscription) {
  39710. this.handleStopQuery();
  39711. return;
  39712. }
  39713. var operationName;
  39714. var operations = this.state.operations;
  39715. if (operations) {
  39716. var editor = this.getQueryEditor();
  39717. if (editor.hasFocus()) {
  39718. var cursor = editor.getCursor();
  39719. var cursorIndex = editor.indexFromPos(cursor); // Loop through all operations to see if one contains the cursor.
  39720. for (var i = 0; i < operations.length; i++) {
  39721. var operation = operations[i];
  39722. if (operation.loc.start <= cursorIndex && operation.loc.end >= cursorIndex) {
  39723. operationName = operation.name && operation.name.value;
  39724. break;
  39725. }
  39726. }
  39727. }
  39728. }
  39729. this.handleRunQuery(operationName);
  39730. }
  39731. }, {
  39732. key: "_didClickDragBar",
  39733. value: function _didClickDragBar(event) {
  39734. // Only for primary unmodified clicks
  39735. if (event.button !== 0 || event.ctrlKey) {
  39736. return false;
  39737. }
  39738. var target = event.target; // We use codemirror's gutter as the drag bar.
  39739. if (target.className.indexOf('CodeMirror-gutter') !== 0) {
  39740. return false;
  39741. } // Specifically the result window's drag bar.
  39742. var resultWindow = _reactDom.default.findDOMNode(this.resultComponent);
  39743. while (target) {
  39744. if (target === resultWindow) {
  39745. return true;
  39746. }
  39747. target = target.parentNode;
  39748. }
  39749. return false;
  39750. }
  39751. }]);
  39752. return GraphiQL;
  39753. }(_react.default.Component); // Configure the UI by providing this Component as a child of GraphiQL.
  39754. exports.GraphiQL = GraphiQL;
  39755. _defineProperty(GraphiQL, "propTypes", {
  39756. fetcher: _propTypes.default.func.isRequired,
  39757. schema: _propTypes.default.instanceOf(_graphql.GraphQLSchema),
  39758. query: _propTypes.default.string,
  39759. variables: _propTypes.default.string,
  39760. operationName: _propTypes.default.string,
  39761. response: _propTypes.default.string,
  39762. storage: _propTypes.default.shape({
  39763. getItem: _propTypes.default.func,
  39764. setItem: _propTypes.default.func,
  39765. removeItem: _propTypes.default.func
  39766. }),
  39767. defaultQuery: _propTypes.default.string,
  39768. onCopyQuery: _propTypes.default.func,
  39769. onEditQuery: _propTypes.default.func,
  39770. onEditVariables: _propTypes.default.func,
  39771. onEditOperationName: _propTypes.default.func,
  39772. onToggleDocs: _propTypes.default.func,
  39773. getDefaultFieldNames: _propTypes.default.func,
  39774. editorTheme: _propTypes.default.string,
  39775. onToggleHistory: _propTypes.default.func,
  39776. ResultsTooltip: _propTypes.default.any,
  39777. readOnly: _propTypes.default.bool,
  39778. docExplorerOpen: _propTypes.default.bool
  39779. });
  39780. GraphiQL.Logo = function GraphiQLLogo(props) {
  39781. return _react.default.createElement("div", {
  39782. className: "title"
  39783. }, props.children || _react.default.createElement("span", null, 'Graph', _react.default.createElement("em", null, 'i'), 'QL'));
  39784. }; // Configure the UI by providing this Component as a child of GraphiQL.
  39785. GraphiQL.Toolbar = function GraphiQLToolbar(props) {
  39786. return _react.default.createElement("div", {
  39787. className: "toolbar"
  39788. }, props.children);
  39789. }; // Export main windows/panes to be used separately if desired.
  39790. GraphiQL.QueryEditor = _QueryEditor.QueryEditor;
  39791. GraphiQL.VariableEditor = _VariableEditor.VariableEditor;
  39792. GraphiQL.ResultViewer = _ResultViewer.ResultViewer; // Add a button to the Toolbar.
  39793. GraphiQL.Button = _ToolbarButton.ToolbarButton;
  39794. GraphiQL.ToolbarButton = _ToolbarButton.ToolbarButton; // Don't break existing API.
  39795. // Add a group of buttons to the Toolbar
  39796. GraphiQL.Group = _ToolbarGroup.ToolbarGroup; // Add a menu of items to the Toolbar.
  39797. GraphiQL.Menu = _ToolbarMenu.ToolbarMenu;
  39798. GraphiQL.MenuItem = _ToolbarMenu.ToolbarMenuItem; // Add a select-option input to the Toolbar.
  39799. GraphiQL.Select = _ToolbarSelect.ToolbarSelect;
  39800. GraphiQL.SelectOption = _ToolbarSelect.ToolbarSelectOption; // Configure the UI by providing this Component as a child of GraphiQL.
  39801. GraphiQL.Footer = function GraphiQLFooter(props) {
  39802. return _react.default.createElement("div", {
  39803. className: "footer"
  39804. }, props.children);
  39805. };
  39806. var defaultQuery = '# Welcome to GraphiQL on EliasDB\n#\n{\n Station(key : "13") {\n key\n name\n lines(traverse:":::Station") {\n key\n name\n kind\n }\n }\n}\n'
  39807. function isPromise(value) {
  39808. return _typeof(value) === 'object' && typeof value.then === 'function';
  39809. } // Duck-type Observable.take(1).toPromise()
  39810. function observableToPromise(observable) {
  39811. if (!isObservable(observable)) {
  39812. return observable;
  39813. }
  39814. return new Promise(function (resolve, reject) {
  39815. var subscription = observable.subscribe(function (v) {
  39816. resolve(v);
  39817. subscription.unsubscribe();
  39818. }, reject, function () {
  39819. reject(new Error('no value resolved'));
  39820. });
  39821. });
  39822. } // Duck-type observable detection.
  39823. function isObservable(value) {
  39824. return _typeof(value) === 'object' && typeof value.subscribe === 'function';
  39825. }
  39826. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  39827. },{"../utility/CodeMirrorSizer":240,"../utility/StorageAPI":242,"../utility/debounce":243,"../utility/elementPosition":244,"../utility/fillLeafs":245,"../utility/find":246,"../utility/getQueryFacts":247,"../utility/getSelectedOperationName":248,"../utility/introspectionQueries":249,"../utility/mergeAst":250,"./DocExplorer":217,"./ExecuteButton":227,"./ImagePreview":230,"./QueryEditor":231,"./QueryHistory":232,"./ResultViewer":233,"./ToolbarButton":234,"./ToolbarGroup":235,"./ToolbarMenu":236,"./ToolbarSelect":237,"./VariableEditor":238,"copy-to-clipboard":17,"graphql":29,"prop-types":202}],229:[function(require,module,exports){
  39828. (function (global){
  39829. "use strict";
  39830. Object.defineProperty(exports, "__esModule", {
  39831. value: true
  39832. });
  39833. exports.default = void 0;
  39834. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  39835. var _propTypes = _interopRequireDefault(require("prop-types"));
  39836. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39837. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  39838. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39839. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  39840. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  39841. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  39842. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  39843. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  39844. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  39845. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39846. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  39847. var HistoryQuery =
  39848. /*#__PURE__*/
  39849. function (_React$Component) {
  39850. _inherits(HistoryQuery, _React$Component);
  39851. function HistoryQuery(props) {
  39852. var _this;
  39853. _classCallCheck(this, HistoryQuery);
  39854. _this = _possibleConstructorReturn(this, _getPrototypeOf(HistoryQuery).call(this, props));
  39855. _defineProperty(_assertThisInitialized(_this), "editField", null);
  39856. _this.state = {
  39857. showButtons: false,
  39858. editable: false
  39859. };
  39860. return _this;
  39861. }
  39862. _createClass(HistoryQuery, [{
  39863. key: "render",
  39864. value: function render() {
  39865. var _this2 = this;
  39866. var editStyles = {
  39867. display: this.state.showButtons ? '' : 'none',
  39868. marginLeft: '10px'
  39869. };
  39870. var starStyles = {
  39871. display: this.props.favorite || this.state.showButtons ? '' : 'none',
  39872. marginLeft: '10px'
  39873. };
  39874. var displayName = this.props.label || this.props.operationName || this.props.query.split('\n').filter(function (line) {
  39875. return line.indexOf('#') !== 0;
  39876. }).join('');
  39877. var starIcon = this.props.favorite ? "\u2605" : "\u2606";
  39878. return _react.default.createElement("p", {
  39879. className: this.state.editable ? 'editable' : undefined,
  39880. onClick: this.handleClick.bind(this),
  39881. onMouseEnter: this.handleMouseEnter.bind(this),
  39882. onMouseLeave: this.handleMouseLeave.bind(this)
  39883. }, this.state.editable ? _react.default.createElement("input", {
  39884. type: "text",
  39885. defaultValue: this.props.label,
  39886. ref: function ref(c) {
  39887. return _this2.editField = c;
  39888. },
  39889. onBlur: this.handleFieldBlur.bind(this),
  39890. onKeyDown: this.handleFieldKeyDown.bind(this),
  39891. placeholder: "Type a label"
  39892. }) : _react.default.createElement("span", {
  39893. className: "history-label"
  39894. }, displayName), _react.default.createElement("span", {
  39895. onClick: this.handleEditClick.bind(this),
  39896. style: editStyles
  39897. }, "\u270E"), _react.default.createElement("span", {
  39898. onClick: this.handleStarClick.bind(this),
  39899. style: starStyles
  39900. }, starIcon));
  39901. }
  39902. }, {
  39903. key: "handleMouseEnter",
  39904. value: function handleMouseEnter() {
  39905. this.setState({
  39906. showButtons: true
  39907. });
  39908. }
  39909. }, {
  39910. key: "handleMouseLeave",
  39911. value: function handleMouseLeave() {
  39912. this.setState({
  39913. showButtons: false
  39914. });
  39915. }
  39916. }, {
  39917. key: "handleClick",
  39918. value: function handleClick() {
  39919. this.props.onSelect(this.props.query, this.props.variables, this.props.operationName, this.props.label);
  39920. }
  39921. }, {
  39922. key: "handleStarClick",
  39923. value: function handleStarClick(e) {
  39924. e.stopPropagation();
  39925. this.props.handleToggleFavorite(this.props.query, this.props.variables, this.props.operationName, this.props.label, this.props.favorite);
  39926. }
  39927. }, {
  39928. key: "handleFieldBlur",
  39929. value: function handleFieldBlur(e) {
  39930. e.stopPropagation();
  39931. this.setState({
  39932. editable: false
  39933. });
  39934. this.props.handleEditLabel(this.props.query, this.props.variables, this.props.operationName, e.target.value, this.props.favorite);
  39935. }
  39936. }, {
  39937. key: "handleFieldKeyDown",
  39938. value: function handleFieldKeyDown(e) {
  39939. if (e.keyCode === 13) {
  39940. e.stopPropagation();
  39941. this.setState({
  39942. editable: false
  39943. });
  39944. this.props.handleEditLabel(this.props.query, this.props.variables, this.props.operationName, e.target.value, this.props.favorite);
  39945. }
  39946. }
  39947. }, {
  39948. key: "handleEditClick",
  39949. value: function handleEditClick(e) {
  39950. var _this3 = this;
  39951. e.stopPropagation();
  39952. this.setState({
  39953. editable: true
  39954. }, function () {
  39955. if (_this3.editField) {
  39956. _this3.editField.focus();
  39957. }
  39958. });
  39959. }
  39960. }]);
  39961. return HistoryQuery;
  39962. }(_react.default.Component);
  39963. exports.default = HistoryQuery;
  39964. _defineProperty(HistoryQuery, "propTypes", {
  39965. favorite: _propTypes.default.bool,
  39966. favoriteSize: _propTypes.default.number,
  39967. handleEditLabel: _propTypes.default.func,
  39968. handleToggleFavorite: _propTypes.default.func,
  39969. operationName: _propTypes.default.string,
  39970. onSelect: _propTypes.default.func,
  39971. query: _propTypes.default.string,
  39972. variables: _propTypes.default.string,
  39973. label: _propTypes.default.string
  39974. });
  39975. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  39976. },{"prop-types":202}],230:[function(require,module,exports){
  39977. (function (global){
  39978. "use strict";
  39979. Object.defineProperty(exports, "__esModule", {
  39980. value: true
  39981. });
  39982. exports.ImagePreview = void 0;
  39983. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  39984. var _propTypes = _interopRequireDefault(require("prop-types"));
  39985. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39986. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  39987. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  39988. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  39989. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  39990. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  39991. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  39992. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  39993. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  39994. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  39995. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  39996. function tokenToURL(token) {
  39997. if (token.type !== 'string') {
  39998. return null;
  39999. }
  40000. var value = token.string.slice(1).slice(0, -1).trim();
  40001. try {
  40002. var location = window.location;
  40003. return new URL(value, location.protocol + '//' + location.host);
  40004. } catch (err) {
  40005. return null;
  40006. }
  40007. }
  40008. function isImageURL(url) {
  40009. return /(bmp|gif|jpeg|jpg|png|svg)$/.test(url.pathname);
  40010. }
  40011. var ImagePreview =
  40012. /*#__PURE__*/
  40013. function (_React$Component) {
  40014. _inherits(ImagePreview, _React$Component);
  40015. _createClass(ImagePreview, null, [{
  40016. key: "shouldRender",
  40017. value: function shouldRender(token) {
  40018. var url = tokenToURL(token);
  40019. return url ? isImageURL(url) : false;
  40020. }
  40021. }]);
  40022. function ImagePreview(props) {
  40023. var _this;
  40024. _classCallCheck(this, ImagePreview);
  40025. _this = _possibleConstructorReturn(this, _getPrototypeOf(ImagePreview).call(this, props));
  40026. _defineProperty(_assertThisInitialized(_this), "state", {
  40027. width: null,
  40028. height: null,
  40029. src: null,
  40030. mime: null
  40031. });
  40032. return _this;
  40033. }
  40034. _createClass(ImagePreview, [{
  40035. key: "componentDidMount",
  40036. value: function componentDidMount() {
  40037. this._updateMetadata();
  40038. }
  40039. }, {
  40040. key: "componentDidUpdate",
  40041. value: function componentDidUpdate() {
  40042. this._updateMetadata();
  40043. }
  40044. }, {
  40045. key: "render",
  40046. value: function render() {
  40047. var _this2 = this;
  40048. var dims = null;
  40049. if (this.state.width !== null && this.state.height !== null) {
  40050. var dimensions = this.state.width + 'x' + this.state.height;
  40051. if (this.state.mime !== null) {
  40052. dimensions += ' ' + this.state.mime;
  40053. }
  40054. dims = _react.default.createElement("div", null, dimensions);
  40055. }
  40056. return _react.default.createElement("div", null, _react.default.createElement("img", {
  40057. onLoad: function onLoad() {
  40058. return _this2._updateMetadata();
  40059. },
  40060. ref: function ref(node) {
  40061. _this2._node = node;
  40062. },
  40063. src: tokenToURL(this.props.token)
  40064. }), dims);
  40065. }
  40066. }, {
  40067. key: "_updateMetadata",
  40068. value: function _updateMetadata() {
  40069. var _this3 = this;
  40070. if (!this._node) {
  40071. return;
  40072. }
  40073. var width = this._node.naturalWidth;
  40074. var height = this._node.naturalHeight;
  40075. var src = this._node.src;
  40076. if (src !== this.state.src) {
  40077. this.setState({
  40078. src: src
  40079. });
  40080. fetch(src, {
  40081. method: 'HEAD'
  40082. }).then(function (response) {
  40083. _this3.setState({
  40084. mime: response.headers.get('Content-Type')
  40085. });
  40086. });
  40087. }
  40088. if (width !== this.state.width || height !== this.state.height) {
  40089. this.setState({
  40090. height: height,
  40091. width: width
  40092. });
  40093. }
  40094. }
  40095. }]);
  40096. return ImagePreview;
  40097. }(_react.default.Component);
  40098. exports.ImagePreview = ImagePreview;
  40099. _defineProperty(ImagePreview, "propTypes", {
  40100. token: _propTypes.default.any
  40101. });
  40102. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40103. },{"prop-types":202}],231:[function(require,module,exports){
  40104. (function (global){
  40105. "use strict";
  40106. Object.defineProperty(exports, "__esModule", {
  40107. value: true
  40108. });
  40109. exports.QueryEditor = void 0;
  40110. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40111. var _propTypes = _interopRequireDefault(require("prop-types"));
  40112. var _graphql = require("graphql");
  40113. var _markdownIt = _interopRequireDefault(require("markdown-it"));
  40114. var _normalizeWhitespace = require("../utility/normalizeWhitespace");
  40115. var _onHasCompletion = _interopRequireDefault(require("../utility/onHasCompletion"));
  40116. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40117. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40118. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40119. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40120. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40121. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40122. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40123. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40124. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40125. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40126. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40127. var md = new _markdownIt.default();
  40128. var AUTO_COMPLETE_AFTER_KEY = /^[a-zA-Z0-9_@(]$/;
  40129. /**
  40130. * QueryEditor
  40131. *
  40132. * Maintains an instance of CodeMirror responsible for editing a GraphQL query.
  40133. *
  40134. * Props:
  40135. *
  40136. * - schema: A GraphQLSchema instance enabling editor linting and hinting.
  40137. * - value: The text of the editor.
  40138. * - onEdit: A function called when the editor changes, given the edited text.
  40139. * - readOnly: Turns the editor to read-only mode.
  40140. *
  40141. */
  40142. var QueryEditor =
  40143. /*#__PURE__*/
  40144. function (_React$Component) {
  40145. _inherits(QueryEditor, _React$Component);
  40146. function QueryEditor(props) {
  40147. var _this;
  40148. _classCallCheck(this, QueryEditor);
  40149. _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryEditor).call(this)); // Keep a cached version of the value, this cache will be updated when the
  40150. // editor is updated, which can later be used to protect the editor from
  40151. // unnecessary updates during the update lifecycle.
  40152. _defineProperty(_assertThisInitialized(_this), "_onKeyUp", function (cm, event) {
  40153. if (AUTO_COMPLETE_AFTER_KEY.test(event.key)) {
  40154. _this.editor.execCommand('autocomplete');
  40155. }
  40156. });
  40157. _defineProperty(_assertThisInitialized(_this), "_onEdit", function () {
  40158. if (!_this.ignoreChangeEvent) {
  40159. _this.cachedValue = _this.editor.getValue();
  40160. if (_this.props.onEdit) {
  40161. _this.props.onEdit(_this.cachedValue);
  40162. }
  40163. }
  40164. });
  40165. _defineProperty(_assertThisInitialized(_this), "_onHasCompletion", function (cm, data) {
  40166. (0, _onHasCompletion.default)(cm, data, _this.props.onHintInformationRender);
  40167. });
  40168. _this.cachedValue = props.value || '';
  40169. return _this;
  40170. }
  40171. _createClass(QueryEditor, [{
  40172. key: "componentDidMount",
  40173. value: function componentDidMount() {
  40174. var _this2 = this;
  40175. // Lazily require to ensure requiring GraphiQL outside of a Browser context
  40176. // does not produce an error.
  40177. var CodeMirror = require('codemirror');
  40178. require('codemirror/addon/hint/show-hint');
  40179. require('codemirror/addon/comment/comment');
  40180. require('codemirror/addon/edit/matchbrackets');
  40181. require('codemirror/addon/edit/closebrackets');
  40182. require('codemirror/addon/fold/foldgutter');
  40183. require('codemirror/addon/fold/brace-fold');
  40184. require('codemirror/addon/search/search');
  40185. require('codemirror/addon/search/searchcursor');
  40186. require('codemirror/addon/search/jump-to-line');
  40187. require('codemirror/addon/dialog/dialog');
  40188. require('codemirror/addon/lint/lint');
  40189. require('codemirror/keymap/sublime');
  40190. require('codemirror-graphql/hint');
  40191. require('codemirror-graphql/lint');
  40192. require('codemirror-graphql/info');
  40193. require('codemirror-graphql/jump');
  40194. require('codemirror-graphql/mode');
  40195. this.editor = CodeMirror(this._node, {
  40196. value: this.props.value || '',
  40197. lineNumbers: true,
  40198. tabSize: 2,
  40199. mode: 'graphql',
  40200. theme: this.props.editorTheme || 'graphiql',
  40201. keyMap: 'sublime',
  40202. autoCloseBrackets: true,
  40203. matchBrackets: true,
  40204. showCursorWhenSelecting: true,
  40205. readOnly: this.props.readOnly ? 'nocursor' : false,
  40206. foldGutter: {
  40207. minFoldSize: 4
  40208. },
  40209. lint: {
  40210. schema: this.props.schema
  40211. },
  40212. hintOptions: {
  40213. schema: this.props.schema,
  40214. closeOnUnfocus: false,
  40215. completeSingle: false,
  40216. container: this._node
  40217. },
  40218. info: {
  40219. schema: this.props.schema,
  40220. renderDescription: function renderDescription(text) {
  40221. return md.render(text);
  40222. },
  40223. onClick: function onClick(reference) {
  40224. return _this2.props.onClickReference(reference);
  40225. }
  40226. },
  40227. jump: {
  40228. schema: this.props.schema,
  40229. onClick: function onClick(reference) {
  40230. return _this2.props.onClickReference(reference);
  40231. }
  40232. },
  40233. gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
  40234. extraKeys: {
  40235. 'Cmd-Space': function CmdSpace() {
  40236. return _this2.editor.showHint({
  40237. completeSingle: true,
  40238. container: _this2._node
  40239. });
  40240. },
  40241. 'Ctrl-Space': function CtrlSpace() {
  40242. return _this2.editor.showHint({
  40243. completeSingle: true,
  40244. container: _this2._node
  40245. });
  40246. },
  40247. 'Alt-Space': function AltSpace() {
  40248. return _this2.editor.showHint({
  40249. completeSingle: true,
  40250. container: _this2._node
  40251. });
  40252. },
  40253. 'Shift-Space': function ShiftSpace() {
  40254. return _this2.editor.showHint({
  40255. completeSingle: true,
  40256. container: _this2._node
  40257. });
  40258. },
  40259. 'Shift-Alt-Space': function ShiftAltSpace() {
  40260. return _this2.editor.showHint({
  40261. completeSingle: true,
  40262. container: _this2._node
  40263. });
  40264. },
  40265. 'Cmd-Enter': function CmdEnter() {
  40266. if (_this2.props.onRunQuery) {
  40267. _this2.props.onRunQuery();
  40268. }
  40269. },
  40270. 'Ctrl-Enter': function CtrlEnter() {
  40271. if (_this2.props.onRunQuery) {
  40272. _this2.props.onRunQuery();
  40273. }
  40274. },
  40275. 'Shift-Ctrl-C': function ShiftCtrlC() {
  40276. if (_this2.props.onCopyQuery) {
  40277. _this2.props.onCopyQuery();
  40278. }
  40279. },
  40280. 'Shift-Ctrl-P': function ShiftCtrlP() {
  40281. if (_this2.props.onPrettifyQuery) {
  40282. _this2.props.onPrettifyQuery();
  40283. }
  40284. },
  40285. 'Shift-Ctrl-M': function ShiftCtrlM() {
  40286. if (_this2.props.onMergeQuery) {
  40287. _this2.props.onMergeQuery();
  40288. }
  40289. },
  40290. // Persistent search box in Query Editor
  40291. 'Cmd-F': 'findPersistent',
  40292. 'Ctrl-F': 'findPersistent',
  40293. 'Cmd-G': 'findPersistent',
  40294. 'Ctrl-G': 'findPersistent',
  40295. // Editor improvements
  40296. 'Ctrl-Left': 'goSubwordLeft',
  40297. 'Ctrl-Right': 'goSubwordRight',
  40298. 'Alt-Left': 'goGroupLeft',
  40299. 'Alt-Right': 'goGroupRight'
  40300. }
  40301. });
  40302. this.editor.on('change', this._onEdit);
  40303. this.editor.on('keyup', this._onKeyUp);
  40304. this.editor.on('hasCompletion', this._onHasCompletion);
  40305. this.editor.on('beforeChange', this._onBeforeChange);
  40306. }
  40307. }, {
  40308. key: "componentDidUpdate",
  40309. value: function componentDidUpdate(prevProps) {
  40310. var CodeMirror = require('codemirror'); // Ensure the changes caused by this update are not interpretted as
  40311. // user-input changes which could otherwise result in an infinite
  40312. // event loop.
  40313. this.ignoreChangeEvent = true;
  40314. if (this.props.schema !== prevProps.schema) {
  40315. this.editor.options.lint.schema = this.props.schema;
  40316. this.editor.options.hintOptions.schema = this.props.schema;
  40317. this.editor.options.info.schema = this.props.schema;
  40318. this.editor.options.jump.schema = this.props.schema;
  40319. CodeMirror.signal(this.editor, 'change', this.editor);
  40320. }
  40321. if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue) {
  40322. this.cachedValue = this.props.value;
  40323. this.editor.setValue(this.props.value);
  40324. }
  40325. this.ignoreChangeEvent = false;
  40326. }
  40327. }, {
  40328. key: "componentWillUnmount",
  40329. value: function componentWillUnmount() {
  40330. this.editor.off('change', this._onEdit);
  40331. this.editor.off('keyup', this._onKeyUp);
  40332. this.editor.off('hasCompletion', this._onHasCompletion);
  40333. this.editor = null;
  40334. }
  40335. }, {
  40336. key: "render",
  40337. value: function render() {
  40338. var _this3 = this;
  40339. return _react.default.createElement("div", {
  40340. className: "query-editor",
  40341. ref: function ref(node) {
  40342. _this3._node = node;
  40343. }
  40344. });
  40345. }
  40346. /**
  40347. * Public API for retrieving the CodeMirror instance from this
  40348. * React component.
  40349. */
  40350. }, {
  40351. key: "getCodeMirror",
  40352. value: function getCodeMirror() {
  40353. return this.editor;
  40354. }
  40355. /**
  40356. * Public API for retrieving the DOM client height for this component.
  40357. */
  40358. }, {
  40359. key: "getClientHeight",
  40360. value: function getClientHeight() {
  40361. return this._node && this._node.clientHeight;
  40362. }
  40363. }, {
  40364. key: "_onBeforeChange",
  40365. value: function _onBeforeChange(instance, change) {
  40366. // The update function is only present on non-redo, non-undo events.
  40367. if (change.origin === 'paste') {
  40368. var text = change.text.map(_normalizeWhitespace.normalizeWhitespace);
  40369. change.update(change.from, change.to, text);
  40370. }
  40371. }
  40372. }]);
  40373. return QueryEditor;
  40374. }(_react.default.Component);
  40375. exports.QueryEditor = QueryEditor;
  40376. _defineProperty(QueryEditor, "propTypes", {
  40377. schema: _propTypes.default.instanceOf(_graphql.GraphQLSchema),
  40378. value: _propTypes.default.string,
  40379. onEdit: _propTypes.default.func,
  40380. readOnly: _propTypes.default.bool,
  40381. onHintInformationRender: _propTypes.default.func,
  40382. onClickReference: _propTypes.default.func,
  40383. onCopyQuery: _propTypes.default.func,
  40384. onPrettifyQuery: _propTypes.default.func,
  40385. onMergeQuery: _propTypes.default.func,
  40386. onRunQuery: _propTypes.default.func,
  40387. editorTheme: _propTypes.default.string
  40388. });
  40389. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40390. },{"../utility/normalizeWhitespace":251,"../utility/onHasCompletion":252,"codemirror":16,"codemirror-graphql/hint":253,"codemirror-graphql/info":254,"codemirror-graphql/jump":255,"codemirror-graphql/lint":256,"codemirror-graphql/mode":257,"codemirror/addon/comment/comment":3,"codemirror/addon/dialog/dialog":4,"codemirror/addon/edit/closebrackets":5,"codemirror/addon/edit/matchbrackets":6,"codemirror/addon/fold/brace-fold":7,"codemirror/addon/fold/foldgutter":9,"codemirror/addon/hint/show-hint":10,"codemirror/addon/lint/lint":11,"codemirror/addon/search/jump-to-line":12,"codemirror/addon/search/search":13,"codemirror/addon/search/searchcursor":14,"codemirror/keymap/sublime":15,"graphql":29,"markdown-it":140,"prop-types":202}],232:[function(require,module,exports){
  40391. (function (global){
  40392. "use strict";
  40393. Object.defineProperty(exports, "__esModule", {
  40394. value: true
  40395. });
  40396. exports.QueryHistory = void 0;
  40397. var _graphql = require("graphql");
  40398. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40399. var _propTypes = _interopRequireDefault(require("prop-types"));
  40400. var _QueryStore = _interopRequireDefault(require("../utility/QueryStore"));
  40401. var _HistoryQuery = _interopRequireDefault(require("./HistoryQuery"));
  40402. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40403. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40404. function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  40405. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  40406. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  40407. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  40408. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  40409. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  40410. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40411. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40412. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40413. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40414. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40415. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40416. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40417. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40418. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40419. var shouldSaveQuery = function shouldSaveQuery(nextProps, current, lastQuerySaved) {
  40420. if (nextProps.queryID === current.queryID) {
  40421. return false;
  40422. }
  40423. try {
  40424. (0, _graphql.parse)(nextProps.query);
  40425. } catch (e) {
  40426. return false;
  40427. }
  40428. if (!lastQuerySaved) {
  40429. return true;
  40430. }
  40431. if (JSON.stringify(nextProps.query) === JSON.stringify(lastQuerySaved.query)) {
  40432. if (JSON.stringify(nextProps.variables) === JSON.stringify(lastQuerySaved.variables)) {
  40433. return false;
  40434. }
  40435. if (!nextProps.variables && !lastQuerySaved.variables) {
  40436. return false;
  40437. }
  40438. }
  40439. return true;
  40440. };
  40441. var MAX_HISTORY_LENGTH = 20;
  40442. var QueryHistory =
  40443. /*#__PURE__*/
  40444. function (_React$Component) {
  40445. _inherits(QueryHistory, _React$Component);
  40446. function QueryHistory(props) {
  40447. var _this;
  40448. _classCallCheck(this, QueryHistory);
  40449. _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryHistory).call(this, props));
  40450. _defineProperty(_assertThisInitialized(_this), "toggleFavorite", function (query, variables, operationName, label, favorite) {
  40451. var item = {
  40452. query: query,
  40453. variables: variables,
  40454. operationName: operationName,
  40455. label: label
  40456. };
  40457. if (!_this.favoriteStore.contains(item)) {
  40458. item.favorite = true;
  40459. _this.favoriteStore.push(item);
  40460. } else if (favorite) {
  40461. item.favorite = false;
  40462. _this.favoriteStore.delete(item);
  40463. }
  40464. _this.setState({
  40465. queries: [].concat(_toConsumableArray(_this.historyStore.items), _toConsumableArray(_this.favoriteStore.items))
  40466. });
  40467. });
  40468. _defineProperty(_assertThisInitialized(_this), "editLabel", function (query, variables, operationName, label, favorite) {
  40469. var item = {
  40470. query: query,
  40471. variables: variables,
  40472. operationName: operationName,
  40473. label: label
  40474. };
  40475. if (favorite) {
  40476. _this.favoriteStore.edit(_objectSpread({}, item, {
  40477. favorite: favorite
  40478. }));
  40479. } else {
  40480. _this.historyStore.edit(item);
  40481. }
  40482. _this.setState({
  40483. queries: [].concat(_toConsumableArray(_this.historyStore.items), _toConsumableArray(_this.favoriteStore.items))
  40484. });
  40485. });
  40486. _this.historyStore = new _QueryStore.default('queries', props.storage);
  40487. _this.favoriteStore = new _QueryStore.default('favorites', props.storage);
  40488. var historyQueries = _this.historyStore.fetchAll();
  40489. var favoriteQueries = _this.favoriteStore.fetchAll();
  40490. var queries = historyQueries.concat(favoriteQueries);
  40491. _this.state = {
  40492. queries: queries
  40493. };
  40494. return _this;
  40495. }
  40496. _createClass(QueryHistory, [{
  40497. key: "componentWillReceiveProps",
  40498. value: function componentWillReceiveProps(nextProps) {
  40499. if (shouldSaveQuery(nextProps, this.props, this.historyStore.fetchRecent())) {
  40500. var item = {
  40501. query: nextProps.query,
  40502. variables: nextProps.variables,
  40503. operationName: nextProps.operationName
  40504. };
  40505. this.historyStore.push(item);
  40506. if (this.historyStore.length > MAX_HISTORY_LENGTH) {
  40507. this.historyStore.shift();
  40508. }
  40509. var historyQueries = this.historyStore.items;
  40510. var favoriteQueries = this.favoriteStore.items;
  40511. var queries = historyQueries.concat(favoriteQueries);
  40512. this.setState({
  40513. queries: queries
  40514. });
  40515. }
  40516. }
  40517. }, {
  40518. key: "render",
  40519. value: function render() {
  40520. var _this2 = this;
  40521. var queries = this.state.queries.slice().reverse();
  40522. var queryNodes = queries.map(function (query, i) {
  40523. return _react.default.createElement(_HistoryQuery.default, _extends({
  40524. handleEditLabel: _this2.editLabel,
  40525. handleToggleFavorite: _this2.toggleFavorite,
  40526. key: i,
  40527. onSelect: _this2.props.onSelectQuery
  40528. }, query));
  40529. });
  40530. return _react.default.createElement("div", null, _react.default.createElement("div", {
  40531. className: "history-title-bar"
  40532. }, _react.default.createElement("div", {
  40533. className: "history-title"
  40534. }, 'History'), _react.default.createElement("div", {
  40535. className: "doc-explorer-rhs"
  40536. }, this.props.children)), _react.default.createElement("div", {
  40537. className: "history-contents"
  40538. }, queryNodes));
  40539. }
  40540. }]);
  40541. return QueryHistory;
  40542. }(_react.default.Component);
  40543. exports.QueryHistory = QueryHistory;
  40544. _defineProperty(QueryHistory, "propTypes", {
  40545. query: _propTypes.default.string,
  40546. variables: _propTypes.default.string,
  40547. operationName: _propTypes.default.string,
  40548. queryID: _propTypes.default.number,
  40549. onSelectQuery: _propTypes.default.func,
  40550. storage: _propTypes.default.object
  40551. });
  40552. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40553. },{"../utility/QueryStore":241,"./HistoryQuery":229,"graphql":29,"prop-types":202}],233:[function(require,module,exports){
  40554. (function (global){
  40555. "use strict";
  40556. Object.defineProperty(exports, "__esModule", {
  40557. value: true
  40558. });
  40559. exports.ResultViewer = void 0;
  40560. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40561. var _reactDom = _interopRequireDefault((typeof window !== "undefined" ? window['ReactDOM'] : typeof global !== "undefined" ? global['ReactDOM'] : null));
  40562. var _propTypes = _interopRequireDefault(require("prop-types"));
  40563. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40564. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40565. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40566. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40567. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40568. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40569. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40570. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40571. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40572. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40573. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40574. /**
  40575. * ResultViewer
  40576. *
  40577. * Maintains an instance of CodeMirror for viewing a GraphQL response.
  40578. *
  40579. * Props:
  40580. *
  40581. * - value: The text of the editor.
  40582. *
  40583. */
  40584. var ResultViewer =
  40585. /*#__PURE__*/
  40586. function (_React$Component) {
  40587. _inherits(ResultViewer, _React$Component);
  40588. function ResultViewer() {
  40589. _classCallCheck(this, ResultViewer);
  40590. return _possibleConstructorReturn(this, _getPrototypeOf(ResultViewer).call(this));
  40591. }
  40592. _createClass(ResultViewer, [{
  40593. key: "componentDidMount",
  40594. value: function componentDidMount() {
  40595. // Lazily require to ensure requiring GraphiQL outside of a Browser context
  40596. // does not produce an error.
  40597. var CodeMirror = require('codemirror');
  40598. require('codemirror/addon/fold/foldgutter');
  40599. require('codemirror/addon/fold/brace-fold');
  40600. require('codemirror/addon/dialog/dialog');
  40601. require('codemirror/addon/search/search');
  40602. require('codemirror/addon/search/searchcursor');
  40603. require('codemirror/addon/search/jump-to-line');
  40604. require('codemirror/keymap/sublime');
  40605. require('codemirror-graphql/results/mode');
  40606. var Tooltip = this.props.ResultsTooltip;
  40607. var ImagePreview = this.props.ImagePreview;
  40608. if (Tooltip || ImagePreview) {
  40609. require('codemirror-graphql/utils/info-addon');
  40610. var tooltipDiv = document.createElement('div');
  40611. CodeMirror.registerHelper('info', 'graphql-results', function (token, options, cm, pos) {
  40612. var infoElements = [];
  40613. if (Tooltip) {
  40614. infoElements.push(_react.default.createElement(Tooltip, {
  40615. pos: pos
  40616. }));
  40617. }
  40618. if (ImagePreview && typeof ImagePreview.shouldRender === 'function' && ImagePreview.shouldRender(token)) {
  40619. infoElements.push(_react.default.createElement(ImagePreview, {
  40620. token: token
  40621. }));
  40622. }
  40623. if (!infoElements.length) {
  40624. _reactDom.default.unmountComponentAtNode(tooltipDiv);
  40625. return null;
  40626. }
  40627. _reactDom.default.render(_react.default.createElement("div", null, infoElements), tooltipDiv);
  40628. return tooltipDiv;
  40629. });
  40630. }
  40631. this.viewer = CodeMirror(this._node, {
  40632. lineWrapping: true,
  40633. value: this.props.value || '',
  40634. readOnly: true,
  40635. theme: this.props.editorTheme || 'graphiql',
  40636. mode: 'graphql-results',
  40637. keyMap: 'sublime',
  40638. foldGutter: {
  40639. minFoldSize: 4
  40640. },
  40641. gutters: ['CodeMirror-foldgutter'],
  40642. info: Boolean(this.props.ResultsTooltip || this.props.ImagePreview),
  40643. extraKeys: {
  40644. // Persistent search box in Query Editor
  40645. 'Cmd-F': 'findPersistent',
  40646. 'Ctrl-F': 'findPersistent',
  40647. 'Cmd-G': 'findPersistent',
  40648. 'Ctrl-G': 'findPersistent',
  40649. // Editor improvements
  40650. 'Ctrl-Left': 'goSubwordLeft',
  40651. 'Ctrl-Right': 'goSubwordRight',
  40652. 'Alt-Left': 'goGroupLeft',
  40653. 'Alt-Right': 'goGroupRight'
  40654. }
  40655. });
  40656. }
  40657. }, {
  40658. key: "shouldComponentUpdate",
  40659. value: function shouldComponentUpdate(nextProps) {
  40660. return this.props.value !== nextProps.value;
  40661. }
  40662. }, {
  40663. key: "componentDidUpdate",
  40664. value: function componentDidUpdate() {
  40665. this.viewer.setValue(this.props.value || '');
  40666. }
  40667. }, {
  40668. key: "componentWillUnmount",
  40669. value: function componentWillUnmount() {
  40670. this.viewer = null;
  40671. }
  40672. }, {
  40673. key: "render",
  40674. value: function render() {
  40675. var _this = this;
  40676. return _react.default.createElement("div", {
  40677. className: "result-window",
  40678. ref: function ref(node) {
  40679. _this._node = node;
  40680. }
  40681. });
  40682. }
  40683. /**
  40684. * Public API for retrieving the CodeMirror instance from this
  40685. * React component.
  40686. */
  40687. }, {
  40688. key: "getCodeMirror",
  40689. value: function getCodeMirror() {
  40690. return this.viewer;
  40691. }
  40692. /**
  40693. * Public API for retrieving the DOM client height for this component.
  40694. */
  40695. }, {
  40696. key: "getClientHeight",
  40697. value: function getClientHeight() {
  40698. return this._node && this._node.clientHeight;
  40699. }
  40700. }]);
  40701. return ResultViewer;
  40702. }(_react.default.Component);
  40703. exports.ResultViewer = ResultViewer;
  40704. _defineProperty(ResultViewer, "propTypes", {
  40705. value: _propTypes.default.string,
  40706. editorTheme: _propTypes.default.string,
  40707. ResultsTooltip: _propTypes.default.any,
  40708. ImagePreview: _propTypes.default.any
  40709. });
  40710. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40711. },{"codemirror":16,"codemirror-graphql/results/mode":391,"codemirror-graphql/utils/info-addon":396,"codemirror/addon/dialog/dialog":4,"codemirror/addon/fold/brace-fold":7,"codemirror/addon/fold/foldgutter":9,"codemirror/addon/search/jump-to-line":12,"codemirror/addon/search/search":13,"codemirror/addon/search/searchcursor":14,"codemirror/keymap/sublime":15,"prop-types":202}],234:[function(require,module,exports){
  40712. (function (global){
  40713. "use strict";
  40714. Object.defineProperty(exports, "__esModule", {
  40715. value: true
  40716. });
  40717. exports.ToolbarButton = void 0;
  40718. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40719. var _propTypes = _interopRequireDefault(require("prop-types"));
  40720. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40721. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40723. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40724. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40725. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40726. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40727. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40728. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40729. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40730. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40731. /**
  40732. * ToolbarButton
  40733. *
  40734. * A button to use within the Toolbar.
  40735. */
  40736. var ToolbarButton =
  40737. /*#__PURE__*/
  40738. function (_React$Component) {
  40739. _inherits(ToolbarButton, _React$Component);
  40740. function ToolbarButton(props) {
  40741. var _this;
  40742. _classCallCheck(this, ToolbarButton);
  40743. _this = _possibleConstructorReturn(this, _getPrototypeOf(ToolbarButton).call(this, props));
  40744. _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
  40745. e.preventDefault();
  40746. try {
  40747. _this.props.onClick();
  40748. _this.setState({
  40749. error: null
  40750. });
  40751. } catch (error) {
  40752. _this.setState({
  40753. error: error
  40754. });
  40755. }
  40756. });
  40757. _this.state = {
  40758. error: null
  40759. };
  40760. return _this;
  40761. }
  40762. _createClass(ToolbarButton, [{
  40763. key: "render",
  40764. value: function render() {
  40765. var error = this.state.error;
  40766. return _react.default.createElement("a", {
  40767. className: 'toolbar-button' + (error ? ' error' : ''),
  40768. onMouseDown: preventDefault,
  40769. onClick: this.handleClick,
  40770. title: error ? error.message : this.props.title
  40771. }, this.props.label);
  40772. }
  40773. }]);
  40774. return ToolbarButton;
  40775. }(_react.default.Component);
  40776. exports.ToolbarButton = ToolbarButton;
  40777. _defineProperty(ToolbarButton, "propTypes", {
  40778. onClick: _propTypes.default.func,
  40779. title: _propTypes.default.string,
  40780. label: _propTypes.default.string
  40781. });
  40782. function preventDefault(e) {
  40783. e.preventDefault();
  40784. }
  40785. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40786. },{"prop-types":202}],235:[function(require,module,exports){
  40787. (function (global){
  40788. "use strict";
  40789. Object.defineProperty(exports, "__esModule", {
  40790. value: true
  40791. });
  40792. exports.ToolbarGroup = ToolbarGroup;
  40793. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40794. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40795. /**
  40796. * Copyright (c) 2019 GraphQL Contributors.
  40797. *
  40798. * This source code is licensed under the MIT license found in the
  40799. * LICENSE file in the root directory of this source tree.
  40800. */
  40801. /**
  40802. * ToolbarGroup
  40803. *
  40804. * A group of associated controls.
  40805. */
  40806. function ToolbarGroup(_ref) {
  40807. var children = _ref.children;
  40808. return _react.default.createElement("div", {
  40809. className: "toolbar-button-group"
  40810. }, children);
  40811. }
  40812. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40813. },{}],236:[function(require,module,exports){
  40814. (function (global){
  40815. "use strict";
  40816. Object.defineProperty(exports, "__esModule", {
  40817. value: true
  40818. });
  40819. exports.ToolbarMenuItem = ToolbarMenuItem;
  40820. exports.ToolbarMenu = void 0;
  40821. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40822. var _propTypes = _interopRequireDefault(require("prop-types"));
  40823. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40824. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40825. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40826. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40827. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40828. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40829. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40830. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40831. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40832. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40833. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40834. /**
  40835. * ToolbarMenu
  40836. *
  40837. * A menu style button to use within the Toolbar.
  40838. */
  40839. var ToolbarMenu =
  40840. /*#__PURE__*/
  40841. function (_React$Component) {
  40842. _inherits(ToolbarMenu, _React$Component);
  40843. function ToolbarMenu(props) {
  40844. var _this;
  40845. _classCallCheck(this, ToolbarMenu);
  40846. _this = _possibleConstructorReturn(this, _getPrototypeOf(ToolbarMenu).call(this, props));
  40847. _defineProperty(_assertThisInitialized(_this), "handleOpen", function (e) {
  40848. preventDefault(e);
  40849. _this.setState({
  40850. visible: true
  40851. });
  40852. _this._subscribe();
  40853. });
  40854. _this.state = {
  40855. visible: false
  40856. };
  40857. return _this;
  40858. }
  40859. _createClass(ToolbarMenu, [{
  40860. key: "componentWillUnmount",
  40861. value: function componentWillUnmount() {
  40862. this._release();
  40863. }
  40864. }, {
  40865. key: "render",
  40866. value: function render() {
  40867. var _this2 = this;
  40868. var visible = this.state.visible;
  40869. return _react.default.createElement("a", {
  40870. className: "toolbar-menu toolbar-button",
  40871. onClick: this.handleOpen.bind(this),
  40872. onMouseDown: preventDefault,
  40873. ref: function ref(node) {
  40874. _this2._node = node;
  40875. },
  40876. title: this.props.title
  40877. }, this.props.label, _react.default.createElement("svg", {
  40878. width: "14",
  40879. height: "8"
  40880. }, _react.default.createElement("path", {
  40881. fill: "#666",
  40882. d: "M 5 1.5 L 14 1.5 L 9.5 7 z"
  40883. })), _react.default.createElement("ul", {
  40884. className: 'toolbar-menu-items' + (visible ? ' open' : '')
  40885. }, this.props.children));
  40886. }
  40887. }, {
  40888. key: "_subscribe",
  40889. value: function _subscribe() {
  40890. if (!this._listener) {
  40891. this._listener = this.handleClick.bind(this);
  40892. document.addEventListener('click', this._listener);
  40893. }
  40894. }
  40895. }, {
  40896. key: "_release",
  40897. value: function _release() {
  40898. if (this._listener) {
  40899. document.removeEventListener('click', this._listener);
  40900. this._listener = null;
  40901. }
  40902. }
  40903. }, {
  40904. key: "handleClick",
  40905. value: function handleClick(e) {
  40906. if (this._node !== e.target) {
  40907. preventDefault(e);
  40908. this.setState({
  40909. visible: false
  40910. });
  40911. this._release();
  40912. }
  40913. }
  40914. }]);
  40915. return ToolbarMenu;
  40916. }(_react.default.Component);
  40917. exports.ToolbarMenu = ToolbarMenu;
  40918. _defineProperty(ToolbarMenu, "propTypes", {
  40919. title: _propTypes.default.string,
  40920. label: _propTypes.default.string
  40921. });
  40922. function ToolbarMenuItem(_ref) {
  40923. var onSelect = _ref.onSelect,
  40924. title = _ref.title,
  40925. label = _ref.label;
  40926. return _react.default.createElement("li", {
  40927. onMouseOver: function onMouseOver(e) {
  40928. e.target.className = 'hover';
  40929. },
  40930. onMouseOut: function onMouseOut(e) {
  40931. e.target.className = null;
  40932. },
  40933. onMouseDown: preventDefault,
  40934. onMouseUp: onSelect,
  40935. title: title
  40936. }, label);
  40937. }
  40938. ToolbarMenuItem.propTypes = {
  40939. onSelect: _propTypes.default.func,
  40940. title: _propTypes.default.string,
  40941. label: _propTypes.default.string
  40942. };
  40943. function preventDefault(e) {
  40944. e.preventDefault();
  40945. }
  40946. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40947. },{"prop-types":202}],237:[function(require,module,exports){
  40948. (function (global){
  40949. "use strict";
  40950. Object.defineProperty(exports, "__esModule", {
  40951. value: true
  40952. });
  40953. exports.ToolbarSelectOption = ToolbarSelectOption;
  40954. exports.ToolbarSelect = void 0;
  40955. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  40956. var _propTypes = _interopRequireDefault(require("prop-types"));
  40957. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  40958. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  40959. function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  40960. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  40961. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  40962. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  40963. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  40964. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  40965. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  40966. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  40967. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  40968. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  40969. /**
  40970. * ToolbarSelect
  40971. *
  40972. * A select-option style button to use within the Toolbar.
  40973. *
  40974. */
  40975. var ToolbarSelect =
  40976. /*#__PURE__*/
  40977. function (_React$Component) {
  40978. _inherits(ToolbarSelect, _React$Component);
  40979. function ToolbarSelect(props) {
  40980. var _this;
  40981. _classCallCheck(this, ToolbarSelect);
  40982. _this = _possibleConstructorReturn(this, _getPrototypeOf(ToolbarSelect).call(this, props));
  40983. _defineProperty(_assertThisInitialized(_this), "handleOpen", function (e) {
  40984. preventDefault(e);
  40985. _this.setState({
  40986. visible: true
  40987. });
  40988. _this._subscribe();
  40989. });
  40990. _this.state = {
  40991. visible: false
  40992. };
  40993. return _this;
  40994. }
  40995. _createClass(ToolbarSelect, [{
  40996. key: "componentWillUnmount",
  40997. value: function componentWillUnmount() {
  40998. this._release();
  40999. }
  41000. }, {
  41001. key: "render",
  41002. value: function render() {
  41003. var _this2 = this;
  41004. var selectedChild;
  41005. var visible = this.state.visible;
  41006. var optionChildren = _react.default.Children.map(this.props.children, function (child, i) {
  41007. if (!selectedChild || child.props.selected) {
  41008. selectedChild = child;
  41009. }
  41010. var onChildSelect = child.props.onSelect || _this2.props.onSelect && _this2.props.onSelect.bind(null, child.props.value, i);
  41011. return _react.default.createElement(ToolbarSelectOption, _extends({}, child.props, {
  41012. onSelect: onChildSelect
  41013. }));
  41014. });
  41015. return _react.default.createElement("a", {
  41016. className: "toolbar-select toolbar-button",
  41017. onClick: this.handleOpen.bind(this),
  41018. onMouseDown: preventDefault,
  41019. ref: function ref(node) {
  41020. _this2._node = node;
  41021. },
  41022. title: this.props.title
  41023. }, selectedChild.props.label, _react.default.createElement("svg", {
  41024. width: "13",
  41025. height: "10"
  41026. }, _react.default.createElement("path", {
  41027. fill: "#666",
  41028. d: "M 5 5 L 13 5 L 9 1 z"
  41029. }), _react.default.createElement("path", {
  41030. fill: "#666",
  41031. d: "M 5 6 L 13 6 L 9 10 z"
  41032. })), _react.default.createElement("ul", {
  41033. className: 'toolbar-select-options' + (visible ? ' open' : '')
  41034. }, optionChildren));
  41035. }
  41036. }, {
  41037. key: "_subscribe",
  41038. value: function _subscribe() {
  41039. if (!this._listener) {
  41040. this._listener = this.handleClick.bind(this);
  41041. document.addEventListener('click', this._listener);
  41042. }
  41043. }
  41044. }, {
  41045. key: "_release",
  41046. value: function _release() {
  41047. if (this._listener) {
  41048. document.removeEventListener('click', this._listener);
  41049. this._listener = null;
  41050. }
  41051. }
  41052. }, {
  41053. key: "handleClick",
  41054. value: function handleClick(e) {
  41055. if (this._node !== e.target) {
  41056. preventDefault(e);
  41057. this.setState({
  41058. visible: false
  41059. });
  41060. this._release();
  41061. }
  41062. }
  41063. }]);
  41064. return ToolbarSelect;
  41065. }(_react.default.Component);
  41066. exports.ToolbarSelect = ToolbarSelect;
  41067. _defineProperty(ToolbarSelect, "propTypes", {
  41068. title: _propTypes.default.string,
  41069. label: _propTypes.default.string,
  41070. onSelect: _propTypes.default.func
  41071. });
  41072. function ToolbarSelectOption(_ref) {
  41073. var onSelect = _ref.onSelect,
  41074. label = _ref.label,
  41075. selected = _ref.selected;
  41076. return _react.default.createElement("li", {
  41077. onMouseOver: function onMouseOver(e) {
  41078. e.target.className = 'hover';
  41079. },
  41080. onMouseOut: function onMouseOut(e) {
  41081. e.target.className = null;
  41082. },
  41083. onMouseDown: preventDefault,
  41084. onMouseUp: onSelect
  41085. }, label, selected && _react.default.createElement("svg", {
  41086. width: "13",
  41087. height: "13"
  41088. }, _react.default.createElement("polygon", {
  41089. points: "4.851,10.462 0,5.611 2.314,3.297 4.851,5.835 10.686,0 13,2.314 4.851,10.462"
  41090. })));
  41091. }
  41092. ToolbarSelectOption.propTypes = {
  41093. onSelect: _propTypes.default.func,
  41094. selected: _propTypes.default.bool,
  41095. label: _propTypes.default.string,
  41096. value: _propTypes.default.any
  41097. };
  41098. function preventDefault(e) {
  41099. e.preventDefault();
  41100. }
  41101. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  41102. },{"prop-types":202}],238:[function(require,module,exports){
  41103. (function (global){
  41104. "use strict";
  41105. Object.defineProperty(exports, "__esModule", {
  41106. value: true
  41107. });
  41108. exports.VariableEditor = void 0;
  41109. var _react = _interopRequireDefault((typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null));
  41110. var _propTypes = _interopRequireDefault(require("prop-types"));
  41111. var _onHasCompletion = _interopRequireDefault(require("../utility/onHasCompletion"));
  41112. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41113. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  41114. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41115. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  41116. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  41117. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  41118. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  41119. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  41120. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  41121. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  41122. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  41123. /**
  41124. * VariableEditor
  41125. *
  41126. * An instance of CodeMirror for editing variables defined in QueryEditor.
  41127. *
  41128. * Props:
  41129. *
  41130. * - variableToType: A mapping of variable name to GraphQLType.
  41131. * - value: The text of the editor.
  41132. * - onEdit: A function called when the editor changes, given the edited text.
  41133. * - readOnly: Turns the editor to read-only mode.
  41134. *
  41135. */
  41136. var VariableEditor =
  41137. /*#__PURE__*/
  41138. function (_React$Component) {
  41139. _inherits(VariableEditor, _React$Component);
  41140. function VariableEditor(props) {
  41141. var _this;
  41142. _classCallCheck(this, VariableEditor);
  41143. _this = _possibleConstructorReturn(this, _getPrototypeOf(VariableEditor).call(this)); // Keep a cached version of the value, this cache will be updated when the
  41144. // editor is updated, which can later be used to protect the editor from
  41145. // unnecessary updates during the update lifecycle.
  41146. _defineProperty(_assertThisInitialized(_this), "_onKeyUp", function (cm, event) {
  41147. var code = event.keyCode;
  41148. if (code >= 65 && code <= 90 || // letters
  41149. !event.shiftKey && code >= 48 && code <= 57 || // numbers
  41150. event.shiftKey && code === 189 || // underscore
  41151. event.shiftKey && code === 222 // "
  41152. ) {
  41153. _this.editor.execCommand('autocomplete');
  41154. }
  41155. });
  41156. _defineProperty(_assertThisInitialized(_this), "_onEdit", function () {
  41157. if (!_this.ignoreChangeEvent) {
  41158. _this.cachedValue = _this.editor.getValue();
  41159. if (_this.props.onEdit) {
  41160. _this.props.onEdit(_this.cachedValue);
  41161. }
  41162. }
  41163. });
  41164. _defineProperty(_assertThisInitialized(_this), "_onHasCompletion", function (cm, data) {
  41165. (0, _onHasCompletion.default)(cm, data, _this.props.onHintInformationRender);
  41166. });
  41167. _this.cachedValue = props.value || '';
  41168. return _this;
  41169. }
  41170. _createClass(VariableEditor, [{
  41171. key: "componentDidMount",
  41172. value: function componentDidMount() {
  41173. var _this2 = this;
  41174. // Lazily require to ensure requiring GraphiQL outside of a Browser context
  41175. // does not produce an error.
  41176. var CodeMirror = require('codemirror');
  41177. require('codemirror/addon/hint/show-hint');
  41178. require('codemirror/addon/edit/matchbrackets');
  41179. require('codemirror/addon/edit/closebrackets');
  41180. require('codemirror/addon/fold/brace-fold');
  41181. require('codemirror/addon/fold/foldgutter');
  41182. require('codemirror/addon/lint/lint');
  41183. require('codemirror/addon/search/searchcursor');
  41184. require('codemirror/addon/search/jump-to-line');
  41185. require('codemirror/addon/dialog/dialog');
  41186. require('codemirror/keymap/sublime');
  41187. require('codemirror-graphql/variables/hint');
  41188. require('codemirror-graphql/variables/lint');
  41189. require('codemirror-graphql/variables/mode');
  41190. this.editor = CodeMirror(this._node, {
  41191. value: this.props.value || '',
  41192. lineNumbers: true,
  41193. tabSize: 2,
  41194. mode: 'graphql-variables',
  41195. theme: this.props.editorTheme || 'graphiql',
  41196. keyMap: 'sublime',
  41197. autoCloseBrackets: true,
  41198. matchBrackets: true,
  41199. showCursorWhenSelecting: true,
  41200. readOnly: this.props.readOnly ? 'nocursor' : false,
  41201. foldGutter: {
  41202. minFoldSize: 4
  41203. },
  41204. lint: {
  41205. variableToType: this.props.variableToType
  41206. },
  41207. hintOptions: {
  41208. variableToType: this.props.variableToType,
  41209. closeOnUnfocus: false,
  41210. completeSingle: false,
  41211. container: this._node
  41212. },
  41213. gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
  41214. extraKeys: {
  41215. 'Cmd-Space': function CmdSpace() {
  41216. return _this2.editor.showHint({
  41217. completeSingle: false,
  41218. container: _this2._node
  41219. });
  41220. },
  41221. 'Ctrl-Space': function CtrlSpace() {
  41222. return _this2.editor.showHint({
  41223. completeSingle: false,
  41224. container: _this2._node
  41225. });
  41226. },
  41227. 'Alt-Space': function AltSpace() {
  41228. return _this2.editor.showHint({
  41229. completeSingle: false,
  41230. container: _this2._node
  41231. });
  41232. },
  41233. 'Shift-Space': function ShiftSpace() {
  41234. return _this2.editor.showHint({
  41235. completeSingle: false,
  41236. container: _this2._node
  41237. });
  41238. },
  41239. 'Cmd-Enter': function CmdEnter() {
  41240. if (_this2.props.onRunQuery) {
  41241. _this2.props.onRunQuery();
  41242. }
  41243. },
  41244. 'Ctrl-Enter': function CtrlEnter() {
  41245. if (_this2.props.onRunQuery) {
  41246. _this2.props.onRunQuery();
  41247. }
  41248. },
  41249. 'Shift-Ctrl-P': function ShiftCtrlP() {
  41250. if (_this2.props.onPrettifyQuery) {
  41251. _this2.props.onPrettifyQuery();
  41252. }
  41253. },
  41254. 'Shift-Ctrl-M': function ShiftCtrlM() {
  41255. if (_this2.props.onMergeQuery) {
  41256. _this2.props.onMergeQuery();
  41257. }
  41258. },
  41259. // Persistent search box in Query Editor
  41260. 'Cmd-F': 'findPersistent',
  41261. 'Ctrl-F': 'findPersistent',
  41262. 'Cmd-G': 'findPersistent',
  41263. 'Ctrl-G': 'findPersistent',
  41264. // Editor improvements
  41265. 'Ctrl-Left': 'goSubwordLeft',
  41266. 'Ctrl-Right': 'goSubwordRight',
  41267. 'Alt-Left': 'goGroupLeft',
  41268. 'Alt-Right': 'goGroupRight'
  41269. }
  41270. });
  41271. this.editor.on('change', this._onEdit);
  41272. this.editor.on('keyup', this._onKeyUp);
  41273. this.editor.on('hasCompletion', this._onHasCompletion);
  41274. }
  41275. }, {
  41276. key: "componentDidUpdate",
  41277. value: function componentDidUpdate(prevProps) {
  41278. var CodeMirror = require('codemirror'); // Ensure the changes caused by this update are not interpretted as
  41279. // user-input changes which could otherwise result in an infinite
  41280. // event loop.
  41281. this.ignoreChangeEvent = true;
  41282. if (this.props.variableToType !== prevProps.variableToType) {
  41283. this.editor.options.lint.variableToType = this.props.variableToType;
  41284. this.editor.options.hintOptions.variableToType = this.props.variableToType;
  41285. CodeMirror.signal(this.editor, 'change', this.editor);
  41286. }
  41287. if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue) {
  41288. var thisValue = this.props.value || '';
  41289. this.cachedValue = thisValue;
  41290. this.editor.setValue(thisValue);
  41291. }
  41292. this.ignoreChangeEvent = false;
  41293. }
  41294. }, {
  41295. key: "componentWillUnmount",
  41296. value: function componentWillUnmount() {
  41297. this.editor.off('change', this._onEdit);
  41298. this.editor.off('keyup', this._onKeyUp);
  41299. this.editor.off('hasCompletion', this._onHasCompletion);
  41300. this.editor = null;
  41301. }
  41302. }, {
  41303. key: "render",
  41304. value: function render() {
  41305. var _this3 = this;
  41306. return _react.default.createElement("div", {
  41307. className: "codemirrorWrap",
  41308. ref: function ref(node) {
  41309. _this3._node = node;
  41310. }
  41311. });
  41312. }
  41313. /**
  41314. * Public API for retrieving the CodeMirror instance from this
  41315. * React component.
  41316. */
  41317. }, {
  41318. key: "getCodeMirror",
  41319. value: function getCodeMirror() {
  41320. return this.editor;
  41321. }
  41322. /**
  41323. * Public API for retrieving the DOM client height for this component.
  41324. */
  41325. }, {
  41326. key: "getClientHeight",
  41327. value: function getClientHeight() {
  41328. return this._node && this._node.clientHeight;
  41329. }
  41330. }]);
  41331. return VariableEditor;
  41332. }(_react.default.Component);
  41333. exports.VariableEditor = VariableEditor;
  41334. _defineProperty(VariableEditor, "propTypes", {
  41335. variableToType: _propTypes.default.object,
  41336. value: _propTypes.default.string,
  41337. onEdit: _propTypes.default.func,
  41338. readOnly: _propTypes.default.bool,
  41339. onHintInformationRender: _propTypes.default.func,
  41340. onPrettifyQuery: _propTypes.default.func,
  41341. onMergeQuery: _propTypes.default.func,
  41342. onRunQuery: _propTypes.default.func,
  41343. editorTheme: _propTypes.default.string
  41344. });
  41345. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  41346. },{"../utility/onHasCompletion":252,"codemirror":16,"codemirror-graphql/variables/hint":399,"codemirror-graphql/variables/lint":400,"codemirror-graphql/variables/mode":401,"codemirror/addon/dialog/dialog":4,"codemirror/addon/edit/closebrackets":5,"codemirror/addon/edit/matchbrackets":6,"codemirror/addon/fold/brace-fold":7,"codemirror/addon/fold/foldgutter":9,"codemirror/addon/hint/show-hint":10,"codemirror/addon/lint/lint":11,"codemirror/addon/search/jump-to-line":12,"codemirror/addon/search/searchcursor":14,"codemirror/keymap/sublime":15,"prop-types":202}],239:[function(require,module,exports){
  41347. "use strict";
  41348. /**
  41349. * Copyright (c) 2019 GraphQL Contributors.
  41350. *
  41351. * This source code is licensed under the MIT license found in the
  41352. * LICENSE file in the root directory of this source tree.
  41353. */
  41354. // The primary React component to use.
  41355. module.exports = require('./components/GraphiQL').GraphiQL;
  41356. },{"./components/GraphiQL":228}],240:[function(require,module,exports){
  41357. "use strict";
  41358. Object.defineProperty(exports, "__esModule", {
  41359. value: true
  41360. });
  41361. exports.default = void 0;
  41362. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41363. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  41364. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  41365. /**
  41366. * Copyright (c) 2019 GraphQL Contributors.
  41367. *
  41368. * This source code is licensed under the MIT license found in the
  41369. * LICENSE file in the root directory of this source tree.
  41370. */
  41371. /**
  41372. * When a containing DOM node's height has been altered, trigger a resize of
  41373. * the related CodeMirror instance so that it is always correctly sized.
  41374. */
  41375. var CodeMirrorSizer =
  41376. /*#__PURE__*/
  41377. function () {
  41378. function CodeMirrorSizer() {
  41379. _classCallCheck(this, CodeMirrorSizer);
  41380. this.sizes = [];
  41381. }
  41382. _createClass(CodeMirrorSizer, [{
  41383. key: "updateSizes",
  41384. value: function updateSizes(components) {
  41385. var _this = this;
  41386. components.forEach(function (component, i) {
  41387. var size = component.getClientHeight();
  41388. if (i <= _this.sizes.length && size !== _this.sizes[i]) {
  41389. component.getCodeMirror().setSize();
  41390. }
  41391. _this.sizes[i] = size;
  41392. });
  41393. }
  41394. }]);
  41395. return CodeMirrorSizer;
  41396. }();
  41397. exports.default = CodeMirrorSizer;
  41398. },{}],241:[function(require,module,exports){
  41399. "use strict";
  41400. Object.defineProperty(exports, "__esModule", {
  41401. value: true
  41402. });
  41403. exports.default = void 0;
  41404. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  41405. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41406. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  41407. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  41408. /**
  41409. * Copyright (c) 2019 GraphQL Contributors.
  41410. *
  41411. * This source code is licensed under the MIT license found in the
  41412. * LICENSE file in the root directory of this source tree.
  41413. */
  41414. var QueryStore =
  41415. /*#__PURE__*/
  41416. function () {
  41417. function QueryStore(key, storage) {
  41418. _classCallCheck(this, QueryStore);
  41419. this.key = key;
  41420. this.storage = storage;
  41421. this.items = this.fetchAll();
  41422. }
  41423. _createClass(QueryStore, [{
  41424. key: "contains",
  41425. value: function contains(item) {
  41426. return this.items.some(function (x) {
  41427. return x.query === item.query && x.variables === item.variables && x.operationName === item.operationName;
  41428. });
  41429. }
  41430. }, {
  41431. key: "edit",
  41432. value: function edit(item) {
  41433. var itemIndex = this.items.findIndex(function (x) {
  41434. return x.query === item.query && x.variables === item.variables && x.operationName === item.operationName;
  41435. });
  41436. if (itemIndex !== -1) {
  41437. this.items.splice(itemIndex, 1, item);
  41438. this.save();
  41439. }
  41440. }
  41441. }, {
  41442. key: "delete",
  41443. value: function _delete(item) {
  41444. var itemIndex = this.items.findIndex(function (x) {
  41445. return x.query === item.query && x.variables === item.variables && x.operationName === item.operationName;
  41446. });
  41447. if (itemIndex !== -1) {
  41448. this.items.splice(itemIndex, 1);
  41449. this.save();
  41450. }
  41451. }
  41452. }, {
  41453. key: "fetchRecent",
  41454. value: function fetchRecent() {
  41455. return this.items[this.items.length - 1];
  41456. }
  41457. }, {
  41458. key: "fetchAll",
  41459. value: function fetchAll() {
  41460. var raw = this.storage.get(this.key);
  41461. if (raw) {
  41462. return JSON.parse(raw)[this.key];
  41463. }
  41464. return [];
  41465. }
  41466. }, {
  41467. key: "push",
  41468. value: function push(item) {
  41469. this.items.push(item);
  41470. this.save();
  41471. }
  41472. }, {
  41473. key: "shift",
  41474. value: function shift() {
  41475. this.items.shift();
  41476. this.save();
  41477. }
  41478. }, {
  41479. key: "save",
  41480. value: function save() {
  41481. this.storage.set(this.key, JSON.stringify(_defineProperty({}, this.key, this.items)));
  41482. }
  41483. }, {
  41484. key: "length",
  41485. get: function get() {
  41486. return this.items.length;
  41487. }
  41488. }]);
  41489. return QueryStore;
  41490. }();
  41491. exports.default = QueryStore;
  41492. },{}],242:[function(require,module,exports){
  41493. "use strict";
  41494. Object.defineProperty(exports, "__esModule", {
  41495. value: true
  41496. });
  41497. exports.default = void 0;
  41498. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41499. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  41500. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  41501. /**
  41502. * Copyright (c) 2019 GraphQL Contributors.
  41503. *
  41504. * This source code is licensed under the MIT license found in the
  41505. * LICENSE file in the root directory of this source tree.
  41506. */
  41507. var StorageAPI =
  41508. /*#__PURE__*/
  41509. function () {
  41510. function StorageAPI(storage) {
  41511. _classCallCheck(this, StorageAPI);
  41512. this.storage = storage || window.localStorage;
  41513. }
  41514. _createClass(StorageAPI, [{
  41515. key: "get",
  41516. value: function get(name) {
  41517. if (this.storage) {
  41518. var value = this.storage.getItem('graphiql:' + name); // Clean up any inadvertently saved null/undefined values.
  41519. if (value === 'null' || value === 'undefined') {
  41520. this.storage.removeItem('graphiql:' + name);
  41521. } else {
  41522. return value;
  41523. }
  41524. }
  41525. }
  41526. }, {
  41527. key: "set",
  41528. value: function set(name, value) {
  41529. if (this.storage) {
  41530. var key = "graphiql:".concat(name);
  41531. if (value) {
  41532. if (isStorageAvailable(this.storage, key, value)) {
  41533. this.storage.setItem(key, value);
  41534. }
  41535. } else {
  41536. // Clean up by removing the item if there's no value to set
  41537. this.storage.removeItem(key);
  41538. }
  41539. }
  41540. }
  41541. }]);
  41542. return StorageAPI;
  41543. }();
  41544. exports.default = StorageAPI;
  41545. function isStorageAvailable(storage, key, value) {
  41546. try {
  41547. storage.setItem(key, value);
  41548. return true;
  41549. } catch (e) {
  41550. return e instanceof DOMException && ( // everything except Firefox
  41551. e.code === 22 || // Firefox
  41552. e.code === 1014 || // test name field too, because code might not be present
  41553. // everything except Firefox
  41554. e.name === 'QuotaExceededError' || // Firefox
  41555. e.name === 'NS_ERROR_DOM_QUOTA_REACHED') && // acknowledge QuotaExceededError only if there's something already stored
  41556. storage.length !== 0;
  41557. }
  41558. }
  41559. },{}],243:[function(require,module,exports){
  41560. "use strict";
  41561. Object.defineProperty(exports, "__esModule", {
  41562. value: true
  41563. });
  41564. exports.default = debounce;
  41565. /**
  41566. * Copyright (c) 2019 GraphQL Contributors.
  41567. *
  41568. * This source code is licensed under the MIT license found in the
  41569. * LICENSE file in the root directory of this source tree.
  41570. */
  41571. /**
  41572. * Provided a duration and a function, returns a new function which is called
  41573. * `duration` milliseconds after the last call.
  41574. */
  41575. function debounce(duration, fn) {
  41576. var timeout;
  41577. return function () {
  41578. var _this = this,
  41579. _arguments = arguments;
  41580. clearTimeout(timeout);
  41581. timeout = setTimeout(function () {
  41582. timeout = null;
  41583. fn.apply(_this, _arguments);
  41584. }, duration);
  41585. };
  41586. }
  41587. },{}],244:[function(require,module,exports){
  41588. "use strict";
  41589. Object.defineProperty(exports, "__esModule", {
  41590. value: true
  41591. });
  41592. exports.getLeft = getLeft;
  41593. exports.getTop = getTop;
  41594. /**
  41595. * Copyright (c) 2019 GraphQL Contributors.
  41596. *
  41597. * This source code is licensed under the MIT license found in the
  41598. * LICENSE file in the root directory of this source tree.
  41599. */
  41600. /**
  41601. * Utility functions to get a pixel distance from left/top of the window.
  41602. */
  41603. function getLeft(initialElem) {
  41604. var pt = 0;
  41605. var elem = initialElem;
  41606. while (elem.offsetParent) {
  41607. pt += elem.offsetLeft;
  41608. elem = elem.offsetParent;
  41609. }
  41610. return pt;
  41611. }
  41612. function getTop(initialElem) {
  41613. var pt = 0;
  41614. var elem = initialElem;
  41615. while (elem.offsetParent) {
  41616. pt += elem.offsetTop;
  41617. elem = elem.offsetParent;
  41618. }
  41619. return pt;
  41620. }
  41621. },{}],245:[function(require,module,exports){
  41622. "use strict";
  41623. Object.defineProperty(exports, "__esModule", {
  41624. value: true
  41625. });
  41626. exports.fillLeafs = fillLeafs;
  41627. var _graphql = require("graphql");
  41628. /**
  41629. * Copyright (c) 2019 GraphQL Contributors.
  41630. *
  41631. * This source code is licensed under the MIT license found in the
  41632. * LICENSE file in the root directory of this source tree.
  41633. */
  41634. /**
  41635. * Given a document string which may not be valid due to terminal fields not
  41636. * representing leaf values (Spec Section: "Leaf Field Selections"), and a
  41637. * function which provides reasonable default field names for a given type,
  41638. * this function will attempt to produce a schema which is valid after filling
  41639. * in selection sets for the invalid fields.
  41640. *
  41641. * Note that there is no guarantee that the result will be a valid query, this
  41642. * utility represents a "best effort" which may be useful within IDE tools.
  41643. */
  41644. function fillLeafs(schema, docString, getDefaultFieldNames) {
  41645. var insertions = [];
  41646. if (!schema) {
  41647. return {
  41648. insertions: insertions,
  41649. result: docString
  41650. };
  41651. }
  41652. var ast;
  41653. try {
  41654. ast = (0, _graphql.parse)(docString);
  41655. } catch (error) {
  41656. return {
  41657. insertions: insertions,
  41658. result: docString
  41659. };
  41660. }
  41661. var fieldNameFn = getDefaultFieldNames || defaultGetDefaultFieldNames;
  41662. var typeInfo = new _graphql.TypeInfo(schema);
  41663. (0, _graphql.visit)(ast, {
  41664. leave: function leave(node) {
  41665. typeInfo.leave(node);
  41666. },
  41667. enter: function enter(node) {
  41668. typeInfo.enter(node);
  41669. if (node.kind === 'Field' && !node.selectionSet) {
  41670. var fieldType = typeInfo.getType();
  41671. var selectionSet = buildSelectionSet(fieldType, fieldNameFn);
  41672. if (selectionSet) {
  41673. var indent = getIndentation(docString, node.loc.start);
  41674. insertions.push({
  41675. index: node.loc.end,
  41676. string: ' ' + (0, _graphql.print)(selectionSet).replace(/\n/g, '\n' + indent)
  41677. });
  41678. }
  41679. }
  41680. }
  41681. }); // Apply the insertions, but also return the insertions metadata.
  41682. return {
  41683. insertions: insertions,
  41684. result: withInsertions(docString, insertions)
  41685. };
  41686. } // The default function to use for producing the default fields from a type.
  41687. // This function first looks for some common patterns, and falls back to
  41688. // including all leaf-type fields.
  41689. function defaultGetDefaultFieldNames(type) {
  41690. // If this type cannot access fields, then return an empty set.
  41691. if (!type.getFields) {
  41692. return [];
  41693. }
  41694. var fields = type.getFields(); // Is there an `id` field?
  41695. if (fields['id']) {
  41696. return ['id'];
  41697. } // Is there an `edges` field?
  41698. if (fields['edges']) {
  41699. return ['edges'];
  41700. } // Is there an `node` field?
  41701. if (fields['node']) {
  41702. return ['node'];
  41703. } // Include all leaf-type fields.
  41704. var leafFieldNames = [];
  41705. Object.keys(fields).forEach(function (fieldName) {
  41706. if ((0, _graphql.isLeafType)(fields[fieldName].type)) {
  41707. leafFieldNames.push(fieldName);
  41708. }
  41709. });
  41710. return leafFieldNames;
  41711. } // Given a GraphQL type, and a function which produces field names, recursively
  41712. // generate a SelectionSet which includes default fields.
  41713. function buildSelectionSet(type, getDefaultFieldNames) {
  41714. // Unwrap any non-null or list types.
  41715. var namedType = (0, _graphql.getNamedType)(type); // Unknown types and leaf types do not have selection sets.
  41716. if (!type || (0, _graphql.isLeafType)(type)) {
  41717. return;
  41718. } // Get an array of field names to use.
  41719. var fieldNames = getDefaultFieldNames(namedType); // If there are no field names to use, return no selection set.
  41720. if (!Array.isArray(fieldNames) || fieldNames.length === 0) {
  41721. return;
  41722. } // Build a selection set of each field, calling buildSelectionSet recursively.
  41723. return {
  41724. kind: 'SelectionSet',
  41725. selections: fieldNames.map(function (fieldName) {
  41726. var fieldDef = namedType.getFields()[fieldName];
  41727. var fieldType = fieldDef ? fieldDef.type : null;
  41728. return {
  41729. kind: 'Field',
  41730. name: {
  41731. kind: 'Name',
  41732. value: fieldName
  41733. },
  41734. selectionSet: buildSelectionSet(fieldType, getDefaultFieldNames)
  41735. };
  41736. })
  41737. };
  41738. } // Given an initial string, and a list of "insertion" { index, string } objects,
  41739. // return a new string with these insertions applied.
  41740. function withInsertions(initial, insertions) {
  41741. if (insertions.length === 0) {
  41742. return initial;
  41743. }
  41744. var edited = '';
  41745. var prevIndex = 0;
  41746. insertions.forEach(function (_ref) {
  41747. var index = _ref.index,
  41748. string = _ref.string;
  41749. edited += initial.slice(prevIndex, index) + string;
  41750. prevIndex = index;
  41751. });
  41752. edited += initial.slice(prevIndex);
  41753. return edited;
  41754. } // Given a string and an index, look backwards to find the string of whitespace
  41755. // following the next previous line break.
  41756. function getIndentation(str, index) {
  41757. var indentStart = index;
  41758. var indentEnd = index;
  41759. while (indentStart) {
  41760. var c = str.charCodeAt(indentStart - 1); // line break
  41761. if (c === 10 || c === 13 || c === 0x2028 || c === 0x2029) {
  41762. break;
  41763. }
  41764. indentStart--; // not white space
  41765. if (c !== 9 && c !== 11 && c !== 12 && c !== 32 && c !== 160) {
  41766. indentEnd = indentStart;
  41767. }
  41768. }
  41769. return str.substring(indentStart, indentEnd);
  41770. }
  41771. },{"graphql":29}],246:[function(require,module,exports){
  41772. "use strict";
  41773. Object.defineProperty(exports, "__esModule", {
  41774. value: true
  41775. });
  41776. exports.default = find;
  41777. /**
  41778. * Copyright (c) 2019 GraphQL Contributors.
  41779. *
  41780. * This source code is licensed under the MIT license found in the
  41781. * LICENSE file in the root directory of this source tree.
  41782. *
  41783. *
  41784. *
  41785. */
  41786. function find(list, predicate) {
  41787. for (var i = 0; i < list.length; i++) {
  41788. if (predicate(list[i])) {
  41789. return list[i];
  41790. }
  41791. }
  41792. }
  41793. },{}],247:[function(require,module,exports){
  41794. "use strict";
  41795. Object.defineProperty(exports, "__esModule", {
  41796. value: true
  41797. });
  41798. exports.default = getQueryFacts;
  41799. exports.collectVariables = collectVariables;
  41800. var _graphql = require("graphql");
  41801. /**
  41802. * Copyright (c) 2019 GraphQL Contributors.
  41803. *
  41804. * This source code is licensed under the MIT license found in the
  41805. * LICENSE file in the root directory of this source tree.
  41806. */
  41807. /**
  41808. * Provided previous "queryFacts", a GraphQL schema, and a query document
  41809. * string, return a set of facts about that query useful for GraphiQL features.
  41810. *
  41811. * If the query cannot be parsed, returns undefined.
  41812. */
  41813. function getQueryFacts(schema, documentStr) {
  41814. if (!documentStr) {
  41815. return;
  41816. }
  41817. var documentAST;
  41818. try {
  41819. documentAST = (0, _graphql.parse)(documentStr);
  41820. } catch (e) {
  41821. return;
  41822. }
  41823. var variableToType = schema ? collectVariables(schema, documentAST) : null; // Collect operations by their names.
  41824. var operations = [];
  41825. documentAST.definitions.forEach(function (def) {
  41826. if (def.kind === 'OperationDefinition') {
  41827. operations.push(def);
  41828. }
  41829. });
  41830. return {
  41831. variableToType: variableToType,
  41832. operations: operations
  41833. };
  41834. }
  41835. /**
  41836. * Provided a schema and a document, produces a `variableToType` Object.
  41837. */
  41838. function collectVariables(schema, documentAST) {
  41839. var variableToType = Object.create(null);
  41840. documentAST.definitions.forEach(function (definition) {
  41841. if (definition.kind === 'OperationDefinition') {
  41842. var variableDefinitions = definition.variableDefinitions;
  41843. if (variableDefinitions) {
  41844. variableDefinitions.forEach(function (_ref) {
  41845. var variable = _ref.variable,
  41846. type = _ref.type;
  41847. var inputType = (0, _graphql.typeFromAST)(schema, type);
  41848. if (inputType) {
  41849. variableToType[variable.name.value] = inputType;
  41850. }
  41851. });
  41852. }
  41853. }
  41854. });
  41855. return variableToType;
  41856. }
  41857. },{"graphql":29}],248:[function(require,module,exports){
  41858. "use strict";
  41859. Object.defineProperty(exports, "__esModule", {
  41860. value: true
  41861. });
  41862. exports.default = getSelectedOperationName;
  41863. /**
  41864. * Copyright (c) 2019 GraphQL Contributors.
  41865. *
  41866. * This source code is licensed under the MIT license found in the
  41867. * LICENSE file in the root directory of this source tree.
  41868. */
  41869. /**
  41870. * Provided optional previous operations and selected name, and a next list of
  41871. * operations, determine what the next selected operation should be.
  41872. */
  41873. function getSelectedOperationName(prevOperations, prevSelectedOperationName, operations) {
  41874. // If there are not enough operations to bother with, return nothing.
  41875. if (!operations || operations.length < 1) {
  41876. return;
  41877. } // If a previous selection still exists, continue to use it.
  41878. var names = operations.map(function (op) {
  41879. return op.name && op.name.value;
  41880. });
  41881. if (prevSelectedOperationName && names.indexOf(prevSelectedOperationName) !== -1) {
  41882. return prevSelectedOperationName;
  41883. } // If a previous selection was the Nth operation, use the same Nth.
  41884. if (prevSelectedOperationName && prevOperations) {
  41885. var prevNames = prevOperations.map(function (op) {
  41886. return op.name && op.name.value;
  41887. });
  41888. var prevIndex = prevNames.indexOf(prevSelectedOperationName);
  41889. if (prevIndex !== -1 && prevIndex < names.length) {
  41890. return names[prevIndex];
  41891. }
  41892. } // Use the first operation.
  41893. return names[0];
  41894. }
  41895. },{}],249:[function(require,module,exports){
  41896. "use strict";
  41897. Object.defineProperty(exports, "__esModule", {
  41898. value: true
  41899. });
  41900. Object.defineProperty(exports, "introspectionQuery", {
  41901. enumerable: true,
  41902. get: function get() {
  41903. return _graphql.introspectionQuery;
  41904. }
  41905. });
  41906. exports.introspectionQuerySansSubscriptions = exports.introspectionQueryName = void 0;
  41907. var _graphql = require("graphql");
  41908. /**
  41909. * Copyright (c) 2019 GraphQL Contributors.
  41910. *
  41911. * This source code is licensed under the MIT license found in the
  41912. * LICENSE file in the root directory of this source tree.
  41913. */
  41914. var introspectionQueryName = (0, _graphql.getOperationAST)((0, _graphql.parse)(_graphql.introspectionQuery)).name.value; // Some GraphQL services do not support subscriptions and fail an introspection
  41915. // query which includes the `subscriptionType` field as the stock introspection
  41916. // query does. This backup query removes that field.
  41917. exports.introspectionQueryName = introspectionQueryName;
  41918. var introspectionQuerySansSubscriptions = "\n query ".concat(introspectionQueryName, " {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n description\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n");
  41919. exports.introspectionQuerySansSubscriptions = introspectionQuerySansSubscriptions;
  41920. },{"graphql":29}],250:[function(require,module,exports){
  41921. "use strict";
  41922. Object.defineProperty(exports, "__esModule", {
  41923. value: true
  41924. });
  41925. exports.mergeAst = mergeAst;
  41926. var _kinds = require("graphql/language/kinds");
  41927. /**
  41928. * Copyright (c) 2019 GraphQL Contributors.
  41929. *
  41930. * This source code is licensed under the MIT license found in the
  41931. * LICENSE file in the root directory of this source tree.
  41932. */
  41933. function resolveDefinition(fragments, obj) {
  41934. var definition = obj;
  41935. if (definition.kind === _kinds.Kind.FRAGMENT_SPREAD) {
  41936. definition = fragments[definition.name.value];
  41937. }
  41938. if (definition.selectionSet) {
  41939. definition.selectionSet.selections = definition.selectionSet.selections.filter(function (selection, idx, self) {
  41940. return selection.kind !== _kinds.Kind.FRAGMENT_SPREAD || idx === self.findIndex(function (_selection) {
  41941. return _selection.kind === _kinds.Kind.FRAGMENT_SPREAD && selection.name.value === _selection.name.value;
  41942. });
  41943. }).map(function (selection) {
  41944. return resolveDefinition(fragments, selection);
  41945. });
  41946. }
  41947. return definition;
  41948. }
  41949. function mergeAst(queryAst) {
  41950. var fragments = {};
  41951. queryAst.definitions.filter(function (elem) {
  41952. return elem.kind === _kinds.Kind.FRAGMENT_DEFINITION;
  41953. }).forEach(function (frag) {
  41954. var copyFragment = Object.assign({}, frag);
  41955. copyFragment.kind = _kinds.Kind.INLINE_FRAGMENT;
  41956. fragments[frag.name.value] = copyFragment;
  41957. });
  41958. var copyAst = Object.assign({}, queryAst);
  41959. copyAst.definitions = queryAst.definitions.filter(function (elem) {
  41960. return elem.kind !== _kinds.Kind.FRAGMENT_DEFINITION;
  41961. }).map(function (op) {
  41962. return resolveDefinition(fragments, op);
  41963. });
  41964. return copyAst;
  41965. }
  41966. },{"graphql/language/kinds":51}],251:[function(require,module,exports){
  41967. "use strict";
  41968. Object.defineProperty(exports, "__esModule", {
  41969. value: true
  41970. });
  41971. exports.normalizeWhitespace = normalizeWhitespace;
  41972. exports.invalidCharacters = void 0;
  41973. /**
  41974. * Copyright (c) 2019 GraphQL Contributors.
  41975. *
  41976. * This source code is licensed under the MIT license found in the
  41977. * LICENSE file in the root directory of this source tree.
  41978. */
  41979. // Unicode whitespace characters that break the interface.
  41980. var invalidCharacters = Array.from({
  41981. length: 11
  41982. }, function (x, i) {
  41983. // \u2000 -> \u200a
  41984. return String.fromCharCode(0x2000 + i);
  41985. }).concat(["\u2028", "\u2029", "\u202F", "\xA0"]);
  41986. exports.invalidCharacters = invalidCharacters;
  41987. var sanitizeRegex = new RegExp('[' + invalidCharacters.join('') + ']', 'g');
  41988. function normalizeWhitespace(line) {
  41989. return line.replace(sanitizeRegex, ' ');
  41990. }
  41991. },{}],252:[function(require,module,exports){
  41992. "use strict";
  41993. Object.defineProperty(exports, "__esModule", {
  41994. value: true
  41995. });
  41996. exports.default = onHasCompletion;
  41997. var _graphql = require("graphql");
  41998. var _markdownIt = _interopRequireDefault(require("markdown-it"));
  41999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42000. /**
  42001. * Copyright (c) 2019 GraphQL Contributors.
  42002. *
  42003. * This source code is licensed under the MIT license found in the
  42004. * LICENSE file in the root directory of this source tree.
  42005. */
  42006. var md = new _markdownIt.default();
  42007. /**
  42008. * Render a custom UI for CodeMirror's hint which includes additional info
  42009. * about the type and description for the selected context.
  42010. */
  42011. function onHasCompletion(cm, data, onHintInformationRender) {
  42012. var CodeMirror = require('codemirror');
  42013. var information;
  42014. var deprecation; // When a hint result is selected, we augment the UI with information.
  42015. CodeMirror.on(data, 'select', function (ctx, el) {
  42016. // Only the first time (usually when the hint UI is first displayed)
  42017. // do we create the information nodes.
  42018. if (!information) {
  42019. var hintsUl = el.parentNode; // This "information" node will contain the additional info about the
  42020. // highlighted typeahead option.
  42021. information = document.createElement('div');
  42022. information.className = 'CodeMirror-hint-information';
  42023. hintsUl.appendChild(information); // This "deprecation" node will contain info about deprecated usage.
  42024. deprecation = document.createElement('div');
  42025. deprecation.className = 'CodeMirror-hint-deprecation';
  42026. hintsUl.appendChild(deprecation); // When CodeMirror attempts to remove the hint UI, we detect that it was
  42027. // removed and in turn remove the information nodes.
  42028. var _onRemoveFn;
  42029. hintsUl.addEventListener('DOMNodeRemoved', _onRemoveFn = function onRemoveFn(event) {
  42030. if (event.target === hintsUl) {
  42031. hintsUl.removeEventListener('DOMNodeRemoved', _onRemoveFn);
  42032. information = null;
  42033. deprecation = null;
  42034. _onRemoveFn = null;
  42035. }
  42036. });
  42037. } // Now that the UI has been set up, add info to information.
  42038. var description = ctx.description ? md.render(ctx.description) : 'Self descriptive.';
  42039. var type = ctx.type ? '<span class="infoType">' + renderType(ctx.type) + '</span>' : '';
  42040. information.innerHTML = '<div class="content">' + (description.slice(0, 3) === '<p>' ? '<p>' + type + description.slice(3) : type + description) + '</div>';
  42041. if (ctx.isDeprecated) {
  42042. var reason = ctx.deprecationReason ? md.render(ctx.deprecationReason) : '';
  42043. deprecation.innerHTML = '<span class="deprecation-label">Deprecated</span>' + reason;
  42044. deprecation.style.display = 'block';
  42045. } else {
  42046. deprecation.style.display = 'none';
  42047. } // Additional rendering?
  42048. if (onHintInformationRender) {
  42049. onHintInformationRender(information);
  42050. }
  42051. });
  42052. }
  42053. function renderType(type) {
  42054. if (type instanceof _graphql.GraphQLNonNull) {
  42055. return "".concat(renderType(type.ofType), "!");
  42056. }
  42057. if (type instanceof _graphql.GraphQLList) {
  42058. return "[".concat(renderType(type.ofType), "]");
  42059. }
  42060. return "<a class=\"typeName\">".concat(type.name, "</a>");
  42061. }
  42062. },{"codemirror":16,"graphql":29,"markdown-it":140}],253:[function(require,module,exports){
  42063. 'use strict';
  42064. var _codemirror = require('codemirror');
  42065. var _codemirror2 = _interopRequireDefault(_codemirror);
  42066. var _graphqlLanguageServiceInterface = require('graphql-language-service-interface');
  42067. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42068. /**
  42069. * Registers a "hint" helper for CodeMirror.
  42070. *
  42071. * Using CodeMirror's "hint" addon: https://codemirror.net/demo/complete.html
  42072. * Given an editor, this helper will take the token at the cursor and return a
  42073. * list of suggested tokens.
  42074. *
  42075. * Options:
  42076. *
  42077. * - schema: GraphQLSchema provides the hinter with positionally relevant info
  42078. *
  42079. * Additional Events:
  42080. *
  42081. * - hasCompletion (codemirror, data, token) - signaled when the hinter has a
  42082. * new list of completion suggestions.
  42083. *
  42084. */
  42085. /**
  42086. * Copyright (c) 2015, Facebook, Inc.
  42087. * All rights reserved.
  42088. *
  42089. * This source code is licensed under the BSD-style license found in the
  42090. * LICENSE file in the root directory of this source tree. An additional grant
  42091. * of patent rights can be found in the PATENTS file in the same directory.
  42092. */
  42093. _codemirror2.default.registerHelper('hint', 'graphql', function (editor, options) {
  42094. var schema = options.schema;
  42095. if (!schema) {
  42096. return;
  42097. }
  42098. var cur = editor.getCursor();
  42099. var token = editor.getTokenAt(cur);
  42100. var rawResults = (0, _graphqlLanguageServiceInterface.getAutocompleteSuggestions)(schema, editor.getValue(), cur, token);
  42101. /**
  42102. * GraphQL language service responds to the autocompletion request with
  42103. * a different format:
  42104. * type CompletionItem = {
  42105. * label: string,
  42106. * kind?: number,
  42107. * detail?: string,
  42108. * documentation?: string,
  42109. * // GraphQL Deprecation information
  42110. * isDeprecated?: ?string,
  42111. * deprecationReason?: ?string,
  42112. * };
  42113. *
  42114. * Switch to codemirror-compliant format before returning results.
  42115. */
  42116. var tokenStart = token.type !== null && /"|\w/.test(token.string[0]) ? token.start : token.end;
  42117. var results = {
  42118. list: rawResults.map(function (item) {
  42119. return {
  42120. text: item.label,
  42121. type: schema.getType(item.detail),
  42122. description: item.documentation,
  42123. isDeprecated: item.isDeprecated,
  42124. deprecationReason: item.deprecationReason
  42125. };
  42126. }),
  42127. from: { line: cur.line, column: tokenStart },
  42128. to: { line: cur.line, column: token.end }
  42129. };
  42130. if (results && results.list && results.list.length > 0) {
  42131. results.from = _codemirror2.default.Pos(results.from.line, results.from.column);
  42132. results.to = _codemirror2.default.Pos(results.to.line, results.to.column);
  42133. _codemirror2.default.signal(editor, 'hasCompletion', editor, results, token);
  42134. }
  42135. return results;
  42136. });
  42137. },{"codemirror":16,"graphql-language-service-interface":265}],254:[function(require,module,exports){
  42138. 'use strict';
  42139. var _graphql = require('graphql');
  42140. var _codemirror = require('codemirror');
  42141. var _codemirror2 = _interopRequireDefault(_codemirror);
  42142. var _getTypeInfo = require('./utils/getTypeInfo');
  42143. var _getTypeInfo2 = _interopRequireDefault(_getTypeInfo);
  42144. var _SchemaReference = require('./utils/SchemaReference');
  42145. require('./utils/info-addon');
  42146. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42147. /**
  42148. * Registers GraphQL "info" tooltips for CodeMirror.
  42149. *
  42150. * When hovering over a token, this presents a tooltip explaining it.
  42151. *
  42152. * Options:
  42153. *
  42154. * - schema: GraphQLSchema provides positionally relevant info.
  42155. * - hoverTime: The number of ms to wait before showing info. (Default 500)
  42156. * - renderDescription: Convert a description to some HTML, Useful since
  42157. * descriptions are often Markdown formatted.
  42158. * - onClick: A function called when a named thing is clicked.
  42159. *
  42160. */
  42161. _codemirror2.default.registerHelper('info', 'graphql', function (token, options) {
  42162. if (!options.schema || !token.state) {
  42163. return;
  42164. }
  42165. var state = token.state;
  42166. var kind = state.kind;
  42167. var step = state.step;
  42168. var typeInfo = (0, _getTypeInfo2.default)(options.schema, token.state);
  42169. // Given a Schema and a Token, produce the contents of an info tooltip.
  42170. // To do this, create a div element that we will render "into" and then pass
  42171. // it to various rendering functions.
  42172. if (kind === 'Field' && step === 0 && typeInfo.fieldDef || kind === 'AliasedField' && step === 2 && typeInfo.fieldDef) {
  42173. var into = document.createElement('div');
  42174. renderField(into, typeInfo, options);
  42175. renderDescription(into, options, typeInfo.fieldDef);
  42176. return into;
  42177. } else if (kind === 'Directive' && step === 1 && typeInfo.directiveDef) {
  42178. var _into = document.createElement('div');
  42179. renderDirective(_into, typeInfo, options);
  42180. renderDescription(_into, options, typeInfo.directiveDef);
  42181. return _into;
  42182. } else if (kind === 'Argument' && step === 0 && typeInfo.argDef) {
  42183. var _into2 = document.createElement('div');
  42184. renderArg(_into2, typeInfo, options);
  42185. renderDescription(_into2, options, typeInfo.argDef);
  42186. return _into2;
  42187. } else if (kind === 'EnumValue' && typeInfo.enumValue && typeInfo.enumValue.description) {
  42188. var _into3 = document.createElement('div');
  42189. renderEnumValue(_into3, typeInfo, options);
  42190. renderDescription(_into3, options, typeInfo.enumValue);
  42191. return _into3;
  42192. } else if (kind === 'NamedType' && typeInfo.type && typeInfo.type.description) {
  42193. var _into4 = document.createElement('div');
  42194. renderType(_into4, typeInfo, options, typeInfo.type);
  42195. renderDescription(_into4, options, typeInfo.type);
  42196. return _into4;
  42197. }
  42198. });
  42199. /**
  42200. * Copyright (c) 2017, Facebook, Inc.
  42201. * All rights reserved.
  42202. *
  42203. * This source code is licensed under the BSD-style license found in the
  42204. * LICENSE file in the root directory of this source tree. An additional grant
  42205. * of patent rights can be found in the PATENTS file in the same directory.
  42206. */
  42207. function renderField(into, typeInfo, options) {
  42208. renderQualifiedField(into, typeInfo, options);
  42209. renderTypeAnnotation(into, typeInfo, options, typeInfo.type);
  42210. }
  42211. function renderQualifiedField(into, typeInfo, options) {
  42212. var fieldName = typeInfo.fieldDef.name;
  42213. if (fieldName.slice(0, 2) !== '__') {
  42214. renderType(into, typeInfo, options, typeInfo.parentType);
  42215. text(into, '.');
  42216. }
  42217. text(into, fieldName, 'field-name', options, (0, _SchemaReference.getFieldReference)(typeInfo));
  42218. }
  42219. function renderDirective(into, typeInfo, options) {
  42220. var name = '@' + typeInfo.directiveDef.name;
  42221. text(into, name, 'directive-name', options, (0, _SchemaReference.getDirectiveReference)(typeInfo));
  42222. }
  42223. function renderArg(into, typeInfo, options) {
  42224. if (typeInfo.directiveDef) {
  42225. renderDirective(into, typeInfo, options);
  42226. } else if (typeInfo.fieldDef) {
  42227. renderQualifiedField(into, typeInfo, options);
  42228. }
  42229. var name = typeInfo.argDef.name;
  42230. text(into, '(');
  42231. text(into, name, 'arg-name', options, (0, _SchemaReference.getArgumentReference)(typeInfo));
  42232. renderTypeAnnotation(into, typeInfo, options, typeInfo.inputType);
  42233. text(into, ')');
  42234. }
  42235. function renderTypeAnnotation(into, typeInfo, options, t) {
  42236. text(into, ': ');
  42237. renderType(into, typeInfo, options, t);
  42238. }
  42239. function renderEnumValue(into, typeInfo, options) {
  42240. var name = typeInfo.enumValue.name;
  42241. renderType(into, typeInfo, options, typeInfo.inputType);
  42242. text(into, '.');
  42243. text(into, name, 'enum-value', options, (0, _SchemaReference.getEnumValueReference)(typeInfo));
  42244. }
  42245. function renderType(into, typeInfo, options, t) {
  42246. if (t instanceof _graphql.GraphQLNonNull) {
  42247. renderType(into, typeInfo, options, t.ofType);
  42248. text(into, '!');
  42249. } else if (t instanceof _graphql.GraphQLList) {
  42250. text(into, '[');
  42251. renderType(into, typeInfo, options, t.ofType);
  42252. text(into, ']');
  42253. } else {
  42254. text(into, t.name, 'type-name', options, (0, _SchemaReference.getTypeReference)(typeInfo, t));
  42255. }
  42256. }
  42257. function renderDescription(into, options, def) {
  42258. var description = def.description;
  42259. if (description) {
  42260. var descriptionDiv = document.createElement('div');
  42261. descriptionDiv.className = 'info-description';
  42262. if (options.renderDescription) {
  42263. descriptionDiv.innerHTML = options.renderDescription(description);
  42264. } else {
  42265. descriptionDiv.appendChild(document.createTextNode(description));
  42266. }
  42267. into.appendChild(descriptionDiv);
  42268. }
  42269. renderDeprecation(into, options, def);
  42270. }
  42271. function renderDeprecation(into, options, def) {
  42272. var reason = def.deprecationReason;
  42273. if (reason) {
  42274. var deprecationDiv = document.createElement('div');
  42275. deprecationDiv.className = 'info-deprecation';
  42276. if (options.renderDescription) {
  42277. deprecationDiv.innerHTML = options.renderDescription(reason);
  42278. } else {
  42279. deprecationDiv.appendChild(document.createTextNode(reason));
  42280. }
  42281. var label = document.createElement('span');
  42282. label.className = 'info-deprecation-label';
  42283. label.appendChild(document.createTextNode('Deprecated: '));
  42284. deprecationDiv.insertBefore(label, deprecationDiv.firstChild);
  42285. into.appendChild(deprecationDiv);
  42286. }
  42287. }
  42288. function text(into, content, className, options, ref) {
  42289. if (className) {
  42290. var onClick = options.onClick;
  42291. var node = document.createElement(onClick ? 'a' : 'span');
  42292. if (onClick) {
  42293. // Providing a href forces proper a tag behavior, though we don't actually
  42294. // want clicking the node to navigate anywhere.
  42295. node.href = 'javascript:void 0'; // eslint-disable-line no-script-url
  42296. node.addEventListener('click', function (e) {
  42297. onClick(ref, e);
  42298. });
  42299. }
  42300. node.className = className;
  42301. node.appendChild(document.createTextNode(content));
  42302. into.appendChild(node);
  42303. } else {
  42304. into.appendChild(document.createTextNode(content));
  42305. }
  42306. }
  42307. },{"./utils/SchemaReference":392,"./utils/getTypeInfo":394,"./utils/info-addon":396,"codemirror":16,"graphql":285}],255:[function(require,module,exports){
  42308. 'use strict';
  42309. var _codemirror = require('codemirror');
  42310. var _codemirror2 = _interopRequireDefault(_codemirror);
  42311. var _getTypeInfo = require('./utils/getTypeInfo');
  42312. var _getTypeInfo2 = _interopRequireDefault(_getTypeInfo);
  42313. var _SchemaReference = require('./utils/SchemaReference');
  42314. require('./utils/jump-addon');
  42315. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42316. /**
  42317. * Registers GraphQL "jump" links for CodeMirror.
  42318. *
  42319. * When command-hovering over a token, this converts it to a link, which when
  42320. * pressed will call the provided onClick handler.
  42321. *
  42322. * Options:
  42323. *
  42324. * - schema: GraphQLSchema provides positionally relevant info.
  42325. * - onClick: A function called when a named thing is clicked.
  42326. *
  42327. */
  42328. /**
  42329. * Copyright (c) 2017, Facebook, Inc.
  42330. * All rights reserved.
  42331. *
  42332. * This source code is licensed under the BSD-style license found in the
  42333. * LICENSE file in the root directory of this source tree. An additional grant
  42334. * of patent rights can be found in the PATENTS file in the same directory.
  42335. */
  42336. _codemirror2.default.registerHelper('jump', 'graphql', function (token, options) {
  42337. if (!options.schema || !options.onClick || !token.state) {
  42338. return;
  42339. }
  42340. // Given a Schema and a Token, produce a "SchemaReference" which refers to
  42341. // the particular artifact from the schema (such as a type, field, argument,
  42342. // or directive) that token references.
  42343. var state = token.state;
  42344. var kind = state.kind;
  42345. var step = state.step;
  42346. var typeInfo = (0, _getTypeInfo2.default)(options.schema, state);
  42347. if (kind === 'Field' && step === 0 && typeInfo.fieldDef || kind === 'AliasedField' && step === 2 && typeInfo.fieldDef) {
  42348. return (0, _SchemaReference.getFieldReference)(typeInfo);
  42349. } else if (kind === 'Directive' && step === 1 && typeInfo.directiveDef) {
  42350. return (0, _SchemaReference.getDirectiveReference)(typeInfo);
  42351. } else if (kind === 'Argument' && step === 0 && typeInfo.argDef) {
  42352. return (0, _SchemaReference.getArgumentReference)(typeInfo);
  42353. } else if (kind === 'EnumValue' && typeInfo.enumValue) {
  42354. return (0, _SchemaReference.getEnumValueReference)(typeInfo);
  42355. } else if (kind === 'NamedType' && typeInfo.type) {
  42356. return (0, _SchemaReference.getTypeReference)(typeInfo);
  42357. }
  42358. });
  42359. },{"./utils/SchemaReference":392,"./utils/getTypeInfo":394,"./utils/jump-addon":398,"codemirror":16}],256:[function(require,module,exports){
  42360. 'use strict';
  42361. var _codemirror = require('codemirror');
  42362. var _codemirror2 = _interopRequireDefault(_codemirror);
  42363. var _graphqlLanguageServiceInterface = require('graphql-language-service-interface');
  42364. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42365. /**
  42366. * Copyright (c) 2015, Facebook, Inc.
  42367. * All rights reserved.
  42368. *
  42369. * This source code is licensed under the BSD-style license found in the
  42370. * LICENSE file in the root directory of this source tree. An additional grant
  42371. * of patent rights can be found in the PATENTS file in the same directory.
  42372. */
  42373. var SEVERITY = ['error', 'warning', 'information', 'hint'];
  42374. var TYPE = {
  42375. 'GraphQL: Validation': 'validation',
  42376. 'GraphQL: Deprecation': 'deprecation',
  42377. 'GraphQL: Syntax': 'syntax'
  42378. };
  42379. /**
  42380. * Registers a "lint" helper for CodeMirror.
  42381. *
  42382. * Using CodeMirror's "lint" addon: https://codemirror.net/demo/lint.html
  42383. * Given the text within an editor, this helper will take that text and return
  42384. * a list of linter issues, derived from GraphQL's parse and validate steps.
  42385. * Also, this uses `graphql-language-service-parser` to power the diagnostics
  42386. * service.
  42387. *
  42388. * Options:
  42389. *
  42390. * - schema: GraphQLSchema provides the linter with positionally relevant info
  42391. *
  42392. */
  42393. _codemirror2.default.registerHelper('lint', 'graphql', function (text, options) {
  42394. var schema = options.schema;
  42395. var rawResults = (0, _graphqlLanguageServiceInterface.getDiagnostics)(text, schema);
  42396. var results = rawResults.map(function (error) {
  42397. return {
  42398. message: error.message,
  42399. severity: SEVERITY[error.severity - 1],
  42400. type: TYPE[error.source],
  42401. from: _codemirror2.default.Pos(error.range.start.line, error.range.start.character),
  42402. to: _codemirror2.default.Pos(error.range.end.line, error.range.end.character)
  42403. };
  42404. });
  42405. return results;
  42406. });
  42407. },{"codemirror":16,"graphql-language-service-interface":265}],257:[function(require,module,exports){
  42408. 'use strict';
  42409. var _codemirror = require('codemirror');
  42410. var _codemirror2 = _interopRequireDefault(_codemirror);
  42411. var _graphqlLanguageServiceParser = require('graphql-language-service-parser');
  42412. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  42413. /**
  42414. * The GraphQL mode is defined as a tokenizer along with a list of rules, each
  42415. * of which is either a function or an array.
  42416. *
  42417. * * Function: Provided a token and the stream, returns an expected next step.
  42418. * * Array: A list of steps to take in order.
  42419. *
  42420. * A step is either another rule, or a terminal description of a token. If it
  42421. * is a rule, that rule is pushed onto the stack and the parsing continues from
  42422. * that point.
  42423. *
  42424. * If it is a terminal description, the token is checked against it using a
  42425. * `match` function. If the match is successful, the token is colored and the
  42426. * rule is stepped forward. If the match is unsuccessful, the remainder of the
  42427. * rule is skipped and the previous rule is advanced.
  42428. *
  42429. * This parsing algorithm allows for incremental online parsing within various
  42430. * levels of the syntax tree and results in a structured `state` linked-list
  42431. * which contains the relevant information to produce valuable typeaheads.
  42432. */
  42433. /**
  42434. * Copyright (c) 2015, Facebook, Inc.
  42435. * All rights reserved.
  42436. *
  42437. * This source code is licensed under the BSD-style license found in the
  42438. * LICENSE file in the root directory of this source tree. An additional grant
  42439. * of patent rights can be found in the PATENTS file in the same directory.
  42440. */
  42441. _codemirror2.default.defineMode('graphql', function (config) {
  42442. var parser = (0, _graphqlLanguageServiceParser.onlineParser)({
  42443. eatWhitespace: function eatWhitespace(stream) {
  42444. return stream.eatWhile(_graphqlLanguageServiceParser.isIgnored);
  42445. },
  42446. lexRules: _graphqlLanguageServiceParser.LexRules,
  42447. parseRules: _graphqlLanguageServiceParser.ParseRules,
  42448. editorConfig: { tabSize: config.tabSize }
  42449. });
  42450. return {
  42451. config: config,
  42452. startState: parser.startState,
  42453. token: parser.token,
  42454. indent: indent,
  42455. electricInput: /^\s*[})\]]/,
  42456. fold: 'brace',
  42457. lineComment: '#',
  42458. closeBrackets: {
  42459. pairs: '()[]{}""',
  42460. explode: '()[]{}'
  42461. }
  42462. };
  42463. });
  42464. function indent(state, textAfter) {
  42465. var levels = state.levels;
  42466. // If there is no stack of levels, use the current level.
  42467. // Otherwise, use the top level, pre-emptively dedenting for close braces.
  42468. var level = !levels || levels.length === 0 ? state.indentLevel : levels[levels.length - 1] - (this.electricInput.test(textAfter) ? 1 : 0);
  42469. return level * this.config.indentUnit;
  42470. }
  42471. },{"codemirror":16,"graphql-language-service-parser":269}],258:[function(require,module,exports){
  42472. 'use strict';
  42473. Object.defineProperty(exports, "__esModule", {
  42474. value: true
  42475. });
  42476. exports.GraphQLLanguageService = undefined;
  42477. var _graphql = require('graphql');
  42478. var _getAutocompleteSuggestions2 = require('./getAutocompleteSuggestions');
  42479. var _getHoverInformation2 = require('./getHoverInformation');
  42480. var _getDiagnostics = require('./getDiagnostics');
  42481. var _getDefinition = require('./getDefinition');
  42482. var _graphqlLanguageServiceUtils = require('graphql-language-service-utils');
  42483. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
  42484. * Copyright (c) Facebook, Inc.
  42485. * All rights reserved.
  42486. *
  42487. * This source code is licensed under the license found in the
  42488. * LICENSE file in the root directory of this source tree.
  42489. *
  42490. *
  42491. */
  42492. var FRAGMENT_DEFINITION = _graphql.Kind.FRAGMENT_DEFINITION,
  42493. OBJECT_TYPE_DEFINITION = _graphql.Kind.OBJECT_TYPE_DEFINITION,
  42494. INTERFACE_TYPE_DEFINITION = _graphql.Kind.INTERFACE_TYPE_DEFINITION,
  42495. ENUM_TYPE_DEFINITION = _graphql.Kind.ENUM_TYPE_DEFINITION,
  42496. UNION_TYPE_DEFINITION = _graphql.Kind.UNION_TYPE_DEFINITION,
  42497. SCALAR_TYPE_DEFINITION = _graphql.Kind.SCALAR_TYPE_DEFINITION,
  42498. INPUT_OBJECT_TYPE_DEFINITION = _graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
  42499. SCALAR_TYPE_EXTENSION = _graphql.Kind.SCALAR_TYPE_EXTENSION,
  42500. OBJECT_TYPE_EXTENSION = _graphql.Kind.OBJECT_TYPE_EXTENSION,
  42501. INTERFACE_TYPE_EXTENSION = _graphql.Kind.INTERFACE_TYPE_EXTENSION,
  42502. UNION_TYPE_EXTENSION = _graphql.Kind.UNION_TYPE_EXTENSION,
  42503. ENUM_TYPE_EXTENSION = _graphql.Kind.ENUM_TYPE_EXTENSION,
  42504. INPUT_OBJECT_TYPE_EXTENSION = _graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION,
  42505. DIRECTIVE_DEFINITION = _graphql.Kind.DIRECTIVE_DEFINITION,
  42506. FRAGMENT_SPREAD = _graphql.Kind.FRAGMENT_SPREAD,
  42507. OPERATION_DEFINITION = _graphql.Kind.OPERATION_DEFINITION,
  42508. NAMED_TYPE = _graphql.Kind.NAMED_TYPE;
  42509. var GraphQLLanguageService = exports.GraphQLLanguageService = function () {
  42510. function GraphQLLanguageService(cache) {
  42511. _classCallCheck(this, GraphQLLanguageService);
  42512. this._graphQLCache = cache;
  42513. this._graphQLConfig = cache.getGraphQLConfig();
  42514. }
  42515. GraphQLLanguageService.prototype.getDiagnostics = function getDiagnostics(query, uri, isRelayCompatMode) {
  42516. var queryHasExtensions, projectConfig, schemaPath, queryAST, range, source, fragmentDefinitions, fragmentDependencies, dependenciesSource, validationAst, customRules, customRulesModulePath, rulesPath, schema;
  42517. return regeneratorRuntime.async(function getDiagnostics$(_context) {
  42518. while (1) {
  42519. switch (_context.prev = _context.next) {
  42520. case 0:
  42521. // Perform syntax diagnostics first, as this doesn't require
  42522. // schema/fragment definitions, even the project configuration.
  42523. queryHasExtensions = false;
  42524. projectConfig = this._graphQLConfig.getConfigForFile(uri);
  42525. schemaPath = projectConfig.schemaPath;
  42526. _context.prev = 3;
  42527. queryAST = (0, _graphql.parse)(query);
  42528. if (!schemaPath || uri !== schemaPath) {
  42529. queryHasExtensions = queryAST.definitions.some(function (definition) {
  42530. switch (definition.kind) {
  42531. case OBJECT_TYPE_DEFINITION:
  42532. case INTERFACE_TYPE_DEFINITION:
  42533. case ENUM_TYPE_DEFINITION:
  42534. case UNION_TYPE_DEFINITION:
  42535. case SCALAR_TYPE_DEFINITION:
  42536. case INPUT_OBJECT_TYPE_DEFINITION:
  42537. case SCALAR_TYPE_EXTENSION:
  42538. case OBJECT_TYPE_EXTENSION:
  42539. case INTERFACE_TYPE_EXTENSION:
  42540. case UNION_TYPE_EXTENSION:
  42541. case ENUM_TYPE_EXTENSION:
  42542. case INPUT_OBJECT_TYPE_EXTENSION:
  42543. case DIRECTIVE_DEFINITION:
  42544. return true;
  42545. }
  42546. return false;
  42547. });
  42548. }
  42549. _context.next = 12;
  42550. break;
  42551. case 8:
  42552. _context.prev = 8;
  42553. _context.t0 = _context['catch'](3);
  42554. range = (0, _getDiagnostics.getRange)(_context.t0.locations[0], query);
  42555. return _context.abrupt('return', [{
  42556. severity: _getDiagnostics.SEVERITY.ERROR,
  42557. message: _context.t0.message,
  42558. source: 'GraphQL: Syntax',
  42559. range: range
  42560. }]);
  42561. case 12:
  42562. // If there's a matching config, proceed to prepare to run validation
  42563. source = query;
  42564. _context.next = 15;
  42565. return regeneratorRuntime.awrap(this._graphQLCache.getFragmentDefinitions(projectConfig));
  42566. case 15:
  42567. fragmentDefinitions = _context.sent;
  42568. _context.next = 18;
  42569. return regeneratorRuntime.awrap(this._graphQLCache.getFragmentDependencies(query, fragmentDefinitions));
  42570. case 18:
  42571. fragmentDependencies = _context.sent;
  42572. dependenciesSource = fragmentDependencies.reduce(function (prev, cur) {
  42573. return prev + ' ' + (0, _graphql.print)(cur.definition);
  42574. }, '');
  42575. source = source + ' ' + dependenciesSource;
  42576. validationAst = null;
  42577. _context.prev = 22;
  42578. validationAst = (0, _graphql.parse)(source);
  42579. _context.next = 29;
  42580. break;
  42581. case 26:
  42582. _context.prev = 26;
  42583. _context.t1 = _context['catch'](22);
  42584. return _context.abrupt('return', []);
  42585. case 29:
  42586. // Check if there are custom validation rules to be used
  42587. customRules = void 0;
  42588. customRulesModulePath = projectConfig.extensions.customValidationRules;
  42589. if (customRulesModulePath) {
  42590. /* eslint-disable no-implicit-coercion */
  42591. rulesPath = require.resolve('' + customRulesModulePath);
  42592. if (rulesPath) {
  42593. customRules = require('' + rulesPath)(this._graphQLConfig);
  42594. }
  42595. /* eslint-enable no-implicit-coercion */
  42596. }
  42597. _context.next = 34;
  42598. return regeneratorRuntime.awrap(this._graphQLCache.getSchema(projectConfig.projectName, queryHasExtensions).catch(function () {
  42599. return null;
  42600. }));
  42601. case 34:
  42602. schema = _context.sent;
  42603. if (schema) {
  42604. _context.next = 37;
  42605. break;
  42606. }
  42607. return _context.abrupt('return', []);
  42608. case 37:
  42609. return _context.abrupt('return', (0, _getDiagnostics.validateQuery)(validationAst, schema, customRules, isRelayCompatMode));
  42610. case 38:
  42611. case 'end':
  42612. return _context.stop();
  42613. }
  42614. }
  42615. }, null, this, [[3, 8], [22, 26]]);
  42616. };
  42617. GraphQLLanguageService.prototype.getAutocompleteSuggestions = function getAutocompleteSuggestions(query, position, filePath) {
  42618. var projectConfig, schema;
  42619. return regeneratorRuntime.async(function getAutocompleteSuggestions$(_context2) {
  42620. while (1) {
  42621. switch (_context2.prev = _context2.next) {
  42622. case 0:
  42623. projectConfig = this._graphQLConfig.getConfigForFile(filePath);
  42624. _context2.next = 3;
  42625. return regeneratorRuntime.awrap(this._graphQLCache.getSchema(projectConfig.projectName).catch(function () {
  42626. return null;
  42627. }));
  42628. case 3:
  42629. schema = _context2.sent;
  42630. if (!schema) {
  42631. _context2.next = 6;
  42632. break;
  42633. }
  42634. return _context2.abrupt('return', (0, _getAutocompleteSuggestions2.getAutocompleteSuggestions)(schema, query, position));
  42635. case 6:
  42636. return _context2.abrupt('return', []);
  42637. case 7:
  42638. case 'end':
  42639. return _context2.stop();
  42640. }
  42641. }
  42642. }, null, this);
  42643. };
  42644. GraphQLLanguageService.prototype.getHoverInformation = function getHoverInformation(query, position, filePath) {
  42645. var projectConfig, schema;
  42646. return regeneratorRuntime.async(function getHoverInformation$(_context3) {
  42647. while (1) {
  42648. switch (_context3.prev = _context3.next) {
  42649. case 0:
  42650. projectConfig = this._graphQLConfig.getConfigForFile(filePath);
  42651. _context3.next = 3;
  42652. return regeneratorRuntime.awrap(this._graphQLCache.getSchema(projectConfig.projectName).catch(function () {
  42653. return null;
  42654. }));
  42655. case 3:
  42656. schema = _context3.sent;
  42657. if (!schema) {
  42658. _context3.next = 6;
  42659. break;
  42660. }
  42661. return _context3.abrupt('return', (0, _getHoverInformation2.getHoverInformation)(schema, query, position));
  42662. case 6:
  42663. return _context3.abrupt('return', '');
  42664. case 7:
  42665. case 'end':
  42666. return _context3.stop();
  42667. }
  42668. }
  42669. }, null, this);
  42670. };
  42671. GraphQLLanguageService.prototype.getDefinition = function getDefinition(query, position, filePath) {
  42672. var projectConfig, ast, node;
  42673. return regeneratorRuntime.async(function getDefinition$(_context4) {
  42674. while (1) {
  42675. switch (_context4.prev = _context4.next) {
  42676. case 0:
  42677. projectConfig = this._graphQLConfig.getConfigForFile(filePath);
  42678. ast = void 0;
  42679. _context4.prev = 2;
  42680. ast = (0, _graphql.parse)(query);
  42681. _context4.next = 9;
  42682. break;
  42683. case 6:
  42684. _context4.prev = 6;
  42685. _context4.t0 = _context4['catch'](2);
  42686. return _context4.abrupt('return', null);
  42687. case 9:
  42688. node = (0, _graphqlLanguageServiceUtils.getASTNodeAtPosition)(query, ast, position);
  42689. if (!node) {
  42690. _context4.next = 17;
  42691. break;
  42692. }
  42693. _context4.t1 = node.kind;
  42694. _context4.next = _context4.t1 === FRAGMENT_SPREAD ? 14 : _context4.t1 === FRAGMENT_DEFINITION ? 15 : _context4.t1 === OPERATION_DEFINITION ? 15 : _context4.t1 === NAMED_TYPE ? 16 : 17;
  42695. break;
  42696. case 14:
  42697. return _context4.abrupt('return', this._getDefinitionForFragmentSpread(query, ast, node, filePath, projectConfig));
  42698. case 15:
  42699. return _context4.abrupt('return', (0, _getDefinition.getDefinitionQueryResultForDefinitionNode)(filePath, query, node));
  42700. case 16:
  42701. return _context4.abrupt('return', this._getDefinitionForNamedType(query, ast, node, filePath, projectConfig));
  42702. case 17:
  42703. return _context4.abrupt('return', null);
  42704. case 18:
  42705. case 'end':
  42706. return _context4.stop();
  42707. }
  42708. }
  42709. }, null, this, [[2, 6]]);
  42710. };
  42711. GraphQLLanguageService.prototype._getDefinitionForNamedType = function _getDefinitionForNamedType(query, ast, node, filePath, projectConfig) {
  42712. var objectTypeDefinitions, dependencies, localObjectTypeDefinitions, typeCastedDefs, localOperationDefinationInfos, result;
  42713. return regeneratorRuntime.async(function _getDefinitionForNamedType$(_context5) {
  42714. while (1) {
  42715. switch (_context5.prev = _context5.next) {
  42716. case 0:
  42717. _context5.next = 2;
  42718. return regeneratorRuntime.awrap(this._graphQLCache.getObjectTypeDefinitions(projectConfig));
  42719. case 2:
  42720. objectTypeDefinitions = _context5.sent;
  42721. _context5.next = 5;
  42722. return regeneratorRuntime.awrap(this._graphQLCache.getObjectTypeDependenciesForAST(ast, objectTypeDefinitions));
  42723. case 5:
  42724. dependencies = _context5.sent;
  42725. localObjectTypeDefinitions = ast.definitions.filter(function (definition) {
  42726. return definition.kind === OBJECT_TYPE_DEFINITION || definition.kind === INPUT_OBJECT_TYPE_DEFINITION || definition.kind === ENUM_TYPE_DEFINITION;
  42727. });
  42728. typeCastedDefs = localObjectTypeDefinitions;
  42729. localOperationDefinationInfos = typeCastedDefs.map(function (definition) {
  42730. return {
  42731. filePath: filePath,
  42732. content: query,
  42733. definition: definition
  42734. };
  42735. });
  42736. _context5.next = 11;
  42737. return regeneratorRuntime.awrap((0, _getDefinition.getDefinitionQueryResultForNamedType)(query, node, dependencies.concat(localOperationDefinationInfos)));
  42738. case 11:
  42739. result = _context5.sent;
  42740. return _context5.abrupt('return', result);
  42741. case 13:
  42742. case 'end':
  42743. return _context5.stop();
  42744. }
  42745. }
  42746. }, null, this);
  42747. };
  42748. GraphQLLanguageService.prototype._getDefinitionForFragmentSpread = function _getDefinitionForFragmentSpread(query, ast, node, filePath, projectConfig) {
  42749. var fragmentDefinitions, dependencies, localFragDefinitions, typeCastedDefs, localFragInfos, result;
  42750. return regeneratorRuntime.async(function _getDefinitionForFragmentSpread$(_context6) {
  42751. while (1) {
  42752. switch (_context6.prev = _context6.next) {
  42753. case 0:
  42754. _context6.next = 2;
  42755. return regeneratorRuntime.awrap(this._graphQLCache.getFragmentDefinitions(projectConfig));
  42756. case 2:
  42757. fragmentDefinitions = _context6.sent;
  42758. _context6.next = 5;
  42759. return regeneratorRuntime.awrap(this._graphQLCache.getFragmentDependenciesForAST(ast, fragmentDefinitions));
  42760. case 5:
  42761. dependencies = _context6.sent;
  42762. localFragDefinitions = ast.definitions.filter(function (definition) {
  42763. return definition.kind === FRAGMENT_DEFINITION;
  42764. });
  42765. typeCastedDefs = localFragDefinitions;
  42766. localFragInfos = typeCastedDefs.map(function (definition) {
  42767. return {
  42768. filePath: filePath,
  42769. content: query,
  42770. definition: definition
  42771. };
  42772. });
  42773. _context6.next = 11;
  42774. return regeneratorRuntime.awrap((0, _getDefinition.getDefinitionQueryResultForFragmentSpread)(query, node, dependencies.concat(localFragInfos)));
  42775. case 11:
  42776. result = _context6.sent;
  42777. return _context6.abrupt('return', result);
  42778. case 13:
  42779. case 'end':
  42780. return _context6.stop();
  42781. }
  42782. }
  42783. }, null, this);
  42784. };
  42785. return GraphQLLanguageService;
  42786. }();
  42787. },{"./getAutocompleteSuggestions":260,"./getDefinition":261,"./getDiagnostics":262,"./getHoverInformation":263,"graphql":285,"graphql-language-service-utils":273}],259:[function(require,module,exports){
  42788. 'use strict';
  42789. Object.defineProperty(exports, "__esModule", {
  42790. value: true
  42791. });
  42792. exports.getDefinitionState = getDefinitionState;
  42793. exports.getFieldDef = getFieldDef;
  42794. exports.forEachState = forEachState;
  42795. exports.objectValues = objectValues;
  42796. exports.hintList = hintList;
  42797. var _graphql = require('graphql');
  42798. var _introspection = require('graphql/type/introspection');
  42799. // Utility for returning the state representing the Definition this token state
  42800. // is within, if any.
  42801. function getDefinitionState(tokenState) {
  42802. var definitionState = void 0;
  42803. forEachState(tokenState, function (state) {
  42804. switch (state.kind) {
  42805. case 'Query':
  42806. case 'ShortQuery':
  42807. case 'Mutation':
  42808. case 'Subscription':
  42809. case 'FragmentDefinition':
  42810. definitionState = state;
  42811. break;
  42812. }
  42813. });
  42814. return definitionState;
  42815. }
  42816. // Gets the field definition given a type and field name
  42817. /**
  42818. * Copyright (c) Facebook, Inc.
  42819. * All rights reserved.
  42820. *
  42821. * This source code is licensed under the license found in the
  42822. * LICENSE file in the root directory of this source tree.
  42823. *
  42824. *
  42825. */
  42826. function getFieldDef(schema, type, fieldName) {
  42827. if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === type) {
  42828. return _introspection.SchemaMetaFieldDef;
  42829. }
  42830. if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === type) {
  42831. return _introspection.TypeMetaFieldDef;
  42832. }
  42833. if (fieldName === _introspection.TypeNameMetaFieldDef.name && (0, _graphql.isCompositeType)(type)) {
  42834. return _introspection.TypeNameMetaFieldDef;
  42835. }
  42836. if (type.getFields && typeof type.getFields === 'function') {
  42837. return type.getFields()[fieldName];
  42838. }
  42839. return null;
  42840. }
  42841. // Utility for iterating through a CodeMirror parse state stack bottom-up.
  42842. function forEachState(stack, fn) {
  42843. var reverseStateStack = [];
  42844. var state = stack;
  42845. while (state && state.kind) {
  42846. reverseStateStack.push(state);
  42847. state = state.prevState;
  42848. }
  42849. for (var i = reverseStateStack.length - 1; i >= 0; i--) {
  42850. fn(reverseStateStack[i]);
  42851. }
  42852. }
  42853. function objectValues(object) {
  42854. var keys = Object.keys(object);
  42855. var len = keys.length;
  42856. var values = new Array(len);
  42857. for (var i = 0; i < len; ++i) {
  42858. values[i] = object[keys[i]];
  42859. }
  42860. return values;
  42861. }
  42862. // Create the expected hint response given a possible list and a token
  42863. function hintList(token, list) {
  42864. return filterAndSortList(list, normalizeText(token.string));
  42865. }
  42866. // Given a list of hint entries and currently typed text, sort and filter to
  42867. // provide a concise list.
  42868. function filterAndSortList(list, text) {
  42869. if (!text) {
  42870. return filterNonEmpty(list, function (entry) {
  42871. return !entry.isDeprecated;
  42872. });
  42873. }
  42874. var byProximity = list.map(function (entry) {
  42875. return {
  42876. proximity: getProximity(normalizeText(entry.label), text),
  42877. entry: entry
  42878. };
  42879. });
  42880. var conciseMatches = filterNonEmpty(filterNonEmpty(byProximity, function (pair) {
  42881. return pair.proximity <= 2;
  42882. }), function (pair) {
  42883. return !pair.entry.isDeprecated;
  42884. });
  42885. var sortedMatches = conciseMatches.sort(function (a, b) {
  42886. return (a.entry.isDeprecated ? 1 : 0) - (b.entry.isDeprecated ? 1 : 0) || a.proximity - b.proximity || a.entry.label.length - b.entry.label.length;
  42887. });
  42888. return sortedMatches.map(function (pair) {
  42889. return pair.entry;
  42890. });
  42891. }
  42892. // Filters the array by the predicate, unless it results in an empty array,
  42893. // in which case return the original array.
  42894. function filterNonEmpty(array, predicate) {
  42895. var filtered = array.filter(predicate);
  42896. return filtered.length === 0 ? array : filtered;
  42897. }
  42898. function normalizeText(text) {
  42899. return text.toLowerCase().replace(/\W/g, '');
  42900. }
  42901. // Determine a numeric proximity for a suggestion based on current text.
  42902. function getProximity(suggestion, text) {
  42903. // start with lexical distance
  42904. var proximity = lexicalDistance(text, suggestion);
  42905. if (suggestion.length > text.length) {
  42906. // do not penalize long suggestions.
  42907. proximity -= suggestion.length - text.length - 1;
  42908. // penalize suggestions not starting with this phrase
  42909. proximity += suggestion.indexOf(text) === 0 ? 0 : 0.5;
  42910. }
  42911. return proximity;
  42912. }
  42913. /**
  42914. * Computes the lexical distance between strings A and B.
  42915. *
  42916. * The "distance" between two strings is given by counting the minimum number
  42917. * of edits needed to transform string A into string B. An edit can be an
  42918. * insertion, deletion, or substitution of a single character, or a swap of two
  42919. * adjacent characters.
  42920. *
  42921. * This distance can be useful for detecting typos in input or sorting
  42922. *
  42923. * @param {string} a
  42924. * @param {string} b
  42925. * @return {int} distance in number of edits
  42926. */
  42927. function lexicalDistance(a, b) {
  42928. var i = void 0;
  42929. var j = void 0;
  42930. var d = [];
  42931. var aLength = a.length;
  42932. var bLength = b.length;
  42933. for (i = 0; i <= aLength; i++) {
  42934. d[i] = [i];
  42935. }
  42936. for (j = 1; j <= bLength; j++) {
  42937. d[0][j] = j;
  42938. }
  42939. for (i = 1; i <= aLength; i++) {
  42940. for (j = 1; j <= bLength; j++) {
  42941. var cost = a[i - 1] === b[j - 1] ? 0 : 1;
  42942. d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
  42943. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  42944. d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
  42945. }
  42946. }
  42947. }
  42948. return d[aLength][bLength];
  42949. }
  42950. },{"graphql":285,"graphql/type/introspection":326}],260:[function(require,module,exports){
  42951. 'use strict';
  42952. Object.defineProperty(exports, "__esModule", {
  42953. value: true
  42954. });
  42955. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /**
  42956. * Copyright (c) Facebook, Inc.
  42957. * All rights reserved.
  42958. *
  42959. * This source code is licensed under the license found in the
  42960. * LICENSE file in the root directory of this source tree.
  42961. *
  42962. *
  42963. */
  42964. exports.getAutocompleteSuggestions = getAutocompleteSuggestions;
  42965. exports.getTokenAtPosition = getTokenAtPosition;
  42966. exports.getTypeInfo = getTypeInfo;
  42967. var _graphql = require('graphql');
  42968. var _graphqlLanguageServiceParser = require('graphql-language-service-parser');
  42969. var _autocompleteUtils = require('./autocompleteUtils');
  42970. /**
  42971. * Given GraphQLSchema, queryText, and context of the current position within
  42972. * the source text, provide a list of typeahead entries.
  42973. */
  42974. function getAutocompleteSuggestions(schema, queryText, cursor, contextToken) {
  42975. var token = contextToken || getTokenAtPosition(queryText, cursor);
  42976. var state = token.state.kind === 'Invalid' ? token.state.prevState : token.state;
  42977. // relieve flow errors by checking if `state` exists
  42978. if (!state) {
  42979. return [];
  42980. }
  42981. var kind = state.kind;
  42982. var step = state.step;
  42983. var typeInfo = getTypeInfo(schema, token.state);
  42984. // Definition kinds
  42985. if (kind === 'Document') {
  42986. return (0, _autocompleteUtils.hintList)(token, [{ label: 'query' }, { label: 'mutation' }, { label: 'subscription' }, { label: 'fragment' }, { label: '{' }]);
  42987. }
  42988. // Field names
  42989. if (kind === 'SelectionSet' || kind === 'Field' || kind === 'AliasedField') {
  42990. return getSuggestionsForFieldNames(token, typeInfo, schema);
  42991. }
  42992. // Argument names
  42993. if (kind === 'Arguments' || kind === 'Argument' && step === 0) {
  42994. var argDefs = typeInfo.argDefs;
  42995. if (argDefs) {
  42996. return (0, _autocompleteUtils.hintList)(token, argDefs.map(function (argDef) {
  42997. return {
  42998. label: argDef.name,
  42999. detail: String(argDef.type),
  43000. documentation: argDef.description
  43001. };
  43002. }));
  43003. }
  43004. }
  43005. // Input Object fields
  43006. if (kind === 'ObjectValue' || kind === 'ObjectField' && step === 0) {
  43007. if (typeInfo.objectFieldDefs) {
  43008. var objectFields = (0, _autocompleteUtils.objectValues)(typeInfo.objectFieldDefs);
  43009. return (0, _autocompleteUtils.hintList)(token, objectFields.map(function (field) {
  43010. return {
  43011. label: field.name,
  43012. detail: String(field.type),
  43013. documentation: field.description
  43014. };
  43015. }));
  43016. }
  43017. }
  43018. // Input values: Enum and Boolean
  43019. if (kind === 'EnumValue' || kind === 'ListValue' && step === 1 || kind === 'ObjectField' && step === 2 || kind === 'Argument' && step === 2) {
  43020. return getSuggestionsForInputValues(token, typeInfo);
  43021. }
  43022. // Fragment type conditions
  43023. if (kind === 'TypeCondition' && step === 1 || kind === 'NamedType' && state.prevState != null && state.prevState.kind === 'TypeCondition') {
  43024. return getSuggestionsForFragmentTypeConditions(token, typeInfo, schema);
  43025. }
  43026. // Fragment spread names
  43027. if (kind === 'FragmentSpread' && step === 1) {
  43028. return getSuggestionsForFragmentSpread(token, typeInfo, schema, queryText);
  43029. }
  43030. // Variable definition types
  43031. if (kind === 'VariableDefinition' && step === 2 || kind === 'ListType' && step === 1 || kind === 'NamedType' && state.prevState && (state.prevState.kind === 'VariableDefinition' || state.prevState.kind === 'ListType')) {
  43032. return getSuggestionsForVariableDefinition(token, schema);
  43033. }
  43034. // Directive names
  43035. if (kind === 'Directive') {
  43036. return getSuggestionsForDirective(token, state, schema);
  43037. }
  43038. return [];
  43039. }
  43040. // Helper functions to get suggestions for each kinds
  43041. function getSuggestionsForFieldNames(token, typeInfo, schema) {
  43042. if (typeInfo.parentType) {
  43043. var parentType = typeInfo.parentType;
  43044. var fields = parentType.getFields instanceof Function ? (0, _autocompleteUtils.objectValues)(parentType.getFields()) : [];
  43045. if ((0, _graphql.isAbstractType)(parentType)) {
  43046. fields.push(_graphql.TypeNameMetaFieldDef);
  43047. }
  43048. if (parentType === schema.getQueryType()) {
  43049. fields.push(_graphql.SchemaMetaFieldDef, _graphql.TypeMetaFieldDef);
  43050. }
  43051. return (0, _autocompleteUtils.hintList)(token, fields.map(function (field) {
  43052. return {
  43053. label: field.name,
  43054. detail: String(field.type),
  43055. documentation: field.description,
  43056. isDeprecated: field.isDeprecated,
  43057. deprecationReason: field.deprecationReason
  43058. };
  43059. }));
  43060. }
  43061. return [];
  43062. }
  43063. function getSuggestionsForInputValues(token, typeInfo) {
  43064. var namedInputType = (0, _graphql.getNamedType)(typeInfo.inputType);
  43065. if (namedInputType instanceof _graphql.GraphQLEnumType) {
  43066. var values = namedInputType.getValues();
  43067. return (0, _autocompleteUtils.hintList)(token, values.map(function (value) {
  43068. return {
  43069. label: value.name,
  43070. detail: String(namedInputType),
  43071. documentation: value.description,
  43072. isDeprecated: value.isDeprecated,
  43073. deprecationReason: value.deprecationReason
  43074. };
  43075. }));
  43076. } else if (namedInputType === _graphql.GraphQLBoolean) {
  43077. return (0, _autocompleteUtils.hintList)(token, [{
  43078. label: 'true',
  43079. detail: String(_graphql.GraphQLBoolean),
  43080. documentation: 'Not false.'
  43081. }, {
  43082. label: 'false',
  43083. detail: String(_graphql.GraphQLBoolean),
  43084. documentation: 'Not true.'
  43085. }]);
  43086. }
  43087. return [];
  43088. }
  43089. function getSuggestionsForFragmentTypeConditions(token, typeInfo, schema) {
  43090. var possibleTypes = void 0;
  43091. if (typeInfo.parentType) {
  43092. if ((0, _graphql.isAbstractType)(typeInfo.parentType)) {
  43093. var abstractType = (0, _graphql.assertAbstractType)(typeInfo.parentType);
  43094. // Collect both the possible Object types as well as the interfaces
  43095. // they implement.
  43096. var possibleObjTypes = schema.getPossibleTypes(abstractType);
  43097. var possibleIfaceMap = Object.create(null);
  43098. possibleObjTypes.forEach(function (type) {
  43099. type.getInterfaces().forEach(function (iface) {
  43100. possibleIfaceMap[iface.name] = iface;
  43101. });
  43102. });
  43103. possibleTypes = possibleObjTypes.concat((0, _autocompleteUtils.objectValues)(possibleIfaceMap));
  43104. } else {
  43105. // The parent type is a non-abstract Object type, so the only possible
  43106. // type that can be used is that same type.
  43107. possibleTypes = [typeInfo.parentType];
  43108. }
  43109. } else {
  43110. var typeMap = schema.getTypeMap();
  43111. possibleTypes = (0, _autocompleteUtils.objectValues)(typeMap).filter(_graphql.isCompositeType);
  43112. }
  43113. return (0, _autocompleteUtils.hintList)(token, possibleTypes.map(function (type) {
  43114. var namedType = (0, _graphql.getNamedType)(type);
  43115. return {
  43116. label: String(type),
  43117. documentation: namedType && namedType.description || ''
  43118. };
  43119. }));
  43120. }
  43121. function getSuggestionsForFragmentSpread(token, typeInfo, schema, queryText) {
  43122. var typeMap = schema.getTypeMap();
  43123. var defState = (0, _autocompleteUtils.getDefinitionState)(token.state);
  43124. var fragments = getFragmentDefinitions(queryText);
  43125. // Filter down to only the fragments which may exist here.
  43126. var relevantFrags = fragments.filter(function (frag) {
  43127. return (
  43128. // Only include fragments with known types.
  43129. typeMap[frag.typeCondition.name.value] &&
  43130. // Only include fragments which are not cyclic.
  43131. !(defState && defState.kind === 'FragmentDefinition' && defState.name === frag.name.value) &&
  43132. // Only include fragments which could possibly be spread here.
  43133. (0, _graphql.isCompositeType)(typeInfo.parentType) && (0, _graphql.isCompositeType)(typeMap[frag.typeCondition.name.value]) && (0, _graphql.doTypesOverlap)(schema, typeInfo.parentType, typeMap[frag.typeCondition.name.value])
  43134. );
  43135. });
  43136. return (0, _autocompleteUtils.hintList)(token, relevantFrags.map(function (frag) {
  43137. return {
  43138. label: frag.name.value,
  43139. detail: String(typeMap[frag.typeCondition.name.value]),
  43140. documentation: 'fragment ' + frag.name.value + ' on ' + frag.typeCondition.name.value
  43141. };
  43142. }));
  43143. }
  43144. function getFragmentDefinitions(queryText) {
  43145. var fragmentDefs = [];
  43146. runOnlineParser(queryText, function (_, state) {
  43147. if (state.kind === 'FragmentDefinition' && state.name && state.type) {
  43148. fragmentDefs.push({
  43149. kind: 'FragmentDefinition',
  43150. name: {
  43151. kind: 'Name',
  43152. value: state.name
  43153. },
  43154. selectionSet: {
  43155. kind: 'SelectionSet',
  43156. selections: []
  43157. },
  43158. typeCondition: {
  43159. kind: 'NamedType',
  43160. name: {
  43161. kind: 'Name',
  43162. value: state.type
  43163. }
  43164. }
  43165. });
  43166. }
  43167. });
  43168. return fragmentDefs;
  43169. }
  43170. function getSuggestionsForVariableDefinition(token, schema) {
  43171. var inputTypeMap = schema.getTypeMap();
  43172. var inputTypes = (0, _autocompleteUtils.objectValues)(inputTypeMap).filter(_graphql.isInputType);
  43173. return (0, _autocompleteUtils.hintList)(token, inputTypes.map(function (type) {
  43174. return {
  43175. label: type.name,
  43176. documentation: type.description
  43177. };
  43178. }));
  43179. }
  43180. function getSuggestionsForDirective(token, state, schema) {
  43181. if (state.prevState && state.prevState.kind) {
  43182. var directives = schema.getDirectives().filter(function (directive) {
  43183. return canUseDirective(state.prevState, directive);
  43184. });
  43185. return (0, _autocompleteUtils.hintList)(token, directives.map(function (directive) {
  43186. return {
  43187. label: directive.name,
  43188. documentation: directive.description || ''
  43189. };
  43190. }));
  43191. }
  43192. return [];
  43193. }
  43194. function getTokenAtPosition(queryText, cursor) {
  43195. var styleAtCursor = null;
  43196. var stateAtCursor = null;
  43197. var stringAtCursor = null;
  43198. var token = runOnlineParser(queryText, function (stream, state, style, index) {
  43199. if (index === cursor.line) {
  43200. if (stream.getCurrentPosition() >= cursor.character) {
  43201. styleAtCursor = style;
  43202. stateAtCursor = _extends({}, state);
  43203. stringAtCursor = stream.current();
  43204. return 'BREAK';
  43205. }
  43206. }
  43207. });
  43208. // Return the state/style of parsed token in case those at cursor aren't
  43209. // available.
  43210. return {
  43211. start: token.start,
  43212. end: token.end,
  43213. string: stringAtCursor || token.string,
  43214. state: stateAtCursor || token.state,
  43215. style: styleAtCursor || token.style
  43216. };
  43217. }
  43218. /**
  43219. * Provides an utility function to parse a given query text and construct a
  43220. * `token` context object.
  43221. * A token context provides useful information about the token/style that
  43222. * CharacterStream currently possesses, as well as the end state and style
  43223. * of the token.
  43224. */
  43225. function runOnlineParser(queryText, callback) {
  43226. var lines = queryText.split('\n');
  43227. var parser = (0, _graphqlLanguageServiceParser.onlineParser)();
  43228. var state = parser.startState();
  43229. var style = '';
  43230. var stream = new _graphqlLanguageServiceParser.CharacterStream('');
  43231. for (var i = 0; i < lines.length; i++) {
  43232. stream = new _graphqlLanguageServiceParser.CharacterStream(lines[i]);
  43233. while (!stream.eol()) {
  43234. style = parser.token(stream, state);
  43235. var code = callback(stream, state, style, i);
  43236. if (code === 'BREAK') {
  43237. break;
  43238. }
  43239. }
  43240. // Above while loop won't run if there is an empty line.
  43241. // Run the callback one more time to catch this.
  43242. callback(stream, state, style, i);
  43243. if (!state.kind) {
  43244. state = parser.startState();
  43245. }
  43246. }
  43247. return {
  43248. start: stream.getStartOfToken(),
  43249. end: stream.getCurrentPosition(),
  43250. string: stream.current(),
  43251. state: state,
  43252. style: style
  43253. };
  43254. }
  43255. function canUseDirective(state, directive) {
  43256. if (!state || !state.kind) {
  43257. return false;
  43258. }
  43259. var kind = state.kind;
  43260. var locations = directive.locations;
  43261. switch (kind) {
  43262. case 'Query':
  43263. return locations.indexOf('QUERY') !== -1;
  43264. case 'Mutation':
  43265. return locations.indexOf('MUTATION') !== -1;
  43266. case 'Subscription':
  43267. return locations.indexOf('SUBSCRIPTION') !== -1;
  43268. case 'Field':
  43269. case 'AliasedField':
  43270. return locations.indexOf('FIELD') !== -1;
  43271. case 'FragmentDefinition':
  43272. return locations.indexOf('FRAGMENT_DEFINITION') !== -1;
  43273. case 'FragmentSpread':
  43274. return locations.indexOf('FRAGMENT_SPREAD') !== -1;
  43275. case 'InlineFragment':
  43276. return locations.indexOf('INLINE_FRAGMENT') !== -1;
  43277. // Schema Definitions
  43278. case 'SchemaDef':
  43279. return locations.indexOf('SCHEMA') !== -1;
  43280. case 'ScalarDef':
  43281. return locations.indexOf('SCALAR') !== -1;
  43282. case 'ObjectTypeDef':
  43283. return locations.indexOf('OBJECT') !== -1;
  43284. case 'FieldDef':
  43285. return locations.indexOf('FIELD_DEFINITION') !== -1;
  43286. case 'InterfaceDef':
  43287. return locations.indexOf('INTERFACE') !== -1;
  43288. case 'UnionDef':
  43289. return locations.indexOf('UNION') !== -1;
  43290. case 'EnumDef':
  43291. return locations.indexOf('ENUM') !== -1;
  43292. case 'EnumValue':
  43293. return locations.indexOf('ENUM_VALUE') !== -1;
  43294. case 'InputDef':
  43295. return locations.indexOf('INPUT_OBJECT') !== -1;
  43296. case 'InputValueDef':
  43297. var prevStateKind = state.prevState && state.prevState.kind;
  43298. switch (prevStateKind) {
  43299. case 'ArgumentsDef':
  43300. return locations.indexOf('ARGUMENT_DEFINITION') !== -1;
  43301. case 'InputDef':
  43302. return locations.indexOf('INPUT_FIELD_DEFINITION') !== -1;
  43303. }
  43304. }
  43305. return false;
  43306. }
  43307. // Utility for collecting rich type information given any token's state
  43308. // from the graphql-mode parser.
  43309. function getTypeInfo(schema, tokenState) {
  43310. var argDef = void 0;
  43311. var argDefs = void 0;
  43312. var directiveDef = void 0;
  43313. var enumValue = void 0;
  43314. var fieldDef = void 0;
  43315. var inputType = void 0;
  43316. var objectFieldDefs = void 0;
  43317. var parentType = void 0;
  43318. var type = void 0;
  43319. (0, _autocompleteUtils.forEachState)(tokenState, function (state) {
  43320. switch (state.kind) {
  43321. case 'Query':
  43322. case 'ShortQuery':
  43323. type = schema.getQueryType();
  43324. break;
  43325. case 'Mutation':
  43326. type = schema.getMutationType();
  43327. break;
  43328. case 'Subscription':
  43329. type = schema.getSubscriptionType();
  43330. break;
  43331. case 'InlineFragment':
  43332. case 'FragmentDefinition':
  43333. if (state.type) {
  43334. type = schema.getType(state.type);
  43335. }
  43336. break;
  43337. case 'Field':
  43338. case 'AliasedField':
  43339. if (!type || !state.name) {
  43340. fieldDef = null;
  43341. } else {
  43342. fieldDef = parentType ? (0, _autocompleteUtils.getFieldDef)(schema, parentType, state.name) : null;
  43343. type = fieldDef ? fieldDef.type : null;
  43344. }
  43345. break;
  43346. case 'SelectionSet':
  43347. parentType = (0, _graphql.getNamedType)(type);
  43348. break;
  43349. case 'Directive':
  43350. directiveDef = state.name ? schema.getDirective(state.name) : null;
  43351. break;
  43352. case 'Arguments':
  43353. if (!state.prevState) {
  43354. argDefs = null;
  43355. } else {
  43356. switch (state.prevState.kind) {
  43357. case 'Field':
  43358. argDefs = fieldDef && fieldDef.args;
  43359. break;
  43360. case 'Directive':
  43361. argDefs = directiveDef && directiveDef.args;
  43362. break;
  43363. case 'AliasedField':
  43364. var name = state.prevState && state.prevState.name;
  43365. if (!name) {
  43366. argDefs = null;
  43367. break;
  43368. }
  43369. var field = parentType ? (0, _autocompleteUtils.getFieldDef)(schema, parentType, name) : null;
  43370. if (!field) {
  43371. argDefs = null;
  43372. break;
  43373. }
  43374. argDefs = field.args;
  43375. break;
  43376. default:
  43377. argDefs = null;
  43378. break;
  43379. }
  43380. }
  43381. break;
  43382. case 'Argument':
  43383. if (argDefs) {
  43384. for (var i = 0; i < argDefs.length; i++) {
  43385. if (argDefs[i].name === state.name) {
  43386. argDef = argDefs[i];
  43387. break;
  43388. }
  43389. }
  43390. }
  43391. inputType = argDef && argDef.type;
  43392. break;
  43393. case 'EnumValue':
  43394. var enumType = (0, _graphql.getNamedType)(inputType);
  43395. enumValue = enumType instanceof _graphql.GraphQLEnumType ? find(enumType.getValues(), function (val) {
  43396. return val.value === state.name;
  43397. }) : null;
  43398. break;
  43399. case 'ListValue':
  43400. var nullableType = (0, _graphql.getNullableType)(inputType);
  43401. inputType = nullableType instanceof _graphql.GraphQLList ? nullableType.ofType : null;
  43402. break;
  43403. case 'ObjectValue':
  43404. var objectType = (0, _graphql.getNamedType)(inputType);
  43405. objectFieldDefs = objectType instanceof _graphql.GraphQLInputObjectType ? objectType.getFields() : null;
  43406. break;
  43407. case 'ObjectField':
  43408. var objectField = state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
  43409. inputType = objectField && objectField.type;
  43410. break;
  43411. case 'NamedType':
  43412. if (state.name) {
  43413. type = schema.getType(state.name);
  43414. }
  43415. break;
  43416. }
  43417. });
  43418. return {
  43419. argDef: argDef,
  43420. argDefs: argDefs,
  43421. directiveDef: directiveDef,
  43422. enumValue: enumValue,
  43423. fieldDef: fieldDef,
  43424. inputType: inputType,
  43425. objectFieldDefs: objectFieldDefs,
  43426. parentType: parentType,
  43427. type: type
  43428. };
  43429. }
  43430. // Returns the first item in the array which causes predicate to return truthy.
  43431. function find(array, predicate) {
  43432. for (var i = 0; i < array.length; i++) {
  43433. if (predicate(array[i])) {
  43434. return array[i];
  43435. }
  43436. }
  43437. return null;
  43438. }
  43439. },{"./autocompleteUtils":259,"graphql":285,"graphql-language-service-parser":269}],261:[function(require,module,exports){
  43440. (function (process){
  43441. 'use strict';
  43442. Object.defineProperty(exports, "__esModule", {
  43443. value: true
  43444. });
  43445. exports.LANGUAGE = undefined;
  43446. exports.getDefinitionQueryResultForNamedType = getDefinitionQueryResultForNamedType;
  43447. exports.getDefinitionQueryResultForFragmentSpread = getDefinitionQueryResultForFragmentSpread;
  43448. exports.getDefinitionQueryResultForDefinitionNode = getDefinitionQueryResultForDefinitionNode;
  43449. var _graphqlLanguageServiceUtils = require('graphql-language-service-utils');
  43450. var _assert = require('assert');
  43451. var _assert2 = _interopRequireDefault(_assert);
  43452. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43453. /**
  43454. * Copyright (c) Facebook, Inc.
  43455. * All rights reserved.
  43456. *
  43457. * This source code is licensed under the license found in the
  43458. * LICENSE file in the root directory of this source tree.
  43459. *
  43460. *
  43461. */
  43462. var LANGUAGE = exports.LANGUAGE = 'GraphQL';
  43463. function getRange(text, node) {
  43464. var location = node.loc;
  43465. (0, _assert2.default)(location, 'Expected ASTNode to have a location.');
  43466. return (0, _graphqlLanguageServiceUtils.locToRange)(text, location);
  43467. }
  43468. function getPosition(text, node) {
  43469. var location = node.loc;
  43470. (0, _assert2.default)(location, 'Expected ASTNode to have a location.');
  43471. return (0, _graphqlLanguageServiceUtils.offsetToPosition)(text, location.start);
  43472. }
  43473. function getDefinitionQueryResultForNamedType(text, node, dependencies) {
  43474. var name, defNodes, definitions;
  43475. return regeneratorRuntime.async(function getDefinitionQueryResultForNamedType$(_context) {
  43476. while (1) {
  43477. switch (_context.prev = _context.next) {
  43478. case 0:
  43479. name = node.name.value;
  43480. defNodes = dependencies.filter(function (_ref) {
  43481. var definition = _ref.definition;
  43482. return definition.name && definition.name.value === name;
  43483. });
  43484. if (!(defNodes.length === 0)) {
  43485. _context.next = 5;
  43486. break;
  43487. }
  43488. process.stderr.write('Definition not found for GraphQL type ' + name);
  43489. return _context.abrupt('return', { queryRange: [], definitions: [] });
  43490. case 5:
  43491. definitions = defNodes.map(function (_ref2) {
  43492. var filePath = _ref2.filePath,
  43493. content = _ref2.content,
  43494. definition = _ref2.definition;
  43495. return getDefinitionForNodeDefinition(filePath || '', content, definition);
  43496. });
  43497. return _context.abrupt('return', {
  43498. definitions: definitions,
  43499. queryRange: definitions.map(function (_) {
  43500. return getRange(text, node);
  43501. })
  43502. });
  43503. case 7:
  43504. case 'end':
  43505. return _context.stop();
  43506. }
  43507. }
  43508. }, null, this);
  43509. }
  43510. function getDefinitionQueryResultForFragmentSpread(text, fragment, dependencies) {
  43511. var name, defNodes, definitions;
  43512. return regeneratorRuntime.async(function getDefinitionQueryResultForFragmentSpread$(_context2) {
  43513. while (1) {
  43514. switch (_context2.prev = _context2.next) {
  43515. case 0:
  43516. name = fragment.name.value;
  43517. defNodes = dependencies.filter(function (_ref3) {
  43518. var definition = _ref3.definition;
  43519. return definition.name.value === name;
  43520. });
  43521. if (!(defNodes.length === 0)) {
  43522. _context2.next = 5;
  43523. break;
  43524. }
  43525. process.stderr.write('Definition not found for GraphQL fragment ' + name);
  43526. return _context2.abrupt('return', { queryRange: [], definitions: [] });
  43527. case 5:
  43528. definitions = defNodes.map(function (_ref4) {
  43529. var filePath = _ref4.filePath,
  43530. content = _ref4.content,
  43531. definition = _ref4.definition;
  43532. return getDefinitionForFragmentDefinition(filePath || '', content, definition);
  43533. });
  43534. return _context2.abrupt('return', {
  43535. definitions: definitions,
  43536. queryRange: definitions.map(function (_) {
  43537. return getRange(text, fragment);
  43538. })
  43539. });
  43540. case 7:
  43541. case 'end':
  43542. return _context2.stop();
  43543. }
  43544. }
  43545. }, null, this);
  43546. }
  43547. function getDefinitionQueryResultForDefinitionNode(path, text, definition) {
  43548. return {
  43549. definitions: [getDefinitionForFragmentDefinition(path, text, definition)],
  43550. queryRange: definition.name ? [getRange(text, definition.name)] : []
  43551. };
  43552. }
  43553. function getDefinitionForFragmentDefinition(path, text, definition) {
  43554. var name = definition.name;
  43555. (0, _assert2.default)(name, 'Expected ASTNode to have a Name.');
  43556. return {
  43557. path: path,
  43558. position: getPosition(text, definition),
  43559. range: getRange(text, definition),
  43560. name: name.value || '',
  43561. language: LANGUAGE,
  43562. // This is a file inside the project root, good enough for now
  43563. projectRoot: path
  43564. };
  43565. }
  43566. function getDefinitionForNodeDefinition(path, text, definition) {
  43567. var name = definition.name;
  43568. (0, _assert2.default)(name, 'Expected ASTNode to have a Name.');
  43569. return {
  43570. path: path,
  43571. position: getPosition(text, definition),
  43572. range: getRange(text, definition),
  43573. name: name.value || '',
  43574. language: LANGUAGE,
  43575. // This is a file inside the project root, good enough for now
  43576. projectRoot: path
  43577. };
  43578. }
  43579. }).call(this,require('_process'))
  43580. },{"_process":198,"assert":1,"graphql-language-service-utils":273}],262:[function(require,module,exports){
  43581. 'use strict';
  43582. Object.defineProperty(exports, "__esModule", {
  43583. value: true
  43584. });
  43585. exports.SEVERITY = undefined;
  43586. exports.getDiagnostics = getDiagnostics;
  43587. exports.validateQuery = validateQuery;
  43588. exports.getRange = getRange;
  43589. var _assert = require('assert');
  43590. var _assert2 = _interopRequireDefault(_assert);
  43591. var _graphql = require('graphql');
  43592. var _graphqlLanguageServiceParser = require('graphql-language-service-parser');
  43593. var _graphqlLanguageServiceUtils = require('graphql-language-service-utils');
  43594. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  43595. /**
  43596. * Copyright (c) Facebook, Inc.
  43597. * All rights reserved.
  43598. *
  43599. * This source code is licensed under the license found in the
  43600. * LICENSE file in the root directory of this source tree.
  43601. *
  43602. *
  43603. */
  43604. var SEVERITY = exports.SEVERITY = {
  43605. ERROR: 1,
  43606. WARNING: 2,
  43607. INFORMATION: 3,
  43608. HINT: 4
  43609. };
  43610. function getDiagnostics(query) {
  43611. var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  43612. var customRules = arguments[2];
  43613. var isRelayCompatMode = arguments[3];
  43614. var ast = null;
  43615. try {
  43616. ast = (0, _graphql.parse)(query);
  43617. } catch (error) {
  43618. var range = getRange(error.locations[0], query);
  43619. return [{
  43620. severity: SEVERITY.ERROR,
  43621. message: error.message,
  43622. source: 'GraphQL: Syntax',
  43623. range: range
  43624. }];
  43625. }
  43626. return validateQuery(ast, schema, customRules, isRelayCompatMode);
  43627. }
  43628. function validateQuery(ast) {
  43629. var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  43630. var customRules = arguments[2];
  43631. var isRelayCompatMode = arguments[3];
  43632. // We cannot validate the query unless a schema is provided.
  43633. if (!schema) {
  43634. return [];
  43635. }
  43636. var validationErrorAnnotations = mapCat((0, _graphqlLanguageServiceUtils.validateWithCustomRules)(schema, ast, customRules, isRelayCompatMode), function (error) {
  43637. return annotations(error, SEVERITY.ERROR, 'Validation');
  43638. });
  43639. // Note: findDeprecatedUsages was added in graphql@0.9.0, but we want to
  43640. // support older versions of graphql-js.
  43641. var deprecationWarningAnnotations = !_graphql.findDeprecatedUsages ? [] : mapCat((0, _graphql.findDeprecatedUsages)(schema, ast), function (error) {
  43642. return annotations(error, SEVERITY.WARNING, 'Deprecation');
  43643. });
  43644. return validationErrorAnnotations.concat(deprecationWarningAnnotations);
  43645. }
  43646. // General utility for map-cating (aka flat-mapping).
  43647. function mapCat(array, mapper) {
  43648. return Array.prototype.concat.apply([], array.map(mapper));
  43649. }
  43650. function annotations(error, severity, type) {
  43651. if (!error.nodes) {
  43652. return [];
  43653. }
  43654. return error.nodes.map(function (node) {
  43655. var highlightNode = node.kind !== 'Variable' && node.name ? node.name : node.variable ? node.variable : node;
  43656. (0, _assert2.default)(error.locations, 'GraphQL validation error requires locations.');
  43657. var loc = error.locations[0];
  43658. var highlightLoc = getLocation(highlightNode);
  43659. var end = loc.column + (highlightLoc.end - highlightLoc.start);
  43660. return {
  43661. source: 'GraphQL: ' + type,
  43662. message: error.message,
  43663. severity: severity,
  43664. range: new _graphqlLanguageServiceUtils.Range(new _graphqlLanguageServiceUtils.Position(loc.line - 1, loc.column - 1), new _graphqlLanguageServiceUtils.Position(loc.line - 1, end))
  43665. };
  43666. });
  43667. }
  43668. function getRange(location, queryText) {
  43669. var parser = (0, _graphqlLanguageServiceParser.onlineParser)();
  43670. var state = parser.startState();
  43671. var lines = queryText.split('\n');
  43672. (0, _assert2.default)(lines.length >= location.line, 'Query text must have more lines than where the error happened');
  43673. var stream = null;
  43674. for (var i = 0; i < location.line; i++) {
  43675. stream = new _graphqlLanguageServiceParser.CharacterStream(lines[i]);
  43676. while (!stream.eol()) {
  43677. var style = parser.token(stream, state);
  43678. if (style === 'invalidchar') {
  43679. break;
  43680. }
  43681. }
  43682. }
  43683. (0, _assert2.default)(stream, 'Expected Parser stream to be available.');
  43684. var line = location.line - 1;
  43685. var start = stream.getStartOfToken();
  43686. var end = stream.getCurrentPosition();
  43687. return new _graphqlLanguageServiceUtils.Range(new _graphqlLanguageServiceUtils.Position(line, start), new _graphqlLanguageServiceUtils.Position(line, end));
  43688. }
  43689. /**
  43690. * Get location info from a node in a type-safe way.
  43691. *
  43692. * The only way a node could not have a location is if we initialized the parser
  43693. * (and therefore the lexer) with the `noLocation` option, but we always
  43694. * call `parse` without options above.
  43695. */
  43696. function getLocation(node) {
  43697. var typeCastedNode = node;
  43698. var location = typeCastedNode.loc;
  43699. (0, _assert2.default)(location, 'Expected ASTNode to have a location.');
  43700. return location;
  43701. }
  43702. },{"assert":1,"graphql":285,"graphql-language-service-parser":269,"graphql-language-service-utils":273}],263:[function(require,module,exports){
  43703. 'use strict';
  43704. Object.defineProperty(exports, "__esModule", {
  43705. value: true
  43706. });
  43707. exports.getHoverInformation = getHoverInformation;
  43708. var _getAutocompleteSuggestions = require('./getAutocompleteSuggestions');
  43709. var _graphql = require('graphql');
  43710. /**
  43711. * Copyright (c) Facebook, Inc.
  43712. * All rights reserved.
  43713. *
  43714. * This source code is licensed under the license found in the
  43715. * LICENSE file in the root directory of this source tree.
  43716. *
  43717. *
  43718. */
  43719. /**
  43720. * Ported from codemirror-graphql
  43721. * https://github.com/graphql/codemirror-graphql/blob/master/src/info.js
  43722. */
  43723. function getHoverInformation(schema, queryText, cursor, contextToken) {
  43724. var token = contextToken || (0, _getAutocompleteSuggestions.getTokenAtPosition)(queryText, cursor);
  43725. if (!schema || !token || !token.state) {
  43726. return [];
  43727. }
  43728. var state = token.state;
  43729. var kind = state.kind;
  43730. var step = state.step;
  43731. var typeInfo = (0, _getAutocompleteSuggestions.getTypeInfo)(schema, token.state);
  43732. var options = { schema: schema };
  43733. // Given a Schema and a Token, produce the contents of an info tooltip.
  43734. // To do this, create a div element that we will render "into" and then pass
  43735. // it to various rendering functions.
  43736. if (kind === 'Field' && step === 0 && typeInfo.fieldDef || kind === 'AliasedField' && step === 2 && typeInfo.fieldDef) {
  43737. var into = [];
  43738. renderField(into, typeInfo, options);
  43739. renderDescription(into, options, typeInfo.fieldDef);
  43740. return into.join('').trim();
  43741. } else if (kind === 'Directive' && step === 1 && typeInfo.directiveDef) {
  43742. var _into = [];
  43743. renderDirective(_into, typeInfo, options);
  43744. renderDescription(_into, options, typeInfo.directiveDef);
  43745. return _into.join('').trim();
  43746. } else if (kind === 'Argument' && step === 0 && typeInfo.argDef) {
  43747. var _into2 = [];
  43748. renderArg(_into2, typeInfo, options);
  43749. renderDescription(_into2, options, typeInfo.argDef);
  43750. return _into2.join('').trim();
  43751. } else if (kind === 'EnumValue' && typeInfo.enumValue && typeInfo.enumValue.description) {
  43752. var _into3 = [];
  43753. renderEnumValue(_into3, typeInfo, options);
  43754. renderDescription(_into3, options, typeInfo.enumValue);
  43755. return _into3.join('').trim();
  43756. } else if (kind === 'NamedType' && typeInfo.type && typeInfo.type.description) {
  43757. var _into4 = [];
  43758. renderType(_into4, typeInfo, options, typeInfo.type);
  43759. renderDescription(_into4, options, typeInfo.type);
  43760. return _into4.join('').trim();
  43761. }
  43762. }
  43763. function renderField(into, typeInfo, options) {
  43764. renderQualifiedField(into, typeInfo, options);
  43765. renderTypeAnnotation(into, typeInfo, options, typeInfo.type);
  43766. }
  43767. function renderQualifiedField(into, typeInfo, options) {
  43768. if (!typeInfo.fieldDef) {
  43769. return;
  43770. }
  43771. var fieldName = typeInfo.fieldDef.name;
  43772. if (fieldName.slice(0, 2) !== '__') {
  43773. renderType(into, typeInfo, options, typeInfo.parentType);
  43774. text(into, '.');
  43775. }
  43776. text(into, fieldName);
  43777. }
  43778. function renderDirective(into, typeInfo, options) {
  43779. if (!typeInfo.directiveDef) {
  43780. return;
  43781. }
  43782. var name = '@' + typeInfo.directiveDef.name;
  43783. text(into, name);
  43784. }
  43785. function renderArg(into, typeInfo, options) {
  43786. if (typeInfo.directiveDef) {
  43787. renderDirective(into, typeInfo, options);
  43788. } else if (typeInfo.fieldDef) {
  43789. renderQualifiedField(into, typeInfo, options);
  43790. }
  43791. if (!typeInfo.argDef) {
  43792. return;
  43793. }
  43794. var name = typeInfo.argDef.name;
  43795. text(into, '(');
  43796. text(into, name);
  43797. renderTypeAnnotation(into, typeInfo, options, typeInfo.inputType);
  43798. text(into, ')');
  43799. }
  43800. function renderTypeAnnotation(into, typeInfo, options, t) {
  43801. text(into, ': ');
  43802. renderType(into, typeInfo, options, t);
  43803. }
  43804. function renderEnumValue(into, typeInfo, options) {
  43805. if (!typeInfo.enumValue) {
  43806. return;
  43807. }
  43808. var name = typeInfo.enumValue.name;
  43809. renderType(into, typeInfo, options, typeInfo.inputType);
  43810. text(into, '.');
  43811. text(into, name);
  43812. }
  43813. function renderType(into, typeInfo, options, t) {
  43814. if (!t) {
  43815. return;
  43816. }
  43817. if (t instanceof _graphql.GraphQLNonNull) {
  43818. renderType(into, typeInfo, options, t.ofType);
  43819. text(into, '!');
  43820. } else if (t instanceof _graphql.GraphQLList) {
  43821. text(into, '[');
  43822. renderType(into, typeInfo, options, t.ofType);
  43823. text(into, ']');
  43824. } else {
  43825. text(into, t.name);
  43826. }
  43827. }
  43828. function renderDescription(into, options, def) {
  43829. if (!def) {
  43830. return;
  43831. }
  43832. var description = typeof def.description === 'string' ? def.description : null;
  43833. if (description) {
  43834. text(into, '\n\n');
  43835. text(into, description);
  43836. }
  43837. renderDeprecation(into, options, def);
  43838. }
  43839. function renderDeprecation(into, options, def) {
  43840. if (!def) {
  43841. return;
  43842. }
  43843. var reason = typeof def.deprecationReason === 'string' ? def.deprecationReason : null;
  43844. if (!reason) {
  43845. return;
  43846. }
  43847. text(into, '\n\n');
  43848. text(into, 'Deprecated: ');
  43849. text(into, reason);
  43850. }
  43851. function text(into, content) {
  43852. into.push(content);
  43853. }
  43854. },{"./getAutocompleteSuggestions":260,"graphql":285}],264:[function(require,module,exports){
  43855. 'use strict';
  43856. Object.defineProperty(exports, "__esModule", {
  43857. value: true
  43858. });
  43859. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /**
  43860. * Copyright (c) Facebook, Inc.
  43861. * All rights reserved.
  43862. *
  43863. * This source code is licensed under the license found in the
  43864. * LICENSE file in the root directory of this source tree.
  43865. *
  43866. *
  43867. */
  43868. exports.getOutline = getOutline;
  43869. var _graphql = require('graphql');
  43870. var _graphqlLanguageServiceUtils = require('graphql-language-service-utils');
  43871. var INLINE_FRAGMENT = _graphql.Kind.INLINE_FRAGMENT;
  43872. var OUTLINEABLE_KINDS = {
  43873. Field: true,
  43874. OperationDefinition: true,
  43875. Document: true,
  43876. SelectionSet: true,
  43877. Name: true,
  43878. FragmentDefinition: true,
  43879. FragmentSpread: true,
  43880. InlineFragment: true
  43881. };
  43882. function getOutline(queryText) {
  43883. var ast = void 0;
  43884. try {
  43885. ast = (0, _graphql.parse)(queryText);
  43886. } catch (error) {
  43887. return null;
  43888. }
  43889. var visitorFns = outlineTreeConverter(queryText);
  43890. var outlineTrees = (0, _graphql.visit)(ast, {
  43891. leave: function leave(node) {
  43892. if (OUTLINEABLE_KINDS.hasOwnProperty(node.kind) && visitorFns[node.kind]) {
  43893. return visitorFns[node.kind](node);
  43894. }
  43895. return null;
  43896. }
  43897. });
  43898. return { outlineTrees: outlineTrees };
  43899. }
  43900. function outlineTreeConverter(docText) {
  43901. var meta = function meta(node) {
  43902. return {
  43903. representativeName: node.name,
  43904. startPosition: (0, _graphqlLanguageServiceUtils.offsetToPosition)(docText, node.loc.start),
  43905. endPosition: (0, _graphqlLanguageServiceUtils.offsetToPosition)(docText, node.loc.end),
  43906. children: node.selectionSet || []
  43907. };
  43908. };
  43909. return {
  43910. Field: function Field(node) {
  43911. var tokenizedText = node.alias ? [buildToken('plain', node.alias), buildToken('plain', ': ')] : [];
  43912. tokenizedText.push(buildToken('plain', node.name));
  43913. return _extends({ tokenizedText: tokenizedText }, meta(node));
  43914. },
  43915. OperationDefinition: function OperationDefinition(node) {
  43916. return _extends({
  43917. tokenizedText: [buildToken('keyword', node.operation), buildToken('whitespace', ' '), buildToken('class-name', node.name)]
  43918. }, meta(node));
  43919. },
  43920. Document: function Document(node) {
  43921. return node.definitions;
  43922. },
  43923. SelectionSet: function SelectionSet(node) {
  43924. return concatMap(node.selections, function (child) {
  43925. return child.kind === INLINE_FRAGMENT ? child.selectionSet : child;
  43926. });
  43927. },
  43928. Name: function Name(node) {
  43929. return node.value;
  43930. },
  43931. FragmentDefinition: function FragmentDefinition(node) {
  43932. return _extends({
  43933. tokenizedText: [buildToken('keyword', 'fragment'), buildToken('whitespace', ' '), buildToken('class-name', node.name)]
  43934. }, meta(node));
  43935. },
  43936. FragmentSpread: function FragmentSpread(node) {
  43937. return _extends({
  43938. tokenizedText: [buildToken('plain', '...'), buildToken('class-name', node.name)]
  43939. }, meta(node));
  43940. },
  43941. InlineFragment: function InlineFragment(node) {
  43942. return node.selectionSet;
  43943. }
  43944. };
  43945. }
  43946. function buildToken(kind, value) {
  43947. return { kind: kind, value: value };
  43948. }
  43949. function concatMap(arr, fn) {
  43950. var res = [];
  43951. for (var i = 0; i < arr.length; i++) {
  43952. var x = fn(arr[i], i);
  43953. if (Array.isArray(x)) {
  43954. res.push.apply(res, x);
  43955. } else {
  43956. res.push(x);
  43957. }
  43958. }
  43959. return res;
  43960. }
  43961. },{"graphql":285,"graphql-language-service-utils":273}],265:[function(require,module,exports){
  43962. 'use strict';
  43963. Object.defineProperty(exports, "__esModule", {
  43964. value: true
  43965. });
  43966. var _autocompleteUtils = require('./autocompleteUtils');
  43967. Object.defineProperty(exports, 'getDefinitionState', {
  43968. enumerable: true,
  43969. get: function get() {
  43970. return _autocompleteUtils.getDefinitionState;
  43971. }
  43972. });
  43973. Object.defineProperty(exports, 'getFieldDef', {
  43974. enumerable: true,
  43975. get: function get() {
  43976. return _autocompleteUtils.getFieldDef;
  43977. }
  43978. });
  43979. Object.defineProperty(exports, 'forEachState', {
  43980. enumerable: true,
  43981. get: function get() {
  43982. return _autocompleteUtils.forEachState;
  43983. }
  43984. });
  43985. Object.defineProperty(exports, 'objectValues', {
  43986. enumerable: true,
  43987. get: function get() {
  43988. return _autocompleteUtils.objectValues;
  43989. }
  43990. });
  43991. Object.defineProperty(exports, 'hintList', {
  43992. enumerable: true,
  43993. get: function get() {
  43994. return _autocompleteUtils.hintList;
  43995. }
  43996. });
  43997. var _getAutocompleteSuggestions = require('./getAutocompleteSuggestions');
  43998. Object.defineProperty(exports, 'getAutocompleteSuggestions', {
  43999. enumerable: true,
  44000. get: function get() {
  44001. return _getAutocompleteSuggestions.getAutocompleteSuggestions;
  44002. }
  44003. });
  44004. var _getDefinition = require('./getDefinition');
  44005. Object.defineProperty(exports, 'LANGUAGE', {
  44006. enumerable: true,
  44007. get: function get() {
  44008. return _getDefinition.LANGUAGE;
  44009. }
  44010. });
  44011. Object.defineProperty(exports, 'getDefinitionQueryResultForFragmentSpread', {
  44012. enumerable: true,
  44013. get: function get() {
  44014. return _getDefinition.getDefinitionQueryResultForFragmentSpread;
  44015. }
  44016. });
  44017. Object.defineProperty(exports, 'getDefinitionQueryResultForDefinitionNode', {
  44018. enumerable: true,
  44019. get: function get() {
  44020. return _getDefinition.getDefinitionQueryResultForDefinitionNode;
  44021. }
  44022. });
  44023. var _getDiagnostics = require('./getDiagnostics');
  44024. Object.defineProperty(exports, 'getDiagnostics', {
  44025. enumerable: true,
  44026. get: function get() {
  44027. return _getDiagnostics.getDiagnostics;
  44028. }
  44029. });
  44030. Object.defineProperty(exports, 'validateQuery', {
  44031. enumerable: true,
  44032. get: function get() {
  44033. return _getDiagnostics.validateQuery;
  44034. }
  44035. });
  44036. var _getOutline = require('./getOutline');
  44037. Object.defineProperty(exports, 'getOutline', {
  44038. enumerable: true,
  44039. get: function get() {
  44040. return _getOutline.getOutline;
  44041. }
  44042. });
  44043. var _getHoverInformation = require('./getHoverInformation');
  44044. Object.defineProperty(exports, 'getHoverInformation', {
  44045. enumerable: true,
  44046. get: function get() {
  44047. return _getHoverInformation.getHoverInformation;
  44048. }
  44049. });
  44050. var _GraphQLLanguageService = require('./GraphQLLanguageService');
  44051. Object.defineProperty(exports, 'GraphQLLanguageService', {
  44052. enumerable: true,
  44053. get: function get() {
  44054. return _GraphQLLanguageService.GraphQLLanguageService;
  44055. }
  44056. });
  44057. },{"./GraphQLLanguageService":258,"./autocompleteUtils":259,"./getAutocompleteSuggestions":260,"./getDefinition":261,"./getDiagnostics":262,"./getHoverInformation":263,"./getOutline":264}],266:[function(require,module,exports){
  44058. 'use strict';
  44059. Object.defineProperty(exports, "__esModule", {
  44060. value: true
  44061. });
  44062. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44063. var CharacterStream = function () {
  44064. function CharacterStream(sourceText) {
  44065. var _this = this;
  44066. _classCallCheck(this, CharacterStream);
  44067. this.getStartOfToken = function () {
  44068. return _this._start;
  44069. };
  44070. this.getCurrentPosition = function () {
  44071. return _this._pos;
  44072. };
  44073. this.eol = function () {
  44074. return _this._sourceText.length === _this._pos;
  44075. };
  44076. this.sol = function () {
  44077. return _this._pos === 0;
  44078. };
  44079. this.peek = function () {
  44080. return _this._sourceText.charAt(_this._pos) ? _this._sourceText.charAt(_this._pos) : null;
  44081. };
  44082. this.next = function () {
  44083. var char = _this._sourceText.charAt(_this._pos);
  44084. _this._pos++;
  44085. return char;
  44086. };
  44087. this.eat = function (pattern) {
  44088. var isMatched = _this._testNextCharacter(pattern);
  44089. if (isMatched) {
  44090. _this._start = _this._pos;
  44091. _this._pos++;
  44092. return _this._sourceText.charAt(_this._pos - 1);
  44093. }
  44094. return undefined;
  44095. };
  44096. this.eatWhile = function (match) {
  44097. var isMatched = _this._testNextCharacter(match);
  44098. var didEat = false;
  44099. // If a match, treat the total upcoming matches as one token
  44100. if (isMatched) {
  44101. didEat = isMatched;
  44102. _this._start = _this._pos;
  44103. }
  44104. while (isMatched) {
  44105. _this._pos++;
  44106. isMatched = _this._testNextCharacter(match);
  44107. didEat = true;
  44108. }
  44109. return didEat;
  44110. };
  44111. this.eatSpace = function () {
  44112. return _this.eatWhile(/[\s\u00a0]/);
  44113. };
  44114. this.skipToEnd = function () {
  44115. _this._pos = _this._sourceText.length;
  44116. };
  44117. this.skipTo = function (position) {
  44118. _this._pos = position;
  44119. };
  44120. this.match = function (pattern) {
  44121. var consume = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  44122. var caseFold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  44123. var token = null;
  44124. var match = null;
  44125. if (typeof pattern === 'string') {
  44126. var regex = new RegExp(pattern, caseFold ? 'i' : 'g');
  44127. match = regex.test(_this._sourceText.substr(_this._pos, pattern.length));
  44128. token = pattern;
  44129. } else if (pattern instanceof RegExp) {
  44130. match = _this._sourceText.slice(_this._pos).match(pattern);
  44131. token = match && match[0];
  44132. }
  44133. if (match != null) {
  44134. if (typeof pattern === 'string' || match instanceof Array &&
  44135. // String.match returns 'index' property, which flow fails to detect
  44136. // for some reason. The below is a workaround, but an easier solution
  44137. // is just checking if `match.index === 0`
  44138. _this._sourceText.startsWith(match[0], _this._pos)) {
  44139. if (consume) {
  44140. _this._start = _this._pos;
  44141. if (token && token.length) {
  44142. _this._pos += token.length;
  44143. }
  44144. }
  44145. return match;
  44146. }
  44147. }
  44148. // No match available.
  44149. return false;
  44150. };
  44151. this.backUp = function (num) {
  44152. _this._pos -= num;
  44153. };
  44154. this.column = function () {
  44155. return _this._pos;
  44156. };
  44157. this.indentation = function () {
  44158. var match = _this._sourceText.match(/\s*/);
  44159. var indent = 0;
  44160. if (match && match.length === 0) {
  44161. var whitespaces = match[0];
  44162. var pos = 0;
  44163. while (whitespaces.length > pos) {
  44164. if (whitespaces.charCodeAt(pos) === 9) {
  44165. indent += 2;
  44166. } else {
  44167. indent++;
  44168. }
  44169. pos++;
  44170. }
  44171. }
  44172. return indent;
  44173. };
  44174. this.current = function () {
  44175. return _this._sourceText.slice(_this._start, _this._pos);
  44176. };
  44177. this._start = 0;
  44178. this._pos = 0;
  44179. this._sourceText = sourceText;
  44180. }
  44181. CharacterStream.prototype._testNextCharacter = function _testNextCharacter(pattern) {
  44182. var character = this._sourceText.charAt(this._pos);
  44183. var isMatched = false;
  44184. if (typeof pattern === 'string') {
  44185. isMatched = character === pattern;
  44186. } else {
  44187. isMatched = pattern instanceof RegExp ? pattern.test(character) : pattern(character);
  44188. }
  44189. return isMatched;
  44190. };
  44191. return CharacterStream;
  44192. }(); /**
  44193. * Copyright (c) Facebook, Inc.
  44194. * All rights reserved.
  44195. *
  44196. * This source code is licensed under the license found in the
  44197. * LICENSE file in the root directory of this source tree.
  44198. *
  44199. *
  44200. */
  44201. /**
  44202. * CharacterStream implements a stream of character tokens given a source text.
  44203. * The API design follows that of CodeMirror.StringStream.
  44204. *
  44205. * Required:
  44206. *
  44207. * sourceText: (string), A raw GraphQL source text. Works best if a line
  44208. * is supplied.
  44209. *
  44210. */
  44211. exports.default = CharacterStream;
  44212. },{}],267:[function(require,module,exports){
  44213. 'use strict';
  44214. Object.defineProperty(exports, "__esModule", {
  44215. value: true
  44216. });
  44217. exports.opt = opt;
  44218. exports.list = list;
  44219. exports.butNot = butNot;
  44220. exports.t = t;
  44221. exports.p = p;
  44222. // An optional rule.
  44223. function opt(ofRule) {
  44224. return { ofRule: ofRule };
  44225. }
  44226. // A list of another rule.
  44227. /**
  44228. * Copyright (c) Facebook, Inc.
  44229. * All rights reserved.
  44230. *
  44231. * This source code is licensed under the license found in the
  44232. * LICENSE file in the root directory of this source tree.
  44233. *
  44234. *
  44235. */
  44236. // These functions help build matching rules for ParseRules.
  44237. function list(ofRule, separator) {
  44238. return { ofRule: ofRule, isList: true, separator: separator };
  44239. }
  44240. // An constraint described as `but not` in the GraphQL spec.
  44241. function butNot(rule, exclusions) {
  44242. var ruleMatch = rule.match;
  44243. rule.match = function (token) {
  44244. var check = false;
  44245. if (ruleMatch) {
  44246. check = ruleMatch(token);
  44247. }
  44248. return check && exclusions.every(function (exclusion) {
  44249. return exclusion.match && !exclusion.match(token);
  44250. });
  44251. };
  44252. return rule;
  44253. }
  44254. // Token of a kind
  44255. function t(kind, style) {
  44256. return { style: style, match: function match(token) {
  44257. return token.kind === kind;
  44258. } };
  44259. }
  44260. // Punctuator
  44261. function p(value, style) {
  44262. return {
  44263. style: style || 'punctuation',
  44264. match: function match(token) {
  44265. return token.kind === 'Punctuation' && token.value === value;
  44266. }
  44267. };
  44268. }
  44269. },{}],268:[function(require,module,exports){
  44270. 'use strict';
  44271. Object.defineProperty(exports, "__esModule", {
  44272. value: true
  44273. });
  44274. exports.ParseRules = exports.LexRules = exports.isIgnored = undefined;
  44275. var _RuleHelpers = require('./RuleHelpers');
  44276. /**
  44277. * Whitespace tokens defined in GraphQL spec.
  44278. */
  44279. /**
  44280. * Copyright (c) Facebook, Inc.
  44281. * All rights reserved.
  44282. *
  44283. * This source code is licensed under the license found in the
  44284. * LICENSE file in the root directory of this source tree.
  44285. *
  44286. *
  44287. */
  44288. var isIgnored = exports.isIgnored = function isIgnored(ch) {
  44289. return ch === ' ' || ch === '\t' || ch === ',' || ch === '\n' || ch === '\r' || ch === '\uFEFF';
  44290. };
  44291. /**
  44292. * The lexer rules. These are exactly as described by the spec.
  44293. */
  44294. var LexRules = exports.LexRules = {
  44295. // The Name token.
  44296. Name: /^[_A-Za-z][_0-9A-Za-z]*/,
  44297. // All Punctuation used in GraphQL
  44298. Punctuation: /^(?:!|\$|\(|\)|\.\.\.|:|=|@|\[|]|\{|\||\})/,
  44299. // Combines the IntValue and FloatValue tokens.
  44300. Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,
  44301. // Note the closing quote is made optional as an IDE experience improvment.
  44302. String: /^(?:"""(?:\\"""|[^"]|"[^"]|""[^"])*(?:""")?|"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?)/,
  44303. // Comments consume entire lines.
  44304. Comment: /^#.*/
  44305. };
  44306. /**
  44307. * The parser rules. These are very close to, but not exactly the same as the
  44308. * spec. Minor deviations allow for a simpler implementation. The resulting
  44309. * parser can parse everything the spec declares possible.
  44310. */
  44311. var ParseRules = exports.ParseRules = {
  44312. Document: [(0, _RuleHelpers.list)('Definition')],
  44313. Definition: function Definition(token) {
  44314. switch (token.value) {
  44315. case '{':
  44316. return 'ShortQuery';
  44317. case 'query':
  44318. return 'Query';
  44319. case 'mutation':
  44320. return 'Mutation';
  44321. case 'subscription':
  44322. return 'Subscription';
  44323. case 'fragment':
  44324. return 'FragmentDefinition';
  44325. case 'schema':
  44326. return 'SchemaDef';
  44327. case 'scalar':
  44328. return 'ScalarDef';
  44329. case 'type':
  44330. return 'ObjectTypeDef';
  44331. case 'interface':
  44332. return 'InterfaceDef';
  44333. case 'union':
  44334. return 'UnionDef';
  44335. case 'enum':
  44336. return 'EnumDef';
  44337. case 'input':
  44338. return 'InputDef';
  44339. case 'extend':
  44340. return 'ExtendDef';
  44341. case 'directive':
  44342. return 'DirectiveDef';
  44343. }
  44344. },
  44345. // Note: instead of "Operation", these rules have been separated out.
  44346. ShortQuery: ['SelectionSet'],
  44347. Query: [word('query'), (0, _RuleHelpers.opt)(name('def')), (0, _RuleHelpers.opt)('VariableDefinitions'), (0, _RuleHelpers.list)('Directive'), 'SelectionSet'],
  44348. Mutation: [word('mutation'), (0, _RuleHelpers.opt)(name('def')), (0, _RuleHelpers.opt)('VariableDefinitions'), (0, _RuleHelpers.list)('Directive'), 'SelectionSet'],
  44349. Subscription: [word('subscription'), (0, _RuleHelpers.opt)(name('def')), (0, _RuleHelpers.opt)('VariableDefinitions'), (0, _RuleHelpers.list)('Directive'), 'SelectionSet'],
  44350. VariableDefinitions: [(0, _RuleHelpers.p)('('), (0, _RuleHelpers.list)('VariableDefinition'), (0, _RuleHelpers.p)(')')],
  44351. VariableDefinition: ['Variable', (0, _RuleHelpers.p)(':'), 'Type', (0, _RuleHelpers.opt)('DefaultValue')],
  44352. Variable: [(0, _RuleHelpers.p)('$', 'variable'), name('variable')],
  44353. DefaultValue: [(0, _RuleHelpers.p)('='), 'Value'],
  44354. SelectionSet: [(0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('Selection'), (0, _RuleHelpers.p)('}')],
  44355. Selection: function Selection(token, stream) {
  44356. return token.value === '...' ? stream.match(/[\s\u00a0,]*(on\b|@|{)/, false) ? 'InlineFragment' : 'FragmentSpread' : stream.match(/[\s\u00a0,]*:/, false) ? 'AliasedField' : 'Field';
  44357. },
  44358. // Note: this minor deviation of "AliasedField" simplifies the lookahead.
  44359. AliasedField: [name('property'), (0, _RuleHelpers.p)(':'), name('qualifier'), (0, _RuleHelpers.opt)('Arguments'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.opt)('SelectionSet')],
  44360. Field: [name('property'), (0, _RuleHelpers.opt)('Arguments'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.opt)('SelectionSet')],
  44361. Arguments: [(0, _RuleHelpers.p)('('), (0, _RuleHelpers.list)('Argument'), (0, _RuleHelpers.p)(')')],
  44362. Argument: [name('attribute'), (0, _RuleHelpers.p)(':'), 'Value'],
  44363. FragmentSpread: [(0, _RuleHelpers.p)('...'), name('def'), (0, _RuleHelpers.list)('Directive')],
  44364. InlineFragment: [(0, _RuleHelpers.p)('...'), (0, _RuleHelpers.opt)('TypeCondition'), (0, _RuleHelpers.list)('Directive'), 'SelectionSet'],
  44365. FragmentDefinition: [word('fragment'), (0, _RuleHelpers.opt)((0, _RuleHelpers.butNot)(name('def'), [word('on')])), 'TypeCondition', (0, _RuleHelpers.list)('Directive'), 'SelectionSet'],
  44366. TypeCondition: [word('on'), 'NamedType'],
  44367. // Variables could be parsed in cases where only Const is expected by spec.
  44368. Value: function Value(token) {
  44369. switch (token.kind) {
  44370. case 'Number':
  44371. return 'NumberValue';
  44372. case 'String':
  44373. return 'StringValue';
  44374. case 'Punctuation':
  44375. switch (token.value) {
  44376. case '[':
  44377. return 'ListValue';
  44378. case '{':
  44379. return 'ObjectValue';
  44380. case '$':
  44381. return 'Variable';
  44382. }
  44383. return null;
  44384. case 'Name':
  44385. switch (token.value) {
  44386. case 'true':
  44387. case 'false':
  44388. return 'BooleanValue';
  44389. }
  44390. if (token.value === 'null') {
  44391. return 'NullValue';
  44392. }
  44393. return 'EnumValue';
  44394. }
  44395. },
  44396. NumberValue: [(0, _RuleHelpers.t)('Number', 'number')],
  44397. StringValue: [(0, _RuleHelpers.t)('String', 'string')],
  44398. BooleanValue: [(0, _RuleHelpers.t)('Name', 'builtin')],
  44399. NullValue: [(0, _RuleHelpers.t)('Name', 'keyword')],
  44400. EnumValue: [name('string-2')],
  44401. ListValue: [(0, _RuleHelpers.p)('['), (0, _RuleHelpers.list)('Value'), (0, _RuleHelpers.p)(']')],
  44402. ObjectValue: [(0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('ObjectField'), (0, _RuleHelpers.p)('}')],
  44403. ObjectField: [name('attribute'), (0, _RuleHelpers.p)(':'), 'Value'],
  44404. Type: function Type(token) {
  44405. return token.value === '[' ? 'ListType' : 'NonNullType';
  44406. },
  44407. // NonNullType has been merged into ListType to simplify.
  44408. ListType: [(0, _RuleHelpers.p)('['), 'Type', (0, _RuleHelpers.p)(']'), (0, _RuleHelpers.opt)((0, _RuleHelpers.p)('!'))],
  44409. NonNullType: ['NamedType', (0, _RuleHelpers.opt)((0, _RuleHelpers.p)('!'))],
  44410. NamedType: [type('atom')],
  44411. Directive: [(0, _RuleHelpers.p)('@', 'meta'), name('meta'), (0, _RuleHelpers.opt)('Arguments')],
  44412. // GraphQL schema language
  44413. SchemaDef: [word('schema'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('OperationTypeDef'), (0, _RuleHelpers.p)('}')],
  44414. OperationTypeDef: [name('keyword'), (0, _RuleHelpers.p)(':'), name('atom')],
  44415. ScalarDef: [word('scalar'), name('atom'), (0, _RuleHelpers.list)('Directive')],
  44416. ObjectTypeDef: [word('type'), name('atom'), (0, _RuleHelpers.opt)('Implements'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('FieldDef'), (0, _RuleHelpers.p)('}')],
  44417. Implements: [word('implements'), (0, _RuleHelpers.list)('NamedType')],
  44418. FieldDef: [name('property'), (0, _RuleHelpers.opt)('ArgumentsDef'), (0, _RuleHelpers.p)(':'), 'Type', (0, _RuleHelpers.list)('Directive')],
  44419. ArgumentsDef: [(0, _RuleHelpers.p)('('), (0, _RuleHelpers.list)('InputValueDef'), (0, _RuleHelpers.p)(')')],
  44420. InputValueDef: [name('attribute'), (0, _RuleHelpers.p)(':'), 'Type', (0, _RuleHelpers.opt)('DefaultValue'), (0, _RuleHelpers.list)('Directive')],
  44421. InterfaceDef: [word('interface'), name('atom'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('FieldDef'), (0, _RuleHelpers.p)('}')],
  44422. UnionDef: [word('union'), name('atom'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('='), (0, _RuleHelpers.list)('UnionMember', (0, _RuleHelpers.p)('|'))],
  44423. UnionMember: ['NamedType'],
  44424. EnumDef: [word('enum'), name('atom'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('EnumValueDef'), (0, _RuleHelpers.p)('}')],
  44425. EnumValueDef: [name('string-2'), (0, _RuleHelpers.list)('Directive')],
  44426. InputDef: [word('input'), name('atom'), (0, _RuleHelpers.list)('Directive'), (0, _RuleHelpers.p)('{'), (0, _RuleHelpers.list)('InputValueDef'), (0, _RuleHelpers.p)('}')],
  44427. ExtendDef: [word('extend'), 'ObjectTypeDef'],
  44428. DirectiveDef: [word('directive'), (0, _RuleHelpers.p)('@', 'meta'), name('meta'), (0, _RuleHelpers.opt)('ArgumentsDef'), word('on'), (0, _RuleHelpers.list)('DirectiveLocation', (0, _RuleHelpers.p)('|'))],
  44429. DirectiveLocation: [name('string-2')]
  44430. };
  44431. // A keyword Token.
  44432. function word(value) {
  44433. return {
  44434. style: 'keyword',
  44435. match: function match(token) {
  44436. return token.kind === 'Name' && token.value === value;
  44437. }
  44438. };
  44439. }
  44440. // A Name Token which will decorate the state with a `name`.
  44441. function name(style) {
  44442. return {
  44443. style: style,
  44444. match: function match(token) {
  44445. return token.kind === 'Name';
  44446. },
  44447. update: function update(state, token) {
  44448. state.name = token.value;
  44449. }
  44450. };
  44451. }
  44452. // A Name Token which will decorate the previous state with a `type`.
  44453. function type(style) {
  44454. return {
  44455. style: style,
  44456. match: function match(token) {
  44457. return token.kind === 'Name';
  44458. },
  44459. update: function update(state, token) {
  44460. if (state.prevState && state.prevState.prevState) {
  44461. state.name = token.value;
  44462. state.prevState.prevState.type = token.value;
  44463. }
  44464. }
  44465. };
  44466. }
  44467. },{"./RuleHelpers":267}],269:[function(require,module,exports){
  44468. 'use strict';
  44469. Object.defineProperty(exports, "__esModule", {
  44470. value: true
  44471. });
  44472. var _CharacterStream = require('./CharacterStream');
  44473. Object.defineProperty(exports, 'CharacterStream', {
  44474. enumerable: true,
  44475. get: function get() {
  44476. return _interopRequireDefault(_CharacterStream).default;
  44477. }
  44478. });
  44479. var _Rules = require('./Rules');
  44480. Object.defineProperty(exports, 'LexRules', {
  44481. enumerable: true,
  44482. get: function get() {
  44483. return _Rules.LexRules;
  44484. }
  44485. });
  44486. Object.defineProperty(exports, 'ParseRules', {
  44487. enumerable: true,
  44488. get: function get() {
  44489. return _Rules.ParseRules;
  44490. }
  44491. });
  44492. Object.defineProperty(exports, 'isIgnored', {
  44493. enumerable: true,
  44494. get: function get() {
  44495. return _Rules.isIgnored;
  44496. }
  44497. });
  44498. var _RuleHelpers = require('./RuleHelpers');
  44499. Object.defineProperty(exports, 'butNot', {
  44500. enumerable: true,
  44501. get: function get() {
  44502. return _RuleHelpers.butNot;
  44503. }
  44504. });
  44505. Object.defineProperty(exports, 'list', {
  44506. enumerable: true,
  44507. get: function get() {
  44508. return _RuleHelpers.list;
  44509. }
  44510. });
  44511. Object.defineProperty(exports, 'opt', {
  44512. enumerable: true,
  44513. get: function get() {
  44514. return _RuleHelpers.opt;
  44515. }
  44516. });
  44517. Object.defineProperty(exports, 'p', {
  44518. enumerable: true,
  44519. get: function get() {
  44520. return _RuleHelpers.p;
  44521. }
  44522. });
  44523. Object.defineProperty(exports, 't', {
  44524. enumerable: true,
  44525. get: function get() {
  44526. return _RuleHelpers.t;
  44527. }
  44528. });
  44529. var _onlineParser = require('./onlineParser');
  44530. Object.defineProperty(exports, 'onlineParser', {
  44531. enumerable: true,
  44532. get: function get() {
  44533. return _interopRequireDefault(_onlineParser).default;
  44534. }
  44535. });
  44536. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  44537. },{"./CharacterStream":266,"./RuleHelpers":267,"./Rules":268,"./onlineParser":270}],270:[function(require,module,exports){
  44538. 'use strict';
  44539. Object.defineProperty(exports, "__esModule", {
  44540. value: true
  44541. });
  44542. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /**
  44543. * Copyright (c) Facebook, Inc.
  44544. * All rights reserved.
  44545. *
  44546. * This source code is licensed under the license found in the
  44547. * LICENSE file in the root directory of this source tree.
  44548. *
  44549. *
  44550. */
  44551. /**
  44552. * Builds an online immutable parser, designed to be used as part of a syntax
  44553. * highlighting and code intelligence tools.
  44554. *
  44555. * Options:
  44556. *
  44557. * eatWhitespace: (
  44558. * stream: Stream | CodeMirror.StringStream | CharacterStream
  44559. * ) => boolean
  44560. * Use CodeMirror API.
  44561. *
  44562. * LexRules: { [name: string]: RegExp }, Includes `Punctuation`, `Comment`.
  44563. *
  44564. * ParseRules: { [name: string]: Array<Rule> }, Includes `Document`.
  44565. *
  44566. * editorConfig: { [name: string]: any }, Provides an editor-specific
  44567. * configurations set.
  44568. *
  44569. */
  44570. exports.default = onlineParser;
  44571. var _Rules = require('./Rules');
  44572. function onlineParser() {
  44573. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  44574. eatWhitespace: function eatWhitespace(stream) {
  44575. return stream.eatWhile(_Rules.isIgnored);
  44576. },
  44577. lexRules: _Rules.LexRules,
  44578. parseRules: _Rules.ParseRules,
  44579. editorConfig: {}
  44580. };
  44581. return {
  44582. startState: function startState() {
  44583. var initialState = {
  44584. level: 0,
  44585. step: 0,
  44586. name: null,
  44587. kind: null,
  44588. type: null,
  44589. rule: null,
  44590. needsSeperator: false,
  44591. prevState: null
  44592. };
  44593. pushRule(options.parseRules, initialState, 'Document');
  44594. return initialState;
  44595. },
  44596. token: function token(stream, state) {
  44597. return getToken(stream, state, options);
  44598. }
  44599. };
  44600. }
  44601. function getToken(stream, state, options) {
  44602. var lexRules = options.lexRules,
  44603. parseRules = options.parseRules,
  44604. eatWhitespace = options.eatWhitespace,
  44605. editorConfig = options.editorConfig;
  44606. // Restore state after an empty-rule.
  44607. if (state.rule && state.rule.length === 0) {
  44608. popRule(state);
  44609. } else if (state.needsAdvance) {
  44610. state.needsAdvance = false;
  44611. advanceRule(state, true);
  44612. }
  44613. // Remember initial indentation
  44614. if (stream.sol()) {
  44615. var tabSize = editorConfig && editorConfig.tabSize || 2;
  44616. state.indentLevel = Math.floor(stream.indentation() / tabSize);
  44617. }
  44618. // Consume spaces and ignored characters
  44619. if (eatWhitespace(stream)) {
  44620. return 'ws';
  44621. }
  44622. // Get a matched token from the stream, using lex
  44623. var token = lex(lexRules, stream);
  44624. // If there's no matching token, skip ahead.
  44625. if (!token) {
  44626. stream.match(/\S+/);
  44627. pushRule(SpecialParseRules, state, 'Invalid');
  44628. return 'invalidchar';
  44629. }
  44630. // If the next token is a Comment, insert a Comment parsing rule.
  44631. if (token.kind === 'Comment') {
  44632. pushRule(SpecialParseRules, state, 'Comment');
  44633. return 'comment';
  44634. }
  44635. // Save state before continuing.
  44636. var backupState = assign({}, state);
  44637. // Handle changes in expected indentation level
  44638. if (token.kind === 'Punctuation') {
  44639. if (/^[{([]/.test(token.value)) {
  44640. // Push on the stack of levels one level deeper than the current level.
  44641. state.levels = (state.levels || []).concat(state.indentLevel + 1);
  44642. } else if (/^[})\]]/.test(token.value)) {
  44643. // Pop from the stack of levels.
  44644. // If the top of the stack is lower than the current level, lower the
  44645. // current level to match.
  44646. var levels = state.levels = (state.levels || []).slice(0, -1);
  44647. if (state.indentLevel) {
  44648. if (levels.length > 0 && levels[levels.length - 1] < state.indentLevel) {
  44649. state.indentLevel = levels[levels.length - 1];
  44650. }
  44651. }
  44652. }
  44653. }
  44654. while (state.rule) {
  44655. // If this is a forking rule, determine what rule to use based on
  44656. var expected = typeof state.rule === 'function' ? state.step === 0 ? state.rule(token, stream) : null : state.rule[state.step];
  44657. // Seperator between list elements if necessary.
  44658. if (state.needsSeperator) {
  44659. expected = expected && expected.separator;
  44660. }
  44661. if (expected) {
  44662. // Un-wrap optional/list parseRules.
  44663. if (expected.ofRule) {
  44664. expected = expected.ofRule;
  44665. }
  44666. // A string represents a Rule
  44667. if (typeof expected === 'string') {
  44668. pushRule(parseRules, state, expected);
  44669. continue;
  44670. }
  44671. // Otherwise, match a Terminal.
  44672. if (expected.match && expected.match(token)) {
  44673. if (expected.update) {
  44674. expected.update(state, token);
  44675. }
  44676. // If this token was a punctuator, advance the parse rule, otherwise
  44677. // mark the state to be advanced before the next token. This ensures
  44678. // that tokens which can be appended to keep the appropriate state.
  44679. if (token.kind === 'Punctuation') {
  44680. advanceRule(state, true);
  44681. } else {
  44682. state.needsAdvance = true;
  44683. }
  44684. return expected.style;
  44685. }
  44686. }
  44687. unsuccessful(state);
  44688. }
  44689. // The parser does not know how to interpret this token, do not affect state.
  44690. assign(state, backupState);
  44691. pushRule(SpecialParseRules, state, 'Invalid');
  44692. return 'invalidchar';
  44693. }
  44694. // Utility function to assign from object to another object.
  44695. function assign(to, from) {
  44696. var keys = Object.keys(from);
  44697. for (var i = 0; i < keys.length; i++) {
  44698. to[keys[i]] = from[keys[i]];
  44699. }
  44700. return to;
  44701. }
  44702. // A special rule set for parsing comment tokens.
  44703. var SpecialParseRules = {
  44704. Invalid: [],
  44705. Comment: []
  44706. };
  44707. // Push a new rule onto the state.
  44708. function pushRule(rules, state, ruleKind) {
  44709. if (!rules[ruleKind]) {
  44710. throw new TypeError('Unknown rule: ' + ruleKind);
  44711. }
  44712. state.prevState = _extends({}, state);
  44713. state.kind = ruleKind;
  44714. state.name = null;
  44715. state.type = null;
  44716. state.rule = rules[ruleKind];
  44717. state.step = 0;
  44718. state.needsSeperator = false;
  44719. }
  44720. // Pop the current rule from the state.
  44721. function popRule(state) {
  44722. // Check if there's anything to pop
  44723. if (!state.prevState) {
  44724. return;
  44725. }
  44726. state.kind = state.prevState.kind;
  44727. state.name = state.prevState.name;
  44728. state.type = state.prevState.type;
  44729. state.rule = state.prevState.rule;
  44730. state.step = state.prevState.step;
  44731. state.needsSeperator = state.prevState.needsSeperator;
  44732. state.prevState = state.prevState.prevState;
  44733. }
  44734. // Advance the step of the current rule.
  44735. function advanceRule(state, successful) {
  44736. // If this is advancing successfully and the current state is a list, give
  44737. // it an opportunity to repeat itself.
  44738. if (isList(state)) {
  44739. if (state.rule && state.rule[state.step].separator) {
  44740. var separator = state.rule[state.step].separator;
  44741. state.needsSeperator = !state.needsSeperator;
  44742. // If the separator was optional, then give it an opportunity to repeat.
  44743. if (!state.needsSeperator && separator.ofRule) {
  44744. return;
  44745. }
  44746. }
  44747. // If this was a successful list parse, then allow it to repeat itself.
  44748. if (successful) {
  44749. return;
  44750. }
  44751. }
  44752. // Advance the step in the rule. If the rule is completed, pop
  44753. // the rule and advance the parent rule as well (recursively).
  44754. state.needsSeperator = false;
  44755. state.step++;
  44756. // While the current rule is completed.
  44757. while (state.rule && !(Array.isArray(state.rule) && state.step < state.rule.length)) {
  44758. popRule(state);
  44759. if (state.rule) {
  44760. // Do not advance a List step so it has the opportunity to repeat itself.
  44761. if (isList(state)) {
  44762. if (state.rule && state.rule[state.step].separator) {
  44763. state.needsSeperator = !state.needsSeperator;
  44764. }
  44765. } else {
  44766. state.needsSeperator = false;
  44767. state.step++;
  44768. }
  44769. }
  44770. }
  44771. }
  44772. function isList(state) {
  44773. return Array.isArray(state.rule) && typeof state.rule[state.step] !== 'string' && state.rule[state.step].isList;
  44774. }
  44775. // Unwind the state after an unsuccessful match.
  44776. function unsuccessful(state) {
  44777. // Fall back to the parent rule until you get to an optional or list rule or
  44778. // until the entire stack of rules is empty.
  44779. while (state.rule && !(Array.isArray(state.rule) && state.rule[state.step].ofRule)) {
  44780. popRule(state);
  44781. }
  44782. // If there is still a rule, it must be an optional or list rule.
  44783. // Consider this rule a success so that we may move past it.
  44784. if (state.rule) {
  44785. advanceRule(state, false);
  44786. }
  44787. }
  44788. // Given a stream, returns a { kind, value } pair, or null.
  44789. function lex(lexRules, stream) {
  44790. var kinds = Object.keys(lexRules);
  44791. for (var i = 0; i < kinds.length; i++) {
  44792. var match = stream.match(lexRules[kinds[i]]);
  44793. if (match && match instanceof Array) {
  44794. return { kind: kinds[i], value: match[0] };
  44795. }
  44796. }
  44797. }
  44798. },{"./Rules":268}],271:[function(require,module,exports){
  44799. 'use strict';
  44800. Object.defineProperty(exports, "__esModule", {
  44801. value: true
  44802. });
  44803. exports.offsetToPosition = offsetToPosition;
  44804. exports.locToRange = locToRange;
  44805. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  44806. /**
  44807. * Copyright (c) Facebook, Inc.
  44808. * All rights reserved.
  44809. *
  44810. * This source code is licensed under the license found in the
  44811. * LICENSE file in the root directory of this source tree.
  44812. *
  44813. *
  44814. */
  44815. var Range = exports.Range = function () {
  44816. function Range(start, end) {
  44817. var _this = this;
  44818. _classCallCheck(this, Range);
  44819. this.containsPosition = function (position) {
  44820. if (_this.start.line === position.line) {
  44821. return _this.start.character <= position.character;
  44822. } else if (_this.end.line === position.line) {
  44823. return _this.end.character >= position.character;
  44824. } else {
  44825. return _this.start.line <= position.line && _this.end.line >= position.line;
  44826. }
  44827. };
  44828. this.start = start;
  44829. this.end = end;
  44830. }
  44831. Range.prototype.setStart = function setStart(line, character) {
  44832. this.start = new Position(line, character);
  44833. };
  44834. Range.prototype.setEnd = function setEnd(line, character) {
  44835. this.end = new Position(line, character);
  44836. };
  44837. return Range;
  44838. }();
  44839. var Position = exports.Position = function () {
  44840. function Position(line, character) {
  44841. var _this2 = this;
  44842. _classCallCheck(this, Position);
  44843. this.lessThanOrEqualTo = function (position) {
  44844. return _this2.line < position.line || _this2.line === position.line && _this2.character <= position.character;
  44845. };
  44846. this.line = line;
  44847. this.character = character;
  44848. }
  44849. Position.prototype.setLine = function setLine(line) {
  44850. this.line = line;
  44851. };
  44852. Position.prototype.setCharacter = function setCharacter(character) {
  44853. this.character = character;
  44854. };
  44855. return Position;
  44856. }();
  44857. function offsetToPosition(text, loc) {
  44858. var EOL = '\n';
  44859. var buf = text.slice(0, loc);
  44860. var lines = buf.split(EOL).length - 1;
  44861. var lastLineIndex = buf.lastIndexOf(EOL);
  44862. return new Position(lines, loc - lastLineIndex - 1);
  44863. }
  44864. function locToRange(text, loc) {
  44865. var start = offsetToPosition(text, loc.start);
  44866. var end = offsetToPosition(text, loc.end);
  44867. return new Range(start, end);
  44868. }
  44869. },{}],272:[function(require,module,exports){
  44870. 'use strict';
  44871. Object.defineProperty(exports, "__esModule", {
  44872. value: true
  44873. });
  44874. exports.getASTNodeAtPosition = getASTNodeAtPosition;
  44875. exports.pointToOffset = pointToOffset;
  44876. var _Range = require('./Range');
  44877. var _graphql = require('graphql');
  44878. function getASTNodeAtPosition(query, ast, point) {
  44879. var offset = pointToOffset(query, point);
  44880. var nodeContainingPosition = void 0;
  44881. (0, _graphql.visit)(ast, {
  44882. enter: function enter(node) {
  44883. if (node.kind !== 'Name' && // We're usually interested in their parents
  44884. node.loc && node.loc.start <= offset && offset <= node.loc.end) {
  44885. nodeContainingPosition = node;
  44886. } else {
  44887. return false;
  44888. }
  44889. },
  44890. leave: function leave(node) {
  44891. if (node.loc && node.loc.start <= offset && offset <= node.loc.end) {
  44892. return false;
  44893. }
  44894. }
  44895. });
  44896. return nodeContainingPosition;
  44897. } /**
  44898. * Copyright (c) Facebook, Inc.
  44899. * All rights reserved.
  44900. *
  44901. * This source code is licensed under the license found in the
  44902. * LICENSE file in the root directory of this source tree.
  44903. *
  44904. *
  44905. */
  44906. function pointToOffset(text, point) {
  44907. var linesUntilPosition = text.split('\n').slice(0, point.line);
  44908. return point.character + linesUntilPosition.map(function (line) {
  44909. return line.length + 1;
  44910. } // count EOL
  44911. ).reduce(function (a, b) {
  44912. return a + b;
  44913. }, 0);
  44914. }
  44915. },{"./Range":271,"graphql":285}],273:[function(require,module,exports){
  44916. 'use strict';
  44917. Object.defineProperty(exports, "__esModule", {
  44918. value: true
  44919. });
  44920. var _getASTNodeAtPosition = require('./getASTNodeAtPosition');
  44921. Object.defineProperty(exports, 'getASTNodeAtPosition', {
  44922. enumerable: true,
  44923. get: function get() {
  44924. return _getASTNodeAtPosition.getASTNodeAtPosition;
  44925. }
  44926. });
  44927. Object.defineProperty(exports, 'pointToOffset', {
  44928. enumerable: true,
  44929. get: function get() {
  44930. return _getASTNodeAtPosition.pointToOffset;
  44931. }
  44932. });
  44933. var _Range = require('./Range');
  44934. Object.defineProperty(exports, 'Position', {
  44935. enumerable: true,
  44936. get: function get() {
  44937. return _Range.Position;
  44938. }
  44939. });
  44940. Object.defineProperty(exports, 'Range', {
  44941. enumerable: true,
  44942. get: function get() {
  44943. return _Range.Range;
  44944. }
  44945. });
  44946. Object.defineProperty(exports, 'locToRange', {
  44947. enumerable: true,
  44948. get: function get() {
  44949. return _Range.locToRange;
  44950. }
  44951. });
  44952. Object.defineProperty(exports, 'offsetToPosition', {
  44953. enumerable: true,
  44954. get: function get() {
  44955. return _Range.offsetToPosition;
  44956. }
  44957. });
  44958. var _validateWithCustomRules = require('./validateWithCustomRules');
  44959. Object.defineProperty(exports, 'validateWithCustomRules', {
  44960. enumerable: true,
  44961. get: function get() {
  44962. return _validateWithCustomRules.validateWithCustomRules;
  44963. }
  44964. });
  44965. },{"./Range":271,"./getASTNodeAtPosition":272,"./validateWithCustomRules":274}],274:[function(require,module,exports){
  44966. 'use strict';
  44967. Object.defineProperty(exports, "__esModule", {
  44968. value: true
  44969. });
  44970. exports.validateWithCustomRules = validateWithCustomRules;
  44971. var _graphql = require('graphql');
  44972. /**
  44973. * Validate a GraphQL Document optionally with custom validation rules.
  44974. */
  44975. function validateWithCustomRules(schema, ast, customRules, isRelayCompatMode) {
  44976. // Because every fragment is considered for determing model subsets that may
  44977. // be used anywhere in the codebase they're all technically "used" by clients
  44978. // of graphql-data. So we remove this rule from the validators.
  44979. var _require = require('graphql/validation/rules/NoUnusedFragments'),
  44980. NoUnusedFragments = _require.NoUnusedFragments;
  44981. var _require2 = require('graphql/validation/rules/ExecutableDefinitions'),
  44982. ExecutableDefinitions = _require2.ExecutableDefinitions;
  44983. var rulesToSkip = [NoUnusedFragments, ExecutableDefinitions];
  44984. if (isRelayCompatMode) {
  44985. var _require3 = require('graphql/validation/rules/KnownFragmentNames'),
  44986. KnownFragmentNames = _require3.KnownFragmentNames;
  44987. rulesToSkip.push(KnownFragmentNames);
  44988. }
  44989. var rules = _graphql.specifiedRules.filter(function (rule) {
  44990. return !rulesToSkip.some(function (r) {
  44991. return r === rule;
  44992. });
  44993. });
  44994. var typeInfo = new _graphql.TypeInfo(schema);
  44995. if (customRules) {
  44996. Array.prototype.push.apply(rules, customRules);
  44997. }
  44998. var errors = (0, _graphql.validate)(schema, ast, rules, typeInfo);
  44999. if (errors.length > 0) {
  45000. return errors.filter(function (error) {
  45001. if (error.message.indexOf('Unknown directive') === -1) {
  45002. return true;
  45003. }
  45004. return !(error.nodes && error.nodes[0] && error.nodes[0].name && error.nodes[0].name.value === 'arguments' || error.nodes && error.nodes[0] && error.nodes[0].name && error.nodes[0].name.value && error.nodes[0].name.value === 'argumentDefinitions');
  45005. });
  45006. }
  45007. return [];
  45008. } /**
  45009. * Copyright (c) Facebook, Inc.
  45010. * All rights reserved.
  45011. *
  45012. * This source code is licensed under the license found in the
  45013. * LICENSE file in the root directory of this source tree.
  45014. *
  45015. *
  45016. */
  45017. },{"graphql":285,"graphql/validation/rules/ExecutableDefinitions":356,"graphql/validation/rules/KnownFragmentNames":361,"graphql/validation/rules/NoUnusedFragments":367}],275:[function(require,module,exports){
  45018. "use strict";
  45019. Object.defineProperty(exports, "__esModule", {
  45020. value: true
  45021. });
  45022. exports.GraphQLError = GraphQLError;
  45023. var _printError = require("./printError");
  45024. var _location = require("../language/location");
  45025. /**
  45026. * Copyright (c) 2015-present, Facebook, Inc.
  45027. *
  45028. * This source code is licensed under the MIT license found in the
  45029. * LICENSE file in the root directory of this source tree.
  45030. *
  45031. *
  45032. */
  45033. function GraphQLError( // eslint-disable-line no-redeclare
  45034. message, nodes, source, positions, path, originalError, extensions) {
  45035. // Compute list of blame nodes.
  45036. var _nodes = Array.isArray(nodes) ? nodes.length !== 0 ? nodes : undefined : nodes ? [nodes] : undefined; // Compute locations in the source for the given nodes/positions.
  45037. var _source = source;
  45038. if (!_source && _nodes) {
  45039. var node = _nodes[0];
  45040. _source = node && node.loc && node.loc.source;
  45041. }
  45042. var _positions = positions;
  45043. if (!_positions && _nodes) {
  45044. _positions = _nodes.reduce(function (list, node) {
  45045. if (node.loc) {
  45046. list.push(node.loc.start);
  45047. }
  45048. return list;
  45049. }, []);
  45050. }
  45051. if (_positions && _positions.length === 0) {
  45052. _positions = undefined;
  45053. }
  45054. var _locations;
  45055. if (positions && source) {
  45056. _locations = positions.map(function (pos) {
  45057. return (0, _location.getLocation)(source, pos);
  45058. });
  45059. } else if (_nodes) {
  45060. _locations = _nodes.reduce(function (list, node) {
  45061. if (node.loc) {
  45062. list.push((0, _location.getLocation)(node.loc.source, node.loc.start));
  45063. }
  45064. return list;
  45065. }, []);
  45066. }
  45067. var _extensions = extensions || originalError && originalError.extensions;
  45068. Object.defineProperties(this, {
  45069. message: {
  45070. value: message,
  45071. // By being enumerable, JSON.stringify will include `message` in the
  45072. // resulting output. This ensures that the simplest possible GraphQL
  45073. // service adheres to the spec.
  45074. enumerable: true,
  45075. writable: true
  45076. },
  45077. locations: {
  45078. // Coercing falsey values to undefined ensures they will not be included
  45079. // in JSON.stringify() when not provided.
  45080. value: _locations || undefined,
  45081. // By being enumerable, JSON.stringify will include `locations` in the
  45082. // resulting output. This ensures that the simplest possible GraphQL
  45083. // service adheres to the spec.
  45084. enumerable: Boolean(_locations)
  45085. },
  45086. path: {
  45087. // Coercing falsey values to undefined ensures they will not be included
  45088. // in JSON.stringify() when not provided.
  45089. value: path || undefined,
  45090. // By being enumerable, JSON.stringify will include `path` in the
  45091. // resulting output. This ensures that the simplest possible GraphQL
  45092. // service adheres to the spec.
  45093. enumerable: Boolean(path)
  45094. },
  45095. nodes: {
  45096. value: _nodes || undefined
  45097. },
  45098. source: {
  45099. value: _source || undefined
  45100. },
  45101. positions: {
  45102. value: _positions || undefined
  45103. },
  45104. originalError: {
  45105. value: originalError
  45106. },
  45107. extensions: {
  45108. // Coercing falsey values to undefined ensures they will not be included
  45109. // in JSON.stringify() when not provided.
  45110. value: _extensions || undefined,
  45111. // By being enumerable, JSON.stringify will include `path` in the
  45112. // resulting output. This ensures that the simplest possible GraphQL
  45113. // service adheres to the spec.
  45114. enumerable: Boolean(_extensions)
  45115. }
  45116. }); // Include (non-enumerable) stack trace.
  45117. if (originalError && originalError.stack) {
  45118. Object.defineProperty(this, 'stack', {
  45119. value: originalError.stack,
  45120. writable: true,
  45121. configurable: true
  45122. });
  45123. } else if (Error.captureStackTrace) {
  45124. Error.captureStackTrace(this, GraphQLError);
  45125. } else {
  45126. Object.defineProperty(this, 'stack', {
  45127. value: Error().stack,
  45128. writable: true,
  45129. configurable: true
  45130. });
  45131. }
  45132. }
  45133. GraphQLError.prototype = Object.create(Error.prototype, {
  45134. constructor: {
  45135. value: GraphQLError
  45136. },
  45137. name: {
  45138. value: 'GraphQLError'
  45139. },
  45140. toString: {
  45141. value: function toString() {
  45142. return (0, _printError.printError)(this);
  45143. }
  45144. }
  45145. });
  45146. },{"../language/location":309,"./printError":279}],276:[function(require,module,exports){
  45147. "use strict";
  45148. Object.defineProperty(exports, "__esModule", {
  45149. value: true
  45150. });
  45151. exports.formatError = formatError;
  45152. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  45153. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  45154. /**
  45155. * Copyright (c) 2015-present, Facebook, Inc.
  45156. *
  45157. * This source code is licensed under the MIT license found in the
  45158. * LICENSE file in the root directory of this source tree.
  45159. *
  45160. *
  45161. */
  45162. /**
  45163. * Given a GraphQLError, format it according to the rules described by the
  45164. * Response Format, Errors section of the GraphQL Specification.
  45165. */
  45166. function formatError(error) {
  45167. !error ? (0, _invariant.default)(0, 'Received null or undefined error.') : void 0;
  45168. var message = error.message || 'An unknown error occurred.';
  45169. var locations = error.locations;
  45170. var path = error.path;
  45171. var extensions = error.extensions;
  45172. return extensions ? {
  45173. message: message,
  45174. locations: locations,
  45175. path: path,
  45176. extensions: extensions
  45177. } : {
  45178. message: message,
  45179. locations: locations,
  45180. path: path
  45181. };
  45182. }
  45183. },{"../jsutils/invariant":290}],277:[function(require,module,exports){
  45184. "use strict";
  45185. Object.defineProperty(exports, "__esModule", {
  45186. value: true
  45187. });
  45188. Object.defineProperty(exports, "GraphQLError", {
  45189. enumerable: true,
  45190. get: function get() {
  45191. return _GraphQLError.GraphQLError;
  45192. }
  45193. });
  45194. Object.defineProperty(exports, "syntaxError", {
  45195. enumerable: true,
  45196. get: function get() {
  45197. return _syntaxError.syntaxError;
  45198. }
  45199. });
  45200. Object.defineProperty(exports, "locatedError", {
  45201. enumerable: true,
  45202. get: function get() {
  45203. return _locatedError.locatedError;
  45204. }
  45205. });
  45206. Object.defineProperty(exports, "printError", {
  45207. enumerable: true,
  45208. get: function get() {
  45209. return _printError.printError;
  45210. }
  45211. });
  45212. Object.defineProperty(exports, "formatError", {
  45213. enumerable: true,
  45214. get: function get() {
  45215. return _formatError.formatError;
  45216. }
  45217. });
  45218. var _GraphQLError = require("./GraphQLError");
  45219. var _syntaxError = require("./syntaxError");
  45220. var _locatedError = require("./locatedError");
  45221. var _printError = require("./printError");
  45222. var _formatError = require("./formatError");
  45223. },{"./GraphQLError":275,"./formatError":276,"./locatedError":278,"./printError":279,"./syntaxError":280}],278:[function(require,module,exports){
  45224. "use strict";
  45225. Object.defineProperty(exports, "__esModule", {
  45226. value: true
  45227. });
  45228. exports.locatedError = locatedError;
  45229. var _GraphQLError = require("./GraphQLError");
  45230. /**
  45231. * Copyright (c) 2015-present, Facebook, Inc.
  45232. *
  45233. * This source code is licensed under the MIT license found in the
  45234. * LICENSE file in the root directory of this source tree.
  45235. *
  45236. *
  45237. */
  45238. /**
  45239. * Given an arbitrary Error, presumably thrown while attempting to execute a
  45240. * GraphQL operation, produce a new GraphQLError aware of the location in the
  45241. * document responsible for the original Error.
  45242. */
  45243. function locatedError(originalError, nodes, path) {
  45244. // Note: this uses a brand-check to support GraphQL errors originating from
  45245. // other contexts.
  45246. if (originalError && Array.isArray(originalError.path)) {
  45247. return originalError;
  45248. }
  45249. return new _GraphQLError.GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
  45250. }
  45251. },{"./GraphQLError":275}],279:[function(require,module,exports){
  45252. "use strict";
  45253. Object.defineProperty(exports, "__esModule", {
  45254. value: true
  45255. });
  45256. exports.printError = printError;
  45257. var _location = require("../language/location");
  45258. /**
  45259. * Copyright (c) 2015-present, Facebook, Inc.
  45260. *
  45261. * This source code is licensed under the MIT license found in the
  45262. * LICENSE file in the root directory of this source tree.
  45263. *
  45264. *
  45265. */
  45266. /**
  45267. * Prints a GraphQLError to a string, representing useful location information
  45268. * about the error's position in the source.
  45269. */
  45270. function printError(error) {
  45271. var printedLocations = [];
  45272. if (error.nodes) {
  45273. var _iteratorNormalCompletion = true;
  45274. var _didIteratorError = false;
  45275. var _iteratorError = undefined;
  45276. try {
  45277. for (var _iterator = error.nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  45278. var node = _step.value;
  45279. if (node.loc) {
  45280. printedLocations.push(highlightSourceAtLocation(node.loc.source, (0, _location.getLocation)(node.loc.source, node.loc.start)));
  45281. }
  45282. }
  45283. } catch (err) {
  45284. _didIteratorError = true;
  45285. _iteratorError = err;
  45286. } finally {
  45287. try {
  45288. if (!_iteratorNormalCompletion && _iterator.return != null) {
  45289. _iterator.return();
  45290. }
  45291. } finally {
  45292. if (_didIteratorError) {
  45293. throw _iteratorError;
  45294. }
  45295. }
  45296. }
  45297. } else if (error.source && error.locations) {
  45298. var source = error.source;
  45299. var _iteratorNormalCompletion2 = true;
  45300. var _didIteratorError2 = false;
  45301. var _iteratorError2 = undefined;
  45302. try {
  45303. for (var _iterator2 = error.locations[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  45304. var location = _step2.value;
  45305. printedLocations.push(highlightSourceAtLocation(source, location));
  45306. }
  45307. } catch (err) {
  45308. _didIteratorError2 = true;
  45309. _iteratorError2 = err;
  45310. } finally {
  45311. try {
  45312. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  45313. _iterator2.return();
  45314. }
  45315. } finally {
  45316. if (_didIteratorError2) {
  45317. throw _iteratorError2;
  45318. }
  45319. }
  45320. }
  45321. }
  45322. return printedLocations.length === 0 ? error.message : [error.message].concat(printedLocations).join('\n\n') + '\n';
  45323. }
  45324. /**
  45325. * Render a helpful description of the location of the error in the GraphQL
  45326. * Source document.
  45327. */
  45328. function highlightSourceAtLocation(source, location) {
  45329. var firstLineColumnOffset = source.locationOffset.column - 1;
  45330. var body = whitespace(firstLineColumnOffset) + source.body;
  45331. var lineIndex = location.line - 1;
  45332. var lineOffset = source.locationOffset.line - 1;
  45333. var lineNum = location.line + lineOffset;
  45334. var columnOffset = location.line === 1 ? firstLineColumnOffset : 0;
  45335. var columnNum = location.column + columnOffset;
  45336. var lines = body.split(/\r\n|[\n\r]/g);
  45337. return "".concat(source.name, " (").concat(lineNum, ":").concat(columnNum, ")\n") + printPrefixedLines([// Lines specified like this: ["prefix", "string"],
  45338. ["".concat(lineNum - 1, ": "), lines[lineIndex - 1]], ["".concat(lineNum, ": "), lines[lineIndex]], ['', whitespace(columnNum - 1) + '^'], ["".concat(lineNum + 1, ": "), lines[lineIndex + 1]]]);
  45339. }
  45340. function printPrefixedLines(lines) {
  45341. var existingLines = lines.filter(function (_ref) {
  45342. var _ = _ref[0],
  45343. line = _ref[1];
  45344. return line !== undefined;
  45345. });
  45346. var padLen = 0;
  45347. var _iteratorNormalCompletion3 = true;
  45348. var _didIteratorError3 = false;
  45349. var _iteratorError3 = undefined;
  45350. try {
  45351. for (var _iterator3 = existingLines[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  45352. var _ref4 = _step3.value;
  45353. var prefix = _ref4[0];
  45354. padLen = Math.max(padLen, prefix.length);
  45355. }
  45356. } catch (err) {
  45357. _didIteratorError3 = true;
  45358. _iteratorError3 = err;
  45359. } finally {
  45360. try {
  45361. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  45362. _iterator3.return();
  45363. }
  45364. } finally {
  45365. if (_didIteratorError3) {
  45366. throw _iteratorError3;
  45367. }
  45368. }
  45369. }
  45370. return existingLines.map(function (_ref3) {
  45371. var prefix = _ref3[0],
  45372. line = _ref3[1];
  45373. return lpad(padLen, prefix) + line;
  45374. }).join('\n');
  45375. }
  45376. function whitespace(len) {
  45377. return Array(len + 1).join(' ');
  45378. }
  45379. function lpad(len, str) {
  45380. return whitespace(len - str.length) + str;
  45381. }
  45382. },{"../language/location":309}],280:[function(require,module,exports){
  45383. "use strict";
  45384. Object.defineProperty(exports, "__esModule", {
  45385. value: true
  45386. });
  45387. exports.syntaxError = syntaxError;
  45388. var _GraphQLError = require("./GraphQLError");
  45389. /**
  45390. * Copyright (c) 2015-present, Facebook, Inc.
  45391. *
  45392. * This source code is licensed under the MIT license found in the
  45393. * LICENSE file in the root directory of this source tree.
  45394. *
  45395. *
  45396. */
  45397. /**
  45398. * Produces a GraphQLError representing a syntax error, containing useful
  45399. * descriptive information about the syntax error's position in the source.
  45400. */
  45401. function syntaxError(source, position, description) {
  45402. return new _GraphQLError.GraphQLError("Syntax Error: ".concat(description), undefined, source, [position]);
  45403. }
  45404. },{"./GraphQLError":275}],281:[function(require,module,exports){
  45405. "use strict";
  45406. Object.defineProperty(exports, "__esModule", {
  45407. value: true
  45408. });
  45409. exports.execute = execute;
  45410. exports.responsePathAsArray = responsePathAsArray;
  45411. exports.addPath = addPath;
  45412. exports.assertValidExecutionArguments = assertValidExecutionArguments;
  45413. exports.buildExecutionContext = buildExecutionContext;
  45414. exports.collectFields = collectFields;
  45415. exports.buildResolveInfo = buildResolveInfo;
  45416. exports.resolveFieldValueOrError = resolveFieldValueOrError;
  45417. exports.getFieldDef = getFieldDef;
  45418. exports.defaultFieldResolver = void 0;
  45419. var _iterall = require("iterall");
  45420. var _GraphQLError = require("../error/GraphQLError");
  45421. var _locatedError = require("../error/locatedError");
  45422. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  45423. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  45424. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  45425. var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
  45426. var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
  45427. var _memoize = _interopRequireDefault(require("../jsutils/memoize3"));
  45428. var _promiseForObject = _interopRequireDefault(require("../jsutils/promiseForObject"));
  45429. var _promiseReduce = _interopRequireDefault(require("../jsutils/promiseReduce"));
  45430. var _getOperationRootType = require("../utilities/getOperationRootType");
  45431. var _typeFromAST = require("../utilities/typeFromAST");
  45432. var _kinds = require("../language/kinds");
  45433. var _values = require("./values");
  45434. var _definition = require("../type/definition");
  45435. var _introspection = require("../type/introspection");
  45436. var _directives = require("../type/directives");
  45437. var _validate = require("../type/validate");
  45438. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  45439. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  45440. function execute(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  45441. /* eslint-enable no-redeclare */
  45442. // Extract arguments from object args if provided.
  45443. return arguments.length === 1 ? executeImpl(argsOrSchema.schema, argsOrSchema.document, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : executeImpl(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
  45444. }
  45445. function executeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  45446. // If arguments are missing or incorrect, throw an error.
  45447. assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
  45448. // a "Response" with only errors is returned.
  45449. var exeContext = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver); // Return early errors if execution context failed.
  45450. if (Array.isArray(exeContext)) {
  45451. return {
  45452. errors: exeContext
  45453. };
  45454. } // Return a Promise that will eventually resolve to the data described by
  45455. // The "Response" section of the GraphQL specification.
  45456. //
  45457. // If errors are encountered while executing a GraphQL field, only that
  45458. // field and its descendants will be omitted, and sibling fields will still
  45459. // be executed. An execution which encounters errors will still result in a
  45460. // resolved Promise.
  45461. var data = executeOperation(exeContext, exeContext.operation, rootValue);
  45462. return buildResponse(exeContext, data);
  45463. }
  45464. /**
  45465. * Given a completed execution context and data, build the { errors, data }
  45466. * response defined by the "Response" section of the GraphQL specification.
  45467. */
  45468. function buildResponse(exeContext, data) {
  45469. if ((0, _isPromise.default)(data)) {
  45470. return data.then(function (resolved) {
  45471. return buildResponse(exeContext, resolved);
  45472. });
  45473. }
  45474. return exeContext.errors.length === 0 ? {
  45475. data: data
  45476. } : {
  45477. errors: exeContext.errors,
  45478. data: data
  45479. };
  45480. }
  45481. /**
  45482. * Given a ResponsePath (found in the `path` entry in the information provided
  45483. * as the last argument to a field resolver), return an Array of the path keys.
  45484. */
  45485. function responsePathAsArray(path) {
  45486. var flattened = [];
  45487. var curr = path;
  45488. while (curr) {
  45489. flattened.push(curr.key);
  45490. curr = curr.prev;
  45491. }
  45492. return flattened.reverse();
  45493. }
  45494. /**
  45495. * Given a ResponsePath and a key, return a new ResponsePath containing the
  45496. * new key.
  45497. */
  45498. function addPath(prev, key) {
  45499. return {
  45500. prev: prev,
  45501. key: key
  45502. };
  45503. }
  45504. /**
  45505. * Essential assertions before executing to provide developer feedback for
  45506. * improper use of the GraphQL library.
  45507. */
  45508. function assertValidExecutionArguments(schema, document, rawVariableValues) {
  45509. !document ? (0, _invariant.default)(0, 'Must provide document') : void 0; // If the schema used for execution is invalid, throw an error.
  45510. (0, _validate.assertValidSchema)(schema); // Variables, if provided, must be an object.
  45511. !(!rawVariableValues || _typeof(rawVariableValues) === 'object') ? (0, _invariant.default)(0, 'Variables must be provided as an Object where each property is a ' + 'variable value. Perhaps look to see if an unparsed JSON string ' + 'was provided.') : void 0;
  45512. }
  45513. /**
  45514. * Constructs a ExecutionContext object from the arguments passed to
  45515. * execute, which we will pass throughout the other execution methods.
  45516. *
  45517. * Throws a GraphQLError if a valid execution context cannot be created.
  45518. */
  45519. function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName, fieldResolver) {
  45520. var errors = [];
  45521. var operation;
  45522. var hasMultipleAssumedOperations = false;
  45523. var fragments = Object.create(null);
  45524. for (var i = 0; i < document.definitions.length; i++) {
  45525. var definition = document.definitions[i];
  45526. switch (definition.kind) {
  45527. case _kinds.Kind.OPERATION_DEFINITION:
  45528. if (!operationName && operation) {
  45529. hasMultipleAssumedOperations = true;
  45530. } else if (!operationName || definition.name && definition.name.value === operationName) {
  45531. operation = definition;
  45532. }
  45533. break;
  45534. case _kinds.Kind.FRAGMENT_DEFINITION:
  45535. fragments[definition.name.value] = definition;
  45536. break;
  45537. }
  45538. }
  45539. if (!operation) {
  45540. if (operationName) {
  45541. errors.push(new _GraphQLError.GraphQLError("Unknown operation named \"".concat(operationName, "\".")));
  45542. } else {
  45543. errors.push(new _GraphQLError.GraphQLError('Must provide an operation.'));
  45544. }
  45545. } else if (hasMultipleAssumedOperations) {
  45546. errors.push(new _GraphQLError.GraphQLError('Must provide operation name if query contains multiple operations.'));
  45547. }
  45548. var variableValues;
  45549. if (operation) {
  45550. var coercedVariableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {});
  45551. if (coercedVariableValues.errors) {
  45552. errors.push.apply(errors, coercedVariableValues.errors);
  45553. } else {
  45554. variableValues = coercedVariableValues.coerced;
  45555. }
  45556. }
  45557. if (errors.length !== 0) {
  45558. return errors;
  45559. }
  45560. !operation ? (0, _invariant.default)(0, 'Has operation if no errors.') : void 0;
  45561. !variableValues ? (0, _invariant.default)(0, 'Has variables if no errors.') : void 0;
  45562. return {
  45563. schema: schema,
  45564. fragments: fragments,
  45565. rootValue: rootValue,
  45566. contextValue: contextValue,
  45567. operation: operation,
  45568. variableValues: variableValues,
  45569. fieldResolver: fieldResolver || defaultFieldResolver,
  45570. errors: errors
  45571. };
  45572. }
  45573. /**
  45574. * Implements the "Evaluating operations" section of the spec.
  45575. */
  45576. function executeOperation(exeContext, operation, rootValue) {
  45577. var type = (0, _getOperationRootType.getOperationRootType)(exeContext.schema, operation);
  45578. var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
  45579. var path = undefined; // Errors from sub-fields of a NonNull type may propagate to the top level,
  45580. // at which point we still log the error and null the parent field, which
  45581. // in this case is the entire response.
  45582. //
  45583. // Similar to completeValueCatchingError.
  45584. try {
  45585. var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
  45586. if ((0, _isPromise.default)(result)) {
  45587. return result.then(undefined, function (error) {
  45588. exeContext.errors.push(error);
  45589. return Promise.resolve(null);
  45590. });
  45591. }
  45592. return result;
  45593. } catch (error) {
  45594. exeContext.errors.push(error);
  45595. return null;
  45596. }
  45597. }
  45598. /**
  45599. * Implements the "Evaluating selection sets" section of the spec
  45600. * for "write" mode.
  45601. */
  45602. function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
  45603. return (0, _promiseReduce.default)(Object.keys(fields), function (results, responseName) {
  45604. var fieldNodes = fields[responseName];
  45605. var fieldPath = addPath(path, responseName);
  45606. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  45607. if (result === undefined) {
  45608. return results;
  45609. }
  45610. if ((0, _isPromise.default)(result)) {
  45611. return result.then(function (resolvedResult) {
  45612. results[responseName] = resolvedResult;
  45613. return results;
  45614. });
  45615. }
  45616. results[responseName] = result;
  45617. return results;
  45618. }, Object.create(null));
  45619. }
  45620. /**
  45621. * Implements the "Evaluating selection sets" section of the spec
  45622. * for "read" mode.
  45623. */
  45624. function executeFields(exeContext, parentType, sourceValue, path, fields) {
  45625. var results = Object.create(null);
  45626. var containsPromise = false;
  45627. for (var i = 0, keys = Object.keys(fields); i < keys.length; ++i) {
  45628. var responseName = keys[i];
  45629. var fieldNodes = fields[responseName];
  45630. var fieldPath = addPath(path, responseName);
  45631. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  45632. if (result !== undefined) {
  45633. results[responseName] = result;
  45634. if (!containsPromise && (0, _isPromise.default)(result)) {
  45635. containsPromise = true;
  45636. }
  45637. }
  45638. } // If there are no promises, we can just return the object
  45639. if (!containsPromise) {
  45640. return results;
  45641. } // Otherwise, results is a map from field name to the result of resolving that
  45642. // field, which is possibly a promise. Return a promise that will return this
  45643. // same map, but with any promises replaced with the values they resolved to.
  45644. return (0, _promiseForObject.default)(results);
  45645. }
  45646. /**
  45647. * Given a selectionSet, adds all of the fields in that selection to
  45648. * the passed in map of fields, and returns it at the end.
  45649. *
  45650. * CollectFields requires the "runtime type" of an object. For a field which
  45651. * returns an Interface or Union type, the "runtime type" will be the actual
  45652. * Object type returned by that field.
  45653. */
  45654. function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
  45655. for (var i = 0; i < selectionSet.selections.length; i++) {
  45656. var selection = selectionSet.selections[i];
  45657. switch (selection.kind) {
  45658. case _kinds.Kind.FIELD:
  45659. if (!shouldIncludeNode(exeContext, selection)) {
  45660. continue;
  45661. }
  45662. var name = getFieldEntryKey(selection);
  45663. if (!fields[name]) {
  45664. fields[name] = [];
  45665. }
  45666. fields[name].push(selection);
  45667. break;
  45668. case _kinds.Kind.INLINE_FRAGMENT:
  45669. if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
  45670. continue;
  45671. }
  45672. collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
  45673. break;
  45674. case _kinds.Kind.FRAGMENT_SPREAD:
  45675. var fragName = selection.name.value;
  45676. if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
  45677. continue;
  45678. }
  45679. visitedFragmentNames[fragName] = true;
  45680. var fragment = exeContext.fragments[fragName];
  45681. if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
  45682. continue;
  45683. }
  45684. collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
  45685. break;
  45686. }
  45687. }
  45688. return fields;
  45689. }
  45690. /**
  45691. * Determines if a field should be included based on the @include and @skip
  45692. * directives, where @skip has higher precedence than @include.
  45693. */
  45694. function shouldIncludeNode(exeContext, node) {
  45695. var skip = (0, _values.getDirectiveValues)(_directives.GraphQLSkipDirective, node, exeContext.variableValues);
  45696. if (skip && skip.if === true) {
  45697. return false;
  45698. }
  45699. var include = (0, _values.getDirectiveValues)(_directives.GraphQLIncludeDirective, node, exeContext.variableValues);
  45700. if (include && include.if === false) {
  45701. return false;
  45702. }
  45703. return true;
  45704. }
  45705. /**
  45706. * Determines if a fragment is applicable to the given type.
  45707. */
  45708. function doesFragmentConditionMatch(exeContext, fragment, type) {
  45709. var typeConditionNode = fragment.typeCondition;
  45710. if (!typeConditionNode) {
  45711. return true;
  45712. }
  45713. var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
  45714. if (conditionalType === type) {
  45715. return true;
  45716. }
  45717. if ((0, _definition.isAbstractType)(conditionalType)) {
  45718. return exeContext.schema.isPossibleType(conditionalType, type);
  45719. }
  45720. return false;
  45721. }
  45722. /**
  45723. * Implements the logic to compute the key of a given field's entry
  45724. */
  45725. function getFieldEntryKey(node) {
  45726. return node.alias ? node.alias.value : node.name.value;
  45727. }
  45728. /**
  45729. * Resolves the field on the given source object. In particular, this
  45730. * figures out the value that the field returns by calling its resolve function,
  45731. * then calls completeValue to complete promises, serialize scalars, or execute
  45732. * the sub-selection-set for objects.
  45733. */
  45734. function resolveField(exeContext, parentType, source, fieldNodes, path) {
  45735. var fieldNode = fieldNodes[0];
  45736. var fieldName = fieldNode.name.value;
  45737. var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
  45738. if (!fieldDef) {
  45739. return;
  45740. }
  45741. var resolveFn = fieldDef.resolve || exeContext.fieldResolver;
  45742. var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
  45743. // or abrupt (error).
  45744. var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
  45745. return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
  45746. }
  45747. function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
  45748. // The resolve function's optional fourth argument is a collection of
  45749. // information about the current execution state.
  45750. return {
  45751. fieldName: fieldDef.name,
  45752. fieldNodes: fieldNodes,
  45753. returnType: fieldDef.type,
  45754. parentType: parentType,
  45755. path: path,
  45756. schema: exeContext.schema,
  45757. fragments: exeContext.fragments,
  45758. rootValue: exeContext.rootValue,
  45759. operation: exeContext.operation,
  45760. variableValues: exeContext.variableValues
  45761. };
  45762. } // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
  45763. // function. Returns the result of resolveFn or the abrupt-return Error object.
  45764. function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
  45765. try {
  45766. // Build a JS object of arguments from the field.arguments AST, using the
  45767. // variables scope to fulfill any variable references.
  45768. // TODO: find a way to memoize, in case this field is within a List type.
  45769. var args = (0, _values.getArgumentValues)(fieldDef, fieldNodes[0], exeContext.variableValues); // The resolve function's optional third argument is a context value that
  45770. // is provided to every resolve function within an execution. It is commonly
  45771. // used to represent an authenticated user, or request-specific caches.
  45772. var _contextValue = exeContext.contextValue;
  45773. var result = resolveFn(source, args, _contextValue, info);
  45774. return (0, _isPromise.default)(result) ? result.then(undefined, asErrorInstance) : result;
  45775. } catch (error) {
  45776. return asErrorInstance(error);
  45777. }
  45778. } // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
  45779. // consistent Error interface.
  45780. function asErrorInstance(error) {
  45781. return error instanceof Error ? error : new Error(error || undefined);
  45782. } // This is a small wrapper around completeValue which detects and logs errors
  45783. // in the execution context.
  45784. function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
  45785. try {
  45786. var completed;
  45787. if ((0, _isPromise.default)(result)) {
  45788. completed = result.then(function (resolved) {
  45789. return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
  45790. });
  45791. } else {
  45792. completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
  45793. }
  45794. if ((0, _isPromise.default)(completed)) {
  45795. // Note: we don't rely on a `catch` method, but we do expect "thenable"
  45796. // to take a second callback for the error case.
  45797. return completed.then(undefined, function (error) {
  45798. return handleFieldError(error, fieldNodes, path, returnType, exeContext);
  45799. });
  45800. }
  45801. return completed;
  45802. } catch (error) {
  45803. return handleFieldError(error, fieldNodes, path, returnType, exeContext);
  45804. }
  45805. }
  45806. function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
  45807. var error = (0, _locatedError.locatedError)(asErrorInstance(rawError), fieldNodes, responsePathAsArray(path)); // If the field type is non-nullable, then it is resolved without any
  45808. // protection from errors, however it still properly locates the error.
  45809. if ((0, _definition.isNonNullType)(returnType)) {
  45810. throw error;
  45811. } // Otherwise, error protection is applied, logging the error and resolving
  45812. // a null value for this field if one is encountered.
  45813. exeContext.errors.push(error);
  45814. return null;
  45815. }
  45816. /**
  45817. * Implements the instructions for completeValue as defined in the
  45818. * "Field entries" section of the spec.
  45819. *
  45820. * If the field type is Non-Null, then this recursively completes the value
  45821. * for the inner type. It throws a field error if that completion returns null,
  45822. * as per the "Nullability" section of the spec.
  45823. *
  45824. * If the field type is a List, then this recursively completes the value
  45825. * for the inner type on each item in the list.
  45826. *
  45827. * If the field type is a Scalar or Enum, ensures the completed value is a legal
  45828. * value of the type by calling the `serialize` method of GraphQL type
  45829. * definition.
  45830. *
  45831. * If the field is an abstract type, determine the runtime type of the value
  45832. * and then complete based on that type
  45833. *
  45834. * Otherwise, the field type expects a sub-selection set, and will complete the
  45835. * value by evaluating all sub-selections.
  45836. */
  45837. function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
  45838. // If result is an Error, throw a located error.
  45839. if (result instanceof Error) {
  45840. throw result;
  45841. } // If field type is NonNull, complete for inner type, and throw field error
  45842. // if result is null.
  45843. if ((0, _definition.isNonNullType)(returnType)) {
  45844. var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
  45845. if (completed === null) {
  45846. throw new Error("Cannot return null for non-nullable field ".concat(info.parentType.name, ".").concat(info.fieldName, "."));
  45847. }
  45848. return completed;
  45849. } // If result value is null-ish (null, undefined, or NaN) then return null.
  45850. if ((0, _isNullish.default)(result)) {
  45851. return null;
  45852. } // If field type is List, complete each item in the list with the inner type
  45853. if ((0, _definition.isListType)(returnType)) {
  45854. return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
  45855. } // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
  45856. // returning null if serialization is not possible.
  45857. if ((0, _definition.isLeafType)(returnType)) {
  45858. return completeLeafValue(returnType, result);
  45859. } // If field type is an abstract type, Interface or Union, determine the
  45860. // runtime Object type and complete for that type.
  45861. if ((0, _definition.isAbstractType)(returnType)) {
  45862. return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
  45863. } // If field type is Object, execute and complete all sub-selections.
  45864. if ((0, _definition.isObjectType)(returnType)) {
  45865. return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
  45866. } // Not reachable. All possible output types have been considered.
  45867. /* istanbul ignore next */
  45868. throw new Error("Cannot complete value of unexpected type \"".concat((0, _inspect.default)(returnType), "\"."));
  45869. }
  45870. /**
  45871. * Complete a list value by completing each item in the list with the
  45872. * inner type
  45873. */
  45874. function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
  45875. !(0, _iterall.isCollection)(result) ? (0, _invariant.default)(0, "Expected Iterable, but did not find one for field ".concat(info.parentType.name, ".").concat(info.fieldName, ".")) : void 0; // This is specified as a simple map, however we're optimizing the path
  45876. // where the list contains no Promises by avoiding creating another Promise.
  45877. var itemType = returnType.ofType;
  45878. var containsPromise = false;
  45879. var completedResults = [];
  45880. (0, _iterall.forEach)(result, function (item, index) {
  45881. // No need to modify the info object containing the path,
  45882. // since from here on it is not ever accessed by resolver functions.
  45883. var fieldPath = addPath(path, index);
  45884. var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
  45885. if (!containsPromise && (0, _isPromise.default)(completedItem)) {
  45886. containsPromise = true;
  45887. }
  45888. completedResults.push(completedItem);
  45889. });
  45890. return containsPromise ? Promise.all(completedResults) : completedResults;
  45891. }
  45892. /**
  45893. * Complete a Scalar or Enum by serializing to a valid value, returning
  45894. * null if serialization is not possible.
  45895. */
  45896. function completeLeafValue(returnType, result) {
  45897. !returnType.serialize ? (0, _invariant.default)(0, 'Missing serialize method on type') : void 0;
  45898. var serializedResult = returnType.serialize(result);
  45899. if ((0, _isInvalid.default)(serializedResult)) {
  45900. throw new Error("Expected a value of type \"".concat((0, _inspect.default)(returnType), "\" but ") + "received: ".concat((0, _inspect.default)(result)));
  45901. }
  45902. return serializedResult;
  45903. }
  45904. /**
  45905. * Complete a value of an abstract type by determining the runtime object type
  45906. * of that value, then complete the value for that type.
  45907. */
  45908. function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
  45909. var runtimeType = returnType.resolveType ? returnType.resolveType(result, exeContext.contextValue, info) : defaultResolveTypeFn(result, exeContext.contextValue, info, returnType);
  45910. if ((0, _isPromise.default)(runtimeType)) {
  45911. return runtimeType.then(function (resolvedRuntimeType) {
  45912. return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  45913. });
  45914. }
  45915. return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  45916. }
  45917. function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
  45918. var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
  45919. if (!(0, _definition.isObjectType)(runtimeType)) {
  45920. throw new _GraphQLError.GraphQLError("Abstract type ".concat(returnType.name, " must resolve to an Object type at ") + "runtime for field ".concat(info.parentType.name, ".").concat(info.fieldName, " with ") + "value ".concat((0, _inspect.default)(result), ", received \"").concat((0, _inspect.default)(runtimeType), "\". ") + "Either the ".concat(returnType.name, " type should provide a \"resolveType\" ") + 'function or each possible type should provide an "isTypeOf" function.', fieldNodes);
  45921. }
  45922. if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
  45923. throw new _GraphQLError.GraphQLError("Runtime Object type \"".concat(runtimeType.name, "\" is not a possible type ") + "for \"".concat(returnType.name, "\"."), fieldNodes);
  45924. }
  45925. return runtimeType;
  45926. }
  45927. /**
  45928. * Complete an Object value by executing all sub-selections.
  45929. */
  45930. function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
  45931. // If there is an isTypeOf predicate function, call it with the
  45932. // current result. If isTypeOf returns false, then raise an error rather
  45933. // than continuing execution.
  45934. if (returnType.isTypeOf) {
  45935. var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
  45936. if ((0, _isPromise.default)(isTypeOf)) {
  45937. return isTypeOf.then(function (resolvedIsTypeOf) {
  45938. if (!resolvedIsTypeOf) {
  45939. throw invalidReturnTypeError(returnType, result, fieldNodes);
  45940. }
  45941. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
  45942. });
  45943. }
  45944. if (!isTypeOf) {
  45945. throw invalidReturnTypeError(returnType, result, fieldNodes);
  45946. }
  45947. }
  45948. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result);
  45949. }
  45950. function invalidReturnTypeError(returnType, result, fieldNodes) {
  45951. return new _GraphQLError.GraphQLError("Expected value of type \"".concat(returnType.name, "\" but got: ").concat((0, _inspect.default)(result), "."), fieldNodes);
  45952. }
  45953. function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, path, result) {
  45954. // Collect sub-fields to execute to complete this value.
  45955. var subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
  45956. return executeFields(exeContext, returnType, result, path, subFieldNodes);
  45957. }
  45958. /**
  45959. * A memoized collection of relevant subfields with regard to the return
  45960. * type. Memoizing ensures the subfields are not repeatedly calculated, which
  45961. * saves overhead when resolving lists of values.
  45962. */
  45963. var collectSubfields = (0, _memoize.default)(_collectSubfields);
  45964. function _collectSubfields(exeContext, returnType, fieldNodes) {
  45965. var subFieldNodes = Object.create(null);
  45966. var visitedFragmentNames = Object.create(null);
  45967. for (var i = 0; i < fieldNodes.length; i++) {
  45968. var selectionSet = fieldNodes[i].selectionSet;
  45969. if (selectionSet) {
  45970. subFieldNodes = collectFields(exeContext, returnType, selectionSet, subFieldNodes, visitedFragmentNames);
  45971. }
  45972. }
  45973. return subFieldNodes;
  45974. }
  45975. /**
  45976. * If a resolveType function is not given, then a default resolve behavior is
  45977. * used which attempts two strategies:
  45978. *
  45979. * First, See if the provided value has a `__typename` field defined, if so, use
  45980. * that value as name of the resolved type.
  45981. *
  45982. * Otherwise, test each possible type for the abstract type by calling
  45983. * isTypeOf for the object being coerced, returning the first type that matches.
  45984. */
  45985. function defaultResolveTypeFn(value, contextValue, info, abstractType) {
  45986. // First, look for `__typename`.
  45987. if (value !== null && _typeof(value) === 'object' && typeof value.__typename === 'string') {
  45988. return value.__typename;
  45989. } // Otherwise, test each possible type.
  45990. var possibleTypes = info.schema.getPossibleTypes(abstractType);
  45991. var promisedIsTypeOfResults = [];
  45992. for (var i = 0; i < possibleTypes.length; i++) {
  45993. var type = possibleTypes[i];
  45994. if (type.isTypeOf) {
  45995. var isTypeOfResult = type.isTypeOf(value, contextValue, info);
  45996. if ((0, _isPromise.default)(isTypeOfResult)) {
  45997. promisedIsTypeOfResults[i] = isTypeOfResult;
  45998. } else if (isTypeOfResult) {
  45999. return type;
  46000. }
  46001. }
  46002. }
  46003. if (promisedIsTypeOfResults.length) {
  46004. return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
  46005. for (var _i = 0; _i < isTypeOfResults.length; _i++) {
  46006. if (isTypeOfResults[_i]) {
  46007. return possibleTypes[_i];
  46008. }
  46009. }
  46010. });
  46011. }
  46012. }
  46013. /**
  46014. * If a resolve function is not given, then a default resolve behavior is used
  46015. * which takes the property of the source object of the same name as the field
  46016. * and returns it as the result, or if it's a function, returns the result
  46017. * of calling that function while passing along args and context value.
  46018. */
  46019. var defaultFieldResolver = function defaultFieldResolver(source, args, contextValue, info) {
  46020. // ensure source is a value for which property access is acceptable.
  46021. if (_typeof(source) === 'object' || typeof source === 'function') {
  46022. var property = source[info.fieldName];
  46023. if (typeof property === 'function') {
  46024. return source[info.fieldName](args, contextValue, info);
  46025. }
  46026. return property;
  46027. }
  46028. };
  46029. /**
  46030. * This method looks up the field on the given type definition.
  46031. * It has special casing for the two introspection fields, __schema
  46032. * and __typename. __typename is special because it can always be
  46033. * queried as a field, even in situations where no other fields
  46034. * are allowed, like on a Union. __schema could get automatically
  46035. * added to the query type, but that would require mutating type
  46036. * definitions, which would cause issues.
  46037. */
  46038. exports.defaultFieldResolver = defaultFieldResolver;
  46039. function getFieldDef(schema, parentType, fieldName) {
  46040. if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  46041. return _introspection.SchemaMetaFieldDef;
  46042. } else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  46043. return _introspection.TypeMetaFieldDef;
  46044. } else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
  46045. return _introspection.TypeNameMetaFieldDef;
  46046. }
  46047. return parentType.getFields()[fieldName];
  46048. }
  46049. },{"../error/GraphQLError":275,"../error/locatedError":278,"../jsutils/inspect":288,"../jsutils/invariant":290,"../jsutils/isInvalid":291,"../jsutils/isNullish":292,"../jsutils/isPromise":293,"../jsutils/memoize3":297,"../jsutils/promiseForObject":300,"../jsutils/promiseReduce":301,"../language/kinds":307,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/validate":329,"../utilities/getOperationRootType":341,"../utilities/typeFromAST":351,"./values":283,"iterall":137}],282:[function(require,module,exports){
  46050. "use strict";
  46051. Object.defineProperty(exports, "__esModule", {
  46052. value: true
  46053. });
  46054. Object.defineProperty(exports, "execute", {
  46055. enumerable: true,
  46056. get: function get() {
  46057. return _execute.execute;
  46058. }
  46059. });
  46060. Object.defineProperty(exports, "defaultFieldResolver", {
  46061. enumerable: true,
  46062. get: function get() {
  46063. return _execute.defaultFieldResolver;
  46064. }
  46065. });
  46066. Object.defineProperty(exports, "responsePathAsArray", {
  46067. enumerable: true,
  46068. get: function get() {
  46069. return _execute.responsePathAsArray;
  46070. }
  46071. });
  46072. Object.defineProperty(exports, "getDirectiveValues", {
  46073. enumerable: true,
  46074. get: function get() {
  46075. return _values.getDirectiveValues;
  46076. }
  46077. });
  46078. var _execute = require("./execute");
  46079. var _values = require("./values");
  46080. },{"./execute":281,"./values":283}],283:[function(require,module,exports){
  46081. "use strict";
  46082. Object.defineProperty(exports, "__esModule", {
  46083. value: true
  46084. });
  46085. exports.getVariableValues = getVariableValues;
  46086. exports.getArgumentValues = getArgumentValues;
  46087. exports.getDirectiveValues = getDirectiveValues;
  46088. var _find = _interopRequireDefault(require("../polyfills/find"));
  46089. var _GraphQLError = require("../error/GraphQLError");
  46090. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  46091. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  46092. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  46093. var _coerceValue = require("../utilities/coerceValue");
  46094. var _typeFromAST = require("../utilities/typeFromAST");
  46095. var _valueFromAST = require("../utilities/valueFromAST");
  46096. var _kinds = require("../language/kinds");
  46097. var _printer = require("../language/printer");
  46098. var _definition = require("../type/definition");
  46099. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  46100. /**
  46101. * Copyright (c) 2015-present, Facebook, Inc.
  46102. *
  46103. * This source code is licensed under the MIT license found in the
  46104. * LICENSE file in the root directory of this source tree.
  46105. *
  46106. *
  46107. */
  46108. /**
  46109. * Prepares an object map of variableValues of the correct type based on the
  46110. * provided variable definitions and arbitrary input. If the input cannot be
  46111. * parsed to match the variable definitions, a GraphQLError will be thrown.
  46112. *
  46113. * Note: The returned value is a plain Object with a prototype, since it is
  46114. * exposed to user code. Care should be taken to not pull values from the
  46115. * Object prototype.
  46116. */
  46117. function getVariableValues(schema, varDefNodes, inputs) {
  46118. var errors = [];
  46119. var coercedValues = {};
  46120. for (var i = 0; i < varDefNodes.length; i++) {
  46121. var varDefNode = varDefNodes[i];
  46122. var varName = varDefNode.variable.name.value;
  46123. var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
  46124. if (!(0, _definition.isInputType)(varType)) {
  46125. // Must use input types for variables. This should be caught during
  46126. // validation, however is checked again here for safety.
  46127. errors.push(new _GraphQLError.GraphQLError("Variable \"$".concat(varName, "\" expected value of type ") + "\"".concat((0, _printer.print)(varDefNode.type), "\" which cannot be used as an input type."), [varDefNode.type]));
  46128. } else {
  46129. var hasValue = hasOwnProperty(inputs, varName);
  46130. var value = hasValue ? inputs[varName] : undefined;
  46131. if (!hasValue && varDefNode.defaultValue) {
  46132. // If no value was provided to a variable with a default value,
  46133. // use the default value.
  46134. coercedValues[varName] = (0, _valueFromAST.valueFromAST)(varDefNode.defaultValue, varType);
  46135. } else if ((!hasValue || value === null) && (0, _definition.isNonNullType)(varType)) {
  46136. // If no value or a nullish value was provided to a variable with a
  46137. // non-null type (required), produce an error.
  46138. errors.push(new _GraphQLError.GraphQLError(hasValue ? "Variable \"$".concat(varName, "\" of non-null type ") + "\"".concat((0, _inspect.default)(varType), "\" must not be null.") : "Variable \"$".concat(varName, "\" of required type ") + "\"".concat((0, _inspect.default)(varType), "\" was not provided."), [varDefNode]));
  46139. } else if (hasValue) {
  46140. if (value === null) {
  46141. // If the explicit value `null` was provided, an entry in the coerced
  46142. // values must exist as the value `null`.
  46143. coercedValues[varName] = null;
  46144. } else {
  46145. // Otherwise, a non-null value was provided, coerce it to the expected
  46146. // type or report an error if coercion fails.
  46147. var coerced = (0, _coerceValue.coerceValue)(value, varType, varDefNode);
  46148. var coercionErrors = coerced.errors;
  46149. if (coercionErrors) {
  46150. var _iteratorNormalCompletion = true;
  46151. var _didIteratorError = false;
  46152. var _iteratorError = undefined;
  46153. try {
  46154. for (var _iterator = coercionErrors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  46155. var error = _step.value;
  46156. error.message = "Variable \"$".concat(varName, "\" got invalid value ").concat((0, _inspect.default)(value), "; ") + error.message;
  46157. }
  46158. } catch (err) {
  46159. _didIteratorError = true;
  46160. _iteratorError = err;
  46161. } finally {
  46162. try {
  46163. if (!_iteratorNormalCompletion && _iterator.return != null) {
  46164. _iterator.return();
  46165. }
  46166. } finally {
  46167. if (_didIteratorError) {
  46168. throw _iteratorError;
  46169. }
  46170. }
  46171. }
  46172. errors.push.apply(errors, coercionErrors);
  46173. } else {
  46174. coercedValues[varName] = coerced.value;
  46175. }
  46176. }
  46177. }
  46178. }
  46179. }
  46180. return errors.length === 0 ? {
  46181. errors: undefined,
  46182. coerced: coercedValues
  46183. } : {
  46184. errors: errors,
  46185. coerced: undefined
  46186. };
  46187. }
  46188. /**
  46189. * Prepares an object map of argument values given a list of argument
  46190. * definitions and list of argument AST nodes.
  46191. *
  46192. * Note: The returned value is a plain Object with a prototype, since it is
  46193. * exposed to user code. Care should be taken to not pull values from the
  46194. * Object prototype.
  46195. */
  46196. function getArgumentValues(def, node, variableValues) {
  46197. var coercedValues = {};
  46198. var argDefs = def.args;
  46199. var argNodes = node.arguments;
  46200. if (!argDefs || !argNodes) {
  46201. return coercedValues;
  46202. }
  46203. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  46204. return arg.name.value;
  46205. });
  46206. for (var i = 0; i < argDefs.length; i++) {
  46207. var argDef = argDefs[i];
  46208. var name = argDef.name;
  46209. var argType = argDef.type;
  46210. var argumentNode = argNodeMap[name];
  46211. var hasValue = void 0;
  46212. var isNull = void 0;
  46213. if (argumentNode && argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  46214. var variableName = argumentNode.value.name.value;
  46215. hasValue = variableValues && hasOwnProperty(variableValues, variableName);
  46216. isNull = variableValues && variableValues[variableName] === null;
  46217. } else {
  46218. hasValue = argumentNode != null;
  46219. isNull = argumentNode && argumentNode.value.kind === _kinds.Kind.NULL;
  46220. }
  46221. if (!hasValue && argDef.defaultValue !== undefined) {
  46222. // If no argument was provided where the definition has a default value,
  46223. // use the default value.
  46224. coercedValues[name] = argDef.defaultValue;
  46225. } else if ((!hasValue || isNull) && (0, _definition.isNonNullType)(argType)) {
  46226. // If no argument or a null value was provided to an argument with a
  46227. // non-null type (required), produce a field error.
  46228. if (isNull) {
  46229. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat((0, _inspect.default)(argType), "\" ") + 'must not be null.', [argumentNode.value]);
  46230. } else if (argumentNode && argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  46231. var _variableName = argumentNode.value.name.value;
  46232. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + "was provided the variable \"$".concat(_variableName, "\" ") + 'which was not provided a runtime value.', [argumentNode.value]);
  46233. } else {
  46234. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" of required type \"").concat((0, _inspect.default)(argType), "\" ") + 'was not provided.', [node]);
  46235. }
  46236. } else if (hasValue) {
  46237. if (argumentNode.value.kind === _kinds.Kind.NULL) {
  46238. // If the explicit value `null` was provided, an entry in the coerced
  46239. // values must exist as the value `null`.
  46240. coercedValues[name] = null;
  46241. } else if (argumentNode.value.kind === _kinds.Kind.VARIABLE) {
  46242. var _variableName2 = argumentNode.value.name.value;
  46243. !variableValues ? (0, _invariant.default)(0, 'Must exist for hasValue to be true.') : void 0; // Note: This does no further checking that this variable is correct.
  46244. // This assumes that this query has been validated and the variable
  46245. // usage here is of the correct type.
  46246. coercedValues[name] = variableValues[_variableName2];
  46247. } else {
  46248. var valueNode = argumentNode.value;
  46249. var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
  46250. if (coercedValue === undefined) {
  46251. // Note: ValuesOfCorrectType validation should catch this before
  46252. // execution. This is a runtime check to ensure execution does not
  46253. // continue with an invalid argument value.
  46254. throw new _GraphQLError.GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat((0, _printer.print)(valueNode), "."), [argumentNode.value]);
  46255. }
  46256. coercedValues[name] = coercedValue;
  46257. }
  46258. }
  46259. }
  46260. return coercedValues;
  46261. }
  46262. /**
  46263. * Prepares an object map of argument values given a directive definition
  46264. * and a AST node which may contain directives. Optionally also accepts a map
  46265. * of variable values.
  46266. *
  46267. * If the directive does not exist on the node, returns undefined.
  46268. *
  46269. * Note: The returned value is a plain Object with a prototype, since it is
  46270. * exposed to user code. Care should be taken to not pull values from the
  46271. * Object prototype.
  46272. */
  46273. function getDirectiveValues(directiveDef, node, variableValues) {
  46274. var directiveNode = node.directives && (0, _find.default)(node.directives, function (directive) {
  46275. return directive.name.value === directiveDef.name;
  46276. });
  46277. if (directiveNode) {
  46278. return getArgumentValues(directiveDef, directiveNode, variableValues);
  46279. }
  46280. }
  46281. function hasOwnProperty(obj, prop) {
  46282. return Object.prototype.hasOwnProperty.call(obj, prop);
  46283. }
  46284. },{"../error/GraphQLError":275,"../jsutils/inspect":288,"../jsutils/invariant":290,"../jsutils/keyMap":294,"../language/kinds":307,"../language/printer":312,"../polyfills/find":315,"../type/definition":323,"../utilities/coerceValue":335,"../utilities/typeFromAST":351,"../utilities/valueFromAST":352}],284:[function(require,module,exports){
  46285. "use strict";
  46286. Object.defineProperty(exports, "__esModule", {
  46287. value: true
  46288. });
  46289. exports.graphql = graphql;
  46290. exports.graphqlSync = graphqlSync;
  46291. var _validate = require("./type/validate");
  46292. var _parser = require("./language/parser");
  46293. var _validate2 = require("./validation/validate");
  46294. var _execute = require("./execution/execute");
  46295. /**
  46296. * Copyright (c) 2015-present, Facebook, Inc.
  46297. *
  46298. * This source code is licensed under the MIT license found in the
  46299. * LICENSE file in the root directory of this source tree.
  46300. *
  46301. *
  46302. */
  46303. function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  46304. var _arguments = arguments;
  46305. /* eslint-enable no-redeclare */
  46306. // Always return a Promise for a consistent API.
  46307. return new Promise(function (resolve) {
  46308. return resolve( // Extract arguments from object args if provided.
  46309. _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver));
  46310. });
  46311. }
  46312. /**
  46313. * The graphqlSync function also fulfills GraphQL operations by parsing,
  46314. * validating, and executing a GraphQL document along side a GraphQL schema.
  46315. * However, it guarantees to complete synchronously (or throw an error) assuming
  46316. * that all field resolvers are also synchronous.
  46317. */
  46318. function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  46319. /* eslint-enable no-redeclare */
  46320. // Extract arguments from object args if provided.
  46321. var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver); // Assert that the execution was synchronous.
  46322. if (result.then) {
  46323. throw new Error('GraphQL execution failed to complete synchronously.');
  46324. }
  46325. return result;
  46326. }
  46327. function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  46328. // Validate Schema
  46329. var schemaValidationErrors = (0, _validate.validateSchema)(schema);
  46330. if (schemaValidationErrors.length > 0) {
  46331. return {
  46332. errors: schemaValidationErrors
  46333. };
  46334. } // Parse
  46335. var document;
  46336. try {
  46337. document = (0, _parser.parse)(source);
  46338. } catch (syntaxError) {
  46339. return {
  46340. errors: [syntaxError]
  46341. };
  46342. } // Validate
  46343. var validationErrors = (0, _validate2.validate)(schema, document);
  46344. if (validationErrors.length > 0) {
  46345. return {
  46346. errors: validationErrors
  46347. };
  46348. } // Execute
  46349. return (0, _execute.execute)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
  46350. }
  46351. },{"./execution/execute":281,"./language/parser":310,"./type/validate":329,"./validation/validate":390}],285:[function(require,module,exports){
  46352. "use strict";
  46353. Object.defineProperty(exports, "__esModule", {
  46354. value: true
  46355. });
  46356. Object.defineProperty(exports, "graphql", {
  46357. enumerable: true,
  46358. get: function get() {
  46359. return _graphql.graphql;
  46360. }
  46361. });
  46362. Object.defineProperty(exports, "graphqlSync", {
  46363. enumerable: true,
  46364. get: function get() {
  46365. return _graphql.graphqlSync;
  46366. }
  46367. });
  46368. Object.defineProperty(exports, "GraphQLSchema", {
  46369. enumerable: true,
  46370. get: function get() {
  46371. return _type.GraphQLSchema;
  46372. }
  46373. });
  46374. Object.defineProperty(exports, "GraphQLScalarType", {
  46375. enumerable: true,
  46376. get: function get() {
  46377. return _type.GraphQLScalarType;
  46378. }
  46379. });
  46380. Object.defineProperty(exports, "GraphQLObjectType", {
  46381. enumerable: true,
  46382. get: function get() {
  46383. return _type.GraphQLObjectType;
  46384. }
  46385. });
  46386. Object.defineProperty(exports, "GraphQLInterfaceType", {
  46387. enumerable: true,
  46388. get: function get() {
  46389. return _type.GraphQLInterfaceType;
  46390. }
  46391. });
  46392. Object.defineProperty(exports, "GraphQLUnionType", {
  46393. enumerable: true,
  46394. get: function get() {
  46395. return _type.GraphQLUnionType;
  46396. }
  46397. });
  46398. Object.defineProperty(exports, "GraphQLEnumType", {
  46399. enumerable: true,
  46400. get: function get() {
  46401. return _type.GraphQLEnumType;
  46402. }
  46403. });
  46404. Object.defineProperty(exports, "GraphQLInputObjectType", {
  46405. enumerable: true,
  46406. get: function get() {
  46407. return _type.GraphQLInputObjectType;
  46408. }
  46409. });
  46410. Object.defineProperty(exports, "GraphQLList", {
  46411. enumerable: true,
  46412. get: function get() {
  46413. return _type.GraphQLList;
  46414. }
  46415. });
  46416. Object.defineProperty(exports, "GraphQLNonNull", {
  46417. enumerable: true,
  46418. get: function get() {
  46419. return _type.GraphQLNonNull;
  46420. }
  46421. });
  46422. Object.defineProperty(exports, "GraphQLDirective", {
  46423. enumerable: true,
  46424. get: function get() {
  46425. return _type.GraphQLDirective;
  46426. }
  46427. });
  46428. Object.defineProperty(exports, "TypeKind", {
  46429. enumerable: true,
  46430. get: function get() {
  46431. return _type.TypeKind;
  46432. }
  46433. });
  46434. Object.defineProperty(exports, "specifiedScalarTypes", {
  46435. enumerable: true,
  46436. get: function get() {
  46437. return _type.specifiedScalarTypes;
  46438. }
  46439. });
  46440. Object.defineProperty(exports, "GraphQLInt", {
  46441. enumerable: true,
  46442. get: function get() {
  46443. return _type.GraphQLInt;
  46444. }
  46445. });
  46446. Object.defineProperty(exports, "GraphQLFloat", {
  46447. enumerable: true,
  46448. get: function get() {
  46449. return _type.GraphQLFloat;
  46450. }
  46451. });
  46452. Object.defineProperty(exports, "GraphQLString", {
  46453. enumerable: true,
  46454. get: function get() {
  46455. return _type.GraphQLString;
  46456. }
  46457. });
  46458. Object.defineProperty(exports, "GraphQLBoolean", {
  46459. enumerable: true,
  46460. get: function get() {
  46461. return _type.GraphQLBoolean;
  46462. }
  46463. });
  46464. Object.defineProperty(exports, "GraphQLID", {
  46465. enumerable: true,
  46466. get: function get() {
  46467. return _type.GraphQLID;
  46468. }
  46469. });
  46470. Object.defineProperty(exports, "specifiedDirectives", {
  46471. enumerable: true,
  46472. get: function get() {
  46473. return _type.specifiedDirectives;
  46474. }
  46475. });
  46476. Object.defineProperty(exports, "GraphQLIncludeDirective", {
  46477. enumerable: true,
  46478. get: function get() {
  46479. return _type.GraphQLIncludeDirective;
  46480. }
  46481. });
  46482. Object.defineProperty(exports, "GraphQLSkipDirective", {
  46483. enumerable: true,
  46484. get: function get() {
  46485. return _type.GraphQLSkipDirective;
  46486. }
  46487. });
  46488. Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
  46489. enumerable: true,
  46490. get: function get() {
  46491. return _type.GraphQLDeprecatedDirective;
  46492. }
  46493. });
  46494. Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", {
  46495. enumerable: true,
  46496. get: function get() {
  46497. return _type.DEFAULT_DEPRECATION_REASON;
  46498. }
  46499. });
  46500. Object.defineProperty(exports, "SchemaMetaFieldDef", {
  46501. enumerable: true,
  46502. get: function get() {
  46503. return _type.SchemaMetaFieldDef;
  46504. }
  46505. });
  46506. Object.defineProperty(exports, "TypeMetaFieldDef", {
  46507. enumerable: true,
  46508. get: function get() {
  46509. return _type.TypeMetaFieldDef;
  46510. }
  46511. });
  46512. Object.defineProperty(exports, "TypeNameMetaFieldDef", {
  46513. enumerable: true,
  46514. get: function get() {
  46515. return _type.TypeNameMetaFieldDef;
  46516. }
  46517. });
  46518. Object.defineProperty(exports, "introspectionTypes", {
  46519. enumerable: true,
  46520. get: function get() {
  46521. return _type.introspectionTypes;
  46522. }
  46523. });
  46524. Object.defineProperty(exports, "__Schema", {
  46525. enumerable: true,
  46526. get: function get() {
  46527. return _type.__Schema;
  46528. }
  46529. });
  46530. Object.defineProperty(exports, "__Directive", {
  46531. enumerable: true,
  46532. get: function get() {
  46533. return _type.__Directive;
  46534. }
  46535. });
  46536. Object.defineProperty(exports, "__DirectiveLocation", {
  46537. enumerable: true,
  46538. get: function get() {
  46539. return _type.__DirectiveLocation;
  46540. }
  46541. });
  46542. Object.defineProperty(exports, "__Type", {
  46543. enumerable: true,
  46544. get: function get() {
  46545. return _type.__Type;
  46546. }
  46547. });
  46548. Object.defineProperty(exports, "__Field", {
  46549. enumerable: true,
  46550. get: function get() {
  46551. return _type.__Field;
  46552. }
  46553. });
  46554. Object.defineProperty(exports, "__InputValue", {
  46555. enumerable: true,
  46556. get: function get() {
  46557. return _type.__InputValue;
  46558. }
  46559. });
  46560. Object.defineProperty(exports, "__EnumValue", {
  46561. enumerable: true,
  46562. get: function get() {
  46563. return _type.__EnumValue;
  46564. }
  46565. });
  46566. Object.defineProperty(exports, "__TypeKind", {
  46567. enumerable: true,
  46568. get: function get() {
  46569. return _type.__TypeKind;
  46570. }
  46571. });
  46572. Object.defineProperty(exports, "isSchema", {
  46573. enumerable: true,
  46574. get: function get() {
  46575. return _type.isSchema;
  46576. }
  46577. });
  46578. Object.defineProperty(exports, "isDirective", {
  46579. enumerable: true,
  46580. get: function get() {
  46581. return _type.isDirective;
  46582. }
  46583. });
  46584. Object.defineProperty(exports, "isType", {
  46585. enumerable: true,
  46586. get: function get() {
  46587. return _type.isType;
  46588. }
  46589. });
  46590. Object.defineProperty(exports, "isScalarType", {
  46591. enumerable: true,
  46592. get: function get() {
  46593. return _type.isScalarType;
  46594. }
  46595. });
  46596. Object.defineProperty(exports, "isObjectType", {
  46597. enumerable: true,
  46598. get: function get() {
  46599. return _type.isObjectType;
  46600. }
  46601. });
  46602. Object.defineProperty(exports, "isInterfaceType", {
  46603. enumerable: true,
  46604. get: function get() {
  46605. return _type.isInterfaceType;
  46606. }
  46607. });
  46608. Object.defineProperty(exports, "isUnionType", {
  46609. enumerable: true,
  46610. get: function get() {
  46611. return _type.isUnionType;
  46612. }
  46613. });
  46614. Object.defineProperty(exports, "isEnumType", {
  46615. enumerable: true,
  46616. get: function get() {
  46617. return _type.isEnumType;
  46618. }
  46619. });
  46620. Object.defineProperty(exports, "isInputObjectType", {
  46621. enumerable: true,
  46622. get: function get() {
  46623. return _type.isInputObjectType;
  46624. }
  46625. });
  46626. Object.defineProperty(exports, "isListType", {
  46627. enumerable: true,
  46628. get: function get() {
  46629. return _type.isListType;
  46630. }
  46631. });
  46632. Object.defineProperty(exports, "isNonNullType", {
  46633. enumerable: true,
  46634. get: function get() {
  46635. return _type.isNonNullType;
  46636. }
  46637. });
  46638. Object.defineProperty(exports, "isInputType", {
  46639. enumerable: true,
  46640. get: function get() {
  46641. return _type.isInputType;
  46642. }
  46643. });
  46644. Object.defineProperty(exports, "isOutputType", {
  46645. enumerable: true,
  46646. get: function get() {
  46647. return _type.isOutputType;
  46648. }
  46649. });
  46650. Object.defineProperty(exports, "isLeafType", {
  46651. enumerable: true,
  46652. get: function get() {
  46653. return _type.isLeafType;
  46654. }
  46655. });
  46656. Object.defineProperty(exports, "isCompositeType", {
  46657. enumerable: true,
  46658. get: function get() {
  46659. return _type.isCompositeType;
  46660. }
  46661. });
  46662. Object.defineProperty(exports, "isAbstractType", {
  46663. enumerable: true,
  46664. get: function get() {
  46665. return _type.isAbstractType;
  46666. }
  46667. });
  46668. Object.defineProperty(exports, "isWrappingType", {
  46669. enumerable: true,
  46670. get: function get() {
  46671. return _type.isWrappingType;
  46672. }
  46673. });
  46674. Object.defineProperty(exports, "isNullableType", {
  46675. enumerable: true,
  46676. get: function get() {
  46677. return _type.isNullableType;
  46678. }
  46679. });
  46680. Object.defineProperty(exports, "isNamedType", {
  46681. enumerable: true,
  46682. get: function get() {
  46683. return _type.isNamedType;
  46684. }
  46685. });
  46686. Object.defineProperty(exports, "isRequiredArgument", {
  46687. enumerable: true,
  46688. get: function get() {
  46689. return _type.isRequiredArgument;
  46690. }
  46691. });
  46692. Object.defineProperty(exports, "isRequiredInputField", {
  46693. enumerable: true,
  46694. get: function get() {
  46695. return _type.isRequiredInputField;
  46696. }
  46697. });
  46698. Object.defineProperty(exports, "isSpecifiedScalarType", {
  46699. enumerable: true,
  46700. get: function get() {
  46701. return _type.isSpecifiedScalarType;
  46702. }
  46703. });
  46704. Object.defineProperty(exports, "isIntrospectionType", {
  46705. enumerable: true,
  46706. get: function get() {
  46707. return _type.isIntrospectionType;
  46708. }
  46709. });
  46710. Object.defineProperty(exports, "isSpecifiedDirective", {
  46711. enumerable: true,
  46712. get: function get() {
  46713. return _type.isSpecifiedDirective;
  46714. }
  46715. });
  46716. Object.defineProperty(exports, "assertSchema", {
  46717. enumerable: true,
  46718. get: function get() {
  46719. return _type.assertSchema;
  46720. }
  46721. });
  46722. Object.defineProperty(exports, "assertDirective", {
  46723. enumerable: true,
  46724. get: function get() {
  46725. return _type.assertDirective;
  46726. }
  46727. });
  46728. Object.defineProperty(exports, "assertType", {
  46729. enumerable: true,
  46730. get: function get() {
  46731. return _type.assertType;
  46732. }
  46733. });
  46734. Object.defineProperty(exports, "assertScalarType", {
  46735. enumerable: true,
  46736. get: function get() {
  46737. return _type.assertScalarType;
  46738. }
  46739. });
  46740. Object.defineProperty(exports, "assertObjectType", {
  46741. enumerable: true,
  46742. get: function get() {
  46743. return _type.assertObjectType;
  46744. }
  46745. });
  46746. Object.defineProperty(exports, "assertInterfaceType", {
  46747. enumerable: true,
  46748. get: function get() {
  46749. return _type.assertInterfaceType;
  46750. }
  46751. });
  46752. Object.defineProperty(exports, "assertUnionType", {
  46753. enumerable: true,
  46754. get: function get() {
  46755. return _type.assertUnionType;
  46756. }
  46757. });
  46758. Object.defineProperty(exports, "assertEnumType", {
  46759. enumerable: true,
  46760. get: function get() {
  46761. return _type.assertEnumType;
  46762. }
  46763. });
  46764. Object.defineProperty(exports, "assertInputObjectType", {
  46765. enumerable: true,
  46766. get: function get() {
  46767. return _type.assertInputObjectType;
  46768. }
  46769. });
  46770. Object.defineProperty(exports, "assertListType", {
  46771. enumerable: true,
  46772. get: function get() {
  46773. return _type.assertListType;
  46774. }
  46775. });
  46776. Object.defineProperty(exports, "assertNonNullType", {
  46777. enumerable: true,
  46778. get: function get() {
  46779. return _type.assertNonNullType;
  46780. }
  46781. });
  46782. Object.defineProperty(exports, "assertInputType", {
  46783. enumerable: true,
  46784. get: function get() {
  46785. return _type.assertInputType;
  46786. }
  46787. });
  46788. Object.defineProperty(exports, "assertOutputType", {
  46789. enumerable: true,
  46790. get: function get() {
  46791. return _type.assertOutputType;
  46792. }
  46793. });
  46794. Object.defineProperty(exports, "assertLeafType", {
  46795. enumerable: true,
  46796. get: function get() {
  46797. return _type.assertLeafType;
  46798. }
  46799. });
  46800. Object.defineProperty(exports, "assertCompositeType", {
  46801. enumerable: true,
  46802. get: function get() {
  46803. return _type.assertCompositeType;
  46804. }
  46805. });
  46806. Object.defineProperty(exports, "assertAbstractType", {
  46807. enumerable: true,
  46808. get: function get() {
  46809. return _type.assertAbstractType;
  46810. }
  46811. });
  46812. Object.defineProperty(exports, "assertWrappingType", {
  46813. enumerable: true,
  46814. get: function get() {
  46815. return _type.assertWrappingType;
  46816. }
  46817. });
  46818. Object.defineProperty(exports, "assertNullableType", {
  46819. enumerable: true,
  46820. get: function get() {
  46821. return _type.assertNullableType;
  46822. }
  46823. });
  46824. Object.defineProperty(exports, "assertNamedType", {
  46825. enumerable: true,
  46826. get: function get() {
  46827. return _type.assertNamedType;
  46828. }
  46829. });
  46830. Object.defineProperty(exports, "getNullableType", {
  46831. enumerable: true,
  46832. get: function get() {
  46833. return _type.getNullableType;
  46834. }
  46835. });
  46836. Object.defineProperty(exports, "getNamedType", {
  46837. enumerable: true,
  46838. get: function get() {
  46839. return _type.getNamedType;
  46840. }
  46841. });
  46842. Object.defineProperty(exports, "validateSchema", {
  46843. enumerable: true,
  46844. get: function get() {
  46845. return _type.validateSchema;
  46846. }
  46847. });
  46848. Object.defineProperty(exports, "assertValidSchema", {
  46849. enumerable: true,
  46850. get: function get() {
  46851. return _type.assertValidSchema;
  46852. }
  46853. });
  46854. Object.defineProperty(exports, "Source", {
  46855. enumerable: true,
  46856. get: function get() {
  46857. return _language.Source;
  46858. }
  46859. });
  46860. Object.defineProperty(exports, "getLocation", {
  46861. enumerable: true,
  46862. get: function get() {
  46863. return _language.getLocation;
  46864. }
  46865. });
  46866. Object.defineProperty(exports, "parse", {
  46867. enumerable: true,
  46868. get: function get() {
  46869. return _language.parse;
  46870. }
  46871. });
  46872. Object.defineProperty(exports, "parseValue", {
  46873. enumerable: true,
  46874. get: function get() {
  46875. return _language.parseValue;
  46876. }
  46877. });
  46878. Object.defineProperty(exports, "parseType", {
  46879. enumerable: true,
  46880. get: function get() {
  46881. return _language.parseType;
  46882. }
  46883. });
  46884. Object.defineProperty(exports, "print", {
  46885. enumerable: true,
  46886. get: function get() {
  46887. return _language.print;
  46888. }
  46889. });
  46890. Object.defineProperty(exports, "visit", {
  46891. enumerable: true,
  46892. get: function get() {
  46893. return _language.visit;
  46894. }
  46895. });
  46896. Object.defineProperty(exports, "visitInParallel", {
  46897. enumerable: true,
  46898. get: function get() {
  46899. return _language.visitInParallel;
  46900. }
  46901. });
  46902. Object.defineProperty(exports, "visitWithTypeInfo", {
  46903. enumerable: true,
  46904. get: function get() {
  46905. return _language.visitWithTypeInfo;
  46906. }
  46907. });
  46908. Object.defineProperty(exports, "getVisitFn", {
  46909. enumerable: true,
  46910. get: function get() {
  46911. return _language.getVisitFn;
  46912. }
  46913. });
  46914. Object.defineProperty(exports, "Kind", {
  46915. enumerable: true,
  46916. get: function get() {
  46917. return _language.Kind;
  46918. }
  46919. });
  46920. Object.defineProperty(exports, "TokenKind", {
  46921. enumerable: true,
  46922. get: function get() {
  46923. return _language.TokenKind;
  46924. }
  46925. });
  46926. Object.defineProperty(exports, "DirectiveLocation", {
  46927. enumerable: true,
  46928. get: function get() {
  46929. return _language.DirectiveLocation;
  46930. }
  46931. });
  46932. Object.defineProperty(exports, "BREAK", {
  46933. enumerable: true,
  46934. get: function get() {
  46935. return _language.BREAK;
  46936. }
  46937. });
  46938. Object.defineProperty(exports, "isDefinitionNode", {
  46939. enumerable: true,
  46940. get: function get() {
  46941. return _language.isDefinitionNode;
  46942. }
  46943. });
  46944. Object.defineProperty(exports, "isExecutableDefinitionNode", {
  46945. enumerable: true,
  46946. get: function get() {
  46947. return _language.isExecutableDefinitionNode;
  46948. }
  46949. });
  46950. Object.defineProperty(exports, "isSelectionNode", {
  46951. enumerable: true,
  46952. get: function get() {
  46953. return _language.isSelectionNode;
  46954. }
  46955. });
  46956. Object.defineProperty(exports, "isValueNode", {
  46957. enumerable: true,
  46958. get: function get() {
  46959. return _language.isValueNode;
  46960. }
  46961. });
  46962. Object.defineProperty(exports, "isTypeNode", {
  46963. enumerable: true,
  46964. get: function get() {
  46965. return _language.isTypeNode;
  46966. }
  46967. });
  46968. Object.defineProperty(exports, "isTypeSystemDefinitionNode", {
  46969. enumerable: true,
  46970. get: function get() {
  46971. return _language.isTypeSystemDefinitionNode;
  46972. }
  46973. });
  46974. Object.defineProperty(exports, "isTypeDefinitionNode", {
  46975. enumerable: true,
  46976. get: function get() {
  46977. return _language.isTypeDefinitionNode;
  46978. }
  46979. });
  46980. Object.defineProperty(exports, "isTypeSystemExtensionNode", {
  46981. enumerable: true,
  46982. get: function get() {
  46983. return _language.isTypeSystemExtensionNode;
  46984. }
  46985. });
  46986. Object.defineProperty(exports, "isTypeExtensionNode", {
  46987. enumerable: true,
  46988. get: function get() {
  46989. return _language.isTypeExtensionNode;
  46990. }
  46991. });
  46992. Object.defineProperty(exports, "execute", {
  46993. enumerable: true,
  46994. get: function get() {
  46995. return _execution.execute;
  46996. }
  46997. });
  46998. Object.defineProperty(exports, "defaultFieldResolver", {
  46999. enumerable: true,
  47000. get: function get() {
  47001. return _execution.defaultFieldResolver;
  47002. }
  47003. });
  47004. Object.defineProperty(exports, "responsePathAsArray", {
  47005. enumerable: true,
  47006. get: function get() {
  47007. return _execution.responsePathAsArray;
  47008. }
  47009. });
  47010. Object.defineProperty(exports, "getDirectiveValues", {
  47011. enumerable: true,
  47012. get: function get() {
  47013. return _execution.getDirectiveValues;
  47014. }
  47015. });
  47016. Object.defineProperty(exports, "subscribe", {
  47017. enumerable: true,
  47018. get: function get() {
  47019. return _subscription.subscribe;
  47020. }
  47021. });
  47022. Object.defineProperty(exports, "createSourceEventStream", {
  47023. enumerable: true,
  47024. get: function get() {
  47025. return _subscription.createSourceEventStream;
  47026. }
  47027. });
  47028. Object.defineProperty(exports, "validate", {
  47029. enumerable: true,
  47030. get: function get() {
  47031. return _validation.validate;
  47032. }
  47033. });
  47034. Object.defineProperty(exports, "ValidationContext", {
  47035. enumerable: true,
  47036. get: function get() {
  47037. return _validation.ValidationContext;
  47038. }
  47039. });
  47040. Object.defineProperty(exports, "specifiedRules", {
  47041. enumerable: true,
  47042. get: function get() {
  47043. return _validation.specifiedRules;
  47044. }
  47045. });
  47046. Object.defineProperty(exports, "FieldsOnCorrectTypeRule", {
  47047. enumerable: true,
  47048. get: function get() {
  47049. return _validation.FieldsOnCorrectTypeRule;
  47050. }
  47051. });
  47052. Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", {
  47053. enumerable: true,
  47054. get: function get() {
  47055. return _validation.FragmentsOnCompositeTypesRule;
  47056. }
  47057. });
  47058. Object.defineProperty(exports, "KnownArgumentNamesRule", {
  47059. enumerable: true,
  47060. get: function get() {
  47061. return _validation.KnownArgumentNamesRule;
  47062. }
  47063. });
  47064. Object.defineProperty(exports, "KnownDirectivesRule", {
  47065. enumerable: true,
  47066. get: function get() {
  47067. return _validation.KnownDirectivesRule;
  47068. }
  47069. });
  47070. Object.defineProperty(exports, "KnownFragmentNamesRule", {
  47071. enumerable: true,
  47072. get: function get() {
  47073. return _validation.KnownFragmentNamesRule;
  47074. }
  47075. });
  47076. Object.defineProperty(exports, "KnownTypeNamesRule", {
  47077. enumerable: true,
  47078. get: function get() {
  47079. return _validation.KnownTypeNamesRule;
  47080. }
  47081. });
  47082. Object.defineProperty(exports, "LoneAnonymousOperationRule", {
  47083. enumerable: true,
  47084. get: function get() {
  47085. return _validation.LoneAnonymousOperationRule;
  47086. }
  47087. });
  47088. Object.defineProperty(exports, "NoFragmentCyclesRule", {
  47089. enumerable: true,
  47090. get: function get() {
  47091. return _validation.NoFragmentCyclesRule;
  47092. }
  47093. });
  47094. Object.defineProperty(exports, "NoUndefinedVariablesRule", {
  47095. enumerable: true,
  47096. get: function get() {
  47097. return _validation.NoUndefinedVariablesRule;
  47098. }
  47099. });
  47100. Object.defineProperty(exports, "NoUnusedFragmentsRule", {
  47101. enumerable: true,
  47102. get: function get() {
  47103. return _validation.NoUnusedFragmentsRule;
  47104. }
  47105. });
  47106. Object.defineProperty(exports, "NoUnusedVariablesRule", {
  47107. enumerable: true,
  47108. get: function get() {
  47109. return _validation.NoUnusedVariablesRule;
  47110. }
  47111. });
  47112. Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", {
  47113. enumerable: true,
  47114. get: function get() {
  47115. return _validation.OverlappingFieldsCanBeMergedRule;
  47116. }
  47117. });
  47118. Object.defineProperty(exports, "PossibleFragmentSpreadsRule", {
  47119. enumerable: true,
  47120. get: function get() {
  47121. return _validation.PossibleFragmentSpreadsRule;
  47122. }
  47123. });
  47124. Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", {
  47125. enumerable: true,
  47126. get: function get() {
  47127. return _validation.ProvidedRequiredArgumentsRule;
  47128. }
  47129. });
  47130. Object.defineProperty(exports, "ScalarLeafsRule", {
  47131. enumerable: true,
  47132. get: function get() {
  47133. return _validation.ScalarLeafsRule;
  47134. }
  47135. });
  47136. Object.defineProperty(exports, "SingleFieldSubscriptionsRule", {
  47137. enumerable: true,
  47138. get: function get() {
  47139. return _validation.SingleFieldSubscriptionsRule;
  47140. }
  47141. });
  47142. Object.defineProperty(exports, "UniqueArgumentNamesRule", {
  47143. enumerable: true,
  47144. get: function get() {
  47145. return _validation.UniqueArgumentNamesRule;
  47146. }
  47147. });
  47148. Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", {
  47149. enumerable: true,
  47150. get: function get() {
  47151. return _validation.UniqueDirectivesPerLocationRule;
  47152. }
  47153. });
  47154. Object.defineProperty(exports, "UniqueFragmentNamesRule", {
  47155. enumerable: true,
  47156. get: function get() {
  47157. return _validation.UniqueFragmentNamesRule;
  47158. }
  47159. });
  47160. Object.defineProperty(exports, "UniqueInputFieldNamesRule", {
  47161. enumerable: true,
  47162. get: function get() {
  47163. return _validation.UniqueInputFieldNamesRule;
  47164. }
  47165. });
  47166. Object.defineProperty(exports, "UniqueOperationNamesRule", {
  47167. enumerable: true,
  47168. get: function get() {
  47169. return _validation.UniqueOperationNamesRule;
  47170. }
  47171. });
  47172. Object.defineProperty(exports, "UniqueVariableNamesRule", {
  47173. enumerable: true,
  47174. get: function get() {
  47175. return _validation.UniqueVariableNamesRule;
  47176. }
  47177. });
  47178. Object.defineProperty(exports, "ValuesOfCorrectTypeRule", {
  47179. enumerable: true,
  47180. get: function get() {
  47181. return _validation.ValuesOfCorrectTypeRule;
  47182. }
  47183. });
  47184. Object.defineProperty(exports, "VariablesAreInputTypesRule", {
  47185. enumerable: true,
  47186. get: function get() {
  47187. return _validation.VariablesAreInputTypesRule;
  47188. }
  47189. });
  47190. Object.defineProperty(exports, "VariablesInAllowedPositionRule", {
  47191. enumerable: true,
  47192. get: function get() {
  47193. return _validation.VariablesInAllowedPositionRule;
  47194. }
  47195. });
  47196. Object.defineProperty(exports, "GraphQLError", {
  47197. enumerable: true,
  47198. get: function get() {
  47199. return _error.GraphQLError;
  47200. }
  47201. });
  47202. Object.defineProperty(exports, "formatError", {
  47203. enumerable: true,
  47204. get: function get() {
  47205. return _error.formatError;
  47206. }
  47207. });
  47208. Object.defineProperty(exports, "printError", {
  47209. enumerable: true,
  47210. get: function get() {
  47211. return _error.printError;
  47212. }
  47213. });
  47214. Object.defineProperty(exports, "getIntrospectionQuery", {
  47215. enumerable: true,
  47216. get: function get() {
  47217. return _utilities.getIntrospectionQuery;
  47218. }
  47219. });
  47220. Object.defineProperty(exports, "introspectionQuery", {
  47221. enumerable: true,
  47222. get: function get() {
  47223. return _utilities.introspectionQuery;
  47224. }
  47225. });
  47226. Object.defineProperty(exports, "getOperationAST", {
  47227. enumerable: true,
  47228. get: function get() {
  47229. return _utilities.getOperationAST;
  47230. }
  47231. });
  47232. Object.defineProperty(exports, "getOperationRootType", {
  47233. enumerable: true,
  47234. get: function get() {
  47235. return _utilities.getOperationRootType;
  47236. }
  47237. });
  47238. Object.defineProperty(exports, "introspectionFromSchema", {
  47239. enumerable: true,
  47240. get: function get() {
  47241. return _utilities.introspectionFromSchema;
  47242. }
  47243. });
  47244. Object.defineProperty(exports, "buildClientSchema", {
  47245. enumerable: true,
  47246. get: function get() {
  47247. return _utilities.buildClientSchema;
  47248. }
  47249. });
  47250. Object.defineProperty(exports, "buildASTSchema", {
  47251. enumerable: true,
  47252. get: function get() {
  47253. return _utilities.buildASTSchema;
  47254. }
  47255. });
  47256. Object.defineProperty(exports, "buildSchema", {
  47257. enumerable: true,
  47258. get: function get() {
  47259. return _utilities.buildSchema;
  47260. }
  47261. });
  47262. Object.defineProperty(exports, "getDescription", {
  47263. enumerable: true,
  47264. get: function get() {
  47265. return _utilities.getDescription;
  47266. }
  47267. });
  47268. Object.defineProperty(exports, "extendSchema", {
  47269. enumerable: true,
  47270. get: function get() {
  47271. return _utilities.extendSchema;
  47272. }
  47273. });
  47274. Object.defineProperty(exports, "lexicographicSortSchema", {
  47275. enumerable: true,
  47276. get: function get() {
  47277. return _utilities.lexicographicSortSchema;
  47278. }
  47279. });
  47280. Object.defineProperty(exports, "printSchema", {
  47281. enumerable: true,
  47282. get: function get() {
  47283. return _utilities.printSchema;
  47284. }
  47285. });
  47286. Object.defineProperty(exports, "printIntrospectionSchema", {
  47287. enumerable: true,
  47288. get: function get() {
  47289. return _utilities.printIntrospectionSchema;
  47290. }
  47291. });
  47292. Object.defineProperty(exports, "printType", {
  47293. enumerable: true,
  47294. get: function get() {
  47295. return _utilities.printType;
  47296. }
  47297. });
  47298. Object.defineProperty(exports, "typeFromAST", {
  47299. enumerable: true,
  47300. get: function get() {
  47301. return _utilities.typeFromAST;
  47302. }
  47303. });
  47304. Object.defineProperty(exports, "valueFromAST", {
  47305. enumerable: true,
  47306. get: function get() {
  47307. return _utilities.valueFromAST;
  47308. }
  47309. });
  47310. Object.defineProperty(exports, "valueFromASTUntyped", {
  47311. enumerable: true,
  47312. get: function get() {
  47313. return _utilities.valueFromASTUntyped;
  47314. }
  47315. });
  47316. Object.defineProperty(exports, "astFromValue", {
  47317. enumerable: true,
  47318. get: function get() {
  47319. return _utilities.astFromValue;
  47320. }
  47321. });
  47322. Object.defineProperty(exports, "TypeInfo", {
  47323. enumerable: true,
  47324. get: function get() {
  47325. return _utilities.TypeInfo;
  47326. }
  47327. });
  47328. Object.defineProperty(exports, "coerceValue", {
  47329. enumerable: true,
  47330. get: function get() {
  47331. return _utilities.coerceValue;
  47332. }
  47333. });
  47334. Object.defineProperty(exports, "isValidJSValue", {
  47335. enumerable: true,
  47336. get: function get() {
  47337. return _utilities.isValidJSValue;
  47338. }
  47339. });
  47340. Object.defineProperty(exports, "isValidLiteralValue", {
  47341. enumerable: true,
  47342. get: function get() {
  47343. return _utilities.isValidLiteralValue;
  47344. }
  47345. });
  47346. Object.defineProperty(exports, "concatAST", {
  47347. enumerable: true,
  47348. get: function get() {
  47349. return _utilities.concatAST;
  47350. }
  47351. });
  47352. Object.defineProperty(exports, "separateOperations", {
  47353. enumerable: true,
  47354. get: function get() {
  47355. return _utilities.separateOperations;
  47356. }
  47357. });
  47358. Object.defineProperty(exports, "isEqualType", {
  47359. enumerable: true,
  47360. get: function get() {
  47361. return _utilities.isEqualType;
  47362. }
  47363. });
  47364. Object.defineProperty(exports, "isTypeSubTypeOf", {
  47365. enumerable: true,
  47366. get: function get() {
  47367. return _utilities.isTypeSubTypeOf;
  47368. }
  47369. });
  47370. Object.defineProperty(exports, "doTypesOverlap", {
  47371. enumerable: true,
  47372. get: function get() {
  47373. return _utilities.doTypesOverlap;
  47374. }
  47375. });
  47376. Object.defineProperty(exports, "assertValidName", {
  47377. enumerable: true,
  47378. get: function get() {
  47379. return _utilities.assertValidName;
  47380. }
  47381. });
  47382. Object.defineProperty(exports, "isValidNameError", {
  47383. enumerable: true,
  47384. get: function get() {
  47385. return _utilities.isValidNameError;
  47386. }
  47387. });
  47388. Object.defineProperty(exports, "findBreakingChanges", {
  47389. enumerable: true,
  47390. get: function get() {
  47391. return _utilities.findBreakingChanges;
  47392. }
  47393. });
  47394. Object.defineProperty(exports, "findDangerousChanges", {
  47395. enumerable: true,
  47396. get: function get() {
  47397. return _utilities.findDangerousChanges;
  47398. }
  47399. });
  47400. Object.defineProperty(exports, "BreakingChangeType", {
  47401. enumerable: true,
  47402. get: function get() {
  47403. return _utilities.BreakingChangeType;
  47404. }
  47405. });
  47406. Object.defineProperty(exports, "DangerousChangeType", {
  47407. enumerable: true,
  47408. get: function get() {
  47409. return _utilities.DangerousChangeType;
  47410. }
  47411. });
  47412. Object.defineProperty(exports, "findDeprecatedUsages", {
  47413. enumerable: true,
  47414. get: function get() {
  47415. return _utilities.findDeprecatedUsages;
  47416. }
  47417. });
  47418. var _graphql = require("./graphql");
  47419. var _type = require("./type");
  47420. var _language = require("./language");
  47421. var _execution = require("./execution");
  47422. var _subscription = require("./subscription");
  47423. var _validation = require("./validation");
  47424. var _error = require("./error");
  47425. var _utilities = require("./utilities");
  47426. },{"./error":277,"./execution":282,"./graphql":284,"./language":306,"./subscription":320,"./type":325,"./utilities":342,"./validation":355}],286:[function(require,module,exports){
  47427. "use strict";
  47428. Object.defineProperty(exports, "__esModule", {
  47429. value: true
  47430. });
  47431. exports.default = defineToJSON;
  47432. var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
  47433. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47434. /**
  47435. * Copyright (c) 2015-present, Facebook, Inc.
  47436. *
  47437. * This source code is licensed under the MIT license found in the
  47438. * LICENSE file in the root directory of this source tree.
  47439. *
  47440. *
  47441. */
  47442. /**
  47443. * The `defineToJSON()` function defines toJSON() and inspect() prototype
  47444. * methods, if no function provided they become aliases for toString().
  47445. */
  47446. function defineToJSON( // eslint-disable-next-line flowtype/no-weak-types
  47447. classObject) {
  47448. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : classObject.prototype.toString;
  47449. classObject.prototype.toJSON = fn;
  47450. classObject.prototype.inspect = fn;
  47451. if (_nodejsCustomInspectSymbol.default) {
  47452. classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
  47453. }
  47454. }
  47455. },{"./nodejsCustomInspectSymbol":298}],287:[function(require,module,exports){
  47456. "use strict";
  47457. Object.defineProperty(exports, "__esModule", {
  47458. value: true
  47459. });
  47460. exports.default = defineToStringTag;
  47461. /**
  47462. * Copyright (c) 2015-present, Facebook, Inc.
  47463. *
  47464. * This source code is licensed under the MIT license found in the
  47465. * LICENSE file in the root directory of this source tree.
  47466. *
  47467. *
  47468. */
  47469. /**
  47470. * The `defineToStringTag()` function checks first to see if the runtime
  47471. * supports the `Symbol` class and then if the `Symbol.toStringTag` constant
  47472. * is defined as a `Symbol` instance. If both conditions are met, the
  47473. * Symbol.toStringTag property is defined as a getter that returns the
  47474. * supplied class constructor's name.
  47475. *
  47476. * @method defineToStringTag
  47477. *
  47478. * @param {Class<any>} classObject a class such as Object, String, Number but
  47479. * typically one of your own creation through the class keyword; `class A {}`,
  47480. * for example.
  47481. */
  47482. function defineToStringTag(classObject) {
  47483. if (typeof Symbol === 'function' && Symbol.toStringTag) {
  47484. Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
  47485. get: function get() {
  47486. return this.constructor.name;
  47487. }
  47488. });
  47489. }
  47490. }
  47491. },{}],288:[function(require,module,exports){
  47492. "use strict";
  47493. Object.defineProperty(exports, "__esModule", {
  47494. value: true
  47495. });
  47496. exports.default = inspect;
  47497. var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
  47498. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47499. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  47500. /**
  47501. * Used to print values in error messages.
  47502. */
  47503. function inspect(value) {
  47504. switch (_typeof(value)) {
  47505. case 'string':
  47506. return JSON.stringify(value);
  47507. case 'function':
  47508. return value.name ? "[function ".concat(value.name, "]") : '[function]';
  47509. case 'object':
  47510. if (value) {
  47511. var customInspectFn = getCustomFn(value);
  47512. if (customInspectFn) {
  47513. // $FlowFixMe(>=0.90.0)
  47514. var customValue = customInspectFn.call(value);
  47515. return typeof customValue === 'string' ? customValue : inspect(customValue);
  47516. } else if (Array.isArray(value)) {
  47517. return '[' + value.map(inspect).join(', ') + ']';
  47518. }
  47519. var properties = Object.keys(value).map(function (k) {
  47520. return "".concat(k, ": ").concat(inspect(value[k]));
  47521. }).join(', ');
  47522. return properties ? '{ ' + properties + ' }' : '{}';
  47523. }
  47524. return String(value);
  47525. default:
  47526. return String(value);
  47527. }
  47528. }
  47529. function getCustomFn(object) {
  47530. var customInspectFn = object[String(_nodejsCustomInspectSymbol.default)];
  47531. if (typeof customInspectFn === 'function') {
  47532. return customInspectFn;
  47533. }
  47534. if (typeof object.inspect === 'function') {
  47535. return object.inspect;
  47536. }
  47537. }
  47538. },{"./nodejsCustomInspectSymbol":298}],289:[function(require,module,exports){
  47539. (function (process){
  47540. "use strict";
  47541. Object.defineProperty(exports, "__esModule", {
  47542. value: true
  47543. });
  47544. exports.default = void 0;
  47545. /**
  47546. * Copyright (c) 2015-present, Facebook, Inc.
  47547. *
  47548. * This source code is licensed under the MIT license found in the
  47549. * LICENSE file in the root directory of this source tree.
  47550. *
  47551. *
  47552. */
  47553. /**
  47554. * A replacement for instanceof which includes an error warning when multi-realm
  47555. * constructors are detected.
  47556. */
  47557. // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
  47558. // See: https://webpack.js.org/guides/production/
  47559. var _default = process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
  47560. function instanceOf(value, constructor) {
  47561. return value instanceof constructor;
  47562. } : // eslint-disable-next-line no-shadow
  47563. function instanceOf(value, constructor) {
  47564. if (value instanceof constructor) {
  47565. return true;
  47566. }
  47567. if (value) {
  47568. var valueClass = value.constructor;
  47569. var className = constructor.name;
  47570. if (className && valueClass && valueClass.name === className) {
  47571. throw new Error("Cannot use ".concat(className, " \"").concat(value, "\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results."));
  47572. }
  47573. }
  47574. return false;
  47575. };
  47576. exports.default = _default;
  47577. }).call(this,require('_process'))
  47578. },{"_process":198}],290:[function(require,module,exports){
  47579. "use strict";
  47580. Object.defineProperty(exports, "__esModule", {
  47581. value: true
  47582. });
  47583. exports.default = invariant;
  47584. /**
  47585. * Copyright (c) 2015-present, Facebook, Inc.
  47586. *
  47587. * This source code is licensed under the MIT license found in the
  47588. * LICENSE file in the root directory of this source tree.
  47589. *
  47590. *
  47591. */
  47592. function invariant(condition, message) {
  47593. /* istanbul ignore else */
  47594. if (!condition) {
  47595. throw new Error(message);
  47596. }
  47597. }
  47598. },{}],291:[function(require,module,exports){
  47599. "use strict";
  47600. Object.defineProperty(exports, "__esModule", {
  47601. value: true
  47602. });
  47603. exports.default = isInvalid;
  47604. /**
  47605. * Copyright (c) 2015-present, Facebook, Inc.
  47606. *
  47607. * This source code is licensed under the MIT license found in the
  47608. * LICENSE file in the root directory of this source tree.
  47609. *
  47610. *
  47611. */
  47612. /**
  47613. * Returns true if a value is undefined, or NaN.
  47614. */
  47615. function isInvalid(value) {
  47616. return value === undefined || value !== value;
  47617. }
  47618. },{}],292:[function(require,module,exports){
  47619. "use strict";
  47620. Object.defineProperty(exports, "__esModule", {
  47621. value: true
  47622. });
  47623. exports.default = isNullish;
  47624. /**
  47625. * Copyright (c) 2015-present, Facebook, Inc.
  47626. *
  47627. * This source code is licensed under the MIT license found in the
  47628. * LICENSE file in the root directory of this source tree.
  47629. *
  47630. *
  47631. */
  47632. /**
  47633. * Returns true if a value is null, undefined, or NaN.
  47634. */
  47635. function isNullish(value) {
  47636. return value === null || value === undefined || value !== value;
  47637. }
  47638. },{}],293:[function(require,module,exports){
  47639. "use strict";
  47640. Object.defineProperty(exports, "__esModule", {
  47641. value: true
  47642. });
  47643. exports.default = isPromise;
  47644. /**
  47645. * Copyright (c) 2015-present, Facebook, Inc.
  47646. *
  47647. * This source code is licensed under the MIT license found in the
  47648. * LICENSE file in the root directory of this source tree.
  47649. *
  47650. *
  47651. */
  47652. /**
  47653. * Returns true if the value acts like a Promise, i.e. has a "then" function,
  47654. * otherwise returns false.
  47655. */
  47656. // eslint-disable-next-line no-redeclare
  47657. function isPromise(value) {
  47658. return Boolean(value && typeof value.then === 'function');
  47659. }
  47660. },{}],294:[function(require,module,exports){
  47661. "use strict";
  47662. Object.defineProperty(exports, "__esModule", {
  47663. value: true
  47664. });
  47665. exports.default = keyMap;
  47666. /**
  47667. * Copyright (c) 2015-present, Facebook, Inc.
  47668. *
  47669. * This source code is licensed under the MIT license found in the
  47670. * LICENSE file in the root directory of this source tree.
  47671. *
  47672. *
  47673. */
  47674. /**
  47675. * Creates a keyed JS object from an array, given a function to produce the keys
  47676. * for each value in the array.
  47677. *
  47678. * This provides a convenient lookup for the array items if the key function
  47679. * produces unique results.
  47680. *
  47681. * const phoneBook = [
  47682. * { name: 'Jon', num: '555-1234' },
  47683. * { name: 'Jenny', num: '867-5309' }
  47684. * ]
  47685. *
  47686. * // { Jon: { name: 'Jon', num: '555-1234' },
  47687. * // Jenny: { name: 'Jenny', num: '867-5309' } }
  47688. * const entriesByName = keyMap(
  47689. * phoneBook,
  47690. * entry => entry.name
  47691. * )
  47692. *
  47693. * // { name: 'Jenny', num: '857-6309' }
  47694. * const jennyEntry = entriesByName['Jenny']
  47695. *
  47696. */
  47697. function keyMap(list, keyFn) {
  47698. return list.reduce(function (map, item) {
  47699. return map[keyFn(item)] = item, map;
  47700. }, Object.create(null));
  47701. }
  47702. },{}],295:[function(require,module,exports){
  47703. "use strict";
  47704. Object.defineProperty(exports, "__esModule", {
  47705. value: true
  47706. });
  47707. exports.default = keyValMap;
  47708. /**
  47709. * Copyright (c) 2015-present, Facebook, Inc.
  47710. *
  47711. * This source code is licensed under the MIT license found in the
  47712. * LICENSE file in the root directory of this source tree.
  47713. *
  47714. *
  47715. */
  47716. /**
  47717. * Creates a keyed JS object from an array, given a function to produce the keys
  47718. * and a function to produce the values from each item in the array.
  47719. *
  47720. * const phoneBook = [
  47721. * { name: 'Jon', num: '555-1234' },
  47722. * { name: 'Jenny', num: '867-5309' }
  47723. * ]
  47724. *
  47725. * // { Jon: '555-1234', Jenny: '867-5309' }
  47726. * const phonesByName = keyValMap(
  47727. * phoneBook,
  47728. * entry => entry.name,
  47729. * entry => entry.num
  47730. * )
  47731. *
  47732. */
  47733. function keyValMap(list, keyFn, valFn) {
  47734. return list.reduce(function (map, item) {
  47735. return map[keyFn(item)] = valFn(item), map;
  47736. }, Object.create(null));
  47737. }
  47738. },{}],296:[function(require,module,exports){
  47739. "use strict";
  47740. Object.defineProperty(exports, "__esModule", {
  47741. value: true
  47742. });
  47743. exports.default = mapValue;
  47744. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  47745. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47746. /**
  47747. * Copyright (c) 2019-present, Facebook, Inc.
  47748. *
  47749. * This source code is licensed under the MIT license found in the
  47750. * LICENSE file in the root directory of this source tree.
  47751. *
  47752. *
  47753. */
  47754. /**
  47755. * Creates an object map with the same keys as `map` and values generated by
  47756. * running each value of `map` thru `fn`.
  47757. */
  47758. function mapValue(map, fn) {
  47759. var result = Object.create(null);
  47760. var _iteratorNormalCompletion = true;
  47761. var _didIteratorError = false;
  47762. var _iteratorError = undefined;
  47763. try {
  47764. for (var _iterator = (0, _objectEntries.default)(map)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  47765. var _ref2 = _step.value;
  47766. var _key = _ref2[0];
  47767. var _value = _ref2[1];
  47768. result[_key] = fn(_value, _key);
  47769. }
  47770. } catch (err) {
  47771. _didIteratorError = true;
  47772. _iteratorError = err;
  47773. } finally {
  47774. try {
  47775. if (!_iteratorNormalCompletion && _iterator.return != null) {
  47776. _iterator.return();
  47777. }
  47778. } finally {
  47779. if (_didIteratorError) {
  47780. throw _iteratorError;
  47781. }
  47782. }
  47783. }
  47784. return result;
  47785. }
  47786. },{"../polyfills/objectEntries":318}],297:[function(require,module,exports){
  47787. "use strict";
  47788. Object.defineProperty(exports, "__esModule", {
  47789. value: true
  47790. });
  47791. exports.default = memoize3;
  47792. /**
  47793. * Copyright (c) 2017-present, Facebook, Inc.
  47794. *
  47795. * This source code is licensed under the MIT license found in the
  47796. * LICENSE file in the root directory of this source tree.
  47797. *
  47798. *
  47799. */
  47800. /**
  47801. * Memoizes the provided three-argument function.
  47802. */
  47803. function memoize3(fn) {
  47804. var cache0;
  47805. function memoized(a1, a2, a3) {
  47806. if (!cache0) {
  47807. cache0 = new WeakMap();
  47808. }
  47809. var cache1 = cache0.get(a1);
  47810. var cache2;
  47811. if (cache1) {
  47812. cache2 = cache1.get(a2);
  47813. if (cache2) {
  47814. var cachedValue = cache2.get(a3);
  47815. if (cachedValue !== undefined) {
  47816. return cachedValue;
  47817. }
  47818. }
  47819. } else {
  47820. cache1 = new WeakMap();
  47821. cache0.set(a1, cache1);
  47822. }
  47823. if (!cache2) {
  47824. cache2 = new WeakMap();
  47825. cache1.set(a2, cache2);
  47826. }
  47827. var newValue = fn.apply(this, arguments);
  47828. cache2.set(a3, newValue);
  47829. return newValue;
  47830. }
  47831. return memoized;
  47832. }
  47833. },{}],298:[function(require,module,exports){
  47834. "use strict";
  47835. Object.defineProperty(exports, "__esModule", {
  47836. value: true
  47837. });
  47838. exports.default = void 0;
  47839. /**
  47840. * Copyright (c) 2018-present, Facebook, Inc.
  47841. *
  47842. * This source code is licensed under the MIT license found in the
  47843. * LICENSE file in the root directory of this source tree.
  47844. *
  47845. *
  47846. */
  47847. var nodejsCustomInspectSymbol = typeof Symbol === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
  47848. var _default = nodejsCustomInspectSymbol;
  47849. exports.default = _default;
  47850. },{}],299:[function(require,module,exports){
  47851. "use strict";
  47852. Object.defineProperty(exports, "__esModule", {
  47853. value: true
  47854. });
  47855. exports.default = orList;
  47856. var _invariant = _interopRequireDefault(require("./invariant"));
  47857. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47858. /**
  47859. * Copyright (c) 2015-present, Facebook, Inc.
  47860. *
  47861. * This source code is licensed under the MIT license found in the
  47862. * LICENSE file in the root directory of this source tree.
  47863. *
  47864. *
  47865. */
  47866. var MAX_LENGTH = 5;
  47867. /**
  47868. * Given [ A, B, C ] return 'A, B, or C'.
  47869. */
  47870. function orList(items) {
  47871. !(items.length !== 0) ? (0, _invariant.default)(0) : void 0;
  47872. if (items.length === 1) {
  47873. return items[0];
  47874. }
  47875. if (items.length === 2) {
  47876. return items[0] + ' or ' + items[1];
  47877. }
  47878. var selected = items.slice(0, MAX_LENGTH);
  47879. var lastItem = selected.pop();
  47880. return selected.join(', ') + ', or ' + lastItem;
  47881. }
  47882. },{"./invariant":290}],300:[function(require,module,exports){
  47883. "use strict";
  47884. Object.defineProperty(exports, "__esModule", {
  47885. value: true
  47886. });
  47887. exports.default = promiseForObject;
  47888. /**
  47889. * Copyright (c) 2015-present, Facebook, Inc.
  47890. *
  47891. * This source code is licensed under the MIT license found in the
  47892. * LICENSE file in the root directory of this source tree.
  47893. *
  47894. *
  47895. */
  47896. /**
  47897. * This function transforms a JS object `ObjMap<Promise<T>>` into
  47898. * a `Promise<ObjMap<T>>`
  47899. *
  47900. * This is akin to bluebird's `Promise.props`, but implemented only using
  47901. * `Promise.all` so it will work with any implementation of ES6 promises.
  47902. */
  47903. function promiseForObject(object) {
  47904. var keys = Object.keys(object);
  47905. var valuesAndPromises = keys.map(function (name) {
  47906. return object[name];
  47907. });
  47908. return Promise.all(valuesAndPromises).then(function (values) {
  47909. return values.reduce(function (resolvedObject, value, i) {
  47910. resolvedObject[keys[i]] = value;
  47911. return resolvedObject;
  47912. }, Object.create(null));
  47913. });
  47914. }
  47915. },{}],301:[function(require,module,exports){
  47916. "use strict";
  47917. Object.defineProperty(exports, "__esModule", {
  47918. value: true
  47919. });
  47920. exports.default = promiseReduce;
  47921. var _isPromise = _interopRequireDefault(require("./isPromise"));
  47922. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47923. /**
  47924. * Copyright (c) 2015-present, Facebook, Inc.
  47925. *
  47926. * This source code is licensed under the MIT license found in the
  47927. * LICENSE file in the root directory of this source tree.
  47928. *
  47929. *
  47930. */
  47931. /**
  47932. * Similar to Array.prototype.reduce(), however the reducing callback may return
  47933. * a Promise, in which case reduction will continue after each promise resolves.
  47934. *
  47935. * If the callback does not return a Promise, then this function will also not
  47936. * return a Promise.
  47937. */
  47938. function promiseReduce(values, callback, initialValue) {
  47939. return values.reduce(function (previous, value) {
  47940. return (0, _isPromise.default)(previous) ? previous.then(function (resolved) {
  47941. return callback(resolved, value);
  47942. }) : callback(previous, value);
  47943. }, initialValue);
  47944. }
  47945. },{"./isPromise":293}],302:[function(require,module,exports){
  47946. "use strict";
  47947. Object.defineProperty(exports, "__esModule", {
  47948. value: true
  47949. });
  47950. exports.default = quotedOrList;
  47951. var _orList = _interopRequireDefault(require("./orList"));
  47952. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  47953. /**
  47954. * Copyright (c) 2015-present, Facebook, Inc.
  47955. *
  47956. * This source code is licensed under the MIT license found in the
  47957. * LICENSE file in the root directory of this source tree.
  47958. *
  47959. *
  47960. */
  47961. /**
  47962. * Given [ A, B, C ] return '"A", "B", or "C"'.
  47963. */
  47964. function quotedOrList(items) {
  47965. return (0, _orList.default)(items.map(function (item) {
  47966. return "\"".concat(item, "\"");
  47967. }));
  47968. }
  47969. },{"./orList":299}],303:[function(require,module,exports){
  47970. "use strict";
  47971. Object.defineProperty(exports, "__esModule", {
  47972. value: true
  47973. });
  47974. exports.default = suggestionList;
  47975. /**
  47976. * Copyright (c) 2015-present, Facebook, Inc.
  47977. *
  47978. * This source code is licensed under the MIT license found in the
  47979. * LICENSE file in the root directory of this source tree.
  47980. *
  47981. *
  47982. */
  47983. /**
  47984. * Given an invalid input string and a list of valid options, returns a filtered
  47985. * list of valid options sorted based on their similarity with the input.
  47986. */
  47987. function suggestionList(input, options) {
  47988. var optionsByDistance = Object.create(null);
  47989. var oLength = options.length;
  47990. var inputThreshold = input.length / 2;
  47991. for (var i = 0; i < oLength; i++) {
  47992. var distance = lexicalDistance(input, options[i]);
  47993. var threshold = Math.max(inputThreshold, options[i].length / 2, 1);
  47994. if (distance <= threshold) {
  47995. optionsByDistance[options[i]] = distance;
  47996. }
  47997. }
  47998. return Object.keys(optionsByDistance).sort(function (a, b) {
  47999. return optionsByDistance[a] - optionsByDistance[b];
  48000. });
  48001. }
  48002. /**
  48003. * Computes the lexical distance between strings A and B.
  48004. *
  48005. * The "distance" between two strings is given by counting the minimum number
  48006. * of edits needed to transform string A into string B. An edit can be an
  48007. * insertion, deletion, or substitution of a single character, or a swap of two
  48008. * adjacent characters.
  48009. *
  48010. * Includes a custom alteration from Damerau-Levenshtein to treat case changes
  48011. * as a single edit which helps identify mis-cased values with an edit distance
  48012. * of 1.
  48013. *
  48014. * This distance can be useful for detecting typos in input or sorting
  48015. *
  48016. * @param {string} a
  48017. * @param {string} b
  48018. * @return {int} distance in number of edits
  48019. */
  48020. function lexicalDistance(aStr, bStr) {
  48021. if (aStr === bStr) {
  48022. return 0;
  48023. }
  48024. var i;
  48025. var j;
  48026. var d = [];
  48027. var a = aStr.toLowerCase();
  48028. var b = bStr.toLowerCase();
  48029. var aLength = a.length;
  48030. var bLength = b.length; // Any case change counts as a single edit
  48031. if (a === b) {
  48032. return 1;
  48033. }
  48034. for (i = 0; i <= aLength; i++) {
  48035. d[i] = [i];
  48036. }
  48037. for (j = 1; j <= bLength; j++) {
  48038. d[0][j] = j;
  48039. }
  48040. for (i = 1; i <= aLength; i++) {
  48041. for (j = 1; j <= bLength; j++) {
  48042. var cost = a[i - 1] === b[j - 1] ? 0 : 1;
  48043. d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
  48044. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  48045. d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
  48046. }
  48047. }
  48048. }
  48049. return d[aLength][bLength];
  48050. }
  48051. },{}],304:[function(require,module,exports){
  48052. "use strict";
  48053. Object.defineProperty(exports, "__esModule", {
  48054. value: true
  48055. });
  48056. exports.default = blockStringValue;
  48057. /**
  48058. * Copyright (c) 2015-present, Facebook, Inc.
  48059. *
  48060. * This source code is licensed under the MIT license found in the
  48061. * LICENSE file in the root directory of this source tree.
  48062. *
  48063. *
  48064. */
  48065. /**
  48066. * Produces the value of a block string from its parsed raw value, similar to
  48067. * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
  48068. *
  48069. * This implements the GraphQL spec's BlockStringValue() static algorithm.
  48070. */
  48071. function blockStringValue(rawString) {
  48072. // Expand a block string's raw value into independent lines.
  48073. var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
  48074. var commonIndent = null;
  48075. for (var i = 1; i < lines.length; i++) {
  48076. var line = lines[i];
  48077. var indent = leadingWhitespace(line);
  48078. if (indent < line.length && (commonIndent === null || indent < commonIndent)) {
  48079. commonIndent = indent;
  48080. if (commonIndent === 0) {
  48081. break;
  48082. }
  48083. }
  48084. }
  48085. if (commonIndent) {
  48086. for (var _i = 1; _i < lines.length; _i++) {
  48087. lines[_i] = lines[_i].slice(commonIndent);
  48088. }
  48089. } // Remove leading and trailing blank lines.
  48090. while (lines.length > 0 && isBlank(lines[0])) {
  48091. lines.shift();
  48092. }
  48093. while (lines.length > 0 && isBlank(lines[lines.length - 1])) {
  48094. lines.pop();
  48095. } // Return a string of the lines joined with U+000A.
  48096. return lines.join('\n');
  48097. }
  48098. function leadingWhitespace(str) {
  48099. var i = 0;
  48100. while (i < str.length && (str[i] === ' ' || str[i] === '\t')) {
  48101. i++;
  48102. }
  48103. return i;
  48104. }
  48105. function isBlank(str) {
  48106. return leadingWhitespace(str) === str.length;
  48107. }
  48108. },{}],305:[function(require,module,exports){
  48109. "use strict";
  48110. Object.defineProperty(exports, "__esModule", {
  48111. value: true
  48112. });
  48113. exports.DirectiveLocation = void 0;
  48114. /**
  48115. * Copyright (c) 2015-present, Facebook, Inc.
  48116. *
  48117. * This source code is licensed under the MIT license found in the
  48118. * LICENSE file in the root directory of this source tree.
  48119. *
  48120. *
  48121. */
  48122. /**
  48123. * The set of allowed directive location values.
  48124. */
  48125. var DirectiveLocation = Object.freeze({
  48126. // Request Definitions
  48127. QUERY: 'QUERY',
  48128. MUTATION: 'MUTATION',
  48129. SUBSCRIPTION: 'SUBSCRIPTION',
  48130. FIELD: 'FIELD',
  48131. FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
  48132. FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
  48133. INLINE_FRAGMENT: 'INLINE_FRAGMENT',
  48134. VARIABLE_DEFINITION: 'VARIABLE_DEFINITION',
  48135. // Type System Definitions
  48136. SCHEMA: 'SCHEMA',
  48137. SCALAR: 'SCALAR',
  48138. OBJECT: 'OBJECT',
  48139. FIELD_DEFINITION: 'FIELD_DEFINITION',
  48140. ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
  48141. INTERFACE: 'INTERFACE',
  48142. UNION: 'UNION',
  48143. ENUM: 'ENUM',
  48144. ENUM_VALUE: 'ENUM_VALUE',
  48145. INPUT_OBJECT: 'INPUT_OBJECT',
  48146. INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
  48147. });
  48148. /**
  48149. * The enum type representing the directive location values.
  48150. */
  48151. exports.DirectiveLocation = DirectiveLocation;
  48152. },{}],306:[function(require,module,exports){
  48153. "use strict";
  48154. Object.defineProperty(exports, "__esModule", {
  48155. value: true
  48156. });
  48157. Object.defineProperty(exports, "getLocation", {
  48158. enumerable: true,
  48159. get: function get() {
  48160. return _location.getLocation;
  48161. }
  48162. });
  48163. Object.defineProperty(exports, "Kind", {
  48164. enumerable: true,
  48165. get: function get() {
  48166. return _kinds.Kind;
  48167. }
  48168. });
  48169. Object.defineProperty(exports, "createLexer", {
  48170. enumerable: true,
  48171. get: function get() {
  48172. return _lexer.createLexer;
  48173. }
  48174. });
  48175. Object.defineProperty(exports, "TokenKind", {
  48176. enumerable: true,
  48177. get: function get() {
  48178. return _lexer.TokenKind;
  48179. }
  48180. });
  48181. Object.defineProperty(exports, "parse", {
  48182. enumerable: true,
  48183. get: function get() {
  48184. return _parser.parse;
  48185. }
  48186. });
  48187. Object.defineProperty(exports, "parseValue", {
  48188. enumerable: true,
  48189. get: function get() {
  48190. return _parser.parseValue;
  48191. }
  48192. });
  48193. Object.defineProperty(exports, "parseType", {
  48194. enumerable: true,
  48195. get: function get() {
  48196. return _parser.parseType;
  48197. }
  48198. });
  48199. Object.defineProperty(exports, "print", {
  48200. enumerable: true,
  48201. get: function get() {
  48202. return _printer.print;
  48203. }
  48204. });
  48205. Object.defineProperty(exports, "Source", {
  48206. enumerable: true,
  48207. get: function get() {
  48208. return _source.Source;
  48209. }
  48210. });
  48211. Object.defineProperty(exports, "visit", {
  48212. enumerable: true,
  48213. get: function get() {
  48214. return _visitor.visit;
  48215. }
  48216. });
  48217. Object.defineProperty(exports, "visitInParallel", {
  48218. enumerable: true,
  48219. get: function get() {
  48220. return _visitor.visitInParallel;
  48221. }
  48222. });
  48223. Object.defineProperty(exports, "visitWithTypeInfo", {
  48224. enumerable: true,
  48225. get: function get() {
  48226. return _visitor.visitWithTypeInfo;
  48227. }
  48228. });
  48229. Object.defineProperty(exports, "getVisitFn", {
  48230. enumerable: true,
  48231. get: function get() {
  48232. return _visitor.getVisitFn;
  48233. }
  48234. });
  48235. Object.defineProperty(exports, "BREAK", {
  48236. enumerable: true,
  48237. get: function get() {
  48238. return _visitor.BREAK;
  48239. }
  48240. });
  48241. Object.defineProperty(exports, "isDefinitionNode", {
  48242. enumerable: true,
  48243. get: function get() {
  48244. return _predicates.isDefinitionNode;
  48245. }
  48246. });
  48247. Object.defineProperty(exports, "isExecutableDefinitionNode", {
  48248. enumerable: true,
  48249. get: function get() {
  48250. return _predicates.isExecutableDefinitionNode;
  48251. }
  48252. });
  48253. Object.defineProperty(exports, "isSelectionNode", {
  48254. enumerable: true,
  48255. get: function get() {
  48256. return _predicates.isSelectionNode;
  48257. }
  48258. });
  48259. Object.defineProperty(exports, "isValueNode", {
  48260. enumerable: true,
  48261. get: function get() {
  48262. return _predicates.isValueNode;
  48263. }
  48264. });
  48265. Object.defineProperty(exports, "isTypeNode", {
  48266. enumerable: true,
  48267. get: function get() {
  48268. return _predicates.isTypeNode;
  48269. }
  48270. });
  48271. Object.defineProperty(exports, "isTypeSystemDefinitionNode", {
  48272. enumerable: true,
  48273. get: function get() {
  48274. return _predicates.isTypeSystemDefinitionNode;
  48275. }
  48276. });
  48277. Object.defineProperty(exports, "isTypeDefinitionNode", {
  48278. enumerable: true,
  48279. get: function get() {
  48280. return _predicates.isTypeDefinitionNode;
  48281. }
  48282. });
  48283. Object.defineProperty(exports, "isTypeSystemExtensionNode", {
  48284. enumerable: true,
  48285. get: function get() {
  48286. return _predicates.isTypeSystemExtensionNode;
  48287. }
  48288. });
  48289. Object.defineProperty(exports, "isTypeExtensionNode", {
  48290. enumerable: true,
  48291. get: function get() {
  48292. return _predicates.isTypeExtensionNode;
  48293. }
  48294. });
  48295. Object.defineProperty(exports, "DirectiveLocation", {
  48296. enumerable: true,
  48297. get: function get() {
  48298. return _directiveLocation.DirectiveLocation;
  48299. }
  48300. });
  48301. var _location = require("./location");
  48302. var _kinds = require("./kinds");
  48303. var _lexer = require("./lexer");
  48304. var _parser = require("./parser");
  48305. var _printer = require("./printer");
  48306. var _source = require("./source");
  48307. var _visitor = require("./visitor");
  48308. var _predicates = require("./predicates");
  48309. var _directiveLocation = require("./directiveLocation");
  48310. },{"./directiveLocation":305,"./kinds":307,"./lexer":308,"./location":309,"./parser":310,"./predicates":311,"./printer":312,"./source":313,"./visitor":314}],307:[function(require,module,exports){
  48311. "use strict";
  48312. Object.defineProperty(exports, "__esModule", {
  48313. value: true
  48314. });
  48315. exports.Kind = void 0;
  48316. /**
  48317. * Copyright (c) 2015-present, Facebook, Inc.
  48318. *
  48319. * This source code is licensed under the MIT license found in the
  48320. * LICENSE file in the root directory of this source tree.
  48321. *
  48322. *
  48323. */
  48324. /**
  48325. * The set of allowed kind values for AST nodes.
  48326. */
  48327. var Kind = Object.freeze({
  48328. // Name
  48329. NAME: 'Name',
  48330. // Document
  48331. DOCUMENT: 'Document',
  48332. OPERATION_DEFINITION: 'OperationDefinition',
  48333. VARIABLE_DEFINITION: 'VariableDefinition',
  48334. SELECTION_SET: 'SelectionSet',
  48335. FIELD: 'Field',
  48336. ARGUMENT: 'Argument',
  48337. // Fragments
  48338. FRAGMENT_SPREAD: 'FragmentSpread',
  48339. INLINE_FRAGMENT: 'InlineFragment',
  48340. FRAGMENT_DEFINITION: 'FragmentDefinition',
  48341. // Values
  48342. VARIABLE: 'Variable',
  48343. INT: 'IntValue',
  48344. FLOAT: 'FloatValue',
  48345. STRING: 'StringValue',
  48346. BOOLEAN: 'BooleanValue',
  48347. NULL: 'NullValue',
  48348. ENUM: 'EnumValue',
  48349. LIST: 'ListValue',
  48350. OBJECT: 'ObjectValue',
  48351. OBJECT_FIELD: 'ObjectField',
  48352. // Directives
  48353. DIRECTIVE: 'Directive',
  48354. // Types
  48355. NAMED_TYPE: 'NamedType',
  48356. LIST_TYPE: 'ListType',
  48357. NON_NULL_TYPE: 'NonNullType',
  48358. // Type System Definitions
  48359. SCHEMA_DEFINITION: 'SchemaDefinition',
  48360. OPERATION_TYPE_DEFINITION: 'OperationTypeDefinition',
  48361. // Type Definitions
  48362. SCALAR_TYPE_DEFINITION: 'ScalarTypeDefinition',
  48363. OBJECT_TYPE_DEFINITION: 'ObjectTypeDefinition',
  48364. FIELD_DEFINITION: 'FieldDefinition',
  48365. INPUT_VALUE_DEFINITION: 'InputValueDefinition',
  48366. INTERFACE_TYPE_DEFINITION: 'InterfaceTypeDefinition',
  48367. UNION_TYPE_DEFINITION: 'UnionTypeDefinition',
  48368. ENUM_TYPE_DEFINITION: 'EnumTypeDefinition',
  48369. ENUM_VALUE_DEFINITION: 'EnumValueDefinition',
  48370. INPUT_OBJECT_TYPE_DEFINITION: 'InputObjectTypeDefinition',
  48371. // Directive Definitions
  48372. DIRECTIVE_DEFINITION: 'DirectiveDefinition',
  48373. // Type System Extensions
  48374. SCHEMA_EXTENSION: 'SchemaExtension',
  48375. // Type Extensions
  48376. SCALAR_TYPE_EXTENSION: 'ScalarTypeExtension',
  48377. OBJECT_TYPE_EXTENSION: 'ObjectTypeExtension',
  48378. INTERFACE_TYPE_EXTENSION: 'InterfaceTypeExtension',
  48379. UNION_TYPE_EXTENSION: 'UnionTypeExtension',
  48380. ENUM_TYPE_EXTENSION: 'EnumTypeExtension',
  48381. INPUT_OBJECT_TYPE_EXTENSION: 'InputObjectTypeExtension'
  48382. });
  48383. /**
  48384. * The enum type representing the possible kind values of AST nodes.
  48385. */
  48386. exports.Kind = Kind;
  48387. },{}],308:[function(require,module,exports){
  48388. "use strict";
  48389. Object.defineProperty(exports, "__esModule", {
  48390. value: true
  48391. });
  48392. exports.createLexer = createLexer;
  48393. exports.getTokenDesc = getTokenDesc;
  48394. exports.TokenKind = void 0;
  48395. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  48396. var _error = require("../error");
  48397. var _blockStringValue = _interopRequireDefault(require("./blockStringValue"));
  48398. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  48399. /**
  48400. * Copyright (c) 2015-present, Facebook, Inc.
  48401. *
  48402. * This source code is licensed under the MIT license found in the
  48403. * LICENSE file in the root directory of this source tree.
  48404. *
  48405. *
  48406. */
  48407. /**
  48408. * Given a Source object, this returns a Lexer for that source.
  48409. * A Lexer is a stateful stream generator in that every time
  48410. * it is advanced, it returns the next token in the Source. Assuming the
  48411. * source lexes, the final Token emitted by the lexer will be of kind
  48412. * EOF, after which the lexer will repeatedly return the same EOF token
  48413. * whenever called.
  48414. */
  48415. function createLexer(source, options) {
  48416. var startOfFileToken = new Tok(TokenKind.SOF, 0, 0, 0, 0, null);
  48417. var lexer = {
  48418. source: source,
  48419. options: options,
  48420. lastToken: startOfFileToken,
  48421. token: startOfFileToken,
  48422. line: 1,
  48423. lineStart: 0,
  48424. advance: advanceLexer,
  48425. lookahead: lookahead
  48426. };
  48427. return lexer;
  48428. }
  48429. function advanceLexer() {
  48430. this.lastToken = this.token;
  48431. var token = this.token = this.lookahead();
  48432. return token;
  48433. }
  48434. function lookahead() {
  48435. var token = this.token;
  48436. if (token.kind !== TokenKind.EOF) {
  48437. do {
  48438. // Note: next is only mutable during parsing, so we cast to allow this.
  48439. token = token.next || (token.next = readToken(this, token));
  48440. } while (token.kind === TokenKind.COMMENT);
  48441. }
  48442. return token;
  48443. }
  48444. /**
  48445. * The return type of createLexer.
  48446. */
  48447. /**
  48448. * An exported enum describing the different kinds of tokens that the
  48449. * lexer emits.
  48450. */
  48451. var TokenKind = Object.freeze({
  48452. SOF: '<SOF>',
  48453. EOF: '<EOF>',
  48454. BANG: '!',
  48455. DOLLAR: '$',
  48456. AMP: '&',
  48457. PAREN_L: '(',
  48458. PAREN_R: ')',
  48459. SPREAD: '...',
  48460. COLON: ':',
  48461. EQUALS: '=',
  48462. AT: '@',
  48463. BRACKET_L: '[',
  48464. BRACKET_R: ']',
  48465. BRACE_L: '{',
  48466. PIPE: '|',
  48467. BRACE_R: '}',
  48468. NAME: 'Name',
  48469. INT: 'Int',
  48470. FLOAT: 'Float',
  48471. STRING: 'String',
  48472. BLOCK_STRING: 'BlockString',
  48473. COMMENT: 'Comment'
  48474. });
  48475. /**
  48476. * The enum type representing the token kinds values.
  48477. */
  48478. exports.TokenKind = TokenKind;
  48479. /**
  48480. * A helper function to describe a token as a string for debugging
  48481. */
  48482. function getTokenDesc(token) {
  48483. var value = token.value;
  48484. return value ? "".concat(token.kind, " \"").concat(value, "\"") : token.kind;
  48485. }
  48486. var charCodeAt = String.prototype.charCodeAt;
  48487. var slice = String.prototype.slice;
  48488. /**
  48489. * Helper function for constructing the Token object.
  48490. */
  48491. function Tok(kind, start, end, line, column, prev, value) {
  48492. this.kind = kind;
  48493. this.start = start;
  48494. this.end = end;
  48495. this.line = line;
  48496. this.column = column;
  48497. this.value = value;
  48498. this.prev = prev;
  48499. this.next = null;
  48500. } // Print a simplified form when appearing in JSON/util.inspect.
  48501. (0, _defineToJSON.default)(Tok, function () {
  48502. return {
  48503. kind: this.kind,
  48504. value: this.value,
  48505. line: this.line,
  48506. column: this.column
  48507. };
  48508. });
  48509. function printCharCode(code) {
  48510. return (// NaN/undefined represents access beyond the end of the file.
  48511. isNaN(code) ? TokenKind.EOF : // Trust JSON for ASCII.
  48512. code < 0x007f ? JSON.stringify(String.fromCharCode(code)) : // Otherwise print the escaped form.
  48513. "\"\\u".concat(('00' + code.toString(16).toUpperCase()).slice(-4), "\"")
  48514. );
  48515. }
  48516. /**
  48517. * Gets the next token from the source starting at the given position.
  48518. *
  48519. * This skips over whitespace until it finds the next lexable token, then lexes
  48520. * punctuators immediately or calls the appropriate helper function for more
  48521. * complicated tokens.
  48522. */
  48523. function readToken(lexer, prev) {
  48524. var source = lexer.source;
  48525. var body = source.body;
  48526. var bodyLength = body.length;
  48527. var pos = positionAfterWhitespace(body, prev.end, lexer);
  48528. var line = lexer.line;
  48529. var col = 1 + pos - lexer.lineStart;
  48530. if (pos >= bodyLength) {
  48531. return new Tok(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
  48532. }
  48533. var code = charCodeAt.call(body, pos); // SourceCharacter
  48534. switch (code) {
  48535. // !
  48536. case 33:
  48537. return new Tok(TokenKind.BANG, pos, pos + 1, line, col, prev);
  48538. // #
  48539. case 35:
  48540. return readComment(source, pos, line, col, prev);
  48541. // $
  48542. case 36:
  48543. return new Tok(TokenKind.DOLLAR, pos, pos + 1, line, col, prev);
  48544. // &
  48545. case 38:
  48546. return new Tok(TokenKind.AMP, pos, pos + 1, line, col, prev);
  48547. // (
  48548. case 40:
  48549. return new Tok(TokenKind.PAREN_L, pos, pos + 1, line, col, prev);
  48550. // )
  48551. case 41:
  48552. return new Tok(TokenKind.PAREN_R, pos, pos + 1, line, col, prev);
  48553. // .
  48554. case 46:
  48555. if (charCodeAt.call(body, pos + 1) === 46 && charCodeAt.call(body, pos + 2) === 46) {
  48556. return new Tok(TokenKind.SPREAD, pos, pos + 3, line, col, prev);
  48557. }
  48558. break;
  48559. // :
  48560. case 58:
  48561. return new Tok(TokenKind.COLON, pos, pos + 1, line, col, prev);
  48562. // =
  48563. case 61:
  48564. return new Tok(TokenKind.EQUALS, pos, pos + 1, line, col, prev);
  48565. // @
  48566. case 64:
  48567. return new Tok(TokenKind.AT, pos, pos + 1, line, col, prev);
  48568. // [
  48569. case 91:
  48570. return new Tok(TokenKind.BRACKET_L, pos, pos + 1, line, col, prev);
  48571. // ]
  48572. case 93:
  48573. return new Tok(TokenKind.BRACKET_R, pos, pos + 1, line, col, prev);
  48574. // {
  48575. case 123:
  48576. return new Tok(TokenKind.BRACE_L, pos, pos + 1, line, col, prev);
  48577. // |
  48578. case 124:
  48579. return new Tok(TokenKind.PIPE, pos, pos + 1, line, col, prev);
  48580. // }
  48581. case 125:
  48582. return new Tok(TokenKind.BRACE_R, pos, pos + 1, line, col, prev);
  48583. // A-Z _ a-z
  48584. case 65:
  48585. case 66:
  48586. case 67:
  48587. case 68:
  48588. case 69:
  48589. case 70:
  48590. case 71:
  48591. case 72:
  48592. case 73:
  48593. case 74:
  48594. case 75:
  48595. case 76:
  48596. case 77:
  48597. case 78:
  48598. case 79:
  48599. case 80:
  48600. case 81:
  48601. case 82:
  48602. case 83:
  48603. case 84:
  48604. case 85:
  48605. case 86:
  48606. case 87:
  48607. case 88:
  48608. case 89:
  48609. case 90:
  48610. case 95:
  48611. case 97:
  48612. case 98:
  48613. case 99:
  48614. case 100:
  48615. case 101:
  48616. case 102:
  48617. case 103:
  48618. case 104:
  48619. case 105:
  48620. case 106:
  48621. case 107:
  48622. case 108:
  48623. case 109:
  48624. case 110:
  48625. case 111:
  48626. case 112:
  48627. case 113:
  48628. case 114:
  48629. case 115:
  48630. case 116:
  48631. case 117:
  48632. case 118:
  48633. case 119:
  48634. case 120:
  48635. case 121:
  48636. case 122:
  48637. return readName(source, pos, line, col, prev);
  48638. // - 0-9
  48639. case 45:
  48640. case 48:
  48641. case 49:
  48642. case 50:
  48643. case 51:
  48644. case 52:
  48645. case 53:
  48646. case 54:
  48647. case 55:
  48648. case 56:
  48649. case 57:
  48650. return readNumber(source, pos, code, line, col, prev);
  48651. // "
  48652. case 34:
  48653. if (charCodeAt.call(body, pos + 1) === 34 && charCodeAt.call(body, pos + 2) === 34) {
  48654. return readBlockString(source, pos, line, col, prev, lexer);
  48655. }
  48656. return readString(source, pos, line, col, prev);
  48657. }
  48658. throw (0, _error.syntaxError)(source, pos, unexpectedCharacterMessage(code));
  48659. }
  48660. /**
  48661. * Report a message that an unexpected character was encountered.
  48662. */
  48663. function unexpectedCharacterMessage(code) {
  48664. if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
  48665. return "Cannot contain the invalid character ".concat(printCharCode(code), ".");
  48666. }
  48667. if (code === 39) {
  48668. // '
  48669. return "Unexpected single quote character ('), did you mean to use " + 'a double quote (")?';
  48670. }
  48671. return "Cannot parse the unexpected character ".concat(printCharCode(code), ".");
  48672. }
  48673. /**
  48674. * Reads from body starting at startPosition until it finds a non-whitespace
  48675. * character, then returns the position of that character for lexing.
  48676. */
  48677. function positionAfterWhitespace(body, startPosition, lexer) {
  48678. var bodyLength = body.length;
  48679. var position = startPosition;
  48680. while (position < bodyLength) {
  48681. var code = charCodeAt.call(body, position); // tab | space | comma | BOM
  48682. if (code === 9 || code === 32 || code === 44 || code === 0xfeff) {
  48683. ++position;
  48684. } else if (code === 10) {
  48685. // new line
  48686. ++position;
  48687. ++lexer.line;
  48688. lexer.lineStart = position;
  48689. } else if (code === 13) {
  48690. // carriage return
  48691. if (charCodeAt.call(body, position + 1) === 10) {
  48692. position += 2;
  48693. } else {
  48694. ++position;
  48695. }
  48696. ++lexer.line;
  48697. lexer.lineStart = position;
  48698. } else {
  48699. break;
  48700. }
  48701. }
  48702. return position;
  48703. }
  48704. /**
  48705. * Reads a comment token from the source file.
  48706. *
  48707. * #[\u0009\u0020-\uFFFF]*
  48708. */
  48709. function readComment(source, start, line, col, prev) {
  48710. var body = source.body;
  48711. var code;
  48712. var position = start;
  48713. do {
  48714. code = charCodeAt.call(body, ++position);
  48715. } while (code !== null && ( // SourceCharacter but not LineTerminator
  48716. code > 0x001f || code === 0x0009));
  48717. return new Tok(TokenKind.COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position));
  48718. }
  48719. /**
  48720. * Reads a number token from the source file, either a float
  48721. * or an int depending on whether a decimal point appears.
  48722. *
  48723. * Int: -?(0|[1-9][0-9]*)
  48724. * Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
  48725. */
  48726. function readNumber(source, start, firstCode, line, col, prev) {
  48727. var body = source.body;
  48728. var code = firstCode;
  48729. var position = start;
  48730. var isFloat = false;
  48731. if (code === 45) {
  48732. // -
  48733. code = charCodeAt.call(body, ++position);
  48734. }
  48735. if (code === 48) {
  48736. // 0
  48737. code = charCodeAt.call(body, ++position);
  48738. if (code >= 48 && code <= 57) {
  48739. throw (0, _error.syntaxError)(source, position, "Invalid number, unexpected digit after 0: ".concat(printCharCode(code), "."));
  48740. }
  48741. } else {
  48742. position = readDigits(source, position, code);
  48743. code = charCodeAt.call(body, position);
  48744. }
  48745. if (code === 46) {
  48746. // .
  48747. isFloat = true;
  48748. code = charCodeAt.call(body, ++position);
  48749. position = readDigits(source, position, code);
  48750. code = charCodeAt.call(body, position);
  48751. }
  48752. if (code === 69 || code === 101) {
  48753. // E e
  48754. isFloat = true;
  48755. code = charCodeAt.call(body, ++position);
  48756. if (code === 43 || code === 45) {
  48757. // + -
  48758. code = charCodeAt.call(body, ++position);
  48759. }
  48760. position = readDigits(source, position, code);
  48761. }
  48762. return new Tok(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, slice.call(body, start, position));
  48763. }
  48764. /**
  48765. * Returns the new position in the source after reading digits.
  48766. */
  48767. function readDigits(source, start, firstCode) {
  48768. var body = source.body;
  48769. var position = start;
  48770. var code = firstCode;
  48771. if (code >= 48 && code <= 57) {
  48772. // 0 - 9
  48773. do {
  48774. code = charCodeAt.call(body, ++position);
  48775. } while (code >= 48 && code <= 57); // 0 - 9
  48776. return position;
  48777. }
  48778. throw (0, _error.syntaxError)(source, position, "Invalid number, expected digit but got: ".concat(printCharCode(code), "."));
  48779. }
  48780. /**
  48781. * Reads a string token from the source file.
  48782. *
  48783. * "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
  48784. */
  48785. function readString(source, start, line, col, prev) {
  48786. var body = source.body;
  48787. var position = start + 1;
  48788. var chunkStart = position;
  48789. var code = 0;
  48790. var value = '';
  48791. while (position < body.length && (code = charCodeAt.call(body, position)) !== null && // not LineTerminator
  48792. code !== 0x000a && code !== 0x000d) {
  48793. // Closing Quote (")
  48794. if (code === 34) {
  48795. value += slice.call(body, chunkStart, position);
  48796. return new Tok(TokenKind.STRING, start, position + 1, line, col, prev, value);
  48797. } // SourceCharacter
  48798. if (code < 0x0020 && code !== 0x0009) {
  48799. throw (0, _error.syntaxError)(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
  48800. }
  48801. ++position;
  48802. if (code === 92) {
  48803. // \
  48804. value += slice.call(body, chunkStart, position - 1);
  48805. code = charCodeAt.call(body, position);
  48806. switch (code) {
  48807. case 34:
  48808. value += '"';
  48809. break;
  48810. case 47:
  48811. value += '/';
  48812. break;
  48813. case 92:
  48814. value += '\\';
  48815. break;
  48816. case 98:
  48817. value += '\b';
  48818. break;
  48819. case 102:
  48820. value += '\f';
  48821. break;
  48822. case 110:
  48823. value += '\n';
  48824. break;
  48825. case 114:
  48826. value += '\r';
  48827. break;
  48828. case 116:
  48829. value += '\t';
  48830. break;
  48831. case 117:
  48832. // u
  48833. var charCode = uniCharCode(charCodeAt.call(body, position + 1), charCodeAt.call(body, position + 2), charCodeAt.call(body, position + 3), charCodeAt.call(body, position + 4));
  48834. if (charCode < 0) {
  48835. throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + "\\u".concat(body.slice(position + 1, position + 5), "."));
  48836. }
  48837. value += String.fromCharCode(charCode);
  48838. position += 4;
  48839. break;
  48840. default:
  48841. throw (0, _error.syntaxError)(source, position, "Invalid character escape sequence: \\".concat(String.fromCharCode(code), "."));
  48842. }
  48843. ++position;
  48844. chunkStart = position;
  48845. }
  48846. }
  48847. throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
  48848. }
  48849. /**
  48850. * Reads a block string token from the source file.
  48851. *
  48852. * """("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
  48853. */
  48854. function readBlockString(source, start, line, col, prev, lexer) {
  48855. var body = source.body;
  48856. var position = start + 3;
  48857. var chunkStart = position;
  48858. var code = 0;
  48859. var rawValue = '';
  48860. while (position < body.length && (code = charCodeAt.call(body, position)) !== null) {
  48861. // Closing Triple-Quote (""")
  48862. if (code === 34 && charCodeAt.call(body, position + 1) === 34 && charCodeAt.call(body, position + 2) === 34) {
  48863. rawValue += slice.call(body, chunkStart, position);
  48864. return new Tok(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, (0, _blockStringValue.default)(rawValue));
  48865. } // SourceCharacter
  48866. if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
  48867. throw (0, _error.syntaxError)(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
  48868. }
  48869. if (code === 10) {
  48870. // new line
  48871. ++position;
  48872. ++lexer.line;
  48873. lexer.lineStart = position;
  48874. } else if (code === 13) {
  48875. // carriage return
  48876. if (charCodeAt.call(body, position + 1) === 10) {
  48877. position += 2;
  48878. } else {
  48879. ++position;
  48880. }
  48881. ++lexer.line;
  48882. lexer.lineStart = position;
  48883. } else if ( // Escape Triple-Quote (\""")
  48884. code === 92 && charCodeAt.call(body, position + 1) === 34 && charCodeAt.call(body, position + 2) === 34 && charCodeAt.call(body, position + 3) === 34) {
  48885. rawValue += slice.call(body, chunkStart, position) + '"""';
  48886. position += 4;
  48887. chunkStart = position;
  48888. } else {
  48889. ++position;
  48890. }
  48891. }
  48892. throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
  48893. }
  48894. /**
  48895. * Converts four hexadecimal chars to the integer that the
  48896. * string represents. For example, uniCharCode('0','0','0','f')
  48897. * will return 15, and uniCharCode('0','0','f','f') returns 255.
  48898. *
  48899. * Returns a negative number on error, if a char was invalid.
  48900. *
  48901. * This is implemented by noting that char2hex() returns -1 on error,
  48902. * which means the result of ORing the char2hex() will also be negative.
  48903. */
  48904. function uniCharCode(a, b, c, d) {
  48905. return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
  48906. }
  48907. /**
  48908. * Converts a hex character to its integer value.
  48909. * '0' becomes 0, '9' becomes 9
  48910. * 'A' becomes 10, 'F' becomes 15
  48911. * 'a' becomes 10, 'f' becomes 15
  48912. *
  48913. * Returns -1 on error.
  48914. */
  48915. function char2hex(a) {
  48916. return a >= 48 && a <= 57 ? a - 48 // 0-9
  48917. : a >= 65 && a <= 70 ? a - 55 // A-F
  48918. : a >= 97 && a <= 102 ? a - 87 // a-f
  48919. : -1;
  48920. }
  48921. /**
  48922. * Reads an alphanumeric + underscore name from the source.
  48923. *
  48924. * [_A-Za-z][_0-9A-Za-z]*
  48925. */
  48926. function readName(source, start, line, col, prev) {
  48927. var body = source.body;
  48928. var bodyLength = body.length;
  48929. var position = start + 1;
  48930. var code = 0;
  48931. while (position !== bodyLength && (code = charCodeAt.call(body, position)) !== null && (code === 95 || // _
  48932. code >= 48 && code <= 57 || // 0-9
  48933. code >= 65 && code <= 90 || // A-Z
  48934. code >= 97 && code <= 122) // a-z
  48935. ) {
  48936. ++position;
  48937. }
  48938. return new Tok(TokenKind.NAME, start, position, line, col, prev, slice.call(body, start, position));
  48939. }
  48940. },{"../error":277,"../jsutils/defineToJSON":286,"./blockStringValue":304}],309:[function(require,module,exports){
  48941. "use strict";
  48942. Object.defineProperty(exports, "__esModule", {
  48943. value: true
  48944. });
  48945. exports.getLocation = getLocation;
  48946. /**
  48947. * Copyright (c) 2015-present, Facebook, Inc.
  48948. *
  48949. * This source code is licensed under the MIT license found in the
  48950. * LICENSE file in the root directory of this source tree.
  48951. *
  48952. *
  48953. */
  48954. /**
  48955. * Represents a location in a Source.
  48956. */
  48957. /**
  48958. * Takes a Source and a UTF-8 character offset, and returns the corresponding
  48959. * line and column as a SourceLocation.
  48960. */
  48961. function getLocation(source, position) {
  48962. var lineRegexp = /\r\n|[\n\r]/g;
  48963. var line = 1;
  48964. var column = position + 1;
  48965. var match;
  48966. while ((match = lineRegexp.exec(source.body)) && match.index < position) {
  48967. line += 1;
  48968. column = position + 1 - (match.index + match[0].length);
  48969. }
  48970. return {
  48971. line: line,
  48972. column: column
  48973. };
  48974. }
  48975. },{}],310:[function(require,module,exports){
  48976. "use strict";
  48977. Object.defineProperty(exports, "__esModule", {
  48978. value: true
  48979. });
  48980. exports.parse = parse;
  48981. exports.parseValue = parseValue;
  48982. exports.parseType = parseType;
  48983. exports.parseConstValue = parseConstValue;
  48984. exports.parseTypeReference = parseTypeReference;
  48985. exports.parseNamedType = parseNamedType;
  48986. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  48987. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  48988. var _source = require("./source");
  48989. var _error = require("../error");
  48990. var _lexer = require("./lexer");
  48991. var _kinds = require("./kinds");
  48992. var _directiveLocation = require("./directiveLocation");
  48993. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  48994. /**
  48995. * Copyright (c) 2015-present, Facebook, Inc.
  48996. *
  48997. * This source code is licensed under the MIT license found in the
  48998. * LICENSE file in the root directory of this source tree.
  48999. *
  49000. *
  49001. */
  49002. /**
  49003. * Given a GraphQL source, parses it into a Document.
  49004. * Throws GraphQLError if a syntax error is encountered.
  49005. */
  49006. function parse(source, options) {
  49007. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  49008. if (!(sourceObj instanceof _source.Source)) {
  49009. throw new TypeError("Must provide Source. Received: ".concat((0, _inspect.default)(sourceObj)));
  49010. }
  49011. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  49012. return parseDocument(lexer);
  49013. }
  49014. /**
  49015. * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
  49016. * that value.
  49017. * Throws GraphQLError if a syntax error is encountered.
  49018. *
  49019. * This is useful within tools that operate upon GraphQL Values directly and
  49020. * in isolation of complete GraphQL documents.
  49021. *
  49022. * Consider providing the results to the utility function: valueFromAST().
  49023. */
  49024. function parseValue(source, options) {
  49025. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  49026. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  49027. expect(lexer, _lexer.TokenKind.SOF);
  49028. var value = parseValueLiteral(lexer, false);
  49029. expect(lexer, _lexer.TokenKind.EOF);
  49030. return value;
  49031. }
  49032. /**
  49033. * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
  49034. * that type.
  49035. * Throws GraphQLError if a syntax error is encountered.
  49036. *
  49037. * This is useful within tools that operate upon GraphQL Types directly and
  49038. * in isolation of complete GraphQL documents.
  49039. *
  49040. * Consider providing the results to the utility function: typeFromAST().
  49041. */
  49042. function parseType(source, options) {
  49043. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  49044. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  49045. expect(lexer, _lexer.TokenKind.SOF);
  49046. var type = parseTypeReference(lexer);
  49047. expect(lexer, _lexer.TokenKind.EOF);
  49048. return type;
  49049. }
  49050. /**
  49051. * Converts a name lex token into a name parse node.
  49052. */
  49053. function parseName(lexer) {
  49054. var token = expect(lexer, _lexer.TokenKind.NAME);
  49055. return {
  49056. kind: _kinds.Kind.NAME,
  49057. value: token.value,
  49058. loc: loc(lexer, token)
  49059. };
  49060. } // Implements the parsing rules in the Document section.
  49061. /**
  49062. * Document : Definition+
  49063. */
  49064. function parseDocument(lexer) {
  49065. var start = lexer.token;
  49066. return {
  49067. kind: _kinds.Kind.DOCUMENT,
  49068. definitions: many(lexer, _lexer.TokenKind.SOF, parseDefinition, _lexer.TokenKind.EOF),
  49069. loc: loc(lexer, start)
  49070. };
  49071. }
  49072. /**
  49073. * Definition :
  49074. * - ExecutableDefinition
  49075. * - TypeSystemDefinition
  49076. * - TypeSystemExtension
  49077. */
  49078. function parseDefinition(lexer) {
  49079. if (peek(lexer, _lexer.TokenKind.NAME)) {
  49080. switch (lexer.token.value) {
  49081. case 'query':
  49082. case 'mutation':
  49083. case 'subscription':
  49084. case 'fragment':
  49085. return parseExecutableDefinition(lexer);
  49086. case 'schema':
  49087. case 'scalar':
  49088. case 'type':
  49089. case 'interface':
  49090. case 'union':
  49091. case 'enum':
  49092. case 'input':
  49093. case 'directive':
  49094. return parseTypeSystemDefinition(lexer);
  49095. case 'extend':
  49096. return parseTypeSystemExtension(lexer);
  49097. }
  49098. } else if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  49099. return parseExecutableDefinition(lexer);
  49100. } else if (peekDescription(lexer)) {
  49101. return parseTypeSystemDefinition(lexer);
  49102. }
  49103. throw unexpected(lexer);
  49104. }
  49105. /**
  49106. * ExecutableDefinition :
  49107. * - OperationDefinition
  49108. * - FragmentDefinition
  49109. */
  49110. function parseExecutableDefinition(lexer) {
  49111. if (peek(lexer, _lexer.TokenKind.NAME)) {
  49112. switch (lexer.token.value) {
  49113. case 'query':
  49114. case 'mutation':
  49115. case 'subscription':
  49116. return parseOperationDefinition(lexer);
  49117. case 'fragment':
  49118. return parseFragmentDefinition(lexer);
  49119. }
  49120. } else if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  49121. return parseOperationDefinition(lexer);
  49122. }
  49123. throw unexpected(lexer);
  49124. } // Implements the parsing rules in the Operations section.
  49125. /**
  49126. * OperationDefinition :
  49127. * - SelectionSet
  49128. * - OperationType Name? VariableDefinitions? Directives? SelectionSet
  49129. */
  49130. function parseOperationDefinition(lexer) {
  49131. var start = lexer.token;
  49132. if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  49133. return {
  49134. kind: _kinds.Kind.OPERATION_DEFINITION,
  49135. operation: 'query',
  49136. name: undefined,
  49137. variableDefinitions: [],
  49138. directives: [],
  49139. selectionSet: parseSelectionSet(lexer),
  49140. loc: loc(lexer, start)
  49141. };
  49142. }
  49143. var operation = parseOperationType(lexer);
  49144. var name;
  49145. if (peek(lexer, _lexer.TokenKind.NAME)) {
  49146. name = parseName(lexer);
  49147. }
  49148. return {
  49149. kind: _kinds.Kind.OPERATION_DEFINITION,
  49150. operation: operation,
  49151. name: name,
  49152. variableDefinitions: parseVariableDefinitions(lexer),
  49153. directives: parseDirectives(lexer, false),
  49154. selectionSet: parseSelectionSet(lexer),
  49155. loc: loc(lexer, start)
  49156. };
  49157. }
  49158. /**
  49159. * OperationType : one of query mutation subscription
  49160. */
  49161. function parseOperationType(lexer) {
  49162. var operationToken = expect(lexer, _lexer.TokenKind.NAME);
  49163. switch (operationToken.value) {
  49164. case 'query':
  49165. return 'query';
  49166. case 'mutation':
  49167. return 'mutation';
  49168. case 'subscription':
  49169. return 'subscription';
  49170. }
  49171. throw unexpected(lexer, operationToken);
  49172. }
  49173. /**
  49174. * VariableDefinitions : ( VariableDefinition+ )
  49175. */
  49176. function parseVariableDefinitions(lexer) {
  49177. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : [];
  49178. }
  49179. /**
  49180. * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
  49181. */
  49182. function parseVariableDefinition(lexer) {
  49183. var start = lexer.token;
  49184. return {
  49185. kind: _kinds.Kind.VARIABLE_DEFINITION,
  49186. variable: parseVariable(lexer),
  49187. type: (expect(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
  49188. defaultValue: skip(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : undefined,
  49189. directives: parseDirectives(lexer, true),
  49190. loc: loc(lexer, start)
  49191. };
  49192. }
  49193. /**
  49194. * Variable : $ Name
  49195. */
  49196. function parseVariable(lexer) {
  49197. var start = lexer.token;
  49198. expect(lexer, _lexer.TokenKind.DOLLAR);
  49199. return {
  49200. kind: _kinds.Kind.VARIABLE,
  49201. name: parseName(lexer),
  49202. loc: loc(lexer, start)
  49203. };
  49204. }
  49205. /**
  49206. * SelectionSet : { Selection+ }
  49207. */
  49208. function parseSelectionSet(lexer) {
  49209. var start = lexer.token;
  49210. return {
  49211. kind: _kinds.Kind.SELECTION_SET,
  49212. selections: many(lexer, _lexer.TokenKind.BRACE_L, parseSelection, _lexer.TokenKind.BRACE_R),
  49213. loc: loc(lexer, start)
  49214. };
  49215. }
  49216. /**
  49217. * Selection :
  49218. * - Field
  49219. * - FragmentSpread
  49220. * - InlineFragment
  49221. */
  49222. function parseSelection(lexer) {
  49223. return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);
  49224. }
  49225. /**
  49226. * Field : Alias? Name Arguments? Directives? SelectionSet?
  49227. *
  49228. * Alias : Name :
  49229. */
  49230. function parseField(lexer) {
  49231. var start = lexer.token;
  49232. var nameOrAlias = parseName(lexer);
  49233. var alias;
  49234. var name;
  49235. if (skip(lexer, _lexer.TokenKind.COLON)) {
  49236. alias = nameOrAlias;
  49237. name = parseName(lexer);
  49238. } else {
  49239. name = nameOrAlias;
  49240. }
  49241. return {
  49242. kind: _kinds.Kind.FIELD,
  49243. alias: alias,
  49244. name: name,
  49245. arguments: parseArguments(lexer, false),
  49246. directives: parseDirectives(lexer, false),
  49247. selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : undefined,
  49248. loc: loc(lexer, start)
  49249. };
  49250. }
  49251. /**
  49252. * Arguments[Const] : ( Argument[?Const]+ )
  49253. */
  49254. function parseArguments(lexer, isConst) {
  49255. var item = isConst ? parseConstArgument : parseArgument;
  49256. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, item, _lexer.TokenKind.PAREN_R) : [];
  49257. }
  49258. /**
  49259. * Argument[Const] : Name : Value[?Const]
  49260. */
  49261. function parseArgument(lexer) {
  49262. var start = lexer.token;
  49263. return {
  49264. kind: _kinds.Kind.ARGUMENT,
  49265. name: parseName(lexer),
  49266. value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, false)),
  49267. loc: loc(lexer, start)
  49268. };
  49269. }
  49270. function parseConstArgument(lexer) {
  49271. var start = lexer.token;
  49272. return {
  49273. kind: _kinds.Kind.ARGUMENT,
  49274. name: parseName(lexer),
  49275. value: (expect(lexer, _lexer.TokenKind.COLON), parseConstValue(lexer)),
  49276. loc: loc(lexer, start)
  49277. };
  49278. } // Implements the parsing rules in the Fragments section.
  49279. /**
  49280. * Corresponds to both FragmentSpread and InlineFragment in the spec.
  49281. *
  49282. * FragmentSpread : ... FragmentName Directives?
  49283. *
  49284. * InlineFragment : ... TypeCondition? Directives? SelectionSet
  49285. */
  49286. function parseFragment(lexer) {
  49287. var start = lexer.token;
  49288. expect(lexer, _lexer.TokenKind.SPREAD);
  49289. var hasTypeCondition = skipKeyword(lexer, 'on');
  49290. if (!hasTypeCondition && peek(lexer, _lexer.TokenKind.NAME)) {
  49291. return {
  49292. kind: _kinds.Kind.FRAGMENT_SPREAD,
  49293. name: parseFragmentName(lexer),
  49294. directives: parseDirectives(lexer, false),
  49295. loc: loc(lexer, start)
  49296. };
  49297. }
  49298. return {
  49299. kind: _kinds.Kind.INLINE_FRAGMENT,
  49300. typeCondition: hasTypeCondition ? parseNamedType(lexer) : undefined,
  49301. directives: parseDirectives(lexer, false),
  49302. selectionSet: parseSelectionSet(lexer),
  49303. loc: loc(lexer, start)
  49304. };
  49305. }
  49306. /**
  49307. * FragmentDefinition :
  49308. * - fragment FragmentName on TypeCondition Directives? SelectionSet
  49309. *
  49310. * TypeCondition : NamedType
  49311. */
  49312. function parseFragmentDefinition(lexer) {
  49313. var start = lexer.token;
  49314. expectKeyword(lexer, 'fragment'); // Experimental support for defining variables within fragments changes
  49315. // the grammar of FragmentDefinition:
  49316. // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet
  49317. if (lexer.options.experimentalFragmentVariables) {
  49318. return {
  49319. kind: _kinds.Kind.FRAGMENT_DEFINITION,
  49320. name: parseFragmentName(lexer),
  49321. variableDefinitions: parseVariableDefinitions(lexer),
  49322. typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
  49323. directives: parseDirectives(lexer, false),
  49324. selectionSet: parseSelectionSet(lexer),
  49325. loc: loc(lexer, start)
  49326. };
  49327. }
  49328. return {
  49329. kind: _kinds.Kind.FRAGMENT_DEFINITION,
  49330. name: parseFragmentName(lexer),
  49331. typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
  49332. directives: parseDirectives(lexer, false),
  49333. selectionSet: parseSelectionSet(lexer),
  49334. loc: loc(lexer, start)
  49335. };
  49336. }
  49337. /**
  49338. * FragmentName : Name but not `on`
  49339. */
  49340. function parseFragmentName(lexer) {
  49341. if (lexer.token.value === 'on') {
  49342. throw unexpected(lexer);
  49343. }
  49344. return parseName(lexer);
  49345. } // Implements the parsing rules in the Values section.
  49346. /**
  49347. * Value[Const] :
  49348. * - [~Const] Variable
  49349. * - IntValue
  49350. * - FloatValue
  49351. * - StringValue
  49352. * - BooleanValue
  49353. * - NullValue
  49354. * - EnumValue
  49355. * - ListValue[?Const]
  49356. * - ObjectValue[?Const]
  49357. *
  49358. * BooleanValue : one of `true` `false`
  49359. *
  49360. * NullValue : `null`
  49361. *
  49362. * EnumValue : Name but not `true`, `false` or `null`
  49363. */
  49364. function parseValueLiteral(lexer, isConst) {
  49365. var token = lexer.token;
  49366. switch (token.kind) {
  49367. case _lexer.TokenKind.BRACKET_L:
  49368. return parseList(lexer, isConst);
  49369. case _lexer.TokenKind.BRACE_L:
  49370. return parseObject(lexer, isConst);
  49371. case _lexer.TokenKind.INT:
  49372. lexer.advance();
  49373. return {
  49374. kind: _kinds.Kind.INT,
  49375. value: token.value,
  49376. loc: loc(lexer, token)
  49377. };
  49378. case _lexer.TokenKind.FLOAT:
  49379. lexer.advance();
  49380. return {
  49381. kind: _kinds.Kind.FLOAT,
  49382. value: token.value,
  49383. loc: loc(lexer, token)
  49384. };
  49385. case _lexer.TokenKind.STRING:
  49386. case _lexer.TokenKind.BLOCK_STRING:
  49387. return parseStringLiteral(lexer);
  49388. case _lexer.TokenKind.NAME:
  49389. if (token.value === 'true' || token.value === 'false') {
  49390. lexer.advance();
  49391. return {
  49392. kind: _kinds.Kind.BOOLEAN,
  49393. value: token.value === 'true',
  49394. loc: loc(lexer, token)
  49395. };
  49396. } else if (token.value === 'null') {
  49397. lexer.advance();
  49398. return {
  49399. kind: _kinds.Kind.NULL,
  49400. loc: loc(lexer, token)
  49401. };
  49402. }
  49403. lexer.advance();
  49404. return {
  49405. kind: _kinds.Kind.ENUM,
  49406. value: token.value,
  49407. loc: loc(lexer, token)
  49408. };
  49409. case _lexer.TokenKind.DOLLAR:
  49410. if (!isConst) {
  49411. return parseVariable(lexer);
  49412. }
  49413. break;
  49414. }
  49415. throw unexpected(lexer);
  49416. }
  49417. function parseStringLiteral(lexer) {
  49418. var token = lexer.token;
  49419. lexer.advance();
  49420. return {
  49421. kind: _kinds.Kind.STRING,
  49422. value: token.value,
  49423. block: token.kind === _lexer.TokenKind.BLOCK_STRING,
  49424. loc: loc(lexer, token)
  49425. };
  49426. }
  49427. function parseConstValue(lexer) {
  49428. return parseValueLiteral(lexer, true);
  49429. }
  49430. function parseValueValue(lexer) {
  49431. return parseValueLiteral(lexer, false);
  49432. }
  49433. /**
  49434. * ListValue[Const] :
  49435. * - [ ]
  49436. * - [ Value[?Const]+ ]
  49437. */
  49438. function parseList(lexer, isConst) {
  49439. var start = lexer.token;
  49440. var item = isConst ? parseConstValue : parseValueValue;
  49441. return {
  49442. kind: _kinds.Kind.LIST,
  49443. values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R),
  49444. loc: loc(lexer, start)
  49445. };
  49446. }
  49447. /**
  49448. * ObjectValue[Const] :
  49449. * - { }
  49450. * - { ObjectField[?Const]+ }
  49451. */
  49452. function parseObject(lexer, isConst) {
  49453. var start = lexer.token;
  49454. expect(lexer, _lexer.TokenKind.BRACE_L);
  49455. var fields = [];
  49456. while (!skip(lexer, _lexer.TokenKind.BRACE_R)) {
  49457. fields.push(parseObjectField(lexer, isConst));
  49458. }
  49459. return {
  49460. kind: _kinds.Kind.OBJECT,
  49461. fields: fields,
  49462. loc: loc(lexer, start)
  49463. };
  49464. }
  49465. /**
  49466. * ObjectField[Const] : Name : Value[?Const]
  49467. */
  49468. function parseObjectField(lexer, isConst) {
  49469. var start = lexer.token;
  49470. return {
  49471. kind: _kinds.Kind.OBJECT_FIELD,
  49472. name: parseName(lexer),
  49473. value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, isConst)),
  49474. loc: loc(lexer, start)
  49475. };
  49476. } // Implements the parsing rules in the Directives section.
  49477. /**
  49478. * Directives[Const] : Directive[?Const]+
  49479. */
  49480. function parseDirectives(lexer, isConst) {
  49481. var directives = [];
  49482. while (peek(lexer, _lexer.TokenKind.AT)) {
  49483. directives.push(parseDirective(lexer, isConst));
  49484. }
  49485. return directives;
  49486. }
  49487. /**
  49488. * Directive[Const] : @ Name Arguments[?Const]?
  49489. */
  49490. function parseDirective(lexer, isConst) {
  49491. var start = lexer.token;
  49492. expect(lexer, _lexer.TokenKind.AT);
  49493. return {
  49494. kind: _kinds.Kind.DIRECTIVE,
  49495. name: parseName(lexer),
  49496. arguments: parseArguments(lexer, isConst),
  49497. loc: loc(lexer, start)
  49498. };
  49499. } // Implements the parsing rules in the Types section.
  49500. /**
  49501. * Type :
  49502. * - NamedType
  49503. * - ListType
  49504. * - NonNullType
  49505. */
  49506. function parseTypeReference(lexer) {
  49507. var start = lexer.token;
  49508. var type;
  49509. if (skip(lexer, _lexer.TokenKind.BRACKET_L)) {
  49510. type = parseTypeReference(lexer);
  49511. expect(lexer, _lexer.TokenKind.BRACKET_R);
  49512. type = {
  49513. kind: _kinds.Kind.LIST_TYPE,
  49514. type: type,
  49515. loc: loc(lexer, start)
  49516. };
  49517. } else {
  49518. type = parseNamedType(lexer);
  49519. }
  49520. if (skip(lexer, _lexer.TokenKind.BANG)) {
  49521. return {
  49522. kind: _kinds.Kind.NON_NULL_TYPE,
  49523. type: type,
  49524. loc: loc(lexer, start)
  49525. };
  49526. }
  49527. return type;
  49528. }
  49529. /**
  49530. * NamedType : Name
  49531. */
  49532. function parseNamedType(lexer) {
  49533. var start = lexer.token;
  49534. return {
  49535. kind: _kinds.Kind.NAMED_TYPE,
  49536. name: parseName(lexer),
  49537. loc: loc(lexer, start)
  49538. };
  49539. } // Implements the parsing rules in the Type Definition section.
  49540. /**
  49541. * TypeSystemDefinition :
  49542. * - SchemaDefinition
  49543. * - TypeDefinition
  49544. * - DirectiveDefinition
  49545. *
  49546. * TypeDefinition :
  49547. * - ScalarTypeDefinition
  49548. * - ObjectTypeDefinition
  49549. * - InterfaceTypeDefinition
  49550. * - UnionTypeDefinition
  49551. * - EnumTypeDefinition
  49552. * - InputObjectTypeDefinition
  49553. */
  49554. function parseTypeSystemDefinition(lexer) {
  49555. // Many definitions begin with a description and require a lookahead.
  49556. var keywordToken = peekDescription(lexer) ? lexer.lookahead() : lexer.token;
  49557. if (keywordToken.kind === _lexer.TokenKind.NAME) {
  49558. switch (keywordToken.value) {
  49559. case 'schema':
  49560. return parseSchemaDefinition(lexer);
  49561. case 'scalar':
  49562. return parseScalarTypeDefinition(lexer);
  49563. case 'type':
  49564. return parseObjectTypeDefinition(lexer);
  49565. case 'interface':
  49566. return parseInterfaceTypeDefinition(lexer);
  49567. case 'union':
  49568. return parseUnionTypeDefinition(lexer);
  49569. case 'enum':
  49570. return parseEnumTypeDefinition(lexer);
  49571. case 'input':
  49572. return parseInputObjectTypeDefinition(lexer);
  49573. case 'directive':
  49574. return parseDirectiveDefinition(lexer);
  49575. }
  49576. }
  49577. throw unexpected(lexer, keywordToken);
  49578. }
  49579. function peekDescription(lexer) {
  49580. return peek(lexer, _lexer.TokenKind.STRING) || peek(lexer, _lexer.TokenKind.BLOCK_STRING);
  49581. }
  49582. /**
  49583. * Description : StringValue
  49584. */
  49585. function parseDescription(lexer) {
  49586. if (peekDescription(lexer)) {
  49587. return parseStringLiteral(lexer);
  49588. }
  49589. }
  49590. /**
  49591. * SchemaDefinition : schema Directives[Const]? { OperationTypeDefinition+ }
  49592. */
  49593. function parseSchemaDefinition(lexer) {
  49594. var start = lexer.token;
  49595. expectKeyword(lexer, 'schema');
  49596. var directives = parseDirectives(lexer, true);
  49597. var operationTypes = many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R);
  49598. return {
  49599. kind: _kinds.Kind.SCHEMA_DEFINITION,
  49600. directives: directives,
  49601. operationTypes: operationTypes,
  49602. loc: loc(lexer, start)
  49603. };
  49604. }
  49605. /**
  49606. * OperationTypeDefinition : OperationType : NamedType
  49607. */
  49608. function parseOperationTypeDefinition(lexer) {
  49609. var start = lexer.token;
  49610. var operation = parseOperationType(lexer);
  49611. expect(lexer, _lexer.TokenKind.COLON);
  49612. var type = parseNamedType(lexer);
  49613. return {
  49614. kind: _kinds.Kind.OPERATION_TYPE_DEFINITION,
  49615. operation: operation,
  49616. type: type,
  49617. loc: loc(lexer, start)
  49618. };
  49619. }
  49620. /**
  49621. * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
  49622. */
  49623. function parseScalarTypeDefinition(lexer) {
  49624. var start = lexer.token;
  49625. var description = parseDescription(lexer);
  49626. expectKeyword(lexer, 'scalar');
  49627. var name = parseName(lexer);
  49628. var directives = parseDirectives(lexer, true);
  49629. return {
  49630. kind: _kinds.Kind.SCALAR_TYPE_DEFINITION,
  49631. description: description,
  49632. name: name,
  49633. directives: directives,
  49634. loc: loc(lexer, start)
  49635. };
  49636. }
  49637. /**
  49638. * ObjectTypeDefinition :
  49639. * Description?
  49640. * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
  49641. */
  49642. function parseObjectTypeDefinition(lexer) {
  49643. var start = lexer.token;
  49644. var description = parseDescription(lexer);
  49645. expectKeyword(lexer, 'type');
  49646. var name = parseName(lexer);
  49647. var interfaces = parseImplementsInterfaces(lexer);
  49648. var directives = parseDirectives(lexer, true);
  49649. var fields = parseFieldsDefinition(lexer);
  49650. return {
  49651. kind: _kinds.Kind.OBJECT_TYPE_DEFINITION,
  49652. description: description,
  49653. name: name,
  49654. interfaces: interfaces,
  49655. directives: directives,
  49656. fields: fields,
  49657. loc: loc(lexer, start)
  49658. };
  49659. }
  49660. /**
  49661. * ImplementsInterfaces :
  49662. * - implements `&`? NamedType
  49663. * - ImplementsInterfaces & NamedType
  49664. */
  49665. function parseImplementsInterfaces(lexer) {
  49666. var types = [];
  49667. if (skipKeyword(lexer, 'implements')) {
  49668. // Optional leading ampersand
  49669. skip(lexer, _lexer.TokenKind.AMP);
  49670. do {
  49671. types.push(parseNamedType(lexer));
  49672. } while (skip(lexer, _lexer.TokenKind.AMP) || // Legacy support for the SDL?
  49673. lexer.options.allowLegacySDLImplementsInterfaces && peek(lexer, _lexer.TokenKind.NAME));
  49674. }
  49675. return types;
  49676. }
  49677. /**
  49678. * FieldsDefinition : { FieldDefinition+ }
  49679. */
  49680. function parseFieldsDefinition(lexer) {
  49681. // Legacy support for the SDL?
  49682. if (lexer.options.allowLegacySDLEmptyFields && peek(lexer, _lexer.TokenKind.BRACE_L) && lexer.lookahead().kind === _lexer.TokenKind.BRACE_R) {
  49683. lexer.advance();
  49684. lexer.advance();
  49685. return [];
  49686. }
  49687. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R) : [];
  49688. }
  49689. /**
  49690. * FieldDefinition :
  49691. * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
  49692. */
  49693. function parseFieldDefinition(lexer) {
  49694. var start = lexer.token;
  49695. var description = parseDescription(lexer);
  49696. var name = parseName(lexer);
  49697. var args = parseArgumentDefs(lexer);
  49698. expect(lexer, _lexer.TokenKind.COLON);
  49699. var type = parseTypeReference(lexer);
  49700. var directives = parseDirectives(lexer, true);
  49701. return {
  49702. kind: _kinds.Kind.FIELD_DEFINITION,
  49703. description: description,
  49704. name: name,
  49705. arguments: args,
  49706. type: type,
  49707. directives: directives,
  49708. loc: loc(lexer, start)
  49709. };
  49710. }
  49711. /**
  49712. * ArgumentsDefinition : ( InputValueDefinition+ )
  49713. */
  49714. function parseArgumentDefs(lexer) {
  49715. if (!peek(lexer, _lexer.TokenKind.PAREN_L)) {
  49716. return [];
  49717. }
  49718. return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R);
  49719. }
  49720. /**
  49721. * InputValueDefinition :
  49722. * - Description? Name : Type DefaultValue? Directives[Const]?
  49723. */
  49724. function parseInputValueDef(lexer) {
  49725. var start = lexer.token;
  49726. var description = parseDescription(lexer);
  49727. var name = parseName(lexer);
  49728. expect(lexer, _lexer.TokenKind.COLON);
  49729. var type = parseTypeReference(lexer);
  49730. var defaultValue;
  49731. if (skip(lexer, _lexer.TokenKind.EQUALS)) {
  49732. defaultValue = parseConstValue(lexer);
  49733. }
  49734. var directives = parseDirectives(lexer, true);
  49735. return {
  49736. kind: _kinds.Kind.INPUT_VALUE_DEFINITION,
  49737. description: description,
  49738. name: name,
  49739. type: type,
  49740. defaultValue: defaultValue,
  49741. directives: directives,
  49742. loc: loc(lexer, start)
  49743. };
  49744. }
  49745. /**
  49746. * InterfaceTypeDefinition :
  49747. * - Description? interface Name Directives[Const]? FieldsDefinition?
  49748. */
  49749. function parseInterfaceTypeDefinition(lexer) {
  49750. var start = lexer.token;
  49751. var description = parseDescription(lexer);
  49752. expectKeyword(lexer, 'interface');
  49753. var name = parseName(lexer);
  49754. var directives = parseDirectives(lexer, true);
  49755. var fields = parseFieldsDefinition(lexer);
  49756. return {
  49757. kind: _kinds.Kind.INTERFACE_TYPE_DEFINITION,
  49758. description: description,
  49759. name: name,
  49760. directives: directives,
  49761. fields: fields,
  49762. loc: loc(lexer, start)
  49763. };
  49764. }
  49765. /**
  49766. * UnionTypeDefinition :
  49767. * - Description? union Name Directives[Const]? UnionMemberTypes?
  49768. */
  49769. function parseUnionTypeDefinition(lexer) {
  49770. var start = lexer.token;
  49771. var description = parseDescription(lexer);
  49772. expectKeyword(lexer, 'union');
  49773. var name = parseName(lexer);
  49774. var directives = parseDirectives(lexer, true);
  49775. var types = parseUnionMemberTypes(lexer);
  49776. return {
  49777. kind: _kinds.Kind.UNION_TYPE_DEFINITION,
  49778. description: description,
  49779. name: name,
  49780. directives: directives,
  49781. types: types,
  49782. loc: loc(lexer, start)
  49783. };
  49784. }
  49785. /**
  49786. * UnionMemberTypes :
  49787. * - = `|`? NamedType
  49788. * - UnionMemberTypes | NamedType
  49789. */
  49790. function parseUnionMemberTypes(lexer) {
  49791. var types = [];
  49792. if (skip(lexer, _lexer.TokenKind.EQUALS)) {
  49793. // Optional leading pipe
  49794. skip(lexer, _lexer.TokenKind.PIPE);
  49795. do {
  49796. types.push(parseNamedType(lexer));
  49797. } while (skip(lexer, _lexer.TokenKind.PIPE));
  49798. }
  49799. return types;
  49800. }
  49801. /**
  49802. * EnumTypeDefinition :
  49803. * - Description? enum Name Directives[Const]? EnumValuesDefinition?
  49804. */
  49805. function parseEnumTypeDefinition(lexer) {
  49806. var start = lexer.token;
  49807. var description = parseDescription(lexer);
  49808. expectKeyword(lexer, 'enum');
  49809. var name = parseName(lexer);
  49810. var directives = parseDirectives(lexer, true);
  49811. var values = parseEnumValuesDefinition(lexer);
  49812. return {
  49813. kind: _kinds.Kind.ENUM_TYPE_DEFINITION,
  49814. description: description,
  49815. name: name,
  49816. directives: directives,
  49817. values: values,
  49818. loc: loc(lexer, start)
  49819. };
  49820. }
  49821. /**
  49822. * EnumValuesDefinition : { EnumValueDefinition+ }
  49823. */
  49824. function parseEnumValuesDefinition(lexer) {
  49825. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseEnumValueDefinition, _lexer.TokenKind.BRACE_R) : [];
  49826. }
  49827. /**
  49828. * EnumValueDefinition : Description? EnumValue Directives[Const]?
  49829. *
  49830. * EnumValue : Name
  49831. */
  49832. function parseEnumValueDefinition(lexer) {
  49833. var start = lexer.token;
  49834. var description = parseDescription(lexer);
  49835. var name = parseName(lexer);
  49836. var directives = parseDirectives(lexer, true);
  49837. return {
  49838. kind: _kinds.Kind.ENUM_VALUE_DEFINITION,
  49839. description: description,
  49840. name: name,
  49841. directives: directives,
  49842. loc: loc(lexer, start)
  49843. };
  49844. }
  49845. /**
  49846. * InputObjectTypeDefinition :
  49847. * - Description? input Name Directives[Const]? InputFieldsDefinition?
  49848. */
  49849. function parseInputObjectTypeDefinition(lexer) {
  49850. var start = lexer.token;
  49851. var description = parseDescription(lexer);
  49852. expectKeyword(lexer, 'input');
  49853. var name = parseName(lexer);
  49854. var directives = parseDirectives(lexer, true);
  49855. var fields = parseInputFieldsDefinition(lexer);
  49856. return {
  49857. kind: _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION,
  49858. description: description,
  49859. name: name,
  49860. directives: directives,
  49861. fields: fields,
  49862. loc: loc(lexer, start)
  49863. };
  49864. }
  49865. /**
  49866. * InputFieldsDefinition : { InputValueDefinition+ }
  49867. */
  49868. function parseInputFieldsDefinition(lexer) {
  49869. return peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseInputValueDef, _lexer.TokenKind.BRACE_R) : [];
  49870. }
  49871. /**
  49872. * TypeSystemExtension :
  49873. * - SchemaExtension
  49874. * - TypeExtension
  49875. *
  49876. * TypeExtension :
  49877. * - ScalarTypeExtension
  49878. * - ObjectTypeExtension
  49879. * - InterfaceTypeExtension
  49880. * - UnionTypeExtension
  49881. * - EnumTypeExtension
  49882. * - InputObjectTypeDefinition
  49883. */
  49884. function parseTypeSystemExtension(lexer) {
  49885. var keywordToken = lexer.lookahead();
  49886. if (keywordToken.kind === _lexer.TokenKind.NAME) {
  49887. switch (keywordToken.value) {
  49888. case 'schema':
  49889. return parseSchemaExtension(lexer);
  49890. case 'scalar':
  49891. return parseScalarTypeExtension(lexer);
  49892. case 'type':
  49893. return parseObjectTypeExtension(lexer);
  49894. case 'interface':
  49895. return parseInterfaceTypeExtension(lexer);
  49896. case 'union':
  49897. return parseUnionTypeExtension(lexer);
  49898. case 'enum':
  49899. return parseEnumTypeExtension(lexer);
  49900. case 'input':
  49901. return parseInputObjectTypeExtension(lexer);
  49902. }
  49903. }
  49904. throw unexpected(lexer, keywordToken);
  49905. }
  49906. /**
  49907. * SchemaExtension :
  49908. * - extend schema Directives[Const]? { OperationTypeDefinition+ }
  49909. * - extend schema Directives[Const]
  49910. */
  49911. function parseSchemaExtension(lexer) {
  49912. var start = lexer.token;
  49913. expectKeyword(lexer, 'extend');
  49914. expectKeyword(lexer, 'schema');
  49915. var directives = parseDirectives(lexer, true);
  49916. var operationTypes = peek(lexer, _lexer.TokenKind.BRACE_L) ? many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R) : [];
  49917. if (directives.length === 0 && operationTypes.length === 0) {
  49918. throw unexpected(lexer);
  49919. }
  49920. return {
  49921. kind: _kinds.Kind.SCHEMA_EXTENSION,
  49922. directives: directives,
  49923. operationTypes: operationTypes,
  49924. loc: loc(lexer, start)
  49925. };
  49926. }
  49927. /**
  49928. * ScalarTypeExtension :
  49929. * - extend scalar Name Directives[Const]
  49930. */
  49931. function parseScalarTypeExtension(lexer) {
  49932. var start = lexer.token;
  49933. expectKeyword(lexer, 'extend');
  49934. expectKeyword(lexer, 'scalar');
  49935. var name = parseName(lexer);
  49936. var directives = parseDirectives(lexer, true);
  49937. if (directives.length === 0) {
  49938. throw unexpected(lexer);
  49939. }
  49940. return {
  49941. kind: _kinds.Kind.SCALAR_TYPE_EXTENSION,
  49942. name: name,
  49943. directives: directives,
  49944. loc: loc(lexer, start)
  49945. };
  49946. }
  49947. /**
  49948. * ObjectTypeExtension :
  49949. * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
  49950. * - extend type Name ImplementsInterfaces? Directives[Const]
  49951. * - extend type Name ImplementsInterfaces
  49952. */
  49953. function parseObjectTypeExtension(lexer) {
  49954. var start = lexer.token;
  49955. expectKeyword(lexer, 'extend');
  49956. expectKeyword(lexer, 'type');
  49957. var name = parseName(lexer);
  49958. var interfaces = parseImplementsInterfaces(lexer);
  49959. var directives = parseDirectives(lexer, true);
  49960. var fields = parseFieldsDefinition(lexer);
  49961. if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
  49962. throw unexpected(lexer);
  49963. }
  49964. return {
  49965. kind: _kinds.Kind.OBJECT_TYPE_EXTENSION,
  49966. name: name,
  49967. interfaces: interfaces,
  49968. directives: directives,
  49969. fields: fields,
  49970. loc: loc(lexer, start)
  49971. };
  49972. }
  49973. /**
  49974. * InterfaceTypeExtension :
  49975. * - extend interface Name Directives[Const]? FieldsDefinition
  49976. * - extend interface Name Directives[Const]
  49977. */
  49978. function parseInterfaceTypeExtension(lexer) {
  49979. var start = lexer.token;
  49980. expectKeyword(lexer, 'extend');
  49981. expectKeyword(lexer, 'interface');
  49982. var name = parseName(lexer);
  49983. var directives = parseDirectives(lexer, true);
  49984. var fields = parseFieldsDefinition(lexer);
  49985. if (directives.length === 0 && fields.length === 0) {
  49986. throw unexpected(lexer);
  49987. }
  49988. return {
  49989. kind: _kinds.Kind.INTERFACE_TYPE_EXTENSION,
  49990. name: name,
  49991. directives: directives,
  49992. fields: fields,
  49993. loc: loc(lexer, start)
  49994. };
  49995. }
  49996. /**
  49997. * UnionTypeExtension :
  49998. * - extend union Name Directives[Const]? UnionMemberTypes
  49999. * - extend union Name Directives[Const]
  50000. */
  50001. function parseUnionTypeExtension(lexer) {
  50002. var start = lexer.token;
  50003. expectKeyword(lexer, 'extend');
  50004. expectKeyword(lexer, 'union');
  50005. var name = parseName(lexer);
  50006. var directives = parseDirectives(lexer, true);
  50007. var types = parseUnionMemberTypes(lexer);
  50008. if (directives.length === 0 && types.length === 0) {
  50009. throw unexpected(lexer);
  50010. }
  50011. return {
  50012. kind: _kinds.Kind.UNION_TYPE_EXTENSION,
  50013. name: name,
  50014. directives: directives,
  50015. types: types,
  50016. loc: loc(lexer, start)
  50017. };
  50018. }
  50019. /**
  50020. * EnumTypeExtension :
  50021. * - extend enum Name Directives[Const]? EnumValuesDefinition
  50022. * - extend enum Name Directives[Const]
  50023. */
  50024. function parseEnumTypeExtension(lexer) {
  50025. var start = lexer.token;
  50026. expectKeyword(lexer, 'extend');
  50027. expectKeyword(lexer, 'enum');
  50028. var name = parseName(lexer);
  50029. var directives = parseDirectives(lexer, true);
  50030. var values = parseEnumValuesDefinition(lexer);
  50031. if (directives.length === 0 && values.length === 0) {
  50032. throw unexpected(lexer);
  50033. }
  50034. return {
  50035. kind: _kinds.Kind.ENUM_TYPE_EXTENSION,
  50036. name: name,
  50037. directives: directives,
  50038. values: values,
  50039. loc: loc(lexer, start)
  50040. };
  50041. }
  50042. /**
  50043. * InputObjectTypeExtension :
  50044. * - extend input Name Directives[Const]? InputFieldsDefinition
  50045. * - extend input Name Directives[Const]
  50046. */
  50047. function parseInputObjectTypeExtension(lexer) {
  50048. var start = lexer.token;
  50049. expectKeyword(lexer, 'extend');
  50050. expectKeyword(lexer, 'input');
  50051. var name = parseName(lexer);
  50052. var directives = parseDirectives(lexer, true);
  50053. var fields = parseInputFieldsDefinition(lexer);
  50054. if (directives.length === 0 && fields.length === 0) {
  50055. throw unexpected(lexer);
  50056. }
  50057. return {
  50058. kind: _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION,
  50059. name: name,
  50060. directives: directives,
  50061. fields: fields,
  50062. loc: loc(lexer, start)
  50063. };
  50064. }
  50065. /**
  50066. * DirectiveDefinition :
  50067. * - Description? directive @ Name ArgumentsDefinition? on DirectiveLocations
  50068. */
  50069. function parseDirectiveDefinition(lexer) {
  50070. var start = lexer.token;
  50071. var description = parseDescription(lexer);
  50072. expectKeyword(lexer, 'directive');
  50073. expect(lexer, _lexer.TokenKind.AT);
  50074. var name = parseName(lexer);
  50075. var args = parseArgumentDefs(lexer);
  50076. expectKeyword(lexer, 'on');
  50077. var locations = parseDirectiveLocations(lexer);
  50078. return {
  50079. kind: _kinds.Kind.DIRECTIVE_DEFINITION,
  50080. description: description,
  50081. name: name,
  50082. arguments: args,
  50083. locations: locations,
  50084. loc: loc(lexer, start)
  50085. };
  50086. }
  50087. /**
  50088. * DirectiveLocations :
  50089. * - `|`? DirectiveLocation
  50090. * - DirectiveLocations | DirectiveLocation
  50091. */
  50092. function parseDirectiveLocations(lexer) {
  50093. // Optional leading pipe
  50094. skip(lexer, _lexer.TokenKind.PIPE);
  50095. var locations = [];
  50096. do {
  50097. locations.push(parseDirectiveLocation(lexer));
  50098. } while (skip(lexer, _lexer.TokenKind.PIPE));
  50099. return locations;
  50100. }
  50101. /*
  50102. * DirectiveLocation :
  50103. * - ExecutableDirectiveLocation
  50104. * - TypeSystemDirectiveLocation
  50105. *
  50106. * ExecutableDirectiveLocation : one of
  50107. * `QUERY`
  50108. * `MUTATION`
  50109. * `SUBSCRIPTION`
  50110. * `FIELD`
  50111. * `FRAGMENT_DEFINITION`
  50112. * `FRAGMENT_SPREAD`
  50113. * `INLINE_FRAGMENT`
  50114. *
  50115. * TypeSystemDirectiveLocation : one of
  50116. * `SCHEMA`
  50117. * `SCALAR`
  50118. * `OBJECT`
  50119. * `FIELD_DEFINITION`
  50120. * `ARGUMENT_DEFINITION`
  50121. * `INTERFACE`
  50122. * `UNION`
  50123. * `ENUM`
  50124. * `ENUM_VALUE`
  50125. * `INPUT_OBJECT`
  50126. * `INPUT_FIELD_DEFINITION`
  50127. */
  50128. function parseDirectiveLocation(lexer) {
  50129. var start = lexer.token;
  50130. var name = parseName(lexer);
  50131. if (_directiveLocation.DirectiveLocation.hasOwnProperty(name.value)) {
  50132. return name;
  50133. }
  50134. throw unexpected(lexer, start);
  50135. } // Core parsing utility functions
  50136. /**
  50137. * Returns a location object, used to identify the place in
  50138. * the source that created a given parsed object.
  50139. */
  50140. function loc(lexer, startToken) {
  50141. if (!lexer.options.noLocation) {
  50142. return new Loc(startToken, lexer.lastToken, lexer.source);
  50143. }
  50144. }
  50145. function Loc(startToken, endToken, source) {
  50146. this.start = startToken.start;
  50147. this.end = endToken.end;
  50148. this.startToken = startToken;
  50149. this.endToken = endToken;
  50150. this.source = source;
  50151. } // Print a simplified form when appearing in JSON/util.inspect.
  50152. (0, _defineToJSON.default)(Loc, function () {
  50153. return {
  50154. start: this.start,
  50155. end: this.end
  50156. };
  50157. });
  50158. /**
  50159. * Determines if the next token is of a given kind
  50160. */
  50161. function peek(lexer, kind) {
  50162. return lexer.token.kind === kind;
  50163. }
  50164. /**
  50165. * If the next token is of the given kind, return true after advancing
  50166. * the lexer. Otherwise, do not change the parser state and return false.
  50167. */
  50168. function skip(lexer, kind) {
  50169. if (lexer.token.kind === kind) {
  50170. lexer.advance();
  50171. return true;
  50172. }
  50173. return false;
  50174. }
  50175. /**
  50176. * If the next token is of the given kind, return that token after advancing
  50177. * the lexer. Otherwise, do not change the parser state and throw an error.
  50178. */
  50179. function expect(lexer, kind) {
  50180. var token = lexer.token;
  50181. if (token.kind === kind) {
  50182. lexer.advance();
  50183. return token;
  50184. }
  50185. throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
  50186. }
  50187. /**
  50188. * If the next token is a keyword with the given value, return true after advancing
  50189. * the lexer. Otherwise, do not change the parser state and return false.
  50190. */
  50191. function skipKeyword(lexer, value) {
  50192. var token = lexer.token;
  50193. if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
  50194. lexer.advance();
  50195. return true;
  50196. }
  50197. return false;
  50198. }
  50199. /**
  50200. * If the next token is a keyword with the given value, return that token after
  50201. * advancing the lexer. Otherwise, do not change the parser state and throw
  50202. * an error.
  50203. */
  50204. function expectKeyword(lexer, value) {
  50205. if (!skipKeyword(lexer, value)) {
  50206. throw (0, _error.syntaxError)(lexer.source, lexer.token.start, "Expected \"".concat(value, "\", found ").concat((0, _lexer.getTokenDesc)(lexer.token)));
  50207. }
  50208. }
  50209. /**
  50210. * Helper function for creating an error when an unexpected lexed token
  50211. * is encountered.
  50212. */
  50213. function unexpected(lexer, atToken) {
  50214. var token = atToken || lexer.token;
  50215. return (0, _error.syntaxError)(lexer.source, token.start, "Unexpected ".concat((0, _lexer.getTokenDesc)(token)));
  50216. }
  50217. /**
  50218. * Returns a possibly empty list of parse nodes, determined by
  50219. * the parseFn. This list begins with a lex token of openKind
  50220. * and ends with a lex token of closeKind. Advances the parser
  50221. * to the next lex token after the closing token.
  50222. */
  50223. function any(lexer, openKind, parseFn, closeKind) {
  50224. expect(lexer, openKind);
  50225. var nodes = [];
  50226. while (!skip(lexer, closeKind)) {
  50227. nodes.push(parseFn(lexer));
  50228. }
  50229. return nodes;
  50230. }
  50231. /**
  50232. * Returns a non-empty list of parse nodes, determined by
  50233. * the parseFn. This list begins with a lex token of openKind
  50234. * and ends with a lex token of closeKind. Advances the parser
  50235. * to the next lex token after the closing token.
  50236. */
  50237. function many(lexer, openKind, parseFn, closeKind) {
  50238. expect(lexer, openKind);
  50239. var nodes = [parseFn(lexer)];
  50240. while (!skip(lexer, closeKind)) {
  50241. nodes.push(parseFn(lexer));
  50242. }
  50243. return nodes;
  50244. }
  50245. },{"../error":277,"../jsutils/defineToJSON":286,"../jsutils/inspect":288,"./directiveLocation":305,"./kinds":307,"./lexer":308,"./source":313}],311:[function(require,module,exports){
  50246. "use strict";
  50247. Object.defineProperty(exports, "__esModule", {
  50248. value: true
  50249. });
  50250. exports.isDefinitionNode = isDefinitionNode;
  50251. exports.isExecutableDefinitionNode = isExecutableDefinitionNode;
  50252. exports.isSelectionNode = isSelectionNode;
  50253. exports.isValueNode = isValueNode;
  50254. exports.isTypeNode = isTypeNode;
  50255. exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode;
  50256. exports.isTypeDefinitionNode = isTypeDefinitionNode;
  50257. exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode;
  50258. exports.isTypeExtensionNode = isTypeExtensionNode;
  50259. var _kinds = require("./kinds");
  50260. /**
  50261. * Copyright (c) 2018-present, Facebook, Inc.
  50262. *
  50263. * This source code is licensed under the MIT license found in the
  50264. * LICENSE file in the root directory of this source tree.
  50265. *
  50266. *
  50267. */
  50268. function isDefinitionNode(node) {
  50269. return isExecutableDefinitionNode(node) || isTypeSystemDefinitionNode(node) || isTypeSystemExtensionNode(node);
  50270. }
  50271. function isExecutableDefinitionNode(node) {
  50272. return node.kind === _kinds.Kind.OPERATION_DEFINITION || node.kind === _kinds.Kind.FRAGMENT_DEFINITION;
  50273. }
  50274. function isSelectionNode(node) {
  50275. return node.kind === _kinds.Kind.FIELD || node.kind === _kinds.Kind.FRAGMENT_SPREAD || node.kind === _kinds.Kind.INLINE_FRAGMENT;
  50276. }
  50277. function isValueNode(node) {
  50278. return node.kind === _kinds.Kind.VARIABLE || node.kind === _kinds.Kind.INT || node.kind === _kinds.Kind.FLOAT || node.kind === _kinds.Kind.STRING || node.kind === _kinds.Kind.BOOLEAN || node.kind === _kinds.Kind.NULL || node.kind === _kinds.Kind.ENUM || node.kind === _kinds.Kind.LIST || node.kind === _kinds.Kind.OBJECT;
  50279. }
  50280. function isTypeNode(node) {
  50281. return node.kind === _kinds.Kind.NAMED_TYPE || node.kind === _kinds.Kind.LIST_TYPE || node.kind === _kinds.Kind.NON_NULL_TYPE;
  50282. }
  50283. function isTypeSystemDefinitionNode(node) {
  50284. return node.kind === _kinds.Kind.SCHEMA_DEFINITION || isTypeDefinitionNode(node) || node.kind === _kinds.Kind.DIRECTIVE_DEFINITION;
  50285. }
  50286. function isTypeDefinitionNode(node) {
  50287. return node.kind === _kinds.Kind.SCALAR_TYPE_DEFINITION || node.kind === _kinds.Kind.OBJECT_TYPE_DEFINITION || node.kind === _kinds.Kind.INTERFACE_TYPE_DEFINITION || node.kind === _kinds.Kind.UNION_TYPE_DEFINITION || node.kind === _kinds.Kind.ENUM_TYPE_DEFINITION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION;
  50288. }
  50289. function isTypeSystemExtensionNode(node) {
  50290. return node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
  50291. }
  50292. function isTypeExtensionNode(node) {
  50293. return node.kind === _kinds.Kind.SCALAR_TYPE_EXTENSION || node.kind === _kinds.Kind.OBJECT_TYPE_EXTENSION || node.kind === _kinds.Kind.INTERFACE_TYPE_EXTENSION || node.kind === _kinds.Kind.UNION_TYPE_EXTENSION || node.kind === _kinds.Kind.ENUM_TYPE_EXTENSION || node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION;
  50294. }
  50295. },{"./kinds":307}],312:[function(require,module,exports){
  50296. "use strict";
  50297. Object.defineProperty(exports, "__esModule", {
  50298. value: true
  50299. });
  50300. exports.print = print;
  50301. var _visitor = require("./visitor");
  50302. /**
  50303. * Copyright (c) 2015-present, Facebook, Inc.
  50304. *
  50305. * This source code is licensed under the MIT license found in the
  50306. * LICENSE file in the root directory of this source tree.
  50307. *
  50308. *
  50309. */
  50310. /**
  50311. * Converts an AST into a string, using one set of reasonable
  50312. * formatting rules.
  50313. */
  50314. function print(ast) {
  50315. return (0, _visitor.visit)(ast, {
  50316. leave: printDocASTReducer
  50317. });
  50318. }
  50319. var printDocASTReducer = {
  50320. Name: function Name(node) {
  50321. return node.value;
  50322. },
  50323. Variable: function Variable(node) {
  50324. return '$' + node.name;
  50325. },
  50326. // Document
  50327. Document: function Document(node) {
  50328. return join(node.definitions, '\n\n') + '\n';
  50329. },
  50330. OperationDefinition: function OperationDefinition(node) {
  50331. var op = node.operation;
  50332. var name = node.name;
  50333. var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
  50334. var directives = join(node.directives, ' ');
  50335. var selectionSet = node.selectionSet; // Anonymous queries with no directives or variable definitions can use
  50336. // the query short form.
  50337. return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
  50338. },
  50339. VariableDefinition: function VariableDefinition(_ref) {
  50340. var variable = _ref.variable,
  50341. type = _ref.type,
  50342. defaultValue = _ref.defaultValue,
  50343. directives = _ref.directives;
  50344. return variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' '));
  50345. },
  50346. SelectionSet: function SelectionSet(_ref2) {
  50347. var selections = _ref2.selections;
  50348. return block(selections);
  50349. },
  50350. Field: function Field(_ref3) {
  50351. var alias = _ref3.alias,
  50352. name = _ref3.name,
  50353. args = _ref3.arguments,
  50354. directives = _ref3.directives,
  50355. selectionSet = _ref3.selectionSet;
  50356. return join([wrap('', alias, ': ') + name + wrap('(', join(args, ', '), ')'), join(directives, ' '), selectionSet], ' ');
  50357. },
  50358. Argument: function Argument(_ref4) {
  50359. var name = _ref4.name,
  50360. value = _ref4.value;
  50361. return name + ': ' + value;
  50362. },
  50363. // Fragments
  50364. FragmentSpread: function FragmentSpread(_ref5) {
  50365. var name = _ref5.name,
  50366. directives = _ref5.directives;
  50367. return '...' + name + wrap(' ', join(directives, ' '));
  50368. },
  50369. InlineFragment: function InlineFragment(_ref6) {
  50370. var typeCondition = _ref6.typeCondition,
  50371. directives = _ref6.directives,
  50372. selectionSet = _ref6.selectionSet;
  50373. return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
  50374. },
  50375. FragmentDefinition: function FragmentDefinition(_ref7) {
  50376. var name = _ref7.name,
  50377. typeCondition = _ref7.typeCondition,
  50378. variableDefinitions = _ref7.variableDefinitions,
  50379. directives = _ref7.directives,
  50380. selectionSet = _ref7.selectionSet;
  50381. return (// Note: fragment variable definitions are experimental and may be changed
  50382. // or removed in the future.
  50383. "fragment ".concat(name).concat(wrap('(', join(variableDefinitions, ', '), ')'), " ") + "on ".concat(typeCondition, " ").concat(wrap('', join(directives, ' '), ' ')) + selectionSet
  50384. );
  50385. },
  50386. // Value
  50387. IntValue: function IntValue(_ref8) {
  50388. var value = _ref8.value;
  50389. return value;
  50390. },
  50391. FloatValue: function FloatValue(_ref9) {
  50392. var value = _ref9.value;
  50393. return value;
  50394. },
  50395. StringValue: function StringValue(_ref10, key) {
  50396. var value = _ref10.value,
  50397. isBlockString = _ref10.block;
  50398. return isBlockString ? printBlockString(value, key === 'description') : JSON.stringify(value);
  50399. },
  50400. BooleanValue: function BooleanValue(_ref11) {
  50401. var value = _ref11.value;
  50402. return value ? 'true' : 'false';
  50403. },
  50404. NullValue: function NullValue() {
  50405. return 'null';
  50406. },
  50407. EnumValue: function EnumValue(_ref12) {
  50408. var value = _ref12.value;
  50409. return value;
  50410. },
  50411. ListValue: function ListValue(_ref13) {
  50412. var values = _ref13.values;
  50413. return '[' + join(values, ', ') + ']';
  50414. },
  50415. ObjectValue: function ObjectValue(_ref14) {
  50416. var fields = _ref14.fields;
  50417. return '{' + join(fields, ', ') + '}';
  50418. },
  50419. ObjectField: function ObjectField(_ref15) {
  50420. var name = _ref15.name,
  50421. value = _ref15.value;
  50422. return name + ': ' + value;
  50423. },
  50424. // Directive
  50425. Directive: function Directive(_ref16) {
  50426. var name = _ref16.name,
  50427. args = _ref16.arguments;
  50428. return '@' + name + wrap('(', join(args, ', '), ')');
  50429. },
  50430. // Type
  50431. NamedType: function NamedType(_ref17) {
  50432. var name = _ref17.name;
  50433. return name;
  50434. },
  50435. ListType: function ListType(_ref18) {
  50436. var type = _ref18.type;
  50437. return '[' + type + ']';
  50438. },
  50439. NonNullType: function NonNullType(_ref19) {
  50440. var type = _ref19.type;
  50441. return type + '!';
  50442. },
  50443. // Type System Definitions
  50444. SchemaDefinition: function SchemaDefinition(_ref20) {
  50445. var directives = _ref20.directives,
  50446. operationTypes = _ref20.operationTypes;
  50447. return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
  50448. },
  50449. OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
  50450. var operation = _ref21.operation,
  50451. type = _ref21.type;
  50452. return operation + ': ' + type;
  50453. },
  50454. ScalarTypeDefinition: addDescription(function (_ref22) {
  50455. var name = _ref22.name,
  50456. directives = _ref22.directives;
  50457. return join(['scalar', name, join(directives, ' ')], ' ');
  50458. }),
  50459. ObjectTypeDefinition: addDescription(function (_ref23) {
  50460. var name = _ref23.name,
  50461. interfaces = _ref23.interfaces,
  50462. directives = _ref23.directives,
  50463. fields = _ref23.fields;
  50464. return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  50465. }),
  50466. FieldDefinition: addDescription(function (_ref24) {
  50467. var name = _ref24.name,
  50468. args = _ref24.arguments,
  50469. type = _ref24.type,
  50470. directives = _ref24.directives;
  50471. return name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ': ' + type + wrap(' ', join(directives, ' '));
  50472. }),
  50473. InputValueDefinition: addDescription(function (_ref25) {
  50474. var name = _ref25.name,
  50475. type = _ref25.type,
  50476. defaultValue = _ref25.defaultValue,
  50477. directives = _ref25.directives;
  50478. return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
  50479. }),
  50480. InterfaceTypeDefinition: addDescription(function (_ref26) {
  50481. var name = _ref26.name,
  50482. directives = _ref26.directives,
  50483. fields = _ref26.fields;
  50484. return join(['interface', name, join(directives, ' '), block(fields)], ' ');
  50485. }),
  50486. UnionTypeDefinition: addDescription(function (_ref27) {
  50487. var name = _ref27.name,
  50488. directives = _ref27.directives,
  50489. types = _ref27.types;
  50490. return join(['union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  50491. }),
  50492. EnumTypeDefinition: addDescription(function (_ref28) {
  50493. var name = _ref28.name,
  50494. directives = _ref28.directives,
  50495. values = _ref28.values;
  50496. return join(['enum', name, join(directives, ' '), block(values)], ' ');
  50497. }),
  50498. EnumValueDefinition: addDescription(function (_ref29) {
  50499. var name = _ref29.name,
  50500. directives = _ref29.directives;
  50501. return join([name, join(directives, ' ')], ' ');
  50502. }),
  50503. InputObjectTypeDefinition: addDescription(function (_ref30) {
  50504. var name = _ref30.name,
  50505. directives = _ref30.directives,
  50506. fields = _ref30.fields;
  50507. return join(['input', name, join(directives, ' '), block(fields)], ' ');
  50508. }),
  50509. DirectiveDefinition: addDescription(function (_ref31) {
  50510. var name = _ref31.name,
  50511. args = _ref31.arguments,
  50512. locations = _ref31.locations;
  50513. return 'directive @' + name + (hasMultilineItems(args) ? wrap('(\n', indent(join(args, '\n')), '\n)') : wrap('(', join(args, ', '), ')')) + ' on ' + join(locations, ' | ');
  50514. }),
  50515. SchemaExtension: function SchemaExtension(_ref32) {
  50516. var directives = _ref32.directives,
  50517. operationTypes = _ref32.operationTypes;
  50518. return join(['extend schema', join(directives, ' '), block(operationTypes)], ' ');
  50519. },
  50520. ScalarTypeExtension: function ScalarTypeExtension(_ref33) {
  50521. var name = _ref33.name,
  50522. directives = _ref33.directives;
  50523. return join(['extend scalar', name, join(directives, ' ')], ' ');
  50524. },
  50525. ObjectTypeExtension: function ObjectTypeExtension(_ref34) {
  50526. var name = _ref34.name,
  50527. interfaces = _ref34.interfaces,
  50528. directives = _ref34.directives,
  50529. fields = _ref34.fields;
  50530. return join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
  50531. },
  50532. InterfaceTypeExtension: function InterfaceTypeExtension(_ref35) {
  50533. var name = _ref35.name,
  50534. directives = _ref35.directives,
  50535. fields = _ref35.fields;
  50536. return join(['extend interface', name, join(directives, ' '), block(fields)], ' ');
  50537. },
  50538. UnionTypeExtension: function UnionTypeExtension(_ref36) {
  50539. var name = _ref36.name,
  50540. directives = _ref36.directives,
  50541. types = _ref36.types;
  50542. return join(['extend union', name, join(directives, ' '), types && types.length !== 0 ? '= ' + join(types, ' | ') : ''], ' ');
  50543. },
  50544. EnumTypeExtension: function EnumTypeExtension(_ref37) {
  50545. var name = _ref37.name,
  50546. directives = _ref37.directives,
  50547. values = _ref37.values;
  50548. return join(['extend enum', name, join(directives, ' '), block(values)], ' ');
  50549. },
  50550. InputObjectTypeExtension: function InputObjectTypeExtension(_ref38) {
  50551. var name = _ref38.name,
  50552. directives = _ref38.directives,
  50553. fields = _ref38.fields;
  50554. return join(['extend input', name, join(directives, ' '), block(fields)], ' ');
  50555. }
  50556. };
  50557. function addDescription(cb) {
  50558. return function (node) {
  50559. return join([node.description, cb(node)], '\n');
  50560. };
  50561. }
  50562. /**
  50563. * Given maybeArray, print an empty string if it is null or empty, otherwise
  50564. * print all items together separated by separator if provided
  50565. */
  50566. function join(maybeArray, separator) {
  50567. return maybeArray ? maybeArray.filter(function (x) {
  50568. return x;
  50569. }).join(separator || '') : '';
  50570. }
  50571. /**
  50572. * Given array, print each item on its own line, wrapped in an
  50573. * indented "{ }" block.
  50574. */
  50575. function block(array) {
  50576. return array && array.length !== 0 ? '{\n' + indent(join(array, '\n')) + '\n}' : '';
  50577. }
  50578. /**
  50579. * If maybeString is not null or empty, then wrap with start and end, otherwise
  50580. * print an empty string.
  50581. */
  50582. function wrap(start, maybeString, end) {
  50583. return maybeString ? start + maybeString + (end || '') : '';
  50584. }
  50585. function indent(maybeString) {
  50586. return maybeString && ' ' + maybeString.replace(/\n/g, '\n ');
  50587. }
  50588. function isMultiline(string) {
  50589. return string.indexOf('\n') !== -1;
  50590. }
  50591. function hasMultilineItems(maybeArray) {
  50592. return maybeArray && maybeArray.some(isMultiline);
  50593. }
  50594. /**
  50595. * Print a block string in the indented block form by adding a leading and
  50596. * trailing blank line. However, if a block string starts with whitespace and is
  50597. * a single-line, adding a leading blank line would strip that whitespace.
  50598. */
  50599. function printBlockString(value, isDescription) {
  50600. var escaped = value.replace(/"""/g, '\\"""');
  50601. return isMultiline(value) || value[0] !== ' ' && value[0] !== '\t' ? "\"\"\"\n".concat(isDescription ? escaped : indent(escaped), "\n\"\"\"") : "\"\"\"".concat(escaped.replace(/"$/, '"\n'), "\"\"\"");
  50602. }
  50603. },{"./visitor":314}],313:[function(require,module,exports){
  50604. "use strict";
  50605. Object.defineProperty(exports, "__esModule", {
  50606. value: true
  50607. });
  50608. exports.Source = void 0;
  50609. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  50610. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  50611. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  50612. /**
  50613. * Copyright (c) 2015-present, Facebook, Inc.
  50614. *
  50615. * This source code is licensed under the MIT license found in the
  50616. * LICENSE file in the root directory of this source tree.
  50617. *
  50618. *
  50619. */
  50620. /**
  50621. * A representation of source input to GraphQL.
  50622. * `name` and `locationOffset` are optional. They are useful for clients who
  50623. * store GraphQL documents in source files; for example, if the GraphQL input
  50624. * starts at line 40 in a file named Foo.graphql, it might be useful for name to
  50625. * be "Foo.graphql" and location to be `{ line: 40, column: 0 }`.
  50626. * line and column in locationOffset are 1-indexed
  50627. */
  50628. var Source = function Source(body, name, locationOffset) {
  50629. this.body = body;
  50630. this.name = name || 'GraphQL request';
  50631. this.locationOffset = locationOffset || {
  50632. line: 1,
  50633. column: 1
  50634. };
  50635. !(this.locationOffset.line > 0) ? (0, _invariant.default)(0, 'line in locationOffset is 1-indexed and must be positive') : void 0;
  50636. !(this.locationOffset.column > 0) ? (0, _invariant.default)(0, 'column in locationOffset is 1-indexed and must be positive') : void 0;
  50637. }; // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  50638. exports.Source = Source;
  50639. (0, _defineToStringTag.default)(Source);
  50640. },{"../jsutils/defineToStringTag":287,"../jsutils/invariant":290}],314:[function(require,module,exports){
  50641. "use strict";
  50642. Object.defineProperty(exports, "__esModule", {
  50643. value: true
  50644. });
  50645. exports.visit = visit;
  50646. exports.visitInParallel = visitInParallel;
  50647. exports.visitWithTypeInfo = visitWithTypeInfo;
  50648. exports.getVisitFn = getVisitFn;
  50649. exports.BREAK = exports.QueryDocumentKeys = void 0;
  50650. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  50651. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  50652. /**
  50653. * Copyright (c) 2015-present, Facebook, Inc.
  50654. *
  50655. * This source code is licensed under the MIT license found in the
  50656. * LICENSE file in the root directory of this source tree.
  50657. *
  50658. *
  50659. */
  50660. var QueryDocumentKeys = {
  50661. Name: [],
  50662. Document: ['definitions'],
  50663. OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
  50664. VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'],
  50665. Variable: ['name'],
  50666. SelectionSet: ['selections'],
  50667. Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
  50668. Argument: ['name', 'value'],
  50669. FragmentSpread: ['name', 'directives'],
  50670. InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
  50671. FragmentDefinition: ['name', // Note: fragment variable definitions are experimental and may be changed
  50672. // or removed in the future.
  50673. 'variableDefinitions', 'typeCondition', 'directives', 'selectionSet'],
  50674. IntValue: [],
  50675. FloatValue: [],
  50676. StringValue: [],
  50677. BooleanValue: [],
  50678. NullValue: [],
  50679. EnumValue: [],
  50680. ListValue: ['values'],
  50681. ObjectValue: ['fields'],
  50682. ObjectField: ['name', 'value'],
  50683. Directive: ['name', 'arguments'],
  50684. NamedType: ['name'],
  50685. ListType: ['type'],
  50686. NonNullType: ['type'],
  50687. SchemaDefinition: ['directives', 'operationTypes'],
  50688. OperationTypeDefinition: ['type'],
  50689. ScalarTypeDefinition: ['description', 'name', 'directives'],
  50690. ObjectTypeDefinition: ['description', 'name', 'interfaces', 'directives', 'fields'],
  50691. FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'],
  50692. InputValueDefinition: ['description', 'name', 'type', 'defaultValue', 'directives'],
  50693. InterfaceTypeDefinition: ['description', 'name', 'directives', 'fields'],
  50694. UnionTypeDefinition: ['description', 'name', 'directives', 'types'],
  50695. EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
  50696. EnumValueDefinition: ['description', 'name', 'directives'],
  50697. InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
  50698. DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
  50699. SchemaExtension: ['directives', 'operationTypes'],
  50700. ScalarTypeExtension: ['name', 'directives'],
  50701. ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
  50702. InterfaceTypeExtension: ['name', 'directives', 'fields'],
  50703. UnionTypeExtension: ['name', 'directives', 'types'],
  50704. EnumTypeExtension: ['name', 'directives', 'values'],
  50705. InputObjectTypeExtension: ['name', 'directives', 'fields']
  50706. };
  50707. exports.QueryDocumentKeys = QueryDocumentKeys;
  50708. var BREAK = {};
  50709. /**
  50710. * visit() will walk through an AST using a depth first traversal, calling
  50711. * the visitor's enter function at each node in the traversal, and calling the
  50712. * leave function after visiting that node and all of its child nodes.
  50713. *
  50714. * By returning different values from the enter and leave functions, the
  50715. * behavior of the visitor can be altered, including skipping over a sub-tree of
  50716. * the AST (by returning false), editing the AST by returning a value or null
  50717. * to remove the value, or to stop the whole traversal by returning BREAK.
  50718. *
  50719. * When using visit() to edit an AST, the original AST will not be modified, and
  50720. * a new version of the AST with the changes applied will be returned from the
  50721. * visit function.
  50722. *
  50723. * const editedAST = visit(ast, {
  50724. * enter(node, key, parent, path, ancestors) {
  50725. * // @return
  50726. * // undefined: no action
  50727. * // false: skip visiting this node
  50728. * // visitor.BREAK: stop visiting altogether
  50729. * // null: delete this node
  50730. * // any value: replace this node with the returned value
  50731. * },
  50732. * leave(node, key, parent, path, ancestors) {
  50733. * // @return
  50734. * // undefined: no action
  50735. * // false: no action
  50736. * // visitor.BREAK: stop visiting altogether
  50737. * // null: delete this node
  50738. * // any value: replace this node with the returned value
  50739. * }
  50740. * });
  50741. *
  50742. * Alternatively to providing enter() and leave() functions, a visitor can
  50743. * instead provide functions named the same as the kinds of AST nodes, or
  50744. * enter/leave visitors at a named key, leading to four permutations of
  50745. * visitor API:
  50746. *
  50747. * 1) Named visitors triggered when entering a node a specific kind.
  50748. *
  50749. * visit(ast, {
  50750. * Kind(node) {
  50751. * // enter the "Kind" node
  50752. * }
  50753. * })
  50754. *
  50755. * 2) Named visitors that trigger upon entering and leaving a node of
  50756. * a specific kind.
  50757. *
  50758. * visit(ast, {
  50759. * Kind: {
  50760. * enter(node) {
  50761. * // enter the "Kind" node
  50762. * }
  50763. * leave(node) {
  50764. * // leave the "Kind" node
  50765. * }
  50766. * }
  50767. * })
  50768. *
  50769. * 3) Generic visitors that trigger upon entering and leaving any node.
  50770. *
  50771. * visit(ast, {
  50772. * enter(node) {
  50773. * // enter any node
  50774. * },
  50775. * leave(node) {
  50776. * // leave any node
  50777. * }
  50778. * })
  50779. *
  50780. * 4) Parallel visitors for entering and leaving nodes of a specific kind.
  50781. *
  50782. * visit(ast, {
  50783. * enter: {
  50784. * Kind(node) {
  50785. * // enter the "Kind" node
  50786. * }
  50787. * },
  50788. * leave: {
  50789. * Kind(node) {
  50790. * // leave the "Kind" node
  50791. * }
  50792. * }
  50793. * })
  50794. */
  50795. exports.BREAK = BREAK;
  50796. function visit(root, visitor) {
  50797. var visitorKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QueryDocumentKeys;
  50798. /* eslint-disable no-undef-init */
  50799. var stack = undefined;
  50800. var inArray = Array.isArray(root);
  50801. var keys = [root];
  50802. var index = -1;
  50803. var edits = [];
  50804. var node = undefined;
  50805. var key = undefined;
  50806. var parent = undefined;
  50807. var path = [];
  50808. var ancestors = [];
  50809. var newRoot = root;
  50810. /* eslint-enable no-undef-init */
  50811. do {
  50812. index++;
  50813. var isLeaving = index === keys.length;
  50814. var isEdited = isLeaving && edits.length !== 0;
  50815. if (isLeaving) {
  50816. key = ancestors.length === 0 ? undefined : path[path.length - 1];
  50817. node = parent;
  50818. parent = ancestors.pop();
  50819. if (isEdited) {
  50820. if (inArray) {
  50821. node = node.slice();
  50822. } else {
  50823. var clone = {};
  50824. var _arr = Object.keys(node);
  50825. for (var _i = 0; _i < _arr.length; _i++) {
  50826. var k = _arr[_i];
  50827. clone[k] = node[k];
  50828. }
  50829. node = clone;
  50830. }
  50831. var editOffset = 0;
  50832. for (var ii = 0; ii < edits.length; ii++) {
  50833. var editKey = edits[ii][0];
  50834. var editValue = edits[ii][1];
  50835. if (inArray) {
  50836. editKey -= editOffset;
  50837. }
  50838. if (inArray && editValue === null) {
  50839. node.splice(editKey, 1);
  50840. editOffset++;
  50841. } else {
  50842. node[editKey] = editValue;
  50843. }
  50844. }
  50845. }
  50846. index = stack.index;
  50847. keys = stack.keys;
  50848. edits = stack.edits;
  50849. inArray = stack.inArray;
  50850. stack = stack.prev;
  50851. } else {
  50852. key = parent ? inArray ? index : keys[index] : undefined;
  50853. node = parent ? parent[key] : newRoot;
  50854. if (node === null || node === undefined) {
  50855. continue;
  50856. }
  50857. if (parent) {
  50858. path.push(key);
  50859. }
  50860. }
  50861. var result = void 0;
  50862. if (!Array.isArray(node)) {
  50863. if (!isNode(node)) {
  50864. throw new Error('Invalid AST Node: ' + (0, _inspect.default)(node));
  50865. }
  50866. var visitFn = getVisitFn(visitor, node.kind, isLeaving);
  50867. if (visitFn) {
  50868. result = visitFn.call(visitor, node, key, parent, path, ancestors);
  50869. if (result === BREAK) {
  50870. break;
  50871. }
  50872. if (result === false) {
  50873. if (!isLeaving) {
  50874. path.pop();
  50875. continue;
  50876. }
  50877. } else if (result !== undefined) {
  50878. edits.push([key, result]);
  50879. if (!isLeaving) {
  50880. if (isNode(result)) {
  50881. node = result;
  50882. } else {
  50883. path.pop();
  50884. continue;
  50885. }
  50886. }
  50887. }
  50888. }
  50889. }
  50890. if (result === undefined && isEdited) {
  50891. edits.push([key, node]);
  50892. }
  50893. if (isLeaving) {
  50894. path.pop();
  50895. } else {
  50896. stack = {
  50897. inArray: inArray,
  50898. index: index,
  50899. keys: keys,
  50900. edits: edits,
  50901. prev: stack
  50902. };
  50903. inArray = Array.isArray(node);
  50904. keys = inArray ? node : visitorKeys[node.kind] || [];
  50905. index = -1;
  50906. edits = [];
  50907. if (parent) {
  50908. ancestors.push(parent);
  50909. }
  50910. parent = node;
  50911. }
  50912. } while (stack !== undefined);
  50913. if (edits.length !== 0) {
  50914. newRoot = edits[edits.length - 1][1];
  50915. }
  50916. return newRoot;
  50917. }
  50918. function isNode(maybeNode) {
  50919. return Boolean(maybeNode && typeof maybeNode.kind === 'string');
  50920. }
  50921. /**
  50922. * Creates a new visitor instance which delegates to many visitors to run in
  50923. * parallel. Each visitor will be visited for each node before moving on.
  50924. *
  50925. * If a prior visitor edits a node, no following visitors will see that node.
  50926. */
  50927. function visitInParallel(visitors) {
  50928. var skipping = new Array(visitors.length);
  50929. return {
  50930. enter: function enter(node) {
  50931. for (var i = 0; i < visitors.length; i++) {
  50932. if (!skipping[i]) {
  50933. var fn = getVisitFn(visitors[i], node.kind,
  50934. /* isLeaving */
  50935. false);
  50936. if (fn) {
  50937. var result = fn.apply(visitors[i], arguments);
  50938. if (result === false) {
  50939. skipping[i] = node;
  50940. } else if (result === BREAK) {
  50941. skipping[i] = BREAK;
  50942. } else if (result !== undefined) {
  50943. return result;
  50944. }
  50945. }
  50946. }
  50947. }
  50948. },
  50949. leave: function leave(node) {
  50950. for (var i = 0; i < visitors.length; i++) {
  50951. if (!skipping[i]) {
  50952. var fn = getVisitFn(visitors[i], node.kind,
  50953. /* isLeaving */
  50954. true);
  50955. if (fn) {
  50956. var result = fn.apply(visitors[i], arguments);
  50957. if (result === BREAK) {
  50958. skipping[i] = BREAK;
  50959. } else if (result !== undefined && result !== false) {
  50960. return result;
  50961. }
  50962. }
  50963. } else if (skipping[i] === node) {
  50964. skipping[i] = null;
  50965. }
  50966. }
  50967. }
  50968. };
  50969. }
  50970. /**
  50971. * Creates a new visitor instance which maintains a provided TypeInfo instance
  50972. * along with visiting visitor.
  50973. */
  50974. function visitWithTypeInfo(typeInfo, visitor) {
  50975. return {
  50976. enter: function enter(node) {
  50977. typeInfo.enter(node);
  50978. var fn = getVisitFn(visitor, node.kind,
  50979. /* isLeaving */
  50980. false);
  50981. if (fn) {
  50982. var result = fn.apply(visitor, arguments);
  50983. if (result !== undefined) {
  50984. typeInfo.leave(node);
  50985. if (isNode(result)) {
  50986. typeInfo.enter(result);
  50987. }
  50988. }
  50989. return result;
  50990. }
  50991. },
  50992. leave: function leave(node) {
  50993. var fn = getVisitFn(visitor, node.kind,
  50994. /* isLeaving */
  50995. true);
  50996. var result;
  50997. if (fn) {
  50998. result = fn.apply(visitor, arguments);
  50999. }
  51000. typeInfo.leave(node);
  51001. return result;
  51002. }
  51003. };
  51004. }
  51005. /**
  51006. * Given a visitor instance, if it is leaving or not, and a node kind, return
  51007. * the function the visitor runtime should call.
  51008. */
  51009. function getVisitFn(visitor, kind, isLeaving) {
  51010. var kindVisitor = visitor[kind];
  51011. if (kindVisitor) {
  51012. if (!isLeaving && typeof kindVisitor === 'function') {
  51013. // { Kind() {} }
  51014. return kindVisitor;
  51015. }
  51016. var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
  51017. if (typeof kindSpecificVisitor === 'function') {
  51018. // { Kind: { enter() {}, leave() {} } }
  51019. return kindSpecificVisitor;
  51020. }
  51021. } else {
  51022. var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
  51023. if (specificVisitor) {
  51024. if (typeof specificVisitor === 'function') {
  51025. // { enter() {}, leave() {} }
  51026. return specificVisitor;
  51027. }
  51028. var specificKindVisitor = specificVisitor[kind];
  51029. if (typeof specificKindVisitor === 'function') {
  51030. // { enter: { Kind() {} }, leave: { Kind() {} } }
  51031. return specificKindVisitor;
  51032. }
  51033. }
  51034. }
  51035. }
  51036. },{"../jsutils/inspect":288}],315:[function(require,module,exports){
  51037. "use strict";
  51038. Object.defineProperty(exports, "__esModule", {
  51039. value: true
  51040. });
  51041. exports.default = void 0;
  51042. /**
  51043. * Copyright (c) 2015-present, Facebook, Inc.
  51044. *
  51045. * This source code is licensed under the MIT license found in the
  51046. * LICENSE file in the root directory of this source tree.
  51047. *
  51048. *
  51049. */
  51050. /* eslint-disable no-redeclare */
  51051. // $FlowFixMe
  51052. var find = Array.prototype.find ? function (list, predicate) {
  51053. return Array.prototype.find.call(list, predicate);
  51054. } : function (list, predicate) {
  51055. for (var i = 0; i < list.length; i++) {
  51056. var value = list[i];
  51057. if (predicate(value)) {
  51058. return value;
  51059. }
  51060. }
  51061. };
  51062. var _default = find;
  51063. exports.default = _default;
  51064. },{}],316:[function(require,module,exports){
  51065. "use strict";
  51066. Object.defineProperty(exports, "__esModule", {
  51067. value: true
  51068. });
  51069. exports.default = void 0;
  51070. /**
  51071. * Copyright (c) 2018-present, Facebook, Inc.
  51072. *
  51073. * This source code is licensed under the MIT license found in the
  51074. * LICENSE file in the root directory of this source tree.
  51075. *
  51076. *
  51077. */
  51078. /* eslint-disable no-redeclare */
  51079. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
  51080. var isFinite = Number.isFinite || function (value) {
  51081. return typeof value === 'number' && isFinite(value);
  51082. };
  51083. var _default = isFinite;
  51084. exports.default = _default;
  51085. },{}],317:[function(require,module,exports){
  51086. "use strict";
  51087. Object.defineProperty(exports, "__esModule", {
  51088. value: true
  51089. });
  51090. exports.default = void 0;
  51091. /**
  51092. * Copyright (c) 2018-present, Facebook, Inc.
  51093. *
  51094. * This source code is licensed under the MIT license found in the
  51095. * LICENSE file in the root directory of this source tree.
  51096. *
  51097. *
  51098. */
  51099. /* eslint-disable no-redeclare */
  51100. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
  51101. var isInteger = Number.isInteger || function (value) {
  51102. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  51103. };
  51104. var _default = isInteger;
  51105. exports.default = _default;
  51106. },{}],318:[function(require,module,exports){
  51107. "use strict";
  51108. Object.defineProperty(exports, "__esModule", {
  51109. value: true
  51110. });
  51111. exports.default = void 0;
  51112. /**
  51113. * Copyright (c) 2019-present, Facebook, Inc.
  51114. *
  51115. * This source code is licensed under the MIT license found in the
  51116. * LICENSE file in the root directory of this source tree.
  51117. *
  51118. *
  51119. */
  51120. /* eslint-disable no-redeclare */
  51121. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/5838
  51122. var objectEntries = Object.entries || function (obj) {
  51123. return Object.keys(obj).map(function (key) {
  51124. return [key, obj[key]];
  51125. });
  51126. };
  51127. var _default = objectEntries;
  51128. exports.default = _default;
  51129. },{}],319:[function(require,module,exports){
  51130. "use strict";
  51131. Object.defineProperty(exports, "__esModule", {
  51132. value: true
  51133. });
  51134. exports.default = void 0;
  51135. /**
  51136. * Copyright (c) 2015-present, Facebook, Inc.
  51137. *
  51138. * This source code is licensed under the MIT license found in the
  51139. * LICENSE file in the root directory of this source tree.
  51140. *
  51141. *
  51142. */
  51143. /* eslint-disable no-redeclare */
  51144. // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/2221
  51145. var objectValues = Object.values || function (obj) {
  51146. return Object.keys(obj).map(function (key) {
  51147. return obj[key];
  51148. });
  51149. };
  51150. var _default = objectValues;
  51151. exports.default = _default;
  51152. },{}],320:[function(require,module,exports){
  51153. "use strict";
  51154. Object.defineProperty(exports, "__esModule", {
  51155. value: true
  51156. });
  51157. Object.defineProperty(exports, "subscribe", {
  51158. enumerable: true,
  51159. get: function get() {
  51160. return _subscribe.subscribe;
  51161. }
  51162. });
  51163. Object.defineProperty(exports, "createSourceEventStream", {
  51164. enumerable: true,
  51165. get: function get() {
  51166. return _subscribe.createSourceEventStream;
  51167. }
  51168. });
  51169. var _subscribe = require("./subscribe");
  51170. },{"./subscribe":322}],321:[function(require,module,exports){
  51171. "use strict";
  51172. Object.defineProperty(exports, "__esModule", {
  51173. value: true
  51174. });
  51175. exports.default = mapAsyncIterator;
  51176. var _iterall = require("iterall");
  51177. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  51178. /**
  51179. * Given an AsyncIterable and a callback function, return an AsyncIterator
  51180. * which produces values mapped via calling the callback function.
  51181. */
  51182. function mapAsyncIterator(iterable, callback, rejectCallback) {
  51183. var iterator = (0, _iterall.getAsyncIterator)(iterable);
  51184. var $return;
  51185. var abruptClose; // $FlowFixMe(>=0.68.0)
  51186. if (typeof iterator.return === 'function') {
  51187. $return = iterator.return;
  51188. abruptClose = function abruptClose(error) {
  51189. var rethrow = function rethrow() {
  51190. return Promise.reject(error);
  51191. };
  51192. return $return.call(iterator).then(rethrow, rethrow);
  51193. };
  51194. }
  51195. function mapResult(result) {
  51196. return result.done ? result : asyncMapValue(result.value, callback).then(iteratorResult, abruptClose);
  51197. }
  51198. var mapReject;
  51199. if (rejectCallback) {
  51200. // Capture rejectCallback to ensure it cannot be null.
  51201. var reject = rejectCallback;
  51202. mapReject = function mapReject(error) {
  51203. return asyncMapValue(error, reject).then(iteratorResult, abruptClose);
  51204. };
  51205. }
  51206. /* TODO: Flow doesn't support symbols as keys:
  51207. https://github.com/facebook/flow/issues/3258 */
  51208. return _defineProperty({
  51209. next: function next() {
  51210. return iterator.next().then(mapResult, mapReject);
  51211. },
  51212. return: function _return() {
  51213. return $return ? $return.call(iterator).then(mapResult, mapReject) : Promise.resolve({
  51214. value: undefined,
  51215. done: true
  51216. });
  51217. },
  51218. throw: function _throw(error) {
  51219. // $FlowFixMe(>=0.68.0)
  51220. if (typeof iterator.throw === 'function') {
  51221. return iterator.throw(error).then(mapResult, mapReject);
  51222. }
  51223. return Promise.reject(error).catch(abruptClose);
  51224. }
  51225. }, _iterall.$$asyncIterator, function () {
  51226. return this;
  51227. });
  51228. }
  51229. function asyncMapValue(value, callback) {
  51230. return new Promise(function (resolve) {
  51231. return resolve(callback(value));
  51232. });
  51233. }
  51234. function iteratorResult(value) {
  51235. return {
  51236. value: value,
  51237. done: false
  51238. };
  51239. }
  51240. },{"iterall":137}],322:[function(require,module,exports){
  51241. "use strict";
  51242. Object.defineProperty(exports, "__esModule", {
  51243. value: true
  51244. });
  51245. exports.subscribe = subscribe;
  51246. exports.createSourceEventStream = createSourceEventStream;
  51247. var _iterall = require("iterall");
  51248. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  51249. var _GraphQLError = require("../error/GraphQLError");
  51250. var _locatedError = require("../error/locatedError");
  51251. var _execute = require("../execution/execute");
  51252. var _mapAsyncIterator = _interopRequireDefault(require("./mapAsyncIterator"));
  51253. var _getOperationRootType = require("../utilities/getOperationRootType");
  51254. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  51255. /**
  51256. * Copyright (c) 2017-present, Facebook, Inc.
  51257. *
  51258. * This source code is licensed under the MIT license found in the
  51259. * LICENSE file in the root directory of this source tree.
  51260. *
  51261. *
  51262. */
  51263. function subscribe(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {
  51264. /* eslint-enable no-redeclare */
  51265. // Extract arguments from object args if provided.
  51266. return arguments.length === 1 ? subscribeImpl(argsOrSchema.schema, argsOrSchema.document, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.subscribeFieldResolver) : subscribeImpl(argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver);
  51267. }
  51268. /**
  51269. * This function checks if the error is a GraphQLError. If it is, report it as
  51270. * an ExecutionResult, containing only errors and no data. Otherwise treat the
  51271. * error as a system-class error and re-throw it.
  51272. */
  51273. function reportGraphQLError(error) {
  51274. if (error instanceof _GraphQLError.GraphQLError) {
  51275. return {
  51276. errors: [error]
  51277. };
  51278. }
  51279. throw error;
  51280. }
  51281. function subscribeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {
  51282. var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); // For each payload yielded from a subscription, map it over the normal
  51283. // GraphQL `execute` function, with `payload` as the rootValue.
  51284. // This implements the "MapSourceToResponseEvent" algorithm described in
  51285. // the GraphQL specification. The `execute` function provides the
  51286. // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the
  51287. // "ExecuteQuery" algorithm, for which `execute` is also used.
  51288. var mapSourceToResponse = function mapSourceToResponse(payload) {
  51289. return (0, _execute.execute)(schema, document, payload, contextValue, variableValues, operationName, fieldResolver);
  51290. }; // Resolve the Source Stream, then map every source value to a
  51291. // ExecutionResult value as described above.
  51292. return sourcePromise.then(function (resultOrStream) {
  51293. return (// Note: Flow can't refine isAsyncIterable, so explicit casts are used.
  51294. (0, _iterall.isAsyncIterable)(resultOrStream) ? (0, _mapAsyncIterator.default)(resultOrStream, mapSourceToResponse, reportGraphQLError) : resultOrStream
  51295. );
  51296. }, reportGraphQLError);
  51297. }
  51298. /**
  51299. * Implements the "CreateSourceEventStream" algorithm described in the
  51300. * GraphQL specification, resolving the subscription source event stream.
  51301. *
  51302. * Returns a Promise<AsyncIterable>.
  51303. *
  51304. * If the client-provided invalid arguments, the source stream could not be
  51305. * created, or the resolver did not return an AsyncIterable, this function will
  51306. * will throw an error, which should be caught and handled by the caller.
  51307. *
  51308. * A Source Event Stream represents a sequence of events, each of which triggers
  51309. * a GraphQL execution for that event.
  51310. *
  51311. * This may be useful when hosting the stateful subscription service in a
  51312. * different process or machine than the stateless GraphQL execution engine,
  51313. * or otherwise separating these two steps. For more on this, see the
  51314. * "Supporting Subscriptions at Scale" information in the GraphQL specification.
  51315. */
  51316. function createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver) {
  51317. // If arguments are missing or incorrectly typed, this is an internal
  51318. // developer mistake which should throw an early error.
  51319. (0, _execute.assertValidExecutionArguments)(schema, document, variableValues);
  51320. try {
  51321. // If a valid context cannot be created due to incorrect arguments,
  51322. // this will throw an error.
  51323. var exeContext = (0, _execute.buildExecutionContext)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver); // Return early errors if execution context failed.
  51324. if (Array.isArray(exeContext)) {
  51325. return Promise.resolve({
  51326. errors: exeContext
  51327. });
  51328. }
  51329. var type = (0, _getOperationRootType.getOperationRootType)(schema, exeContext.operation);
  51330. var fields = (0, _execute.collectFields)(exeContext, type, exeContext.operation.selectionSet, Object.create(null), Object.create(null));
  51331. var responseNames = Object.keys(fields);
  51332. var responseName = responseNames[0];
  51333. var fieldNodes = fields[responseName];
  51334. var fieldNode = fieldNodes[0];
  51335. var fieldName = fieldNode.name.value;
  51336. var fieldDef = (0, _execute.getFieldDef)(schema, type, fieldName);
  51337. if (!fieldDef) {
  51338. throw new _GraphQLError.GraphQLError("The subscription field \"".concat(fieldName, "\" is not defined."), fieldNodes);
  51339. } // Call the `subscribe()` resolver or the default resolver to produce an
  51340. // AsyncIterable yielding raw payloads.
  51341. var resolveFn = fieldDef.subscribe || exeContext.fieldResolver;
  51342. var path = (0, _execute.addPath)(undefined, responseName);
  51343. var info = (0, _execute.buildResolveInfo)(exeContext, fieldDef, fieldNodes, type, path); // resolveFieldValueOrError implements the "ResolveFieldEventStream"
  51344. // algorithm from GraphQL specification. It differs from
  51345. // "ResolveFieldValue" due to providing a different `resolveFn`.
  51346. var result = (0, _execute.resolveFieldValueOrError)(exeContext, fieldDef, fieldNodes, resolveFn, rootValue, info); // Coerce to Promise for easier error handling and consistent return type.
  51347. return Promise.resolve(result).then(function (eventStream) {
  51348. // If eventStream is an Error, rethrow a located error.
  51349. if (eventStream instanceof Error) {
  51350. throw (0, _locatedError.locatedError)(eventStream, fieldNodes, (0, _execute.responsePathAsArray)(path));
  51351. } // Assert field returned an event stream, otherwise yield an error.
  51352. if ((0, _iterall.isAsyncIterable)(eventStream)) {
  51353. // Note: isAsyncIterable above ensures this will be correct.
  51354. return eventStream;
  51355. }
  51356. throw new Error('Subscription field must return Async Iterable. Received: ' + (0, _inspect.default)(eventStream));
  51357. });
  51358. } catch (error) {
  51359. return Promise.reject(error);
  51360. }
  51361. }
  51362. },{"../error/GraphQLError":275,"../error/locatedError":278,"../execution/execute":281,"../jsutils/inspect":288,"../utilities/getOperationRootType":341,"./mapAsyncIterator":321,"iterall":137}],323:[function(require,module,exports){
  51363. "use strict";
  51364. Object.defineProperty(exports, "__esModule", {
  51365. value: true
  51366. });
  51367. exports.isType = isType;
  51368. exports.assertType = assertType;
  51369. exports.isScalarType = isScalarType;
  51370. exports.assertScalarType = assertScalarType;
  51371. exports.isObjectType = isObjectType;
  51372. exports.assertObjectType = assertObjectType;
  51373. exports.isInterfaceType = isInterfaceType;
  51374. exports.assertInterfaceType = assertInterfaceType;
  51375. exports.isUnionType = isUnionType;
  51376. exports.assertUnionType = assertUnionType;
  51377. exports.isEnumType = isEnumType;
  51378. exports.assertEnumType = assertEnumType;
  51379. exports.isInputObjectType = isInputObjectType;
  51380. exports.assertInputObjectType = assertInputObjectType;
  51381. exports.isListType = isListType;
  51382. exports.assertListType = assertListType;
  51383. exports.isNonNullType = isNonNullType;
  51384. exports.assertNonNullType = assertNonNullType;
  51385. exports.isInputType = isInputType;
  51386. exports.assertInputType = assertInputType;
  51387. exports.isOutputType = isOutputType;
  51388. exports.assertOutputType = assertOutputType;
  51389. exports.isLeafType = isLeafType;
  51390. exports.assertLeafType = assertLeafType;
  51391. exports.isCompositeType = isCompositeType;
  51392. exports.assertCompositeType = assertCompositeType;
  51393. exports.isAbstractType = isAbstractType;
  51394. exports.assertAbstractType = assertAbstractType;
  51395. exports.GraphQLList = GraphQLList;
  51396. exports.GraphQLNonNull = GraphQLNonNull;
  51397. exports.isWrappingType = isWrappingType;
  51398. exports.assertWrappingType = assertWrappingType;
  51399. exports.isNullableType = isNullableType;
  51400. exports.assertNullableType = assertNullableType;
  51401. exports.getNullableType = getNullableType;
  51402. exports.isNamedType = isNamedType;
  51403. exports.assertNamedType = assertNamedType;
  51404. exports.getNamedType = getNamedType;
  51405. exports.isRequiredArgument = isRequiredArgument;
  51406. exports.isRequiredInputField = isRequiredInputField;
  51407. exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = void 0;
  51408. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  51409. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  51410. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  51411. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  51412. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  51413. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  51414. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  51415. var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
  51416. var _kinds = require("../language/kinds");
  51417. var _valueFromASTUntyped = require("../utilities/valueFromASTUntyped");
  51418. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  51419. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  51420. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  51421. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  51422. function isType(type) {
  51423. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type) || isListType(type) || isNonNullType(type);
  51424. }
  51425. function assertType(type) {
  51426. !isType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL type.")) : void 0;
  51427. return type;
  51428. }
  51429. /**
  51430. * There are predicates for each kind of GraphQL type.
  51431. */
  51432. // eslint-disable-next-line no-redeclare
  51433. function isScalarType(type) {
  51434. return (0, _instanceOf.default)(type, GraphQLScalarType);
  51435. }
  51436. function assertScalarType(type) {
  51437. !isScalarType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Scalar type.")) : void 0;
  51438. return type;
  51439. }
  51440. // eslint-disable-next-line no-redeclare
  51441. function isObjectType(type) {
  51442. return (0, _instanceOf.default)(type, GraphQLObjectType);
  51443. }
  51444. function assertObjectType(type) {
  51445. !isObjectType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Object type.")) : void 0;
  51446. return type;
  51447. }
  51448. // eslint-disable-next-line no-redeclare
  51449. function isInterfaceType(type) {
  51450. return (0, _instanceOf.default)(type, GraphQLInterfaceType);
  51451. }
  51452. function assertInterfaceType(type) {
  51453. !isInterfaceType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Interface type.")) : void 0;
  51454. return type;
  51455. }
  51456. // eslint-disable-next-line no-redeclare
  51457. function isUnionType(type) {
  51458. return (0, _instanceOf.default)(type, GraphQLUnionType);
  51459. }
  51460. function assertUnionType(type) {
  51461. !isUnionType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type.")) : void 0;
  51462. return type;
  51463. }
  51464. // eslint-disable-next-line no-redeclare
  51465. function isEnumType(type) {
  51466. return (0, _instanceOf.default)(type, GraphQLEnumType);
  51467. }
  51468. function assertEnumType(type) {
  51469. !isEnumType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type.")) : void 0;
  51470. return type;
  51471. }
  51472. // eslint-disable-next-line no-redeclare
  51473. function isInputObjectType(type) {
  51474. return (0, _instanceOf.default)(type, GraphQLInputObjectType);
  51475. }
  51476. function assertInputObjectType(type) {
  51477. !isInputObjectType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Input Object type.")) : void 0;
  51478. return type;
  51479. }
  51480. // eslint-disable-next-line no-redeclare
  51481. function isListType(type) {
  51482. return (0, _instanceOf.default)(type, GraphQLList);
  51483. }
  51484. function assertListType(type) {
  51485. !isListType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL List type.")) : void 0;
  51486. return type;
  51487. }
  51488. // eslint-disable-next-line no-redeclare
  51489. function isNonNullType(type) {
  51490. return (0, _instanceOf.default)(type, GraphQLNonNull);
  51491. }
  51492. function assertNonNullType(type) {
  51493. !isNonNullType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Non-Null type.")) : void 0;
  51494. return type;
  51495. }
  51496. /**
  51497. * These types may be used as input types for arguments and directives.
  51498. */
  51499. function isInputType(type) {
  51500. return isScalarType(type) || isEnumType(type) || isInputObjectType(type) || isWrappingType(type) && isInputType(type.ofType);
  51501. }
  51502. function assertInputType(type) {
  51503. !isInputType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL input type.")) : void 0;
  51504. return type;
  51505. }
  51506. /**
  51507. * These types may be used as output types as the result of fields.
  51508. */
  51509. function isOutputType(type) {
  51510. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isWrappingType(type) && isOutputType(type.ofType);
  51511. }
  51512. function assertOutputType(type) {
  51513. !isOutputType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL output type.")) : void 0;
  51514. return type;
  51515. }
  51516. /**
  51517. * These types may describe types which may be leaf values.
  51518. */
  51519. function isLeafType(type) {
  51520. return isScalarType(type) || isEnumType(type);
  51521. }
  51522. function assertLeafType(type) {
  51523. !isLeafType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL leaf type.")) : void 0;
  51524. return type;
  51525. }
  51526. /**
  51527. * These types may describe the parent context of a selection set.
  51528. */
  51529. function isCompositeType(type) {
  51530. return isObjectType(type) || isInterfaceType(type) || isUnionType(type);
  51531. }
  51532. function assertCompositeType(type) {
  51533. !isCompositeType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL composite type.")) : void 0;
  51534. return type;
  51535. }
  51536. /**
  51537. * These types may describe the parent context of a selection set.
  51538. */
  51539. function isAbstractType(type) {
  51540. return isInterfaceType(type) || isUnionType(type);
  51541. }
  51542. function assertAbstractType(type) {
  51543. !isAbstractType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type.")) : void 0;
  51544. return type;
  51545. }
  51546. /**
  51547. * List Type Wrapper
  51548. *
  51549. * A list is a wrapping type which points to another type.
  51550. * Lists are often created within the context of defining the fields of
  51551. * an object type.
  51552. *
  51553. * Example:
  51554. *
  51555. * const PersonType = new GraphQLObjectType({
  51556. * name: 'Person',
  51557. * fields: () => ({
  51558. * parents: { type: GraphQLList(PersonType) },
  51559. * children: { type: GraphQLList(PersonType) },
  51560. * })
  51561. * })
  51562. *
  51563. */
  51564. // eslint-disable-next-line no-redeclare
  51565. function GraphQLList(ofType) {
  51566. if (this instanceof GraphQLList) {
  51567. this.ofType = assertType(ofType);
  51568. } else {
  51569. return new GraphQLList(ofType);
  51570. }
  51571. } // Need to cast through any to alter the prototype.
  51572. GraphQLList.prototype.toString = function toString() {
  51573. return '[' + String(this.ofType) + ']';
  51574. };
  51575. (0, _defineToJSON.default)(GraphQLList);
  51576. /**
  51577. * Non-Null Type Wrapper
  51578. *
  51579. * A non-null is a wrapping type which points to another type.
  51580. * Non-null types enforce that their values are never null and can ensure
  51581. * an error is raised if this ever occurs during a request. It is useful for
  51582. * fields which you can make a strong guarantee on non-nullability, for example
  51583. * usually the id field of a database row will never be null.
  51584. *
  51585. * Example:
  51586. *
  51587. * const RowType = new GraphQLObjectType({
  51588. * name: 'Row',
  51589. * fields: () => ({
  51590. * id: { type: GraphQLNonNull(GraphQLString) },
  51591. * })
  51592. * })
  51593. *
  51594. * Note: the enforcement of non-nullability occurs within the executor.
  51595. */
  51596. // eslint-disable-next-line no-redeclare
  51597. function GraphQLNonNull(ofType) {
  51598. if (this instanceof GraphQLNonNull) {
  51599. this.ofType = assertNullableType(ofType);
  51600. } else {
  51601. return new GraphQLNonNull(ofType);
  51602. }
  51603. } // Need to cast through any to alter the prototype.
  51604. GraphQLNonNull.prototype.toString = function toString() {
  51605. return String(this.ofType) + '!';
  51606. };
  51607. (0, _defineToJSON.default)(GraphQLNonNull);
  51608. /**
  51609. * These types wrap and modify other types
  51610. */
  51611. function isWrappingType(type) {
  51612. return isListType(type) || isNonNullType(type);
  51613. }
  51614. function assertWrappingType(type) {
  51615. !isWrappingType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL wrapping type.")) : void 0;
  51616. return type;
  51617. }
  51618. /**
  51619. * These types can all accept null as a value.
  51620. */
  51621. function isNullableType(type) {
  51622. return isType(type) && !isNonNullType(type);
  51623. }
  51624. function assertNullableType(type) {
  51625. !isNullableType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL nullable type.")) : void 0;
  51626. return type;
  51627. }
  51628. /* eslint-disable no-redeclare */
  51629. function getNullableType(type) {
  51630. /* eslint-enable no-redeclare */
  51631. if (type) {
  51632. return isNonNullType(type) ? type.ofType : type;
  51633. }
  51634. }
  51635. /**
  51636. * These named types do not include modifiers like List or NonNull.
  51637. */
  51638. function isNamedType(type) {
  51639. return isScalarType(type) || isObjectType(type) || isInterfaceType(type) || isUnionType(type) || isEnumType(type) || isInputObjectType(type);
  51640. }
  51641. function assertNamedType(type) {
  51642. !isNamedType(type) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(type), " to be a GraphQL named type.")) : void 0;
  51643. return type;
  51644. }
  51645. /* eslint-disable no-redeclare */
  51646. function getNamedType(type) {
  51647. /* eslint-enable no-redeclare */
  51648. if (type) {
  51649. var unwrappedType = type;
  51650. while (isWrappingType(unwrappedType)) {
  51651. unwrappedType = unwrappedType.ofType;
  51652. }
  51653. return unwrappedType;
  51654. }
  51655. }
  51656. /**
  51657. * Used while defining GraphQL types to allow for circular references in
  51658. * otherwise immutable type definitions.
  51659. */
  51660. function resolveThunk(thunk) {
  51661. // $FlowFixMe(>=0.90.0)
  51662. return typeof thunk === 'function' ? thunk() : thunk;
  51663. }
  51664. /**
  51665. * Scalar Type Definition
  51666. *
  51667. * The leaf values of any request and input values to arguments are
  51668. * Scalars (or Enums) and are defined with a name and a series of functions
  51669. * used to parse input from ast or variables and to ensure validity.
  51670. *
  51671. * If a type's serialize function does not return a value (i.e. it returns
  51672. * `undefined`) then an error will be raised and a `null` value will be returned
  51673. * in the response. If the serialize function returns `null`, then no error will
  51674. * be included in the response.
  51675. *
  51676. * Example:
  51677. *
  51678. * const OddType = new GraphQLScalarType({
  51679. * name: 'Odd',
  51680. * serialize(value) {
  51681. * if (value % 2 === 1) {
  51682. * return value;
  51683. * }
  51684. * }
  51685. * });
  51686. *
  51687. */
  51688. var GraphQLScalarType =
  51689. /*#__PURE__*/
  51690. function () {
  51691. function GraphQLScalarType(config) {
  51692. this.name = config.name;
  51693. this.description = config.description;
  51694. this.serialize = config.serialize;
  51695. this.parseValue = config.parseValue || function (value) {
  51696. return value;
  51697. };
  51698. this.parseLiteral = config.parseLiteral || _valueFromASTUntyped.valueFromASTUntyped;
  51699. this.astNode = config.astNode;
  51700. this.extensionASTNodes = config.extensionASTNodes;
  51701. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  51702. !(typeof config.serialize === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"serialize\" function. If this custom Scalar ") + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.') : void 0;
  51703. if (config.parseValue || config.parseLiteral) {
  51704. !(typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide both \"parseValue\" and \"parseLiteral\" ") + 'functions.') : void 0;
  51705. }
  51706. }
  51707. var _proto = GraphQLScalarType.prototype;
  51708. _proto.toString = function toString() {
  51709. return this.name;
  51710. };
  51711. return GraphQLScalarType;
  51712. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  51713. exports.GraphQLScalarType = GraphQLScalarType;
  51714. (0, _defineToStringTag.default)(GraphQLScalarType);
  51715. (0, _defineToJSON.default)(GraphQLScalarType);
  51716. /**
  51717. * Object Type Definition
  51718. *
  51719. * Almost all of the GraphQL types you define will be object types. Object types
  51720. * have a name, but most importantly describe their fields.
  51721. *
  51722. * Example:
  51723. *
  51724. * const AddressType = new GraphQLObjectType({
  51725. * name: 'Address',
  51726. * fields: {
  51727. * street: { type: GraphQLString },
  51728. * number: { type: GraphQLInt },
  51729. * formatted: {
  51730. * type: GraphQLString,
  51731. * resolve(obj) {
  51732. * return obj.number + ' ' + obj.street
  51733. * }
  51734. * }
  51735. * }
  51736. * });
  51737. *
  51738. * When two types need to refer to each other, or a type needs to refer to
  51739. * itself in a field, you can use a function expression (aka a closure or a
  51740. * thunk) to supply the fields lazily.
  51741. *
  51742. * Example:
  51743. *
  51744. * const PersonType = new GraphQLObjectType({
  51745. * name: 'Person',
  51746. * fields: () => ({
  51747. * name: { type: GraphQLString },
  51748. * bestFriend: { type: PersonType },
  51749. * })
  51750. * });
  51751. *
  51752. */
  51753. var GraphQLObjectType =
  51754. /*#__PURE__*/
  51755. function () {
  51756. function GraphQLObjectType(config) {
  51757. this.name = config.name;
  51758. this.description = config.description;
  51759. this.astNode = config.astNode;
  51760. this.extensionASTNodes = config.extensionASTNodes;
  51761. this.isTypeOf = config.isTypeOf;
  51762. this._fields = defineFieldMap.bind(undefined, config);
  51763. this._interfaces = defineInterfaces.bind(undefined, config);
  51764. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  51765. !(config.isTypeOf == null || typeof config.isTypeOf === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"isTypeOf\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.isTypeOf), ".")) : void 0;
  51766. }
  51767. var _proto2 = GraphQLObjectType.prototype;
  51768. _proto2.getFields = function getFields() {
  51769. if (typeof this._fields === 'function') {
  51770. this._fields = this._fields();
  51771. }
  51772. return this._fields;
  51773. };
  51774. _proto2.getInterfaces = function getInterfaces() {
  51775. if (typeof this._interfaces === 'function') {
  51776. this._interfaces = this._interfaces();
  51777. }
  51778. return this._interfaces;
  51779. };
  51780. _proto2.toString = function toString() {
  51781. return this.name;
  51782. };
  51783. return GraphQLObjectType;
  51784. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  51785. exports.GraphQLObjectType = GraphQLObjectType;
  51786. (0, _defineToStringTag.default)(GraphQLObjectType);
  51787. (0, _defineToJSON.default)(GraphQLObjectType);
  51788. function defineInterfaces(config) {
  51789. var interfaces = resolveThunk(config.interfaces) || [];
  51790. !Array.isArray(interfaces) ? (0, _invariant.default)(0, "".concat(config.name, " interfaces must be an Array or a function which returns ") + 'an Array.') : void 0;
  51791. return interfaces;
  51792. }
  51793. function defineFieldMap(config) {
  51794. var fieldMap = resolveThunk(config.fields) || {};
  51795. !isPlainObj(fieldMap) ? (0, _invariant.default)(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
  51796. return (0, _mapValue.default)(fieldMap, function (fieldConfig, fieldName) {
  51797. !isPlainObj(fieldConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field config must be an object")) : void 0;
  51798. !!fieldConfig.hasOwnProperty('isDeprecated') ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " should provide \"deprecationReason\" ") + 'instead of "isDeprecated".') : void 0;
  51799. !(fieldConfig.resolve == null || typeof fieldConfig.resolve === 'function') ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field resolver must be a function if ") + "provided, but got: ".concat((0, _inspect.default)(fieldConfig.resolve), ".")) : void 0;
  51800. var argsConfig = fieldConfig.args || {};
  51801. !isPlainObj(argsConfig) ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " args must be an object with argument ") + 'names as keys.') : void 0;
  51802. var args = (0, _objectEntries.default)(argsConfig).map(function (_ref) {
  51803. var argName = _ref[0],
  51804. arg = _ref[1];
  51805. return {
  51806. name: argName,
  51807. description: arg.description === undefined ? null : arg.description,
  51808. type: arg.type,
  51809. defaultValue: arg.defaultValue,
  51810. astNode: arg.astNode
  51811. };
  51812. });
  51813. return _objectSpread({}, fieldConfig, {
  51814. isDeprecated: Boolean(fieldConfig.deprecationReason),
  51815. name: fieldName,
  51816. args: args
  51817. });
  51818. });
  51819. }
  51820. function isPlainObj(obj) {
  51821. return obj && _typeof(obj) === 'object' && !Array.isArray(obj);
  51822. }
  51823. function isRequiredArgument(arg) {
  51824. return isNonNullType(arg.type) && arg.defaultValue === undefined;
  51825. }
  51826. /**
  51827. * Interface Type Definition
  51828. *
  51829. * When a field can return one of a heterogeneous set of types, a Interface type
  51830. * is used to describe what types are possible, what fields are in common across
  51831. * all types, as well as a function to determine which type is actually used
  51832. * when the field is resolved.
  51833. *
  51834. * Example:
  51835. *
  51836. * const EntityType = new GraphQLInterfaceType({
  51837. * name: 'Entity',
  51838. * fields: {
  51839. * name: { type: GraphQLString }
  51840. * }
  51841. * });
  51842. *
  51843. */
  51844. var GraphQLInterfaceType =
  51845. /*#__PURE__*/
  51846. function () {
  51847. function GraphQLInterfaceType(config) {
  51848. this.name = config.name;
  51849. this.description = config.description;
  51850. this.astNode = config.astNode;
  51851. this.extensionASTNodes = config.extensionASTNodes;
  51852. this.resolveType = config.resolveType;
  51853. this._fields = defineFieldMap.bind(undefined, config);
  51854. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  51855. !(config.resolveType == null || typeof config.resolveType === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"resolveType\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.resolveType), ".")) : void 0;
  51856. }
  51857. var _proto3 = GraphQLInterfaceType.prototype;
  51858. _proto3.getFields = function getFields() {
  51859. if (typeof this._fields === 'function') {
  51860. this._fields = this._fields();
  51861. }
  51862. return this._fields;
  51863. };
  51864. _proto3.toString = function toString() {
  51865. return this.name;
  51866. };
  51867. return GraphQLInterfaceType;
  51868. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  51869. exports.GraphQLInterfaceType = GraphQLInterfaceType;
  51870. (0, _defineToStringTag.default)(GraphQLInterfaceType);
  51871. (0, _defineToJSON.default)(GraphQLInterfaceType);
  51872. /**
  51873. * Union Type Definition
  51874. *
  51875. * When a field can return one of a heterogeneous set of types, a Union type
  51876. * is used to describe what types are possible as well as providing a function
  51877. * to determine which type is actually used when the field is resolved.
  51878. *
  51879. * Example:
  51880. *
  51881. * const PetType = new GraphQLUnionType({
  51882. * name: 'Pet',
  51883. * types: [ DogType, CatType ],
  51884. * resolveType(value) {
  51885. * if (value instanceof Dog) {
  51886. * return DogType;
  51887. * }
  51888. * if (value instanceof Cat) {
  51889. * return CatType;
  51890. * }
  51891. * }
  51892. * });
  51893. *
  51894. */
  51895. var GraphQLUnionType =
  51896. /*#__PURE__*/
  51897. function () {
  51898. function GraphQLUnionType(config) {
  51899. this.name = config.name;
  51900. this.description = config.description;
  51901. this.astNode = config.astNode;
  51902. this.extensionASTNodes = config.extensionASTNodes;
  51903. this.resolveType = config.resolveType;
  51904. this._types = defineTypes.bind(undefined, config);
  51905. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  51906. !(config.resolveType == null || typeof config.resolveType === 'function') ? (0, _invariant.default)(0, "".concat(this.name, " must provide \"resolveType\" as a function, ") + "but got: ".concat((0, _inspect.default)(config.resolveType), ".")) : void 0;
  51907. }
  51908. var _proto4 = GraphQLUnionType.prototype;
  51909. _proto4.getTypes = function getTypes() {
  51910. if (typeof this._types === 'function') {
  51911. this._types = this._types();
  51912. }
  51913. return this._types;
  51914. };
  51915. _proto4.toString = function toString() {
  51916. return this.name;
  51917. };
  51918. return GraphQLUnionType;
  51919. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  51920. exports.GraphQLUnionType = GraphQLUnionType;
  51921. (0, _defineToStringTag.default)(GraphQLUnionType);
  51922. (0, _defineToJSON.default)(GraphQLUnionType);
  51923. function defineTypes(config) {
  51924. var types = resolveThunk(config.types) || [];
  51925. !Array.isArray(types) ? (0, _invariant.default)(0, 'Must provide Array of types or a function which returns ' + "such an array for Union ".concat(config.name, ".")) : void 0;
  51926. return types;
  51927. }
  51928. /**
  51929. * Enum Type Definition
  51930. *
  51931. * Some leaf values of requests and input values are Enums. GraphQL serializes
  51932. * Enum values as strings, however internally Enums can be represented by any
  51933. * kind of type, often integers.
  51934. *
  51935. * Example:
  51936. *
  51937. * const RGBType = new GraphQLEnumType({
  51938. * name: 'RGB',
  51939. * values: {
  51940. * RED: { value: 0 },
  51941. * GREEN: { value: 1 },
  51942. * BLUE: { value: 2 }
  51943. * }
  51944. * });
  51945. *
  51946. * Note: If a value is not provided in a definition, the name of the enum value
  51947. * will be used as its internal value.
  51948. */
  51949. var GraphQLEnumType
  51950. /* <T> */
  51951. =
  51952. /*#__PURE__*/
  51953. function () {
  51954. function GraphQLEnumType(config
  51955. /* <T> */
  51956. ) {
  51957. this.name = config.name;
  51958. this.description = config.description;
  51959. this.astNode = config.astNode;
  51960. this.extensionASTNodes = config.extensionASTNodes;
  51961. this._values = defineEnumValues(this, config.values);
  51962. this._valueLookup = new Map(this._values.map(function (enumValue) {
  51963. return [enumValue.value, enumValue];
  51964. }));
  51965. this._nameLookup = (0, _keyMap.default)(this._values, function (value) {
  51966. return value.name;
  51967. });
  51968. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  51969. }
  51970. var _proto5 = GraphQLEnumType.prototype;
  51971. _proto5.getValues = function getValues() {
  51972. return this._values;
  51973. };
  51974. _proto5.getValue = function getValue(name) {
  51975. return this._nameLookup[name];
  51976. };
  51977. _proto5.serialize = function serialize(value
  51978. /* T */
  51979. ) {
  51980. var enumValue = this._valueLookup.get(value);
  51981. if (enumValue) {
  51982. return enumValue.name;
  51983. }
  51984. };
  51985. _proto5.parseValue = function parseValue(value)
  51986. /* T */
  51987. {
  51988. if (typeof value === 'string') {
  51989. var enumValue = this.getValue(value);
  51990. if (enumValue) {
  51991. return enumValue.value;
  51992. }
  51993. }
  51994. };
  51995. _proto5.parseLiteral = function parseLiteral(valueNode, _variables)
  51996. /* T */
  51997. {
  51998. // Note: variables will be resolved to a value before calling this function.
  51999. if (valueNode.kind === _kinds.Kind.ENUM) {
  52000. var enumValue = this.getValue(valueNode.value);
  52001. if (enumValue) {
  52002. return enumValue.value;
  52003. }
  52004. }
  52005. };
  52006. _proto5.toString = function toString() {
  52007. return this.name;
  52008. };
  52009. return GraphQLEnumType;
  52010. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  52011. exports.GraphQLEnumType = GraphQLEnumType;
  52012. (0, _defineToStringTag.default)(GraphQLEnumType);
  52013. (0, _defineToJSON.default)(GraphQLEnumType);
  52014. function defineEnumValues(type, valueMap
  52015. /* <T> */
  52016. ) {
  52017. !isPlainObj(valueMap) ? (0, _invariant.default)(0, "".concat(type.name, " values must be an object with value names as keys.")) : void 0;
  52018. return (0, _objectEntries.default)(valueMap).map(function (_ref2) {
  52019. var valueName = _ref2[0],
  52020. value = _ref2[1];
  52021. !isPlainObj(value) ? (0, _invariant.default)(0, "".concat(type.name, ".").concat(valueName, " must refer to an object with a \"value\" key ") + "representing an internal value but got: ".concat((0, _inspect.default)(value), ".")) : void 0;
  52022. !!value.hasOwnProperty('isDeprecated') ? (0, _invariant.default)(0, "".concat(type.name, ".").concat(valueName, " should provide \"deprecationReason\" instead ") + 'of "isDeprecated".') : void 0;
  52023. return {
  52024. name: valueName,
  52025. description: value.description,
  52026. isDeprecated: Boolean(value.deprecationReason),
  52027. deprecationReason: value.deprecationReason,
  52028. astNode: value.astNode,
  52029. value: value.hasOwnProperty('value') ? value.value : valueName
  52030. };
  52031. });
  52032. }
  52033. /**
  52034. * Input Object Type Definition
  52035. *
  52036. * An input object defines a structured collection of fields which may be
  52037. * supplied to a field argument.
  52038. *
  52039. * Using `NonNull` will ensure that a value must be provided by the query
  52040. *
  52041. * Example:
  52042. *
  52043. * const GeoPoint = new GraphQLInputObjectType({
  52044. * name: 'GeoPoint',
  52045. * fields: {
  52046. * lat: { type: GraphQLNonNull(GraphQLFloat) },
  52047. * lon: { type: GraphQLNonNull(GraphQLFloat) },
  52048. * alt: { type: GraphQLFloat, defaultValue: 0 },
  52049. * }
  52050. * });
  52051. *
  52052. */
  52053. var GraphQLInputObjectType =
  52054. /*#__PURE__*/
  52055. function () {
  52056. function GraphQLInputObjectType(config) {
  52057. this.name = config.name;
  52058. this.description = config.description;
  52059. this.astNode = config.astNode;
  52060. this.extensionASTNodes = config.extensionASTNodes;
  52061. this._fields = defineInputFieldMap.bind(undefined, config);
  52062. !(typeof config.name === 'string') ? (0, _invariant.default)(0, 'Must provide name.') : void 0;
  52063. }
  52064. var _proto6 = GraphQLInputObjectType.prototype;
  52065. _proto6.getFields = function getFields() {
  52066. if (typeof this._fields === 'function') {
  52067. this._fields = this._fields();
  52068. }
  52069. return this._fields;
  52070. };
  52071. _proto6.toString = function toString() {
  52072. return this.name;
  52073. };
  52074. return GraphQLInputObjectType;
  52075. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  52076. exports.GraphQLInputObjectType = GraphQLInputObjectType;
  52077. (0, _defineToStringTag.default)(GraphQLInputObjectType);
  52078. (0, _defineToJSON.default)(GraphQLInputObjectType);
  52079. function defineInputFieldMap(config) {
  52080. var fieldMap = resolveThunk(config.fields) || {};
  52081. !isPlainObj(fieldMap) ? (0, _invariant.default)(0, "".concat(config.name, " fields must be an object with field names as keys or a ") + 'function which returns such an object.') : void 0;
  52082. return (0, _mapValue.default)(fieldMap, function (fieldConfig, fieldName) {
  52083. !!fieldConfig.hasOwnProperty('resolve') ? (0, _invariant.default)(0, "".concat(config.name, ".").concat(fieldName, " field has a resolve property, but ") + 'Input Types cannot define resolvers.') : void 0;
  52084. return _objectSpread({}, fieldConfig, {
  52085. name: fieldName
  52086. });
  52087. });
  52088. }
  52089. function isRequiredInputField(field) {
  52090. return isNonNullType(field.type) && field.defaultValue === undefined;
  52091. }
  52092. },{"../jsutils/defineToJSON":286,"../jsutils/defineToStringTag":287,"../jsutils/inspect":288,"../jsutils/instanceOf":289,"../jsutils/invariant":290,"../jsutils/keyMap":294,"../jsutils/mapValue":296,"../language/kinds":307,"../polyfills/objectEntries":318,"../utilities/valueFromASTUntyped":353}],324:[function(require,module,exports){
  52093. "use strict";
  52094. Object.defineProperty(exports, "__esModule", {
  52095. value: true
  52096. });
  52097. exports.isDirective = isDirective;
  52098. exports.assertDirective = assertDirective;
  52099. exports.isSpecifiedDirective = isSpecifiedDirective;
  52100. exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0;
  52101. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  52102. var _definition = require("./definition");
  52103. var _scalars = require("./scalars");
  52104. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  52105. var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
  52106. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  52107. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  52108. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  52109. var _directiveLocation = require("../language/directiveLocation");
  52110. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  52111. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  52112. // eslint-disable-next-line no-redeclare
  52113. function isDirective(directive) {
  52114. return (0, _instanceOf.default)(directive, GraphQLDirective);
  52115. }
  52116. function assertDirective(directive) {
  52117. !isDirective(directive) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(directive), " to be a GraphQL directive.")) : void 0;
  52118. return directive;
  52119. }
  52120. /**
  52121. * Directives are used by the GraphQL runtime as a way of modifying execution
  52122. * behavior. Type system creators will usually not create these directly.
  52123. */
  52124. var GraphQLDirective =
  52125. /*#__PURE__*/
  52126. function () {
  52127. function GraphQLDirective(config) {
  52128. this.name = config.name;
  52129. this.description = config.description;
  52130. this.locations = config.locations;
  52131. this.astNode = config.astNode;
  52132. !config.name ? (0, _invariant.default)(0, 'Directive must be named.') : void 0;
  52133. !Array.isArray(config.locations) ? (0, _invariant.default)(0, "@".concat(config.name, " locations must be an Array.")) : void 0;
  52134. var args = config.args || {};
  52135. !(_typeof(args) === 'object' && !Array.isArray(args)) ? (0, _invariant.default)(0, "@".concat(config.name, " args must be an object with argument names as keys.")) : void 0;
  52136. this.args = (0, _objectEntries.default)(args).map(function (_ref) {
  52137. var argName = _ref[0],
  52138. arg = _ref[1];
  52139. return {
  52140. name: argName,
  52141. description: arg.description === undefined ? null : arg.description,
  52142. type: arg.type,
  52143. defaultValue: arg.defaultValue,
  52144. astNode: arg.astNode
  52145. };
  52146. });
  52147. }
  52148. var _proto = GraphQLDirective.prototype;
  52149. _proto.toString = function toString() {
  52150. return '@' + this.name;
  52151. };
  52152. return GraphQLDirective;
  52153. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  52154. exports.GraphQLDirective = GraphQLDirective;
  52155. (0, _defineToStringTag.default)(GraphQLDirective);
  52156. (0, _defineToJSON.default)(GraphQLDirective);
  52157. /**
  52158. * Used to conditionally include fields or fragments.
  52159. */
  52160. var GraphQLIncludeDirective = new GraphQLDirective({
  52161. name: 'include',
  52162. description: 'Directs the executor to include this field or fragment only when ' + 'the `if` argument is true.',
  52163. locations: [_directiveLocation.DirectiveLocation.FIELD, _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, _directiveLocation.DirectiveLocation.INLINE_FRAGMENT],
  52164. args: {
  52165. if: {
  52166. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  52167. description: 'Included when true.'
  52168. }
  52169. }
  52170. });
  52171. /**
  52172. * Used to conditionally skip (exclude) fields or fragments.
  52173. */
  52174. exports.GraphQLIncludeDirective = GraphQLIncludeDirective;
  52175. var GraphQLSkipDirective = new GraphQLDirective({
  52176. name: 'skip',
  52177. description: 'Directs the executor to skip this field or fragment when the `if` ' + 'argument is true.',
  52178. locations: [_directiveLocation.DirectiveLocation.FIELD, _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, _directiveLocation.DirectiveLocation.INLINE_FRAGMENT],
  52179. args: {
  52180. if: {
  52181. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  52182. description: 'Skipped when true.'
  52183. }
  52184. }
  52185. });
  52186. /**
  52187. * Constant string used for default reason for a deprecation.
  52188. */
  52189. exports.GraphQLSkipDirective = GraphQLSkipDirective;
  52190. var DEFAULT_DEPRECATION_REASON = 'No longer supported';
  52191. /**
  52192. * Used to declare element of a GraphQL schema as deprecated.
  52193. */
  52194. exports.DEFAULT_DEPRECATION_REASON = DEFAULT_DEPRECATION_REASON;
  52195. var GraphQLDeprecatedDirective = new GraphQLDirective({
  52196. name: 'deprecated',
  52197. description: 'Marks an element of a GraphQL schema as no longer supported.',
  52198. locations: [_directiveLocation.DirectiveLocation.FIELD_DEFINITION, _directiveLocation.DirectiveLocation.ENUM_VALUE],
  52199. args: {
  52200. reason: {
  52201. type: _scalars.GraphQLString,
  52202. description: 'Explains why this element was deprecated, usually also including a ' + 'suggestion for how to access supported similar data. Formatted using ' + 'the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).',
  52203. defaultValue: DEFAULT_DEPRECATION_REASON
  52204. }
  52205. }
  52206. });
  52207. /**
  52208. * The full list of specified directives.
  52209. */
  52210. exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective;
  52211. var specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
  52212. exports.specifiedDirectives = specifiedDirectives;
  52213. function isSpecifiedDirective(directive) {
  52214. return specifiedDirectives.some(function (specifiedDirective) {
  52215. return specifiedDirective.name === directive.name;
  52216. });
  52217. }
  52218. },{"../jsutils/defineToJSON":286,"../jsutils/defineToStringTag":287,"../jsutils/inspect":288,"../jsutils/instanceOf":289,"../jsutils/invariant":290,"../language/directiveLocation":305,"../polyfills/objectEntries":318,"./definition":323,"./scalars":327}],325:[function(require,module,exports){
  52219. "use strict";
  52220. Object.defineProperty(exports, "__esModule", {
  52221. value: true
  52222. });
  52223. Object.defineProperty(exports, "isSchema", {
  52224. enumerable: true,
  52225. get: function get() {
  52226. return _schema.isSchema;
  52227. }
  52228. });
  52229. Object.defineProperty(exports, "assertSchema", {
  52230. enumerable: true,
  52231. get: function get() {
  52232. return _schema.assertSchema;
  52233. }
  52234. });
  52235. Object.defineProperty(exports, "GraphQLSchema", {
  52236. enumerable: true,
  52237. get: function get() {
  52238. return _schema.GraphQLSchema;
  52239. }
  52240. });
  52241. Object.defineProperty(exports, "isType", {
  52242. enumerable: true,
  52243. get: function get() {
  52244. return _definition.isType;
  52245. }
  52246. });
  52247. Object.defineProperty(exports, "isScalarType", {
  52248. enumerable: true,
  52249. get: function get() {
  52250. return _definition.isScalarType;
  52251. }
  52252. });
  52253. Object.defineProperty(exports, "isObjectType", {
  52254. enumerable: true,
  52255. get: function get() {
  52256. return _definition.isObjectType;
  52257. }
  52258. });
  52259. Object.defineProperty(exports, "isInterfaceType", {
  52260. enumerable: true,
  52261. get: function get() {
  52262. return _definition.isInterfaceType;
  52263. }
  52264. });
  52265. Object.defineProperty(exports, "isUnionType", {
  52266. enumerable: true,
  52267. get: function get() {
  52268. return _definition.isUnionType;
  52269. }
  52270. });
  52271. Object.defineProperty(exports, "isEnumType", {
  52272. enumerable: true,
  52273. get: function get() {
  52274. return _definition.isEnumType;
  52275. }
  52276. });
  52277. Object.defineProperty(exports, "isInputObjectType", {
  52278. enumerable: true,
  52279. get: function get() {
  52280. return _definition.isInputObjectType;
  52281. }
  52282. });
  52283. Object.defineProperty(exports, "isListType", {
  52284. enumerable: true,
  52285. get: function get() {
  52286. return _definition.isListType;
  52287. }
  52288. });
  52289. Object.defineProperty(exports, "isNonNullType", {
  52290. enumerable: true,
  52291. get: function get() {
  52292. return _definition.isNonNullType;
  52293. }
  52294. });
  52295. Object.defineProperty(exports, "isInputType", {
  52296. enumerable: true,
  52297. get: function get() {
  52298. return _definition.isInputType;
  52299. }
  52300. });
  52301. Object.defineProperty(exports, "isOutputType", {
  52302. enumerable: true,
  52303. get: function get() {
  52304. return _definition.isOutputType;
  52305. }
  52306. });
  52307. Object.defineProperty(exports, "isLeafType", {
  52308. enumerable: true,
  52309. get: function get() {
  52310. return _definition.isLeafType;
  52311. }
  52312. });
  52313. Object.defineProperty(exports, "isCompositeType", {
  52314. enumerable: true,
  52315. get: function get() {
  52316. return _definition.isCompositeType;
  52317. }
  52318. });
  52319. Object.defineProperty(exports, "isAbstractType", {
  52320. enumerable: true,
  52321. get: function get() {
  52322. return _definition.isAbstractType;
  52323. }
  52324. });
  52325. Object.defineProperty(exports, "isWrappingType", {
  52326. enumerable: true,
  52327. get: function get() {
  52328. return _definition.isWrappingType;
  52329. }
  52330. });
  52331. Object.defineProperty(exports, "isNullableType", {
  52332. enumerable: true,
  52333. get: function get() {
  52334. return _definition.isNullableType;
  52335. }
  52336. });
  52337. Object.defineProperty(exports, "isNamedType", {
  52338. enumerable: true,
  52339. get: function get() {
  52340. return _definition.isNamedType;
  52341. }
  52342. });
  52343. Object.defineProperty(exports, "isRequiredArgument", {
  52344. enumerable: true,
  52345. get: function get() {
  52346. return _definition.isRequiredArgument;
  52347. }
  52348. });
  52349. Object.defineProperty(exports, "isRequiredInputField", {
  52350. enumerable: true,
  52351. get: function get() {
  52352. return _definition.isRequiredInputField;
  52353. }
  52354. });
  52355. Object.defineProperty(exports, "assertType", {
  52356. enumerable: true,
  52357. get: function get() {
  52358. return _definition.assertType;
  52359. }
  52360. });
  52361. Object.defineProperty(exports, "assertScalarType", {
  52362. enumerable: true,
  52363. get: function get() {
  52364. return _definition.assertScalarType;
  52365. }
  52366. });
  52367. Object.defineProperty(exports, "assertObjectType", {
  52368. enumerable: true,
  52369. get: function get() {
  52370. return _definition.assertObjectType;
  52371. }
  52372. });
  52373. Object.defineProperty(exports, "assertInterfaceType", {
  52374. enumerable: true,
  52375. get: function get() {
  52376. return _definition.assertInterfaceType;
  52377. }
  52378. });
  52379. Object.defineProperty(exports, "assertUnionType", {
  52380. enumerable: true,
  52381. get: function get() {
  52382. return _definition.assertUnionType;
  52383. }
  52384. });
  52385. Object.defineProperty(exports, "assertEnumType", {
  52386. enumerable: true,
  52387. get: function get() {
  52388. return _definition.assertEnumType;
  52389. }
  52390. });
  52391. Object.defineProperty(exports, "assertInputObjectType", {
  52392. enumerable: true,
  52393. get: function get() {
  52394. return _definition.assertInputObjectType;
  52395. }
  52396. });
  52397. Object.defineProperty(exports, "assertListType", {
  52398. enumerable: true,
  52399. get: function get() {
  52400. return _definition.assertListType;
  52401. }
  52402. });
  52403. Object.defineProperty(exports, "assertNonNullType", {
  52404. enumerable: true,
  52405. get: function get() {
  52406. return _definition.assertNonNullType;
  52407. }
  52408. });
  52409. Object.defineProperty(exports, "assertInputType", {
  52410. enumerable: true,
  52411. get: function get() {
  52412. return _definition.assertInputType;
  52413. }
  52414. });
  52415. Object.defineProperty(exports, "assertOutputType", {
  52416. enumerable: true,
  52417. get: function get() {
  52418. return _definition.assertOutputType;
  52419. }
  52420. });
  52421. Object.defineProperty(exports, "assertLeafType", {
  52422. enumerable: true,
  52423. get: function get() {
  52424. return _definition.assertLeafType;
  52425. }
  52426. });
  52427. Object.defineProperty(exports, "assertCompositeType", {
  52428. enumerable: true,
  52429. get: function get() {
  52430. return _definition.assertCompositeType;
  52431. }
  52432. });
  52433. Object.defineProperty(exports, "assertAbstractType", {
  52434. enumerable: true,
  52435. get: function get() {
  52436. return _definition.assertAbstractType;
  52437. }
  52438. });
  52439. Object.defineProperty(exports, "assertWrappingType", {
  52440. enumerable: true,
  52441. get: function get() {
  52442. return _definition.assertWrappingType;
  52443. }
  52444. });
  52445. Object.defineProperty(exports, "assertNullableType", {
  52446. enumerable: true,
  52447. get: function get() {
  52448. return _definition.assertNullableType;
  52449. }
  52450. });
  52451. Object.defineProperty(exports, "assertNamedType", {
  52452. enumerable: true,
  52453. get: function get() {
  52454. return _definition.assertNamedType;
  52455. }
  52456. });
  52457. Object.defineProperty(exports, "getNullableType", {
  52458. enumerable: true,
  52459. get: function get() {
  52460. return _definition.getNullableType;
  52461. }
  52462. });
  52463. Object.defineProperty(exports, "getNamedType", {
  52464. enumerable: true,
  52465. get: function get() {
  52466. return _definition.getNamedType;
  52467. }
  52468. });
  52469. Object.defineProperty(exports, "GraphQLScalarType", {
  52470. enumerable: true,
  52471. get: function get() {
  52472. return _definition.GraphQLScalarType;
  52473. }
  52474. });
  52475. Object.defineProperty(exports, "GraphQLObjectType", {
  52476. enumerable: true,
  52477. get: function get() {
  52478. return _definition.GraphQLObjectType;
  52479. }
  52480. });
  52481. Object.defineProperty(exports, "GraphQLInterfaceType", {
  52482. enumerable: true,
  52483. get: function get() {
  52484. return _definition.GraphQLInterfaceType;
  52485. }
  52486. });
  52487. Object.defineProperty(exports, "GraphQLUnionType", {
  52488. enumerable: true,
  52489. get: function get() {
  52490. return _definition.GraphQLUnionType;
  52491. }
  52492. });
  52493. Object.defineProperty(exports, "GraphQLEnumType", {
  52494. enumerable: true,
  52495. get: function get() {
  52496. return _definition.GraphQLEnumType;
  52497. }
  52498. });
  52499. Object.defineProperty(exports, "GraphQLInputObjectType", {
  52500. enumerable: true,
  52501. get: function get() {
  52502. return _definition.GraphQLInputObjectType;
  52503. }
  52504. });
  52505. Object.defineProperty(exports, "GraphQLList", {
  52506. enumerable: true,
  52507. get: function get() {
  52508. return _definition.GraphQLList;
  52509. }
  52510. });
  52511. Object.defineProperty(exports, "GraphQLNonNull", {
  52512. enumerable: true,
  52513. get: function get() {
  52514. return _definition.GraphQLNonNull;
  52515. }
  52516. });
  52517. Object.defineProperty(exports, "isDirective", {
  52518. enumerable: true,
  52519. get: function get() {
  52520. return _directives.isDirective;
  52521. }
  52522. });
  52523. Object.defineProperty(exports, "assertDirective", {
  52524. enumerable: true,
  52525. get: function get() {
  52526. return _directives.assertDirective;
  52527. }
  52528. });
  52529. Object.defineProperty(exports, "GraphQLDirective", {
  52530. enumerable: true,
  52531. get: function get() {
  52532. return _directives.GraphQLDirective;
  52533. }
  52534. });
  52535. Object.defineProperty(exports, "isSpecifiedDirective", {
  52536. enumerable: true,
  52537. get: function get() {
  52538. return _directives.isSpecifiedDirective;
  52539. }
  52540. });
  52541. Object.defineProperty(exports, "specifiedDirectives", {
  52542. enumerable: true,
  52543. get: function get() {
  52544. return _directives.specifiedDirectives;
  52545. }
  52546. });
  52547. Object.defineProperty(exports, "GraphQLIncludeDirective", {
  52548. enumerable: true,
  52549. get: function get() {
  52550. return _directives.GraphQLIncludeDirective;
  52551. }
  52552. });
  52553. Object.defineProperty(exports, "GraphQLSkipDirective", {
  52554. enumerable: true,
  52555. get: function get() {
  52556. return _directives.GraphQLSkipDirective;
  52557. }
  52558. });
  52559. Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
  52560. enumerable: true,
  52561. get: function get() {
  52562. return _directives.GraphQLDeprecatedDirective;
  52563. }
  52564. });
  52565. Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", {
  52566. enumerable: true,
  52567. get: function get() {
  52568. return _directives.DEFAULT_DEPRECATION_REASON;
  52569. }
  52570. });
  52571. Object.defineProperty(exports, "isSpecifiedScalarType", {
  52572. enumerable: true,
  52573. get: function get() {
  52574. return _scalars.isSpecifiedScalarType;
  52575. }
  52576. });
  52577. Object.defineProperty(exports, "specifiedScalarTypes", {
  52578. enumerable: true,
  52579. get: function get() {
  52580. return _scalars.specifiedScalarTypes;
  52581. }
  52582. });
  52583. Object.defineProperty(exports, "GraphQLInt", {
  52584. enumerable: true,
  52585. get: function get() {
  52586. return _scalars.GraphQLInt;
  52587. }
  52588. });
  52589. Object.defineProperty(exports, "GraphQLFloat", {
  52590. enumerable: true,
  52591. get: function get() {
  52592. return _scalars.GraphQLFloat;
  52593. }
  52594. });
  52595. Object.defineProperty(exports, "GraphQLString", {
  52596. enumerable: true,
  52597. get: function get() {
  52598. return _scalars.GraphQLString;
  52599. }
  52600. });
  52601. Object.defineProperty(exports, "GraphQLBoolean", {
  52602. enumerable: true,
  52603. get: function get() {
  52604. return _scalars.GraphQLBoolean;
  52605. }
  52606. });
  52607. Object.defineProperty(exports, "GraphQLID", {
  52608. enumerable: true,
  52609. get: function get() {
  52610. return _scalars.GraphQLID;
  52611. }
  52612. });
  52613. Object.defineProperty(exports, "TypeKind", {
  52614. enumerable: true,
  52615. get: function get() {
  52616. return _introspection.TypeKind;
  52617. }
  52618. });
  52619. Object.defineProperty(exports, "isIntrospectionType", {
  52620. enumerable: true,
  52621. get: function get() {
  52622. return _introspection.isIntrospectionType;
  52623. }
  52624. });
  52625. Object.defineProperty(exports, "introspectionTypes", {
  52626. enumerable: true,
  52627. get: function get() {
  52628. return _introspection.introspectionTypes;
  52629. }
  52630. });
  52631. Object.defineProperty(exports, "__Schema", {
  52632. enumerable: true,
  52633. get: function get() {
  52634. return _introspection.__Schema;
  52635. }
  52636. });
  52637. Object.defineProperty(exports, "__Directive", {
  52638. enumerable: true,
  52639. get: function get() {
  52640. return _introspection.__Directive;
  52641. }
  52642. });
  52643. Object.defineProperty(exports, "__DirectiveLocation", {
  52644. enumerable: true,
  52645. get: function get() {
  52646. return _introspection.__DirectiveLocation;
  52647. }
  52648. });
  52649. Object.defineProperty(exports, "__Type", {
  52650. enumerable: true,
  52651. get: function get() {
  52652. return _introspection.__Type;
  52653. }
  52654. });
  52655. Object.defineProperty(exports, "__Field", {
  52656. enumerable: true,
  52657. get: function get() {
  52658. return _introspection.__Field;
  52659. }
  52660. });
  52661. Object.defineProperty(exports, "__InputValue", {
  52662. enumerable: true,
  52663. get: function get() {
  52664. return _introspection.__InputValue;
  52665. }
  52666. });
  52667. Object.defineProperty(exports, "__EnumValue", {
  52668. enumerable: true,
  52669. get: function get() {
  52670. return _introspection.__EnumValue;
  52671. }
  52672. });
  52673. Object.defineProperty(exports, "__TypeKind", {
  52674. enumerable: true,
  52675. get: function get() {
  52676. return _introspection.__TypeKind;
  52677. }
  52678. });
  52679. Object.defineProperty(exports, "SchemaMetaFieldDef", {
  52680. enumerable: true,
  52681. get: function get() {
  52682. return _introspection.SchemaMetaFieldDef;
  52683. }
  52684. });
  52685. Object.defineProperty(exports, "TypeMetaFieldDef", {
  52686. enumerable: true,
  52687. get: function get() {
  52688. return _introspection.TypeMetaFieldDef;
  52689. }
  52690. });
  52691. Object.defineProperty(exports, "TypeNameMetaFieldDef", {
  52692. enumerable: true,
  52693. get: function get() {
  52694. return _introspection.TypeNameMetaFieldDef;
  52695. }
  52696. });
  52697. Object.defineProperty(exports, "validateSchema", {
  52698. enumerable: true,
  52699. get: function get() {
  52700. return _validate.validateSchema;
  52701. }
  52702. });
  52703. Object.defineProperty(exports, "assertValidSchema", {
  52704. enumerable: true,
  52705. get: function get() {
  52706. return _validate.assertValidSchema;
  52707. }
  52708. });
  52709. var _schema = require("./schema");
  52710. var _definition = require("./definition");
  52711. var _directives = require("./directives");
  52712. var _scalars = require("./scalars");
  52713. var _introspection = require("./introspection");
  52714. var _validate = require("./validate");
  52715. },{"./definition":323,"./directives":324,"./introspection":326,"./scalars":327,"./schema":328,"./validate":329}],326:[function(require,module,exports){
  52716. "use strict";
  52717. Object.defineProperty(exports, "__esModule", {
  52718. value: true
  52719. });
  52720. exports.isIntrospectionType = isIntrospectionType;
  52721. exports.introspectionTypes = exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = void 0;
  52722. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  52723. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  52724. var _astFromValue = require("../utilities/astFromValue");
  52725. var _printer = require("../language/printer");
  52726. var _definition = require("./definition");
  52727. var _scalars = require("./scalars");
  52728. var _directiveLocation = require("../language/directiveLocation");
  52729. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  52730. /**
  52731. * Copyright (c) 2015-present, Facebook, Inc.
  52732. *
  52733. * This source code is licensed under the MIT license found in the
  52734. * LICENSE file in the root directory of this source tree.
  52735. *
  52736. *
  52737. */
  52738. var __Schema = new _definition.GraphQLObjectType({
  52739. name: '__Schema',
  52740. description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' + 'exposes all available types and directives on the server, as well as ' + 'the entry points for query, mutation, and subscription operations.',
  52741. fields: function fields() {
  52742. return {
  52743. types: {
  52744. description: 'A list of all types supported by this server.',
  52745. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type))),
  52746. resolve: function resolve(schema) {
  52747. return (0, _objectValues.default)(schema.getTypeMap());
  52748. }
  52749. },
  52750. queryType: {
  52751. description: 'The type that query operations will be rooted at.',
  52752. type: (0, _definition.GraphQLNonNull)(__Type),
  52753. resolve: function resolve(schema) {
  52754. return schema.getQueryType();
  52755. }
  52756. },
  52757. mutationType: {
  52758. description: 'If this server supports mutation, the type that ' + 'mutation operations will be rooted at.',
  52759. type: __Type,
  52760. resolve: function resolve(schema) {
  52761. return schema.getMutationType();
  52762. }
  52763. },
  52764. subscriptionType: {
  52765. description: 'If this server support subscription, the type that ' + 'subscription operations will be rooted at.',
  52766. type: __Type,
  52767. resolve: function resolve(schema) {
  52768. return schema.getSubscriptionType();
  52769. }
  52770. },
  52771. directives: {
  52772. description: 'A list of all directives supported by this server.',
  52773. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Directive))),
  52774. resolve: function resolve(schema) {
  52775. return schema.getDirectives();
  52776. }
  52777. }
  52778. };
  52779. }
  52780. });
  52781. exports.__Schema = __Schema;
  52782. var __Directive = new _definition.GraphQLObjectType({
  52783. name: '__Directive',
  52784. description: 'A Directive provides a way to describe alternate runtime execution and ' + 'type validation behavior in a GraphQL document.' + "\n\nIn some cases, you need to provide options to alter GraphQL's " + 'execution behavior in ways field arguments will not suffice, such as ' + 'conditionally including or skipping a field. Directives provide this by ' + 'describing additional information to the executor.',
  52785. fields: function fields() {
  52786. return {
  52787. name: {
  52788. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  52789. resolve: function resolve(obj) {
  52790. return obj.name;
  52791. }
  52792. },
  52793. description: {
  52794. type: _scalars.GraphQLString,
  52795. resolve: function resolve(obj) {
  52796. return obj.description;
  52797. }
  52798. },
  52799. locations: {
  52800. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__DirectiveLocation))),
  52801. resolve: function resolve(obj) {
  52802. return obj.locations;
  52803. }
  52804. },
  52805. args: {
  52806. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue))),
  52807. resolve: function resolve(directive) {
  52808. return directive.args || [];
  52809. }
  52810. }
  52811. };
  52812. }
  52813. });
  52814. exports.__Directive = __Directive;
  52815. var __DirectiveLocation = new _definition.GraphQLEnumType({
  52816. name: '__DirectiveLocation',
  52817. description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.',
  52818. values: {
  52819. QUERY: {
  52820. value: _directiveLocation.DirectiveLocation.QUERY,
  52821. description: 'Location adjacent to a query operation.'
  52822. },
  52823. MUTATION: {
  52824. value: _directiveLocation.DirectiveLocation.MUTATION,
  52825. description: 'Location adjacent to a mutation operation.'
  52826. },
  52827. SUBSCRIPTION: {
  52828. value: _directiveLocation.DirectiveLocation.SUBSCRIPTION,
  52829. description: 'Location adjacent to a subscription operation.'
  52830. },
  52831. FIELD: {
  52832. value: _directiveLocation.DirectiveLocation.FIELD,
  52833. description: 'Location adjacent to a field.'
  52834. },
  52835. FRAGMENT_DEFINITION: {
  52836. value: _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION,
  52837. description: 'Location adjacent to a fragment definition.'
  52838. },
  52839. FRAGMENT_SPREAD: {
  52840. value: _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD,
  52841. description: 'Location adjacent to a fragment spread.'
  52842. },
  52843. INLINE_FRAGMENT: {
  52844. value: _directiveLocation.DirectiveLocation.INLINE_FRAGMENT,
  52845. description: 'Location adjacent to an inline fragment.'
  52846. },
  52847. VARIABLE_DEFINITION: {
  52848. value: _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION,
  52849. description: 'Location adjacent to a variable definition.'
  52850. },
  52851. SCHEMA: {
  52852. value: _directiveLocation.DirectiveLocation.SCHEMA,
  52853. description: 'Location adjacent to a schema definition.'
  52854. },
  52855. SCALAR: {
  52856. value: _directiveLocation.DirectiveLocation.SCALAR,
  52857. description: 'Location adjacent to a scalar definition.'
  52858. },
  52859. OBJECT: {
  52860. value: _directiveLocation.DirectiveLocation.OBJECT,
  52861. description: 'Location adjacent to an object type definition.'
  52862. },
  52863. FIELD_DEFINITION: {
  52864. value: _directiveLocation.DirectiveLocation.FIELD_DEFINITION,
  52865. description: 'Location adjacent to a field definition.'
  52866. },
  52867. ARGUMENT_DEFINITION: {
  52868. value: _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION,
  52869. description: 'Location adjacent to an argument definition.'
  52870. },
  52871. INTERFACE: {
  52872. value: _directiveLocation.DirectiveLocation.INTERFACE,
  52873. description: 'Location adjacent to an interface definition.'
  52874. },
  52875. UNION: {
  52876. value: _directiveLocation.DirectiveLocation.UNION,
  52877. description: 'Location adjacent to a union definition.'
  52878. },
  52879. ENUM: {
  52880. value: _directiveLocation.DirectiveLocation.ENUM,
  52881. description: 'Location adjacent to an enum definition.'
  52882. },
  52883. ENUM_VALUE: {
  52884. value: _directiveLocation.DirectiveLocation.ENUM_VALUE,
  52885. description: 'Location adjacent to an enum value definition.'
  52886. },
  52887. INPUT_OBJECT: {
  52888. value: _directiveLocation.DirectiveLocation.INPUT_OBJECT,
  52889. description: 'Location adjacent to an input object type definition.'
  52890. },
  52891. INPUT_FIELD_DEFINITION: {
  52892. value: _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION,
  52893. description: 'Location adjacent to an input object field definition.'
  52894. }
  52895. }
  52896. });
  52897. exports.__DirectiveLocation = __DirectiveLocation;
  52898. var __Type = new _definition.GraphQLObjectType({
  52899. name: '__Type',
  52900. description: 'The fundamental unit of any GraphQL Schema is the type. There are ' + 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' + '\n\nDepending on the kind of a type, certain fields describe ' + 'information about that type. Scalar types provide no information ' + 'beyond a name and description, while Enum types provide their values. ' + 'Object and Interface types provide the fields they describe. Abstract ' + 'types, Union and Interface, provide the Object types possible ' + 'at runtime. List and NonNull types compose other types.',
  52901. fields: function fields() {
  52902. return {
  52903. kind: {
  52904. type: (0, _definition.GraphQLNonNull)(__TypeKind),
  52905. resolve: function resolve(type) {
  52906. if ((0, _definition.isScalarType)(type)) {
  52907. return TypeKind.SCALAR;
  52908. } else if ((0, _definition.isObjectType)(type)) {
  52909. return TypeKind.OBJECT;
  52910. } else if ((0, _definition.isInterfaceType)(type)) {
  52911. return TypeKind.INTERFACE;
  52912. } else if ((0, _definition.isUnionType)(type)) {
  52913. return TypeKind.UNION;
  52914. } else if ((0, _definition.isEnumType)(type)) {
  52915. return TypeKind.ENUM;
  52916. } else if ((0, _definition.isInputObjectType)(type)) {
  52917. return TypeKind.INPUT_OBJECT;
  52918. } else if ((0, _definition.isListType)(type)) {
  52919. return TypeKind.LIST;
  52920. } else if ((0, _definition.isNonNullType)(type)) {
  52921. return TypeKind.NON_NULL;
  52922. }
  52923. throw new Error('Unknown kind of type: ' + type);
  52924. }
  52925. },
  52926. name: {
  52927. type: _scalars.GraphQLString,
  52928. resolve: function resolve(obj) {
  52929. return obj.name;
  52930. }
  52931. },
  52932. description: {
  52933. type: _scalars.GraphQLString,
  52934. resolve: function resolve(obj) {
  52935. return obj.description;
  52936. }
  52937. },
  52938. fields: {
  52939. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Field)),
  52940. args: {
  52941. includeDeprecated: {
  52942. type: _scalars.GraphQLBoolean,
  52943. defaultValue: false
  52944. }
  52945. },
  52946. resolve: function resolve(type, _ref) {
  52947. var includeDeprecated = _ref.includeDeprecated;
  52948. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  52949. var fields = (0, _objectValues.default)(type.getFields());
  52950. if (!includeDeprecated) {
  52951. fields = fields.filter(function (field) {
  52952. return !field.deprecationReason;
  52953. });
  52954. }
  52955. return fields;
  52956. }
  52957. return null;
  52958. }
  52959. },
  52960. interfaces: {
  52961. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type)),
  52962. resolve: function resolve(type) {
  52963. if ((0, _definition.isObjectType)(type)) {
  52964. return type.getInterfaces();
  52965. }
  52966. }
  52967. },
  52968. possibleTypes: {
  52969. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Type)),
  52970. resolve: function resolve(type, args, context, _ref2) {
  52971. var schema = _ref2.schema;
  52972. if ((0, _definition.isAbstractType)(type)) {
  52973. return schema.getPossibleTypes(type);
  52974. }
  52975. }
  52976. },
  52977. enumValues: {
  52978. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__EnumValue)),
  52979. args: {
  52980. includeDeprecated: {
  52981. type: _scalars.GraphQLBoolean,
  52982. defaultValue: false
  52983. }
  52984. },
  52985. resolve: function resolve(type, _ref3) {
  52986. var includeDeprecated = _ref3.includeDeprecated;
  52987. if ((0, _definition.isEnumType)(type)) {
  52988. var values = type.getValues();
  52989. if (!includeDeprecated) {
  52990. values = values.filter(function (value) {
  52991. return !value.deprecationReason;
  52992. });
  52993. }
  52994. return values;
  52995. }
  52996. }
  52997. },
  52998. inputFields: {
  52999. type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue)),
  53000. resolve: function resolve(type) {
  53001. if ((0, _definition.isInputObjectType)(type)) {
  53002. return (0, _objectValues.default)(type.getFields());
  53003. }
  53004. }
  53005. },
  53006. ofType: {
  53007. type: __Type,
  53008. resolve: function resolve(obj) {
  53009. return obj.ofType;
  53010. }
  53011. }
  53012. };
  53013. }
  53014. });
  53015. exports.__Type = __Type;
  53016. var __Field = new _definition.GraphQLObjectType({
  53017. name: '__Field',
  53018. description: 'Object and Interface types are described by a list of Fields, each of ' + 'which has a name, potentially a list of arguments, and a return type.',
  53019. fields: function fields() {
  53020. return {
  53021. name: {
  53022. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  53023. resolve: function resolve(obj) {
  53024. return obj.name;
  53025. }
  53026. },
  53027. description: {
  53028. type: _scalars.GraphQLString,
  53029. resolve: function resolve(obj) {
  53030. return obj.description;
  53031. }
  53032. },
  53033. args: {
  53034. type: (0, _definition.GraphQLNonNull)((0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__InputValue))),
  53035. resolve: function resolve(field) {
  53036. return field.args || [];
  53037. }
  53038. },
  53039. type: {
  53040. type: (0, _definition.GraphQLNonNull)(__Type),
  53041. resolve: function resolve(obj) {
  53042. return obj.type;
  53043. }
  53044. },
  53045. isDeprecated: {
  53046. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  53047. resolve: function resolve(obj) {
  53048. return obj.isDeprecated;
  53049. }
  53050. },
  53051. deprecationReason: {
  53052. type: _scalars.GraphQLString,
  53053. resolve: function resolve(obj) {
  53054. return obj.deprecationReason;
  53055. }
  53056. }
  53057. };
  53058. }
  53059. });
  53060. exports.__Field = __Field;
  53061. var __InputValue = new _definition.GraphQLObjectType({
  53062. name: '__InputValue',
  53063. description: 'Arguments provided to Fields or Directives and the input fields of an ' + 'InputObject are represented as Input Values which describe their type ' + 'and optionally a default value.',
  53064. fields: function fields() {
  53065. return {
  53066. name: {
  53067. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  53068. resolve: function resolve(obj) {
  53069. return obj.name;
  53070. }
  53071. },
  53072. description: {
  53073. type: _scalars.GraphQLString,
  53074. resolve: function resolve(obj) {
  53075. return obj.description;
  53076. }
  53077. },
  53078. type: {
  53079. type: (0, _definition.GraphQLNonNull)(__Type),
  53080. resolve: function resolve(obj) {
  53081. return obj.type;
  53082. }
  53083. },
  53084. defaultValue: {
  53085. type: _scalars.GraphQLString,
  53086. description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
  53087. resolve: function resolve(inputVal) {
  53088. return (0, _isInvalid.default)(inputVal.defaultValue) ? null : (0, _printer.print)((0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type));
  53089. }
  53090. }
  53091. };
  53092. }
  53093. });
  53094. exports.__InputValue = __InputValue;
  53095. var __EnumValue = new _definition.GraphQLObjectType({
  53096. name: '__EnumValue',
  53097. description: 'One possible value for a given Enum. Enum values are unique values, not ' + 'a placeholder for a string or numeric value. However an Enum value is ' + 'returned in a JSON response as a string.',
  53098. fields: function fields() {
  53099. return {
  53100. name: {
  53101. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  53102. resolve: function resolve(obj) {
  53103. return obj.name;
  53104. }
  53105. },
  53106. description: {
  53107. type: _scalars.GraphQLString,
  53108. resolve: function resolve(obj) {
  53109. return obj.description;
  53110. }
  53111. },
  53112. isDeprecated: {
  53113. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLBoolean),
  53114. resolve: function resolve(obj) {
  53115. return obj.isDeprecated;
  53116. }
  53117. },
  53118. deprecationReason: {
  53119. type: _scalars.GraphQLString,
  53120. resolve: function resolve(obj) {
  53121. return obj.deprecationReason;
  53122. }
  53123. }
  53124. };
  53125. }
  53126. });
  53127. exports.__EnumValue = __EnumValue;
  53128. var TypeKind = {
  53129. SCALAR: 'SCALAR',
  53130. OBJECT: 'OBJECT',
  53131. INTERFACE: 'INTERFACE',
  53132. UNION: 'UNION',
  53133. ENUM: 'ENUM',
  53134. INPUT_OBJECT: 'INPUT_OBJECT',
  53135. LIST: 'LIST',
  53136. NON_NULL: 'NON_NULL'
  53137. };
  53138. exports.TypeKind = TypeKind;
  53139. var __TypeKind = new _definition.GraphQLEnumType({
  53140. name: '__TypeKind',
  53141. description: 'An enum describing what kind of type a given `__Type` is.',
  53142. values: {
  53143. SCALAR: {
  53144. value: TypeKind.SCALAR,
  53145. description: 'Indicates this type is a scalar.'
  53146. },
  53147. OBJECT: {
  53148. value: TypeKind.OBJECT,
  53149. description: 'Indicates this type is an object. ' + '`fields` and `interfaces` are valid fields.'
  53150. },
  53151. INTERFACE: {
  53152. value: TypeKind.INTERFACE,
  53153. description: 'Indicates this type is an interface. ' + '`fields` and `possibleTypes` are valid fields.'
  53154. },
  53155. UNION: {
  53156. value: TypeKind.UNION,
  53157. description: 'Indicates this type is a union. `possibleTypes` is a valid field.'
  53158. },
  53159. ENUM: {
  53160. value: TypeKind.ENUM,
  53161. description: 'Indicates this type is an enum. `enumValues` is a valid field.'
  53162. },
  53163. INPUT_OBJECT: {
  53164. value: TypeKind.INPUT_OBJECT,
  53165. description: 'Indicates this type is an input object. ' + '`inputFields` is a valid field.'
  53166. },
  53167. LIST: {
  53168. value: TypeKind.LIST,
  53169. description: 'Indicates this type is a list. `ofType` is a valid field.'
  53170. },
  53171. NON_NULL: {
  53172. value: TypeKind.NON_NULL,
  53173. description: 'Indicates this type is a non-null. `ofType` is a valid field.'
  53174. }
  53175. }
  53176. });
  53177. /**
  53178. * Note that these are GraphQLField and not GraphQLFieldConfig,
  53179. * so the format for args is different.
  53180. */
  53181. exports.__TypeKind = __TypeKind;
  53182. var SchemaMetaFieldDef = {
  53183. name: '__schema',
  53184. type: (0, _definition.GraphQLNonNull)(__Schema),
  53185. description: 'Access the current type schema of this server.',
  53186. args: [],
  53187. resolve: function resolve(source, args, context, _ref4) {
  53188. var schema = _ref4.schema;
  53189. return schema;
  53190. }
  53191. };
  53192. exports.SchemaMetaFieldDef = SchemaMetaFieldDef;
  53193. var TypeMetaFieldDef = {
  53194. name: '__type',
  53195. type: __Type,
  53196. description: 'Request the type information of a single type.',
  53197. args: [{
  53198. name: 'name',
  53199. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString)
  53200. }],
  53201. resolve: function resolve(source, _ref5, context, _ref6) {
  53202. var name = _ref5.name;
  53203. var schema = _ref6.schema;
  53204. return schema.getType(name);
  53205. }
  53206. };
  53207. exports.TypeMetaFieldDef = TypeMetaFieldDef;
  53208. var TypeNameMetaFieldDef = {
  53209. name: '__typename',
  53210. type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
  53211. description: 'The name of the current Object type at runtime.',
  53212. args: [],
  53213. resolve: function resolve(source, args, context, _ref7) {
  53214. var parentType = _ref7.parentType;
  53215. return parentType.name;
  53216. }
  53217. };
  53218. exports.TypeNameMetaFieldDef = TypeNameMetaFieldDef;
  53219. var introspectionTypes = [__Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind];
  53220. exports.introspectionTypes = introspectionTypes;
  53221. function isIntrospectionType(type) {
  53222. return (0, _definition.isNamedType)(type) && ( // Would prefer to use introspectionTypes.some(), however %checks needs
  53223. // a simple expression.
  53224. type.name === __Schema.name || type.name === __Directive.name || type.name === __DirectiveLocation.name || type.name === __Type.name || type.name === __Field.name || type.name === __InputValue.name || type.name === __EnumValue.name || type.name === __TypeKind.name);
  53225. }
  53226. },{"../jsutils/isInvalid":291,"../language/directiveLocation":305,"../language/printer":312,"../polyfills/objectValues":319,"../utilities/astFromValue":332,"./definition":323,"./scalars":327}],327:[function(require,module,exports){
  53227. "use strict";
  53228. Object.defineProperty(exports, "__esModule", {
  53229. value: true
  53230. });
  53231. exports.isSpecifiedScalarType = isSpecifiedScalarType;
  53232. exports.specifiedScalarTypes = exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = void 0;
  53233. var _isFinite = _interopRequireDefault(require("../polyfills/isFinite"));
  53234. var _isInteger = _interopRequireDefault(require("../polyfills/isInteger"));
  53235. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  53236. var _definition = require("./definition");
  53237. var _kinds = require("../language/kinds");
  53238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  53239. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  53240. // As per the GraphQL Spec, Integers are only treated as valid when a valid
  53241. // 32-bit signed integer, providing the broadest support across platforms.
  53242. //
  53243. // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
  53244. // they are internally represented as IEEE 754 doubles.
  53245. var MAX_INT = 2147483647;
  53246. var MIN_INT = -2147483648;
  53247. function serializeInt(value) {
  53248. if (typeof value === 'boolean') {
  53249. return value ? 1 : 0;
  53250. }
  53251. var num = value;
  53252. if (typeof value === 'string' && value !== '') {
  53253. num = Number(value);
  53254. }
  53255. if (!(0, _isInteger.default)(num)) {
  53256. throw new TypeError("Int cannot represent non-integer value: ".concat((0, _inspect.default)(value)));
  53257. }
  53258. if (num > MAX_INT || num < MIN_INT) {
  53259. throw new TypeError("Int cannot represent non 32-bit signed integer value: ".concat((0, _inspect.default)(value)));
  53260. }
  53261. return num;
  53262. }
  53263. function coerceInt(value) {
  53264. if (!(0, _isInteger.default)(value)) {
  53265. throw new TypeError("Int cannot represent non-integer value: ".concat((0, _inspect.default)(value)));
  53266. }
  53267. if (value > MAX_INT || value < MIN_INT) {
  53268. throw new TypeError("Int cannot represent non 32-bit signed integer value: ".concat((0, _inspect.default)(value)));
  53269. }
  53270. return value;
  53271. }
  53272. var GraphQLInt = new _definition.GraphQLScalarType({
  53273. name: 'Int',
  53274. description: 'The `Int` scalar type represents non-fractional signed whole numeric ' + 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
  53275. serialize: serializeInt,
  53276. parseValue: coerceInt,
  53277. parseLiteral: function parseLiteral(ast) {
  53278. if (ast.kind === _kinds.Kind.INT) {
  53279. var num = parseInt(ast.value, 10);
  53280. if (num <= MAX_INT && num >= MIN_INT) {
  53281. return num;
  53282. }
  53283. }
  53284. return undefined;
  53285. }
  53286. });
  53287. exports.GraphQLInt = GraphQLInt;
  53288. function serializeFloat(value) {
  53289. if (typeof value === 'boolean') {
  53290. return value ? 1 : 0;
  53291. }
  53292. var num = value;
  53293. if (typeof value === 'string' && value !== '') {
  53294. num = Number(value);
  53295. }
  53296. if (!(0, _isFinite.default)(num)) {
  53297. throw new TypeError("Float cannot represent non numeric value: ".concat((0, _inspect.default)(value)));
  53298. }
  53299. return num;
  53300. }
  53301. function coerceFloat(value) {
  53302. if (!(0, _isFinite.default)(value)) {
  53303. throw new TypeError("Float cannot represent non numeric value: ".concat((0, _inspect.default)(value)));
  53304. }
  53305. return value;
  53306. }
  53307. var GraphQLFloat = new _definition.GraphQLScalarType({
  53308. name: 'Float',
  53309. description: 'The `Float` scalar type represents signed double-precision fractional ' + 'values as specified by ' + '[IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point). ',
  53310. serialize: serializeFloat,
  53311. parseValue: coerceFloat,
  53312. parseLiteral: function parseLiteral(ast) {
  53313. return ast.kind === _kinds.Kind.FLOAT || ast.kind === _kinds.Kind.INT ? parseFloat(ast.value) : undefined;
  53314. }
  53315. }); // Support serializing objects with custom valueOf() or toJSON() functions -
  53316. // a common way to represent a complex value which can be represented as
  53317. // a string (ex: MongoDB id objects).
  53318. exports.GraphQLFloat = GraphQLFloat;
  53319. function serializeObject(value) {
  53320. if (_typeof(value) === 'object' && value !== null) {
  53321. if (typeof value.valueOf === 'function') {
  53322. var valueOfResult = value.valueOf();
  53323. if (_typeof(valueOfResult) !== 'object') {
  53324. return valueOfResult;
  53325. }
  53326. }
  53327. if (typeof value.toJSON === 'function') {
  53328. // $FlowFixMe(>=0.90.0)
  53329. return value.toJSON();
  53330. }
  53331. }
  53332. return value;
  53333. }
  53334. function serializeString(rawValue) {
  53335. var value = serializeObject(rawValue); // Serialize string, boolean and number values to a string, but do not
  53336. // attempt to coerce object, function, symbol, or other types as strings.
  53337. if (typeof value === 'string') {
  53338. return value;
  53339. }
  53340. if (typeof value === 'boolean') {
  53341. return value ? 'true' : 'false';
  53342. }
  53343. if ((0, _isFinite.default)(value)) {
  53344. return value.toString();
  53345. }
  53346. throw new TypeError("String cannot represent value: ".concat((0, _inspect.default)(rawValue)));
  53347. }
  53348. function coerceString(value) {
  53349. if (typeof value !== 'string') {
  53350. throw new TypeError("String cannot represent a non string value: ".concat((0, _inspect.default)(value)));
  53351. }
  53352. return value;
  53353. }
  53354. var GraphQLString = new _definition.GraphQLScalarType({
  53355. name: 'String',
  53356. description: 'The `String` scalar type represents textual data, represented as UTF-8 ' + 'character sequences. The String type is most often used by GraphQL to ' + 'represent free-form human-readable text.',
  53357. serialize: serializeString,
  53358. parseValue: coerceString,
  53359. parseLiteral: function parseLiteral(ast) {
  53360. return ast.kind === _kinds.Kind.STRING ? ast.value : undefined;
  53361. }
  53362. });
  53363. exports.GraphQLString = GraphQLString;
  53364. function serializeBoolean(value) {
  53365. if (typeof value === 'boolean') {
  53366. return value;
  53367. }
  53368. if ((0, _isFinite.default)(value)) {
  53369. return value !== 0;
  53370. }
  53371. throw new TypeError("Boolean cannot represent a non boolean value: ".concat((0, _inspect.default)(value)));
  53372. }
  53373. function coerceBoolean(value) {
  53374. if (typeof value !== 'boolean') {
  53375. throw new TypeError("Boolean cannot represent a non boolean value: ".concat((0, _inspect.default)(value)));
  53376. }
  53377. return value;
  53378. }
  53379. var GraphQLBoolean = new _definition.GraphQLScalarType({
  53380. name: 'Boolean',
  53381. description: 'The `Boolean` scalar type represents `true` or `false`.',
  53382. serialize: serializeBoolean,
  53383. parseValue: coerceBoolean,
  53384. parseLiteral: function parseLiteral(ast) {
  53385. return ast.kind === _kinds.Kind.BOOLEAN ? ast.value : undefined;
  53386. }
  53387. });
  53388. exports.GraphQLBoolean = GraphQLBoolean;
  53389. function serializeID(rawValue) {
  53390. var value = serializeObject(rawValue);
  53391. if (typeof value === 'string') {
  53392. return value;
  53393. }
  53394. if ((0, _isInteger.default)(value)) {
  53395. return String(value);
  53396. }
  53397. throw new TypeError("ID cannot represent value: ".concat((0, _inspect.default)(rawValue)));
  53398. }
  53399. function coerceID(value) {
  53400. if (typeof value === 'string') {
  53401. return value;
  53402. }
  53403. if ((0, _isInteger.default)(value)) {
  53404. return value.toString();
  53405. }
  53406. throw new TypeError("ID cannot represent value: ".concat((0, _inspect.default)(value)));
  53407. }
  53408. var GraphQLID = new _definition.GraphQLScalarType({
  53409. name: 'ID',
  53410. description: 'The `ID` scalar type represents a unique identifier, often used to ' + 'refetch an object or as key for a cache. The ID type appears in a JSON ' + 'response as a String; however, it is not intended to be human-readable. ' + 'When expected as an input type, any string (such as `"4"`) or integer ' + '(such as `4`) input value will be accepted as an ID.',
  53411. serialize: serializeID,
  53412. parseValue: coerceID,
  53413. parseLiteral: function parseLiteral(ast) {
  53414. return ast.kind === _kinds.Kind.STRING || ast.kind === _kinds.Kind.INT ? ast.value : undefined;
  53415. }
  53416. });
  53417. exports.GraphQLID = GraphQLID;
  53418. var specifiedScalarTypes = [GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID];
  53419. exports.specifiedScalarTypes = specifiedScalarTypes;
  53420. function isSpecifiedScalarType(type) {
  53421. return (0, _definition.isNamedType)(type) && ( // Would prefer to use specifiedScalarTypes.some(), however %checks needs
  53422. // a simple expression.
  53423. type.name === GraphQLString.name || type.name === GraphQLInt.name || type.name === GraphQLFloat.name || type.name === GraphQLBoolean.name || type.name === GraphQLID.name);
  53424. }
  53425. },{"../jsutils/inspect":288,"../language/kinds":307,"../polyfills/isFinite":316,"../polyfills/isInteger":317,"./definition":323}],328:[function(require,module,exports){
  53426. "use strict";
  53427. Object.defineProperty(exports, "__esModule", {
  53428. value: true
  53429. });
  53430. exports.isSchema = isSchema;
  53431. exports.assertSchema = assertSchema;
  53432. exports.GraphQLSchema = void 0;
  53433. var _find = _interopRequireDefault(require("../polyfills/find"));
  53434. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  53435. var _definition = require("./definition");
  53436. var _directives = require("./directives");
  53437. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  53438. var _introspection = require("./introspection");
  53439. var _defineToStringTag = _interopRequireDefault(require("../jsutils/defineToStringTag"));
  53440. var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
  53441. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  53442. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  53443. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  53444. // eslint-disable-next-line no-redeclare
  53445. function isSchema(schema) {
  53446. return (0, _instanceOf.default)(schema, GraphQLSchema);
  53447. }
  53448. function assertSchema(schema) {
  53449. !isSchema(schema) ? (0, _invariant.default)(0, "Expected ".concat((0, _inspect.default)(schema), " to be a GraphQL schema.")) : void 0;
  53450. return schema;
  53451. }
  53452. /**
  53453. * Schema Definition
  53454. *
  53455. * A Schema is created by supplying the root types of each type of operation,
  53456. * query and mutation (optional). A schema definition is then supplied to the
  53457. * validator and executor.
  53458. *
  53459. * Example:
  53460. *
  53461. * const MyAppSchema = new GraphQLSchema({
  53462. * query: MyAppQueryRootType,
  53463. * mutation: MyAppMutationRootType,
  53464. * })
  53465. *
  53466. * Note: If an array of `directives` are provided to GraphQLSchema, that will be
  53467. * the exact list of directives represented and allowed. If `directives` is not
  53468. * provided then a default set of the specified directives (e.g. @include and
  53469. * @skip) will be used. If you wish to provide *additional* directives to these
  53470. * specified directives, you must explicitly declare them. Example:
  53471. *
  53472. * const MyAppSchema = new GraphQLSchema({
  53473. * ...
  53474. * directives: specifiedDirectives.concat([ myCustomDirective ]),
  53475. * })
  53476. *
  53477. */
  53478. var GraphQLSchema =
  53479. /*#__PURE__*/
  53480. function () {
  53481. // Used as a cache for validateSchema().
  53482. // Referenced by validateSchema().
  53483. function GraphQLSchema(config) {
  53484. // If this schema was built from a source known to be valid, then it may be
  53485. // marked with assumeValid to avoid an additional type system validation.
  53486. if (config && config.assumeValid) {
  53487. this.__validationErrors = [];
  53488. } else {
  53489. this.__validationErrors = undefined; // Otherwise check for common mistakes during construction to produce
  53490. // clear and early error messages.
  53491. !(_typeof(config) === 'object') ? (0, _invariant.default)(0, 'Must provide configuration object.') : void 0;
  53492. !(!config.types || Array.isArray(config.types)) ? (0, _invariant.default)(0, "\"types\" must be Array if provided but got: ".concat((0, _inspect.default)(config.types), ".")) : void 0;
  53493. !(!config.directives || Array.isArray(config.directives)) ? (0, _invariant.default)(0, '"directives" must be Array if provided but got: ' + "".concat((0, _inspect.default)(config.directives), ".")) : void 0;
  53494. !(!config.allowedLegacyNames || Array.isArray(config.allowedLegacyNames)) ? (0, _invariant.default)(0, '"allowedLegacyNames" must be Array if provided but got: ' + "".concat((0, _inspect.default)(config.allowedLegacyNames), ".")) : void 0;
  53495. }
  53496. this.__allowedLegacyNames = config.allowedLegacyNames || [];
  53497. this._queryType = config.query;
  53498. this._mutationType = config.mutation;
  53499. this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default.
  53500. this._directives = config.directives || _directives.specifiedDirectives;
  53501. this.astNode = config.astNode;
  53502. this.extensionASTNodes = config.extensionASTNodes; // Build type map now to detect any errors within this schema.
  53503. var initialTypes = [this.getQueryType(), this.getMutationType(), this.getSubscriptionType(), _introspection.__Schema];
  53504. var types = config.types;
  53505. if (types) {
  53506. initialTypes = initialTypes.concat(types);
  53507. } // Keep track of all types referenced within the schema.
  53508. var typeMap = Object.create(null); // First by deeply visiting all initial types.
  53509. typeMap = initialTypes.reduce(typeMapReducer, typeMap); // Then by deeply visiting all directive types.
  53510. typeMap = this._directives.reduce(typeMapDirectiveReducer, typeMap); // Storing the resulting map for reference by the schema.
  53511. this._typeMap = typeMap;
  53512. this._possibleTypeMap = Object.create(null); // Keep track of all implementations by interface name.
  53513. this._implementations = Object.create(null);
  53514. var _iteratorNormalCompletion = true;
  53515. var _didIteratorError = false;
  53516. var _iteratorError = undefined;
  53517. try {
  53518. for (var _iterator = (0, _objectValues.default)(this._typeMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  53519. var type = _step.value;
  53520. if ((0, _definition.isObjectType)(type)) {
  53521. var _iteratorNormalCompletion2 = true;
  53522. var _didIteratorError2 = false;
  53523. var _iteratorError2 = undefined;
  53524. try {
  53525. for (var _iterator2 = type.getInterfaces()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  53526. var iface = _step2.value;
  53527. if ((0, _definition.isInterfaceType)(iface)) {
  53528. var impls = this._implementations[iface.name];
  53529. if (impls) {
  53530. impls.push(type);
  53531. } else {
  53532. this._implementations[iface.name] = [type];
  53533. }
  53534. }
  53535. }
  53536. } catch (err) {
  53537. _didIteratorError2 = true;
  53538. _iteratorError2 = err;
  53539. } finally {
  53540. try {
  53541. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  53542. _iterator2.return();
  53543. }
  53544. } finally {
  53545. if (_didIteratorError2) {
  53546. throw _iteratorError2;
  53547. }
  53548. }
  53549. }
  53550. } else if ((0, _definition.isAbstractType)(type) && !this._implementations[type.name]) {
  53551. this._implementations[type.name] = [];
  53552. }
  53553. }
  53554. } catch (err) {
  53555. _didIteratorError = true;
  53556. _iteratorError = err;
  53557. } finally {
  53558. try {
  53559. if (!_iteratorNormalCompletion && _iterator.return != null) {
  53560. _iterator.return();
  53561. }
  53562. } finally {
  53563. if (_didIteratorError) {
  53564. throw _iteratorError;
  53565. }
  53566. }
  53567. }
  53568. }
  53569. var _proto = GraphQLSchema.prototype;
  53570. _proto.getQueryType = function getQueryType() {
  53571. return this._queryType;
  53572. };
  53573. _proto.getMutationType = function getMutationType() {
  53574. return this._mutationType;
  53575. };
  53576. _proto.getSubscriptionType = function getSubscriptionType() {
  53577. return this._subscriptionType;
  53578. };
  53579. _proto.getTypeMap = function getTypeMap() {
  53580. return this._typeMap;
  53581. };
  53582. _proto.getType = function getType(name) {
  53583. return this.getTypeMap()[name];
  53584. };
  53585. _proto.getPossibleTypes = function getPossibleTypes(abstractType) {
  53586. if ((0, _definition.isUnionType)(abstractType)) {
  53587. return abstractType.getTypes();
  53588. }
  53589. return this._implementations[abstractType.name];
  53590. };
  53591. _proto.isPossibleType = function isPossibleType(abstractType, possibleType) {
  53592. var possibleTypeMap = this._possibleTypeMap;
  53593. if (!possibleTypeMap[abstractType.name]) {
  53594. var possibleTypes = this.getPossibleTypes(abstractType);
  53595. possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
  53596. return map[type.name] = true, map;
  53597. }, Object.create(null));
  53598. }
  53599. return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
  53600. };
  53601. _proto.getDirectives = function getDirectives() {
  53602. return this._directives;
  53603. };
  53604. _proto.getDirective = function getDirective(name) {
  53605. return (0, _find.default)(this.getDirectives(), function (directive) {
  53606. return directive.name === name;
  53607. });
  53608. };
  53609. return GraphQLSchema;
  53610. }(); // Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
  53611. exports.GraphQLSchema = GraphQLSchema;
  53612. (0, _defineToStringTag.default)(GraphQLSchema);
  53613. function typeMapReducer(map, type) {
  53614. if (!type) {
  53615. return map;
  53616. }
  53617. if ((0, _definition.isWrappingType)(type)) {
  53618. return typeMapReducer(map, type.ofType);
  53619. }
  53620. if (map[type.name]) {
  53621. !(map[type.name] === type) ? (0, _invariant.default)(0, 'Schema must contain unique named types but contains multiple ' + "types named \"".concat(type.name, "\".")) : void 0;
  53622. return map;
  53623. }
  53624. map[type.name] = type;
  53625. var reducedMap = map;
  53626. if ((0, _definition.isUnionType)(type)) {
  53627. reducedMap = type.getTypes().reduce(typeMapReducer, reducedMap);
  53628. }
  53629. if ((0, _definition.isObjectType)(type)) {
  53630. reducedMap = type.getInterfaces().reduce(typeMapReducer, reducedMap);
  53631. }
  53632. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  53633. var _iteratorNormalCompletion3 = true;
  53634. var _didIteratorError3 = false;
  53635. var _iteratorError3 = undefined;
  53636. try {
  53637. for (var _iterator3 = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  53638. var field = _step3.value;
  53639. if (field.args) {
  53640. var fieldArgTypes = field.args.map(function (arg) {
  53641. return arg.type;
  53642. });
  53643. reducedMap = fieldArgTypes.reduce(typeMapReducer, reducedMap);
  53644. }
  53645. reducedMap = typeMapReducer(reducedMap, field.type);
  53646. }
  53647. } catch (err) {
  53648. _didIteratorError3 = true;
  53649. _iteratorError3 = err;
  53650. } finally {
  53651. try {
  53652. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  53653. _iterator3.return();
  53654. }
  53655. } finally {
  53656. if (_didIteratorError3) {
  53657. throw _iteratorError3;
  53658. }
  53659. }
  53660. }
  53661. }
  53662. if ((0, _definition.isInputObjectType)(type)) {
  53663. var _iteratorNormalCompletion4 = true;
  53664. var _didIteratorError4 = false;
  53665. var _iteratorError4 = undefined;
  53666. try {
  53667. for (var _iterator4 = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  53668. var _field = _step4.value;
  53669. reducedMap = typeMapReducer(reducedMap, _field.type);
  53670. }
  53671. } catch (err) {
  53672. _didIteratorError4 = true;
  53673. _iteratorError4 = err;
  53674. } finally {
  53675. try {
  53676. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  53677. _iterator4.return();
  53678. }
  53679. } finally {
  53680. if (_didIteratorError4) {
  53681. throw _iteratorError4;
  53682. }
  53683. }
  53684. }
  53685. }
  53686. return reducedMap;
  53687. }
  53688. function typeMapDirectiveReducer(map, directive) {
  53689. // Directives are not validated until validateSchema() is called.
  53690. if (!(0, _directives.isDirective)(directive)) {
  53691. return map;
  53692. }
  53693. return directive.args.reduce(function (_map, arg) {
  53694. return typeMapReducer(_map, arg.type);
  53695. }, map);
  53696. }
  53697. },{"../jsutils/defineToStringTag":287,"../jsutils/inspect":288,"../jsutils/instanceOf":289,"../jsutils/invariant":290,"../polyfills/find":315,"../polyfills/objectValues":319,"./definition":323,"./directives":324,"./introspection":326}],329:[function(require,module,exports){
  53698. "use strict";
  53699. Object.defineProperty(exports, "__esModule", {
  53700. value: true
  53701. });
  53702. exports.validateSchema = validateSchema;
  53703. exports.assertValidSchema = assertValidSchema;
  53704. var _find = _interopRequireDefault(require("../polyfills/find"));
  53705. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  53706. var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
  53707. var _definition = require("./definition");
  53708. var _directives = require("./directives");
  53709. var _introspection = require("./introspection");
  53710. var _schema = require("./schema");
  53711. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  53712. var _GraphQLError = require("../error/GraphQLError");
  53713. var _assertValidName = require("../utilities/assertValidName");
  53714. var _typeComparators = require("../utilities/typeComparators");
  53715. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  53716. /**
  53717. * Copyright (c) 2015-present, Facebook, Inc.
  53718. *
  53719. * This source code is licensed under the MIT license found in the
  53720. * LICENSE file in the root directory of this source tree.
  53721. *
  53722. *
  53723. */
  53724. /**
  53725. * Implements the "Type Validation" sub-sections of the specification's
  53726. * "Type System" section.
  53727. *
  53728. * Validation runs synchronously, returning an array of encountered errors, or
  53729. * an empty array if no errors were encountered and the Schema is valid.
  53730. */
  53731. function validateSchema(schema) {
  53732. // First check to ensure the provided value is in fact a GraphQLSchema.
  53733. (0, _schema.assertSchema)(schema); // If this Schema has already been validated, return the previous results.
  53734. if (schema.__validationErrors) {
  53735. return schema.__validationErrors;
  53736. } // Validate the schema, producing a list of errors.
  53737. var context = new SchemaValidationContext(schema);
  53738. validateRootTypes(context);
  53739. validateDirectives(context);
  53740. validateTypes(context); // Persist the results of validation before returning to ensure validation
  53741. // does not run multiple times for this schema.
  53742. var errors = context.getErrors();
  53743. schema.__validationErrors = errors;
  53744. return errors;
  53745. }
  53746. /**
  53747. * Utility function which asserts a schema is valid by throwing an error if
  53748. * it is invalid.
  53749. */
  53750. function assertValidSchema(schema) {
  53751. var errors = validateSchema(schema);
  53752. if (errors.length !== 0) {
  53753. throw new Error(errors.map(function (error) {
  53754. return error.message;
  53755. }).join('\n\n'));
  53756. }
  53757. }
  53758. var SchemaValidationContext =
  53759. /*#__PURE__*/
  53760. function () {
  53761. function SchemaValidationContext(schema) {
  53762. this._errors = [];
  53763. this.schema = schema;
  53764. }
  53765. var _proto = SchemaValidationContext.prototype;
  53766. _proto.reportError = function reportError(message, nodes) {
  53767. var _nodes = (Array.isArray(nodes) ? nodes : [nodes]).filter(Boolean);
  53768. this.addError(new _GraphQLError.GraphQLError(message, _nodes));
  53769. };
  53770. _proto.addError = function addError(error) {
  53771. this._errors.push(error);
  53772. };
  53773. _proto.getErrors = function getErrors() {
  53774. return this._errors;
  53775. };
  53776. return SchemaValidationContext;
  53777. }();
  53778. function validateRootTypes(context) {
  53779. var schema = context.schema;
  53780. var queryType = schema.getQueryType();
  53781. if (!queryType) {
  53782. context.reportError("Query root type must be provided.", schema.astNode);
  53783. } else if (!(0, _definition.isObjectType)(queryType)) {
  53784. context.reportError("Query root type must be Object type, it cannot be ".concat((0, _inspect.default)(queryType), "."), getOperationTypeNode(schema, queryType, 'query'));
  53785. }
  53786. var mutationType = schema.getMutationType();
  53787. if (mutationType && !(0, _definition.isObjectType)(mutationType)) {
  53788. context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(mutationType), "."), getOperationTypeNode(schema, mutationType, 'mutation'));
  53789. }
  53790. var subscriptionType = schema.getSubscriptionType();
  53791. if (subscriptionType && !(0, _definition.isObjectType)(subscriptionType)) {
  53792. context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(subscriptionType), "."), getOperationTypeNode(schema, subscriptionType, 'subscription'));
  53793. }
  53794. }
  53795. function getOperationTypeNode(schema, type, operation) {
  53796. var operationNodes = getAllSubNodes(schema, function (node) {
  53797. return node.operationTypes;
  53798. });
  53799. var _iteratorNormalCompletion = true;
  53800. var _didIteratorError = false;
  53801. var _iteratorError = undefined;
  53802. try {
  53803. for (var _iterator = operationNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  53804. var node = _step.value;
  53805. if (node.operation === operation) {
  53806. return node.type;
  53807. }
  53808. }
  53809. } catch (err) {
  53810. _didIteratorError = true;
  53811. _iteratorError = err;
  53812. } finally {
  53813. try {
  53814. if (!_iteratorNormalCompletion && _iterator.return != null) {
  53815. _iterator.return();
  53816. }
  53817. } finally {
  53818. if (_didIteratorError) {
  53819. throw _iteratorError;
  53820. }
  53821. }
  53822. }
  53823. return type.astNode;
  53824. }
  53825. function validateDirectives(context) {
  53826. var _iteratorNormalCompletion2 = true;
  53827. var _didIteratorError2 = false;
  53828. var _iteratorError2 = undefined;
  53829. try {
  53830. for (var _iterator2 = context.schema.getDirectives()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  53831. var directive = _step2.value;
  53832. // Ensure all directives are in fact GraphQL directives.
  53833. if (!(0, _directives.isDirective)(directive)) {
  53834. context.reportError("Expected directive but got: ".concat((0, _inspect.default)(directive), "."), directive && directive.astNode);
  53835. continue;
  53836. } // Ensure they are named correctly.
  53837. validateName(context, directive); // TODO: Ensure proper locations.
  53838. // Ensure the arguments are valid.
  53839. var argNames = Object.create(null);
  53840. var _iteratorNormalCompletion3 = true;
  53841. var _didIteratorError3 = false;
  53842. var _iteratorError3 = undefined;
  53843. try {
  53844. for (var _iterator3 = directive.args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  53845. var arg = _step3.value;
  53846. var argName = arg.name; // Ensure they are named correctly.
  53847. validateName(context, arg); // Ensure they are unique per directive.
  53848. if (argNames[argName]) {
  53849. context.reportError("Argument @".concat(directive.name, "(").concat(argName, ":) can only be defined once."), getAllDirectiveArgNodes(directive, argName));
  53850. continue;
  53851. }
  53852. argNames[argName] = true; // Ensure the type is an input type.
  53853. if (!(0, _definition.isInputType)(arg.type)) {
  53854. context.reportError("The type of @".concat(directive.name, "(").concat(argName, ":) must be Input Type ") + "but got: ".concat((0, _inspect.default)(arg.type), "."), getDirectiveArgTypeNode(directive, argName));
  53855. }
  53856. }
  53857. } catch (err) {
  53858. _didIteratorError3 = true;
  53859. _iteratorError3 = err;
  53860. } finally {
  53861. try {
  53862. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  53863. _iterator3.return();
  53864. }
  53865. } finally {
  53866. if (_didIteratorError3) {
  53867. throw _iteratorError3;
  53868. }
  53869. }
  53870. }
  53871. }
  53872. } catch (err) {
  53873. _didIteratorError2 = true;
  53874. _iteratorError2 = err;
  53875. } finally {
  53876. try {
  53877. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  53878. _iterator2.return();
  53879. }
  53880. } finally {
  53881. if (_didIteratorError2) {
  53882. throw _iteratorError2;
  53883. }
  53884. }
  53885. }
  53886. }
  53887. function validateName(context, node) {
  53888. // If a schema explicitly allows some legacy name which is no longer valid,
  53889. // allow it to be assumed valid.
  53890. if (context.schema.__allowedLegacyNames.indexOf(node.name) !== -1) {
  53891. return;
  53892. } // Ensure names are valid, however introspection types opt out.
  53893. var error = (0, _assertValidName.isValidNameError)(node.name, node.astNode || undefined);
  53894. if (error) {
  53895. context.addError(error);
  53896. }
  53897. }
  53898. function validateTypes(context) {
  53899. var typeMap = context.schema.getTypeMap();
  53900. var _iteratorNormalCompletion4 = true;
  53901. var _didIteratorError4 = false;
  53902. var _iteratorError4 = undefined;
  53903. try {
  53904. for (var _iterator4 = (0, _objectValues.default)(typeMap)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  53905. var type = _step4.value;
  53906. // Ensure all provided types are in fact GraphQL type.
  53907. if (!(0, _definition.isNamedType)(type)) {
  53908. context.reportError("Expected GraphQL named type but got: ".concat((0, _inspect.default)(type), "."), type && type.astNode);
  53909. continue;
  53910. } // Ensure it is named correctly (excluding introspection types).
  53911. if (!(0, _introspection.isIntrospectionType)(type)) {
  53912. validateName(context, type);
  53913. }
  53914. if ((0, _definition.isObjectType)(type)) {
  53915. // Ensure fields are valid
  53916. validateFields(context, type); // Ensure objects implement the interfaces they claim to.
  53917. validateObjectInterfaces(context, type);
  53918. } else if ((0, _definition.isInterfaceType)(type)) {
  53919. // Ensure fields are valid.
  53920. validateFields(context, type);
  53921. } else if ((0, _definition.isUnionType)(type)) {
  53922. // Ensure Unions include valid member types.
  53923. validateUnionMembers(context, type);
  53924. } else if ((0, _definition.isEnumType)(type)) {
  53925. // Ensure Enums have valid values.
  53926. validateEnumValues(context, type);
  53927. } else if ((0, _definition.isInputObjectType)(type)) {
  53928. // Ensure Input Object fields are valid.
  53929. validateInputFields(context, type);
  53930. }
  53931. }
  53932. } catch (err) {
  53933. _didIteratorError4 = true;
  53934. _iteratorError4 = err;
  53935. } finally {
  53936. try {
  53937. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  53938. _iterator4.return();
  53939. }
  53940. } finally {
  53941. if (_didIteratorError4) {
  53942. throw _iteratorError4;
  53943. }
  53944. }
  53945. }
  53946. }
  53947. function validateFields(context, type) {
  53948. var fields = (0, _objectValues.default)(type.getFields()); // Objects and Interfaces both must define one or more fields.
  53949. if (fields.length === 0) {
  53950. context.reportError("Type ".concat(type.name, " must define one or more fields."), getAllNodes(type));
  53951. }
  53952. var _iteratorNormalCompletion5 = true;
  53953. var _didIteratorError5 = false;
  53954. var _iteratorError5 = undefined;
  53955. try {
  53956. for (var _iterator5 = fields[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  53957. var field = _step5.value;
  53958. // Ensure they are named correctly.
  53959. validateName(context, field); // Ensure the type is an output type
  53960. if (!(0, _definition.isOutputType)(field.type)) {
  53961. context.reportError("The type of ".concat(type.name, ".").concat(field.name, " must be Output Type ") + "but got: ".concat((0, _inspect.default)(field.type), "."), getFieldTypeNode(type, field.name));
  53962. } // Ensure the arguments are valid
  53963. var argNames = Object.create(null);
  53964. var _iteratorNormalCompletion6 = true;
  53965. var _didIteratorError6 = false;
  53966. var _iteratorError6 = undefined;
  53967. try {
  53968. for (var _iterator6 = field.args[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  53969. var arg = _step6.value;
  53970. var argName = arg.name; // Ensure they are named correctly.
  53971. validateName(context, arg); // Ensure they are unique per field.
  53972. if (argNames[argName]) {
  53973. context.reportError("Field argument ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) can only ") + 'be defined once.', getAllFieldArgNodes(type, field.name, argName));
  53974. }
  53975. argNames[argName] = true; // Ensure the type is an input type
  53976. if (!(0, _definition.isInputType)(arg.type)) {
  53977. context.reportError("The type of ".concat(type.name, ".").concat(field.name, "(").concat(argName, ":) must be Input ") + "Type but got: ".concat((0, _inspect.default)(arg.type), "."), getFieldArgTypeNode(type, field.name, argName));
  53978. }
  53979. }
  53980. } catch (err) {
  53981. _didIteratorError6 = true;
  53982. _iteratorError6 = err;
  53983. } finally {
  53984. try {
  53985. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  53986. _iterator6.return();
  53987. }
  53988. } finally {
  53989. if (_didIteratorError6) {
  53990. throw _iteratorError6;
  53991. }
  53992. }
  53993. }
  53994. }
  53995. } catch (err) {
  53996. _didIteratorError5 = true;
  53997. _iteratorError5 = err;
  53998. } finally {
  53999. try {
  54000. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  54001. _iterator5.return();
  54002. }
  54003. } finally {
  54004. if (_didIteratorError5) {
  54005. throw _iteratorError5;
  54006. }
  54007. }
  54008. }
  54009. }
  54010. function validateObjectInterfaces(context, object) {
  54011. var implementedTypeNames = Object.create(null);
  54012. var _iteratorNormalCompletion7 = true;
  54013. var _didIteratorError7 = false;
  54014. var _iteratorError7 = undefined;
  54015. try {
  54016. for (var _iterator7 = object.getInterfaces()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  54017. var iface = _step7.value;
  54018. if (!(0, _definition.isInterfaceType)(iface)) {
  54019. context.reportError("Type ".concat((0, _inspect.default)(object), " must only implement Interface types, ") + "it cannot implement ".concat((0, _inspect.default)(iface), "."), getImplementsInterfaceNode(object, iface));
  54020. continue;
  54021. }
  54022. if (implementedTypeNames[iface.name]) {
  54023. context.reportError("Type ".concat(object.name, " can only implement ").concat(iface.name, " once."), getAllImplementsInterfaceNodes(object, iface));
  54024. continue;
  54025. }
  54026. implementedTypeNames[iface.name] = true;
  54027. validateObjectImplementsInterface(context, object, iface);
  54028. }
  54029. } catch (err) {
  54030. _didIteratorError7 = true;
  54031. _iteratorError7 = err;
  54032. } finally {
  54033. try {
  54034. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  54035. _iterator7.return();
  54036. }
  54037. } finally {
  54038. if (_didIteratorError7) {
  54039. throw _iteratorError7;
  54040. }
  54041. }
  54042. }
  54043. }
  54044. function validateObjectImplementsInterface(context, object, iface) {
  54045. var objectFieldMap = object.getFields();
  54046. var ifaceFieldMap = iface.getFields(); // Assert each interface field is implemented.
  54047. var _iteratorNormalCompletion8 = true;
  54048. var _didIteratorError8 = false;
  54049. var _iteratorError8 = undefined;
  54050. try {
  54051. for (var _iterator8 = (0, _objectEntries.default)(ifaceFieldMap)[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  54052. var _ref2 = _step8.value;
  54053. var fieldName = _ref2[0];
  54054. var ifaceField = _ref2[1];
  54055. var objectField = objectFieldMap[fieldName]; // Assert interface field exists on object.
  54056. if (!objectField) {
  54057. context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expected but ") + "".concat(object.name, " does not provide it."), [getFieldNode(iface, fieldName)].concat(getAllNodes(object)));
  54058. continue;
  54059. } // Assert interface field type is satisfied by object field type, by being
  54060. // a valid subtype. (covariant)
  54061. if (!(0, _typeComparators.isTypeSubTypeOf)(context.schema, objectField.type, ifaceField.type)) {
  54062. context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat((0, _inspect.default)(ifaceField.type), " but ").concat(object.name, ".").concat(fieldName, " ") + "is type ".concat((0, _inspect.default)(objectField.type), "."), [getFieldTypeNode(iface, fieldName), getFieldTypeNode(object, fieldName)]);
  54063. } // Assert each interface field arg is implemented.
  54064. var _iteratorNormalCompletion9 = true;
  54065. var _didIteratorError9 = false;
  54066. var _iteratorError9 = undefined;
  54067. try {
  54068. var _loop = function _loop() {
  54069. var ifaceArg = _step9.value;
  54070. var argName = ifaceArg.name;
  54071. var objectArg = (0, _find.default)(objectField.args, function (arg) {
  54072. return arg.name === argName;
  54073. }); // Assert interface field arg exists on object field.
  54074. if (!objectArg) {
  54075. context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expected but ".concat(object.name, ".").concat(fieldName, " does not provide it."), [getFieldArgNode(iface, fieldName, argName), getFieldNode(object, fieldName)]);
  54076. return "continue";
  54077. } // Assert interface field arg type matches object field arg type.
  54078. // (invariant)
  54079. // TODO: change to contravariant?
  54080. if (!(0, _typeComparators.isEqualType)(ifaceArg.type, objectArg.type)) {
  54081. context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat((0, _inspect.default)(ifaceArg.type), " but ") + "".concat(object.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat((0, _inspect.default)(objectArg.type), "."), [getFieldArgTypeNode(iface, fieldName, argName), getFieldArgTypeNode(object, fieldName, argName)]);
  54082. } // TODO: validate default values?
  54083. };
  54084. for (var _iterator9 = ifaceField.args[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  54085. var _ret = _loop();
  54086. if (_ret === "continue") continue;
  54087. } // Assert additional arguments must not be required.
  54088. } catch (err) {
  54089. _didIteratorError9 = true;
  54090. _iteratorError9 = err;
  54091. } finally {
  54092. try {
  54093. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  54094. _iterator9.return();
  54095. }
  54096. } finally {
  54097. if (_didIteratorError9) {
  54098. throw _iteratorError9;
  54099. }
  54100. }
  54101. }
  54102. var _iteratorNormalCompletion10 = true;
  54103. var _didIteratorError10 = false;
  54104. var _iteratorError10 = undefined;
  54105. try {
  54106. var _loop2 = function _loop2() {
  54107. var objectArg = _step10.value;
  54108. var argName = objectArg.name;
  54109. var ifaceArg = (0, _find.default)(ifaceField.args, function (arg) {
  54110. return arg.name === argName;
  54111. });
  54112. if (!ifaceArg && (0, _definition.isRequiredArgument)(objectArg)) {
  54113. context.reportError("Object field ".concat(object.name, ".").concat(fieldName, " includes required ") + "argument ".concat(argName, " that is missing from the Interface field ") + "".concat(iface.name, ".").concat(fieldName, "."), [getFieldArgNode(object, fieldName, argName), getFieldNode(iface, fieldName)]);
  54114. }
  54115. };
  54116. for (var _iterator10 = objectField.args[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  54117. _loop2();
  54118. }
  54119. } catch (err) {
  54120. _didIteratorError10 = true;
  54121. _iteratorError10 = err;
  54122. } finally {
  54123. try {
  54124. if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
  54125. _iterator10.return();
  54126. }
  54127. } finally {
  54128. if (_didIteratorError10) {
  54129. throw _iteratorError10;
  54130. }
  54131. }
  54132. }
  54133. }
  54134. } catch (err) {
  54135. _didIteratorError8 = true;
  54136. _iteratorError8 = err;
  54137. } finally {
  54138. try {
  54139. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  54140. _iterator8.return();
  54141. }
  54142. } finally {
  54143. if (_didIteratorError8) {
  54144. throw _iteratorError8;
  54145. }
  54146. }
  54147. }
  54148. }
  54149. function validateUnionMembers(context, union) {
  54150. var memberTypes = union.getTypes();
  54151. if (memberTypes.length === 0) {
  54152. context.reportError("Union type ".concat(union.name, " must define one or more member types."), getAllNodes(union));
  54153. }
  54154. var includedTypeNames = Object.create(null);
  54155. var _iteratorNormalCompletion11 = true;
  54156. var _didIteratorError11 = false;
  54157. var _iteratorError11 = undefined;
  54158. try {
  54159. for (var _iterator11 = memberTypes[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  54160. var memberType = _step11.value;
  54161. if (includedTypeNames[memberType.name]) {
  54162. context.reportError("Union type ".concat(union.name, " can only include type ") + "".concat(memberType.name, " once."), getUnionMemberTypeNodes(union, memberType.name));
  54163. continue;
  54164. }
  54165. includedTypeNames[memberType.name] = true;
  54166. if (!(0, _definition.isObjectType)(memberType)) {
  54167. context.reportError("Union type ".concat(union.name, " can only include Object types, ") + "it cannot include ".concat((0, _inspect.default)(memberType), "."), getUnionMemberTypeNodes(union, String(memberType)));
  54168. }
  54169. }
  54170. } catch (err) {
  54171. _didIteratorError11 = true;
  54172. _iteratorError11 = err;
  54173. } finally {
  54174. try {
  54175. if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
  54176. _iterator11.return();
  54177. }
  54178. } finally {
  54179. if (_didIteratorError11) {
  54180. throw _iteratorError11;
  54181. }
  54182. }
  54183. }
  54184. }
  54185. function validateEnumValues(context, enumType) {
  54186. var enumValues = enumType.getValues();
  54187. if (enumValues.length === 0) {
  54188. context.reportError("Enum type ".concat(enumType.name, " must define one or more values."), getAllNodes(enumType));
  54189. }
  54190. var _iteratorNormalCompletion12 = true;
  54191. var _didIteratorError12 = false;
  54192. var _iteratorError12 = undefined;
  54193. try {
  54194. for (var _iterator12 = enumValues[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  54195. var enumValue = _step12.value;
  54196. var valueName = enumValue.name; // Ensure valid name.
  54197. validateName(context, enumValue);
  54198. if (valueName === 'true' || valueName === 'false' || valueName === 'null') {
  54199. context.reportError("Enum type ".concat(enumType.name, " cannot include value: ").concat(valueName, "."), enumValue.astNode);
  54200. }
  54201. }
  54202. } catch (err) {
  54203. _didIteratorError12 = true;
  54204. _iteratorError12 = err;
  54205. } finally {
  54206. try {
  54207. if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
  54208. _iterator12.return();
  54209. }
  54210. } finally {
  54211. if (_didIteratorError12) {
  54212. throw _iteratorError12;
  54213. }
  54214. }
  54215. }
  54216. }
  54217. function validateInputFields(context, inputObj) {
  54218. var fields = (0, _objectValues.default)(inputObj.getFields());
  54219. if (fields.length === 0) {
  54220. context.reportError("Input Object type ".concat(inputObj.name, " must define one or more fields."), getAllNodes(inputObj));
  54221. } // Ensure the arguments are valid
  54222. var _iteratorNormalCompletion13 = true;
  54223. var _didIteratorError13 = false;
  54224. var _iteratorError13 = undefined;
  54225. try {
  54226. for (var _iterator13 = fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  54227. var field = _step13.value;
  54228. // Ensure they are named correctly.
  54229. validateName(context, field); // Ensure the type is an input type
  54230. if (!(0, _definition.isInputType)(field.type)) {
  54231. context.reportError("The type of ".concat(inputObj.name, ".").concat(field.name, " must be Input Type ") + "but got: ".concat((0, _inspect.default)(field.type), "."), field.astNode && field.astNode.type);
  54232. }
  54233. }
  54234. } catch (err) {
  54235. _didIteratorError13 = true;
  54236. _iteratorError13 = err;
  54237. } finally {
  54238. try {
  54239. if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
  54240. _iterator13.return();
  54241. }
  54242. } finally {
  54243. if (_didIteratorError13) {
  54244. throw _iteratorError13;
  54245. }
  54246. }
  54247. }
  54248. }
  54249. function getAllNodes(object) {
  54250. var astNode = object.astNode,
  54251. extensionASTNodes = object.extensionASTNodes;
  54252. return astNode ? extensionASTNodes ? [astNode].concat(extensionASTNodes) : [astNode] : extensionASTNodes || [];
  54253. }
  54254. function getAllSubNodes(object, getter) {
  54255. var result = [];
  54256. var _iteratorNormalCompletion14 = true;
  54257. var _didIteratorError14 = false;
  54258. var _iteratorError14 = undefined;
  54259. try {
  54260. for (var _iterator14 = getAllNodes(object)[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  54261. var astNode = _step14.value;
  54262. if (astNode) {
  54263. var subNodes = getter(astNode);
  54264. if (subNodes) {
  54265. result = result.concat(subNodes);
  54266. }
  54267. }
  54268. }
  54269. } catch (err) {
  54270. _didIteratorError14 = true;
  54271. _iteratorError14 = err;
  54272. } finally {
  54273. try {
  54274. if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
  54275. _iterator14.return();
  54276. }
  54277. } finally {
  54278. if (_didIteratorError14) {
  54279. throw _iteratorError14;
  54280. }
  54281. }
  54282. }
  54283. return result;
  54284. }
  54285. function getImplementsInterfaceNode(type, iface) {
  54286. return getAllImplementsInterfaceNodes(type, iface)[0];
  54287. }
  54288. function getAllImplementsInterfaceNodes(type, iface) {
  54289. return getAllSubNodes(type, function (typeNode) {
  54290. return typeNode.interfaces;
  54291. }).filter(function (ifaceNode) {
  54292. return ifaceNode.name.value === iface.name;
  54293. });
  54294. }
  54295. function getFieldNode(type, fieldName) {
  54296. return (0, _find.default)(getAllSubNodes(type, function (typeNode) {
  54297. return typeNode.fields;
  54298. }), function (fieldNode) {
  54299. return fieldNode.name.value === fieldName;
  54300. });
  54301. }
  54302. function getFieldTypeNode(type, fieldName) {
  54303. var fieldNode = getFieldNode(type, fieldName);
  54304. return fieldNode && fieldNode.type;
  54305. }
  54306. function getFieldArgNode(type, fieldName, argName) {
  54307. return getAllFieldArgNodes(type, fieldName, argName)[0];
  54308. }
  54309. function getAllFieldArgNodes(type, fieldName, argName) {
  54310. var argNodes = [];
  54311. var fieldNode = getFieldNode(type, fieldName);
  54312. if (fieldNode && fieldNode.arguments) {
  54313. var _iteratorNormalCompletion15 = true;
  54314. var _didIteratorError15 = false;
  54315. var _iteratorError15 = undefined;
  54316. try {
  54317. for (var _iterator15 = fieldNode.arguments[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
  54318. var node = _step15.value;
  54319. if (node.name.value === argName) {
  54320. argNodes.push(node);
  54321. }
  54322. }
  54323. } catch (err) {
  54324. _didIteratorError15 = true;
  54325. _iteratorError15 = err;
  54326. } finally {
  54327. try {
  54328. if (!_iteratorNormalCompletion15 && _iterator15.return != null) {
  54329. _iterator15.return();
  54330. }
  54331. } finally {
  54332. if (_didIteratorError15) {
  54333. throw _iteratorError15;
  54334. }
  54335. }
  54336. }
  54337. }
  54338. return argNodes;
  54339. }
  54340. function getFieldArgTypeNode(type, fieldName, argName) {
  54341. var fieldArgNode = getFieldArgNode(type, fieldName, argName);
  54342. return fieldArgNode && fieldArgNode.type;
  54343. }
  54344. function getAllDirectiveArgNodes(directive, argName) {
  54345. return getAllSubNodes(directive, function (directiveNode) {
  54346. return directiveNode.arguments;
  54347. }).filter(function (argNode) {
  54348. return argNode.name.value === argName;
  54349. });
  54350. }
  54351. function getDirectiveArgTypeNode(directive, argName) {
  54352. var argNode = getAllDirectiveArgNodes(directive, argName)[0];
  54353. return argNode && argNode.type;
  54354. }
  54355. function getUnionMemberTypeNodes(union, typeName) {
  54356. return getAllSubNodes(union, function (unionNode) {
  54357. return unionNode.types;
  54358. }).filter(function (typeNode) {
  54359. return typeNode.name.value === typeName;
  54360. });
  54361. }
  54362. },{"../error/GraphQLError":275,"../jsutils/inspect":288,"../polyfills/find":315,"../polyfills/objectEntries":318,"../polyfills/objectValues":319,"../utilities/assertValidName":331,"../utilities/typeComparators":350,"./definition":323,"./directives":324,"./introspection":326,"./schema":328}],330:[function(require,module,exports){
  54363. "use strict";
  54364. Object.defineProperty(exports, "__esModule", {
  54365. value: true
  54366. });
  54367. exports.TypeInfo = void 0;
  54368. var _find = _interopRequireDefault(require("../polyfills/find"));
  54369. var _kinds = require("../language/kinds");
  54370. var _definition = require("../type/definition");
  54371. var _introspection = require("../type/introspection");
  54372. var _typeFromAST = require("./typeFromAST");
  54373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  54374. /**
  54375. * Copyright (c) 2015-present, Facebook, Inc.
  54376. *
  54377. * This source code is licensed under the MIT license found in the
  54378. * LICENSE file in the root directory of this source tree.
  54379. *
  54380. *
  54381. */
  54382. /**
  54383. * TypeInfo is a utility class which, given a GraphQL schema, can keep track
  54384. * of the current field and type definitions at any point in a GraphQL document
  54385. * AST during a recursive descent by calling `enter(node)` and `leave(node)`.
  54386. */
  54387. var TypeInfo =
  54388. /*#__PURE__*/
  54389. function () {
  54390. function TypeInfo(schema, // NOTE: this experimental optional second parameter is only needed in order
  54391. // to support non-spec-compliant codebases. You should never need to use it.
  54392. getFieldDefFn, // Initial type may be provided in rare cases to facilitate traversals
  54393. initialType) {
  54394. this._schema = schema;
  54395. this._typeStack = [];
  54396. this._parentTypeStack = [];
  54397. this._inputTypeStack = [];
  54398. this._fieldDefStack = [];
  54399. this._defaultValueStack = [];
  54400. this._directive = null;
  54401. this._argument = null;
  54402. this._enumValue = null;
  54403. this._getFieldDef = getFieldDefFn || getFieldDef;
  54404. if (initialType) {
  54405. if ((0, _definition.isInputType)(initialType)) {
  54406. this._inputTypeStack.push(initialType);
  54407. }
  54408. if ((0, _definition.isCompositeType)(initialType)) {
  54409. this._parentTypeStack.push(initialType);
  54410. }
  54411. if ((0, _definition.isOutputType)(initialType)) {
  54412. this._typeStack.push(initialType);
  54413. }
  54414. }
  54415. }
  54416. var _proto = TypeInfo.prototype;
  54417. _proto.getType = function getType() {
  54418. if (this._typeStack.length > 0) {
  54419. return this._typeStack[this._typeStack.length - 1];
  54420. }
  54421. };
  54422. _proto.getParentType = function getParentType() {
  54423. if (this._parentTypeStack.length > 0) {
  54424. return this._parentTypeStack[this._parentTypeStack.length - 1];
  54425. }
  54426. };
  54427. _proto.getInputType = function getInputType() {
  54428. if (this._inputTypeStack.length > 0) {
  54429. return this._inputTypeStack[this._inputTypeStack.length - 1];
  54430. }
  54431. };
  54432. _proto.getParentInputType = function getParentInputType() {
  54433. if (this._inputTypeStack.length > 1) {
  54434. return this._inputTypeStack[this._inputTypeStack.length - 2];
  54435. }
  54436. };
  54437. _proto.getFieldDef = function getFieldDef() {
  54438. if (this._fieldDefStack.length > 0) {
  54439. return this._fieldDefStack[this._fieldDefStack.length - 1];
  54440. }
  54441. };
  54442. _proto.getDefaultValue = function getDefaultValue() {
  54443. if (this._defaultValueStack.length > 0) {
  54444. return this._defaultValueStack[this._defaultValueStack.length - 1];
  54445. }
  54446. };
  54447. _proto.getDirective = function getDirective() {
  54448. return this._directive;
  54449. };
  54450. _proto.getArgument = function getArgument() {
  54451. return this._argument;
  54452. };
  54453. _proto.getEnumValue = function getEnumValue() {
  54454. return this._enumValue;
  54455. };
  54456. _proto.enter = function enter(node) {
  54457. var schema = this._schema; // Note: many of the types below are explicitly typed as "mixed" to drop
  54458. // any assumptions of a valid schema to ensure runtime types are properly
  54459. // checked before continuing since TypeInfo is used as part of validation
  54460. // which occurs before guarantees of schema and document validity.
  54461. switch (node.kind) {
  54462. case _kinds.Kind.SELECTION_SET:
  54463. var namedType = (0, _definition.getNamedType)(this.getType());
  54464. this._parentTypeStack.push((0, _definition.isCompositeType)(namedType) ? namedType : undefined);
  54465. break;
  54466. case _kinds.Kind.FIELD:
  54467. var parentType = this.getParentType();
  54468. var fieldDef;
  54469. var fieldType;
  54470. if (parentType) {
  54471. fieldDef = this._getFieldDef(schema, parentType, node);
  54472. if (fieldDef) {
  54473. fieldType = fieldDef.type;
  54474. }
  54475. }
  54476. this._fieldDefStack.push(fieldDef);
  54477. this._typeStack.push((0, _definition.isOutputType)(fieldType) ? fieldType : undefined);
  54478. break;
  54479. case _kinds.Kind.DIRECTIVE:
  54480. this._directive = schema.getDirective(node.name.value);
  54481. break;
  54482. case _kinds.Kind.OPERATION_DEFINITION:
  54483. var type;
  54484. if (node.operation === 'query') {
  54485. type = schema.getQueryType();
  54486. } else if (node.operation === 'mutation') {
  54487. type = schema.getMutationType();
  54488. } else if (node.operation === 'subscription') {
  54489. type = schema.getSubscriptionType();
  54490. }
  54491. this._typeStack.push((0, _definition.isObjectType)(type) ? type : undefined);
  54492. break;
  54493. case _kinds.Kind.INLINE_FRAGMENT:
  54494. case _kinds.Kind.FRAGMENT_DEFINITION:
  54495. var typeConditionAST = node.typeCondition;
  54496. var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : (0, _definition.getNamedType)(this.getType());
  54497. this._typeStack.push((0, _definition.isOutputType)(outputType) ? outputType : undefined);
  54498. break;
  54499. case _kinds.Kind.VARIABLE_DEFINITION:
  54500. var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
  54501. this._inputTypeStack.push((0, _definition.isInputType)(inputType) ? inputType : undefined);
  54502. break;
  54503. case _kinds.Kind.ARGUMENT:
  54504. var argDef;
  54505. var argType;
  54506. var fieldOrDirective = this.getDirective() || this.getFieldDef();
  54507. if (fieldOrDirective) {
  54508. argDef = (0, _find.default)(fieldOrDirective.args, function (arg) {
  54509. return arg.name === node.name.value;
  54510. });
  54511. if (argDef) {
  54512. argType = argDef.type;
  54513. }
  54514. }
  54515. this._argument = argDef;
  54516. this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined);
  54517. this._inputTypeStack.push((0, _definition.isInputType)(argType) ? argType : undefined);
  54518. break;
  54519. case _kinds.Kind.LIST:
  54520. var listType = (0, _definition.getNullableType)(this.getInputType());
  54521. var itemType = (0, _definition.isListType)(listType) ? listType.ofType : listType; // List positions never have a default value.
  54522. this._defaultValueStack.push(undefined);
  54523. this._inputTypeStack.push((0, _definition.isInputType)(itemType) ? itemType : undefined);
  54524. break;
  54525. case _kinds.Kind.OBJECT_FIELD:
  54526. var objectType = (0, _definition.getNamedType)(this.getInputType());
  54527. var inputFieldType;
  54528. var inputField;
  54529. if ((0, _definition.isInputObjectType)(objectType)) {
  54530. inputField = objectType.getFields()[node.name.value];
  54531. if (inputField) {
  54532. inputFieldType = inputField.type;
  54533. }
  54534. }
  54535. this._defaultValueStack.push(inputField ? inputField.defaultValue : undefined);
  54536. this._inputTypeStack.push((0, _definition.isInputType)(inputFieldType) ? inputFieldType : undefined);
  54537. break;
  54538. case _kinds.Kind.ENUM:
  54539. var enumType = (0, _definition.getNamedType)(this.getInputType());
  54540. var enumValue;
  54541. if ((0, _definition.isEnumType)(enumType)) {
  54542. enumValue = enumType.getValue(node.value);
  54543. }
  54544. this._enumValue = enumValue;
  54545. break;
  54546. }
  54547. };
  54548. _proto.leave = function leave(node) {
  54549. switch (node.kind) {
  54550. case _kinds.Kind.SELECTION_SET:
  54551. this._parentTypeStack.pop();
  54552. break;
  54553. case _kinds.Kind.FIELD:
  54554. this._fieldDefStack.pop();
  54555. this._typeStack.pop();
  54556. break;
  54557. case _kinds.Kind.DIRECTIVE:
  54558. this._directive = null;
  54559. break;
  54560. case _kinds.Kind.OPERATION_DEFINITION:
  54561. case _kinds.Kind.INLINE_FRAGMENT:
  54562. case _kinds.Kind.FRAGMENT_DEFINITION:
  54563. this._typeStack.pop();
  54564. break;
  54565. case _kinds.Kind.VARIABLE_DEFINITION:
  54566. this._inputTypeStack.pop();
  54567. break;
  54568. case _kinds.Kind.ARGUMENT:
  54569. this._argument = null;
  54570. this._defaultValueStack.pop();
  54571. this._inputTypeStack.pop();
  54572. break;
  54573. case _kinds.Kind.LIST:
  54574. case _kinds.Kind.OBJECT_FIELD:
  54575. this._defaultValueStack.pop();
  54576. this._inputTypeStack.pop();
  54577. break;
  54578. case _kinds.Kind.ENUM:
  54579. this._enumValue = null;
  54580. break;
  54581. }
  54582. };
  54583. return TypeInfo;
  54584. }();
  54585. /**
  54586. * Not exactly the same as the executor's definition of getFieldDef, in this
  54587. * statically evaluated environment we do not always have an Object type,
  54588. * and need to handle Interface and Union types.
  54589. */
  54590. exports.TypeInfo = TypeInfo;
  54591. function getFieldDef(schema, parentType, fieldNode) {
  54592. var name = fieldNode.name.value;
  54593. if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  54594. return _introspection.SchemaMetaFieldDef;
  54595. }
  54596. if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  54597. return _introspection.TypeMetaFieldDef;
  54598. }
  54599. if (name === _introspection.TypeNameMetaFieldDef.name && (0, _definition.isCompositeType)(parentType)) {
  54600. return _introspection.TypeNameMetaFieldDef;
  54601. }
  54602. if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
  54603. return parentType.getFields()[name];
  54604. }
  54605. }
  54606. },{"../language/kinds":307,"../polyfills/find":315,"../type/definition":323,"../type/introspection":326,"./typeFromAST":351}],331:[function(require,module,exports){
  54607. "use strict";
  54608. Object.defineProperty(exports, "__esModule", {
  54609. value: true
  54610. });
  54611. exports.assertValidName = assertValidName;
  54612. exports.isValidNameError = isValidNameError;
  54613. var _GraphQLError = require("../error/GraphQLError");
  54614. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  54615. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  54616. /**
  54617. * Copyright (c) 2015-present, Facebook, Inc.
  54618. *
  54619. * This source code is licensed under the MIT license found in the
  54620. * LICENSE file in the root directory of this source tree.
  54621. *
  54622. *
  54623. */
  54624. var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
  54625. /**
  54626. * Upholds the spec rules about naming.
  54627. */
  54628. function assertValidName(name) {
  54629. var error = isValidNameError(name);
  54630. if (error) {
  54631. throw error;
  54632. }
  54633. return name;
  54634. }
  54635. /**
  54636. * Returns an Error if a name is invalid.
  54637. */
  54638. function isValidNameError(name, node) {
  54639. !(typeof name === 'string') ? (0, _invariant.default)(0, 'Expected string') : void 0;
  54640. if (name.length > 1 && name[0] === '_' && name[1] === '_') {
  54641. return new _GraphQLError.GraphQLError("Name \"".concat(name, "\" must not begin with \"__\", which is reserved by ") + 'GraphQL introspection.', node);
  54642. }
  54643. if (!NAME_RX.test(name)) {
  54644. return new _GraphQLError.GraphQLError("Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"".concat(name, "\" does not."), node);
  54645. }
  54646. }
  54647. },{"../error/GraphQLError":275,"../jsutils/invariant":290}],332:[function(require,module,exports){
  54648. "use strict";
  54649. Object.defineProperty(exports, "__esModule", {
  54650. value: true
  54651. });
  54652. exports.astFromValue = astFromValue;
  54653. var _iterall = require("iterall");
  54654. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  54655. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  54656. var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
  54657. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  54658. var _kinds = require("../language/kinds");
  54659. var _definition = require("../type/definition");
  54660. var _scalars = require("../type/scalars");
  54661. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  54662. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  54663. /**
  54664. * Produces a GraphQL Value AST given a JavaScript value.
  54665. *
  54666. * A GraphQL type must be provided, which will be used to interpret different
  54667. * JavaScript values.
  54668. *
  54669. * | JSON Value | GraphQL Value |
  54670. * | ------------- | -------------------- |
  54671. * | Object | Input Object |
  54672. * | Array | List |
  54673. * | Boolean | Boolean |
  54674. * | String | String / Enum Value |
  54675. * | Number | Int / Float |
  54676. * | Mixed | Enum Value |
  54677. * | null | NullValue |
  54678. *
  54679. */
  54680. function astFromValue(value, type) {
  54681. if ((0, _definition.isNonNullType)(type)) {
  54682. var astValue = astFromValue(value, type.ofType);
  54683. if (astValue && astValue.kind === _kinds.Kind.NULL) {
  54684. return null;
  54685. }
  54686. return astValue;
  54687. } // only explicit null, not undefined, NaN
  54688. if (value === null) {
  54689. return {
  54690. kind: _kinds.Kind.NULL
  54691. };
  54692. } // undefined, NaN
  54693. if ((0, _isInvalid.default)(value)) {
  54694. return null;
  54695. } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
  54696. // the value is not an array, convert the value using the list's item type.
  54697. if ((0, _definition.isListType)(type)) {
  54698. var itemType = type.ofType;
  54699. if ((0, _iterall.isCollection)(value)) {
  54700. var valuesNodes = [];
  54701. (0, _iterall.forEach)(value, function (item) {
  54702. var itemNode = astFromValue(item, itemType);
  54703. if (itemNode) {
  54704. valuesNodes.push(itemNode);
  54705. }
  54706. });
  54707. return {
  54708. kind: _kinds.Kind.LIST,
  54709. values: valuesNodes
  54710. };
  54711. }
  54712. return astFromValue(value, itemType);
  54713. } // Populate the fields of the input object by creating ASTs from each value
  54714. // in the JavaScript object according to the fields in the input type.
  54715. if ((0, _definition.isInputObjectType)(type)) {
  54716. if (value === null || _typeof(value) !== 'object') {
  54717. return null;
  54718. }
  54719. var fields = (0, _objectValues.default)(type.getFields());
  54720. var fieldNodes = [];
  54721. var _iteratorNormalCompletion = true;
  54722. var _didIteratorError = false;
  54723. var _iteratorError = undefined;
  54724. try {
  54725. for (var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  54726. var field = _step.value;
  54727. var fieldValue = astFromValue(value[field.name], field.type);
  54728. if (fieldValue) {
  54729. fieldNodes.push({
  54730. kind: _kinds.Kind.OBJECT_FIELD,
  54731. name: {
  54732. kind: _kinds.Kind.NAME,
  54733. value: field.name
  54734. },
  54735. value: fieldValue
  54736. });
  54737. }
  54738. }
  54739. } catch (err) {
  54740. _didIteratorError = true;
  54741. _iteratorError = err;
  54742. } finally {
  54743. try {
  54744. if (!_iteratorNormalCompletion && _iterator.return != null) {
  54745. _iterator.return();
  54746. }
  54747. } finally {
  54748. if (_didIteratorError) {
  54749. throw _iteratorError;
  54750. }
  54751. }
  54752. }
  54753. return {
  54754. kind: _kinds.Kind.OBJECT,
  54755. fields: fieldNodes
  54756. };
  54757. }
  54758. if ((0, _definition.isScalarType)(type) || (0, _definition.isEnumType)(type)) {
  54759. // Since value is an internally represented value, it must be serialized
  54760. // to an externally represented value before converting into an AST.
  54761. var serialized = type.serialize(value);
  54762. if ((0, _isNullish.default)(serialized)) {
  54763. return null;
  54764. } // Others serialize based on their corresponding JavaScript scalar types.
  54765. if (typeof serialized === 'boolean') {
  54766. return {
  54767. kind: _kinds.Kind.BOOLEAN,
  54768. value: serialized
  54769. };
  54770. } // JavaScript numbers can be Int or Float values.
  54771. if (typeof serialized === 'number') {
  54772. var stringNum = String(serialized);
  54773. return integerStringRegExp.test(stringNum) ? {
  54774. kind: _kinds.Kind.INT,
  54775. value: stringNum
  54776. } : {
  54777. kind: _kinds.Kind.FLOAT,
  54778. value: stringNum
  54779. };
  54780. }
  54781. if (typeof serialized === 'string') {
  54782. // Enum types use Enum literals.
  54783. if ((0, _definition.isEnumType)(type)) {
  54784. return {
  54785. kind: _kinds.Kind.ENUM,
  54786. value: serialized
  54787. };
  54788. } // ID types can use Int literals.
  54789. if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) {
  54790. return {
  54791. kind: _kinds.Kind.INT,
  54792. value: serialized
  54793. };
  54794. }
  54795. return {
  54796. kind: _kinds.Kind.STRING,
  54797. value: serialized
  54798. };
  54799. }
  54800. throw new TypeError("Cannot convert value to AST: ".concat((0, _inspect.default)(serialized)));
  54801. }
  54802. /* istanbul ignore next */
  54803. throw new Error("Unknown type: ".concat(type, "."));
  54804. }
  54805. /**
  54806. * IntValue:
  54807. * - NegativeSign? 0
  54808. * - NegativeSign? NonZeroDigit ( Digit+ )?
  54809. */
  54810. var integerStringRegExp = /^-?(0|[1-9][0-9]*)$/;
  54811. },{"../jsutils/inspect":288,"../jsutils/isInvalid":291,"../jsutils/isNullish":292,"../language/kinds":307,"../polyfills/objectValues":319,"../type/definition":323,"../type/scalars":327,"iterall":137}],333:[function(require,module,exports){
  54812. "use strict";
  54813. Object.defineProperty(exports, "__esModule", {
  54814. value: true
  54815. });
  54816. exports.buildASTSchema = buildASTSchema;
  54817. exports.getDescription = getDescription;
  54818. exports.buildSchema = buildSchema;
  54819. exports.ASTDefinitionBuilder = void 0;
  54820. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  54821. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  54822. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  54823. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  54824. var _valueFromAST = require("./valueFromAST");
  54825. var _validate = require("../validation/validate");
  54826. var _blockStringValue = _interopRequireDefault(require("../language/blockStringValue"));
  54827. var _lexer = require("../language/lexer");
  54828. var _parser = require("../language/parser");
  54829. var _values = require("../execution/values");
  54830. var _kinds = require("../language/kinds");
  54831. var _predicates = require("../language/predicates");
  54832. var _definition = require("../type/definition");
  54833. var _directives = require("../type/directives");
  54834. var _introspection = require("../type/introspection");
  54835. var _scalars = require("../type/scalars");
  54836. var _schema = require("../type/schema");
  54837. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  54838. /**
  54839. * Copyright (c) 2015-present, Facebook, Inc.
  54840. *
  54841. * This source code is licensed under the MIT license found in the
  54842. * LICENSE file in the root directory of this source tree.
  54843. *
  54844. *
  54845. */
  54846. /**
  54847. * This takes the ast of a schema document produced by the parse function in
  54848. * src/language/parser.js.
  54849. *
  54850. * If no schema definition is provided, then it will look for types named Query
  54851. * and Mutation.
  54852. *
  54853. * Given that AST it constructs a GraphQLSchema. The resulting schema
  54854. * has no resolve methods, so execution will use default resolvers.
  54855. *
  54856. * Accepts options as a second argument:
  54857. *
  54858. * - commentDescriptions:
  54859. * Provide true to use preceding comments as the description.
  54860. *
  54861. */
  54862. function buildASTSchema(documentAST, options) {
  54863. !(documentAST && documentAST.kind === _kinds.Kind.DOCUMENT) ? (0, _invariant.default)(0, 'Must provide valid Document AST') : void 0;
  54864. if (!options || !(options.assumeValid || options.assumeValidSDL)) {
  54865. (0, _validate.assertValidSDL)(documentAST);
  54866. }
  54867. var schemaDef;
  54868. var nodeMap = Object.create(null);
  54869. var directiveDefs = [];
  54870. var _iteratorNormalCompletion = true;
  54871. var _didIteratorError = false;
  54872. var _iteratorError = undefined;
  54873. try {
  54874. for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  54875. var def = _step.value;
  54876. if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
  54877. schemaDef = def;
  54878. } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
  54879. nodeMap[def.name.value] = def;
  54880. } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  54881. directiveDefs.push(def);
  54882. }
  54883. }
  54884. } catch (err) {
  54885. _didIteratorError = true;
  54886. _iteratorError = err;
  54887. } finally {
  54888. try {
  54889. if (!_iteratorNormalCompletion && _iterator.return != null) {
  54890. _iterator.return();
  54891. }
  54892. } finally {
  54893. if (_didIteratorError) {
  54894. throw _iteratorError;
  54895. }
  54896. }
  54897. }
  54898. var operationTypes = schemaDef ? getOperationTypes(schemaDef) : {
  54899. query: nodeMap.Query,
  54900. mutation: nodeMap.Mutation,
  54901. subscription: nodeMap.Subscription
  54902. };
  54903. var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (typeName) {
  54904. throw new Error("Type \"".concat(typeName, "\" not found in document."));
  54905. });
  54906. var directives = directiveDefs.map(function (def) {
  54907. return definitionBuilder.buildDirective(def);
  54908. }); // If specified directives were not explicitly declared, add them.
  54909. if (!directives.some(function (directive) {
  54910. return directive.name === 'skip';
  54911. })) {
  54912. directives.push(_directives.GraphQLSkipDirective);
  54913. }
  54914. if (!directives.some(function (directive) {
  54915. return directive.name === 'include';
  54916. })) {
  54917. directives.push(_directives.GraphQLIncludeDirective);
  54918. }
  54919. if (!directives.some(function (directive) {
  54920. return directive.name === 'deprecated';
  54921. })) {
  54922. directives.push(_directives.GraphQLDeprecatedDirective);
  54923. } // Note: While this could make early assertions to get the correctly
  54924. // typed values below, that would throw immediately while type system
  54925. // validation with validateSchema() will produce more actionable results.
  54926. return new _schema.GraphQLSchema({
  54927. query: operationTypes.query ? definitionBuilder.buildType(operationTypes.query) : null,
  54928. mutation: operationTypes.mutation ? definitionBuilder.buildType(operationTypes.mutation) : null,
  54929. subscription: operationTypes.subscription ? definitionBuilder.buildType(operationTypes.subscription) : null,
  54930. types: (0, _objectValues.default)(nodeMap).map(function (node) {
  54931. return definitionBuilder.buildType(node);
  54932. }),
  54933. directives: directives,
  54934. astNode: schemaDef,
  54935. assumeValid: options && options.assumeValid,
  54936. allowedLegacyNames: options && options.allowedLegacyNames
  54937. });
  54938. function getOperationTypes(schema) {
  54939. var opTypes = {};
  54940. var _iteratorNormalCompletion2 = true;
  54941. var _didIteratorError2 = false;
  54942. var _iteratorError2 = undefined;
  54943. try {
  54944. for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  54945. var operationType = _step2.value;
  54946. opTypes[operationType.operation] = operationType.type;
  54947. }
  54948. } catch (err) {
  54949. _didIteratorError2 = true;
  54950. _iteratorError2 = err;
  54951. } finally {
  54952. try {
  54953. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  54954. _iterator2.return();
  54955. }
  54956. } finally {
  54957. if (_didIteratorError2) {
  54958. throw _iteratorError2;
  54959. }
  54960. }
  54961. }
  54962. return opTypes;
  54963. }
  54964. }
  54965. var ASTDefinitionBuilder =
  54966. /*#__PURE__*/
  54967. function () {
  54968. function ASTDefinitionBuilder(typeDefinitionsMap, options, resolveType) {
  54969. this._typeDefinitionsMap = typeDefinitionsMap;
  54970. this._options = options;
  54971. this._resolveType = resolveType; // Initialize to the GraphQL built in scalars and introspection types.
  54972. this._cache = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
  54973. return type.name;
  54974. });
  54975. }
  54976. var _proto = ASTDefinitionBuilder.prototype;
  54977. _proto.buildType = function buildType(node) {
  54978. var typeName = node.name.value;
  54979. if (!this._cache[typeName]) {
  54980. if (node.kind === _kinds.Kind.NAMED_TYPE) {
  54981. var defNode = this._typeDefinitionsMap[typeName];
  54982. this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node.name.value);
  54983. } else {
  54984. this._cache[typeName] = this._makeSchemaDef(node);
  54985. }
  54986. }
  54987. return this._cache[typeName];
  54988. };
  54989. _proto._buildWrappedType = function _buildWrappedType(typeNode) {
  54990. if (typeNode.kind === _kinds.Kind.LIST_TYPE) {
  54991. return (0, _definition.GraphQLList)(this._buildWrappedType(typeNode.type));
  54992. }
  54993. if (typeNode.kind === _kinds.Kind.NON_NULL_TYPE) {
  54994. return (0, _definition.GraphQLNonNull)( // Note: GraphQLNonNull constructor validates this type
  54995. this._buildWrappedType(typeNode.type));
  54996. }
  54997. return this.buildType(typeNode);
  54998. };
  54999. _proto.buildDirective = function buildDirective(directive) {
  55000. var _this = this;
  55001. var locations = directive.locations.map(function (_ref) {
  55002. var value = _ref.value;
  55003. return value;
  55004. });
  55005. return new _directives.GraphQLDirective({
  55006. name: directive.name.value,
  55007. description: getDescription(directive, this._options),
  55008. locations: locations,
  55009. args: keyByNameNode(directive.arguments || [], function (arg) {
  55010. return _this.buildArg(arg);
  55011. }),
  55012. astNode: directive
  55013. });
  55014. };
  55015. _proto.buildField = function buildField(field) {
  55016. var _this2 = this;
  55017. return {
  55018. // Note: While this could make assertions to get the correctly typed
  55019. // value, that would throw immediately while type system validation
  55020. // with validateSchema() will produce more actionable results.
  55021. type: this._buildWrappedType(field.type),
  55022. description: getDescription(field, this._options),
  55023. args: keyByNameNode(field.arguments || [], function (arg) {
  55024. return _this2.buildArg(arg);
  55025. }),
  55026. deprecationReason: getDeprecationReason(field),
  55027. astNode: field
  55028. };
  55029. };
  55030. _proto.buildArg = function buildArg(value) {
  55031. // Note: While this could make assertions to get the correctly typed
  55032. // value, that would throw immediately while type system validation
  55033. var type = this._buildWrappedType(value.type);
  55034. return {
  55035. type: type,
  55036. description: getDescription(value, this._options),
  55037. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
  55038. astNode: value
  55039. };
  55040. };
  55041. _proto.buildInputField = function buildInputField(value) {
  55042. // Note: While this could make assertions to get the correctly typed
  55043. // value, that would throw immediately while type system validation
  55044. var type = this._buildWrappedType(value.type);
  55045. return {
  55046. type: type,
  55047. description: getDescription(value, this._options),
  55048. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
  55049. astNode: value
  55050. };
  55051. };
  55052. _proto.buildEnumValue = function buildEnumValue(value) {
  55053. return {
  55054. description: getDescription(value, this._options),
  55055. deprecationReason: getDeprecationReason(value),
  55056. astNode: value
  55057. };
  55058. };
  55059. _proto._makeSchemaDef = function _makeSchemaDef(astNode) {
  55060. switch (astNode.kind) {
  55061. case _kinds.Kind.OBJECT_TYPE_DEFINITION:
  55062. return this._makeTypeDef(astNode);
  55063. case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
  55064. return this._makeInterfaceDef(astNode);
  55065. case _kinds.Kind.ENUM_TYPE_DEFINITION:
  55066. return this._makeEnumDef(astNode);
  55067. case _kinds.Kind.UNION_TYPE_DEFINITION:
  55068. return this._makeUnionDef(astNode);
  55069. case _kinds.Kind.SCALAR_TYPE_DEFINITION:
  55070. return this._makeScalarDef(astNode);
  55071. case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
  55072. return this._makeInputObjectDef(astNode);
  55073. default:
  55074. throw new Error("Type kind \"".concat(astNode.kind, "\" not supported."));
  55075. }
  55076. };
  55077. _proto._makeTypeDef = function _makeTypeDef(astNode) {
  55078. var _this3 = this;
  55079. var interfaceNodes = astNode.interfaces;
  55080. var fieldNodes = astNode.fields; // Note: While this could make assertions to get the correctly typed
  55081. // values below, that would throw immediately while type system
  55082. // validation with validateSchema() will produce more actionable results.
  55083. var interfaces = interfaceNodes && interfaceNodes.length > 0 ? function () {
  55084. return interfaceNodes.map(function (ref) {
  55085. return _this3.buildType(ref);
  55086. });
  55087. } : [];
  55088. var fields = fieldNodes && fieldNodes.length > 0 ? function () {
  55089. return keyByNameNode(fieldNodes, function (field) {
  55090. return _this3.buildField(field);
  55091. });
  55092. } : Object.create(null);
  55093. return new _definition.GraphQLObjectType({
  55094. name: astNode.name.value,
  55095. description: getDescription(astNode, this._options),
  55096. interfaces: interfaces,
  55097. fields: fields,
  55098. astNode: astNode
  55099. });
  55100. };
  55101. _proto._makeInterfaceDef = function _makeInterfaceDef(astNode) {
  55102. var _this4 = this;
  55103. var fieldNodes = astNode.fields;
  55104. var fields = fieldNodes && fieldNodes.length > 0 ? function () {
  55105. return keyByNameNode(fieldNodes, function (field) {
  55106. return _this4.buildField(field);
  55107. });
  55108. } : Object.create(null);
  55109. return new _definition.GraphQLInterfaceType({
  55110. name: astNode.name.value,
  55111. description: getDescription(astNode, this._options),
  55112. fields: fields,
  55113. astNode: astNode
  55114. });
  55115. };
  55116. _proto._makeEnumDef = function _makeEnumDef(astNode) {
  55117. var _this5 = this;
  55118. var valueNodes = astNode.values || [];
  55119. return new _definition.GraphQLEnumType({
  55120. name: astNode.name.value,
  55121. description: getDescription(astNode, this._options),
  55122. values: keyByNameNode(valueNodes, function (value) {
  55123. return _this5.buildEnumValue(value);
  55124. }),
  55125. astNode: astNode
  55126. });
  55127. };
  55128. _proto._makeUnionDef = function _makeUnionDef(astNode) {
  55129. var _this6 = this;
  55130. var typeNodes = astNode.types; // Note: While this could make assertions to get the correctly typed
  55131. // values below, that would throw immediately while type system
  55132. // validation with validateSchema() will produce more actionable results.
  55133. var types = typeNodes && typeNodes.length > 0 ? function () {
  55134. return typeNodes.map(function (ref) {
  55135. return _this6.buildType(ref);
  55136. });
  55137. } : [];
  55138. return new _definition.GraphQLUnionType({
  55139. name: astNode.name.value,
  55140. description: getDescription(astNode, this._options),
  55141. types: types,
  55142. astNode: astNode
  55143. });
  55144. };
  55145. _proto._makeScalarDef = function _makeScalarDef(astNode) {
  55146. return new _definition.GraphQLScalarType({
  55147. name: astNode.name.value,
  55148. description: getDescription(astNode, this._options),
  55149. astNode: astNode,
  55150. serialize: function serialize(value) {
  55151. return value;
  55152. }
  55153. });
  55154. };
  55155. _proto._makeInputObjectDef = function _makeInputObjectDef(def) {
  55156. var _this7 = this;
  55157. var fields = def.fields;
  55158. return new _definition.GraphQLInputObjectType({
  55159. name: def.name.value,
  55160. description: getDescription(def, this._options),
  55161. fields: fields ? function () {
  55162. return keyByNameNode(fields, function (field) {
  55163. return _this7.buildInputField(field);
  55164. });
  55165. } : Object.create(null),
  55166. astNode: def
  55167. });
  55168. };
  55169. return ASTDefinitionBuilder;
  55170. }();
  55171. exports.ASTDefinitionBuilder = ASTDefinitionBuilder;
  55172. function keyByNameNode(list, valFn) {
  55173. return (0, _keyValMap.default)(list, function (_ref2) {
  55174. var name = _ref2.name;
  55175. return name.value;
  55176. }, valFn);
  55177. }
  55178. /**
  55179. * Given a field or enum value node, returns the string value for the
  55180. * deprecation reason.
  55181. */
  55182. function getDeprecationReason(node) {
  55183. var deprecated = (0, _values.getDirectiveValues)(_directives.GraphQLDeprecatedDirective, node);
  55184. return deprecated && deprecated.reason;
  55185. }
  55186. /**
  55187. * Given an ast node, returns its string description.
  55188. * @deprecated: provided to ease adoption and will be removed in v16.
  55189. *
  55190. * Accepts options as a second argument:
  55191. *
  55192. * - commentDescriptions:
  55193. * Provide true to use preceding comments as the description.
  55194. *
  55195. */
  55196. function getDescription(node, options) {
  55197. if (node.description) {
  55198. return node.description.value;
  55199. }
  55200. if (options && options.commentDescriptions) {
  55201. var rawValue = getLeadingCommentBlock(node);
  55202. if (rawValue !== undefined) {
  55203. return (0, _blockStringValue.default)('\n' + rawValue);
  55204. }
  55205. }
  55206. }
  55207. function getLeadingCommentBlock(node) {
  55208. var loc = node.loc;
  55209. if (!loc) {
  55210. return;
  55211. }
  55212. var comments = [];
  55213. var token = loc.startToken.prev;
  55214. while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) {
  55215. var value = String(token.value);
  55216. comments.push(value);
  55217. token = token.prev;
  55218. }
  55219. return comments.reverse().join('\n');
  55220. }
  55221. /**
  55222. * A helper function to build a GraphQLSchema directly from a source
  55223. * document.
  55224. */
  55225. function buildSchema(source, options) {
  55226. return buildASTSchema((0, _parser.parse)(source, options), options);
  55227. }
  55228. },{"../execution/values":283,"../jsutils/invariant":290,"../jsutils/keyMap":294,"../jsutils/keyValMap":295,"../language/blockStringValue":304,"../language/kinds":307,"../language/lexer":308,"../language/parser":310,"../language/predicates":311,"../polyfills/objectValues":319,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/scalars":327,"../type/schema":328,"../validation/validate":390,"./valueFromAST":352}],334:[function(require,module,exports){
  55229. "use strict";
  55230. Object.defineProperty(exports, "__esModule", {
  55231. value: true
  55232. });
  55233. exports.buildClientSchema = buildClientSchema;
  55234. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  55235. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  55236. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  55237. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  55238. var _valueFromAST = require("./valueFromAST");
  55239. var _parser = require("../language/parser");
  55240. var _schema = require("../type/schema");
  55241. var _definition = require("../type/definition");
  55242. var _directives = require("../type/directives");
  55243. var _introspection = require("../type/introspection");
  55244. var _scalars = require("../type/scalars");
  55245. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  55246. /**
  55247. * Copyright (c) 2015-present, Facebook, Inc.
  55248. *
  55249. * This source code is licensed under the MIT license found in the
  55250. * LICENSE file in the root directory of this source tree.
  55251. *
  55252. *
  55253. */
  55254. /**
  55255. * Build a GraphQLSchema for use by client tools.
  55256. *
  55257. * Given the result of a client running the introspection query, creates and
  55258. * returns a GraphQLSchema instance which can be then used with all graphql-js
  55259. * tools, but cannot be used to execute a query, as introspection does not
  55260. * represent the "resolver", "parse" or "serialize" functions or any other
  55261. * server-internal mechanisms.
  55262. *
  55263. * This function expects a complete introspection result. Don't forget to check
  55264. * the "errors" field of a server response before calling this function.
  55265. */
  55266. function buildClientSchema(introspection, options) {
  55267. // Get the schema from the introspection result.
  55268. var schemaIntrospection = introspection.__schema; // Converts the list of types into a keyMap based on the type names.
  55269. var typeIntrospectionMap = (0, _keyMap.default)(schemaIntrospection.types, function (type) {
  55270. return type.name;
  55271. }); // A cache to use to store the actual GraphQLType definition objects by name.
  55272. // Initialize to the GraphQL built in scalars. All functions below are inline
  55273. // so that this type def cache is within the scope of the closure.
  55274. var typeDefCache = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
  55275. return type.name;
  55276. }); // Given a type reference in introspection, return the GraphQLType instance.
  55277. // preferring cached instances before building new instances.
  55278. function getType(typeRef) {
  55279. if (typeRef.kind === _introspection.TypeKind.LIST) {
  55280. var itemRef = typeRef.ofType;
  55281. if (!itemRef) {
  55282. throw new Error('Decorated type deeper than introspection query.');
  55283. }
  55284. return (0, _definition.GraphQLList)(getType(itemRef));
  55285. }
  55286. if (typeRef.kind === _introspection.TypeKind.NON_NULL) {
  55287. var nullableRef = typeRef.ofType;
  55288. if (!nullableRef) {
  55289. throw new Error('Decorated type deeper than introspection query.');
  55290. }
  55291. var nullableType = getType(nullableRef);
  55292. return (0, _definition.GraphQLNonNull)((0, _definition.assertNullableType)(nullableType));
  55293. }
  55294. if (!typeRef.name) {
  55295. throw new Error('Unknown type reference: ' + (0, _inspect.default)(typeRef));
  55296. }
  55297. return getNamedType(typeRef.name);
  55298. }
  55299. function getNamedType(typeName) {
  55300. if (typeDefCache[typeName]) {
  55301. return typeDefCache[typeName];
  55302. }
  55303. var typeIntrospection = typeIntrospectionMap[typeName];
  55304. if (!typeIntrospection) {
  55305. throw new Error("Invalid or incomplete schema, unknown type: ".concat(typeName, ". Ensure ") + 'that a full introspection query is used in order to build a ' + 'client schema.');
  55306. }
  55307. var typeDef = buildType(typeIntrospection);
  55308. typeDefCache[typeName] = typeDef;
  55309. return typeDef;
  55310. }
  55311. function getInputType(typeRef) {
  55312. var type = getType(typeRef);
  55313. !(0, _definition.isInputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide input type for arguments, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
  55314. return type;
  55315. }
  55316. function getOutputType(typeRef) {
  55317. var type = getType(typeRef);
  55318. !(0, _definition.isOutputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide output type for fields, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
  55319. return type;
  55320. }
  55321. function getObjectType(typeRef) {
  55322. var type = getType(typeRef);
  55323. return (0, _definition.assertObjectType)(type);
  55324. }
  55325. function getInterfaceType(typeRef) {
  55326. var type = getType(typeRef);
  55327. return (0, _definition.assertInterfaceType)(type);
  55328. } // Given a type's introspection result, construct the correct
  55329. // GraphQLType instance.
  55330. function buildType(type) {
  55331. if (type && type.name && type.kind) {
  55332. switch (type.kind) {
  55333. case _introspection.TypeKind.SCALAR:
  55334. return buildScalarDef(type);
  55335. case _introspection.TypeKind.OBJECT:
  55336. return buildObjectDef(type);
  55337. case _introspection.TypeKind.INTERFACE:
  55338. return buildInterfaceDef(type);
  55339. case _introspection.TypeKind.UNION:
  55340. return buildUnionDef(type);
  55341. case _introspection.TypeKind.ENUM:
  55342. return buildEnumDef(type);
  55343. case _introspection.TypeKind.INPUT_OBJECT:
  55344. return buildInputObjectDef(type);
  55345. }
  55346. }
  55347. throw new Error('Invalid or incomplete introspection result. Ensure that a full ' + 'introspection query is used in order to build a client schema:' + (0, _inspect.default)(type));
  55348. }
  55349. function buildScalarDef(scalarIntrospection) {
  55350. return new _definition.GraphQLScalarType({
  55351. name: scalarIntrospection.name,
  55352. description: scalarIntrospection.description,
  55353. serialize: function serialize(value) {
  55354. return value;
  55355. }
  55356. });
  55357. }
  55358. function buildObjectDef(objectIntrospection) {
  55359. if (!objectIntrospection.interfaces) {
  55360. throw new Error('Introspection result missing interfaces: ' + (0, _inspect.default)(objectIntrospection));
  55361. }
  55362. return new _definition.GraphQLObjectType({
  55363. name: objectIntrospection.name,
  55364. description: objectIntrospection.description,
  55365. interfaces: function interfaces() {
  55366. return objectIntrospection.interfaces.map(getInterfaceType);
  55367. },
  55368. fields: function fields() {
  55369. return buildFieldDefMap(objectIntrospection);
  55370. }
  55371. });
  55372. }
  55373. function buildInterfaceDef(interfaceIntrospection) {
  55374. return new _definition.GraphQLInterfaceType({
  55375. name: interfaceIntrospection.name,
  55376. description: interfaceIntrospection.description,
  55377. fields: function fields() {
  55378. return buildFieldDefMap(interfaceIntrospection);
  55379. }
  55380. });
  55381. }
  55382. function buildUnionDef(unionIntrospection) {
  55383. if (!unionIntrospection.possibleTypes) {
  55384. throw new Error('Introspection result missing possibleTypes: ' + (0, _inspect.default)(unionIntrospection));
  55385. }
  55386. return new _definition.GraphQLUnionType({
  55387. name: unionIntrospection.name,
  55388. description: unionIntrospection.description,
  55389. types: function types() {
  55390. return unionIntrospection.possibleTypes.map(getObjectType);
  55391. }
  55392. });
  55393. }
  55394. function buildEnumDef(enumIntrospection) {
  55395. if (!enumIntrospection.enumValues) {
  55396. throw new Error('Introspection result missing enumValues: ' + (0, _inspect.default)(enumIntrospection));
  55397. }
  55398. return new _definition.GraphQLEnumType({
  55399. name: enumIntrospection.name,
  55400. description: enumIntrospection.description,
  55401. values: (0, _keyValMap.default)(enumIntrospection.enumValues, function (valueIntrospection) {
  55402. return valueIntrospection.name;
  55403. }, function (valueIntrospection) {
  55404. return {
  55405. description: valueIntrospection.description,
  55406. deprecationReason: valueIntrospection.deprecationReason
  55407. };
  55408. })
  55409. });
  55410. }
  55411. function buildInputObjectDef(inputObjectIntrospection) {
  55412. if (!inputObjectIntrospection.inputFields) {
  55413. throw new Error('Introspection result missing inputFields: ' + (0, _inspect.default)(inputObjectIntrospection));
  55414. }
  55415. return new _definition.GraphQLInputObjectType({
  55416. name: inputObjectIntrospection.name,
  55417. description: inputObjectIntrospection.description,
  55418. fields: function fields() {
  55419. return buildInputValueDefMap(inputObjectIntrospection.inputFields);
  55420. }
  55421. });
  55422. }
  55423. function buildFieldDefMap(typeIntrospection) {
  55424. if (!typeIntrospection.fields) {
  55425. throw new Error('Introspection result missing fields: ' + (0, _inspect.default)(typeIntrospection));
  55426. }
  55427. return (0, _keyValMap.default)(typeIntrospection.fields, function (fieldIntrospection) {
  55428. return fieldIntrospection.name;
  55429. }, function (fieldIntrospection) {
  55430. if (!fieldIntrospection.args) {
  55431. throw new Error('Introspection result missing field args: ' + (0, _inspect.default)(fieldIntrospection));
  55432. }
  55433. return {
  55434. description: fieldIntrospection.description,
  55435. deprecationReason: fieldIntrospection.deprecationReason,
  55436. type: getOutputType(fieldIntrospection.type),
  55437. args: buildInputValueDefMap(fieldIntrospection.args)
  55438. };
  55439. });
  55440. }
  55441. function buildInputValueDefMap(inputValueIntrospections) {
  55442. return (0, _keyValMap.default)(inputValueIntrospections, function (inputValue) {
  55443. return inputValue.name;
  55444. }, buildInputValue);
  55445. }
  55446. function buildInputValue(inputValueIntrospection) {
  55447. var type = getInputType(inputValueIntrospection.type);
  55448. var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined;
  55449. return {
  55450. description: inputValueIntrospection.description,
  55451. type: type,
  55452. defaultValue: defaultValue
  55453. };
  55454. }
  55455. function buildDirective(directiveIntrospection) {
  55456. if (!directiveIntrospection.args) {
  55457. throw new Error('Introspection result missing directive args: ' + (0, _inspect.default)(directiveIntrospection));
  55458. }
  55459. if (!directiveIntrospection.locations) {
  55460. throw new Error('Introspection result missing directive locations: ' + (0, _inspect.default)(directiveIntrospection));
  55461. }
  55462. return new _directives.GraphQLDirective({
  55463. name: directiveIntrospection.name,
  55464. description: directiveIntrospection.description,
  55465. locations: directiveIntrospection.locations.slice(),
  55466. args: buildInputValueDefMap(directiveIntrospection.args)
  55467. });
  55468. } // Iterate through all types, getting the type definition for each, ensuring
  55469. // that any type not directly referenced by a field will get created.
  55470. var types = schemaIntrospection.types.map(function (typeIntrospection) {
  55471. return getNamedType(typeIntrospection.name);
  55472. }); // Get the root Query, Mutation, and Subscription types.
  55473. var queryType = schemaIntrospection.queryType ? getObjectType(schemaIntrospection.queryType) : null;
  55474. var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;
  55475. var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null; // Get the directives supported by Introspection, assuming empty-set if
  55476. // directives were not queried for.
  55477. var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : []; // Then produce and return a Schema with these types.
  55478. return new _schema.GraphQLSchema({
  55479. query: queryType,
  55480. mutation: mutationType,
  55481. subscription: subscriptionType,
  55482. types: types,
  55483. directives: directives,
  55484. assumeValid: options && options.assumeValid,
  55485. allowedLegacyNames: options && options.allowedLegacyNames
  55486. });
  55487. }
  55488. },{"../jsutils/inspect":288,"../jsutils/invariant":290,"../jsutils/keyMap":294,"../jsutils/keyValMap":295,"../language/parser":310,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/scalars":327,"../type/schema":328,"./valueFromAST":352}],335:[function(require,module,exports){
  55489. "use strict";
  55490. Object.defineProperty(exports, "__esModule", {
  55491. value: true
  55492. });
  55493. exports.coerceValue = coerceValue;
  55494. var _iterall = require("iterall");
  55495. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  55496. var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
  55497. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  55498. var _orList = _interopRequireDefault(require("../jsutils/orList"));
  55499. var _suggestionList = _interopRequireDefault(require("../jsutils/suggestionList"));
  55500. var _GraphQLError = require("../error/GraphQLError");
  55501. var _definition = require("../type/definition");
  55502. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  55503. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  55504. /**
  55505. * Coerces a JavaScript value given a GraphQL Type.
  55506. *
  55507. * Returns either a value which is valid for the provided type or a list of
  55508. * encountered coercion errors.
  55509. *
  55510. */
  55511. function coerceValue(value, type, blameNode, path) {
  55512. // A value must be provided if the type is non-null.
  55513. if ((0, _definition.isNonNullType)(type)) {
  55514. if (value == null) {
  55515. return ofErrors([coercionError("Expected non-nullable type ".concat((0, _inspect.default)(type), " not to be null"), blameNode, path)]);
  55516. }
  55517. return coerceValue(value, type.ofType, blameNode, path);
  55518. }
  55519. if (value == null) {
  55520. // Explicitly return the value null.
  55521. return ofValue(null);
  55522. }
  55523. if ((0, _definition.isScalarType)(type)) {
  55524. // Scalars determine if a value is valid via parseValue(), which can
  55525. // throw to indicate failure. If it throws, maintain a reference to
  55526. // the original error.
  55527. try {
  55528. var parseResult = type.parseValue(value);
  55529. if ((0, _isInvalid.default)(parseResult)) {
  55530. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path)]);
  55531. }
  55532. return ofValue(parseResult);
  55533. } catch (error) {
  55534. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path, error.message, error)]);
  55535. }
  55536. }
  55537. if ((0, _definition.isEnumType)(type)) {
  55538. if (typeof value === 'string') {
  55539. var enumValue = type.getValue(value);
  55540. if (enumValue) {
  55541. return ofValue(enumValue.value);
  55542. }
  55543. }
  55544. var suggestions = (0, _suggestionList.default)(String(value), type.getValues().map(function (enumValue) {
  55545. return enumValue.name;
  55546. }));
  55547. var didYouMean = suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(suggestions), "?") : undefined;
  55548. return ofErrors([coercionError("Expected type ".concat(type.name), blameNode, path, didYouMean)]);
  55549. }
  55550. if ((0, _definition.isListType)(type)) {
  55551. var itemType = type.ofType;
  55552. if ((0, _iterall.isCollection)(value)) {
  55553. var errors;
  55554. var coercedValue = [];
  55555. (0, _iterall.forEach)(value, function (itemValue, index) {
  55556. var coercedItem = coerceValue(itemValue, itemType, blameNode, atPath(path, index));
  55557. if (coercedItem.errors) {
  55558. errors = add(errors, coercedItem.errors);
  55559. } else if (!errors) {
  55560. coercedValue.push(coercedItem.value);
  55561. }
  55562. });
  55563. return errors ? ofErrors(errors) : ofValue(coercedValue);
  55564. } // Lists accept a non-list value as a list of one.
  55565. var coercedItem = coerceValue(value, itemType, blameNode);
  55566. return coercedItem.errors ? coercedItem : ofValue([coercedItem.value]);
  55567. }
  55568. if ((0, _definition.isInputObjectType)(type)) {
  55569. if (_typeof(value) !== 'object') {
  55570. return ofErrors([coercionError("Expected type ".concat(type.name, " to be an object"), blameNode, path)]);
  55571. }
  55572. var _errors;
  55573. var _coercedValue = {};
  55574. var fields = type.getFields(); // Ensure every defined field is valid.
  55575. var _iteratorNormalCompletion = true;
  55576. var _didIteratorError = false;
  55577. var _iteratorError = undefined;
  55578. try {
  55579. for (var _iterator = (0, _objectValues.default)(fields)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  55580. var field = _step.value;
  55581. var fieldValue = value[field.name];
  55582. if ((0, _isInvalid.default)(fieldValue)) {
  55583. if (!(0, _isInvalid.default)(field.defaultValue)) {
  55584. _coercedValue[field.name] = field.defaultValue;
  55585. } else if ((0, _definition.isNonNullType)(field.type)) {
  55586. _errors = add(_errors, coercionError("Field ".concat(printPath(atPath(path, field.name)), " of required ") + "type ".concat((0, _inspect.default)(field.type), " was not provided"), blameNode));
  55587. }
  55588. } else {
  55589. var coercedField = coerceValue(fieldValue, field.type, blameNode, atPath(path, field.name));
  55590. if (coercedField.errors) {
  55591. _errors = add(_errors, coercedField.errors);
  55592. } else if (!_errors) {
  55593. _coercedValue[field.name] = coercedField.value;
  55594. }
  55595. }
  55596. } // Ensure every provided field is defined.
  55597. } catch (err) {
  55598. _didIteratorError = true;
  55599. _iteratorError = err;
  55600. } finally {
  55601. try {
  55602. if (!_iteratorNormalCompletion && _iterator.return != null) {
  55603. _iterator.return();
  55604. }
  55605. } finally {
  55606. if (_didIteratorError) {
  55607. throw _iteratorError;
  55608. }
  55609. }
  55610. }
  55611. var _arr = Object.keys(value);
  55612. for (var _i = 0; _i < _arr.length; _i++) {
  55613. var fieldName = _arr[_i];
  55614. if (!fields[fieldName]) {
  55615. var _suggestions = (0, _suggestionList.default)(fieldName, Object.keys(fields));
  55616. var _didYouMean = _suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(_suggestions), "?") : undefined;
  55617. _errors = add(_errors, coercionError("Field \"".concat(fieldName, "\" is not defined by type ").concat(type.name), blameNode, path, _didYouMean));
  55618. }
  55619. }
  55620. return _errors ? ofErrors(_errors) : ofValue(_coercedValue);
  55621. }
  55622. /* istanbul ignore next */
  55623. throw new Error("Unexpected type: ".concat(type, "."));
  55624. }
  55625. function ofValue(value) {
  55626. return {
  55627. errors: undefined,
  55628. value: value
  55629. };
  55630. }
  55631. function ofErrors(errors) {
  55632. return {
  55633. errors: errors,
  55634. value: undefined
  55635. };
  55636. }
  55637. function add(errors, moreErrors) {
  55638. return (errors || []).concat(moreErrors);
  55639. }
  55640. function atPath(prev, key) {
  55641. return {
  55642. prev: prev,
  55643. key: key
  55644. };
  55645. }
  55646. function coercionError(message, blameNode, path, subMessage, originalError) {
  55647. var pathStr = printPath(path); // Return a GraphQLError instance
  55648. return new _GraphQLError.GraphQLError(message + (pathStr ? ' at ' + pathStr : '') + (subMessage ? '; ' + subMessage : '.'), blameNode, undefined, undefined, undefined, originalError);
  55649. } // Build a string describing the path into the value where the error was found
  55650. function printPath(path) {
  55651. var pathStr = '';
  55652. var currentPath = path;
  55653. while (currentPath) {
  55654. pathStr = (typeof currentPath.key === 'string' ? '.' + currentPath.key : '[' + String(currentPath.key) + ']') + pathStr;
  55655. currentPath = currentPath.prev;
  55656. }
  55657. return pathStr ? 'value' + pathStr : '';
  55658. }
  55659. },{"../error/GraphQLError":275,"../jsutils/inspect":288,"../jsutils/isInvalid":291,"../jsutils/orList":299,"../jsutils/suggestionList":303,"../polyfills/objectValues":319,"../type/definition":323,"iterall":137}],336:[function(require,module,exports){
  55660. "use strict";
  55661. Object.defineProperty(exports, "__esModule", {
  55662. value: true
  55663. });
  55664. exports.concatAST = concatAST;
  55665. /**
  55666. * Copyright (c) 2015-present, Facebook, Inc.
  55667. *
  55668. * This source code is licensed under the MIT license found in the
  55669. * LICENSE file in the root directory of this source tree.
  55670. *
  55671. *
  55672. */
  55673. /**
  55674. * Provided a collection of ASTs, presumably each from different files,
  55675. * concatenate the ASTs together into batched AST, useful for validating many
  55676. * GraphQL source files which together represent one conceptual application.
  55677. */
  55678. function concatAST(asts) {
  55679. var batchDefinitions = [];
  55680. for (var i = 0; i < asts.length; i++) {
  55681. var definitions = asts[i].definitions;
  55682. for (var j = 0; j < definitions.length; j++) {
  55683. batchDefinitions.push(definitions[j]);
  55684. }
  55685. }
  55686. return {
  55687. kind: 'Document',
  55688. definitions: batchDefinitions
  55689. };
  55690. }
  55691. },{}],337:[function(require,module,exports){
  55692. "use strict";
  55693. Object.defineProperty(exports, "__esModule", {
  55694. value: true
  55695. });
  55696. exports.extendSchema = extendSchema;
  55697. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  55698. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  55699. var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
  55700. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  55701. var _buildASTSchema = require("./buildASTSchema");
  55702. var _validate = require("../validation/validate");
  55703. var _schema = require("../type/schema");
  55704. var _introspection = require("../type/introspection");
  55705. var _scalars = require("../type/scalars");
  55706. var _definition = require("../type/definition");
  55707. var _directives = require("../type/directives");
  55708. var _kinds = require("../language/kinds");
  55709. var _predicates = require("../language/predicates");
  55710. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  55711. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  55712. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  55713. /**
  55714. * Produces a new schema given an existing schema and a document which may
  55715. * contain GraphQL type extensions and definitions. The original schema will
  55716. * remain unaltered.
  55717. *
  55718. * Because a schema represents a graph of references, a schema cannot be
  55719. * extended without effectively making an entire copy. We do not know until it's
  55720. * too late if subgraphs remain unchanged.
  55721. *
  55722. * This algorithm copies the provided schema, applying extensions while
  55723. * producing the copy. The original schema remains unaltered.
  55724. *
  55725. * Accepts options as a third argument:
  55726. *
  55727. * - commentDescriptions:
  55728. * Provide true to use preceding comments as the description.
  55729. *
  55730. */
  55731. function extendSchema(schema, documentAST, options) {
  55732. (0, _schema.assertSchema)(schema);
  55733. !(documentAST && documentAST.kind === _kinds.Kind.DOCUMENT) ? (0, _invariant.default)(0, 'Must provide valid Document AST') : void 0;
  55734. if (!options || !(options.assumeValid || options.assumeValidSDL)) {
  55735. (0, _validate.assertValidSDLExtension)(documentAST, schema);
  55736. } // Collect the type definitions and extensions found in the document.
  55737. var typeDefinitionMap = Object.create(null);
  55738. var typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can
  55739. // have the same name. For example, a type named "skip".
  55740. var directiveDefinitions = [];
  55741. var schemaDef; // Schema extensions are collected which may add additional operation types.
  55742. var schemaExtensions = [];
  55743. var _iteratorNormalCompletion = true;
  55744. var _didIteratorError = false;
  55745. var _iteratorError = undefined;
  55746. try {
  55747. for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  55748. var def = _step.value;
  55749. if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
  55750. schemaDef = def;
  55751. } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) {
  55752. schemaExtensions.push(def);
  55753. } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
  55754. var typeName = def.name.value;
  55755. typeDefinitionMap[typeName] = def;
  55756. } else if ((0, _predicates.isTypeExtensionNode)(def)) {
  55757. var extendedTypeName = def.name.value;
  55758. var existingTypeExtensions = typeExtensionsMap[extendedTypeName];
  55759. typeExtensionsMap[extendedTypeName] = existingTypeExtensions ? existingTypeExtensions.concat([def]) : [def];
  55760. } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  55761. directiveDefinitions.push(def);
  55762. }
  55763. } // If this document contains no new types, extensions, or directives then
  55764. // return the same unmodified GraphQLSchema instance.
  55765. } catch (err) {
  55766. _didIteratorError = true;
  55767. _iteratorError = err;
  55768. } finally {
  55769. try {
  55770. if (!_iteratorNormalCompletion && _iterator.return != null) {
  55771. _iterator.return();
  55772. }
  55773. } finally {
  55774. if (_didIteratorError) {
  55775. throw _iteratorError;
  55776. }
  55777. }
  55778. }
  55779. if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0 && schemaExtensions.length === 0 && !schemaDef) {
  55780. return schema;
  55781. }
  55782. var astBuilder = new _buildASTSchema.ASTDefinitionBuilder(typeDefinitionMap, options, function (typeName) {
  55783. var existingType = schema.getType(typeName);
  55784. !existingType ? (0, _invariant.default)(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
  55785. return extendNamedType(existingType);
  55786. });
  55787. var extendTypeCache = Object.create(null); // Get the extended root operation types.
  55788. var operationTypes = {
  55789. query: extendMaybeNamedType(schema.getQueryType()),
  55790. mutation: extendMaybeNamedType(schema.getMutationType()),
  55791. subscription: extendMaybeNamedType(schema.getSubscriptionType())
  55792. };
  55793. if (schemaDef) {
  55794. var _iteratorNormalCompletion2 = true;
  55795. var _didIteratorError2 = false;
  55796. var _iteratorError2 = undefined;
  55797. try {
  55798. for (var _iterator2 = schemaDef.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  55799. var _ref2 = _step2.value;
  55800. var operation = _ref2.operation;
  55801. var type = _ref2.type;
  55802. // Note: While this could make early assertions to get the correctly
  55803. // typed values, that would throw immediately while type system
  55804. // validation with validateSchema() will produce more actionable results.
  55805. operationTypes[operation] = astBuilder.buildType(type);
  55806. }
  55807. } catch (err) {
  55808. _didIteratorError2 = true;
  55809. _iteratorError2 = err;
  55810. } finally {
  55811. try {
  55812. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  55813. _iterator2.return();
  55814. }
  55815. } finally {
  55816. if (_didIteratorError2) {
  55817. throw _iteratorError2;
  55818. }
  55819. }
  55820. }
  55821. } // Then, incorporate schema definition and all schema extensions.
  55822. for (var _i = 0; _i < schemaExtensions.length; _i++) {
  55823. var schemaExtension = schemaExtensions[_i];
  55824. if (schemaExtension.operationTypes) {
  55825. var _iteratorNormalCompletion14 = true;
  55826. var _didIteratorError14 = false;
  55827. var _iteratorError14 = undefined;
  55828. try {
  55829. for (var _iterator14 = schemaExtension.operationTypes[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  55830. var _ref4 = _step14.value;
  55831. var _operation = _ref4.operation;
  55832. var _type = _ref4.type;
  55833. // Note: While this could make early assertions to get the correctly
  55834. // typed values, that would throw immediately while type system
  55835. // validation with validateSchema() will produce more actionable results.
  55836. operationTypes[_operation] = astBuilder.buildType(_type);
  55837. }
  55838. } catch (err) {
  55839. _didIteratorError14 = true;
  55840. _iteratorError14 = err;
  55841. } finally {
  55842. try {
  55843. if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
  55844. _iterator14.return();
  55845. }
  55846. } finally {
  55847. if (_didIteratorError14) {
  55848. throw _iteratorError14;
  55849. }
  55850. }
  55851. }
  55852. }
  55853. }
  55854. var schemaExtensionASTNodes = schemaExtensions ? schema.extensionASTNodes ? schema.extensionASTNodes.concat(schemaExtensions) : schemaExtensions : schema.extensionASTNodes;
  55855. var types = [].concat((0, _objectValues.default)(schema.getTypeMap()).map(function (type) {
  55856. return extendNamedType(type);
  55857. }), (0, _objectValues.default)(typeDefinitionMap).map(function (type) {
  55858. return astBuilder.buildType(type);
  55859. })); // Support both original legacy names and extended legacy names.
  55860. var allowedLegacyNames = schema.__allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
  55861. return new _schema.GraphQLSchema(_objectSpread({}, operationTypes, {
  55862. types: types,
  55863. directives: getMergedDirectives(),
  55864. astNode: schema.astNode,
  55865. extensionASTNodes: schemaExtensionASTNodes,
  55866. allowedLegacyNames: allowedLegacyNames
  55867. })); // Below are functions used for producing this schema that have closed over
  55868. // this scope and have access to the schema, cache, and newly defined types.
  55869. function getMergedDirectives() {
  55870. var existingDirectives = schema.getDirectives().map(extendDirective);
  55871. !existingDirectives ? (0, _invariant.default)(0, 'schema must have default directives') : void 0;
  55872. return existingDirectives.concat(directiveDefinitions.map(function (node) {
  55873. return astBuilder.buildDirective(node);
  55874. }));
  55875. }
  55876. function extendMaybeNamedType(type) {
  55877. return type ? extendNamedType(type) : null;
  55878. }
  55879. function extendNamedType(type) {
  55880. if ((0, _introspection.isIntrospectionType)(type) || (0, _scalars.isSpecifiedScalarType)(type)) {
  55881. // Builtin types are not extended.
  55882. return type;
  55883. }
  55884. var name = type.name;
  55885. if (!extendTypeCache[name]) {
  55886. if ((0, _definition.isScalarType)(type)) {
  55887. extendTypeCache[name] = extendScalarType(type);
  55888. } else if ((0, _definition.isObjectType)(type)) {
  55889. extendTypeCache[name] = extendObjectType(type);
  55890. } else if ((0, _definition.isInterfaceType)(type)) {
  55891. extendTypeCache[name] = extendInterfaceType(type);
  55892. } else if ((0, _definition.isUnionType)(type)) {
  55893. extendTypeCache[name] = extendUnionType(type);
  55894. } else if ((0, _definition.isEnumType)(type)) {
  55895. extendTypeCache[name] = extendEnumType(type);
  55896. } else if ((0, _definition.isInputObjectType)(type)) {
  55897. extendTypeCache[name] = extendInputObjectType(type);
  55898. }
  55899. }
  55900. return extendTypeCache[name];
  55901. }
  55902. function extendDirective(directive) {
  55903. return new _directives.GraphQLDirective({
  55904. name: directive.name,
  55905. description: directive.description,
  55906. locations: directive.locations,
  55907. args: extendArgs(directive.args),
  55908. astNode: directive.astNode
  55909. });
  55910. }
  55911. function extendInputObjectType(type) {
  55912. var name = type.name;
  55913. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  55914. return new _definition.GraphQLInputObjectType({
  55915. name: name,
  55916. description: type.description,
  55917. fields: function fields() {
  55918. return extendInputFieldMap(type);
  55919. },
  55920. astNode: type.astNode,
  55921. extensionASTNodes: extensionASTNodes
  55922. });
  55923. }
  55924. function extendInputFieldMap(type) {
  55925. var newFieldMap = (0, _mapValue.default)(type.getFields(), function (field) {
  55926. return {
  55927. description: field.description,
  55928. type: extendType(field.type),
  55929. defaultValue: field.defaultValue,
  55930. astNode: field.astNode
  55931. };
  55932. }); // If there are any extensions to the fields, apply those here.
  55933. var extensions = typeExtensionsMap[type.name];
  55934. if (extensions) {
  55935. var _iteratorNormalCompletion3 = true;
  55936. var _didIteratorError3 = false;
  55937. var _iteratorError3 = undefined;
  55938. try {
  55939. for (var _iterator3 = extensions[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  55940. var extension = _step3.value;
  55941. var _iteratorNormalCompletion4 = true;
  55942. var _didIteratorError4 = false;
  55943. var _iteratorError4 = undefined;
  55944. try {
  55945. for (var _iterator4 = extension.fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  55946. var field = _step4.value;
  55947. newFieldMap[field.name.value] = astBuilder.buildInputField(field);
  55948. }
  55949. } catch (err) {
  55950. _didIteratorError4 = true;
  55951. _iteratorError4 = err;
  55952. } finally {
  55953. try {
  55954. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  55955. _iterator4.return();
  55956. }
  55957. } finally {
  55958. if (_didIteratorError4) {
  55959. throw _iteratorError4;
  55960. }
  55961. }
  55962. }
  55963. }
  55964. } catch (err) {
  55965. _didIteratorError3 = true;
  55966. _iteratorError3 = err;
  55967. } finally {
  55968. try {
  55969. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  55970. _iterator3.return();
  55971. }
  55972. } finally {
  55973. if (_didIteratorError3) {
  55974. throw _iteratorError3;
  55975. }
  55976. }
  55977. }
  55978. }
  55979. return newFieldMap;
  55980. }
  55981. function extendEnumType(type) {
  55982. var name = type.name;
  55983. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  55984. return new _definition.GraphQLEnumType({
  55985. name: name,
  55986. description: type.description,
  55987. values: extendValueMap(type),
  55988. astNode: type.astNode,
  55989. extensionASTNodes: extensionASTNodes
  55990. });
  55991. }
  55992. function extendValueMap(type) {
  55993. var newValueMap = Object.create(null);
  55994. var _iteratorNormalCompletion5 = true;
  55995. var _didIteratorError5 = false;
  55996. var _iteratorError5 = undefined;
  55997. try {
  55998. for (var _iterator5 = type.getValues()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  55999. var _value = _step5.value;
  56000. newValueMap[_value.name] = {
  56001. description: _value.description,
  56002. value: _value.value,
  56003. deprecationReason: _value.deprecationReason,
  56004. astNode: _value.astNode
  56005. };
  56006. } // If there are any extensions to the values, apply those here.
  56007. } catch (err) {
  56008. _didIteratorError5 = true;
  56009. _iteratorError5 = err;
  56010. } finally {
  56011. try {
  56012. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  56013. _iterator5.return();
  56014. }
  56015. } finally {
  56016. if (_didIteratorError5) {
  56017. throw _iteratorError5;
  56018. }
  56019. }
  56020. }
  56021. var extensions = typeExtensionsMap[type.name];
  56022. if (extensions) {
  56023. var _iteratorNormalCompletion6 = true;
  56024. var _didIteratorError6 = false;
  56025. var _iteratorError6 = undefined;
  56026. try {
  56027. for (var _iterator6 = extensions[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  56028. var extension = _step6.value;
  56029. var _iteratorNormalCompletion7 = true;
  56030. var _didIteratorError7 = false;
  56031. var _iteratorError7 = undefined;
  56032. try {
  56033. for (var _iterator7 = extension.values[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  56034. var value = _step7.value;
  56035. newValueMap[value.name.value] = astBuilder.buildEnumValue(value);
  56036. }
  56037. } catch (err) {
  56038. _didIteratorError7 = true;
  56039. _iteratorError7 = err;
  56040. } finally {
  56041. try {
  56042. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  56043. _iterator7.return();
  56044. }
  56045. } finally {
  56046. if (_didIteratorError7) {
  56047. throw _iteratorError7;
  56048. }
  56049. }
  56050. }
  56051. }
  56052. } catch (err) {
  56053. _didIteratorError6 = true;
  56054. _iteratorError6 = err;
  56055. } finally {
  56056. try {
  56057. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  56058. _iterator6.return();
  56059. }
  56060. } finally {
  56061. if (_didIteratorError6) {
  56062. throw _iteratorError6;
  56063. }
  56064. }
  56065. }
  56066. }
  56067. return newValueMap;
  56068. }
  56069. function extendScalarType(type) {
  56070. var name = type.name;
  56071. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  56072. return new _definition.GraphQLScalarType({
  56073. name: name,
  56074. description: type.description,
  56075. astNode: type.astNode,
  56076. extensionASTNodes: extensionASTNodes,
  56077. serialize: type.serialize,
  56078. parseValue: type.parseValue,
  56079. parseLiteral: type.parseLiteral
  56080. });
  56081. }
  56082. function extendObjectType(type) {
  56083. var name = type.name;
  56084. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  56085. return new _definition.GraphQLObjectType({
  56086. name: name,
  56087. description: type.description,
  56088. interfaces: function interfaces() {
  56089. return extendImplementedInterfaces(type);
  56090. },
  56091. fields: function fields() {
  56092. return extendFieldMap(type);
  56093. },
  56094. astNode: type.astNode,
  56095. extensionASTNodes: extensionASTNodes,
  56096. isTypeOf: type.isTypeOf
  56097. });
  56098. }
  56099. function extendArgs(args) {
  56100. return (0, _keyValMap.default)(args, function (arg) {
  56101. return arg.name;
  56102. }, function (arg) {
  56103. return {
  56104. type: extendType(arg.type),
  56105. defaultValue: arg.defaultValue,
  56106. description: arg.description,
  56107. astNode: arg.astNode
  56108. };
  56109. });
  56110. }
  56111. function extendInterfaceType(type) {
  56112. var name = type.name;
  56113. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  56114. return new _definition.GraphQLInterfaceType({
  56115. name: type.name,
  56116. description: type.description,
  56117. fields: function fields() {
  56118. return extendFieldMap(type);
  56119. },
  56120. astNode: type.astNode,
  56121. extensionASTNodes: extensionASTNodes,
  56122. resolveType: type.resolveType
  56123. });
  56124. }
  56125. function extendUnionType(type) {
  56126. var name = type.name;
  56127. var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
  56128. return new _definition.GraphQLUnionType({
  56129. name: name,
  56130. description: type.description,
  56131. types: function types() {
  56132. return extendPossibleTypes(type);
  56133. },
  56134. astNode: type.astNode,
  56135. resolveType: type.resolveType,
  56136. extensionASTNodes: extensionASTNodes
  56137. });
  56138. }
  56139. function extendPossibleTypes(type) {
  56140. var possibleTypes = type.getTypes().map(extendNamedType); // If there are any extensions to the union, apply those here.
  56141. var extensions = typeExtensionsMap[type.name];
  56142. if (extensions) {
  56143. var _iteratorNormalCompletion8 = true;
  56144. var _didIteratorError8 = false;
  56145. var _iteratorError8 = undefined;
  56146. try {
  56147. for (var _iterator8 = extensions[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  56148. var extension = _step8.value;
  56149. var _iteratorNormalCompletion9 = true;
  56150. var _didIteratorError9 = false;
  56151. var _iteratorError9 = undefined;
  56152. try {
  56153. for (var _iterator9 = extension.types[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  56154. var namedType = _step9.value;
  56155. // Note: While this could make early assertions to get the correctly
  56156. // typed values, that would throw immediately while type system
  56157. // validation with validateSchema() will produce more actionable results.
  56158. possibleTypes.push(astBuilder.buildType(namedType));
  56159. }
  56160. } catch (err) {
  56161. _didIteratorError9 = true;
  56162. _iteratorError9 = err;
  56163. } finally {
  56164. try {
  56165. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  56166. _iterator9.return();
  56167. }
  56168. } finally {
  56169. if (_didIteratorError9) {
  56170. throw _iteratorError9;
  56171. }
  56172. }
  56173. }
  56174. }
  56175. } catch (err) {
  56176. _didIteratorError8 = true;
  56177. _iteratorError8 = err;
  56178. } finally {
  56179. try {
  56180. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  56181. _iterator8.return();
  56182. }
  56183. } finally {
  56184. if (_didIteratorError8) {
  56185. throw _iteratorError8;
  56186. }
  56187. }
  56188. }
  56189. }
  56190. return possibleTypes;
  56191. }
  56192. function extendImplementedInterfaces(type) {
  56193. var interfaces = type.getInterfaces().map(extendNamedType); // If there are any extensions to the interfaces, apply those here.
  56194. var extensions = typeExtensionsMap[type.name];
  56195. if (extensions) {
  56196. var _iteratorNormalCompletion10 = true;
  56197. var _didIteratorError10 = false;
  56198. var _iteratorError10 = undefined;
  56199. try {
  56200. for (var _iterator10 = extensions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  56201. var extension = _step10.value;
  56202. var _iteratorNormalCompletion11 = true;
  56203. var _didIteratorError11 = false;
  56204. var _iteratorError11 = undefined;
  56205. try {
  56206. for (var _iterator11 = extension.interfaces[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  56207. var namedType = _step11.value;
  56208. // Note: While this could make early assertions to get the correctly
  56209. // typed values, that would throw immediately while type system
  56210. // validation with validateSchema() will produce more actionable results.
  56211. interfaces.push(astBuilder.buildType(namedType));
  56212. }
  56213. } catch (err) {
  56214. _didIteratorError11 = true;
  56215. _iteratorError11 = err;
  56216. } finally {
  56217. try {
  56218. if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
  56219. _iterator11.return();
  56220. }
  56221. } finally {
  56222. if (_didIteratorError11) {
  56223. throw _iteratorError11;
  56224. }
  56225. }
  56226. }
  56227. }
  56228. } catch (err) {
  56229. _didIteratorError10 = true;
  56230. _iteratorError10 = err;
  56231. } finally {
  56232. try {
  56233. if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
  56234. _iterator10.return();
  56235. }
  56236. } finally {
  56237. if (_didIteratorError10) {
  56238. throw _iteratorError10;
  56239. }
  56240. }
  56241. }
  56242. }
  56243. return interfaces;
  56244. }
  56245. function extendFieldMap(type) {
  56246. var newFieldMap = (0, _mapValue.default)(type.getFields(), function (field) {
  56247. return {
  56248. description: field.description,
  56249. deprecationReason: field.deprecationReason,
  56250. type: extendType(field.type),
  56251. args: extendArgs(field.args),
  56252. astNode: field.astNode,
  56253. resolve: field.resolve
  56254. };
  56255. }); // If there are any extensions to the fields, apply those here.
  56256. var extensions = typeExtensionsMap[type.name];
  56257. if (extensions) {
  56258. var _iteratorNormalCompletion12 = true;
  56259. var _didIteratorError12 = false;
  56260. var _iteratorError12 = undefined;
  56261. try {
  56262. for (var _iterator12 = extensions[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  56263. var extension = _step12.value;
  56264. var _iteratorNormalCompletion13 = true;
  56265. var _didIteratorError13 = false;
  56266. var _iteratorError13 = undefined;
  56267. try {
  56268. for (var _iterator13 = extension.fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  56269. var field = _step13.value;
  56270. newFieldMap[field.name.value] = astBuilder.buildField(field);
  56271. }
  56272. } catch (err) {
  56273. _didIteratorError13 = true;
  56274. _iteratorError13 = err;
  56275. } finally {
  56276. try {
  56277. if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
  56278. _iterator13.return();
  56279. }
  56280. } finally {
  56281. if (_didIteratorError13) {
  56282. throw _iteratorError13;
  56283. }
  56284. }
  56285. }
  56286. }
  56287. } catch (err) {
  56288. _didIteratorError12 = true;
  56289. _iteratorError12 = err;
  56290. } finally {
  56291. try {
  56292. if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
  56293. _iterator12.return();
  56294. }
  56295. } finally {
  56296. if (_didIteratorError12) {
  56297. throw _iteratorError12;
  56298. }
  56299. }
  56300. }
  56301. }
  56302. return newFieldMap;
  56303. }
  56304. function extendType(typeDef) {
  56305. if ((0, _definition.isListType)(typeDef)) {
  56306. return (0, _definition.GraphQLList)(extendType(typeDef.ofType));
  56307. }
  56308. if ((0, _definition.isNonNullType)(typeDef)) {
  56309. return (0, _definition.GraphQLNonNull)(extendType(typeDef.ofType));
  56310. }
  56311. return extendNamedType(typeDef);
  56312. }
  56313. }
  56314. },{"../jsutils/invariant":290,"../jsutils/keyValMap":295,"../jsutils/mapValue":296,"../language/kinds":307,"../language/predicates":311,"../polyfills/objectValues":319,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/scalars":327,"../type/schema":328,"../validation/validate":390,"./buildASTSchema":333}],338:[function(require,module,exports){
  56315. "use strict";
  56316. Object.defineProperty(exports, "__esModule", {
  56317. value: true
  56318. });
  56319. exports.findBreakingChanges = findBreakingChanges;
  56320. exports.findDangerousChanges = findDangerousChanges;
  56321. exports.findRemovedTypes = findRemovedTypes;
  56322. exports.findTypesThatChangedKind = findTypesThatChangedKind;
  56323. exports.findArgChanges = findArgChanges;
  56324. exports.findFieldsThatChangedTypeOnObjectOrInterfaceTypes = findFieldsThatChangedTypeOnObjectOrInterfaceTypes;
  56325. exports.findFieldsThatChangedTypeOnInputObjectTypes = findFieldsThatChangedTypeOnInputObjectTypes;
  56326. exports.findTypesRemovedFromUnions = findTypesRemovedFromUnions;
  56327. exports.findTypesAddedToUnions = findTypesAddedToUnions;
  56328. exports.findValuesRemovedFromEnums = findValuesRemovedFromEnums;
  56329. exports.findValuesAddedToEnums = findValuesAddedToEnums;
  56330. exports.findInterfacesRemovedFromObjectTypes = findInterfacesRemovedFromObjectTypes;
  56331. exports.findInterfacesAddedToObjectTypes = findInterfacesAddedToObjectTypes;
  56332. exports.findRemovedDirectives = findRemovedDirectives;
  56333. exports.findRemovedDirectiveArgs = findRemovedDirectiveArgs;
  56334. exports.findAddedNonNullDirectiveArgs = findAddedNonNullDirectiveArgs;
  56335. exports.findRemovedLocationsForDirective = findRemovedLocationsForDirective;
  56336. exports.findRemovedDirectiveLocations = findRemovedDirectiveLocations;
  56337. exports.DangerousChangeType = exports.BreakingChangeType = void 0;
  56338. var _find = _interopRequireDefault(require("../polyfills/find"));
  56339. var _definition = require("../type/definition");
  56340. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  56341. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  56342. /**
  56343. * Copyright (c) 2016-present, Facebook, Inc.
  56344. *
  56345. * This source code is licensed under the MIT license found in the
  56346. * LICENSE file in the root directory of this source tree.
  56347. *
  56348. *
  56349. */
  56350. var BreakingChangeType = {
  56351. FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND',
  56352. FIELD_REMOVED: 'FIELD_REMOVED',
  56353. TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND',
  56354. TYPE_REMOVED: 'TYPE_REMOVED',
  56355. TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION',
  56356. VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM',
  56357. ARG_REMOVED: 'ARG_REMOVED',
  56358. ARG_CHANGED_KIND: 'ARG_CHANGED_KIND',
  56359. REQUIRED_ARG_ADDED: 'REQUIRED_ARG_ADDED',
  56360. REQUIRED_INPUT_FIELD_ADDED: 'REQUIRED_INPUT_FIELD_ADDED',
  56361. INTERFACE_REMOVED_FROM_OBJECT: 'INTERFACE_REMOVED_FROM_OBJECT',
  56362. DIRECTIVE_REMOVED: 'DIRECTIVE_REMOVED',
  56363. DIRECTIVE_ARG_REMOVED: 'DIRECTIVE_ARG_REMOVED',
  56364. DIRECTIVE_LOCATION_REMOVED: 'DIRECTIVE_LOCATION_REMOVED',
  56365. REQUIRED_DIRECTIVE_ARG_ADDED: 'REQUIRED_DIRECTIVE_ARG_ADDED'
  56366. };
  56367. exports.BreakingChangeType = BreakingChangeType;
  56368. var DangerousChangeType = {
  56369. ARG_DEFAULT_VALUE_CHANGE: 'ARG_DEFAULT_VALUE_CHANGE',
  56370. VALUE_ADDED_TO_ENUM: 'VALUE_ADDED_TO_ENUM',
  56371. INTERFACE_ADDED_TO_OBJECT: 'INTERFACE_ADDED_TO_OBJECT',
  56372. TYPE_ADDED_TO_UNION: 'TYPE_ADDED_TO_UNION',
  56373. OPTIONAL_INPUT_FIELD_ADDED: 'OPTIONAL_INPUT_FIELD_ADDED',
  56374. OPTIONAL_ARG_ADDED: 'OPTIONAL_ARG_ADDED'
  56375. };
  56376. exports.DangerousChangeType = DangerousChangeType;
  56377. /**
  56378. * Given two schemas, returns an Array containing descriptions of all the types
  56379. * of breaking changes covered by the other functions down below.
  56380. */
  56381. function findBreakingChanges(oldSchema, newSchema) {
  56382. return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedTypeOnObjectOrInterfaceTypes(oldSchema, newSchema), findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema).breakingChanges, findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema), findArgChanges(oldSchema, newSchema).breakingChanges, findInterfacesRemovedFromObjectTypes(oldSchema, newSchema), findRemovedDirectives(oldSchema, newSchema), findRemovedDirectiveArgs(oldSchema, newSchema), findAddedNonNullDirectiveArgs(oldSchema, newSchema), findRemovedDirectiveLocations(oldSchema, newSchema));
  56383. }
  56384. /**
  56385. * Given two schemas, returns an Array containing descriptions of all the types
  56386. * of potentially dangerous changes covered by the other functions down below.
  56387. */
  56388. function findDangerousChanges(oldSchema, newSchema) {
  56389. return [].concat(findArgChanges(oldSchema, newSchema).dangerousChanges, findValuesAddedToEnums(oldSchema, newSchema), findInterfacesAddedToObjectTypes(oldSchema, newSchema), findTypesAddedToUnions(oldSchema, newSchema), findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema).dangerousChanges);
  56390. }
  56391. /**
  56392. * Given two schemas, returns an Array containing descriptions of any breaking
  56393. * changes in the newSchema related to removing an entire type.
  56394. */
  56395. function findRemovedTypes(oldSchema, newSchema) {
  56396. var oldTypeMap = oldSchema.getTypeMap();
  56397. var newTypeMap = newSchema.getTypeMap();
  56398. var breakingChanges = [];
  56399. var _arr = Object.keys(oldTypeMap);
  56400. for (var _i = 0; _i < _arr.length; _i++) {
  56401. var typeName = _arr[_i];
  56402. if (!newTypeMap[typeName]) {
  56403. breakingChanges.push({
  56404. type: BreakingChangeType.TYPE_REMOVED,
  56405. description: "".concat(typeName, " was removed.")
  56406. });
  56407. }
  56408. }
  56409. return breakingChanges;
  56410. }
  56411. /**
  56412. * Given two schemas, returns an Array containing descriptions of any breaking
  56413. * changes in the newSchema related to changing the type of a type.
  56414. */
  56415. function findTypesThatChangedKind(oldSchema, newSchema) {
  56416. var oldTypeMap = oldSchema.getTypeMap();
  56417. var newTypeMap = newSchema.getTypeMap();
  56418. var breakingChanges = [];
  56419. var _arr2 = Object.keys(oldTypeMap);
  56420. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  56421. var typeName = _arr2[_i2];
  56422. if (!newTypeMap[typeName]) {
  56423. continue;
  56424. }
  56425. var oldType = oldTypeMap[typeName];
  56426. var newType = newTypeMap[typeName];
  56427. if (oldType.constructor !== newType.constructor) {
  56428. breakingChanges.push({
  56429. type: BreakingChangeType.TYPE_CHANGED_KIND,
  56430. description: "".concat(typeName, " changed from ") + "".concat(typeKindName(oldType), " to ").concat(typeKindName(newType), ".")
  56431. });
  56432. }
  56433. }
  56434. return breakingChanges;
  56435. }
  56436. /**
  56437. * Given two schemas, returns an Array containing descriptions of any
  56438. * breaking or dangerous changes in the newSchema related to arguments
  56439. * (such as removal or change of type of an argument, or a change in an
  56440. * argument's default value).
  56441. */
  56442. function findArgChanges(oldSchema, newSchema) {
  56443. var oldTypeMap = oldSchema.getTypeMap();
  56444. var newTypeMap = newSchema.getTypeMap();
  56445. var breakingChanges = [];
  56446. var dangerousChanges = [];
  56447. var _arr3 = Object.keys(oldTypeMap);
  56448. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  56449. var typeName = _arr3[_i3];
  56450. var oldType = oldTypeMap[typeName];
  56451. var newType = newTypeMap[typeName];
  56452. if (!((0, _definition.isObjectType)(oldType) || (0, _definition.isInterfaceType)(oldType)) || !((0, _definition.isObjectType)(newType) || (0, _definition.isInterfaceType)(newType)) || newType.constructor !== oldType.constructor) {
  56453. continue;
  56454. }
  56455. var oldTypeFields = oldType.getFields();
  56456. var newTypeFields = newType.getFields();
  56457. var _arr4 = Object.keys(oldTypeFields);
  56458. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  56459. var fieldName = _arr4[_i4];
  56460. if (!newTypeFields[fieldName]) {
  56461. continue;
  56462. }
  56463. var _iteratorNormalCompletion = true;
  56464. var _didIteratorError = false;
  56465. var _iteratorError = undefined;
  56466. try {
  56467. var _loop = function _loop() {
  56468. var oldArgDef = _step.value;
  56469. var newArgs = newTypeFields[fieldName].args;
  56470. var newArgDef = (0, _find.default)(newArgs, function (arg) {
  56471. return arg.name === oldArgDef.name;
  56472. }); // Arg not present
  56473. if (!newArgDef) {
  56474. breakingChanges.push({
  56475. type: BreakingChangeType.ARG_REMOVED,
  56476. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " was removed")
  56477. });
  56478. } else {
  56479. var isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArgDef.type, newArgDef.type);
  56480. if (!isSafe) {
  56481. breakingChanges.push({
  56482. type: BreakingChangeType.ARG_CHANGED_KIND,
  56483. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " has changed type from ") + "".concat(oldArgDef.type.toString(), " to ").concat(newArgDef.type.toString())
  56484. });
  56485. } else if (oldArgDef.defaultValue !== undefined && oldArgDef.defaultValue !== newArgDef.defaultValue) {
  56486. dangerousChanges.push({
  56487. type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
  56488. description: "".concat(oldType.name, ".").concat(fieldName, " arg ") + "".concat(oldArgDef.name, " has changed defaultValue")
  56489. });
  56490. }
  56491. }
  56492. };
  56493. for (var _iterator = oldTypeFields[fieldName].args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  56494. _loop();
  56495. } // Check if arg was added to the field
  56496. } catch (err) {
  56497. _didIteratorError = true;
  56498. _iteratorError = err;
  56499. } finally {
  56500. try {
  56501. if (!_iteratorNormalCompletion && _iterator.return != null) {
  56502. _iterator.return();
  56503. }
  56504. } finally {
  56505. if (_didIteratorError) {
  56506. throw _iteratorError;
  56507. }
  56508. }
  56509. }
  56510. var _iteratorNormalCompletion2 = true;
  56511. var _didIteratorError2 = false;
  56512. var _iteratorError2 = undefined;
  56513. try {
  56514. var _loop2 = function _loop2() {
  56515. var newArgDef = _step2.value;
  56516. var oldArgs = oldTypeFields[fieldName].args;
  56517. var oldArgDef = (0, _find.default)(oldArgs, function (arg) {
  56518. return arg.name === newArgDef.name;
  56519. });
  56520. if (!oldArgDef) {
  56521. var argName = newArgDef.name;
  56522. if ((0, _definition.isRequiredArgument)(newArgDef)) {
  56523. breakingChanges.push({
  56524. type: BreakingChangeType.REQUIRED_ARG_ADDED,
  56525. description: "A required arg ".concat(argName, " on ") + "".concat(typeName, ".").concat(fieldName, " was added")
  56526. });
  56527. } else {
  56528. dangerousChanges.push({
  56529. type: DangerousChangeType.OPTIONAL_ARG_ADDED,
  56530. description: "An optional arg ".concat(argName, " on ") + "".concat(typeName, ".").concat(fieldName, " was added")
  56531. });
  56532. }
  56533. }
  56534. };
  56535. for (var _iterator2 = newTypeFields[fieldName].args[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  56536. _loop2();
  56537. }
  56538. } catch (err) {
  56539. _didIteratorError2 = true;
  56540. _iteratorError2 = err;
  56541. } finally {
  56542. try {
  56543. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  56544. _iterator2.return();
  56545. }
  56546. } finally {
  56547. if (_didIteratorError2) {
  56548. throw _iteratorError2;
  56549. }
  56550. }
  56551. }
  56552. }
  56553. }
  56554. return {
  56555. breakingChanges: breakingChanges,
  56556. dangerousChanges: dangerousChanges
  56557. };
  56558. }
  56559. function typeKindName(type) {
  56560. if ((0, _definition.isScalarType)(type)) {
  56561. return 'a Scalar type';
  56562. }
  56563. if ((0, _definition.isObjectType)(type)) {
  56564. return 'an Object type';
  56565. }
  56566. if ((0, _definition.isInterfaceType)(type)) {
  56567. return 'an Interface type';
  56568. }
  56569. if ((0, _definition.isUnionType)(type)) {
  56570. return 'a Union type';
  56571. }
  56572. if ((0, _definition.isEnumType)(type)) {
  56573. return 'an Enum type';
  56574. }
  56575. if ((0, _definition.isInputObjectType)(type)) {
  56576. return 'an Input type';
  56577. }
  56578. throw new TypeError('Unknown type ' + type.constructor.name);
  56579. }
  56580. function findFieldsThatChangedTypeOnObjectOrInterfaceTypes(oldSchema, newSchema) {
  56581. var oldTypeMap = oldSchema.getTypeMap();
  56582. var newTypeMap = newSchema.getTypeMap();
  56583. var breakingChanges = [];
  56584. var _arr5 = Object.keys(oldTypeMap);
  56585. for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
  56586. var typeName = _arr5[_i5];
  56587. var oldType = oldTypeMap[typeName];
  56588. var newType = newTypeMap[typeName];
  56589. if (!((0, _definition.isObjectType)(oldType) || (0, _definition.isInterfaceType)(oldType)) || !((0, _definition.isObjectType)(newType) || (0, _definition.isInterfaceType)(newType)) || newType.constructor !== oldType.constructor) {
  56590. continue;
  56591. }
  56592. var oldTypeFieldsDef = oldType.getFields();
  56593. var newTypeFieldsDef = newType.getFields();
  56594. var _arr6 = Object.keys(oldTypeFieldsDef);
  56595. for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
  56596. var fieldName = _arr6[_i6];
  56597. // Check if the field is missing on the type in the new schema.
  56598. if (!(fieldName in newTypeFieldsDef)) {
  56599. breakingChanges.push({
  56600. type: BreakingChangeType.FIELD_REMOVED,
  56601. description: "".concat(typeName, ".").concat(fieldName, " was removed.")
  56602. });
  56603. } else {
  56604. var oldFieldType = oldTypeFieldsDef[fieldName].type;
  56605. var newFieldType = newTypeFieldsDef[fieldName].type;
  56606. var isSafe = isChangeSafeForObjectOrInterfaceField(oldFieldType, newFieldType);
  56607. if (!isSafe) {
  56608. var oldFieldTypeString = (0, _definition.isNamedType)(oldFieldType) ? oldFieldType.name : oldFieldType.toString();
  56609. var newFieldTypeString = (0, _definition.isNamedType)(newFieldType) ? newFieldType.name : newFieldType.toString();
  56610. breakingChanges.push({
  56611. type: BreakingChangeType.FIELD_CHANGED_KIND,
  56612. description: "".concat(typeName, ".").concat(fieldName, " changed type from ") + "".concat(oldFieldTypeString, " to ").concat(newFieldTypeString, ".")
  56613. });
  56614. }
  56615. }
  56616. }
  56617. }
  56618. return breakingChanges;
  56619. }
  56620. function findFieldsThatChangedTypeOnInputObjectTypes(oldSchema, newSchema) {
  56621. var oldTypeMap = oldSchema.getTypeMap();
  56622. var newTypeMap = newSchema.getTypeMap();
  56623. var breakingChanges = [];
  56624. var dangerousChanges = [];
  56625. var _arr7 = Object.keys(oldTypeMap);
  56626. for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
  56627. var typeName = _arr7[_i7];
  56628. var oldType = oldTypeMap[typeName];
  56629. var newType = newTypeMap[typeName];
  56630. if (!(0, _definition.isInputObjectType)(oldType) || !(0, _definition.isInputObjectType)(newType)) {
  56631. continue;
  56632. }
  56633. var oldTypeFieldsDef = oldType.getFields();
  56634. var newTypeFieldsDef = newType.getFields();
  56635. var _arr8 = Object.keys(oldTypeFieldsDef);
  56636. for (var _i8 = 0; _i8 < _arr8.length; _i8++) {
  56637. var fieldName = _arr8[_i8];
  56638. // Check if the field is missing on the type in the new schema.
  56639. if (!(fieldName in newTypeFieldsDef)) {
  56640. breakingChanges.push({
  56641. type: BreakingChangeType.FIELD_REMOVED,
  56642. description: "".concat(typeName, ".").concat(fieldName, " was removed.")
  56643. });
  56644. } else {
  56645. var oldFieldType = oldTypeFieldsDef[fieldName].type;
  56646. var newFieldType = newTypeFieldsDef[fieldName].type;
  56647. var isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldFieldType, newFieldType);
  56648. if (!isSafe) {
  56649. var oldFieldTypeString = (0, _definition.isNamedType)(oldFieldType) ? oldFieldType.name : oldFieldType.toString();
  56650. var newFieldTypeString = (0, _definition.isNamedType)(newFieldType) ? newFieldType.name : newFieldType.toString();
  56651. breakingChanges.push({
  56652. type: BreakingChangeType.FIELD_CHANGED_KIND,
  56653. description: "".concat(typeName, ".").concat(fieldName, " changed type from ") + "".concat(oldFieldTypeString, " to ").concat(newFieldTypeString, ".")
  56654. });
  56655. }
  56656. }
  56657. } // Check if a field was added to the input object type
  56658. var _arr9 = Object.keys(newTypeFieldsDef);
  56659. for (var _i9 = 0; _i9 < _arr9.length; _i9++) {
  56660. var _fieldName = _arr9[_i9];
  56661. if (!(_fieldName in oldTypeFieldsDef)) {
  56662. if ((0, _definition.isRequiredInputField)(newTypeFieldsDef[_fieldName])) {
  56663. breakingChanges.push({
  56664. type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED,
  56665. description: "A required field ".concat(_fieldName, " on ") + "input type ".concat(typeName, " was added.")
  56666. });
  56667. } else {
  56668. dangerousChanges.push({
  56669. type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED,
  56670. description: "An optional field ".concat(_fieldName, " on ") + "input type ".concat(typeName, " was added.")
  56671. });
  56672. }
  56673. }
  56674. }
  56675. }
  56676. return {
  56677. breakingChanges: breakingChanges,
  56678. dangerousChanges: dangerousChanges
  56679. };
  56680. }
  56681. function isChangeSafeForObjectOrInterfaceField(oldType, newType) {
  56682. if ((0, _definition.isNamedType)(oldType)) {
  56683. return (// if they're both named types, see if their names are equivalent
  56684. (0, _definition.isNamedType)(newType) && oldType.name === newType.name || // moving from nullable to non-null of the same underlying type is safe
  56685. (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)
  56686. );
  56687. } else if ((0, _definition.isListType)(oldType)) {
  56688. return (// if they're both lists, make sure the underlying types are compatible
  56689. (0, _definition.isListType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) || // moving from nullable to non-null of the same underlying type is safe
  56690. (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)
  56691. );
  56692. } else if ((0, _definition.isNonNullType)(oldType)) {
  56693. // if they're both non-null, make sure the underlying types are compatible
  56694. return (0, _definition.isNonNullType)(newType) && isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType);
  56695. }
  56696. return false;
  56697. }
  56698. function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) {
  56699. if ((0, _definition.isNamedType)(oldType)) {
  56700. // if they're both named types, see if their names are equivalent
  56701. return (0, _definition.isNamedType)(newType) && oldType.name === newType.name;
  56702. } else if ((0, _definition.isListType)(oldType)) {
  56703. // if they're both lists, make sure the underlying types are compatible
  56704. return (0, _definition.isListType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType);
  56705. } else if ((0, _definition.isNonNullType)(oldType)) {
  56706. return (// if they're both non-null, make sure the underlying types are
  56707. // compatible
  56708. (0, _definition.isNonNullType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) || // moving from non-null to nullable of the same underlying type is safe
  56709. !(0, _definition.isNonNullType)(newType) && isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)
  56710. );
  56711. }
  56712. return false;
  56713. }
  56714. /**
  56715. * Given two schemas, returns an Array containing descriptions of any breaking
  56716. * changes in the newSchema related to removing types from a union type.
  56717. */
  56718. function findTypesRemovedFromUnions(oldSchema, newSchema) {
  56719. var oldTypeMap = oldSchema.getTypeMap();
  56720. var newTypeMap = newSchema.getTypeMap();
  56721. var typesRemovedFromUnion = [];
  56722. var _arr10 = Object.keys(oldTypeMap);
  56723. for (var _i10 = 0; _i10 < _arr10.length; _i10++) {
  56724. var typeName = _arr10[_i10];
  56725. var oldType = oldTypeMap[typeName];
  56726. var newType = newTypeMap[typeName];
  56727. if (!(0, _definition.isUnionType)(oldType) || !(0, _definition.isUnionType)(newType)) {
  56728. continue;
  56729. }
  56730. var typeNamesInNewUnion = Object.create(null);
  56731. var _iteratorNormalCompletion3 = true;
  56732. var _didIteratorError3 = false;
  56733. var _iteratorError3 = undefined;
  56734. try {
  56735. for (var _iterator3 = newType.getTypes()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  56736. var type = _step3.value;
  56737. typeNamesInNewUnion[type.name] = true;
  56738. }
  56739. } catch (err) {
  56740. _didIteratorError3 = true;
  56741. _iteratorError3 = err;
  56742. } finally {
  56743. try {
  56744. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  56745. _iterator3.return();
  56746. }
  56747. } finally {
  56748. if (_didIteratorError3) {
  56749. throw _iteratorError3;
  56750. }
  56751. }
  56752. }
  56753. var _iteratorNormalCompletion4 = true;
  56754. var _didIteratorError4 = false;
  56755. var _iteratorError4 = undefined;
  56756. try {
  56757. for (var _iterator4 = oldType.getTypes()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  56758. var _type = _step4.value;
  56759. if (!typeNamesInNewUnion[_type.name]) {
  56760. typesRemovedFromUnion.push({
  56761. type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,
  56762. description: "".concat(_type.name, " was removed from union type ").concat(typeName, ".")
  56763. });
  56764. }
  56765. }
  56766. } catch (err) {
  56767. _didIteratorError4 = true;
  56768. _iteratorError4 = err;
  56769. } finally {
  56770. try {
  56771. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  56772. _iterator4.return();
  56773. }
  56774. } finally {
  56775. if (_didIteratorError4) {
  56776. throw _iteratorError4;
  56777. }
  56778. }
  56779. }
  56780. }
  56781. return typesRemovedFromUnion;
  56782. }
  56783. /**
  56784. * Given two schemas, returns an Array containing descriptions of any dangerous
  56785. * changes in the newSchema related to adding types to a union type.
  56786. */
  56787. function findTypesAddedToUnions(oldSchema, newSchema) {
  56788. var oldTypeMap = oldSchema.getTypeMap();
  56789. var newTypeMap = newSchema.getTypeMap();
  56790. var typesAddedToUnion = [];
  56791. var _arr11 = Object.keys(newTypeMap);
  56792. for (var _i11 = 0; _i11 < _arr11.length; _i11++) {
  56793. var typeName = _arr11[_i11];
  56794. var oldType = oldTypeMap[typeName];
  56795. var newType = newTypeMap[typeName];
  56796. if (!(0, _definition.isUnionType)(oldType) || !(0, _definition.isUnionType)(newType)) {
  56797. continue;
  56798. }
  56799. var typeNamesInOldUnion = Object.create(null);
  56800. var _iteratorNormalCompletion5 = true;
  56801. var _didIteratorError5 = false;
  56802. var _iteratorError5 = undefined;
  56803. try {
  56804. for (var _iterator5 = oldType.getTypes()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  56805. var type = _step5.value;
  56806. typeNamesInOldUnion[type.name] = true;
  56807. }
  56808. } catch (err) {
  56809. _didIteratorError5 = true;
  56810. _iteratorError5 = err;
  56811. } finally {
  56812. try {
  56813. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  56814. _iterator5.return();
  56815. }
  56816. } finally {
  56817. if (_didIteratorError5) {
  56818. throw _iteratorError5;
  56819. }
  56820. }
  56821. }
  56822. var _iteratorNormalCompletion6 = true;
  56823. var _didIteratorError6 = false;
  56824. var _iteratorError6 = undefined;
  56825. try {
  56826. for (var _iterator6 = newType.getTypes()[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  56827. var _type2 = _step6.value;
  56828. if (!typeNamesInOldUnion[_type2.name]) {
  56829. typesAddedToUnion.push({
  56830. type: DangerousChangeType.TYPE_ADDED_TO_UNION,
  56831. description: "".concat(_type2.name, " was added to union type ").concat(typeName, ".")
  56832. });
  56833. }
  56834. }
  56835. } catch (err) {
  56836. _didIteratorError6 = true;
  56837. _iteratorError6 = err;
  56838. } finally {
  56839. try {
  56840. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  56841. _iterator6.return();
  56842. }
  56843. } finally {
  56844. if (_didIteratorError6) {
  56845. throw _iteratorError6;
  56846. }
  56847. }
  56848. }
  56849. }
  56850. return typesAddedToUnion;
  56851. }
  56852. /**
  56853. * Given two schemas, returns an Array containing descriptions of any breaking
  56854. * changes in the newSchema related to removing values from an enum type.
  56855. */
  56856. function findValuesRemovedFromEnums(oldSchema, newSchema) {
  56857. var oldTypeMap = oldSchema.getTypeMap();
  56858. var newTypeMap = newSchema.getTypeMap();
  56859. var valuesRemovedFromEnums = [];
  56860. var _arr12 = Object.keys(oldTypeMap);
  56861. for (var _i12 = 0; _i12 < _arr12.length; _i12++) {
  56862. var typeName = _arr12[_i12];
  56863. var oldType = oldTypeMap[typeName];
  56864. var newType = newTypeMap[typeName];
  56865. if (!(0, _definition.isEnumType)(oldType) || !(0, _definition.isEnumType)(newType)) {
  56866. continue;
  56867. }
  56868. var valuesInNewEnum = Object.create(null);
  56869. var _iteratorNormalCompletion7 = true;
  56870. var _didIteratorError7 = false;
  56871. var _iteratorError7 = undefined;
  56872. try {
  56873. for (var _iterator7 = newType.getValues()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  56874. var value = _step7.value;
  56875. valuesInNewEnum[value.name] = true;
  56876. }
  56877. } catch (err) {
  56878. _didIteratorError7 = true;
  56879. _iteratorError7 = err;
  56880. } finally {
  56881. try {
  56882. if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
  56883. _iterator7.return();
  56884. }
  56885. } finally {
  56886. if (_didIteratorError7) {
  56887. throw _iteratorError7;
  56888. }
  56889. }
  56890. }
  56891. var _iteratorNormalCompletion8 = true;
  56892. var _didIteratorError8 = false;
  56893. var _iteratorError8 = undefined;
  56894. try {
  56895. for (var _iterator8 = oldType.getValues()[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  56896. var _value = _step8.value;
  56897. if (!valuesInNewEnum[_value.name]) {
  56898. valuesRemovedFromEnums.push({
  56899. type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,
  56900. description: "".concat(_value.name, " was removed from enum type ").concat(typeName, ".")
  56901. });
  56902. }
  56903. }
  56904. } catch (err) {
  56905. _didIteratorError8 = true;
  56906. _iteratorError8 = err;
  56907. } finally {
  56908. try {
  56909. if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
  56910. _iterator8.return();
  56911. }
  56912. } finally {
  56913. if (_didIteratorError8) {
  56914. throw _iteratorError8;
  56915. }
  56916. }
  56917. }
  56918. }
  56919. return valuesRemovedFromEnums;
  56920. }
  56921. /**
  56922. * Given two schemas, returns an Array containing descriptions of any dangerous
  56923. * changes in the newSchema related to adding values to an enum type.
  56924. */
  56925. function findValuesAddedToEnums(oldSchema, newSchema) {
  56926. var oldTypeMap = oldSchema.getTypeMap();
  56927. var newTypeMap = newSchema.getTypeMap();
  56928. var valuesAddedToEnums = [];
  56929. var _arr13 = Object.keys(oldTypeMap);
  56930. for (var _i13 = 0; _i13 < _arr13.length; _i13++) {
  56931. var typeName = _arr13[_i13];
  56932. var oldType = oldTypeMap[typeName];
  56933. var newType = newTypeMap[typeName];
  56934. if (!(0, _definition.isEnumType)(oldType) || !(0, _definition.isEnumType)(newType)) {
  56935. continue;
  56936. }
  56937. var valuesInOldEnum = Object.create(null);
  56938. var _iteratorNormalCompletion9 = true;
  56939. var _didIteratorError9 = false;
  56940. var _iteratorError9 = undefined;
  56941. try {
  56942. for (var _iterator9 = oldType.getValues()[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  56943. var value = _step9.value;
  56944. valuesInOldEnum[value.name] = true;
  56945. }
  56946. } catch (err) {
  56947. _didIteratorError9 = true;
  56948. _iteratorError9 = err;
  56949. } finally {
  56950. try {
  56951. if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
  56952. _iterator9.return();
  56953. }
  56954. } finally {
  56955. if (_didIteratorError9) {
  56956. throw _iteratorError9;
  56957. }
  56958. }
  56959. }
  56960. var _iteratorNormalCompletion10 = true;
  56961. var _didIteratorError10 = false;
  56962. var _iteratorError10 = undefined;
  56963. try {
  56964. for (var _iterator10 = newType.getValues()[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  56965. var _value2 = _step10.value;
  56966. if (!valuesInOldEnum[_value2.name]) {
  56967. valuesAddedToEnums.push({
  56968. type: DangerousChangeType.VALUE_ADDED_TO_ENUM,
  56969. description: "".concat(_value2.name, " was added to enum type ").concat(typeName, ".")
  56970. });
  56971. }
  56972. }
  56973. } catch (err) {
  56974. _didIteratorError10 = true;
  56975. _iteratorError10 = err;
  56976. } finally {
  56977. try {
  56978. if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
  56979. _iterator10.return();
  56980. }
  56981. } finally {
  56982. if (_didIteratorError10) {
  56983. throw _iteratorError10;
  56984. }
  56985. }
  56986. }
  56987. }
  56988. return valuesAddedToEnums;
  56989. }
  56990. function findInterfacesRemovedFromObjectTypes(oldSchema, newSchema) {
  56991. var oldTypeMap = oldSchema.getTypeMap();
  56992. var newTypeMap = newSchema.getTypeMap();
  56993. var breakingChanges = [];
  56994. var _arr14 = Object.keys(oldTypeMap);
  56995. for (var _i14 = 0; _i14 < _arr14.length; _i14++) {
  56996. var typeName = _arr14[_i14];
  56997. var oldType = oldTypeMap[typeName];
  56998. var newType = newTypeMap[typeName];
  56999. if (!(0, _definition.isObjectType)(oldType) || !(0, _definition.isObjectType)(newType)) {
  57000. continue;
  57001. }
  57002. var oldInterfaces = oldType.getInterfaces();
  57003. var newInterfaces = newType.getInterfaces();
  57004. var _iteratorNormalCompletion11 = true;
  57005. var _didIteratorError11 = false;
  57006. var _iteratorError11 = undefined;
  57007. try {
  57008. var _loop3 = function _loop3() {
  57009. var oldInterface = _step11.value;
  57010. if (!newInterfaces.some(function (int) {
  57011. return int.name === oldInterface.name;
  57012. })) {
  57013. breakingChanges.push({
  57014. type: BreakingChangeType.INTERFACE_REMOVED_FROM_OBJECT,
  57015. description: "".concat(typeName, " no longer implements interface ") + "".concat(oldInterface.name, ".")
  57016. });
  57017. }
  57018. };
  57019. for (var _iterator11 = oldInterfaces[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  57020. _loop3();
  57021. }
  57022. } catch (err) {
  57023. _didIteratorError11 = true;
  57024. _iteratorError11 = err;
  57025. } finally {
  57026. try {
  57027. if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
  57028. _iterator11.return();
  57029. }
  57030. } finally {
  57031. if (_didIteratorError11) {
  57032. throw _iteratorError11;
  57033. }
  57034. }
  57035. }
  57036. }
  57037. return breakingChanges;
  57038. }
  57039. function findInterfacesAddedToObjectTypes(oldSchema, newSchema) {
  57040. var oldTypeMap = oldSchema.getTypeMap();
  57041. var newTypeMap = newSchema.getTypeMap();
  57042. var interfacesAddedToObjectTypes = [];
  57043. var _arr15 = Object.keys(newTypeMap);
  57044. for (var _i15 = 0; _i15 < _arr15.length; _i15++) {
  57045. var typeName = _arr15[_i15];
  57046. var oldType = oldTypeMap[typeName];
  57047. var newType = newTypeMap[typeName];
  57048. if (!(0, _definition.isObjectType)(oldType) || !(0, _definition.isObjectType)(newType)) {
  57049. continue;
  57050. }
  57051. var oldInterfaces = oldType.getInterfaces();
  57052. var newInterfaces = newType.getInterfaces();
  57053. var _iteratorNormalCompletion12 = true;
  57054. var _didIteratorError12 = false;
  57055. var _iteratorError12 = undefined;
  57056. try {
  57057. var _loop4 = function _loop4() {
  57058. var newInterface = _step12.value;
  57059. if (!oldInterfaces.some(function (int) {
  57060. return int.name === newInterface.name;
  57061. })) {
  57062. interfacesAddedToObjectTypes.push({
  57063. type: DangerousChangeType.INTERFACE_ADDED_TO_OBJECT,
  57064. description: "".concat(newInterface.name, " added to interfaces implemented ") + "by ".concat(typeName, ".")
  57065. });
  57066. }
  57067. };
  57068. for (var _iterator12 = newInterfaces[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  57069. _loop4();
  57070. }
  57071. } catch (err) {
  57072. _didIteratorError12 = true;
  57073. _iteratorError12 = err;
  57074. } finally {
  57075. try {
  57076. if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
  57077. _iterator12.return();
  57078. }
  57079. } finally {
  57080. if (_didIteratorError12) {
  57081. throw _iteratorError12;
  57082. }
  57083. }
  57084. }
  57085. }
  57086. return interfacesAddedToObjectTypes;
  57087. }
  57088. function findRemovedDirectives(oldSchema, newSchema) {
  57089. var removedDirectives = [];
  57090. var newSchemaDirectiveMap = getDirectiveMapForSchema(newSchema);
  57091. var _iteratorNormalCompletion13 = true;
  57092. var _didIteratorError13 = false;
  57093. var _iteratorError13 = undefined;
  57094. try {
  57095. for (var _iterator13 = oldSchema.getDirectives()[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  57096. var directive = _step13.value;
  57097. if (!newSchemaDirectiveMap[directive.name]) {
  57098. removedDirectives.push({
  57099. type: BreakingChangeType.DIRECTIVE_REMOVED,
  57100. description: "".concat(directive.name, " was removed")
  57101. });
  57102. }
  57103. }
  57104. } catch (err) {
  57105. _didIteratorError13 = true;
  57106. _iteratorError13 = err;
  57107. } finally {
  57108. try {
  57109. if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
  57110. _iterator13.return();
  57111. }
  57112. } finally {
  57113. if (_didIteratorError13) {
  57114. throw _iteratorError13;
  57115. }
  57116. }
  57117. }
  57118. return removedDirectives;
  57119. }
  57120. function findRemovedArgsForDirective(oldDirective, newDirective) {
  57121. var removedArgs = [];
  57122. var newArgMap = getArgumentMapForDirective(newDirective);
  57123. var _iteratorNormalCompletion14 = true;
  57124. var _didIteratorError14 = false;
  57125. var _iteratorError14 = undefined;
  57126. try {
  57127. for (var _iterator14 = oldDirective.args[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  57128. var arg = _step14.value;
  57129. if (!newArgMap[arg.name]) {
  57130. removedArgs.push(arg);
  57131. }
  57132. }
  57133. } catch (err) {
  57134. _didIteratorError14 = true;
  57135. _iteratorError14 = err;
  57136. } finally {
  57137. try {
  57138. if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
  57139. _iterator14.return();
  57140. }
  57141. } finally {
  57142. if (_didIteratorError14) {
  57143. throw _iteratorError14;
  57144. }
  57145. }
  57146. }
  57147. return removedArgs;
  57148. }
  57149. function findRemovedDirectiveArgs(oldSchema, newSchema) {
  57150. var removedDirectiveArgs = [];
  57151. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  57152. var _iteratorNormalCompletion15 = true;
  57153. var _didIteratorError15 = false;
  57154. var _iteratorError15 = undefined;
  57155. try {
  57156. for (var _iterator15 = newSchema.getDirectives()[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
  57157. var newDirective = _step15.value;
  57158. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  57159. if (!oldDirective) {
  57160. continue;
  57161. }
  57162. var _iteratorNormalCompletion16 = true;
  57163. var _didIteratorError16 = false;
  57164. var _iteratorError16 = undefined;
  57165. try {
  57166. for (var _iterator16 = findRemovedArgsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
  57167. var arg = _step16.value;
  57168. removedDirectiveArgs.push({
  57169. type: BreakingChangeType.DIRECTIVE_ARG_REMOVED,
  57170. description: "".concat(arg.name, " was removed from ").concat(newDirective.name)
  57171. });
  57172. }
  57173. } catch (err) {
  57174. _didIteratorError16 = true;
  57175. _iteratorError16 = err;
  57176. } finally {
  57177. try {
  57178. if (!_iteratorNormalCompletion16 && _iterator16.return != null) {
  57179. _iterator16.return();
  57180. }
  57181. } finally {
  57182. if (_didIteratorError16) {
  57183. throw _iteratorError16;
  57184. }
  57185. }
  57186. }
  57187. }
  57188. } catch (err) {
  57189. _didIteratorError15 = true;
  57190. _iteratorError15 = err;
  57191. } finally {
  57192. try {
  57193. if (!_iteratorNormalCompletion15 && _iterator15.return != null) {
  57194. _iterator15.return();
  57195. }
  57196. } finally {
  57197. if (_didIteratorError15) {
  57198. throw _iteratorError15;
  57199. }
  57200. }
  57201. }
  57202. return removedDirectiveArgs;
  57203. }
  57204. function findAddedArgsForDirective(oldDirective, newDirective) {
  57205. var addedArgs = [];
  57206. var oldArgMap = getArgumentMapForDirective(oldDirective);
  57207. var _iteratorNormalCompletion17 = true;
  57208. var _didIteratorError17 = false;
  57209. var _iteratorError17 = undefined;
  57210. try {
  57211. for (var _iterator17 = newDirective.args[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
  57212. var arg = _step17.value;
  57213. if (!oldArgMap[arg.name]) {
  57214. addedArgs.push(arg);
  57215. }
  57216. }
  57217. } catch (err) {
  57218. _didIteratorError17 = true;
  57219. _iteratorError17 = err;
  57220. } finally {
  57221. try {
  57222. if (!_iteratorNormalCompletion17 && _iterator17.return != null) {
  57223. _iterator17.return();
  57224. }
  57225. } finally {
  57226. if (_didIteratorError17) {
  57227. throw _iteratorError17;
  57228. }
  57229. }
  57230. }
  57231. return addedArgs;
  57232. }
  57233. function findAddedNonNullDirectiveArgs(oldSchema, newSchema) {
  57234. var addedNonNullableArgs = [];
  57235. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  57236. var _iteratorNormalCompletion18 = true;
  57237. var _didIteratorError18 = false;
  57238. var _iteratorError18 = undefined;
  57239. try {
  57240. for (var _iterator18 = newSchema.getDirectives()[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
  57241. var newDirective = _step18.value;
  57242. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  57243. if (!oldDirective) {
  57244. continue;
  57245. }
  57246. var _iteratorNormalCompletion19 = true;
  57247. var _didIteratorError19 = false;
  57248. var _iteratorError19 = undefined;
  57249. try {
  57250. for (var _iterator19 = findAddedArgsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
  57251. var arg = _step19.value;
  57252. if ((0, _definition.isRequiredArgument)(arg)) {
  57253. addedNonNullableArgs.push({
  57254. type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED,
  57255. description: "A required arg ".concat(arg.name, " on directive ") + "".concat(newDirective.name, " was added")
  57256. });
  57257. }
  57258. }
  57259. } catch (err) {
  57260. _didIteratorError19 = true;
  57261. _iteratorError19 = err;
  57262. } finally {
  57263. try {
  57264. if (!_iteratorNormalCompletion19 && _iterator19.return != null) {
  57265. _iterator19.return();
  57266. }
  57267. } finally {
  57268. if (_didIteratorError19) {
  57269. throw _iteratorError19;
  57270. }
  57271. }
  57272. }
  57273. }
  57274. } catch (err) {
  57275. _didIteratorError18 = true;
  57276. _iteratorError18 = err;
  57277. } finally {
  57278. try {
  57279. if (!_iteratorNormalCompletion18 && _iterator18.return != null) {
  57280. _iterator18.return();
  57281. }
  57282. } finally {
  57283. if (_didIteratorError18) {
  57284. throw _iteratorError18;
  57285. }
  57286. }
  57287. }
  57288. return addedNonNullableArgs;
  57289. }
  57290. function findRemovedLocationsForDirective(oldDirective, newDirective) {
  57291. var removedLocations = [];
  57292. var newLocationSet = new Set(newDirective.locations);
  57293. var _iteratorNormalCompletion20 = true;
  57294. var _didIteratorError20 = false;
  57295. var _iteratorError20 = undefined;
  57296. try {
  57297. for (var _iterator20 = oldDirective.locations[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
  57298. var oldLocation = _step20.value;
  57299. if (!newLocationSet.has(oldLocation)) {
  57300. removedLocations.push(oldLocation);
  57301. }
  57302. }
  57303. } catch (err) {
  57304. _didIteratorError20 = true;
  57305. _iteratorError20 = err;
  57306. } finally {
  57307. try {
  57308. if (!_iteratorNormalCompletion20 && _iterator20.return != null) {
  57309. _iterator20.return();
  57310. }
  57311. } finally {
  57312. if (_didIteratorError20) {
  57313. throw _iteratorError20;
  57314. }
  57315. }
  57316. }
  57317. return removedLocations;
  57318. }
  57319. function findRemovedDirectiveLocations(oldSchema, newSchema) {
  57320. var removedLocations = [];
  57321. var oldSchemaDirectiveMap = getDirectiveMapForSchema(oldSchema);
  57322. var _iteratorNormalCompletion21 = true;
  57323. var _didIteratorError21 = false;
  57324. var _iteratorError21 = undefined;
  57325. try {
  57326. for (var _iterator21 = newSchema.getDirectives()[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
  57327. var newDirective = _step21.value;
  57328. var oldDirective = oldSchemaDirectiveMap[newDirective.name];
  57329. if (!oldDirective) {
  57330. continue;
  57331. }
  57332. var _iteratorNormalCompletion22 = true;
  57333. var _didIteratorError22 = false;
  57334. var _iteratorError22 = undefined;
  57335. try {
  57336. for (var _iterator22 = findRemovedLocationsForDirective(oldDirective, newDirective)[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
  57337. var location = _step22.value;
  57338. removedLocations.push({
  57339. type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED,
  57340. description: "".concat(location, " was removed from ").concat(newDirective.name)
  57341. });
  57342. }
  57343. } catch (err) {
  57344. _didIteratorError22 = true;
  57345. _iteratorError22 = err;
  57346. } finally {
  57347. try {
  57348. if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
  57349. _iterator22.return();
  57350. }
  57351. } finally {
  57352. if (_didIteratorError22) {
  57353. throw _iteratorError22;
  57354. }
  57355. }
  57356. }
  57357. }
  57358. } catch (err) {
  57359. _didIteratorError21 = true;
  57360. _iteratorError21 = err;
  57361. } finally {
  57362. try {
  57363. if (!_iteratorNormalCompletion21 && _iterator21.return != null) {
  57364. _iterator21.return();
  57365. }
  57366. } finally {
  57367. if (_didIteratorError21) {
  57368. throw _iteratorError21;
  57369. }
  57370. }
  57371. }
  57372. return removedLocations;
  57373. }
  57374. function getDirectiveMapForSchema(schema) {
  57375. return (0, _keyMap.default)(schema.getDirectives(), function (dir) {
  57376. return dir.name;
  57377. });
  57378. }
  57379. function getArgumentMapForDirective(directive) {
  57380. return (0, _keyMap.default)(directive.args, function (arg) {
  57381. return arg.name;
  57382. });
  57383. }
  57384. },{"../jsutils/keyMap":294,"../polyfills/find":315,"../type/definition":323}],339:[function(require,module,exports){
  57385. "use strict";
  57386. Object.defineProperty(exports, "__esModule", {
  57387. value: true
  57388. });
  57389. exports.findDeprecatedUsages = findDeprecatedUsages;
  57390. var _GraphQLError = require("../error/GraphQLError");
  57391. var _visitor = require("../language/visitor");
  57392. var _definition = require("../type/definition");
  57393. var _TypeInfo = require("./TypeInfo");
  57394. /**
  57395. * Copyright (c) 2015-present, Facebook, Inc.
  57396. *
  57397. * This source code is licensed under the MIT license found in the
  57398. * LICENSE file in the root directory of this source tree.
  57399. *
  57400. *
  57401. */
  57402. /**
  57403. * A validation rule which reports deprecated usages.
  57404. *
  57405. * Returns a list of GraphQLError instances describing each deprecated use.
  57406. */
  57407. function findDeprecatedUsages(schema, ast) {
  57408. var errors = [];
  57409. var typeInfo = new _TypeInfo.TypeInfo(schema);
  57410. (0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  57411. Field: function Field(node) {
  57412. var fieldDef = typeInfo.getFieldDef();
  57413. if (fieldDef && fieldDef.isDeprecated) {
  57414. var parentType = typeInfo.getParentType();
  57415. if (parentType) {
  57416. var reason = fieldDef.deprecationReason;
  57417. errors.push(new _GraphQLError.GraphQLError("The field ".concat(parentType.name, ".").concat(fieldDef.name, " is deprecated.") + (reason ? ' ' + reason : ''), [node]));
  57418. }
  57419. }
  57420. },
  57421. EnumValue: function EnumValue(node) {
  57422. var enumVal = typeInfo.getEnumValue();
  57423. if (enumVal && enumVal.isDeprecated) {
  57424. var type = (0, _definition.getNamedType)(typeInfo.getInputType());
  57425. if (type) {
  57426. var reason = enumVal.deprecationReason;
  57427. errors.push(new _GraphQLError.GraphQLError("The enum value ".concat(type.name, ".").concat(enumVal.name, " is deprecated.") + (reason ? ' ' + reason : ''), [node]));
  57428. }
  57429. }
  57430. }
  57431. }));
  57432. return errors;
  57433. }
  57434. },{"../error/GraphQLError":275,"../language/visitor":314,"../type/definition":323,"./TypeInfo":330}],340:[function(require,module,exports){
  57435. "use strict";
  57436. Object.defineProperty(exports, "__esModule", {
  57437. value: true
  57438. });
  57439. exports.getOperationAST = getOperationAST;
  57440. var _kinds = require("../language/kinds");
  57441. /**
  57442. * Copyright (c) 2015-present, Facebook, Inc.
  57443. *
  57444. * This source code is licensed under the MIT license found in the
  57445. * LICENSE file in the root directory of this source tree.
  57446. *
  57447. *
  57448. */
  57449. /**
  57450. * Returns an operation AST given a document AST and optionally an operation
  57451. * name. If a name is not provided, an operation is only returned if only one is
  57452. * provided in the document.
  57453. */
  57454. function getOperationAST(documentAST, operationName) {
  57455. var operation = null;
  57456. for (var i = 0; i < documentAST.definitions.length; i++) {
  57457. var definition = documentAST.definitions[i];
  57458. if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
  57459. if (!operationName) {
  57460. // If no operation name was provided, only return an Operation if there
  57461. // is one defined in the document. Upon encountering the second, return
  57462. // null.
  57463. if (operation) {
  57464. return null;
  57465. }
  57466. operation = definition;
  57467. } else if (definition.name && definition.name.value === operationName) {
  57468. return definition;
  57469. }
  57470. }
  57471. }
  57472. return operation;
  57473. }
  57474. },{"../language/kinds":307}],341:[function(require,module,exports){
  57475. "use strict";
  57476. Object.defineProperty(exports, "__esModule", {
  57477. value: true
  57478. });
  57479. exports.getOperationRootType = getOperationRootType;
  57480. var _GraphQLError = require("../error/GraphQLError");
  57481. /**
  57482. * Copyright (c) 2015-present, Facebook, Inc.
  57483. *
  57484. * This source code is licensed under the MIT license found in the
  57485. * LICENSE file in the root directory of this source tree.
  57486. *
  57487. *
  57488. */
  57489. /**
  57490. * Extracts the root type of the operation from the schema.
  57491. */
  57492. function getOperationRootType(schema, operation) {
  57493. switch (operation.operation) {
  57494. case 'query':
  57495. var queryType = schema.getQueryType();
  57496. if (!queryType) {
  57497. throw new _GraphQLError.GraphQLError('Schema does not define the required query root type.', [operation]);
  57498. }
  57499. return queryType;
  57500. case 'mutation':
  57501. var mutationType = schema.getMutationType();
  57502. if (!mutationType) {
  57503. throw new _GraphQLError.GraphQLError('Schema is not configured for mutations.', [operation]);
  57504. }
  57505. return mutationType;
  57506. case 'subscription':
  57507. var subscriptionType = schema.getSubscriptionType();
  57508. if (!subscriptionType) {
  57509. throw new _GraphQLError.GraphQLError('Schema is not configured for subscriptions.', [operation]);
  57510. }
  57511. return subscriptionType;
  57512. default:
  57513. throw new _GraphQLError.GraphQLError('Can only have query, mutation and subscription operations.', [operation]);
  57514. }
  57515. }
  57516. },{"../error/GraphQLError":275}],342:[function(require,module,exports){
  57517. "use strict";
  57518. Object.defineProperty(exports, "__esModule", {
  57519. value: true
  57520. });
  57521. Object.defineProperty(exports, "getIntrospectionQuery", {
  57522. enumerable: true,
  57523. get: function get() {
  57524. return _introspectionQuery.getIntrospectionQuery;
  57525. }
  57526. });
  57527. Object.defineProperty(exports, "introspectionQuery", {
  57528. enumerable: true,
  57529. get: function get() {
  57530. return _introspectionQuery.introspectionQuery;
  57531. }
  57532. });
  57533. Object.defineProperty(exports, "getOperationAST", {
  57534. enumerable: true,
  57535. get: function get() {
  57536. return _getOperationAST.getOperationAST;
  57537. }
  57538. });
  57539. Object.defineProperty(exports, "getOperationRootType", {
  57540. enumerable: true,
  57541. get: function get() {
  57542. return _getOperationRootType.getOperationRootType;
  57543. }
  57544. });
  57545. Object.defineProperty(exports, "introspectionFromSchema", {
  57546. enumerable: true,
  57547. get: function get() {
  57548. return _introspectionFromSchema.introspectionFromSchema;
  57549. }
  57550. });
  57551. Object.defineProperty(exports, "buildClientSchema", {
  57552. enumerable: true,
  57553. get: function get() {
  57554. return _buildClientSchema.buildClientSchema;
  57555. }
  57556. });
  57557. Object.defineProperty(exports, "buildASTSchema", {
  57558. enumerable: true,
  57559. get: function get() {
  57560. return _buildASTSchema.buildASTSchema;
  57561. }
  57562. });
  57563. Object.defineProperty(exports, "buildSchema", {
  57564. enumerable: true,
  57565. get: function get() {
  57566. return _buildASTSchema.buildSchema;
  57567. }
  57568. });
  57569. Object.defineProperty(exports, "getDescription", {
  57570. enumerable: true,
  57571. get: function get() {
  57572. return _buildASTSchema.getDescription;
  57573. }
  57574. });
  57575. Object.defineProperty(exports, "extendSchema", {
  57576. enumerable: true,
  57577. get: function get() {
  57578. return _extendSchema.extendSchema;
  57579. }
  57580. });
  57581. Object.defineProperty(exports, "lexicographicSortSchema", {
  57582. enumerable: true,
  57583. get: function get() {
  57584. return _lexicographicSortSchema.lexicographicSortSchema;
  57585. }
  57586. });
  57587. Object.defineProperty(exports, "printSchema", {
  57588. enumerable: true,
  57589. get: function get() {
  57590. return _schemaPrinter.printSchema;
  57591. }
  57592. });
  57593. Object.defineProperty(exports, "printType", {
  57594. enumerable: true,
  57595. get: function get() {
  57596. return _schemaPrinter.printType;
  57597. }
  57598. });
  57599. Object.defineProperty(exports, "printIntrospectionSchema", {
  57600. enumerable: true,
  57601. get: function get() {
  57602. return _schemaPrinter.printIntrospectionSchema;
  57603. }
  57604. });
  57605. Object.defineProperty(exports, "typeFromAST", {
  57606. enumerable: true,
  57607. get: function get() {
  57608. return _typeFromAST.typeFromAST;
  57609. }
  57610. });
  57611. Object.defineProperty(exports, "valueFromAST", {
  57612. enumerable: true,
  57613. get: function get() {
  57614. return _valueFromAST.valueFromAST;
  57615. }
  57616. });
  57617. Object.defineProperty(exports, "valueFromASTUntyped", {
  57618. enumerable: true,
  57619. get: function get() {
  57620. return _valueFromASTUntyped.valueFromASTUntyped;
  57621. }
  57622. });
  57623. Object.defineProperty(exports, "astFromValue", {
  57624. enumerable: true,
  57625. get: function get() {
  57626. return _astFromValue.astFromValue;
  57627. }
  57628. });
  57629. Object.defineProperty(exports, "TypeInfo", {
  57630. enumerable: true,
  57631. get: function get() {
  57632. return _TypeInfo.TypeInfo;
  57633. }
  57634. });
  57635. Object.defineProperty(exports, "coerceValue", {
  57636. enumerable: true,
  57637. get: function get() {
  57638. return _coerceValue.coerceValue;
  57639. }
  57640. });
  57641. Object.defineProperty(exports, "isValidJSValue", {
  57642. enumerable: true,
  57643. get: function get() {
  57644. return _isValidJSValue.isValidJSValue;
  57645. }
  57646. });
  57647. Object.defineProperty(exports, "isValidLiteralValue", {
  57648. enumerable: true,
  57649. get: function get() {
  57650. return _isValidLiteralValue.isValidLiteralValue;
  57651. }
  57652. });
  57653. Object.defineProperty(exports, "concatAST", {
  57654. enumerable: true,
  57655. get: function get() {
  57656. return _concatAST.concatAST;
  57657. }
  57658. });
  57659. Object.defineProperty(exports, "separateOperations", {
  57660. enumerable: true,
  57661. get: function get() {
  57662. return _separateOperations.separateOperations;
  57663. }
  57664. });
  57665. Object.defineProperty(exports, "isEqualType", {
  57666. enumerable: true,
  57667. get: function get() {
  57668. return _typeComparators.isEqualType;
  57669. }
  57670. });
  57671. Object.defineProperty(exports, "isTypeSubTypeOf", {
  57672. enumerable: true,
  57673. get: function get() {
  57674. return _typeComparators.isTypeSubTypeOf;
  57675. }
  57676. });
  57677. Object.defineProperty(exports, "doTypesOverlap", {
  57678. enumerable: true,
  57679. get: function get() {
  57680. return _typeComparators.doTypesOverlap;
  57681. }
  57682. });
  57683. Object.defineProperty(exports, "assertValidName", {
  57684. enumerable: true,
  57685. get: function get() {
  57686. return _assertValidName.assertValidName;
  57687. }
  57688. });
  57689. Object.defineProperty(exports, "isValidNameError", {
  57690. enumerable: true,
  57691. get: function get() {
  57692. return _assertValidName.isValidNameError;
  57693. }
  57694. });
  57695. Object.defineProperty(exports, "BreakingChangeType", {
  57696. enumerable: true,
  57697. get: function get() {
  57698. return _findBreakingChanges.BreakingChangeType;
  57699. }
  57700. });
  57701. Object.defineProperty(exports, "DangerousChangeType", {
  57702. enumerable: true,
  57703. get: function get() {
  57704. return _findBreakingChanges.DangerousChangeType;
  57705. }
  57706. });
  57707. Object.defineProperty(exports, "findBreakingChanges", {
  57708. enumerable: true,
  57709. get: function get() {
  57710. return _findBreakingChanges.findBreakingChanges;
  57711. }
  57712. });
  57713. Object.defineProperty(exports, "findDangerousChanges", {
  57714. enumerable: true,
  57715. get: function get() {
  57716. return _findBreakingChanges.findDangerousChanges;
  57717. }
  57718. });
  57719. Object.defineProperty(exports, "findDeprecatedUsages", {
  57720. enumerable: true,
  57721. get: function get() {
  57722. return _findDeprecatedUsages.findDeprecatedUsages;
  57723. }
  57724. });
  57725. var _introspectionQuery = require("./introspectionQuery");
  57726. var _getOperationAST = require("./getOperationAST");
  57727. var _getOperationRootType = require("./getOperationRootType");
  57728. var _introspectionFromSchema = require("./introspectionFromSchema");
  57729. var _buildClientSchema = require("./buildClientSchema");
  57730. var _buildASTSchema = require("./buildASTSchema");
  57731. var _extendSchema = require("./extendSchema");
  57732. var _lexicographicSortSchema = require("./lexicographicSortSchema");
  57733. var _schemaPrinter = require("./schemaPrinter");
  57734. var _typeFromAST = require("./typeFromAST");
  57735. var _valueFromAST = require("./valueFromAST");
  57736. var _valueFromASTUntyped = require("./valueFromASTUntyped");
  57737. var _astFromValue = require("./astFromValue");
  57738. var _TypeInfo = require("./TypeInfo");
  57739. var _coerceValue = require("./coerceValue");
  57740. var _isValidJSValue = require("./isValidJSValue");
  57741. var _isValidLiteralValue = require("./isValidLiteralValue");
  57742. var _concatAST = require("./concatAST");
  57743. var _separateOperations = require("./separateOperations");
  57744. var _typeComparators = require("./typeComparators");
  57745. var _assertValidName = require("./assertValidName");
  57746. var _findBreakingChanges = require("./findBreakingChanges");
  57747. var _findDeprecatedUsages = require("./findDeprecatedUsages");
  57748. },{"./TypeInfo":330,"./assertValidName":331,"./astFromValue":332,"./buildASTSchema":333,"./buildClientSchema":334,"./coerceValue":335,"./concatAST":336,"./extendSchema":337,"./findBreakingChanges":338,"./findDeprecatedUsages":339,"./getOperationAST":340,"./getOperationRootType":341,"./introspectionFromSchema":343,"./introspectionQuery":344,"./isValidJSValue":345,"./isValidLiteralValue":346,"./lexicographicSortSchema":347,"./schemaPrinter":348,"./separateOperations":349,"./typeComparators":350,"./typeFromAST":351,"./valueFromAST":352,"./valueFromASTUntyped":353}],343:[function(require,module,exports){
  57749. "use strict";
  57750. Object.defineProperty(exports, "__esModule", {
  57751. value: true
  57752. });
  57753. exports.introspectionFromSchema = introspectionFromSchema;
  57754. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  57755. var _introspectionQuery = require("./introspectionQuery");
  57756. var _execute = require("../execution/execute");
  57757. var _parser = require("../language/parser");
  57758. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  57759. /**
  57760. * Copyright (c) 2015-present, Facebook, Inc.
  57761. *
  57762. * This source code is licensed under the MIT license found in the
  57763. * LICENSE file in the root directory of this source tree.
  57764. *
  57765. *
  57766. */
  57767. /**
  57768. * Build an IntrospectionQuery from a GraphQLSchema
  57769. *
  57770. * IntrospectionQuery is useful for utilities that care about type and field
  57771. * relationships, but do not need to traverse through those relationships.
  57772. *
  57773. * This is the inverse of buildClientSchema. The primary use case is outside
  57774. * of the server context, for instance when doing schema comparisons.
  57775. */
  57776. function introspectionFromSchema(schema, options) {
  57777. var queryAST = (0, _parser.parse)((0, _introspectionQuery.getIntrospectionQuery)(options));
  57778. var result = (0, _execute.execute)(schema, queryAST);
  57779. !(!result.then && !result.errors && result.data) ? (0, _invariant.default)(0) : void 0;
  57780. return result.data;
  57781. }
  57782. },{"../execution/execute":281,"../jsutils/invariant":290,"../language/parser":310,"./introspectionQuery":344}],344:[function(require,module,exports){
  57783. "use strict";
  57784. Object.defineProperty(exports, "__esModule", {
  57785. value: true
  57786. });
  57787. exports.getIntrospectionQuery = getIntrospectionQuery;
  57788. exports.introspectionQuery = void 0;
  57789. /**
  57790. * Copyright (c) 2015-present, Facebook, Inc.
  57791. *
  57792. * This source code is licensed under the MIT license found in the
  57793. * LICENSE file in the root directory of this source tree.
  57794. *
  57795. *
  57796. */
  57797. function getIntrospectionQuery(options) {
  57798. var descriptions = !(options && options.descriptions === false);
  57799. return "\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n ".concat(descriptions ? 'description' : '', "\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n ").concat(descriptions ? 'description' : '', "\n fields(includeDeprecated: true) {\n name\n ").concat(descriptions ? 'description' : '', "\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n ").concat(descriptions ? 'description' : '', "\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n ").concat(descriptions ? 'description' : '', "\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n ");
  57800. }
  57801. /**
  57802. * Deprecated, call getIntrospectionQuery directly.
  57803. *
  57804. * This function will be removed in v15
  57805. */
  57806. var introspectionQuery = getIntrospectionQuery();
  57807. exports.introspectionQuery = introspectionQuery;
  57808. },{}],345:[function(require,module,exports){
  57809. "use strict";
  57810. Object.defineProperty(exports, "__esModule", {
  57811. value: true
  57812. });
  57813. exports.isValidJSValue = isValidJSValue;
  57814. var _coerceValue = require("./coerceValue");
  57815. /**
  57816. * Copyright (c) 2015-present, Facebook, Inc.
  57817. *
  57818. * This source code is licensed under the MIT license found in the
  57819. * LICENSE file in the root directory of this source tree.
  57820. *
  57821. *
  57822. */
  57823. /**
  57824. * Deprecated. Use coerceValue() directly for richer information.
  57825. *
  57826. * This function will be removed in v15
  57827. */
  57828. function isValidJSValue(value, type) {
  57829. var errors = (0, _coerceValue.coerceValue)(value, type).errors;
  57830. return errors ? errors.map(function (error) {
  57831. return error.message;
  57832. }) : [];
  57833. }
  57834. },{"./coerceValue":335}],346:[function(require,module,exports){
  57835. "use strict";
  57836. Object.defineProperty(exports, "__esModule", {
  57837. value: true
  57838. });
  57839. exports.isValidLiteralValue = isValidLiteralValue;
  57840. var _TypeInfo = require("./TypeInfo");
  57841. var _kinds = require("../language/kinds");
  57842. var _visitor = require("../language/visitor");
  57843. var _schema = require("../type/schema");
  57844. var _ValuesOfCorrectType = require("../validation/rules/ValuesOfCorrectType");
  57845. var _ValidationContext = require("../validation/ValidationContext");
  57846. /**
  57847. * Copyright (c) 2015-present, Facebook, Inc.
  57848. *
  57849. * This source code is licensed under the MIT license found in the
  57850. * LICENSE file in the root directory of this source tree.
  57851. *
  57852. *
  57853. */
  57854. /**
  57855. * Utility which determines if a value literal node is valid for an input type.
  57856. *
  57857. * Deprecated. Rely on validation for documents containing literal values.
  57858. *
  57859. * This function will be removed in v15
  57860. */
  57861. function isValidLiteralValue(type, valueNode) {
  57862. var emptySchema = new _schema.GraphQLSchema({});
  57863. var emptyDoc = {
  57864. kind: _kinds.Kind.DOCUMENT,
  57865. definitions: []
  57866. };
  57867. var typeInfo = new _TypeInfo.TypeInfo(emptySchema, undefined, type);
  57868. var context = new _ValidationContext.ValidationContext(emptySchema, emptyDoc, typeInfo);
  57869. var visitor = (0, _ValuesOfCorrectType.ValuesOfCorrectType)(context);
  57870. (0, _visitor.visit)(valueNode, (0, _visitor.visitWithTypeInfo)(typeInfo, visitor));
  57871. return context.getErrors();
  57872. }
  57873. },{"../language/kinds":307,"../language/visitor":314,"../type/schema":328,"../validation/ValidationContext":354,"../validation/rules/ValuesOfCorrectType":386,"./TypeInfo":330}],347:[function(require,module,exports){
  57874. "use strict";
  57875. Object.defineProperty(exports, "__esModule", {
  57876. value: true
  57877. });
  57878. exports.lexicographicSortSchema = lexicographicSortSchema;
  57879. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  57880. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  57881. var _schema = require("../type/schema");
  57882. var _directives = require("../type/directives");
  57883. var _definition = require("../type/definition");
  57884. var _scalars = require("../type/scalars");
  57885. var _introspection = require("../type/introspection");
  57886. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  57887. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  57888. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  57889. /**
  57890. * Sort GraphQLSchema.
  57891. */
  57892. function lexicographicSortSchema(schema) {
  57893. var cache = Object.create(null);
  57894. var sortMaybeType = function sortMaybeType(maybeType) {
  57895. return maybeType && sortNamedType(maybeType);
  57896. };
  57897. return new _schema.GraphQLSchema({
  57898. types: sortTypes((0, _objectValues.default)(schema.getTypeMap())),
  57899. directives: sortByName(schema.getDirectives()).map(sortDirective),
  57900. query: sortMaybeType(schema.getQueryType()),
  57901. mutation: sortMaybeType(schema.getMutationType()),
  57902. subscription: sortMaybeType(schema.getSubscriptionType()),
  57903. astNode: schema.astNode
  57904. });
  57905. function sortDirective(directive) {
  57906. return new _directives.GraphQLDirective({
  57907. name: directive.name,
  57908. description: directive.description,
  57909. locations: sortBy(directive.locations, function (x) {
  57910. return x;
  57911. }),
  57912. args: sortArgs(directive.args),
  57913. astNode: directive.astNode
  57914. });
  57915. }
  57916. function sortArgs(args) {
  57917. return (0, _keyValMap.default)(sortByName(args), function (arg) {
  57918. return arg.name;
  57919. }, function (arg) {
  57920. return _objectSpread({}, arg, {
  57921. type: sortType(arg.type)
  57922. });
  57923. });
  57924. }
  57925. function sortFields(fieldsMap) {
  57926. return sortObjMap(fieldsMap, function (field) {
  57927. return {
  57928. type: sortType(field.type),
  57929. args: sortArgs(field.args),
  57930. resolve: field.resolve,
  57931. subscribe: field.subscribe,
  57932. deprecationReason: field.deprecationReason,
  57933. description: field.description,
  57934. astNode: field.astNode
  57935. };
  57936. });
  57937. }
  57938. function sortInputFields(fieldsMap) {
  57939. return sortObjMap(fieldsMap, function (field) {
  57940. return {
  57941. type: sortType(field.type),
  57942. defaultValue: field.defaultValue,
  57943. description: field.description,
  57944. astNode: field.astNode
  57945. };
  57946. });
  57947. }
  57948. function sortType(type) {
  57949. if ((0, _definition.isListType)(type)) {
  57950. return new _definition.GraphQLList(sortType(type.ofType));
  57951. } else if ((0, _definition.isNonNullType)(type)) {
  57952. return new _definition.GraphQLNonNull(sortType(type.ofType));
  57953. }
  57954. return sortNamedType(type);
  57955. }
  57956. function sortTypes(arr) {
  57957. return sortByName(arr).map(sortNamedType);
  57958. }
  57959. function sortNamedType(type) {
  57960. if ((0, _scalars.isSpecifiedScalarType)(type) || (0, _introspection.isIntrospectionType)(type)) {
  57961. return type;
  57962. }
  57963. var sortedType = cache[type.name];
  57964. if (!sortedType) {
  57965. sortedType = sortNamedTypeImpl(type);
  57966. cache[type.name] = sortedType;
  57967. }
  57968. return sortedType;
  57969. }
  57970. function sortNamedTypeImpl(type) {
  57971. if ((0, _definition.isScalarType)(type)) {
  57972. return type;
  57973. } else if ((0, _definition.isObjectType)(type)) {
  57974. return new _definition.GraphQLObjectType({
  57975. name: type.name,
  57976. interfaces: function interfaces() {
  57977. return sortTypes(type.getInterfaces());
  57978. },
  57979. fields: function fields() {
  57980. return sortFields(type.getFields());
  57981. },
  57982. isTypeOf: type.isTypeOf,
  57983. description: type.description,
  57984. astNode: type.astNode,
  57985. extensionASTNodes: type.extensionASTNodes
  57986. });
  57987. } else if ((0, _definition.isInterfaceType)(type)) {
  57988. return new _definition.GraphQLInterfaceType({
  57989. name: type.name,
  57990. fields: function fields() {
  57991. return sortFields(type.getFields());
  57992. },
  57993. resolveType: type.resolveType,
  57994. description: type.description,
  57995. astNode: type.astNode,
  57996. extensionASTNodes: type.extensionASTNodes
  57997. });
  57998. } else if ((0, _definition.isUnionType)(type)) {
  57999. return new _definition.GraphQLUnionType({
  58000. name: type.name,
  58001. types: function types() {
  58002. return sortTypes(type.getTypes());
  58003. },
  58004. resolveType: type.resolveType,
  58005. description: type.description,
  58006. astNode: type.astNode
  58007. });
  58008. } else if ((0, _definition.isEnumType)(type)) {
  58009. return new _definition.GraphQLEnumType({
  58010. name: type.name,
  58011. values: (0, _keyValMap.default)(sortByName(type.getValues()), function (val) {
  58012. return val.name;
  58013. }, function (val) {
  58014. return {
  58015. value: val.value,
  58016. deprecationReason: val.deprecationReason,
  58017. description: val.description,
  58018. astNode: val.astNode
  58019. };
  58020. }),
  58021. description: type.description,
  58022. astNode: type.astNode
  58023. });
  58024. } else if ((0, _definition.isInputObjectType)(type)) {
  58025. return new _definition.GraphQLInputObjectType({
  58026. name: type.name,
  58027. fields: function fields() {
  58028. return sortInputFields(type.getFields());
  58029. },
  58030. description: type.description,
  58031. astNode: type.astNode
  58032. });
  58033. }
  58034. throw new Error("Unknown type: \"".concat(type, "\""));
  58035. }
  58036. }
  58037. function sortObjMap(map, sortValueFn) {
  58038. var sortedMap = Object.create(null);
  58039. var sortedKeys = sortBy(Object.keys(map), function (x) {
  58040. return x;
  58041. });
  58042. for (var _i = 0; _i < sortedKeys.length; _i++) {
  58043. var key = sortedKeys[_i];
  58044. var value = map[key];
  58045. sortedMap[key] = sortValueFn ? sortValueFn(value) : value;
  58046. }
  58047. return sortedMap;
  58048. }
  58049. function sortByName(array) {
  58050. return sortBy(array, function (obj) {
  58051. return obj.name;
  58052. });
  58053. }
  58054. function sortBy(array, mapToKey) {
  58055. return array.slice().sort(function (obj1, obj2) {
  58056. var key1 = mapToKey(obj1);
  58057. var key2 = mapToKey(obj2);
  58058. return key1.localeCompare(key2);
  58059. });
  58060. }
  58061. },{"../jsutils/keyValMap":295,"../polyfills/objectValues":319,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/scalars":327,"../type/schema":328}],348:[function(require,module,exports){
  58062. "use strict";
  58063. Object.defineProperty(exports, "__esModule", {
  58064. value: true
  58065. });
  58066. exports.printSchema = printSchema;
  58067. exports.printIntrospectionSchema = printIntrospectionSchema;
  58068. exports.printType = printType;
  58069. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  58070. var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
  58071. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  58072. var _astFromValue = require("../utilities/astFromValue");
  58073. var _printer = require("../language/printer");
  58074. var _definition = require("../type/definition");
  58075. var _scalars = require("../type/scalars");
  58076. var _directives = require("../type/directives");
  58077. var _introspection = require("../type/introspection");
  58078. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  58079. /**
  58080. * Copyright (c) 2015-present, Facebook, Inc.
  58081. *
  58082. * This source code is licensed under the MIT license found in the
  58083. * LICENSE file in the root directory of this source tree.
  58084. *
  58085. *
  58086. */
  58087. /**
  58088. * Accepts options as a second argument:
  58089. *
  58090. * - commentDescriptions:
  58091. * Provide true to use preceding comments as the description.
  58092. *
  58093. */
  58094. function printSchema(schema, options) {
  58095. return printFilteredSchema(schema, function (n) {
  58096. return !(0, _directives.isSpecifiedDirective)(n);
  58097. }, isDefinedType, options);
  58098. }
  58099. function printIntrospectionSchema(schema, options) {
  58100. return printFilteredSchema(schema, _directives.isSpecifiedDirective, _introspection.isIntrospectionType, options);
  58101. }
  58102. function isDefinedType(type) {
  58103. return !(0, _scalars.isSpecifiedScalarType)(type) && !(0, _introspection.isIntrospectionType)(type);
  58104. }
  58105. function printFilteredSchema(schema, directiveFilter, typeFilter, options) {
  58106. var directives = schema.getDirectives().filter(directiveFilter);
  58107. var typeMap = schema.getTypeMap();
  58108. var types = (0, _objectValues.default)(typeMap).sort(function (type1, type2) {
  58109. return type1.name.localeCompare(type2.name);
  58110. }).filter(typeFilter);
  58111. return [printSchemaDefinition(schema)].concat(directives.map(function (directive) {
  58112. return printDirective(directive, options);
  58113. }), types.map(function (type) {
  58114. return printType(type, options);
  58115. })).filter(Boolean).join('\n\n') + '\n';
  58116. }
  58117. function printSchemaDefinition(schema) {
  58118. if (isSchemaOfCommonNames(schema)) {
  58119. return;
  58120. }
  58121. var operationTypes = [];
  58122. var queryType = schema.getQueryType();
  58123. if (queryType) {
  58124. operationTypes.push(" query: ".concat(queryType.name));
  58125. }
  58126. var mutationType = schema.getMutationType();
  58127. if (mutationType) {
  58128. operationTypes.push(" mutation: ".concat(mutationType.name));
  58129. }
  58130. var subscriptionType = schema.getSubscriptionType();
  58131. if (subscriptionType) {
  58132. operationTypes.push(" subscription: ".concat(subscriptionType.name));
  58133. }
  58134. return "schema {\n".concat(operationTypes.join('\n'), "\n}");
  58135. }
  58136. /**
  58137. * GraphQL schema define root types for each type of operation. These types are
  58138. * the same as any other type and can be named in any manner, however there is
  58139. * a common naming convention:
  58140. *
  58141. * schema {
  58142. * query: Query
  58143. * mutation: Mutation
  58144. * }
  58145. *
  58146. * When using this naming convention, the schema description can be omitted.
  58147. */
  58148. function isSchemaOfCommonNames(schema) {
  58149. var queryType = schema.getQueryType();
  58150. if (queryType && queryType.name !== 'Query') {
  58151. return false;
  58152. }
  58153. var mutationType = schema.getMutationType();
  58154. if (mutationType && mutationType.name !== 'Mutation') {
  58155. return false;
  58156. }
  58157. var subscriptionType = schema.getSubscriptionType();
  58158. if (subscriptionType && subscriptionType.name !== 'Subscription') {
  58159. return false;
  58160. }
  58161. return true;
  58162. }
  58163. function printType(type, options) {
  58164. if ((0, _definition.isScalarType)(type)) {
  58165. return printScalar(type, options);
  58166. } else if ((0, _definition.isObjectType)(type)) {
  58167. return printObject(type, options);
  58168. } else if ((0, _definition.isInterfaceType)(type)) {
  58169. return printInterface(type, options);
  58170. } else if ((0, _definition.isUnionType)(type)) {
  58171. return printUnion(type, options);
  58172. } else if ((0, _definition.isEnumType)(type)) {
  58173. return printEnum(type, options);
  58174. } else if ((0, _definition.isInputObjectType)(type)) {
  58175. return printInputObject(type, options);
  58176. }
  58177. /* istanbul ignore next */
  58178. throw new Error("Unknown type: ".concat(type, "."));
  58179. }
  58180. function printScalar(type, options) {
  58181. return printDescription(options, type) + "scalar ".concat(type.name);
  58182. }
  58183. function printObject(type, options) {
  58184. var interfaces = type.getInterfaces();
  58185. var implementedInterfaces = interfaces.length ? ' implements ' + interfaces.map(function (i) {
  58186. return i.name;
  58187. }).join(' & ') : '';
  58188. return printDescription(options, type) + "type ".concat(type.name).concat(implementedInterfaces, " {\n") + printFields(options, type) + '\n' + '}';
  58189. }
  58190. function printInterface(type, options) {
  58191. return printDescription(options, type) + "interface ".concat(type.name, " {\n") + printFields(options, type) + '\n' + '}';
  58192. }
  58193. function printUnion(type, options) {
  58194. return printDescription(options, type) + "union ".concat(type.name, " = ").concat(type.getTypes().join(' | '));
  58195. }
  58196. function printEnum(type, options) {
  58197. return printDescription(options, type) + "enum ".concat(type.name, " {\n") + printEnumValues(type.getValues(), options) + '\n' + '}';
  58198. }
  58199. function printEnumValues(values, options) {
  58200. return values.map(function (value, i) {
  58201. return printDescription(options, value, ' ', !i) + ' ' + value.name + printDeprecated(value);
  58202. }).join('\n');
  58203. }
  58204. function printInputObject(type, options) {
  58205. var fields = (0, _objectValues.default)(type.getFields());
  58206. return printDescription(options, type) + "input ".concat(type.name, " {\n") + fields.map(function (f, i) {
  58207. return printDescription(options, f, ' ', !i) + ' ' + printInputValue(f);
  58208. }).join('\n') + '\n' + '}';
  58209. }
  58210. function printFields(options, type) {
  58211. var fields = (0, _objectValues.default)(type.getFields());
  58212. return fields.map(function (f, i) {
  58213. return printDescription(options, f, ' ', !i) + ' ' + f.name + printArgs(options, f.args, ' ') + ': ' + String(f.type) + printDeprecated(f);
  58214. }).join('\n');
  58215. }
  58216. function printArgs(options, args) {
  58217. var indentation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  58218. if (args.length === 0) {
  58219. return '';
  58220. } // If every arg does not have a description, print them on one line.
  58221. if (args.every(function (arg) {
  58222. return !arg.description;
  58223. })) {
  58224. return '(' + args.map(printInputValue).join(', ') + ')';
  58225. }
  58226. return '(\n' + args.map(function (arg, i) {
  58227. return printDescription(options, arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg);
  58228. }).join('\n') + '\n' + indentation + ')';
  58229. }
  58230. function printInputValue(arg) {
  58231. var argDecl = arg.name + ': ' + String(arg.type);
  58232. if (!(0, _isInvalid.default)(arg.defaultValue)) {
  58233. argDecl += " = ".concat((0, _printer.print)((0, _astFromValue.astFromValue)(arg.defaultValue, arg.type)));
  58234. }
  58235. return argDecl;
  58236. }
  58237. function printDirective(directive, options) {
  58238. return printDescription(options, directive) + 'directive @' + directive.name + printArgs(options, directive.args) + ' on ' + directive.locations.join(' | ');
  58239. }
  58240. function printDeprecated(fieldOrEnumVal) {
  58241. if (!fieldOrEnumVal.isDeprecated) {
  58242. return '';
  58243. }
  58244. var reason = fieldOrEnumVal.deprecationReason;
  58245. if ((0, _isNullish.default)(reason) || reason === '' || reason === _directives.DEFAULT_DEPRECATION_REASON) {
  58246. return ' @deprecated';
  58247. }
  58248. return ' @deprecated(reason: ' + (0, _printer.print)((0, _astFromValue.astFromValue)(reason, _scalars.GraphQLString)) + ')';
  58249. }
  58250. function printDescription(options, def) {
  58251. var indentation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  58252. var firstInBlock = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  58253. if (!def.description) {
  58254. return '';
  58255. }
  58256. var lines = descriptionLines(def.description, 120 - indentation.length);
  58257. if (options && options.commentDescriptions) {
  58258. return printDescriptionWithComments(lines, indentation, firstInBlock);
  58259. }
  58260. var description = indentation && !firstInBlock ? '\n' + indentation + '"""' : indentation + '"""'; // In some circumstances, a single line can be used for the description.
  58261. if (lines.length === 1 && lines[0].length < 70 && lines[0][lines[0].length - 1] !== '"') {
  58262. return description + escapeQuote(lines[0]) + '"""\n';
  58263. } // Format a multi-line block quote to account for leading space.
  58264. var hasLeadingSpace = lines[0][0] === ' ' || lines[0][0] === '\t';
  58265. if (!hasLeadingSpace) {
  58266. description += '\n';
  58267. }
  58268. for (var i = 0; i < lines.length; i++) {
  58269. if (i !== 0 || !hasLeadingSpace) {
  58270. description += indentation;
  58271. }
  58272. description += escapeQuote(lines[i]) + '\n';
  58273. }
  58274. description += indentation + '"""\n';
  58275. return description;
  58276. }
  58277. function escapeQuote(line) {
  58278. return line.replace(/"""/g, '\\"""');
  58279. }
  58280. function printDescriptionWithComments(lines, indentation, firstInBlock) {
  58281. var description = indentation && !firstInBlock ? '\n' : '';
  58282. for (var i = 0; i < lines.length; i++) {
  58283. if (lines[i] === '') {
  58284. description += indentation + '#\n';
  58285. } else {
  58286. description += indentation + '# ' + lines[i] + '\n';
  58287. }
  58288. }
  58289. return description;
  58290. }
  58291. function descriptionLines(description, maxLen) {
  58292. var lines = [];
  58293. var rawLines = description.split('\n');
  58294. for (var i = 0; i < rawLines.length; i++) {
  58295. if (rawLines[i] === '') {
  58296. lines.push(rawLines[i]);
  58297. } else {
  58298. // For > 120 character long lines, cut at space boundaries into sublines
  58299. // of ~80 chars.
  58300. var sublines = breakLine(rawLines[i], maxLen);
  58301. for (var j = 0; j < sublines.length; j++) {
  58302. lines.push(sublines[j]);
  58303. }
  58304. }
  58305. }
  58306. return lines;
  58307. }
  58308. function breakLine(line, maxLen) {
  58309. if (line.length < maxLen + 5) {
  58310. return [line];
  58311. }
  58312. var parts = line.split(new RegExp("((?: |^).{15,".concat(maxLen - 40, "}(?= |$))")));
  58313. if (parts.length < 4) {
  58314. return [line];
  58315. }
  58316. var sublines = [parts[0] + parts[1] + parts[2]];
  58317. for (var i = 3; i < parts.length; i += 2) {
  58318. sublines.push(parts[i].slice(1) + parts[i + 1]);
  58319. }
  58320. return sublines;
  58321. }
  58322. },{"../jsutils/isInvalid":291,"../jsutils/isNullish":292,"../language/printer":312,"../polyfills/objectValues":319,"../type/definition":323,"../type/directives":324,"../type/introspection":326,"../type/scalars":327,"../utilities/astFromValue":332}],349:[function(require,module,exports){
  58323. "use strict";
  58324. Object.defineProperty(exports, "__esModule", {
  58325. value: true
  58326. });
  58327. exports.separateOperations = separateOperations;
  58328. var _visitor = require("../language/visitor");
  58329. /**
  58330. * Copyright (c) 2015-present, Facebook, Inc.
  58331. *
  58332. * This source code is licensed under the MIT license found in the
  58333. * LICENSE file in the root directory of this source tree.
  58334. *
  58335. *
  58336. */
  58337. /**
  58338. * separateOperations accepts a single AST document which may contain many
  58339. * operations and fragments and returns a collection of AST documents each of
  58340. * which contains a single operation as well the fragment definitions it
  58341. * refers to.
  58342. */
  58343. function separateOperations(documentAST) {
  58344. var operations = [];
  58345. var fragments = Object.create(null);
  58346. var positions = new Map();
  58347. var depGraph = Object.create(null);
  58348. var fromName;
  58349. var idx = 0; // Populate metadata and build a dependency graph.
  58350. (0, _visitor.visit)(documentAST, {
  58351. OperationDefinition: function OperationDefinition(node) {
  58352. fromName = opName(node);
  58353. operations.push(node);
  58354. positions.set(node, idx++);
  58355. },
  58356. FragmentDefinition: function FragmentDefinition(node) {
  58357. fromName = node.name.value;
  58358. fragments[fromName] = node;
  58359. positions.set(node, idx++);
  58360. },
  58361. FragmentSpread: function FragmentSpread(node) {
  58362. var toName = node.name.value;
  58363. (depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true;
  58364. }
  58365. }); // For each operation, produce a new synthesized AST which includes only what
  58366. // is necessary for completing that operation.
  58367. var separatedDocumentASTs = Object.create(null);
  58368. for (var _i = 0; _i < operations.length; _i++) {
  58369. var operation = operations[_i];
  58370. var operationName = opName(operation);
  58371. var dependencies = Object.create(null);
  58372. collectTransitiveDependencies(dependencies, depGraph, operationName); // The list of definition nodes to be included for this operation, sorted
  58373. // to retain the same order as the original document.
  58374. var definitions = [operation];
  58375. var _arr = Object.keys(dependencies);
  58376. for (var _i2 = 0; _i2 < _arr.length; _i2++) {
  58377. var name = _arr[_i2];
  58378. definitions.push(fragments[name]);
  58379. }
  58380. definitions.sort(function (n1, n2) {
  58381. return (positions.get(n1) || 0) - (positions.get(n2) || 0);
  58382. });
  58383. separatedDocumentASTs[operationName] = {
  58384. kind: 'Document',
  58385. definitions: definitions
  58386. };
  58387. }
  58388. return separatedDocumentASTs;
  58389. }
  58390. // Provides the empty string for anonymous operations.
  58391. function opName(operation) {
  58392. return operation.name ? operation.name.value : '';
  58393. } // From a dependency graph, collects a list of transitive dependencies by
  58394. // recursing through a dependency graph.
  58395. function collectTransitiveDependencies(collected, depGraph, fromName) {
  58396. var immediateDeps = depGraph[fromName];
  58397. if (immediateDeps) {
  58398. var _arr2 = Object.keys(immediateDeps);
  58399. for (var _i3 = 0; _i3 < _arr2.length; _i3++) {
  58400. var toName = _arr2[_i3];
  58401. if (!collected[toName]) {
  58402. collected[toName] = true;
  58403. collectTransitiveDependencies(collected, depGraph, toName);
  58404. }
  58405. }
  58406. }
  58407. }
  58408. },{"../language/visitor":314}],350:[function(require,module,exports){
  58409. "use strict";
  58410. Object.defineProperty(exports, "__esModule", {
  58411. value: true
  58412. });
  58413. exports.isEqualType = isEqualType;
  58414. exports.isTypeSubTypeOf = isTypeSubTypeOf;
  58415. exports.doTypesOverlap = doTypesOverlap;
  58416. var _definition = require("../type/definition");
  58417. /**
  58418. * Copyright (c) 2015-present, Facebook, Inc.
  58419. *
  58420. * This source code is licensed under the MIT license found in the
  58421. * LICENSE file in the root directory of this source tree.
  58422. *
  58423. *
  58424. */
  58425. /**
  58426. * Provided two types, return true if the types are equal (invariant).
  58427. */
  58428. function isEqualType(typeA, typeB) {
  58429. // Equivalent types are equal.
  58430. if (typeA === typeB) {
  58431. return true;
  58432. } // If either type is non-null, the other must also be non-null.
  58433. if ((0, _definition.isNonNullType)(typeA) && (0, _definition.isNonNullType)(typeB)) {
  58434. return isEqualType(typeA.ofType, typeB.ofType);
  58435. } // If either type is a list, the other must also be a list.
  58436. if ((0, _definition.isListType)(typeA) && (0, _definition.isListType)(typeB)) {
  58437. return isEqualType(typeA.ofType, typeB.ofType);
  58438. } // Otherwise the types are not equal.
  58439. return false;
  58440. }
  58441. /**
  58442. * Provided a type and a super type, return true if the first type is either
  58443. * equal or a subset of the second super type (covariant).
  58444. */
  58445. function isTypeSubTypeOf(schema, maybeSubType, superType) {
  58446. // Equivalent type is a valid subtype
  58447. if (maybeSubType === superType) {
  58448. return true;
  58449. } // If superType is non-null, maybeSubType must also be non-null.
  58450. if ((0, _definition.isNonNullType)(superType)) {
  58451. if ((0, _definition.isNonNullType)(maybeSubType)) {
  58452. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  58453. }
  58454. return false;
  58455. }
  58456. if ((0, _definition.isNonNullType)(maybeSubType)) {
  58457. // If superType is nullable, maybeSubType may be non-null or nullable.
  58458. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
  58459. } // If superType type is a list, maybeSubType type must also be a list.
  58460. if ((0, _definition.isListType)(superType)) {
  58461. if ((0, _definition.isListType)(maybeSubType)) {
  58462. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  58463. }
  58464. return false;
  58465. }
  58466. if ((0, _definition.isListType)(maybeSubType)) {
  58467. // If superType is not a list, maybeSubType must also be not a list.
  58468. return false;
  58469. } // If superType type is an abstract type, maybeSubType type may be a currently
  58470. // possible object type.
  58471. if ((0, _definition.isAbstractType)(superType) && (0, _definition.isObjectType)(maybeSubType) && schema.isPossibleType(superType, maybeSubType)) {
  58472. return true;
  58473. } // Otherwise, the child type is not a valid subtype of the parent type.
  58474. return false;
  58475. }
  58476. /**
  58477. * Provided two composite types, determine if they "overlap". Two composite
  58478. * types overlap when the Sets of possible concrete types for each intersect.
  58479. *
  58480. * This is often used to determine if a fragment of a given type could possibly
  58481. * be visited in a context of another type.
  58482. *
  58483. * This function is commutative.
  58484. */
  58485. function doTypesOverlap(schema, typeA, typeB) {
  58486. // Equivalent types overlap
  58487. if (typeA === typeB) {
  58488. return true;
  58489. }
  58490. if ((0, _definition.isAbstractType)(typeA)) {
  58491. if ((0, _definition.isAbstractType)(typeB)) {
  58492. // If both types are abstract, then determine if there is any intersection
  58493. // between possible concrete types of each.
  58494. return schema.getPossibleTypes(typeA).some(function (type) {
  58495. return schema.isPossibleType(typeB, type);
  58496. });
  58497. } // Determine if the latter type is a possible concrete type of the former.
  58498. return schema.isPossibleType(typeA, typeB);
  58499. }
  58500. if ((0, _definition.isAbstractType)(typeB)) {
  58501. // Determine if the former type is a possible concrete type of the latter.
  58502. return schema.isPossibleType(typeB, typeA);
  58503. } // Otherwise the types do not overlap.
  58504. return false;
  58505. }
  58506. },{"../type/definition":323}],351:[function(require,module,exports){
  58507. "use strict";
  58508. Object.defineProperty(exports, "__esModule", {
  58509. value: true
  58510. });
  58511. exports.typeFromAST = typeFromAST;
  58512. var _kinds = require("../language/kinds");
  58513. var _definition = require("../type/definition");
  58514. /**
  58515. * Copyright (c) 2015-present, Facebook, Inc.
  58516. *
  58517. * This source code is licensed under the MIT license found in the
  58518. * LICENSE file in the root directory of this source tree.
  58519. *
  58520. *
  58521. */
  58522. function typeFromAST(schema, typeNode) {
  58523. /* eslint-enable no-redeclare */
  58524. var innerType;
  58525. if (typeNode.kind === _kinds.Kind.LIST_TYPE) {
  58526. innerType = typeFromAST(schema, typeNode.type);
  58527. return innerType && (0, _definition.GraphQLList)(innerType);
  58528. }
  58529. if (typeNode.kind === _kinds.Kind.NON_NULL_TYPE) {
  58530. innerType = typeFromAST(schema, typeNode.type);
  58531. return innerType && (0, _definition.GraphQLNonNull)(innerType);
  58532. }
  58533. if (typeNode.kind === _kinds.Kind.NAMED_TYPE) {
  58534. return schema.getType(typeNode.name.value);
  58535. }
  58536. /* istanbul ignore next */
  58537. throw new Error("Unexpected type kind: ".concat(typeNode.kind, "."));
  58538. }
  58539. },{"../language/kinds":307,"../type/definition":323}],352:[function(require,module,exports){
  58540. "use strict";
  58541. Object.defineProperty(exports, "__esModule", {
  58542. value: true
  58543. });
  58544. exports.valueFromAST = valueFromAST;
  58545. var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
  58546. var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
  58547. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  58548. var _kinds = require("../language/kinds");
  58549. var _definition = require("../type/definition");
  58550. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  58551. /**
  58552. * Copyright (c) 2015-present, Facebook, Inc.
  58553. *
  58554. * This source code is licensed under the MIT license found in the
  58555. * LICENSE file in the root directory of this source tree.
  58556. *
  58557. *
  58558. */
  58559. /**
  58560. * Produces a JavaScript value given a GraphQL Value AST.
  58561. *
  58562. * A GraphQL type must be provided, which will be used to interpret different
  58563. * GraphQL Value literals.
  58564. *
  58565. * Returns `undefined` when the value could not be validly coerced according to
  58566. * the provided type.
  58567. *
  58568. * | GraphQL Value | JSON Value |
  58569. * | -------------------- | ------------- |
  58570. * | Input Object | Object |
  58571. * | List | Array |
  58572. * | Boolean | Boolean |
  58573. * | String | String |
  58574. * | Int / Float | Number |
  58575. * | Enum Value | Mixed |
  58576. * | NullValue | null |
  58577. *
  58578. */
  58579. function valueFromAST(valueNode, type, variables) {
  58580. if (!valueNode) {
  58581. // When there is no node, then there is also no value.
  58582. // Importantly, this is different from returning the value null.
  58583. return;
  58584. }
  58585. if ((0, _definition.isNonNullType)(type)) {
  58586. if (valueNode.kind === _kinds.Kind.NULL) {
  58587. return; // Invalid: intentionally return no value.
  58588. }
  58589. return valueFromAST(valueNode, type.ofType, variables);
  58590. }
  58591. if (valueNode.kind === _kinds.Kind.NULL) {
  58592. // This is explicitly returning the value null.
  58593. return null;
  58594. }
  58595. if (valueNode.kind === _kinds.Kind.VARIABLE) {
  58596. var variableName = valueNode.name.value;
  58597. if (!variables || (0, _isInvalid.default)(variables[variableName])) {
  58598. // No valid return value.
  58599. return;
  58600. }
  58601. var variableValue = variables[variableName];
  58602. if (variableValue === null && (0, _definition.isNonNullType)(type)) {
  58603. return; // Invalid: intentionally return no value.
  58604. } // Note: This does no further checking that this variable is correct.
  58605. // This assumes that this query has been validated and the variable
  58606. // usage here is of the correct type.
  58607. return variableValue;
  58608. }
  58609. if ((0, _definition.isListType)(type)) {
  58610. var itemType = type.ofType;
  58611. if (valueNode.kind === _kinds.Kind.LIST) {
  58612. var coercedValues = [];
  58613. var itemNodes = valueNode.values;
  58614. for (var i = 0; i < itemNodes.length; i++) {
  58615. if (isMissingVariable(itemNodes[i], variables)) {
  58616. // If an array contains a missing variable, it is either coerced to
  58617. // null or if the item type is non-null, it considered invalid.
  58618. if ((0, _definition.isNonNullType)(itemType)) {
  58619. return; // Invalid: intentionally return no value.
  58620. }
  58621. coercedValues.push(null);
  58622. } else {
  58623. var itemValue = valueFromAST(itemNodes[i], itemType, variables);
  58624. if ((0, _isInvalid.default)(itemValue)) {
  58625. return; // Invalid: intentionally return no value.
  58626. }
  58627. coercedValues.push(itemValue);
  58628. }
  58629. }
  58630. return coercedValues;
  58631. }
  58632. var coercedValue = valueFromAST(valueNode, itemType, variables);
  58633. if ((0, _isInvalid.default)(coercedValue)) {
  58634. return; // Invalid: intentionally return no value.
  58635. }
  58636. return [coercedValue];
  58637. }
  58638. if ((0, _definition.isInputObjectType)(type)) {
  58639. if (valueNode.kind !== _kinds.Kind.OBJECT) {
  58640. return; // Invalid: intentionally return no value.
  58641. }
  58642. var coercedObj = Object.create(null);
  58643. var fieldNodes = (0, _keyMap.default)(valueNode.fields, function (field) {
  58644. return field.name.value;
  58645. });
  58646. var fields = (0, _objectValues.default)(type.getFields());
  58647. for (var _i = 0; _i < fields.length; _i++) {
  58648. var field = fields[_i];
  58649. var fieldNode = fieldNodes[field.name];
  58650. if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
  58651. if (field.defaultValue !== undefined) {
  58652. coercedObj[field.name] = field.defaultValue;
  58653. } else if ((0, _definition.isNonNullType)(field.type)) {
  58654. return; // Invalid: intentionally return no value.
  58655. }
  58656. continue;
  58657. }
  58658. var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
  58659. if ((0, _isInvalid.default)(fieldValue)) {
  58660. return; // Invalid: intentionally return no value.
  58661. }
  58662. coercedObj[field.name] = fieldValue;
  58663. }
  58664. return coercedObj;
  58665. }
  58666. if ((0, _definition.isEnumType)(type)) {
  58667. if (valueNode.kind !== _kinds.Kind.ENUM) {
  58668. return; // Invalid: intentionally return no value.
  58669. }
  58670. var enumValue = type.getValue(valueNode.value);
  58671. if (!enumValue) {
  58672. return; // Invalid: intentionally return no value.
  58673. }
  58674. return enumValue.value;
  58675. }
  58676. if ((0, _definition.isScalarType)(type)) {
  58677. // Scalars fulfill parsing a literal value via parseLiteral().
  58678. // Invalid values represent a failure to parse correctly, in which case
  58679. // no value is returned.
  58680. var result;
  58681. try {
  58682. result = type.parseLiteral(valueNode, variables);
  58683. } catch (_error) {
  58684. return; // Invalid: intentionally return no value.
  58685. }
  58686. if ((0, _isInvalid.default)(result)) {
  58687. return; // Invalid: intentionally return no value.
  58688. }
  58689. return result;
  58690. }
  58691. /* istanbul ignore next */
  58692. throw new Error("Unknown type: ".concat(type, "."));
  58693. } // Returns true if the provided valueNode is a variable which is not defined
  58694. // in the set of variables.
  58695. function isMissingVariable(valueNode, variables) {
  58696. return valueNode.kind === _kinds.Kind.VARIABLE && (!variables || (0, _isInvalid.default)(variables[valueNode.name.value]));
  58697. }
  58698. },{"../jsutils/isInvalid":291,"../jsutils/keyMap":294,"../language/kinds":307,"../polyfills/objectValues":319,"../type/definition":323}],353:[function(require,module,exports){
  58699. "use strict";
  58700. Object.defineProperty(exports, "__esModule", {
  58701. value: true
  58702. });
  58703. exports.valueFromASTUntyped = valueFromASTUntyped;
  58704. var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
  58705. var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
  58706. var _kinds = require("../language/kinds");
  58707. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  58708. /**
  58709. * Copyright (c) 2015-present, Facebook, Inc.
  58710. *
  58711. * This source code is licensed under the MIT license found in the
  58712. * LICENSE file in the root directory of this source tree.
  58713. *
  58714. *
  58715. */
  58716. /**
  58717. * Produces a JavaScript value given a GraphQL Value AST.
  58718. *
  58719. * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value
  58720. * will reflect the provided GraphQL value AST.
  58721. *
  58722. * | GraphQL Value | JavaScript Value |
  58723. * | -------------------- | ---------------- |
  58724. * | Input Object | Object |
  58725. * | List | Array |
  58726. * | Boolean | Boolean |
  58727. * | String / Enum | String |
  58728. * | Int / Float | Number |
  58729. * | Null | null |
  58730. *
  58731. */
  58732. function valueFromASTUntyped(valueNode, variables) {
  58733. switch (valueNode.kind) {
  58734. case _kinds.Kind.NULL:
  58735. return null;
  58736. case _kinds.Kind.INT:
  58737. return parseInt(valueNode.value, 10);
  58738. case _kinds.Kind.FLOAT:
  58739. return parseFloat(valueNode.value);
  58740. case _kinds.Kind.STRING:
  58741. case _kinds.Kind.ENUM:
  58742. case _kinds.Kind.BOOLEAN:
  58743. return valueNode.value;
  58744. case _kinds.Kind.LIST:
  58745. return valueNode.values.map(function (node) {
  58746. return valueFromASTUntyped(node, variables);
  58747. });
  58748. case _kinds.Kind.OBJECT:
  58749. return (0, _keyValMap.default)(valueNode.fields, function (field) {
  58750. return field.name.value;
  58751. }, function (field) {
  58752. return valueFromASTUntyped(field.value, variables);
  58753. });
  58754. case _kinds.Kind.VARIABLE:
  58755. var variableName = valueNode.name.value;
  58756. return variables && !(0, _isInvalid.default)(variables[variableName]) ? variables[variableName] : undefined;
  58757. }
  58758. /* istanbul ignore next */
  58759. throw new Error('Unexpected value kind: ' + valueNode.kind);
  58760. }
  58761. },{"../jsutils/isInvalid":291,"../jsutils/keyValMap":295,"../language/kinds":307}],354:[function(require,module,exports){
  58762. "use strict";
  58763. Object.defineProperty(exports, "__esModule", {
  58764. value: true
  58765. });
  58766. exports.ValidationContext = exports.SDLValidationContext = exports.ASTValidationContext = void 0;
  58767. var _visitor = require("../language/visitor");
  58768. var _kinds = require("../language/kinds");
  58769. var _TypeInfo = require("../utilities/TypeInfo");
  58770. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  58771. /**
  58772. * An instance of this class is passed as the "this" context to all validators,
  58773. * allowing access to commonly useful contextual information from within a
  58774. * validation rule.
  58775. */
  58776. var ASTValidationContext =
  58777. /*#__PURE__*/
  58778. function () {
  58779. function ASTValidationContext(ast) {
  58780. this._ast = ast;
  58781. this._errors = [];
  58782. this._fragments = undefined;
  58783. this._fragmentSpreads = new Map();
  58784. this._recursivelyReferencedFragments = new Map();
  58785. }
  58786. var _proto = ASTValidationContext.prototype;
  58787. _proto.reportError = function reportError(error) {
  58788. this._errors.push(error);
  58789. };
  58790. _proto.getErrors = function getErrors() {
  58791. return this._errors;
  58792. };
  58793. _proto.getDocument = function getDocument() {
  58794. return this._ast;
  58795. };
  58796. _proto.getFragment = function getFragment(name) {
  58797. var fragments = this._fragments;
  58798. if (!fragments) {
  58799. this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
  58800. if (statement.kind === _kinds.Kind.FRAGMENT_DEFINITION) {
  58801. frags[statement.name.value] = statement;
  58802. }
  58803. return frags;
  58804. }, Object.create(null));
  58805. }
  58806. return fragments[name];
  58807. };
  58808. _proto.getFragmentSpreads = function getFragmentSpreads(node) {
  58809. var spreads = this._fragmentSpreads.get(node);
  58810. if (!spreads) {
  58811. spreads = [];
  58812. var setsToVisit = [node];
  58813. while (setsToVisit.length !== 0) {
  58814. var set = setsToVisit.pop();
  58815. for (var i = 0; i < set.selections.length; i++) {
  58816. var selection = set.selections[i];
  58817. if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
  58818. spreads.push(selection);
  58819. } else if (selection.selectionSet) {
  58820. setsToVisit.push(selection.selectionSet);
  58821. }
  58822. }
  58823. }
  58824. this._fragmentSpreads.set(node, spreads);
  58825. }
  58826. return spreads;
  58827. };
  58828. _proto.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
  58829. var fragments = this._recursivelyReferencedFragments.get(operation);
  58830. if (!fragments) {
  58831. fragments = [];
  58832. var collectedNames = Object.create(null);
  58833. var nodesToVisit = [operation.selectionSet];
  58834. while (nodesToVisit.length !== 0) {
  58835. var node = nodesToVisit.pop();
  58836. var spreads = this.getFragmentSpreads(node);
  58837. for (var i = 0; i < spreads.length; i++) {
  58838. var fragName = spreads[i].name.value;
  58839. if (collectedNames[fragName] !== true) {
  58840. collectedNames[fragName] = true;
  58841. var fragment = this.getFragment(fragName);
  58842. if (fragment) {
  58843. fragments.push(fragment);
  58844. nodesToVisit.push(fragment.selectionSet);
  58845. }
  58846. }
  58847. }
  58848. }
  58849. this._recursivelyReferencedFragments.set(operation, fragments);
  58850. }
  58851. return fragments;
  58852. };
  58853. return ASTValidationContext;
  58854. }();
  58855. exports.ASTValidationContext = ASTValidationContext;
  58856. var SDLValidationContext =
  58857. /*#__PURE__*/
  58858. function (_ASTValidationContext) {
  58859. _inheritsLoose(SDLValidationContext, _ASTValidationContext);
  58860. function SDLValidationContext(ast, schema) {
  58861. var _this;
  58862. _this = _ASTValidationContext.call(this, ast) || this;
  58863. _this._schema = schema;
  58864. return _this;
  58865. }
  58866. var _proto2 = SDLValidationContext.prototype;
  58867. _proto2.getSchema = function getSchema() {
  58868. return this._schema;
  58869. };
  58870. return SDLValidationContext;
  58871. }(ASTValidationContext);
  58872. exports.SDLValidationContext = SDLValidationContext;
  58873. var ValidationContext =
  58874. /*#__PURE__*/
  58875. function (_ASTValidationContext2) {
  58876. _inheritsLoose(ValidationContext, _ASTValidationContext2);
  58877. function ValidationContext(schema, ast, typeInfo) {
  58878. var _this2;
  58879. _this2 = _ASTValidationContext2.call(this, ast) || this;
  58880. _this2._schema = schema;
  58881. _this2._typeInfo = typeInfo;
  58882. _this2._variableUsages = new Map();
  58883. _this2._recursiveVariableUsages = new Map();
  58884. return _this2;
  58885. }
  58886. var _proto3 = ValidationContext.prototype;
  58887. _proto3.getSchema = function getSchema() {
  58888. return this._schema;
  58889. };
  58890. _proto3.getVariableUsages = function getVariableUsages(node) {
  58891. var usages = this._variableUsages.get(node);
  58892. if (!usages) {
  58893. var newUsages = [];
  58894. var typeInfo = new _TypeInfo.TypeInfo(this._schema);
  58895. (0, _visitor.visit)(node, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  58896. VariableDefinition: function VariableDefinition() {
  58897. return false;
  58898. },
  58899. Variable: function Variable(variable) {
  58900. newUsages.push({
  58901. node: variable,
  58902. type: typeInfo.getInputType(),
  58903. defaultValue: typeInfo.getDefaultValue()
  58904. });
  58905. }
  58906. }));
  58907. usages = newUsages;
  58908. this._variableUsages.set(node, usages);
  58909. }
  58910. return usages;
  58911. };
  58912. _proto3.getRecursiveVariableUsages = function getRecursiveVariableUsages(operation) {
  58913. var usages = this._recursiveVariableUsages.get(operation);
  58914. if (!usages) {
  58915. usages = this.getVariableUsages(operation);
  58916. var fragments = this.getRecursivelyReferencedFragments(operation);
  58917. for (var i = 0; i < fragments.length; i++) {
  58918. Array.prototype.push.apply(usages, this.getVariableUsages(fragments[i]));
  58919. }
  58920. this._recursiveVariableUsages.set(operation, usages);
  58921. }
  58922. return usages;
  58923. };
  58924. _proto3.getType = function getType() {
  58925. return this._typeInfo.getType();
  58926. };
  58927. _proto3.getParentType = function getParentType() {
  58928. return this._typeInfo.getParentType();
  58929. };
  58930. _proto3.getInputType = function getInputType() {
  58931. return this._typeInfo.getInputType();
  58932. };
  58933. _proto3.getParentInputType = function getParentInputType() {
  58934. return this._typeInfo.getParentInputType();
  58935. };
  58936. _proto3.getFieldDef = function getFieldDef() {
  58937. return this._typeInfo.getFieldDef();
  58938. };
  58939. _proto3.getDirective = function getDirective() {
  58940. return this._typeInfo.getDirective();
  58941. };
  58942. _proto3.getArgument = function getArgument() {
  58943. return this._typeInfo.getArgument();
  58944. };
  58945. return ValidationContext;
  58946. }(ASTValidationContext);
  58947. exports.ValidationContext = ValidationContext;
  58948. },{"../language/kinds":307,"../language/visitor":314,"../utilities/TypeInfo":330}],355:[function(require,module,exports){
  58949. "use strict";
  58950. Object.defineProperty(exports, "__esModule", {
  58951. value: true
  58952. });
  58953. Object.defineProperty(exports, "validate", {
  58954. enumerable: true,
  58955. get: function get() {
  58956. return _validate.validate;
  58957. }
  58958. });
  58959. Object.defineProperty(exports, "ValidationContext", {
  58960. enumerable: true,
  58961. get: function get() {
  58962. return _ValidationContext.ValidationContext;
  58963. }
  58964. });
  58965. Object.defineProperty(exports, "specifiedRules", {
  58966. enumerable: true,
  58967. get: function get() {
  58968. return _specifiedRules.specifiedRules;
  58969. }
  58970. });
  58971. Object.defineProperty(exports, "FieldsOnCorrectTypeRule", {
  58972. enumerable: true,
  58973. get: function get() {
  58974. return _FieldsOnCorrectType.FieldsOnCorrectType;
  58975. }
  58976. });
  58977. Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", {
  58978. enumerable: true,
  58979. get: function get() {
  58980. return _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes;
  58981. }
  58982. });
  58983. Object.defineProperty(exports, "KnownArgumentNamesRule", {
  58984. enumerable: true,
  58985. get: function get() {
  58986. return _KnownArgumentNames.KnownArgumentNames;
  58987. }
  58988. });
  58989. Object.defineProperty(exports, "KnownDirectivesRule", {
  58990. enumerable: true,
  58991. get: function get() {
  58992. return _KnownDirectives.KnownDirectives;
  58993. }
  58994. });
  58995. Object.defineProperty(exports, "KnownFragmentNamesRule", {
  58996. enumerable: true,
  58997. get: function get() {
  58998. return _KnownFragmentNames.KnownFragmentNames;
  58999. }
  59000. });
  59001. Object.defineProperty(exports, "KnownTypeNamesRule", {
  59002. enumerable: true,
  59003. get: function get() {
  59004. return _KnownTypeNames.KnownTypeNames;
  59005. }
  59006. });
  59007. Object.defineProperty(exports, "LoneAnonymousOperationRule", {
  59008. enumerable: true,
  59009. get: function get() {
  59010. return _LoneAnonymousOperation.LoneAnonymousOperation;
  59011. }
  59012. });
  59013. Object.defineProperty(exports, "NoFragmentCyclesRule", {
  59014. enumerable: true,
  59015. get: function get() {
  59016. return _NoFragmentCycles.NoFragmentCycles;
  59017. }
  59018. });
  59019. Object.defineProperty(exports, "NoUndefinedVariablesRule", {
  59020. enumerable: true,
  59021. get: function get() {
  59022. return _NoUndefinedVariables.NoUndefinedVariables;
  59023. }
  59024. });
  59025. Object.defineProperty(exports, "NoUnusedFragmentsRule", {
  59026. enumerable: true,
  59027. get: function get() {
  59028. return _NoUnusedFragments.NoUnusedFragments;
  59029. }
  59030. });
  59031. Object.defineProperty(exports, "NoUnusedVariablesRule", {
  59032. enumerable: true,
  59033. get: function get() {
  59034. return _NoUnusedVariables.NoUnusedVariables;
  59035. }
  59036. });
  59037. Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", {
  59038. enumerable: true,
  59039. get: function get() {
  59040. return _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged;
  59041. }
  59042. });
  59043. Object.defineProperty(exports, "PossibleFragmentSpreadsRule", {
  59044. enumerable: true,
  59045. get: function get() {
  59046. return _PossibleFragmentSpreads.PossibleFragmentSpreads;
  59047. }
  59048. });
  59049. Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", {
  59050. enumerable: true,
  59051. get: function get() {
  59052. return _ProvidedRequiredArguments.ProvidedRequiredArguments;
  59053. }
  59054. });
  59055. Object.defineProperty(exports, "ScalarLeafsRule", {
  59056. enumerable: true,
  59057. get: function get() {
  59058. return _ScalarLeafs.ScalarLeafs;
  59059. }
  59060. });
  59061. Object.defineProperty(exports, "SingleFieldSubscriptionsRule", {
  59062. enumerable: true,
  59063. get: function get() {
  59064. return _SingleFieldSubscriptions.SingleFieldSubscriptions;
  59065. }
  59066. });
  59067. Object.defineProperty(exports, "UniqueArgumentNamesRule", {
  59068. enumerable: true,
  59069. get: function get() {
  59070. return _UniqueArgumentNames.UniqueArgumentNames;
  59071. }
  59072. });
  59073. Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", {
  59074. enumerable: true,
  59075. get: function get() {
  59076. return _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation;
  59077. }
  59078. });
  59079. Object.defineProperty(exports, "UniqueFragmentNamesRule", {
  59080. enumerable: true,
  59081. get: function get() {
  59082. return _UniqueFragmentNames.UniqueFragmentNames;
  59083. }
  59084. });
  59085. Object.defineProperty(exports, "UniqueInputFieldNamesRule", {
  59086. enumerable: true,
  59087. get: function get() {
  59088. return _UniqueInputFieldNames.UniqueInputFieldNames;
  59089. }
  59090. });
  59091. Object.defineProperty(exports, "UniqueOperationNamesRule", {
  59092. enumerable: true,
  59093. get: function get() {
  59094. return _UniqueOperationNames.UniqueOperationNames;
  59095. }
  59096. });
  59097. Object.defineProperty(exports, "UniqueVariableNamesRule", {
  59098. enumerable: true,
  59099. get: function get() {
  59100. return _UniqueVariableNames.UniqueVariableNames;
  59101. }
  59102. });
  59103. Object.defineProperty(exports, "ValuesOfCorrectTypeRule", {
  59104. enumerable: true,
  59105. get: function get() {
  59106. return _ValuesOfCorrectType.ValuesOfCorrectType;
  59107. }
  59108. });
  59109. Object.defineProperty(exports, "VariablesAreInputTypesRule", {
  59110. enumerable: true,
  59111. get: function get() {
  59112. return _VariablesAreInputTypes.VariablesAreInputTypes;
  59113. }
  59114. });
  59115. Object.defineProperty(exports, "VariablesInAllowedPositionRule", {
  59116. enumerable: true,
  59117. get: function get() {
  59118. return _VariablesInAllowedPosition.VariablesInAllowedPosition;
  59119. }
  59120. });
  59121. var _validate = require("./validate");
  59122. var _ValidationContext = require("./ValidationContext");
  59123. var _specifiedRules = require("./specifiedRules");
  59124. var _FieldsOnCorrectType = require("./rules/FieldsOnCorrectType");
  59125. var _FragmentsOnCompositeTypes = require("./rules/FragmentsOnCompositeTypes");
  59126. var _KnownArgumentNames = require("./rules/KnownArgumentNames");
  59127. var _KnownDirectives = require("./rules/KnownDirectives");
  59128. var _KnownFragmentNames = require("./rules/KnownFragmentNames");
  59129. var _KnownTypeNames = require("./rules/KnownTypeNames");
  59130. var _LoneAnonymousOperation = require("./rules/LoneAnonymousOperation");
  59131. var _NoFragmentCycles = require("./rules/NoFragmentCycles");
  59132. var _NoUndefinedVariables = require("./rules/NoUndefinedVariables");
  59133. var _NoUnusedFragments = require("./rules/NoUnusedFragments");
  59134. var _NoUnusedVariables = require("./rules/NoUnusedVariables");
  59135. var _OverlappingFieldsCanBeMerged = require("./rules/OverlappingFieldsCanBeMerged");
  59136. var _PossibleFragmentSpreads = require("./rules/PossibleFragmentSpreads");
  59137. var _ProvidedRequiredArguments = require("./rules/ProvidedRequiredArguments");
  59138. var _ScalarLeafs = require("./rules/ScalarLeafs");
  59139. var _SingleFieldSubscriptions = require("./rules/SingleFieldSubscriptions");
  59140. var _UniqueArgumentNames = require("./rules/UniqueArgumentNames");
  59141. var _UniqueDirectivesPerLocation = require("./rules/UniqueDirectivesPerLocation");
  59142. var _UniqueFragmentNames = require("./rules/UniqueFragmentNames");
  59143. var _UniqueInputFieldNames = require("./rules/UniqueInputFieldNames");
  59144. var _UniqueOperationNames = require("./rules/UniqueOperationNames");
  59145. var _UniqueVariableNames = require("./rules/UniqueVariableNames");
  59146. var _ValuesOfCorrectType = require("./rules/ValuesOfCorrectType");
  59147. var _VariablesAreInputTypes = require("./rules/VariablesAreInputTypes");
  59148. var _VariablesInAllowedPosition = require("./rules/VariablesInAllowedPosition");
  59149. },{"./ValidationContext":354,"./rules/FieldsOnCorrectType":357,"./rules/FragmentsOnCompositeTypes":358,"./rules/KnownArgumentNames":359,"./rules/KnownDirectives":360,"./rules/KnownFragmentNames":361,"./rules/KnownTypeNames":362,"./rules/LoneAnonymousOperation":363,"./rules/NoFragmentCycles":365,"./rules/NoUndefinedVariables":366,"./rules/NoUnusedFragments":367,"./rules/NoUnusedVariables":368,"./rules/OverlappingFieldsCanBeMerged":369,"./rules/PossibleFragmentSpreads":370,"./rules/ProvidedRequiredArguments":372,"./rules/ScalarLeafs":373,"./rules/SingleFieldSubscriptions":374,"./rules/UniqueArgumentNames":375,"./rules/UniqueDirectivesPerLocation":377,"./rules/UniqueFragmentNames":380,"./rules/UniqueInputFieldNames":381,"./rules/UniqueOperationNames":382,"./rules/UniqueVariableNames":385,"./rules/ValuesOfCorrectType":386,"./rules/VariablesAreInputTypes":387,"./rules/VariablesInAllowedPosition":388,"./specifiedRules":389,"./validate":390}],356:[function(require,module,exports){
  59150. "use strict";
  59151. Object.defineProperty(exports, "__esModule", {
  59152. value: true
  59153. });
  59154. exports.nonExecutableDefinitionMessage = nonExecutableDefinitionMessage;
  59155. exports.ExecutableDefinitions = ExecutableDefinitions;
  59156. var _GraphQLError = require("../../error/GraphQLError");
  59157. var _kinds = require("../../language/kinds");
  59158. var _predicates = require("../../language/predicates");
  59159. /**
  59160. * Copyright (c) 2015-present, Facebook, Inc.
  59161. *
  59162. * This source code is licensed under the MIT license found in the
  59163. * LICENSE file in the root directory of this source tree.
  59164. *
  59165. *
  59166. */
  59167. function nonExecutableDefinitionMessage(defName) {
  59168. return "The ".concat(defName, " definition is not executable.");
  59169. }
  59170. /**
  59171. * Executable definitions
  59172. *
  59173. * A GraphQL document is only valid for execution if all definitions are either
  59174. * operation or fragment definitions.
  59175. */
  59176. function ExecutableDefinitions(context) {
  59177. return {
  59178. Document: function Document(node) {
  59179. var _iteratorNormalCompletion = true;
  59180. var _didIteratorError = false;
  59181. var _iteratorError = undefined;
  59182. try {
  59183. for (var _iterator = node.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  59184. var definition = _step.value;
  59185. if (!(0, _predicates.isExecutableDefinitionNode)(definition)) {
  59186. context.reportError(new _GraphQLError.GraphQLError(nonExecutableDefinitionMessage(definition.kind === _kinds.Kind.SCHEMA_DEFINITION || definition.kind === _kinds.Kind.SCHEMA_EXTENSION ? 'schema' : definition.name.value), [definition]));
  59187. }
  59188. }
  59189. } catch (err) {
  59190. _didIteratorError = true;
  59191. _iteratorError = err;
  59192. } finally {
  59193. try {
  59194. if (!_iteratorNormalCompletion && _iterator.return != null) {
  59195. _iterator.return();
  59196. }
  59197. } finally {
  59198. if (_didIteratorError) {
  59199. throw _iteratorError;
  59200. }
  59201. }
  59202. }
  59203. return false;
  59204. }
  59205. };
  59206. }
  59207. },{"../../error/GraphQLError":275,"../../language/kinds":307,"../../language/predicates":311}],357:[function(require,module,exports){
  59208. "use strict";
  59209. Object.defineProperty(exports, "__esModule", {
  59210. value: true
  59211. });
  59212. exports.undefinedFieldMessage = undefinedFieldMessage;
  59213. exports.FieldsOnCorrectType = FieldsOnCorrectType;
  59214. var _GraphQLError = require("../../error/GraphQLError");
  59215. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  59216. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  59217. var _definition = require("../../type/definition");
  59218. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  59219. /**
  59220. * Copyright (c) 2015-present, Facebook, Inc.
  59221. *
  59222. * This source code is licensed under the MIT license found in the
  59223. * LICENSE file in the root directory of this source tree.
  59224. *
  59225. *
  59226. */
  59227. function undefinedFieldMessage(fieldName, type, suggestedTypeNames, suggestedFieldNames) {
  59228. var message = "Cannot query field \"".concat(fieldName, "\" on type \"").concat(type, "\".");
  59229. if (suggestedTypeNames.length !== 0) {
  59230. var suggestions = (0, _quotedOrList.default)(suggestedTypeNames);
  59231. message += " Did you mean to use an inline fragment on ".concat(suggestions, "?");
  59232. } else if (suggestedFieldNames.length !== 0) {
  59233. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedFieldNames), "?");
  59234. }
  59235. return message;
  59236. }
  59237. /**
  59238. * Fields on correct type
  59239. *
  59240. * A GraphQL document is only valid if all fields selected are defined by the
  59241. * parent type, or are an allowed meta field such as __typename.
  59242. */
  59243. function FieldsOnCorrectType(context) {
  59244. return {
  59245. Field: function Field(node) {
  59246. var type = context.getParentType();
  59247. if (type) {
  59248. var fieldDef = context.getFieldDef();
  59249. if (!fieldDef) {
  59250. // This field doesn't exist, lets look for suggestions.
  59251. var schema = context.getSchema();
  59252. var fieldName = node.name.value; // First determine if there are any suggested types to condition on.
  59253. var suggestedTypeNames = getSuggestedTypeNames(schema, type, fieldName); // If there are no suggested types, then perhaps this was a typo?
  59254. var suggestedFieldNames = suggestedTypeNames.length !== 0 ? [] : getSuggestedFieldNames(schema, type, fieldName); // Report an error, including helpful suggestions.
  59255. context.reportError(new _GraphQLError.GraphQLError(undefinedFieldMessage(fieldName, type.name, suggestedTypeNames, suggestedFieldNames), [node]));
  59256. }
  59257. }
  59258. }
  59259. };
  59260. }
  59261. /**
  59262. * Go through all of the implementations of type, as well as the interfaces that
  59263. * they implement. If any of those types include the provided field, suggest
  59264. * them, sorted by how often the type is referenced, starting with Interfaces.
  59265. */
  59266. function getSuggestedTypeNames(schema, type, fieldName) {
  59267. if ((0, _definition.isAbstractType)(type)) {
  59268. var suggestedObjectTypes = [];
  59269. var interfaceUsageCount = Object.create(null);
  59270. var _iteratorNormalCompletion = true;
  59271. var _didIteratorError = false;
  59272. var _iteratorError = undefined;
  59273. try {
  59274. for (var _iterator = schema.getPossibleTypes(type)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  59275. var possibleType = _step.value;
  59276. if (!possibleType.getFields()[fieldName]) {
  59277. continue;
  59278. } // This object type defines this field.
  59279. suggestedObjectTypes.push(possibleType.name);
  59280. var _iteratorNormalCompletion2 = true;
  59281. var _didIteratorError2 = false;
  59282. var _iteratorError2 = undefined;
  59283. try {
  59284. for (var _iterator2 = possibleType.getInterfaces()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  59285. var possibleInterface = _step2.value;
  59286. if (!possibleInterface.getFields()[fieldName]) {
  59287. continue;
  59288. } // This interface type defines this field.
  59289. interfaceUsageCount[possibleInterface.name] = (interfaceUsageCount[possibleInterface.name] || 0) + 1;
  59290. }
  59291. } catch (err) {
  59292. _didIteratorError2 = true;
  59293. _iteratorError2 = err;
  59294. } finally {
  59295. try {
  59296. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  59297. _iterator2.return();
  59298. }
  59299. } finally {
  59300. if (_didIteratorError2) {
  59301. throw _iteratorError2;
  59302. }
  59303. }
  59304. }
  59305. } // Suggest interface types based on how common they are.
  59306. } catch (err) {
  59307. _didIteratorError = true;
  59308. _iteratorError = err;
  59309. } finally {
  59310. try {
  59311. if (!_iteratorNormalCompletion && _iterator.return != null) {
  59312. _iterator.return();
  59313. }
  59314. } finally {
  59315. if (_didIteratorError) {
  59316. throw _iteratorError;
  59317. }
  59318. }
  59319. }
  59320. var suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(function (a, b) {
  59321. return interfaceUsageCount[b] - interfaceUsageCount[a];
  59322. }); // Suggest both interface and object types.
  59323. return suggestedInterfaceTypes.concat(suggestedObjectTypes);
  59324. } // Otherwise, must be an Object type, which does not have possible fields.
  59325. return [];
  59326. }
  59327. /**
  59328. * For the field name provided, determine if there are any similar field names
  59329. * that may be the result of a typo.
  59330. */
  59331. function getSuggestedFieldNames(schema, type, fieldName) {
  59332. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type)) {
  59333. var possibleFieldNames = Object.keys(type.getFields());
  59334. return (0, _suggestionList.default)(fieldName, possibleFieldNames);
  59335. } // Otherwise, must be a Union type, which does not define fields.
  59336. return [];
  59337. }
  59338. },{"../../error/GraphQLError":275,"../../jsutils/quotedOrList":302,"../../jsutils/suggestionList":303,"../../type/definition":323}],358:[function(require,module,exports){
  59339. "use strict";
  59340. Object.defineProperty(exports, "__esModule", {
  59341. value: true
  59342. });
  59343. exports.inlineFragmentOnNonCompositeErrorMessage = inlineFragmentOnNonCompositeErrorMessage;
  59344. exports.fragmentOnNonCompositeErrorMessage = fragmentOnNonCompositeErrorMessage;
  59345. exports.FragmentsOnCompositeTypes = FragmentsOnCompositeTypes;
  59346. var _GraphQLError = require("../../error/GraphQLError");
  59347. var _printer = require("../../language/printer");
  59348. var _definition = require("../../type/definition");
  59349. var _typeFromAST = require("../../utilities/typeFromAST");
  59350. /**
  59351. * Copyright (c) 2015-present, Facebook, Inc.
  59352. *
  59353. * This source code is licensed under the MIT license found in the
  59354. * LICENSE file in the root directory of this source tree.
  59355. *
  59356. *
  59357. */
  59358. function inlineFragmentOnNonCompositeErrorMessage(type) {
  59359. return "Fragment cannot condition on non composite type \"".concat(type, "\".");
  59360. }
  59361. function fragmentOnNonCompositeErrorMessage(fragName, type) {
  59362. return "Fragment \"".concat(fragName, "\" cannot condition on non composite ") + "type \"".concat(type, "\".");
  59363. }
  59364. /**
  59365. * Fragments on composite type
  59366. *
  59367. * Fragments use a type condition to determine if they apply, since fragments
  59368. * can only be spread into a composite type (object, interface, or union), the
  59369. * type condition must also be a composite type.
  59370. */
  59371. function FragmentsOnCompositeTypes(context) {
  59372. return {
  59373. InlineFragment: function InlineFragment(node) {
  59374. var typeCondition = node.typeCondition;
  59375. if (typeCondition) {
  59376. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition);
  59377. if (type && !(0, _definition.isCompositeType)(type)) {
  59378. context.reportError(new _GraphQLError.GraphQLError(inlineFragmentOnNonCompositeErrorMessage((0, _printer.print)(typeCondition)), [typeCondition]));
  59379. }
  59380. }
  59381. },
  59382. FragmentDefinition: function FragmentDefinition(node) {
  59383. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.typeCondition);
  59384. if (type && !(0, _definition.isCompositeType)(type)) {
  59385. context.reportError(new _GraphQLError.GraphQLError(fragmentOnNonCompositeErrorMessage(node.name.value, (0, _printer.print)(node.typeCondition)), [node.typeCondition]));
  59386. }
  59387. }
  59388. };
  59389. }
  59390. },{"../../error/GraphQLError":275,"../../language/printer":312,"../../type/definition":323,"../../utilities/typeFromAST":351}],359:[function(require,module,exports){
  59391. "use strict";
  59392. Object.defineProperty(exports, "__esModule", {
  59393. value: true
  59394. });
  59395. exports.unknownArgMessage = unknownArgMessage;
  59396. exports.unknownDirectiveArgMessage = unknownDirectiveArgMessage;
  59397. exports.KnownArgumentNames = KnownArgumentNames;
  59398. exports.KnownArgumentNamesOnDirectives = KnownArgumentNamesOnDirectives;
  59399. var _GraphQLError = require("../../error/GraphQLError");
  59400. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  59401. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  59402. var _kinds = require("../../language/kinds");
  59403. var _directives = require("../../type/directives");
  59404. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  59405. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  59406. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  59407. function unknownArgMessage(argName, fieldName, typeName, suggestedArgs) {
  59408. var message = "Unknown argument \"".concat(argName, "\" on field \"").concat(fieldName, "\" of ") + "type \"".concat(typeName, "\".");
  59409. if (suggestedArgs.length) {
  59410. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedArgs), "?");
  59411. }
  59412. return message;
  59413. }
  59414. function unknownDirectiveArgMessage(argName, directiveName, suggestedArgs) {
  59415. var message = "Unknown argument \"".concat(argName, "\" on directive \"@").concat(directiveName, "\".");
  59416. if (suggestedArgs.length) {
  59417. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedArgs), "?");
  59418. }
  59419. return message;
  59420. }
  59421. /**
  59422. * Known argument names
  59423. *
  59424. * A GraphQL field is only valid if all supplied arguments are defined by
  59425. * that field.
  59426. */
  59427. function KnownArgumentNames(context) {
  59428. return _objectSpread({}, KnownArgumentNamesOnDirectives(context), {
  59429. Argument: function Argument(argNode) {
  59430. var argDef = context.getArgument();
  59431. var fieldDef = context.getFieldDef();
  59432. var parentType = context.getParentType();
  59433. if (!argDef && fieldDef && parentType) {
  59434. var argName = argNode.name.value;
  59435. var knownArgsNames = fieldDef.args.map(function (arg) {
  59436. return arg.name;
  59437. });
  59438. context.reportError(new _GraphQLError.GraphQLError(unknownArgMessage(argName, fieldDef.name, parentType.name, (0, _suggestionList.default)(argName, knownArgsNames)), argNode));
  59439. }
  59440. }
  59441. });
  59442. } // @internal
  59443. function KnownArgumentNamesOnDirectives(context) {
  59444. var directiveArgs = Object.create(null);
  59445. var schema = context.getSchema();
  59446. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  59447. var _iteratorNormalCompletion = true;
  59448. var _didIteratorError = false;
  59449. var _iteratorError = undefined;
  59450. try {
  59451. for (var _iterator = definedDirectives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  59452. var directive = _step.value;
  59453. directiveArgs[directive.name] = directive.args.map(function (arg) {
  59454. return arg.name;
  59455. });
  59456. }
  59457. } catch (err) {
  59458. _didIteratorError = true;
  59459. _iteratorError = err;
  59460. } finally {
  59461. try {
  59462. if (!_iteratorNormalCompletion && _iterator.return != null) {
  59463. _iterator.return();
  59464. }
  59465. } finally {
  59466. if (_didIteratorError) {
  59467. throw _iteratorError;
  59468. }
  59469. }
  59470. }
  59471. var astDefinitions = context.getDocument().definitions;
  59472. var _iteratorNormalCompletion2 = true;
  59473. var _didIteratorError2 = false;
  59474. var _iteratorError2 = undefined;
  59475. try {
  59476. for (var _iterator2 = astDefinitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  59477. var def = _step2.value;
  59478. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  59479. directiveArgs[def.name.value] = def.arguments ? def.arguments.map(function (arg) {
  59480. return arg.name.value;
  59481. }) : [];
  59482. }
  59483. }
  59484. } catch (err) {
  59485. _didIteratorError2 = true;
  59486. _iteratorError2 = err;
  59487. } finally {
  59488. try {
  59489. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  59490. _iterator2.return();
  59491. }
  59492. } finally {
  59493. if (_didIteratorError2) {
  59494. throw _iteratorError2;
  59495. }
  59496. }
  59497. }
  59498. return {
  59499. Directive: function Directive(directiveNode) {
  59500. var directiveName = directiveNode.name.value;
  59501. var knownArgs = directiveArgs[directiveName];
  59502. if (directiveNode.arguments && knownArgs) {
  59503. var _iteratorNormalCompletion3 = true;
  59504. var _didIteratorError3 = false;
  59505. var _iteratorError3 = undefined;
  59506. try {
  59507. for (var _iterator3 = directiveNode.arguments[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  59508. var argNode = _step3.value;
  59509. var argName = argNode.name.value;
  59510. if (knownArgs.indexOf(argName) === -1) {
  59511. var suggestions = (0, _suggestionList.default)(argName, knownArgs);
  59512. context.reportError(new _GraphQLError.GraphQLError(unknownDirectiveArgMessage(argName, directiveName, suggestions), argNode));
  59513. }
  59514. }
  59515. } catch (err) {
  59516. _didIteratorError3 = true;
  59517. _iteratorError3 = err;
  59518. } finally {
  59519. try {
  59520. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  59521. _iterator3.return();
  59522. }
  59523. } finally {
  59524. if (_didIteratorError3) {
  59525. throw _iteratorError3;
  59526. }
  59527. }
  59528. }
  59529. }
  59530. return false;
  59531. }
  59532. };
  59533. }
  59534. },{"../../error/GraphQLError":275,"../../jsutils/quotedOrList":302,"../../jsutils/suggestionList":303,"../../language/kinds":307,"../../type/directives":324}],360:[function(require,module,exports){
  59535. "use strict";
  59536. Object.defineProperty(exports, "__esModule", {
  59537. value: true
  59538. });
  59539. exports.unknownDirectiveMessage = unknownDirectiveMessage;
  59540. exports.misplacedDirectiveMessage = misplacedDirectiveMessage;
  59541. exports.KnownDirectives = KnownDirectives;
  59542. var _GraphQLError = require("../../error/GraphQLError");
  59543. var _kinds = require("../../language/kinds");
  59544. var _directiveLocation = require("../../language/directiveLocation");
  59545. var _directives = require("../../type/directives");
  59546. /**
  59547. * Copyright (c) 2015-present, Facebook, Inc.
  59548. *
  59549. * This source code is licensed under the MIT license found in the
  59550. * LICENSE file in the root directory of this source tree.
  59551. *
  59552. *
  59553. */
  59554. function unknownDirectiveMessage(directiveName) {
  59555. return "Unknown directive \"".concat(directiveName, "\".");
  59556. }
  59557. function misplacedDirectiveMessage(directiveName, location) {
  59558. return "Directive \"".concat(directiveName, "\" may not be used on ").concat(location, ".");
  59559. }
  59560. /**
  59561. * Known directives
  59562. *
  59563. * A GraphQL document is only valid if all `@directives` are known by the
  59564. * schema and legally positioned.
  59565. */
  59566. function KnownDirectives(context) {
  59567. var locationsMap = Object.create(null);
  59568. var schema = context.getSchema();
  59569. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  59570. var _iteratorNormalCompletion = true;
  59571. var _didIteratorError = false;
  59572. var _iteratorError = undefined;
  59573. try {
  59574. for (var _iterator = definedDirectives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  59575. var directive = _step.value;
  59576. locationsMap[directive.name] = directive.locations;
  59577. }
  59578. } catch (err) {
  59579. _didIteratorError = true;
  59580. _iteratorError = err;
  59581. } finally {
  59582. try {
  59583. if (!_iteratorNormalCompletion && _iterator.return != null) {
  59584. _iterator.return();
  59585. }
  59586. } finally {
  59587. if (_didIteratorError) {
  59588. throw _iteratorError;
  59589. }
  59590. }
  59591. }
  59592. var astDefinitions = context.getDocument().definitions;
  59593. var _iteratorNormalCompletion2 = true;
  59594. var _didIteratorError2 = false;
  59595. var _iteratorError2 = undefined;
  59596. try {
  59597. for (var _iterator2 = astDefinitions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  59598. var def = _step2.value;
  59599. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  59600. locationsMap[def.name.value] = def.locations.map(function (name) {
  59601. return name.value;
  59602. });
  59603. }
  59604. }
  59605. } catch (err) {
  59606. _didIteratorError2 = true;
  59607. _iteratorError2 = err;
  59608. } finally {
  59609. try {
  59610. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  59611. _iterator2.return();
  59612. }
  59613. } finally {
  59614. if (_didIteratorError2) {
  59615. throw _iteratorError2;
  59616. }
  59617. }
  59618. }
  59619. return {
  59620. Directive: function Directive(node, key, parent, path, ancestors) {
  59621. var name = node.name.value;
  59622. var locations = locationsMap[name];
  59623. if (!locations) {
  59624. context.reportError(new _GraphQLError.GraphQLError(unknownDirectiveMessage(name), [node]));
  59625. return;
  59626. }
  59627. var candidateLocation = getDirectiveLocationForASTPath(ancestors);
  59628. if (candidateLocation && locations.indexOf(candidateLocation) === -1) {
  59629. context.reportError(new _GraphQLError.GraphQLError(misplacedDirectiveMessage(name, candidateLocation), [node]));
  59630. }
  59631. }
  59632. };
  59633. }
  59634. function getDirectiveLocationForASTPath(ancestors) {
  59635. var appliedTo = ancestors[ancestors.length - 1];
  59636. if (!Array.isArray(appliedTo)) {
  59637. switch (appliedTo.kind) {
  59638. case _kinds.Kind.OPERATION_DEFINITION:
  59639. switch (appliedTo.operation) {
  59640. case 'query':
  59641. return _directiveLocation.DirectiveLocation.QUERY;
  59642. case 'mutation':
  59643. return _directiveLocation.DirectiveLocation.MUTATION;
  59644. case 'subscription':
  59645. return _directiveLocation.DirectiveLocation.SUBSCRIPTION;
  59646. }
  59647. break;
  59648. case _kinds.Kind.FIELD:
  59649. return _directiveLocation.DirectiveLocation.FIELD;
  59650. case _kinds.Kind.FRAGMENT_SPREAD:
  59651. return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD;
  59652. case _kinds.Kind.INLINE_FRAGMENT:
  59653. return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT;
  59654. case _kinds.Kind.FRAGMENT_DEFINITION:
  59655. return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION;
  59656. case _kinds.Kind.VARIABLE_DEFINITION:
  59657. return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION;
  59658. case _kinds.Kind.SCHEMA_DEFINITION:
  59659. case _kinds.Kind.SCHEMA_EXTENSION:
  59660. return _directiveLocation.DirectiveLocation.SCHEMA;
  59661. case _kinds.Kind.SCALAR_TYPE_DEFINITION:
  59662. case _kinds.Kind.SCALAR_TYPE_EXTENSION:
  59663. return _directiveLocation.DirectiveLocation.SCALAR;
  59664. case _kinds.Kind.OBJECT_TYPE_DEFINITION:
  59665. case _kinds.Kind.OBJECT_TYPE_EXTENSION:
  59666. return _directiveLocation.DirectiveLocation.OBJECT;
  59667. case _kinds.Kind.FIELD_DEFINITION:
  59668. return _directiveLocation.DirectiveLocation.FIELD_DEFINITION;
  59669. case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
  59670. case _kinds.Kind.INTERFACE_TYPE_EXTENSION:
  59671. return _directiveLocation.DirectiveLocation.INTERFACE;
  59672. case _kinds.Kind.UNION_TYPE_DEFINITION:
  59673. case _kinds.Kind.UNION_TYPE_EXTENSION:
  59674. return _directiveLocation.DirectiveLocation.UNION;
  59675. case _kinds.Kind.ENUM_TYPE_DEFINITION:
  59676. case _kinds.Kind.ENUM_TYPE_EXTENSION:
  59677. return _directiveLocation.DirectiveLocation.ENUM;
  59678. case _kinds.Kind.ENUM_VALUE_DEFINITION:
  59679. return _directiveLocation.DirectiveLocation.ENUM_VALUE;
  59680. case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
  59681. case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION:
  59682. return _directiveLocation.DirectiveLocation.INPUT_OBJECT;
  59683. case _kinds.Kind.INPUT_VALUE_DEFINITION:
  59684. var parentNode = ancestors[ancestors.length - 3];
  59685. return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION;
  59686. }
  59687. }
  59688. }
  59689. },{"../../error/GraphQLError":275,"../../language/directiveLocation":305,"../../language/kinds":307,"../../type/directives":324}],361:[function(require,module,exports){
  59690. "use strict";
  59691. Object.defineProperty(exports, "__esModule", {
  59692. value: true
  59693. });
  59694. exports.unknownFragmentMessage = unknownFragmentMessage;
  59695. exports.KnownFragmentNames = KnownFragmentNames;
  59696. var _GraphQLError = require("../../error/GraphQLError");
  59697. /**
  59698. * Copyright (c) 2015-present, Facebook, Inc.
  59699. *
  59700. * This source code is licensed under the MIT license found in the
  59701. * LICENSE file in the root directory of this source tree.
  59702. *
  59703. *
  59704. */
  59705. function unknownFragmentMessage(fragName) {
  59706. return "Unknown fragment \"".concat(fragName, "\".");
  59707. }
  59708. /**
  59709. * Known fragment names
  59710. *
  59711. * A GraphQL document is only valid if all `...Fragment` fragment spreads refer
  59712. * to fragments defined in the same document.
  59713. */
  59714. function KnownFragmentNames(context) {
  59715. return {
  59716. FragmentSpread: function FragmentSpread(node) {
  59717. var fragmentName = node.name.value;
  59718. var fragment = context.getFragment(fragmentName);
  59719. if (!fragment) {
  59720. context.reportError(new _GraphQLError.GraphQLError(unknownFragmentMessage(fragmentName), [node.name]));
  59721. }
  59722. }
  59723. };
  59724. }
  59725. },{"../../error/GraphQLError":275}],362:[function(require,module,exports){
  59726. "use strict";
  59727. Object.defineProperty(exports, "__esModule", {
  59728. value: true
  59729. });
  59730. exports.unknownTypeMessage = unknownTypeMessage;
  59731. exports.KnownTypeNames = KnownTypeNames;
  59732. var _GraphQLError = require("../../error/GraphQLError");
  59733. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  59734. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  59735. var _predicates = require("../../language/predicates");
  59736. var _scalars = require("../../type/scalars");
  59737. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  59738. /**
  59739. * Copyright (c) 2015-present, Facebook, Inc.
  59740. *
  59741. * This source code is licensed under the MIT license found in the
  59742. * LICENSE file in the root directory of this source tree.
  59743. *
  59744. *
  59745. */
  59746. function unknownTypeMessage(typeName, suggestedTypes) {
  59747. var message = "Unknown type \"".concat(typeName, "\".");
  59748. if (suggestedTypes.length) {
  59749. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedTypes), "?");
  59750. }
  59751. return message;
  59752. }
  59753. /**
  59754. * Known type names
  59755. *
  59756. * A GraphQL document is only valid if referenced types (specifically
  59757. * variable definitions and fragment conditions) are defined by the type schema.
  59758. */
  59759. function KnownTypeNames(context) {
  59760. var schema = context.getSchema();
  59761. var existingTypesMap = schema ? schema.getTypeMap() : Object.create(null);
  59762. var definedTypes = Object.create(null);
  59763. var _iteratorNormalCompletion = true;
  59764. var _didIteratorError = false;
  59765. var _iteratorError = undefined;
  59766. try {
  59767. for (var _iterator = context.getDocument().definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  59768. var def = _step.value;
  59769. if ((0, _predicates.isTypeDefinitionNode)(def)) {
  59770. definedTypes[def.name.value] = true;
  59771. }
  59772. }
  59773. } catch (err) {
  59774. _didIteratorError = true;
  59775. _iteratorError = err;
  59776. } finally {
  59777. try {
  59778. if (!_iteratorNormalCompletion && _iterator.return != null) {
  59779. _iterator.return();
  59780. }
  59781. } finally {
  59782. if (_didIteratorError) {
  59783. throw _iteratorError;
  59784. }
  59785. }
  59786. }
  59787. var typeNames = Object.keys(existingTypesMap).concat(Object.keys(definedTypes));
  59788. return {
  59789. NamedType: function NamedType(node, _1, parent, _2, ancestors) {
  59790. var typeName = node.name.value;
  59791. if (!existingTypesMap[typeName] && !definedTypes[typeName]) {
  59792. var definitionNode = ancestors[2] || parent;
  59793. var isSDL = isSDLNode(definitionNode);
  59794. if (isSDL && isSpecifiedScalarName(typeName)) {
  59795. return;
  59796. }
  59797. var suggestedTypes = (0, _suggestionList.default)(typeName, isSDL ? specifiedScalarsNames.concat(typeNames) : typeNames);
  59798. context.reportError(new _GraphQLError.GraphQLError(unknownTypeMessage(typeName, suggestedTypes), node));
  59799. }
  59800. }
  59801. };
  59802. }
  59803. var specifiedScalarsNames = _scalars.specifiedScalarTypes.map(function (type) {
  59804. return type.name;
  59805. });
  59806. function isSpecifiedScalarName(typeName) {
  59807. return specifiedScalarsNames.indexOf(typeName) !== -1;
  59808. }
  59809. function isSDLNode(value) {
  59810. return Boolean(value && !Array.isArray(value) && ((0, _predicates.isTypeSystemDefinitionNode)(value) || (0, _predicates.isTypeSystemExtensionNode)(value)));
  59811. }
  59812. },{"../../error/GraphQLError":275,"../../jsutils/quotedOrList":302,"../../jsutils/suggestionList":303,"../../language/predicates":311,"../../type/scalars":327}],363:[function(require,module,exports){
  59813. "use strict";
  59814. Object.defineProperty(exports, "__esModule", {
  59815. value: true
  59816. });
  59817. exports.anonOperationNotAloneMessage = anonOperationNotAloneMessage;
  59818. exports.LoneAnonymousOperation = LoneAnonymousOperation;
  59819. var _GraphQLError = require("../../error/GraphQLError");
  59820. var _kinds = require("../../language/kinds");
  59821. /**
  59822. * Copyright (c) 2015-present, Facebook, Inc.
  59823. *
  59824. * This source code is licensed under the MIT license found in the
  59825. * LICENSE file in the root directory of this source tree.
  59826. *
  59827. *
  59828. */
  59829. function anonOperationNotAloneMessage() {
  59830. return 'This anonymous operation must be the only defined operation.';
  59831. }
  59832. /**
  59833. * Lone anonymous operation
  59834. *
  59835. * A GraphQL document is only valid if when it contains an anonymous operation
  59836. * (the query short-hand) that it contains only that one operation definition.
  59837. */
  59838. function LoneAnonymousOperation(context) {
  59839. var operationCount = 0;
  59840. return {
  59841. Document: function Document(node) {
  59842. operationCount = node.definitions.filter(function (definition) {
  59843. return definition.kind === _kinds.Kind.OPERATION_DEFINITION;
  59844. }).length;
  59845. },
  59846. OperationDefinition: function OperationDefinition(node) {
  59847. if (!node.name && operationCount > 1) {
  59848. context.reportError(new _GraphQLError.GraphQLError(anonOperationNotAloneMessage(), [node]));
  59849. }
  59850. }
  59851. };
  59852. }
  59853. },{"../../error/GraphQLError":275,"../../language/kinds":307}],364:[function(require,module,exports){
  59854. "use strict";
  59855. Object.defineProperty(exports, "__esModule", {
  59856. value: true
  59857. });
  59858. exports.schemaDefinitionNotAloneMessage = schemaDefinitionNotAloneMessage;
  59859. exports.canNotDefineSchemaWithinExtensionMessage = canNotDefineSchemaWithinExtensionMessage;
  59860. exports.LoneSchemaDefinition = LoneSchemaDefinition;
  59861. var _GraphQLError = require("../../error/GraphQLError");
  59862. /**
  59863. * Copyright (c) 2018-present, Facebook, Inc.
  59864. *
  59865. * This source code is licensed under the MIT license found in the
  59866. * LICENSE file in the root directory of this source tree.
  59867. *
  59868. *
  59869. */
  59870. function schemaDefinitionNotAloneMessage() {
  59871. return 'Must provide only one schema definition.';
  59872. }
  59873. function canNotDefineSchemaWithinExtensionMessage() {
  59874. return 'Cannot define a new schema within a schema extension.';
  59875. }
  59876. /**
  59877. * Lone Schema definition
  59878. *
  59879. * A GraphQL document is only valid if it contains only one schema definition.
  59880. */
  59881. function LoneSchemaDefinition(context) {
  59882. var oldSchema = context.getSchema();
  59883. var alreadyDefined = oldSchema && (oldSchema.astNode || oldSchema.getQueryType() || oldSchema.getMutationType() || oldSchema.getSubscriptionType());
  59884. var schemaDefinitionsCount = 0;
  59885. return {
  59886. SchemaDefinition: function SchemaDefinition(node) {
  59887. if (alreadyDefined) {
  59888. context.reportError(new _GraphQLError.GraphQLError(canNotDefineSchemaWithinExtensionMessage(), node));
  59889. return;
  59890. }
  59891. if (schemaDefinitionsCount > 0) {
  59892. context.reportError(new _GraphQLError.GraphQLError(schemaDefinitionNotAloneMessage(), node));
  59893. }
  59894. ++schemaDefinitionsCount;
  59895. }
  59896. };
  59897. }
  59898. },{"../../error/GraphQLError":275}],365:[function(require,module,exports){
  59899. "use strict";
  59900. Object.defineProperty(exports, "__esModule", {
  59901. value: true
  59902. });
  59903. exports.cycleErrorMessage = cycleErrorMessage;
  59904. exports.NoFragmentCycles = NoFragmentCycles;
  59905. var _GraphQLError = require("../../error/GraphQLError");
  59906. /**
  59907. * Copyright (c) 2015-present, Facebook, Inc.
  59908. *
  59909. * This source code is licensed under the MIT license found in the
  59910. * LICENSE file in the root directory of this source tree.
  59911. *
  59912. *
  59913. */
  59914. function cycleErrorMessage(fragName, spreadNames) {
  59915. var via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
  59916. return "Cannot spread fragment \"".concat(fragName, "\" within itself").concat(via, ".");
  59917. }
  59918. function NoFragmentCycles(context) {
  59919. // Tracks already visited fragments to maintain O(N) and to ensure that cycles
  59920. // are not redundantly reported.
  59921. var visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors
  59922. var spreadPath = []; // Position in the spread path
  59923. var spreadPathIndexByName = Object.create(null);
  59924. return {
  59925. OperationDefinition: function OperationDefinition() {
  59926. return false;
  59927. },
  59928. FragmentDefinition: function FragmentDefinition(node) {
  59929. detectCycleRecursive(node);
  59930. return false;
  59931. }
  59932. }; // This does a straight-forward DFS to find cycles.
  59933. // It does not terminate when a cycle was found but continues to explore
  59934. // the graph to find all possible cycles.
  59935. function detectCycleRecursive(fragment) {
  59936. if (visitedFrags[fragment.name.value]) {
  59937. return;
  59938. }
  59939. var fragmentName = fragment.name.value;
  59940. visitedFrags[fragmentName] = true;
  59941. var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
  59942. if (spreadNodes.length === 0) {
  59943. return;
  59944. }
  59945. spreadPathIndexByName[fragmentName] = spreadPath.length;
  59946. for (var i = 0; i < spreadNodes.length; i++) {
  59947. var spreadNode = spreadNodes[i];
  59948. var spreadName = spreadNode.name.value;
  59949. var cycleIndex = spreadPathIndexByName[spreadName];
  59950. spreadPath.push(spreadNode);
  59951. if (cycleIndex === undefined) {
  59952. var spreadFragment = context.getFragment(spreadName);
  59953. if (spreadFragment) {
  59954. detectCycleRecursive(spreadFragment);
  59955. }
  59956. } else {
  59957. var cyclePath = spreadPath.slice(cycleIndex);
  59958. var fragmentNames = cyclePath.slice(0, -1).map(function (s) {
  59959. return s.name.value;
  59960. });
  59961. context.reportError(new _GraphQLError.GraphQLError(cycleErrorMessage(spreadName, fragmentNames), cyclePath));
  59962. }
  59963. spreadPath.pop();
  59964. }
  59965. spreadPathIndexByName[fragmentName] = undefined;
  59966. }
  59967. }
  59968. },{"../../error/GraphQLError":275}],366:[function(require,module,exports){
  59969. "use strict";
  59970. Object.defineProperty(exports, "__esModule", {
  59971. value: true
  59972. });
  59973. exports.undefinedVarMessage = undefinedVarMessage;
  59974. exports.NoUndefinedVariables = NoUndefinedVariables;
  59975. var _GraphQLError = require("../../error/GraphQLError");
  59976. /**
  59977. * Copyright (c) 2015-present, Facebook, Inc.
  59978. *
  59979. * This source code is licensed under the MIT license found in the
  59980. * LICENSE file in the root directory of this source tree.
  59981. *
  59982. *
  59983. */
  59984. function undefinedVarMessage(varName, opName) {
  59985. return opName ? "Variable \"$".concat(varName, "\" is not defined by operation \"").concat(opName, "\".") : "Variable \"$".concat(varName, "\" is not defined.");
  59986. }
  59987. /**
  59988. * No undefined variables
  59989. *
  59990. * A GraphQL operation is only valid if all variables encountered, both directly
  59991. * and via fragment spreads, are defined by that operation.
  59992. */
  59993. function NoUndefinedVariables(context) {
  59994. var variableNameDefined = Object.create(null);
  59995. return {
  59996. OperationDefinition: {
  59997. enter: function enter() {
  59998. variableNameDefined = Object.create(null);
  59999. },
  60000. leave: function leave(operation) {
  60001. var usages = context.getRecursiveVariableUsages(operation);
  60002. var _iteratorNormalCompletion = true;
  60003. var _didIteratorError = false;
  60004. var _iteratorError = undefined;
  60005. try {
  60006. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60007. var _ref2 = _step.value;
  60008. var node = _ref2.node;
  60009. var varName = node.name.value;
  60010. if (variableNameDefined[varName] !== true) {
  60011. context.reportError(new _GraphQLError.GraphQLError(undefinedVarMessage(varName, operation.name && operation.name.value), [node, operation]));
  60012. }
  60013. }
  60014. } catch (err) {
  60015. _didIteratorError = true;
  60016. _iteratorError = err;
  60017. } finally {
  60018. try {
  60019. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60020. _iterator.return();
  60021. }
  60022. } finally {
  60023. if (_didIteratorError) {
  60024. throw _iteratorError;
  60025. }
  60026. }
  60027. }
  60028. }
  60029. },
  60030. VariableDefinition: function VariableDefinition(node) {
  60031. variableNameDefined[node.variable.name.value] = true;
  60032. }
  60033. };
  60034. }
  60035. },{"../../error/GraphQLError":275}],367:[function(require,module,exports){
  60036. "use strict";
  60037. Object.defineProperty(exports, "__esModule", {
  60038. value: true
  60039. });
  60040. exports.unusedFragMessage = unusedFragMessage;
  60041. exports.NoUnusedFragments = NoUnusedFragments;
  60042. var _GraphQLError = require("../../error/GraphQLError");
  60043. /**
  60044. * Copyright (c) 2015-present, Facebook, Inc.
  60045. *
  60046. * This source code is licensed under the MIT license found in the
  60047. * LICENSE file in the root directory of this source tree.
  60048. *
  60049. *
  60050. */
  60051. function unusedFragMessage(fragName) {
  60052. return "Fragment \"".concat(fragName, "\" is never used.");
  60053. }
  60054. /**
  60055. * No unused fragments
  60056. *
  60057. * A GraphQL document is only valid if all fragment definitions are spread
  60058. * within operations, or spread within other fragments spread within operations.
  60059. */
  60060. function NoUnusedFragments(context) {
  60061. var operationDefs = [];
  60062. var fragmentDefs = [];
  60063. return {
  60064. OperationDefinition: function OperationDefinition(node) {
  60065. operationDefs.push(node);
  60066. return false;
  60067. },
  60068. FragmentDefinition: function FragmentDefinition(node) {
  60069. fragmentDefs.push(node);
  60070. return false;
  60071. },
  60072. Document: {
  60073. leave: function leave() {
  60074. var fragmentNameUsed = Object.create(null);
  60075. for (var _i = 0; _i < operationDefs.length; _i++) {
  60076. var operation = operationDefs[_i];
  60077. var _iteratorNormalCompletion = true;
  60078. var _didIteratorError = false;
  60079. var _iteratorError = undefined;
  60080. try {
  60081. for (var _iterator = context.getRecursivelyReferencedFragments(operation)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60082. var fragment = _step.value;
  60083. fragmentNameUsed[fragment.name.value] = true;
  60084. }
  60085. } catch (err) {
  60086. _didIteratorError = true;
  60087. _iteratorError = err;
  60088. } finally {
  60089. try {
  60090. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60091. _iterator.return();
  60092. }
  60093. } finally {
  60094. if (_didIteratorError) {
  60095. throw _iteratorError;
  60096. }
  60097. }
  60098. }
  60099. }
  60100. for (var _i2 = 0; _i2 < fragmentDefs.length; _i2++) {
  60101. var fragmentDef = fragmentDefs[_i2];
  60102. var fragName = fragmentDef.name.value;
  60103. if (fragmentNameUsed[fragName] !== true) {
  60104. context.reportError(new _GraphQLError.GraphQLError(unusedFragMessage(fragName), [fragmentDef]));
  60105. }
  60106. }
  60107. }
  60108. }
  60109. };
  60110. }
  60111. },{"../../error/GraphQLError":275}],368:[function(require,module,exports){
  60112. "use strict";
  60113. Object.defineProperty(exports, "__esModule", {
  60114. value: true
  60115. });
  60116. exports.unusedVariableMessage = unusedVariableMessage;
  60117. exports.NoUnusedVariables = NoUnusedVariables;
  60118. var _GraphQLError = require("../../error/GraphQLError");
  60119. /**
  60120. * Copyright (c) 2015-present, Facebook, Inc.
  60121. *
  60122. * This source code is licensed under the MIT license found in the
  60123. * LICENSE file in the root directory of this source tree.
  60124. *
  60125. *
  60126. */
  60127. function unusedVariableMessage(varName, opName) {
  60128. return opName ? "Variable \"$".concat(varName, "\" is never used in operation \"").concat(opName, "\".") : "Variable \"$".concat(varName, "\" is never used.");
  60129. }
  60130. /**
  60131. * No unused variables
  60132. *
  60133. * A GraphQL operation is only valid if all variables defined by an operation
  60134. * are used, either directly or within a spread fragment.
  60135. */
  60136. function NoUnusedVariables(context) {
  60137. var variableDefs = [];
  60138. return {
  60139. OperationDefinition: {
  60140. enter: function enter() {
  60141. variableDefs = [];
  60142. },
  60143. leave: function leave(operation) {
  60144. var variableNameUsed = Object.create(null);
  60145. var usages = context.getRecursiveVariableUsages(operation);
  60146. var opName = operation.name ? operation.name.value : null;
  60147. var _iteratorNormalCompletion = true;
  60148. var _didIteratorError = false;
  60149. var _iteratorError = undefined;
  60150. try {
  60151. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60152. var _ref2 = _step.value;
  60153. var node = _ref2.node;
  60154. variableNameUsed[node.name.value] = true;
  60155. }
  60156. } catch (err) {
  60157. _didIteratorError = true;
  60158. _iteratorError = err;
  60159. } finally {
  60160. try {
  60161. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60162. _iterator.return();
  60163. }
  60164. } finally {
  60165. if (_didIteratorError) {
  60166. throw _iteratorError;
  60167. }
  60168. }
  60169. }
  60170. for (var _i = 0; _i < variableDefs.length; _i++) {
  60171. var variableDef = variableDefs[_i];
  60172. var variableName = variableDef.variable.name.value;
  60173. if (variableNameUsed[variableName] !== true) {
  60174. context.reportError(new _GraphQLError.GraphQLError(unusedVariableMessage(variableName, opName), [variableDef]));
  60175. }
  60176. }
  60177. }
  60178. },
  60179. VariableDefinition: function VariableDefinition(def) {
  60180. variableDefs.push(def);
  60181. }
  60182. };
  60183. }
  60184. },{"../../error/GraphQLError":275}],369:[function(require,module,exports){
  60185. "use strict";
  60186. Object.defineProperty(exports, "__esModule", {
  60187. value: true
  60188. });
  60189. exports.fieldsConflictMessage = fieldsConflictMessage;
  60190. exports.OverlappingFieldsCanBeMerged = OverlappingFieldsCanBeMerged;
  60191. var _find = _interopRequireDefault(require("../../polyfills/find"));
  60192. var _objectEntries = _interopRequireDefault(require("../../polyfills/objectEntries"));
  60193. var _GraphQLError = require("../../error/GraphQLError");
  60194. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  60195. var _kinds = require("../../language/kinds");
  60196. var _printer = require("../../language/printer");
  60197. var _definition = require("../../type/definition");
  60198. var _typeFromAST = require("../../utilities/typeFromAST");
  60199. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  60200. /**
  60201. * Copyright (c) 2015-present, Facebook, Inc.
  60202. *
  60203. * This source code is licensed under the MIT license found in the
  60204. * LICENSE file in the root directory of this source tree.
  60205. *
  60206. *
  60207. */
  60208. function fieldsConflictMessage(responseName, reason) {
  60209. return "Fields \"".concat(responseName, "\" conflict because ").concat(reasonMessage(reason), ". ") + 'Use different aliases on the fields to fetch both if this was intentional.';
  60210. }
  60211. function reasonMessage(reason) {
  60212. if (Array.isArray(reason)) {
  60213. return reason.map(function (_ref) {
  60214. var responseName = _ref[0],
  60215. subreason = _ref[1];
  60216. return "subfields \"".concat(responseName, "\" conflict because ").concat(reasonMessage(subreason));
  60217. }).join(' and ');
  60218. }
  60219. return reason;
  60220. }
  60221. /**
  60222. * Overlapping fields can be merged
  60223. *
  60224. * A selection set is only valid if all fields (including spreading any
  60225. * fragments) either correspond to distinct response names or can be merged
  60226. * without ambiguity.
  60227. */
  60228. function OverlappingFieldsCanBeMerged(context) {
  60229. // A memoization for when two fragments are compared "between" each other for
  60230. // conflicts. Two fragments may be compared many times, so memoizing this can
  60231. // dramatically improve the performance of this validator.
  60232. var comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given
  60233. // selection set. Selection sets may be asked for this information multiple
  60234. // times, so this improves the performance of this validator.
  60235. var cachedFieldsAndFragmentNames = new Map();
  60236. return {
  60237. SelectionSet: function SelectionSet(selectionSet) {
  60238. var conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, context.getParentType(), selectionSet);
  60239. for (var _i = 0; _i < conflicts.length; _i++) {
  60240. var _ref3 = conflicts[_i];
  60241. var _ref2$ = _ref3[0];
  60242. var responseName = _ref2$[0];
  60243. var reason = _ref2$[1];
  60244. var fields1 = _ref3[1];
  60245. var fields2 = _ref3[2];
  60246. context.reportError(new _GraphQLError.GraphQLError(fieldsConflictMessage(responseName, reason), fields1.concat(fields2)));
  60247. }
  60248. }
  60249. };
  60250. }
  60251. /**
  60252. * Algorithm:
  60253. *
  60254. * Conflicts occur when two fields exist in a query which will produce the same
  60255. * response name, but represent differing values, thus creating a conflict.
  60256. * The algorithm below finds all conflicts via making a series of comparisons
  60257. * between fields. In order to compare as few fields as possible, this makes
  60258. * a series of comparisons "within" sets of fields and "between" sets of fields.
  60259. *
  60260. * Given any selection set, a collection produces both a set of fields by
  60261. * also including all inline fragments, as well as a list of fragments
  60262. * referenced by fragment spreads.
  60263. *
  60264. * A) Each selection set represented in the document first compares "within" its
  60265. * collected set of fields, finding any conflicts between every pair of
  60266. * overlapping fields.
  60267. * Note: This is the *only time* that a the fields "within" a set are compared
  60268. * to each other. After this only fields "between" sets are compared.
  60269. *
  60270. * B) Also, if any fragment is referenced in a selection set, then a
  60271. * comparison is made "between" the original set of fields and the
  60272. * referenced fragment.
  60273. *
  60274. * C) Also, if multiple fragments are referenced, then comparisons
  60275. * are made "between" each referenced fragment.
  60276. *
  60277. * D) When comparing "between" a set of fields and a referenced fragment, first
  60278. * a comparison is made between each field in the original set of fields and
  60279. * each field in the the referenced set of fields.
  60280. *
  60281. * E) Also, if any fragment is referenced in the referenced selection set,
  60282. * then a comparison is made "between" the original set of fields and the
  60283. * referenced fragment (recursively referring to step D).
  60284. *
  60285. * F) When comparing "between" two fragments, first a comparison is made between
  60286. * each field in the first referenced set of fields and each field in the the
  60287. * second referenced set of fields.
  60288. *
  60289. * G) Also, any fragments referenced by the first must be compared to the
  60290. * second, and any fragments referenced by the second must be compared to the
  60291. * first (recursively referring to step F).
  60292. *
  60293. * H) When comparing two fields, if both have selection sets, then a comparison
  60294. * is made "between" both selection sets, first comparing the set of fields in
  60295. * the first selection set with the set of fields in the second.
  60296. *
  60297. * I) Also, if any fragment is referenced in either selection set, then a
  60298. * comparison is made "between" the other set of fields and the
  60299. * referenced fragment.
  60300. *
  60301. * J) Also, if two fragments are referenced in both selection sets, then a
  60302. * comparison is made "between" the two fragments.
  60303. *
  60304. */
  60305. // Find all conflicts found "within" a selection set, including those found
  60306. // via spreading in fragments. Called when visiting each SelectionSet in the
  60307. // GraphQL Document.
  60308. function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentType, selectionSet) {
  60309. var conflicts = [];
  60310. var _getFieldsAndFragment = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet),
  60311. fieldMap = _getFieldsAndFragment[0],
  60312. fragmentNames = _getFieldsAndFragment[1]; // (A) Find find all conflicts "within" the fields of this selection set.
  60313. // Note: this is the *only place* `collectConflictsWithin` is called.
  60314. collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap);
  60315. if (fragmentNames.length !== 0) {
  60316. // (B) Then collect conflicts between these fields and those represented by
  60317. // each spread fragment name found.
  60318. var comparedFragments = Object.create(null);
  60319. for (var i = 0; i < fragmentNames.length; i++) {
  60320. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, false, fieldMap, fragmentNames[i]); // (C) Then compare this fragment with all other fragments found in this
  60321. // selection set to collect conflicts between fragments spread together.
  60322. // This compares each item in the list of fragment names to every other
  60323. // item in that same list (except for itself).
  60324. for (var j = i + 1; j < fragmentNames.length; j++) {
  60325. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, fragmentNames[i], fragmentNames[j]);
  60326. }
  60327. }
  60328. }
  60329. return conflicts;
  60330. } // Collect all conflicts found between a set of fields and a fragment reference
  60331. // including via spreading in any nested fragments.
  60332. function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
  60333. // Memoize so a fragment is not compared for conflicts more than once.
  60334. if (comparedFragments[fragmentName]) {
  60335. return;
  60336. }
  60337. comparedFragments[fragmentName] = true;
  60338. var fragment = context.getFragment(fragmentName);
  60339. if (!fragment) {
  60340. return;
  60341. }
  60342. var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment),
  60343. fieldMap2 = _getReferencedFieldsA[0],
  60344. fragmentNames2 = _getReferencedFieldsA[1]; // Do not compare a fragment's fieldMap to itself.
  60345. if (fieldMap === fieldMap2) {
  60346. return;
  60347. } // (D) First collect any conflicts between the provided collection of fields
  60348. // and the collection of fields represented by the given fragment.
  60349. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fieldMap2); // (E) Then collect any conflicts between the provided collection of fields
  60350. // and any fragment names found in the given fragment.
  60351. for (var i = 0; i < fragmentNames2.length; i++) {
  60352. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentNames2[i]);
  60353. }
  60354. } // Collect all conflicts found between two fragments, including via spreading in
  60355. // any nested fragments.
  60356. function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentName2) {
  60357. // No need to compare a fragment to itself.
  60358. if (fragmentName1 === fragmentName2) {
  60359. return;
  60360. } // Memoize so two fragments are not compared for conflicts more than once.
  60361. if (comparedFragmentPairs.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {
  60362. return;
  60363. }
  60364. comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive);
  60365. var fragment1 = context.getFragment(fragmentName1);
  60366. var fragment2 = context.getFragment(fragmentName2);
  60367. if (!fragment1 || !fragment2) {
  60368. return;
  60369. }
  60370. var _getReferencedFieldsA2 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1),
  60371. fieldMap1 = _getReferencedFieldsA2[0],
  60372. fragmentNames1 = _getReferencedFieldsA2[1];
  60373. var _getReferencedFieldsA3 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2),
  60374. fieldMap2 = _getReferencedFieldsA3[0],
  60375. fragmentNames2 = _getReferencedFieldsA3[1]; // (F) First, collect all conflicts between these two collections of fields
  60376. // (not including any nested fragments).
  60377. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (G) Then collect conflicts between the first fragment and any nested
  60378. // fragments spread in the second fragment.
  60379. for (var j = 0; j < fragmentNames2.length; j++) {
  60380. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);
  60381. } // (G) Then collect conflicts between the second fragment and any nested
  60382. // fragments spread in the first fragment.
  60383. for (var i = 0; i < fragmentNames1.length; i++) {
  60384. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[i], fragmentName2);
  60385. }
  60386. } // Find all conflicts found between two selection sets, including those found
  60387. // via spreading in fragments. Called when determining if conflicts exist
  60388. // between the sub-fields of two overlapping fields.
  60389. function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {
  60390. var conflicts = [];
  60391. var _getFieldsAndFragment2 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1),
  60392. fieldMap1 = _getFieldsAndFragment2[0],
  60393. fragmentNames1 = _getFieldsAndFragment2[1];
  60394. var _getFieldsAndFragment3 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2),
  60395. fieldMap2 = _getFieldsAndFragment3[0],
  60396. fragmentNames2 = _getFieldsAndFragment3[1]; // (H) First, collect all conflicts between these two collections of field.
  60397. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fieldMap2); // (I) Then collect conflicts between the first collection of fields and
  60398. // those referenced by each fragment name associated with the second.
  60399. if (fragmentNames2.length !== 0) {
  60400. var comparedFragments = Object.create(null);
  60401. for (var j = 0; j < fragmentNames2.length; j++) {
  60402. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);
  60403. }
  60404. } // (I) Then collect conflicts between the second collection of fields and
  60405. // those referenced by each fragment name associated with the first.
  60406. if (fragmentNames1.length !== 0) {
  60407. var _comparedFragments = Object.create(null);
  60408. for (var i = 0; i < fragmentNames1.length; i++) {
  60409. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, _comparedFragments, comparedFragmentPairs, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);
  60410. }
  60411. } // (J) Also collect conflicts between any fragment names by the first and
  60412. // fragment names by the second. This compares each item in the first set of
  60413. // names to each item in the second set of names.
  60414. for (var _i2 = 0; _i2 < fragmentNames1.length; _i2++) {
  60415. for (var _j = 0; _j < fragmentNames2.length; _j++) {
  60416. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fragmentNames1[_i2], fragmentNames2[_j]);
  60417. }
  60418. }
  60419. return conflicts;
  60420. } // Collect all Conflicts "within" one collection of fields.
  60421. function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, fieldMap) {
  60422. // A field map is a keyed collection, where each key represents a response
  60423. // name and the value at that key is a list of all fields which provide that
  60424. // response name. For every response name, if there are multiple fields, they
  60425. var _iteratorNormalCompletion = true;
  60426. var _didIteratorError = false;
  60427. var _iteratorError = undefined;
  60428. try {
  60429. for (var _iterator = (0, _objectEntries.default)(fieldMap)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60430. var _ref5 = _step.value;
  60431. var responseName = _ref5[0];
  60432. var fields = _ref5[1];
  60433. // This compares every field in the list to every other field in this list
  60434. // (except to itself). If the list only has one item, nothing needs to
  60435. // be compared.
  60436. if (fields.length > 1) {
  60437. for (var i = 0; i < fields.length; i++) {
  60438. for (var j = i + 1; j < fields.length; j++) {
  60439. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, false, // within one collection is never mutually exclusive
  60440. responseName, fields[i], fields[j]);
  60441. if (conflict) {
  60442. conflicts.push(conflict);
  60443. }
  60444. }
  60445. }
  60446. }
  60447. }
  60448. } catch (err) {
  60449. _didIteratorError = true;
  60450. _iteratorError = err;
  60451. } finally {
  60452. try {
  60453. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60454. _iterator.return();
  60455. }
  60456. } finally {
  60457. if (_didIteratorError) {
  60458. throw _iteratorError;
  60459. }
  60460. }
  60461. }
  60462. } // Collect all Conflicts between two collections of fields. This is similar to,
  60463. // but different from the `collectConflictsWithin` function above. This check
  60464. // assumes that `collectConflictsWithin` has already been called on each
  60465. // provided collection of fields. This is true because this validator traverses
  60466. // each individual selection set.
  60467. function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {
  60468. // A field map is a keyed collection, where each key represents a response
  60469. // name and the value at that key is a list of all fields which provide that
  60470. // response name. For any response name which appears in both provided field
  60471. // maps, each field from the first field map must be compared to every field
  60472. // in the second field map to find potential conflicts.
  60473. var _arr = Object.keys(fieldMap1);
  60474. for (var _i3 = 0; _i3 < _arr.length; _i3++) {
  60475. var responseName = _arr[_i3];
  60476. var fields2 = fieldMap2[responseName];
  60477. if (fields2) {
  60478. var fields1 = fieldMap1[responseName];
  60479. for (var i = 0; i < fields1.length; i++) {
  60480. for (var j = 0; j < fields2.length; j++) {
  60481. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);
  60482. if (conflict) {
  60483. conflicts.push(conflict);
  60484. }
  60485. }
  60486. }
  60487. }
  60488. }
  60489. } // Determines if there is a conflict between two particular fields, including
  60490. // comparing their sub-fields.
  60491. function findConflict(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {
  60492. var parentType1 = field1[0],
  60493. node1 = field1[1],
  60494. def1 = field1[2];
  60495. var parentType2 = field2[0],
  60496. node2 = field2[1],
  60497. def2 = field2[2]; // If it is known that two fields could not possibly apply at the same
  60498. // time, due to the parent types, then it is safe to permit them to diverge
  60499. // in aliased field or arguments used as they will not present any ambiguity
  60500. // by differing.
  60501. // It is known that two parent types could never overlap if they are
  60502. // different Object types. Interface or Union types might overlap - if not
  60503. // in the current state of the schema, then perhaps in some future version,
  60504. // thus may not safely diverge.
  60505. var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && (0, _definition.isObjectType)(parentType1) && (0, _definition.isObjectType)(parentType2); // The return type for each field.
  60506. var type1 = def1 && def1.type;
  60507. var type2 = def2 && def2.type;
  60508. if (!areMutuallyExclusive) {
  60509. // Two aliases must refer to the same field.
  60510. var name1 = node1.name.value;
  60511. var name2 = node2.name.value;
  60512. if (name1 !== name2) {
  60513. return [[responseName, "".concat(name1, " and ").concat(name2, " are different fields")], [node1], [node2]];
  60514. } // Two field calls must have the same arguments.
  60515. if (!sameArguments(node1.arguments || [], node2.arguments || [])) {
  60516. return [[responseName, 'they have differing arguments'], [node1], [node2]];
  60517. }
  60518. }
  60519. if (type1 && type2 && doTypesConflict(type1, type2)) {
  60520. return [[responseName, "they return conflicting types ".concat((0, _inspect.default)(type1), " and ").concat((0, _inspect.default)(type2))], [node1], [node2]];
  60521. } // Collect and compare sub-fields. Use the same "visited fragment names" list
  60522. // for both collections so fields in a fragment reference are never
  60523. // compared to themselves.
  60524. var selectionSet1 = node1.selectionSet;
  60525. var selectionSet2 = node2.selectionSet;
  60526. if (selectionSet1 && selectionSet2) {
  60527. var conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, (0, _definition.getNamedType)(type1), selectionSet1, (0, _definition.getNamedType)(type2), selectionSet2);
  60528. return subfieldConflicts(conflicts, responseName, node1, node2);
  60529. }
  60530. }
  60531. function sameArguments(arguments1, arguments2) {
  60532. if (arguments1.length !== arguments2.length) {
  60533. return false;
  60534. }
  60535. return arguments1.every(function (argument1) {
  60536. var argument2 = (0, _find.default)(arguments2, function (argument) {
  60537. return argument.name.value === argument1.name.value;
  60538. });
  60539. if (!argument2) {
  60540. return false;
  60541. }
  60542. return sameValue(argument1.value, argument2.value);
  60543. });
  60544. }
  60545. function sameValue(value1, value2) {
  60546. return !value1 && !value2 || (0, _printer.print)(value1) === (0, _printer.print)(value2);
  60547. } // Two types conflict if both types could not apply to a value simultaneously.
  60548. // Composite types are ignored as their individual field types will be compared
  60549. // later recursively. However List and Non-Null types must match.
  60550. function doTypesConflict(type1, type2) {
  60551. if ((0, _definition.isListType)(type1)) {
  60552. return (0, _definition.isListType)(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;
  60553. }
  60554. if ((0, _definition.isListType)(type2)) {
  60555. return true;
  60556. }
  60557. if ((0, _definition.isNonNullType)(type1)) {
  60558. return (0, _definition.isNonNullType)(type2) ? doTypesConflict(type1.ofType, type2.ofType) : true;
  60559. }
  60560. if ((0, _definition.isNonNullType)(type2)) {
  60561. return true;
  60562. }
  60563. if ((0, _definition.isLeafType)(type1) || (0, _definition.isLeafType)(type2)) {
  60564. return type1 !== type2;
  60565. }
  60566. return false;
  60567. } // Given a selection set, return the collection of fields (a mapping of response
  60568. // name to field nodes and definitions) as well as a list of fragment names
  60569. // referenced via fragment spreads.
  60570. function getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {
  60571. var cached = cachedFieldsAndFragmentNames.get(selectionSet);
  60572. if (!cached) {
  60573. var nodeAndDefs = Object.create(null);
  60574. var fragmentNames = Object.create(null);
  60575. _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);
  60576. cached = [nodeAndDefs, Object.keys(fragmentNames)];
  60577. cachedFieldsAndFragmentNames.set(selectionSet, cached);
  60578. }
  60579. return cached;
  60580. } // Given a reference to a fragment, return the represented collection of fields
  60581. // as well as a list of nested fragment names referenced via fragment spreads.
  60582. function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
  60583. // Short-circuit building a type from the node if possible.
  60584. var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
  60585. if (cached) {
  60586. return cached;
  60587. }
  60588. var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
  60589. return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
  60590. }
  60591. function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
  60592. for (var i = 0; i < selectionSet.selections.length; i++) {
  60593. var selection = selectionSet.selections[i];
  60594. switch (selection.kind) {
  60595. case _kinds.Kind.FIELD:
  60596. var fieldName = selection.name.value;
  60597. var fieldDef = void 0;
  60598. if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
  60599. fieldDef = parentType.getFields()[fieldName];
  60600. }
  60601. var responseName = selection.alias ? selection.alias.value : fieldName;
  60602. if (!nodeAndDefs[responseName]) {
  60603. nodeAndDefs[responseName] = [];
  60604. }
  60605. nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
  60606. break;
  60607. case _kinds.Kind.FRAGMENT_SPREAD:
  60608. fragmentNames[selection.name.value] = true;
  60609. break;
  60610. case _kinds.Kind.INLINE_FRAGMENT:
  60611. var typeCondition = selection.typeCondition;
  60612. var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
  60613. _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
  60614. break;
  60615. }
  60616. }
  60617. } // Given a series of Conflicts which occurred between two sub-fields, generate
  60618. // a single Conflict.
  60619. function subfieldConflicts(conflicts, responseName, node1, node2) {
  60620. if (conflicts.length > 0) {
  60621. return [[responseName, conflicts.map(function (_ref6) {
  60622. var reason = _ref6[0];
  60623. return reason;
  60624. })], conflicts.reduce(function (allFields, _ref7) {
  60625. var fields1 = _ref7[1];
  60626. return allFields.concat(fields1);
  60627. }, [node1]), conflicts.reduce(function (allFields, _ref8) {
  60628. var fields2 = _ref8[2];
  60629. return allFields.concat(fields2);
  60630. }, [node2])];
  60631. }
  60632. }
  60633. /**
  60634. * A way to keep track of pairs of things when the ordering of the pair does
  60635. * not matter. We do this by maintaining a sort of double adjacency sets.
  60636. */
  60637. var PairSet =
  60638. /*#__PURE__*/
  60639. function () {
  60640. function PairSet() {
  60641. this._data = Object.create(null);
  60642. }
  60643. var _proto = PairSet.prototype;
  60644. _proto.has = function has(a, b, areMutuallyExclusive) {
  60645. var first = this._data[a];
  60646. var result = first && first[b];
  60647. if (result === undefined) {
  60648. return false;
  60649. } // areMutuallyExclusive being false is a superset of being true,
  60650. // hence if we want to know if this PairSet "has" these two with no
  60651. // exclusivity, we have to ensure it was added as such.
  60652. if (areMutuallyExclusive === false) {
  60653. return result === false;
  60654. }
  60655. return true;
  60656. };
  60657. _proto.add = function add(a, b, areMutuallyExclusive) {
  60658. _pairSetAdd(this._data, a, b, areMutuallyExclusive);
  60659. _pairSetAdd(this._data, b, a, areMutuallyExclusive);
  60660. };
  60661. return PairSet;
  60662. }();
  60663. function _pairSetAdd(data, a, b, areMutuallyExclusive) {
  60664. var map = data[a];
  60665. if (!map) {
  60666. map = Object.create(null);
  60667. data[a] = map;
  60668. }
  60669. map[b] = areMutuallyExclusive;
  60670. }
  60671. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../language/kinds":307,"../../language/printer":312,"../../polyfills/find":315,"../../polyfills/objectEntries":318,"../../type/definition":323,"../../utilities/typeFromAST":351}],370:[function(require,module,exports){
  60672. "use strict";
  60673. Object.defineProperty(exports, "__esModule", {
  60674. value: true
  60675. });
  60676. exports.typeIncompatibleSpreadMessage = typeIncompatibleSpreadMessage;
  60677. exports.typeIncompatibleAnonSpreadMessage = typeIncompatibleAnonSpreadMessage;
  60678. exports.PossibleFragmentSpreads = PossibleFragmentSpreads;
  60679. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  60680. var _GraphQLError = require("../../error/GraphQLError");
  60681. var _typeComparators = require("../../utilities/typeComparators");
  60682. var _typeFromAST = require("../../utilities/typeFromAST");
  60683. var _definition = require("../../type/definition");
  60684. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  60685. /**
  60686. * Copyright (c) 2015-present, Facebook, Inc.
  60687. *
  60688. * This source code is licensed under the MIT license found in the
  60689. * LICENSE file in the root directory of this source tree.
  60690. *
  60691. *
  60692. */
  60693. function typeIncompatibleSpreadMessage(fragName, parentType, fragType) {
  60694. return "Fragment \"".concat(fragName, "\" cannot be spread here as objects of ") + "type \"".concat(parentType, "\" can never be of type \"").concat(fragType, "\".");
  60695. }
  60696. function typeIncompatibleAnonSpreadMessage(parentType, fragType) {
  60697. return 'Fragment cannot be spread here as objects of ' + "type \"".concat(parentType, "\" can never be of type \"").concat(fragType, "\".");
  60698. }
  60699. /**
  60700. * Possible fragment spread
  60701. *
  60702. * A fragment spread is only valid if the type condition could ever possibly
  60703. * be true: if there is a non-empty intersection of the possible parent types,
  60704. * and possible types which pass the type condition.
  60705. */
  60706. function PossibleFragmentSpreads(context) {
  60707. return {
  60708. InlineFragment: function InlineFragment(node) {
  60709. var fragType = context.getType();
  60710. var parentType = context.getParentType();
  60711. if ((0, _definition.isCompositeType)(fragType) && (0, _definition.isCompositeType)(parentType) && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  60712. context.reportError(new _GraphQLError.GraphQLError(typeIncompatibleAnonSpreadMessage((0, _inspect.default)(parentType), (0, _inspect.default)(fragType)), [node]));
  60713. }
  60714. },
  60715. FragmentSpread: function FragmentSpread(node) {
  60716. var fragName = node.name.value;
  60717. var fragType = getFragmentType(context, fragName);
  60718. var parentType = context.getParentType();
  60719. if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  60720. context.reportError(new _GraphQLError.GraphQLError(typeIncompatibleSpreadMessage(fragName, (0, _inspect.default)(parentType), (0, _inspect.default)(fragType)), [node]));
  60721. }
  60722. }
  60723. };
  60724. }
  60725. function getFragmentType(context, name) {
  60726. var frag = context.getFragment(name);
  60727. if (frag) {
  60728. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition);
  60729. if ((0, _definition.isCompositeType)(type)) {
  60730. return type;
  60731. }
  60732. }
  60733. }
  60734. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../type/definition":323,"../../utilities/typeComparators":350,"../../utilities/typeFromAST":351}],371:[function(require,module,exports){
  60735. "use strict";
  60736. Object.defineProperty(exports, "__esModule", {
  60737. value: true
  60738. });
  60739. exports.extendingUnknownTypeMessage = extendingUnknownTypeMessage;
  60740. exports.extendingDifferentTypeKindMessage = extendingDifferentTypeKindMessage;
  60741. exports.PossibleTypeExtensions = PossibleTypeExtensions;
  60742. var _quotedOrList = _interopRequireDefault(require("../../jsutils/quotedOrList"));
  60743. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  60744. var _GraphQLError = require("../../error/GraphQLError");
  60745. var _kinds = require("../../language/kinds");
  60746. var _predicates = require("../../language/predicates");
  60747. var _definition = require("../../type/definition");
  60748. var _defKindToExtKind;
  60749. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  60750. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  60751. function extendingUnknownTypeMessage(typeName, suggestedTypes) {
  60752. var message = "Cannot extend type \"".concat(typeName, "\" because it does not defined.");
  60753. if (suggestedTypes.length) {
  60754. message += " Did you mean ".concat((0, _quotedOrList.default)(suggestedTypes), "?");
  60755. }
  60756. return message;
  60757. }
  60758. function extendingDifferentTypeKindMessage(typeName, kind) {
  60759. return "Cannot extend non-".concat(kind, " type \"").concat(typeName, "\".");
  60760. }
  60761. /**
  60762. * Possible type extension
  60763. *
  60764. * A type extension is only valid if the type defined and have the same kind.
  60765. */
  60766. function PossibleTypeExtensions(context) {
  60767. var schema = context.getSchema();
  60768. var definedTypes = Object.create(null);
  60769. var _iteratorNormalCompletion = true;
  60770. var _didIteratorError = false;
  60771. var _iteratorError = undefined;
  60772. try {
  60773. for (var _iterator = context.getDocument().definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60774. var def = _step.value;
  60775. if ((0, _predicates.isTypeDefinitionNode)(def)) {
  60776. definedTypes[def.name.value] = def;
  60777. }
  60778. }
  60779. } catch (err) {
  60780. _didIteratorError = true;
  60781. _iteratorError = err;
  60782. } finally {
  60783. try {
  60784. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60785. _iterator.return();
  60786. }
  60787. } finally {
  60788. if (_didIteratorError) {
  60789. throw _iteratorError;
  60790. }
  60791. }
  60792. }
  60793. return {
  60794. ScalarTypeExtension: checkExtension,
  60795. ObjectTypeExtension: checkExtension,
  60796. InterfaceTypeExtension: checkExtension,
  60797. UnionTypeExtension: checkExtension,
  60798. EnumTypeExtension: checkExtension,
  60799. InputObjectTypeExtension: checkExtension
  60800. };
  60801. function checkExtension(node) {
  60802. var typeName = node.name.value;
  60803. var defNode = definedTypes[typeName];
  60804. var existingType = schema && schema.getType(typeName);
  60805. if (defNode) {
  60806. var expectedKind = defKindToExtKind[defNode.kind];
  60807. if (expectedKind !== node.kind) {
  60808. context.reportError(new _GraphQLError.GraphQLError(extendingDifferentTypeKindMessage(typeName, extensionKindToTypeName(expectedKind)), [defNode, node]));
  60809. }
  60810. } else if (existingType) {
  60811. var _expectedKind = typeToExtKind(existingType);
  60812. if (_expectedKind !== node.kind) {
  60813. context.reportError(new _GraphQLError.GraphQLError(extendingDifferentTypeKindMessage(typeName, extensionKindToTypeName(_expectedKind)), node));
  60814. }
  60815. } else {
  60816. var allTypeNames = Object.keys(definedTypes);
  60817. if (schema) {
  60818. allTypeNames = allTypeNames.concat(Object.keys(schema.getTypeMap()));
  60819. }
  60820. var suggestedTypes = (0, _suggestionList.default)(typeName, allTypeNames);
  60821. context.reportError(new _GraphQLError.GraphQLError(extendingUnknownTypeMessage(typeName, suggestedTypes), node.name));
  60822. }
  60823. }
  60824. }
  60825. var defKindToExtKind = (_defKindToExtKind = {}, _defineProperty(_defKindToExtKind, _kinds.Kind.SCALAR_TYPE_DEFINITION, _kinds.Kind.SCALAR_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.OBJECT_TYPE_DEFINITION, _kinds.Kind.OBJECT_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.INTERFACE_TYPE_DEFINITION, _kinds.Kind.INTERFACE_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.UNION_TYPE_DEFINITION, _kinds.Kind.UNION_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.ENUM_TYPE_DEFINITION, _kinds.Kind.ENUM_TYPE_EXTENSION), _defineProperty(_defKindToExtKind, _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION, _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION), _defKindToExtKind);
  60826. function typeToExtKind(type) {
  60827. if ((0, _definition.isScalarType)(type)) {
  60828. return _kinds.Kind.SCALAR_TYPE_EXTENSION;
  60829. } else if ((0, _definition.isObjectType)(type)) {
  60830. return _kinds.Kind.OBJECT_TYPE_EXTENSION;
  60831. } else if ((0, _definition.isInterfaceType)(type)) {
  60832. return _kinds.Kind.INTERFACE_TYPE_EXTENSION;
  60833. } else if ((0, _definition.isUnionType)(type)) {
  60834. return _kinds.Kind.UNION_TYPE_EXTENSION;
  60835. } else if ((0, _definition.isEnumType)(type)) {
  60836. return _kinds.Kind.ENUM_TYPE_EXTENSION;
  60837. } else if ((0, _definition.isInputObjectType)(type)) {
  60838. return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION;
  60839. }
  60840. }
  60841. function extensionKindToTypeName(kind) {
  60842. switch (kind) {
  60843. case _kinds.Kind.SCALAR_TYPE_EXTENSION:
  60844. return 'scalar';
  60845. case _kinds.Kind.OBJECT_TYPE_EXTENSION:
  60846. return 'object';
  60847. case _kinds.Kind.INTERFACE_TYPE_EXTENSION:
  60848. return 'interface';
  60849. case _kinds.Kind.UNION_TYPE_EXTENSION:
  60850. return 'union';
  60851. case _kinds.Kind.ENUM_TYPE_EXTENSION:
  60852. return 'enum';
  60853. case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION:
  60854. return 'input object';
  60855. default:
  60856. return 'unknown type';
  60857. }
  60858. }
  60859. },{"../../error/GraphQLError":275,"../../jsutils/quotedOrList":302,"../../jsutils/suggestionList":303,"../../language/kinds":307,"../../language/predicates":311,"../../type/definition":323}],372:[function(require,module,exports){
  60860. "use strict";
  60861. Object.defineProperty(exports, "__esModule", {
  60862. value: true
  60863. });
  60864. exports.missingFieldArgMessage = missingFieldArgMessage;
  60865. exports.missingDirectiveArgMessage = missingDirectiveArgMessage;
  60866. exports.ProvidedRequiredArguments = ProvidedRequiredArguments;
  60867. exports.ProvidedRequiredArgumentsOnDirectives = ProvidedRequiredArgumentsOnDirectives;
  60868. var _GraphQLError = require("../../error/GraphQLError");
  60869. var _kinds = require("../../language/kinds");
  60870. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  60871. var _keyMap = _interopRequireDefault(require("../../jsutils/keyMap"));
  60872. var _definition = require("../../type/definition");
  60873. var _printer = require("../../language/printer");
  60874. var _directives = require("../../type/directives");
  60875. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  60876. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  60877. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  60878. function missingFieldArgMessage(fieldName, argName, type) {
  60879. return "Field \"".concat(fieldName, "\" argument \"").concat(argName, "\" of type ") + "\"".concat(type, "\" is required but not provided.");
  60880. }
  60881. function missingDirectiveArgMessage(directiveName, argName, type) {
  60882. return "Directive \"@".concat(directiveName, "\" argument \"").concat(argName, "\" of type ") + "\"".concat(type, "\" is required but not provided.");
  60883. }
  60884. /**
  60885. * Provided required arguments
  60886. *
  60887. * A field or directive is only valid if all required (non-null without a
  60888. * default value) field arguments have been provided.
  60889. */
  60890. function ProvidedRequiredArguments(context) {
  60891. return _objectSpread({}, ProvidedRequiredArgumentsOnDirectives(context), {
  60892. Field: {
  60893. // Validate on leave to allow for deeper errors to appear first.
  60894. leave: function leave(fieldNode) {
  60895. var fieldDef = context.getFieldDef();
  60896. if (!fieldDef) {
  60897. return false;
  60898. }
  60899. var argNodes = fieldNode.arguments || [];
  60900. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  60901. return arg.name.value;
  60902. });
  60903. var _iteratorNormalCompletion = true;
  60904. var _didIteratorError = false;
  60905. var _iteratorError = undefined;
  60906. try {
  60907. for (var _iterator = fieldDef.args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  60908. var argDef = _step.value;
  60909. var argNode = argNodeMap[argDef.name];
  60910. if (!argNode && (0, _definition.isRequiredArgument)(argDef)) {
  60911. context.reportError(new _GraphQLError.GraphQLError(missingFieldArgMessage(fieldDef.name, argDef.name, (0, _inspect.default)(argDef.type)), [fieldNode]));
  60912. }
  60913. }
  60914. } catch (err) {
  60915. _didIteratorError = true;
  60916. _iteratorError = err;
  60917. } finally {
  60918. try {
  60919. if (!_iteratorNormalCompletion && _iterator.return != null) {
  60920. _iterator.return();
  60921. }
  60922. } finally {
  60923. if (_didIteratorError) {
  60924. throw _iteratorError;
  60925. }
  60926. }
  60927. }
  60928. }
  60929. }
  60930. });
  60931. } // @internal
  60932. function ProvidedRequiredArgumentsOnDirectives(context) {
  60933. var requiredArgsMap = Object.create(null);
  60934. var schema = context.getSchema();
  60935. var definedDirectives = schema ? schema.getDirectives() : _directives.specifiedDirectives;
  60936. var _iteratorNormalCompletion2 = true;
  60937. var _didIteratorError2 = false;
  60938. var _iteratorError2 = undefined;
  60939. try {
  60940. for (var _iterator2 = definedDirectives[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  60941. var directive = _step2.value;
  60942. requiredArgsMap[directive.name] = (0, _keyMap.default)(directive.args.filter(_definition.isRequiredArgument), function (arg) {
  60943. return arg.name;
  60944. });
  60945. }
  60946. } catch (err) {
  60947. _didIteratorError2 = true;
  60948. _iteratorError2 = err;
  60949. } finally {
  60950. try {
  60951. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  60952. _iterator2.return();
  60953. }
  60954. } finally {
  60955. if (_didIteratorError2) {
  60956. throw _iteratorError2;
  60957. }
  60958. }
  60959. }
  60960. var astDefinitions = context.getDocument().definitions;
  60961. var _iteratorNormalCompletion3 = true;
  60962. var _didIteratorError3 = false;
  60963. var _iteratorError3 = undefined;
  60964. try {
  60965. for (var _iterator3 = astDefinitions[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  60966. var def = _step3.value;
  60967. if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
  60968. requiredArgsMap[def.name.value] = (0, _keyMap.default)(def.arguments ? def.arguments.filter(isRequiredArgumentNode) : [], function (arg) {
  60969. return arg.name.value;
  60970. });
  60971. }
  60972. }
  60973. } catch (err) {
  60974. _didIteratorError3 = true;
  60975. _iteratorError3 = err;
  60976. } finally {
  60977. try {
  60978. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  60979. _iterator3.return();
  60980. }
  60981. } finally {
  60982. if (_didIteratorError3) {
  60983. throw _iteratorError3;
  60984. }
  60985. }
  60986. }
  60987. return {
  60988. Directive: {
  60989. // Validate on leave to allow for deeper errors to appear first.
  60990. leave: function leave(directiveNode) {
  60991. var directiveName = directiveNode.name.value;
  60992. var requiredArgs = requiredArgsMap[directiveName];
  60993. if (requiredArgs) {
  60994. var argNodes = directiveNode.arguments || [];
  60995. var argNodeMap = (0, _keyMap.default)(argNodes, function (arg) {
  60996. return arg.name.value;
  60997. });
  60998. var _arr = Object.keys(requiredArgs);
  60999. for (var _i = 0; _i < _arr.length; _i++) {
  61000. var argName = _arr[_i];
  61001. if (!argNodeMap[argName]) {
  61002. var argType = requiredArgs[argName].type;
  61003. context.reportError(new _GraphQLError.GraphQLError(missingDirectiveArgMessage(directiveName, argName, (0, _definition.isType)(argType) ? (0, _inspect.default)(argType) : (0, _printer.print)(argType)), directiveNode));
  61004. }
  61005. }
  61006. }
  61007. }
  61008. }
  61009. };
  61010. }
  61011. function isRequiredArgumentNode(arg) {
  61012. return arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null;
  61013. }
  61014. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../jsutils/keyMap":294,"../../language/kinds":307,"../../language/printer":312,"../../type/definition":323,"../../type/directives":324}],373:[function(require,module,exports){
  61015. "use strict";
  61016. Object.defineProperty(exports, "__esModule", {
  61017. value: true
  61018. });
  61019. exports.noSubselectionAllowedMessage = noSubselectionAllowedMessage;
  61020. exports.requiredSubselectionMessage = requiredSubselectionMessage;
  61021. exports.ScalarLeafs = ScalarLeafs;
  61022. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  61023. var _GraphQLError = require("../../error/GraphQLError");
  61024. var _definition = require("../../type/definition");
  61025. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  61026. /**
  61027. * Copyright (c) 2015-present, Facebook, Inc.
  61028. *
  61029. * This source code is licensed under the MIT license found in the
  61030. * LICENSE file in the root directory of this source tree.
  61031. *
  61032. *
  61033. */
  61034. function noSubselectionAllowedMessage(fieldName, type) {
  61035. return "Field \"".concat(fieldName, "\" must not have a selection since ") + "type \"".concat(type, "\" has no subfields.");
  61036. }
  61037. function requiredSubselectionMessage(fieldName, type) {
  61038. return "Field \"".concat(fieldName, "\" of type \"").concat(type, "\" must have a ") + "selection of subfields. Did you mean \"".concat(fieldName, " { ... }\"?");
  61039. }
  61040. /**
  61041. * Scalar leafs
  61042. *
  61043. * A GraphQL document is valid only if all leaf fields (fields without
  61044. * sub selections) are of scalar or enum types.
  61045. */
  61046. function ScalarLeafs(context) {
  61047. return {
  61048. Field: function Field(node) {
  61049. var type = context.getType();
  61050. var selectionSet = node.selectionSet;
  61051. if (type) {
  61052. if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) {
  61053. if (selectionSet) {
  61054. context.reportError(new _GraphQLError.GraphQLError(noSubselectionAllowedMessage(node.name.value, (0, _inspect.default)(type)), [selectionSet]));
  61055. }
  61056. } else if (!selectionSet) {
  61057. context.reportError(new _GraphQLError.GraphQLError(requiredSubselectionMessage(node.name.value, (0, _inspect.default)(type)), [node]));
  61058. }
  61059. }
  61060. }
  61061. };
  61062. }
  61063. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../type/definition":323}],374:[function(require,module,exports){
  61064. "use strict";
  61065. Object.defineProperty(exports, "__esModule", {
  61066. value: true
  61067. });
  61068. exports.singleFieldOnlyMessage = singleFieldOnlyMessage;
  61069. exports.SingleFieldSubscriptions = SingleFieldSubscriptions;
  61070. var _GraphQLError = require("../../error/GraphQLError");
  61071. /**
  61072. * Copyright (c) 2015-present, Facebook, Inc.
  61073. *
  61074. * This source code is licensed under the MIT license found in the
  61075. * LICENSE file in the root directory of this source tree.
  61076. *
  61077. *
  61078. */
  61079. function singleFieldOnlyMessage(name) {
  61080. return (name ? "Subscription \"".concat(name, "\" ") : 'Anonymous Subscription ') + 'must select only one top level field.';
  61081. }
  61082. /**
  61083. * Subscriptions must only include one field.
  61084. *
  61085. * A GraphQL subscription is valid only if it contains a single root field.
  61086. */
  61087. function SingleFieldSubscriptions(context) {
  61088. return {
  61089. OperationDefinition: function OperationDefinition(node) {
  61090. if (node.operation === 'subscription') {
  61091. if (node.selectionSet.selections.length !== 1) {
  61092. context.reportError(new _GraphQLError.GraphQLError(singleFieldOnlyMessage(node.name && node.name.value), node.selectionSet.selections.slice(1)));
  61093. }
  61094. }
  61095. }
  61096. };
  61097. }
  61098. },{"../../error/GraphQLError":275}],375:[function(require,module,exports){
  61099. "use strict";
  61100. Object.defineProperty(exports, "__esModule", {
  61101. value: true
  61102. });
  61103. exports.duplicateArgMessage = duplicateArgMessage;
  61104. exports.UniqueArgumentNames = UniqueArgumentNames;
  61105. var _GraphQLError = require("../../error/GraphQLError");
  61106. /**
  61107. * Copyright (c) 2015-present, Facebook, Inc.
  61108. *
  61109. * This source code is licensed under the MIT license found in the
  61110. * LICENSE file in the root directory of this source tree.
  61111. *
  61112. *
  61113. */
  61114. function duplicateArgMessage(argName) {
  61115. return "There can be only one argument named \"".concat(argName, "\".");
  61116. }
  61117. /**
  61118. * Unique argument names
  61119. *
  61120. * A GraphQL field or directive is only valid if all supplied arguments are
  61121. * uniquely named.
  61122. */
  61123. function UniqueArgumentNames(context) {
  61124. var knownArgNames = Object.create(null);
  61125. return {
  61126. Field: function Field() {
  61127. knownArgNames = Object.create(null);
  61128. },
  61129. Directive: function Directive() {
  61130. knownArgNames = Object.create(null);
  61131. },
  61132. Argument: function Argument(node) {
  61133. var argName = node.name.value;
  61134. if (knownArgNames[argName]) {
  61135. context.reportError(new _GraphQLError.GraphQLError(duplicateArgMessage(argName), [knownArgNames[argName], node.name]));
  61136. } else {
  61137. knownArgNames[argName] = node.name;
  61138. }
  61139. return false;
  61140. }
  61141. };
  61142. }
  61143. },{"../../error/GraphQLError":275}],376:[function(require,module,exports){
  61144. "use strict";
  61145. Object.defineProperty(exports, "__esModule", {
  61146. value: true
  61147. });
  61148. exports.duplicateDirectiveNameMessage = duplicateDirectiveNameMessage;
  61149. exports.existedDirectiveNameMessage = existedDirectiveNameMessage;
  61150. exports.UniqueDirectiveNames = UniqueDirectiveNames;
  61151. var _GraphQLError = require("../../error/GraphQLError");
  61152. /**
  61153. * Copyright (c) 2018-present, Facebook, Inc.
  61154. *
  61155. * This source code is licensed under the MIT license found in the
  61156. * LICENSE file in the root directory of this source tree.
  61157. *
  61158. *
  61159. */
  61160. function duplicateDirectiveNameMessage(directiveName) {
  61161. return "There can be only one directive named \"".concat(directiveName, "\".");
  61162. }
  61163. function existedDirectiveNameMessage(directiveName) {
  61164. return "Directive \"".concat(directiveName, "\" already exists in the schema. ") + 'It cannot be redefined.';
  61165. }
  61166. /**
  61167. * Unique directive names
  61168. *
  61169. * A GraphQL document is only valid if all defined directives have unique names.
  61170. */
  61171. function UniqueDirectiveNames(context) {
  61172. var knownDirectiveNames = Object.create(null);
  61173. var schema = context.getSchema();
  61174. return {
  61175. DirectiveDefinition: function DirectiveDefinition(node) {
  61176. var directiveName = node.name.value;
  61177. if (schema && schema.getDirective(directiveName)) {
  61178. context.reportError(new _GraphQLError.GraphQLError(existedDirectiveNameMessage(directiveName), node.name));
  61179. return;
  61180. }
  61181. if (knownDirectiveNames[directiveName]) {
  61182. context.reportError(new _GraphQLError.GraphQLError(duplicateDirectiveNameMessage(directiveName), [knownDirectiveNames[directiveName], node.name]));
  61183. } else {
  61184. knownDirectiveNames[directiveName] = node.name;
  61185. }
  61186. return false;
  61187. }
  61188. };
  61189. }
  61190. },{"../../error/GraphQLError":275}],377:[function(require,module,exports){
  61191. "use strict";
  61192. Object.defineProperty(exports, "__esModule", {
  61193. value: true
  61194. });
  61195. exports.duplicateDirectiveMessage = duplicateDirectiveMessage;
  61196. exports.UniqueDirectivesPerLocation = UniqueDirectivesPerLocation;
  61197. var _GraphQLError = require("../../error/GraphQLError");
  61198. /**
  61199. * Copyright (c) 2015-present, Facebook, Inc.
  61200. *
  61201. * This source code is licensed under the MIT license found in the
  61202. * LICENSE file in the root directory of this source tree.
  61203. *
  61204. *
  61205. */
  61206. function duplicateDirectiveMessage(directiveName) {
  61207. return "The directive \"".concat(directiveName, "\" can only be used once at ") + 'this location.';
  61208. }
  61209. /**
  61210. * Unique directive names per location
  61211. *
  61212. * A GraphQL document is only valid if all directives at a given location
  61213. * are uniquely named.
  61214. */
  61215. function UniqueDirectivesPerLocation(context) {
  61216. return {
  61217. // Many different AST nodes may contain directives. Rather than listing
  61218. // them all, just listen for entering any node, and check to see if it
  61219. // defines any directives.
  61220. enter: function enter(node) {
  61221. // Flow can't refine that node.directives will only contain directives,
  61222. var directives = node.directives;
  61223. if (directives) {
  61224. var knownDirectives = Object.create(null);
  61225. var _iteratorNormalCompletion = true;
  61226. var _didIteratorError = false;
  61227. var _iteratorError = undefined;
  61228. try {
  61229. for (var _iterator = directives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61230. var directive = _step.value;
  61231. var directiveName = directive.name.value;
  61232. if (knownDirectives[directiveName]) {
  61233. context.reportError(new _GraphQLError.GraphQLError(duplicateDirectiveMessage(directiveName), [knownDirectives[directiveName], directive]));
  61234. } else {
  61235. knownDirectives[directiveName] = directive;
  61236. }
  61237. }
  61238. } catch (err) {
  61239. _didIteratorError = true;
  61240. _iteratorError = err;
  61241. } finally {
  61242. try {
  61243. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61244. _iterator.return();
  61245. }
  61246. } finally {
  61247. if (_didIteratorError) {
  61248. throw _iteratorError;
  61249. }
  61250. }
  61251. }
  61252. }
  61253. }
  61254. };
  61255. }
  61256. },{"../../error/GraphQLError":275}],378:[function(require,module,exports){
  61257. "use strict";
  61258. Object.defineProperty(exports, "__esModule", {
  61259. value: true
  61260. });
  61261. exports.duplicateEnumValueNameMessage = duplicateEnumValueNameMessage;
  61262. exports.existedEnumValueNameMessage = existedEnumValueNameMessage;
  61263. exports.UniqueEnumValueNames = UniqueEnumValueNames;
  61264. var _GraphQLError = require("../../error/GraphQLError");
  61265. var _definition = require("../../type/definition");
  61266. /**
  61267. * Copyright (c) 2018-present, Facebook, Inc.
  61268. *
  61269. * This source code is licensed under the MIT license found in the
  61270. * LICENSE file in the root directory of this source tree.
  61271. *
  61272. *
  61273. */
  61274. function duplicateEnumValueNameMessage(typeName, valueName) {
  61275. return "Enum value \"".concat(typeName, ".").concat(valueName, "\" can only be defined once.");
  61276. }
  61277. function existedEnumValueNameMessage(typeName, valueName) {
  61278. return "Enum value \"".concat(typeName, ".").concat(valueName, "\" already exists in the schema. ") + 'It cannot also be defined in this type extension.';
  61279. }
  61280. /**
  61281. * Unique enum value names
  61282. *
  61283. * A GraphQL enum type is only valid if all its values are uniquely named.
  61284. */
  61285. function UniqueEnumValueNames(context) {
  61286. var schema = context.getSchema();
  61287. var existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);
  61288. var knownValueNames = Object.create(null);
  61289. return {
  61290. EnumTypeDefinition: checkValueUniqueness,
  61291. EnumTypeExtension: checkValueUniqueness
  61292. };
  61293. function checkValueUniqueness(node) {
  61294. var typeName = node.name.value;
  61295. if (!knownValueNames[typeName]) {
  61296. knownValueNames[typeName] = Object.create(null);
  61297. }
  61298. var valueNames = knownValueNames[typeName];
  61299. if (node.values) {
  61300. var _iteratorNormalCompletion = true;
  61301. var _didIteratorError = false;
  61302. var _iteratorError = undefined;
  61303. try {
  61304. for (var _iterator = node.values[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61305. var valueDef = _step.value;
  61306. var valueName = valueDef.name.value;
  61307. var existingType = existingTypeMap[typeName];
  61308. if ((0, _definition.isEnumType)(existingType) && existingType.getValue(valueName)) {
  61309. context.reportError(new _GraphQLError.GraphQLError(existedEnumValueNameMessage(typeName, valueName), valueDef.name));
  61310. continue;
  61311. }
  61312. if (valueNames[valueName]) {
  61313. context.reportError(new _GraphQLError.GraphQLError(duplicateEnumValueNameMessage(typeName, valueName), [valueNames[valueName], valueDef.name]));
  61314. } else {
  61315. valueNames[valueName] = valueDef.name;
  61316. }
  61317. }
  61318. } catch (err) {
  61319. _didIteratorError = true;
  61320. _iteratorError = err;
  61321. } finally {
  61322. try {
  61323. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61324. _iterator.return();
  61325. }
  61326. } finally {
  61327. if (_didIteratorError) {
  61328. throw _iteratorError;
  61329. }
  61330. }
  61331. }
  61332. }
  61333. return false;
  61334. }
  61335. }
  61336. },{"../../error/GraphQLError":275,"../../type/definition":323}],379:[function(require,module,exports){
  61337. "use strict";
  61338. Object.defineProperty(exports, "__esModule", {
  61339. value: true
  61340. });
  61341. exports.duplicateFieldDefinitionNameMessage = duplicateFieldDefinitionNameMessage;
  61342. exports.existedFieldDefinitionNameMessage = existedFieldDefinitionNameMessage;
  61343. exports.UniqueFieldDefinitionNames = UniqueFieldDefinitionNames;
  61344. var _GraphQLError = require("../../error/GraphQLError");
  61345. var _definition = require("../../type/definition");
  61346. /**
  61347. * Copyright (c) 2018-present, Facebook, Inc.
  61348. *
  61349. * This source code is licensed under the MIT license found in the
  61350. * LICENSE file in the root directory of this source tree.
  61351. *
  61352. *
  61353. */
  61354. function duplicateFieldDefinitionNameMessage(typeName, fieldName) {
  61355. return "Field \"".concat(typeName, ".").concat(fieldName, "\" can only be defined once.");
  61356. }
  61357. function existedFieldDefinitionNameMessage(typeName, fieldName) {
  61358. return "Field \"".concat(typeName, ".").concat(fieldName, "\" already exists in the schema. ") + 'It cannot also be defined in this type extension.';
  61359. }
  61360. /**
  61361. * Unique field definition names
  61362. *
  61363. * A GraphQL complex type is only valid if all its fields are uniquely named.
  61364. */
  61365. function UniqueFieldDefinitionNames(context) {
  61366. var schema = context.getSchema();
  61367. var existingTypeMap = schema ? schema.getTypeMap() : Object.create(null);
  61368. var knownFieldNames = Object.create(null);
  61369. return {
  61370. InputObjectTypeDefinition: checkFieldUniqueness,
  61371. InputObjectTypeExtension: checkFieldUniqueness,
  61372. InterfaceTypeDefinition: checkFieldUniqueness,
  61373. InterfaceTypeExtension: checkFieldUniqueness,
  61374. ObjectTypeDefinition: checkFieldUniqueness,
  61375. ObjectTypeExtension: checkFieldUniqueness
  61376. };
  61377. function checkFieldUniqueness(node) {
  61378. var typeName = node.name.value;
  61379. if (!knownFieldNames[typeName]) {
  61380. knownFieldNames[typeName] = Object.create(null);
  61381. }
  61382. var fieldNames = knownFieldNames[typeName];
  61383. if (node.fields) {
  61384. var _iteratorNormalCompletion = true;
  61385. var _didIteratorError = false;
  61386. var _iteratorError = undefined;
  61387. try {
  61388. for (var _iterator = node.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61389. var fieldDef = _step.value;
  61390. var fieldName = fieldDef.name.value;
  61391. if (hasField(existingTypeMap[typeName], fieldName)) {
  61392. context.reportError(new _GraphQLError.GraphQLError(existedFieldDefinitionNameMessage(typeName, fieldName), fieldDef.name));
  61393. continue;
  61394. }
  61395. if (fieldNames[fieldName]) {
  61396. context.reportError(new _GraphQLError.GraphQLError(duplicateFieldDefinitionNameMessage(typeName, fieldName), [fieldNames[fieldName], fieldDef.name]));
  61397. } else {
  61398. fieldNames[fieldName] = fieldDef.name;
  61399. }
  61400. }
  61401. } catch (err) {
  61402. _didIteratorError = true;
  61403. _iteratorError = err;
  61404. } finally {
  61405. try {
  61406. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61407. _iterator.return();
  61408. }
  61409. } finally {
  61410. if (_didIteratorError) {
  61411. throw _iteratorError;
  61412. }
  61413. }
  61414. }
  61415. }
  61416. return false;
  61417. }
  61418. }
  61419. function hasField(type, fieldName) {
  61420. if ((0, _definition.isObjectType)(type) || (0, _definition.isInterfaceType)(type) || (0, _definition.isInputObjectType)(type)) {
  61421. return type.getFields()[fieldName];
  61422. }
  61423. return false;
  61424. }
  61425. },{"../../error/GraphQLError":275,"../../type/definition":323}],380:[function(require,module,exports){
  61426. "use strict";
  61427. Object.defineProperty(exports, "__esModule", {
  61428. value: true
  61429. });
  61430. exports.duplicateFragmentNameMessage = duplicateFragmentNameMessage;
  61431. exports.UniqueFragmentNames = UniqueFragmentNames;
  61432. var _GraphQLError = require("../../error/GraphQLError");
  61433. /**
  61434. * Copyright (c) 2015-present, Facebook, Inc.
  61435. *
  61436. * This source code is licensed under the MIT license found in the
  61437. * LICENSE file in the root directory of this source tree.
  61438. *
  61439. *
  61440. */
  61441. function duplicateFragmentNameMessage(fragName) {
  61442. return "There can be only one fragment named \"".concat(fragName, "\".");
  61443. }
  61444. /**
  61445. * Unique fragment names
  61446. *
  61447. * A GraphQL document is only valid if all defined fragments have unique names.
  61448. */
  61449. function UniqueFragmentNames(context) {
  61450. var knownFragmentNames = Object.create(null);
  61451. return {
  61452. OperationDefinition: function OperationDefinition() {
  61453. return false;
  61454. },
  61455. FragmentDefinition: function FragmentDefinition(node) {
  61456. var fragmentName = node.name.value;
  61457. if (knownFragmentNames[fragmentName]) {
  61458. context.reportError(new _GraphQLError.GraphQLError(duplicateFragmentNameMessage(fragmentName), [knownFragmentNames[fragmentName], node.name]));
  61459. } else {
  61460. knownFragmentNames[fragmentName] = node.name;
  61461. }
  61462. return false;
  61463. }
  61464. };
  61465. }
  61466. },{"../../error/GraphQLError":275}],381:[function(require,module,exports){
  61467. "use strict";
  61468. Object.defineProperty(exports, "__esModule", {
  61469. value: true
  61470. });
  61471. exports.duplicateInputFieldMessage = duplicateInputFieldMessage;
  61472. exports.UniqueInputFieldNames = UniqueInputFieldNames;
  61473. var _GraphQLError = require("../../error/GraphQLError");
  61474. /**
  61475. * Copyright (c) 2015-present, Facebook, Inc.
  61476. *
  61477. * This source code is licensed under the MIT license found in the
  61478. * LICENSE file in the root directory of this source tree.
  61479. *
  61480. *
  61481. */
  61482. function duplicateInputFieldMessage(fieldName) {
  61483. return "There can be only one input field named \"".concat(fieldName, "\".");
  61484. }
  61485. /**
  61486. * Unique input field names
  61487. *
  61488. * A GraphQL input object value is only valid if all supplied fields are
  61489. * uniquely named.
  61490. */
  61491. function UniqueInputFieldNames(context) {
  61492. var knownNameStack = [];
  61493. var knownNames = Object.create(null);
  61494. return {
  61495. ObjectValue: {
  61496. enter: function enter() {
  61497. knownNameStack.push(knownNames);
  61498. knownNames = Object.create(null);
  61499. },
  61500. leave: function leave() {
  61501. knownNames = knownNameStack.pop();
  61502. }
  61503. },
  61504. ObjectField: function ObjectField(node) {
  61505. var fieldName = node.name.value;
  61506. if (knownNames[fieldName]) {
  61507. context.reportError(new _GraphQLError.GraphQLError(duplicateInputFieldMessage(fieldName), [knownNames[fieldName], node.name]));
  61508. } else {
  61509. knownNames[fieldName] = node.name;
  61510. }
  61511. return false;
  61512. }
  61513. };
  61514. }
  61515. },{"../../error/GraphQLError":275}],382:[function(require,module,exports){
  61516. "use strict";
  61517. Object.defineProperty(exports, "__esModule", {
  61518. value: true
  61519. });
  61520. exports.duplicateOperationNameMessage = duplicateOperationNameMessage;
  61521. exports.UniqueOperationNames = UniqueOperationNames;
  61522. var _GraphQLError = require("../../error/GraphQLError");
  61523. /**
  61524. * Copyright (c) 2015-present, Facebook, Inc.
  61525. *
  61526. * This source code is licensed under the MIT license found in the
  61527. * LICENSE file in the root directory of this source tree.
  61528. *
  61529. *
  61530. */
  61531. function duplicateOperationNameMessage(operationName) {
  61532. return "There can be only one operation named \"".concat(operationName, "\".");
  61533. }
  61534. /**
  61535. * Unique operation names
  61536. *
  61537. * A GraphQL document is only valid if all defined operations have unique names.
  61538. */
  61539. function UniqueOperationNames(context) {
  61540. var knownOperationNames = Object.create(null);
  61541. return {
  61542. OperationDefinition: function OperationDefinition(node) {
  61543. var operationName = node.name;
  61544. if (operationName) {
  61545. if (knownOperationNames[operationName.value]) {
  61546. context.reportError(new _GraphQLError.GraphQLError(duplicateOperationNameMessage(operationName.value), [knownOperationNames[operationName.value], operationName]));
  61547. } else {
  61548. knownOperationNames[operationName.value] = operationName;
  61549. }
  61550. }
  61551. return false;
  61552. },
  61553. FragmentDefinition: function FragmentDefinition() {
  61554. return false;
  61555. }
  61556. };
  61557. }
  61558. },{"../../error/GraphQLError":275}],383:[function(require,module,exports){
  61559. "use strict";
  61560. Object.defineProperty(exports, "__esModule", {
  61561. value: true
  61562. });
  61563. exports.duplicateOperationTypeMessage = duplicateOperationTypeMessage;
  61564. exports.existedOperationTypeMessage = existedOperationTypeMessage;
  61565. exports.UniqueOperationTypes = UniqueOperationTypes;
  61566. var _GraphQLError = require("../../error/GraphQLError");
  61567. /**
  61568. * Copyright (c) 2018-present, Facebook, Inc.
  61569. *
  61570. * This source code is licensed under the MIT license found in the
  61571. * LICENSE file in the root directory of this source tree.
  61572. *
  61573. *
  61574. */
  61575. function duplicateOperationTypeMessage(operation) {
  61576. return "There can be only one ".concat(operation, " type in schema.");
  61577. }
  61578. function existedOperationTypeMessage(operation) {
  61579. return "Type for ".concat(operation, " already defined in the schema. ") + 'It cannot be redefined.';
  61580. }
  61581. /**
  61582. * Unique operation types
  61583. *
  61584. * A GraphQL document is only valid if it has only one type per operation.
  61585. */
  61586. function UniqueOperationTypes(context) {
  61587. var schema = context.getSchema();
  61588. var definedOperationTypes = Object.create(null);
  61589. var existingOperationTypes = schema ? {
  61590. query: schema.getQueryType(),
  61591. mutation: schema.getMutationType(),
  61592. subscription: schema.getSubscriptionType()
  61593. } : {};
  61594. return {
  61595. SchemaDefinition: checkOperationTypes,
  61596. SchemaExtension: checkOperationTypes
  61597. };
  61598. function checkOperationTypes(node) {
  61599. if (node.operationTypes) {
  61600. var _iteratorNormalCompletion = true;
  61601. var _didIteratorError = false;
  61602. var _iteratorError = undefined;
  61603. try {
  61604. for (var _iterator = (node.operationTypes || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61605. var operationType = _step.value;
  61606. var operation = operationType.operation;
  61607. var alreadyDefinedOperationType = definedOperationTypes[operation];
  61608. if (existingOperationTypes[operation]) {
  61609. context.reportError(new _GraphQLError.GraphQLError(existedOperationTypeMessage(operation), operationType));
  61610. } else if (alreadyDefinedOperationType) {
  61611. context.reportError(new _GraphQLError.GraphQLError(duplicateOperationTypeMessage(operation), [alreadyDefinedOperationType, operationType]));
  61612. } else {
  61613. definedOperationTypes[operation] = operationType;
  61614. }
  61615. }
  61616. } catch (err) {
  61617. _didIteratorError = true;
  61618. _iteratorError = err;
  61619. } finally {
  61620. try {
  61621. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61622. _iterator.return();
  61623. }
  61624. } finally {
  61625. if (_didIteratorError) {
  61626. throw _iteratorError;
  61627. }
  61628. }
  61629. }
  61630. }
  61631. return false;
  61632. }
  61633. }
  61634. },{"../../error/GraphQLError":275}],384:[function(require,module,exports){
  61635. "use strict";
  61636. Object.defineProperty(exports, "__esModule", {
  61637. value: true
  61638. });
  61639. exports.duplicateTypeNameMessage = duplicateTypeNameMessage;
  61640. exports.existedTypeNameMessage = existedTypeNameMessage;
  61641. exports.UniqueTypeNames = UniqueTypeNames;
  61642. var _GraphQLError = require("../../error/GraphQLError");
  61643. /**
  61644. * Copyright (c) 2018-present, Facebook, Inc.
  61645. *
  61646. * This source code is licensed under the MIT license found in the
  61647. * LICENSE file in the root directory of this source tree.
  61648. *
  61649. *
  61650. */
  61651. function duplicateTypeNameMessage(typeName) {
  61652. return "There can be only one type named \"".concat(typeName, "\".");
  61653. }
  61654. function existedTypeNameMessage(typeName) {
  61655. return "Type \"".concat(typeName, "\" already exists in the schema. ") + 'It cannot also be defined in this type definition.';
  61656. }
  61657. /**
  61658. * Unique type names
  61659. *
  61660. * A GraphQL document is only valid if all defined types have unique names.
  61661. */
  61662. function UniqueTypeNames(context) {
  61663. var knownTypeNames = Object.create(null);
  61664. var schema = context.getSchema();
  61665. return {
  61666. ScalarTypeDefinition: checkTypeName,
  61667. ObjectTypeDefinition: checkTypeName,
  61668. InterfaceTypeDefinition: checkTypeName,
  61669. UnionTypeDefinition: checkTypeName,
  61670. EnumTypeDefinition: checkTypeName,
  61671. InputObjectTypeDefinition: checkTypeName
  61672. };
  61673. function checkTypeName(node) {
  61674. var typeName = node.name.value;
  61675. if (schema && schema.getType(typeName)) {
  61676. context.reportError(new _GraphQLError.GraphQLError(existedTypeNameMessage(typeName), node.name));
  61677. return;
  61678. }
  61679. if (knownTypeNames[typeName]) {
  61680. context.reportError(new _GraphQLError.GraphQLError(duplicateTypeNameMessage(typeName), [knownTypeNames[typeName], node.name]));
  61681. } else {
  61682. knownTypeNames[typeName] = node.name;
  61683. }
  61684. return false;
  61685. }
  61686. }
  61687. },{"../../error/GraphQLError":275}],385:[function(require,module,exports){
  61688. "use strict";
  61689. Object.defineProperty(exports, "__esModule", {
  61690. value: true
  61691. });
  61692. exports.duplicateVariableMessage = duplicateVariableMessage;
  61693. exports.UniqueVariableNames = UniqueVariableNames;
  61694. var _GraphQLError = require("../../error/GraphQLError");
  61695. /**
  61696. * Copyright (c) 2015-present, Facebook, Inc.
  61697. *
  61698. * This source code is licensed under the MIT license found in the
  61699. * LICENSE file in the root directory of this source tree.
  61700. *
  61701. *
  61702. */
  61703. function duplicateVariableMessage(variableName) {
  61704. return "There can be only one variable named \"".concat(variableName, "\".");
  61705. }
  61706. /**
  61707. * Unique variable names
  61708. *
  61709. * A GraphQL operation is only valid if all its variables are uniquely named.
  61710. */
  61711. function UniqueVariableNames(context) {
  61712. var knownVariableNames = Object.create(null);
  61713. return {
  61714. OperationDefinition: function OperationDefinition() {
  61715. knownVariableNames = Object.create(null);
  61716. },
  61717. VariableDefinition: function VariableDefinition(node) {
  61718. var variableName = node.variable.name.value;
  61719. if (knownVariableNames[variableName]) {
  61720. context.reportError(new _GraphQLError.GraphQLError(duplicateVariableMessage(variableName), [knownVariableNames[variableName], node.variable.name]));
  61721. } else {
  61722. knownVariableNames[variableName] = node.variable.name;
  61723. }
  61724. }
  61725. };
  61726. }
  61727. },{"../../error/GraphQLError":275}],386:[function(require,module,exports){
  61728. "use strict";
  61729. Object.defineProperty(exports, "__esModule", {
  61730. value: true
  61731. });
  61732. exports.badValueMessage = badValueMessage;
  61733. exports.requiredFieldMessage = requiredFieldMessage;
  61734. exports.unknownFieldMessage = unknownFieldMessage;
  61735. exports.ValuesOfCorrectType = ValuesOfCorrectType;
  61736. var _objectValues = _interopRequireDefault(require("../../polyfills/objectValues"));
  61737. var _GraphQLError = require("../../error/GraphQLError");
  61738. var _printer = require("../../language/printer");
  61739. var _definition = require("../../type/definition");
  61740. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  61741. var _isInvalid = _interopRequireDefault(require("../../jsutils/isInvalid"));
  61742. var _keyMap = _interopRequireDefault(require("../../jsutils/keyMap"));
  61743. var _orList = _interopRequireDefault(require("../../jsutils/orList"));
  61744. var _suggestionList = _interopRequireDefault(require("../../jsutils/suggestionList"));
  61745. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  61746. /**
  61747. * Copyright (c) 2015-present, Facebook, Inc.
  61748. *
  61749. * This source code is licensed under the MIT license found in the
  61750. * LICENSE file in the root directory of this source tree.
  61751. *
  61752. *
  61753. */
  61754. function badValueMessage(typeName, valueName, message) {
  61755. return "Expected type ".concat(typeName, ", found ").concat(valueName) + (message ? "; ".concat(message) : '.');
  61756. }
  61757. function requiredFieldMessage(typeName, fieldName, fieldTypeName) {
  61758. return "Field ".concat(typeName, ".").concat(fieldName, " of required type ") + "".concat(fieldTypeName, " was not provided.");
  61759. }
  61760. function unknownFieldMessage(typeName, fieldName, message) {
  61761. return "Field \"".concat(fieldName, "\" is not defined by type ").concat(typeName) + (message ? "; ".concat(message) : '.');
  61762. }
  61763. /**
  61764. * Value literals of correct type
  61765. *
  61766. * A GraphQL document is only valid if all value literals are of the type
  61767. * expected at their position.
  61768. */
  61769. function ValuesOfCorrectType(context) {
  61770. return {
  61771. NullValue: function NullValue(node) {
  61772. var type = context.getInputType();
  61773. if ((0, _definition.isNonNullType)(type)) {
  61774. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(type), (0, _printer.print)(node)), node));
  61775. }
  61776. },
  61777. ListValue: function ListValue(node) {
  61778. // Note: TypeInfo will traverse into a list's item type, so look to the
  61779. // parent input type to check if it is a list.
  61780. var type = (0, _definition.getNullableType)(context.getParentInputType());
  61781. if (!(0, _definition.isListType)(type)) {
  61782. isValidScalar(context, node);
  61783. return false; // Don't traverse further.
  61784. }
  61785. },
  61786. ObjectValue: function ObjectValue(node) {
  61787. var type = (0, _definition.getNamedType)(context.getInputType());
  61788. if (!(0, _definition.isInputObjectType)(type)) {
  61789. isValidScalar(context, node);
  61790. return false; // Don't traverse further.
  61791. } // Ensure every required field exists.
  61792. var fieldNodeMap = (0, _keyMap.default)(node.fields, function (field) {
  61793. return field.name.value;
  61794. });
  61795. var _iteratorNormalCompletion = true;
  61796. var _didIteratorError = false;
  61797. var _iteratorError = undefined;
  61798. try {
  61799. for (var _iterator = (0, _objectValues.default)(type.getFields())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61800. var fieldDef = _step.value;
  61801. var fieldNode = fieldNodeMap[fieldDef.name];
  61802. if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) {
  61803. var typeStr = (0, _inspect.default)(fieldDef.type);
  61804. context.reportError(new _GraphQLError.GraphQLError(requiredFieldMessage(type.name, fieldDef.name, typeStr), node));
  61805. }
  61806. }
  61807. } catch (err) {
  61808. _didIteratorError = true;
  61809. _iteratorError = err;
  61810. } finally {
  61811. try {
  61812. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61813. _iterator.return();
  61814. }
  61815. } finally {
  61816. if (_didIteratorError) {
  61817. throw _iteratorError;
  61818. }
  61819. }
  61820. }
  61821. },
  61822. ObjectField: function ObjectField(node) {
  61823. var parentType = (0, _definition.getNamedType)(context.getParentInputType());
  61824. var fieldType = context.getInputType();
  61825. if (!fieldType && (0, _definition.isInputObjectType)(parentType)) {
  61826. var suggestions = (0, _suggestionList.default)(node.name.value, Object.keys(parentType.getFields()));
  61827. var didYouMean = suggestions.length !== 0 ? "Did you mean ".concat((0, _orList.default)(suggestions), "?") : undefined;
  61828. context.reportError(new _GraphQLError.GraphQLError(unknownFieldMessage(parentType.name, node.name.value, didYouMean), node));
  61829. }
  61830. },
  61831. EnumValue: function EnumValue(node) {
  61832. var type = (0, _definition.getNamedType)(context.getInputType());
  61833. if (!(0, _definition.isEnumType)(type)) {
  61834. isValidScalar(context, node);
  61835. } else if (!type.getValue(node.value)) {
  61836. context.reportError(new _GraphQLError.GraphQLError(badValueMessage(type.name, (0, _printer.print)(node), enumTypeSuggestion(type, node)), node));
  61837. }
  61838. },
  61839. IntValue: function IntValue(node) {
  61840. return isValidScalar(context, node);
  61841. },
  61842. FloatValue: function FloatValue(node) {
  61843. return isValidScalar(context, node);
  61844. },
  61845. StringValue: function StringValue(node) {
  61846. return isValidScalar(context, node);
  61847. },
  61848. BooleanValue: function BooleanValue(node) {
  61849. return isValidScalar(context, node);
  61850. }
  61851. };
  61852. }
  61853. /**
  61854. * Any value literal may be a valid representation of a Scalar, depending on
  61855. * that scalar type.
  61856. */
  61857. function isValidScalar(context, node) {
  61858. // Report any error at the full type expected by the location.
  61859. var locationType = context.getInputType();
  61860. if (!locationType) {
  61861. return;
  61862. }
  61863. var type = (0, _definition.getNamedType)(locationType);
  61864. if (!(0, _definition.isScalarType)(type)) {
  61865. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node), enumTypeSuggestion(type, node)), node));
  61866. return;
  61867. } // Scalars determine if a literal value is valid via parseLiteral() which
  61868. // may throw or return an invalid value to indicate failure.
  61869. try {
  61870. var parseResult = type.parseLiteral(node, undefined
  61871. /* variables */
  61872. );
  61873. if ((0, _isInvalid.default)(parseResult)) {
  61874. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node)), node));
  61875. }
  61876. } catch (error) {
  61877. // Ensure a reference to the original error is maintained.
  61878. context.reportError(new _GraphQLError.GraphQLError(badValueMessage((0, _inspect.default)(locationType), (0, _printer.print)(node), error.message), node, undefined, undefined, undefined, error));
  61879. }
  61880. }
  61881. function enumTypeSuggestion(type, node) {
  61882. if ((0, _definition.isEnumType)(type)) {
  61883. var suggestions = (0, _suggestionList.default)((0, _printer.print)(node), type.getValues().map(function (value) {
  61884. return value.name;
  61885. }));
  61886. if (suggestions.length !== 0) {
  61887. return "Did you mean the enum value ".concat((0, _orList.default)(suggestions), "?");
  61888. }
  61889. }
  61890. }
  61891. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../jsutils/isInvalid":291,"../../jsutils/keyMap":294,"../../jsutils/orList":299,"../../jsutils/suggestionList":303,"../../language/printer":312,"../../polyfills/objectValues":319,"../../type/definition":323}],387:[function(require,module,exports){
  61892. "use strict";
  61893. Object.defineProperty(exports, "__esModule", {
  61894. value: true
  61895. });
  61896. exports.nonInputTypeOnVarMessage = nonInputTypeOnVarMessage;
  61897. exports.VariablesAreInputTypes = VariablesAreInputTypes;
  61898. var _GraphQLError = require("../../error/GraphQLError");
  61899. var _printer = require("../../language/printer");
  61900. var _definition = require("../../type/definition");
  61901. var _typeFromAST = require("../../utilities/typeFromAST");
  61902. /**
  61903. * Copyright (c) 2015-present, Facebook, Inc.
  61904. *
  61905. * This source code is licensed under the MIT license found in the
  61906. * LICENSE file in the root directory of this source tree.
  61907. *
  61908. *
  61909. */
  61910. function nonInputTypeOnVarMessage(variableName, typeName) {
  61911. return "Variable \"$".concat(variableName, "\" cannot be non-input type \"").concat(typeName, "\".");
  61912. }
  61913. /**
  61914. * Variables are input types
  61915. *
  61916. * A GraphQL operation is only valid if all the variables it defines are of
  61917. * input types (scalar, enum, or input object).
  61918. */
  61919. function VariablesAreInputTypes(context) {
  61920. return {
  61921. VariableDefinition: function VariableDefinition(node) {
  61922. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type); // If the variable type is not an input type, return an error.
  61923. if (type && !(0, _definition.isInputType)(type)) {
  61924. var variableName = node.variable.name.value;
  61925. context.reportError(new _GraphQLError.GraphQLError(nonInputTypeOnVarMessage(variableName, (0, _printer.print)(node.type)), [node.type]));
  61926. }
  61927. }
  61928. };
  61929. }
  61930. },{"../../error/GraphQLError":275,"../../language/printer":312,"../../type/definition":323,"../../utilities/typeFromAST":351}],388:[function(require,module,exports){
  61931. "use strict";
  61932. Object.defineProperty(exports, "__esModule", {
  61933. value: true
  61934. });
  61935. exports.badVarPosMessage = badVarPosMessage;
  61936. exports.VariablesInAllowedPosition = VariablesInAllowedPosition;
  61937. var _inspect = _interopRequireDefault(require("../../jsutils/inspect"));
  61938. var _GraphQLError = require("../../error/GraphQLError");
  61939. var _kinds = require("../../language/kinds");
  61940. var _definition = require("../../type/definition");
  61941. var _typeComparators = require("../../utilities/typeComparators");
  61942. var _typeFromAST = require("../../utilities/typeFromAST");
  61943. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  61944. /**
  61945. * Copyright (c) 2015-present, Facebook, Inc.
  61946. *
  61947. * This source code is licensed under the MIT license found in the
  61948. * LICENSE file in the root directory of this source tree.
  61949. *
  61950. *
  61951. */
  61952. function badVarPosMessage(varName, varType, expectedType) {
  61953. return "Variable \"$".concat(varName, "\" of type \"").concat(varType, "\" used in ") + "position expecting type \"".concat(expectedType, "\".");
  61954. }
  61955. /**
  61956. * Variables passed to field arguments conform to type
  61957. */
  61958. function VariablesInAllowedPosition(context) {
  61959. var varDefMap = Object.create(null);
  61960. return {
  61961. OperationDefinition: {
  61962. enter: function enter() {
  61963. varDefMap = Object.create(null);
  61964. },
  61965. leave: function leave(operation) {
  61966. var usages = context.getRecursiveVariableUsages(operation);
  61967. var _iteratorNormalCompletion = true;
  61968. var _didIteratorError = false;
  61969. var _iteratorError = undefined;
  61970. try {
  61971. for (var _iterator = usages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  61972. var _ref2 = _step.value;
  61973. var node = _ref2.node;
  61974. var type = _ref2.type;
  61975. var defaultValue = _ref2.defaultValue;
  61976. var varName = node.name.value;
  61977. var varDef = varDefMap[varName];
  61978. if (varDef && type) {
  61979. // A var type is allowed if it is the same or more strict (e.g. is
  61980. // a subtype of) than the expected type. It can be more strict if
  61981. // the variable type is non-null when the expected type is nullable.
  61982. // If both are list types, the variable item type can be more strict
  61983. // than the expected item type (contravariant).
  61984. var schema = context.getSchema();
  61985. var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type);
  61986. if (varType && !allowedVariableUsage(schema, varType, varDef.defaultValue, type, defaultValue)) {
  61987. context.reportError(new _GraphQLError.GraphQLError(badVarPosMessage(varName, (0, _inspect.default)(varType), (0, _inspect.default)(type)), [varDef, node]));
  61988. }
  61989. }
  61990. }
  61991. } catch (err) {
  61992. _didIteratorError = true;
  61993. _iteratorError = err;
  61994. } finally {
  61995. try {
  61996. if (!_iteratorNormalCompletion && _iterator.return != null) {
  61997. _iterator.return();
  61998. }
  61999. } finally {
  62000. if (_didIteratorError) {
  62001. throw _iteratorError;
  62002. }
  62003. }
  62004. }
  62005. }
  62006. },
  62007. VariableDefinition: function VariableDefinition(node) {
  62008. varDefMap[node.variable.name.value] = node;
  62009. }
  62010. };
  62011. }
  62012. /**
  62013. * Returns true if the variable is allowed in the location it was found,
  62014. * which includes considering if default values exist for either the variable
  62015. * or the location at which it is located.
  62016. */
  62017. function allowedVariableUsage(schema, varType, varDefaultValue, locationType, locationDefaultValue) {
  62018. if ((0, _definition.isNonNullType)(locationType) && !(0, _definition.isNonNullType)(varType)) {
  62019. var hasNonNullVariableDefaultValue = varDefaultValue && varDefaultValue.kind !== _kinds.Kind.NULL;
  62020. var hasLocationDefaultValue = locationDefaultValue !== undefined;
  62021. if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
  62022. return false;
  62023. }
  62024. var nullableLocationType = locationType.ofType;
  62025. return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, nullableLocationType);
  62026. }
  62027. return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType);
  62028. }
  62029. },{"../../error/GraphQLError":275,"../../jsutils/inspect":288,"../../language/kinds":307,"../../type/definition":323,"../../utilities/typeComparators":350,"../../utilities/typeFromAST":351}],389:[function(require,module,exports){
  62030. "use strict";
  62031. Object.defineProperty(exports, "__esModule", {
  62032. value: true
  62033. });
  62034. exports.specifiedSDLRules = exports.specifiedRules = void 0;
  62035. var _ExecutableDefinitions = require("./rules/ExecutableDefinitions");
  62036. var _UniqueOperationNames = require("./rules/UniqueOperationNames");
  62037. var _LoneAnonymousOperation = require("./rules/LoneAnonymousOperation");
  62038. var _SingleFieldSubscriptions = require("./rules/SingleFieldSubscriptions");
  62039. var _KnownTypeNames = require("./rules/KnownTypeNames");
  62040. var _FragmentsOnCompositeTypes = require("./rules/FragmentsOnCompositeTypes");
  62041. var _VariablesAreInputTypes = require("./rules/VariablesAreInputTypes");
  62042. var _ScalarLeafs = require("./rules/ScalarLeafs");
  62043. var _FieldsOnCorrectType = require("./rules/FieldsOnCorrectType");
  62044. var _UniqueFragmentNames = require("./rules/UniqueFragmentNames");
  62045. var _KnownFragmentNames = require("./rules/KnownFragmentNames");
  62046. var _NoUnusedFragments = require("./rules/NoUnusedFragments");
  62047. var _PossibleFragmentSpreads = require("./rules/PossibleFragmentSpreads");
  62048. var _NoFragmentCycles = require("./rules/NoFragmentCycles");
  62049. var _UniqueVariableNames = require("./rules/UniqueVariableNames");
  62050. var _NoUndefinedVariables = require("./rules/NoUndefinedVariables");
  62051. var _NoUnusedVariables = require("./rules/NoUnusedVariables");
  62052. var _KnownDirectives = require("./rules/KnownDirectives");
  62053. var _UniqueDirectivesPerLocation = require("./rules/UniqueDirectivesPerLocation");
  62054. var _KnownArgumentNames = require("./rules/KnownArgumentNames");
  62055. var _UniqueArgumentNames = require("./rules/UniqueArgumentNames");
  62056. var _ValuesOfCorrectType = require("./rules/ValuesOfCorrectType");
  62057. var _ProvidedRequiredArguments = require("./rules/ProvidedRequiredArguments");
  62058. var _VariablesInAllowedPosition = require("./rules/VariablesInAllowedPosition");
  62059. var _OverlappingFieldsCanBeMerged = require("./rules/OverlappingFieldsCanBeMerged");
  62060. var _UniqueInputFieldNames = require("./rules/UniqueInputFieldNames");
  62061. var _LoneSchemaDefinition = require("./rules/LoneSchemaDefinition");
  62062. var _UniqueOperationTypes = require("./rules/UniqueOperationTypes");
  62063. var _UniqueTypeNames = require("./rules/UniqueTypeNames");
  62064. var _UniqueEnumValueNames = require("./rules/UniqueEnumValueNames");
  62065. var _UniqueFieldDefinitionNames = require("./rules/UniqueFieldDefinitionNames");
  62066. var _UniqueDirectiveNames = require("./rules/UniqueDirectiveNames");
  62067. var _PossibleTypeExtensions = require("./rules/PossibleTypeExtensions");
  62068. /**
  62069. * Copyright (c) 2015-present, Facebook, Inc.
  62070. *
  62071. * This source code is licensed under the MIT license found in the
  62072. * LICENSE file in the root directory of this source tree.
  62073. *
  62074. *
  62075. */
  62076. // Spec Section: "Executable Definitions"
  62077. // Spec Section: "Operation Name Uniqueness"
  62078. // Spec Section: "Lone Anonymous Operation"
  62079. // Spec Section: "Subscriptions with Single Root Field"
  62080. // Spec Section: "Fragment Spread Type Existence"
  62081. // Spec Section: "Fragments on Composite Types"
  62082. // Spec Section: "Variables are Input Types"
  62083. // Spec Section: "Leaf Field Selections"
  62084. // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
  62085. // Spec Section: "Fragment Name Uniqueness"
  62086. // Spec Section: "Fragment spread target defined"
  62087. // Spec Section: "Fragments must be used"
  62088. // Spec Section: "Fragment spread is possible"
  62089. // Spec Section: "Fragments must not form cycles"
  62090. // Spec Section: "Variable Uniqueness"
  62091. // Spec Section: "All Variable Used Defined"
  62092. // Spec Section: "All Variables Used"
  62093. // Spec Section: "Directives Are Defined"
  62094. // Spec Section: "Directives Are Unique Per Location"
  62095. // Spec Section: "Argument Names"
  62096. // Spec Section: "Argument Uniqueness"
  62097. // Spec Section: "Value Type Correctness"
  62098. // Spec Section: "Argument Optionality"
  62099. // Spec Section: "All Variable Usages Are Allowed"
  62100. // Spec Section: "Field Selection Merging"
  62101. // Spec Section: "Input Object Field Uniqueness"
  62102. /**
  62103. * This set includes all validation rules defined by the GraphQL spec.
  62104. *
  62105. * The order of the rules in this list has been adjusted to lead to the
  62106. * most clear output when encountering multiple validation errors.
  62107. */
  62108. var specifiedRules = [_ExecutableDefinitions.ExecutableDefinitions, _UniqueOperationNames.UniqueOperationNames, _LoneAnonymousOperation.LoneAnonymousOperation, _SingleFieldSubscriptions.SingleFieldSubscriptions, _KnownTypeNames.KnownTypeNames, _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes, _VariablesAreInputTypes.VariablesAreInputTypes, _ScalarLeafs.ScalarLeafs, _FieldsOnCorrectType.FieldsOnCorrectType, _UniqueFragmentNames.UniqueFragmentNames, _KnownFragmentNames.KnownFragmentNames, _NoUnusedFragments.NoUnusedFragments, _PossibleFragmentSpreads.PossibleFragmentSpreads, _NoFragmentCycles.NoFragmentCycles, _UniqueVariableNames.UniqueVariableNames, _NoUndefinedVariables.NoUndefinedVariables, _NoUnusedVariables.NoUnusedVariables, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _KnownArgumentNames.KnownArgumentNames, _UniqueArgumentNames.UniqueArgumentNames, _ValuesOfCorrectType.ValuesOfCorrectType, _ProvidedRequiredArguments.ProvidedRequiredArguments, _VariablesInAllowedPosition.VariablesInAllowedPosition, _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged, _UniqueInputFieldNames.UniqueInputFieldNames];
  62109. exports.specifiedRules = specifiedRules;
  62110. // @internal
  62111. var specifiedSDLRules = [_LoneSchemaDefinition.LoneSchemaDefinition, _UniqueOperationTypes.UniqueOperationTypes, _UniqueTypeNames.UniqueTypeNames, _UniqueEnumValueNames.UniqueEnumValueNames, _UniqueFieldDefinitionNames.UniqueFieldDefinitionNames, _UniqueDirectiveNames.UniqueDirectiveNames, _KnownTypeNames.KnownTypeNames, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _PossibleTypeExtensions.PossibleTypeExtensions, _KnownArgumentNames.KnownArgumentNamesOnDirectives, _UniqueArgumentNames.UniqueArgumentNames, _UniqueInputFieldNames.UniqueInputFieldNames, _ProvidedRequiredArguments.ProvidedRequiredArgumentsOnDirectives];
  62112. exports.specifiedSDLRules = specifiedSDLRules;
  62113. },{"./rules/ExecutableDefinitions":356,"./rules/FieldsOnCorrectType":357,"./rules/FragmentsOnCompositeTypes":358,"./rules/KnownArgumentNames":359,"./rules/KnownDirectives":360,"./rules/KnownFragmentNames":361,"./rules/KnownTypeNames":362,"./rules/LoneAnonymousOperation":363,"./rules/LoneSchemaDefinition":364,"./rules/NoFragmentCycles":365,"./rules/NoUndefinedVariables":366,"./rules/NoUnusedFragments":367,"./rules/NoUnusedVariables":368,"./rules/OverlappingFieldsCanBeMerged":369,"./rules/PossibleFragmentSpreads":370,"./rules/PossibleTypeExtensions":371,"./rules/ProvidedRequiredArguments":372,"./rules/ScalarLeafs":373,"./rules/SingleFieldSubscriptions":374,"./rules/UniqueArgumentNames":375,"./rules/UniqueDirectiveNames":376,"./rules/UniqueDirectivesPerLocation":377,"./rules/UniqueEnumValueNames":378,"./rules/UniqueFieldDefinitionNames":379,"./rules/UniqueFragmentNames":380,"./rules/UniqueInputFieldNames":381,"./rules/UniqueOperationNames":382,"./rules/UniqueOperationTypes":383,"./rules/UniqueTypeNames":384,"./rules/UniqueVariableNames":385,"./rules/ValuesOfCorrectType":386,"./rules/VariablesAreInputTypes":387,"./rules/VariablesInAllowedPosition":388}],390:[function(require,module,exports){
  62114. "use strict";
  62115. Object.defineProperty(exports, "__esModule", {
  62116. value: true
  62117. });
  62118. exports.validate = validate;
  62119. exports.validateSDL = validateSDL;
  62120. exports.assertValidSDL = assertValidSDL;
  62121. exports.assertValidSDLExtension = assertValidSDLExtension;
  62122. var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
  62123. var _visitor = require("../language/visitor");
  62124. var _validate = require("../type/validate");
  62125. var _TypeInfo = require("../utilities/TypeInfo");
  62126. var _specifiedRules = require("./specifiedRules");
  62127. var _ValidationContext = require("./ValidationContext");
  62128. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  62129. /**
  62130. * Copyright (c) 2015-present, Facebook, Inc.
  62131. *
  62132. * This source code is licensed under the MIT license found in the
  62133. * LICENSE file in the root directory of this source tree.
  62134. *
  62135. *
  62136. */
  62137. /**
  62138. * Implements the "Validation" section of the spec.
  62139. *
  62140. * Validation runs synchronously, returning an array of encountered errors, or
  62141. * an empty array if no errors were encountered and the document is valid.
  62142. *
  62143. * A list of specific validation rules may be provided. If not provided, the
  62144. * default list of rules defined by the GraphQL specification will be used.
  62145. *
  62146. * Each validation rules is a function which returns a visitor
  62147. * (see the language/visitor API). Visitor methods are expected to return
  62148. * GraphQLErrors, or Arrays of GraphQLErrors when invalid.
  62149. *
  62150. * Optionally a custom TypeInfo instance may be provided. If not provided, one
  62151. * will be created from the provided schema.
  62152. */
  62153. function validate(schema, documentAST) {
  62154. var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _specifiedRules.specifiedRules;
  62155. var typeInfo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _TypeInfo.TypeInfo(schema);
  62156. !documentAST ? (0, _invariant.default)(0, 'Must provide document') : void 0; // If the schema used for validation is invalid, throw an error.
  62157. (0, _validate.assertValidSchema)(schema);
  62158. var context = new _ValidationContext.ValidationContext(schema, documentAST, typeInfo); // This uses a specialized visitor which runs multiple visitors in parallel,
  62159. // while maintaining the visitor skip and break API.
  62160. var visitor = (0, _visitor.visitInParallel)(rules.map(function (rule) {
  62161. return rule(context);
  62162. })); // Visit the whole document with each instance of all provided rules.
  62163. (0, _visitor.visit)(documentAST, (0, _visitor.visitWithTypeInfo)(typeInfo, visitor));
  62164. return context.getErrors();
  62165. } // @internal
  62166. function validateSDL(documentAST, schemaToExtend) {
  62167. var rules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _specifiedRules.specifiedSDLRules;
  62168. var context = new _ValidationContext.SDLValidationContext(documentAST, schemaToExtend);
  62169. var visitors = rules.map(function (rule) {
  62170. return rule(context);
  62171. });
  62172. (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors));
  62173. return context.getErrors();
  62174. }
  62175. /**
  62176. * Utility function which asserts a SDL document is valid by throwing an error
  62177. * if it is invalid.
  62178. *
  62179. * @internal
  62180. */
  62181. function assertValidSDL(documentAST) {
  62182. var errors = validateSDL(documentAST);
  62183. if (errors.length !== 0) {
  62184. throw new Error(errors.map(function (error) {
  62185. return error.message;
  62186. }).join('\n\n'));
  62187. }
  62188. }
  62189. /**
  62190. * Utility function which asserts a SDL document is valid by throwing an error
  62191. * if it is invalid.
  62192. *
  62193. * @internal
  62194. */
  62195. function assertValidSDLExtension(documentAST, schema) {
  62196. var errors = validateSDL(documentAST, schema);
  62197. if (errors.length !== 0) {
  62198. throw new Error(errors.map(function (error) {
  62199. return error.message;
  62200. }).join('\n\n'));
  62201. }
  62202. }
  62203. },{"../jsutils/invariant":290,"../language/visitor":314,"../type/validate":329,"../utilities/TypeInfo":330,"./ValidationContext":354,"./specifiedRules":389}],391:[function(require,module,exports){
  62204. 'use strict';
  62205. var _codemirror = require('codemirror');
  62206. var _codemirror2 = _interopRequireDefault(_codemirror);
  62207. var _graphqlLanguageServiceParser = require('graphql-language-service-parser');
  62208. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  62209. /**
  62210. * This mode defines JSON, but provides a data-laden parser state to enable
  62211. * better code intelligence.
  62212. */
  62213. /**
  62214. * Copyright (c) 2015, Facebook, Inc.
  62215. * All rights reserved.
  62216. *
  62217. * This source code is licensed under the BSD-style license found in the
  62218. * LICENSE file in the root directory of this source tree. An additional grant
  62219. * of patent rights can be found in the PATENTS file in the same directory.
  62220. */
  62221. _codemirror2.default.defineMode('graphql-results', function (config) {
  62222. var parser = (0, _graphqlLanguageServiceParser.onlineParser)({
  62223. eatWhitespace: function eatWhitespace(stream) {
  62224. return stream.eatSpace();
  62225. },
  62226. lexRules: LexRules,
  62227. parseRules: ParseRules,
  62228. editorConfig: { tabSize: config.tabSize }
  62229. });
  62230. return {
  62231. config: config,
  62232. startState: parser.startState,
  62233. token: parser.token,
  62234. indent: indent,
  62235. electricInput: /^\s*[}\]]/,
  62236. fold: 'brace',
  62237. closeBrackets: {
  62238. pairs: '[]{}""',
  62239. explode: '[]{}'
  62240. }
  62241. };
  62242. });
  62243. function indent(state, textAfter) {
  62244. var levels = state.levels;
  62245. // If there is no stack of levels, use the current level.
  62246. // Otherwise, use the top level, pre-emptively dedenting for close braces.
  62247. var level = !levels || levels.length === 0 ? state.indentLevel : levels[levels.length - 1] - (this.electricInput.test(textAfter) ? 1 : 0);
  62248. return level * this.config.indentUnit;
  62249. }
  62250. /**
  62251. * The lexer rules. These are exactly as described by the spec.
  62252. */
  62253. var LexRules = {
  62254. // All Punctuation used in JSON.
  62255. Punctuation: /^\[|]|\{|\}|:|,/,
  62256. // JSON Number.
  62257. Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,
  62258. // JSON String.
  62259. String: /^"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?/,
  62260. // JSON literal keywords.
  62261. Keyword: /^true|false|null/
  62262. };
  62263. /**
  62264. * The parser rules for JSON.
  62265. */
  62266. var ParseRules = {
  62267. Document: [(0, _graphqlLanguageServiceParser.p)('{'), (0, _graphqlLanguageServiceParser.list)('Entry', (0, _graphqlLanguageServiceParser.p)(',')), (0, _graphqlLanguageServiceParser.p)('}')],
  62268. Entry: [(0, _graphqlLanguageServiceParser.t)('String', 'def'), (0, _graphqlLanguageServiceParser.p)(':'), 'Value'],
  62269. Value: function Value(token) {
  62270. switch (token.kind) {
  62271. case 'Number':
  62272. return 'NumberValue';
  62273. case 'String':
  62274. return 'StringValue';
  62275. case 'Punctuation':
  62276. switch (token.value) {
  62277. case '[':
  62278. return 'ListValue';
  62279. case '{':
  62280. return 'ObjectValue';
  62281. }
  62282. return null;
  62283. case 'Keyword':
  62284. switch (token.value) {
  62285. case 'true':
  62286. case 'false':
  62287. return 'BooleanValue';
  62288. case 'null':
  62289. return 'NullValue';
  62290. }
  62291. return null;
  62292. }
  62293. },
  62294. NumberValue: [(0, _graphqlLanguageServiceParser.t)('Number', 'number')],
  62295. StringValue: [(0, _graphqlLanguageServiceParser.t)('String', 'string')],
  62296. BooleanValue: [(0, _graphqlLanguageServiceParser.t)('Keyword', 'builtin')],
  62297. NullValue: [(0, _graphqlLanguageServiceParser.t)('Keyword', 'keyword')],
  62298. ListValue: [(0, _graphqlLanguageServiceParser.p)('['), (0, _graphqlLanguageServiceParser.list)('Value', (0, _graphqlLanguageServiceParser.p)(',')), (0, _graphqlLanguageServiceParser.p)(']')],
  62299. ObjectValue: [(0, _graphqlLanguageServiceParser.p)('{'), (0, _graphqlLanguageServiceParser.list)('ObjectField', (0, _graphqlLanguageServiceParser.p)(',')), (0, _graphqlLanguageServiceParser.p)('}')],
  62300. ObjectField: [(0, _graphqlLanguageServiceParser.t)('String', 'property'), (0, _graphqlLanguageServiceParser.p)(':'), 'Value']
  62301. };
  62302. },{"codemirror":16,"graphql-language-service-parser":269}],392:[function(require,module,exports){
  62303. 'use strict';
  62304. Object.defineProperty(exports, "__esModule", {
  62305. value: true
  62306. });
  62307. exports.getFieldReference = getFieldReference;
  62308. exports.getDirectiveReference = getDirectiveReference;
  62309. exports.getArgumentReference = getArgumentReference;
  62310. exports.getEnumValueReference = getEnumValueReference;
  62311. exports.getTypeReference = getTypeReference;
  62312. var _graphql = require('graphql');
  62313. function getFieldReference(typeInfo) {
  62314. return {
  62315. kind: 'Field',
  62316. schema: typeInfo.schema,
  62317. field: typeInfo.fieldDef,
  62318. type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType
  62319. };
  62320. }
  62321. /**
  62322. * Copyright (c), Facebook, Inc.
  62323. * All rights reserved.
  62324. *
  62325. * This source code is licensed under the BSD-style license found in the
  62326. * LICENSE file in the root directory of this source tree. An additional grant
  62327. * of patent rights can be found in the PATENTS file in the same directory.
  62328. */
  62329. function getDirectiveReference(typeInfo) {
  62330. return {
  62331. kind: 'Directive',
  62332. schema: typeInfo.schema,
  62333. directive: typeInfo.directiveDef
  62334. };
  62335. }
  62336. function getArgumentReference(typeInfo) {
  62337. return typeInfo.directiveDef ? {
  62338. kind: 'Argument',
  62339. schema: typeInfo.schema,
  62340. argument: typeInfo.argDef,
  62341. directive: typeInfo.directiveDef
  62342. } : {
  62343. kind: 'Argument',
  62344. schema: typeInfo.schema,
  62345. argument: typeInfo.argDef,
  62346. field: typeInfo.fieldDef,
  62347. type: isMetaField(typeInfo.fieldDef) ? null : typeInfo.parentType
  62348. };
  62349. }
  62350. function getEnumValueReference(typeInfo) {
  62351. return {
  62352. kind: 'EnumValue',
  62353. value: typeInfo.enumValue,
  62354. type: (0, _graphql.getNamedType)(typeInfo.inputType)
  62355. };
  62356. }
  62357. // Note: for reusability, getTypeReference can produce a reference to any type,
  62358. // though it defaults to the current type.
  62359. function getTypeReference(typeInfo, type) {
  62360. return {
  62361. kind: 'Type',
  62362. schema: typeInfo.schema,
  62363. type: type || typeInfo.type
  62364. };
  62365. }
  62366. function isMetaField(fieldDef) {
  62367. return fieldDef.name.slice(0, 2) === '__';
  62368. }
  62369. },{"graphql":285}],393:[function(require,module,exports){
  62370. "use strict";
  62371. Object.defineProperty(exports, "__esModule", {
  62372. value: true
  62373. });
  62374. exports.default = forEachState;
  62375. /**
  62376. * Copyright (c) 2015, Facebook, Inc.
  62377. * All rights reserved.
  62378. *
  62379. * This source code is licensed under the BSD-style license found in the
  62380. * LICENSE file in the root directory of this source tree. An additional grant
  62381. * of patent rights can be found in the PATENTS file in the same directory.
  62382. */
  62383. // Utility for iterating through a CodeMirror parse state stack bottom-up.
  62384. function forEachState(stack, fn) {
  62385. var reverseStateStack = [];
  62386. var state = stack;
  62387. while (state && state.kind) {
  62388. reverseStateStack.push(state);
  62389. state = state.prevState;
  62390. }
  62391. for (var i = reverseStateStack.length - 1; i >= 0; i--) {
  62392. fn(reverseStateStack[i]);
  62393. }
  62394. }
  62395. },{}],394:[function(require,module,exports){
  62396. 'use strict';
  62397. Object.defineProperty(exports, "__esModule", {
  62398. value: true
  62399. });
  62400. exports.default = getTypeInfo;
  62401. var _graphql = require('graphql');
  62402. var _introspection = require('graphql/type/introspection');
  62403. var _forEachState = require('./forEachState');
  62404. var _forEachState2 = _interopRequireDefault(_forEachState);
  62405. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  62406. /**
  62407. * Utility for collecting rich type information given any token's state
  62408. * from the graphql-mode parser.
  62409. */
  62410. function getTypeInfo(schema, tokenState) {
  62411. var info = {
  62412. schema: schema,
  62413. type: null,
  62414. parentType: null,
  62415. inputType: null,
  62416. directiveDef: null,
  62417. fieldDef: null,
  62418. argDef: null,
  62419. argDefs: null,
  62420. objectFieldDefs: null
  62421. };
  62422. (0, _forEachState2.default)(tokenState, function (state) {
  62423. switch (state.kind) {
  62424. case 'Query':
  62425. case 'ShortQuery':
  62426. info.type = schema.getQueryType();
  62427. break;
  62428. case 'Mutation':
  62429. info.type = schema.getMutationType();
  62430. break;
  62431. case 'Subscription':
  62432. info.type = schema.getSubscriptionType();
  62433. break;
  62434. case 'InlineFragment':
  62435. case 'FragmentDefinition':
  62436. if (state.type) {
  62437. info.type = schema.getType(state.type);
  62438. }
  62439. break;
  62440. case 'Field':
  62441. case 'AliasedField':
  62442. info.fieldDef = info.type && state.name ? getFieldDef(schema, info.parentType, state.name) : null;
  62443. info.type = info.fieldDef && info.fieldDef.type;
  62444. break;
  62445. case 'SelectionSet':
  62446. info.parentType = (0, _graphql.getNamedType)(info.type);
  62447. break;
  62448. case 'Directive':
  62449. info.directiveDef = state.name && schema.getDirective(state.name);
  62450. break;
  62451. case 'Arguments':
  62452. var parentDef = state.prevState.kind === 'Field' ? info.fieldDef : state.prevState.kind === 'Directive' ? info.directiveDef : state.prevState.kind === 'AliasedField' ? state.prevState.name && getFieldDef(schema, info.parentType, state.prevState.name) : null;
  62453. info.argDefs = parentDef && parentDef.args;
  62454. break;
  62455. case 'Argument':
  62456. info.argDef = null;
  62457. if (info.argDefs) {
  62458. for (var i = 0; i < info.argDefs.length; i++) {
  62459. if (info.argDefs[i].name === state.name) {
  62460. info.argDef = info.argDefs[i];
  62461. break;
  62462. }
  62463. }
  62464. }
  62465. info.inputType = info.argDef && info.argDef.type;
  62466. break;
  62467. case 'EnumValue':
  62468. var enumType = (0, _graphql.getNamedType)(info.inputType);
  62469. info.enumValue = enumType instanceof _graphql.GraphQLEnumType ? find(enumType.getValues(), function (val) {
  62470. return val.value === state.name;
  62471. }) : null;
  62472. break;
  62473. case 'ListValue':
  62474. var nullableType = (0, _graphql.getNullableType)(info.inputType);
  62475. info.inputType = nullableType instanceof _graphql.GraphQLList ? nullableType.ofType : null;
  62476. break;
  62477. case 'ObjectValue':
  62478. var objectType = (0, _graphql.getNamedType)(info.inputType);
  62479. info.objectFieldDefs = objectType instanceof _graphql.GraphQLInputObjectType ? objectType.getFields() : null;
  62480. break;
  62481. case 'ObjectField':
  62482. var objectField = state.name && info.objectFieldDefs ? info.objectFieldDefs[state.name] : null;
  62483. info.inputType = objectField && objectField.type;
  62484. break;
  62485. case 'NamedType':
  62486. info.type = schema.getType(state.name);
  62487. break;
  62488. }
  62489. });
  62490. return info;
  62491. }
  62492. // Gets the field definition given a type and field name
  62493. /**
  62494. * Copyright (c) 2015, Facebook, Inc.
  62495. * All rights reserved.
  62496. *
  62497. * This source code is licensed under the BSD-style license found in the
  62498. * LICENSE file in the root directory of this source tree. An additional grant
  62499. * of patent rights can be found in the PATENTS file in the same directory.
  62500. */
  62501. function getFieldDef(schema, type, fieldName) {
  62502. if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === type) {
  62503. return _introspection.SchemaMetaFieldDef;
  62504. }
  62505. if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === type) {
  62506. return _introspection.TypeMetaFieldDef;
  62507. }
  62508. if (fieldName === _introspection.TypeNameMetaFieldDef.name && (0, _graphql.isCompositeType)(type)) {
  62509. return _introspection.TypeNameMetaFieldDef;
  62510. }
  62511. if (type.getFields) {
  62512. return type.getFields()[fieldName];
  62513. }
  62514. }
  62515. // Returns the first item in the array which causes predicate to return truthy.
  62516. function find(array, predicate) {
  62517. for (var i = 0; i < array.length; i++) {
  62518. if (predicate(array[i])) {
  62519. return array[i];
  62520. }
  62521. }
  62522. }
  62523. },{"./forEachState":393,"graphql":285,"graphql/type/introspection":326}],395:[function(require,module,exports){
  62524. 'use strict';
  62525. Object.defineProperty(exports, "__esModule", {
  62526. value: true
  62527. });
  62528. exports.default = hintList;
  62529. /**
  62530. * Copyright (c) 2015, Facebook, Inc.
  62531. * All rights reserved.
  62532. *
  62533. * This source code is licensed under the BSD-style license found in the
  62534. * LICENSE file in the root directory of this source tree. An additional grant
  62535. * of patent rights can be found in the PATENTS file in the same directory.
  62536. */
  62537. // Create the expected hint response given a possible list and a token
  62538. function hintList(cursor, token, list) {
  62539. var hints = filterAndSortList(list, normalizeText(token.string));
  62540. if (!hints) {
  62541. return;
  62542. }
  62543. var tokenStart = token.type !== null && /"|\w/.test(token.string[0]) ? token.start : token.end;
  62544. return {
  62545. list: hints,
  62546. from: { line: cursor.line, column: tokenStart },
  62547. to: { line: cursor.line, column: token.end }
  62548. };
  62549. }
  62550. // Given a list of hint entries and currently typed text, sort and filter to
  62551. // provide a concise list.
  62552. function filterAndSortList(list, text) {
  62553. if (!text) {
  62554. return filterNonEmpty(list, function (entry) {
  62555. return !entry.isDeprecated;
  62556. });
  62557. }
  62558. var byProximity = list.map(function (entry) {
  62559. return {
  62560. proximity: getProximity(normalizeText(entry.text), text),
  62561. entry: entry
  62562. };
  62563. });
  62564. var conciseMatches = filterNonEmpty(filterNonEmpty(byProximity, function (pair) {
  62565. return pair.proximity <= 2;
  62566. }), function (pair) {
  62567. return !pair.entry.isDeprecated;
  62568. });
  62569. var sortedMatches = conciseMatches.sort(function (a, b) {
  62570. return (a.entry.isDeprecated ? 1 : 0) - (b.entry.isDeprecated ? 1 : 0) || a.proximity - b.proximity || a.entry.text.length - b.entry.text.length;
  62571. });
  62572. return sortedMatches.map(function (pair) {
  62573. return pair.entry;
  62574. });
  62575. }
  62576. // Filters the array by the predicate, unless it results in an empty array,
  62577. // in which case return the original array.
  62578. function filterNonEmpty(array, predicate) {
  62579. var filtered = array.filter(predicate);
  62580. return filtered.length === 0 ? array : filtered;
  62581. }
  62582. function normalizeText(text) {
  62583. return text.toLowerCase().replace(/\W/g, '');
  62584. }
  62585. // Determine a numeric proximity for a suggestion based on current text.
  62586. function getProximity(suggestion, text) {
  62587. // start with lexical distance
  62588. var proximity = lexicalDistance(text, suggestion);
  62589. if (suggestion.length > text.length) {
  62590. // do not penalize long suggestions.
  62591. proximity -= suggestion.length - text.length - 1;
  62592. // penalize suggestions not starting with this phrase
  62593. proximity += suggestion.indexOf(text) === 0 ? 0 : 0.5;
  62594. }
  62595. return proximity;
  62596. }
  62597. /**
  62598. * Computes the lexical distance between strings A and B.
  62599. *
  62600. * The "distance" between two strings is given by counting the minimum number
  62601. * of edits needed to transform string A into string B. An edit can be an
  62602. * insertion, deletion, or substitution of a single character, or a swap of two
  62603. * adjacent characters.
  62604. *
  62605. * This distance can be useful for detecting typos in input or sorting
  62606. *
  62607. * @param {string} a
  62608. * @param {string} b
  62609. * @return {int} distance in number of edits
  62610. */
  62611. function lexicalDistance(a, b) {
  62612. var i = void 0;
  62613. var j = void 0;
  62614. var d = [];
  62615. var aLength = a.length;
  62616. var bLength = b.length;
  62617. for (i = 0; i <= aLength; i++) {
  62618. d[i] = [i];
  62619. }
  62620. for (j = 1; j <= bLength; j++) {
  62621. d[0][j] = j;
  62622. }
  62623. for (i = 1; i <= aLength; i++) {
  62624. for (j = 1; j <= bLength; j++) {
  62625. var cost = a[i - 1] === b[j - 1] ? 0 : 1;
  62626. d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
  62627. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  62628. d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
  62629. }
  62630. }
  62631. }
  62632. return d[aLength][bLength];
  62633. }
  62634. },{}],396:[function(require,module,exports){
  62635. 'use strict';
  62636. var _codemirror = require('codemirror');
  62637. var _codemirror2 = _interopRequireDefault(_codemirror);
  62638. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  62639. _codemirror2.default.defineOption('info', false, function (cm, options, old) {
  62640. if (old && old !== _codemirror2.default.Init) {
  62641. var oldOnMouseOver = cm.state.info.onMouseOver;
  62642. _codemirror2.default.off(cm.getWrapperElement(), 'mouseover', oldOnMouseOver);
  62643. clearTimeout(cm.state.info.hoverTimeout);
  62644. delete cm.state.info;
  62645. }
  62646. if (options) {
  62647. var state = cm.state.info = createState(options);
  62648. state.onMouseOver = onMouseOver.bind(null, cm);
  62649. _codemirror2.default.on(cm.getWrapperElement(), 'mouseover', state.onMouseOver);
  62650. }
  62651. }); /**
  62652. * Copyright (c) 2017, Facebook, Inc.
  62653. * All rights reserved.
  62654. *
  62655. * This source code is licensed under the BSD-style license found in the
  62656. * LICENSE file in the root directory of this source tree. An additional grant
  62657. * of patent rights can be found in the PATENTS file in the same directory.
  62658. */
  62659. function createState(options) {
  62660. return {
  62661. options: options instanceof Function ? { render: options } : options === true ? {} : options
  62662. };
  62663. }
  62664. function getHoverTime(cm) {
  62665. var options = cm.state.info.options;
  62666. return options && options.hoverTime || 500;
  62667. }
  62668. function onMouseOver(cm, e) {
  62669. var state = cm.state.info;
  62670. var target = e.target || e.srcElement;
  62671. if (target.nodeName !== 'SPAN' || state.hoverTimeout !== undefined) {
  62672. return;
  62673. }
  62674. var box = target.getBoundingClientRect();
  62675. var hoverTime = getHoverTime(cm);
  62676. state.hoverTimeout = setTimeout(onHover, hoverTime);
  62677. var onMouseMove = function onMouseMove() {
  62678. clearTimeout(state.hoverTimeout);
  62679. state.hoverTimeout = setTimeout(onHover, hoverTime);
  62680. };
  62681. var onMouseOut = function onMouseOut() {
  62682. _codemirror2.default.off(document, 'mousemove', onMouseMove);
  62683. _codemirror2.default.off(cm.getWrapperElement(), 'mouseout', onMouseOut);
  62684. clearTimeout(state.hoverTimeout);
  62685. state.hoverTimeout = undefined;
  62686. };
  62687. var onHover = function onHover() {
  62688. _codemirror2.default.off(document, 'mousemove', onMouseMove);
  62689. _codemirror2.default.off(cm.getWrapperElement(), 'mouseout', onMouseOut);
  62690. state.hoverTimeout = undefined;
  62691. onMouseHover(cm, box);
  62692. };
  62693. _codemirror2.default.on(document, 'mousemove', onMouseMove);
  62694. _codemirror2.default.on(cm.getWrapperElement(), 'mouseout', onMouseOut);
  62695. }
  62696. function onMouseHover(cm, box) {
  62697. var pos = cm.coordsChar({
  62698. left: (box.left + box.right) / 2,
  62699. top: (box.top + box.bottom) / 2
  62700. });
  62701. var state = cm.state.info;
  62702. var options = state.options;
  62703. var render = options.render || cm.getHelper(pos, 'info');
  62704. if (render) {
  62705. var token = cm.getTokenAt(pos, true);
  62706. if (token) {
  62707. var info = render(token, options, cm, pos);
  62708. if (info) {
  62709. showPopup(cm, box, info);
  62710. }
  62711. }
  62712. }
  62713. }
  62714. function showPopup(cm, box, info) {
  62715. var popup = document.createElement('div');
  62716. popup.className = 'CodeMirror-info';
  62717. popup.appendChild(info);
  62718. document.body.appendChild(popup);
  62719. var popupBox = popup.getBoundingClientRect();
  62720. var popupStyle = popup.currentStyle || window.getComputedStyle(popup);
  62721. var popupWidth = popupBox.right - popupBox.left + parseFloat(popupStyle.marginLeft) + parseFloat(popupStyle.marginRight);
  62722. var popupHeight = popupBox.bottom - popupBox.top + parseFloat(popupStyle.marginTop) + parseFloat(popupStyle.marginBottom);
  62723. var topPos = box.bottom;
  62724. if (popupHeight > window.innerHeight - box.bottom - 15 && box.top > window.innerHeight - box.bottom) {
  62725. topPos = box.top - popupHeight;
  62726. }
  62727. if (topPos < 0) {
  62728. topPos = box.bottom;
  62729. }
  62730. var leftPos = Math.max(0, window.innerWidth - popupWidth - 15);
  62731. if (leftPos > box.left) {
  62732. leftPos = box.left;
  62733. }
  62734. popup.style.opacity = 1;
  62735. popup.style.top = topPos + 'px';
  62736. popup.style.left = leftPos + 'px';
  62737. var popupTimeout = void 0;
  62738. var onMouseOverPopup = function onMouseOverPopup() {
  62739. clearTimeout(popupTimeout);
  62740. };
  62741. var onMouseOut = function onMouseOut() {
  62742. clearTimeout(popupTimeout);
  62743. popupTimeout = setTimeout(hidePopup, 200);
  62744. };
  62745. var hidePopup = function hidePopup() {
  62746. _codemirror2.default.off(popup, 'mouseover', onMouseOverPopup);
  62747. _codemirror2.default.off(popup, 'mouseout', onMouseOut);
  62748. _codemirror2.default.off(cm.getWrapperElement(), 'mouseout', onMouseOut);
  62749. if (popup.style.opacity) {
  62750. popup.style.opacity = 0;
  62751. setTimeout(function () {
  62752. if (popup.parentNode) {
  62753. popup.parentNode.removeChild(popup);
  62754. }
  62755. }, 600);
  62756. } else if (popup.parentNode) {
  62757. popup.parentNode.removeChild(popup);
  62758. }
  62759. };
  62760. _codemirror2.default.on(popup, 'mouseover', onMouseOverPopup);
  62761. _codemirror2.default.on(popup, 'mouseout', onMouseOut);
  62762. _codemirror2.default.on(cm.getWrapperElement(), 'mouseout', onMouseOut);
  62763. }
  62764. },{"codemirror":16}],397:[function(require,module,exports){
  62765. 'use strict';
  62766. Object.defineProperty(exports, "__esModule", {
  62767. value: true
  62768. });
  62769. exports.default = jsonParse;
  62770. /**
  62771. * Copyright (c) 2015, Facebook, Inc.
  62772. * All rights reserved.
  62773. *
  62774. * This source code is licensed under the BSD-style license found in the
  62775. * LICENSE file in the root directory of this source tree. An additional grant
  62776. * of patent rights can be found in the PATENTS file in the same directory.
  62777. */
  62778. /**
  62779. * This JSON parser simply walks the input, generating an AST. Use this in lieu
  62780. * of JSON.parse if you need character offset parse errors and an AST parse tree
  62781. * with location information.
  62782. *
  62783. * If an error is encountered, a SyntaxError will be thrown, with properties:
  62784. *
  62785. * - message: string
  62786. * - start: int - the start inclusive offset of the syntax error
  62787. * - end: int - the end exclusive offset of the syntax error
  62788. *
  62789. */
  62790. function jsonParse(str) {
  62791. string = str;
  62792. strLen = str.length;
  62793. start = end = lastEnd = -1;
  62794. ch();
  62795. lex();
  62796. var ast = parseObj();
  62797. expect('EOF');
  62798. return ast;
  62799. }
  62800. var string = void 0;
  62801. var strLen = void 0;
  62802. var start = void 0;
  62803. var end = void 0;
  62804. var lastEnd = void 0;
  62805. var code = void 0;
  62806. var kind = void 0;
  62807. function parseObj() {
  62808. var nodeStart = start;
  62809. var members = [];
  62810. expect('{');
  62811. if (!skip('}')) {
  62812. do {
  62813. members.push(parseMember());
  62814. } while (skip(','));
  62815. expect('}');
  62816. }
  62817. return {
  62818. kind: 'Object',
  62819. start: nodeStart,
  62820. end: lastEnd,
  62821. members: members
  62822. };
  62823. }
  62824. function parseMember() {
  62825. var nodeStart = start;
  62826. var key = kind === 'String' ? curToken() : null;
  62827. expect('String');
  62828. expect(':');
  62829. var value = parseVal();
  62830. return {
  62831. kind: 'Member',
  62832. start: nodeStart,
  62833. end: lastEnd,
  62834. key: key,
  62835. value: value
  62836. };
  62837. }
  62838. function parseArr() {
  62839. var nodeStart = start;
  62840. var values = [];
  62841. expect('[');
  62842. if (!skip(']')) {
  62843. do {
  62844. values.push(parseVal());
  62845. } while (skip(','));
  62846. expect(']');
  62847. }
  62848. return {
  62849. kind: 'Array',
  62850. start: nodeStart,
  62851. end: lastEnd,
  62852. values: values
  62853. };
  62854. }
  62855. function parseVal() {
  62856. switch (kind) {
  62857. case '[':
  62858. return parseArr();
  62859. case '{':
  62860. return parseObj();
  62861. case 'String':
  62862. case 'Number':
  62863. case 'Boolean':
  62864. case 'Null':
  62865. var token = curToken();
  62866. lex();
  62867. return token;
  62868. }
  62869. return expect('Value');
  62870. }
  62871. function curToken() {
  62872. return { kind: kind, start: start, end: end, value: JSON.parse(string.slice(start, end)) };
  62873. }
  62874. function expect(str) {
  62875. if (kind === str) {
  62876. lex();
  62877. return;
  62878. }
  62879. var found = void 0;
  62880. if (kind === 'EOF') {
  62881. found = '[end of file]';
  62882. } else if (end - start > 1) {
  62883. found = '`' + string.slice(start, end) + '`';
  62884. } else {
  62885. var match = string.slice(start).match(/^.+?\b/);
  62886. found = '`' + (match ? match[0] : string[start]) + '`';
  62887. }
  62888. throw syntaxError('Expected ' + str + ' but found ' + found + '.');
  62889. }
  62890. function syntaxError(message) {
  62891. return { message: message, start: start, end: end };
  62892. }
  62893. function skip(k) {
  62894. if (kind === k) {
  62895. lex();
  62896. return true;
  62897. }
  62898. }
  62899. function ch() {
  62900. if (end < strLen) {
  62901. end++;
  62902. code = end === strLen ? 0 : string.charCodeAt(end);
  62903. }
  62904. }
  62905. function lex() {
  62906. lastEnd = end;
  62907. while (code === 9 || code === 10 || code === 13 || code === 32) {
  62908. ch();
  62909. }
  62910. if (code === 0) {
  62911. kind = 'EOF';
  62912. return;
  62913. }
  62914. start = end;
  62915. switch (code) {
  62916. // "
  62917. case 34:
  62918. kind = 'String';
  62919. return readString();
  62920. // -, 0-9
  62921. case 45:
  62922. case 48:
  62923. case 49:
  62924. case 50:
  62925. case 51:
  62926. case 52:
  62927. case 53:
  62928. case 54:
  62929. case 55:
  62930. case 56:
  62931. case 57:
  62932. kind = 'Number';
  62933. return readNumber();
  62934. // f
  62935. case 102:
  62936. if (string.slice(start, start + 5) !== 'false') {
  62937. break;
  62938. }
  62939. end += 4;
  62940. ch();
  62941. kind = 'Boolean';
  62942. return;
  62943. // n
  62944. case 110:
  62945. if (string.slice(start, start + 4) !== 'null') {
  62946. break;
  62947. }
  62948. end += 3;
  62949. ch();
  62950. kind = 'Null';
  62951. return;
  62952. // t
  62953. case 116:
  62954. if (string.slice(start, start + 4) !== 'true') {
  62955. break;
  62956. }
  62957. end += 3;
  62958. ch();
  62959. kind = 'Boolean';
  62960. return;
  62961. }
  62962. kind = string[start];
  62963. ch();
  62964. }
  62965. function readString() {
  62966. ch();
  62967. while (code !== 34 && code > 31) {
  62968. if (code === 92) {
  62969. // \
  62970. ch();
  62971. switch (code) {
  62972. case 34: // "
  62973. case 47: // /
  62974. case 92: // \
  62975. case 98: // b
  62976. case 102: // f
  62977. case 110: // n
  62978. case 114: // r
  62979. case 116:
  62980. // t
  62981. ch();
  62982. break;
  62983. case 117:
  62984. // u
  62985. ch();
  62986. readHex();
  62987. readHex();
  62988. readHex();
  62989. readHex();
  62990. break;
  62991. default:
  62992. throw syntaxError('Bad character escape sequence.');
  62993. }
  62994. } else if (end === strLen) {
  62995. throw syntaxError('Unterminated string.');
  62996. } else {
  62997. ch();
  62998. }
  62999. }
  63000. if (code === 34) {
  63001. ch();
  63002. return;
  63003. }
  63004. throw syntaxError('Unterminated string.');
  63005. }
  63006. function readHex() {
  63007. if (code >= 48 && code <= 57 || // 0-9
  63008. code >= 65 && code <= 70 || // A-F
  63009. code >= 97 && code <= 102 // a-f
  63010. ) {
  63011. return ch();
  63012. }
  63013. throw syntaxError('Expected hexadecimal digit.');
  63014. }
  63015. function readNumber() {
  63016. if (code === 45) {
  63017. // -
  63018. ch();
  63019. }
  63020. if (code === 48) {
  63021. // 0
  63022. ch();
  63023. } else {
  63024. readDigits();
  63025. }
  63026. if (code === 46) {
  63027. // .
  63028. ch();
  63029. readDigits();
  63030. }
  63031. if (code === 69 || code === 101) {
  63032. // E e
  63033. ch();
  63034. if (code === 43 || code === 45) {
  63035. // + -
  63036. ch();
  63037. }
  63038. readDigits();
  63039. }
  63040. }
  63041. function readDigits() {
  63042. if (code < 48 || code > 57) {
  63043. // 0 - 9
  63044. throw syntaxError('Expected decimal digit.');
  63045. }
  63046. do {
  63047. ch();
  63048. } while (code >= 48 && code <= 57); // 0 - 9
  63049. }
  63050. },{}],398:[function(require,module,exports){
  63051. 'use strict';
  63052. var _codemirror = require('codemirror');
  63053. var _codemirror2 = _interopRequireDefault(_codemirror);
  63054. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  63055. _codemirror2.default.defineOption('jump', false, function (cm, options, old) {
  63056. if (old && old !== _codemirror2.default.Init) {
  63057. var oldOnMouseOver = cm.state.jump.onMouseOver;
  63058. _codemirror2.default.off(cm.getWrapperElement(), 'mouseover', oldOnMouseOver);
  63059. var oldOnMouseOut = cm.state.jump.onMouseOut;
  63060. _codemirror2.default.off(cm.getWrapperElement(), 'mouseout', oldOnMouseOut);
  63061. _codemirror2.default.off(document, 'keydown', cm.state.jump.onKeyDown);
  63062. delete cm.state.jump;
  63063. }
  63064. if (options) {
  63065. var state = cm.state.jump = {
  63066. options: options,
  63067. onMouseOver: onMouseOver.bind(null, cm),
  63068. onMouseOut: onMouseOut.bind(null, cm),
  63069. onKeyDown: onKeyDown.bind(null, cm)
  63070. };
  63071. _codemirror2.default.on(cm.getWrapperElement(), 'mouseover', state.onMouseOver);
  63072. _codemirror2.default.on(cm.getWrapperElement(), 'mouseout', state.onMouseOut);
  63073. _codemirror2.default.on(document, 'keydown', state.onKeyDown);
  63074. }
  63075. }); /**
  63076. * Copyright (c) 2017, Facebook, Inc.
  63077. * All rights reserved.
  63078. *
  63079. * This source code is licensed under the BSD-style license found in the
  63080. * LICENSE file in the root directory of this source tree. An additional grant
  63081. * of patent rights can be found in the PATENTS file in the same directory.
  63082. */
  63083. function onMouseOver(cm, event) {
  63084. var target = event.target || event.srcElement;
  63085. if (target.nodeName !== 'SPAN') {
  63086. return;
  63087. }
  63088. var box = target.getBoundingClientRect();
  63089. var cursor = {
  63090. left: (box.left + box.right) / 2,
  63091. top: (box.top + box.bottom) / 2
  63092. };
  63093. cm.state.jump.cursor = cursor;
  63094. if (cm.state.jump.isHoldingModifier) {
  63095. enableJumpMode(cm);
  63096. }
  63097. }
  63098. function onMouseOut(cm) {
  63099. if (!cm.state.jump.isHoldingModifier && cm.state.jump.cursor) {
  63100. cm.state.jump.cursor = null;
  63101. return;
  63102. }
  63103. if (cm.state.jump.isHoldingModifier && cm.state.jump.marker) {
  63104. disableJumpMode(cm);
  63105. }
  63106. }
  63107. function onKeyDown(cm, event) {
  63108. if (cm.state.jump.isHoldingModifier || !isJumpModifier(event.key)) {
  63109. return;
  63110. }
  63111. cm.state.jump.isHoldingModifier = true;
  63112. if (cm.state.jump.cursor) {
  63113. enableJumpMode(cm);
  63114. }
  63115. var onKeyUp = function onKeyUp(upEvent) {
  63116. if (upEvent.code !== event.code) {
  63117. return;
  63118. }
  63119. cm.state.jump.isHoldingModifier = false;
  63120. if (cm.state.jump.marker) {
  63121. disableJumpMode(cm);
  63122. }
  63123. _codemirror2.default.off(document, 'keyup', onKeyUp);
  63124. _codemirror2.default.off(document, 'click', onClick);
  63125. cm.off('mousedown', onMouseDown);
  63126. };
  63127. var onClick = function onClick(clickEvent) {
  63128. var destination = cm.state.jump.destination;
  63129. if (destination) {
  63130. cm.state.jump.options.onClick(destination, clickEvent);
  63131. }
  63132. };
  63133. var onMouseDown = function onMouseDown(_, downEvent) {
  63134. if (cm.state.jump.destination) {
  63135. downEvent.codemirrorIgnore = true;
  63136. }
  63137. };
  63138. _codemirror2.default.on(document, 'keyup', onKeyUp);
  63139. _codemirror2.default.on(document, 'click', onClick);
  63140. cm.on('mousedown', onMouseDown);
  63141. }
  63142. var isMac = navigator && navigator.appVersion.indexOf('Mac') !== -1;
  63143. function isJumpModifier(key) {
  63144. return key === (isMac ? 'Meta' : 'Control');
  63145. }
  63146. function enableJumpMode(cm) {
  63147. if (cm.state.jump.marker) {
  63148. return;
  63149. }
  63150. var cursor = cm.state.jump.cursor;
  63151. var pos = cm.coordsChar(cursor);
  63152. var token = cm.getTokenAt(pos, true);
  63153. var options = cm.state.jump.options;
  63154. var getDestination = options.getDestination || cm.getHelper(pos, 'jump');
  63155. if (getDestination) {
  63156. var destination = getDestination(token, options, cm);
  63157. if (destination) {
  63158. var marker = cm.markText({ line: pos.line, ch: token.start }, { line: pos.line, ch: token.end }, { className: 'CodeMirror-jump-token' });
  63159. cm.state.jump.marker = marker;
  63160. cm.state.jump.destination = destination;
  63161. }
  63162. }
  63163. }
  63164. function disableJumpMode(cm) {
  63165. var marker = cm.state.jump.marker;
  63166. cm.state.jump.marker = null;
  63167. cm.state.jump.destination = null;
  63168. marker.clear();
  63169. }
  63170. },{"codemirror":16}],399:[function(require,module,exports){
  63171. 'use strict';
  63172. var _codemirror = require('codemirror');
  63173. var _codemirror2 = _interopRequireDefault(_codemirror);
  63174. var _graphql = require('graphql');
  63175. var _forEachState = require('../utils/forEachState');
  63176. var _forEachState2 = _interopRequireDefault(_forEachState);
  63177. var _hintList = require('../utils/hintList');
  63178. var _hintList2 = _interopRequireDefault(_hintList);
  63179. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  63180. /**
  63181. * Registers a "hint" helper for CodeMirror.
  63182. *
  63183. * Using CodeMirror's "hint" addon: https://codemirror.net/demo/complete.html
  63184. * Given an editor, this helper will take the token at the cursor and return a
  63185. * list of suggested tokens.
  63186. *
  63187. * Options:
  63188. *
  63189. * - variableToType: { [variable: string]: GraphQLInputType }
  63190. *
  63191. * Additional Events:
  63192. *
  63193. * - hasCompletion (codemirror, data, token) - signaled when the hinter has a
  63194. * new list of completion suggestions.
  63195. *
  63196. */
  63197. /**
  63198. * Copyright (c) 2015, Facebook, Inc.
  63199. * All rights reserved.
  63200. *
  63201. * This source code is licensed under the BSD-style license found in the
  63202. * LICENSE file in the root directory of this source tree. An additional grant
  63203. * of patent rights can be found in the PATENTS file in the same directory.
  63204. */
  63205. _codemirror2.default.registerHelper('hint', 'graphql-variables', function (editor, options) {
  63206. var cur = editor.getCursor();
  63207. var token = editor.getTokenAt(cur);
  63208. var results = getVariablesHint(cur, token, options);
  63209. if (results && results.list && results.list.length > 0) {
  63210. results.from = _codemirror2.default.Pos(results.from.line, results.from.column);
  63211. results.to = _codemirror2.default.Pos(results.to.line, results.to.column);
  63212. _codemirror2.default.signal(editor, 'hasCompletion', editor, results, token);
  63213. }
  63214. return results;
  63215. });
  63216. function getVariablesHint(cur, token, options) {
  63217. // If currently parsing an invalid state, attempt to hint to the prior state.
  63218. var state = token.state.kind === 'Invalid' ? token.state.prevState : token.state;
  63219. var kind = state.kind;
  63220. var step = state.step;
  63221. // Variables can only be an object literal.
  63222. if (kind === 'Document' && step === 0) {
  63223. return (0, _hintList2.default)(cur, token, [{ text: '{' }]);
  63224. }
  63225. var variableToType = options.variableToType;
  63226. if (!variableToType) {
  63227. return;
  63228. }
  63229. var typeInfo = getTypeInfo(variableToType, token.state);
  63230. // Top level should typeahead possible variables.
  63231. if (kind === 'Document' || kind === 'Variable' && step === 0) {
  63232. var variableNames = Object.keys(variableToType);
  63233. return (0, _hintList2.default)(cur, token, variableNames.map(function (name) {
  63234. return {
  63235. text: '"' + name + '": ',
  63236. type: variableToType[name]
  63237. };
  63238. }));
  63239. }
  63240. // Input Object fields
  63241. if (kind === 'ObjectValue' || kind === 'ObjectField' && step === 0) {
  63242. if (typeInfo.fields) {
  63243. var inputFields = Object.keys(typeInfo.fields).map(function (fieldName) {
  63244. return typeInfo.fields[fieldName];
  63245. });
  63246. return (0, _hintList2.default)(cur, token, inputFields.map(function (field) {
  63247. return {
  63248. text: '"' + field.name + '": ',
  63249. type: field.type,
  63250. description: field.description
  63251. };
  63252. }));
  63253. }
  63254. }
  63255. // Input values.
  63256. if (kind === 'StringValue' || kind === 'NumberValue' || kind === 'BooleanValue' || kind === 'NullValue' || kind === 'ListValue' && step === 1 || kind === 'ObjectField' && step === 2 || kind === 'Variable' && step === 2) {
  63257. var namedInputType = (0, _graphql.getNamedType)(typeInfo.type);
  63258. if (namedInputType instanceof _graphql.GraphQLInputObjectType) {
  63259. return (0, _hintList2.default)(cur, token, [{ text: '{' }]);
  63260. } else if (namedInputType instanceof _graphql.GraphQLEnumType) {
  63261. var valueMap = namedInputType.getValues();
  63262. var values = Object.keys(valueMap).map(function (name) {
  63263. return valueMap[name];
  63264. });
  63265. return (0, _hintList2.default)(cur, token, values.map(function (value) {
  63266. return {
  63267. text: '"' + value.name + '"',
  63268. type: namedInputType,
  63269. description: value.description
  63270. };
  63271. }));
  63272. } else if (namedInputType === _graphql.GraphQLBoolean) {
  63273. return (0, _hintList2.default)(cur, token, [{ text: 'true', type: _graphql.GraphQLBoolean, description: 'Not false.' }, { text: 'false', type: _graphql.GraphQLBoolean, description: 'Not true.' }]);
  63274. }
  63275. }
  63276. }
  63277. // Utility for collecting rich type information given any token's state
  63278. // from the graphql-variables-mode parser.
  63279. function getTypeInfo(variableToType, tokenState) {
  63280. var info = {
  63281. type: null,
  63282. fields: null
  63283. };
  63284. (0, _forEachState2.default)(tokenState, function (state) {
  63285. if (state.kind === 'Variable') {
  63286. info.type = variableToType[state.name];
  63287. } else if (state.kind === 'ListValue') {
  63288. var nullableType = (0, _graphql.getNullableType)(info.type);
  63289. info.type = nullableType instanceof _graphql.GraphQLList ? nullableType.ofType : null;
  63290. } else if (state.kind === 'ObjectValue') {
  63291. var objectType = (0, _graphql.getNamedType)(info.type);
  63292. info.fields = objectType instanceof _graphql.GraphQLInputObjectType ? objectType.getFields() : null;
  63293. } else if (state.kind === 'ObjectField') {
  63294. var objectField = state.name && info.fields ? info.fields[state.name] : null;
  63295. info.type = objectField && objectField.type;
  63296. }
  63297. });
  63298. return info;
  63299. }
  63300. },{"../utils/forEachState":393,"../utils/hintList":395,"codemirror":16,"graphql":285}],400:[function(require,module,exports){
  63301. 'use strict';
  63302. var _codemirror = require('codemirror');
  63303. var _codemirror2 = _interopRequireDefault(_codemirror);
  63304. var _graphql = require('graphql');
  63305. var _jsonParse = require('../utils/jsonParse');
  63306. var _jsonParse2 = _interopRequireDefault(_jsonParse);
  63307. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  63308. /**
  63309. * Registers a "lint" helper for CodeMirror.
  63310. *
  63311. * Using CodeMirror's "lint" addon: https://codemirror.net/demo/lint.html
  63312. * Given the text within an editor, this helper will take that text and return
  63313. * a list of linter issues ensuring that correct variables were provided.
  63314. *
  63315. * Options:
  63316. *
  63317. * - variableToType: { [variable: string]: GraphQLInputType }
  63318. *
  63319. */
  63320. _codemirror2.default.registerHelper('lint', 'graphql-variables', function (text, options, editor) {
  63321. // If there's no text, do nothing.
  63322. if (!text) {
  63323. return [];
  63324. }
  63325. // First, linter needs to determine if there are any parsing errors.
  63326. var ast = void 0;
  63327. try {
  63328. ast = (0, _jsonParse2.default)(text);
  63329. } catch (syntaxError) {
  63330. if (syntaxError.stack) {
  63331. throw syntaxError;
  63332. }
  63333. return [lintError(editor, syntaxError, syntaxError.message)];
  63334. }
  63335. // If there are not yet known variables, do nothing.
  63336. var variableToType = options.variableToType;
  63337. if (!variableToType) {
  63338. return [];
  63339. }
  63340. // Then highlight any issues with the provided variables.
  63341. return validateVariables(editor, variableToType, ast);
  63342. });
  63343. // Given a variableToType object, a source text, and a JSON AST, produces a
  63344. // list of CodeMirror annotations for any variable validation errors.
  63345. /* eslint-disable max-len */
  63346. /**
  63347. * Copyright (c) 2015, Facebook, Inc.
  63348. * All rights reserved.
  63349. *
  63350. * This source code is licensed under the BSD-style license found in the
  63351. * LICENSE file in the root directory of this source tree. An additional grant
  63352. * of patent rights can be found in the PATENTS file in the same directory.
  63353. */
  63354. function validateVariables(editor, variableToType, variablesAST) {
  63355. var errors = [];
  63356. variablesAST.members.forEach(function (member) {
  63357. var variableName = member.key.value;
  63358. var type = variableToType[variableName];
  63359. if (!type) {
  63360. errors.push(lintError(editor, member.key, 'Variable "$' + variableName + '" does not appear in any GraphQL query.'));
  63361. } else {
  63362. validateValue(type, member.value).forEach(function (_ref) {
  63363. var node = _ref[0],
  63364. message = _ref[1];
  63365. errors.push(lintError(editor, node, message));
  63366. });
  63367. }
  63368. });
  63369. return errors;
  63370. }
  63371. // Returns a list of validation errors in the form Array<[Node, String]>.
  63372. function validateValue(type, valueAST) {
  63373. // Validate non-nullable values.
  63374. if (type instanceof _graphql.GraphQLNonNull) {
  63375. if (valueAST.kind === 'Null') {
  63376. return [[valueAST, 'Type "' + type + '" is non-nullable and cannot be null.']];
  63377. }
  63378. return validateValue(type.ofType, valueAST);
  63379. }
  63380. if (valueAST.kind === 'Null') {
  63381. return [];
  63382. }
  63383. // Validate lists of values, accepting a non-list as a list of one.
  63384. if (type instanceof _graphql.GraphQLList) {
  63385. var itemType = type.ofType;
  63386. if (valueAST.kind === 'Array') {
  63387. return mapCat(valueAST.values, function (item) {
  63388. return validateValue(itemType, item);
  63389. });
  63390. }
  63391. return validateValue(itemType, valueAST);
  63392. }
  63393. // Validate input objects.
  63394. if (type instanceof _graphql.GraphQLInputObjectType) {
  63395. if (valueAST.kind !== 'Object') {
  63396. return [[valueAST, 'Type "' + type + '" must be an Object.']];
  63397. }
  63398. // Validate each field in the input object.
  63399. var providedFields = Object.create(null);
  63400. var fieldErrors = mapCat(valueAST.members, function (member) {
  63401. var fieldName = member.key.value;
  63402. providedFields[fieldName] = true;
  63403. var inputField = type.getFields()[fieldName];
  63404. if (!inputField) {
  63405. return [[member.key, 'Type "' + type + '" does not have a field "' + fieldName + '".']];
  63406. }
  63407. var fieldType = inputField ? inputField.type : undefined;
  63408. return validateValue(fieldType, member.value);
  63409. });
  63410. // Look for missing non-nullable fields.
  63411. Object.keys(type.getFields()).forEach(function (fieldName) {
  63412. if (!providedFields[fieldName]) {
  63413. var fieldType = type.getFields()[fieldName].type;
  63414. if (fieldType instanceof _graphql.GraphQLNonNull) {
  63415. fieldErrors.push([valueAST, 'Object of type "' + type + '" is missing required field "' + fieldName + '".']);
  63416. }
  63417. }
  63418. });
  63419. return fieldErrors;
  63420. }
  63421. // Validate common scalars.
  63422. if (type.name === 'Boolean' && valueAST.kind !== 'Boolean' || type.name === 'String' && valueAST.kind !== 'String' || type.name === 'ID' && valueAST.kind !== 'Number' && valueAST.kind !== 'String' || type.name === 'Float' && valueAST.kind !== 'Number' || type.name === 'Int' && (valueAST.kind !== 'Number' || (valueAST.value | 0) !== valueAST.value)) {
  63423. return [[valueAST, 'Expected value of type "' + type + '".']];
  63424. }
  63425. // Validate enums and custom scalars.
  63426. if (type instanceof _graphql.GraphQLEnumType || type instanceof _graphql.GraphQLScalarType) {
  63427. if (valueAST.kind !== 'String' && valueAST.kind !== 'Number' && valueAST.kind !== 'Boolean' && valueAST.kind !== 'Null' || isNullish(type.parseValue(valueAST.value))) {
  63428. return [[valueAST, 'Expected value of type "' + type + '".']];
  63429. }
  63430. }
  63431. return [];
  63432. }
  63433. // Give a parent text, an AST node with location, and a message, produces a
  63434. // CodeMirror annotation object.
  63435. function lintError(editor, node, message) {
  63436. return {
  63437. message: message,
  63438. severity: 'error',
  63439. type: 'validation',
  63440. from: editor.posFromIndex(node.start),
  63441. to: editor.posFromIndex(node.end)
  63442. };
  63443. }
  63444. function isNullish(value) {
  63445. return value === null || value === undefined || value !== value;
  63446. }
  63447. function mapCat(array, mapper) {
  63448. return Array.prototype.concat.apply([], array.map(mapper));
  63449. }
  63450. },{"../utils/jsonParse":397,"codemirror":16,"graphql":285}],401:[function(require,module,exports){
  63451. 'use strict';
  63452. var _codemirror = require('codemirror');
  63453. var _codemirror2 = _interopRequireDefault(_codemirror);
  63454. var _graphqlLanguageServiceParser = require('graphql-language-service-parser');
  63455. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  63456. /**
  63457. * This mode defines JSON, but provides a data-laden parser state to enable
  63458. * better code intelligence.
  63459. */
  63460. /**
  63461. * Copyright (c) 2015, Facebook, Inc.
  63462. * All rights reserved.
  63463. *
  63464. * This source code is licensed under the BSD-style license found in the
  63465. * LICENSE file in the root directory of this source tree. An additional grant
  63466. * of patent rights can be found in the PATENTS file in the same directory.
  63467. */
  63468. _codemirror2.default.defineMode('graphql-variables', function (config) {
  63469. var parser = (0, _graphqlLanguageServiceParser.onlineParser)({
  63470. eatWhitespace: function eatWhitespace(stream) {
  63471. return stream.eatSpace();
  63472. },
  63473. lexRules: LexRules,
  63474. parseRules: ParseRules,
  63475. editorConfig: { tabSize: config.tabSize }
  63476. });
  63477. return {
  63478. config: config,
  63479. startState: parser.startState,
  63480. token: parser.token,
  63481. indent: indent,
  63482. electricInput: /^\s*[}\]]/,
  63483. fold: 'brace',
  63484. closeBrackets: {
  63485. pairs: '[]{}""',
  63486. explode: '[]{}'
  63487. }
  63488. };
  63489. });
  63490. function indent(state, textAfter) {
  63491. var levels = state.levels;
  63492. // If there is no stack of levels, use the current level.
  63493. // Otherwise, use the top level, pre-emptively dedenting for close braces.
  63494. var level = !levels || levels.length === 0 ? state.indentLevel : levels[levels.length - 1] - (this.electricInput.test(textAfter) ? 1 : 0);
  63495. return level * this.config.indentUnit;
  63496. }
  63497. /**
  63498. * The lexer rules. These are exactly as described by the spec.
  63499. */
  63500. var LexRules = {
  63501. // All Punctuation used in JSON.
  63502. Punctuation: /^\[|]|\{|\}|:|,/,
  63503. // JSON Number.
  63504. Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,
  63505. // JSON String.
  63506. String: /^"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?/,
  63507. // JSON literal keywords.
  63508. Keyword: /^true|false|null/
  63509. };
  63510. /**
  63511. * The parser rules for JSON.
  63512. */
  63513. var ParseRules = {
  63514. Document: [(0, _graphqlLanguageServiceParser.p)('{'), (0, _graphqlLanguageServiceParser.list)('Variable', (0, _graphqlLanguageServiceParser.opt)((0, _graphqlLanguageServiceParser.p)(','))), (0, _graphqlLanguageServiceParser.p)('}')],
  63515. Variable: [namedKey('variable'), (0, _graphqlLanguageServiceParser.p)(':'), 'Value'],
  63516. Value: function Value(token) {
  63517. switch (token.kind) {
  63518. case 'Number':
  63519. return 'NumberValue';
  63520. case 'String':
  63521. return 'StringValue';
  63522. case 'Punctuation':
  63523. switch (token.value) {
  63524. case '[':
  63525. return 'ListValue';
  63526. case '{':
  63527. return 'ObjectValue';
  63528. }
  63529. return null;
  63530. case 'Keyword':
  63531. switch (token.value) {
  63532. case 'true':
  63533. case 'false':
  63534. return 'BooleanValue';
  63535. case 'null':
  63536. return 'NullValue';
  63537. }
  63538. return null;
  63539. }
  63540. },
  63541. NumberValue: [(0, _graphqlLanguageServiceParser.t)('Number', 'number')],
  63542. StringValue: [(0, _graphqlLanguageServiceParser.t)('String', 'string')],
  63543. BooleanValue: [(0, _graphqlLanguageServiceParser.t)('Keyword', 'builtin')],
  63544. NullValue: [(0, _graphqlLanguageServiceParser.t)('Keyword', 'keyword')],
  63545. ListValue: [(0, _graphqlLanguageServiceParser.p)('['), (0, _graphqlLanguageServiceParser.list)('Value', (0, _graphqlLanguageServiceParser.opt)((0, _graphqlLanguageServiceParser.p)(','))), (0, _graphqlLanguageServiceParser.p)(']')],
  63546. ObjectValue: [(0, _graphqlLanguageServiceParser.p)('{'), (0, _graphqlLanguageServiceParser.list)('ObjectField', (0, _graphqlLanguageServiceParser.opt)((0, _graphqlLanguageServiceParser.p)(','))), (0, _graphqlLanguageServiceParser.p)('}')],
  63547. ObjectField: [namedKey('attribute'), (0, _graphqlLanguageServiceParser.p)(':'), 'Value']
  63548. };
  63549. // A namedKey Token which will decorate the state with a `name`
  63550. function namedKey(style) {
  63551. return {
  63552. style: style,
  63553. match: function match(token) {
  63554. return token.kind === 'String';
  63555. },
  63556. update: function update(state, token) {
  63557. state.name = token.value.slice(1, -1); // Remove quotes.
  63558. }
  63559. };
  63560. }
  63561. },{"codemirror":16,"graphql-language-service-parser":269}]},{},[239])(239)
  63562. });