wecom.global.js 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693
  1. var ww = (function (exports) {
  2. 'use strict';
  3. const win = typeof window !== 'undefined' ? window : undefined;
  4. const doc = typeof document !== 'undefined' ? document : undefined;
  5. const nav = typeof navigator !== 'undefined' ? navigator : undefined;
  6. const loc = typeof location !== 'undefined' ? location : undefined;
  7. function getHref() {
  8. return loc?.href || '';
  9. }
  10. function getTitle() {
  11. return doc?.title || '';
  12. }
  13. const ua = nav?.userAgent || '';
  14. const platform = nav?.platform || '';
  15. const wecomVersion = ua?.match(/wxwork\/([\d.]+)/i)?.[1];
  16. const isWeCom = !!wecomVersion;
  17. const isWeChat = !isWeCom && /micromessenger/i.test(ua);
  18. const isAndroid = /\bAndroid\b/i.test(ua);
  19. const isWindows = /Win/i.test(platform);
  20. const { isIOS, isMac } = getAppleDeviceType();
  21. function getAppleDeviceType() {
  22. const maxTouchPoints = nav?.maxTouchPoints ?? 1;
  23. const isMac = /Mac/i.test(platform);
  24. // https://stackoverflow.com/questions/56934826/distinguish-between-ipad-and-mac-on-ipad-with-ipados
  25. if (isMac && maxTouchPoints > 2) {
  26. return {
  27. isMac: false,
  28. isIOS: true
  29. };
  30. }
  31. return {
  32. isMac,
  33. isIOS: /\b(iPhone|iPad|iPod)\b/i.test(ua)
  34. };
  35. }
  36. let registerOptions;
  37. let corpConfigTask;
  38. let agentConfigTask;
  39. function setRegisterOptions(options) {
  40. if (!options.corpId) {
  41. throw new Error('Missing corpId');
  42. }
  43. registerOptions = options;
  44. }
  45. function getRegisterOptions() {
  46. return registerOptions;
  47. }
  48. function getCorpConfigTask() {
  49. return corpConfigTask;
  50. }
  51. function setCorpConfigTask(task) {
  52. corpConfigTask = task;
  53. }
  54. function getCorpConfigParams() {
  55. return corpConfigTask?.getResult()?.params;
  56. }
  57. function getAgentConfigTask() {
  58. return agentConfigTask;
  59. }
  60. function setAgentConfigTask(task) {
  61. agentConfigTask = task;
  62. }
  63. function getAgentConfigParams() {
  64. return agentConfigTask?.getResult()?.params;
  65. }
  66. function getConfigParams() {
  67. const registerOptions = getRegisterOptions();
  68. if (isWeCom && registerOptions?.getAgentConfigSignature) {
  69. return getAgentConfigParams();
  70. }
  71. return getCorpConfigParams();
  72. }
  73. function getConfigCorpId() {
  74. const registerOptions = getRegisterOptions();
  75. if (isWeCom && registerOptions?.getAgentConfigSignature) {
  76. const params = getAgentConfigParams();
  77. return params?.corpid;
  78. }
  79. const params = getCorpConfigParams();
  80. return params?.appId;
  81. }
  82. /**
  83. * 获取 config 或 agentConfig 传入的相关参数
  84. *
  85. * 用于外部 sdk 调用私有方法
  86. */ function getVerifyParams() {
  87. const verifyParams = getConfigParams();
  88. if (!verifyParams) {
  89. return;
  90. }
  91. const corpId = getConfigCorpId();
  92. return {
  93. appId: corpId,
  94. verifyAppId: corpId,
  95. verifySignType: 'sha1',
  96. verifyTimestamp: verifyParams.timestamp,
  97. verifyNonceStr: verifyParams.nonceStr,
  98. verifySignature: verifyParams.signature
  99. };
  100. }
  101. const webToClientJsApiMap = {
  102. config: 'preVerifyJsApi',
  103. onMenuShareTimeline: 'menu:share:timeline',
  104. onMenuShareAppMessage: 'menu:share:appmessage',
  105. onMenuShareWechat: 'menu:share:wechat',
  106. onMenuShareQQ: 'menu:share:qq',
  107. onMenuShareWeibo: 'menu:share:weiboApp',
  108. onMenuShareQZone: 'menu:share:QZone',
  109. previewImage: 'imagePreview',
  110. getLocation: 'geoLocation',
  111. openProductSpecificView: 'openProductViewWithPid',
  112. addCard: 'batchAddCard',
  113. openCard: 'batchViewCard',
  114. chooseWXPay: 'getBrandWCPayRequest',
  115. openEnterpriseRedPacket: 'getRecevieBizHongBaoRequest',
  116. startSearchBeacons: 'startMonitoringBeacons',
  117. stopSearchBeacons: 'stopMonitoringBeacons',
  118. onSearchBeacons: 'onBeaconsInRange',
  119. consumeAndShareCard: 'consumedShareCard',
  120. openAddress: 'editAddress',
  121. getBrandWCPayRequest: 'getBrandWCPayRequest'
  122. };
  123. const clientToWebJsApiMap = {};
  124. for (const key of Object.keys(webToClientJsApiMap)){
  125. clientToWebJsApiMap[webToClientJsApiMap[key]] = key;
  126. }
  127. function mapJsApiNameToClient(name) {
  128. return webToClientJsApiMap[name] || name;
  129. }
  130. function mapJsApiNameToWeb(name) {
  131. return clientToWebJsApiMap[name] || name;
  132. }
  133. function mapJsApiListToClient(list) {
  134. return list.map(mapJsApiNameToClient);
  135. }
  136. function error(...args) {
  137. console.error('[wwsdk]', ...args);
  138. }
  139. const originalHref = getHref();
  140. /**
  141. * 两个 SemVer 相减,取差的符号
  142. */ function semverSubtract(v1, v2) {
  143. const v1Seg = v1?.split('.') || [];
  144. const v2Seg = v2?.split('.') || [];
  145. for(let i = 0, ii = Math.max(v1Seg.length, v2Seg.length); i < ii; i++){
  146. const v1Num = parseInt(v1Seg[i]) || 0;
  147. const v2Num = parseInt(v2Seg[i]) || 0;
  148. if (v1Num > v2Num) {
  149. return 1;
  150. }
  151. if (v1Num < v2Num) {
  152. return -1;
  153. }
  154. }
  155. return 0;
  156. }
  157. function arrayBufferToBase64(buffer) {
  158. if (typeof Buffer !== 'undefined') {
  159. return Buffer.from(buffer).toString('base64');
  160. }
  161. let binary = '';
  162. const bytes = new Uint8Array(buffer);
  163. const len = bytes.byteLength;
  164. for(let i = 0; i < len; i++){
  165. binary += String.fromCharCode(bytes[i]);
  166. }
  167. return btoa(binary);
  168. }
  169. function base64ToArrayBuffer(base64) {
  170. if (typeof Buffer !== 'undefined') {
  171. return Buffer.from(base64, 'base64').buffer;
  172. }
  173. const binary = atob(base64);
  174. const length = binary.length;
  175. const bytes = new Uint8Array(length);
  176. for(let i = 0; i < length; i++){
  177. bytes[i] = binary.charCodeAt(i);
  178. }
  179. return bytes.buffer;
  180. }
  181. function safeRun(fn, param, thisArg) {
  182. if (!isFunction(fn)) {
  183. return;
  184. }
  185. try {
  186. return fn.call(thisArg, param);
  187. } catch (error$1) {
  188. error(error$1);
  189. }
  190. }
  191. function startsWith(str, search) {
  192. return str.slice(0, search.length) === search;
  193. }
  194. function getSignURL(original) {
  195. if (original) {
  196. return originalHref.split('#')[0];
  197. }
  198. return getHref().split('#')[0];
  199. }
  200. function extractErrMsgKeyword(errMsg) {
  201. if (!isString(errMsg)) {
  202. return '';
  203. }
  204. return errMsg.slice(errMsg.indexOf(':') + 1);
  205. }
  206. function isFalsy(val) {
  207. return val === false || val === 0;
  208. }
  209. function isObject$1(val) {
  210. if (!val) {
  211. return false;
  212. }
  213. return typeof val === 'object';
  214. }
  215. function isFunction(val) {
  216. return typeof val === 'function';
  217. }
  218. function isString(val) {
  219. return typeof val === 'string';
  220. }
  221. function joinList(list) {
  222. if (!list) {
  223. return list;
  224. }
  225. if (isString(list)) {
  226. return list;
  227. }
  228. return list.join(';');
  229. }
  230. /**
  231. * WeixinJSBridge 是否已注入到 window
  232. */ exports.isWeixinJSBridgeReady = !!win?.WeixinJSBridge;
  233. /**
  234. * 等待 WeixinJSBridge 注入到 window
  235. */ exports.onWeixinJSBridgeReady = Promise.resolve();
  236. if (!exports.isWeixinJSBridgeReady) {
  237. exports.onWeixinJSBridgeReady = new Promise((resolve)=>{
  238. doc?.addEventListener('WeixinJSBridgeReady', ()=>{
  239. exports.isWeixinJSBridgeReady = true;
  240. resolve();
  241. });
  242. });
  243. }
  244. /**
  245. * 监听 JSSDK 未定义的事件
  246. *
  247. * @example
  248. * ```ts
  249. * ww.on('onBeaconsInRange', res => {
  250. * console.log(res)
  251. * })
  252. * ```
  253. *
  254. * @param name 事件名称
  255. * @param callback 监听回调
  256. */ async function on(name, callback) {
  257. if (!exports.isWeixinJSBridgeReady) {
  258. await exports.onWeixinJSBridgeReady;
  259. }
  260. win.WeixinJSBridge.on(name, callback);
  261. }
  262. /**
  263. * 调用 JSSDK 未定义的 JSAPI
  264. *
  265. * @example
  266. * ```ts
  267. * ww.invoke('openEnterpriseChat', params, res => {
  268. * console.log(res)
  269. * })
  270. * ```
  271. *
  272. * @param name JSAPI 名称
  273. * @param params JSAPI 参数
  274. * @param callback 回调函数
  275. * @returns JSAPI 返回值
  276. */ async function invoke(name, params = {}, callback) {
  277. if (!exports.isWeixinJSBridgeReady) {
  278. await exports.onWeixinJSBridgeReady;
  279. }
  280. const result = await new Promise((resolve)=>{
  281. const fullParams = {
  282. ...params,
  283. ...getVerifyParams()
  284. };
  285. win.WeixinJSBridge.invoke(name, fullParams, resolve);
  286. });
  287. if (!result.errMsg) {
  288. result.errMsg = formatErrMsg(name, result.err_msg || result.errmsg);
  289. }
  290. const keyword = extractErrMsgKeyword(result.errMsg);
  291. if (result.errCode == null) {
  292. if (result.err_code != null) {
  293. result.errCode = result.err_code;
  294. } else {
  295. result.errCode = keyword === 'ok' ? 0 : -1;
  296. }
  297. }
  298. safeRun(callback, result);
  299. if (keyword !== 'ok' && keyword !== 'yes') {
  300. throw result;
  301. }
  302. return result;
  303. }
  304. function formatErrMsg(name, errMsg) {
  305. const apiName = mapJsApiNameToWeb(name);
  306. if (!errMsg) {
  307. return `${apiName}:ok`;
  308. }
  309. let keyword = extractErrMsgKeyword(errMsg);
  310. if (keyword === 'confirm') {
  311. keyword = 'ok';
  312. }
  313. if (keyword === 'failed') {
  314. keyword = 'fail';
  315. }
  316. if (startsWith(keyword, 'failed_')) {
  317. keyword = keyword.slice(7);
  318. }
  319. if (startsWith(keyword, 'fail_')) {
  320. keyword = keyword.slice(5);
  321. }
  322. keyword = keyword.replace(/_/g, '').toLowerCase();
  323. if (keyword === 'access denied' || keyword === 'no permission to execute') {
  324. keyword = 'permission denied';
  325. }
  326. if (apiName === 'config' && keyword === 'function not exist') {
  327. keyword = 'ok';
  328. }
  329. if (!keyword) {
  330. keyword = 'fail';
  331. }
  332. return `${apiName}:${keyword}`;
  333. }
  334. class SDKError extends Error {
  335. constructor(message){
  336. super(`SDK Error: ${message}`);
  337. }
  338. }
  339. class AbortError extends SDKError {
  340. constructor(){
  341. super('Aborted');
  342. }
  343. }
  344. function _define_property(obj, key, value) {
  345. if (key in obj) {
  346. Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
  347. } else obj[key] = value;
  348. return obj;
  349. }
  350. const CONFIG_TYPE_CORP = 1;
  351. const CONFIG_TYPE_AGENT = 2;
  352. class ConfigTask {
  353. checkValid() {
  354. if (isWeCom && this.url !== getSignURL(this.useOriginalURL)) {
  355. this.error = new AbortError();
  356. }
  357. return !this.error;
  358. }
  359. getResult() {
  360. if (this.checkValid()) {
  361. return this.result;
  362. }
  363. }
  364. async awaitPromise(promise) {
  365. try {
  366. this.result = await promise;
  367. return this.result;
  368. } catch (error) {
  369. this.error = error;
  370. throw error;
  371. }
  372. }
  373. constructor(type, factory){
  374. _define_property(this, "type", void 0);
  375. _define_property(this, "url", void 0);
  376. _define_property(this, "promise", void 0);
  377. _define_property(this, "result", void 0);
  378. _define_property(this, "error", void 0);
  379. _define_property(this, "useOriginalURL", void 0);
  380. this.type = type;
  381. this.useOriginalURL = isWeChat && !isWindows && !isMac && type === CONFIG_TYPE_CORP;
  382. this.url = getSignURL(this.useOriginalURL);
  383. this.promise = this.awaitPromise(factory(this.url));
  384. }
  385. }
  386. /**
  387. * 触发或等待 config 返回
  388. */ async function ensureCorpConfigReady() {
  389. const originalTask = getCorpConfigTask();
  390. if (originalTask?.checkValid()) {
  391. return originalTask.promise;
  392. }
  393. const task = new ConfigTask(CONFIG_TYPE_CORP, async (url)=>{
  394. const registerOptions = getRegisterOptions();
  395. if (!registerOptions?.getConfigSignature) {
  396. throw new SDKError('Missing getConfigSignature');
  397. }
  398. // 1. 获取 config 签名参数
  399. const data = await registerOptions.getConfigSignature(url);
  400. if (!task.checkValid()) {
  401. throw new AbortError();
  402. }
  403. // 2. 构建参数
  404. const params = buildCorpConfigParams(registerOptions, data);
  405. // 3. 调用 JSAPI
  406. const result = await invoke('preVerifyJSAPI', {
  407. appId: params.appId,
  408. verifyJsApiList: params.jsApiList,
  409. verifyOpenTagList: params.openTagList,
  410. verifyAppId: params.appId,
  411. verifySignType: 'sha1',
  412. verifyTimestamp: params.timestamp,
  413. verifyNonceStr: params.nonceStr,
  414. verifySignature: params.signature
  415. });
  416. if (!task.checkValid()) {
  417. throw new AbortError();
  418. }
  419. return {
  420. params,
  421. result
  422. };
  423. });
  424. task.promise.then((res)=>{
  425. const registerOptions = getRegisterOptions();
  426. safeRun(registerOptions?.onConfigSuccess, res.result);
  427. safeRun(registerOptions?.onConfigComplete, res.result);
  428. }, (error)=>{
  429. const registerOptions = getRegisterOptions();
  430. safeRun(registerOptions?.onConfigFail, error);
  431. safeRun(registerOptions?.onConfigComplete, error);
  432. });
  433. setCorpConfigTask(task);
  434. return task.promise;
  435. }
  436. function buildCorpConfigParams(options, data) {
  437. return {
  438. appId: options.corpId,
  439. timestamp: `${data.timestamp}`,
  440. nonceStr: data.nonceStr,
  441. signature: data.signature,
  442. jsApiList: mapJsApiListToClient(options.jsApiList || [
  443. 'config'
  444. ]),
  445. openTagList: mapJsApiListToClient(options.openTagList || [])
  446. };
  447. }
  448. /**
  449. * 触发或等待 agentConfig 返回
  450. */ async function ensureAgentConfigReady() {
  451. const originalTask = getAgentConfigTask();
  452. if (originalTask?.checkValid()) {
  453. return originalTask.promise;
  454. }
  455. const task = new ConfigTask(CONFIG_TYPE_AGENT, async (url)=>{
  456. // 1. 若为低版本企业微信,agentConfig 需要在 config 成功后执行
  457. let configPromise;
  458. if (isWeCom && semverSubtract(wecomVersion, '3.0.24') < 0) {
  459. configPromise = ensureCorpConfigReady();
  460. }
  461. // 2. 等待 config 成功的时候同时获取 agentConfig 签名参数
  462. const [params] = await Promise.all([
  463. resolveAgentConfigParams(url),
  464. configPromise
  465. ]);
  466. if (!task.checkValid()) {
  467. throw new AbortError();
  468. }
  469. // 4. 调用 JSAPI
  470. const result = await invoke('agentConfig', params);
  471. if (!task.checkValid()) {
  472. throw new AbortError();
  473. }
  474. return {
  475. params,
  476. result
  477. };
  478. });
  479. task.promise.then((res)=>handleAgentConfigSuccess(res.result), (error)=>handleAgentConfigFail(error));
  480. setAgentConfigTask(task);
  481. return task.promise;
  482. }
  483. async function resolveAgentConfigParams(url) {
  484. const registerOptions = getRegisterOptions();
  485. if (!registerOptions?.getAgentConfigSignature) {
  486. throw new SDKError('Missing getAgentConfigSignature');
  487. }
  488. const data = await registerOptions.getAgentConfigSignature(url);
  489. return {
  490. corpid: registerOptions.corpId,
  491. agentid: `${registerOptions.agentId}`,
  492. timestamp: `${data.timestamp}`,
  493. nonceStr: data.nonceStr,
  494. signature: data.signature,
  495. jsApiList: mapJsApiListToClient(registerOptions.jsApiList || [
  496. 'agentConfig'
  497. ])
  498. };
  499. }
  500. function handleAgentConfigSuccess(result) {
  501. const registerOptions = getRegisterOptions();
  502. safeRun(registerOptions?.onAgentConfigSuccess, result);
  503. safeRun(registerOptions?.onAgentConfigComplete, result);
  504. }
  505. function handleAgentConfigFail(error) {
  506. const registerOptions = getRegisterOptions();
  507. safeRun(registerOptions?.onAgentConfigFail, error);
  508. safeRun(registerOptions?.onAgentConfigComplete, error);
  509. }
  510. /**
  511. * 触发或等待 config、agentConfig 完成
  512. *
  513. * @example
  514. * ```ts
  515. * await ww.ensureConfigReady()
  516. * ```
  517. */ function ensureConfigReady() {
  518. const registerOptions = getRegisterOptions();
  519. if (isWeCom && registerOptions?.getAgentConfigSignature) {
  520. return ensureAgentConfigReady();
  521. }
  522. return ensureCorpConfigReady();
  523. }
  524. /**
  525. * 在提供了 registerOptions 的情况下保证 config、agentConfig 完成
  526. *
  527. * @private
  528. */ function tryEnsureConfigReady() {
  529. const registerOptions = getRegisterOptions();
  530. if (!registerOptions) {
  531. return;
  532. }
  533. if (isWeCom && registerOptions.getAgentConfigSignature) {
  534. return ensureAgentConfigReady();
  535. }
  536. if (registerOptions.getConfigSignature) {
  537. return ensureCorpConfigReady();
  538. }
  539. }
  540. /**
  541. * 注册应用信息。
  542. *
  543. * @example
  544. * ```ts
  545. * ww.register({
  546. * corpId: 'ww7ca4776b2a70000',
  547. * jsApiList: ['getExternalContact'],
  548. * getConfigSignature
  549. * })
  550. * ```
  551. */ function register(options) {
  552. setRegisterOptions(options);
  553. if (isWeChat || isWeCom) {
  554. tryEnsureConfigReady();
  555. }
  556. }
  557. /**
  558. * 透传 JSAPI 调用
  559. */ async function passthrough(name, params, jsapiParams = params) {
  560. return promiseToCallback(params, async ()=>{
  561. await tryEnsureConfigReady();
  562. return invoke(name, jsapiParams);
  563. });
  564. }
  565. /**
  566. * 绑定事件
  567. */ async function bindShare(name, params, handler) {
  568. await tryEnsureConfigReady();
  569. on(name, ()=>{
  570. promiseToCallback(params, handler);
  571. });
  572. }
  573. /**
  574. * 把 promise 转为 success/fail callbacak 回调
  575. */ function promiseToCallback(params, factory) {
  576. return factory(params).then((result)=>{
  577. safeRun(params?.success, result);
  578. safeRun(params?.complete, result);
  579. return result;
  580. }, (error)=>{
  581. const keyword = extractErrMsgKeyword(error.errMsg);
  582. if (keyword === 'cancel') {
  583. safeRun(params?.cancel, error);
  584. } else {
  585. safeRun(params?.fail, error);
  586. }
  587. safeRun(params?.complete, error);
  588. throw error;
  589. });
  590. }
  591. exports.Proximity = void 0;
  592. (function(Proximity) {
  593. /**
  594. * CLProximityUnknown
  595. */ Proximity["CLProximityUnknown"] = "0";
  596. /**
  597. * CLProximityImmediate
  598. */ Proximity["CLProximityImmediate"] = "1";
  599. /**
  600. * CLProximityNear
  601. */ Proximity["CLProximityNear"] = "2";
  602. /**
  603. * CLProximityFar
  604. */ Proximity["CLProximityFar"] = "3";
  605. })(exports.Proximity || (exports.Proximity = {}));
  606. /**
  607. * 开启查找周边 iBeacon 设备。
  608. *
  609. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
  610. * @compat WeChat
  611. */ function startSearchBeacons(params = {}) {
  612. return passthrough('startMonitoringBeacons', params);
  613. }
  614. /**
  615. * 关闭查找周边 iBeacon 设备。
  616. *
  617. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
  618. * @compat WeChat
  619. */ function stopSearchBeacons(params = {}) {
  620. return passthrough('stopMonitoringBeacons', params);
  621. }
  622. /**
  623. * 监听周边 iBeacon 设备接口。
  624. *
  625. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
  626. * @compat WeChat
  627. */ function onSearchBeacons(callback) {
  628. on('onBeaconsInRange', callback);
  629. }
  630. /**
  631. * 连接低功耗蓝牙设备。
  632. *
  633. * @note
  634. * - 安卓手机上如果多次调用 createBLEConnection 创建连接,有可能导致系统持有同一设备多个连接的实例,导致调用 closeBLEConnection 的时候并不能真正的断开与设备的连接。因此请保证尽量成对的调用 create 和 close 接口
  635. * - 蓝牙链接随时可能断开,建议监听 onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作
  636. * - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作
  637. *
  638. * @compat WeCom
  639. *
  640. * @example
  641. * ```ts
  642. * ww.createBLEConnection({
  643. * deviceId: deviceId
  644. * })
  645. * ```
  646. */ function createBLEConnection(params) {
  647. return passthrough('createBLEConnection', params);
  648. }
  649. /**
  650. * 断开与低功耗蓝牙设备的连接。
  651. *
  652. * @compat WeCom
  653. *
  654. * @example
  655. * ```ts
  656. * ww.closeBLEConnection({
  657. * deviceId: deviceId
  658. * })
  659. * ```
  660. */ function closeBLEConnection(params) {
  661. return passthrough('closeBLEConnection', params);
  662. }
  663. /**
  664. * 监听低功耗蓝牙连接状态的改变事件,包括开发者主动连接或断开连接,设备丢失,连接异常断开等等。
  665. *
  666. * @compat WeCom
  667. *
  668. * @example
  669. * ```ts
  670. * ww.onBLEConnectionStateChange(function(event) {
  671. * console.log(event)
  672. * })
  673. * ```
  674. */ function onBLEConnectionStateChange(callback) {
  675. on('onBLEConnectionStateChange', callback);
  676. }
  677. /**
  678. * 获取蓝牙设备所有 service(服务)。
  679. *
  680. * @compat WeCom
  681. *
  682. * @example
  683. * ```ts
  684. * ww.getBLEDeviceServices({
  685. * deviceId: deviceId
  686. * })
  687. * ```
  688. */ function getBLEDeviceServices(params) {
  689. return passthrough('getBLEDeviceServices', params);
  690. }
  691. /**
  692. * 获取蓝牙设备某个服务中的所有 characteristic(特征值)。
  693. *
  694. * @compat WeCom
  695. *
  696. * @example
  697. * ```ts
  698. * ww.getBLEDeviceCharacteristics({
  699. * deviceId: deviceId,
  700. * serviceId: serviceId
  701. * })
  702. * ```
  703. */ function getBLEDeviceCharacteristics(params) {
  704. return passthrough('getBLEDeviceCharacteristics', params);
  705. }
  706. /**
  707. * 读取低功耗蓝牙设备的特征值的二进制数据值。
  708. *
  709. * @note
  710. * - 设备的特征值必须支持 read 才可以成功调用,具体参照 characteristic 的 properties 属性
  711. * - 并行调用多次读写接口存在读写失败的可能性
  712. * - 接口读取到的信息需要在 onBLECharacteristicValueChange 的回调中获取
  713. *
  714. * @compat WeCom
  715. *
  716. * @example
  717. * ```ts
  718. * ww.readBLECharacteristicValue({
  719. * deviceId: deviceId,
  720. * serviceId: serviceId,
  721. * characteristicId: characteristicId
  722. * })
  723. * ```
  724. */ function readBLECharacteristicValue(params) {
  725. return passthrough('readBLECharacteristicValue', params);
  726. }
  727. /**
  728. * 向低功耗蓝牙设备特征值中写入二进制数据。
  729. *
  730. * @note
  731. * - 设备的特征值必须支持 write 才可以成功调用,具体参照 characteristic 的 properties 属性
  732. * - 并行调用多次读写接口存在读写失败的可能性
  733. * - 接口不会对写入数据包大小做限制,但系统与蓝牙设备会确定蓝牙 4.0 单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过 20 字节
  734. * - 安卓平台上,在调用 notify 成功后立即调用 write 接口,在部分机型上会发生 10008 系统错误
  735. * - 若单次写入数据过长,iOS 平台上存在系统不会有任何回调的情况(包括错误回调)
  736. *
  737. * @compat WeCom
  738. *
  739. * @example
  740. * ```ts
  741. * ww.writeBLECharacteristicValue({
  742. * deviceId: deviceId,
  743. * serviceId: serviceId,
  744. * characteristicId: characteristicId,
  745. * value: arrayBufferValue
  746. * })
  747. * ```
  748. */ function writeBLECharacteristicValue(params) {
  749. return passthrough('writeBLECharacteristicValue', params, {
  750. deviceId: params.deviceId,
  751. serviceId: params.serviceId,
  752. characteristicId: params.characteristicId,
  753. value: arrayBufferToBase64(params.value)
  754. });
  755. }
  756. /**
  757. * 启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值。
  758. *
  759. * @note
  760. * - 设备的特征值必须支持 notify 或者 indicate 才可以成功调用,具体参照 characteristic 的 properties 属性
  761. * - 订阅操作成功后需要设备主动更新特征值的 value 才会触发 onBLECharacteristicValueChange 回调
  762. * - 安卓平台上,在调用 notify 成功后立即调用 write 接口,在部分机型上会发生 10008 系统错误
  763. *
  764. * @compat WeCom
  765. *
  766. * @example
  767. * ```ts
  768. * ww.notifyBLECharacteristicValueChange({
  769. * deviceId: deviceId,
  770. * serviceId: serviceId,
  771. * characteristicId: characteristicId,
  772. * state: true
  773. * })
  774. * ```
  775. */ function notifyBLECharacteristicValueChange(params) {
  776. return passthrough('notifyBLECharacteristicValueChange', params);
  777. }
  778. /**
  779. * 监听低功耗蓝牙设备的特征值变化。
  780. *
  781. * 必须先启用 notify 才能接收到设备推送的 notification。
  782. *
  783. * @compat WeCom
  784. *
  785. * @example
  786. * ```ts
  787. * ww.onBLECharacteristicValueChange(function(event) {
  788. * console.log(event)
  789. * })
  790. * ```
  791. */ function onBLECharacteristicValueChange(callback) {
  792. on('onBLECharacteristicValueChange', (event)=>{
  793. if (typeof event?.value === 'string') {
  794. event.value = base64ToArrayBuffer(event.value);
  795. }
  796. callback(event);
  797. });
  798. }
  799. /**
  800. * 初始化蓝牙模块。
  801. *
  802. * @compat WeCom
  803. *
  804. * @example
  805. * ```ts
  806. * ww.openBluetoothAdapter()
  807. * ```
  808. */ function openBluetoothAdapter(params = {}) {
  809. return passthrough('openBluetoothAdapter', params);
  810. }
  811. /**
  812. * 关闭蓝牙模块。
  813. *
  814. * @note
  815. * - 调用该方法将断开所有已建立的链接并释放系统资源
  816. *
  817. * @compat WeCom
  818. *
  819. * @example
  820. * ```ts
  821. * ww.closeBluetoothAdapter()
  822. * ```
  823. */ function closeBluetoothAdapter(params = {}) {
  824. return passthrough('closeBluetoothAdapter', params);
  825. }
  826. /**
  827. * 获取本机蓝牙适配器状态。
  828. *
  829. * @compat WeCom
  830. *
  831. * @example
  832. * ```ts
  833. * ww.getBluetoothAdapterState()
  834. * ```
  835. */ function getBluetoothAdapterState(params = {}) {
  836. return passthrough('getBluetoothAdapterState', params);
  837. }
  838. /**
  839. * 监听蓝牙适配器状态变化。
  840. *
  841. * @compat WeCom
  842. *
  843. * @example
  844. * ```ts
  845. * ww.onBluetoothAdapterStateChange(function(event) {
  846. * console.log(event)
  847. * })
  848. * ```
  849. */ function onBluetoothAdapterStateChange(callback) {
  850. on('onBluetoothAdapterStateChange', callback);
  851. }
  852. /**
  853. * 开始搜寻附近的蓝牙外围设备。
  854. *
  855. * @compat WeCom
  856. *
  857. * @example
  858. * ```ts
  859. * ww.startBluetoothDevicesDiscovery({
  860. * services: ['FEE7']
  861. * })
  862. * ```
  863. */ function startBluetoothDevicesDiscovery(params = {}) {
  864. return passthrough('startBluetoothDevicesDiscovery', params);
  865. }
  866. /**
  867. * 停止搜寻附近的蓝牙外围设备。
  868. *
  869. * 若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
  870. *
  871. * @compat WeCom
  872. *
  873. * @example
  874. * ```ts
  875. * ww.stopBluetoothDevicesDiscovery()
  876. * ```
  877. */ function stopBluetoothDevicesDiscovery(params = {}) {
  878. return passthrough('stopBluetoothDevicesDiscovery', params);
  879. }
  880. /**
  881. * 获取在蓝牙模块生效期间所有已发现的蓝牙设备。
  882. *
  883. * @note
  884. * - 该接口获取到的设备列表为蓝牙模块生效期间所有搜索到的蓝牙设备,若在蓝牙模块使用流程结束后未及时调用 closeBluetoothAdapter 释放资源,调用该接口可能会返回之前蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接
  885. * - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 GattName。若需要动态改变设备名称并展示,建议使用 localName 字段
  886. *
  887. * @compat WeCom
  888. *
  889. * @example
  890. * ```ts
  891. * ww.getBluetoothDevices()
  892. * ```
  893. */ function getBluetoothDevices(params = {}) {
  894. return promiseToCallback(params, async ()=>{
  895. await tryEnsureConfigReady();
  896. const res = await invoke('getBluetoothDevices');
  897. for (const device of res.devices || []){
  898. normalizeBluetoothDevice(device);
  899. }
  900. return res;
  901. });
  902. }
  903. /**
  904. * 监听寻找到新设备。
  905. *
  906. * @note
  907. * - 若在该接口中回调了某个设备,则此设备会添加到 getBluetoothDevices 接口返回的设备列表中
  908. *
  909. * @compat WeCom
  910. *
  911. * @example
  912. * ```ts
  913. * ww.onBluetoothDeviceFound(function(event) {
  914. * console.log(event)
  915. * })
  916. * ```
  917. */ function onBluetoothDeviceFound(callback) {
  918. on('onBluetoothDeviceFound', (res)=>{
  919. for (const device of res.devices || []){
  920. normalizeBluetoothDevice(device);
  921. }
  922. callback(res);
  923. });
  924. }
  925. /**
  926. * 根据 uuid 获取处于已连接状态的设备。
  927. *
  928. * @compat WeCom
  929. *
  930. * @example
  931. * ```ts
  932. * ww.getConnectedBluetoothDevices({
  933. * services: ['FEE7']
  934. * })
  935. * ```
  936. */ function getConnectedBluetoothDevices(params) {
  937. return passthrough('getConnectedBluetoothDevices', params);
  938. }
  939. function normalizeBluetoothDevice(device) {
  940. if (typeof device.advertisData === 'string') {
  941. device.advertisData = base64ToArrayBuffer(device.advertisData);
  942. }
  943. /**
  944. * @desc 客户端返回字段为 serviceDataV2,sdk 统一转换为 serviceData 字段后对外返回
  945. */ if (device.serviceDataV2) {
  946. const finalServiceData = device.serviceDataV2;
  947. for (const key of Object.keys(finalServiceData)){
  948. if (typeof finalServiceData[key] === 'string') {
  949. finalServiceData[key] = base64ToArrayBuffer(finalServiceData[key]);
  950. }
  951. }
  952. device.serviceData = finalServiceData;
  953. delete device.serviceDataV2;
  954. }
  955. }
  956. /**
  957. * 设置系统剪贴板的内容。
  958. *
  959. * @compat WeCom iOS, Android >= 2.4.16; WeCom PC, Mac >= 3.1.2
  960. *
  961. * @example
  962. * ```ts
  963. * ww.setClipboardData({
  964. * data: 'data'
  965. * })
  966. * ```
  967. */ function setClipboardData(params) {
  968. return passthrough('setClipboardData', params);
  969. }
  970. /**
  971. * 获取系统剪贴板内容。
  972. *
  973. * @compat WeCom >= 3.1.2
  974. *
  975. * @example
  976. * ```ts
  977. * ww.getClipboardData()
  978. * ```
  979. */ function getClipboardData(params = {}) {
  980. return passthrough('getClipboardData', params);
  981. }
  982. /**
  983. * 开始搜索附近的 iBeacon 设备。
  984. *
  985. * @compat WeCom
  986. *
  987. * @example
  988. * ```ts
  989. * ww.startBeaconDiscovery({
  990. * uuids: ['uuid']
  991. * })
  992. * ```
  993. */ function startBeaconDiscovery(params) {
  994. return passthrough('startBeaconDiscovery', params);
  995. }
  996. /**
  997. * 停止搜索附近的 iBeacon 设备。
  998. *
  999. * @compat WeCom
  1000. *
  1001. * @example
  1002. * ```ts
  1003. * ww.stopBeaconDiscovery()
  1004. * ```
  1005. */ function stopBeaconDiscovery(params = {}) {
  1006. return passthrough('stopBeaconDiscovery', params);
  1007. }
  1008. /**
  1009. * 获取所有已搜索到的 iBeacon 设备。
  1010. *
  1011. * @compat WeCom
  1012. *
  1013. * @example
  1014. * ```ts
  1015. * ww.getBeacons()
  1016. * ```
  1017. */ function getBeacons(params = {}) {
  1018. return passthrough('getBeacons', params);
  1019. }
  1020. /**
  1021. * 监听 iBeacon 设备的更新事件。
  1022. *
  1023. * @compat WeCom
  1024. *
  1025. * @example
  1026. * ```ts
  1027. * ww.onBeaconUpdate(function(event) {
  1028. * console.log(event)
  1029. * })
  1030. * ```
  1031. */ function onBeaconUpdate(callback) {
  1032. on('onBeaconUpdate', callback);
  1033. }
  1034. /**
  1035. * 监听 iBeacon 服务的状态变化。
  1036. *
  1037. * @compat WeCom
  1038. *
  1039. * @example
  1040. * ```ts
  1041. * ww.onBeaconServiceChange(function(event) {
  1042. * console.log(event)
  1043. * })
  1044. * ```
  1045. */ function onBeaconServiceChange(callback) {
  1046. on('onBeaconServiceChange', callback);
  1047. }
  1048. exports.LocationType = void 0;
  1049. (function(LocationType) {
  1050. /**
  1051. * gps 坐标
  1052. */ LocationType["wgs84"] = "wgs84";
  1053. /**
  1054. * 火星坐标
  1055. */ LocationType["gcj02"] = "gcj02";
  1056. })(exports.LocationType || (exports.LocationType = {}));
  1057. /**
  1058. * 使用企业微信内置地图查看位置。
  1059. *
  1060. * @example
  1061. * ```ts
  1062. * ww.openLocation({
  1063. * latitude: 0,
  1064. * longitude: 0,
  1065. * name: 'name',
  1066. * address: 'address',
  1067. * scale: 1
  1068. * })
  1069. * ```
  1070. */ function openLocation(params) {
  1071. return passthrough('openLocation', params, {
  1072. latitude: params.latitude,
  1073. longitude: params.longitude,
  1074. name: params.name || '',
  1075. address: params.address || '',
  1076. scale: params.scale || 28,
  1077. infoUrl: params.infoUrl || ''
  1078. });
  1079. }
  1080. /**
  1081. * 获取地理位置。
  1082. *
  1083. * @example
  1084. * ```ts
  1085. * ww.getLocation({
  1086. * type: 'wgs84'
  1087. * })
  1088. * ```
  1089. */ function getLocation(params = {}) {
  1090. return promiseToCallback(params, async ()=>{
  1091. await tryEnsureConfigReady();
  1092. const res = await invoke('geoLocation', {
  1093. type: params.type || 'wgs84'
  1094. });
  1095. delete res.type;
  1096. return res;
  1097. });
  1098. }
  1099. /**
  1100. * 打开持续定位。
  1101. *
  1102. * @compat WeCom >= 2.4.20
  1103. *
  1104. * @example
  1105. * ```ts
  1106. * ww.startAutoLBS({
  1107. * type: 'gcj02'
  1108. * })
  1109. * ```
  1110. */ function startAutoLBS(params) {
  1111. return passthrough('startAutoLBS', params);
  1112. }
  1113. /**
  1114. * 停止持续定位。
  1115. *
  1116. * @compat WeCom >= 2.4.20
  1117. *
  1118. * @example
  1119. * ```ts
  1120. * ww.stopAutoLBS()
  1121. * ```
  1122. */ function stopAutoLBS(params = {}) {
  1123. return passthrough('stopAutoLBS', params);
  1124. }
  1125. /**
  1126. * 监听地理位置的变化。
  1127. *
  1128. * @limit
  1129. * - 需要提前调用 startAutoLBS
  1130. * - 需要用户停留在当前页面
  1131. *
  1132. * @compat WeCom >= 2.4.20
  1133. *
  1134. * @example
  1135. * ```ts
  1136. * ww.onLocationChange(function(event) {
  1137. * console.log(event)
  1138. * })
  1139. * ```
  1140. *
  1141. * @throws
  1142. * | errMsg | 说明 | 兼容性 |
  1143. * | --- | --- | --- |
  1144. * | auto:location:report:ok | 执行成功 | |
  1145. * | auto:location:report:fail, gps closed. | 用户关闭了 GPS | 企业微信 3.0.26 |
  1146. */ function onLocationChange(callback) {
  1147. on('auto:location:report', callback);
  1148. }
  1149. exports.NetworkType = void 0;
  1150. (function(NetworkType) {
  1151. /**
  1152. * wifi
  1153. */ NetworkType["wifi"] = "wifi";
  1154. /**
  1155. * 2g
  1156. */ NetworkType["network2g"] = "2g";
  1157. /**
  1158. * 3g
  1159. */ NetworkType["network3g"] = "3g";
  1160. /**
  1161. * 4g
  1162. */ NetworkType["network4g"] = "4g";
  1163. /**
  1164. * 无网络
  1165. */ NetworkType["none"] = "none";
  1166. /**
  1167. * Android下不常见的网络类型
  1168. */ NetworkType["unknown"] = "unknown";
  1169. })(exports.NetworkType || (exports.NetworkType = {}));
  1170. /**
  1171. * 获取网络状态。
  1172. *
  1173. * @compat WeCom iOS, Android; WeChat
  1174. *
  1175. * @example
  1176. * ```ts
  1177. * ww.getNetworkType()
  1178. * ```
  1179. */ function getNetworkType(params = {}) {
  1180. return passthrough('getNetworkType', params);
  1181. }
  1182. /**
  1183. * 监听网络状态变化。
  1184. *
  1185. * @compat WeCom iOS, Android
  1186. *
  1187. * @example
  1188. * ```ts
  1189. * ww.onNetworkStatusChange(function(event) {
  1190. * console.log(event)
  1191. * })
  1192. * ```
  1193. */ function onNetworkStatusChange(callback) {
  1194. on('onNetworkStatusChange', callback);
  1195. }
  1196. /**
  1197. * 初始化 Wi-Fi 模块。
  1198. *
  1199. * @compat WeCom iOS, Android >= 2.4.16
  1200. *
  1201. * @example
  1202. * ```ts
  1203. * ww.startWifi()
  1204. * ```
  1205. */ function startWifi(params = {}) {
  1206. return passthrough('startWifi', params);
  1207. }
  1208. /**
  1209. * 关闭 Wi-Fi 模块。
  1210. *
  1211. * @compat WeCom iOS, Android >= 2.4.16
  1212. *
  1213. * @example
  1214. * ```ts
  1215. * ww.stopWifi()
  1216. * ```
  1217. */ function stopWifi(params = {}) {
  1218. return passthrough('stopWifi', params);
  1219. }
  1220. /**
  1221. * 连接 Wi-Fi。
  1222. *
  1223. * @compat WeCom iOS, Android >= 2.4.16
  1224. *
  1225. * @example
  1226. * ```ts
  1227. * ww.connectWifi({
  1228. * SSID: 'vincenthome',
  1229. * BSSID: '8c:a6:df:c8:f7:4b',
  1230. * password: 'test1234',
  1231. * })
  1232. * ```
  1233. */ function connectWifi(params) {
  1234. return passthrough('connectWifi', params);
  1235. }
  1236. /**
  1237. * 获取 Wi-Fi 列表。
  1238. *
  1239. * @compat WeCom iOS, Android >= 2.4.16
  1240. *
  1241. * @example
  1242. * ```ts
  1243. * ww.getWifiList()
  1244. * ```
  1245. */ function getWifiList(params = {}) {
  1246. return passthrough('getWifiList', params);
  1247. }
  1248. /**
  1249. * 监听 Wi-Fi 列表更新。
  1250. *
  1251. * @compat WeCom iOS, Android >= 2.4.16
  1252. *
  1253. * @example
  1254. * ```ts
  1255. * ww.onGetWifiList(function(event) {
  1256. * console.log(event)
  1257. * })
  1258. * ```
  1259. */ function onGetWifiList(callback) {
  1260. on('onGetWifiList', callback);
  1261. }
  1262. /**
  1263. * 监听 Wi-Fi 连接成功。
  1264. *
  1265. * @compat WeCom iOS, Android >= 2.4.16
  1266. *
  1267. * @example
  1268. * ```ts
  1269. * ww.onWifiConnected(function(event) {
  1270. * console.log(event)
  1271. * })
  1272. * ```
  1273. */ function onWifiConnected(callback) {
  1274. on('onWifiConnected', callback);
  1275. }
  1276. /**
  1277. * 获取已连接中的 Wi-Fi 信息。
  1278. *
  1279. * @compat WeCom iOS, Android >= 2.4.16
  1280. *
  1281. * @example
  1282. * ```ts
  1283. * ww.getConnectedWifi()
  1284. * ```
  1285. */ function getConnectedWifi(params = {}) {
  1286. return passthrough('getConnectedWifi', params);
  1287. }
  1288. /**
  1289. * 预览文件
  1290. *
  1291. * @compat WeCom iOS, Android
  1292. *
  1293. * @note
  1294. * 本接口将 URL 对应的文件下载后,在内置浏览器中预览。目前支持图片、音频、视频、文档等格式的文件。
  1295. * 从 2.4.6 版本开始,iOS 版企业微信浏览器升级为 WkWebView,企业微信原生层面的网络请求读取不到WKWebview中设置的cookie,即使域名是相同的。
  1296. * **问题说明:**
  1297. * 如果页面的资源或图片存储的服务器依赖校验Cookie来返回数据的情况,在切换到WKWebview后,在企业微信内长按保存,或者点击预览文件时,原生层面发起的网络请求将不会完整地带上所设置的Cookie,会导致图片保存失败或预览失败。
  1298. * **适配建议:**
  1299. * 建议静态资源cookie free。如果确实有信息需要传递,可通过业务后台存储需要传递的信息,然后给页面一个存储信息相对应的access_token加密码,再通过Url中加入自己业务的access_token进行页面间信息传递。
  1300. *
  1301. * @example
  1302. * ```ts
  1303. * ww.previewFile({
  1304. * url: 'http://open.work.weixin.qq.com/wwopen/downloadfile/wwapi.zip',
  1305. * name: 'Android开发工具包集合',
  1306. * size: 22189
  1307. * })
  1308. * ```
  1309. */ function previewFile(params) {
  1310. return passthrough('previewFile', params);
  1311. }
  1312. exports.ChooseMessageFileType = void 0;
  1313. (function(ChooseMessageFileType) {
  1314. /**
  1315. * 仅选择视频文件
  1316. */ ChooseMessageFileType["video"] = "video";
  1317. /**
  1318. * 仅选择图片文件
  1319. */ ChooseMessageFileType["image"] = "image";
  1320. /**
  1321. * 可选择除了图片和视频之外的其它的文件
  1322. */ ChooseMessageFileType["file"] = "file";
  1323. /**
  1324. * 可同时选择视频与图片
  1325. */ ChooseMessageFileType["video_and_image"] = "video_and_image";
  1326. })(exports.ChooseMessageFileType || (exports.ChooseMessageFileType = {}));
  1327. exports.TempFileType = void 0;
  1328. (function(TempFileType) {
  1329. /**
  1330. * 视频文件
  1331. */ TempFileType["video"] = "video";
  1332. /**
  1333. * 图片文件
  1334. */ TempFileType["image"] = "image";
  1335. /**
  1336. * 除图片和视频的文件
  1337. */ TempFileType["file"] = "file";
  1338. })(exports.TempFileType || (exports.TempFileType = {}));
  1339. /**
  1340. * 从企业微信会话中选择文件,用户选择文件之后,返回临时文件 localId,可再调用 [getLocalFileData](#56784) 获取文件内容。
  1341. *
  1342. * @compat WeCom iOS, Android >= 4.0.20
  1343. *
  1344. * @limit
  1345. * - 本接口必须使用应用身份进行注册
  1346. * - 当前成员必须在应用的可见范围之中
  1347. *
  1348. * @example
  1349. * ```ts
  1350. * ww.chooseMessageFile({
  1351. * count: 10,
  1352. * type: 'image',
  1353. * })
  1354. * ```
  1355. */ function chooseMessageFile(params) {
  1356. return passthrough('chooseMessageFile', params);
  1357. }
  1358. /**
  1359. * 获取 chooseMessageFile 返回的 localId 对应的文件内容。
  1360. *
  1361. * @compat WeCom iOS, Android >= 4.0.20
  1362. *
  1363. * @limit
  1364. * - 本接口必须使用应用身份进行注册
  1365. * - 当前成员必须在应用的可见范围之中
  1366. *
  1367. * @example
  1368. * ```ts
  1369. * ww.getLocalFileData({
  1370. * localId: '',
  1371. * })
  1372. * ```
  1373. *
  1374. * @throws
  1375. * | errMsg | 说明 |
  1376. * | --- | --- |
  1377. * | getLocalFileData:ok | 执行成功 |
  1378. * | no permission | 应用签名校验失败,或成员不在应用的可见范围内 |
  1379. * | no such file | localId不存在或者文件已删除 |
  1380. * | file exceed size limit | 不支持超过20M的文件 |
  1381. */ function getLocalFileData(params) {
  1382. return passthrough('getLocalFileData', params);
  1383. }
  1384. exports.SizeType = void 0;
  1385. (function(SizeType) {
  1386. /**
  1387. * 原图
  1388. */ SizeType["original"] = "original";
  1389. /**
  1390. * 压缩后的图片
  1391. */ SizeType["compressed"] = "compressed";
  1392. })(exports.SizeType || (exports.SizeType = {}));
  1393. exports.SourceType = void 0;
  1394. (function(SourceType) {
  1395. /**
  1396. * 相册
  1397. */ SourceType["album"] = "album";
  1398. /**
  1399. * 相机,企业微信 2.3 及以后版本支持相机连拍
  1400. */ SourceType["camera"] = "camera";
  1401. })(exports.SourceType || (exports.SourceType = {}));
  1402. exports.CameraMode = void 0;
  1403. (function(CameraMode) {
  1404. /**
  1405. * 单拍
  1406. */ CameraMode["normal"] = "normal";
  1407. /**
  1408. * 连拍
  1409. *
  1410. * @compat WeCom >= 2.3.0
  1411. */ CameraMode["batch"] = "batch";
  1412. /**
  1413. * 前置摄像头单拍
  1414. *
  1415. * @compat WeCom >= 3.0.26
  1416. */ CameraMode["front"] = "front";
  1417. /**
  1418. * 前置摄像头连拍
  1419. *
  1420. * @compat WeCom >= 3.0.26
  1421. */ CameraMode["batch_front"] = "batch_front";
  1422. })(exports.CameraMode || (exports.CameraMode = {}));
  1423. /**
  1424. * 拍照或从手机相册中选图。
  1425. *
  1426. * @compat WeCom iOS, Android; WeChat
  1427. *
  1428. * @example
  1429. * ```ts
  1430. * ww.chooseImage({
  1431. * count: 1,
  1432. * sizeType: ['original', 'compressed'],
  1433. * sourceType: ['album', 'camera'],
  1434. * defaultCameraMode: 'batch',
  1435. * isSaveToAlbum: true
  1436. * })
  1437. * ```
  1438. */ function chooseImage(params = {}) {
  1439. return promiseToCallback(params, async ()=>{
  1440. await tryEnsureConfigReady();
  1441. const res = await invoke('chooseImage', {
  1442. scene: '1|2',
  1443. count: params.count || 9,
  1444. sizeType: params.sizeType || [
  1445. 'original',
  1446. 'compressed'
  1447. ],
  1448. sourceType: params.sourceType || [
  1449. 'album',
  1450. 'camera'
  1451. ],
  1452. defaultCameraMode: params.defaultCameraMode || 'normal',
  1453. isSaveToAlbum: isFalsy(params.isSaveToAlbum) ? 0 : 1
  1454. });
  1455. if (isAndroid && res.localIds) {
  1456. res.localIds = res.localIds || '[]';
  1457. try {
  1458. res.localIds = JSON.parse(res.localIds);
  1459. } catch (error) {
  1460. // noop
  1461. }
  1462. }
  1463. return res;
  1464. });
  1465. }
  1466. /**
  1467. * 预览图片
  1468. *
  1469. * @note
  1470. * 从2.4.6版本开始,IOS版企业微信浏览器升级为WkWebView,企业微信原生层面的网络请求读取不到WKWebview中设置的cookie,即使域名是相同的。
  1471. * **问题说明:**
  1472. * 如果页面的资源或图片存储的服务器依赖校验Cookie来返回数据的情况,在切换到WKWebview后,在企业微信内长按保存,或者点击预览大图时,原生层面发起的网络请求将不会完整地带上所设置的Cookie,会导致图片保存失败或预览失败。
  1473. * **适配建议**
  1474. * 建议静态资源cookie free。如果确实有信息需要传递,可通过业务后台存储需要传递的信息,然后给页面一个存储信息相对应的access_token加密码,再通过Url中加入自己业务的access_token进行页面间信息传递。
  1475. *
  1476. * @example
  1477. * ```ts
  1478. * ww.previewImage({
  1479. * current: imgURL,
  1480. * urls: [imgURL]
  1481. * });
  1482. * ```
  1483. */ function previewImage(params) {
  1484. return passthrough('imagePreview', params);
  1485. }
  1486. /**
  1487. * 上传图片。
  1488. *
  1489. * @note
  1490. * 上传的图片有效期 3 天,可用[素材管理](#10115)接口下载图片到自己的服务器,此处获得的 serverId 即 media_id。
  1491. *
  1492. * @example
  1493. * ```ts
  1494. * ww.uploadImage({
  1495. * localId: localId,
  1496. * isShowProgressTips: true
  1497. * })
  1498. * ```
  1499. */ function uploadImage(params) {
  1500. return passthrough('uploadImage', params, {
  1501. localId: params.localId,
  1502. isShowProgressTips: isFalsy(params.isShowProgressTips) ? 0 : 1
  1503. });
  1504. }
  1505. /**
  1506. * 下载图片。
  1507. *
  1508. * @example
  1509. * ```ts
  1510. * ww.downloadImage({
  1511. * serverId: serverId,
  1512. * isShowProgressTips: true
  1513. * })
  1514. * ```
  1515. */ function downloadImage(params) {
  1516. return passthrough('downloadImage', params, {
  1517. serverId: params.serverId,
  1518. isShowProgressTips: isFalsy(params.isShowProgressTips) ? 0 : 1
  1519. });
  1520. }
  1521. /**
  1522. * 获取本地图片内容。
  1523. *
  1524. * @limit
  1525. * 仅在 iOS WKWebView 下支持。
  1526. *
  1527. * @compat WeCom iOS >= 2.4.6
  1528. *
  1529. * @example
  1530. * ```ts
  1531. * ww.getLocalImgData({
  1532. * localId: localId
  1533. * })
  1534. * ```
  1535. */ function getLocalImgData(params) {
  1536. return passthrough('getLocalImgData', params);
  1537. }
  1538. /**
  1539. * 开始录音。
  1540. *
  1541. * @example
  1542. * ```ts
  1543. * ww.startRecord()
  1544. * ```
  1545. */ function startRecord(params = {}) {
  1546. return passthrough('startRecord', params);
  1547. }
  1548. /**
  1549. * 停止录音。
  1550. *
  1551. * @example
  1552. * ```ts
  1553. * ww.stopRecord()
  1554. * ```
  1555. */ function stopRecord(params = {}) {
  1556. return passthrough('stopRecord', params);
  1557. }
  1558. /**
  1559. * 监听录音自动停止。
  1560. *
  1561. * @note
  1562. * 录音时间超过一分钟没有停止的时候会执行 complete 回调
  1563. *
  1564. * @example
  1565. * ```ts
  1566. * ww.onVoiceRecordEnd(function(event) {
  1567. * console.log(event)
  1568. * })
  1569. * ```
  1570. */ function onVoiceRecordEnd(callback) {
  1571. on('onVoiceRecordEnd', callback);
  1572. }
  1573. /**
  1574. * 播放语音。
  1575. *
  1576. * @example
  1577. * ```ts
  1578. * ww.playVoice({
  1579. * localId: localId
  1580. * })
  1581. * ```
  1582. */ function playVoice(params) {
  1583. return passthrough('playVoice', params);
  1584. }
  1585. /**
  1586. * 暂停播放。
  1587. *
  1588. * @example
  1589. * ```ts
  1590. * ww.pauseVoice({
  1591. * localId: localId
  1592. * })
  1593. * ```
  1594. */ function pauseVoice(params) {
  1595. return passthrough('pauseVoice', params);
  1596. }
  1597. /**
  1598. * 停止播放。
  1599. *
  1600. * @example
  1601. * ```ts
  1602. * ww.stopVoice({
  1603. * localId: localId
  1604. * })
  1605. * ```
  1606. */ function stopVoice(params) {
  1607. return passthrough('stopVoice', params);
  1608. }
  1609. /**
  1610. * 监听语音播放完毕。
  1611. *
  1612. * @example
  1613. * ```ts
  1614. * ww.onVoicePlayEnd(function(event) {
  1615. * console.log(event)
  1616. * })
  1617. * ```
  1618. */ function onVoicePlayEnd(callback) {
  1619. on('onVoicePlayEnd', callback);
  1620. }
  1621. /**
  1622. * 上传语音。
  1623. *
  1624. * @note
  1625. * 上传语音有效期 3 天,可以通过[素材管理](https://developer.work.weixin.qq.com/document/path/91054)接口下载语音到自己的服务器,接口返回的的 `serverId` 即 `media_id`。
  1626. *
  1627. * @example
  1628. * ```ts
  1629. * ww.uploadVoice({
  1630. * localId: localId,
  1631. * isShowProgressTips: true
  1632. * })
  1633. * ```
  1634. */ function uploadVoice(params) {
  1635. return passthrough('uploadVoice', params, {
  1636. localId: params.localId,
  1637. isShowProgressTips: isFalsy(params.isShowProgressTips) ? 0 : 1
  1638. });
  1639. }
  1640. /**
  1641. * 下载语音。
  1642. *
  1643. * @example
  1644. * ```ts
  1645. * ww.downloadVoice({
  1646. * serverId: serverId,
  1647. * isShowProgressTips: true
  1648. * })
  1649. * ```
  1650. */ function downloadVoice(params) {
  1651. return passthrough('downloadVoice', params, {
  1652. serverId: params.serverId,
  1653. isShowProgressTips: isFalsy(params.isShowProgressTips) ? 0 : 1
  1654. });
  1655. }
  1656. /**
  1657. * 语音转文字。
  1658. *
  1659. * @compat WeCom iOS, Android >= 2.7.5
  1660. *
  1661. * @example
  1662. * ```ts
  1663. * ww.translateVoice({
  1664. * localId: localId,
  1665. * isShowProgressTips: true
  1666. * })
  1667. * ```
  1668. */ function translateVoice(params) {
  1669. return passthrough('translateVoice', params, {
  1670. localId: params.localId,
  1671. isShowProgressTips: isFalsy(params.isShowProgressTips) ? 0 : 1
  1672. });
  1673. }
  1674. exports.LiveType = void 0;
  1675. (function(LiveType) {
  1676. /**
  1677. * 通用直播
  1678. */ LiveType[LiveType["common"] = 0] = "common";
  1679. /**
  1680. * 企业培训
  1681. */ LiveType[LiveType["corp_training"] = 1] = "corp_training";
  1682. /**
  1683. * 大班课
  1684. */ LiveType[LiveType["edu_normal_class"] = 2] = "edu_normal_class";
  1685. /**
  1686. * 小班课
  1687. */ LiveType[LiveType["edu_small_class"] = 3] = "edu_small_class";
  1688. })(exports.LiveType || (exports.LiveType = {}));
  1689. function startLiving(params = {}) {
  1690. return passthrough('startLiving', params);
  1691. }
  1692. /**
  1693. * 调起直播间回放页面。
  1694. *
  1695. * @limit
  1696. * - 本接口必须使用应用身份进行注册
  1697. * - 应用需具有直播使用权限,参考[配置可使用直播的应用](#25967/配置可使用直播的应用)
  1698. *
  1699. * @compat WeCom >= 3.1.0
  1700. *
  1701. * @example
  1702. * ```ts
  1703. * ww.replayLiving({
  1704. * livingId: 'LIVINGID'
  1705. * })
  1706. * ```
  1707. *
  1708. * @throws
  1709. * | errMsg | 说明 |
  1710. * | --- | --- |
  1711. * | replayLiving:ok | 执行成功 |
  1712. * | replayLiving:fail no permission | 应用签名校验失败,或应用不具备直播权限 |
  1713. * | replayLiving:fail invalid living id | 不合法的直播ID |
  1714. * | replayLiving:fail not allow to cross corp | 不可跨企业使用直播ID |
  1715. * | replayLiving:fail not allow to cross app | 不可跨应用使用直播ID |
  1716. * | replayLiving:fail living has no replay | 不存在直播回放 |
  1717. * | replayLiving:fail replay is beging creating | 正在直播中,或回放正在生成中,稍后观看回放 |
  1718. * | replayLiving:fail create replay failed | 回放创建失败 |
  1719. * | replayLiving:fail invalid parameter | 参数不合法 |
  1720. */ function replayLiving(params) {
  1721. return passthrough('replayLiving', params);
  1722. }
  1723. /**
  1724. * 调起直播回放下载页面。
  1725. *
  1726. * @limit
  1727. * - 本接口必须使用应用身份进行注册
  1728. * - 应用需具有直播使用权限,参考[配置可使用直播的应用](#25967/配置可使用直播的应用)
  1729. * - 只允许直播的发起人下载直播回放
  1730. *
  1731. * @compat WeCom PC >= 3.1.0
  1732. *
  1733. * @example
  1734. * ```ts
  1735. * ww.downloadLivingReplay({
  1736. * livingId: 'LIVINGID'
  1737. * })
  1738. * ```
  1739. *
  1740. * @throws
  1741. * | errMsg | 说明 |
  1742. * | --- | --- |
  1743. * | downloadLivingReplay:ok | 执行成功 |
  1744. * | downloadLivingReplay:fail no permission | 应用签名校验失败,或应用不具备直播权限 |
  1745. * | downloadLivingReplay:fail invalid living id | 不合法的直播ID |
  1746. * | downloadLivingReplay:fail not allow to cross corp | 不可跨企业使用直播ID |
  1747. * | downloadLivingReplay:fail not allow to cross app | 不可跨应用使用直播ID |
  1748. * | downloadLivingReplay:fail invalid parameter | 参数不合法 |
  1749. * | downloadLivingReplay:fail living has no replay | 不存在直播回放 |
  1750. * | downloadLivingReplay:fail replay is beging creating | 正在直播中,或回放正在生成中,稍后观看回放 |
  1751. * | downloadLivingReplay:fail create replay failed | 回放创建失败 |
  1752. * | downloadLivingReplay:fail invalid operator | 只允许直播的发起人下载直播回放 |
  1753. */ function downloadLivingReplay(params) {
  1754. return passthrough('downloadLivingReplay', params);
  1755. }
  1756. function startMeeting(params = {}) {
  1757. return passthrough('startMeeting', params);
  1758. }
  1759. /**
  1760. * 新建文档、表格或者收集表。
  1761. *
  1762. * @limit
  1763. * - 本接口必须使用应用身份进行注册
  1764. * - 签名应用必须具有文档使用权限
  1765. * - 当前用户必须在应用的可见范围之内
  1766. * - 在 Mac 端使用时,macOS 版本需 > 10.12
  1767. *
  1768. * @compat WeCom >= 4.1.0
  1769. *
  1770. * @example
  1771. * ```
  1772. * ww.createDoc({
  1773. * docType: 3
  1774. * })
  1775. * ```
  1776. *
  1777. * @throws
  1778. * | errMsg | 说明 |
  1779. * | --- | --- |
  1780. * | createDoc:ok | 执行成功 |
  1781. * | createDoc:fail no permission | 应用签名校验失败,或成员不在应用的可见范围内,或应用未开启文档使用权限 |
  1782. * | createDoc:fail doc app closed. | 基础应用“文档”如果未启用 |
  1783. * | createDoc:fail form app closed. | 基础应用“收集表”如果没有启用 |
  1784. */ function createDoc(params) {
  1785. return passthrough('createDoc', params);
  1786. }
  1787. exports.WedocSelectedFileType = void 0;
  1788. (function(WedocSelectedFileType) {
  1789. /**
  1790. * 其他
  1791. */ WedocSelectedFileType[WedocSelectedFileType["other"] = 0] = "other";
  1792. /**
  1793. * 文档
  1794. */ WedocSelectedFileType[WedocSelectedFileType["doc"] = 3] = "doc";
  1795. /**
  1796. * 表格
  1797. */ WedocSelectedFileType[WedocSelectedFileType["sheet"] = 4] = "sheet";
  1798. /**
  1799. * 收集表
  1800. */ WedocSelectedFileType[WedocSelectedFileType["form"] = 5] = "form";
  1801. /**
  1802. * 幻灯片
  1803. */ WedocSelectedFileType[WedocSelectedFileType["slide"] = 6] = "slide";
  1804. /**
  1805. * 思维导图
  1806. */ WedocSelectedFileType[WedocSelectedFileType["mindmap"] = 7] = "mindmap";
  1807. /**
  1808. * 流程图
  1809. */ WedocSelectedFileType[WedocSelectedFileType["flowchart"] = 8] = "flowchart";
  1810. /**
  1811. * 智能表格
  1812. */ WedocSelectedFileType[WedocSelectedFileType["smartsheet"] = 10] = "smartsheet";
  1813. })(exports.WedocSelectedFileType || (exports.WedocSelectedFileType = {}));
  1814. /**
  1815. * 选择一个或多个文档,返回对应文档的 URL。
  1816. *
  1817. * @limit
  1818. * - 本接口必须使用应用身份进行注册,签名应用必须具有文档使用权限
  1819. * - 当前用户必须在应用的可见范围之内
  1820. * - Mac 端使用时,macOS 版本需 > 10.12
  1821. *
  1822. * @compat WeCom >= 4.0.12
  1823. *
  1824. * @example
  1825. * ```
  1826. * ww.wedocSelectDoc({
  1827. * selectedFileNum: 1
  1828. * })
  1829. * ```
  1830. *
  1831. * @throws
  1832. * | errMsg | 说明 |
  1833. * | --- | --- |
  1834. * | wedocSelectDoc:ok | 执行成功 |
  1835. * | wedocSelectDoc:cancel | 取消选择 |
  1836. * | wedocSelectDoc:fail no permission | 应用签名失败,或应用无文档使用权限,或用户不在应用可见范围内 |
  1837. * | wedocSelectDoc:fail param error | 参数错误 |
  1838. * | wedocSelectDoc:fail context error | 选择器异常 |
  1839. * | wedocSelectDoc:fail not supported system version| 低系统版本不支持 |
  1840. */ function wedocSelectDoc(params) {
  1841. return passthrough('wedocSelectDoc', params);
  1842. }
  1843. /**
  1844. * 在微盘中选择一个具有可上传权限的目录/空间,返回选中目录/空间对应的 selectedTicket。
  1845. *
  1846. * @limit
  1847. * - 本接口必须使用应用身份进行注册
  1848. * - 所使用的应用必须具有微盘权限
  1849. * - 当前成员必须在应用的可见范围之内
  1850. * - 若用户在某一目录位置不具备「上传」权限(微盘权限值为“可下载”/“仅预览”或自定义权限取消勾选“上传”权限),则无法选择该目录
  1851. * - 在 Mac 端使用时,macOS 版本需 > 10.12
  1852. *
  1853. * @compat WeCom >= 4.0.12
  1854. *
  1855. * @example
  1856. * ```
  1857. * ww.wedriveSelectDir()
  1858. * ```
  1859. *
  1860. * @throws
  1861. * | errMsg | 说明 |
  1862. * | --- | --- |
  1863. * | wedriveSelectDir:ok | 执行成功 |
  1864. * | wedriveSelectDir:cancel | 取消选择 |
  1865. * | wedriveSelectDir:fail no permission | 无权限 |
  1866. * | wedriveSelectDir:fail param error | 参数错误 |
  1867. * | wedriveSelectDir:fail context error | 选择器异常 |
  1868. * | wedriveSelectDir:fail not supported system version | 低系统版本不支持 |
  1869. */ function wedriveSelectDir(params = {}) {
  1870. return passthrough('wedriveSelectDir', params);
  1871. }
  1872. /**
  1873. * 唤起微盘选择器,选择微盘中的文件
  1874. *
  1875. * 在微盘中选择一个或多个具有可分享权限的微盘文件或在线文档,返回选中文件的 url。
  1876. *
  1877. * @compat WeCom >= 4.0.12
  1878. *
  1879. * @limit
  1880. * - 本接口必须使用应用身份进行注册
  1881. * - 所使用的应用必须具有微盘和文档使用权限
  1882. * - 当前成员必须在应用的可见范围之内
  1883. * - 若用户对某文件不具备「分享」权限(微盘自定义权限取消勾选“分享”权限),则无法选择该文件。
  1884. * - 在 Mac 端使用时,macOS 版本需 > 10.12
  1885. *
  1886. * @example
  1887. * ```
  1888. * ww.wedriveSelectFile({
  1889. * selectedFileNum: 1,
  1890. * })
  1891. * ```
  1892. *
  1893. * @throws
  1894. * | errMsg | 说明 |
  1895. * | --- | --- |
  1896. * | wedriveSelectFile:ok | 执行成功 |
  1897. * | wedriveSelectFile:cancel | 取消选择 |
  1898. * | wedriveSelectFile:fail no permission | 无权限 |
  1899. * | wedriveSelectFile:fail param error | 参数错误 |
  1900. * | wedriveSelectFile:fail context error | 选择器异常 |
  1901. * | wedriveSelectFile:fail not supported system version | 低系统版本不支持 |
  1902. */ function wedriveSelectFile(params) {
  1903. return passthrough('wedriveSelectFile', params);
  1904. }
  1905. /**
  1906. * 选择可分享的文件
  1907. *
  1908. * 在微盘中选择一个或多个具有可分享权限的微盘文件或在线文档,返回选中文件的 url。
  1909. *
  1910. * @deprecated 该接口即将废弃,请使用 wedriveSelectFile 代替
  1911. *
  1912. * @compat WeCom >= 4.0.12
  1913. */ function wedriveSelectFileForShare(params) {
  1914. return passthrough('wedriveSelectFileForShare', params);
  1915. }
  1916. /**
  1917. * 在微盘中选择一个或多个具有下载权限的文件(只能是微盘文件,不支持在线文档),返回选中文件对应的 selectedTickets 列表。
  1918. *
  1919. * @limit
  1920. * - 本接口必须使用应用身份进行注册
  1921. * - 应用必须具有微盘使用权限
  1922. * - 当前成员必须在应用的可见范围之中
  1923. * - 自建应用不支持调用
  1924. *
  1925. * @compat WeCom >= 4.0.12
  1926. *
  1927. * @example
  1928. * ```
  1929. * ww.wedriveSelectFileForDownload({
  1930. * selectedFileNum: 1
  1931. * })
  1932. * ```
  1933. *
  1934. * @throws
  1935. * | errMsg | 说明 |
  1936. * | --- | --- |
  1937. * | wedriveSelectFileForDownload:ok | 执行成功 |
  1938. * | wedriveSelectFileForDownload:cancel | 取消选择 |
  1939. * | wedriveSelectFileForDownload:fail no permission | 无权限 |
  1940. * | wedriveSelectFileForDownload:fail param error | 参数错误 |
  1941. * | wedriveSelectFileForDownload:fail context error | 选择器异常 |
  1942. * | wedriveSelectFileForDownload:fail not supported system version | 低系统版本不支持 |
  1943. */ function wedriveSelectFileForDownload(params) {
  1944. return passthrough('wedriveSelectFileForDownload', params);
  1945. }
  1946. /**
  1947. * 监听页面返回事件。
  1948. *
  1949. * @param callback 回调函数,返回 false 则表示中断此次返回操作
  1950. *
  1951. * @limit
  1952. * - 当页面左上角没有关闭按钮,不产生该事件
  1953. * - iOS 系统下使用手势返回时,不产生该事件
  1954. *
  1955. * @compat WeCom iOS, Android >= 2.2.0; WeCom PC, Mac >= 2.4.5
  1956. *
  1957. * @example
  1958. * ```ts
  1959. * ww.onHistoryBack(function() {
  1960. * return confirm('确定放弃当前页面的修改?')
  1961. * })
  1962. * ```
  1963. */ function onHistoryBack(callback) {
  1964. on('historyBack', callback);
  1965. }
  1966. /**
  1967. * 隐藏右上角菜单。
  1968. *
  1969. * @example
  1970. * ```ts
  1971. * ww.hideOptionMenu()
  1972. * ```
  1973. */ function hideOptionMenu(params = {}) {
  1974. return passthrough('hideOptionMenu', params);
  1975. }
  1976. /**
  1977. * 显示右上角菜单。
  1978. *
  1979. * @example
  1980. * ```ts
  1981. * ww.showOptionMenu()
  1982. * ```
  1983. */ function showOptionMenu(params = {}) {
  1984. return passthrough('showOptionMenu', params);
  1985. }
  1986. /**
  1987. * 关闭当前网页窗口。
  1988. *
  1989. * @example
  1990. * ```ts
  1991. * ww.closeWindow()
  1992. * ```
  1993. */ function closeWindow(params = {}) {
  1994. return passthrough('closeWindow', params);
  1995. }
  1996. /**
  1997. * 批量隐藏功能按钮。
  1998. *
  1999. * @note
  2000. * 完整功能按钮列表请参考[所有菜单项列表](#14926)。
  2001. *
  2002. * @example
  2003. * ```ts
  2004. * ww.hideMenuItems({
  2005. * menuList: ['menuItem:setFont']
  2006. * })
  2007. * ```
  2008. */ function hideMenuItems(params) {
  2009. return passthrough('hideMenuItems', params);
  2010. }
  2011. /**
  2012. * 批量显示功能按钮。
  2013. *
  2014. * @note
  2015. * 完整功能按钮列表请参考[所有菜单项列表](#14926)。
  2016. *
  2017. * @example
  2018. * ```ts
  2019. * ww.showMenuItems({
  2020. * menuList: ['menuItem:setFont']
  2021. * })
  2022. * ```
  2023. */ function showMenuItems(params) {
  2024. return passthrough('showMenuItems', params);
  2025. }
  2026. /**
  2027. * 隐藏所有非基础按钮。
  2028. *
  2029. * @example
  2030. * ```ts
  2031. * ww.hideAllNonBaseMenuItem()
  2032. * ```
  2033. */ function hideAllNonBaseMenuItem(params = {}) {
  2034. return passthrough('hideAllNonBaseMenuItem', params);
  2035. }
  2036. /**
  2037. * 显示所有功能按钮。
  2038. *
  2039. * @example
  2040. * ```ts
  2041. * ww.showAllNonBaseMenuItem()
  2042. * ```
  2043. */ function showAllNonBaseMenuItem(params = {}) {
  2044. return passthrough('showAllNonBaseMenuItem', params);
  2045. }
  2046. /**
  2047. * 使用系统浏览器打开指定 URL,支持传入 oauth2 链接,从而实现在系统浏览器内免登录的效果。
  2048. *
  2049. * @compat WeCom PC >= 2.3.0
  2050. *
  2051. * @example
  2052. * ```ts
  2053. * ww.openDefaultBrowser({
  2054. * url: 'https://work.weixin.qq.com/'
  2055. * })
  2056. * ```
  2057. */ function openDefaultBrowser(params) {
  2058. return passthrough('openDefaultBrowser', params);
  2059. }
  2060. /**
  2061. * 监听用户截屏事件。
  2062. *
  2063. * @compat WeCom iOS, Android >= 2.5.0
  2064. *
  2065. * @example
  2066. * ```ts
  2067. * ww.onUserCaptureScreen(function() {
  2068. * console.log('用户截屏了')
  2069. * })
  2070. * ```
  2071. */ function onUserCaptureScreen(callback) {
  2072. on('onUserCaptureScreen', callback);
  2073. }
  2074. /**
  2075. * 获取「转发」按钮点击状态并自定义分享内容。
  2076. *
  2077. * @note
  2078. * 微信客户端即将废弃该接口。
  2079. *
  2080. * @limit
  2081. * - 仅激活成员数超过 200 人且已经认证的企业才可在微信上调用
  2082. *
  2083. * @example
  2084. * ```ts
  2085. * ww.onMenuShareAppMessage({
  2086. * title: '企业微信',
  2087. * desc: '让每个企业都有自己的微信',
  2088. * link: 'https://work.weixin.qq.com/',
  2089. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  2090. * success() {
  2091. * // 用户确认分享后回调
  2092. * },
  2093. * cancel() {
  2094. * // 用户取消分享后回调
  2095. * }
  2096. * })
  2097. * ```
  2098. */ function onMenuShareAppMessage(params) {
  2099. bindShare('menu:share:appmessage', params, ()=>invoke('sendAppMessage', {
  2100. title: params.title || getTitle(),
  2101. desc: params.desc || '',
  2102. link: params.link || getHref(),
  2103. img_url: params.imgUrl || '',
  2104. type: params.type || 'link',
  2105. data_url: params.dataUrl || '',
  2106. finder_feed: params.finderFeed || params.finder_feed,
  2107. finder_topic: params.finderTopic || params.finder_topic,
  2108. finder_profile: params.finderProfile || params.finder_profile,
  2109. enableIdTrans: params.enableIdTrans ? 1 : 0
  2110. }));
  2111. }
  2112. /**
  2113. * 获取「分享到朋友圈」按钮点击状态并自定义分享内容。
  2114. *
  2115. * @note
  2116. * 微信客户端即将废弃该接口。
  2117. *
  2118. * @example
  2119. * ```ts
  2120. * ww.onMenuShareTimeline({
  2121. * title: '企业微信',
  2122. * link: 'https://work.weixin.qq.com/',
  2123. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  2124. * success() {
  2125. * // 用户确认分享后回调
  2126. * },
  2127. * cancel() {
  2128. * // 用户取消分享后回调
  2129. * }
  2130. * })
  2131. * ```
  2132. */ function onMenuShareTimeline(params) {
  2133. bindShare('menu:share:timeline', params, ()=>invoke('shareTimeline', {
  2134. title: params.title || getTitle(),
  2135. desc: params.title || getTitle(),
  2136. img_url: params.imgUrl || '',
  2137. link: params.link || getHref(),
  2138. type: params.type || 'link',
  2139. data_url: params.dataUrl || '',
  2140. enableIdTrans: params.enableIdTrans ? 1 : 0
  2141. }));
  2142. }
  2143. /**
  2144. * 获取「微信」按钮点击状态并自定义分享内容。
  2145. *
  2146. * @compat WeCom
  2147. *
  2148. * @example
  2149. * ```ts
  2150. * ww.onMenuShareWechat({
  2151. * title: '企业微信',
  2152. * desc: '让每个企业都有自己的微信',
  2153. * link: 'https://work.weixin.qq.com/',
  2154. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  2155. * success() {
  2156. * // 用户确认分享后回调
  2157. * },
  2158. * cancel() {
  2159. * // 用户取消分享后回调
  2160. * }
  2161. * })
  2162. * ```
  2163. */ function onMenuShareWechat(params) {
  2164. bindShare('menu:share:wechat', params, ()=>invoke('shareWechat', {
  2165. title: params.title || getTitle(),
  2166. desc: params.desc || '',
  2167. link: params.link || getHref(),
  2168. img_url: params.imgUrl || '',
  2169. type: params.type || 'link',
  2170. data_url: params.dataUrl || '',
  2171. enableIdTrans: params.enableIdTrans ? 1 : 0
  2172. }));
  2173. }
  2174. /**
  2175. * 获取「分享到QQ」按钮点击状态并自定义分享内容。
  2176. *
  2177. * @note
  2178. * 微信客户端即将废弃该接口。
  2179. *
  2180. * @compat WeChat
  2181. */ function onMenuShareQQ(params) {
  2182. bindShare('menu:share:qq', params, ()=>invoke('shareQQ', {
  2183. title: params.title || getTitle(),
  2184. desc: params.desc || '',
  2185. img_url: params.imgUrl || '',
  2186. link: params.link || getHref()
  2187. }));
  2188. }
  2189. /**
  2190. * 获取「分享到微博」按钮点击状态并自定义分享内容。
  2191. *
  2192. * @compat WeChat
  2193. */ function onMenuShareWeibo(params) {
  2194. bindShare('menu:share:weiboApp', params, ()=>invoke('shareWeiboApp', {
  2195. title: params.title || getTitle(),
  2196. desc: params.desc || '',
  2197. img_url: params.imgUrl || '',
  2198. link: params.link || getHref()
  2199. }));
  2200. }
  2201. /**
  2202. * 获取「分享到QQ空间」按钮点击状态并自定义分享内容。
  2203. *
  2204. * @note
  2205. * 微信客户端即将废弃该接口。
  2206. *
  2207. * @compat WeChat
  2208. */ function onMenuShareQZone(params) {
  2209. bindShare('menu:share:QZone', params, ()=>invoke('shareQZone', {
  2210. title: params.title || getTitle(),
  2211. desc: params.desc || '',
  2212. img_url: params.imgUrl || '',
  2213. link: params.link || getHref()
  2214. }));
  2215. }
  2216. /**
  2217. * 自定义转发到会话。
  2218. *
  2219. * @compat WeCom >= 2.4.5
  2220. *
  2221. * @example
  2222. * ```ts
  2223. * ww.shareAppMessage({
  2224. * title: '企业微信',
  2225. * desc: '让每个企业都有自己的微信',
  2226. * link: 'https://work.weixin.qq.com/',
  2227. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  2228. * })
  2229. * ```
  2230. */ function shareAppMessage(params) {
  2231. return passthrough('shareAppMessage', params);
  2232. }
  2233. /**
  2234. * 自定义转发到微信。
  2235. *
  2236. * @compat WeCom >= 2.4.5
  2237. *
  2238. * @example
  2239. * ```ts
  2240. * ww.shareWechatMessage({
  2241. * title: '企业微信',
  2242. * desc: '让每个企业都有自己的微信',
  2243. * link: 'https://work.weixin.qq.com/',
  2244. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  2245. * })
  2246. * ```
  2247. */ function shareWechatMessage(params) {
  2248. return passthrough('shareWechatMessage', params);
  2249. }
  2250. /**
  2251. * 自定义「分享到朋友圈」及「分享到QQ空间」按钮的分享内容。
  2252. *
  2253. * @compat WeChat
  2254. */ function updateTimelineShareData(params = {}) {
  2255. return passthrough('updateTimelineShareData', params);
  2256. }
  2257. /**
  2258. * 自定义「分享给朋友」及「分享到QQ」按钮的分享内容。
  2259. *
  2260. * @compat WeChat
  2261. */ function updateAppMessageShareData(params = {}) {
  2262. return passthrough('updateAppMessageShareData', params);
  2263. }
  2264. /**
  2265. * 批量添加卡券。
  2266. *
  2267. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#批量添加卡券接口
  2268. */ function addCard(params) {
  2269. return promiseToCallback(params, async ()=>{
  2270. await tryEnsureConfigReady();
  2271. const res = await invoke('batchAddCard', {
  2272. card_list: params.cardList.map((card)=>({
  2273. card_id: card.cardId,
  2274. card_ext: card.cardExt
  2275. }))
  2276. });
  2277. if (!res.card_list) {
  2278. return res;
  2279. }
  2280. for (const card of res.card_list){
  2281. card.cardId = card.card_id;
  2282. delete card.card_id;
  2283. card.cardExt = card.card_ext;
  2284. delete card.card_ext;
  2285. card.isSuccess = !!card.is_succ;
  2286. delete card.is_succ;
  2287. }
  2288. res.cardList = res.card_list;
  2289. delete res.card_list;
  2290. return res;
  2291. });
  2292. }
  2293. /**
  2294. * 拉取适用卡券列表并获取用户选择信息。
  2295. *
  2296. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#拉取适用卡券列表并获取用户选择信息
  2297. */ function chooseCard(params) {
  2298. return promiseToCallback(params, async ()=>{
  2299. await tryEnsureConfigReady();
  2300. const res = await invoke('chooseCard', {
  2301. app_id: getConfigCorpId(),
  2302. location_id: params.shopId || '',
  2303. sign_type: params.signType || 'SHA1',
  2304. card_id: params.cardId || '',
  2305. card_type: params.cardType || '',
  2306. card_sign: params.cardSign,
  2307. time_stamp: `${params.timestamp}`,
  2308. nonce_str: params.nonceStr
  2309. });
  2310. res.cardList = res.choose_card_info;
  2311. delete res.choose_card_info;
  2312. return res;
  2313. });
  2314. }
  2315. /**
  2316. * 查看微信卡包中的卡券。
  2317. *
  2318. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#查看微信卡包中的卡券接口
  2319. */ function openCard(params) {
  2320. return passthrough('batchViewCard', params, {
  2321. card_list: params.cardList.map((card)=>({
  2322. card_id: card.cardId,
  2323. code: card.code
  2324. }))
  2325. });
  2326. }
  2327. /**
  2328. * 核销并分享卡券。
  2329. *
  2330. * @deprecated
  2331. */ function consumeAndShareCard(params) {
  2332. return passthrough('consumedShareCard', params, {
  2333. consumedCardId: params.cardId,
  2334. consumedCode: params.code
  2335. });
  2336. }
  2337. exports.ProductViewType = void 0;
  2338. (function(ProductViewType) {
  2339. ProductViewType[ProductViewType["normal"] = 0] = "normal";
  2340. ProductViewType[ProductViewType["scan"] = 1] = "scan";
  2341. })(exports.ProductViewType || (exports.ProductViewType = {}));
  2342. /**
  2343. * 跳转微信商品页。
  2344. *
  2345. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#跳转微信商品页接口
  2346. */ function openProductSpecificView(params) {
  2347. return passthrough('openProductViewWithPid', params, {
  2348. pid: params.productId,
  2349. view_type: params.viewType || 0,
  2350. ext_info: params.extInfo
  2351. });
  2352. }
  2353. /**
  2354. * 发起一个微信支付请求。
  2355. *
  2356. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#发起一个微信支付请求
  2357. */ function chooseWXPay(params) {
  2358. return passthrough('getBrandWCPayRequest', params, normalizeParams(params));
  2359. }
  2360. /**
  2361. * 领取企业红包。
  2362. */ function openEnterpriseRedPacket(params) {
  2363. return passthrough('getRecevieBizHongBaoRequest', params, normalizeParams(params));
  2364. }
  2365. function normalizeParams(params) {
  2366. return {
  2367. timeStamp: `${params.timestamp}`,
  2368. nonceStr: params.nonceStr,
  2369. package: params.package,
  2370. paySign: params.paySign,
  2371. signType: params.signType || 'SHA1'
  2372. };
  2373. }
  2374. /**
  2375. * 添加设备。
  2376. *
  2377. * @limit
  2378. * - 本接口必须使用应用身份进行注册
  2379. * - 发起用户需要有设备添加权限(超级管理员/设备管理员)
  2380. *
  2381. * @compat WeCom iOS, Android >= 4.0.18
  2382. *
  2383. * @example
  2384. * ```ts
  2385. * ww.addDevice({
  2386. * type: 'qrcode',
  2387. * qrcode_url: 'https://open.work.weixin.qq.com/connect?xxx',
  2388. * })
  2389. * ```
  2390. */ function addDevice(params) {
  2391. return passthrough('addDevice', params);
  2392. }
  2393. /**
  2394. * 判断当前客户端版本是否支持指定 JS 接口。
  2395. *
  2396. * @example
  2397. * ```ts
  2398. * ww.checkJsApi({
  2399. * jsApiList: ['chooseImage']
  2400. * })
  2401. * ```
  2402. */ async function checkJsApi(params) {
  2403. return promiseToCallback(params, async ()=>{
  2404. await tryEnsureConfigReady();
  2405. const res = await invoke('checkJsApi', {
  2406. jsApiList: mapJsApiListToClient(params.jsApiList)
  2407. });
  2408. if (typeof res.checkResult === 'string') {
  2409. try {
  2410. res.checkResult = JSON.parse(res.checkResult);
  2411. } catch (error) {
  2412. res.checkResult = {};
  2413. }
  2414. }
  2415. res.checkResult = normalize(flatten(res.checkResult));
  2416. return res;
  2417. });
  2418. }
  2419. function normalize(data) {
  2420. const result = {
  2421. ...data
  2422. };
  2423. for (const key of Object.keys(data)){
  2424. result[mapJsApiNameToWeb(key)] = data[key];
  2425. }
  2426. return result;
  2427. }
  2428. function flatten(data) {
  2429. const result = {};
  2430. for (const key of Object.keys(data)){
  2431. if (!isObject$1(data[key])) {
  2432. result[key] = data[key];
  2433. continue;
  2434. }
  2435. const child = flatten(data[key]);
  2436. for (const childKey of Object.keys(child)){
  2437. result[`${key}.${childKey}`] = child[childKey];
  2438. }
  2439. }
  2440. return result;
  2441. }
  2442. /**
  2443. * 查看其他成员某段时间内日程中的闲忙状态。
  2444. *
  2445. * @limit
  2446. * - 本接口必须使用应用身份进行注册
  2447. * - 当前成员必须在应用可见范围内
  2448. * - 应用需具有日程使用权限
  2449. *
  2450. * @compat WeCom >= 4.0.20
  2451. *
  2452. * @example
  2453. * ```ts
  2454. * ww.checkSchedule({
  2455. * start_time: 1667232000,
  2456. * end_time: 1667318400,
  2457. * users: ['jack', 'jason']
  2458. * })
  2459. * ```
  2460. */ function checkSchedule(params) {
  2461. return passthrough('checkSchedule', params);
  2462. }
  2463. /**
  2464. * 拉起电子发票列表。
  2465. *
  2466. * @compat WeCom iOS, Android >= 2.1.0
  2467. *
  2468. * @example
  2469. * ```ts
  2470. * ww.chooseInvoice({
  2471. * timestamp: timestamp,
  2472. * nonceStr: nonceStr,
  2473. * signType: signType,
  2474. * cardSign: cardSign
  2475. * })
  2476. * ```
  2477. *
  2478. * @throws
  2479. * | errMsg | 说明 |
  2480. * | --- | --- |
  2481. * | choose_invoice:ok | 执行成功 |
  2482. * | choose_invoice: fail | 选取发票失败 |
  2483. * | choose_invoice: cancel | 选取发票取消 |
  2484. */ function chooseInvoice(params) {
  2485. return passthrough('chooseInvoice', params);
  2486. }
  2487. /**
  2488. * 跳转到认领班级的界面。
  2489. *
  2490. * @compat WeCom >= 3.1.8
  2491. *
  2492. * @limit 本接口必须使用应用身份进行注册
  2493. *
  2494. * @example
  2495. * ```ts
  2496. * ww.claimClassAdmin()
  2497. * ```
  2498. *
  2499. * @throws
  2500. * | errMsg | 说明 |
  2501. * | --- | --- |
  2502. * | claimClassAdmin:ok | 执行成功 |
  2503. * | claimClassAdmin:fail no permission | 应用身份鉴权失败 |
  2504. * | claimClassAdmin:fail user not in allow list | 当前成员不在应用可见范围 |
  2505. */ function claimClassAdmin(params = {}) {
  2506. return passthrough('claimClassAdmin', params);
  2507. }
  2508. /**
  2509. * 向用户申请给指定范围发送消息。
  2510. *
  2511. * 调用接口后,用户可在选人界面对群聊范围进行修改,当创建群聊成功时会返回新建的群聊 ID。
  2512. *
  2513. * @limit
  2514. * - 仅第三方应用(非通讯录应用)与代开发应用可调用
  2515. * - 本接口必须使用应用身份进行注册
  2516. *
  2517. * @compat WeCom >= 3.1.8
  2518. *
  2519. * @example
  2520. * ```ts
  2521. * ww.createChatWithMsg({
  2522. * selectedOpenUserIds: ['zhangsan','lisi'],
  2523. * selectedTickets: ['tick1','token2'],
  2524. * chatName: 'discussName',
  2525. * msg: {
  2526. * msgtype: 'link',
  2527. * link: {
  2528. * title: 'title1',
  2529. * desc: 'desc1',
  2530. * url: 'link1',
  2531. * imgUrl: 'imgurl1'
  2532. * }
  2533. * }
  2534. * })
  2535. * ```
  2536. *
  2537. * @throws
  2538. * | errMsg | 说明 |
  2539. * | --- | --- |
  2540. * | createChatWithMsg:ok | 执行成功 |
  2541. * | createChatWithMsg:fail_unsupported_msgtype | msgtype不合法 |
  2542. * | createChatWithMsg:fail_msg_link_missing_url | msg.link.url未传入 |
  2543. */ function createChatWithMsg(params) {
  2544. return passthrough('createChatWithMsg', params);
  2545. }
  2546. /**
  2547. * 创建企业互联/上下游会话。
  2548. *
  2549. * @limit
  2550. * - 本接口必须使用应用身份进行注册
  2551. * - 企业必须开启互联群功能
  2552. * - 仅局校互联和上下游企业可调用
  2553. * - 当前成员必须在应用的可见范围
  2554. * - 群成员人数不能超过 2000 人
  2555. * - 如果创建的会话有外部联系人,群成员人数不能超过 40 人
  2556. * - 当前成员为下游企业成员时,需要打开上下游空间中的“允许外部单位之间互相查看”配置,群成员中才可以包含其他下游企业成员
  2557. *
  2558. * @compat WeCom iOS, Android, PC >= 3.1.8
  2559. *
  2560. * @example
  2561. * ```ts
  2562. * ww.createCorpGroupChat({
  2563. * groupName: '讨论组',
  2564. * userIds: ['lisi', 'lisi2'],
  2565. * openUserIds: ['wabc3', 'wbcde'],
  2566. * externalUserIds: ['exid1', 'exid2'],
  2567. * corpGroupUserIds: [
  2568. * {
  2569. * corpId: 'ww3333',
  2570. * userId: 'userid123',
  2571. * openUserId: 'wx1111'
  2572. * },
  2573. * {
  2574. * corpId: 'ww4444',
  2575. * userId: 'userid123',
  2576. * openUserId: 'wx1111'
  2577. * }
  2578. * ]
  2579. * })
  2580. * ```
  2581. *
  2582. * @throws
  2583. * | errMsg | 说明 |
  2584. * | --- | --- |
  2585. * | createCorpGroupChat:ok | 执行成功 |
  2586. * | createCorpGroupChat:fail no permission | 应用签名校验失败 |
  2587. * | createCorpGroupChat:fail exceed user id list size | 超过人数上限 |
  2588. * | createCorpGroupChat:fail invalid parameter | 参数不合法 |
  2589. * | createCorpGroupChat:fail need open corp group chat | 企业未开启企业互联群功能 |
  2590. * | createCorpGroupChat:fail exceed external user id list size | 超过包含外部联系人群人数上限 |
  2591. */ function createCorpGroupChat(params) {
  2592. return passthrough('createCorpGroupChat', params, {
  2593. groupName: params.groupName || '',
  2594. userIds: params.userIds,
  2595. openUserIds: params.openUserIds,
  2596. externalUserIds: params.externalUserIds,
  2597. corpGroupUserIds: params.corpGroupUserIds
  2598. });
  2599. }
  2600. exports.CreateExternalPaymentType = void 0;
  2601. (function(CreateExternalPaymentType) {
  2602. /**
  2603. * 在聊天中收款
  2604. */ CreateExternalPaymentType[CreateExternalPaymentType["chat"] = 0] = "chat";
  2605. /**
  2606. * 收款码收款
  2607. */ CreateExternalPaymentType[CreateExternalPaymentType["qrcode"] = 1] = "qrcode";
  2608. })(exports.CreateExternalPaymentType || (exports.CreateExternalPaymentType = {}));
  2609. /**
  2610. * 发起对外收款。
  2611. *
  2612. * @limit
  2613. * - 本接口必须使用应用身份进行注册
  2614. * - 所使用的应用必须具有对外收款权限
  2615. * - 发起的用户必须在应用可见范围并实名
  2616. * - 允许第三方应用、代开发应用和自建应用调用
  2617. *
  2618. * @compat WeCom >= 4.0.12
  2619. *
  2620. * @example
  2621. * ```ts
  2622. * ww.createExternalPayment({
  2623. * paymentType: 0,
  2624. * totalFee: 300,
  2625. * description: '可乐一罐'
  2626. * })
  2627. * ```
  2628. */ function createExternalPayment(params = {}) {
  2629. return passthrough('createExternalPayment', params);
  2630. }
  2631. /**
  2632. * 发起班级收款。
  2633. *
  2634. * 用于老师对学生家长发起付款请求,接口调用成功后会通过家校通知发送付款小程序给家长。
  2635. *
  2636. * @limit
  2637. * - 本接口必须使用应用身份进行注册
  2638. * - 所使用的应用必须具有对外收款权限
  2639. * - 仅支持配置在家长可使用范围内的应用
  2640. * - 企业必须已验证或者已认证
  2641. * - 发起的用户必须在应用可见范围并实名
  2642. * - 发起的用户需在个人微信零钱账户的可用范围内
  2643. *
  2644. * @compat WeCom iOS, Android, PC >= 3.1.10
  2645. *
  2646. * @note
  2647. * - 用户可以手动调整收款金额,收款项目和收款范围
  2648. * - 通过接口发起的收款,默认收款账户为“我的微信零钱账户”,且不可修改
  2649. * - 若用户未授权个人付款码权限,会唤起授权付款码权限页面,授权完成返回页面后会返回错误信息 `'require authorize the payment qr code'`。用户授权完成后可引导用户重新发起收款
  2650. *
  2651. * @example
  2652. * ```ts
  2653. * ww.createSchoolPayment({
  2654. * projectName: '1班班费',
  2655. * amount: 100,
  2656. * payers: {
  2657. * students: ['zhagnshan', 'lisi'],
  2658. * departments: [1, 2]
  2659. * }
  2660. * })
  2661. * ```
  2662. */ function createSchoolPayment(params) {
  2663. return passthrough('createSchoolPayment', params);
  2664. }
  2665. /**
  2666. * 添加设备。
  2667. *
  2668. * @deprecated 请使用 addDevice 接口
  2669. *
  2670. * @limit
  2671. * 调用者必须为企业超级管理员
  2672. *
  2673. * @compat WeCom iOS, Android >= 2.5.8
  2674. *
  2675. * @example
  2676. * ```ts
  2677. * ww.discoverDevice({
  2678. * type: 'qrcode',
  2679. * qrcode_url: 'https://open.work.weixin.qq.com/connect?xxx'
  2680. * })
  2681. * ```
  2682. */ function discoverDevice(params) {
  2683. return passthrough('discoverDevice', params);
  2684. }
  2685. /**
  2686. * 加入视频会议。
  2687. *
  2688. * @limit
  2689. * 只能加入同企业硬件创建的视频会议。
  2690. *
  2691. * @compat WeCom >= 2.5.0
  2692. *
  2693. * @example
  2694. * ```ts
  2695. * ww.enterHWOpenTalk({
  2696. * code: code,
  2697. * ticket: ticket
  2698. * })
  2699. * ```
  2700. */ function enterHWOpenTalk(params) {
  2701. return passthrough('enterHWOpenTalk', params);
  2702. }
  2703. /**
  2704. * 跳转认证界面。
  2705. *
  2706. * @compat WeCom iOS, Android >= 2.8.7
  2707. *
  2708. * @example
  2709. * ```ts
  2710. * ww.enterpriseVerify()
  2711. * ```
  2712. */ function enterpriseVerify(params = {}) {
  2713. return passthrough('enterpriseVerify', params);
  2714. }
  2715. /**
  2716. * 获取 saveApprovalSelectedItems 保存的审批选项。
  2717. *
  2718. * 当用户打开网页后,应该先调用一次该接口获取用户已经选择的数据作为初始数据。获取到初始数据后,应该恢复已经选择的选项。
  2719. *
  2720. * @limit
  2721. * - 本接口必须使用应用身份进行注册
  2722. * - 所签名的应用必须具有审批权限
  2723. *
  2724. * @note
  2725. * - 网页应该做好深色模式适配
  2726. * - 接口仅用于审批设置外部选项场景,请勿用作其他场景
  2727. *
  2728. * @compat WeCom >= 4.0.18
  2729. *
  2730. * @example
  2731. * ```ts
  2732. * ww.getApprovalSelectedItems({
  2733. * key: 'key'
  2734. * })
  2735. * ```
  2736. */ function getApprovalSelectedItems(params) {
  2737. return promiseToCallback(params, async ()=>{
  2738. await tryEnsureConfigReady();
  2739. const res = await invoke('getApprovalSelectedItems', {
  2740. key: params.key
  2741. });
  2742. if (!res.selectedData) {
  2743. return res;
  2744. }
  2745. try {
  2746. res.selectedData = JSON.parse(res.selectedData);
  2747. } catch (error) {
  2748. res.selectedData = [];
  2749. }
  2750. return res;
  2751. });
  2752. }
  2753. exports.EntryType = void 0;
  2754. (function(EntryType) {
  2755. /**
  2756. * 从联系人详情进入
  2757. */ EntryType["contact_profile"] = "contact_profile";
  2758. /**
  2759. * 从单聊会话的工具栏进入
  2760. */ EntryType["single_chat_tools"] = "single_chat_tools";
  2761. /**
  2762. * 从群聊会话的工具栏进入
  2763. */ EntryType["group_chat_tools"] = "group_chat_tools";
  2764. /**
  2765. * 从会话的聊天附件栏进入
  2766. *
  2767. * @compat WeCom >= 3.1.6
  2768. */ EntryType["chat_attachment"] = "chat_attachment";
  2769. /**
  2770. * 从微信客服的工具栏进入
  2771. *
  2772. * @compat WeCom >= 3.1.10
  2773. */ EntryType["single_kf_tools"] = "single_kf_tools";
  2774. /**
  2775. * 上下游单聊会话的工具栏
  2776. *
  2777. * @compat WeCom >= 4.0.8
  2778. */ EntryType["chain_single_chat_tools"] = "chain_single_chat_tools";
  2779. /**
  2780. * 上下游群聊会话的工具栏
  2781. *
  2782. * @compat WeCom >= 4.0.8
  2783. */ EntryType["chain_group_chat_tools"] = "chain_group_chat_tools";
  2784. /**
  2785. * 从内部群群看板进入
  2786. *
  2787. * @compat WeCom >= 4.1.36
  2788. */ EntryType["internal_group_chat_board"] = "internal_group_chat_board";
  2789. /**
  2790. * 除以上场景之外进入,例如工作台,聊天会话等
  2791. */ EntryType["normal"] = "normal";
  2792. })(exports.EntryType || (exports.EntryType = {}));
  2793. /**
  2794. * 获取当前页面打开场景。
  2795. *
  2796. * @note
  2797. * 调用该接口可以判断用户是从哪个入口打开页面,从而决定是否可以调用客户联系相关的接口。
  2798. *
  2799. * @compat WeCom >= 3.0.24
  2800. *
  2801. * @example
  2802. * ```ts
  2803. * ww.getContext()
  2804. * ```
  2805. */ function getContext(params = {}) {
  2806. return passthrough('getContext', params);
  2807. }
  2808. /**
  2809. * 页面在聊天工具栏中打开时,获取当前上下游互联群的群 ID.
  2810. *
  2811. * @compat WeCom >= 4.0.12
  2812. *
  2813. * @limit
  2814. * - 仅支持上下游聊天工具栏中进入的页面调用,即 getContext 返回 `entry` 为 `chain_single_chat_tools` 或 `chain_group_chat_tools` 的场景
  2815. * - 本接口必须使用应用身份进行注册
  2816. * - 当前成员必须在应用的可见范围
  2817. *
  2818. * @example
  2819. * ```
  2820. * ww.getCurCorpGroupChat()
  2821. * ```
  2822. * @throws
  2823. * | errMsg | 说明 |
  2824. * | --- | --- |
  2825. * | getCurCorpGroupChat:ok| 执行成功 |
  2826. * | getCurCorpGroupChat:no permission | 应用身份鉴权失败 |
  2827. * | getCurCorpGroupChat:without context of corpgroup contact | 当前页面入口不支持调用 |
  2828. */ function getCurCorpGroupChat(params = {}) {
  2829. return passthrough('getCurCorpGroupChat', params);
  2830. }
  2831. /**
  2832. * 页面在上下游聊天工具栏中打开时,获取当前上下游联系人用户 ID。
  2833. *
  2834. * @compat WeCom >= 4.0.8
  2835. *
  2836. * @limit
  2837. * - 仅支持上下游聊天工具栏中进入的页面调用,即 getContext 返回 `entry` 为 `chain_single_chat_tools` 或 `chain_group_chat_tools` 的场景
  2838. * - 本接口必须使用应用身份进行注册
  2839. * - 当前成员必须在应用的可见范围
  2840. *
  2841. * @example
  2842. * ```
  2843. * ww.getCurCorpGroupContact()
  2844. * ```
  2845. * @throws
  2846. * | errMsg | 说明 |
  2847. * | --- | --- |
  2848. * | getCurCorpGroupContact:ok| 执行成功 |
  2849. * | getCurCorpGroupContact:no permission | 应用身份鉴权失败 |
  2850. * | getCurCorpGroupContact:without context of corpgroup contact | 当前页面入口不支持调用 |
  2851. */ function getCurCorpGroupContact(params) {
  2852. return passthrough('getCurCorpGroupContact', params);
  2853. }
  2854. /**
  2855. * 获取当前客户群的群 ID。
  2856. *
  2857. * @limit
  2858. * - 本接口必须使用应用身份进行注册
  2859. * - 从客户群或班级群的聊天工具栏进入页面时才可成功调用该接口
  2860. * - 不同的入口对应用及用户有相应的限制
  2861. * | 入口 | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 兼容性 |
  2862. * | --- | --- | --- | --- | --- | --- |
  2863. * | 外部群聊工具栏 | group_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.17 |
  2864. * | 班级群的聊天工具栏 | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 3.0.36 |
  2865. * | 学生群的聊天工具栏 | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 4.0.8 |
  2866. *
  2867. * @compat WeCom >= 2.8.17
  2868. *
  2869. * @example
  2870. * ```ts
  2871. * ww.getCurExternalChat()
  2872. * ```
  2873. *
  2874. * @throws
  2875. * | errMsg | 说明 |
  2876. * | --- | --- |
  2877. * | getCurExternalChat:ok | 执行成功 |
  2878. * | getCurExternalChat:fail no permission | 应用签名校验失败,或签名所使用的应用不满足权限要求 |
  2879. * | getCurExternalChat:fail without context of external contact | 当前页面入口不支持调用 |
  2880. */ function getCurExternalChat(params = {}) {
  2881. return passthrough('getCurExternalChat', params);
  2882. }
  2883. /**
  2884. * 获取当前外部联系人 userId。
  2885. *
  2886. * @limit
  2887. * - 本接口必须使用应用身份进行注册
  2888. * - 不同的入口对应用及用户有相应的限制,目前支持的入口有联系人详情页、外部单聊工具栏
  2889. * | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 支持的最低版本 |
  2890. * | --- | --- | --- | --- | --- |
  2891. * | contact_profile | [客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.5.8 |
  2892. * | single_chat_tools | [客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
  2893. * | single_kf_tools | 所有 | 需有“微信客服权限->获取基础信息”权限 | 所有 | 企业微信 3.1.10 |
  2894. *
  2895. * @compat WeCom >= 2.5.8
  2896. *
  2897. * @example
  2898. * ```ts
  2899. * ww.getCurExternalContact()
  2900. * ```
  2901. *
  2902. * @throws
  2903. * | errMsg | 说明 |
  2904. * | --- | --- |
  2905. * | getCurExternalContact:ok | 执行成功 |
  2906. * | getCurExternalContact:fail no permission | 应用签名校验失败或应用不满足权限条件 |
  2907. * | getCurExternalContact:fail without context of external contact | 当前页面入口不支持调用 |
  2908. */ function getCurExternalContact(params = {}) {
  2909. return passthrough('getCurExternalContact', params);
  2910. }
  2911. /**
  2912. * 获取私密消息信息。
  2913. *
  2914. * @compat WeCom >= 3.1.8
  2915. *
  2916. * @limit
  2917. * 本接口必须使用应用身份进行注册
  2918. *
  2919. * @example
  2920. * ```ts
  2921. * ww.getShareInfo({
  2922. * shareTicket: 'xxx'
  2923. * })
  2924. * ```
  2925. */ function getShareInfo(params) {
  2926. return passthrough('getShareInfo', params);
  2927. }
  2928. /**
  2929. * 页面在聊天附件栏中打开时,隐藏聊天附件栏的发送按钮。开发者可以通过[分享消息到当前会话](#sendChatMessage)接口灵活适配对页面或页面中具体内容的转发。
  2930. *
  2931. * @limit
  2932. * - 仅支持聊天附件栏进入的页面调用,即 getContext 返回 `entry` 为 `chat_attachment` 的场景
  2933. * - 本接口必须使用应用身份进行注册
  2934. *
  2935. * @compat WeCom >= 3.1.6
  2936. *
  2937. * @example
  2938. * ```
  2939. * ww.hideChatAttachmentMenu({
  2940. * menuList: ["sendMessage"]
  2941. * })
  2942. * ```
  2943. *
  2944. * @throws
  2945. * | errMsg | 说明 |
  2946. * | --- | --- |
  2947. * | hideChatAttachmentMenu:ok | 执行成功 |
  2948. * | hideChatAttachmentMenu:invalid menuList | menuList不合法 |
  2949. * | hideChatAttachmentMenu:without context of chat_attachment | 未在聊天附件栏打开场景下调用 |
  2950. */ function hideChatAttachmentMenu(params) {
  2951. return passthrough('hideChatAttachmentMenu', params);
  2952. }
  2953. /**
  2954. * 跳转到小程序。
  2955. *
  2956. * @note
  2957. * 打开小程序时如果需要关闭页面,需同步调用 closeWindow,不推荐用 setTimeout 延迟关闭。
  2958. *
  2959. * @limit
  2960. * - 本接口必须使用应用身份进行注册
  2961. * - 跳转的小程序必须属于页面所属的企业
  2962. * - 跳转的小程序必须已关联到工作台
  2963. * - 应用必须与要跳转的小程序应用同属于一个企业
  2964. * - 跳转的小程序必须已经关联到工作台
  2965. *
  2966. * @compat WeCom >= 3.0.36
  2967. *
  2968. * @example
  2969. * ```ts
  2970. * ww.launchMiniprogram({
  2971. * appid: 'wx062f7a5507909000',
  2972. * path: 'pages/home/index'
  2973. * })
  2974. * ```
  2975. */ function launchMiniprogram(params) {
  2976. return passthrough('launchMiniprogram', params, {
  2977. appid: params.appid,
  2978. path: addHTMLToPath(params.path),
  2979. envVersion: params.envVersion
  2980. });
  2981. }
  2982. function addHTMLToPath(url) {
  2983. if (!url || !isString(url)) {
  2984. return;
  2985. }
  2986. const [path, ...query] = url.split('?');
  2987. if (!query.length) {
  2988. return `${path}.html`;
  2989. }
  2990. return `${path}.html?${query.join('?')}`;
  2991. }
  2992. /**
  2993. * 在企业微信内快速跳转到添加客户的界面。
  2994. *
  2995. * @limit
  2996. * - 本接口必须使用应用身份进行注册
  2997. * - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  2998. * - 当前成员必须配置了客户联系功能
  2999. *
  3000. * @compat WeCom iOS, Android >= 3.0.36
  3001. *
  3002. * @example
  3003. * ```ts
  3004. * ww.navigateToAddCustomer()
  3005. * ```
  3006. */ function navigateToAddCustomer(params = {}) {
  3007. return passthrough('navigateToAddCustomer', params);
  3008. }
  3009. /**
  3010. * 进入微信客服消息界面。
  3011. *
  3012. * @limit
  3013. * - 本接口必须使用应用身份进行注册
  3014. * - 应用必须具有“微信客服->获取基础信息”权限
  3015. * - 当前企业须已开启「微信客服」应用
  3016. * - 当前成员须是指定客服账号的坐席
  3017. *
  3018. * @compat WeCom iOS, Android, PC >= 3.1.12
  3019. *
  3020. * @example
  3021. * ```ts
  3022. * ww.navigateToKfChat({
  3023. * openKfId: 'wkAJ2GCAAAZSfhHCt7IFSvLKtMPxyAAA',
  3024. * externalUserId: 'wmAJ2GCAAAZSfhHCt7IFSvLKtMPxyBBB'
  3025. * })
  3026. * ```
  3027. */ function navigateToKfChat(params) {
  3028. return passthrough('navigateToKfChat', params);
  3029. }
  3030. /**
  3031. * 共享收货地址。
  3032. *
  3033. * @see https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#共享收货地址接口
  3034. */ function openAddress(params = {}) {
  3035. return promiseToCallback(params, async ()=>{
  3036. await tryEnsureConfigReady();
  3037. const res = await invoke('editAddress');
  3038. res.postalCode = res.addressPostalCode;
  3039. delete res.addressPostalCode;
  3040. res.provinceName = res.proviceFirstStageName;
  3041. delete res.proviceFirstStageName;
  3042. res.cityName = res.addressCitySecondStageName;
  3043. delete res.addressCitySecondStageName;
  3044. res.countryName = res.addressCountiesThirdStageName;
  3045. delete res.addressCountiesThirdStageName;
  3046. res.detailInfo = res.addressDetailInfo;
  3047. delete res.addressDetailInfo;
  3048. return res;
  3049. });
  3050. }
  3051. /**
  3052. * 打开应用评价页面。
  3053. *
  3054. * 第三方应用可以使用该接口提供按钮,让用户快速打开应用评价页面。
  3055. *
  3056. * @compat WeCom iOS, Android, PC >= 4.0.2
  3057. *
  3058. * @limit
  3059. * - 本接口必须使用应用身份进行注册,
  3060. * - 仅第三方应用可调用
  3061. * - 对成员授权的应用,当前用户在应用可见范围内,可以进行应用评价
  3062. * - 管理员授权的应用,当前用户在可见范围内,或者当前用户为超管或有应用管理权限的分管,可以进行应用评价
  3063. *
  3064. * @example
  3065. * ```
  3066. * ww.openAppComment()
  3067. * ```
  3068. *
  3069. * @throws
  3070. * | errMsg | 说明 |
  3071. * | --- | --- |
  3072. * | openAppComment:ok| 执行成功 |
  3073. * | openAppComment:fail:no permission | 调用人身份不符合 |
  3074. * | openAppComment:fail:unknown app | 应用信息获取失败 |
  3075. * | openAppComment:fail:unsupported app type | 应用类型不符合要求 |
  3076. * | openAppComment:fail | 其它错误 |
  3077. */ function openAppComment(params = {}) {
  3078. return passthrough('openAppComment', params);
  3079. }
  3080. /**
  3081. * 获取设备数据授权。
  3082. *
  3083. * 唤起设备选择列表,企业管理员选择设备后,应用可以通过云端接口获取到设备上报的数据。
  3084. *
  3085. * @limit
  3086. * - 本接口必须使用应用身份进行注册
  3087. * - 应用必须具有智慧硬件接口权限
  3088. * - 仅第三方应用使用
  3089. *
  3090. * @compat WeCom >= 4.0.12
  3091. *
  3092. * @example
  3093. * ```ts
  3094. * ww.openAppDeviceDataAuth()
  3095. * ```
  3096. */ function openAppDeviceDataAuth(params = {}) {
  3097. return passthrough('openAppDeviceDataAuth', params);
  3098. }
  3099. exports.OpenAppManagePageType = void 0;
  3100. (function(OpenAppManagePageType) {
  3101. /**
  3102. * 应用权限详情页
  3103. */ OpenAppManagePageType["permission"] = "permission";
  3104. /**
  3105. * 数据与智能专区权限授权页
  3106. *
  3107. * 需要满足:
  3108. *
  3109. * - 企业访问者身份为超级管理员
  3110. * - 应用需要满足勾选了“数据与智能专区权限”(注:该权限目前灰度开放)
  3111. * - 应用类型为第三方应用/代开发应用(注:不支持上下游共享应用)
  3112. */ OpenAppManagePageType["datazone_permission"] = "datazone_permission";
  3113. })(exports.OpenAppManagePageType || (exports.OpenAppManagePageType = {}));
  3114. /**
  3115. * 打开应用管理页面。
  3116. *
  3117. * 应用可以使用该接口提供按钮,让企业管理员快速打开应用的管理页面。
  3118. *
  3119. * @limit
  3120. * - 本接口必须使用应用身份进行注册
  3121. * - 当前用户需要是企业超级管理员,或具有应用管理权限
  3122. *
  3123. * @compat WeCom >= 4.0.2
  3124. *
  3125. * @example
  3126. * ```
  3127. * ww.openAppManage({
  3128. * page: "permission",
  3129. * suiteId: "wwabcdefghijk",
  3130. * })
  3131. * ```
  3132. */ function openAppManage(params = {}) {
  3133. return passthrough('openAppManage', params);
  3134. }
  3135. /**
  3136. * 进入应用购买页面。
  3137. *
  3138. * 第三方应用可以使用该接口提供按钮,让用户可快速进入应用购买流程。
  3139. *
  3140. * @limit
  3141. * - 本接口必须使用应用身份进行注册
  3142. * - 当前用户应在应用的可见范围内
  3143. * - 仅第三方应用可调用
  3144. *
  3145. * @compat WeCom >= 4.1.6
  3146. *
  3147. * @example
  3148. * ```
  3149. * ww.openAppPurchase()
  3150. * ```
  3151. *
  3152. * @throws
  3153. * | errMsg | 说明 |
  3154. * | --- | --- |
  3155. * | openAppPurchase:ok | 执行成功 |
  3156. * | openAppPurchase:fail:no permission | 应用签名校验失败,或成员不在应用的可见范围内 |
  3157. * | openAppPurchase:fail | 其它错误 |
  3158. */ function openAppPurchase(params) {
  3159. return passthrough('openAppPurchase', params);
  3160. }
  3161. exports.EnvVersion = void 0;
  3162. (function(EnvVersion) {
  3163. EnvVersion["release"] = "release";
  3164. EnvVersion["trial"] = "trial";
  3165. EnvVersion["develop"] = "develop";
  3166. })(exports.EnvVersion || (exports.EnvVersion = {}));
  3167. /**
  3168. * 商户小程序跳转微信支付分小程序。
  3169. *
  3170. * @see https://pay.weixin.qq.com/wiki/doc/apiv3/payscore.php?chapter=29_3&index=3
  3171. */ function openBusinessView(params) {
  3172. return promiseToCallback(params, async ()=>{
  3173. await tryEnsureConfigReady();
  3174. const res = await invoke('openBusinessView', {
  3175. businessType: params.businessType,
  3176. queryString: params.queryString || '',
  3177. envVersion: params.envVersion
  3178. });
  3179. if (!isAndroid || !res.extraData) {
  3180. return res;
  3181. }
  3182. try {
  3183. res.extraData = JSON.parse(res.extraData);
  3184. } catch (error) {
  3185. res.extraData = {};
  3186. }
  3187. return res;
  3188. });
  3189. }
  3190. /**
  3191. * 查看设备。
  3192. *
  3193. * @limit
  3194. * 调用者必须拥有指定 deviceSn 的管理权限。
  3195. *
  3196. * @note
  3197. * 若开发者需要在 web 端引导跳转设备管理,可以构造链接跳转:`https://work.weixin.qq.com/wework_admin/frame#hardware/device?sn={{DEVICESN}}`。
  3198. *
  3199. * @compat WeCom iOS, Android >= 2.8.2
  3200. *
  3201. * @example
  3202. * ```ts
  3203. * ww.openDeviceProfile({
  3204. * deviceSn: 'QYWX001'
  3205. * })
  3206. * ```
  3207. *
  3208. * @throws
  3209. * | errMsg | 说明 |
  3210. * | --- | --- |
  3211. * | openDeviceProfile:ok | 执行成功 |
  3212. * | openDeviceProfile:fail_device_permission_denied | 管理员无设备管理权限 |
  3213. * | openDeviceProfile:fail_device_not_found | 不存在此设备 |
  3214. */ function openDeviceProfile(params) {
  3215. return passthrough('openDeviceProfile', params);
  3216. }
  3217. /**
  3218. * 打开会话。
  3219. *
  3220. * @limit
  3221. * - 内部群最多 2000 人,外部群最多 500 人
  3222. * - 若创建的会话包含微信联系人,群成员人数不能超过 40 人
  3223. * - 第三方应用与代开发应用必须使用应用身份进行注册
  3224. *
  3225. * @compat WeCom >= 2.0.0
  3226. *
  3227. * @example
  3228. * ```ts
  3229. * ww.openEnterpriseChat({
  3230. * groupName: '讨论组',
  3231. * userIds: [
  3232. * 'zhangsan',
  3233. * 'lisi'
  3234. * ],
  3235. * externalUserIds: [
  3236. * 'wmEAlECwAAHrbWYDOK5u3Bf13xlYDAAA',
  3237. * 'wmEAlECwAAHibWYDOK5u3Af13xlYDAAA'
  3238. * ]
  3239. * })
  3240. * ```
  3241. */ function openEnterpriseChat(params = {}) {
  3242. return passthrough('openEnterpriseChat', params, {
  3243. chatId: params.chatId || '',
  3244. chatname: params.groupName || '',
  3245. groupName: params.groupName || '',
  3246. useridlist: joinList(params.userIds),
  3247. userIds: joinList(params.userIds),
  3248. openIds: joinList(params.openIds),
  3249. externalUserIds: joinList(params.externalUserIds)
  3250. });
  3251. }
  3252. /**
  3253. * 打开已有群聊并可选发送一条链接消息(link消息)。支持打开企业内部群、外部群、互联群。
  3254. *
  3255. * @compat WeCom >= 3.1.8
  3256. *
  3257. * @limit
  3258. * 本接口必须使用应用身份进行注册
  3259. *
  3260. * @example
  3261. * ```ts
  3262. * ww.openExistedChatWithMsg({
  3263. * chatId: 'chatId123',
  3264. * msg: {
  3265. * msgtype: 'link',
  3266. * link: {
  3267. * title: 'title1',
  3268. * desc: 'desc1',
  3269. * url: 'link1',
  3270. * imgUrl: 'imgurl1'
  3271. * }
  3272. * }
  3273. * })
  3274. * ```
  3275. *
  3276. * @throws
  3277. * | errMsg | 说明 |
  3278. * | --- | --- |
  3279. * | openExistedChatWithMsg:ok | 执行成功 |
  3280. * | openExistedChatWithMsg:fail_unsupported_msgtype | msgtype不合法 |
  3281. * | openExistedChatWithMsg:fail_msg_link_missing_url | msg.link.url未传入 |
  3282. */ function openExistedChatWithMsg(params) {
  3283. return passthrough('openExistedChatWithMsg', params);
  3284. }
  3285. /**
  3286. * 进入应用客服会话。
  3287. *
  3288. * 第三方应用可以使用该接口提供按钮,让用户快速打开应用客服的会话。。
  3289. *
  3290. * @compat WeCom iOS, Android >= 3.1.18; WeCom PC, Mac >= 4.1.6
  3291. *
  3292. * @limit
  3293. * - 本接口必须使用应用身份进行注册
  3294. * - 仅第三方应用可调用
  3295. * - 第三方应用需要提前配置客服
  3296. * - 当前用户需要有添加外部联系人权限
  3297. *
  3298. * @example
  3299. * ```
  3300. * ww.openThirdAppServiceChat()
  3301. * ```
  3302. */ function openThirdAppServiceChat(params = {}) {
  3303. return passthrough('openThirdAppServiceChat', params);
  3304. }
  3305. exports.OpenUserProfileType = void 0;
  3306. (function(OpenUserProfileType) {
  3307. /**
  3308. * 企业成员
  3309. */ OpenUserProfileType[OpenUserProfileType["internal"] = 1] = "internal";
  3310. /**
  3311. * 外部联系人
  3312. */ OpenUserProfileType[OpenUserProfileType["external"] = 2] = "external";
  3313. })(exports.OpenUserProfileType || (exports.OpenUserProfileType = {}));
  3314. /**
  3315. * 唤起成员或外部联系人的个人信息页面。
  3316. *
  3317. * @compat WeCom >= 2.4.20
  3318. *
  3319. * @limit
  3320. * - 第三方应用调用时,需使用应用身份进行注册
  3321. *
  3322. * @example
  3323. * ```ts
  3324. * ww.openUserProfile({
  3325. * type: 1,
  3326. * userid: 'wmEAlECwAAHrbWYDetiu3Af13xlYDAAA'
  3327. * })
  3328. * ```
  3329. */ function openUserProfile(params) {
  3330. return passthrough('openUserProfile', params);
  3331. }
  3332. exports.PrintFileIdType = void 0;
  3333. (function(PrintFileIdType) {
  3334. /**
  3335. * mediaid
  3336. */ PrintFileIdType[PrintFileIdType["mediaid"] = 1] = "mediaid";
  3337. /**
  3338. * url
  3339. */ PrintFileIdType[PrintFileIdType["url"] = 2] = "url";
  3340. /**
  3341. * localId
  3342. *
  3343. * 可通过以下方式获得:
  3344. * 1. [从会话选择文件](#34301)
  3345. * 2. [拍照或从手机相册中选图接口](#14915)
  3346. */ PrintFileIdType[PrintFileIdType["localId"] = 4] = "localId";
  3347. })(exports.PrintFileIdType || (exports.PrintFileIdType = {}));
  3348. /**
  3349. * 发起文件打印。
  3350. *
  3351. * @limit
  3352. * - 本接口必须使用应用身份进行注册
  3353. * - 应用必须具有“设备信息-打印扫描设备-发起文件打印权限”授权
  3354. * - 当前触发调用人员身份需要在应用的可见范围内
  3355. * - 当前企业有安装企业微信打印设备
  3356. * - 仅第三方应用使用
  3357. *
  3358. * @compat WeCom >= 4.0.12
  3359. *
  3360. * @example
  3361. * ```ts
  3362. * ww.printFile({
  3363. * fileId: 'fileId',
  3364. * fileIdType: 1,
  3365. * fileName: 'fileName.jpg'
  3366. * })
  3367. * ```
  3368. */ function printFile(params) {
  3369. return passthrough('printFile', params);
  3370. }
  3371. exports.InTalkType = void 0;
  3372. (function(InTalkType) {
  3373. /**
  3374. * 当前不在任何通话中
  3375. */ InTalkType["None"] = "None";
  3376. /**
  3377. * 视频会议中
  3378. */ InTalkType["HWOpenTalk"] = "HWOpenTalk";
  3379. /**
  3380. * voip通话中
  3381. */ InTalkType["VoIP"] = "VoIP";
  3382. /**
  3383. * 系统通话中
  3384. */ InTalkType["SystemCall"] = "SystemCall";
  3385. })(exports.InTalkType || (exports.InTalkType = {}));
  3386. /**
  3387. * 查询当前是否在视频会议。
  3388. *
  3389. * @compat WeCom >= 2.5.0
  3390. *
  3391. * @example
  3392. * ```ts
  3393. * ww.queryCurrHWOpenTalk()
  3394. * ```
  3395. */ function queryCurrHWOpenTalk(params = {}) {
  3396. return passthrough('queryCurrHWOpenTalk', params);
  3397. }
  3398. /**
  3399. * 发起退款。
  3400. *
  3401. * @limit
  3402. * - 本接口必须使用应用身份进行注册
  3403. * - 应用必须具有对外收款权限
  3404. * - 发起的用户必须在应用可见范围并实名
  3405. * - 只允许退款由应用本身发起的收款
  3406. *
  3407. * @compat WeCom >= 4.0.12
  3408. *
  3409. * @example
  3410. * ```ts
  3411. * ww.refundExternalPayment({
  3412. * paymentId: 'xxxx',
  3413. * outTradeNo: 'yyyy',
  3414. * refundFee: 100,
  3415. * refundComment: '7天无理由退货'
  3416. * })
  3417. * ```
  3418. */ function refundExternalPayment(params) {
  3419. return passthrough('refundExternalPayment', params);
  3420. }
  3421. /**
  3422. * 保存用户选择的审批选项。
  3423. *
  3424. * 用户在网页中修改审批选项时,调用该接口保存用户的选择。
  3425. *
  3426. * @note
  3427. * - 接口仅用于审批设置外部选项场景,请勿用作其他场景
  3428. * - 网页应该做好深色模式适配
  3429. *
  3430. * @limit
  3431. * - 本接口必须使用应用身份进行注册
  3432. * - 应用必须具有审批权限
  3433. *
  3434. * @compat WeCom >= 4.0.18
  3435. *
  3436. * @example
  3437. * ```ts
  3438. * ww.saveApprovalSelectedItems({
  3439. * key: 'key',
  3440. * selectedData: [
  3441. * {
  3442. * key: 'item-1',
  3443. * value: '选项1'
  3444. * },
  3445. * {
  3446. * key: 'item-2',
  3447. * value: '选项2'
  3448. * }
  3449. * ]
  3450. * })
  3451. * ```
  3452. */ function saveApprovalSelectedItems(params) {
  3453. return passthrough('saveApprovalSelectedItems', params, {
  3454. key: params.key,
  3455. selectedData: typeof params.selectedData === 'string' ? params.selectedData : JSON.stringify(params.selectedData)
  3456. });
  3457. }
  3458. exports.ScanQRCodeType = void 0;
  3459. (function(ScanQRCodeType) {
  3460. /**
  3461. * 扫描二维码
  3462. */ ScanQRCodeType["qrCode"] = "qrCode";
  3463. /**
  3464. * 扫描条形码
  3465. */ ScanQRCodeType["barCode"] = "barCode";
  3466. })(exports.ScanQRCodeType || (exports.ScanQRCodeType = {}));
  3467. /**
  3468. * 调起企业微信扫一扫。
  3469. *
  3470. * @example
  3471. * ```ts
  3472. * ww.scanQRCode({
  3473. * needResult: true,
  3474. * scanType: ['qrCode']
  3475. * })
  3476. * ```
  3477. */ function scanQRCode(params = {}) {
  3478. return promiseToCallback(params, async ()=>{
  3479. await tryEnsureConfigReady();
  3480. const res = await invoke('scanQRCode', {
  3481. needResult: params.needResult ? 1 : 0,
  3482. scanType: params.scanType || [
  3483. 'qrCode',
  3484. 'barCode'
  3485. ]
  3486. });
  3487. if (!isIOS) {
  3488. return res;
  3489. }
  3490. const resultStr = res.resultStr;
  3491. if (!resultStr) {
  3492. return res;
  3493. }
  3494. let data;
  3495. try {
  3496. data = JSON.parse(resultStr);
  3497. } catch (error) {
  3498. // noop
  3499. }
  3500. res.resultStr = data?.scan_code?.scan_result;
  3501. return res;
  3502. });
  3503. }
  3504. exports.InputCorpGroupContactMode = void 0;
  3505. (function(InputCorpGroupContactMode) {
  3506. /**
  3507. * 单选
  3508. */ InputCorpGroupContactMode["single"] = "single";
  3509. /**
  3510. * 多选
  3511. */ InputCorpGroupContactMode["multi"] = "multi";
  3512. })(exports.InputCorpGroupContactMode || (exports.InputCorpGroupContactMode = {}));
  3513. exports.InputCorpGroupContactType = void 0;
  3514. (function(InputCorpGroupContactType) {
  3515. /**
  3516. * 选择部门
  3517. */ InputCorpGroupContactType["department"] = "department";
  3518. /**
  3519. * 选择成员
  3520. */ InputCorpGroupContactType["user"] = "user";
  3521. })(exports.InputCorpGroupContactType || (exports.InputCorpGroupContactType = {}));
  3522. /**
  3523. * 企业互联/上下游选人
  3524. *
  3525. * @limit
  3526. * - 本接口必须使用应用身份进行注册
  3527. * - 该接口仅可选择应用可见范围内的成员和部门
  3528. *
  3529. * @compat WeCom iOS, Android, PC >= 3.1.6
  3530. *
  3531. * @note
  3532. * 自建应用调用该接口时userid返回的是企业内部的userid,对于服务商该字段返回的是open_userid,同一个服务商,不同应用获取到企业内同一个成员的open_userid是相同的,最多64个字节
  3533. *
  3534. * @example
  3535. * ```ts
  3536. * ww.selectCorpGroupContact({
  3537. * fromDepartmentId: -1,
  3538. * mode: 'single',
  3539. * type: ['department', 'user'],
  3540. * selectedDepartmentIds: ['2','3'],
  3541. * selectedUserIds: ['lisi','lisi2'],
  3542. * selectedOpenUserIds: ['wabc3','wbcde'],
  3543. * selectedChainDepartmentIds: [
  3544. * {
  3545. * corpId: 'ww3333',
  3546. * departmentId: '2'
  3547. * },
  3548. * {
  3549. * corpId: 'ww4444',
  3550. * departmentId: '3'
  3551. * }
  3552. * ],
  3553. * selectedChainUserIds: [
  3554. * {
  3555. * corpId: 'ww3333',
  3556. * userId: 'userid123',
  3557. * openUserId: 'wx1111'
  3558. * },
  3559. * {
  3560. * corpId: 'ww4444',
  3561. * userId: 'userid123',
  3562. * openUserId: 'wx1111'
  3563. * }
  3564. * ],
  3565. * selectedCorpGroupDepartmentIds: [
  3566. * {
  3567. * corpId: 'ww3333',
  3568. * departmentId: '2'
  3569. * },
  3570. * {
  3571. * corpId: 'ww4444',
  3572. * departmentId: '3'
  3573. * }
  3574. * ],
  3575. * selectedCorpGroupUserIds: [
  3576. * {
  3577. * corpId: 'ww3333',
  3578. * userId: 'userid123',
  3579. * openUserId: 'wx1111'
  3580. * },
  3581. * {
  3582. * corpId: 'ww4444',
  3583. * userId: 'userid123',
  3584. * openUserId: 'wx1111'
  3585. * }
  3586. * ]
  3587. * })
  3588. * ```
  3589. * @throws
  3590. * | errMsg | 说明 |
  3591. * | --- | --- |
  3592. * | selectCorpGroupContact:ok | 执行成功 |
  3593. * | selectCorpGroupContact:fail no permission | 应用身份鉴权失败 |
  3594. *
  3595. */ function selectCorpGroupContact(params) {
  3596. return promiseToCallback(params, async ()=>{
  3597. await tryEnsureConfigReady();
  3598. const res = await invoke('selectCorpGroupContact', params);
  3599. if (!isString(res.result)) {
  3600. return res;
  3601. }
  3602. try {
  3603. res.result = JSON.parse(res.result);
  3604. } catch (error) {
  3605. // noop
  3606. }
  3607. return res;
  3608. });
  3609. }
  3610. exports.SelectEnterpriseContactMode = void 0;
  3611. (function(SelectEnterpriseContactMode) {
  3612. /**
  3613. * 单选
  3614. */ SelectEnterpriseContactMode["single"] = "single";
  3615. /**
  3616. * 多选
  3617. */ SelectEnterpriseContactMode["multi"] = "multi";
  3618. })(exports.SelectEnterpriseContactMode || (exports.SelectEnterpriseContactMode = {}));
  3619. exports.SelectEnterpriseContactType = void 0;
  3620. (function(SelectEnterpriseContactType) {
  3621. /**
  3622. * 选择部门
  3623. */ SelectEnterpriseContactType["department"] = "department";
  3624. /**
  3625. * 选择成员
  3626. */ SelectEnterpriseContactType["user"] = "user";
  3627. })(exports.SelectEnterpriseContactType || (exports.SelectEnterpriseContactType = {}));
  3628. /**
  3629. * 选择通讯录成员。
  3630. *
  3631. * @compat WeCom >= 1.3.11; WeChat iOS, Android >= 6.5.10
  3632. *
  3633. * @example
  3634. * ```ts
  3635. * ww.selectEnterpriseContact({
  3636. * fromDepartmentId: -1,
  3637. * mode: 'multi',
  3638. * type: ['department', 'user'],
  3639. * selectedDepartmentIds: ['2', '3'],
  3640. * selectedUserIds: ['lisi', 'lisi2']
  3641. * })
  3642. * ```
  3643. */ function selectEnterpriseContact(params) {
  3644. return promiseToCallback(params, async ()=>{
  3645. await tryEnsureConfigReady();
  3646. const res = await invoke('selectEnterpriseContact', params);
  3647. if (!isString(res.result)) {
  3648. return res;
  3649. }
  3650. try {
  3651. res.result = JSON.parse(res.result);
  3652. } catch (error) {
  3653. // noop
  3654. }
  3655. return res;
  3656. });
  3657. }
  3658. exports.SelectExternalContactType = void 0;
  3659. (function(SelectExternalContactType) {
  3660. /**
  3661. * 展示全部外部联系人列表
  3662. */ SelectExternalContactType[SelectExternalContactType["all"] = 0] = "all";
  3663. /**
  3664. * 仅展示未曾选择过的外部联系人
  3665. */ SelectExternalContactType[SelectExternalContactType["unselected"] = 1] = "unselected";
  3666. })(exports.SelectExternalContactType || (exports.SelectExternalContactType = {}));
  3667. /**
  3668. * 唤起该成员的外部联系人列表,并返回员工选择的外部联系人的 userId。
  3669. *
  3670. * @limit
  3671. * - 本接口必须使用应用身份进行注册
  3672. * - 应用须配置[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  3673. * - 当前成员必须配置[客户联系功能](#13473/开始开发)
  3674. *
  3675. * @compat WeCom >= 2.4.20
  3676. *
  3677. * @example
  3678. * ```ts
  3679. * ww.selectExternalContact({
  3680. * filterType: 0
  3681. * })
  3682. * ```
  3683. */ function selectExternalContact(params = {}) {
  3684. return passthrough('selectExternalContact', params);
  3685. }
  3686. exports.SelectPrivilegedContactMode = void 0;
  3687. (function(SelectPrivilegedContactMode) {
  3688. /**
  3689. * 单选
  3690. */ SelectPrivilegedContactMode["single"] = "single";
  3691. /**
  3692. * 多选
  3693. */ SelectPrivilegedContactMode["multi"] = "multi";
  3694. })(exports.SelectPrivilegedContactMode || (exports.SelectPrivilegedContactMode = {}));
  3695. /**
  3696. * 返回 ticket 的选人接口。
  3697. *
  3698. * 用于第三方应用唤起选择企业通讯录成员,用户选择的范围区分成两部分回传给第三方应用:
  3699. *
  3700. * 1. 过滤应用可见范围后的 openUserId 列表
  3701. * 2. 完整列表的 ticket,ticket 后续可用于[创建群聊](#30292) 或者[发送模板消息](#94515)
  3702. *
  3703. * @limit
  3704. * - 本接口必须使用应用身份进行注册
  3705. * - 仅第三方应用(非通讯录应用)可调用
  3706. *
  3707. * @compat WeCom >= 3.1.8
  3708. *
  3709. * @example
  3710. * ```ts
  3711. * ww.selectPrivilegedContact({
  3712. * fromDepartmentId: -1,
  3713. * mode: 'multi',
  3714. * selectedContextContact: 1
  3715. * selectedOpenUserIds: ['xxx', 'yyy'],
  3716. * selectedTickets: ['ticket1', 'ticket2']
  3717. * })
  3718. * ```
  3719. */ function selectPrivilegedContact(params) {
  3720. return passthrough('selectPrivilegedContact', params);
  3721. }
  3722. /**
  3723. * 从聊天工具栏或附件栏打开的页面中向当前会话发送消息
  3724. *
  3725. * @note
  3726. * 消息格式支持文本(“text”),图片(“image”),视频(“video”),文件(“file”),H5(“news”),小程序(“miniprogram”),菜单消息(“msgmenu”)和视频号商品(“channels_shop_product”)
  3727. *
  3728. * @limit
  3729. * - 本接口必须使用应用身份进行注册
  3730. * - 仅从特定入口进入页面才可调用,可通过 getContext 接口进行判断
  3731. * - 不同的入口对应用及用户有相应的限制
  3732. * | getContext 接口返回的 entry 值 | 自建应用 | 第三方应用 | 用户 | 支持的最低版本 |
  3733. * | --- | --- | --- | --- | --- |
  3734. * | single_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[配置了客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
  3735. * | group_chat_tools | 需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用) | 需有“企业客户权限->客户基础信息”权限 | 配置了|[配置了客户联系功能](#13473/配置可使用客户联系功能的成员) | 企业微信 2.8.10 |
  3736. * | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 3.0.36 |
  3737. * | group_chat_tools | 所有 | 需有「家校沟通」使用权限 | 所有 | 企业微信 4.0.8 |
  3738. * | chat_attachment | 所有 | 所有 | 所有 | 企业微信 3.1.6(mac 端暂不支持) |
  3739. * | single_kf_tools | 所有 | 需有“微信客服权限->获取基础信息”权限 | 所有 | 企业微信 3.1.10 |
  3740. * - 消息中的 mediaId 可通过[素材管理](#10112)接口获得,暂不支持公众平台的 mediaId
  3741. *
  3742. * @compat WeCom >= 2.8.10
  3743. *
  3744. * @example
  3745. * ```ts
  3746. * ww.sendChatMessage({
  3747. * msgtype: 'text',
  3748. * text: {
  3749. * content: '你好'
  3750. * }
  3751. * })
  3752. * ```
  3753. *
  3754. * @throws
  3755. * | errMsg | 说明 |
  3756. * | --- | --- |
  3757. * | sendChatMessage:ok | 执行成功 |
  3758. * | claimClassAdmin:fail without context of external contact | 当前页面打开的场景不支持调用 |
  3759. * | claimClassAdmin:fail no permission | 应用签名错误,或不满足权限要求 |
  3760. * | claimClassAdmin:fail invalid imgUrl | 小程序消息封面图不合法 |
  3761. */ function sendChatMessage(params) {
  3762. return passthrough('sendChatMessage', params);
  3763. }
  3764. /**
  3765. * 设置私密消息。
  3766. *
  3767. * @compat WeCom >= 3.1.8
  3768. *
  3769. * @limit
  3770. * 本接口必须使用应用身份进行注册
  3771. *
  3772. * @example
  3773. * ```ts
  3774. * ww.setShareAttr({
  3775. * withShareTicket: true,
  3776. * state: 'STATE'
  3777. * })
  3778. * ```
  3779. */ function setShareAttr(params = {}) {
  3780. return passthrough('setShareAttr', params);
  3781. }
  3782. /**
  3783. * 具有客户联系权限的企业成员,可通过该接口将文本内容和附件传递到客户群群发、发送到客户群。
  3784. *
  3785. * @limit
  3786. * - 本接口必须使用应用身份进行注册
  3787. * - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  3788. * - 当前成员必须配置了[客户联系功能](#13473/配置可使用客户联系功能的成员)
  3789. *
  3790. * @note
  3791. * - 为防止滥用,同一个成员每日向一个客户最多可群发一条消息,每次群发最多可选 2000 个最近活跃的客户群
  3792. *
  3793. * @compat WeCom >= 2.8.7
  3794. *
  3795. * @example
  3796. * ```ts
  3797. * // WeCom >= 3.1.6
  3798. * ww.shareToExternalChat({
  3799. * chatIds: ["wr2GCAAAXAAAaWJHDDGasdadAAA","wr2GCAAAXBBBaWJHDDGasdadBBB"],
  3800. * text: {
  3801. * content: '企业微信'
  3802. * },
  3803. * attachments: [
  3804. * {
  3805. * msgtype: 'image',
  3806. * image: {
  3807. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
  3808. * }
  3809. * }
  3810. * ]
  3811. * })
  3812. * // 或者
  3813. * ww.shareToExternalChat({
  3814. * title: '', // 消息的标题
  3815. * desc: '', // 消息的描述
  3816. * link: '', // 消息链接
  3817. * imgUrl: '' // 消息封面
  3818. * })
  3819. * ```
  3820. */ function shareToExternalChat(params) {
  3821. return passthrough('shareToExternalChat', params);
  3822. }
  3823. /**
  3824. * 具有客户联系权限的企业成员,可通过该接口将文本内容和附件传递到群发助手、发送给客户。
  3825. *
  3826. * @limit
  3827. * - 本接口必须使用应用身份进行注册
  3828. * - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  3829. * - 当前成员必须配置了[客户联系功能](#13473/配置可使用客户联系功能的成员)
  3830. *
  3831. * @note
  3832. * - 为防止滥用,同一个成员每日向一个客户最多可群发一条消息,每次群发最多可选 20000 个客户
  3833. *
  3834. *
  3835. * @compat WeCom >= 2.8.7
  3836. *
  3837. * @example
  3838. * ```ts
  3839. * // WeCom >= 3.1.6
  3840. * ww.shareToExternalContact({
  3841. * externalUserIds: ["wr2GCAAAXAAAaWJHDDGasdadAAA","wr2GCAAAXBBBaWJHDDGasdadBBB"],
  3842. * text: {
  3843. * content: '企业微信'
  3844. * },
  3845. * attachments: [
  3846. * {
  3847. * msgtype: 'image',
  3848. * image: {
  3849. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
  3850. * }
  3851. * }
  3852. * ]
  3853. * })
  3854. *
  3855. * // 或者
  3856. * ww.shareToExternalContact({
  3857. * title: '', // 消息的标题
  3858. * desc: '', // 消息的描述
  3859. * link: '', // 消息链接
  3860. * imgUrl: '' // 消息封面
  3861. * })
  3862. * ```
  3863. */ function shareToExternalContact(params) {
  3864. return passthrough('shareToExternalContact', params);
  3865. }
  3866. /**
  3867. * 发表内容到客户朋友圈。
  3868. *
  3869. * @limit
  3870. * - 本接口必须使用应用身份进行注册
  3871. * - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  3872. * - 当前成员必须配置了客户联系功能
  3873. * - 当前成员必须在客户朋友圈使用范围
  3874. * - 当前成员必须具备外部沟通管理成员使用权限
  3875. *
  3876. * @compat WeCom iOS, Android >= 3.1.12
  3877. *
  3878. * @example
  3879. * ```ts
  3880. * ww.shareToExternalMoments({
  3881. * text: {
  3882. * content: '企业微信'
  3883. * },
  3884. * attachments: [
  3885. * {
  3886. * msgtype: 'image',
  3887. * image: {
  3888. * imgUrl: 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png'
  3889. * }
  3890. * }
  3891. * ]
  3892. * })
  3893. * ```
  3894. */ function shareToExternalMoments(params) {
  3895. return passthrough('shareToExternalMoments', params);
  3896. }
  3897. /**
  3898. * 发起无线投屏。
  3899. *
  3900. * @compat WeCom
  3901. *
  3902. * @limit
  3903. * 仅支持第三方服务商接入。
  3904. * 需要配合硬件设备使用,硬件接入流程参考 [无线投屏](#14789)。
  3905. *
  3906. * @example
  3907. * ```ts
  3908. * ww.startWecast()
  3909. * ```
  3910. */ function startWecast(params = {}) {
  3911. return passthrough('startWecast', params);
  3912. }
  3913. exports.OAType = void 0;
  3914. (function(OAType) {
  3915. /**
  3916. * 发起审批
  3917. */ OAType["create_approval"] = "10001";
  3918. /**
  3919. * 查看审批详情
  3920. */ OAType["view_approval"] = "10002";
  3921. })(exports.OAType || (exports.OAType = {}));
  3922. exports.OaExtDataType = void 0;
  3923. (function(OaExtDataType) {
  3924. /**
  3925. * 链接
  3926. */ OaExtDataType["link"] = "link";
  3927. /**
  3928. * 文本
  3929. */ OaExtDataType["text"] = "text";
  3930. })(exports.OaExtDataType || (exports.OaExtDataType = {}));
  3931. /**
  3932. * 在应用页面中发起审批流程。之后审批流程的每次状态变化都会通知开发者,开发者可按需进行拓展开发。具体参见[审批流程引擎](#14584)。
  3933. *
  3934. * @limit
  3935. * - 本接口必须使用应用身份进行注册
  3936. * - 应用必须具有审批权限
  3937. *
  3938. * @compat WeCom >= 2.5.0
  3939. *
  3940. * @example
  3941. * ```ts
  3942. * ww.thirdPartyOpenPage({
  3943. * oaType: '10001',
  3944. * templateId: '46af67a118a6ebf000002',
  3945. * thirdNo: 'thirdNo',
  3946. * extData: {
  3947. * fieldList: [
  3948. * {
  3949. * type: 'text',
  3950. * title: '采购类型',
  3951. * value: '市场活动'
  3952. * },
  3953. * {
  3954. * type: 'link',
  3955. * title: '订单链接',
  3956. * value: 'https://work.weixin.qq.com'
  3957. * }
  3958. * ]
  3959. * }
  3960. * })
  3961. * ```
  3962. * @throws
  3963. * | errMsg | 说明 |
  3964. * | --- | --- |
  3965. * | 已存在相同的审批编号 | oaType为10001时,传入的thirdNo已经被其他审批单占用。 |
  3966. * | 审批申请不存在 | oaType为10002时,在历史记录中,传入的thirdNo对应的审批单不存在。 |
  3967. * | 审批模板ID不正确 | 调用接口时传入了错误的templateId |
  3968. * | 应用ID不正确 | 使用了错误的 agentId |
  3969. */ function thirdPartyOpenPage(params) {
  3970. return passthrough('thirdPartyOpenPage', params);
  3971. }
  3972. /**
  3973. * 变更企业互联/上下游群成员
  3974. *
  3975. * @limit
  3976. * - 本接口必须使用应用身份进行注册
  3977. * - 当前成员必须在应用的可见范围
  3978. * - 仅支持往群里添加企业内部成员/企业互联成员
  3979. * - 仅限企业互联/上下游企业可调用
  3980. * - 当前成员为下游企业成员时,需要打开上下游空间中的“允许外部单位之间互相查看”配置才可以往群里添加其他下游企业成员
  3981. *
  3982. * @compat WeCom >= 3.1.8
  3983. *
  3984. * @example
  3985. * ```ts
  3986. * ww.updateCorpGroupChat({
  3987. * chatId: 'CHATID',
  3988. * userIdsToAdd: ['lisi', 'lisi2'],
  3989. * openUserIdsToAdd: ['wabc3', 'wbcde'],
  3990. * corpGroupUserIdsToAdd: [
  3991. * {
  3992. * corpId: 'ww3333',
  3993. * userId: 'userid123',
  3994. * openUserId: 'wx1111'
  3995. * },
  3996. * {
  3997. * corpId: 'ww4444',
  3998. * userId: 'userid123',
  3999. * openUserId: 'wx1111'
  4000. * }
  4001. * ]
  4002. * })
  4003. * ```
  4004. *
  4005. * @throws
  4006. * | errMsg | 说明 |
  4007. * | --- | --- |
  4008. * | updateCorpGroupChat:ok | 执行成功 |
  4009. * | updateCorpGroupChat:fail no permission | 应用签名校验失败 |
  4010. * | updateCorpGroupChat:fail exceed user id list size | 超过人数上限 |
  4011. * | updateCorpGroupChat:fail invalid parameter | 参数不合法 |
  4012. * | updateCorpGroupChat:fail unsupported chat | 不支持群类型 |
  4013. */ function updateCorpGroupChat(params) {
  4014. return passthrough('updateCorpGroupChat', params);
  4015. }
  4016. /**
  4017. * 变更群成员。
  4018. *
  4019. * @limit
  4020. * - 本接口必须使用应用身份进行注册
  4021. * - 目前仅支持添加企业内部成员
  4022. * - 仅支持客户群调用
  4023. *
  4024. * @compat WeCom iOS, Android, PC >= 3.0.36
  4025. *
  4026. * @example
  4027. * ```ts
  4028. * ww.updateEnterpriseChat({
  4029. * chatId: 'CHATID',
  4030. * userIdsToAdd: [
  4031. * 'zhangsan',
  4032. * 'lisi'
  4033. * ]
  4034. * })
  4035. * ```
  4036. */ function updateEnterpriseChat(params) {
  4037. return passthrough('updateEnterpriseChat', params, {
  4038. chatId: params.chatId,
  4039. userIdsToAdd: joinList(params.userIdsToAdd)
  4040. });
  4041. }
  4042. /**
  4043. * 设置朋友圈封面与签名。
  4044. *
  4045. * @compat WeCom iOS, Android >= 3.1.12
  4046. *
  4047. * @limit
  4048. * - 本接口必须使用应用身份进行注册
  4049. * - 应用需有[客户联系功能权限](#13473/配置可使用客户联系接口的应用)
  4050. * - 当前成员必须配置了客户联系功能
  4051. * - 当前成员必须在客户朋友圈使用范围
  4052. * - 当前成员必须具备外部沟通管理成员使用权限
  4053. *
  4054. * @note
  4055. * 同时设置了签名跟封面url,客户端更新顺序为先更新签名,再更新封面图url(封面图若不符合要求会让用户重新调整)。
  4056. *
  4057. * @example
  4058. * ```ts
  4059. * ww.updateMomentsSetting({
  4060. * signature: '个性签名',
  4061. * imgUrl: 'https://work.weixin.qq.com/'
  4062. * })
  4063. * ```
  4064. */ function updateMomentsSetting(params) {
  4065. return passthrough('updateMomentsSetting', params);
  4066. }
  4067. /**
  4068. * 保持屏幕常亮。
  4069. *
  4070. * 在企业微信内打开 H5 页面时,调用该接口让屏幕保持常亮。
  4071. *
  4072. * @note
  4073. * 仅在当前页面生效,离开页面后设置失效。
  4074. *
  4075. * @limit
  4076. * - 本接口必须使用应用身份进行注册
  4077. * - 成员必须在应用可见范围内
  4078. *
  4079. * @compat @compat WeCom iOS, Android >= 4.0.20
  4080. *
  4081. * @example
  4082. * ```ts
  4083. * ww.setKeepScreenOn({
  4084. * keepScreenOn: true,
  4085. * })
  4086. * ```
  4087. */ function setKeepScreenOn(params) {
  4088. return passthrough('setKeepScreenOn', params);
  4089. }
  4090. /**
  4091. * **注意:页面上需要提前引入 `jwxwork-1.0.0.js`:**
  4092. *
  4093. * ```html
  4094. * <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>
  4095. * ```
  4096. *
  4097. * 初始化[通讯录展示组件](#91958)。
  4098. *
  4099. * 在该接口返回成功后,可以直接调用通讯录展示组件的相关方法。
  4100. *
  4101. * @example
  4102. * ```ts
  4103. * ww.initOpenData()
  4104. * ```
  4105. */ function initOpenData(params = {}) {
  4106. return promiseToCallback(params, async ()=>{
  4107. if (!isWeCom) {
  4108. return invokeOpenDataAgentConfig();
  4109. }
  4110. const { result } = await ensureAgentConfigReady();
  4111. if (!isWindows && !win?.WeixinSandBox) {
  4112. throw new SDKError('Missing WeixinSandBox');
  4113. }
  4114. if (!win?.WWOpenData) {
  4115. await invoke('wwapp.initWwOpenData');
  4116. }
  4117. if (!win?.WWOpenData) {
  4118. throw new SDKError('Init WWOpenData failed');
  4119. }
  4120. if (win.WWOpenData.initJSSDK) {
  4121. win.WWOpenData.initJSSDK({
  4122. invoke,
  4123. ensureAgentConfigReady
  4124. });
  4125. }
  4126. return result;
  4127. });
  4128. }
  4129. async function invokeOpenDataAgentConfig() {
  4130. if (!win?.WWOpenData?.agentConfig) {
  4131. throw new SDKError('Missing WWOpenData.agentConfig');
  4132. }
  4133. const params = await resolveAgentConfigParams(getSignURL());
  4134. const promise = new Promise((success, fail)=>{
  4135. win.WWOpenData.agentConfig({
  4136. ...params,
  4137. success,
  4138. fail
  4139. });
  4140. });
  4141. promise.then(handleAgentConfigSuccess, handleAgentConfigFail);
  4142. return promise;
  4143. }
  4144. function createTransparentIFrame(el) {
  4145. const iframeEl = document.createElement('iframe');
  4146. const { style } = iframeEl;
  4147. style.display = 'block';
  4148. style.border = 'none';
  4149. style.background = 'transparent';
  4150. iframeEl.referrerPolicy = 'origin';
  4151. iframeEl.setAttribute('frameborder', '0');
  4152. iframeEl.setAttribute('allowtransparency', 'true');
  4153. const containerEl = resolveEl(el);
  4154. if (containerEl) {
  4155. containerEl.appendChild(iframeEl);
  4156. }
  4157. return iframeEl;
  4158. }
  4159. function resolveEl(el) {
  4160. if (typeof el === 'string') {
  4161. return document.querySelector(el);
  4162. }
  4163. return el;
  4164. }
  4165. const clientId = random();
  4166. let uid = 0;
  4167. function genUid() {
  4168. return `${clientId}-${uid++}`;
  4169. }
  4170. function random() {
  4171. return Math.random().toString(36).slice(2);
  4172. }
  4173. function normalizeError(error) {
  4174. if (!error || typeof error !== 'object') {
  4175. return error;
  4176. }
  4177. return {
  4178. ...error,
  4179. message: error.message,
  4180. stack: error.stack
  4181. };
  4182. }
  4183. function tryParseJSON(data) {
  4184. try {
  4185. if (typeof data === 'string') {
  4186. return JSON.parse(data);
  4187. }
  4188. return data;
  4189. } catch (error) {
  4190. // noop
  4191. }
  4192. }
  4193. function useRemoteInvoke(postMessage, callback) {
  4194. const messageMap = new Map();
  4195. function invoke(args, opts) {
  4196. if (opts?.dropResult) {
  4197. postMessage({
  4198. type: 'ww-iframe-handle:call',
  4199. args
  4200. }, opts);
  4201. return Promise.resolve(undefined);
  4202. }
  4203. return new Promise((resolve, reject)=>{
  4204. const uid = genUid();
  4205. messageMap.set(uid, {
  4206. resolve,
  4207. reject
  4208. });
  4209. postMessage({
  4210. type: 'ww-iframe-handle:call',
  4211. uid,
  4212. args
  4213. }, opts);
  4214. });
  4215. }
  4216. async function handleCallMessage(msg, event) {
  4217. if (!msg.uid) {
  4218. return callback(msg.args, event);
  4219. }
  4220. try {
  4221. postMessage({
  4222. type: 'ww-iframe-handle:response',
  4223. uid: msg.uid,
  4224. kind: 'resolve',
  4225. args: await callback(msg.args, event)
  4226. });
  4227. } catch (error) {
  4228. postMessage({
  4229. type: 'ww-iframe-handle:response',
  4230. uid: msg.uid,
  4231. kind: 'reject',
  4232. args: normalizeError(error)
  4233. });
  4234. throw error;
  4235. }
  4236. }
  4237. function handleResponseMessage(msg) {
  4238. const handle = messageMap.get(msg.uid);
  4239. if (!handle) {
  4240. return;
  4241. }
  4242. handle[msg.kind](msg.args);
  4243. messageMap.delete(msg.uid);
  4244. }
  4245. return {
  4246. invoke,
  4247. handleCallMessage,
  4248. handleResponseMessage
  4249. };
  4250. }
  4251. function useIframeClient(iframeEl, origin, callback) {
  4252. const messageQueue = [];
  4253. let iframeReady = false;
  4254. let useChannel = false;
  4255. window.addEventListener('message', handleWindowMessage);
  4256. function handleWindowMessage(event) {
  4257. if (event.origin !== origin || iframeEl.contentWindow !== event.source) {
  4258. return;
  4259. }
  4260. const msg = tryParseJSON(event.data);
  4261. if (typeof msg?.type !== 'string') {
  4262. return;
  4263. }
  4264. if (msg.type.startsWith('ww-iframe-handle:')) {
  4265. handleMessage(msg, event);
  4266. }
  4267. }
  4268. const channel = new MessageChannel();
  4269. channel.port1.onmessage = (event)=>{
  4270. const msg = tryParseJSON(event.data);
  4271. handleMessage(msg, event);
  4272. };
  4273. const { invoke, handleCallMessage, handleResponseMessage } = useRemoteInvoke(enqueueMsg, callback);
  4274. function handleMessage(msg, event) {
  4275. switch(msg.type){
  4276. case 'ww-iframe-handle:ready':
  4277. return handleReadyMessage(msg);
  4278. case 'ww-iframe-handle:call':
  4279. return handleCallMessage(msg, event);
  4280. case 'ww-iframe-handle:response':
  4281. handleResponseMessage(msg);
  4282. return;
  4283. }
  4284. }
  4285. function handleReadyMessage(msg) {
  4286. if (iframeReady) {
  4287. return;
  4288. }
  4289. iframeReady = true;
  4290. if (msg.supportChannel) {
  4291. switchToChannel();
  4292. }
  4293. for (const info of messageQueue){
  4294. postMessage(info.msg, info.opts);
  4295. }
  4296. }
  4297. iframeEl.addEventListener('load', ()=>{
  4298. if (!iframeReady) {
  4299. postMessage({
  4300. type: 'ww-iframe-handle:init'
  4301. });
  4302. }
  4303. });
  4304. function switchToChannel() {
  4305. postMessage({
  4306. type: 'ww-iframe-handle:set-port',
  4307. port: channel.port2
  4308. }, {
  4309. transfer: [
  4310. channel.port2
  4311. ],
  4312. serialize: false
  4313. });
  4314. useChannel = true;
  4315. }
  4316. function enqueueMsg(msg, opts) {
  4317. if (!iframeReady) {
  4318. messageQueue.push({
  4319. msg,
  4320. opts
  4321. });
  4322. } else {
  4323. postMessage(msg, opts);
  4324. }
  4325. }
  4326. function postMessage(msg, opts) {
  4327. const data = opts?.serialize === false ? msg : JSON.stringify(msg);
  4328. if (useChannel) {
  4329. channel.port1.postMessage(data, opts?.transfer);
  4330. } else {
  4331. iframeEl.contentWindow?.postMessage(data, origin, opts?.transfer);
  4332. }
  4333. }
  4334. function dispose() {
  4335. window.removeEventListener('message', handleWindowMessage);
  4336. channel.port1.onmessage = null;
  4337. }
  4338. return {
  4339. el: iframeEl,
  4340. invoke,
  4341. dispose
  4342. };
  4343. }
  4344. async function resolveSuiteConfigParams(url) {
  4345. const registerOptions = getRegisterOptions();
  4346. if (!registerOptions?.getSuiteConfigSignature) {
  4347. throw new SDKError('Missing getSuiteConfigSignature');
  4348. }
  4349. const data = await registerOptions.getSuiteConfigSignature(url);
  4350. return {
  4351. suiteid: registerOptions.suiteId,
  4352. timestamp: `${data.timestamp}`,
  4353. nonceStr: data.nonceStr,
  4354. signature: data.signature,
  4355. jsApiList: mapJsApiListToClient(registerOptions.jsApiList || [
  4356. 'agentConfig'
  4357. ])
  4358. };
  4359. }
  4360. function has$1(obj, key) {
  4361. return Object.prototype.hasOwnProperty.call(obj, key);
  4362. }
  4363. function handleCallMsg(msg, options, thisArg) {
  4364. safeRun(options[msg.name], msg.payload || msg.data, thisArg);
  4365. }
  4366. function createMsgDispatcher() {
  4367. const handlers = new Map();
  4368. function subscribe(type, handler) {
  4369. handlers.set(type, handler);
  4370. }
  4371. function handleMessage(msg) {
  4372. return handlers.get(msg.type)?.(msg);
  4373. }
  4374. return {
  4375. subscribe,
  4376. handleMessage
  4377. };
  4378. }
  4379. let disposeModalFrame;
  4380. function showModalFrame(url, callback) {
  4381. disposeModalFrame?.();
  4382. const iframeEl = createTransparentIFrame(document.body);
  4383. const { style } = iframeEl;
  4384. style.position = 'fixed';
  4385. style.left = '0';
  4386. style.top = '0';
  4387. style.zIndex = '1000';
  4388. style.width = '100vw';
  4389. style.height = '100vh';
  4390. iframeEl.classList.add('wecom-jssdk-modal');
  4391. iframeEl.setAttribute('src', url);
  4392. const { origin } = new URL(url);
  4393. const client = useIframeClient(iframeEl, origin, (msg)=>{
  4394. if (msg.type === 'close') {
  4395. handleCloseMsg();
  4396. }
  4397. return callback?.(msg);
  4398. });
  4399. function handleCloseMsg() {
  4400. client.dispose();
  4401. iframeEl.parentNode?.removeChild(iframeEl);
  4402. }
  4403. disposeModalFrame = handleCloseMsg;
  4404. return client;
  4405. }
  4406. const FRAME_ORIGIN$1 = 'https://login.work.weixin.qq.com';
  4407. /**
  4408. * 创建 JSAPI 触发面板。
  4409. *
  4410. * 在非企业微信内置浏览器环境下,开发者可以创建 JSAPI 触发面板。当用户点击面板时,内置的 iframe 将调起用户本地的企业微信客户端并调用指定的 JSAPI。
  4411. *
  4412. * @param name 要调用的 JSAPI 名称
  4413. *
  4414. * @limit
  4415. * - 应用必须经过 SSO 登录获取 web_token
  4416. * - 用户必须登录了企业微信桌面端且当前用户身份和页面身份一致
  4417. */ function createJSAPIPanel(name, options) {
  4418. const iframeEl = createTransparentIFrame(options.el);
  4419. const { style } = iframeEl;
  4420. style.width = '100%';
  4421. style.height = '100%';
  4422. const jsapiParamsMap = new Map();
  4423. const { subscribe, handleMessage } = createMsgDispatcher();
  4424. const { dispose } = useIframeClient(iframeEl, FRAME_ORIGIN$1, handleMessage);
  4425. subscribe('call', (msg)=>{
  4426. handleCallMsg(msg, options);
  4427. });
  4428. subscribe('getStaticOptions', ()=>{
  4429. return {
  4430. name,
  4431. options: {
  4432. ...options,
  4433. el: undefined,
  4434. params: undefined
  4435. }
  4436. };
  4437. });
  4438. subscribe('jsapiCallback', (msg)=>{
  4439. if (!jsapiParamsMap.has(msg.seq)) {
  4440. return;
  4441. }
  4442. const jsapiParams = jsapiParamsMap.get(msg.seq);
  4443. jsapiParamsMap.delete(msg.seq);
  4444. if (msg.kind === 'success') {
  4445. safeRun(jsapiParams?.success, msg.payload);
  4446. } else {
  4447. safeRun(jsapiParams?.fail, msg.payload);
  4448. }
  4449. safeRun(jsapiParams?.complete, msg.payload);
  4450. });
  4451. subscribe('getJSAPIParams', async (msg)=>{
  4452. const jsapiParams = isFunction(options.params) ? await options.params() : options.params;
  4453. const signUrl = getSignURL();
  4454. jsapiParamsMap.set(msg.seq, jsapiParams);
  4455. return {
  4456. webToken: options.webToken,
  4457. url: signUrl,
  4458. configParams: msg.payload?.skipSignature ? undefined : await resolveSignatureData(signUrl, msg.payload?.preferSignatureTypeList || [
  4459. 'agentConfig'
  4460. ]),
  4461. jsapi: name,
  4462. jsapiParams
  4463. };
  4464. });
  4465. subscribe('openModalFrame', (msg)=>{
  4466. showModalFrame(msg.payload.url);
  4467. });
  4468. iframeEl.style.opacity = '0';
  4469. iframeEl.src = 'https://login.work.weixin.qq.com/wwopen/ww-jsapi-transparent-frame';
  4470. return {
  4471. /**
  4472. * JSAPI 触发面板的 iframe 元素
  4473. */ el: iframeEl,
  4474. /**
  4475. * 卸载 JSAPI 触发面板
  4476. */ unmount () {
  4477. dispose();
  4478. iframeEl.parentNode?.removeChild(iframeEl);
  4479. }
  4480. };
  4481. }
  4482. const resolveSignatureFnMap = {
  4483. agentConfig: resolveAgentConfigParams,
  4484. suiteConfig: resolveSuiteConfigParams
  4485. };
  4486. async function resolveSignatureData(url, typeList) {
  4487. let lastError = new Error('Missing signature handler');
  4488. for (const type of typeList){
  4489. try {
  4490. if (!has$1(resolveSignatureFnMap, type)) {
  4491. continue;
  4492. }
  4493. return {
  4494. type,
  4495. params: await resolveSignatureFnMap[type](url)
  4496. };
  4497. } catch (error) {
  4498. lastError = error;
  4499. }
  4500. }
  4501. throw lastError;
  4502. }
  4503. function has(object, key) {
  4504. return Object.prototype.hasOwnProperty.call(object, key);
  4505. }
  4506. function isObject(val) {
  4507. return typeof val === 'object' && val !== null;
  4508. }
  4509. function includes(list, value) {
  4510. if (!list) {
  4511. return false;
  4512. }
  4513. return list.indexOf(value) >= 0;
  4514. }
  4515. var createIdentifier = createBuilder("Identifier" /* Types.Identifier */ , 'name');
  4516. var createLiteral = createBuilder("Literal" /* Types.Literal */ , 'value');
  4517. function createBuilder(type, key) {
  4518. return function(val) {
  4519. var _a;
  4520. return _a = {
  4521. type: type
  4522. }, _a[key] = val, _a;
  4523. };
  4524. }
  4525. function isIdentifierStart(ch) {
  4526. return isInRange(ch, 65, 90) // A-Z
  4527. || isInRange(ch, 97, 122) // a-z
  4528. || ch === 36 /* Code.dollarSign */ || ch === 95 /* Code.underscore */ ;
  4529. }
  4530. function isIdentifierPart(ch) {
  4531. return isIdentifierStart(ch) || isDecimalDigit(ch);
  4532. }
  4533. function isDecimalDigit(ch) {
  4534. return isInRange(ch, 48, 57); // 0-9
  4535. }
  4536. function isHexDigit(ch) {
  4537. return isDecimalDigit(ch) || isInRange(ch, 65, 70) // A-F
  4538. || isInRange(ch, 97, 102); // a-f
  4539. }
  4540. function isInRange(val, min, max) {
  4541. return val >= min && val <= max;
  4542. }
  4543. /**
  4544. * 12.6 Names and Keywords & 13.1 Identifiers
  4545. */ var LITERAL_NAME = {
  4546. "null": null,
  4547. "true": true,
  4548. "false": false,
  4549. NaN: NaN,
  4550. Infinity: Infinity
  4551. };
  4552. var reserveWords = ('await break case catch class const continue ' + 'debugger default delete do else enum export ' + 'extends false finally for function if import ' + 'in instanceof new null return super switch ' + 'this throw true try typeof var void while ' + 'with yield').split(' ');
  4553. var reserveWordMap = {};
  4554. for(var _i = 0, reserveWords_1 = reserveWords; _i < reserveWords_1.length; _i++){
  4555. var word = reserveWords_1[_i];
  4556. reserveWordMap[word] = true;
  4557. }
  4558. /**
  4559. * IdentifierReference
  4560. *
  4561. * https://tc39.es/ecma262/#prod-IdentifierReference
  4562. */ function parseIdentifierReference(ctx) {
  4563. var name = parseIdentifierName(ctx);
  4564. if (has(LITERAL_NAME, name)) {
  4565. return ctx.build(createLiteral(LITERAL_NAME[name]));
  4566. }
  4567. if (has(reserveWordMap, name)) {
  4568. ctx.unexpected(name);
  4569. }
  4570. return ctx.build(createIdentifier(name));
  4571. }
  4572. /**
  4573. * Identifier
  4574. *
  4575. * https://tc39.es/ecma262/#prod-Identifier
  4576. */ function parseIdentifier(ctx) {
  4577. var name = parseIdentifierName(ctx);
  4578. return ctx.build(createIdentifier(name));
  4579. }
  4580. /**
  4581. * IdentifierName
  4582. *
  4583. * https://tc39.es/ecma262/#prod-IdentifierName
  4584. */ function parseIdentifierName(ctx) {
  4585. if (!isIdentifierStart(ctx.peek())) {
  4586. ctx.unexpected();
  4587. }
  4588. var start = ctx.index;
  4589. do {
  4590. ctx.next();
  4591. }while (isIdentifierPart(ctx.peek()))
  4592. return ctx.expr.slice(start, ctx.index);
  4593. }
  4594. /**
  4595. * 12.8.3 Numeric Literals
  4596. */ /**
  4597. * NumericLiteral
  4598. *
  4599. * https://tc39.es/ecma262/#prod-NumericLiteral
  4600. */ function parseNumericLiteral(ctx) {
  4601. var number = '';
  4602. while(isDecimalDigit(ctx.peek())){
  4603. number += ctx.nextCh();
  4604. }
  4605. if (number === '0') {
  4606. // HexIntegerLiteral
  4607. // https://tc39.es/ecma262/#prod-HexIntegerLiteral
  4608. if (ctx.eat(120 /* Code.lowercaseX */ ) || ctx.eat(88 /* Code.uppercaseX */ )) {
  4609. number = '';
  4610. while(isHexDigit(ctx.peek())){
  4611. number += ctx.nextCh();
  4612. }
  4613. if (!number) {
  4614. ctx.unexpected();
  4615. }
  4616. return ctx.build(createLiteral(parseInt(number, 16)));
  4617. }
  4618. // BinaryIntegerLiteral
  4619. // https://tc39.es/ecma262/#prod-BinaryIntegerLiteral
  4620. if (ctx.eat(98 /* Code.lowercaseB */ ) || ctx.eat(66 /* Code.uppercaseB */ )) {
  4621. number = '';
  4622. while(ctx.peek() === 48 /* Code.digit0 */ || ctx.peek() === 49 /* Code.digit1 */ ){
  4623. number += ctx.nextCh();
  4624. }
  4625. if (!number) {
  4626. ctx.unexpected();
  4627. }
  4628. return ctx.build(createLiteral(parseInt(number, 2)));
  4629. }
  4630. }
  4631. if (ctx.peek() === 46 /* Code.dot */ ) {
  4632. number += ctx.nextCh();
  4633. while(isDecimalDigit(ctx.peek())){
  4634. number += ctx.nextCh();
  4635. }
  4636. }
  4637. // ExponentPart
  4638. // https://tc39.es/ecma262/#prod-ExponentPart
  4639. if (ctx.peek() === 101 /* Code.lowercaseE */ || ctx.peek() === 69 /* Code.uppercaseE */ ) {
  4640. number += ctx.nextCh();
  4641. if (ctx.peek() === 43 /* Code.plusSign */ || ctx.peek() === 45 /* Code.dash */ ) {
  4642. number += ctx.nextCh();
  4643. }
  4644. var hasDecimal = false;
  4645. while(isDecimalDigit(ctx.peek())){
  4646. hasDecimal = true;
  4647. number += ctx.nextCh();
  4648. }
  4649. if (!hasDecimal) {
  4650. ctx.unexpected();
  4651. }
  4652. }
  4653. if (isIdentifierStart(ctx.peek())) {
  4654. ctx["throw"]("Variable name cannot start with a number (".concat(number).concat(ctx.peekCh(), ")."));
  4655. }
  4656. if (ctx.peek() === 46 /* Code.dot */ || number === '.') {
  4657. ctx.unexpected();
  4658. }
  4659. return ctx.build(createLiteral(parseFloat(number)));
  4660. }
  4661. /**
  4662. * 12.8.4 String Literals
  4663. */ var ESCAPE_CHARACTER = {
  4664. n: '\n',
  4665. r: '\r',
  4666. t: '\t'
  4667. };
  4668. /**
  4669. * StringLiteral
  4670. *
  4671. * https://tc39.es/ecma262/#prod-StringLiteral
  4672. */ function parseStringLiteral(ctx) {
  4673. var quote = ctx.nextCh();
  4674. var value = '';
  4675. var ch;
  4676. while(ch = ctx.nextCh()){
  4677. if (ch === quote) {
  4678. return ctx.build(createLiteral(value));
  4679. }
  4680. if (ch !== '\\') {
  4681. value += ch;
  4682. continue;
  4683. }
  4684. ch = ctx.nextCh();
  4685. if (has(ESCAPE_CHARACTER, ch)) {
  4686. value += ESCAPE_CHARACTER[ch];
  4687. } else {
  4688. value += ch;
  4689. }
  4690. }
  4691. ctx.unexpected();
  4692. }
  4693. /**
  4694. * 13.2 Primary Expression
  4695. */ /**
  4696. * PrimaryExpression
  4697. *
  4698. * https://tc39.es/ecma262/#prod-PrimaryExpression
  4699. */ function parsePrimaryExpression(ctx) {
  4700. var code = ctx.peek();
  4701. if (isDecimalDigit(code) || code === 46 /* Code.dot */ ) {
  4702. return parseNumericLiteral(ctx);
  4703. }
  4704. if (code === 39 /* Code.singleQuote */ || code === 34 /* Code.doubleQuote */ ) {
  4705. return parseStringLiteral(ctx);
  4706. }
  4707. if (isIdentifierStart(code)) {
  4708. return parseIdentifierReference(ctx);
  4709. }
  4710. ctx.unexpected();
  4711. }
  4712. /**
  4713. * 13.3 Left-Hand-Side Expressions
  4714. */ /**
  4715. * LeftHandSideExpression
  4716. *
  4717. * https://tc39.es/ecma262/#prod-LeftHandSideExpression
  4718. */ function parseLeftHandSideExpression(ctx) {
  4719. var content = parsePrimaryExpression(ctx);
  4720. var code;
  4721. while(code = ctx.peek()){
  4722. // base [ prop ]
  4723. if (code === 91 /* Code.leftSquareBracket */ ) {
  4724. content = buildMemberExpression(ctx, content, true);
  4725. continue;
  4726. }
  4727. // base . prop
  4728. if (ctx.eat(46 /* Code.dot */ )) {
  4729. content = buildMemberExpression(ctx, content);
  4730. continue;
  4731. }
  4732. break;
  4733. }
  4734. return content;
  4735. }
  4736. /**
  4737. * MemberExpression
  4738. *
  4739. * https://tc39.es/ecma262/#prod-MemberExpression
  4740. */ function buildMemberExpression(ctx, object, computed) {
  4741. if (computed === void 0) {
  4742. computed = false;
  4743. }
  4744. var property;
  4745. if (computed) {
  4746. ctx.expect(91 /* Code.leftSquareBracket */ );
  4747. property = parseExpression(ctx);
  4748. ctx.expect(93 /* Code.rightSquareBracket */ );
  4749. } else {
  4750. property = parseIdentifier(ctx);
  4751. }
  4752. return ctx.build({
  4753. type: "MemberExpression" /* Types.MemberExpression */ ,
  4754. object: object,
  4755. property: property,
  4756. computed: computed
  4757. });
  4758. }
  4759. /**
  4760. * 13.16 Comma Operator ( , )
  4761. */ /**
  4762. * Expression
  4763. *
  4764. * https://tc39.es/ecma262/#prod-Expression
  4765. */ function parseExpression(ctx) {
  4766. return parseLeftHandSideExpression(ctx);
  4767. }
  4768. function createParserContext(expr) {
  4769. return {
  4770. expr: expr,
  4771. index: 0,
  4772. peek: function() {
  4773. return this.expr.charCodeAt(this.index);
  4774. },
  4775. peekCh: function() {
  4776. return this.expr.charAt(this.index);
  4777. },
  4778. next: function() {
  4779. this.index += 1;
  4780. },
  4781. nextCh: function() {
  4782. this.index += 1;
  4783. return this.expr.charAt(this.index - 1);
  4784. },
  4785. eat: function(ch) {
  4786. if (this.peek() !== ch) {
  4787. return false;
  4788. }
  4789. this.next();
  4790. this.skipWhitespace();
  4791. return true;
  4792. },
  4793. expect: function(ch) {
  4794. if (!this.eat(ch)) {
  4795. this.unexpected();
  4796. }
  4797. },
  4798. skip: function(length) {
  4799. this.index += length;
  4800. this.skipWhitespace();
  4801. },
  4802. skipWhitespace: function() {
  4803. var ch = expr.charCodeAt(this.index);
  4804. while(ch === 32 /* Code.space */ || ch === 9 /* Code.tab */ || ch === 13 /* Code.carriageReturn */ || ch === 10 /* Code.lineFeed */ ){
  4805. this.index += 1;
  4806. ch = expr.charCodeAt(this.index);
  4807. }
  4808. return this.index;
  4809. },
  4810. build: function(expr) {
  4811. this.skipWhitespace();
  4812. return expr;
  4813. },
  4814. unexpected: function(token) {
  4815. if (!token && this.index >= expr.length) {
  4816. throw this["throw"]('Unexpected end of input.');
  4817. }
  4818. throw this["throw"]("Unexpected token '".concat(token || this.peekCh(), "'."));
  4819. },
  4820. "throw": function(msg) {
  4821. throw new SyntaxError("".concat(msg, " (1:").concat(this.index, ")"));
  4822. }
  4823. };
  4824. }
  4825. function parseDataPath(input) {
  4826. var ctx = createParserContext(input.trim());
  4827. var ast = parseExpression(ctx);
  4828. if (ctx.index !== ctx.expr.length) {
  4829. ctx.unexpected();
  4830. }
  4831. return ast;
  4832. }
  4833. var DEFAULT_PROTECTED_KEYS = [
  4834. 'constrcutor',
  4835. 'prototype',
  4836. '__proto__'
  4837. ];
  4838. function patch(data, update, options) {
  4839. if (options === void 0) {
  4840. options = {};
  4841. }
  4842. var protectedKeys = options.protectedKeys || DEFAULT_PROTECTED_KEYS;
  4843. var set = options.set || defaultSet;
  4844. for(var _i = 0, _a = Object.keys(update); _i < _a.length; _i++){
  4845. var key = _a[_i];
  4846. if (includes(protectedKeys, key)) {
  4847. continue;
  4848. }
  4849. if (!includes(key, '[') && !includes(key, '.')) {
  4850. set(data, key, update[key]);
  4851. continue;
  4852. }
  4853. try {
  4854. var path = extractPath(parseDataPath(key), protectedKeys || []);
  4855. if (path) {
  4856. setIn(data, path, update[key], set);
  4857. } else {
  4858. set(data, key, update[key]);
  4859. }
  4860. } catch (error) {
  4861. set(data, key, update[key]);
  4862. }
  4863. }
  4864. }
  4865. function extractPath(expr, protectedKeys, path) {
  4866. if (protectedKeys === void 0) {
  4867. protectedKeys = [];
  4868. }
  4869. if (path === void 0) {
  4870. path = [];
  4871. }
  4872. if (expr.type === "Identifier" /* Types.Identifier */ ) {
  4873. path.unshift(expr.name);
  4874. return path;
  4875. }
  4876. if (expr.type !== "MemberExpression" /* Types.MemberExpression */ ) {
  4877. return;
  4878. }
  4879. var object = expr.object, property = expr.property, computed = expr.computed;
  4880. if (computed) {
  4881. if (property.type !== "Literal" /* Types.Literal */ ) {
  4882. return;
  4883. }
  4884. var value = property.value;
  4885. if (includes(protectedKeys, value)) {
  4886. return;
  4887. }
  4888. path.unshift(value);
  4889. } else {
  4890. if (property.type !== "Identifier" /* Types.Identifier */ ) {
  4891. return;
  4892. }
  4893. var name_1 = property.name;
  4894. if (includes(protectedKeys, name_1)) {
  4895. return;
  4896. }
  4897. path.unshift(name_1);
  4898. }
  4899. return extractPath(object, protectedKeys, path);
  4900. }
  4901. function setIn(data, path, value, set) {
  4902. var ptr = data;
  4903. for(var i = 0, ii = path.length - 1; i < ii; i++){
  4904. var key = path[i];
  4905. if (!has(ptr, key) || !isObject(ptr[key])) {
  4906. set(ptr, key, typeof path[i + 1] === 'string' ? {} : []);
  4907. }
  4908. ptr = ptr[key];
  4909. }
  4910. set(ptr, path[path.length - 1], value);
  4911. return ptr;
  4912. }
  4913. function defaultSet(object, key, value) {
  4914. // eslint-disable-next-line no-param-reassign
  4915. object[key] = value;
  4916. }
  4917. function cloneDeep(value) {
  4918. if (Array.isArray(value)) {
  4919. return value.map(cloneDeep);
  4920. }
  4921. if (value == null || typeof value !== 'object') {
  4922. return value;
  4923. }
  4924. const result = {};
  4925. for (const key of Object.keys(value)){
  4926. result[key] = cloneDeep(value[key]);
  4927. }
  4928. return result;
  4929. }
  4930. const contextMap = new WeakMap();
  4931. function setPluginContext(instance, internal) {
  4932. contextMap.set(instance, internal);
  4933. }
  4934. function getPluginContext(instance) {
  4935. return contextMap.get(instance);
  4936. }
  4937. function createOpenSessionInjector(params) {
  4938. return new Promise((resolve, reject)=>{
  4939. win.WWOpenData.createOpenSessionInjector(params, (error, injectOpenSession)=>{
  4940. if (error || !injectOpenSession) {
  4941. reject(error || new Error('System error'));
  4942. } else {
  4943. resolve(injectOpenSession);
  4944. }
  4945. });
  4946. });
  4947. }
  4948. function getHookNames(options) {
  4949. return Object.keys(options).filter((name)=>typeof options[name] === 'function');
  4950. }
  4951. function removeHooks(options) {
  4952. return Object.entries(options).reduce((acc, [name, value])=>{
  4953. if (typeof value !== 'function') {
  4954. acc[name] = value;
  4955. }
  4956. return acc;
  4957. }, {});
  4958. }
  4959. const FRAME_ORIGIN = 'https://open.work.weixin.qq.com';
  4960. const BUSINESS_URL = `${FRAME_ORIGIN}/wwopen/ww-open-data-frame`;
  4961. const PROTECTED_DATA_KEYS = [
  4962. 'constructor',
  4963. 'prototype',
  4964. '__proto__',
  4965. '__ob__'
  4966. ];
  4967. /**
  4968. * 创建 open-data frame 工厂对象。
  4969. *
  4970. * @compat WeCom >= 4.0.20
  4971. *
  4972. * @example
  4973. * ```ts
  4974. * const factory = ww.createOpenDataFrameFactory()
  4975. * const instance = factory.createOpenDataFrame(options)
  4976. *
  4977. * containerEl.appendChild(instance.el)
  4978. * ```
  4979. */ function createOpenDataFrameFactory(params) {
  4980. const initOpenDataPromise = isWeCom ? initOpenData() : undefined;
  4981. let openSessionInjectorPromise = createSessionInjector();
  4982. async function createSessionInjector() {
  4983. if (!isWeCom) {
  4984. return;
  4985. }
  4986. try {
  4987. await initOpenDataPromise;
  4988. return createOpenSessionInjector({
  4989. url: BUSINESS_URL
  4990. });
  4991. } catch (error) {
  4992. safeRun(params?.onError, error);
  4993. safeRun(params?.handleError, error);
  4994. throw error;
  4995. }
  4996. }
  4997. async function injectOpenSession(iframe) {
  4998. if (!isWeCom) {
  4999. return;
  5000. }
  5001. const injectSession = await openSessionInjectorPromise;
  5002. if (injectSession) {
  5003. injectSession(iframe);
  5004. }
  5005. }
  5006. function createOpenDataFrame(options) {
  5007. if (!options.template) {
  5008. throw new Error('options.template is required');
  5009. }
  5010. const iframeEl = createTransparentIFrame(options.el);
  5011. const registerOpenFramePromise = initOpenDataPromise?.then(()=>win?.WWOpenData?.registerOpenFrame(iframeEl));
  5012. const { subscribe, handleMessage } = createMsgDispatcher();
  5013. const { invoke: invoke$1, dispose } = useIframeClient(iframeEl, FRAME_ORIGIN, handleMessage);
  5014. const publicInstance = {
  5015. el: iframeEl,
  5016. data: cloneDeep(options.data) || {},
  5017. setData,
  5018. dispose: disposeComponent,
  5019. ...options.methods
  5020. };
  5021. async function setData(partialData) {
  5022. patch(publicInstance.data, partialData, {
  5023. protectedKeys: PROTECTED_DATA_KEYS
  5024. });
  5025. await invoke$1({
  5026. type: 'update',
  5027. options: {
  5028. data: partialData
  5029. }
  5030. });
  5031. }
  5032. function disposeComponent() {
  5033. dispose();
  5034. registerOpenFramePromise?.then((iframeId)=>{
  5035. win?.WWOpenData?.unregisterOpenFrame(iframeId);
  5036. });
  5037. }
  5038. setPluginContext(publicInstance, {
  5039. frame: publicInstance,
  5040. invoke: invoke$1,
  5041. subscribe
  5042. });
  5043. iframeEl.src = BUSINESS_URL;
  5044. subscribe('init', async ()=>{
  5045. return {
  5046. id: isWeCom ? await registerOpenFramePromise : undefined,
  5047. hooks: getHookNames(options),
  5048. options: removeHooks({
  5049. ...options,
  5050. el: undefined,
  5051. methods: undefined,
  5052. data: publicInstance.data
  5053. }),
  5054. config: {
  5055. support: [
  5056. 'injectSession'
  5057. ]
  5058. }
  5059. };
  5060. });
  5061. subscribe('call', (msg)=>{
  5062. let base = options;
  5063. if (msg.kind === 'method') {
  5064. base = base.methods;
  5065. }
  5066. return handleCallMsg(msg, base, publicInstance);
  5067. });
  5068. subscribe('injectSession', async ()=>{
  5069. await injectOpenSession(iframeEl);
  5070. });
  5071. subscribe('refreshSession', async ()=>{
  5072. openSessionInjectorPromise = createSessionInjector();
  5073. await injectOpenSession(iframeEl);
  5074. });
  5075. subscribe('invokeJsapi', (msg)=>{
  5076. return invoke('wwapp.invokeJsApiByCallInfo', {
  5077. callInfo: msg.callInfo
  5078. });
  5079. });
  5080. subscribe('invokeDownload', (msg)=>{
  5081. if (!msg.url.startsWith('https://open.work.weixin.qq.com/')) {
  5082. throw new Error('Invalid download url');
  5083. }
  5084. const el = document.createElement('a');
  5085. el.href = msg.url;
  5086. el.target = '_blank';
  5087. el.style.display = 'none';
  5088. el.click();
  5089. });
  5090. subscribe('agentConfig', async ()=>{
  5091. const url = getSignURL();
  5092. return {
  5093. url,
  5094. params: await resolveAgentConfigParams(url)
  5095. };
  5096. });
  5097. subscribe('modal', async (msg)=>{
  5098. const defaultPreviewType = isWeCom ? 'wecom-window' : undefined;
  5099. if (typeof options.handleModal !== 'function') {
  5100. return {
  5101. modalType: defaultPreviewType
  5102. };
  5103. }
  5104. const res = options.handleModal({
  5105. modalUrl: msg.modalUrl,
  5106. modalSize: msg.modalSize
  5107. });
  5108. return {
  5109. modalType: res === false ? 'iframe' : defaultPreviewType
  5110. };
  5111. });
  5112. return publicInstance;
  5113. }
  5114. return {
  5115. /**
  5116. * 创建 open-data frame 组件
  5117. */ createOpenDataFrame
  5118. };
  5119. }
  5120. /**
  5121. * 显示确认安全网关配置页面。
  5122. *
  5123. * 在桌面端页面以 iframe 弹窗的形式覆盖在页面上;在移动端页面将跳转至确认页面,返回后页面需要主动确认 confirm_id 的确认情况。
  5124. */ function showSecurityGatewayConfirmModal(options) {
  5125. const url = new URL('https://open.work.weixin.qq.com/wwopen/secureGateway/confirm');
  5126. url.searchParams.set('confirm_id', options.confirmId);
  5127. if (isIOS || isAndroid) {
  5128. location.href = url.href;
  5129. return;
  5130. }
  5131. url.searchParams.set('modal', 'true');
  5132. const client = showModalFrame(url.href, (msg)=>{
  5133. switch(msg.type){
  5134. case 'call':
  5135. return handleCallMsg(msg, options);
  5136. case 'close':
  5137. return;
  5138. default:
  5139. throw new Error(`Unknown message type '${msg.type}'`);
  5140. }
  5141. });
  5142. return {
  5143. /**
  5144. * 弹窗面板的 iframe 元素
  5145. */ el: client.el,
  5146. /**
  5147. * 卸载弹窗面板
  5148. */ unmount () {
  5149. client.dispose();
  5150. client.el.parentNode?.removeChild(client.el);
  5151. }
  5152. };
  5153. }
  5154. const SDK_VERSION = "2.3.1";
  5155. exports.WWLoginType = void 0;
  5156. (function(WWLoginType) {
  5157. /**
  5158. * [第三方应用登录](#45846)
  5159. */ WWLoginType["serviceApp"] = "ServiceApp";
  5160. /**
  5161. * [企业自建应用登录](/document/path/98151)、[服务商代开发应用登录](/document/path/98173)
  5162. */ WWLoginType["corpApp"] = "CorpApp";
  5163. })(exports.WWLoginType || (exports.WWLoginType = {}));
  5164. exports.WWLoginLangType = void 0;
  5165. (function(WWLoginLangType) {
  5166. /**
  5167. * 中文
  5168. */ WWLoginLangType["zh"] = "zh";
  5169. /**
  5170. * 英文
  5171. */ WWLoginLangType["en"] = "en";
  5172. })(exports.WWLoginLangType || (exports.WWLoginLangType = {}));
  5173. exports.WWLoginRedirectType = void 0;
  5174. (function(WWLoginRedirectType) {
  5175. /**
  5176. * 默认 `top window` 顶层页面跳转
  5177. */ WWLoginRedirectType["top"] = "top";
  5178. /**
  5179. * 通过 `onLoginSuccess` 回调用户授权 `code`,开发者自行处理跳转
  5180. */ WWLoginRedirectType["callback"] = "callback";
  5181. /**
  5182. * 登录组件跳转
  5183. */ WWLoginRedirectType["self"] = "self";
  5184. })(exports.WWLoginRedirectType || (exports.WWLoginRedirectType = {}));
  5185. exports.WWLoginPanelSizeType = void 0;
  5186. (function(WWLoginPanelSizeType) {
  5187. /**
  5188. * 默认: 480x416px
  5189. */ WWLoginPanelSizeType["middle"] = "middle";
  5190. /**
  5191. * 小尺寸: 320x380px
  5192. */ WWLoginPanelSizeType["small"] = "small";
  5193. })(exports.WWLoginPanelSizeType || (exports.WWLoginPanelSizeType = {}));
  5194. const PANEL_SIZE = {
  5195. [exports.WWLoginPanelSizeType.middle]: [
  5196. '480px',
  5197. '416px'
  5198. ],
  5199. [exports.WWLoginPanelSizeType.small]: [
  5200. '320px',
  5201. '380px'
  5202. ]
  5203. };
  5204. /**
  5205. * 初始化企业微信Web登录组件,创建登录面板。
  5206. *
  5207. * @example
  5208. * ```ts
  5209. * // 初始化登录组件
  5210. * const wwLogin = ww.createWWLoginPanel({
  5211. * el: '#ww_login',
  5212. * params: {
  5213. * login_type: 'CorpApp',
  5214. * appid: 'wwbbb6a7b539f2xxxxx',
  5215. * agentid: '10000xx',
  5216. * redirect_uri: 'https://work.weixin.qq.com',
  5217. * state: 'loginState',
  5218. * redirect_type: 'callback',
  5219. * },
  5220. * onCheckWeComLogin({ isWeComLogin }) {
  5221. * console.log(isWeComLogin)
  5222. * },
  5223. * onLoginSuccess({ code }) {
  5224. * console.log({ code })
  5225. * },
  5226. * onLoginFail(err) {
  5227. * console.log(err)
  5228. * },
  5229. * })
  5230. * ```
  5231. */ function createWWLoginPanel(options) {
  5232. const { width, height } = getPanelSize(options.params?.panel_size);
  5233. const iframeEl = createTransparentIFrame(options.el);
  5234. const { style } = iframeEl;
  5235. style.width = width;
  5236. style.height = height;
  5237. const { dispose } = useIframeClient(iframeEl, 'https://login.work.weixin.qq.com', (msg)=>{
  5238. if (msg.type === 'call') {
  5239. return handleCallMsg(msg, options);
  5240. }
  5241. throw new Error(`Unknown message type '${msg.type}'`);
  5242. });
  5243. const url = new URL('https://login.work.weixin.qq.com/wwlogin/sso/login');
  5244. for (const key of Object.keys(options.params || {})){
  5245. url.searchParams.set(key, options.params[key]);
  5246. }
  5247. url.searchParams.set('version', SDK_VERSION);
  5248. iframeEl.src = url.href;
  5249. return {
  5250. el: iframeEl,
  5251. unmount () {
  5252. dispose();
  5253. iframeEl.parentNode?.removeChild(iframeEl);
  5254. }
  5255. };
  5256. }
  5257. function getPanelSize(panelSizeType = exports.WWLoginPanelSizeType.middle) {
  5258. const size = PANEL_SIZE[panelSizeType] || PANEL_SIZE[exports.WWLoginPanelSizeType.middle];
  5259. return {
  5260. width: size[0],
  5261. height: size[1]
  5262. };
  5263. }
  5264. function createSingleton(factory) {
  5265. const map = new WeakMap();
  5266. return (object, ...args)=>{
  5267. if (!map.has(object)) {
  5268. map.set(object, factory(object, ...args));
  5269. }
  5270. return map.get(object);
  5271. };
  5272. }
  5273. function createWeakRef(target) {
  5274. if (typeof WeakRef !== 'undefined') {
  5275. return new WeakRef(target);
  5276. }
  5277. return {
  5278. deref: ()=>target
  5279. };
  5280. }
  5281. function createPlugin(factory) {
  5282. return createSingleton((instance)=>{
  5283. const context = getPluginContext(instance);
  5284. if (!context) {
  5285. throw new TypeError('Illegal invocation');
  5286. }
  5287. return factory(context);
  5288. });
  5289. }
  5290. const useRefManager = createPlugin(({ frame, invoke, subscribe })=>{
  5291. const refid2refMap = new Map();
  5292. const refid2eventMap = new Map();
  5293. subscribe('ref.event', (msg)=>{
  5294. const subscribers = refid2eventMap.get(msg.refId);
  5295. if (!subscribers) {
  5296. return;
  5297. }
  5298. for (const fn of subscribers){
  5299. fn(msg.data);
  5300. }
  5301. });
  5302. subscribe('refDispose', (msg)=>{
  5303. refid2refMap.delete(msg.refId);
  5304. refid2eventMap.delete(msg.refId);
  5305. });
  5306. async function getRef(name) {
  5307. const res = await invoke({
  5308. type: 'ref.get',
  5309. name
  5310. });
  5311. if (!res) {
  5312. return;
  5313. }
  5314. const ref = refid2refMap.get(res.refId)?.deref();
  5315. if (ref) {
  5316. return ref;
  5317. }
  5318. const newRef = createRef(res.refId);
  5319. refid2refMap.set(res.refId, createWeakRef(newRef));
  5320. return newRef;
  5321. }
  5322. function createRef(refId) {
  5323. if (!refid2eventMap.has(refId)) {
  5324. refid2eventMap.set(refId, []);
  5325. }
  5326. const subscribers = refid2eventMap.get(refId);
  5327. function invokeRef(name, data, opts) {
  5328. return invoke({
  5329. type: 'ref.call',
  5330. refId,
  5331. name,
  5332. data
  5333. }, opts);
  5334. }
  5335. function subscribeRef(fn) {
  5336. subscribers.push(fn);
  5337. return ()=>{
  5338. const index = subscribers.indexOf(fn);
  5339. if (index >= 0) {
  5340. subscribers.splice(index, 1);
  5341. }
  5342. };
  5343. }
  5344. return {
  5345. frame,
  5346. invoke: invokeRef,
  5347. subscribe: subscribeRef
  5348. };
  5349. }
  5350. return {
  5351. get: getRef
  5352. };
  5353. });
  5354. function createSymbolKey(name) {
  5355. if (typeof Symbol === 'function') {
  5356. return Symbol(name);
  5357. }
  5358. return name;
  5359. }
  5360. /// <reference types="../../../types/arraybuffer.d.ts" />
  5361. const MIN_PAGE_SIZE = 64 * 1024;
  5362. const MAX_PAGE_SIZE = 1024 * 1024;
  5363. class BufferList {
  5364. concat() {
  5365. if (this.list.length === 1) {
  5366. return stabilizeBufferItem(this.current);
  5367. }
  5368. const result = new Uint8Array(this.list.reduce((total, item)=>total + item.offset, 0));
  5369. this.list.reduce((offset, item)=>{
  5370. result.set(new Uint8Array(stabilizeBufferItem(item)), offset);
  5371. return offset + item.offset;
  5372. }, 0);
  5373. return result.buffer;
  5374. }
  5375. ensureCapacity(size) {
  5376. const current = this.current;
  5377. const minNewSize = current.offset + size;
  5378. if (minNewSize <= current.size) {
  5379. return;
  5380. }
  5381. const buffer = current.buffer;
  5382. if (!buffer.resizable || minNewSize > buffer.maxByteLength) {
  5383. this.current = this.createBufferItem();
  5384. this.list.push(this.current);
  5385. } else {
  5386. current.size = Math.min(current.size * 2, buffer.maxByteLength);
  5387. buffer.resize(current.size);
  5388. }
  5389. }
  5390. createBufferItem() {
  5391. const buffer = new ArrayBuffer(MIN_PAGE_SIZE, {
  5392. maxByteLength: MAX_PAGE_SIZE
  5393. });
  5394. return {
  5395. view: new DataView(buffer),
  5396. buffer,
  5397. size: buffer.byteLength,
  5398. offset: 0
  5399. };
  5400. }
  5401. constructor(){
  5402. _define_property(this, "list", void 0);
  5403. _define_property(this, "current", void 0);
  5404. this.current = this.createBufferItem();
  5405. this.list = [
  5406. this.current
  5407. ];
  5408. }
  5409. }
  5410. function stabilizeBufferItem(item) {
  5411. if (item.offset >= item.size) {
  5412. return item.buffer;
  5413. }
  5414. if (item.buffer.resizable && item.buffer.transfer) {
  5415. return item.buffer.transfer(item.offset);
  5416. }
  5417. return item.buffer.slice(0, item.offset);
  5418. }
  5419. var VariantType;
  5420. (function(VariantType) {
  5421. VariantType[VariantType["int32"] = 1] = "int32";
  5422. VariantType[VariantType["float64"] = 2] = "float64";
  5423. VariantType[VariantType["boolean"] = 3] = "boolean";
  5424. VariantType[VariantType["null"] = 4] = "null";
  5425. VariantType[VariantType["undefined"] = 5] = "undefined";
  5426. VariantType[VariantType["valueRef"] = 6] = "valueRef";
  5427. })(VariantType || (VariantType = {}));
  5428. const MIN_INT32 = -Math.pow(2, 31);
  5429. const MAX_INT32 = Math.pow(2, 31);
  5430. function create() {
  5431. return {
  5432. buffer: new BufferList(),
  5433. values: [],
  5434. stringIndexMap: new Map()
  5435. };
  5436. }
  5437. function encode(state) {
  5438. return {
  5439. buffer: state.buffer.concat(),
  5440. values: state.values
  5441. };
  5442. }
  5443. function uint8(state, value) {
  5444. state.buffer.ensureCapacity(1);
  5445. const current = state.buffer.current;
  5446. current.view.setUint8(current.offset, value);
  5447. current.offset += 1;
  5448. }
  5449. function int32(state, value) {
  5450. state.buffer.ensureCapacity(4);
  5451. const current = state.buffer.current;
  5452. current.view.setInt32(current.offset, value);
  5453. current.offset += 4;
  5454. }
  5455. function uint32(state, value) {
  5456. state.buffer.ensureCapacity(4);
  5457. const current = state.buffer.current;
  5458. current.view.setUint32(current.offset, value);
  5459. current.offset += 4;
  5460. }
  5461. function float64(state, value) {
  5462. state.buffer.ensureCapacity(8);
  5463. const current = state.buffer.current;
  5464. current.view.setFloat64(current.offset, value);
  5465. current.offset += 8;
  5466. }
  5467. function string(state, value) {
  5468. let index = state.stringIndexMap.get(value);
  5469. if (!index) {
  5470. index = state.values.push(value);
  5471. state.stringIndexMap.set(value, index);
  5472. }
  5473. uint32(state, index - 1);
  5474. }
  5475. function unknown(state, value) {
  5476. uint32(state, state.values.push(value) - 1);
  5477. }
  5478. function variant(state, value) {
  5479. if (value === null) {
  5480. uint8(state, 4);
  5481. return;
  5482. }
  5483. switch(typeof value){
  5484. case 'number':
  5485. if (isInt32(value)) {
  5486. uint8(state, 1);
  5487. int32(state, value);
  5488. break;
  5489. }
  5490. uint8(state, 2);
  5491. float64(state, value);
  5492. break;
  5493. case 'string':
  5494. uint8(state, 6);
  5495. string(state, value);
  5496. break;
  5497. case 'boolean':
  5498. uint8(state, 3);
  5499. uint8(state, value ? 1 : 0);
  5500. break;
  5501. case 'undefined':
  5502. uint8(state, 5);
  5503. break;
  5504. default:
  5505. uint8(state, 6);
  5506. unknown(state, value);
  5507. break;
  5508. }
  5509. }
  5510. function isInt32(value) {
  5511. if (!Number.isInteger(value)) {
  5512. return false;
  5513. }
  5514. return MIN_INT32 <= value && value < MAX_INT32;
  5515. }
  5516. var CommandType;
  5517. (function(CommandType) {
  5518. CommandType[CommandType["set"] = 1] = "set";
  5519. CommandType[CommandType["call"] = 2] = "call";
  5520. CommandType[CommandType["dispose"] = 3] = "dispose";
  5521. })(CommandType || (CommandType = {}));
  5522. var ValueType;
  5523. (function(ValueType) {
  5524. ValueType[ValueType["value"] = 1] = "value";
  5525. ValueType[ValueType["ref"] = 2] = "ref";
  5526. })(ValueType || (ValueType = {}));
  5527. const KEY_REFLECT_ID = createSymbolKey('__WECOM_REFLECT_ID__');
  5528. const useReflectStore = createPlugin(({ invoke })=>{
  5529. const finalizationRegistry = typeof FinalizationRegistry === 'function' ? new FinalizationRegistry(cleanup) : null;
  5530. // WHY: weakSet.has(obj) + obj[key] 速度远快于 weakMap.get(obj)
  5531. const reflectObjectSet = new WeakSet();
  5532. let nextReflectId = 1;
  5533. const flushPromise = Promise.resolve();
  5534. let flushPending = false;
  5535. let writer = create();
  5536. function bind(obj, reflectId = genReflectId()) {
  5537. if (reflectObjectSet.has(obj)) {
  5538. return obj[KEY_REFLECT_ID];
  5539. }
  5540. obj[KEY_REFLECT_ID] = reflectId;
  5541. reflectObjectSet.add(obj);
  5542. finalizationRegistry?.register(obj, reflectId);
  5543. return reflectId;
  5544. }
  5545. function set(obj, name, value) {
  5546. const refId = obj[KEY_REFLECT_ID];
  5547. if (!refId) {
  5548. throw new TypeError('Illegal invocation');
  5549. }
  5550. uint8(writer, 1);
  5551. uint32(writer, refId);
  5552. string(writer, name);
  5553. writeCustomValue(value);
  5554. enqueueFlush();
  5555. }
  5556. function call(obj, name, args, result) {
  5557. const refId = obj[KEY_REFLECT_ID];
  5558. if (!refId) {
  5559. throw new TypeError('Illegal invocation');
  5560. }
  5561. uint8(writer, 2);
  5562. uint32(writer, refId);
  5563. string(writer, name);
  5564. uint32(writer, (result ? result[KEY_REFLECT_ID] : 0) ?? 0);
  5565. uint32(writer, args.length);
  5566. args.forEach(writeCustomValue);
  5567. enqueueFlush();
  5568. }
  5569. function cleanup(refId) {
  5570. uint8(writer, 3);
  5571. uint32(writer, refId);
  5572. enqueueFlush();
  5573. }
  5574. function writeCustomValue(value) {
  5575. if (reflectObjectSet.has(value)) {
  5576. uint8(writer, 2);
  5577. uint32(writer, value[KEY_REFLECT_ID]);
  5578. } else {
  5579. uint8(writer, 1);
  5580. variant(writer, value);
  5581. }
  5582. }
  5583. function enqueueFlush() {
  5584. if (flushPending) {
  5585. return;
  5586. }
  5587. flushPending = true;
  5588. flushPromise.then(flush);
  5589. }
  5590. function flush() {
  5591. flushPending = false;
  5592. const commands = encode(writer);
  5593. writer = create();
  5594. invoke({
  5595. type: 'reflect.command',
  5596. commands
  5597. }, {
  5598. serialize: false,
  5599. dropResult: true,
  5600. transfer: [
  5601. commands.buffer
  5602. ]
  5603. });
  5604. }
  5605. function genReflectId() {
  5606. return nextReflectId++;
  5607. }
  5608. return {
  5609. genReflectId,
  5610. bind,
  5611. set,
  5612. call
  5613. };
  5614. });
  5615. function _class_apply_descriptor_get(receiver, descriptor) {
  5616. if (descriptor.get) return descriptor.get.call(receiver);
  5617. return descriptor.value;
  5618. }
  5619. function _class_extract_field_descriptor(receiver, privateMap, action) {
  5620. if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
  5621. return privateMap.get(receiver);
  5622. }
  5623. function _class_private_field_get(receiver, privateMap) {
  5624. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
  5625. return _class_apply_descriptor_get(receiver, descriptor);
  5626. }
  5627. function _check_private_redeclaration(obj, privateCollection) {
  5628. if (privateCollection.has(obj)) {
  5629. throw new TypeError("Cannot initialize the same private elements twice on an object");
  5630. }
  5631. }
  5632. function _class_private_field_init(obj, privateMap, value) {
  5633. _check_private_redeclaration(obj, privateMap);
  5634. privateMap.set(obj, value);
  5635. }
  5636. function _class_apply_descriptor_set(receiver, descriptor, value) {
  5637. if (descriptor.set) descriptor.set.call(receiver, value);
  5638. else {
  5639. if (!descriptor.writable) {
  5640. // This should only throw in strict mode, but class bodies are
  5641. // always strict and private fields can only be used inside
  5642. // class bodies.
  5643. throw new TypeError("attempted to set read only private field");
  5644. }
  5645. descriptor.value = value;
  5646. }
  5647. }
  5648. function _class_private_field_set(receiver, privateMap, value) {
  5649. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
  5650. _class_apply_descriptor_set(receiver, descriptor, value);
  5651. return value;
  5652. }
  5653. const wrapper2NativeMap = new WeakMap();
  5654. const native2wrapperMap = new WeakMap();
  5655. function setNativeObject(wrapped, native) {
  5656. wrapper2NativeMap.set(wrapped, native);
  5657. native2wrapperMap.set(native, wrapped);
  5658. }
  5659. function toNativeValue(wrapped) {
  5660. if (wrapper2NativeMap.has(wrapped)) {
  5661. return wrapper2NativeMap.get(wrapped);
  5662. }
  5663. return wrapped;
  5664. }
  5665. function toWrappedValue(native) {
  5666. if (native2wrapperMap.has(native)) {
  5667. return native2wrapperMap.get(native);
  5668. }
  5669. return native;
  5670. }
  5671. const PLACEHOLDER_SRC = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
  5672. let placeholderImage = null;
  5673. function getPlaceholderImage() {
  5674. if (!placeholderImage) {
  5675. placeholderImage = new Image();
  5676. placeholderImage.src = PLACEHOLDER_SRC;
  5677. }
  5678. return placeholderImage;
  5679. }
  5680. var _src = /*#__PURE__*/ new WeakMap(), _complete = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap();
  5681. let _KEY_REFLECT_ID$3 = KEY_REFLECT_ID;
  5682. class ImageResource {
  5683. get src() {
  5684. return _class_private_field_get(this, _src);
  5685. }
  5686. get loading() {
  5687. return !_class_private_field_get(this, _complete);
  5688. }
  5689. get complete() {
  5690. return _class_private_field_get(this, _complete);
  5691. }
  5692. get error() {
  5693. return _class_private_field_get(this, _error);
  5694. }
  5695. __handleSettled(error) {
  5696. _class_private_field_set(this, _complete, true);
  5697. _class_private_field_set(this, _error, error);
  5698. if (error) {
  5699. safeRun(this.onerror, error);
  5700. } else {
  5701. safeRun(this.onload, undefined);
  5702. }
  5703. }
  5704. constructor(src){
  5705. _define_property(this, _KEY_REFLECT_ID$3, void 0);
  5706. _define_property(this, "onload", void 0);
  5707. _define_property(this, "onerror", void 0);
  5708. _class_private_field_init(this, _src, {
  5709. writable: true,
  5710. value: void 0
  5711. });
  5712. _class_private_field_init(this, _complete, {
  5713. writable: true,
  5714. value: false
  5715. });
  5716. _class_private_field_init(this, _error, {
  5717. writable: true,
  5718. value: void 0
  5719. });
  5720. _class_private_field_set(this, _src, src);
  5721. setNativeObject(this, getPlaceholderImage());
  5722. }
  5723. }
  5724. const useImageStore = createPlugin(({ frame, invoke, subscribe })=>{
  5725. const reflectStore = useReflectStore(frame);
  5726. const imageSettledHandlerMap = new Map();
  5727. function createImage(data, type) {
  5728. const res = new ImageResource(data);
  5729. const refId = reflectStore.bind(res);
  5730. invoke({
  5731. type: 'image.load',
  5732. refId,
  5733. data: getImageInfo(data, type)
  5734. }, {
  5735. serialize: typeof data === 'string'
  5736. });
  5737. imageSettledHandlerMap.set(refId, (msg)=>{
  5738. res.__handleSettled(msg.error);
  5739. });
  5740. return res;
  5741. }
  5742. function getImageInfo(data, mime) {
  5743. if (typeof data === 'string') {
  5744. return {
  5745. type: 'url',
  5746. src: data
  5747. };
  5748. }
  5749. return {
  5750. type: 'arraybuffer',
  5751. data,
  5752. mime
  5753. };
  5754. }
  5755. subscribe('image.settled', (msg)=>{
  5756. const handler = imageSettledHandlerMap.get(msg.refId);
  5757. imageSettledHandlerMap.delete(msg.refId);
  5758. if (handler) {
  5759. handler(msg);
  5760. }
  5761. });
  5762. return {
  5763. createImage
  5764. };
  5765. });
  5766. const useRefEventManager = createSingleton((ref)=>{
  5767. const listenerMap = new Map();
  5768. ref.subscribe((msg)=>{
  5769. if (msg.type !== 'event.trigger') {
  5770. return;
  5771. }
  5772. const listeners = listenerMap.get(`${msg.capture}|${msg.name}`);
  5773. if (!listeners?.size) {
  5774. return;
  5775. }
  5776. const event = createCustomEvent(msg.event);
  5777. for (const listener of Array.from(listeners)){
  5778. safeRun(listener, event);
  5779. }
  5780. });
  5781. function addListener(name, listener, options) {
  5782. const capture = typeof options === 'boolean' ? options : !!options?.capture;
  5783. if (!listenerMap.has(`${capture}|${name}`)) {
  5784. listenerMap.set(`${capture}|${name}`, new Set());
  5785. }
  5786. const listeners = listenerMap.get(`${capture}|${name}`);
  5787. if (!listeners.size) {
  5788. ref.invoke('event.subscribe', {
  5789. name,
  5790. capture
  5791. });
  5792. }
  5793. listeners.add(listener);
  5794. }
  5795. function removeListener(name, listener, options) {
  5796. const capture = typeof options === 'boolean' ? options : !!options?.capture;
  5797. if (!listenerMap.has(`${capture}|${name}`)) {
  5798. return;
  5799. }
  5800. const listeners = listenerMap.get(`${capture}|${name}`);
  5801. listeners.delete(listener);
  5802. if (!listeners.size) {
  5803. ref.invoke('event.unsubscribe', {
  5804. name,
  5805. capture
  5806. });
  5807. }
  5808. }
  5809. return {
  5810. addListener,
  5811. removeListener
  5812. };
  5813. });
  5814. function createCustomEvent(info) {
  5815. const event = new CustomEvent(info.type, {
  5816. detail: info.detail
  5817. });
  5818. for (const key of Object.keys(info)){
  5819. if (!(key in event)) {
  5820. event[key] = info[key];
  5821. }
  5822. }
  5823. Object.defineProperties(event, {
  5824. target: {
  5825. value: info.target
  5826. },
  5827. currentTarget: {
  5828. value: info.currentTarget
  5829. }
  5830. });
  5831. return event;
  5832. }
  5833. var _store$1 = /*#__PURE__*/ new WeakMap(), _native$1 = /*#__PURE__*/ new WeakMap();
  5834. let _KEY_REFLECT_ID$2 = KEY_REFLECT_ID;
  5835. class FrameCanvasPattern {
  5836. setTransform(matrix) {
  5837. _class_private_field_get(this, _native$1).setTransform(matrix);
  5838. _class_private_field_get(this, _store$1).call(this, 'setTransform', [
  5839. matrix
  5840. ]);
  5841. }
  5842. constructor(store, native){
  5843. _define_property(this, _KEY_REFLECT_ID$2, void 0);
  5844. _class_private_field_init(this, _store$1, {
  5845. writable: true,
  5846. value: void 0
  5847. });
  5848. _class_private_field_init(this, _native$1, {
  5849. writable: true,
  5850. value: void 0
  5851. });
  5852. _class_private_field_set(this, _store$1, store);
  5853. _class_private_field_set(this, _native$1, native);
  5854. store.bind(this);
  5855. setNativeObject(this, native);
  5856. }
  5857. }
  5858. var _store1 = /*#__PURE__*/ new WeakMap(), _native1 = /*#__PURE__*/ new WeakMap();
  5859. let _KEY_REFLECT_ID1 = KEY_REFLECT_ID;
  5860. class FrameCanvasGradient {
  5861. addColorStop(offset, color) {
  5862. _class_private_field_get(this, _native1).addColorStop(offset, color);
  5863. _class_private_field_get(this, _store1).call(this, 'addColorStop', [
  5864. offset,
  5865. color
  5866. ]);
  5867. }
  5868. constructor(store, native){
  5869. _define_property(this, _KEY_REFLECT_ID1, void 0);
  5870. _class_private_field_init(this, _store1, {
  5871. writable: true,
  5872. value: void 0
  5873. });
  5874. _class_private_field_init(this, _native1, {
  5875. writable: true,
  5876. value: void 0
  5877. });
  5878. _class_private_field_set(this, _store1, store);
  5879. _class_private_field_set(this, _native1, native);
  5880. store.bind(this);
  5881. setNativeObject(this, native);
  5882. }
  5883. }
  5884. /**
  5885. * 纯样式属性
  5886. *
  5887. * 修改这些属性不会改变 CANVAS_LOCAL_METHODS 的表现,因此无需映射到 native object
  5888. */ const CANVAS_STYLE_PROPS = [
  5889. 'fillStyle',
  5890. 'filter',
  5891. 'globalAlpha',
  5892. 'globalCompositeOperation',
  5893. 'imageSmoothingEnabled',
  5894. 'imageSmoothingQuality',
  5895. 'shadowBlur',
  5896. 'shadowColor',
  5897. 'shadowOffsetX',
  5898. 'shadowOffsetY',
  5899. 'strokeStyle'
  5900. ];
  5901. const CANVAS_CONFIG_PROPS = [
  5902. 'direction',
  5903. 'font',
  5904. 'fontKerning',
  5905. 'fontStretch',
  5906. 'fontVariantCaps',
  5907. 'letterSpacing',
  5908. 'lineCap',
  5909. 'lineDashOffset',
  5910. 'lineJoin',
  5911. 'lineWidth',
  5912. 'miterLimit',
  5913. 'textAlign',
  5914. 'textBaseline',
  5915. 'textRendering',
  5916. 'wordSpacing'
  5917. ];
  5918. const CANVAS_CONFIG_METHODS = [
  5919. 'arc',
  5920. 'arcTo',
  5921. 'beginPath',
  5922. 'bezierCurveTo',
  5923. 'clip',
  5924. 'closePath',
  5925. 'ellipse',
  5926. 'lineTo',
  5927. 'moveTo',
  5928. 'quadraticCurveTo',
  5929. 'rect',
  5930. 'reset',
  5931. 'resetTransform',
  5932. 'restore',
  5933. 'rotate',
  5934. 'roundRect',
  5935. 'save',
  5936. 'scale',
  5937. 'setLineDash',
  5938. 'setTransform',
  5939. 'transform',
  5940. 'translate'
  5941. ];
  5942. const CANVAS_DRAW_METHODS = [
  5943. 'clearRect',
  5944. 'drawFocusIfNeeded',
  5945. 'drawImage',
  5946. 'fill',
  5947. 'fillRect',
  5948. 'fillText',
  5949. 'stroke',
  5950. 'strokeRect',
  5951. 'strokeText'
  5952. ];
  5953. const CANVAS_LOCAL_METHODS = [
  5954. 'getContextAttributes',
  5955. 'getLineDash',
  5956. 'getTransform',
  5957. 'isContextLost',
  5958. 'isPointInPath',
  5959. 'isPointInStroke',
  5960. 'measureText'
  5961. ];
  5962. const CANVAS_FACTORY_METHODS = [
  5963. [
  5964. 'createConicGradient',
  5965. FrameCanvasGradient
  5966. ],
  5967. [
  5968. 'createLinearGradient',
  5969. FrameCanvasGradient
  5970. ],
  5971. [
  5972. 'createPattern',
  5973. FrameCanvasPattern
  5974. ],
  5975. [
  5976. 'createRadialGradient',
  5977. FrameCanvasGradient
  5978. ]
  5979. ];
  5980. const KEY_INTERNAL = createSymbolKey('__WECOM_INTERNAL__');
  5981. const createFrameContext = createSingleton((canvas, store, native)=>new FrameCanvasRenderingContext2D(canvas, store, native));
  5982. let _KEY_INTERNAL = KEY_INTERNAL, _KEY_REFLECT_ID$1 = KEY_REFLECT_ID;
  5983. class FrameCanvasRenderingContext2D {
  5984. constructor(canvas, store, native){
  5985. _define_property(this, "canvas", void 0);
  5986. _define_property(this, _KEY_INTERNAL, void 0);
  5987. _define_property(this, _KEY_REFLECT_ID$1, void 0);
  5988. this.canvas = canvas;
  5989. this[KEY_INTERNAL] = {
  5990. store,
  5991. native,
  5992. props: Object.create(null)
  5993. };
  5994. store.bind(this);
  5995. setNativeObject(this, native);
  5996. }
  5997. }
  5998. const FrameContextProto = FrameCanvasRenderingContext2D.prototype;
  5999. for (const name of CANVAS_STYLE_PROPS){
  6000. Object.defineProperty(FrameContextProto, name, {
  6001. configurable: true,
  6002. enumerable: true,
  6003. get () {
  6004. const { native, props } = this[KEY_INTERNAL];
  6005. return props[name] ?? toWrappedValue(native[name]);
  6006. },
  6007. set (value) {
  6008. const { store, props } = this[KEY_INTERNAL];
  6009. props[name] = toNativeValue(value);
  6010. store.set(this, name, value);
  6011. }
  6012. });
  6013. }
  6014. for (const name of CANVAS_CONFIG_PROPS){
  6015. Object.defineProperty(FrameContextProto, name, {
  6016. configurable: true,
  6017. enumerable: true,
  6018. get () {
  6019. return toWrappedValue(this[KEY_INTERNAL].native[name]);
  6020. },
  6021. set (value) {
  6022. const { store, native } = this[KEY_INTERNAL];
  6023. native[name] = toNativeValue(value);
  6024. store.set(this, name, value);
  6025. }
  6026. });
  6027. }
  6028. for (const name of CANVAS_LOCAL_METHODS){
  6029. FrameContextProto[name] = function(...args) {
  6030. const { native } = this[KEY_INTERNAL];
  6031. return callNative(native, name, args);
  6032. };
  6033. }
  6034. for (const name of CANVAS_CONFIG_METHODS){
  6035. FrameContextProto[name] = function(...args) {
  6036. const { store, native } = this[KEY_INTERNAL];
  6037. callNative(native, name, args);
  6038. store.call(this, name, args);
  6039. };
  6040. }
  6041. for (const name of CANVAS_DRAW_METHODS){
  6042. FrameContextProto[name] = function(...args) {
  6043. const { store } = this[KEY_INTERNAL];
  6044. store.call(this, name, args);
  6045. };
  6046. }
  6047. for (const [name, Ctor] of CANVAS_FACTORY_METHODS){
  6048. FrameContextProto[name] = function(...args) {
  6049. const { store, native } = this[KEY_INTERNAL];
  6050. const nativeRes = callNative(native, name, args);
  6051. const frameRes = new Ctor(store, nativeRes);
  6052. store.call(this, name, args, frameRes);
  6053. return frameRes;
  6054. };
  6055. }
  6056. function callNative(native, name, args) {
  6057. switch(args.length){
  6058. case 1:
  6059. return native[name](args[0]);
  6060. case 2:
  6061. return native[name](args[0], args[1]);
  6062. case 3:
  6063. return native[name](args[0], args[1], args[2]);
  6064. case 4:
  6065. return native[name](args[0], args[1], args[2], args[3]);
  6066. case 5:
  6067. return native[name](args[0], args[1], args[2], args[3], args[4]);
  6068. case 6:
  6069. return native[name](args[0], args[1], args[2], args[3], args[4], args[5]);
  6070. default:
  6071. return native[name](...args);
  6072. }
  6073. }
  6074. var _native = /*#__PURE__*/ new WeakMap(), _store = /*#__PURE__*/ new WeakMap(), _imageStore = /*#__PURE__*/ new WeakMap(), _refEvent = /*#__PURE__*/ new WeakMap(), _context = /*#__PURE__*/ new WeakMap();
  6075. let _KEY_REFLECT_ID = KEY_REFLECT_ID;
  6076. class FrameCanvas {
  6077. /**
  6078. * canvas 元素宽度
  6079. */ get width() {
  6080. return _class_private_field_get(this, _native).width;
  6081. }
  6082. set width(value) {
  6083. _class_private_field_get(this, _native).width = value;
  6084. _class_private_field_get(this, _store).set(this, 'width', value);
  6085. }
  6086. /**
  6087. * canvas 元素高度
  6088. */ get height() {
  6089. return _class_private_field_get(this, _native).height;
  6090. }
  6091. set height(value) {
  6092. _class_private_field_get(this, _native).height = value;
  6093. _class_private_field_get(this, _store).set(this, 'height', value);
  6094. }
  6095. createImage(data, type) {
  6096. return _class_private_field_get(this, _imageStore).createImage(data, type);
  6097. }
  6098. /**
  6099. * 获取 canvas 的上下文
  6100. *
  6101. * @param type 上下文类型,目前只支持 2d
  6102. * @param attrs 渲染上下文配置
  6103. */ getContext(type, attrs) {
  6104. if (type !== '2d') {
  6105. throw new Error(`Failed to execute 'getContext' on 'FrameCanvas': The provided value '${type}' is not a valid enum value of type RenderingContextType`);
  6106. }
  6107. if (_class_private_field_get(this, _context)) {
  6108. return _class_private_field_get(this, _context);
  6109. }
  6110. const nativeContext = _class_private_field_get(this, _native).getContext(type, attrs);
  6111. _class_private_field_set(this, _context, createFrameContext(this, _class_private_field_get(this, _store), nativeContext));
  6112. _class_private_field_get(this, _store).call(this, 'getContext', [
  6113. type,
  6114. attrs
  6115. ], _class_private_field_get(this, _context));
  6116. return _class_private_field_get(this, _context);
  6117. }
  6118. addEventListener(type, listener, options) {
  6119. _class_private_field_get(this, _refEvent).addListener(type, listener, options);
  6120. }
  6121. removeEventListener(type, listener, options) {
  6122. _class_private_field_get(this, _refEvent).removeListener(type, listener, options);
  6123. }
  6124. constructor(ref, refId, info){
  6125. /** @internal */ _define_property(this, _KEY_REFLECT_ID, void 0);
  6126. _class_private_field_init(this, _native, {
  6127. writable: true,
  6128. value: void 0
  6129. });
  6130. _class_private_field_init(this, _store, {
  6131. writable: true,
  6132. value: void 0
  6133. });
  6134. _class_private_field_init(this, _imageStore, {
  6135. writable: true,
  6136. value: void 0
  6137. });
  6138. _class_private_field_init(this, _refEvent, {
  6139. writable: true,
  6140. value: void 0
  6141. });
  6142. _class_private_field_init(this, _context, {
  6143. writable: true,
  6144. value: void 0
  6145. });
  6146. _class_private_field_set(this, _native, new OffscreenCanvas(info.width, info.height));
  6147. _class_private_field_set(this, _store, useReflectStore(ref.frame));
  6148. _class_private_field_get(this, _store).bind(this, refId);
  6149. _class_private_field_set(this, _imageStore, useImageStore(ref.frame));
  6150. _class_private_field_set(this, _refEvent, useRefEventManager(ref));
  6151. setNativeObject(this, _class_private_field_get(this, _native));
  6152. }
  6153. }
  6154. const ref2canvasMap = new WeakMap();
  6155. const getCanvasId = createSingleton((ref)=>{
  6156. const { genReflectId } = useReflectStore(ref.frame);
  6157. return genReflectId();
  6158. });
  6159. /**
  6160. * 获取 open-data frame 组件内的 canvas 元素。
  6161. *
  6162. * @param instance open-data frame 组件实例
  6163. * @param refName 模板引用名称
  6164. *
  6165. * @example
  6166. * ```ts
  6167. * const canvas = await ww.getCanvas(frame, 'canvas')
  6168. * const context = canvas.getContext('2d')
  6169. * ```
  6170. */ async function getCanvas(instance, refName) {
  6171. const { get: getRef } = useRefManager(instance);
  6172. const ref = await getRef(refName);
  6173. if (!ref) {
  6174. return;
  6175. }
  6176. if (ref2canvasMap.has(ref)) {
  6177. return ref2canvasMap.get(ref);
  6178. }
  6179. const refId = getCanvasId(ref);
  6180. const info = await ref.invoke('bind', {
  6181. refId
  6182. });
  6183. if (!info) {
  6184. return;
  6185. }
  6186. if (!ref2canvasMap.has(ref)) {
  6187. ref2canvasMap.set(ref, new FrameCanvas(ref, refId, info));
  6188. }
  6189. return ref2canvasMap.get(ref);
  6190. }
  6191. const getScrollViewContext = createSingleton((ref)=>{
  6192. return {
  6193. scrollTo (options) {
  6194. ref.invoke('scrollTo', options);
  6195. },
  6196. scrollIntoView (selector, options) {
  6197. ref.invoke('scrollIntoView', {
  6198. selector,
  6199. options
  6200. });
  6201. }
  6202. };
  6203. });
  6204. /**
  6205. * 创建 open-data frame 组件内指定 scroll-view 元素的上下文。
  6206. *
  6207. * @param instance open-data frame 组件实例
  6208. * @param refName 模板引用名称
  6209. *
  6210. * @example
  6211. * ```ts
  6212. * const scrollView = await ww.createScrollViewContext(instance, 'scroll-view')
  6213. *
  6214. * scrollView.scrollTo({ top: 100 })
  6215. * ```
  6216. */ async function createScrollViewContext(instance, refName) {
  6217. const { get: getRef } = useRefManager(instance);
  6218. const ref = await getRef(refName);
  6219. if (!ref) {
  6220. return;
  6221. }
  6222. return getScrollViewContext(ref);
  6223. }
  6224. /**
  6225. * 获取节点的相关信息
  6226. *
  6227. * @param instance open-data frame 组件实例
  6228. * @param refName 模板引用名称
  6229. * @param fields 需要获取的字段
  6230. *
  6231. * @example
  6232. * ```ts
  6233. * ww.getNodeInfo(instance, 'node-ref')
  6234. * ```
  6235. */ async function getNodeInfo(instance, refName, fields) {
  6236. const { get: getRef } = useRefManager(instance);
  6237. const ref = await getRef(refName);
  6238. if (!ref) {
  6239. return;
  6240. }
  6241. return ref.invoke('nodeInfo.get', {
  6242. fields
  6243. });
  6244. }
  6245. /**
  6246. * From https://gist.github.com/schacon/12703
  6247. */ function hex_sha1(s) {
  6248. return rstr2hex(rstr_sha1(s));
  6249. }
  6250. /**
  6251. * Calculate the SHA1 of a raw string
  6252. */ function rstr_sha1(s) {
  6253. return binb2rstr(binb_sha1(rstr2binb(s), s.length * 8));
  6254. }
  6255. /**
  6256. * Convert a raw string to a hex string
  6257. */ function rstr2hex(input) {
  6258. const hex_tab = '0123456789abcdef';
  6259. let output = '';
  6260. let x;
  6261. for(let i = 0; i < input.length; i++){
  6262. x = input.charCodeAt(i);
  6263. output += hex_tab.charAt(x >>> 4 & 0x0f) + hex_tab.charAt(x & 0x0f);
  6264. }
  6265. return output;
  6266. }
  6267. /**
  6268. * Convert a raw string to an array of big-endian words
  6269. * Characters >255 have their high-byte silently ignored.
  6270. */ function rstr2binb(input) {
  6271. const output = new Array(input.length >> 2);
  6272. for(let i = 0; i < output.length; i++)output[i] = 0;
  6273. for(let i = 0; i < input.length * 8; i += 8)output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << 24 - i % 32;
  6274. return output;
  6275. }
  6276. /**
  6277. * Convert an array of little-endian words to a string
  6278. */ function binb2rstr(input) {
  6279. let output = '';
  6280. for(let i = 0; i < input.length * 32; i += 8)output += String.fromCharCode(input[i >> 5] >>> 24 - i % 32 & 0xff);
  6281. return output;
  6282. }
  6283. /**
  6284. * Calculate the SHA-1 of an array of big-endian words, and a bit length
  6285. */ function binb_sha1(x, len) {
  6286. /* append padding */ x[len >> 5] |= 0x80 << 24 - len % 32;
  6287. x[(len + 64 >> 9 << 4) + 15] = len;
  6288. const w = new Array(80);
  6289. let a = 1732584193;
  6290. let b = -271733879;
  6291. let c = -1732584194;
  6292. let d = 271733878;
  6293. let e = -1009589776;
  6294. for(let i = 0; i < x.length; i += 16){
  6295. const olda = a;
  6296. const oldb = b;
  6297. const oldc = c;
  6298. const oldd = d;
  6299. const olde = e;
  6300. for(let j = 0; j < 80; j++){
  6301. if (j < 16) w[j] = x[i + j];
  6302. else w[j] = bit_rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
  6303. const t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
  6304. e = d;
  6305. d = c;
  6306. c = bit_rol(b, 30);
  6307. b = a;
  6308. a = t;
  6309. }
  6310. a = safe_add(a, olda);
  6311. b = safe_add(b, oldb);
  6312. c = safe_add(c, oldc);
  6313. d = safe_add(d, oldd);
  6314. e = safe_add(e, olde);
  6315. }
  6316. return [
  6317. a,
  6318. b,
  6319. c,
  6320. d,
  6321. e
  6322. ];
  6323. }
  6324. /**
  6325. * Perform the appropriate triplet combination function for the current
  6326. * iteration
  6327. */ function sha1_ft(t, b, c, d) {
  6328. if (t < 20) return b & c | ~b & d;
  6329. if (t < 40) return b ^ c ^ d;
  6330. if (t < 60) return b & c | b & d | c & d;
  6331. return b ^ c ^ d;
  6332. }
  6333. /**
  6334. * Determine the appropriate additive constant for the current iteration
  6335. */ function sha1_kt(t) {
  6336. return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
  6337. }
  6338. /**
  6339. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  6340. * to work around bugs in some JS interpreters.
  6341. */ function safe_add(x, y) {
  6342. const lsw = (x & 0xffff) + (y & 0xffff);
  6343. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  6344. return msw << 16 | lsw & 0xffff;
  6345. }
  6346. /**
  6347. * Bitwise rotate a 32-bit number to the left.
  6348. */ function bit_rol(num, cnt) {
  6349. return num << cnt | num >>> 32 - cnt;
  6350. }
  6351. function getSignature(options) {
  6352. let normalized = options;
  6353. if (typeof options === 'string') {
  6354. normalized = {
  6355. ticket: options
  6356. };
  6357. }
  6358. const nonceStr = normalized.nonceStr || random();
  6359. const timestamp = normalized.timestamp || Math.floor(Date.now() / 1000);
  6360. const url = normalized.url || getHref().split('#')[0];
  6361. const ticket = normalized.ticket;
  6362. const signature = hex_sha1(`jsapi_ticket=${ticket}&noncestr=${nonceStr}&timestamp=${timestamp}&url=${url}`);
  6363. return {
  6364. timestamp,
  6365. nonceStr,
  6366. signature
  6367. };
  6368. }
  6369. const env = {
  6370. isWeChat,
  6371. isWeCom
  6372. };
  6373. const IS_WECOM_SDK = true;
  6374. exports.FrameCanvas = FrameCanvas;
  6375. exports.IS_WECOM_SDK = IS_WECOM_SDK;
  6376. exports.SDK_VERSION = SDK_VERSION;
  6377. exports.addCard = addCard;
  6378. exports.addDevice = addDevice;
  6379. exports.checkJsApi = checkJsApi;
  6380. exports.checkSchedule = checkSchedule;
  6381. exports.chooseCard = chooseCard;
  6382. exports.chooseImage = chooseImage;
  6383. exports.chooseInvoice = chooseInvoice;
  6384. exports.chooseMessageFile = chooseMessageFile;
  6385. exports.chooseWXPay = chooseWXPay;
  6386. exports.claimClassAdmin = claimClassAdmin;
  6387. exports.closeBLEConnection = closeBLEConnection;
  6388. exports.closeBluetoothAdapter = closeBluetoothAdapter;
  6389. exports.closeWindow = closeWindow;
  6390. exports.connectWifi = connectWifi;
  6391. exports.consumeAndShareCard = consumeAndShareCard;
  6392. exports.createBLEConnection = createBLEConnection;
  6393. exports.createChatWithMsg = createChatWithMsg;
  6394. exports.createCorpGroupChat = createCorpGroupChat;
  6395. exports.createDoc = createDoc;
  6396. exports.createExternalPayment = createExternalPayment;
  6397. exports.createJSAPIPanel = createJSAPIPanel;
  6398. exports.createOpenDataFrameFactory = createOpenDataFrameFactory;
  6399. exports.createSchoolPayment = createSchoolPayment;
  6400. exports.createScrollViewContext = createScrollViewContext;
  6401. exports.createWWLoginPanel = createWWLoginPanel;
  6402. exports.discoverDevice = discoverDevice;
  6403. exports.downloadImage = downloadImage;
  6404. exports.downloadLivingReplay = downloadLivingReplay;
  6405. exports.downloadVoice = downloadVoice;
  6406. exports.ensureAgentConfigReady = ensureAgentConfigReady;
  6407. exports.ensureConfigReady = ensureConfigReady;
  6408. exports.ensureCorpConfigReady = ensureCorpConfigReady;
  6409. exports.enterHWOpenTalk = enterHWOpenTalk;
  6410. exports.enterpriseVerify = enterpriseVerify;
  6411. exports.env = env;
  6412. exports.getApprovalSelectedItems = getApprovalSelectedItems;
  6413. exports.getBLEDeviceCharacteristics = getBLEDeviceCharacteristics;
  6414. exports.getBLEDeviceServices = getBLEDeviceServices;
  6415. exports.getBeacons = getBeacons;
  6416. exports.getBluetoothAdapterState = getBluetoothAdapterState;
  6417. exports.getBluetoothDevices = getBluetoothDevices;
  6418. exports.getCanvas = getCanvas;
  6419. exports.getClipboardData = getClipboardData;
  6420. exports.getConnectedBluetoothDevices = getConnectedBluetoothDevices;
  6421. exports.getConnectedWifi = getConnectedWifi;
  6422. exports.getContext = getContext;
  6423. exports.getCurCorpGroupChat = getCurCorpGroupChat;
  6424. exports.getCurCorpGroupContact = getCurCorpGroupContact;
  6425. exports.getCurExternalChat = getCurExternalChat;
  6426. exports.getCurExternalContact = getCurExternalContact;
  6427. exports.getLocalFileData = getLocalFileData;
  6428. exports.getLocalImgData = getLocalImgData;
  6429. exports.getLocation = getLocation;
  6430. exports.getNetworkType = getNetworkType;
  6431. exports.getNodeInfo = getNodeInfo;
  6432. exports.getShareInfo = getShareInfo;
  6433. exports.getSignature = getSignature;
  6434. exports.getVerifyParams = getVerifyParams;
  6435. exports.getWifiList = getWifiList;
  6436. exports.hideAllNonBaseMenuItem = hideAllNonBaseMenuItem;
  6437. exports.hideChatAttachmentMenu = hideChatAttachmentMenu;
  6438. exports.hideMenuItems = hideMenuItems;
  6439. exports.hideOptionMenu = hideOptionMenu;
  6440. exports.initOpenData = initOpenData;
  6441. exports.invoke = invoke;
  6442. exports.launchMiniprogram = launchMiniprogram;
  6443. exports.navigateToAddCustomer = navigateToAddCustomer;
  6444. exports.navigateToKfChat = navigateToKfChat;
  6445. exports.notifyBLECharacteristicValueChange = notifyBLECharacteristicValueChange;
  6446. exports.on = on;
  6447. exports.onBLECharacteristicValueChange = onBLECharacteristicValueChange;
  6448. exports.onBLEConnectionStateChange = onBLEConnectionStateChange;
  6449. exports.onBeaconServiceChange = onBeaconServiceChange;
  6450. exports.onBeaconUpdate = onBeaconUpdate;
  6451. exports.onBluetoothAdapterStateChange = onBluetoothAdapterStateChange;
  6452. exports.onBluetoothDeviceFound = onBluetoothDeviceFound;
  6453. exports.onGetWifiList = onGetWifiList;
  6454. exports.onHistoryBack = onHistoryBack;
  6455. exports.onLocationChange = onLocationChange;
  6456. exports.onMenuShareAppMessage = onMenuShareAppMessage;
  6457. exports.onMenuShareQQ = onMenuShareQQ;
  6458. exports.onMenuShareQZone = onMenuShareQZone;
  6459. exports.onMenuShareTimeline = onMenuShareTimeline;
  6460. exports.onMenuShareWechat = onMenuShareWechat;
  6461. exports.onMenuShareWeibo = onMenuShareWeibo;
  6462. exports.onNetworkStatusChange = onNetworkStatusChange;
  6463. exports.onSearchBeacons = onSearchBeacons;
  6464. exports.onUserCaptureScreen = onUserCaptureScreen;
  6465. exports.onVoicePlayEnd = onVoicePlayEnd;
  6466. exports.onVoiceRecordEnd = onVoiceRecordEnd;
  6467. exports.onWifiConnected = onWifiConnected;
  6468. exports.openAddress = openAddress;
  6469. exports.openAppComment = openAppComment;
  6470. exports.openAppDeviceDataAuth = openAppDeviceDataAuth;
  6471. exports.openAppManage = openAppManage;
  6472. exports.openAppPurchase = openAppPurchase;
  6473. exports.openBluetoothAdapter = openBluetoothAdapter;
  6474. exports.openBusinessView = openBusinessView;
  6475. exports.openCard = openCard;
  6476. exports.openDefaultBrowser = openDefaultBrowser;
  6477. exports.openDeviceProfile = openDeviceProfile;
  6478. exports.openEnterpriseChat = openEnterpriseChat;
  6479. exports.openEnterpriseRedPacket = openEnterpriseRedPacket;
  6480. exports.openExistedChatWithMsg = openExistedChatWithMsg;
  6481. exports.openLocation = openLocation;
  6482. exports.openProductSpecificView = openProductSpecificView;
  6483. exports.openThirdAppServiceChat = openThirdAppServiceChat;
  6484. exports.openUserProfile = openUserProfile;
  6485. exports.pauseVoice = pauseVoice;
  6486. exports.playVoice = playVoice;
  6487. exports.previewFile = previewFile;
  6488. exports.previewImage = previewImage;
  6489. exports.printFile = printFile;
  6490. exports.queryCurrHWOpenTalk = queryCurrHWOpenTalk;
  6491. exports.readBLECharacteristicValue = readBLECharacteristicValue;
  6492. exports.refundExternalPayment = refundExternalPayment;
  6493. exports.register = register;
  6494. exports.replayLiving = replayLiving;
  6495. exports.saveApprovalSelectedItems = saveApprovalSelectedItems;
  6496. exports.scanQRCode = scanQRCode;
  6497. exports.selectCorpGroupContact = selectCorpGroupContact;
  6498. exports.selectEnterpriseContact = selectEnterpriseContact;
  6499. exports.selectExternalContact = selectExternalContact;
  6500. exports.selectPrivilegedContact = selectPrivilegedContact;
  6501. exports.sendChatMessage = sendChatMessage;
  6502. exports.setClipboardData = setClipboardData;
  6503. exports.setKeepScreenOn = setKeepScreenOn;
  6504. exports.setShareAttr = setShareAttr;
  6505. exports.shareAppMessage = shareAppMessage;
  6506. exports.shareToExternalChat = shareToExternalChat;
  6507. exports.shareToExternalContact = shareToExternalContact;
  6508. exports.shareToExternalMoments = shareToExternalMoments;
  6509. exports.shareWechatMessage = shareWechatMessage;
  6510. exports.showAllNonBaseMenuItem = showAllNonBaseMenuItem;
  6511. exports.showMenuItems = showMenuItems;
  6512. exports.showOptionMenu = showOptionMenu;
  6513. exports.showSecurityGatewayConfirmModal = showSecurityGatewayConfirmModal;
  6514. exports.startAutoLBS = startAutoLBS;
  6515. exports.startBeaconDiscovery = startBeaconDiscovery;
  6516. exports.startBluetoothDevicesDiscovery = startBluetoothDevicesDiscovery;
  6517. exports.startLiving = startLiving;
  6518. exports.startMeeting = startMeeting;
  6519. exports.startRecord = startRecord;
  6520. exports.startSearchBeacons = startSearchBeacons;
  6521. exports.startWecast = startWecast;
  6522. exports.startWifi = startWifi;
  6523. exports.stopAutoLBS = stopAutoLBS;
  6524. exports.stopBeaconDiscovery = stopBeaconDiscovery;
  6525. exports.stopBluetoothDevicesDiscovery = stopBluetoothDevicesDiscovery;
  6526. exports.stopRecord = stopRecord;
  6527. exports.stopSearchBeacons = stopSearchBeacons;
  6528. exports.stopVoice = stopVoice;
  6529. exports.stopWifi = stopWifi;
  6530. exports.thirdPartyOpenPage = thirdPartyOpenPage;
  6531. exports.translateVoice = translateVoice;
  6532. exports.updateAppMessageShareData = updateAppMessageShareData;
  6533. exports.updateCorpGroupChat = updateCorpGroupChat;
  6534. exports.updateEnterpriseChat = updateEnterpriseChat;
  6535. exports.updateMomentsSetting = updateMomentsSetting;
  6536. exports.updateTimelineShareData = updateTimelineShareData;
  6537. exports.uploadImage = uploadImage;
  6538. exports.uploadVoice = uploadVoice;
  6539. exports.wedocSelectDoc = wedocSelectDoc;
  6540. exports.wedriveSelectDir = wedriveSelectDir;
  6541. exports.wedriveSelectFile = wedriveSelectFile;
  6542. exports.wedriveSelectFileForDownload = wedriveSelectFileForDownload;
  6543. exports.wedriveSelectFileForShare = wedriveSelectFileForShare;
  6544. exports.writeBLECharacteristicValue = writeBLECharacteristicValue;
  6545. return exports;
  6546. })({});