electron.d.ts 374 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261
  1. // Type definitions for Electron 3.0.0
  2. // Project: http://electronjs.org/
  3. // Definitions by: The Electron Team <https://github.com/electron/electron>
  4. // Definitions: https://github.com/electron/electron-typescript-definitions
  5. /// <reference types="node" />
  6. type GlobalEvent = Event;
  7. declare namespace Electron {
  8. class EventEmitter {
  9. addListener(event: string, listener: Function): this;
  10. on(event: string, listener: Function): this;
  11. once(event: string, listener: Function): this;
  12. removeListener(event: string, listener: Function): this;
  13. removeAllListeners(event?: string): this;
  14. setMaxListeners(n: number): this;
  15. getMaxListeners(): number;
  16. listeners(event: string): Function[];
  17. emit(event: string, ...args: any[]): boolean;
  18. listenerCount(type: string): number;
  19. prependListener(event: string, listener: Function): this;
  20. prependOnceListener(event: string, listener: Function): this;
  21. eventNames(): string[];
  22. }
  23. class Accelerator extends String {
  24. }
  25. interface Event extends GlobalEvent {
  26. preventDefault: () => void;
  27. sender: WebContents;
  28. returnValue: any;
  29. ctrlKey?: boolean;
  30. metaKey?: boolean;
  31. shiftKey?: boolean;
  32. altKey?: boolean;
  33. }
  34. interface CommonInterface {
  35. clipboard: Clipboard;
  36. crashReporter: CrashReporter;
  37. nativeImage: typeof NativeImage;
  38. screen: Screen;
  39. shell: Shell;
  40. }
  41. interface MainInterface extends CommonInterface {
  42. app: App;
  43. autoUpdater: AutoUpdater;
  44. BrowserView: typeof BrowserView;
  45. BrowserWindow: typeof BrowserWindow;
  46. ClientRequest: typeof ClientRequest;
  47. contentTracing: ContentTracing;
  48. Cookies: typeof Cookies;
  49. Debugger: typeof Debugger;
  50. dialog: Dialog;
  51. DownloadItem: typeof DownloadItem;
  52. globalShortcut: GlobalShortcut;
  53. inAppPurchase: InAppPurchase;
  54. IncomingMessage: typeof IncomingMessage;
  55. ipcMain: IpcMain;
  56. Menu: typeof Menu;
  57. MenuItem: typeof MenuItem;
  58. net: Net;
  59. netLog: NetLog;
  60. Notification: typeof Notification;
  61. powerMonitor: PowerMonitor;
  62. powerSaveBlocker: PowerSaveBlocker;
  63. protocol: Protocol;
  64. session: typeof Session;
  65. systemPreferences: SystemPreferences;
  66. TouchBar: typeof TouchBar;
  67. Tray: typeof Tray;
  68. webContents: typeof WebContents;
  69. WebRequest: typeof WebRequest;
  70. }
  71. interface RendererInterface extends CommonInterface {
  72. BrowserWindowProxy: typeof BrowserWindowProxy;
  73. desktopCapturer: DesktopCapturer;
  74. ipcRenderer: IpcRenderer;
  75. remote: Remote;
  76. webFrame: WebFrame;
  77. webviewTag: WebviewTag;
  78. }
  79. interface AllElectron extends MainInterface, RendererInterface {}
  80. const app: App;
  81. const autoUpdater: AutoUpdater;
  82. const clipboard: Clipboard;
  83. const contentTracing: ContentTracing;
  84. const crashReporter: CrashReporter;
  85. const desktopCapturer: DesktopCapturer;
  86. const dialog: Dialog;
  87. const globalShortcut: GlobalShortcut;
  88. const inAppPurchase: InAppPurchase;
  89. const ipcMain: IpcMain;
  90. const ipcRenderer: IpcRenderer;
  91. type nativeImage = NativeImage;
  92. const nativeImage: typeof NativeImage;
  93. const net: Net;
  94. const netLog: NetLog;
  95. const powerMonitor: PowerMonitor;
  96. const powerSaveBlocker: PowerSaveBlocker;
  97. const protocol: Protocol;
  98. const remote: Remote;
  99. const screen: Screen;
  100. type session = Session;
  101. const session: typeof Session;
  102. const shell: Shell;
  103. const systemPreferences: SystemPreferences;
  104. type webContents = WebContents;
  105. const webContents: typeof WebContents;
  106. const webFrame: WebFrame;
  107. const webviewTag: WebviewTag;
  108. interface App extends EventEmitter {
  109. // Docs: http://electron.atom.io/docs/api/app
  110. /**
  111. * Emitted when Chrome's accessibility support changes. This event fires when
  112. * assistive technologies, such as screen readers, are enabled or disabled. See
  113. * https://www.chromium.org/developers/design-documents/accessibility for more
  114. * details.
  115. */
  116. on(event: 'accessibility-support-changed', listener: (event: Event,
  117. /**
  118. * `true` when Chrome's accessibility support is enabled, `false` otherwise.
  119. */
  120. accessibilitySupportEnabled: boolean) => void): this;
  121. once(event: 'accessibility-support-changed', listener: (event: Event,
  122. /**
  123. * `true` when Chrome's accessibility support is enabled, `false` otherwise.
  124. */
  125. accessibilitySupportEnabled: boolean) => void): this;
  126. addListener(event: 'accessibility-support-changed', listener: (event: Event,
  127. /**
  128. * `true` when Chrome's accessibility support is enabled, `false` otherwise.
  129. */
  130. accessibilitySupportEnabled: boolean) => void): this;
  131. removeListener(event: 'accessibility-support-changed', listener: (event: Event,
  132. /**
  133. * `true` when Chrome's accessibility support is enabled, `false` otherwise.
  134. */
  135. accessibilitySupportEnabled: boolean) => void): this;
  136. /**
  137. * Emitted when the application is activated. Various actions can trigger this
  138. * event, such as launching the application for the first time, attempting to
  139. * re-launch the application when it's already running, or clicking on the
  140. * application's dock or taskbar icon.
  141. */
  142. on(event: 'activate', listener: (event: Event,
  143. hasVisibleWindows: boolean) => void): this;
  144. once(event: 'activate', listener: (event: Event,
  145. hasVisibleWindows: boolean) => void): this;
  146. addListener(event: 'activate', listener: (event: Event,
  147. hasVisibleWindows: boolean) => void): this;
  148. removeListener(event: 'activate', listener: (event: Event,
  149. hasVisibleWindows: boolean) => void): this;
  150. /**
  151. * Emitted during Handoff after an activity from this device was successfully
  152. * resumed on another one.
  153. */
  154. on(event: 'activity-was-continued', listener: (event: Event,
  155. /**
  156. * A string identifying the activity. Maps to .
  157. */
  158. type: string,
  159. /**
  160. * Contains app-specific state stored by the activity.
  161. */
  162. userInfo: any) => void): this;
  163. once(event: 'activity-was-continued', listener: (event: Event,
  164. /**
  165. * A string identifying the activity. Maps to .
  166. */
  167. type: string,
  168. /**
  169. * Contains app-specific state stored by the activity.
  170. */
  171. userInfo: any) => void): this;
  172. addListener(event: 'activity-was-continued', listener: (event: Event,
  173. /**
  174. * A string identifying the activity. Maps to .
  175. */
  176. type: string,
  177. /**
  178. * Contains app-specific state stored by the activity.
  179. */
  180. userInfo: any) => void): this;
  181. removeListener(event: 'activity-was-continued', listener: (event: Event,
  182. /**
  183. * A string identifying the activity. Maps to .
  184. */
  185. type: string,
  186. /**
  187. * Contains app-specific state stored by the activity.
  188. */
  189. userInfo: any) => void): this;
  190. /**
  191. * Emitted before the application starts closing its windows. Calling
  192. * event.preventDefault() will prevent the default behaviour, which is terminating
  193. * the application. Note: If application quit was initiated by
  194. * autoUpdater.quitAndInstall() then before-quit is emitted after emitting close
  195. * event on all windows and closing them. Note: On Windows, this event will not be
  196. * emitted if the app is closed due to a shutdown/restart of the system or a user
  197. * logout.
  198. */
  199. on(event: 'before-quit', listener: (event: Event) => void): this;
  200. once(event: 'before-quit', listener: (event: Event) => void): this;
  201. addListener(event: 'before-quit', listener: (event: Event) => void): this;
  202. removeListener(event: 'before-quit', listener: (event: Event) => void): this;
  203. /**
  204. * Emitted when a browserWindow gets blurred.
  205. */
  206. on(event: 'browser-window-blur', listener: (event: Event,
  207. window: BrowserWindow) => void): this;
  208. once(event: 'browser-window-blur', listener: (event: Event,
  209. window: BrowserWindow) => void): this;
  210. addListener(event: 'browser-window-blur', listener: (event: Event,
  211. window: BrowserWindow) => void): this;
  212. removeListener(event: 'browser-window-blur', listener: (event: Event,
  213. window: BrowserWindow) => void): this;
  214. /**
  215. * Emitted when a new browserWindow is created.
  216. */
  217. on(event: 'browser-window-created', listener: (event: Event,
  218. window: BrowserWindow) => void): this;
  219. once(event: 'browser-window-created', listener: (event: Event,
  220. window: BrowserWindow) => void): this;
  221. addListener(event: 'browser-window-created', listener: (event: Event,
  222. window: BrowserWindow) => void): this;
  223. removeListener(event: 'browser-window-created', listener: (event: Event,
  224. window: BrowserWindow) => void): this;
  225. /**
  226. * Emitted when a browserWindow gets focused.
  227. */
  228. on(event: 'browser-window-focus', listener: (event: Event,
  229. window: BrowserWindow) => void): this;
  230. once(event: 'browser-window-focus', listener: (event: Event,
  231. window: BrowserWindow) => void): this;
  232. addListener(event: 'browser-window-focus', listener: (event: Event,
  233. window: BrowserWindow) => void): this;
  234. removeListener(event: 'browser-window-focus', listener: (event: Event,
  235. window: BrowserWindow) => void): this;
  236. /**
  237. * Emitted when failed to verify the certificate for url, to trust the certificate
  238. * you should prevent the default behavior with event.preventDefault() and call
  239. * callback(true).
  240. */
  241. on(event: 'certificate-error', listener: (event: Event,
  242. webContents: WebContents,
  243. url: string,
  244. /**
  245. * The error code
  246. */
  247. error: string,
  248. certificate: Certificate,
  249. callback: (isTrusted: boolean) => void) => void): this;
  250. once(event: 'certificate-error', listener: (event: Event,
  251. webContents: WebContents,
  252. url: string,
  253. /**
  254. * The error code
  255. */
  256. error: string,
  257. certificate: Certificate,
  258. callback: (isTrusted: boolean) => void) => void): this;
  259. addListener(event: 'certificate-error', listener: (event: Event,
  260. webContents: WebContents,
  261. url: string,
  262. /**
  263. * The error code
  264. */
  265. error: string,
  266. certificate: Certificate,
  267. callback: (isTrusted: boolean) => void) => void): this;
  268. removeListener(event: 'certificate-error', listener: (event: Event,
  269. webContents: WebContents,
  270. url: string,
  271. /**
  272. * The error code
  273. */
  274. error: string,
  275. certificate: Certificate,
  276. callback: (isTrusted: boolean) => void) => void): this;
  277. /**
  278. * Emitted during Handoff when an activity from a different device wants to be
  279. * resumed. You should call event.preventDefault() if you want to handle this
  280. * event. A user activity can be continued only in an app that has the same
  281. * developer Team ID as the activity's source app and that supports the activity's
  282. * type. Supported activity types are specified in the app's Info.plist under the
  283. * NSUserActivityTypes key.
  284. */
  285. on(event: 'continue-activity', listener: (event: Event,
  286. /**
  287. * A string identifying the activity. Maps to .
  288. */
  289. type: string,
  290. /**
  291. * Contains app-specific state stored by the activity on another device.
  292. */
  293. userInfo: any) => void): this;
  294. once(event: 'continue-activity', listener: (event: Event,
  295. /**
  296. * A string identifying the activity. Maps to .
  297. */
  298. type: string,
  299. /**
  300. * Contains app-specific state stored by the activity on another device.
  301. */
  302. userInfo: any) => void): this;
  303. addListener(event: 'continue-activity', listener: (event: Event,
  304. /**
  305. * A string identifying the activity. Maps to .
  306. */
  307. type: string,
  308. /**
  309. * Contains app-specific state stored by the activity on another device.
  310. */
  311. userInfo: any) => void): this;
  312. removeListener(event: 'continue-activity', listener: (event: Event,
  313. /**
  314. * A string identifying the activity. Maps to .
  315. */
  316. type: string,
  317. /**
  318. * Contains app-specific state stored by the activity on another device.
  319. */
  320. userInfo: any) => void): this;
  321. /**
  322. * Emitted during Handoff when an activity from a different device fails to be
  323. * resumed.
  324. */
  325. on(event: 'continue-activity-error', listener: (event: Event,
  326. /**
  327. * A string identifying the activity. Maps to .
  328. */
  329. type: string,
  330. /**
  331. * A string with the error's localized description.
  332. */
  333. error: string) => void): this;
  334. once(event: 'continue-activity-error', listener: (event: Event,
  335. /**
  336. * A string identifying the activity. Maps to .
  337. */
  338. type: string,
  339. /**
  340. * A string with the error's localized description.
  341. */
  342. error: string) => void): this;
  343. addListener(event: 'continue-activity-error', listener: (event: Event,
  344. /**
  345. * A string identifying the activity. Maps to .
  346. */
  347. type: string,
  348. /**
  349. * A string with the error's localized description.
  350. */
  351. error: string) => void): this;
  352. removeListener(event: 'continue-activity-error', listener: (event: Event,
  353. /**
  354. * A string identifying the activity. Maps to .
  355. */
  356. type: string,
  357. /**
  358. * A string with the error's localized description.
  359. */
  360. error: string) => void): this;
  361. /**
  362. * Emitted when the gpu process crashes or is killed.
  363. */
  364. on(event: 'gpu-process-crashed', listener: (event: Event,
  365. killed: boolean) => void): this;
  366. once(event: 'gpu-process-crashed', listener: (event: Event,
  367. killed: boolean) => void): this;
  368. addListener(event: 'gpu-process-crashed', listener: (event: Event,
  369. killed: boolean) => void): this;
  370. removeListener(event: 'gpu-process-crashed', listener: (event: Event,
  371. killed: boolean) => void): this;
  372. /**
  373. * Emitted when webContents wants to do basic auth. The default behavior is to
  374. * cancel all authentications, to override this you should prevent the default
  375. * behavior with event.preventDefault() and call callback(username, password) with
  376. * the credentials.
  377. */
  378. on(event: 'login', listener: (event: Event,
  379. webContents: WebContents,
  380. request: Request,
  381. authInfo: AuthInfo,
  382. callback: (username: string, password: string) => void) => void): this;
  383. once(event: 'login', listener: (event: Event,
  384. webContents: WebContents,
  385. request: Request,
  386. authInfo: AuthInfo,
  387. callback: (username: string, password: string) => void) => void): this;
  388. addListener(event: 'login', listener: (event: Event,
  389. webContents: WebContents,
  390. request: Request,
  391. authInfo: AuthInfo,
  392. callback: (username: string, password: string) => void) => void): this;
  393. removeListener(event: 'login', listener: (event: Event,
  394. webContents: WebContents,
  395. request: Request,
  396. authInfo: AuthInfo,
  397. callback: (username: string, password: string) => void) => void): this;
  398. /**
  399. * Emitted when the user clicks the native macOS new tab button. The new tab button
  400. * is only visible if the current BrowserWindow has a tabbingIdentifier
  401. */
  402. on(event: 'new-window-for-tab', listener: (event: Event) => void): this;
  403. once(event: 'new-window-for-tab', listener: (event: Event) => void): this;
  404. addListener(event: 'new-window-for-tab', listener: (event: Event) => void): this;
  405. removeListener(event: 'new-window-for-tab', listener: (event: Event) => void): this;
  406. /**
  407. * Emitted when the user wants to open a file with the application. The open-file
  408. * event is usually emitted when the application is already open and the OS wants
  409. * to reuse the application to open the file. open-file is also emitted when a file
  410. * is dropped onto the dock and the application is not yet running. Make sure to
  411. * listen for the open-file event very early in your application startup to handle
  412. * this case (even before the ready event is emitted). You should call
  413. * event.preventDefault() if you want to handle this event. On Windows, you have to
  414. * parse process.argv (in the main process) to get the filepath.
  415. */
  416. on(event: 'open-file', listener: (event: Event,
  417. path: string) => void): this;
  418. once(event: 'open-file', listener: (event: Event,
  419. path: string) => void): this;
  420. addListener(event: 'open-file', listener: (event: Event,
  421. path: string) => void): this;
  422. removeListener(event: 'open-file', listener: (event: Event,
  423. path: string) => void): this;
  424. /**
  425. * Emitted when the user wants to open a URL with the application. Your
  426. * application's Info.plist file must define the url scheme within the
  427. * CFBundleURLTypes key, and set NSPrincipalClass to AtomApplication. You should
  428. * call event.preventDefault() if you want to handle this event.
  429. */
  430. on(event: 'open-url', listener: (event: Event,
  431. url: string) => void): this;
  432. once(event: 'open-url', listener: (event: Event,
  433. url: string) => void): this;
  434. addListener(event: 'open-url', listener: (event: Event,
  435. url: string) => void): this;
  436. removeListener(event: 'open-url', listener: (event: Event,
  437. url: string) => void): this;
  438. /**
  439. * Emitted when the application is quitting. Note: On Windows, this event will not
  440. * be emitted if the app is closed due to a shutdown/restart of the system or a
  441. * user logout.
  442. */
  443. on(event: 'quit', listener: (event: Event,
  444. exitCode: number) => void): this;
  445. once(event: 'quit', listener: (event: Event,
  446. exitCode: number) => void): this;
  447. addListener(event: 'quit', listener: (event: Event,
  448. exitCode: number) => void): this;
  449. removeListener(event: 'quit', listener: (event: Event,
  450. exitCode: number) => void): this;
  451. /**
  452. * Emitted when Electron has finished initializing. On macOS, launchInfo holds the
  453. * userInfo of the NSUserNotification that was used to open the application, if it
  454. * was launched from Notification Center. You can call app.isReady() to check if
  455. * this event has already fired.
  456. */
  457. on(event: 'ready', listener: (launchInfo: any) => void): this;
  458. once(event: 'ready', listener: (launchInfo: any) => void): this;
  459. addListener(event: 'ready', listener: (launchInfo: any) => void): this;
  460. removeListener(event: 'ready', listener: (launchInfo: any) => void): this;
  461. /**
  462. * This event will be emitted inside the primary instance of your application when
  463. * a second instance has been executed. argv is an Array of the second instance's
  464. * command line arguments, and workingDirectory is its current working directory.
  465. * Usually applications respond to this by making their primary window focused and
  466. * non-minimized. This event is guaranteed to be emitted after the ready event of
  467. * app gets emitted.
  468. */
  469. on(event: 'second-instance', listener: (event: Event,
  470. /**
  471. * An array of the second instance's command line arguments
  472. */
  473. argv: string[],
  474. /**
  475. * The second instance's working directory
  476. */
  477. workingDirectory: string) => void): this;
  478. once(event: 'second-instance', listener: (event: Event,
  479. /**
  480. * An array of the second instance's command line arguments
  481. */
  482. argv: string[],
  483. /**
  484. * The second instance's working directory
  485. */
  486. workingDirectory: string) => void): this;
  487. addListener(event: 'second-instance', listener: (event: Event,
  488. /**
  489. * An array of the second instance's command line arguments
  490. */
  491. argv: string[],
  492. /**
  493. * The second instance's working directory
  494. */
  495. workingDirectory: string) => void): this;
  496. removeListener(event: 'second-instance', listener: (event: Event,
  497. /**
  498. * An array of the second instance's command line arguments
  499. */
  500. argv: string[],
  501. /**
  502. * The second instance's working directory
  503. */
  504. workingDirectory: string) => void): this;
  505. /**
  506. * Emitted when a client certificate is requested. The url corresponds to the
  507. * navigation entry requesting the client certificate and callback can be called
  508. * with an entry filtered from the list. Using event.preventDefault() prevents the
  509. * application from using the first certificate from the store.
  510. */
  511. on(event: 'select-client-certificate', listener: (event: Event,
  512. webContents: WebContents,
  513. url: string,
  514. certificateList: Certificate[],
  515. callback: (certificate?: Certificate) => void) => void): this;
  516. once(event: 'select-client-certificate', listener: (event: Event,
  517. webContents: WebContents,
  518. url: string,
  519. certificateList: Certificate[],
  520. callback: (certificate?: Certificate) => void) => void): this;
  521. addListener(event: 'select-client-certificate', listener: (event: Event,
  522. webContents: WebContents,
  523. url: string,
  524. certificateList: Certificate[],
  525. callback: (certificate?: Certificate) => void) => void): this;
  526. removeListener(event: 'select-client-certificate', listener: (event: Event,
  527. webContents: WebContents,
  528. url: string,
  529. certificateList: Certificate[],
  530. callback: (certificate?: Certificate) => void) => void): this;
  531. /**
  532. * Emitted when Electron has created a new session.
  533. */
  534. on(event: 'session-created', listener: (event: Event,
  535. session: Session) => void): this;
  536. once(event: 'session-created', listener: (event: Event,
  537. session: Session) => void): this;
  538. addListener(event: 'session-created', listener: (event: Event,
  539. session: Session) => void): this;
  540. removeListener(event: 'session-created', listener: (event: Event,
  541. session: Session) => void): this;
  542. /**
  543. * Emitted when Handoff is about to be resumed on another device. If you need to
  544. * update the state to be transferred, you should call event.preventDefault()
  545. * immediately, construct a new userInfo dictionary and call
  546. * app.updateCurrentActiviy() in a timely manner. Otherwise the operation will fail
  547. * and continue-activity-error will be called.
  548. */
  549. on(event: 'update-activity-state', listener: (event: Event,
  550. /**
  551. * A string identifying the activity. Maps to .
  552. */
  553. type: string,
  554. /**
  555. * Contains app-specific state stored by the activity.
  556. */
  557. userInfo: any) => void): this;
  558. once(event: 'update-activity-state', listener: (event: Event,
  559. /**
  560. * A string identifying the activity. Maps to .
  561. */
  562. type: string,
  563. /**
  564. * Contains app-specific state stored by the activity.
  565. */
  566. userInfo: any) => void): this;
  567. addListener(event: 'update-activity-state', listener: (event: Event,
  568. /**
  569. * A string identifying the activity. Maps to .
  570. */
  571. type: string,
  572. /**
  573. * Contains app-specific state stored by the activity.
  574. */
  575. userInfo: any) => void): this;
  576. removeListener(event: 'update-activity-state', listener: (event: Event,
  577. /**
  578. * A string identifying the activity. Maps to .
  579. */
  580. type: string,
  581. /**
  582. * Contains app-specific state stored by the activity.
  583. */
  584. userInfo: any) => void): this;
  585. /**
  586. * Emitted when a new webContents is created.
  587. */
  588. on(event: 'web-contents-created', listener: (event: Event,
  589. webContents: WebContents) => void): this;
  590. once(event: 'web-contents-created', listener: (event: Event,
  591. webContents: WebContents) => void): this;
  592. addListener(event: 'web-contents-created', listener: (event: Event,
  593. webContents: WebContents) => void): this;
  594. removeListener(event: 'web-contents-created', listener: (event: Event,
  595. webContents: WebContents) => void): this;
  596. /**
  597. * Emitted during Handoff before an activity from a different device wants to be
  598. * resumed. You should call event.preventDefault() if you want to handle this
  599. * event.
  600. */
  601. on(event: 'will-continue-activity', listener: (event: Event,
  602. /**
  603. * A string identifying the activity. Maps to .
  604. */
  605. type: string) => void): this;
  606. once(event: 'will-continue-activity', listener: (event: Event,
  607. /**
  608. * A string identifying the activity. Maps to .
  609. */
  610. type: string) => void): this;
  611. addListener(event: 'will-continue-activity', listener: (event: Event,
  612. /**
  613. * A string identifying the activity. Maps to .
  614. */
  615. type: string) => void): this;
  616. removeListener(event: 'will-continue-activity', listener: (event: Event,
  617. /**
  618. * A string identifying the activity. Maps to .
  619. */
  620. type: string) => void): this;
  621. /**
  622. * Emitted when the application has finished basic startup. On Windows and Linux,
  623. * the will-finish-launching event is the same as the ready event; on macOS, this
  624. * event represents the applicationWillFinishLaunching notification of
  625. * NSApplication. You would usually set up listeners for the open-file and open-url
  626. * events here, and start the crash reporter and auto updater. In most cases, you
  627. * should do everything in the ready event handler.
  628. */
  629. on(event: 'will-finish-launching', listener: Function): this;
  630. once(event: 'will-finish-launching', listener: Function): this;
  631. addListener(event: 'will-finish-launching', listener: Function): this;
  632. removeListener(event: 'will-finish-launching', listener: Function): this;
  633. /**
  634. * Emitted when all windows have been closed and the application will quit. Calling
  635. * event.preventDefault() will prevent the default behaviour, which is terminating
  636. * the application. See the description of the window-all-closed event for the
  637. * differences between the will-quit and window-all-closed events. Note: On
  638. * Windows, this event will not be emitted if the app is closed due to a
  639. * shutdown/restart of the system or a user logout.
  640. */
  641. on(event: 'will-quit', listener: (event: Event) => void): this;
  642. once(event: 'will-quit', listener: (event: Event) => void): this;
  643. addListener(event: 'will-quit', listener: (event: Event) => void): this;
  644. removeListener(event: 'will-quit', listener: (event: Event) => void): this;
  645. /**
  646. * Emitted when all windows have been closed. If you do not subscribe to this event
  647. * and all windows are closed, the default behavior is to quit the app; however, if
  648. * you subscribe, you control whether the app quits or not. If the user pressed Cmd
  649. * + Q, or the developer called app.quit(), Electron will first try to close all
  650. * the windows and then emit the will-quit event, and in this case the
  651. * window-all-closed event would not be emitted.
  652. */
  653. on(event: 'window-all-closed', listener: Function): this;
  654. once(event: 'window-all-closed', listener: Function): this;
  655. addListener(event: 'window-all-closed', listener: Function): this;
  656. removeListener(event: 'window-all-closed', listener: Function): this;
  657. /**
  658. * Adds path to the recent documents list. This list is managed by the OS. On
  659. * Windows you can visit the list from the task bar, and on macOS you can visit it
  660. * from dock menu.
  661. */
  662. addRecentDocument(path: string): void;
  663. /**
  664. * Clears the recent documents list.
  665. */
  666. clearRecentDocuments(): void;
  667. /**
  668. * By default, Chromium disables 3D APIs (e.g. WebGL) until restart on a per domain
  669. * basis if the GPU processes crashes too frequently. This function disables that
  670. * behaviour. This method can only be called before app is ready.
  671. */
  672. disableDomainBlockingFor3DAPIs(): void;
  673. /**
  674. * Disables hardware acceleration for current app. This method can only be called
  675. * before app is ready.
  676. */
  677. disableHardwareAcceleration(): void;
  678. /**
  679. * Enables mixed sandbox mode on the app. This method can only be called before app
  680. * is ready.
  681. */
  682. enableMixedSandbox(): void;
  683. /**
  684. * Exits immediately with exitCode. exitCode defaults to 0. All windows will be
  685. * closed immediately without asking user and the before-quit and will-quit events
  686. * will not be emitted.
  687. */
  688. exit(exitCode?: number): void;
  689. /**
  690. * On Linux, focuses on the first visible window. On macOS, makes the application
  691. * the active app. On Windows, focuses on the application's first window.
  692. */
  693. focus(): void;
  694. getAppMetrics(): ProcessMetric[];
  695. getAppPath(): string;
  696. getBadgeCount(): number;
  697. getCurrentActivityType(): string;
  698. /**
  699. * Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
  700. * and macOS, icons depend on the application associated with file mime type.
  701. */
  702. getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void;
  703. /**
  704. * Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux
  705. * and macOS, icons depend on the application associated with file mime type.
  706. */
  707. getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void;
  708. getGPUFeatureStatus(): GPUFeatureStatus;
  709. getJumpListSettings(): JumpListSettings;
  710. /**
  711. * To set the locale, you'll want to use a command line switch at app startup,
  712. * which may be found here. Note: When distributing your packaged app, you have to
  713. * also ship the locales folder. Note: On Windows you have to call it after the
  714. * ready events gets emitted.
  715. */
  716. getLocale(): string;
  717. /**
  718. * If you provided path and args options to app.setLoginItemSettings then you need
  719. * to pass the same arguments here for openAtLogin to be set correctly.
  720. */
  721. getLoginItemSettings(options?: LoginItemSettingsOptions): LoginItemSettings;
  722. /**
  723. * Usually the name field of package.json is a short lowercased name, according to
  724. * the npm modules spec. You should usually also specify a productName field, which
  725. * is your application's full capitalized name, and which will be preferred over
  726. * name by Electron.
  727. */
  728. getName(): string;
  729. /**
  730. * You can request the following paths by the name:
  731. */
  732. getPath(name: string): string;
  733. getVersion(): string;
  734. /**
  735. * This method returns whether or not this instance of your app is currently
  736. * holding the single instance lock. You can request the lock with
  737. * app.requestSingleInstanceLock() and release with app.releaseSingleInstanceLock()
  738. */
  739. hasSingleInstanceLock(): boolean;
  740. /**
  741. * Hides all application windows without minimizing them.
  742. */
  743. hide(): void;
  744. /**
  745. * Imports the certificate in pkcs12 format into the platform certificate store.
  746. * callback is called with the result of import operation, a value of 0 indicates
  747. * success while any other value indicates failure according to chromium
  748. * net_error_list.
  749. */
  750. importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void;
  751. /**
  752. * Invalidates the current Handoff user activity.
  753. */
  754. invalidateCurrentActivity(type: string): void;
  755. isAccessibilitySupportEnabled(): boolean;
  756. /**
  757. * This method checks if the current executable is the default handler for a
  758. * protocol (aka URI scheme). If so, it will return true. Otherwise, it will return
  759. * false. Note: On macOS, you can use this method to check if the app has been
  760. * registered as the default protocol handler for a protocol. You can also verify
  761. * this by checking ~/Library/Preferences/com.apple.LaunchServices.plist on the
  762. * macOS machine. Please refer to Apple's documentation for details. The API uses
  763. * the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
  764. */
  765. isDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
  766. isInApplicationsFolder(): boolean;
  767. isReady(): boolean;
  768. isUnityRunning(): boolean;
  769. /**
  770. * No confirmation dialog will be presented by default, if you wish to allow the
  771. * user to confirm the operation you may do so using the dialog API. NOTE: This
  772. * method throws errors if anything other than the user causes the move to fail.
  773. * For instance if the user cancels the authorization dialog this method returns
  774. * false. If we fail to perform the copy then this method will throw an error. The
  775. * message in the error should be informative and tell you exactly what went wrong
  776. */
  777. moveToApplicationsFolder(): boolean;
  778. /**
  779. * Try to close all windows. The before-quit event will be emitted first. If all
  780. * windows are successfully closed, the will-quit event will be emitted and by
  781. * default the application will terminate. This method guarantees that all
  782. * beforeunload and unload event handlers are correctly executed. It is possible
  783. * that a window cancels the quitting by returning false in the beforeunload event
  784. * handler.
  785. */
  786. quit(): void;
  787. /**
  788. * Relaunches the app when current instance exits. By default the new instance will
  789. * use the same working directory and command line arguments with current instance.
  790. * When args is specified, the args will be passed as command line arguments
  791. * instead. When execPath is specified, the execPath will be executed for relaunch
  792. * instead of current app. Note that this method does not quit the app when
  793. * executed, you have to call app.quit or app.exit after calling app.relaunch to
  794. * make the app restart. When app.relaunch is called for multiple times, multiple
  795. * instances will be started after current instance exited. An example of
  796. * restarting current instance immediately and adding a new command line argument
  797. * to the new instance:
  798. */
  799. relaunch(options?: RelaunchOptions): void;
  800. /**
  801. * Releases all locks that were created by requestSingleInstanceLock. This will
  802. * allow multiple instances of the application to once again run side by side.
  803. */
  804. releaseSingleInstanceLock(): void;
  805. /**
  806. * This method checks if the current executable as the default handler for a
  807. * protocol (aka URI scheme). If so, it will remove the app as the default handler.
  808. */
  809. removeAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
  810. /**
  811. * This method makes your application a Single Instance Application - instead of
  812. * allowing multiple instances of your app to run, this will ensure that only a
  813. * single instance of your app is running, and other instances signal this instance
  814. * and exit. The return value of this method indicates whether or not this instance
  815. * of your application successfully obtained the lock. If it failed to obtain the
  816. * lock you can assume that another instance of your application is already running
  817. * with the lock and exit immediately. I.e. This method returns true if your
  818. * process is the primary instance of your application and your app should continue
  819. * loading. It returns false if your process should immediately quit as it has
  820. * sent its parameters to another instance that has already acquired the lock. On
  821. * macOS the system enforces single instance automatically when users try to open a
  822. * second instance of your app in Finder, and the open-file and open-url events
  823. * will be emitted for that. However when users start your app in command line the
  824. * system's single instance mechanism will be bypassed and you have to use this
  825. * method to ensure single instance. An example of activating the window of primary
  826. * instance when a second instance starts:
  827. */
  828. requestSingleInstanceLock(): boolean;
  829. /**
  830. * Set the about panel options. This will override the values defined in the app's
  831. * .plist file. See the Apple docs for more details.
  832. */
  833. setAboutPanelOptions(options: AboutPanelOptionsOptions): void;
  834. /**
  835. * Manually enables Chrome's accessibility support, allowing to expose
  836. * accessibility switch to users in application settings.
  837. * https://www.chromium.org/developers/design-documents/accessibility for more
  838. * details. Disabled by default. Note: Rendering accessibility tree can
  839. * significantly affect the performance of your app. It should not be enabled by
  840. * default.
  841. */
  842. setAccessibilitySupportEnabled(enabled: boolean): void;
  843. /**
  844. * Changes the Application User Model ID to id.
  845. */
  846. setAppUserModelId(id: string): void;
  847. /**
  848. * This method sets the current executable as the default handler for a protocol
  849. * (aka URI scheme). It allows you to integrate your app deeper into the operating
  850. * system. Once registered, all links with your-protocol:// will be opened with the
  851. * current executable. The whole link, including protocol, will be passed to your
  852. * application as a parameter. On Windows you can provide optional parameters path,
  853. * the path to your executable, and args, an array of arguments to be passed to
  854. * your executable when it launches. Note: On macOS, you can only register
  855. * protocols that have been added to your app's info.plist, which can not be
  856. * modified at runtime. You can however change the file with a simple text editor
  857. * or script during build time. Please refer to Apple's documentation for details.
  858. * The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme
  859. * internally.
  860. */
  861. setAsDefaultProtocolClient(protocol: string, path?: string, args?: string[]): boolean;
  862. /**
  863. * Sets the counter badge for current app. Setting the count to 0 will hide the
  864. * badge. On macOS it shows on the dock icon. On Linux it only works for Unity
  865. * launcher, Note: Unity launcher requires the existence of a .desktop file to
  866. * work, for more information please read Desktop Environment Integration.
  867. */
  868. setBadgeCount(count: number): boolean;
  869. /**
  870. * Sets or removes a custom Jump List for the application, and returns one of the
  871. * following strings: If categories is null the previously set custom Jump List (if
  872. * any) will be replaced by the standard Jump List for the app (managed by
  873. * Windows). Note: If a JumpListCategory object has neither the type nor the name
  874. * property set then its type is assumed to be tasks. If the name property is set
  875. * but the type property is omitted then the type is assumed to be custom. Note:
  876. * Users can remove items from custom categories, and Windows will not allow a
  877. * removed item to be added back into a custom category until after the next
  878. * successful call to app.setJumpList(categories). Any attempt to re-add a removed
  879. * item to a custom category earlier than that will result in the entire custom
  880. * category being omitted from the Jump List. The list of removed items can be
  881. * obtained using app.getJumpListSettings(). Here's a very simple example of
  882. * creating a custom Jump List:
  883. */
  884. setJumpList(categories: JumpListCategory[]): void;
  885. /**
  886. * Set the app's login item settings. To work with Electron's autoUpdater on
  887. * Windows, which uses Squirrel, you'll want to set the launch path to Update.exe,
  888. * and pass arguments that specify your application name. For example:
  889. */
  890. setLoginItemSettings(settings: Settings): void;
  891. /**
  892. * Overrides the current application's name.
  893. */
  894. setName(name: string): void;
  895. /**
  896. * Overrides the path to a special directory or file associated with name. If the
  897. * path specifies a directory that does not exist, the directory will be created by
  898. * this method. On failure an Error is thrown. You can only override paths of a
  899. * name defined in app.getPath. By default, web pages' cookies and caches will be
  900. * stored under the userData directory. If you want to change this location, you
  901. * have to override the userData path before the ready event of the app module is
  902. * emitted.
  903. */
  904. setPath(name: string, path: string): void;
  905. /**
  906. * Creates an NSUserActivity and sets it as the current activity. The activity is
  907. * eligible for Handoff to another device afterward.
  908. */
  909. setUserActivity(type: string, userInfo: any, webpageURL?: string): void;
  910. /**
  911. * Adds tasks to the Tasks category of the JumpList on Windows. tasks is an array
  912. * of Task objects. Note: If you'd like to customize the Jump List even more use
  913. * app.setJumpList(categories) instead.
  914. */
  915. setUserTasks(tasks: Task[]): boolean;
  916. /**
  917. * Shows application windows after they were hidden. Does not automatically focus
  918. * them.
  919. */
  920. show(): void;
  921. /**
  922. * Start accessing a security scoped resource. With this method electron
  923. * applications that are packaged for the Mac App Store may reach outside their
  924. * sandbox to access files chosen by the user. See Apple's documentation for a
  925. * description of how this system works.
  926. */
  927. startAccessingSecurityScopedResource(bookmarkData: string): Function;
  928. /**
  929. * Updates the current activity if its type matches type, merging the entries from
  930. * userInfo into its current userInfo dictionary.
  931. */
  932. updateCurrentActivity(type: string, userInfo: any): void;
  933. whenReady(): Promise<any>;
  934. commandLine: CommandLine;
  935. dock: Dock;
  936. /**
  937. * A Boolean property that returns true if the app is packaged, false otherwise.
  938. * For many apps, this property can be used to distinguish development and
  939. * production environments.
  940. */
  941. isPackaged?: boolean;
  942. }
  943. interface AutoUpdater extends EventEmitter {
  944. // Docs: http://electron.atom.io/docs/api/auto-updater
  945. /**
  946. * This event is emitted after a user calls quitAndInstall(). When this API is
  947. * called, the before-quit event is not emitted before all windows are closed. As a
  948. * result you should listen to this event if you wish to perform actions before the
  949. * windows are closed while a process is quitting, as well as listening to
  950. * before-quit.
  951. */
  952. on(event: 'before-quit-for-update', listener: Function): this;
  953. once(event: 'before-quit-for-update', listener: Function): this;
  954. addListener(event: 'before-quit-for-update', listener: Function): this;
  955. removeListener(event: 'before-quit-for-update', listener: Function): this;
  956. /**
  957. * Emitted when checking if an update has started.
  958. */
  959. on(event: 'checking-for-update', listener: Function): this;
  960. once(event: 'checking-for-update', listener: Function): this;
  961. addListener(event: 'checking-for-update', listener: Function): this;
  962. removeListener(event: 'checking-for-update', listener: Function): this;
  963. /**
  964. * Emitted when there is an error while updating.
  965. */
  966. on(event: 'error', listener: (error: Error) => void): this;
  967. once(event: 'error', listener: (error: Error) => void): this;
  968. addListener(event: 'error', listener: (error: Error) => void): this;
  969. removeListener(event: 'error', listener: (error: Error) => void): this;
  970. /**
  971. * Emitted when there is an available update. The update is downloaded
  972. * automatically.
  973. */
  974. on(event: 'update-available', listener: Function): this;
  975. once(event: 'update-available', listener: Function): this;
  976. addListener(event: 'update-available', listener: Function): this;
  977. removeListener(event: 'update-available', listener: Function): this;
  978. /**
  979. * Emitted when an update has been downloaded. On Windows only releaseName is
  980. * available.
  981. */
  982. on(event: 'update-downloaded', listener: (event: Event,
  983. releaseNotes: string,
  984. releaseName: string,
  985. releaseDate: Date,
  986. updateURL: string) => void): this;
  987. once(event: 'update-downloaded', listener: (event: Event,
  988. releaseNotes: string,
  989. releaseName: string,
  990. releaseDate: Date,
  991. updateURL: string) => void): this;
  992. addListener(event: 'update-downloaded', listener: (event: Event,
  993. releaseNotes: string,
  994. releaseName: string,
  995. releaseDate: Date,
  996. updateURL: string) => void): this;
  997. removeListener(event: 'update-downloaded', listener: (event: Event,
  998. releaseNotes: string,
  999. releaseName: string,
  1000. releaseDate: Date,
  1001. updateURL: string) => void): this;
  1002. /**
  1003. * Emitted when there is no available update.
  1004. */
  1005. on(event: 'update-not-available', listener: Function): this;
  1006. once(event: 'update-not-available', listener: Function): this;
  1007. addListener(event: 'update-not-available', listener: Function): this;
  1008. removeListener(event: 'update-not-available', listener: Function): this;
  1009. /**
  1010. * Asks the server whether there is an update. You must call setFeedURL before
  1011. * using this API.
  1012. */
  1013. checkForUpdates(): void;
  1014. getFeedURL(): string;
  1015. /**
  1016. * Restarts the app and installs the update after it has been downloaded. It should
  1017. * only be called after update-downloaded has been emitted. Under the hood calling
  1018. * autoUpdater.quitAndInstall() will close all application windows first, and
  1019. * automatically call app.quit() after all windows have been closed. Note: If the
  1020. * application is quit without calling this API after the update-downloaded event
  1021. * has been emitted, the application will still be replaced by the updated one on
  1022. * the next run.
  1023. */
  1024. quitAndInstall(): void;
  1025. /**
  1026. * Sets the url and initialize the auto updater.
  1027. */
  1028. setFeedURL(options: FeedURLOptions): void;
  1029. }
  1030. interface BluetoothDevice {
  1031. // Docs: http://electron.atom.io/docs/api/structures/bluetooth-device
  1032. deviceId: string;
  1033. deviceName: string;
  1034. }
  1035. class BrowserView extends EventEmitter {
  1036. // Docs: http://electron.atom.io/docs/api/browser-view
  1037. constructor(options?: BrowserViewConstructorOptions);
  1038. static fromId(id: number): BrowserView;
  1039. static fromWebContents(webContents: WebContents): BrowserView | null;
  1040. static getAllViews(): BrowserView[];
  1041. /**
  1042. * Force closing the view, the unload and beforeunload events won't be emitted for
  1043. * the web page. After you're done with a view, call this function in order to free
  1044. * memory and other resources as soon as possible.
  1045. */
  1046. destroy(): void;
  1047. isDestroyed(): boolean;
  1048. setAutoResize(options: AutoResizeOptions): void;
  1049. setBackgroundColor(color: string): void;
  1050. /**
  1051. * Resizes and moves the view to the supplied bounds relative to the window.
  1052. */
  1053. setBounds(bounds: Rectangle): void;
  1054. id: number;
  1055. webContents: WebContents;
  1056. }
  1057. class BrowserWindow extends EventEmitter {
  1058. // Docs: http://electron.atom.io/docs/api/browser-window
  1059. /**
  1060. * Emitted when an App Command is invoked. These are typically related to keyboard
  1061. * media keys or browser commands, as well as the "Back" button built into some
  1062. * mice on Windows. Commands are lowercased, underscores are replaced with hyphens,
  1063. * and the APPCOMMAND_ prefix is stripped off. e.g. APPCOMMAND_BROWSER_BACKWARD is
  1064. * emitted as browser-backward.
  1065. */
  1066. on(event: 'app-command', listener: (event: Event,
  1067. command: string) => void): this;
  1068. once(event: 'app-command', listener: (event: Event,
  1069. command: string) => void): this;
  1070. addListener(event: 'app-command', listener: (event: Event,
  1071. command: string) => void): this;
  1072. removeListener(event: 'app-command', listener: (event: Event,
  1073. command: string) => void): this;
  1074. /**
  1075. * Emitted when the window loses focus.
  1076. */
  1077. on(event: 'blur', listener: Function): this;
  1078. once(event: 'blur', listener: Function): this;
  1079. addListener(event: 'blur', listener: Function): this;
  1080. removeListener(event: 'blur', listener: Function): this;
  1081. /**
  1082. * Emitted when the window is going to be closed. It's emitted before the
  1083. * beforeunload and unload event of the DOM. Calling event.preventDefault() will
  1084. * cancel the close. Usually you would want to use the beforeunload handler to
  1085. * decide whether the window should be closed, which will also be called when the
  1086. * window is reloaded. In Electron, returning any value other than undefined would
  1087. * cancel the close. For example: Note: There is a subtle difference between the
  1088. * behaviors of window.onbeforeunload = handler and
  1089. * window.addEventListener('beforeunload', handler). It is recommended to always
  1090. * set the event.returnValue explicitly, instead of only returning a value, as the
  1091. * former works more consistently within Electron.
  1092. */
  1093. on(event: 'close', listener: (event: Event) => void): this;
  1094. once(event: 'close', listener: (event: Event) => void): this;
  1095. addListener(event: 'close', listener: (event: Event) => void): this;
  1096. removeListener(event: 'close', listener: (event: Event) => void): this;
  1097. /**
  1098. * Emitted when the window is closed. After you have received this event you should
  1099. * remove the reference to the window and avoid using it any more.
  1100. */
  1101. on(event: 'closed', listener: Function): this;
  1102. once(event: 'closed', listener: Function): this;
  1103. addListener(event: 'closed', listener: Function): this;
  1104. removeListener(event: 'closed', listener: Function): this;
  1105. /**
  1106. * Emitted when the window enters a full-screen state.
  1107. */
  1108. on(event: 'enter-full-screen', listener: Function): this;
  1109. once(event: 'enter-full-screen', listener: Function): this;
  1110. addListener(event: 'enter-full-screen', listener: Function): this;
  1111. removeListener(event: 'enter-full-screen', listener: Function): this;
  1112. /**
  1113. * Emitted when the window enters a full-screen state triggered by HTML API.
  1114. */
  1115. on(event: 'enter-html-full-screen', listener: Function): this;
  1116. once(event: 'enter-html-full-screen', listener: Function): this;
  1117. addListener(event: 'enter-html-full-screen', listener: Function): this;
  1118. removeListener(event: 'enter-html-full-screen', listener: Function): this;
  1119. /**
  1120. * Emitted when the window gains focus.
  1121. */
  1122. on(event: 'focus', listener: Function): this;
  1123. once(event: 'focus', listener: Function): this;
  1124. addListener(event: 'focus', listener: Function): this;
  1125. removeListener(event: 'focus', listener: Function): this;
  1126. /**
  1127. * Emitted when the window is hidden.
  1128. */
  1129. on(event: 'hide', listener: Function): this;
  1130. once(event: 'hide', listener: Function): this;
  1131. addListener(event: 'hide', listener: Function): this;
  1132. removeListener(event: 'hide', listener: Function): this;
  1133. /**
  1134. * Emitted when the window leaves a full-screen state.
  1135. */
  1136. on(event: 'leave-full-screen', listener: Function): this;
  1137. once(event: 'leave-full-screen', listener: Function): this;
  1138. addListener(event: 'leave-full-screen', listener: Function): this;
  1139. removeListener(event: 'leave-full-screen', listener: Function): this;
  1140. /**
  1141. * Emitted when the window leaves a full-screen state triggered by HTML API.
  1142. */
  1143. on(event: 'leave-html-full-screen', listener: Function): this;
  1144. once(event: 'leave-html-full-screen', listener: Function): this;
  1145. addListener(event: 'leave-html-full-screen', listener: Function): this;
  1146. removeListener(event: 'leave-html-full-screen', listener: Function): this;
  1147. /**
  1148. * Emitted when window is maximized.
  1149. */
  1150. on(event: 'maximize', listener: Function): this;
  1151. once(event: 'maximize', listener: Function): this;
  1152. addListener(event: 'maximize', listener: Function): this;
  1153. removeListener(event: 'maximize', listener: Function): this;
  1154. /**
  1155. * Emitted when the window is minimized.
  1156. */
  1157. on(event: 'minimize', listener: Function): this;
  1158. once(event: 'minimize', listener: Function): this;
  1159. addListener(event: 'minimize', listener: Function): this;
  1160. removeListener(event: 'minimize', listener: Function): this;
  1161. /**
  1162. * Emitted when the window is being moved to a new position. Note: On macOS this
  1163. * event is an alias of moved.
  1164. */
  1165. on(event: 'move', listener: Function): this;
  1166. once(event: 'move', listener: Function): this;
  1167. addListener(event: 'move', listener: Function): this;
  1168. removeListener(event: 'move', listener: Function): this;
  1169. /**
  1170. * Emitted once when the window is moved to a new position.
  1171. */
  1172. on(event: 'moved', listener: Function): this;
  1173. once(event: 'moved', listener: Function): this;
  1174. addListener(event: 'moved', listener: Function): this;
  1175. removeListener(event: 'moved', listener: Function): this;
  1176. /**
  1177. * Emitted when the native new tab button is clicked.
  1178. */
  1179. on(event: 'new-window-for-tab', listener: Function): this;
  1180. once(event: 'new-window-for-tab', listener: Function): this;
  1181. addListener(event: 'new-window-for-tab', listener: Function): this;
  1182. removeListener(event: 'new-window-for-tab', listener: Function): this;
  1183. /**
  1184. * Emitted when the document changed its title, calling event.preventDefault() will
  1185. * prevent the native window's title from changing.
  1186. */
  1187. on(event: 'page-title-updated', listener: (event: Event,
  1188. title: string) => void): this;
  1189. once(event: 'page-title-updated', listener: (event: Event,
  1190. title: string) => void): this;
  1191. addListener(event: 'page-title-updated', listener: (event: Event,
  1192. title: string) => void): this;
  1193. removeListener(event: 'page-title-updated', listener: (event: Event,
  1194. title: string) => void): this;
  1195. /**
  1196. * Emitted when the web page has been rendered (while not being shown) and window
  1197. * can be displayed without a visual flash.
  1198. */
  1199. on(event: 'ready-to-show', listener: Function): this;
  1200. once(event: 'ready-to-show', listener: Function): this;
  1201. addListener(event: 'ready-to-show', listener: Function): this;
  1202. removeListener(event: 'ready-to-show', listener: Function): this;
  1203. /**
  1204. * Emitted when the window is being resized.
  1205. */
  1206. on(event: 'resize', listener: Function): this;
  1207. once(event: 'resize', listener: Function): this;
  1208. addListener(event: 'resize', listener: Function): this;
  1209. removeListener(event: 'resize', listener: Function): this;
  1210. /**
  1211. * Emitted when the unresponsive web page becomes responsive again.
  1212. */
  1213. on(event: 'responsive', listener: Function): this;
  1214. once(event: 'responsive', listener: Function): this;
  1215. addListener(event: 'responsive', listener: Function): this;
  1216. removeListener(event: 'responsive', listener: Function): this;
  1217. /**
  1218. * Emitted when the window is restored from a minimized state.
  1219. */
  1220. on(event: 'restore', listener: Function): this;
  1221. once(event: 'restore', listener: Function): this;
  1222. addListener(event: 'restore', listener: Function): this;
  1223. removeListener(event: 'restore', listener: Function): this;
  1224. /**
  1225. * Emitted when scroll wheel event phase has begun.
  1226. */
  1227. on(event: 'scroll-touch-begin', listener: Function): this;
  1228. once(event: 'scroll-touch-begin', listener: Function): this;
  1229. addListener(event: 'scroll-touch-begin', listener: Function): this;
  1230. removeListener(event: 'scroll-touch-begin', listener: Function): this;
  1231. /**
  1232. * Emitted when scroll wheel event phase filed upon reaching the edge of element.
  1233. */
  1234. on(event: 'scroll-touch-edge', listener: Function): this;
  1235. once(event: 'scroll-touch-edge', listener: Function): this;
  1236. addListener(event: 'scroll-touch-edge', listener: Function): this;
  1237. removeListener(event: 'scroll-touch-edge', listener: Function): this;
  1238. /**
  1239. * Emitted when scroll wheel event phase has ended.
  1240. */
  1241. on(event: 'scroll-touch-end', listener: Function): this;
  1242. once(event: 'scroll-touch-end', listener: Function): this;
  1243. addListener(event: 'scroll-touch-end', listener: Function): this;
  1244. removeListener(event: 'scroll-touch-end', listener: Function): this;
  1245. /**
  1246. * Emitted when window session is going to end due to force shutdown or machine
  1247. * restart or session log off.
  1248. */
  1249. on(event: 'session-end', listener: Function): this;
  1250. once(event: 'session-end', listener: Function): this;
  1251. addListener(event: 'session-end', listener: Function): this;
  1252. removeListener(event: 'session-end', listener: Function): this;
  1253. /**
  1254. * Emitted when the window opens a sheet.
  1255. */
  1256. on(event: 'sheet-begin', listener: Function): this;
  1257. once(event: 'sheet-begin', listener: Function): this;
  1258. addListener(event: 'sheet-begin', listener: Function): this;
  1259. removeListener(event: 'sheet-begin', listener: Function): this;
  1260. /**
  1261. * Emitted when the window has closed a sheet.
  1262. */
  1263. on(event: 'sheet-end', listener: Function): this;
  1264. once(event: 'sheet-end', listener: Function): this;
  1265. addListener(event: 'sheet-end', listener: Function): this;
  1266. removeListener(event: 'sheet-end', listener: Function): this;
  1267. /**
  1268. * Emitted when the window is shown.
  1269. */
  1270. on(event: 'show', listener: Function): this;
  1271. once(event: 'show', listener: Function): this;
  1272. addListener(event: 'show', listener: Function): this;
  1273. removeListener(event: 'show', listener: Function): this;
  1274. /**
  1275. * Emitted on 3-finger swipe. Possible directions are up, right, down, left.
  1276. */
  1277. on(event: 'swipe', listener: (event: Event,
  1278. direction: string) => void): this;
  1279. once(event: 'swipe', listener: (event: Event,
  1280. direction: string) => void): this;
  1281. addListener(event: 'swipe', listener: (event: Event,
  1282. direction: string) => void): this;
  1283. removeListener(event: 'swipe', listener: (event: Event,
  1284. direction: string) => void): this;
  1285. /**
  1286. * Emitted when the window exits from a maximized state.
  1287. */
  1288. on(event: 'unmaximize', listener: Function): this;
  1289. once(event: 'unmaximize', listener: Function): this;
  1290. addListener(event: 'unmaximize', listener: Function): this;
  1291. removeListener(event: 'unmaximize', listener: Function): this;
  1292. /**
  1293. * Emitted when the web page becomes unresponsive.
  1294. */
  1295. on(event: 'unresponsive', listener: Function): this;
  1296. once(event: 'unresponsive', listener: Function): this;
  1297. addListener(event: 'unresponsive', listener: Function): this;
  1298. removeListener(event: 'unresponsive', listener: Function): this;
  1299. constructor(options?: BrowserWindowConstructorOptions);
  1300. /**
  1301. * Adds DevTools extension located at path, and returns extension's name. The
  1302. * extension will be remembered so you only need to call this API once, this API is
  1303. * not for programming use. If you try to add an extension that has already been
  1304. * loaded, this method will not return and instead log a warning to the console.
  1305. * The method will also not return if the extension's manifest is missing or
  1306. * incomplete. Note: This API cannot be called before the ready event of the app
  1307. * module is emitted.
  1308. */
  1309. static addDevToolsExtension(path: string): void;
  1310. /**
  1311. * Adds Chrome extension located at path, and returns extension's name. The method
  1312. * will also not return if the extension's manifest is missing or incomplete. Note:
  1313. * This API cannot be called before the ready event of the app module is emitted.
  1314. */
  1315. static addExtension(path: string): void;
  1316. static fromBrowserView(browserView: BrowserView): BrowserWindow | null;
  1317. static fromId(id: number): BrowserWindow;
  1318. static fromWebContents(webContents: WebContents): BrowserWindow;
  1319. static getAllWindows(): BrowserWindow[];
  1320. /**
  1321. * To check if a DevTools extension is installed you can run the following: Note:
  1322. * This API cannot be called before the ready event of the app module is emitted.
  1323. */
  1324. static getDevToolsExtensions(): DevToolsExtensions;
  1325. /**
  1326. * Note: This API cannot be called before the ready event of the app module is
  1327. * emitted.
  1328. */
  1329. static getExtensions(): Extensions;
  1330. static getFocusedWindow(): BrowserWindow | null;
  1331. /**
  1332. * Remove a DevTools extension by name. Note: This API cannot be called before the
  1333. * ready event of the app module is emitted.
  1334. */
  1335. static removeDevToolsExtension(name: string): void;
  1336. /**
  1337. * Remove a Chrome extension by name. Note: This API cannot be called before the
  1338. * ready event of the app module is emitted.
  1339. */
  1340. static removeExtension(name: string): void;
  1341. /**
  1342. * Adds a window as a tab on this window, after the tab for the window instance.
  1343. */
  1344. addTabbedWindow(browserWindow: BrowserWindow): void;
  1345. /**
  1346. * Removes focus from the window.
  1347. */
  1348. blur(): void;
  1349. blurWebView(): void;
  1350. /**
  1351. * Same as webContents.capturePage([rect, ]callback).
  1352. */
  1353. capturePage(callback: (image: NativeImage) => void): void;
  1354. /**
  1355. * Same as webContents.capturePage([rect, ]callback).
  1356. */
  1357. capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
  1358. /**
  1359. * Moves window to the center of the screen.
  1360. */
  1361. center(): void;
  1362. /**
  1363. * Try to close the window. This has the same effect as a user manually clicking
  1364. * the close button of the window. The web page may cancel the close though. See
  1365. * the close event.
  1366. */
  1367. close(): void;
  1368. /**
  1369. * Closes the currently open Quick Look panel.
  1370. */
  1371. closeFilePreview(): void;
  1372. /**
  1373. * Force closing the window, the unload and beforeunload event won't be emitted for
  1374. * the web page, and close event will also not be emitted for this window, but it
  1375. * guarantees the closed event will be emitted.
  1376. */
  1377. destroy(): void;
  1378. /**
  1379. * Starts or stops flashing the window to attract user's attention.
  1380. */
  1381. flashFrame(flag: boolean): void;
  1382. /**
  1383. * Focuses on the window.
  1384. */
  1385. focus(): void;
  1386. focusOnWebView(): void;
  1387. getBounds(): Rectangle;
  1388. /**
  1389. * Note: The BrowserView API is currently experimental and may change or be removed
  1390. * in future Electron releases.
  1391. */
  1392. getBrowserView(): BrowserView | null;
  1393. getChildWindows(): BrowserWindow[];
  1394. getContentBounds(): Rectangle;
  1395. getContentSize(): number[];
  1396. getMaximumSize(): number[];
  1397. getMinimumSize(): number[];
  1398. /**
  1399. * The native type of the handle is HWND on Windows, NSView* on macOS, and Window
  1400. * (unsigned long) on Linux.
  1401. */
  1402. getNativeWindowHandle(): Buffer;
  1403. getOpacity(): number;
  1404. getParentWindow(): BrowserWindow;
  1405. getPosition(): number[];
  1406. getRepresentedFilename(): string;
  1407. getSize(): number[];
  1408. /**
  1409. * Note: The title of web page can be different from the title of the native
  1410. * window.
  1411. */
  1412. getTitle(): string;
  1413. /**
  1414. * On Windows and Linux always returns true.
  1415. */
  1416. hasShadow(): boolean;
  1417. /**
  1418. * Hides the window.
  1419. */
  1420. hide(): void;
  1421. /**
  1422. * Hooks a windows message. The callback is called when the message is received in
  1423. * the WndProc.
  1424. */
  1425. hookWindowMessage(message: number, callback: Function): void;
  1426. isAlwaysOnTop(): boolean;
  1427. /**
  1428. * On Linux always returns true.
  1429. */
  1430. isClosable(): boolean;
  1431. isDestroyed(): boolean;
  1432. isDocumentEdited(): boolean;
  1433. isFocused(): boolean;
  1434. isFullScreen(): boolean;
  1435. isFullScreenable(): boolean;
  1436. isKiosk(): boolean;
  1437. /**
  1438. * On Linux always returns true.
  1439. */
  1440. isMaximizable(): boolean;
  1441. isMaximized(): boolean;
  1442. isMenuBarAutoHide(): boolean;
  1443. isMenuBarVisible(): boolean;
  1444. /**
  1445. * On Linux always returns true.
  1446. */
  1447. isMinimizable(): boolean;
  1448. isMinimized(): boolean;
  1449. isModal(): boolean;
  1450. /**
  1451. * On Linux always returns true.
  1452. */
  1453. isMovable(): boolean;
  1454. isResizable(): boolean;
  1455. isSimpleFullScreen(): boolean;
  1456. isVisible(): boolean;
  1457. /**
  1458. * Note: This API always returns false on Windows.
  1459. */
  1460. isVisibleOnAllWorkspaces(): boolean;
  1461. isWindowMessageHooked(message: number): boolean;
  1462. /**
  1463. * Same as webContents.loadFile, filePath should be a path to an HTML file relative
  1464. * to the root of your application. See the webContents docs for more information.
  1465. */
  1466. loadFile(filePath: string): void;
  1467. /**
  1468. * Same as webContents.loadURL(url[, options]). The url can be a remote address
  1469. * (e.g. http://) or a path to a local HTML file using the file:// protocol. To
  1470. * ensure that file URLs are properly formatted, it is recommended to use Node's
  1471. * url.format method: You can load a URL using a POST request with URL-encoded data
  1472. * by doing the following:
  1473. */
  1474. loadURL(url: string, options?: LoadURLOptions): void;
  1475. /**
  1476. * Maximizes the window. This will also show (but not focus) the window if it isn't
  1477. * being displayed already.
  1478. */
  1479. maximize(): void;
  1480. /**
  1481. * Merges all windows into one window with multiple tabs when native tabs are
  1482. * enabled and there is more than one open window.
  1483. */
  1484. mergeAllWindows(): void;
  1485. /**
  1486. * Minimizes the window. On some platforms the minimized window will be shown in
  1487. * the Dock.
  1488. */
  1489. minimize(): void;
  1490. /**
  1491. * Moves the current tab into a new window if native tabs are enabled and there is
  1492. * more than one tab in the current window.
  1493. */
  1494. moveTabToNewWindow(): void;
  1495. /**
  1496. * Moves window to top(z-order) regardless of focus
  1497. */
  1498. moveTop(): void;
  1499. /**
  1500. * Uses Quick Look to preview a file at a given path.
  1501. */
  1502. previewFile(path: string, displayName?: string): void;
  1503. /**
  1504. * Same as webContents.reload.
  1505. */
  1506. reload(): void;
  1507. /**
  1508. * Restores the window from minimized state to its previous state.
  1509. */
  1510. restore(): void;
  1511. /**
  1512. * Selects the next tab when native tabs are enabled and there are other tabs in
  1513. * the window.
  1514. */
  1515. selectNextTab(): void;
  1516. /**
  1517. * Selects the previous tab when native tabs are enabled and there are other tabs
  1518. * in the window.
  1519. */
  1520. selectPreviousTab(): void;
  1521. /**
  1522. * Sets whether the window should show always on top of other windows. After
  1523. * setting this, the window is still a normal window, not a toolbox window which
  1524. * can not be focused on.
  1525. */
  1526. setAlwaysOnTop(flag: boolean, level?: 'normal' | 'floating' | 'torn-off-menu' | 'modal-panel' | 'main-menu' | 'status' | 'pop-up-menu' | 'screen-saver', relativeLevel?: number): void;
  1527. /**
  1528. * Sets the properties for the window's taskbar button. Note: relaunchCommand and
  1529. * relaunchDisplayName must always be set together. If one of those properties is
  1530. * not set, then neither will be used.
  1531. */
  1532. setAppDetails(options: AppDetailsOptions): void;
  1533. /**
  1534. * This will make a window maintain an aspect ratio. The extra size allows a
  1535. * developer to have space, specified in pixels, not included within the aspect
  1536. * ratio calculations. This API already takes into account the difference between a
  1537. * window's size and its content size. Consider a normal window with an HD video
  1538. * player and associated controls. Perhaps there are 15 pixels of controls on the
  1539. * left edge, 25 pixels of controls on the right edge and 50 pixels of controls
  1540. * below the player. In order to maintain a 16:9 aspect ratio (standard aspect
  1541. * ratio for HD @1920x1080) within the player itself we would call this function
  1542. * with arguments of 16/9 and [ 40, 50 ]. The second argument doesn't care where
  1543. * the extra width and height are within the content view--only that they exist.
  1544. * Sum any extra width and height areas you have within the overall content view.
  1545. * Calling this function with a value of 0 will remove any previously set aspect
  1546. * ratios.
  1547. */
  1548. setAspectRatio(aspectRatio: number, extraSize: Size): void;
  1549. /**
  1550. * Controls whether to hide cursor when typing.
  1551. */
  1552. setAutoHideCursor(autoHide: boolean): void;
  1553. /**
  1554. * Sets whether the window menu bar should hide itself automatically. Once set the
  1555. * menu bar will only show when users press the single Alt key. If the menu bar is
  1556. * already visible, calling setAutoHideMenuBar(true) won't hide it immediately.
  1557. */
  1558. setAutoHideMenuBar(hide: boolean): void;
  1559. /**
  1560. * Resizes and moves the window to the supplied bounds
  1561. */
  1562. setBounds(bounds: Rectangle, animate?: boolean): void;
  1563. setBrowserView(browserView: BrowserView): void;
  1564. /**
  1565. * Sets whether the window can be manually closed by user. On Linux does nothing.
  1566. */
  1567. setClosable(closable: boolean): void;
  1568. /**
  1569. * Resizes and moves the window's client area (e.g. the web page) to the supplied
  1570. * bounds.
  1571. */
  1572. setContentBounds(bounds: Rectangle, animate?: boolean): void;
  1573. /**
  1574. * Prevents the window contents from being captured by other apps. On macOS it sets
  1575. * the NSWindow's sharingType to NSWindowSharingNone. On Windows it calls
  1576. * SetWindowDisplayAffinity with WDA_MONITOR.
  1577. */
  1578. setContentProtection(enable: boolean): void;
  1579. /**
  1580. * Resizes the window's client area (e.g. the web page) to width and height.
  1581. */
  1582. setContentSize(width: number, height: number, animate?: boolean): void;
  1583. /**
  1584. * Specifies whether the window’s document has been edited, and the icon in title
  1585. * bar will become gray when set to true.
  1586. */
  1587. setDocumentEdited(edited: boolean): void;
  1588. /**
  1589. * Disable or enable the window.
  1590. */
  1591. setEnabled(enable: boolean): void;
  1592. /**
  1593. * Changes whether the window can be focused.
  1594. */
  1595. setFocusable(focusable: boolean): void;
  1596. /**
  1597. * Sets whether the window should be in fullscreen mode.
  1598. */
  1599. setFullScreen(flag: boolean): void;
  1600. /**
  1601. * Sets whether the maximize/zoom window button toggles fullscreen mode or
  1602. * maximizes the window.
  1603. */
  1604. setFullScreenable(fullscreenable: boolean): void;
  1605. /**
  1606. * Sets whether the window should have a shadow. On Windows and Linux does nothing.
  1607. */
  1608. setHasShadow(hasShadow: boolean): void;
  1609. /**
  1610. * Changes window icon.
  1611. */
  1612. setIcon(icon: NativeImage): void;
  1613. /**
  1614. * Makes the window ignore all mouse events. All mouse events happened in this
  1615. * window will be passed to the window below this window, but if this window has
  1616. * focus, it will still receive keyboard events.
  1617. */
  1618. setIgnoreMouseEvents(ignore: boolean, options?: IgnoreMouseEventsOptions): void;
  1619. /**
  1620. * Enters or leaves the kiosk mode.
  1621. */
  1622. setKiosk(flag: boolean): void;
  1623. /**
  1624. * Sets whether the window can be manually maximized by user. On Linux does
  1625. * nothing.
  1626. */
  1627. setMaximizable(maximizable: boolean): void;
  1628. /**
  1629. * Sets the maximum size of window to width and height.
  1630. */
  1631. setMaximumSize(width: number, height: number): void;
  1632. /**
  1633. * Sets the menu as the window's menu bar, setting it to null will remove the menu
  1634. * bar.
  1635. */
  1636. setMenu(menu: Menu | null): void;
  1637. /**
  1638. * Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
  1639. * can still bring up the menu bar by pressing the single Alt key.
  1640. */
  1641. setMenuBarVisibility(visible: boolean): void;
  1642. /**
  1643. * Sets whether the window can be manually minimized by user. On Linux does
  1644. * nothing.
  1645. */
  1646. setMinimizable(minimizable: boolean): void;
  1647. /**
  1648. * Sets the minimum size of window to width and height.
  1649. */
  1650. setMinimumSize(width: number, height: number): void;
  1651. /**
  1652. * Sets whether the window can be moved by user. On Linux does nothing.
  1653. */
  1654. setMovable(movable: boolean): void;
  1655. /**
  1656. * Sets the opacity of the window. On Linux does nothing.
  1657. */
  1658. setOpacity(opacity: number): void;
  1659. /**
  1660. * Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to
  1661. * convey some sort of application status or to passively notify the user.
  1662. */
  1663. setOverlayIcon(overlay: NativeImage | null, description: string): void;
  1664. /**
  1665. * Sets parent as current window's parent window, passing null will turn current
  1666. * window into a top-level window.
  1667. */
  1668. setParentWindow(parent: BrowserWindow): void;
  1669. /**
  1670. * Moves window to x and y.
  1671. */
  1672. setPosition(x: number, y: number, animate?: boolean): void;
  1673. /**
  1674. * Sets progress value in progress bar. Valid range is [0, 1.0]. Remove progress
  1675. * bar when progress < 0; Change to indeterminate mode when progress > 1. On Linux
  1676. * platform, only supports Unity desktop environment, you need to specify the
  1677. * *.desktop file name to desktopName field in package.json. By default, it will
  1678. * assume app.getName().desktop. On Windows, a mode can be passed. Accepted values
  1679. * are none, normal, indeterminate, error, and paused. If you call setProgressBar
  1680. * without a mode set (but with a value within the valid range), normal will be
  1681. * assumed.
  1682. */
  1683. setProgressBar(progress: number, options?: ProgressBarOptions): void;
  1684. /**
  1685. * Sets the pathname of the file the window represents, and the icon of the file
  1686. * will show in window's title bar.
  1687. */
  1688. setRepresentedFilename(filename: string): void;
  1689. /**
  1690. * Sets whether the window can be manually resized by user.
  1691. */
  1692. setResizable(resizable: boolean): void;
  1693. /**
  1694. * Setting a window shape determines the area within the window where the system
  1695. * permits drawing and user interaction. Outside of the given region, no pixels
  1696. * will be drawn and no mouse events will be registered. Mouse events outside of
  1697. * the region will not be received by that window, but will fall through to
  1698. * whatever is behind the window.
  1699. */
  1700. setShape(rects: Rectangle[]): void;
  1701. /**
  1702. * Changes the attachment point for sheets on macOS. By default, sheets are
  1703. * attached just below the window frame, but you may want to display them beneath a
  1704. * HTML-rendered toolbar. For example:
  1705. */
  1706. setSheetOffset(offsetY: number, offsetX?: number): void;
  1707. /**
  1708. * Enters or leaves simple fullscreen mode. Simple fullscreen mode emulates the
  1709. * native fullscreen behavior found in versions of Mac OS X prior to Lion (10.7).
  1710. */
  1711. setSimpleFullScreen(flag: boolean): void;
  1712. /**
  1713. * Resizes the window to width and height.
  1714. */
  1715. setSize(width: number, height: number, animate?: boolean): void;
  1716. /**
  1717. * Makes the window not show in the taskbar.
  1718. */
  1719. setSkipTaskbar(skip: boolean): void;
  1720. /**
  1721. * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image
  1722. * of a window in a taskbar button layout. Returns a Boolean object indicates
  1723. * whether the thumbnail has been added successfully. The number of buttons in
  1724. * thumbnail toolbar should be no greater than 7 due to the limited room. Once you
  1725. * setup the thumbnail toolbar, the toolbar cannot be removed due to the platform's
  1726. * limitation. But you can call the API with an empty array to clean the buttons.
  1727. * The buttons is an array of Button objects: The flags is an array that can
  1728. * include following Strings:
  1729. */
  1730. setThumbarButtons(buttons: ThumbarButton[]): boolean;
  1731. /**
  1732. * Sets the region of the window to show as the thumbnail image displayed when
  1733. * hovering over the window in the taskbar. You can reset the thumbnail to be the
  1734. * entire window by specifying an empty region: {x: 0, y: 0, width: 0, height: 0}.
  1735. */
  1736. setThumbnailClip(region: Rectangle): void;
  1737. /**
  1738. * Sets the toolTip that is displayed when hovering over the window thumbnail in
  1739. * the taskbar.
  1740. */
  1741. setThumbnailToolTip(toolTip: string): void;
  1742. /**
  1743. * Changes the title of native window to title.
  1744. */
  1745. setTitle(title: string): void;
  1746. /**
  1747. * Sets the touchBar layout for the current window. Specifying null or undefined
  1748. * clears the touch bar. This method only has an effect if the machine has a touch
  1749. * bar and is running on macOS 10.12.1+. Note: The TouchBar API is currently
  1750. * experimental and may change or be removed in future Electron releases.
  1751. */
  1752. setTouchBar(touchBar: TouchBar): void;
  1753. /**
  1754. * Adds a vibrancy effect to the browser window. Passing null or an empty string
  1755. * will remove the vibrancy effect on the window.
  1756. */
  1757. setVibrancy(type: 'appearance-based' | 'light' | 'dark' | 'titlebar' | 'selection' | 'menu' | 'popover' | 'sidebar' | 'medium-light' | 'ultra-dark'): void;
  1758. /**
  1759. * Sets whether the window should be visible on all workspaces. Note: This API does
  1760. * nothing on Windows.
  1761. */
  1762. setVisibleOnAllWorkspaces(visible: boolean): void;
  1763. /**
  1764. * Shows and gives focus to the window.
  1765. */
  1766. show(): void;
  1767. /**
  1768. * Same as webContents.showDefinitionForSelection().
  1769. */
  1770. showDefinitionForSelection(): void;
  1771. /**
  1772. * Shows the window but doesn't focus on it.
  1773. */
  1774. showInactive(): void;
  1775. /**
  1776. * Toggles the visibility of the tab bar if native tabs are enabled and there is
  1777. * only one tab in the current window.
  1778. */
  1779. toggleTabBar(): void;
  1780. /**
  1781. * Unhooks all of the window messages.
  1782. */
  1783. unhookAllWindowMessages(): void;
  1784. /**
  1785. * Unhook the window message.
  1786. */
  1787. unhookWindowMessage(message: number): void;
  1788. /**
  1789. * Unmaximizes the window.
  1790. */
  1791. unmaximize(): void;
  1792. id: number;
  1793. webContents: WebContents;
  1794. }
  1795. class BrowserWindowProxy extends EventEmitter {
  1796. // Docs: http://electron.atom.io/docs/api/browser-window-proxy
  1797. /**
  1798. * Removes focus from the child window.
  1799. */
  1800. blur(): void;
  1801. /**
  1802. * Forcefully closes the child window without calling its unload event.
  1803. */
  1804. close(): void;
  1805. /**
  1806. * Evaluates the code in the child window.
  1807. */
  1808. eval(code: string): void;
  1809. /**
  1810. * Focuses the child window (brings the window to front).
  1811. */
  1812. focus(): void;
  1813. /**
  1814. * Sends a message to the child window with the specified origin or * for no origin
  1815. * preference. In addition to these methods, the child window implements
  1816. * window.opener object with no properties and a single method.
  1817. */
  1818. postMessage(message: string, targetOrigin: string): void;
  1819. /**
  1820. * Invokes the print dialog on the child window.
  1821. */
  1822. print(): void;
  1823. closed: boolean;
  1824. }
  1825. interface Certificate {
  1826. // Docs: http://electron.atom.io/docs/api/structures/certificate
  1827. /**
  1828. * PEM encoded data
  1829. */
  1830. data: string;
  1831. /**
  1832. * Fingerprint of the certificate
  1833. */
  1834. fingerprint: string;
  1835. /**
  1836. * Issuer principal
  1837. */
  1838. issuer: CertificatePrincipal;
  1839. /**
  1840. * Issuer certificate (if not self-signed)
  1841. */
  1842. issuerCert: Certificate;
  1843. /**
  1844. * Issuer's Common Name
  1845. */
  1846. issuerName: string;
  1847. /**
  1848. * Hex value represented string
  1849. */
  1850. serialNumber: string;
  1851. /**
  1852. * Subject principal
  1853. */
  1854. subject: CertificatePrincipal;
  1855. /**
  1856. * Subject's Common Name
  1857. */
  1858. subjectName: string;
  1859. /**
  1860. * End date of the certificate being valid in seconds
  1861. */
  1862. validExpiry: number;
  1863. /**
  1864. * Start date of the certificate being valid in seconds
  1865. */
  1866. validStart: number;
  1867. }
  1868. interface CertificatePrincipal {
  1869. // Docs: http://electron.atom.io/docs/api/structures/certificate-principal
  1870. /**
  1871. * Common Name
  1872. */
  1873. commonName: string;
  1874. /**
  1875. * Country or region
  1876. */
  1877. country: string;
  1878. /**
  1879. * Locality
  1880. */
  1881. locality: string;
  1882. /**
  1883. * Organization names
  1884. */
  1885. organizations: string[];
  1886. /**
  1887. * Organization Unit names
  1888. */
  1889. organizationUnits: string[];
  1890. /**
  1891. * State or province
  1892. */
  1893. state: string;
  1894. }
  1895. class ClientRequest extends EventEmitter {
  1896. // Docs: http://electron.atom.io/docs/api/client-request
  1897. /**
  1898. * Emitted when the request is aborted. The abort event will not be fired if the
  1899. * request is already closed.
  1900. */
  1901. on(event: 'abort', listener: Function): this;
  1902. once(event: 'abort', listener: Function): this;
  1903. addListener(event: 'abort', listener: Function): this;
  1904. removeListener(event: 'abort', listener: Function): this;
  1905. /**
  1906. * Emitted as the last event in the HTTP request-response transaction. The close
  1907. * event indicates that no more events will be emitted on either the request or
  1908. * response objects.
  1909. */
  1910. on(event: 'close', listener: Function): this;
  1911. once(event: 'close', listener: Function): this;
  1912. addListener(event: 'close', listener: Function): this;
  1913. removeListener(event: 'close', listener: Function): this;
  1914. /**
  1915. * Emitted when the net module fails to issue a network request. Typically when the
  1916. * request object emits an error event, a close event will subsequently follow and
  1917. * no response object will be provided.
  1918. */
  1919. on(event: 'error', listener: (
  1920. /**
  1921. * an error object providing some information about the failure.
  1922. */
  1923. error: Error) => void): this;
  1924. once(event: 'error', listener: (
  1925. /**
  1926. * an error object providing some information about the failure.
  1927. */
  1928. error: Error) => void): this;
  1929. addListener(event: 'error', listener: (
  1930. /**
  1931. * an error object providing some information about the failure.
  1932. */
  1933. error: Error) => void): this;
  1934. removeListener(event: 'error', listener: (
  1935. /**
  1936. * an error object providing some information about the failure.
  1937. */
  1938. error: Error) => void): this;
  1939. /**
  1940. * Emitted just after the last chunk of the request's data has been written into
  1941. * the request object.
  1942. */
  1943. on(event: 'finish', listener: Function): this;
  1944. once(event: 'finish', listener: Function): this;
  1945. addListener(event: 'finish', listener: Function): this;
  1946. removeListener(event: 'finish', listener: Function): this;
  1947. /**
  1948. * Emitted when an authenticating proxy is asking for user credentials. The
  1949. * callback function is expected to be called back with user credentials: Providing
  1950. * empty credentials will cancel the request and report an authentication error on
  1951. * the response object:
  1952. */
  1953. on(event: 'login', listener: (authInfo: AuthInfo,
  1954. callback: (username: string, password: string) => void) => void): this;
  1955. once(event: 'login', listener: (authInfo: AuthInfo,
  1956. callback: (username: string, password: string) => void) => void): this;
  1957. addListener(event: 'login', listener: (authInfo: AuthInfo,
  1958. callback: (username: string, password: string) => void) => void): this;
  1959. removeListener(event: 'login', listener: (authInfo: AuthInfo,
  1960. callback: (username: string, password: string) => void) => void): this;
  1961. /**
  1962. * Emitted when there is redirection and the mode is manual. Calling
  1963. * request.followRedirect will continue with the redirection.
  1964. */
  1965. on(event: 'redirect', listener: (statusCode: number,
  1966. method: string,
  1967. redirectUrl: string,
  1968. responseHeaders: any) => void): this;
  1969. once(event: 'redirect', listener: (statusCode: number,
  1970. method: string,
  1971. redirectUrl: string,
  1972. responseHeaders: any) => void): this;
  1973. addListener(event: 'redirect', listener: (statusCode: number,
  1974. method: string,
  1975. redirectUrl: string,
  1976. responseHeaders: any) => void): this;
  1977. removeListener(event: 'redirect', listener: (statusCode: number,
  1978. method: string,
  1979. redirectUrl: string,
  1980. responseHeaders: any) => void): this;
  1981. on(event: 'response', listener: (
  1982. /**
  1983. * An object representing the HTTP response message.
  1984. */
  1985. response: IncomingMessage) => void): this;
  1986. once(event: 'response', listener: (
  1987. /**
  1988. * An object representing the HTTP response message.
  1989. */
  1990. response: IncomingMessage) => void): this;
  1991. addListener(event: 'response', listener: (
  1992. /**
  1993. * An object representing the HTTP response message.
  1994. */
  1995. response: IncomingMessage) => void): this;
  1996. removeListener(event: 'response', listener: (
  1997. /**
  1998. * An object representing the HTTP response message.
  1999. */
  2000. response: IncomingMessage) => void): this;
  2001. constructor(options: 'method' | 'url' | 'session' | 'partition' | 'protocol' | 'host' | 'hostname' | 'port' | 'path' | 'redirect');
  2002. /**
  2003. * Cancels an ongoing HTTP transaction. If the request has already emitted the
  2004. * close event, the abort operation will have no effect. Otherwise an ongoing event
  2005. * will emit abort and close events. Additionally, if there is an ongoing response
  2006. * object,it will emit the aborted event.
  2007. */
  2008. abort(): void;
  2009. /**
  2010. * Sends the last chunk of the request data. Subsequent write or end operations
  2011. * will not be allowed. The finish event is emitted just after the end operation.
  2012. */
  2013. end(chunk?: string | Buffer, encoding?: string, callback?: Function): void;
  2014. /**
  2015. * Continues any deferred redirection request when the redirection mode is manual.
  2016. */
  2017. followRedirect(): void;
  2018. getHeader(name: string): Header;
  2019. /**
  2020. * You can use this method in conjunction with POST requests to get the progress of
  2021. * a file upload or other data transfer.
  2022. */
  2023. getUploadProgress(): UploadProgress;
  2024. /**
  2025. * Removes a previously set extra header name. This method can be called only
  2026. * before first write. Trying to call it after the first write will throw an error.
  2027. */
  2028. removeHeader(name: string): void;
  2029. /**
  2030. * Adds an extra HTTP header. The header name will issued as it is without
  2031. * lowercasing. It can be called only before first write. Calling this method after
  2032. * the first write will throw an error. If the passed value is not a String, its
  2033. * toString() method will be called to obtain the final value.
  2034. */
  2035. setHeader(name: string, value: any): void;
  2036. /**
  2037. * callback is essentially a dummy function introduced in the purpose of keeping
  2038. * similarity with the Node.js API. It is called asynchronously in the next tick
  2039. * after chunk content have been delivered to the Chromium networking layer.
  2040. * Contrary to the Node.js implementation, it is not guaranteed that chunk content
  2041. * have been flushed on the wire before callback is called. Adds a chunk of data to
  2042. * the request body. The first write operation may cause the request headers to be
  2043. * issued on the wire. After the first write operation, it is not allowed to add or
  2044. * remove a custom header.
  2045. */
  2046. write(chunk: string | Buffer, encoding?: string, callback?: Function): void;
  2047. chunkedEncoding: boolean;
  2048. }
  2049. interface Clipboard extends EventEmitter {
  2050. // Docs: http://electron.atom.io/docs/api/clipboard
  2051. availableFormats(type?: string): string[];
  2052. /**
  2053. * Clears the clipboard content.
  2054. */
  2055. clear(type?: string): void;
  2056. has(format: string, type?: string): boolean;
  2057. read(format: string): string;
  2058. /**
  2059. * Returns an Object containing title and url keys representing the bookmark in the
  2060. * clipboard. The title and url values will be empty strings when the bookmark is
  2061. * unavailable.
  2062. */
  2063. readBookmark(): ReadBookmark;
  2064. readBuffer(format: string): Buffer;
  2065. readFindText(): string;
  2066. readHTML(type?: string): string;
  2067. readImage(type?: string): NativeImage;
  2068. readRTF(type?: string): string;
  2069. readText(type?: string): string;
  2070. /**
  2071. * Writes data to the clipboard.
  2072. */
  2073. write(data: Data, type?: string): void;
  2074. /**
  2075. * Writes the title and url into the clipboard as a bookmark. Note: Most apps on
  2076. * Windows don't support pasting bookmarks into them so you can use clipboard.write
  2077. * to write both a bookmark and fallback text to the clipboard.
  2078. */
  2079. writeBookmark(title: string, url: string, type?: string): void;
  2080. /**
  2081. * Writes the buffer into the clipboard as format.
  2082. */
  2083. writeBuffer(format: string, buffer: Buffer, type?: string): void;
  2084. /**
  2085. * Writes the text into the find pasteboard as plain text. This method uses
  2086. * synchronous IPC when called from the renderer process.
  2087. */
  2088. writeFindText(text: string): void;
  2089. /**
  2090. * Writes markup to the clipboard.
  2091. */
  2092. writeHTML(markup: string, type?: string): void;
  2093. /**
  2094. * Writes image to the clipboard.
  2095. */
  2096. writeImage(image: NativeImage, type?: string): void;
  2097. /**
  2098. * Writes the text into the clipboard in RTF.
  2099. */
  2100. writeRTF(text: string, type?: string): void;
  2101. /**
  2102. * Writes the text into the clipboard as plain text.
  2103. */
  2104. writeText(text: string, type?: string): void;
  2105. }
  2106. interface ContentTracing extends EventEmitter {
  2107. // Docs: http://electron.atom.io/docs/api/content-tracing
  2108. /**
  2109. * Get the current monitoring traced data. Child processes typically cache trace
  2110. * data and only rarely flush and send trace data back to the main process. This is
  2111. * because it may be an expensive operation to send the trace data over IPC and we
  2112. * would like to avoid unneeded runtime overhead from tracing. So, to end tracing,
  2113. * we must asynchronously ask all child processes to flush any pending trace data.
  2114. * Once all child processes have acknowledged the captureMonitoringSnapshot request
  2115. * the callback will be called with a file that contains the traced data.
  2116. */
  2117. captureMonitoringSnapshot(resultFilePath: string, callback: (resultFilePath: string) => void): void;
  2118. /**
  2119. * Get a set of category groups. The category groups can change as new code paths
  2120. * are reached. Once all child processes have acknowledged the getCategories
  2121. * request the callback is invoked with an array of category groups.
  2122. */
  2123. getCategories(callback: (categories: string[]) => void): void;
  2124. /**
  2125. * Get the maximum usage across processes of trace buffer as a percentage of the
  2126. * full state. When the TraceBufferUsage value is determined the callback is
  2127. * called.
  2128. */
  2129. getTraceBufferUsage(callback: (value: number, percentage: number) => void): void;
  2130. /**
  2131. * Start monitoring on all processes. Monitoring begins immediately locally and
  2132. * asynchronously on child processes as soon as they receive the startMonitoring
  2133. * request. Once all child processes have acknowledged the startMonitoring request
  2134. * the callback will be called.
  2135. */
  2136. startMonitoring(options: StartMonitoringOptions, callback: Function): void;
  2137. /**
  2138. * Start recording on all processes. Recording begins immediately locally and
  2139. * asynchronously on child processes as soon as they receive the EnableRecording
  2140. * request. The callback will be called once all child processes have acknowledged
  2141. * the startRecording request. categoryFilter is a filter to control what category
  2142. * groups should be traced. A filter can have an optional - prefix to exclude
  2143. * category groups that contain a matching category. Having both included and
  2144. * excluded category patterns in the same list is not supported. Examples:
  2145. * traceOptions controls what kind of tracing is enabled, it is a comma-delimited
  2146. * list. Possible options are: The first 3 options are trace recording modes and
  2147. * hence mutually exclusive. If more than one trace recording modes appear in the
  2148. * traceOptions string, the last one takes precedence. If none of the trace
  2149. * recording modes are specified, recording mode is record-until-full. The trace
  2150. * option will first be reset to the default option (record_mode set to
  2151. * record-until-full, enable_sampling and enable_systrace set to false) before
  2152. * options parsed from traceOptions are applied on it.
  2153. */
  2154. startRecording(options: StartRecordingOptions, callback: Function): void;
  2155. /**
  2156. * Stop monitoring on all processes. Once all child processes have acknowledged the
  2157. * stopMonitoring request the callback is called.
  2158. */
  2159. stopMonitoring(callback: Function): void;
  2160. /**
  2161. * Stop recording on all processes. Child processes typically cache trace data and
  2162. * only rarely flush and send trace data back to the main process. This helps to
  2163. * minimize the runtime overhead of tracing since sending trace data over IPC can
  2164. * be an expensive operation. So, to end tracing, we must asynchronously ask all
  2165. * child processes to flush any pending trace data. Once all child processes have
  2166. * acknowledged the stopRecording request, callback will be called with a file that
  2167. * contains the traced data. Trace data will be written into resultFilePath if it
  2168. * is not empty or into a temporary file. The actual file path will be passed to
  2169. * callback if it's not null.
  2170. */
  2171. stopRecording(resultFilePath: string, callback: (resultFilePath: string) => void): void;
  2172. }
  2173. interface Cookie {
  2174. // Docs: http://electron.atom.io/docs/api/structures/cookie
  2175. /**
  2176. * The domain of the cookie.
  2177. */
  2178. domain?: string;
  2179. /**
  2180. * The expiration date of the cookie as the number of seconds since the UNIX epoch.
  2181. * Not provided for session cookies.
  2182. */
  2183. expirationDate?: number;
  2184. /**
  2185. * Whether the cookie is a host-only cookie.
  2186. */
  2187. hostOnly?: boolean;
  2188. /**
  2189. * Whether the cookie is marked as HTTP only.
  2190. */
  2191. httpOnly?: boolean;
  2192. /**
  2193. * The name of the cookie.
  2194. */
  2195. name: string;
  2196. /**
  2197. * The path of the cookie.
  2198. */
  2199. path?: string;
  2200. /**
  2201. * Whether the cookie is marked as secure.
  2202. */
  2203. secure?: boolean;
  2204. /**
  2205. * Whether the cookie is a session cookie or a persistent cookie with an expiration
  2206. * date.
  2207. */
  2208. session?: boolean;
  2209. /**
  2210. * The value of the cookie.
  2211. */
  2212. value: string;
  2213. }
  2214. class Cookies extends EventEmitter {
  2215. // Docs: http://electron.atom.io/docs/api/cookies
  2216. /**
  2217. * Emitted when a cookie is changed because it was added, edited, removed, or
  2218. * expired.
  2219. */
  2220. on(event: 'changed', listener: (event: Event,
  2221. /**
  2222. * The cookie that was changed.
  2223. */
  2224. cookie: Cookie,
  2225. /**
  2226. * The cause of the change with one of the following values:
  2227. */
  2228. cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'),
  2229. /**
  2230. * `true` if the cookie was removed, `false` otherwise.
  2231. */
  2232. removed: boolean) => void): this;
  2233. once(event: 'changed', listener: (event: Event,
  2234. /**
  2235. * The cookie that was changed.
  2236. */
  2237. cookie: Cookie,
  2238. /**
  2239. * The cause of the change with one of the following values:
  2240. */
  2241. cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'),
  2242. /**
  2243. * `true` if the cookie was removed, `false` otherwise.
  2244. */
  2245. removed: boolean) => void): this;
  2246. addListener(event: 'changed', listener: (event: Event,
  2247. /**
  2248. * The cookie that was changed.
  2249. */
  2250. cookie: Cookie,
  2251. /**
  2252. * The cause of the change with one of the following values:
  2253. */
  2254. cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'),
  2255. /**
  2256. * `true` if the cookie was removed, `false` otherwise.
  2257. */
  2258. removed: boolean) => void): this;
  2259. removeListener(event: 'changed', listener: (event: Event,
  2260. /**
  2261. * The cookie that was changed.
  2262. */
  2263. cookie: Cookie,
  2264. /**
  2265. * The cause of the change with one of the following values:
  2266. */
  2267. cause: ('explicit' | 'overwrite' | 'expired' | 'evicted' | 'expired-overwrite'),
  2268. /**
  2269. * `true` if the cookie was removed, `false` otherwise.
  2270. */
  2271. removed: boolean) => void): this;
  2272. /**
  2273. * Writes any unwritten cookies data to disk.
  2274. */
  2275. flushStore(callback: Function): void;
  2276. /**
  2277. * Sends a request to get all cookies matching filter, callback will be called with
  2278. * callback(error, cookies) on complete.
  2279. */
  2280. get(filter: Filter, callback: (error: Error, cookies: Cookie[]) => void): void;
  2281. /**
  2282. * Removes the cookies matching url and name, callback will called with callback()
  2283. * on complete.
  2284. */
  2285. remove(url: string, name: string, callback: Function): void;
  2286. /**
  2287. * Sets a cookie with details, callback will be called with callback(error) on
  2288. * complete.
  2289. */
  2290. set(details: Details, callback: (error: Error) => void): void;
  2291. }
  2292. interface CPUUsage {
  2293. // Docs: http://electron.atom.io/docs/api/structures/cpu-usage
  2294. /**
  2295. * The number of average idle cpu wakeups per second since the last call to
  2296. * getCPUUsage. First call returns 0. Will always return 0 on Windows.
  2297. */
  2298. idleWakeupsPerSecond: number;
  2299. /**
  2300. * Percentage of CPU used since the last call to getCPUUsage. First call returns 0.
  2301. */
  2302. percentCPUUsage: number;
  2303. }
  2304. interface CrashReport {
  2305. // Docs: http://electron.atom.io/docs/api/structures/crash-report
  2306. date: Date;
  2307. id: string;
  2308. }
  2309. interface CrashReporter extends EventEmitter {
  2310. // Docs: http://electron.atom.io/docs/api/crash-reporter
  2311. /**
  2312. * Set an extra parameter to be sent with the crash report. The values specified
  2313. * here will be sent in addition to any values set via the extra option when start
  2314. * was called. This API is only available on macOS, if you need to add/update extra
  2315. * parameters on Linux and Windows after your first call to start you can call
  2316. * start again with the updated extra options.
  2317. */
  2318. addExtraParameter(key: string, value: string): void;
  2319. /**
  2320. * Returns the date and ID of the last crash report. If no crash reports have been
  2321. * sent or the crash reporter has not been started, null is returned.
  2322. */
  2323. getLastCrashReport(): CrashReport;
  2324. /**
  2325. * See all of the current parameters being passed to the crash reporter.
  2326. */
  2327. getParameters(): void;
  2328. /**
  2329. * Returns all uploaded crash reports. Each report contains the date and uploaded
  2330. * ID.
  2331. */
  2332. getUploadedReports(): CrashReport[];
  2333. /**
  2334. * Note: This API can only be called from the main process.
  2335. */
  2336. getUploadToServer(): boolean;
  2337. /**
  2338. * Remove a extra parameter from the current set of parameters so that it will not
  2339. * be sent with the crash report.
  2340. */
  2341. removeExtraParameter(key: string): void;
  2342. /**
  2343. * This would normally be controlled by user preferences. This has no effect if
  2344. * called before start is called. Note: This API can only be called from the main
  2345. * process.
  2346. */
  2347. setUploadToServer(uploadToServer: boolean): void;
  2348. /**
  2349. * You are required to call this method before using any other crashReporter APIs
  2350. * and in each process (main/renderer) from which you want to collect crash
  2351. * reports. You can pass different options to crashReporter.start when calling from
  2352. * different processes. Note Child processes created via the child_process module
  2353. * will not have access to the Electron modules. Therefore, to collect crash
  2354. * reports from them, use process.crashReporter.start instead. Pass the same
  2355. * options as above along with an additional one called crashesDirectory that
  2356. * should point to a directory to store the crash reports temporarily. You can test
  2357. * this out by calling process.crash() to crash the child process. Note: To collect
  2358. * crash reports from child process in Windows, you need to add this extra code as
  2359. * well. This will start the process that will monitor and send the crash reports.
  2360. * Replace submitURL, productName and crashesDirectory with appropriate values.
  2361. * Note: If you need send additional/updated extra parameters after your first call
  2362. * start you can call addExtraParameter on macOS or call start again with the
  2363. * new/updated extra parameters on Linux and Windows. Note: On macOS, Electron uses
  2364. * a new crashpad client for crash collection and reporting. If you want to enable
  2365. * crash reporting, initializing crashpad from the main process using
  2366. * crashReporter.start is required regardless of which process you want to collect
  2367. * crashes from. Once initialized this way, the crashpad handler collects crashes
  2368. * from all processes. You still have to call crashReporter.start from the renderer
  2369. * or child process, otherwise crashes from them will get reported without
  2370. * companyName, productName or any of the extra information.
  2371. */
  2372. start(options: CrashReporterStartOptions): void;
  2373. }
  2374. class Debugger extends EventEmitter {
  2375. // Docs: http://electron.atom.io/docs/api/debugger
  2376. /**
  2377. * Emitted when debugging session is terminated. This happens either when
  2378. * webContents is closed or devtools is invoked for the attached webContents.
  2379. */
  2380. on(event: 'detach', listener: (event: Event,
  2381. /**
  2382. * Reason for detaching debugger.
  2383. */
  2384. reason: string) => void): this;
  2385. once(event: 'detach', listener: (event: Event,
  2386. /**
  2387. * Reason for detaching debugger.
  2388. */
  2389. reason: string) => void): this;
  2390. addListener(event: 'detach', listener: (event: Event,
  2391. /**
  2392. * Reason for detaching debugger.
  2393. */
  2394. reason: string) => void): this;
  2395. removeListener(event: 'detach', listener: (event: Event,
  2396. /**
  2397. * Reason for detaching debugger.
  2398. */
  2399. reason: string) => void): this;
  2400. /**
  2401. * Emitted whenever debugging target issues instrumentation event.
  2402. */
  2403. on(event: 'message', listener: (event: Event,
  2404. /**
  2405. * Method name.
  2406. */
  2407. method: string,
  2408. /**
  2409. * Event parameters defined by the 'parameters' attribute in the remote debugging
  2410. * protocol.
  2411. */
  2412. params: any) => void): this;
  2413. once(event: 'message', listener: (event: Event,
  2414. /**
  2415. * Method name.
  2416. */
  2417. method: string,
  2418. /**
  2419. * Event parameters defined by the 'parameters' attribute in the remote debugging
  2420. * protocol.
  2421. */
  2422. params: any) => void): this;
  2423. addListener(event: 'message', listener: (event: Event,
  2424. /**
  2425. * Method name.
  2426. */
  2427. method: string,
  2428. /**
  2429. * Event parameters defined by the 'parameters' attribute in the remote debugging
  2430. * protocol.
  2431. */
  2432. params: any) => void): this;
  2433. removeListener(event: 'message', listener: (event: Event,
  2434. /**
  2435. * Method name.
  2436. */
  2437. method: string,
  2438. /**
  2439. * Event parameters defined by the 'parameters' attribute in the remote debugging
  2440. * protocol.
  2441. */
  2442. params: any) => void): this;
  2443. /**
  2444. * Attaches the debugger to the webContents.
  2445. */
  2446. attach(protocolVersion?: string): void;
  2447. /**
  2448. * Detaches the debugger from the webContents.
  2449. */
  2450. detach(): void;
  2451. isAttached(): boolean;
  2452. /**
  2453. * Send given command to the debugging target.
  2454. */
  2455. sendCommand(method: string, commandParams?: any, callback?: (error: any, result: any) => void): void;
  2456. }
  2457. interface DesktopCapturer extends EventEmitter {
  2458. // Docs: http://electron.atom.io/docs/api/desktop-capturer
  2459. /**
  2460. * Starts gathering information about all available desktop media sources, and
  2461. * calls callback(error, sources) when finished. sources is an array of
  2462. * DesktopCapturerSource objects, each DesktopCapturerSource represents a screen or
  2463. * an individual window that can be captured.
  2464. */
  2465. getSources(options: SourcesOptions, callback: (error: Error, sources: DesktopCapturerSource[]) => void): void;
  2466. }
  2467. interface DesktopCapturerSource {
  2468. // Docs: http://electron.atom.io/docs/api/structures/desktop-capturer-source
  2469. /**
  2470. * A unique identifier that will correspond to the id of the matching returned by
  2471. * the . On some platforms, this is equivalent to the XX portion of the id field
  2472. * above and on others it will differ. It will be an empty string if not available.
  2473. */
  2474. display_id: string;
  2475. /**
  2476. * The identifier of a window or screen that can be used as a chromeMediaSourceId
  2477. * constraint when calling [navigator.webkitGetUserMedia]. The format of the
  2478. * identifier will be window:XX or screen:XX, where XX is a random generated
  2479. * number.
  2480. */
  2481. id: string;
  2482. /**
  2483. * A screen source will be named either Entire Screen or Screen <index>, while the
  2484. * name of a window source will match the window title.
  2485. */
  2486. name: string;
  2487. /**
  2488. * A thumbnail image. There is no guarantee that the size of the thumbnail is the
  2489. * same as the thumbnailSize specified in the options passed to
  2490. * desktopCapturer.getSources. The actual size depends on the scale of the screen
  2491. * or window.
  2492. */
  2493. thumbnail: NativeImage;
  2494. }
  2495. interface Dialog extends EventEmitter {
  2496. // Docs: http://electron.atom.io/docs/api/dialog
  2497. /**
  2498. * On macOS, this displays a modal dialog that shows a message and certificate
  2499. * information, and gives the user the option of trusting/importing the
  2500. * certificate. If you provide a browserWindow argument the dialog will be attached
  2501. * to the parent window, making it modal. On Windows the options are more limited,
  2502. * due to the Win32 APIs used:
  2503. */
  2504. showCertificateTrustDialog(browserWindow: BrowserWindow, options: CertificateTrustDialogOptions, callback: Function): void;
  2505. /**
  2506. * On macOS, this displays a modal dialog that shows a message and certificate
  2507. * information, and gives the user the option of trusting/importing the
  2508. * certificate. If you provide a browserWindow argument the dialog will be attached
  2509. * to the parent window, making it modal. On Windows the options are more limited,
  2510. * due to the Win32 APIs used:
  2511. */
  2512. showCertificateTrustDialog(options: CertificateTrustDialogOptions, callback: Function): void;
  2513. /**
  2514. * On macOS, this displays a modal dialog that shows a message and certificate
  2515. * information, and gives the user the option of trusting/importing the
  2516. * certificate. If you provide a browserWindow argument the dialog will be attached
  2517. * to the parent window, making it modal. On Windows the options are more limited,
  2518. * due to the Win32 APIs used:
  2519. */
  2520. showCertificateTrustDialog(browserWindow: BrowserWindow, options: CertificateTrustDialogOptions, callback: Function): void;
  2521. /**
  2522. * Displays a modal dialog that shows an error message. This API can be called
  2523. * safely before the ready event the app module emits, it is usually used to report
  2524. * errors in early stage of startup. If called before the app readyevent on Linux,
  2525. * the message will be emitted to stderr, and no GUI dialog will appear.
  2526. */
  2527. showErrorBox(title: string, content: string): void;
  2528. /**
  2529. * Shows a message box, it will block the process until the message box is closed.
  2530. * It returns the index of the clicked button. The browserWindow argument allows
  2531. * the dialog to attach itself to a parent window, making it modal. If a callback
  2532. * is passed, the dialog will not block the process. The API call will be
  2533. * asynchronous and the result will be passed via callback(response).
  2534. */
  2535. showMessageBox(browserWindow: BrowserWindow, options: MessageBoxOptions, callback?: (response: number, checkboxChecked: boolean) => void): number;
  2536. /**
  2537. * Shows a message box, it will block the process until the message box is closed.
  2538. * It returns the index of the clicked button. The browserWindow argument allows
  2539. * the dialog to attach itself to a parent window, making it modal. If a callback
  2540. * is passed, the dialog will not block the process. The API call will be
  2541. * asynchronous and the result will be passed via callback(response).
  2542. */
  2543. showMessageBox(options: MessageBoxOptions, callback?: (response: number, checkboxChecked: boolean) => void): number;
  2544. /**
  2545. * The browserWindow argument allows the dialog to attach itself to a parent
  2546. * window, making it modal. The filters specifies an array of file types that can
  2547. * be displayed or selected when you want to limit the user to a specific type. For
  2548. * example: The extensions array should contain extensions without wildcards or
  2549. * dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use
  2550. * the '*' wildcard (no other wildcard is supported). If a callback is passed, the
  2551. * API call will be asynchronous and the result will be passed via
  2552. * callback(filenames). Note: On Windows and Linux an open dialog can not be both a
  2553. * file selector and a directory selector, so if you set properties to ['openFile',
  2554. * 'openDirectory'] on these platforms, a directory selector will be shown.
  2555. */
  2556. showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[];
  2557. /**
  2558. * The browserWindow argument allows the dialog to attach itself to a parent
  2559. * window, making it modal. The filters specifies an array of file types that can
  2560. * be displayed or selected when you want to limit the user to a specific type. For
  2561. * example: The extensions array should contain extensions without wildcards or
  2562. * dots (e.g. 'png' is good but '.png' and '*.png' are bad). To show all files, use
  2563. * the '*' wildcard (no other wildcard is supported). If a callback is passed, the
  2564. * API call will be asynchronous and the result will be passed via
  2565. * callback(filenames). Note: On Windows and Linux an open dialog can not be both a
  2566. * file selector and a directory selector, so if you set properties to ['openFile',
  2567. * 'openDirectory'] on these platforms, a directory selector will be shown.
  2568. */
  2569. showOpenDialog(options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[];
  2570. /**
  2571. * The browserWindow argument allows the dialog to attach itself to a parent
  2572. * window, making it modal. The filters specifies an array of file types that can
  2573. * be displayed, see dialog.showOpenDialog for an example. If a callback is passed,
  2574. * the API call will be asynchronous and the result will be passed via
  2575. * callback(filename).
  2576. */
  2577. showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string;
  2578. /**
  2579. * The browserWindow argument allows the dialog to attach itself to a parent
  2580. * window, making it modal. The filters specifies an array of file types that can
  2581. * be displayed, see dialog.showOpenDialog for an example. If a callback is passed,
  2582. * the API call will be asynchronous and the result will be passed via
  2583. * callback(filename).
  2584. */
  2585. showSaveDialog(options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string;
  2586. }
  2587. interface Display {
  2588. // Docs: http://electron.atom.io/docs/api/structures/display
  2589. bounds: Rectangle;
  2590. /**
  2591. * Unique identifier associated with the display.
  2592. */
  2593. id: number;
  2594. /**
  2595. * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
  2596. */
  2597. rotation: number;
  2598. /**
  2599. * Output device's pixel scale factor.
  2600. */
  2601. scaleFactor: number;
  2602. size: Size;
  2603. /**
  2604. * Can be available, unavailable, unknown.
  2605. */
  2606. touchSupport: ('available' | 'unavailable' | 'unknown');
  2607. workArea: Rectangle;
  2608. workAreaSize: Size;
  2609. }
  2610. class DownloadItem extends EventEmitter {
  2611. // Docs: http://electron.atom.io/docs/api/download-item
  2612. /**
  2613. * Emitted when the download is in a terminal state. This includes a completed
  2614. * download, a cancelled download (via downloadItem.cancel()), and interrupted
  2615. * download that can't be resumed. The state can be one of following:
  2616. */
  2617. on(event: 'done', listener: (event: Event,
  2618. /**
  2619. * Can be `completed`, `cancelled` or `interrupted`.
  2620. */
  2621. state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
  2622. once(event: 'done', listener: (event: Event,
  2623. /**
  2624. * Can be `completed`, `cancelled` or `interrupted`.
  2625. */
  2626. state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
  2627. addListener(event: 'done', listener: (event: Event,
  2628. /**
  2629. * Can be `completed`, `cancelled` or `interrupted`.
  2630. */
  2631. state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
  2632. removeListener(event: 'done', listener: (event: Event,
  2633. /**
  2634. * Can be `completed`, `cancelled` or `interrupted`.
  2635. */
  2636. state: ('completed' | 'cancelled' | 'interrupted')) => void): this;
  2637. /**
  2638. * Emitted when the download has been updated and is not done. The state can be one
  2639. * of following:
  2640. */
  2641. on(event: 'updated', listener: (event: Event,
  2642. /**
  2643. * Can be `progressing` or `interrupted`.
  2644. */
  2645. state: ('progressing' | 'interrupted')) => void): this;
  2646. once(event: 'updated', listener: (event: Event,
  2647. /**
  2648. * Can be `progressing` or `interrupted`.
  2649. */
  2650. state: ('progressing' | 'interrupted')) => void): this;
  2651. addListener(event: 'updated', listener: (event: Event,
  2652. /**
  2653. * Can be `progressing` or `interrupted`.
  2654. */
  2655. state: ('progressing' | 'interrupted')) => void): this;
  2656. removeListener(event: 'updated', listener: (event: Event,
  2657. /**
  2658. * Can be `progressing` or `interrupted`.
  2659. */
  2660. state: ('progressing' | 'interrupted')) => void): this;
  2661. /**
  2662. * Cancels the download operation.
  2663. */
  2664. cancel(): void;
  2665. canResume(): boolean;
  2666. getContentDisposition(): string;
  2667. getETag(): string;
  2668. /**
  2669. * Note: The file name is not always the same as the actual one saved in local
  2670. * disk. If user changes the file name in a prompted download saving dialog, the
  2671. * actual name of saved file will be different.
  2672. */
  2673. getFilename(): string;
  2674. getLastModifiedTime(): string;
  2675. getMimeType(): string;
  2676. getReceivedBytes(): number;
  2677. getSavePath(): string;
  2678. getStartTime(): number;
  2679. /**
  2680. * Note: The following methods are useful specifically to resume a cancelled item
  2681. * when session is restarted.
  2682. */
  2683. getState(): ('progressing' | 'completed' | 'cancelled' | 'interrupted');
  2684. /**
  2685. * If the size is unknown, it returns 0.
  2686. */
  2687. getTotalBytes(): number;
  2688. getURL(): string;
  2689. getURLChain(): string[];
  2690. hasUserGesture(): boolean;
  2691. isPaused(): boolean;
  2692. /**
  2693. * Pauses the download.
  2694. */
  2695. pause(): void;
  2696. /**
  2697. * Resumes the download that has been paused. Note: To enable resumable downloads
  2698. * the server you are downloading from must support range requests and provide both
  2699. * Last-Modified and ETag header values. Otherwise resume() will dismiss previously
  2700. * received bytes and restart the download from the beginning.
  2701. */
  2702. resume(): void;
  2703. /**
  2704. * The API is only available in session's will-download callback function. If user
  2705. * doesn't set the save path via the API, Electron will use the original routine to
  2706. * determine the save path(Usually prompts a save dialog).
  2707. */
  2708. setSavePath(path: string): void;
  2709. }
  2710. interface FileFilter {
  2711. // Docs: http://electron.atom.io/docs/api/structures/file-filter
  2712. extensions: string[];
  2713. name: string;
  2714. }
  2715. interface GlobalShortcut extends EventEmitter {
  2716. // Docs: http://electron.atom.io/docs/api/global-shortcut
  2717. /**
  2718. * When the accelerator is already taken by other applications, this call will
  2719. * still return false. This behavior is intended by operating systems, since they
  2720. * don't want applications to fight for global shortcuts.
  2721. */
  2722. isRegistered(accelerator: Accelerator): boolean;
  2723. /**
  2724. * Registers a global shortcut of accelerator. The callback is called when the
  2725. * registered shortcut is pressed by the user. When the accelerator is already
  2726. * taken by other applications, this call will silently fail. This behavior is
  2727. * intended by operating systems, since they don't want applications to fight for
  2728. * global shortcuts.
  2729. */
  2730. register(accelerator: Accelerator, callback: Function): void;
  2731. /**
  2732. * Unregisters the global shortcut of accelerator.
  2733. */
  2734. unregister(accelerator: Accelerator): void;
  2735. /**
  2736. * Unregisters all of the global shortcuts.
  2737. */
  2738. unregisterAll(): void;
  2739. }
  2740. interface GPUFeatureStatus {
  2741. // Docs: http://electron.atom.io/docs/api/structures/gpu-feature-status
  2742. /**
  2743. * Canvas
  2744. */
  2745. '2d_canvas': string;
  2746. /**
  2747. * Flash
  2748. */
  2749. flash_3d: string;
  2750. /**
  2751. * Flash Stage3D
  2752. */
  2753. flash_stage3d: string;
  2754. /**
  2755. * Flash Stage3D Baseline profile
  2756. */
  2757. flash_stage3d_baseline: string;
  2758. /**
  2759. * Compositing
  2760. */
  2761. gpu_compositing: string;
  2762. /**
  2763. * Multiple Raster Threads
  2764. */
  2765. multiple_raster_threads: string;
  2766. /**
  2767. * Native GpuMemoryBuffers
  2768. */
  2769. native_gpu_memory_buffers: string;
  2770. /**
  2771. * Rasterization
  2772. */
  2773. rasterization: string;
  2774. /**
  2775. * Video Decode
  2776. */
  2777. video_decode: string;
  2778. /**
  2779. * Video Encode
  2780. */
  2781. video_encode: string;
  2782. /**
  2783. * VPx Video Decode
  2784. */
  2785. vpx_decode: string;
  2786. /**
  2787. * WebGL
  2788. */
  2789. webgl: string;
  2790. /**
  2791. * WebGL2
  2792. */
  2793. webgl2: string;
  2794. }
  2795. interface InAppPurchase extends EventEmitter {
  2796. // Docs: http://electron.atom.io/docs/api/in-app-purchase
  2797. /**
  2798. * Emitted when one or more transactions have been updated.
  2799. */
  2800. on(event: 'transactions-updated', listener: (event: Event,
  2801. /**
  2802. * Array of objects.
  2803. */
  2804. transactions: Transaction[]) => void): this;
  2805. once(event: 'transactions-updated', listener: (event: Event,
  2806. /**
  2807. * Array of objects.
  2808. */
  2809. transactions: Transaction[]) => void): this;
  2810. addListener(event: 'transactions-updated', listener: (event: Event,
  2811. /**
  2812. * Array of objects.
  2813. */
  2814. transactions: Transaction[]) => void): this;
  2815. removeListener(event: 'transactions-updated', listener: (event: Event,
  2816. /**
  2817. * Array of objects.
  2818. */
  2819. transactions: Transaction[]) => void): this;
  2820. canMakePayments(): boolean;
  2821. /**
  2822. * Completes all pending transactions.
  2823. */
  2824. finishAllTransactions(): void;
  2825. /**
  2826. * Completes the pending transactions corresponding to the date.
  2827. */
  2828. finishTransactionByDate(date: string): void;
  2829. /**
  2830. * Retrieves the product descriptions.
  2831. */
  2832. getProducts(productIDs: string[], callback: (products: Product[]) => void): void;
  2833. getReceiptURL(): string;
  2834. /**
  2835. * You should listen for the transactions-updated event as soon as possible and
  2836. * certainly before you call purchaseProduct.
  2837. */
  2838. purchaseProduct(productID: string, quantity?: number, callback?: (isProductValid: boolean) => void): void;
  2839. }
  2840. class IncomingMessage extends EventEmitter {
  2841. // Docs: http://electron.atom.io/docs/api/incoming-message
  2842. /**
  2843. * Emitted when a request has been canceled during an ongoing HTTP transaction.
  2844. */
  2845. on(event: 'aborted', listener: Function): this;
  2846. once(event: 'aborted', listener: Function): this;
  2847. addListener(event: 'aborted', listener: Function): this;
  2848. removeListener(event: 'aborted', listener: Function): this;
  2849. /**
  2850. * The data event is the usual method of transferring response data into
  2851. * applicative code.
  2852. */
  2853. on(event: 'data', listener: (
  2854. /**
  2855. * A chunk of response body's data.
  2856. */
  2857. chunk: Buffer) => void): this;
  2858. once(event: 'data', listener: (
  2859. /**
  2860. * A chunk of response body's data.
  2861. */
  2862. chunk: Buffer) => void): this;
  2863. addListener(event: 'data', listener: (
  2864. /**
  2865. * A chunk of response body's data.
  2866. */
  2867. chunk: Buffer) => void): this;
  2868. removeListener(event: 'data', listener: (
  2869. /**
  2870. * A chunk of response body's data.
  2871. */
  2872. chunk: Buffer) => void): this;
  2873. /**
  2874. * Indicates that response body has ended.
  2875. */
  2876. on(event: 'end', listener: Function): this;
  2877. once(event: 'end', listener: Function): this;
  2878. addListener(event: 'end', listener: Function): this;
  2879. removeListener(event: 'end', listener: Function): this;
  2880. /**
  2881. * error Error - Typically holds an error string identifying failure root cause.
  2882. * Emitted when an error was encountered while streaming response data events. For
  2883. * instance, if the server closes the underlying while the response is still
  2884. * streaming, an error event will be emitted on the response object and a close
  2885. * event will subsequently follow on the request object.
  2886. */
  2887. on(event: 'error', listener: Function): this;
  2888. once(event: 'error', listener: Function): this;
  2889. addListener(event: 'error', listener: Function): this;
  2890. removeListener(event: 'error', listener: Function): this;
  2891. headers: any;
  2892. httpVersion: string;
  2893. httpVersionMajor: number;
  2894. httpVersionMinor: number;
  2895. statusCode: number;
  2896. statusMessage: string;
  2897. }
  2898. interface IOCounters {
  2899. // Docs: http://electron.atom.io/docs/api/structures/io-counters
  2900. /**
  2901. * Then number of I/O other operations.
  2902. */
  2903. otherOperationCount: number;
  2904. /**
  2905. * Then number of I/O other transfers.
  2906. */
  2907. otherTransferCount: number;
  2908. /**
  2909. * The number of I/O read operations.
  2910. */
  2911. readOperationCount: number;
  2912. /**
  2913. * The number of I/O read transfers.
  2914. */
  2915. readTransferCount: number;
  2916. /**
  2917. * The number of I/O write operations.
  2918. */
  2919. writeOperationCount: number;
  2920. /**
  2921. * The number of I/O write transfers.
  2922. */
  2923. writeTransferCount: number;
  2924. }
  2925. interface IpcMain extends EventEmitter {
  2926. // Docs: http://electron.atom.io/docs/api/ipc-main
  2927. /**
  2928. * Listens to channel, when a new message arrives listener would be called with
  2929. * listener(event, args...).
  2930. */
  2931. on(channel: string, listener: Function): this;
  2932. /**
  2933. * Adds a one time listener function for the event. This listener is invoked only
  2934. * the next time a message is sent to channel, after which it is removed.
  2935. */
  2936. once(channel: string, listener: Function): this;
  2937. /**
  2938. * Removes listeners of the specified channel.
  2939. */
  2940. removeAllListeners(channel: string): this;
  2941. /**
  2942. * Removes the specified listener from the listener array for the specified
  2943. * channel.
  2944. */
  2945. removeListener(channel: string, listener: Function): this;
  2946. }
  2947. interface IpcRenderer extends EventEmitter {
  2948. // Docs: http://electron.atom.io/docs/api/ipc-renderer
  2949. /**
  2950. * Listens to channel, when a new message arrives listener would be called with
  2951. * listener(event, args...).
  2952. */
  2953. on(channel: string, listener: Function): this;
  2954. /**
  2955. * Adds a one time listener function for the event. This listener is invoked only
  2956. * the next time a message is sent to channel, after which it is removed.
  2957. */
  2958. once(channel: string, listener: Function): this;
  2959. /**
  2960. * Removes all listeners, or those of the specified channel.
  2961. */
  2962. removeAllListeners(channel: string): this;
  2963. /**
  2964. * Removes the specified listener from the listener array for the specified
  2965. * channel.
  2966. */
  2967. removeListener(channel: string, listener: Function): this;
  2968. /**
  2969. * Send a message to the main process asynchronously via channel, you can also send
  2970. * arbitrary arguments. Arguments will be serialized in JSON internally and hence
  2971. * no functions or prototype chain will be included. The main process handles it by
  2972. * listening for channel with ipcMain module.
  2973. */
  2974. send(channel: string, ...args: any[]): void;
  2975. /**
  2976. * Send a message to the main process synchronously via channel, you can also send
  2977. * arbitrary arguments. Arguments will be serialized in JSON internally and hence
  2978. * no functions or prototype chain will be included. The main process handles it by
  2979. * listening for channel with ipcMain module, and replies by setting
  2980. * event.returnValue. Note: Sending a synchronous message will block the whole
  2981. * renderer process, unless you know what you are doing you should never use it.
  2982. */
  2983. sendSync(channel: string, ...args: any[]): any;
  2984. /**
  2985. * Sends a message to a window with windowid via channel.
  2986. */
  2987. sendTo(windowId: number, channel: string, ...args: any[]): void;
  2988. /**
  2989. * Like ipcRenderer.send but the event will be sent to the <webview> element in the
  2990. * host page instead of the main process.
  2991. */
  2992. sendToHost(channel: string, ...args: any[]): void;
  2993. }
  2994. interface JumpListCategory {
  2995. // Docs: http://electron.atom.io/docs/api/structures/jump-list-category
  2996. /**
  2997. * Array of objects if type is tasks or custom, otherwise it should be omitted.
  2998. */
  2999. items?: JumpListItem[];
  3000. /**
  3001. * Must be set if type is custom, otherwise it should be omitted.
  3002. */
  3003. name?: string;
  3004. /**
  3005. * One of the following:
  3006. */
  3007. type?: ('tasks' | 'frequent' | 'recent' | 'custom');
  3008. }
  3009. interface JumpListItem {
  3010. // Docs: http://electron.atom.io/docs/api/structures/jump-list-item
  3011. /**
  3012. * The command line arguments when program is executed. Should only be set if type
  3013. * is task.
  3014. */
  3015. args?: string;
  3016. /**
  3017. * Description of the task (displayed in a tooltip). Should only be set if type is
  3018. * task.
  3019. */
  3020. description?: string;
  3021. /**
  3022. * The index of the icon in the resource file. If a resource file contains multiple
  3023. * icons this value can be used to specify the zero-based index of the icon that
  3024. * should be displayed for this task. If a resource file contains only one icon,
  3025. * this property should be set to zero.
  3026. */
  3027. iconIndex?: number;
  3028. /**
  3029. * The absolute path to an icon to be displayed in a Jump List, which can be an
  3030. * arbitrary resource file that contains an icon (e.g. .ico, .exe, .dll). You can
  3031. * usually specify process.execPath to show the program icon.
  3032. */
  3033. iconPath?: string;
  3034. /**
  3035. * Path of the file to open, should only be set if type is file.
  3036. */
  3037. path?: string;
  3038. /**
  3039. * Path of the program to execute, usually you should specify process.execPath
  3040. * which opens the current program. Should only be set if type is task.
  3041. */
  3042. program?: string;
  3043. /**
  3044. * The text to be displayed for the item in the Jump List. Should only be set if
  3045. * type is task.
  3046. */
  3047. title?: string;
  3048. /**
  3049. * One of the following:
  3050. */
  3051. type?: ('task' | 'separator' | 'file');
  3052. }
  3053. interface MemoryInfo {
  3054. // Docs: http://electron.atom.io/docs/api/structures/memory-info
  3055. /**
  3056. * The maximum amount of memory that has ever been pinned to actual physical RAM.
  3057. * On macOS its value will always be 0.
  3058. */
  3059. peakWorkingSetSize: number;
  3060. /**
  3061. * Process id of the process.
  3062. */
  3063. pid: number;
  3064. /**
  3065. * The amount of memory not shared by other processes, such as JS heap or HTML
  3066. * content.
  3067. */
  3068. privateBytes: number;
  3069. /**
  3070. * The amount of memory shared between processes, typically memory consumed by the
  3071. * Electron code itself
  3072. */
  3073. sharedBytes: number;
  3074. /**
  3075. * The amount of memory currently pinned to actual physical RAM.
  3076. */
  3077. workingSetSize: number;
  3078. }
  3079. interface MemoryUsageDetails {
  3080. // Docs: http://electron.atom.io/docs/api/structures/memory-usage-details
  3081. count: number;
  3082. liveSize: number;
  3083. size: number;
  3084. }
  3085. class Menu {
  3086. // Docs: http://electron.atom.io/docs/api/menu
  3087. /**
  3088. * Emitted when a popup is closed either manually or with menu.closePopup().
  3089. */
  3090. on(event: 'menu-will-close', listener: (event: Event) => void): this;
  3091. once(event: 'menu-will-close', listener: (event: Event) => void): this;
  3092. addListener(event: 'menu-will-close', listener: (event: Event) => void): this;
  3093. removeListener(event: 'menu-will-close', listener: (event: Event) => void): this;
  3094. /**
  3095. * Emitted when menu.popup() is called.
  3096. */
  3097. on(event: 'menu-will-show', listener: (event: Event) => void): this;
  3098. once(event: 'menu-will-show', listener: (event: Event) => void): this;
  3099. addListener(event: 'menu-will-show', listener: (event: Event) => void): this;
  3100. removeListener(event: 'menu-will-show', listener: (event: Event) => void): this;
  3101. constructor();
  3102. /**
  3103. * Generally, the template is an array of options for constructing a MenuItem. The
  3104. * usage can be referenced above. You can also attach other fields to the element
  3105. * of the template and they will become properties of the constructed menu items.
  3106. */
  3107. static buildFromTemplate(template: MenuItemConstructorOptions[]): Menu;
  3108. /**
  3109. * Note: The returned Menu instance doesn't support dynamic addition or removal of
  3110. * menu items. Instance properties can still be dynamically modified.
  3111. */
  3112. static getApplicationMenu(): Menu | null;
  3113. /**
  3114. * Sends the action to the first responder of application. This is used for
  3115. * emulating default macOS menu behaviors. Usually you would use the role property
  3116. * of a MenuItem. See the macOS Cocoa Event Handling Guide for more information on
  3117. * macOS' native actions.
  3118. */
  3119. static sendActionToFirstResponder(action: string): void;
  3120. /**
  3121. * Sets menu as the application menu on macOS. On Windows and Linux, the menu will
  3122. * be set as each window's top menu. Passing null will remove the menu bar on
  3123. * Windows and Linux but has no effect on macOS. Note: This API has to be called
  3124. * after the ready event of app module.
  3125. */
  3126. static setApplicationMenu(menu: Menu | null): void;
  3127. /**
  3128. * Appends the menuItem to the menu.
  3129. */
  3130. append(menuItem: MenuItem): void;
  3131. /**
  3132. * Closes the context menu in the browserWindow.
  3133. */
  3134. closePopup(browserWindow?: BrowserWindow): void;
  3135. getMenuItemById(id: string): MenuItem;
  3136. /**
  3137. * Inserts the menuItem to the pos position of the menu.
  3138. */
  3139. insert(pos: number, menuItem: MenuItem): void;
  3140. /**
  3141. * Pops up this menu as a context menu in the BrowserWindow.
  3142. */
  3143. popup(options: PopupOptions): void;
  3144. items: MenuItem[];
  3145. }
  3146. class MenuItem {
  3147. // Docs: http://electron.atom.io/docs/api/menu-item
  3148. constructor(options: MenuItemConstructorOptions);
  3149. checked: boolean;
  3150. click: Function;
  3151. enabled: boolean;
  3152. label: string;
  3153. visible: boolean;
  3154. }
  3155. interface MimeTypedBuffer {
  3156. // Docs: http://electron.atom.io/docs/api/structures/mime-typed-buffer
  3157. /**
  3158. * The actual Buffer content
  3159. */
  3160. data: Buffer;
  3161. /**
  3162. * The mimeType of the Buffer that you are sending
  3163. */
  3164. mimeType: string;
  3165. }
  3166. class NativeImage {
  3167. // Docs: http://electron.atom.io/docs/api/native-image
  3168. /**
  3169. * Creates an empty NativeImage instance.
  3170. */
  3171. static createEmpty(): NativeImage;
  3172. /**
  3173. * Creates a new NativeImage instance from buffer.
  3174. */
  3175. static createFromBuffer(buffer: Buffer, options?: CreateFromBufferOptions): NativeImage;
  3176. /**
  3177. * Creates a new NativeImage instance from dataURL.
  3178. */
  3179. static createFromDataURL(dataURL: string): NativeImage;
  3180. /**
  3181. * Creates a new NativeImage instance from the NSImage that maps to the given image
  3182. * name. See NSImageName for a list of possible values. The hslShift is applied to
  3183. * the image with the following rules This means that [-1, 0, 1] will make the
  3184. * image completely white and [-1, 1, 0] will make the image completely black.
  3185. */
  3186. static createFromNamedImage(imageName: string, hslShift: number[]): NativeImage;
  3187. /**
  3188. * Creates a new NativeImage instance from a file located at path. This method
  3189. * returns an empty image if the path does not exist, cannot be read, or is not a
  3190. * valid image.
  3191. */
  3192. static createFromPath(path: string): NativeImage;
  3193. /**
  3194. * Add an image representation for a specific scale factor. This can be used to
  3195. * explicitly add different scale factor representations to an image. This can be
  3196. * called on empty images.
  3197. */
  3198. addRepresentation(options: AddRepresentationOptions): void;
  3199. crop(rect: Rectangle): NativeImage;
  3200. getAspectRatio(): number;
  3201. /**
  3202. * The difference between getBitmap() and toBitmap() is, getBitmap() does not copy
  3203. * the bitmap data, so you have to use the returned Buffer immediately in current
  3204. * event loop tick, otherwise the data might be changed or destroyed.
  3205. */
  3206. getBitmap(options?: BitmapOptions): Buffer;
  3207. /**
  3208. * Notice that the returned pointer is a weak pointer to the underlying native
  3209. * image instead of a copy, so you must ensure that the associated nativeImage
  3210. * instance is kept around.
  3211. */
  3212. getNativeHandle(): Buffer;
  3213. getSize(): Size;
  3214. isEmpty(): boolean;
  3215. isTemplateImage(): boolean;
  3216. /**
  3217. * If only the height or the width are specified then the current aspect ratio will
  3218. * be preserved in the resized image.
  3219. */
  3220. resize(options: ResizeOptions): NativeImage;
  3221. /**
  3222. * Marks the image as a template image.
  3223. */
  3224. setTemplateImage(option: boolean): void;
  3225. toBitmap(options?: ToBitmapOptions): Buffer;
  3226. toDataURL(options?: ToDataURLOptions): string;
  3227. toJPEG(quality: number): Buffer;
  3228. toPNG(options?: ToPNGOptions): Buffer;
  3229. }
  3230. interface Net extends EventEmitter {
  3231. // Docs: http://electron.atom.io/docs/api/net
  3232. /**
  3233. * Creates a ClientRequest instance using the provided options which are directly
  3234. * forwarded to the ClientRequest constructor. The net.request method would be used
  3235. * to issue both secure and insecure HTTP requests according to the specified
  3236. * protocol scheme in the options object.
  3237. */
  3238. request(options: any | string): ClientRequest;
  3239. }
  3240. interface NetLog extends EventEmitter {
  3241. // Docs: http://electron.atom.io/docs/api/net-log
  3242. /**
  3243. * Starts recording network events to path.
  3244. */
  3245. startLogging(path: string): void;
  3246. /**
  3247. * Stops recording network events. If not called, net logging will automatically
  3248. * end when app quits.
  3249. */
  3250. stopLogging(callback?: (path: string) => void): void;
  3251. /**
  3252. * A Boolean property that indicates whether network logs are recorded.
  3253. */
  3254. currentlyLogging?: boolean;
  3255. /**
  3256. * A String property that returns the path to the current log file.
  3257. */
  3258. currentlyLoggingPath?: string;
  3259. }
  3260. class Notification extends EventEmitter {
  3261. // Docs: http://electron.atom.io/docs/api/notification
  3262. on(event: 'action', listener: (event: Event,
  3263. /**
  3264. * The index of the action that was activated.
  3265. */
  3266. index: number) => void): this;
  3267. once(event: 'action', listener: (event: Event,
  3268. /**
  3269. * The index of the action that was activated.
  3270. */
  3271. index: number) => void): this;
  3272. addListener(event: 'action', listener: (event: Event,
  3273. /**
  3274. * The index of the action that was activated.
  3275. */
  3276. index: number) => void): this;
  3277. removeListener(event: 'action', listener: (event: Event,
  3278. /**
  3279. * The index of the action that was activated.
  3280. */
  3281. index: number) => void): this;
  3282. /**
  3283. * Emitted when the notification is clicked by the user.
  3284. */
  3285. on(event: 'click', listener: (event: Event) => void): this;
  3286. once(event: 'click', listener: (event: Event) => void): this;
  3287. addListener(event: 'click', listener: (event: Event) => void): this;
  3288. removeListener(event: 'click', listener: (event: Event) => void): this;
  3289. /**
  3290. * Emitted when the notification is closed by manual intervention from the user.
  3291. * This event is not guaranteed to be emitted in all cases where the notification
  3292. * is closed.
  3293. */
  3294. on(event: 'close', listener: (event: Event) => void): this;
  3295. once(event: 'close', listener: (event: Event) => void): this;
  3296. addListener(event: 'close', listener: (event: Event) => void): this;
  3297. removeListener(event: 'close', listener: (event: Event) => void): this;
  3298. /**
  3299. * Emitted when the user clicks the "Reply" button on a notification with hasReply:
  3300. * true.
  3301. */
  3302. on(event: 'reply', listener: (event: Event,
  3303. /**
  3304. * The string the user entered into the inline reply field.
  3305. */
  3306. reply: string) => void): this;
  3307. once(event: 'reply', listener: (event: Event,
  3308. /**
  3309. * The string the user entered into the inline reply field.
  3310. */
  3311. reply: string) => void): this;
  3312. addListener(event: 'reply', listener: (event: Event,
  3313. /**
  3314. * The string the user entered into the inline reply field.
  3315. */
  3316. reply: string) => void): this;
  3317. removeListener(event: 'reply', listener: (event: Event,
  3318. /**
  3319. * The string the user entered into the inline reply field.
  3320. */
  3321. reply: string) => void): this;
  3322. /**
  3323. * Emitted when the notification is shown to the user, note this could be fired
  3324. * multiple times as a notification can be shown multiple times through the show()
  3325. * method.
  3326. */
  3327. on(event: 'show', listener: (event: Event) => void): this;
  3328. once(event: 'show', listener: (event: Event) => void): this;
  3329. addListener(event: 'show', listener: (event: Event) => void): this;
  3330. removeListener(event: 'show', listener: (event: Event) => void): this;
  3331. constructor(options: NotificationConstructorOptions);
  3332. static isSupported(): boolean;
  3333. /**
  3334. * Dismisses the notification.
  3335. */
  3336. close(): void;
  3337. /**
  3338. * Immediately shows the notification to the user, please note this means unlike
  3339. * the HTML5 Notification implementation, instantiating a new Notification does not
  3340. * immediately show it to the user, you need to call this method before the OS will
  3341. * display it. If the notification has been shown before, this method will dismiss
  3342. * the previously shown notification and create a new one with identical
  3343. * properties.
  3344. */
  3345. show(): void;
  3346. }
  3347. interface NotificationAction {
  3348. // Docs: http://electron.atom.io/docs/api/structures/notification-action
  3349. /**
  3350. * The label for the given action.
  3351. */
  3352. text?: string;
  3353. /**
  3354. * The type of action, can be button.
  3355. */
  3356. type: ('button');
  3357. }
  3358. interface Point {
  3359. // Docs: http://electron.atom.io/docs/api/structures/point
  3360. x: number;
  3361. y: number;
  3362. }
  3363. interface PowerMonitor extends EventEmitter {
  3364. // Docs: http://electron.atom.io/docs/api/power-monitor
  3365. /**
  3366. * Emitted when the system is about to lock the screen.
  3367. */
  3368. on(event: 'lock-screen', listener: Function): this;
  3369. once(event: 'lock-screen', listener: Function): this;
  3370. addListener(event: 'lock-screen', listener: Function): this;
  3371. removeListener(event: 'lock-screen', listener: Function): this;
  3372. /**
  3373. * Emitted when the system changes to AC power.
  3374. */
  3375. on(event: 'on-ac', listener: Function): this;
  3376. once(event: 'on-ac', listener: Function): this;
  3377. addListener(event: 'on-ac', listener: Function): this;
  3378. removeListener(event: 'on-ac', listener: Function): this;
  3379. /**
  3380. * Emitted when system changes to battery power.
  3381. */
  3382. on(event: 'on-battery', listener: Function): this;
  3383. once(event: 'on-battery', listener: Function): this;
  3384. addListener(event: 'on-battery', listener: Function): this;
  3385. removeListener(event: 'on-battery', listener: Function): this;
  3386. /**
  3387. * Emitted when system is resuming.
  3388. */
  3389. on(event: 'resume', listener: Function): this;
  3390. once(event: 'resume', listener: Function): this;
  3391. addListener(event: 'resume', listener: Function): this;
  3392. removeListener(event: 'resume', listener: Function): this;
  3393. /**
  3394. * Emitted when the system is about to reboot or shut down. If the event handler
  3395. * invokes e.preventDefault(), Electron will attempt to delay system shutdown in
  3396. * order for the app to exit cleanly. If e.preventDefault() is called, the app
  3397. * should exit as soon as possible by calling something like app.quit().
  3398. */
  3399. on(event: 'shutdown', listener: Function): this;
  3400. once(event: 'shutdown', listener: Function): this;
  3401. addListener(event: 'shutdown', listener: Function): this;
  3402. removeListener(event: 'shutdown', listener: Function): this;
  3403. /**
  3404. * Emitted when the system is suspending.
  3405. */
  3406. on(event: 'suspend', listener: Function): this;
  3407. once(event: 'suspend', listener: Function): this;
  3408. addListener(event: 'suspend', listener: Function): this;
  3409. removeListener(event: 'suspend', listener: Function): this;
  3410. /**
  3411. * Emitted as soon as the systems screen is unlocked.
  3412. */
  3413. on(event: 'unlock-screen', listener: Function): this;
  3414. once(event: 'unlock-screen', listener: Function): this;
  3415. addListener(event: 'unlock-screen', listener: Function): this;
  3416. removeListener(event: 'unlock-screen', listener: Function): this;
  3417. }
  3418. interface PowerSaveBlocker extends EventEmitter {
  3419. // Docs: http://electron.atom.io/docs/api/power-save-blocker
  3420. isStarted(id: number): boolean;
  3421. /**
  3422. * Starts preventing the system from entering lower-power mode. Returns an integer
  3423. * identifying the power save blocker. Note: prevent-display-sleep has higher
  3424. * precedence over prevent-app-suspension. Only the highest precedence type takes
  3425. * effect. In other words, prevent-display-sleep always takes precedence over
  3426. * prevent-app-suspension. For example, an API calling A requests for
  3427. * prevent-app-suspension, and another calling B requests for
  3428. * prevent-display-sleep. prevent-display-sleep will be used until B stops its
  3429. * request. After that, prevent-app-suspension is used.
  3430. */
  3431. start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number;
  3432. /**
  3433. * Stops the specified power save blocker.
  3434. */
  3435. stop(id: number): void;
  3436. }
  3437. interface PrinterInfo {
  3438. // Docs: http://electron.atom.io/docs/api/structures/printer-info
  3439. description: string;
  3440. isDefault: boolean;
  3441. name: string;
  3442. status: number;
  3443. }
  3444. interface ProcessMetric {
  3445. // Docs: http://electron.atom.io/docs/api/structures/process-metric
  3446. /**
  3447. * CPU usage of the process.
  3448. */
  3449. cpu: CPUUsage;
  3450. /**
  3451. * Memory information for the process.
  3452. */
  3453. memory: MemoryInfo;
  3454. /**
  3455. * Process id of the process.
  3456. */
  3457. pid: number;
  3458. /**
  3459. * Process type (Browser or Tab or GPU etc).
  3460. */
  3461. type: string;
  3462. }
  3463. interface Product {
  3464. // Docs: http://electron.atom.io/docs/api/structures/product
  3465. /**
  3466. * The total size of the content, in bytes.
  3467. */
  3468. contentLengths: number[];
  3469. /**
  3470. * A string that identifies the version of the content.
  3471. */
  3472. contentVersion: string;
  3473. /**
  3474. * A Boolean value that indicates whether the App Store has downloadable content
  3475. * for this product.
  3476. */
  3477. downloadable: boolean;
  3478. /**
  3479. * The locale formatted price of the product.
  3480. */
  3481. formattedPrice: string;
  3482. /**
  3483. * A description of the product.
  3484. */
  3485. localizedDescription: string;
  3486. /**
  3487. * The name of the product.
  3488. */
  3489. localizedTitle: string;
  3490. /**
  3491. * The cost of the product in the local currency.
  3492. */
  3493. price: number;
  3494. /**
  3495. * The string that identifies the product to the Apple App Store.
  3496. */
  3497. productIdentifier: string;
  3498. }
  3499. interface Protocol extends EventEmitter {
  3500. // Docs: http://electron.atom.io/docs/api/protocol
  3501. /**
  3502. * Intercepts scheme protocol and uses handler as the protocol's new handler which
  3503. * sends a Buffer as a response.
  3504. */
  3505. interceptBufferProtocol(scheme: string, handler: (request: InterceptBufferProtocolRequest, callback: (buffer?: Buffer) => void) => void, completion?: (error: Error) => void): void;
  3506. /**
  3507. * Intercepts scheme protocol and uses handler as the protocol's new handler which
  3508. * sends a file as a response.
  3509. */
  3510. interceptFileProtocol(scheme: string, handler: (request: InterceptFileProtocolRequest, callback: (filePath: string) => void) => void, completion?: (error: Error) => void): void;
  3511. /**
  3512. * Intercepts scheme protocol and uses handler as the protocol's new handler which
  3513. * sends a new HTTP request as a response.
  3514. */
  3515. interceptHttpProtocol(scheme: string, handler: (request: InterceptHttpProtocolRequest, callback: (redirectRequest: RedirectRequest) => void) => void, completion?: (error: Error) => void): void;
  3516. /**
  3517. * Same as protocol.registerStreamProtocol, except that it replaces an existing
  3518. * protocol handler.
  3519. */
  3520. interceptStreamProtocol(scheme: string, handler: (request: InterceptStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void;
  3521. /**
  3522. * Intercepts scheme protocol and uses handler as the protocol's new handler which
  3523. * sends a String as a response.
  3524. */
  3525. interceptStringProtocol(scheme: string, handler: (request: InterceptStringProtocolRequest, callback: (data?: string) => void) => void, completion?: (error: Error) => void): void;
  3526. /**
  3527. * The callback will be called with a boolean that indicates whether there is
  3528. * already a handler for scheme.
  3529. */
  3530. isProtocolHandled(scheme: string, callback: (error: Error) => void): void;
  3531. /**
  3532. * Registers a protocol of scheme that will send a Buffer as a response. The usage
  3533. * is the same with registerFileProtocol, except that the callback should be called
  3534. * with either a Buffer object or an object that has the data, mimeType, and
  3535. * charset properties. Example:
  3536. */
  3537. registerBufferProtocol(scheme: string, handler: (request: RegisterBufferProtocolRequest, callback: (buffer?: Buffer | MimeTypedBuffer) => void) => void, completion?: (error: Error) => void): void;
  3538. /**
  3539. * Registers a protocol of scheme that will send the file as a response. The
  3540. * handler will be called with handler(request, callback) when a request is going
  3541. * to be created with scheme. completion will be called with completion(null) when
  3542. * scheme is successfully registered or completion(error) when failed. To handle
  3543. * the request, the callback should be called with either the file's path or an
  3544. * object that has a path property, e.g. callback(filePath) or callback({path:
  3545. * filePath}). When callback is called with nothing, a number, or an object that
  3546. * has an error property, the request will fail with the error number you
  3547. * specified. For the available error numbers you can use, please see the net error
  3548. * list. By default the scheme is treated like http:, which is parsed differently
  3549. * than protocols that follow the "generic URI syntax" like file:, so you probably
  3550. * want to call protocol.registerStandardSchemes to have your scheme treated as a
  3551. * standard scheme.
  3552. */
  3553. registerFileProtocol(scheme: string, handler: (request: RegisterFileProtocolRequest, callback: (filePath?: string) => void) => void, completion?: (error: Error) => void): void;
  3554. /**
  3555. * Registers a protocol of scheme that will send an HTTP request as a response. The
  3556. * usage is the same with registerFileProtocol, except that the callback should be
  3557. * called with a redirectRequest object that has the url, method, referrer,
  3558. * uploadData and session properties. By default the HTTP request will reuse the
  3559. * current session. If you want the request to have a different session you should
  3560. * set session to null. For POST requests the uploadData object must be provided.
  3561. */
  3562. registerHttpProtocol(scheme: string, handler: (request: RegisterHttpProtocolRequest, callback: (redirectRequest: RedirectRequest) => void) => void, completion?: (error: Error) => void): void;
  3563. registerServiceWorkerSchemes(schemes: string[]): void;
  3564. /**
  3565. * A standard scheme adheres to what RFC 3986 calls generic URI syntax. For example
  3566. * http and https are standard schemes, while file is not. Registering a scheme as
  3567. * standard, will allow relative and absolute resources to be resolved correctly
  3568. * when served. Otherwise the scheme will behave like the file protocol, but
  3569. * without the ability to resolve relative URLs. For example when you load
  3570. * following page with custom protocol without registering it as standard scheme,
  3571. * the image will not be loaded because non-standard schemes can not recognize
  3572. * relative URLs: Registering a scheme as standard will allow access to files
  3573. * through the FileSystem API. Otherwise the renderer will throw a security error
  3574. * for the scheme. By default web storage apis (localStorage, sessionStorage,
  3575. * webSQL, indexedDB, cookies) are disabled for non standard schemes. So in general
  3576. * if you want to register a custom protocol to replace the http protocol, you have
  3577. * to register it as a standard scheme: Note: This method can only be used before
  3578. * the ready event of the app module gets emitted.
  3579. */
  3580. registerStandardSchemes(schemes: string[], options?: RegisterStandardSchemesOptions): void;
  3581. /**
  3582. * Registers a protocol of scheme that will send a Readable as a response. The
  3583. * usage is similar to the other register{Any}Protocol, except that the callback
  3584. * should be called with either a Readable object or an object that has the data,
  3585. * statusCode, and headers properties. Example: It is possible to pass any object
  3586. * that implements the readable stream API (emits data/end/error events). For
  3587. * example, here's how a file could be returned:
  3588. */
  3589. registerStreamProtocol(scheme: string, handler: (request: RegisterStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void;
  3590. /**
  3591. * Registers a protocol of scheme that will send a String as a response. The usage
  3592. * is the same with registerFileProtocol, except that the callback should be called
  3593. * with either a String or an object that has the data, mimeType, and charset
  3594. * properties.
  3595. */
  3596. registerStringProtocol(scheme: string, handler: (request: RegisterStringProtocolRequest, callback: (data?: string) => void) => void, completion?: (error: Error) => void): void;
  3597. /**
  3598. * Remove the interceptor installed for scheme and restore its original handler.
  3599. */
  3600. uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void;
  3601. /**
  3602. * Unregisters the custom protocol of scheme.
  3603. */
  3604. unregisterProtocol(scheme: string, completion?: (error: Error) => void): void;
  3605. }
  3606. interface Rectangle {
  3607. // Docs: http://electron.atom.io/docs/api/structures/rectangle
  3608. /**
  3609. * The height of the rectangle (must be an integer)
  3610. */
  3611. height: number;
  3612. /**
  3613. * The width of the rectangle (must be an integer)
  3614. */
  3615. width: number;
  3616. /**
  3617. * The x coordinate of the origin of the rectangle (must be an integer)
  3618. */
  3619. x: number;
  3620. /**
  3621. * The y coordinate of the origin of the rectangle (must be an integer)
  3622. */
  3623. y: number;
  3624. }
  3625. interface Referrer {
  3626. // Docs: http://electron.atom.io/docs/api/structures/referrer
  3627. /**
  3628. * Can be default, unsafe-url, no-referrer-when-downgrade, no-referrer, origin,
  3629. * strict-origin-when-cross-origin, same-origin or strict-origin. See the for more
  3630. * details on the meaning of these values.
  3631. */
  3632. policy: ('default' | 'unsafe-url' | 'no-referrer-when-downgrade' | 'no-referrer' | 'origin' | 'strict-origin-when-cross-origin' | 'same-origin' | 'strict-origin');
  3633. /**
  3634. * HTTP Referrer URL.
  3635. */
  3636. url: string;
  3637. }
  3638. interface Remote extends MainInterface {
  3639. // Docs: http://electron.atom.io/docs/api/remote
  3640. getCurrentWebContents(): WebContents;
  3641. /**
  3642. * Note: Do not use removeAllListeners on BrowserWindow. Use of this can remove all
  3643. * blur listeners, disable click events on touch bar buttons, and other unintended
  3644. * consequences.
  3645. */
  3646. getCurrentWindow(): BrowserWindow;
  3647. getGlobal(name: string): any;
  3648. /**
  3649. * e.g.
  3650. */
  3651. require(module: string): any;
  3652. /**
  3653. * The process object in the main process. This is the same as
  3654. * remote.getGlobal('process') but is cached.
  3655. */
  3656. process?: any;
  3657. }
  3658. interface RemoveClientCertificate {
  3659. // Docs: http://electron.atom.io/docs/api/structures/remove-client-certificate
  3660. /**
  3661. * Origin of the server whose associated client certificate must be removed from
  3662. * the cache.
  3663. */
  3664. origin: string;
  3665. /**
  3666. * clientCertificate.
  3667. */
  3668. type: string;
  3669. }
  3670. interface RemovePassword {
  3671. // Docs: http://electron.atom.io/docs/api/structures/remove-password
  3672. /**
  3673. * When provided, the authentication info related to the origin will only be
  3674. * removed otherwise the entire cache will be cleared.
  3675. */
  3676. origin?: string;
  3677. /**
  3678. * Credentials of the authentication. Must be provided if removing by origin.
  3679. */
  3680. password?: string;
  3681. /**
  3682. * Realm of the authentication. Must be provided if removing by origin.
  3683. */
  3684. realm?: string;
  3685. /**
  3686. * Scheme of the authentication. Can be basic, digest, ntlm, negotiate. Must be
  3687. * provided if removing by origin.
  3688. */
  3689. scheme?: ('basic' | 'digest' | 'ntlm' | 'negotiate');
  3690. /**
  3691. * password.
  3692. */
  3693. type: string;
  3694. /**
  3695. * Credentials of the authentication. Must be provided if removing by origin.
  3696. */
  3697. username?: string;
  3698. }
  3699. interface Screen extends EventEmitter {
  3700. // Docs: http://electron.atom.io/docs/api/screen
  3701. /**
  3702. * Emitted when newDisplay has been added.
  3703. */
  3704. on(event: 'display-added', listener: (event: Event,
  3705. newDisplay: Display) => void): this;
  3706. once(event: 'display-added', listener: (event: Event,
  3707. newDisplay: Display) => void): this;
  3708. addListener(event: 'display-added', listener: (event: Event,
  3709. newDisplay: Display) => void): this;
  3710. removeListener(event: 'display-added', listener: (event: Event,
  3711. newDisplay: Display) => void): this;
  3712. /**
  3713. * Emitted when one or more metrics change in a display. The changedMetrics is an
  3714. * array of strings that describe the changes. Possible changes are bounds,
  3715. * workArea, scaleFactor and rotation.
  3716. */
  3717. on(event: 'display-metrics-changed', listener: (event: Event,
  3718. display: Display,
  3719. changedMetrics: string[]) => void): this;
  3720. once(event: 'display-metrics-changed', listener: (event: Event,
  3721. display: Display,
  3722. changedMetrics: string[]) => void): this;
  3723. addListener(event: 'display-metrics-changed', listener: (event: Event,
  3724. display: Display,
  3725. changedMetrics: string[]) => void): this;
  3726. removeListener(event: 'display-metrics-changed', listener: (event: Event,
  3727. display: Display,
  3728. changedMetrics: string[]) => void): this;
  3729. /**
  3730. * Emitted when oldDisplay has been removed.
  3731. */
  3732. on(event: 'display-removed', listener: (event: Event,
  3733. oldDisplay: Display) => void): this;
  3734. once(event: 'display-removed', listener: (event: Event,
  3735. oldDisplay: Display) => void): this;
  3736. addListener(event: 'display-removed', listener: (event: Event,
  3737. oldDisplay: Display) => void): this;
  3738. removeListener(event: 'display-removed', listener: (event: Event,
  3739. oldDisplay: Display) => void): this;
  3740. /**
  3741. * Converts a screen DIP point to a screen physical point. The DPI scale is
  3742. * performed relative to the display containing the DIP point.
  3743. */
  3744. dipToScreenPoint(point: Point): Point;
  3745. /**
  3746. * Converts a screen DIP rect to a screen physical rect. The DPI scale is performed
  3747. * relative to the display nearest to window. If window is null, scaling will be
  3748. * performed to the display nearest to rect.
  3749. */
  3750. dipToScreenRect(window: BrowserWindow | null, rect: Rectangle): Rectangle;
  3751. getAllDisplays(): Display[];
  3752. /**
  3753. * The current absolute position of the mouse pointer.
  3754. */
  3755. getCursorScreenPoint(): Point;
  3756. getDisplayMatching(rect: Rectangle): Display;
  3757. getDisplayNearestPoint(point: Point): Display;
  3758. getPrimaryDisplay(): Display;
  3759. /**
  3760. * Converts a screen physical point to a screen DIP point. The DPI scale is
  3761. * performed relative to the display containing the physical point.
  3762. */
  3763. screenToDipPoint(point: Point): Point;
  3764. /**
  3765. * Converts a screen physical rect to a screen DIP rect. The DPI scale is performed
  3766. * relative to the display nearest to window. If window is null, scaling will be
  3767. * performed to the display nearest to rect.
  3768. */
  3769. screenToDipRect(window: BrowserWindow | null, rect: Rectangle): Rectangle;
  3770. }
  3771. interface ScrubberItem {
  3772. // Docs: http://electron.atom.io/docs/api/structures/scrubber-item
  3773. /**
  3774. * The image to appear in this item
  3775. */
  3776. icon?: NativeImage;
  3777. /**
  3778. * The text to appear in this item
  3779. */
  3780. label?: string;
  3781. }
  3782. interface SegmentedControlSegment {
  3783. // Docs: http://electron.atom.io/docs/api/structures/segmented-control-segment
  3784. /**
  3785. * Whether this segment is selectable. Default: true
  3786. */
  3787. enabled?: boolean;
  3788. /**
  3789. * The image to appear in this segment
  3790. */
  3791. icon?: NativeImage;
  3792. /**
  3793. * The text to appear in this segment
  3794. */
  3795. label?: string;
  3796. }
  3797. class Session extends EventEmitter {
  3798. // Docs: http://electron.atom.io/docs/api/session
  3799. /**
  3800. * If partition starts with persist:, the page will use a persistent session
  3801. * available to all pages in the app with the same partition. if there is no
  3802. * persist: prefix, the page will use an in-memory session. If the partition is
  3803. * empty then default session of the app will be returned. To create a Session with
  3804. * options, you have to ensure the Session with the partition has never been used
  3805. * before. There is no way to change the options of an existing Session object.
  3806. */
  3807. static fromPartition(partition: string, options?: FromPartitionOptions): Session;
  3808. /**
  3809. * A Session object, the default session object of the app.
  3810. */
  3811. static defaultSession?: Session;
  3812. /**
  3813. * Emitted when Electron is about to download item in webContents. Calling
  3814. * event.preventDefault() will cancel the download and item will not be available
  3815. * from next tick of the process.
  3816. */
  3817. on(event: 'will-download', listener: (event: Event,
  3818. item: DownloadItem,
  3819. webContents: WebContents) => void): this;
  3820. once(event: 'will-download', listener: (event: Event,
  3821. item: DownloadItem,
  3822. webContents: WebContents) => void): this;
  3823. addListener(event: 'will-download', listener: (event: Event,
  3824. item: DownloadItem,
  3825. webContents: WebContents) => void): this;
  3826. removeListener(event: 'will-download', listener: (event: Event,
  3827. item: DownloadItem,
  3828. webContents: WebContents) => void): this;
  3829. /**
  3830. * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate
  3831. * authentication.
  3832. */
  3833. allowNTLMCredentialsForDomains(domains: string): void;
  3834. /**
  3835. * Clears the session’s HTTP authentication cache.
  3836. */
  3837. clearAuthCache(options: RemovePassword | RemoveClientCertificate, callback?: Function): void;
  3838. /**
  3839. * Clears the session’s HTTP cache.
  3840. */
  3841. clearCache(callback: Function): void;
  3842. /**
  3843. * Clears the host resolver cache.
  3844. */
  3845. clearHostResolverCache(callback?: Function): void;
  3846. /**
  3847. * Clears the data of web storages.
  3848. */
  3849. clearStorageData(options?: ClearStorageDataOptions, callback?: Function): void;
  3850. /**
  3851. * Allows resuming cancelled or interrupted downloads from previous Session. The
  3852. * API will generate a DownloadItem that can be accessed with the will-download
  3853. * event. The DownloadItem will not have any WebContents associated with it and the
  3854. * initial state will be interrupted. The download will start only when the resume
  3855. * API is called on the DownloadItem.
  3856. */
  3857. createInterruptedDownload(options: CreateInterruptedDownloadOptions): void;
  3858. /**
  3859. * Disables any network emulation already active for the session. Resets to the
  3860. * original network configuration.
  3861. */
  3862. disableNetworkEmulation(): void;
  3863. /**
  3864. * Emulates network with the given configuration for the session.
  3865. */
  3866. enableNetworkEmulation(options: EnableNetworkEmulationOptions): void;
  3867. /**
  3868. * Writes any unwritten DOMStorage data to disk.
  3869. */
  3870. flushStorageData(): void;
  3871. getBlobData(identifier: string, callback: (result: Buffer) => void): void;
  3872. /**
  3873. * Callback is invoked with the session's current cache size.
  3874. */
  3875. getCacheSize(callback: (size: number) => void): void;
  3876. getPreloads(): string[];
  3877. getUserAgent(): string;
  3878. /**
  3879. * Resolves the proxy information for url. The callback will be called with
  3880. * callback(proxy) when the request is performed.
  3881. */
  3882. resolveProxy(url: string, callback: (proxy: string) => void): void;
  3883. /**
  3884. * Sets the certificate verify proc for session, the proc will be called with
  3885. * proc(request, callback) whenever a server certificate verification is requested.
  3886. * Calling callback(0) accepts the certificate, calling callback(-2) rejects it.
  3887. * Calling setCertificateVerifyProc(null) will revert back to default certificate
  3888. * verify proc.
  3889. */
  3890. setCertificateVerifyProc(proc: (request: CertificateVerifyProcRequest, callback: (verificationResult: number) => void) => void): void;
  3891. /**
  3892. * Sets download saving directory. By default, the download directory will be the
  3893. * Downloads under the respective app folder.
  3894. */
  3895. setDownloadPath(path: string): void;
  3896. /**
  3897. * Sets the handler which can be used to respond to permission requests for the
  3898. * session. Calling callback(true) will allow the permission and callback(false)
  3899. * will reject it. To clear the handler, call setPermissionRequestHandler(null).
  3900. */
  3901. setPermissionRequestHandler(handler: (webContents: WebContents, permission: string, callback: (permissionGranted: boolean) => void, details: PermissionRequestHandlerDetails) => void | null): void;
  3902. /**
  3903. * Adds scripts that will be executed on ALL web contents that are associated with
  3904. * this session just before normal preload scripts run.
  3905. */
  3906. setPreloads(preloads: string[]): void;
  3907. /**
  3908. * Sets the proxy settings. When pacScript and proxyRules are provided together,
  3909. * the proxyRules option is ignored and pacScript configuration is applied. The
  3910. * proxyRules has to follow the rules below: For example: The proxyBypassRules is a
  3911. * comma separated list of rules described below:
  3912. */
  3913. setProxy(config: Config, callback: Function): void;
  3914. /**
  3915. * Overrides the userAgent and acceptLanguages for this session. The
  3916. * acceptLanguages must a comma separated ordered list of language codes, for
  3917. * example "en-US,fr,de,ko,zh-CN,ja". This doesn't affect existing WebContents, and
  3918. * each WebContents can use webContents.setUserAgent to override the session-wide
  3919. * user agent.
  3920. */
  3921. setUserAgent(userAgent: string, acceptLanguages?: string): void;
  3922. cookies: Cookies;
  3923. protocol: Protocol;
  3924. webRequest: WebRequest;
  3925. }
  3926. interface Shell {
  3927. // Docs: http://electron.atom.io/docs/api/shell
  3928. /**
  3929. * Play the beep sound.
  3930. */
  3931. beep(): void;
  3932. /**
  3933. * Move the given file to trash and returns a boolean status for the operation.
  3934. */
  3935. moveItemToTrash(fullPath: string): boolean;
  3936. /**
  3937. * Open the given external protocol URL in the desktop's default manner. (For
  3938. * example, mailto: URLs in the user's default mail agent).
  3939. */
  3940. openExternal(url: string, options?: OpenExternalOptions, callback?: (error: Error) => void): boolean;
  3941. /**
  3942. * Open the given file in the desktop's default manner.
  3943. */
  3944. openItem(fullPath: string): boolean;
  3945. /**
  3946. * Resolves the shortcut link at shortcutPath. An exception will be thrown when any
  3947. * error happens.
  3948. */
  3949. readShortcutLink(shortcutPath: string): ShortcutDetails;
  3950. /**
  3951. * Show the given file in a file manager. If possible, select the file.
  3952. */
  3953. showItemInFolder(fullPath: string): boolean;
  3954. /**
  3955. * Creates or updates a shortcut link at shortcutPath.
  3956. */
  3957. writeShortcutLink(shortcutPath: string, operation: 'create' | 'update' | 'replace', options: ShortcutDetails): boolean;
  3958. /**
  3959. * Creates or updates a shortcut link at shortcutPath.
  3960. */
  3961. writeShortcutLink(shortcutPath: string, options: ShortcutDetails): boolean;
  3962. }
  3963. interface ShortcutDetails {
  3964. // Docs: http://electron.atom.io/docs/api/structures/shortcut-details
  3965. /**
  3966. * The Application User Model ID. Default is empty.
  3967. */
  3968. appUserModelId?: string;
  3969. /**
  3970. * The arguments to be applied to target when launching from this shortcut. Default
  3971. * is empty.
  3972. */
  3973. args?: string;
  3974. /**
  3975. * The working directory. Default is empty.
  3976. */
  3977. cwd?: string;
  3978. /**
  3979. * The description of the shortcut. Default is empty.
  3980. */
  3981. description?: string;
  3982. /**
  3983. * The path to the icon, can be a DLL or EXE. icon and iconIndex have to be set
  3984. * together. Default is empty, which uses the target's icon.
  3985. */
  3986. icon?: string;
  3987. /**
  3988. * The resource ID of icon when icon is a DLL or EXE. Default is 0.
  3989. */
  3990. iconIndex?: number;
  3991. /**
  3992. * The target to launch from this shortcut.
  3993. */
  3994. target: string;
  3995. }
  3996. interface Size {
  3997. // Docs: http://electron.atom.io/docs/api/structures/size
  3998. height: number;
  3999. width: number;
  4000. }
  4001. interface StreamProtocolResponse {
  4002. // Docs: http://electron.atom.io/docs/api/structures/stream-protocol-response
  4003. /**
  4004. * A Node.js readable stream representing the response body
  4005. */
  4006. data: ReadableStream;
  4007. /**
  4008. * An object containing the response headers
  4009. */
  4010. headers: Headers;
  4011. /**
  4012. * The HTTP response code
  4013. */
  4014. statusCode: number;
  4015. }
  4016. interface SystemPreferences extends EventEmitter {
  4017. // Docs: http://electron.atom.io/docs/api/system-preferences
  4018. on(event: 'accent-color-changed', listener: (event: Event,
  4019. /**
  4020. * The new RGBA color the user assigned to be their system accent color.
  4021. */
  4022. newColor: string) => void): this;
  4023. once(event: 'accent-color-changed', listener: (event: Event,
  4024. /**
  4025. * The new RGBA color the user assigned to be their system accent color.
  4026. */
  4027. newColor: string) => void): this;
  4028. addListener(event: 'accent-color-changed', listener: (event: Event,
  4029. /**
  4030. * The new RGBA color the user assigned to be their system accent color.
  4031. */
  4032. newColor: string) => void): this;
  4033. removeListener(event: 'accent-color-changed', listener: (event: Event,
  4034. /**
  4035. * The new RGBA color the user assigned to be their system accent color.
  4036. */
  4037. newColor: string) => void): this;
  4038. on(event: 'color-changed', listener: (event: Event) => void): this;
  4039. once(event: 'color-changed', listener: (event: Event) => void): this;
  4040. addListener(event: 'color-changed', listener: (event: Event) => void): this;
  4041. removeListener(event: 'color-changed', listener: (event: Event) => void): this;
  4042. on(event: 'inverted-color-scheme-changed', listener: (event: Event,
  4043. /**
  4044. * `true` if an inverted color scheme, such as a high contrast theme, is being
  4045. * used, `false` otherwise.
  4046. */
  4047. invertedColorScheme: boolean) => void): this;
  4048. once(event: 'inverted-color-scheme-changed', listener: (event: Event,
  4049. /**
  4050. * `true` if an inverted color scheme, such as a high contrast theme, is being
  4051. * used, `false` otherwise.
  4052. */
  4053. invertedColorScheme: boolean) => void): this;
  4054. addListener(event: 'inverted-color-scheme-changed', listener: (event: Event,
  4055. /**
  4056. * `true` if an inverted color scheme, such as a high contrast theme, is being
  4057. * used, `false` otherwise.
  4058. */
  4059. invertedColorScheme: boolean) => void): this;
  4060. removeListener(event: 'inverted-color-scheme-changed', listener: (event: Event,
  4061. /**
  4062. * `true` if an inverted color scheme, such as a high contrast theme, is being
  4063. * used, `false` otherwise.
  4064. */
  4065. invertedColorScheme: boolean) => void): this;
  4066. getAccentColor(): string;
  4067. getColor(color: '3d-dark-shadow' | '3d-face' | '3d-highlight' | '3d-light' | '3d-shadow' | 'active-border' | 'active-caption' | 'active-caption-gradient' | 'app-workspace' | 'button-text' | 'caption-text' | 'desktop' | 'disabled-text' | 'highlight' | 'highlight-text' | 'hotlight' | 'inactive-border' | 'inactive-caption' | 'inactive-caption-gradient' | 'inactive-caption-text' | 'info-background' | 'info-text' | 'menu' | 'menu-highlight' | 'menubar' | 'menu-text' | 'scrollbar' | 'window' | 'window-frame' | 'window-text'): string;
  4068. /**
  4069. * Some popular key and types are:
  4070. */
  4071. getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url' | 'array' | 'dictionary'): any;
  4072. /**
  4073. * An example of using it to determine if you should create a transparent window or
  4074. * not (transparent windows won't work correctly when DWM composition is disabled):
  4075. */
  4076. isAeroGlassEnabled(): boolean;
  4077. isDarkMode(): boolean;
  4078. isInvertedColorScheme(): boolean;
  4079. isSwipeTrackingFromScrollEventsEnabled(): boolean;
  4080. /**
  4081. * Posts event as native notifications of macOS. The userInfo is an Object that
  4082. * contains the user information dictionary sent along with the notification.
  4083. */
  4084. postLocalNotification(event: string, userInfo: any): void;
  4085. /**
  4086. * Posts event as native notifications of macOS. The userInfo is an Object that
  4087. * contains the user information dictionary sent along with the notification.
  4088. */
  4089. postNotification(event: string, userInfo: any): void;
  4090. /**
  4091. * Posts event as native notifications of macOS. The userInfo is an Object that
  4092. * contains the user information dictionary sent along with the notification.
  4093. */
  4094. postWorkspaceNotification(event: string, userInfo: any): void;
  4095. /**
  4096. * Add the specified defaults to your application's NSUserDefaults.
  4097. */
  4098. registerDefaults(defaults: any): void;
  4099. /**
  4100. * Removes the key in NSUserDefaults. This can be used to restore the default or
  4101. * global value of a key previously set with setUserDefault.
  4102. */
  4103. removeUserDefault(key: string): void;
  4104. /**
  4105. * Set the value of key in NSUserDefaults. Note that type should match actual type
  4106. * of value. An exception is thrown if they don't. Some popular key and types are:
  4107. */
  4108. setUserDefault(key: string, type: string, value: string): void;
  4109. /**
  4110. * Same as subscribeNotification, but uses NSNotificationCenter for local defaults.
  4111. * This is necessary for events such as NSUserDefaultsDidChangeNotification.
  4112. */
  4113. subscribeLocalNotification(event: string, callback: (event: string, userInfo: any) => void): void;
  4114. /**
  4115. * Subscribes to native notifications of macOS, callback will be called with
  4116. * callback(event, userInfo) when the corresponding event happens. The userInfo is
  4117. * an Object that contains the user information dictionary sent along with the
  4118. * notification. The id of the subscriber is returned, which can be used to
  4119. * unsubscribe the event. Under the hood this API subscribes to
  4120. * NSDistributedNotificationCenter, example values of event are:
  4121. */
  4122. subscribeNotification(event: string, callback: (event: string, userInfo: any) => void): void;
  4123. /**
  4124. * Same as subscribeNotification, but uses
  4125. * NSWorkspace.sharedWorkspace.notificationCenter. This is necessary for events
  4126. * such as NSWorkspaceDidActivateApplicationNotification.
  4127. */
  4128. subscribeWorkspaceNotification(event: string, callback: (event: string, userInfo: any) => void): void;
  4129. /**
  4130. * Same as unsubscribeNotification, but removes the subscriber from
  4131. * NSNotificationCenter.
  4132. */
  4133. unsubscribeLocalNotification(id: number): void;
  4134. /**
  4135. * Removes the subscriber with id.
  4136. */
  4137. unsubscribeNotification(id: number): void;
  4138. /**
  4139. * Same as unsubscribeNotification, but removes the subscriber from
  4140. * NSWorkspace.sharedWorkspace.notificationCenter.
  4141. */
  4142. unsubscribeWorkspaceNotification(id: number): void;
  4143. }
  4144. interface Task {
  4145. // Docs: http://electron.atom.io/docs/api/structures/task
  4146. /**
  4147. * The command line arguments when program is executed.
  4148. */
  4149. arguments: string;
  4150. /**
  4151. * Description of this task.
  4152. */
  4153. description: string;
  4154. /**
  4155. * The icon index in the icon file. If an icon file consists of two or more icons,
  4156. * set this value to identify the icon. If an icon file consists of one icon, this
  4157. * value is 0.
  4158. */
  4159. iconIndex: number;
  4160. /**
  4161. * The absolute path to an icon to be displayed in a JumpList, which can be an
  4162. * arbitrary resource file that contains an icon. You can usually specify
  4163. * process.execPath to show the icon of the program.
  4164. */
  4165. iconPath: string;
  4166. /**
  4167. * Path of the program to execute, usually you should specify process.execPath
  4168. * which opens the current program.
  4169. */
  4170. program: string;
  4171. /**
  4172. * The string to be displayed in a JumpList.
  4173. */
  4174. title: string;
  4175. }
  4176. interface ThumbarButton {
  4177. // Docs: http://electron.atom.io/docs/api/structures/thumbar-button
  4178. click: Function;
  4179. /**
  4180. * Control specific states and behaviors of the button. By default, it is
  4181. * ['enabled'].
  4182. */
  4183. flags?: string[];
  4184. /**
  4185. * The icon showing in thumbnail toolbar.
  4186. */
  4187. icon: NativeImage;
  4188. /**
  4189. * The text of the button's tooltip.
  4190. */
  4191. tooltip?: string;
  4192. }
  4193. class TouchBarButton extends EventEmitter {
  4194. // Docs: http://electron.atom.io/docs/api/touch-bar-button
  4195. constructor(options: TouchBarButtonConstructorOptions);
  4196. backgroundColor: string;
  4197. icon: NativeImage;
  4198. label: string;
  4199. }
  4200. class TouchBarColorPicker extends EventEmitter {
  4201. // Docs: http://electron.atom.io/docs/api/touch-bar-color-picker
  4202. constructor(options: TouchBarColorPickerConstructorOptions);
  4203. availableColors: string[];
  4204. selectedColor: string;
  4205. }
  4206. class TouchBarGroup extends EventEmitter {
  4207. // Docs: http://electron.atom.io/docs/api/touch-bar-group
  4208. constructor(options: TouchBarGroupConstructorOptions);
  4209. }
  4210. class TouchBarLabel extends EventEmitter {
  4211. // Docs: http://electron.atom.io/docs/api/touch-bar-label
  4212. constructor(options: TouchBarLabelConstructorOptions);
  4213. label: string;
  4214. textColor: string;
  4215. }
  4216. class TouchBarPopover extends EventEmitter {
  4217. // Docs: http://electron.atom.io/docs/api/touch-bar-popover
  4218. constructor(options: TouchBarPopoverConstructorOptions);
  4219. icon: NativeImage;
  4220. label: string;
  4221. }
  4222. class TouchBarScrubber extends EventEmitter {
  4223. // Docs: http://electron.atom.io/docs/api/touch-bar-scrubber
  4224. constructor(options: TouchBarScrubberConstructorOptions);
  4225. continuous: boolean;
  4226. items: ScrubberItem[];
  4227. mode: string;
  4228. overlayStyle: string;
  4229. selectedStyle: string;
  4230. showArrowButtons: boolean;
  4231. }
  4232. class TouchBarSegmentedControl extends EventEmitter {
  4233. // Docs: http://electron.atom.io/docs/api/touch-bar-segmented-control
  4234. constructor(options: TouchBarSegmentedControlConstructorOptions);
  4235. segments: SegmentedControlSegment[];
  4236. segmentStyle: string;
  4237. selectedIndex: number;
  4238. }
  4239. class TouchBarSlider extends EventEmitter {
  4240. // Docs: http://electron.atom.io/docs/api/touch-bar-slider
  4241. constructor(options: TouchBarSliderConstructorOptions);
  4242. label: string;
  4243. maxValue: number;
  4244. minValue: number;
  4245. value: number;
  4246. }
  4247. class TouchBarSpacer extends EventEmitter {
  4248. // Docs: http://electron.atom.io/docs/api/touch-bar-spacer
  4249. constructor(options: TouchBarSpacerConstructorOptions);
  4250. }
  4251. class TouchBar extends EventEmitter {
  4252. // Docs: http://electron.atom.io/docs/api/touch-bar
  4253. constructor(options: TouchBarConstructorOptions);
  4254. escapeItem: (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null);
  4255. static TouchBarButton: typeof TouchBarButton;
  4256. static TouchBarColorPicker: typeof TouchBarColorPicker;
  4257. static TouchBarGroup: typeof TouchBarGroup;
  4258. static TouchBarLabel: typeof TouchBarLabel;
  4259. static TouchBarPopover: typeof TouchBarPopover;
  4260. static TouchBarScrubber: typeof TouchBarScrubber;
  4261. static TouchBarSegmentedControl: typeof TouchBarSegmentedControl;
  4262. static TouchBarSlider: typeof TouchBarSlider;
  4263. static TouchBarSpacer: typeof TouchBarSpacer;
  4264. }
  4265. interface Transaction {
  4266. // Docs: http://electron.atom.io/docs/api/structures/transaction
  4267. /**
  4268. * The error code if an error occurred while processing the transaction.
  4269. */
  4270. errorCode: number;
  4271. /**
  4272. * The error message if an error occurred while processing the transaction.
  4273. */
  4274. errorMessage: string;
  4275. /**
  4276. * The identifier of the restored transaction by the App Store.
  4277. */
  4278. originalTransactionIdentifier: string;
  4279. payment: Payment;
  4280. /**
  4281. * The date the transaction was added to the App Store’s payment queue.
  4282. */
  4283. transactionDate: string;
  4284. /**
  4285. * A string that uniquely identifies a successful payment transaction.
  4286. */
  4287. transactionIdentifier: string;
  4288. /**
  4289. * The transaction state, can be purchasing, purchased, failed, restored or
  4290. * deferred.
  4291. */
  4292. transactionState: ('purchasing' | 'purchased' | 'failed' | 'restored' | 'deferred');
  4293. }
  4294. class Tray extends EventEmitter {
  4295. // Docs: http://electron.atom.io/docs/api/tray
  4296. /**
  4297. * Emitted when the tray balloon is clicked.
  4298. */
  4299. on(event: 'balloon-click', listener: Function): this;
  4300. once(event: 'balloon-click', listener: Function): this;
  4301. addListener(event: 'balloon-click', listener: Function): this;
  4302. removeListener(event: 'balloon-click', listener: Function): this;
  4303. /**
  4304. * Emitted when the tray balloon is closed because of timeout or user manually
  4305. * closes it.
  4306. */
  4307. on(event: 'balloon-closed', listener: Function): this;
  4308. once(event: 'balloon-closed', listener: Function): this;
  4309. addListener(event: 'balloon-closed', listener: Function): this;
  4310. removeListener(event: 'balloon-closed', listener: Function): this;
  4311. /**
  4312. * Emitted when the tray balloon shows.
  4313. */
  4314. on(event: 'balloon-show', listener: Function): this;
  4315. once(event: 'balloon-show', listener: Function): this;
  4316. addListener(event: 'balloon-show', listener: Function): this;
  4317. removeListener(event: 'balloon-show', listener: Function): this;
  4318. /**
  4319. * Emitted when the tray icon is clicked.
  4320. */
  4321. on(event: 'click', listener: (event: Event,
  4322. /**
  4323. * The bounds of tray icon.
  4324. */
  4325. bounds: Rectangle,
  4326. /**
  4327. * The position of the event.
  4328. */
  4329. position: Point) => void): this;
  4330. once(event: 'click', listener: (event: Event,
  4331. /**
  4332. * The bounds of tray icon.
  4333. */
  4334. bounds: Rectangle,
  4335. /**
  4336. * The position of the event.
  4337. */
  4338. position: Point) => void): this;
  4339. addListener(event: 'click', listener: (event: Event,
  4340. /**
  4341. * The bounds of tray icon.
  4342. */
  4343. bounds: Rectangle,
  4344. /**
  4345. * The position of the event.
  4346. */
  4347. position: Point) => void): this;
  4348. removeListener(event: 'click', listener: (event: Event,
  4349. /**
  4350. * The bounds of tray icon.
  4351. */
  4352. bounds: Rectangle,
  4353. /**
  4354. * The position of the event.
  4355. */
  4356. position: Point) => void): this;
  4357. /**
  4358. * Emitted when the tray icon is double clicked.
  4359. */
  4360. on(event: 'double-click', listener: (event: Event,
  4361. /**
  4362. * The bounds of tray icon.
  4363. */
  4364. bounds: Rectangle) => void): this;
  4365. once(event: 'double-click', listener: (event: Event,
  4366. /**
  4367. * The bounds of tray icon.
  4368. */
  4369. bounds: Rectangle) => void): this;
  4370. addListener(event: 'double-click', listener: (event: Event,
  4371. /**
  4372. * The bounds of tray icon.
  4373. */
  4374. bounds: Rectangle) => void): this;
  4375. removeListener(event: 'double-click', listener: (event: Event,
  4376. /**
  4377. * The bounds of tray icon.
  4378. */
  4379. bounds: Rectangle) => void): this;
  4380. /**
  4381. * Emitted when a drag operation ends on the tray or ends at another location.
  4382. */
  4383. on(event: 'drag-end', listener: Function): this;
  4384. once(event: 'drag-end', listener: Function): this;
  4385. addListener(event: 'drag-end', listener: Function): this;
  4386. removeListener(event: 'drag-end', listener: Function): this;
  4387. /**
  4388. * Emitted when a drag operation enters the tray icon.
  4389. */
  4390. on(event: 'drag-enter', listener: Function): this;
  4391. once(event: 'drag-enter', listener: Function): this;
  4392. addListener(event: 'drag-enter', listener: Function): this;
  4393. removeListener(event: 'drag-enter', listener: Function): this;
  4394. /**
  4395. * Emitted when a drag operation exits the tray icon.
  4396. */
  4397. on(event: 'drag-leave', listener: Function): this;
  4398. once(event: 'drag-leave', listener: Function): this;
  4399. addListener(event: 'drag-leave', listener: Function): this;
  4400. removeListener(event: 'drag-leave', listener: Function): this;
  4401. /**
  4402. * Emitted when any dragged items are dropped on the tray icon.
  4403. */
  4404. on(event: 'drop', listener: Function): this;
  4405. once(event: 'drop', listener: Function): this;
  4406. addListener(event: 'drop', listener: Function): this;
  4407. removeListener(event: 'drop', listener: Function): this;
  4408. /**
  4409. * Emitted when dragged files are dropped in the tray icon.
  4410. */
  4411. on(event: 'drop-files', listener: (event: Event,
  4412. /**
  4413. * The paths of the dropped files.
  4414. */
  4415. files: string[]) => void): this;
  4416. once(event: 'drop-files', listener: (event: Event,
  4417. /**
  4418. * The paths of the dropped files.
  4419. */
  4420. files: string[]) => void): this;
  4421. addListener(event: 'drop-files', listener: (event: Event,
  4422. /**
  4423. * The paths of the dropped files.
  4424. */
  4425. files: string[]) => void): this;
  4426. removeListener(event: 'drop-files', listener: (event: Event,
  4427. /**
  4428. * The paths of the dropped files.
  4429. */
  4430. files: string[]) => void): this;
  4431. /**
  4432. * Emitted when dragged text is dropped in the tray icon.
  4433. */
  4434. on(event: 'drop-text', listener: (event: Event,
  4435. /**
  4436. * the dropped text string.
  4437. */
  4438. text: string) => void): this;
  4439. once(event: 'drop-text', listener: (event: Event,
  4440. /**
  4441. * the dropped text string.
  4442. */
  4443. text: string) => void): this;
  4444. addListener(event: 'drop-text', listener: (event: Event,
  4445. /**
  4446. * the dropped text string.
  4447. */
  4448. text: string) => void): this;
  4449. removeListener(event: 'drop-text', listener: (event: Event,
  4450. /**
  4451. * the dropped text string.
  4452. */
  4453. text: string) => void): this;
  4454. /**
  4455. * Emitted when the mouse enters the tray icon.
  4456. */
  4457. on(event: 'mouse-enter', listener: (event: Event,
  4458. /**
  4459. * The position of the event.
  4460. */
  4461. position: Point) => void): this;
  4462. once(event: 'mouse-enter', listener: (event: Event,
  4463. /**
  4464. * The position of the event.
  4465. */
  4466. position: Point) => void): this;
  4467. addListener(event: 'mouse-enter', listener: (event: Event,
  4468. /**
  4469. * The position of the event.
  4470. */
  4471. position: Point) => void): this;
  4472. removeListener(event: 'mouse-enter', listener: (event: Event,
  4473. /**
  4474. * The position of the event.
  4475. */
  4476. position: Point) => void): this;
  4477. /**
  4478. * Emitted when the mouse exits the tray icon.
  4479. */
  4480. on(event: 'mouse-leave', listener: (event: Event,
  4481. /**
  4482. * The position of the event.
  4483. */
  4484. position: Point) => void): this;
  4485. once(event: 'mouse-leave', listener: (event: Event,
  4486. /**
  4487. * The position of the event.
  4488. */
  4489. position: Point) => void): this;
  4490. addListener(event: 'mouse-leave', listener: (event: Event,
  4491. /**
  4492. * The position of the event.
  4493. */
  4494. position: Point) => void): this;
  4495. removeListener(event: 'mouse-leave', listener: (event: Event,
  4496. /**
  4497. * The position of the event.
  4498. */
  4499. position: Point) => void): this;
  4500. /**
  4501. * Emitted when the mouse moves in the tray icon.
  4502. */
  4503. on(event: 'mouse-move', listener: (event: Event,
  4504. /**
  4505. * The position of the event.
  4506. */
  4507. position: Point) => void): this;
  4508. once(event: 'mouse-move', listener: (event: Event,
  4509. /**
  4510. * The position of the event.
  4511. */
  4512. position: Point) => void): this;
  4513. addListener(event: 'mouse-move', listener: (event: Event,
  4514. /**
  4515. * The position of the event.
  4516. */
  4517. position: Point) => void): this;
  4518. removeListener(event: 'mouse-move', listener: (event: Event,
  4519. /**
  4520. * The position of the event.
  4521. */
  4522. position: Point) => void): this;
  4523. /**
  4524. * Emitted when the tray icon is right clicked.
  4525. */
  4526. on(event: 'right-click', listener: (event: Event,
  4527. /**
  4528. * The bounds of tray icon.
  4529. */
  4530. bounds: Rectangle) => void): this;
  4531. once(event: 'right-click', listener: (event: Event,
  4532. /**
  4533. * The bounds of tray icon.
  4534. */
  4535. bounds: Rectangle) => void): this;
  4536. addListener(event: 'right-click', listener: (event: Event,
  4537. /**
  4538. * The bounds of tray icon.
  4539. */
  4540. bounds: Rectangle) => void): this;
  4541. removeListener(event: 'right-click', listener: (event: Event,
  4542. /**
  4543. * The bounds of tray icon.
  4544. */
  4545. bounds: Rectangle) => void): this;
  4546. constructor(image: NativeImage | string);
  4547. /**
  4548. * Destroys the tray icon immediately.
  4549. */
  4550. destroy(): void;
  4551. /**
  4552. * Displays a tray balloon.
  4553. */
  4554. displayBalloon(options: DisplayBalloonOptions): void;
  4555. /**
  4556. * The bounds of this tray icon as Object.
  4557. */
  4558. getBounds(): Rectangle;
  4559. getIgnoreDoubleClickEvents(): boolean;
  4560. isDestroyed(): boolean;
  4561. /**
  4562. * Pops up the context menu of the tray icon. When menu is passed, the menu will be
  4563. * shown instead of the tray icon's context menu. The position is only available on
  4564. * Windows, and it is (0, 0) by default.
  4565. */
  4566. popUpContextMenu(menu?: Menu, position?: Point): void;
  4567. /**
  4568. * Sets the context menu for this icon.
  4569. */
  4570. setContextMenu(menu: Menu | null): void;
  4571. /**
  4572. * Sets when the tray's icon background becomes highlighted (in blue). Note: You
  4573. * can use highlightMode with a BrowserWindow by toggling between 'never' and
  4574. * 'always' modes when the window visibility changes.
  4575. */
  4576. setHighlightMode(mode: 'selection' | 'always' | 'never'): void;
  4577. /**
  4578. * Sets the option to ignore double click events. Ignoring these events allows you
  4579. * to detect every individual click of the tray icon. This value is set to false by
  4580. * default.
  4581. */
  4582. setIgnoreDoubleClickEvents(ignore: boolean): void;
  4583. /**
  4584. * Sets the image associated with this tray icon.
  4585. */
  4586. setImage(image: NativeImage | string): void;
  4587. /**
  4588. * Sets the image associated with this tray icon when pressed on macOS.
  4589. */
  4590. setPressedImage(image: NativeImage | string): void;
  4591. /**
  4592. * Sets the title displayed aside of the tray icon in the status bar (Support ANSI
  4593. * colors).
  4594. */
  4595. setTitle(title: string): void;
  4596. /**
  4597. * Sets the hover text for this tray icon.
  4598. */
  4599. setToolTip(toolTip: string): void;
  4600. }
  4601. interface UploadBlob {
  4602. // Docs: http://electron.atom.io/docs/api/structures/upload-blob
  4603. /**
  4604. * UUID of blob data to upload.
  4605. */
  4606. blobUUID: string;
  4607. /**
  4608. * blob.
  4609. */
  4610. type: string;
  4611. }
  4612. interface UploadData {
  4613. // Docs: http://electron.atom.io/docs/api/structures/upload-data
  4614. /**
  4615. * UUID of blob data. Use method to retrieve the data.
  4616. */
  4617. blobUUID: string;
  4618. /**
  4619. * Content being sent.
  4620. */
  4621. bytes: Buffer;
  4622. /**
  4623. * Path of file being uploaded.
  4624. */
  4625. file: string;
  4626. }
  4627. interface UploadFile {
  4628. // Docs: http://electron.atom.io/docs/api/structures/upload-file
  4629. /**
  4630. * Path of file to be uploaded.
  4631. */
  4632. filePath: string;
  4633. /**
  4634. * Number of bytes to read from offset. Defaults to 0.
  4635. */
  4636. length: number;
  4637. /**
  4638. * Last Modification time in number of seconds since the UNIX epoch.
  4639. */
  4640. modificationTime: number;
  4641. /**
  4642. * Defaults to 0.
  4643. */
  4644. offset: number;
  4645. /**
  4646. * file.
  4647. */
  4648. type: string;
  4649. }
  4650. interface UploadRawData {
  4651. // Docs: http://electron.atom.io/docs/api/structures/upload-raw-data
  4652. /**
  4653. * Data to be uploaded.
  4654. */
  4655. bytes: Buffer;
  4656. /**
  4657. * rawData.
  4658. */
  4659. type: string;
  4660. }
  4661. class WebContents extends EventEmitter {
  4662. // Docs: http://electron.atom.io/docs/api/web-contents
  4663. static fromId(id: number): WebContents;
  4664. static getAllWebContents(): WebContents[];
  4665. static getFocusedWebContents(): WebContents;
  4666. /**
  4667. * Emitted before dispatching the keydown and keyup events in the page. Calling
  4668. * event.preventDefault will prevent the page keydown/keyup events and the menu
  4669. * shortcuts. To only prevent the menu shortcuts, use setIgnoreMenuShortcuts:
  4670. */
  4671. on(event: 'before-input-event', listener: (event: Event,
  4672. /**
  4673. * Input properties.
  4674. */
  4675. input: Input) => void): this;
  4676. once(event: 'before-input-event', listener: (event: Event,
  4677. /**
  4678. * Input properties.
  4679. */
  4680. input: Input) => void): this;
  4681. addListener(event: 'before-input-event', listener: (event: Event,
  4682. /**
  4683. * Input properties.
  4684. */
  4685. input: Input) => void): this;
  4686. removeListener(event: 'before-input-event', listener: (event: Event,
  4687. /**
  4688. * Input properties.
  4689. */
  4690. input: Input) => void): this;
  4691. /**
  4692. * Emitted when failed to verify the certificate for url. The usage is the same
  4693. * with the certificate-error event of app.
  4694. */
  4695. on(event: 'certificate-error', listener: (event: Event,
  4696. url: string,
  4697. /**
  4698. * The error code.
  4699. */
  4700. error: string,
  4701. certificate: Certificate,
  4702. callback: (isTrusted: boolean) => void) => void): this;
  4703. once(event: 'certificate-error', listener: (event: Event,
  4704. url: string,
  4705. /**
  4706. * The error code.
  4707. */
  4708. error: string,
  4709. certificate: Certificate,
  4710. callback: (isTrusted: boolean) => void) => void): this;
  4711. addListener(event: 'certificate-error', listener: (event: Event,
  4712. url: string,
  4713. /**
  4714. * The error code.
  4715. */
  4716. error: string,
  4717. certificate: Certificate,
  4718. callback: (isTrusted: boolean) => void) => void): this;
  4719. removeListener(event: 'certificate-error', listener: (event: Event,
  4720. url: string,
  4721. /**
  4722. * The error code.
  4723. */
  4724. error: string,
  4725. certificate: Certificate,
  4726. callback: (isTrusted: boolean) => void) => void): this;
  4727. /**
  4728. * Emitted when the associated window logs a console message. Will not be emitted
  4729. * for windows with offscreen rendering enabled.
  4730. */
  4731. on(event: 'console-message', listener: (event: Event,
  4732. level: number,
  4733. message: string,
  4734. line: number,
  4735. sourceId: string) => void): this;
  4736. once(event: 'console-message', listener: (event: Event,
  4737. level: number,
  4738. message: string,
  4739. line: number,
  4740. sourceId: string) => void): this;
  4741. addListener(event: 'console-message', listener: (event: Event,
  4742. level: number,
  4743. message: string,
  4744. line: number,
  4745. sourceId: string) => void): this;
  4746. removeListener(event: 'console-message', listener: (event: Event,
  4747. level: number,
  4748. message: string,
  4749. line: number,
  4750. sourceId: string) => void): this;
  4751. /**
  4752. * Emitted when there is a new context menu that needs to be handled.
  4753. */
  4754. on(event: 'context-menu', listener: (event: Event,
  4755. params: ContextMenuParams) => void): this;
  4756. once(event: 'context-menu', listener: (event: Event,
  4757. params: ContextMenuParams) => void): this;
  4758. addListener(event: 'context-menu', listener: (event: Event,
  4759. params: ContextMenuParams) => void): this;
  4760. removeListener(event: 'context-menu', listener: (event: Event,
  4761. params: ContextMenuParams) => void): this;
  4762. /**
  4763. * Emitted when the renderer process crashes or is killed.
  4764. */
  4765. on(event: 'crashed', listener: (event: Event,
  4766. killed: boolean) => void): this;
  4767. once(event: 'crashed', listener: (event: Event,
  4768. killed: boolean) => void): this;
  4769. addListener(event: 'crashed', listener: (event: Event,
  4770. killed: boolean) => void): this;
  4771. removeListener(event: 'crashed', listener: (event: Event,
  4772. killed: boolean) => void): this;
  4773. /**
  4774. * Emitted when the cursor's type changes. The type parameter can be default,
  4775. * crosshair, pointer, text, wait, help, e-resize, n-resize, ne-resize, nw-resize,
  4776. * s-resize, se-resize, sw-resize, w-resize, ns-resize, ew-resize, nesw-resize,
  4777. * nwse-resize, col-resize, row-resize, m-panning, e-panning, n-panning,
  4778. * ne-panning, nw-panning, s-panning, se-panning, sw-panning, w-panning, move,
  4779. * vertical-text, cell, context-menu, alias, progress, nodrop, copy, none,
  4780. * not-allowed, zoom-in, zoom-out, grab, grabbing or custom. If the type parameter
  4781. * is custom, the image parameter will hold the custom cursor image in a
  4782. * NativeImage, and scale, size and hotspot will hold additional information about
  4783. * the custom cursor.
  4784. */
  4785. on(event: 'cursor-changed', listener: (event: Event,
  4786. type: string,
  4787. image?: NativeImage,
  4788. /**
  4789. * scaling factor for the custom cursor.
  4790. */
  4791. scale?: number,
  4792. /**
  4793. * the size of the `image`.
  4794. */
  4795. size?: Size,
  4796. /**
  4797. * coordinates of the custom cursor's hotspot.
  4798. */
  4799. hotspot?: Point) => void): this;
  4800. once(event: 'cursor-changed', listener: (event: Event,
  4801. type: string,
  4802. image?: NativeImage,
  4803. /**
  4804. * scaling factor for the custom cursor.
  4805. */
  4806. scale?: number,
  4807. /**
  4808. * the size of the `image`.
  4809. */
  4810. size?: Size,
  4811. /**
  4812. * coordinates of the custom cursor's hotspot.
  4813. */
  4814. hotspot?: Point) => void): this;
  4815. addListener(event: 'cursor-changed', listener: (event: Event,
  4816. type: string,
  4817. image?: NativeImage,
  4818. /**
  4819. * scaling factor for the custom cursor.
  4820. */
  4821. scale?: number,
  4822. /**
  4823. * the size of the `image`.
  4824. */
  4825. size?: Size,
  4826. /**
  4827. * coordinates of the custom cursor's hotspot.
  4828. */
  4829. hotspot?: Point) => void): this;
  4830. removeListener(event: 'cursor-changed', listener: (event: Event,
  4831. type: string,
  4832. image?: NativeImage,
  4833. /**
  4834. * scaling factor for the custom cursor.
  4835. */
  4836. scale?: number,
  4837. /**
  4838. * the size of the `image`.
  4839. */
  4840. size?: Size,
  4841. /**
  4842. * coordinates of the custom cursor's hotspot.
  4843. */
  4844. hotspot?: Point) => void): this;
  4845. /**
  4846. * Emitted when webContents is destroyed.
  4847. */
  4848. on(event: 'destroyed', listener: Function): this;
  4849. once(event: 'destroyed', listener: Function): this;
  4850. addListener(event: 'destroyed', listener: Function): this;
  4851. removeListener(event: 'destroyed', listener: Function): this;
  4852. /**
  4853. * Emitted when DevTools is closed.
  4854. */
  4855. on(event: 'devtools-closed', listener: Function): this;
  4856. once(event: 'devtools-closed', listener: Function): this;
  4857. addListener(event: 'devtools-closed', listener: Function): this;
  4858. removeListener(event: 'devtools-closed', listener: Function): this;
  4859. /**
  4860. * Emitted when DevTools is focused / opened.
  4861. */
  4862. on(event: 'devtools-focused', listener: Function): this;
  4863. once(event: 'devtools-focused', listener: Function): this;
  4864. addListener(event: 'devtools-focused', listener: Function): this;
  4865. removeListener(event: 'devtools-focused', listener: Function): this;
  4866. /**
  4867. * Emitted when DevTools is opened.
  4868. */
  4869. on(event: 'devtools-opened', listener: Function): this;
  4870. once(event: 'devtools-opened', listener: Function): this;
  4871. addListener(event: 'devtools-opened', listener: Function): this;
  4872. removeListener(event: 'devtools-opened', listener: Function): this;
  4873. /**
  4874. * Emitted when the devtools window instructs the webContents to reload
  4875. */
  4876. on(event: 'devtools-reload-page', listener: Function): this;
  4877. once(event: 'devtools-reload-page', listener: Function): this;
  4878. addListener(event: 'devtools-reload-page', listener: Function): this;
  4879. removeListener(event: 'devtools-reload-page', listener: Function): this;
  4880. /**
  4881. * Emitted when a <webview> has been attached to this web contents.
  4882. */
  4883. on(event: 'did-attach-webview', listener: (event: Event,
  4884. /**
  4885. * The guest web contents that is used by the `<webview>`.
  4886. */
  4887. webContents: WebContents) => void): this;
  4888. once(event: 'did-attach-webview', listener: (event: Event,
  4889. /**
  4890. * The guest web contents that is used by the `<webview>`.
  4891. */
  4892. webContents: WebContents) => void): this;
  4893. addListener(event: 'did-attach-webview', listener: (event: Event,
  4894. /**
  4895. * The guest web contents that is used by the `<webview>`.
  4896. */
  4897. webContents: WebContents) => void): this;
  4898. removeListener(event: 'did-attach-webview', listener: (event: Event,
  4899. /**
  4900. * The guest web contents that is used by the `<webview>`.
  4901. */
  4902. webContents: WebContents) => void): this;
  4903. /**
  4904. * Emitted when a page's theme color changes. This is usually due to encountering a
  4905. * meta tag:
  4906. */
  4907. on(event: 'did-change-theme-color', listener: (event: Event,
  4908. /**
  4909. * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
  4910. */
  4911. color: string | null) => void): this;
  4912. once(event: 'did-change-theme-color', listener: (event: Event,
  4913. /**
  4914. * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
  4915. */
  4916. color: string | null) => void): this;
  4917. addListener(event: 'did-change-theme-color', listener: (event: Event,
  4918. /**
  4919. * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
  4920. */
  4921. color: string | null) => void): this;
  4922. removeListener(event: 'did-change-theme-color', listener: (event: Event,
  4923. /**
  4924. * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set.
  4925. */
  4926. color: string | null) => void): this;
  4927. /**
  4928. * This event is like did-finish-load but emitted when the load failed or was
  4929. * cancelled, e.g. window.stop() is invoked. The full list of error codes and their
  4930. * meaning is available here.
  4931. */
  4932. on(event: 'did-fail-load', listener: (event: Event,
  4933. errorCode: number,
  4934. errorDescription: string,
  4935. validatedURL: string,
  4936. isMainFrame: boolean,
  4937. frameProcessId: number,
  4938. frameRoutingId: number) => void): this;
  4939. once(event: 'did-fail-load', listener: (event: Event,
  4940. errorCode: number,
  4941. errorDescription: string,
  4942. validatedURL: string,
  4943. isMainFrame: boolean,
  4944. frameProcessId: number,
  4945. frameRoutingId: number) => void): this;
  4946. addListener(event: 'did-fail-load', listener: (event: Event,
  4947. errorCode: number,
  4948. errorDescription: string,
  4949. validatedURL: string,
  4950. isMainFrame: boolean,
  4951. frameProcessId: number,
  4952. frameRoutingId: number) => void): this;
  4953. removeListener(event: 'did-fail-load', listener: (event: Event,
  4954. errorCode: number,
  4955. errorDescription: string,
  4956. validatedURL: string,
  4957. isMainFrame: boolean,
  4958. frameProcessId: number,
  4959. frameRoutingId: number) => void): this;
  4960. /**
  4961. * Emitted when the navigation is done, i.e. the spinner of the tab has stopped
  4962. * spinning, and the onload event was dispatched.
  4963. */
  4964. on(event: 'did-finish-load', listener: Function): this;
  4965. once(event: 'did-finish-load', listener: Function): this;
  4966. addListener(event: 'did-finish-load', listener: Function): this;
  4967. removeListener(event: 'did-finish-load', listener: Function): this;
  4968. /**
  4969. * Emitted when a frame has done navigation.
  4970. */
  4971. on(event: 'did-frame-finish-load', listener: (event: Event,
  4972. isMainFrame: boolean,
  4973. frameProcessId: number,
  4974. frameRoutingId: number) => void): this;
  4975. once(event: 'did-frame-finish-load', listener: (event: Event,
  4976. isMainFrame: boolean,
  4977. frameProcessId: number,
  4978. frameRoutingId: number) => void): this;
  4979. addListener(event: 'did-frame-finish-load', listener: (event: Event,
  4980. isMainFrame: boolean,
  4981. frameProcessId: number,
  4982. frameRoutingId: number) => void): this;
  4983. removeListener(event: 'did-frame-finish-load', listener: (event: Event,
  4984. isMainFrame: boolean,
  4985. frameProcessId: number,
  4986. frameRoutingId: number) => void): this;
  4987. /**
  4988. * Emitted when any frame navigation is done. This event is not emitted for in-page
  4989. * navigations, such as clicking anchor links or updating the window.location.hash.
  4990. * Use did-navigate-in-page event for this purpose.
  4991. */
  4992. on(event: 'did-frame-navigate', listener: (event: Event,
  4993. url: string,
  4994. /**
  4995. * -1 for non HTTP navigations
  4996. */
  4997. httpResponseCode: number,
  4998. /**
  4999. * empty for non HTTP navigations,
  5000. */
  5001. httpStatusText: string,
  5002. isMainFrame: boolean,
  5003. frameProcessId: number,
  5004. frameRoutingId: number) => void): this;
  5005. once(event: 'did-frame-navigate', listener: (event: Event,
  5006. url: string,
  5007. /**
  5008. * -1 for non HTTP navigations
  5009. */
  5010. httpResponseCode: number,
  5011. /**
  5012. * empty for non HTTP navigations,
  5013. */
  5014. httpStatusText: string,
  5015. isMainFrame: boolean,
  5016. frameProcessId: number,
  5017. frameRoutingId: number) => void): this;
  5018. addListener(event: 'did-frame-navigate', listener: (event: Event,
  5019. url: string,
  5020. /**
  5021. * -1 for non HTTP navigations
  5022. */
  5023. httpResponseCode: number,
  5024. /**
  5025. * empty for non HTTP navigations,
  5026. */
  5027. httpStatusText: string,
  5028. isMainFrame: boolean,
  5029. frameProcessId: number,
  5030. frameRoutingId: number) => void): this;
  5031. removeListener(event: 'did-frame-navigate', listener: (event: Event,
  5032. url: string,
  5033. /**
  5034. * -1 for non HTTP navigations
  5035. */
  5036. httpResponseCode: number,
  5037. /**
  5038. * empty for non HTTP navigations,
  5039. */
  5040. httpStatusText: string,
  5041. isMainFrame: boolean,
  5042. frameProcessId: number,
  5043. frameRoutingId: number) => void): this;
  5044. /**
  5045. * Emitted when a main frame navigation is done. This event is not emitted for
  5046. * in-page navigations, such as clicking anchor links or updating the
  5047. * window.location.hash. Use did-navigate-in-page event for this purpose.
  5048. */
  5049. on(event: 'did-navigate', listener: (event: Event,
  5050. url: string,
  5051. /**
  5052. * -1 for non HTTP navigations
  5053. */
  5054. httpResponseCode: number,
  5055. /**
  5056. * empty for non HTTP navigations
  5057. */
  5058. httpStatusText: string) => void): this;
  5059. once(event: 'did-navigate', listener: (event: Event,
  5060. url: string,
  5061. /**
  5062. * -1 for non HTTP navigations
  5063. */
  5064. httpResponseCode: number,
  5065. /**
  5066. * empty for non HTTP navigations
  5067. */
  5068. httpStatusText: string) => void): this;
  5069. addListener(event: 'did-navigate', listener: (event: Event,
  5070. url: string,
  5071. /**
  5072. * -1 for non HTTP navigations
  5073. */
  5074. httpResponseCode: number,
  5075. /**
  5076. * empty for non HTTP navigations
  5077. */
  5078. httpStatusText: string) => void): this;
  5079. removeListener(event: 'did-navigate', listener: (event: Event,
  5080. url: string,
  5081. /**
  5082. * -1 for non HTTP navigations
  5083. */
  5084. httpResponseCode: number,
  5085. /**
  5086. * empty for non HTTP navigations
  5087. */
  5088. httpStatusText: string) => void): this;
  5089. /**
  5090. * Emitted when an in-page navigation happened in any frame. When in-page
  5091. * navigation happens, the page URL changes but does not cause navigation outside
  5092. * of the page. Examples of this occurring are when anchor links are clicked or
  5093. * when the DOM hashchange event is triggered.
  5094. */
  5095. on(event: 'did-navigate-in-page', listener: (event: Event,
  5096. url: string,
  5097. isMainFrame: boolean,
  5098. frameProcessId: number,
  5099. frameRoutingId: number) => void): this;
  5100. once(event: 'did-navigate-in-page', listener: (event: Event,
  5101. url: string,
  5102. isMainFrame: boolean,
  5103. frameProcessId: number,
  5104. frameRoutingId: number) => void): this;
  5105. addListener(event: 'did-navigate-in-page', listener: (event: Event,
  5106. url: string,
  5107. isMainFrame: boolean,
  5108. frameProcessId: number,
  5109. frameRoutingId: number) => void): this;
  5110. removeListener(event: 'did-navigate-in-page', listener: (event: Event,
  5111. url: string,
  5112. isMainFrame: boolean,
  5113. frameProcessId: number,
  5114. frameRoutingId: number) => void): this;
  5115. /**
  5116. * Corresponds to the points in time when the spinner of the tab started spinning.
  5117. */
  5118. on(event: 'did-start-loading', listener: Function): this;
  5119. once(event: 'did-start-loading', listener: Function): this;
  5120. addListener(event: 'did-start-loading', listener: Function): this;
  5121. removeListener(event: 'did-start-loading', listener: Function): this;
  5122. /**
  5123. * Emitted when any frame (including main) starts navigating. isInplace will be
  5124. * true for in-page navigations.
  5125. */
  5126. on(event: 'did-start-navigation', listener: (url: string,
  5127. isInPlace: boolean,
  5128. isMainFrame: boolean,
  5129. frameProcessId: number,
  5130. frameRoutingId: number) => void): this;
  5131. once(event: 'did-start-navigation', listener: (url: string,
  5132. isInPlace: boolean,
  5133. isMainFrame: boolean,
  5134. frameProcessId: number,
  5135. frameRoutingId: number) => void): this;
  5136. addListener(event: 'did-start-navigation', listener: (url: string,
  5137. isInPlace: boolean,
  5138. isMainFrame: boolean,
  5139. frameProcessId: number,
  5140. frameRoutingId: number) => void): this;
  5141. removeListener(event: 'did-start-navigation', listener: (url: string,
  5142. isInPlace: boolean,
  5143. isMainFrame: boolean,
  5144. frameProcessId: number,
  5145. frameRoutingId: number) => void): this;
  5146. /**
  5147. * Corresponds to the points in time when the spinner of the tab stopped spinning.
  5148. */
  5149. on(event: 'did-stop-loading', listener: Function): this;
  5150. once(event: 'did-stop-loading', listener: Function): this;
  5151. addListener(event: 'did-stop-loading', listener: Function): this;
  5152. removeListener(event: 'did-stop-loading', listener: Function): this;
  5153. /**
  5154. * Emitted when the document in the given frame is loaded.
  5155. */
  5156. on(event: 'dom-ready', listener: (event: Event) => void): this;
  5157. once(event: 'dom-ready', listener: (event: Event) => void): this;
  5158. addListener(event: 'dom-ready', listener: (event: Event) => void): this;
  5159. removeListener(event: 'dom-ready', listener: (event: Event) => void): this;
  5160. /**
  5161. * Emitted when a result is available for [webContents.findInPage] request.
  5162. */
  5163. on(event: 'found-in-page', listener: (event: Event,
  5164. result: Result) => void): this;
  5165. once(event: 'found-in-page', listener: (event: Event,
  5166. result: Result) => void): this;
  5167. addListener(event: 'found-in-page', listener: (event: Event,
  5168. result: Result) => void): this;
  5169. removeListener(event: 'found-in-page', listener: (event: Event,
  5170. result: Result) => void): this;
  5171. /**
  5172. * Emitted when webContents wants to do basic auth. The usage is the same with the
  5173. * login event of app.
  5174. */
  5175. on(event: 'login', listener: (event: Event,
  5176. request: Request,
  5177. authInfo: AuthInfo,
  5178. callback: (username: string, password: string) => void) => void): this;
  5179. once(event: 'login', listener: (event: Event,
  5180. request: Request,
  5181. authInfo: AuthInfo,
  5182. callback: (username: string, password: string) => void) => void): this;
  5183. addListener(event: 'login', listener: (event: Event,
  5184. request: Request,
  5185. authInfo: AuthInfo,
  5186. callback: (username: string, password: string) => void) => void): this;
  5187. removeListener(event: 'login', listener: (event: Event,
  5188. request: Request,
  5189. authInfo: AuthInfo,
  5190. callback: (username: string, password: string) => void) => void): this;
  5191. /**
  5192. * Emitted when media is paused or done playing.
  5193. */
  5194. on(event: 'media-paused', listener: Function): this;
  5195. once(event: 'media-paused', listener: Function): this;
  5196. addListener(event: 'media-paused', listener: Function): this;
  5197. removeListener(event: 'media-paused', listener: Function): this;
  5198. /**
  5199. * Emitted when media starts playing.
  5200. */
  5201. on(event: 'media-started-playing', listener: Function): this;
  5202. once(event: 'media-started-playing', listener: Function): this;
  5203. addListener(event: 'media-started-playing', listener: Function): this;
  5204. removeListener(event: 'media-started-playing', listener: Function): this;
  5205. /**
  5206. * Emitted when the page requests to open a new window for a url. It could be
  5207. * requested by window.open or an external link like <a target='_blank'>. By
  5208. * default a new BrowserWindow will be created for the url. Calling
  5209. * event.preventDefault() will prevent Electron from automatically creating a new
  5210. * BrowserWindow. If you call event.preventDefault() and manually create a new
  5211. * BrowserWindow then you must set event.newGuest to reference the new
  5212. * BrowserWindow instance, failing to do so may result in unexpected behavior. For
  5213. * example:
  5214. */
  5215. on(event: 'new-window', listener: (event: Event,
  5216. url: string,
  5217. frameName: string,
  5218. /**
  5219. * Can be `default`, `foreground-tab`, `background-tab`, `new-window`,
  5220. * `save-to-disk` and `other`.
  5221. */
  5222. disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
  5223. /**
  5224. * The options which will be used for creating the new .
  5225. */
  5226. options: any,
  5227. /**
  5228. * The non-standard features (features not handled by Chromium or Electron) given
  5229. * to `window.open()`.
  5230. */
  5231. additionalFeatures: string[],
  5232. /**
  5233. * The referrer that will be passed to the new window. May or may not result in the
  5234. * `Referer` header being sent, depending on the referrer policy.
  5235. */
  5236. referrer: Referrer) => void): this;
  5237. once(event: 'new-window', listener: (event: Event,
  5238. url: string,
  5239. frameName: string,
  5240. /**
  5241. * Can be `default`, `foreground-tab`, `background-tab`, `new-window`,
  5242. * `save-to-disk` and `other`.
  5243. */
  5244. disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
  5245. /**
  5246. * The options which will be used for creating the new .
  5247. */
  5248. options: any,
  5249. /**
  5250. * The non-standard features (features not handled by Chromium or Electron) given
  5251. * to `window.open()`.
  5252. */
  5253. additionalFeatures: string[],
  5254. /**
  5255. * The referrer that will be passed to the new window. May or may not result in the
  5256. * `Referer` header being sent, depending on the referrer policy.
  5257. */
  5258. referrer: Referrer) => void): this;
  5259. addListener(event: 'new-window', listener: (event: Event,
  5260. url: string,
  5261. frameName: string,
  5262. /**
  5263. * Can be `default`, `foreground-tab`, `background-tab`, `new-window`,
  5264. * `save-to-disk` and `other`.
  5265. */
  5266. disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
  5267. /**
  5268. * The options which will be used for creating the new .
  5269. */
  5270. options: any,
  5271. /**
  5272. * The non-standard features (features not handled by Chromium or Electron) given
  5273. * to `window.open()`.
  5274. */
  5275. additionalFeatures: string[],
  5276. /**
  5277. * The referrer that will be passed to the new window. May or may not result in the
  5278. * `Referer` header being sent, depending on the referrer policy.
  5279. */
  5280. referrer: Referrer) => void): this;
  5281. removeListener(event: 'new-window', listener: (event: Event,
  5282. url: string,
  5283. frameName: string,
  5284. /**
  5285. * Can be `default`, `foreground-tab`, `background-tab`, `new-window`,
  5286. * `save-to-disk` and `other`.
  5287. */
  5288. disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
  5289. /**
  5290. * The options which will be used for creating the new .
  5291. */
  5292. options: any,
  5293. /**
  5294. * The non-standard features (features not handled by Chromium or Electron) given
  5295. * to `window.open()`.
  5296. */
  5297. additionalFeatures: string[],
  5298. /**
  5299. * The referrer that will be passed to the new window. May or may not result in the
  5300. * `Referer` header being sent, depending on the referrer policy.
  5301. */
  5302. referrer: Referrer) => void): this;
  5303. /**
  5304. * Emitted when page receives favicon urls.
  5305. */
  5306. on(event: 'page-favicon-updated', listener: (event: Event,
  5307. /**
  5308. * Array of URLs.
  5309. */
  5310. favicons: string[]) => void): this;
  5311. once(event: 'page-favicon-updated', listener: (event: Event,
  5312. /**
  5313. * Array of URLs.
  5314. */
  5315. favicons: string[]) => void): this;
  5316. addListener(event: 'page-favicon-updated', listener: (event: Event,
  5317. /**
  5318. * Array of URLs.
  5319. */
  5320. favicons: string[]) => void): this;
  5321. removeListener(event: 'page-favicon-updated', listener: (event: Event,
  5322. /**
  5323. * Array of URLs.
  5324. */
  5325. favicons: string[]) => void): this;
  5326. /**
  5327. * Emitted when a new frame is generated. Only the dirty area is passed in the
  5328. * buffer.
  5329. */
  5330. on(event: 'paint', listener: (event: Event,
  5331. dirtyRect: Rectangle,
  5332. /**
  5333. * The image data of the whole frame.
  5334. */
  5335. image: NativeImage) => void): this;
  5336. once(event: 'paint', listener: (event: Event,
  5337. dirtyRect: Rectangle,
  5338. /**
  5339. * The image data of the whole frame.
  5340. */
  5341. image: NativeImage) => void): this;
  5342. addListener(event: 'paint', listener: (event: Event,
  5343. dirtyRect: Rectangle,
  5344. /**
  5345. * The image data of the whole frame.
  5346. */
  5347. image: NativeImage) => void): this;
  5348. removeListener(event: 'paint', listener: (event: Event,
  5349. dirtyRect: Rectangle,
  5350. /**
  5351. * The image data of the whole frame.
  5352. */
  5353. image: NativeImage) => void): this;
  5354. /**
  5355. * Emitted when a plugin process has crashed.
  5356. */
  5357. on(event: 'plugin-crashed', listener: (event: Event,
  5358. name: string,
  5359. version: string) => void): this;
  5360. once(event: 'plugin-crashed', listener: (event: Event,
  5361. name: string,
  5362. version: string) => void): this;
  5363. addListener(event: 'plugin-crashed', listener: (event: Event,
  5364. name: string,
  5365. version: string) => void): this;
  5366. removeListener(event: 'plugin-crashed', listener: (event: Event,
  5367. name: string,
  5368. version: string) => void): this;
  5369. /**
  5370. * Emitted when the unresponsive web page becomes responsive again.
  5371. */
  5372. on(event: 'responsive', listener: Function): this;
  5373. once(event: 'responsive', listener: Function): this;
  5374. addListener(event: 'responsive', listener: Function): this;
  5375. removeListener(event: 'responsive', listener: Function): this;
  5376. /**
  5377. * Emitted when bluetooth device needs to be selected on call to
  5378. * navigator.bluetooth.requestDevice. To use navigator.bluetooth api webBluetooth
  5379. * should be enabled. If event.preventDefault is not called, first available device
  5380. * will be selected. callback should be called with deviceId to be selected,
  5381. * passing empty string to callback will cancel the request.
  5382. */
  5383. on(event: 'select-bluetooth-device', listener: (event: Event,
  5384. devices: BluetoothDevice[],
  5385. callback: (deviceId: string) => void) => void): this;
  5386. once(event: 'select-bluetooth-device', listener: (event: Event,
  5387. devices: BluetoothDevice[],
  5388. callback: (deviceId: string) => void) => void): this;
  5389. addListener(event: 'select-bluetooth-device', listener: (event: Event,
  5390. devices: BluetoothDevice[],
  5391. callback: (deviceId: string) => void) => void): this;
  5392. removeListener(event: 'select-bluetooth-device', listener: (event: Event,
  5393. devices: BluetoothDevice[],
  5394. callback: (deviceId: string) => void) => void): this;
  5395. /**
  5396. * Emitted when a client certificate is requested. The usage is the same with the
  5397. * select-client-certificate event of app.
  5398. */
  5399. on(event: 'select-client-certificate', listener: (event: Event,
  5400. url: string,
  5401. certificateList: Certificate[],
  5402. callback: (certificate: Certificate) => void) => void): this;
  5403. once(event: 'select-client-certificate', listener: (event: Event,
  5404. url: string,
  5405. certificateList: Certificate[],
  5406. callback: (certificate: Certificate) => void) => void): this;
  5407. addListener(event: 'select-client-certificate', listener: (event: Event,
  5408. url: string,
  5409. certificateList: Certificate[],
  5410. callback: (certificate: Certificate) => void) => void): this;
  5411. removeListener(event: 'select-client-certificate', listener: (event: Event,
  5412. url: string,
  5413. certificateList: Certificate[],
  5414. callback: (certificate: Certificate) => void) => void): this;
  5415. /**
  5416. * Emitted when the web page becomes unresponsive.
  5417. */
  5418. on(event: 'unresponsive', listener: Function): this;
  5419. once(event: 'unresponsive', listener: Function): this;
  5420. addListener(event: 'unresponsive', listener: Function): this;
  5421. removeListener(event: 'unresponsive', listener: Function): this;
  5422. /**
  5423. * Emitted when mouse moves over a link or the keyboard moves the focus to a link.
  5424. */
  5425. on(event: 'update-target-url', listener: (event: Event,
  5426. url: string) => void): this;
  5427. once(event: 'update-target-url', listener: (event: Event,
  5428. url: string) => void): this;
  5429. addListener(event: 'update-target-url', listener: (event: Event,
  5430. url: string) => void): this;
  5431. removeListener(event: 'update-target-url', listener: (event: Event,
  5432. url: string) => void): this;
  5433. /**
  5434. * Emitted when a <webview>'s web contents is being attached to this web contents.
  5435. * Calling event.preventDefault() will destroy the guest page. This event can be
  5436. * used to configure webPreferences for the webContents of a <webview> before it's
  5437. * loaded, and provides the ability to set settings that can't be set via <webview>
  5438. * attributes. Note: The specified preload script option will be appear as
  5439. * preloadURL (not preload) in the webPreferences object emitted with this event.
  5440. */
  5441. on(event: 'will-attach-webview', listener: (event: Event,
  5442. /**
  5443. * The web preferences that will be used by the guest page. This object can be
  5444. * modified to adjust the preferences for the guest page.
  5445. */
  5446. webPreferences: any,
  5447. /**
  5448. * The other `<webview>` parameters such as the `src` URL. This object can be
  5449. * modified to adjust the parameters of the guest page.
  5450. */
  5451. params: any) => void): this;
  5452. once(event: 'will-attach-webview', listener: (event: Event,
  5453. /**
  5454. * The web preferences that will be used by the guest page. This object can be
  5455. * modified to adjust the preferences for the guest page.
  5456. */
  5457. webPreferences: any,
  5458. /**
  5459. * The other `<webview>` parameters such as the `src` URL. This object can be
  5460. * modified to adjust the parameters of the guest page.
  5461. */
  5462. params: any) => void): this;
  5463. addListener(event: 'will-attach-webview', listener: (event: Event,
  5464. /**
  5465. * The web preferences that will be used by the guest page. This object can be
  5466. * modified to adjust the preferences for the guest page.
  5467. */
  5468. webPreferences: any,
  5469. /**
  5470. * The other `<webview>` parameters such as the `src` URL. This object can be
  5471. * modified to adjust the parameters of the guest page.
  5472. */
  5473. params: any) => void): this;
  5474. removeListener(event: 'will-attach-webview', listener: (event: Event,
  5475. /**
  5476. * The web preferences that will be used by the guest page. This object can be
  5477. * modified to adjust the preferences for the guest page.
  5478. */
  5479. webPreferences: any,
  5480. /**
  5481. * The other `<webview>` parameters such as the `src` URL. This object can be
  5482. * modified to adjust the parameters of the guest page.
  5483. */
  5484. params: any) => void): this;
  5485. /**
  5486. * Emitted when a user or the page wants to start navigation. It can happen when
  5487. * the window.location object is changed or a user clicks a link in the page. This
  5488. * event will not emit when the navigation is started programmatically with APIs
  5489. * like webContents.loadURL and webContents.back. It is also not emitted for
  5490. * in-page navigations, such as clicking anchor links or updating the
  5491. * window.location.hash. Use did-navigate-in-page event for this purpose. Calling
  5492. * event.preventDefault() will prevent the navigation.
  5493. */
  5494. on(event: 'will-navigate', listener: (event: Event,
  5495. url: string) => void): this;
  5496. once(event: 'will-navigate', listener: (event: Event,
  5497. url: string) => void): this;
  5498. addListener(event: 'will-navigate', listener: (event: Event,
  5499. url: string) => void): this;
  5500. removeListener(event: 'will-navigate', listener: (event: Event,
  5501. url: string) => void): this;
  5502. /**
  5503. * Emitted when a beforeunload event handler is attempting to cancel a page unload.
  5504. * Calling event.preventDefault() will ignore the beforeunload event handler and
  5505. * allow the page to be unloaded.
  5506. */
  5507. on(event: 'will-prevent-unload', listener: (event: Event) => void): this;
  5508. once(event: 'will-prevent-unload', listener: (event: Event) => void): this;
  5509. addListener(event: 'will-prevent-unload', listener: (event: Event) => void): this;
  5510. removeListener(event: 'will-prevent-unload', listener: (event: Event) => void): this;
  5511. /**
  5512. * Adds the specified path to DevTools workspace. Must be used after DevTools
  5513. * creation:
  5514. */
  5515. addWorkSpace(path: string): void;
  5516. /**
  5517. * Begin subscribing for presentation events and captured frames, the callback will
  5518. * be called with callback(image, dirtyRect) when there is a presentation event.
  5519. * The image is an instance of NativeImage that stores the captured frame. The
  5520. * dirtyRect is an object with x, y, width, height properties that describes which
  5521. * part of the page was repainted. If onlyDirty is set to true, image will only
  5522. * contain the repainted area. onlyDirty defaults to false.
  5523. */
  5524. beginFrameSubscription(callback: (image: NativeImage, dirtyRect: Rectangle) => void): void;
  5525. /**
  5526. * Begin subscribing for presentation events and captured frames, the callback will
  5527. * be called with callback(image, dirtyRect) when there is a presentation event.
  5528. * The image is an instance of NativeImage that stores the captured frame. The
  5529. * dirtyRect is an object with x, y, width, height properties that describes which
  5530. * part of the page was repainted. If onlyDirty is set to true, image will only
  5531. * contain the repainted area. onlyDirty defaults to false.
  5532. */
  5533. beginFrameSubscription(onlyDirty: boolean, callback: (image: NativeImage, dirtyRect: Rectangle) => void): void;
  5534. canGoBack(): boolean;
  5535. canGoForward(): boolean;
  5536. canGoToOffset(offset: number): boolean;
  5537. /**
  5538. * Captures a snapshot of the page within rect. Upon completion callback will be
  5539. * called with callback(image). The image is an instance of NativeImage that stores
  5540. * data of the snapshot. Omitting rect will capture the whole visible page.
  5541. */
  5542. capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
  5543. /**
  5544. * Captures a snapshot of the page within rect. Upon completion callback will be
  5545. * called with callback(image). The image is an instance of NativeImage that stores
  5546. * data of the snapshot. Omitting rect will capture the whole visible page.
  5547. */
  5548. capturePage(callback: (image: NativeImage) => void): void;
  5549. /**
  5550. * Clears the navigation history.
  5551. */
  5552. clearHistory(): void;
  5553. /**
  5554. * Closes the devtools.
  5555. */
  5556. closeDevTools(): void;
  5557. /**
  5558. * Executes the editing command copy in web page.
  5559. */
  5560. copy(): void;
  5561. /**
  5562. * Copy the image at the given position to the clipboard.
  5563. */
  5564. copyImageAt(x: number, y: number): void;
  5565. /**
  5566. * Executes the editing command cut in web page.
  5567. */
  5568. cut(): void;
  5569. /**
  5570. * Executes the editing command delete in web page.
  5571. */
  5572. delete(): void;
  5573. /**
  5574. * Disable device emulation enabled by webContents.enableDeviceEmulation.
  5575. */
  5576. disableDeviceEmulation(): void;
  5577. /**
  5578. * Initiates a download of the resource at url without navigating. The
  5579. * will-download event of session will be triggered.
  5580. */
  5581. downloadURL(url: string): void;
  5582. /**
  5583. * Enable device emulation with the given parameters.
  5584. */
  5585. enableDeviceEmulation(parameters: Parameters): void;
  5586. /**
  5587. * End subscribing for frame presentation events.
  5588. */
  5589. endFrameSubscription(): void;
  5590. /**
  5591. * Evaluates code in page. In the browser window some HTML APIs like
  5592. * requestFullScreen can only be invoked by a gesture from the user. Setting
  5593. * userGesture to true will remove this limitation. If the result of the executed
  5594. * code is a promise the callback result will be the resolved value of the promise.
  5595. * We recommend that you use the returned Promise to handle code that results in a
  5596. * Promise.
  5597. */
  5598. executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
  5599. /**
  5600. * Starts a request to find all matches for the text in the web page. The result of
  5601. * the request can be obtained by subscribing to found-in-page event.
  5602. */
  5603. findInPage(text: string, options?: FindInPageOptions): number;
  5604. /**
  5605. * Focuses the web page.
  5606. */
  5607. focus(): void;
  5608. getFrameRate(): number;
  5609. getOSProcessId(): number;
  5610. /**
  5611. * Get the system printer list.
  5612. */
  5613. getPrinters(): PrinterInfo[];
  5614. getProcessId(): number;
  5615. getTitle(): string;
  5616. getURL(): string;
  5617. getUserAgent(): string;
  5618. getWebRTCIPHandlingPolicy(): string;
  5619. /**
  5620. * Sends a request to get current zoom factor, the callback will be called with
  5621. * callback(zoomFactor).
  5622. */
  5623. getZoomFactor(callback: (zoomFactor: number) => void): void;
  5624. /**
  5625. * Sends a request to get current zoom level, the callback will be called with
  5626. * callback(zoomLevel).
  5627. */
  5628. getZoomLevel(callback: (zoomLevel: number) => void): void;
  5629. /**
  5630. * Makes the browser go back a web page.
  5631. */
  5632. goBack(): void;
  5633. /**
  5634. * Makes the browser go forward a web page.
  5635. */
  5636. goForward(): void;
  5637. /**
  5638. * Navigates browser to the specified absolute web page index.
  5639. */
  5640. goToIndex(index: number): void;
  5641. /**
  5642. * Navigates to the specified offset from the "current entry".
  5643. */
  5644. goToOffset(offset: number): void;
  5645. /**
  5646. * Checks if any ServiceWorker is registered and returns a boolean as response to
  5647. * callback.
  5648. */
  5649. hasServiceWorker(callback: (hasWorker: boolean) => void): void;
  5650. /**
  5651. * Injects CSS into the current web page.
  5652. */
  5653. insertCSS(css: string): void;
  5654. /**
  5655. * Inserts text to the focused element.
  5656. */
  5657. insertText(text: string): void;
  5658. /**
  5659. * Starts inspecting element at position (x, y).
  5660. */
  5661. inspectElement(x: number, y: number): void;
  5662. /**
  5663. * Opens the developer tools for the service worker context.
  5664. */
  5665. inspectServiceWorker(): void;
  5666. /**
  5667. * Schedules a full repaint of the window this web contents is in. If offscreen
  5668. * rendering is enabled invalidates the frame and generates a new one through the
  5669. * 'paint' event.
  5670. */
  5671. invalidate(): void;
  5672. isAudioMuted(): boolean;
  5673. isCrashed(): boolean;
  5674. isDestroyed(): boolean;
  5675. isDevToolsFocused(): boolean;
  5676. isDevToolsOpened(): boolean;
  5677. isFocused(): boolean;
  5678. isLoading(): boolean;
  5679. isLoadingMainFrame(): boolean;
  5680. isOffscreen(): boolean;
  5681. isPainting(): boolean;
  5682. isWaitingForResponse(): boolean;
  5683. /**
  5684. * Loads the given file in the window, filePath should be a path to an HTML file
  5685. * relative to the root of your application. For instance an app structure like
  5686. * this: Would require code like this
  5687. */
  5688. loadFile(filePath: string): void;
  5689. /**
  5690. * Loads the url in the window. The url must contain the protocol prefix, e.g. the
  5691. * http:// or file://. If the load should bypass http cache then use the pragma
  5692. * header to achieve it.
  5693. */
  5694. loadURL(url: string, options?: LoadURLOptions): void;
  5695. /**
  5696. * Opens the devtools. When contents is a <webview> tag, the mode would be detach
  5697. * by default, explicitly passing an empty mode can force using last used dock
  5698. * state.
  5699. */
  5700. openDevTools(options?: OpenDevToolsOptions): void;
  5701. /**
  5702. * Executes the editing command paste in web page.
  5703. */
  5704. paste(): void;
  5705. /**
  5706. * Executes the editing command pasteAndMatchStyle in web page.
  5707. */
  5708. pasteAndMatchStyle(): void;
  5709. /**
  5710. * Prints window's web page. When silent is set to true, Electron will pick the
  5711. * system's default printer if deviceName is empty and the default settings for
  5712. * printing. Calling window.print() in web page is equivalent to calling
  5713. * webContents.print({silent: false, printBackground: false, deviceName: ''}). Use
  5714. * page-break-before: always; CSS style to force to print to a new page.
  5715. */
  5716. print(options?: PrintOptions, callback?: (success: boolean) => void): void;
  5717. /**
  5718. * Prints window's web page as PDF with Chromium's preview printing custom
  5719. * settings. The callback will be called with callback(error, data) on completion.
  5720. * The data is a Buffer that contains the generated PDF data. The landscape will be
  5721. * ignored if @page CSS at-rule is used in the web page. By default, an empty
  5722. * options will be regarded as: Use page-break-before: always; CSS style to force
  5723. * to print to a new page. An example of webContents.printToPDF:
  5724. */
  5725. printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
  5726. /**
  5727. * Executes the editing command redo in web page.
  5728. */
  5729. redo(): void;
  5730. /**
  5731. * Reloads the current web page.
  5732. */
  5733. reload(): void;
  5734. /**
  5735. * Reloads current page and ignores cache.
  5736. */
  5737. reloadIgnoringCache(): void;
  5738. /**
  5739. * Removes the specified path from DevTools workspace.
  5740. */
  5741. removeWorkSpace(path: string): void;
  5742. /**
  5743. * Executes the editing command replace in web page.
  5744. */
  5745. replace(text: string): void;
  5746. /**
  5747. * Executes the editing command replaceMisspelling in web page.
  5748. */
  5749. replaceMisspelling(text: string): void;
  5750. savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback: (error: Error) => void): boolean;
  5751. /**
  5752. * Executes the editing command selectAll in web page.
  5753. */
  5754. selectAll(): void;
  5755. /**
  5756. * Send an asynchronous message to renderer process via channel, you can also send
  5757. * arbitrary arguments. Arguments will be serialized in JSON internally and hence
  5758. * no functions or prototype chain will be included. The renderer process can
  5759. * handle the message by listening to channel with the ipcRenderer module. An
  5760. * example of sending messages from the main process to the renderer process:
  5761. */
  5762. send(channel: string, ...args: any[]): void;
  5763. /**
  5764. * Sends an input event to the page. Note: The BrowserWindow containing the
  5765. * contents needs to be focused for sendInputEvent() to work. For keyboard events,
  5766. * the event object also have following properties: For mouse events, the event
  5767. * object also have following properties: For the mouseWheel event, the event
  5768. * object also have following properties:
  5769. */
  5770. sendInputEvent(event: Event): void;
  5771. /**
  5772. * Mute the audio on the current web page.
  5773. */
  5774. setAudioMuted(muted: boolean): void;
  5775. /**
  5776. * Uses the devToolsWebContents as the target WebContents to show devtools. The
  5777. * devToolsWebContents must not have done any navigation, and it should not be used
  5778. * for other purposes after the call. By default Electron manages the devtools by
  5779. * creating an internal WebContents with native view, which developers have very
  5780. * limited control of. With the setDevToolsWebContents method, developers can use
  5781. * any WebContents to show the devtools in it, including BrowserWindow, BrowserView
  5782. * and <webview> tag. Note that closing the devtools does not destroy the
  5783. * devToolsWebContents, it is caller's responsibility to destroy
  5784. * devToolsWebContents. An example of showing devtools in a <webview> tag: An
  5785. * example of showing devtools in a BrowserWindow:
  5786. */
  5787. setDevToolsWebContents(devToolsWebContents: WebContents): void;
  5788. /**
  5789. * If offscreen rendering is enabled sets the frame rate to the specified number.
  5790. * Only values between 1 and 60 are accepted.
  5791. */
  5792. setFrameRate(fps: number): void;
  5793. /**
  5794. * Ignore application menu shortcuts while this web contents is focused.
  5795. */
  5796. setIgnoreMenuShortcuts(ignore: boolean): void;
  5797. /**
  5798. * Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
  5799. */
  5800. setLayoutZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
  5801. /**
  5802. * Overrides the user agent for this web page.
  5803. */
  5804. setUserAgent(userAgent: string): void;
  5805. /**
  5806. * Sets the maximum and minimum pinch-to-zoom level.
  5807. */
  5808. setVisualZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
  5809. /**
  5810. * Setting the WebRTC IP handling policy allows you to control which IPs are
  5811. * exposed via WebRTC. See BrowserLeaks for more details.
  5812. */
  5813. setWebRTCIPHandlingPolicy(policy: 'default' | 'default_public_interface_only' | 'default_public_and_private_interfaces' | 'disable_non_proxied_udp'): void;
  5814. /**
  5815. * Changes the zoom factor to the specified factor. Zoom factor is zoom percent
  5816. * divided by 100, so 300% = 3.0.
  5817. */
  5818. setZoomFactor(factor: number): void;
  5819. /**
  5820. * Changes the zoom level to the specified level. The original size is 0 and each
  5821. * increment above or below represents zooming 20% larger or smaller to default
  5822. * limits of 300% and 50% of original size, respectively. The formula for this is
  5823. * scale := 1.2 ^ level.
  5824. */
  5825. setZoomLevel(level: number): void;
  5826. /**
  5827. * Shows pop-up dictionary that searches the selected word on the page.
  5828. */
  5829. showDefinitionForSelection(): void;
  5830. /**
  5831. * Sets the item as dragging item for current drag-drop operation, file is the
  5832. * absolute path of the file to be dragged, and icon is the image showing under the
  5833. * cursor when dragging.
  5834. */
  5835. startDrag(item: Item): void;
  5836. /**
  5837. * If offscreen rendering is enabled and not painting, start painting.
  5838. */
  5839. startPainting(): void;
  5840. /**
  5841. * Stops any pending navigation.
  5842. */
  5843. stop(): void;
  5844. /**
  5845. * Stops any findInPage request for the webContents with the provided action.
  5846. */
  5847. stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
  5848. /**
  5849. * If offscreen rendering is enabled and painting, stop painting.
  5850. */
  5851. stopPainting(): void;
  5852. /**
  5853. * Toggles the developer tools.
  5854. */
  5855. toggleDevTools(): void;
  5856. /**
  5857. * Executes the editing command undo in web page.
  5858. */
  5859. undo(): void;
  5860. /**
  5861. * Unregisters any ServiceWorker if present and returns a boolean as response to
  5862. * callback when the JS promise is fulfilled or false when the JS promise is
  5863. * rejected.
  5864. */
  5865. unregisterServiceWorker(callback: (success: boolean) => void): void;
  5866. /**
  5867. * Executes the editing command unselect in web page.
  5868. */
  5869. unselect(): void;
  5870. debugger: Debugger;
  5871. devToolsWebContents: WebContents;
  5872. hostWebContents: WebContents;
  5873. id: number;
  5874. session: Session;
  5875. }
  5876. interface WebFrame extends EventEmitter {
  5877. // Docs: http://electron.atom.io/docs/api/web-frame
  5878. /**
  5879. * Attempts to free memory that is no longer being used (like images from a
  5880. * previous navigation). Note that blindly calling this method probably makes
  5881. * Electron slower since it will have to refill these emptied caches, you should
  5882. * only call it if an event in your app has occurred that makes you think your page
  5883. * is actually using less memory (i.e. you have navigated from a super heavy page
  5884. * to a mostly empty one, and intend to stay there).
  5885. */
  5886. clearCache(): void;
  5887. /**
  5888. * Evaluates code in page. In the browser window some HTML APIs like
  5889. * requestFullScreen can only be invoked by a gesture from the user. Setting
  5890. * userGesture to true will remove this limitation.
  5891. */
  5892. executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise<any>;
  5893. /**
  5894. * Work like executeJavaScript but evaluates scripts in isolated context.
  5895. */
  5896. executeJavaScriptInIsolatedWorld(worldId: number, scripts: WebSource[], userGesture?: boolean, callback?: (result: any) => void): void;
  5897. findFrameByName(name: string): WebFrame;
  5898. findFrameByRoutingId(routingId: number): WebFrame;
  5899. getFrameForSelector(selector: string): WebFrame;
  5900. /**
  5901. * Returns an object describing usage information of Blink's internal memory
  5902. * caches. This will generate:
  5903. */
  5904. getResourceUsage(): ResourceUsage;
  5905. getZoomFactor(): number;
  5906. getZoomLevel(): number;
  5907. /**
  5908. * Inserts text to the focused element.
  5909. */
  5910. insertText(text: string): void;
  5911. /**
  5912. * Resources will be loaded from this scheme regardless of the current page's
  5913. * Content Security Policy.
  5914. */
  5915. registerURLSchemeAsBypassingCSP(scheme: string): void;
  5916. /**
  5917. * Registers the scheme as secure, bypasses content security policy for resources,
  5918. * allows registering ServiceWorker and supports fetch API. Specify an option with
  5919. * the value of false to omit it from the registration. An example of registering a
  5920. * privileged scheme, without bypassing Content Security Policy:
  5921. */
  5922. registerURLSchemeAsPrivileged(scheme: string, options?: RegisterURLSchemeAsPrivilegedOptions): void;
  5923. /**
  5924. * Set the content security policy of the isolated world.
  5925. */
  5926. setIsolatedWorldContentSecurityPolicy(worldId: number, csp: string): void;
  5927. /**
  5928. * Set the name of the isolated world. Useful in devtools.
  5929. */
  5930. setIsolatedWorldHumanReadableName(worldId: number, name: string): void;
  5931. /**
  5932. * Set the security origin of the isolated world.
  5933. */
  5934. setIsolatedWorldSecurityOrigin(worldId: number, securityOrigin: string): void;
  5935. /**
  5936. * Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
  5937. */
  5938. setLayoutZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
  5939. /**
  5940. * Sets a provider for spell checking in input fields and text areas. The provider
  5941. * must be an object that has a spellCheck method that returns whether the word
  5942. * passed is correctly spelled. An example of using node-spellchecker as provider:
  5943. */
  5944. setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: Provider): void;
  5945. /**
  5946. * Sets the maximum and minimum pinch-to-zoom level.
  5947. */
  5948. setVisualZoomLevelLimits(minimumLevel: number, maximumLevel: number): void;
  5949. /**
  5950. * Changes the zoom factor to the specified factor. Zoom factor is zoom percent
  5951. * divided by 100, so 300% = 3.0.
  5952. */
  5953. setZoomFactor(factor: number): void;
  5954. /**
  5955. * Changes the zoom level to the specified level. The original size is 0 and each
  5956. * increment above or below represents zooming 20% larger or smaller to default
  5957. * limits of 300% and 50% of original size, respectively.
  5958. */
  5959. setZoomLevel(level: number): void;
  5960. /**
  5961. * A WebFrame representing the first child frame of webFrame, the property would be
  5962. * null if webFrame has no children or if first child is not in the current
  5963. * renderer process.
  5964. */
  5965. firstChild?: WebFrame;
  5966. /**
  5967. * A WebFrame representing next sibling frame, the property would be null if
  5968. * webFrame is the last frame in its parent or if the next sibling is not in the
  5969. * current renderer process.
  5970. */
  5971. nextSibling?: WebFrame;
  5972. /**
  5973. * A WebFrame representing the frame which opened webFrame, the property would be
  5974. * null if there's no opener or opener is not in the current renderer process.
  5975. */
  5976. opener?: WebFrame;
  5977. /**
  5978. * A WebFrame representing parent frame of webFrame, the property would be null if
  5979. * webFrame is top or parent is not in the current renderer process.
  5980. */
  5981. parent?: WebFrame;
  5982. /**
  5983. * An Integer representing the unique frame id in the current renderer process.
  5984. * Distinct WebFrame instances that refer to the same underlying frame will have
  5985. * the same routingId.
  5986. */
  5987. routingId?: number;
  5988. /**
  5989. * A WebFrame representing top frame in frame hierarchy to which webFrame belongs,
  5990. * the property would be null if top frame is not in the current renderer process.
  5991. */
  5992. top?: WebFrame;
  5993. }
  5994. class WebRequest extends EventEmitter {
  5995. // Docs: http://electron.atom.io/docs/api/web-request
  5996. /**
  5997. * The listener will be called with listener(details) when a server initiated
  5998. * redirect is about to occur.
  5999. */
  6000. onBeforeRedirect(listener: (details: OnBeforeRedirectDetails) => void): void;
  6001. /**
  6002. * The listener will be called with listener(details) when a server initiated
  6003. * redirect is about to occur.
  6004. */
  6005. onBeforeRedirect(filter: OnBeforeRedirectFilter, listener: (details: OnBeforeRedirectDetails) => void): void;
  6006. /**
  6007. * The listener will be called with listener(details, callback) when a request is
  6008. * about to occur. The uploadData is an array of UploadData objects. The callback
  6009. * has to be called with an response object.
  6010. */
  6011. onBeforeRequest(listener: (details: OnBeforeRequestDetails, callback: (response: Response) => void) => void): void;
  6012. /**
  6013. * The listener will be called with listener(details, callback) when a request is
  6014. * about to occur. The uploadData is an array of UploadData objects. The callback
  6015. * has to be called with an response object.
  6016. */
  6017. onBeforeRequest(filter: OnBeforeRequestFilter, listener: (details: OnBeforeRequestDetails, callback: (response: Response) => void) => void): void;
  6018. /**
  6019. * The listener will be called with listener(details, callback) before sending an
  6020. * HTTP request, once the request headers are available. This may occur after a TCP
  6021. * connection is made to the server, but before any http data is sent. The callback
  6022. * has to be called with an response object.
  6023. */
  6024. onBeforeSendHeaders(filter: OnBeforeSendHeadersFilter, listener: Function): void;
  6025. /**
  6026. * The listener will be called with listener(details, callback) before sending an
  6027. * HTTP request, once the request headers are available. This may occur after a TCP
  6028. * connection is made to the server, but before any http data is sent. The callback
  6029. * has to be called with an response object.
  6030. */
  6031. onBeforeSendHeaders(listener: Function): void;
  6032. /**
  6033. * The listener will be called with listener(details) when a request is completed.
  6034. */
  6035. onCompleted(filter: OnCompletedFilter, listener: (details: OnCompletedDetails) => void): void;
  6036. /**
  6037. * The listener will be called with listener(details) when a request is completed.
  6038. */
  6039. onCompleted(listener: (details: OnCompletedDetails) => void): void;
  6040. /**
  6041. * The listener will be called with listener(details) when an error occurs.
  6042. */
  6043. onErrorOccurred(listener: (details: OnErrorOccurredDetails) => void): void;
  6044. /**
  6045. * The listener will be called with listener(details) when an error occurs.
  6046. */
  6047. onErrorOccurred(filter: OnErrorOccurredFilter, listener: (details: OnErrorOccurredDetails) => void): void;
  6048. /**
  6049. * The listener will be called with listener(details, callback) when HTTP response
  6050. * headers of a request have been received. The callback has to be called with an
  6051. * response object.
  6052. */
  6053. onHeadersReceived(filter: OnHeadersReceivedFilter, listener: Function): void;
  6054. /**
  6055. * The listener will be called with listener(details, callback) when HTTP response
  6056. * headers of a request have been received. The callback has to be called with an
  6057. * response object.
  6058. */
  6059. onHeadersReceived(listener: Function): void;
  6060. /**
  6061. * The listener will be called with listener(details) when first byte of the
  6062. * response body is received. For HTTP requests, this means that the status line
  6063. * and response headers are available.
  6064. */
  6065. onResponseStarted(listener: (details: OnResponseStartedDetails) => void): void;
  6066. /**
  6067. * The listener will be called with listener(details) when first byte of the
  6068. * response body is received. For HTTP requests, this means that the status line
  6069. * and response headers are available.
  6070. */
  6071. onResponseStarted(filter: OnResponseStartedFilter, listener: (details: OnResponseStartedDetails) => void): void;
  6072. /**
  6073. * The listener will be called with listener(details) just before a request is
  6074. * going to be sent to the server, modifications of previous onBeforeSendHeaders
  6075. * response are visible by the time this listener is fired.
  6076. */
  6077. onSendHeaders(filter: OnSendHeadersFilter, listener: (details: OnSendHeadersDetails) => void): void;
  6078. /**
  6079. * The listener will be called with listener(details) just before a request is
  6080. * going to be sent to the server, modifications of previous onBeforeSendHeaders
  6081. * response are visible by the time this listener is fired.
  6082. */
  6083. onSendHeaders(listener: (details: OnSendHeadersDetails) => void): void;
  6084. }
  6085. interface WebSource {
  6086. // Docs: http://electron.atom.io/docs/api/structures/web-source
  6087. code: string;
  6088. /**
  6089. * Default is 1.
  6090. */
  6091. startLine?: number;
  6092. url?: string;
  6093. }
  6094. interface WebviewTag extends HTMLElement {
  6095. // Docs: http://electron.atom.io/docs/api/webview-tag
  6096. /**
  6097. * Fired when a load has committed. This includes navigation within the current
  6098. * document as well as subframe document-level loads, but does not include
  6099. * asynchronous resource loads.
  6100. */
  6101. addEventListener(event: 'load-commit', listener: (event: LoadCommitEvent) => void, useCapture?: boolean): this;
  6102. removeEventListener(event: 'load-commit', listener: (event: LoadCommitEvent) => void): this;
  6103. /**
  6104. * Fired when the navigation is done, i.e. the spinner of the tab will stop
  6105. * spinning, and the onload event is dispatched.
  6106. */
  6107. addEventListener(event: 'did-finish-load', listener: (event: Event) => void, useCapture?: boolean): this;
  6108. removeEventListener(event: 'did-finish-load', listener: (event: Event) => void): this;
  6109. /**
  6110. * This event is like did-finish-load, but fired when the load failed or was
  6111. * cancelled, e.g. window.stop() is invoked.
  6112. */
  6113. addEventListener(event: 'did-fail-load', listener: (event: DidFailLoadEvent) => void, useCapture?: boolean): this;
  6114. removeEventListener(event: 'did-fail-load', listener: (event: DidFailLoadEvent) => void): this;
  6115. /**
  6116. * Fired when a frame has done navigation.
  6117. */
  6118. addEventListener(event: 'did-frame-finish-load', listener: (event: DidFrameFinishLoadEvent) => void, useCapture?: boolean): this;
  6119. removeEventListener(event: 'did-frame-finish-load', listener: (event: DidFrameFinishLoadEvent) => void): this;
  6120. /**
  6121. * Corresponds to the points in time when the spinner of the tab starts spinning.
  6122. */
  6123. addEventListener(event: 'did-start-loading', listener: (event: Event) => void, useCapture?: boolean): this;
  6124. removeEventListener(event: 'did-start-loading', listener: (event: Event) => void): this;
  6125. /**
  6126. * Corresponds to the points in time when the spinner of the tab stops spinning.
  6127. */
  6128. addEventListener(event: 'did-stop-loading', listener: (event: Event) => void, useCapture?: boolean): this;
  6129. removeEventListener(event: 'did-stop-loading', listener: (event: Event) => void): this;
  6130. /**
  6131. * Fired when document in the given frame is loaded.
  6132. */
  6133. addEventListener(event: 'dom-ready', listener: (event: Event) => void, useCapture?: boolean): this;
  6134. removeEventListener(event: 'dom-ready', listener: (event: Event) => void): this;
  6135. /**
  6136. * Fired when page title is set during navigation. explicitSet is false when title
  6137. * is synthesized from file url.
  6138. */
  6139. addEventListener(event: 'page-title-updated', listener: (event: PageTitleUpdatedEvent) => void, useCapture?: boolean): this;
  6140. removeEventListener(event: 'page-title-updated', listener: (event: PageTitleUpdatedEvent) => void): this;
  6141. /**
  6142. * Fired when page receives favicon urls.
  6143. */
  6144. addEventListener(event: 'page-favicon-updated', listener: (event: PageFaviconUpdatedEvent) => void, useCapture?: boolean): this;
  6145. removeEventListener(event: 'page-favicon-updated', listener: (event: PageFaviconUpdatedEvent) => void): this;
  6146. /**
  6147. * Fired when page enters fullscreen triggered by HTML API.
  6148. */
  6149. addEventListener(event: 'enter-html-full-screen', listener: (event: Event) => void, useCapture?: boolean): this;
  6150. removeEventListener(event: 'enter-html-full-screen', listener: (event: Event) => void): this;
  6151. /**
  6152. * Fired when page leaves fullscreen triggered by HTML API.
  6153. */
  6154. addEventListener(event: 'leave-html-full-screen', listener: (event: Event) => void, useCapture?: boolean): this;
  6155. removeEventListener(event: 'leave-html-full-screen', listener: (event: Event) => void): this;
  6156. /**
  6157. * Fired when the guest window logs a console message. The following example code
  6158. * forwards all log messages to the embedder's console without regard for log level
  6159. * or other properties.
  6160. */
  6161. addEventListener(event: 'console-message', listener: (event: ConsoleMessageEvent) => void, useCapture?: boolean): this;
  6162. removeEventListener(event: 'console-message', listener: (event: ConsoleMessageEvent) => void): this;
  6163. /**
  6164. * Fired when a result is available for webview.findInPage request.
  6165. */
  6166. addEventListener(event: 'found-in-page', listener: (event: FoundInPageEvent) => void, useCapture?: boolean): this;
  6167. removeEventListener(event: 'found-in-page', listener: (event: FoundInPageEvent) => void): this;
  6168. /**
  6169. * Fired when the guest page attempts to open a new browser window. The following
  6170. * example code opens the new url in system's default browser.
  6171. */
  6172. addEventListener(event: 'new-window', listener: (event: NewWindowEvent) => void, useCapture?: boolean): this;
  6173. removeEventListener(event: 'new-window', listener: (event: NewWindowEvent) => void): this;
  6174. /**
  6175. * Emitted when a user or the page wants to start navigation. It can happen when
  6176. * the window.location object is changed or a user clicks a link in the page. This
  6177. * event will not emit when the navigation is started programmatically with APIs
  6178. * like <webview>.loadURL and <webview>.back. It is also not emitted during in-page
  6179. * navigation, such as clicking anchor links or updating the window.location.hash.
  6180. * Use did-navigate-in-page event for this purpose. Calling event.preventDefault()
  6181. * does NOT have any effect.
  6182. */
  6183. addEventListener(event: 'will-navigate', listener: (event: WillNavigateEvent) => void, useCapture?: boolean): this;
  6184. removeEventListener(event: 'will-navigate', listener: (event: WillNavigateEvent) => void): this;
  6185. /**
  6186. * Emitted when a navigation is done. This event is not emitted for in-page
  6187. * navigations, such as clicking anchor links or updating the window.location.hash.
  6188. * Use did-navigate-in-page event for this purpose.
  6189. */
  6190. addEventListener(event: 'did-navigate', listener: (event: DidNavigateEvent) => void, useCapture?: boolean): this;
  6191. removeEventListener(event: 'did-navigate', listener: (event: DidNavigateEvent) => void): this;
  6192. /**
  6193. * Emitted when an in-page navigation happened. When in-page navigation happens,
  6194. * the page URL changes but does not cause navigation outside of the page. Examples
  6195. * of this occurring are when anchor links are clicked or when the DOM hashchange
  6196. * event is triggered.
  6197. */
  6198. addEventListener(event: 'did-navigate-in-page', listener: (event: DidNavigateInPageEvent) => void, useCapture?: boolean): this;
  6199. removeEventListener(event: 'did-navigate-in-page', listener: (event: DidNavigateInPageEvent) => void): this;
  6200. /**
  6201. * Fired when the guest page attempts to close itself. The following example code
  6202. * navigates the webview to about:blank when the guest attempts to close itself.
  6203. */
  6204. addEventListener(event: 'close', listener: (event: Event) => void, useCapture?: boolean): this;
  6205. removeEventListener(event: 'close', listener: (event: Event) => void): this;
  6206. /**
  6207. * Fired when the guest page has sent an asynchronous message to embedder page.
  6208. * With sendToHost method and ipc-message event you can communicate between guest
  6209. * page and embedder page:
  6210. */
  6211. addEventListener(event: 'ipc-message', listener: (event: IpcMessageEvent) => void, useCapture?: boolean): this;
  6212. removeEventListener(event: 'ipc-message', listener: (event: IpcMessageEvent) => void): this;
  6213. /**
  6214. * Fired when the renderer process is crashed.
  6215. */
  6216. addEventListener(event: 'crashed', listener: (event: Event) => void, useCapture?: boolean): this;
  6217. removeEventListener(event: 'crashed', listener: (event: Event) => void): this;
  6218. /**
  6219. * Fired when the gpu process is crashed.
  6220. */
  6221. addEventListener(event: 'gpu-crashed', listener: (event: Event) => void, useCapture?: boolean): this;
  6222. removeEventListener(event: 'gpu-crashed', listener: (event: Event) => void): this;
  6223. /**
  6224. * Fired when a plugin process is crashed.
  6225. */
  6226. addEventListener(event: 'plugin-crashed', listener: (event: PluginCrashedEvent) => void, useCapture?: boolean): this;
  6227. removeEventListener(event: 'plugin-crashed', listener: (event: PluginCrashedEvent) => void): this;
  6228. /**
  6229. * Fired when the WebContents is destroyed.
  6230. */
  6231. addEventListener(event: 'destroyed', listener: (event: Event) => void, useCapture?: boolean): this;
  6232. removeEventListener(event: 'destroyed', listener: (event: Event) => void): this;
  6233. /**
  6234. * Emitted when media starts playing.
  6235. */
  6236. addEventListener(event: 'media-started-playing', listener: (event: Event) => void, useCapture?: boolean): this;
  6237. removeEventListener(event: 'media-started-playing', listener: (event: Event) => void): this;
  6238. /**
  6239. * Emitted when media is paused or done playing.
  6240. */
  6241. addEventListener(event: 'media-paused', listener: (event: Event) => void, useCapture?: boolean): this;
  6242. removeEventListener(event: 'media-paused', listener: (event: Event) => void): this;
  6243. /**
  6244. * Emitted when a page's theme color changes. This is usually due to encountering a
  6245. * meta tag:
  6246. */
  6247. addEventListener(event: 'did-change-theme-color', listener: (event: DidChangeThemeColorEvent) => void, useCapture?: boolean): this;
  6248. removeEventListener(event: 'did-change-theme-color', listener: (event: DidChangeThemeColorEvent) => void): this;
  6249. /**
  6250. * Emitted when mouse moves over a link or the keyboard moves the focus to a link.
  6251. */
  6252. addEventListener(event: 'update-target-url', listener: (event: UpdateTargetUrlEvent) => void, useCapture?: boolean): this;
  6253. removeEventListener(event: 'update-target-url', listener: (event: UpdateTargetUrlEvent) => void): this;
  6254. /**
  6255. * Emitted when DevTools is opened.
  6256. */
  6257. addEventListener(event: 'devtools-opened', listener: (event: Event) => void, useCapture?: boolean): this;
  6258. removeEventListener(event: 'devtools-opened', listener: (event: Event) => void): this;
  6259. /**
  6260. * Emitted when DevTools is closed.
  6261. */
  6262. addEventListener(event: 'devtools-closed', listener: (event: Event) => void, useCapture?: boolean): this;
  6263. removeEventListener(event: 'devtools-closed', listener: (event: Event) => void): this;
  6264. /**
  6265. * Emitted when DevTools is focused / opened.
  6266. */
  6267. addEventListener(event: 'devtools-focused', listener: (event: Event) => void, useCapture?: boolean): this;
  6268. removeEventListener(event: 'devtools-focused', listener: (event: Event) => void): this;
  6269. addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
  6270. addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
  6271. removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
  6272. removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
  6273. canGoBack(): boolean;
  6274. canGoForward(): boolean;
  6275. canGoToOffset(offset: number): boolean;
  6276. /**
  6277. * Captures a snapshot of the webview's page. Same as
  6278. * webContents.capturePage([rect, ]callback).
  6279. */
  6280. capturePage(callback: (image: NativeImage) => void): void;
  6281. /**
  6282. * Captures a snapshot of the webview's page. Same as
  6283. * webContents.capturePage([rect, ]callback).
  6284. */
  6285. capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
  6286. /**
  6287. * Clears the navigation history.
  6288. */
  6289. clearHistory(): void;
  6290. /**
  6291. * Closes the DevTools window of guest page.
  6292. */
  6293. closeDevTools(): void;
  6294. /**
  6295. * Executes editing command copy in page.
  6296. */
  6297. copy(): void;
  6298. /**
  6299. * Executes editing command cut in page.
  6300. */
  6301. cut(): void;
  6302. /**
  6303. * Executes editing command delete in page.
  6304. */
  6305. delete(): void;
  6306. /**
  6307. * Evaluates code in page. If userGesture is set, it will create the user gesture
  6308. * context in the page. HTML APIs like requestFullScreen, which require user
  6309. * action, can take advantage of this option for automation.
  6310. */
  6311. executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void;
  6312. /**
  6313. * Starts a request to find all matches for the text in the web page. The result of
  6314. * the request can be obtained by subscribing to found-in-page event.
  6315. */
  6316. findInPage(text: string, options?: FindInPageOptions): number;
  6317. getTitle(): string;
  6318. getURL(): string;
  6319. getUserAgent(): string;
  6320. getWebContents(): WebContents;
  6321. /**
  6322. * Makes the guest page go back.
  6323. */
  6324. goBack(): void;
  6325. /**
  6326. * Makes the guest page go forward.
  6327. */
  6328. goForward(): void;
  6329. /**
  6330. * Navigates to the specified absolute index.
  6331. */
  6332. goToIndex(index: number): void;
  6333. /**
  6334. * Navigates to the specified offset from the "current entry".
  6335. */
  6336. goToOffset(offset: number): void;
  6337. /**
  6338. * Injects CSS into the guest page.
  6339. */
  6340. insertCSS(css: string): void;
  6341. /**
  6342. * Inserts text to the focused element.
  6343. */
  6344. insertText(text: string): void;
  6345. /**
  6346. * Starts inspecting element at position (x, y) of guest page.
  6347. */
  6348. inspectElement(x: number, y: number): void;
  6349. /**
  6350. * Opens the DevTools for the service worker context present in the guest page.
  6351. */
  6352. inspectServiceWorker(): void;
  6353. isAudioMuted(): boolean;
  6354. isCrashed(): boolean;
  6355. isDevToolsFocused(): boolean;
  6356. isDevToolsOpened(): boolean;
  6357. isLoading(): boolean;
  6358. isWaitingForResponse(): boolean;
  6359. /**
  6360. * Loads the url in the webview, the url must contain the protocol prefix, e.g. the
  6361. * http:// or file://.
  6362. */
  6363. loadURL(url: string, options?: LoadURLOptions): void;
  6364. /**
  6365. * Opens a DevTools window for guest page.
  6366. */
  6367. openDevTools(): void;
  6368. /**
  6369. * Executes editing command paste in page.
  6370. */
  6371. paste(): void;
  6372. /**
  6373. * Executes editing command pasteAndMatchStyle in page.
  6374. */
  6375. pasteAndMatchStyle(): void;
  6376. /**
  6377. * Prints webview's web page. Same as webContents.print([options]).
  6378. */
  6379. print(options?: PrintOptions): void;
  6380. /**
  6381. * Prints webview's web page as PDF, Same as webContents.printToPDF(options,
  6382. * callback).
  6383. */
  6384. printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void;
  6385. /**
  6386. * Executes editing command redo in page.
  6387. */
  6388. redo(): void;
  6389. /**
  6390. * Reloads the guest page.
  6391. */
  6392. reload(): void;
  6393. /**
  6394. * Reloads the guest page and ignores cache.
  6395. */
  6396. reloadIgnoringCache(): void;
  6397. /**
  6398. * Executes editing command replace in page.
  6399. */
  6400. replace(text: string): void;
  6401. /**
  6402. * Executes editing command replaceMisspelling in page.
  6403. */
  6404. replaceMisspelling(text: string): void;
  6405. /**
  6406. * Executes editing command selectAll in page.
  6407. */
  6408. selectAll(): void;
  6409. /**
  6410. * Send an asynchronous message to renderer process via channel, you can also send
  6411. * arbitrary arguments. The renderer process can handle the message by listening to
  6412. * the channel event with the ipcRenderer module. See webContents.send for
  6413. * examples.
  6414. */
  6415. send(channel: string, ...args: any[]): void;
  6416. /**
  6417. * Sends an input event to the page. See webContents.sendInputEvent for detailed
  6418. * description of event object.
  6419. */
  6420. sendInputEvent(event: any): void;
  6421. /**
  6422. * Set guest page muted.
  6423. */
  6424. setAudioMuted(muted: boolean): void;
  6425. /**
  6426. * Overrides the user agent for the guest page.
  6427. */
  6428. setUserAgent(userAgent: string): void;
  6429. /**
  6430. * Changes the zoom factor to the specified factor. Zoom factor is zoom percent
  6431. * divided by 100, so 300% = 3.0.
  6432. */
  6433. setZoomFactor(factor: number): void;
  6434. /**
  6435. * Changes the zoom level to the specified level. The original size is 0 and each
  6436. * increment above or below represents zooming 20% larger or smaller to default
  6437. * limits of 300% and 50% of original size, respectively.
  6438. */
  6439. setZoomLevel(level: number): void;
  6440. /**
  6441. * Shows pop-up dictionary that searches the selected word on the page.
  6442. */
  6443. showDefinitionForSelection(): void;
  6444. /**
  6445. * Stops any pending navigation.
  6446. */
  6447. stop(): void;
  6448. /**
  6449. * Stops any findInPage request for the webview with the provided action.
  6450. */
  6451. stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
  6452. /**
  6453. * Executes editing command undo in page.
  6454. */
  6455. undo(): void;
  6456. /**
  6457. * Executes editing command unselect in page.
  6458. */
  6459. unselect(): void;
  6460. /**
  6461. * When this attribute is present the guest page will be allowed to open new
  6462. * windows. Popups are disabled by default.
  6463. */
  6464. allowpopups?: string;
  6465. /**
  6466. * When this attribute is present the webview container will automatically resize
  6467. * within the bounds specified by the attributes minwidth, minheight, maxwidth, and
  6468. * maxheight. These constraints do not impact the webview unless autosize is
  6469. * enabled. When autosize is enabled, the webview container size cannot be less
  6470. * than the minimum values or greater than the maximum.
  6471. */
  6472. autosize?: string;
  6473. /**
  6474. * A list of strings which specifies the blink features to be disabled separated by
  6475. * ,. The full list of supported feature strings can be found in the
  6476. * RuntimeEnabledFeatures.json5 file.
  6477. */
  6478. disableblinkfeatures?: string;
  6479. /**
  6480. * When this attribute is present the guest page will have web security disabled.
  6481. * Web security is enabled by default.
  6482. */
  6483. disablewebsecurity?: string;
  6484. /**
  6485. * A list of strings which specifies the blink features to be enabled separated by
  6486. * ,. The full list of supported feature strings can be found in the
  6487. * RuntimeEnabledFeatures.json5 file.
  6488. */
  6489. enableblinkfeatures?: string;
  6490. /**
  6491. * Sets the referrer URL for the guest page.
  6492. */
  6493. httpreferrer?: string;
  6494. /**
  6495. * When this attribute is present the guest page in webview will have node
  6496. * integration and can use node APIs like require and process to access low level
  6497. * system resources. Node integration is disabled by default in the guest page.
  6498. */
  6499. nodeintegration?: string;
  6500. /**
  6501. * Sets the session used by the page. If partition starts with persist:, the page
  6502. * will use a persistent session available to all pages in the app with the same
  6503. * partition. if there is no persist: prefix, the page will use an in-memory
  6504. * session. By assigning the same partition, multiple pages can share the same
  6505. * session. If the partition is unset then default session of the app will be used.
  6506. * This value can only be modified before the first navigation, since the session
  6507. * of an active renderer process cannot change. Subsequent attempts to modify the
  6508. * value will fail with a DOM exception.
  6509. */
  6510. partition?: string;
  6511. /**
  6512. * When this attribute is present the guest page in webview will be able to use
  6513. * browser plugins. Plugins are disabled by default.
  6514. */
  6515. plugins?: string;
  6516. /**
  6517. * Specifies a script that will be loaded before other scripts run in the guest
  6518. * page. The protocol of script's URL must be either file: or asar:, because it
  6519. * will be loaded by require in guest page under the hood. When the guest page
  6520. * doesn't have node integration this script will still have access to all Node
  6521. * APIs, but global objects injected by Node will be deleted after this script has
  6522. * finished executing. Note: This option will be appear as preloadURL (not preload)
  6523. * in the webPreferences specified to the will-attach-webview event.
  6524. */
  6525. preload?: string;
  6526. /**
  6527. * Returns the visible URL. Writing to this attribute initiates top-level
  6528. * navigation. Assigning src its own value will reload the current page. The src
  6529. * attribute can also accept data URLs, such as data:text/plain,Hello, world!.
  6530. */
  6531. src?: string;
  6532. /**
  6533. * Sets the user agent for the guest page before the page is navigated to. Once the
  6534. * page is loaded, use the setUserAgent method to change the user agent.
  6535. */
  6536. useragent?: string;
  6537. /**
  6538. * A list of strings which specifies the web preferences to be set on the webview,
  6539. * separated by ,. The full list of supported preference strings can be found in
  6540. * BrowserWindow. The string follows the same format as the features string in
  6541. * window.open. A name by itself is given a true boolean value. A preference can be
  6542. * set to another value by including an =, followed by the value. Special values
  6543. * yes and 1 are interpreted as true, while no and 0 are interpreted as false.
  6544. */
  6545. webpreferences?: string;
  6546. }
  6547. interface AboutPanelOptionsOptions {
  6548. /**
  6549. * The app's name.
  6550. */
  6551. applicationName?: string;
  6552. /**
  6553. * The app's version.
  6554. */
  6555. applicationVersion?: string;
  6556. /**
  6557. * Copyright information.
  6558. */
  6559. copyright?: string;
  6560. /**
  6561. * Credit information.
  6562. */
  6563. credits?: string;
  6564. /**
  6565. * The app's build version number.
  6566. */
  6567. version?: string;
  6568. }
  6569. interface AddRepresentationOptions {
  6570. /**
  6571. * The scale factor to add the image representation for.
  6572. */
  6573. scaleFactor: number;
  6574. /**
  6575. * Defaults to 0. Required if a bitmap buffer is specified as buffer.
  6576. */
  6577. width?: number;
  6578. /**
  6579. * Defaults to 0. Required if a bitmap buffer is specified as buffer.
  6580. */
  6581. height?: number;
  6582. /**
  6583. * The buffer containing the raw image data.
  6584. */
  6585. buffer?: Buffer;
  6586. /**
  6587. * The data URL containing either a base 64 encoded PNG or JPEG image.
  6588. */
  6589. dataURL?: string;
  6590. }
  6591. interface AppDetailsOptions {
  6592. /**
  6593. * Window's . It has to be set, otherwise the other options will have no effect.
  6594. */
  6595. appId?: string;
  6596. /**
  6597. * Window's .
  6598. */
  6599. appIconPath?: string;
  6600. /**
  6601. * Index of the icon in appIconPath. Ignored when appIconPath is not set. Default
  6602. * is 0.
  6603. */
  6604. appIconIndex?: number;
  6605. /**
  6606. * Window's .
  6607. */
  6608. relaunchCommand?: string;
  6609. /**
  6610. * Window's .
  6611. */
  6612. relaunchDisplayName?: string;
  6613. }
  6614. interface AuthInfo {
  6615. isProxy: boolean;
  6616. scheme: string;
  6617. host: string;
  6618. port: number;
  6619. realm: string;
  6620. }
  6621. interface AutoResizeOptions {
  6622. /**
  6623. * If true, the view's width will grow and shrink together with the window. false
  6624. * by default.
  6625. */
  6626. width: boolean;
  6627. /**
  6628. * If true, the view's height will grow and shrink together with the window. false
  6629. * by default.
  6630. */
  6631. height: boolean;
  6632. }
  6633. interface BitmapOptions {
  6634. /**
  6635. * Defaults to 1.0.
  6636. */
  6637. scaleFactor?: number;
  6638. }
  6639. interface BrowserViewConstructorOptions {
  6640. /**
  6641. * See .
  6642. */
  6643. webPreferences?: WebPreferences;
  6644. }
  6645. interface BrowserWindowConstructorOptions {
  6646. /**
  6647. * Window's width in pixels. Default is 800.
  6648. */
  6649. width?: number;
  6650. /**
  6651. * Window's height in pixels. Default is 600.
  6652. */
  6653. height?: number;
  6654. /**
  6655. * ( if y is used) Window's left offset from screen. Default is to center the
  6656. * window.
  6657. */
  6658. x?: number;
  6659. /**
  6660. * ( if x is used) Window's top offset from screen. Default is to center the
  6661. * window.
  6662. */
  6663. y?: number;
  6664. /**
  6665. * The width and height would be used as web page's size, which means the actual
  6666. * window's size will include window frame's size and be slightly larger. Default
  6667. * is false.
  6668. */
  6669. useContentSize?: boolean;
  6670. /**
  6671. * Show window in the center of the screen.
  6672. */
  6673. center?: boolean;
  6674. /**
  6675. * Window's minimum width. Default is 0.
  6676. */
  6677. minWidth?: number;
  6678. /**
  6679. * Window's minimum height. Default is 0.
  6680. */
  6681. minHeight?: number;
  6682. /**
  6683. * Window's maximum width. Default is no limit.
  6684. */
  6685. maxWidth?: number;
  6686. /**
  6687. * Window's maximum height. Default is no limit.
  6688. */
  6689. maxHeight?: number;
  6690. /**
  6691. * Whether window is resizable. Default is true.
  6692. */
  6693. resizable?: boolean;
  6694. /**
  6695. * Whether window is movable. This is not implemented on Linux. Default is true.
  6696. */
  6697. movable?: boolean;
  6698. /**
  6699. * Whether window is minimizable. This is not implemented on Linux. Default is
  6700. * true.
  6701. */
  6702. minimizable?: boolean;
  6703. /**
  6704. * Whether window is maximizable. This is not implemented on Linux. Default is
  6705. * true.
  6706. */
  6707. maximizable?: boolean;
  6708. /**
  6709. * Whether window is closable. This is not implemented on Linux. Default is true.
  6710. */
  6711. closable?: boolean;
  6712. /**
  6713. * Whether the window can be focused. Default is true. On Windows setting
  6714. * focusable: false also implies setting skipTaskbar: true. On Linux setting
  6715. * focusable: false makes the window stop interacting with wm, so the window will
  6716. * always stay on top in all workspaces.
  6717. */
  6718. focusable?: boolean;
  6719. /**
  6720. * Whether the window should always stay on top of other windows. Default is false.
  6721. */
  6722. alwaysOnTop?: boolean;
  6723. /**
  6724. * Whether the window should show in fullscreen. When explicitly set to false the
  6725. * fullscreen button will be hidden or disabled on macOS. Default is false.
  6726. */
  6727. fullscreen?: boolean;
  6728. /**
  6729. * Whether the window can be put into fullscreen mode. On macOS, also whether the
  6730. * maximize/zoom button should toggle full screen mode or maximize window. Default
  6731. * is true.
  6732. */
  6733. fullscreenable?: boolean;
  6734. /**
  6735. * Use pre-Lion fullscreen on macOS. Default is false.
  6736. */
  6737. simpleFullscreen?: boolean;
  6738. /**
  6739. * Whether to show the window in taskbar. Default is false.
  6740. */
  6741. skipTaskbar?: boolean;
  6742. /**
  6743. * The kiosk mode. Default is false.
  6744. */
  6745. kiosk?: boolean;
  6746. /**
  6747. * Default window title. Default is "Electron".
  6748. */
  6749. title?: string;
  6750. /**
  6751. * The window icon. On Windows it is recommended to use ICO icons to get best
  6752. * visual effects, you can also leave it undefined so the executable's icon will be
  6753. * used.
  6754. */
  6755. icon?: NativeImage | string;
  6756. /**
  6757. * Whether window should be shown when created. Default is true.
  6758. */
  6759. show?: boolean;
  6760. /**
  6761. * Specify false to create a . Default is true.
  6762. */
  6763. frame?: boolean;
  6764. /**
  6765. * Specify parent window. Default is null.
  6766. */
  6767. parent?: BrowserWindow;
  6768. /**
  6769. * Whether this is a modal window. This only works when the window is a child
  6770. * window. Default is false.
  6771. */
  6772. modal?: boolean;
  6773. /**
  6774. * Whether the web view accepts a single mouse-down event that simultaneously
  6775. * activates the window. Default is false.
  6776. */
  6777. acceptFirstMouse?: boolean;
  6778. /**
  6779. * Whether to hide cursor when typing. Default is false.
  6780. */
  6781. disableAutoHideCursor?: boolean;
  6782. /**
  6783. * Auto hide the menu bar unless the Alt key is pressed. Default is false.
  6784. */
  6785. autoHideMenuBar?: boolean;
  6786. /**
  6787. * Enable the window to be resized larger than screen. Default is false.
  6788. */
  6789. enableLargerThanScreen?: boolean;
  6790. /**
  6791. * Window's background color as a hexadecimal value, like #66CD00 or #FFF or
  6792. * #80FFFFFF (alpha is supported). Default is #FFF (white).
  6793. */
  6794. backgroundColor?: string;
  6795. /**
  6796. * Whether window should have a shadow. This is only implemented on macOS. Default
  6797. * is true.
  6798. */
  6799. hasShadow?: boolean;
  6800. /**
  6801. * Set the initial opacity of the window, between 0.0 (fully transparent) and 1.0
  6802. * (fully opaque). This is only implemented on Windows and macOS.
  6803. */
  6804. opacity?: number;
  6805. /**
  6806. * Forces using dark theme for the window, only works on some GTK+3 desktop
  6807. * environments. Default is false.
  6808. */
  6809. darkTheme?: boolean;
  6810. /**
  6811. * Makes the window . Default is false.
  6812. */
  6813. transparent?: boolean;
  6814. /**
  6815. * The type of window, default is normal window. See more about this below.
  6816. */
  6817. type?: string;
  6818. /**
  6819. * The style of window title bar. Default is default. Possible values are:
  6820. */
  6821. titleBarStyle?: ('default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover');
  6822. /**
  6823. * Shows the title in the title bar in full screen mode on macOS for all
  6824. * titleBarStyle options. Default is false.
  6825. */
  6826. fullscreenWindowTitle?: boolean;
  6827. /**
  6828. * Use WS_THICKFRAME style for frameless windows on Windows, which adds standard
  6829. * window frame. Setting it to false will remove window shadow and window
  6830. * animations. Default is true.
  6831. */
  6832. thickFrame?: boolean;
  6833. /**
  6834. * Add a type of vibrancy effect to the window, only on macOS. Can be
  6835. * appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
  6836. * medium-light or ultra-dark. Please note that using frame: false in combination
  6837. * with a vibrancy value requires that you use a non-default titleBarStyle as well.
  6838. */
  6839. vibrancy?: ('appearance-based' | 'light' | 'dark' | 'titlebar' | 'selection' | 'menu' | 'popover' | 'sidebar' | 'medium-light' | 'ultra-dark');
  6840. /**
  6841. * Controls the behavior on macOS when option-clicking the green stoplight button
  6842. * on the toolbar or by clicking the Window > Zoom menu item. If true, the window
  6843. * will grow to the preferred width of the web page when zoomed, false will cause
  6844. * it to zoom to the width of the screen. This will also affect the behavior when
  6845. * calling maximize() directly. Default is false.
  6846. */
  6847. zoomToPageWidth?: boolean;
  6848. /**
  6849. * Tab group name, allows opening the window as a native tab on macOS 10.12+.
  6850. * Windows with the same tabbing identifier will be grouped together. This also
  6851. * adds a native new tab button to your window's tab bar and allows your app and
  6852. * window to receive the new-window-for-tab event.
  6853. */
  6854. tabbingIdentifier?: string;
  6855. /**
  6856. * Settings of web page's features.
  6857. */
  6858. webPreferences?: WebPreferences;
  6859. }
  6860. interface CertificateTrustDialogOptions {
  6861. /**
  6862. * The certificate to trust/import.
  6863. */
  6864. certificate: Certificate;
  6865. /**
  6866. * The message to display to the user.
  6867. */
  6868. message: string;
  6869. }
  6870. interface CertificateVerifyProcRequest {
  6871. hostname: string;
  6872. certificate: Certificate;
  6873. /**
  6874. * Verification result from chromium.
  6875. */
  6876. verificationResult: string;
  6877. /**
  6878. * Error code.
  6879. */
  6880. errorCode: number;
  6881. }
  6882. interface ClearStorageDataOptions {
  6883. /**
  6884. * Should follow window.location.origin’s representation scheme://host:port.
  6885. */
  6886. origin?: string;
  6887. /**
  6888. * The types of storages to clear, can contain: appcache, cookies, filesystem,
  6889. * indexdb, localstorage, shadercache, websql, serviceworkers, cachestorage.
  6890. */
  6891. storages?: string[];
  6892. /**
  6893. * The types of quotas to clear, can contain: temporary, persistent, syncable.
  6894. */
  6895. quotas?: string[];
  6896. }
  6897. interface CommandLine {
  6898. /**
  6899. * Append a switch (with optional value) to Chromium's command line. Note: This
  6900. * will not affect process.argv, and is mainly used by developers to control some
  6901. * low-level Chromium behaviors.
  6902. */
  6903. appendSwitch: (the_switch: string, value?: string) => void;
  6904. /**
  6905. * Append an argument to Chromium's command line. The argument will be quoted
  6906. * correctly. Note: This will not affect process.argv.
  6907. */
  6908. appendArgument: (value: string) => void;
  6909. }
  6910. interface Config {
  6911. /**
  6912. * The URL associated with the PAC file.
  6913. */
  6914. pacScript: string;
  6915. /**
  6916. * Rules indicating which proxies to use.
  6917. */
  6918. proxyRules: string;
  6919. /**
  6920. * Rules indicating which URLs should bypass the proxy settings.
  6921. */
  6922. proxyBypassRules: string;
  6923. }
  6924. interface ConsoleMessageEvent extends Event {
  6925. level: number;
  6926. message: string;
  6927. line: number;
  6928. sourceId: string;
  6929. }
  6930. interface ContextMenuParams {
  6931. /**
  6932. * x coordinate.
  6933. */
  6934. x: number;
  6935. /**
  6936. * y coordinate.
  6937. */
  6938. y: number;
  6939. /**
  6940. * URL of the link that encloses the node the context menu was invoked on.
  6941. */
  6942. linkURL: string;
  6943. /**
  6944. * Text associated with the link. May be an empty string if the contents of the
  6945. * link are an image.
  6946. */
  6947. linkText: string;
  6948. /**
  6949. * URL of the top level page that the context menu was invoked on.
  6950. */
  6951. pageURL: string;
  6952. /**
  6953. * URL of the subframe that the context menu was invoked on.
  6954. */
  6955. frameURL: string;
  6956. /**
  6957. * Source URL for the element that the context menu was invoked on. Elements with
  6958. * source URLs are images, audio and video.
  6959. */
  6960. srcURL: string;
  6961. /**
  6962. * Type of the node the context menu was invoked on. Can be none, image, audio,
  6963. * video, canvas, file or plugin.
  6964. */
  6965. mediaType: ('none' | 'image' | 'audio' | 'video' | 'canvas' | 'file' | 'plugin');
  6966. /**
  6967. * Whether the context menu was invoked on an image which has non-empty contents.
  6968. */
  6969. hasImageContents: boolean;
  6970. /**
  6971. * Whether the context is editable.
  6972. */
  6973. isEditable: boolean;
  6974. /**
  6975. * Text of the selection that the context menu was invoked on.
  6976. */
  6977. selectionText: string;
  6978. /**
  6979. * Title or alt text of the selection that the context was invoked on.
  6980. */
  6981. titleText: string;
  6982. /**
  6983. * The misspelled word under the cursor, if any.
  6984. */
  6985. misspelledWord: string;
  6986. /**
  6987. * The character encoding of the frame on which the menu was invoked.
  6988. */
  6989. frameCharset: string;
  6990. /**
  6991. * If the context menu was invoked on an input field, the type of that field.
  6992. * Possible values are none, plainText, password, other.
  6993. */
  6994. inputFieldType: string;
  6995. /**
  6996. * Input source that invoked the context menu. Can be none, mouse, keyboard, touch
  6997. * or touchMenu.
  6998. */
  6999. menuSourceType: ('none' | 'mouse' | 'keyboard' | 'touch' | 'touchMenu');
  7000. /**
  7001. * The flags for the media element the context menu was invoked on.
  7002. */
  7003. mediaFlags: MediaFlags;
  7004. /**
  7005. * These flags indicate whether the renderer believes it is able to perform the
  7006. * corresponding action.
  7007. */
  7008. editFlags: EditFlags;
  7009. }
  7010. interface CrashReporterStartOptions {
  7011. companyName?: string;
  7012. /**
  7013. * URL that crash reports will be sent to as POST.
  7014. */
  7015. submitURL: string;
  7016. /**
  7017. * Defaults to app.getName().
  7018. */
  7019. productName?: string;
  7020. /**
  7021. * Whether crash reports should be sent to the server Default is true.
  7022. */
  7023. uploadToServer?: boolean;
  7024. /**
  7025. * Default is false.
  7026. */
  7027. ignoreSystemCrashHandler?: boolean;
  7028. /**
  7029. * An object you can define that will be sent along with the report. Only string
  7030. * properties are sent correctly. Nested objects are not supported and the property
  7031. * names and values must be less than 64 characters long.
  7032. */
  7033. extra?: Extra;
  7034. /**
  7035. * Directory to store the crashreports temporarily (only used when the crash
  7036. * reporter is started via process.crashReporter.start).
  7037. */
  7038. crashesDirectory?: string;
  7039. }
  7040. interface CreateFromBufferOptions {
  7041. /**
  7042. * Required for bitmap buffers.
  7043. */
  7044. width?: number;
  7045. /**
  7046. * Required for bitmap buffers.
  7047. */
  7048. height?: number;
  7049. /**
  7050. * Defaults to 1.0.
  7051. */
  7052. scaleFactor?: number;
  7053. }
  7054. interface CreateInterruptedDownloadOptions {
  7055. /**
  7056. * Absolute path of the download.
  7057. */
  7058. path: string;
  7059. /**
  7060. * Complete URL chain for the download.
  7061. */
  7062. urlChain: string[];
  7063. mimeType?: string;
  7064. /**
  7065. * Start range for the download.
  7066. */
  7067. offset: number;
  7068. /**
  7069. * Total length of the download.
  7070. */
  7071. length: number;
  7072. /**
  7073. * Last-Modified header value.
  7074. */
  7075. lastModified: string;
  7076. /**
  7077. * ETag header value.
  7078. */
  7079. eTag: string;
  7080. /**
  7081. * Time when download was started in number of seconds since UNIX epoch.
  7082. */
  7083. startTime?: number;
  7084. }
  7085. interface Data {
  7086. text?: string;
  7087. html?: string;
  7088. image?: NativeImage;
  7089. rtf?: string;
  7090. /**
  7091. * The title of the url at text.
  7092. */
  7093. bookmark?: string;
  7094. }
  7095. interface Details {
  7096. /**
  7097. * The url to associate the cookie with.
  7098. */
  7099. url: string;
  7100. /**
  7101. * The name of the cookie. Empty by default if omitted.
  7102. */
  7103. name?: string;
  7104. /**
  7105. * The value of the cookie. Empty by default if omitted.
  7106. */
  7107. value?: string;
  7108. /**
  7109. * The domain of the cookie. Empty by default if omitted.
  7110. */
  7111. domain?: string;
  7112. /**
  7113. * The path of the cookie. Empty by default if omitted.
  7114. */
  7115. path?: string;
  7116. /**
  7117. * Whether the cookie should be marked as Secure. Defaults to false.
  7118. */
  7119. secure?: boolean;
  7120. /**
  7121. * Whether the cookie should be marked as HTTP only. Defaults to false.
  7122. */
  7123. httpOnly?: boolean;
  7124. /**
  7125. * The expiration date of the cookie as the number of seconds since the UNIX epoch.
  7126. * If omitted then the cookie becomes a session cookie and will not be retained
  7127. * between sessions.
  7128. */
  7129. expirationDate?: number;
  7130. }
  7131. interface DevToolsExtensions {
  7132. }
  7133. interface DidChangeThemeColorEvent extends Event {
  7134. themeColor: string;
  7135. }
  7136. interface DidFailLoadEvent extends Event {
  7137. errorCode: number;
  7138. errorDescription: string;
  7139. validatedURL: string;
  7140. isMainFrame: boolean;
  7141. }
  7142. interface DidFrameFinishLoadEvent extends Event {
  7143. isMainFrame: boolean;
  7144. }
  7145. interface DidNavigateEvent extends Event {
  7146. url: string;
  7147. }
  7148. interface DidNavigateInPageEvent extends Event {
  7149. isMainFrame: boolean;
  7150. url: string;
  7151. }
  7152. interface DisplayBalloonOptions {
  7153. /**
  7154. * -
  7155. */
  7156. icon?: NativeImage | string;
  7157. title: string;
  7158. content: string;
  7159. }
  7160. interface Dock {
  7161. /**
  7162. * When critical is passed, the dock icon will bounce until either the application
  7163. * becomes active or the request is canceled. When informational is passed, the
  7164. * dock icon will bounce for one second. However, the request remains active until
  7165. * either the application becomes active or the request is canceled.
  7166. */
  7167. bounce: (type?: 'critical' | 'informational') => number;
  7168. /**
  7169. * Cancel the bounce of id.
  7170. */
  7171. cancelBounce: (id: number) => void;
  7172. /**
  7173. * Bounces the Downloads stack if the filePath is inside the Downloads folder.
  7174. */
  7175. downloadFinished: (filePath: string) => void;
  7176. /**
  7177. * Sets the string to be displayed in the dock’s badging area.
  7178. */
  7179. setBadge: (text: string) => void;
  7180. getBadge: () => string;
  7181. /**
  7182. * Hides the dock icon.
  7183. */
  7184. hide: () => void;
  7185. /**
  7186. * Shows the dock icon.
  7187. */
  7188. show: () => void;
  7189. isVisible: () => boolean;
  7190. /**
  7191. * Sets the application's dock menu.
  7192. */
  7193. setMenu: (menu: Menu) => void;
  7194. /**
  7195. * Sets the image associated with this dock icon.
  7196. */
  7197. setIcon: (image: NativeImage | string) => void;
  7198. }
  7199. interface EnableNetworkEmulationOptions {
  7200. /**
  7201. * Whether to emulate network outage. Defaults to false.
  7202. */
  7203. offline?: boolean;
  7204. /**
  7205. * RTT in ms. Defaults to 0 which will disable latency throttling.
  7206. */
  7207. latency?: number;
  7208. /**
  7209. * Download rate in Bps. Defaults to 0 which will disable download throttling.
  7210. */
  7211. downloadThroughput?: number;
  7212. /**
  7213. * Upload rate in Bps. Defaults to 0 which will disable upload throttling.
  7214. */
  7215. uploadThroughput?: number;
  7216. }
  7217. interface Extensions {
  7218. }
  7219. interface FeedURLOptions {
  7220. url: string;
  7221. /**
  7222. * HTTP request headers.
  7223. */
  7224. headers?: Headers;
  7225. /**
  7226. * Either json or default, see the README for more information.
  7227. */
  7228. serverType?: string;
  7229. }
  7230. interface FileIconOptions {
  7231. size: ('small' | 'normal' | 'large');
  7232. }
  7233. interface Filter {
  7234. /**
  7235. * Retrieves cookies which are associated with url. Empty implies retrieving
  7236. * cookies of all urls.
  7237. */
  7238. url?: string;
  7239. /**
  7240. * Filters cookies by name.
  7241. */
  7242. name?: string;
  7243. /**
  7244. * Retrieves cookies whose domains match or are subdomains of domains.
  7245. */
  7246. domain?: string;
  7247. /**
  7248. * Retrieves cookies whose path matches path.
  7249. */
  7250. path?: string;
  7251. /**
  7252. * Filters cookies by their Secure property.
  7253. */
  7254. secure?: boolean;
  7255. /**
  7256. * Filters out session or persistent cookies.
  7257. */
  7258. session?: boolean;
  7259. }
  7260. interface FindInPageOptions {
  7261. /**
  7262. * Whether to search forward or backward, defaults to true.
  7263. */
  7264. forward?: boolean;
  7265. /**
  7266. * Whether the operation is first request or a follow up, defaults to false.
  7267. */
  7268. findNext?: boolean;
  7269. /**
  7270. * Whether search should be case-sensitive, defaults to false.
  7271. */
  7272. matchCase?: boolean;
  7273. /**
  7274. * Whether to look only at the start of words. defaults to false.
  7275. */
  7276. wordStart?: boolean;
  7277. /**
  7278. * When combined with wordStart, accepts a match in the middle of a word if the
  7279. * match begins with an uppercase letter followed by a lowercase or non-letter.
  7280. * Accepts several other intra-word matches, defaults to false.
  7281. */
  7282. medialCapitalAsWordStart?: boolean;
  7283. }
  7284. interface FoundInPageEvent extends Event {
  7285. result: FoundInPageResult;
  7286. }
  7287. interface FromPartitionOptions {
  7288. /**
  7289. * Whether to enable cache.
  7290. */
  7291. cache: boolean;
  7292. }
  7293. interface Header {
  7294. /**
  7295. * Specify an extra header name.
  7296. */
  7297. name: string;
  7298. }
  7299. interface Headers {
  7300. }
  7301. interface HeapStatistics {
  7302. totalHeapSize: number;
  7303. totalHeapSizeExecutable: number;
  7304. totalPhysicalSize: number;
  7305. totalAvailableSize: number;
  7306. usedHeapSize: number;
  7307. heapSizeLimit: number;
  7308. mallocedMemory: number;
  7309. peakMallocedMemory: number;
  7310. doesZapGarbage: boolean;
  7311. }
  7312. interface IgnoreMouseEventsOptions {
  7313. /**
  7314. * If true, forwards mouse move messages to Chromium, enabling mouse related events
  7315. * such as mouseleave. Only used when ignore is true. If ignore is false,
  7316. * forwarding is always disabled regardless of this value.
  7317. */
  7318. forward?: boolean;
  7319. }
  7320. interface ImportCertificateOptions {
  7321. /**
  7322. * Path for the pkcs12 file.
  7323. */
  7324. certificate: string;
  7325. /**
  7326. * Passphrase for the certificate.
  7327. */
  7328. password: string;
  7329. }
  7330. interface Input {
  7331. /**
  7332. * Either keyUp or keyDown.
  7333. */
  7334. type: string;
  7335. /**
  7336. * Equivalent to .
  7337. */
  7338. key: string;
  7339. /**
  7340. * Equivalent to .
  7341. */
  7342. code: string;
  7343. /**
  7344. * Equivalent to .
  7345. */
  7346. isAutoRepeat: boolean;
  7347. /**
  7348. * Equivalent to .
  7349. */
  7350. shift: boolean;
  7351. /**
  7352. * Equivalent to .
  7353. */
  7354. control: boolean;
  7355. /**
  7356. * Equivalent to .
  7357. */
  7358. alt: boolean;
  7359. /**
  7360. * Equivalent to .
  7361. */
  7362. meta: boolean;
  7363. }
  7364. interface InterceptBufferProtocolRequest {
  7365. url: string;
  7366. referrer: string;
  7367. method: string;
  7368. uploadData: UploadData[];
  7369. }
  7370. interface InterceptFileProtocolRequest {
  7371. url: string;
  7372. referrer: string;
  7373. method: string;
  7374. uploadData: UploadData[];
  7375. }
  7376. interface InterceptHttpProtocolRequest {
  7377. url: string;
  7378. referrer: string;
  7379. method: string;
  7380. uploadData: UploadData[];
  7381. }
  7382. interface InterceptStreamProtocolRequest {
  7383. url: string;
  7384. headers: Headers;
  7385. referrer: string;
  7386. method: string;
  7387. uploadData: UploadData[];
  7388. }
  7389. interface InterceptStringProtocolRequest {
  7390. url: string;
  7391. referrer: string;
  7392. method: string;
  7393. uploadData: UploadData[];
  7394. }
  7395. interface IpcMessageEvent extends Event {
  7396. channel: string;
  7397. args: any[];
  7398. }
  7399. interface Item {
  7400. /**
  7401. * or files Array The path(s) to the file(s) being dragged.
  7402. */
  7403. file: string;
  7404. /**
  7405. * The image must be non-empty on macOS.
  7406. */
  7407. icon: NativeImage;
  7408. }
  7409. interface JumpListSettings {
  7410. /**
  7411. * The minimum number of items that will be shown in the Jump List (for a more
  7412. * detailed description of this value see the ).
  7413. */
  7414. minItems: number;
  7415. /**
  7416. * Array of JumpListItem objects that correspond to items that the user has
  7417. * explicitly removed from custom categories in the Jump List. These items must not
  7418. * be re-added to the Jump List in the call to app.setJumpList(), Windows will not
  7419. * display any custom category that contains any of the removed items.
  7420. */
  7421. removedItems: JumpListItem[];
  7422. }
  7423. interface LoadCommitEvent extends Event {
  7424. url: string;
  7425. isMainFrame: boolean;
  7426. }
  7427. interface LoadURLOptions {
  7428. /**
  7429. * An HTTP Referrer url.
  7430. */
  7431. httpReferrer?: string | Referrer;
  7432. /**
  7433. * A user agent originating the request.
  7434. */
  7435. userAgent?: string;
  7436. /**
  7437. * Extra headers separated by "\n"
  7438. */
  7439. extraHeaders?: string;
  7440. postData?: UploadRawData[] | UploadFile[] | UploadBlob[];
  7441. /**
  7442. * Base url (with trailing path separator) for files to be loaded by the data url.
  7443. * This is needed only if the specified url is a data url and needs to load other
  7444. * files.
  7445. */
  7446. baseURLForDataURL?: string;
  7447. }
  7448. interface LoginItemSettings {
  7449. options?: Options;
  7450. /**
  7451. * true if the app is set to open at login.
  7452. */
  7453. openAtLogin: boolean;
  7454. /**
  7455. * true if the app is set to open as hidden at login. This setting is not available
  7456. * on .
  7457. */
  7458. openAsHidden: boolean;
  7459. /**
  7460. * true if the app was opened at login automatically. This setting is not available
  7461. * on .
  7462. */
  7463. wasOpenedAtLogin: boolean;
  7464. /**
  7465. * true if the app was opened as a hidden login item. This indicates that the app
  7466. * should not open any windows at startup. This setting is not available on .
  7467. */
  7468. wasOpenedAsHidden: boolean;
  7469. /**
  7470. * true if the app was opened as a login item that should restore the state from
  7471. * the previous session. This indicates that the app should restore the windows
  7472. * that were open the last time the app was closed. This setting is not available
  7473. * on .
  7474. */
  7475. restoreState: boolean;
  7476. }
  7477. interface LoginItemSettingsOptions {
  7478. /**
  7479. * The executable path to compare against. Defaults to process.execPath.
  7480. */
  7481. path?: string;
  7482. /**
  7483. * The command-line arguments to compare against. Defaults to an empty array.
  7484. */
  7485. args?: string[];
  7486. }
  7487. interface MenuItemConstructorOptions {
  7488. /**
  7489. * Will be called with click(menuItem, browserWindow, event) when the menu item is
  7490. * clicked.
  7491. */
  7492. click?: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void;
  7493. /**
  7494. * Define the action of the menu item, when specified the click property will be
  7495. * ignored. See .
  7496. */
  7497. role?: string;
  7498. /**
  7499. * Can be normal, separator, submenu, checkbox or radio.
  7500. */
  7501. type?: ('normal' | 'separator' | 'submenu' | 'checkbox' | 'radio');
  7502. label?: string;
  7503. sublabel?: string;
  7504. accelerator?: Accelerator;
  7505. icon?: NativeImage | string;
  7506. /**
  7507. * If false, the menu item will be greyed out and unclickable.
  7508. */
  7509. enabled?: boolean;
  7510. /**
  7511. * If false, the menu item will be entirely hidden.
  7512. */
  7513. visible?: boolean;
  7514. /**
  7515. * Should only be specified for checkbox or radio type menu items.
  7516. */
  7517. checked?: boolean;
  7518. /**
  7519. * Should be specified for submenu type menu items. If submenu is specified, the
  7520. * type: 'submenu' can be omitted. If the value is not a then it will be
  7521. * automatically converted to one using Menu.buildFromTemplate.
  7522. */
  7523. submenu?: MenuItemConstructorOptions[] | Menu;
  7524. /**
  7525. * Unique within a single menu. If defined then it can be used as a reference to
  7526. * this item by the position attribute.
  7527. */
  7528. id?: string;
  7529. /**
  7530. * This field allows fine-grained definition of the specific location within a
  7531. * given menu.
  7532. */
  7533. position?: string;
  7534. }
  7535. interface MessageBoxOptions {
  7536. /**
  7537. * Can be "none", "info", "error", "question" or "warning". On Windows, "question"
  7538. * displays the same icon as "info", unless you set an icon using the "icon"
  7539. * option. On macOS, both "warning" and "error" display the same warning icon.
  7540. */
  7541. type?: string;
  7542. /**
  7543. * Array of texts for buttons. On Windows, an empty array will result in one button
  7544. * labeled "OK".
  7545. */
  7546. buttons?: string[];
  7547. /**
  7548. * Index of the button in the buttons array which will be selected by default when
  7549. * the message box opens.
  7550. */
  7551. defaultId?: number;
  7552. /**
  7553. * Title of the message box, some platforms will not show it.
  7554. */
  7555. title?: string;
  7556. /**
  7557. * Content of the message box.
  7558. */
  7559. message: string;
  7560. /**
  7561. * Extra information of the message.
  7562. */
  7563. detail?: string;
  7564. /**
  7565. * If provided, the message box will include a checkbox with the given label. The
  7566. * checkbox state can be inspected only when using callback.
  7567. */
  7568. checkboxLabel?: string;
  7569. /**
  7570. * Initial checked state of the checkbox. false by default.
  7571. */
  7572. checkboxChecked?: boolean;
  7573. icon?: NativeImage;
  7574. /**
  7575. * The index of the button to be used to cancel the dialog, via the Esc key. By
  7576. * default this is assigned to the first button with "cancel" or "no" as the label.
  7577. * If no such labeled buttons exist and this option is not set, 0 will be used as
  7578. * the return value or callback response. This option is ignored on Windows.
  7579. */
  7580. cancelId?: number;
  7581. /**
  7582. * On Windows Electron will try to figure out which one of the buttons are common
  7583. * buttons (like "Cancel" or "Yes"), and show the others as command links in the
  7584. * dialog. This can make the dialog appear in the style of modern Windows apps. If
  7585. * you don't like this behavior, you can set noLink to true.
  7586. */
  7587. noLink?: boolean;
  7588. /**
  7589. * Normalize the keyboard access keys across platforms. Default is false. Enabling
  7590. * this assumes & is used in the button labels for the placement of the keyboard
  7591. * shortcut access key and labels will be converted so they work correctly on each
  7592. * platform, & characters are removed on macOS, converted to _ on Linux, and left
  7593. * untouched on Windows. For example, a button label of Vie&w will be converted to
  7594. * Vie_w on Linux and View on macOS and can be selected via Alt-W on Windows and
  7595. * Linux.
  7596. */
  7597. normalizeAccessKeys?: boolean;
  7598. }
  7599. interface NewWindowEvent extends Event {
  7600. url: string;
  7601. frameName: string;
  7602. /**
  7603. * Can be `default`, `foreground-tab`, `background-tab`, `new-window`,
  7604. * `save-to-disk` and `other`.
  7605. */
  7606. disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other');
  7607. /**
  7608. * The options which should be used for creating the new .
  7609. */
  7610. options: Options;
  7611. }
  7612. interface NotificationConstructorOptions {
  7613. /**
  7614. * A title for the notification, which will be shown at the top of the notification
  7615. * window when it is shown.
  7616. */
  7617. title: string;
  7618. /**
  7619. * A subtitle for the notification, which will be displayed below the title.
  7620. */
  7621. subtitle?: string;
  7622. /**
  7623. * The body text of the notification, which will be displayed below the title or
  7624. * subtitle.
  7625. */
  7626. body: string;
  7627. /**
  7628. * Whether or not to emit an OS notification noise when showing the notification.
  7629. */
  7630. silent?: boolean;
  7631. /**
  7632. * An icon to use in the notification.
  7633. */
  7634. icon?: string | NativeImage;
  7635. /**
  7636. * Whether or not to add an inline reply option to the notification.
  7637. */
  7638. hasReply?: boolean;
  7639. /**
  7640. * The placeholder to write in the inline reply input field.
  7641. */
  7642. replyPlaceholder?: string;
  7643. /**
  7644. * The name of the sound file to play when the notification is shown.
  7645. */
  7646. sound?: string;
  7647. /**
  7648. * Actions to add to the notification. Please read the available actions and
  7649. * limitations in the NotificationAction documentation.
  7650. */
  7651. actions?: NotificationAction[];
  7652. /**
  7653. * A custom title for the close button of an alert. An empty string will cause the
  7654. * default localized text to be used.
  7655. */
  7656. closeButtonText?: string;
  7657. }
  7658. interface OnBeforeRedirectDetails {
  7659. id: number;
  7660. url: string;
  7661. method: string;
  7662. webContentsId?: number;
  7663. resourceType: string;
  7664. timestamp: number;
  7665. redirectURL: string;
  7666. statusCode: number;
  7667. /**
  7668. * The server IP address that the request was actually sent to.
  7669. */
  7670. ip?: string;
  7671. fromCache: boolean;
  7672. responseHeaders: ResponseHeaders;
  7673. }
  7674. interface OnBeforeRedirectFilter {
  7675. /**
  7676. * Array of URL patterns that will be used to filter out the requests that do not
  7677. * match the URL patterns.
  7678. */
  7679. urls: string[];
  7680. }
  7681. interface OnBeforeRequestDetails {
  7682. id: number;
  7683. url: string;
  7684. method: string;
  7685. webContentsId?: number;
  7686. resourceType: string;
  7687. timestamp: number;
  7688. uploadData: UploadData[];
  7689. }
  7690. interface OnBeforeRequestFilter {
  7691. /**
  7692. * Array of URL patterns that will be used to filter out the requests that do not
  7693. * match the URL patterns.
  7694. */
  7695. urls: string[];
  7696. }
  7697. interface OnBeforeSendHeadersFilter {
  7698. /**
  7699. * Array of URL patterns that will be used to filter out the requests that do not
  7700. * match the URL patterns.
  7701. */
  7702. urls: string[];
  7703. }
  7704. interface OnCompletedDetails {
  7705. id: number;
  7706. url: string;
  7707. method: string;
  7708. webContentsId?: number;
  7709. resourceType: string;
  7710. timestamp: number;
  7711. responseHeaders: ResponseHeaders;
  7712. fromCache: boolean;
  7713. statusCode: number;
  7714. statusLine: string;
  7715. }
  7716. interface OnCompletedFilter {
  7717. /**
  7718. * Array of URL patterns that will be used to filter out the requests that do not
  7719. * match the URL patterns.
  7720. */
  7721. urls: string[];
  7722. }
  7723. interface OnErrorOccurredDetails {
  7724. id: number;
  7725. url: string;
  7726. method: string;
  7727. webContentsId?: number;
  7728. resourceType: string;
  7729. timestamp: number;
  7730. fromCache: boolean;
  7731. /**
  7732. * The error description.
  7733. */
  7734. error: string;
  7735. }
  7736. interface OnErrorOccurredFilter {
  7737. /**
  7738. * Array of URL patterns that will be used to filter out the requests that do not
  7739. * match the URL patterns.
  7740. */
  7741. urls: string[];
  7742. }
  7743. interface OnHeadersReceivedFilter {
  7744. /**
  7745. * Array of URL patterns that will be used to filter out the requests that do not
  7746. * match the URL patterns.
  7747. */
  7748. urls: string[];
  7749. }
  7750. interface OnResponseStartedDetails {
  7751. id: number;
  7752. url: string;
  7753. method: string;
  7754. webContentsId?: number;
  7755. resourceType: string;
  7756. timestamp: number;
  7757. responseHeaders: ResponseHeaders;
  7758. /**
  7759. * Indicates whether the response was fetched from disk cache.
  7760. */
  7761. fromCache: boolean;
  7762. statusCode: number;
  7763. statusLine: string;
  7764. }
  7765. interface OnResponseStartedFilter {
  7766. /**
  7767. * Array of URL patterns that will be used to filter out the requests that do not
  7768. * match the URL patterns.
  7769. */
  7770. urls: string[];
  7771. }
  7772. interface OnSendHeadersDetails {
  7773. id: number;
  7774. url: string;
  7775. method: string;
  7776. webContentsId?: number;
  7777. resourceType: string;
  7778. timestamp: number;
  7779. requestHeaders: RequestHeaders;
  7780. }
  7781. interface OnSendHeadersFilter {
  7782. /**
  7783. * Array of URL patterns that will be used to filter out the requests that do not
  7784. * match the URL patterns.
  7785. */
  7786. urls: string[];
  7787. }
  7788. interface OpenDevToolsOptions {
  7789. /**
  7790. * Opens the devtools with specified dock state, can be right, bottom, undocked,
  7791. * detach. Defaults to last used dock state. In undocked mode it's possible to dock
  7792. * back. In detach mode it's not.
  7793. */
  7794. mode: ('right' | 'bottom' | 'undocked' | 'detach');
  7795. }
  7796. interface OpenDialogOptions {
  7797. title?: string;
  7798. defaultPath?: string;
  7799. /**
  7800. * Custom label for the confirmation button, when left empty the default label will
  7801. * be used.
  7802. */
  7803. buttonLabel?: string;
  7804. filters?: FileFilter[];
  7805. /**
  7806. * Contains which features the dialog should use. The following values are
  7807. * supported:
  7808. */
  7809. properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'>;
  7810. /**
  7811. * Message to display above input boxes.
  7812. */
  7813. message?: string;
  7814. /**
  7815. * Create when packaged for the Mac App Store.
  7816. */
  7817. securityScopedBookmarks?: boolean;
  7818. }
  7819. interface OpenExternalOptions {
  7820. /**
  7821. * true to bring the opened application to the foreground. The default is true.
  7822. */
  7823. activate: boolean;
  7824. }
  7825. interface PageFaviconUpdatedEvent extends Event {
  7826. /**
  7827. * Array of URLs.
  7828. */
  7829. favicons: string[];
  7830. }
  7831. interface PageTitleUpdatedEvent extends Event {
  7832. title: string;
  7833. explicitSet: boolean;
  7834. }
  7835. interface Parameters {
  7836. /**
  7837. * Specify the screen type to emulate (default: desktop):
  7838. */
  7839. screenPosition: ('desktop' | 'mobile');
  7840. /**
  7841. * Set the emulated screen size (screenPosition == mobile).
  7842. */
  7843. screenSize: Size;
  7844. /**
  7845. * Position the view on the screen (screenPosition == mobile) (default: {x: 0, y:
  7846. * 0}).
  7847. */
  7848. viewPosition: Point;
  7849. /**
  7850. * Set the device scale factor (if zero defaults to original device scale factor)
  7851. * (default: 0).
  7852. */
  7853. deviceScaleFactor: number;
  7854. /**
  7855. * Set the emulated view size (empty means no override)
  7856. */
  7857. viewSize: Size;
  7858. /**
  7859. * Scale of emulated view inside available space (not in fit to view mode)
  7860. * (default: 1).
  7861. */
  7862. scale: number;
  7863. }
  7864. interface Payment {
  7865. /**
  7866. * The identifier of the purchased product.
  7867. */
  7868. productIdentifier: string;
  7869. /**
  7870. * The quantity purchased.
  7871. */
  7872. quantity: number;
  7873. }
  7874. interface PermissionRequestHandlerDetails {
  7875. /**
  7876. * The url of the openExternal request.
  7877. */
  7878. externalURL: string;
  7879. }
  7880. interface PluginCrashedEvent extends Event {
  7881. name: string;
  7882. version: string;
  7883. }
  7884. interface PopupOptions {
  7885. /**
  7886. * Default is the focused window.
  7887. */
  7888. window?: BrowserWindow;
  7889. /**
  7890. * Default is the current mouse cursor position. Must be declared if y is declared.
  7891. */
  7892. x?: number;
  7893. /**
  7894. * Default is the current mouse cursor position. Must be declared if x is declared.
  7895. */
  7896. y?: number;
  7897. /**
  7898. * The index of the menu item to be positioned under the mouse cursor at the
  7899. * specified coordinates. Default is -1.
  7900. */
  7901. positioningItem?: number;
  7902. /**
  7903. * Called when menu is closed.
  7904. */
  7905. callback?: () => void;
  7906. }
  7907. interface PrintOptions {
  7908. /**
  7909. * Don't ask user for print settings. Default is false.
  7910. */
  7911. silent?: boolean;
  7912. /**
  7913. * Also prints the background color and image of the web page. Default is false.
  7914. */
  7915. printBackground?: boolean;
  7916. /**
  7917. * Set the printer device name to use. Default is ''.
  7918. */
  7919. deviceName?: string;
  7920. }
  7921. interface PrintToPDFOptions {
  7922. /**
  7923. * Specifies the type of margins to use. Uses 0 for default margin, 1 for no
  7924. * margin, and 2 for minimum margin.
  7925. */
  7926. marginsType?: number;
  7927. /**
  7928. * Specify page size of the generated PDF. Can be A3, A4, A5, Legal, Letter,
  7929. * Tabloid or an Object containing height and width in microns.
  7930. */
  7931. pageSize?: string;
  7932. /**
  7933. * Whether to print CSS backgrounds.
  7934. */
  7935. printBackground?: boolean;
  7936. /**
  7937. * Whether to print selection only.
  7938. */
  7939. printSelectionOnly?: boolean;
  7940. /**
  7941. * true for landscape, false for portrait.
  7942. */
  7943. landscape?: boolean;
  7944. }
  7945. interface ProcessMemoryInfo {
  7946. /**
  7947. * The amount of memory currently pinned to actual physical RAM.
  7948. */
  7949. workingSetSize: number;
  7950. /**
  7951. * The maximum amount of memory that has ever been pinned to actual physical RAM.
  7952. */
  7953. peakWorkingSetSize: number;
  7954. /**
  7955. * The amount of memory not shared by other processes, such as JS heap or HTML
  7956. * content.
  7957. */
  7958. privateBytes: number;
  7959. /**
  7960. * The amount of memory shared between processes, typically memory consumed by the
  7961. * Electron code itself.
  7962. */
  7963. sharedBytes: number;
  7964. }
  7965. interface ProgressBarOptions {
  7966. /**
  7967. * Mode for the progress bar. Can be none, normal, indeterminate, error or paused.
  7968. */
  7969. mode: ('none' | 'normal' | 'indeterminate' | 'error' | 'paused');
  7970. }
  7971. interface Provider {
  7972. /**
  7973. * Returns Boolean.
  7974. */
  7975. spellCheck: (text: string) => void;
  7976. }
  7977. interface ReadBookmark {
  7978. title: string;
  7979. url: string;
  7980. }
  7981. interface RedirectRequest {
  7982. url: string;
  7983. method: string;
  7984. session?: Session;
  7985. uploadData?: UploadData;
  7986. }
  7987. interface RegisterBufferProtocolRequest {
  7988. url: string;
  7989. referrer: string;
  7990. method: string;
  7991. uploadData: UploadData[];
  7992. }
  7993. interface RegisterFileProtocolRequest {
  7994. url: string;
  7995. referrer: string;
  7996. method: string;
  7997. uploadData: UploadData[];
  7998. }
  7999. interface RegisterHttpProtocolRequest {
  8000. url: string;
  8001. referrer: string;
  8002. method: string;
  8003. uploadData: UploadData[];
  8004. }
  8005. interface RegisterStandardSchemesOptions {
  8006. /**
  8007. * true to register the scheme as secure. Default false.
  8008. */
  8009. secure?: boolean;
  8010. }
  8011. interface RegisterStreamProtocolRequest {
  8012. url: string;
  8013. headers: Headers;
  8014. referrer: string;
  8015. method: string;
  8016. uploadData: UploadData[];
  8017. }
  8018. interface RegisterStringProtocolRequest {
  8019. url: string;
  8020. referrer: string;
  8021. method: string;
  8022. uploadData: UploadData[];
  8023. }
  8024. interface RegisterURLSchemeAsPrivilegedOptions {
  8025. /**
  8026. * Default true.
  8027. */
  8028. secure?: boolean;
  8029. /**
  8030. * Default true.
  8031. */
  8032. bypassCSP?: boolean;
  8033. /**
  8034. * Default true.
  8035. */
  8036. allowServiceWorkers?: boolean;
  8037. /**
  8038. * Default true.
  8039. */
  8040. supportFetchAPI?: boolean;
  8041. /**
  8042. * Default true.
  8043. */
  8044. corsEnabled?: boolean;
  8045. }
  8046. interface RelaunchOptions {
  8047. args?: string[];
  8048. execPath?: string;
  8049. }
  8050. interface Request {
  8051. method: string;
  8052. url: string;
  8053. referrer: string;
  8054. }
  8055. interface ResizeOptions {
  8056. /**
  8057. * Defaults to the image's width.
  8058. */
  8059. width?: number;
  8060. /**
  8061. * Defaults to the image's height.
  8062. */
  8063. height?: number;
  8064. /**
  8065. * The desired quality of the resize image. Possible values are good, better or
  8066. * best. The default is best. These values express a desired quality/speed
  8067. * tradeoff. They are translated into an algorithm-specific method that depends on
  8068. * the capabilities (CPU, GPU) of the underlying platform. It is possible for all
  8069. * three methods to be mapped to the same algorithm on a given platform.
  8070. */
  8071. quality?: string;
  8072. }
  8073. interface ResourceUsage {
  8074. images: MemoryUsageDetails;
  8075. scripts: MemoryUsageDetails;
  8076. cssStyleSheets: MemoryUsageDetails;
  8077. xslStyleSheets: MemoryUsageDetails;
  8078. fonts: MemoryUsageDetails;
  8079. other: MemoryUsageDetails;
  8080. }
  8081. interface Response {
  8082. cancel?: boolean;
  8083. /**
  8084. * The original request is prevented from being sent or completed and is instead
  8085. * redirected to the given URL.
  8086. */
  8087. redirectURL?: string;
  8088. }
  8089. interface Result {
  8090. requestId: number;
  8091. /**
  8092. * Position of the active match.
  8093. */
  8094. activeMatchOrdinal: number;
  8095. /**
  8096. * Number of Matches.
  8097. */
  8098. matches: number;
  8099. /**
  8100. * Coordinates of first match region.
  8101. */
  8102. selectionArea: SelectionArea;
  8103. finalUpdate: boolean;
  8104. }
  8105. interface SaveDialogOptions {
  8106. title?: string;
  8107. /**
  8108. * Absolute directory path, absolute file path, or file name to use by default.
  8109. */
  8110. defaultPath?: string;
  8111. /**
  8112. * Custom label for the confirmation button, when left empty the default label will
  8113. * be used.
  8114. */
  8115. buttonLabel?: string;
  8116. filters?: FileFilter[];
  8117. /**
  8118. * Message to display above text fields.
  8119. */
  8120. message?: string;
  8121. /**
  8122. * Custom label for the text displayed in front of the filename text field.
  8123. */
  8124. nameFieldLabel?: string;
  8125. /**
  8126. * Show the tags input box, defaults to true.
  8127. */
  8128. showsTagField?: boolean;
  8129. /**
  8130. * Create a when packaged for the Mac App Store. If this option is enabled and the
  8131. * file doesn't already exist a blank file will be created at the chosen path.
  8132. */
  8133. securityScopedBookmarks?: boolean;
  8134. }
  8135. interface Settings {
  8136. /**
  8137. * true to open the app at login, false to remove the app as a login item. Defaults
  8138. * to false.
  8139. */
  8140. openAtLogin?: boolean;
  8141. /**
  8142. * true to open the app as hidden. Defaults to false. The user can edit this
  8143. * setting from the System Preferences so
  8144. * app.getLoginItemStatus().wasOpenedAsHidden should be checked when the app is
  8145. * opened to know the current value. This setting is not available on .
  8146. */
  8147. openAsHidden?: boolean;
  8148. /**
  8149. * The executable to launch at login. Defaults to process.execPath.
  8150. */
  8151. path?: string;
  8152. /**
  8153. * The command-line arguments to pass to the executable. Defaults to an empty
  8154. * array. Take care to wrap paths in quotes.
  8155. */
  8156. args?: string[];
  8157. }
  8158. interface SourcesOptions {
  8159. /**
  8160. * An array of Strings that lists the types of desktop sources to be captured,
  8161. * available types are screen and window.
  8162. */
  8163. types: string[];
  8164. /**
  8165. * The size that the media source thumbnail should be scaled to. Default is 150 x
  8166. * 150.
  8167. */
  8168. thumbnailSize?: Size;
  8169. }
  8170. interface StartMonitoringOptions {
  8171. categoryFilter: string;
  8172. traceOptions: string;
  8173. }
  8174. interface StartRecordingOptions {
  8175. categoryFilter: string;
  8176. traceOptions: string;
  8177. }
  8178. interface SystemMemoryInfo {
  8179. /**
  8180. * The total amount of physical memory in Kilobytes available to the system.
  8181. */
  8182. total: number;
  8183. /**
  8184. * The total amount of memory not being used by applications or disk cache.
  8185. */
  8186. free: number;
  8187. /**
  8188. * The total amount of swap memory in Kilobytes available to the system.
  8189. */
  8190. swapTotal: number;
  8191. /**
  8192. * The free amount of swap memory in Kilobytes available to the system.
  8193. */
  8194. swapFree: number;
  8195. }
  8196. interface ToBitmapOptions {
  8197. /**
  8198. * Defaults to 1.0.
  8199. */
  8200. scaleFactor?: number;
  8201. }
  8202. interface ToDataURLOptions {
  8203. /**
  8204. * Defaults to 1.0.
  8205. */
  8206. scaleFactor?: number;
  8207. }
  8208. interface ToPNGOptions {
  8209. /**
  8210. * Defaults to 1.0.
  8211. */
  8212. scaleFactor?: number;
  8213. }
  8214. interface TouchBarButtonConstructorOptions {
  8215. /**
  8216. * Button text.
  8217. */
  8218. label?: string;
  8219. /**
  8220. * Button background color in hex format, i.e #ABCDEF.
  8221. */
  8222. backgroundColor?: string;
  8223. /**
  8224. * Button icon.
  8225. */
  8226. icon?: NativeImage;
  8227. /**
  8228. * Can be left, right or overlay.
  8229. */
  8230. iconPosition?: ('left' | 'right' | 'overlay');
  8231. /**
  8232. * Function to call when the button is clicked.
  8233. */
  8234. click?: () => void;
  8235. }
  8236. interface TouchBarColorPickerConstructorOptions {
  8237. /**
  8238. * Array of hex color strings to appear as possible colors to select.
  8239. */
  8240. availableColors?: string[];
  8241. /**
  8242. * The selected hex color in the picker, i.e #ABCDEF.
  8243. */
  8244. selectedColor?: string;
  8245. /**
  8246. * Function to call when a color is selected.
  8247. */
  8248. change?: (color: string) => void;
  8249. }
  8250. interface TouchBarConstructorOptions {
  8251. items: Array<TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer>;
  8252. escapeItem?: TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null;
  8253. }
  8254. interface TouchBarGroupConstructorOptions {
  8255. /**
  8256. * Items to display as a group.
  8257. */
  8258. items: TouchBar;
  8259. }
  8260. interface TouchBarLabelConstructorOptions {
  8261. /**
  8262. * Text to display.
  8263. */
  8264. label?: string;
  8265. /**
  8266. * Hex color of text, i.e #ABCDEF.
  8267. */
  8268. textColor?: string;
  8269. }
  8270. interface TouchBarPopoverConstructorOptions {
  8271. /**
  8272. * Popover button text.
  8273. */
  8274. label?: string;
  8275. /**
  8276. * Popover button icon.
  8277. */
  8278. icon?: NativeImage;
  8279. /**
  8280. * Items to display in the popover.
  8281. */
  8282. items?: TouchBar;
  8283. /**
  8284. * true to display a close button on the left of the popover, false to not show it.
  8285. * Default is true.
  8286. */
  8287. showCloseButton?: boolean;
  8288. }
  8289. interface TouchBarScrubberConstructorOptions {
  8290. /**
  8291. * An array of items to place in this scrubber.
  8292. */
  8293. items: ScrubberItem[];
  8294. /**
  8295. * Called when the user taps an item that was not the last tapped item.
  8296. */
  8297. select: (selectedIndex: number) => void;
  8298. /**
  8299. * Called when the user taps any item.
  8300. */
  8301. highlight: (highlightedIndex: number) => void;
  8302. /**
  8303. * Selected item style. Defaults to null.
  8304. */
  8305. selectedStyle: string;
  8306. /**
  8307. * Selected overlay item style. Defaults to null.
  8308. */
  8309. overlayStyle: string;
  8310. /**
  8311. * Defaults to false.
  8312. */
  8313. showArrowButtons: boolean;
  8314. /**
  8315. * Defaults to free.
  8316. */
  8317. mode: string;
  8318. /**
  8319. * Defaults to true.
  8320. */
  8321. continuous: boolean;
  8322. }
  8323. interface TouchBarSegmentedControlConstructorOptions {
  8324. /**
  8325. * Style of the segments:
  8326. */
  8327. segmentStyle?: ('automatic' | 'rounded' | 'textured-rounded' | 'round-rect' | 'textured-square' | 'capsule' | 'small-square' | 'separated');
  8328. /**
  8329. * The selection mode of the control:
  8330. */
  8331. mode?: ('single' | 'multiple' | 'buttons');
  8332. /**
  8333. * An array of segments to place in this control.
  8334. */
  8335. segments: SegmentedControlSegment[];
  8336. /**
  8337. * The index of the currently selected segment, will update automatically with user
  8338. * interaction. When the mode is multiple it will be the last selected item.
  8339. */
  8340. selectedIndex?: number;
  8341. /**
  8342. * Called when the user selects a new segment.
  8343. */
  8344. change: (selectedIndex: number, isSelected: boolean) => void;
  8345. }
  8346. interface TouchBarSliderConstructorOptions {
  8347. /**
  8348. * Label text.
  8349. */
  8350. label?: string;
  8351. /**
  8352. * Selected value.
  8353. */
  8354. value?: number;
  8355. /**
  8356. * Minimum value.
  8357. */
  8358. minValue?: number;
  8359. /**
  8360. * Maximum value.
  8361. */
  8362. maxValue?: number;
  8363. /**
  8364. * Function to call when the slider is changed.
  8365. */
  8366. change?: (newValue: number) => void;
  8367. }
  8368. interface TouchBarSpacerConstructorOptions {
  8369. /**
  8370. * Size of spacer, possible values are:
  8371. */
  8372. size?: ('small' | 'large' | 'flexible');
  8373. }
  8374. interface UpdateTargetUrlEvent extends Event {
  8375. url: string;
  8376. }
  8377. interface UploadProgress {
  8378. /**
  8379. * Whether the request is currently active. If this is false no other properties
  8380. * will be set
  8381. */
  8382. active: boolean;
  8383. /**
  8384. * Whether the upload has started. If this is false both current and total will be
  8385. * set to 0.
  8386. */
  8387. started: boolean;
  8388. /**
  8389. * The number of bytes that have been uploaded so far
  8390. */
  8391. current: number;
  8392. /**
  8393. * The number of bytes that will be uploaded this request
  8394. */
  8395. total: number;
  8396. }
  8397. interface Versions {
  8398. /**
  8399. * A String representing Chrome's version string.
  8400. */
  8401. chrome?: string;
  8402. /**
  8403. * A String representing Electron's version string.
  8404. */
  8405. electron?: string;
  8406. }
  8407. interface WillNavigateEvent extends Event {
  8408. url: string;
  8409. }
  8410. interface EditFlags {
  8411. /**
  8412. * Whether the renderer believes it can undo.
  8413. */
  8414. canUndo: boolean;
  8415. /**
  8416. * Whether the renderer believes it can redo.
  8417. */
  8418. canRedo: boolean;
  8419. /**
  8420. * Whether the renderer believes it can cut.
  8421. */
  8422. canCut: boolean;
  8423. /**
  8424. * Whether the renderer believes it can copy
  8425. */
  8426. canCopy: boolean;
  8427. /**
  8428. * Whether the renderer believes it can paste.
  8429. */
  8430. canPaste: boolean;
  8431. /**
  8432. * Whether the renderer believes it can delete.
  8433. */
  8434. canDelete: boolean;
  8435. /**
  8436. * Whether the renderer believes it can select all.
  8437. */
  8438. canSelectAll: boolean;
  8439. }
  8440. interface Extra {
  8441. }
  8442. interface FoundInPageResult {
  8443. requestId: number;
  8444. /**
  8445. * Position of the active match.
  8446. */
  8447. activeMatchOrdinal: number;
  8448. /**
  8449. * Number of Matches.
  8450. */
  8451. matches: number;
  8452. /**
  8453. * Coordinates of first match region.
  8454. */
  8455. selectionArea: SelectionArea;
  8456. finalUpdate: boolean;
  8457. }
  8458. interface MediaFlags {
  8459. /**
  8460. * Whether the media element has crashed.
  8461. */
  8462. inError: boolean;
  8463. /**
  8464. * Whether the media element is paused.
  8465. */
  8466. isPaused: boolean;
  8467. /**
  8468. * Whether the media element is muted.
  8469. */
  8470. isMuted: boolean;
  8471. /**
  8472. * Whether the media element has audio.
  8473. */
  8474. hasAudio: boolean;
  8475. /**
  8476. * Whether the media element is looping.
  8477. */
  8478. isLooping: boolean;
  8479. /**
  8480. * Whether the media element's controls are visible.
  8481. */
  8482. isControlsVisible: boolean;
  8483. /**
  8484. * Whether the media element's controls are toggleable.
  8485. */
  8486. canToggleControls: boolean;
  8487. /**
  8488. * Whether the media element can be rotated.
  8489. */
  8490. canRotate: boolean;
  8491. }
  8492. interface Options {
  8493. }
  8494. interface RequestHeaders {
  8495. }
  8496. interface ResponseHeaders {
  8497. }
  8498. interface SelectionArea {
  8499. }
  8500. interface WebPreferences {
  8501. /**
  8502. * Whether to enable DevTools. If it is set to false, can not use
  8503. * BrowserWindow.webContents.openDevTools() to open DevTools. Default is true.
  8504. */
  8505. devTools?: boolean;
  8506. /**
  8507. * Whether node integration is enabled. Default is true.
  8508. */
  8509. nodeIntegration?: boolean;
  8510. /**
  8511. * Whether node integration is enabled in web workers. Default is false. More about
  8512. * this can be found in .
  8513. */
  8514. nodeIntegrationInWorker?: boolean;
  8515. /**
  8516. * Specifies a script that will be loaded before other scripts run in the page.
  8517. * This script will always have access to node APIs no matter whether node
  8518. * integration is turned on or off. The value should be the absolute file path to
  8519. * the script. When node integration is turned off, the preload script can
  8520. * reintroduce Node global symbols back to the global scope. See example .
  8521. */
  8522. preload?: string;
  8523. /**
  8524. * If set, this will sandbox the renderer associated with the window, making it
  8525. * compatible with the Chromium OS-level sandbox and disabling the Node.js engine.
  8526. * This is not the same as the nodeIntegration option and the APIs available to the
  8527. * preload script are more limited. Read more about the option . This option is
  8528. * currently experimental and may change or be removed in future Electron releases.
  8529. */
  8530. sandbox?: boolean;
  8531. /**
  8532. * Sets the session used by the page. Instead of passing the Session object
  8533. * directly, you can also choose to use the partition option instead, which accepts
  8534. * a partition string. When both session and partition are provided, session will
  8535. * be preferred. Default is the default session.
  8536. */
  8537. session?: Session;
  8538. /**
  8539. * Sets the session used by the page according to the session's partition string.
  8540. * If partition starts with persist:, the page will use a persistent session
  8541. * available to all pages in the app with the same partition. If there is no
  8542. * persist: prefix, the page will use an in-memory session. By assigning the same
  8543. * partition, multiple pages can share the same session. Default is the default
  8544. * session.
  8545. */
  8546. partition?: string;
  8547. /**
  8548. * When specified, web pages with the same affinity will run in the same renderer
  8549. * process. Note that due to reusing the renderer process, certain webPreferences
  8550. * options will also be shared between the web pages even when you specified
  8551. * different values for them, including but not limited to preload, sandbox and
  8552. * nodeIntegration. So it is suggested to use exact same webPreferences for web
  8553. * pages with the same affinity.
  8554. */
  8555. affinity?: string;
  8556. /**
  8557. * The default zoom factor of the page, 3.0 represents 300%. Default is 1.0.
  8558. */
  8559. zoomFactor?: number;
  8560. /**
  8561. * Enables JavaScript support. Default is true.
  8562. */
  8563. javascript?: boolean;
  8564. /**
  8565. * When false, it will disable the same-origin policy (usually using testing
  8566. * websites by people), and set allowRunningInsecureContent to true if this options
  8567. * has not been set by user. Default is true.
  8568. */
  8569. webSecurity?: boolean;
  8570. /**
  8571. * Allow an https page to run JavaScript, CSS or plugins from http URLs. Default is
  8572. * false.
  8573. */
  8574. allowRunningInsecureContent?: boolean;
  8575. /**
  8576. * Enables image support. Default is true.
  8577. */
  8578. images?: boolean;
  8579. /**
  8580. * Make TextArea elements resizable. Default is true.
  8581. */
  8582. textAreasAreResizable?: boolean;
  8583. /**
  8584. * Enables WebGL support. Default is true.
  8585. */
  8586. webgl?: boolean;
  8587. /**
  8588. * Enables WebAudio support. Default is true.
  8589. */
  8590. webaudio?: boolean;
  8591. /**
  8592. * Whether plugins should be enabled. Default is false.
  8593. */
  8594. plugins?: boolean;
  8595. /**
  8596. * Enables Chromium's experimental features. Default is false.
  8597. */
  8598. experimentalFeatures?: boolean;
  8599. /**
  8600. * Enables Chromium's experimental canvas features. Default is false.
  8601. */
  8602. experimentalCanvasFeatures?: boolean;
  8603. /**
  8604. * Enables scroll bounce (rubber banding) effect on macOS. Default is false.
  8605. */
  8606. scrollBounce?: boolean;
  8607. /**
  8608. * A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
  8609. * enable. The full list of supported feature strings can be found in the file.
  8610. */
  8611. enableBlinkFeatures?: string;
  8612. /**
  8613. * A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
  8614. * disable. The full list of supported feature strings can be found in the file.
  8615. */
  8616. disableBlinkFeatures?: string;
  8617. /**
  8618. * Sets the default font for the font-family.
  8619. */
  8620. defaultFontFamily?: DefaultFontFamily;
  8621. /**
  8622. * Defaults to 16.
  8623. */
  8624. defaultFontSize?: number;
  8625. /**
  8626. * Defaults to 13.
  8627. */
  8628. defaultMonospaceFontSize?: number;
  8629. /**
  8630. * Defaults to 0.
  8631. */
  8632. minimumFontSize?: number;
  8633. /**
  8634. * Defaults to ISO-8859-1.
  8635. */
  8636. defaultEncoding?: string;
  8637. /**
  8638. * Whether to throttle animations and timers when the page becomes background. This
  8639. * also affects the . Defaults to true.
  8640. */
  8641. backgroundThrottling?: boolean;
  8642. /**
  8643. * Whether to enable offscreen rendering for the browser window. Defaults to false.
  8644. * See the for more details.
  8645. */
  8646. offscreen?: boolean;
  8647. /**
  8648. * Whether to run Electron APIs and the specified preload script in a separate
  8649. * JavaScript context. Defaults to false. The context that the preload script runs
  8650. * in will still have full access to the document and window globals but it will
  8651. * use its own set of JavaScript builtins (Array, Object, JSON, etc.) and will be
  8652. * isolated from any changes made to the global environment by the loaded page. The
  8653. * Electron API will only be available in the preload script and not the loaded
  8654. * page. This option should be used when loading potentially untrusted remote
  8655. * content to ensure the loaded content cannot tamper with the preload script and
  8656. * any Electron APIs being used. This option uses the same technique used by . You
  8657. * can access this context in the dev tools by selecting the 'Electron Isolated
  8658. * Context' entry in the combo box at the top of the Console tab. This option is
  8659. * currently experimental and may change or be removed in future Electron releases.
  8660. */
  8661. contextIsolation?: boolean;
  8662. /**
  8663. * Whether to use native window.open(). Defaults to false. This option is currently
  8664. * experimental.
  8665. */
  8666. nativeWindowOpen?: boolean;
  8667. /**
  8668. * Whether to enable the . Defaults to the value of the nodeIntegration option. The
  8669. * preload script configured for the <webview> will have node integration enabled
  8670. * when it is executed so you should ensure remote/untrusted content is not able to
  8671. * create a <webview> tag with a possibly malicious preload script. You can use the
  8672. * will-attach-webview event on to strip away the preload script and to validate or
  8673. * alter the <webview>'s initial settings.
  8674. */
  8675. webviewTag?: boolean;
  8676. /**
  8677. * A list of strings that will be appended to process.argv in the renderer process
  8678. * of this app. Useful for passing small bits of data down to renderer process
  8679. * preload scripts.
  8680. */
  8681. additionalArguments?: string[];
  8682. /**
  8683. * Whether to enable browser style consecutive dialog protection. Default is false.
  8684. */
  8685. safeDialogs?: boolean;
  8686. /**
  8687. * The message to display when consecutive dialog protection is triggered. If not
  8688. * defined the default message would be used, note that currently the default
  8689. * message is in English and not localized.
  8690. */
  8691. safeDialogsMessage?: string;
  8692. /**
  8693. * Whether dragging and dropping a file or link onto the page causes a navigation.
  8694. * Default is false.
  8695. */
  8696. navigateOnDragDrop?: boolean;
  8697. }
  8698. interface DefaultFontFamily {
  8699. /**
  8700. * Defaults to Times New Roman.
  8701. */
  8702. standard?: string;
  8703. /**
  8704. * Defaults to Times New Roman.
  8705. */
  8706. serif?: string;
  8707. /**
  8708. * Defaults to Arial.
  8709. */
  8710. sansSerif?: string;
  8711. /**
  8712. * Defaults to Courier New.
  8713. */
  8714. monospace?: string;
  8715. /**
  8716. * Defaults to Script.
  8717. */
  8718. cursive?: string;
  8719. /**
  8720. * Defaults to Impact.
  8721. */
  8722. fantasy?: string;
  8723. }
  8724. }
  8725. declare module 'electron' {
  8726. export = Electron;
  8727. }
  8728. interface NodeRequireFunction {
  8729. (moduleName: 'electron'): typeof Electron;
  8730. }
  8731. interface File {
  8732. /**
  8733. * The real path to the file on the users filesystem
  8734. */
  8735. path: string;
  8736. }
  8737. declare module 'original-fs' {
  8738. import * as fs from 'fs';
  8739. export = fs;
  8740. }
  8741. interface Document {
  8742. createElement(tagName: 'webview'): Electron.WebviewTag;
  8743. }
  8744. declare namespace NodeJS {
  8745. interface Process extends EventEmitter {
  8746. // Docs: http://electron.atom.io/docs/api/process
  8747. /**
  8748. * Emitted when Electron has loaded its internal initialization script and is
  8749. * beginning to load the web page or the main script. It can be used by the preload
  8750. * script to add removed Node global symbols back to the global scope when node
  8751. * integration is turned off:
  8752. */
  8753. on(event: 'loaded', listener: Function): this;
  8754. once(event: 'loaded', listener: Function): this;
  8755. addListener(event: 'loaded', listener: Function): this;
  8756. removeListener(event: 'loaded', listener: Function): this;
  8757. /**
  8758. * Causes the main thread of the current process crash.
  8759. */
  8760. crash(): void;
  8761. getCPUUsage(): Electron.CPUUsage;
  8762. /**
  8763. * Returns an object with V8 heap statistics. Note that all statistics are reported
  8764. * in Kilobytes.
  8765. */
  8766. getHeapStatistics(): Electron.HeapStatistics;
  8767. getIOCounters(): Electron.IOCounters;
  8768. /**
  8769. * Returns an object giving memory usage statistics about the current process. Note
  8770. * that all statistics are reported in Kilobytes.
  8771. */
  8772. getProcessMemoryInfo(): Electron.ProcessMemoryInfo;
  8773. /**
  8774. * Returns an object giving memory usage statistics about the entire system. Note
  8775. * that all statistics are reported in Kilobytes.
  8776. */
  8777. getSystemMemoryInfo(): Electron.SystemMemoryInfo;
  8778. /**
  8779. * Causes the main thread of the current process hang.
  8780. */
  8781. hang(): void;
  8782. /**
  8783. * Sets the file descriptor soft limit to maxDescriptors or the OS hard limit,
  8784. * whichever is lower for the current process.
  8785. */
  8786. setFdLimit(maxDescriptors: number): void;
  8787. /**
  8788. * A Boolean. When app is started by being passed as parameter to the default app,
  8789. * this property is true in the main process, otherwise it is undefined.
  8790. */
  8791. defaultApp?: boolean;
  8792. /**
  8793. * A Boolean. For Mac App Store build, this property is true, for other builds it
  8794. * is undefined.
  8795. */
  8796. mas?: boolean;
  8797. /**
  8798. * A Boolean that controls ASAR support inside your application. Setting this to
  8799. * true will disable the support for asar archives in Node's built-in modules.
  8800. */
  8801. noAsar?: boolean;
  8802. /**
  8803. * A Boolean that controls whether or not deprecation warnings are printed to
  8804. * stderr. Setting this to true will silence deprecation warnings. This property is
  8805. * used instead of the --no-deprecation command line flag.
  8806. */
  8807. noDeprecation?: boolean;
  8808. /**
  8809. * A String representing the path to the resources directory.
  8810. */
  8811. resourcesPath?: string;
  8812. /**
  8813. * A Boolean that controls whether or not deprecation warnings will be thrown as
  8814. * exceptions. Setting this to true will throw errors for deprecations. This
  8815. * property is used instead of the --throw-deprecation command line flag.
  8816. */
  8817. throwDeprecation?: boolean;
  8818. /**
  8819. * A Boolean that controls whether or not deprecations printed to stderr include
  8820. * their stack trace. Setting this to true will print stack traces for
  8821. * deprecations. This property is instead of the --trace-deprecation command line
  8822. * flag.
  8823. */
  8824. traceDeprecation?: boolean;
  8825. /**
  8826. * A Boolean that controls whether or not process warnings printed to stderr
  8827. * include their stack trace. Setting this to true will print stack traces for
  8828. * process warnings (including deprecations). This property is instead of the
  8829. * --trace-warnings command line flag.
  8830. */
  8831. traceProcessWarnings?: boolean;
  8832. /**
  8833. * A String representing the current process's type, can be "browser" (i.e. main
  8834. * process) or "renderer".
  8835. */
  8836. type?: string;
  8837. /**
  8838. * A Boolean. If the app is running as a Windows Store app (appx), this property is
  8839. * true, for otherwise it is undefined.
  8840. */
  8841. windowsStore?: boolean;
  8842. }
  8843. interface ProcessVersions {
  8844. electron: string;
  8845. chrome: string;
  8846. }
  8847. }