electron.d.ts 347 KB

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