electron.d.ts 358 KB

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