智慧水务管理系统 - 精河县供水工程综合管理平台

zip-fs.js 325KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zip = {}));
  5. })(this, (function (exports) { 'use strict';
  6. const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker } = typeof globalThis !== 'undefined' ? globalThis : this || self;
  7. var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
  8. /*
  9. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions are met:
  12. 1. Redistributions of source code must retain the above copyright notice,
  13. this list of conditions and the following disclaimer.
  14. 2. Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in
  16. the documentation and/or other materials provided with the distribution.
  17. 3. The names of the authors may not be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  20. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  21. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  22. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  25. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  28. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. const MAX_32_BITS = 0xffffffff;
  31. const MAX_16_BITS = 0xffff;
  32. const MAX_8_BITS = 0xff;
  33. const COMPRESSION_METHOD_DEFLATE = 0x08;
  34. const COMPRESSION_METHOD_DEFLATE_64 = 0x09;
  35. const COMPRESSION_METHOD_STORE = 0x00;
  36. const COMPRESSION_METHOD_AES = 0x63;
  37. const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
  38. const SPLIT_ZIP_FILE_SIGNATURE = 0x08074b50;
  39. const DATA_DESCRIPTOR_RECORD_SIGNATURE = SPLIT_ZIP_FILE_SIGNATURE;
  40. const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
  41. const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
  42. const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50;
  43. const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50;
  44. const END_OF_CENTRAL_DIR_LENGTH = 22;
  45. const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20;
  46. const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56;
  47. const ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH = END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LENGTH;
  48. const DATA_DESCRIPTOR_RECORD_LENGTH = 12;
  49. const DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH = 20;
  50. const DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH = 4;
  51. const EXTRAFIELD_TYPE_ZIP64 = 0x0001;
  52. const EXTRAFIELD_TYPE_AES = 0x9901;
  53. const EXTRAFIELD_TYPE_NTFS = 0x000a;
  54. const EXTRAFIELD_TYPE_NTFS_TAG1 = 0x0001;
  55. const EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP = 0x5455;
  56. const EXTRAFIELD_TYPE_UNICODE_PATH = 0x7075;
  57. const EXTRAFIELD_TYPE_UNICODE_COMMENT = 0x6375;
  58. const EXTRAFIELD_TYPE_USDZ = 0x1986;
  59. const EXTRAFIELD_TYPE_INFOZIP = 0x7875;
  60. const EXTRAFIELD_TYPE_UNIX = 0x7855;
  61. const BITFLAG_ENCRYPTED = 0b1;
  62. const BITFLAG_LEVEL = 0b0110;
  63. const BITFLAG_LEVEL_MAX_MASK = 0b010;
  64. const BITFLAG_LEVEL_FAST_MASK = 0b100;
  65. const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
  66. const BITFLAG_DATA_DESCRIPTOR = 0b1000;
  67. const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
  68. const FILE_ATTR_MSDOS_DIR_MASK = 0b10000;
  69. const FILE_ATTR_MSDOS_READONLY_MASK = 0x01;
  70. const FILE_ATTR_MSDOS_HIDDEN_MASK = 0x02;
  71. const FILE_ATTR_MSDOS_SYSTEM_MASK = 0x04;
  72. const FILE_ATTR_MSDOS_ARCHIVE_MASK = 0x20;
  73. const FILE_ATTR_UNIX_TYPE_MASK = 0o170000;
  74. const FILE_ATTR_UNIX_TYPE_DIR = 0o040000;
  75. const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
  76. const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
  77. const FILE_ATTR_UNIX_SETUID_MASK = 0o4000;
  78. const FILE_ATTR_UNIX_SETGID_MASK = 0o2000;
  79. const FILE_ATTR_UNIX_STICKY_MASK = 0o1000;
  80. const VERSION_DEFLATE = 0x14;
  81. const VERSION_ZIP64 = 0x2D;
  82. const VERSION_AES = 0x33;
  83. const DIRECTORY_SIGNATURE = "/";
  84. const HEADER_SIZE = 30;
  85. const HEADER_OFFSET_SIGNATURE = 10;
  86. const HEADER_OFFSET_COMPRESSED_SIZE = 14;
  87. const HEADER_OFFSET_UNCOMPRESSED_SIZE = 18;
  88. const MAX_DATE = new Date(2107, 11, 31);
  89. const MIN_DATE = new Date(1980, 0, 1);
  90. const UNDEFINED_VALUE = undefined;
  91. const INFINITY_VALUE = Infinity;
  92. const UNDEFINED_TYPE = "undefined";
  93. const FUNCTION_TYPE = "function";
  94. const OBJECT_TYPE = "object";
  95. /*
  96. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  97. Redistribution and use in source and binary forms, with or without
  98. modification, are permitted provided that the following conditions are met:
  99. 1. Redistributions of source code must retain the above copyright notice,
  100. this list of conditions and the following disclaimer.
  101. 2. Redistributions in binary form must reproduce the above copyright
  102. notice, this list of conditions and the following disclaimer in
  103. the documentation and/or other materials provided with the distribution.
  104. 3. The names of the authors may not be used to endorse or promote products
  105. derived from this software without specific prior written permission.
  106. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  107. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  108. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  109. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  110. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  111. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  112. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  113. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  114. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  115. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  116. */
  117. const MINIMUM_CHUNK_SIZE = 64;
  118. let maxWorkers = 2;
  119. try {
  120. if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
  121. maxWorkers = navigator.hardwareConcurrency;
  122. }
  123. } catch {
  124. // ignored
  125. }
  126. const DEFAULT_CONFIGURATION = {
  127. workerURI: "./core/web-worker-wasm.js",
  128. wasmURI: "./core/streams/zlib-wasm/zlib-streams.wasm",
  129. chunkSize: 64 * 1024,
  130. maxWorkers,
  131. terminateWorkerTimeout: 5000,
  132. useWebWorkers: true,
  133. useCompressionStream: true,
  134. CompressionStream: typeof CompressionStream != UNDEFINED_TYPE && CompressionStream,
  135. DecompressionStream: typeof DecompressionStream != UNDEFINED_TYPE && DecompressionStream
  136. };
  137. const config = Object.assign({}, DEFAULT_CONFIGURATION);
  138. function getConfiguration() {
  139. return config;
  140. }
  141. function getChunkSize(config) {
  142. return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
  143. }
  144. function configure(configuration) {
  145. const {
  146. baseURI,
  147. chunkSize,
  148. maxWorkers,
  149. terminateWorkerTimeout,
  150. useCompressionStream,
  151. useWebWorkers,
  152. CompressionStream,
  153. DecompressionStream,
  154. CompressionStreamZlib,
  155. DecompressionStreamZlib,
  156. workerURI,
  157. wasmURI
  158. } = configuration;
  159. setIfDefined("baseURI", baseURI);
  160. setIfDefined("wasmURI", wasmURI);
  161. setIfDefined("workerURI", workerURI);
  162. setIfDefined("chunkSize", chunkSize);
  163. setIfDefined("maxWorkers", maxWorkers);
  164. setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
  165. setIfDefined("useCompressionStream", useCompressionStream);
  166. setIfDefined("useWebWorkers", useWebWorkers);
  167. setIfDefined("CompressionStream", CompressionStream);
  168. setIfDefined("DecompressionStream", DecompressionStream);
  169. setIfDefined("CompressionStreamZlib", CompressionStreamZlib);
  170. setIfDefined("DecompressionStreamZlib", DecompressionStreamZlib);
  171. }
  172. function setIfDefined(propertyName, propertyValue) {
  173. if (propertyValue !== UNDEFINED_VALUE) {
  174. config[propertyName] = propertyValue;
  175. }
  176. }
  177. function t(t){const e='(t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:i,Uint32Array:c,Int32Array:a,Map:h,DataView:f,Promise:l,TextEncoder:u,crypto:w,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,b=void 0,v="undefined",k="function",z=[];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)1&e?e=e>>>1^3988292384:e>>>=1;z[t]=e}class C{constructor(t){this.t=t||-1}append(t){let e=0|this.t;for(let n=0,s=0|t.length;s>n;n++)e=e>>>8^z[255&(e^t[n])];this.t=e}get(){return~this.t}}class A extends d{constructor(){let t;const e=new C;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}const x={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=x.o(n);return 32===s?t.concat(e):x.i(e,s,0|n,t.slice(0,t.length-1))},h(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+x.o(n)},l(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=x.u(e,t[n-1]&2147483648>>e-1,1)),t},u:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,o:t=>s.round(t/1099511627776)||32,i(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=x.o(r);return s.push(x.u(e+o&31,e+o>32?n:s.pop(),1)),s}},I={bytes:{p(t){const e=x.h(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},m(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(x.u(8*(3&n),s)),e}}},R=class{constructor(t){const e=this;e.blockSize=512,e.S=[1732584193,4023233417,2562383102,271733878,3285377520],e.v=[1518500249,1859775393,2400959708,3395469782],t?(e.k=t.k.slice(0),e.C=t.C.slice(0),e.A=t.A):e.reset()}reset(){const t=this;return t.k=t.S.slice(0),t.C=[],t.A=0,t}update(t){const e=this;"string"==typeof t&&(t=I.I.m(t));const n=e.C=x.concat(e.C,t),s=e.A,o=e.A=s+x.h(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const i=new c(n);let a=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.R(i.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),e}P(){const t=this;let e=t.C;const n=t.k;e=x.concat(e,[x.u(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.A/4294967296)),e.push(0|t.A);e.length;)t.R(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}V(t,e){return e<<t|e>>>32-t}R(e){const n=this,r=n.k,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let i=r[0],c=r[1],a=r[2],h=r[3],f=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.V(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.V(5,i)+n.U(t,c,a,h)+f+o[t]+n.v[s.floor(t/20)]|0;f=h,h=a,a=n.V(30,c),c=i,i=e}r[0]=r[0]+i|0,r[1]=r[1]+c|0,r[2]=r[2]+a|0,r[3]=r[3]+h|0,r[4]=r[4]+f|0}},P={getRandomValues(t){const e=new c(t.buffer),n=t=>{let e=987654321;const n=4294967295;return()=>(e=36969*(65535&e)+(e>>16)&n,(((e<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,o=0;o<t.length;o+=4){const t=n(4294967296*(r||s.random()));r=987654071*t(),e[o/4]=4294967296*t()|0}return t}},U={importKey:t=>new U.M(I.bytes.m(t)),_(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let i,c,a,h,l;const u=new ArrayBuffer(o),w=new f(u);let p=0;const d=x;for(e=I.bytes.m(e),l=1;(o||1)>p;l++){for(i=c=t.encrypt(d.concat(e,[l])),a=1;n>a;a++)for(c=t.encrypt(c),h=0;h<c.length;h++)i[h]^=c[h];for(a=0;(o||1)>p&&a<i.length;a++)w.setInt32(p,i[a]),p+=4}return u.slice(0,s/8)},M:class{constructor(t){const e=this,n=e.B=R,s=[[],[]];e.D=[new n,new n];const r=e.D[0].blockSize/32;t.length>r&&(t=(new n).update(t).P());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.D[0].update(s[0]),e.D[1].update(s[1]),e.W=new n(e.D[0])}reset(){const t=this;t.W=new t.B(t.D[0]),t.K=!1}update(t){this.K=!0,this.W.update(t)}digest(){const t=this,e=t.W.P(),n=new t.B(t.D[1]).update(e).P();return t.reset(),n}encrypt(t){if(this.K)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},V=typeof w!=v&&typeof w.getRandomValues==k,M="Invalid password",_="Invalid signature",B="zipjs-abort-check-password";function D(t){return V?w.getRandomValues(t):P.getRandomValues(t)}const W=16,K={name:"PBKDF2"},E=e.assign({hash:{name:"HMAC"}},K),L=e.assign({iterations:1e3,hash:{name:"SHA-1"}},K),O=["deriveBits"],T=[8,12,16],j=[16,24,32],H=10,Z=[0,0,0,0],F=typeof w!=v,N=F&&w.subtle,q=F&&typeof N!=v,G=I.bytes,J=class{constructor(t){const e=this;e.L=[[[],[],[],[],[]],[[],[],[],[],[]]],e.L[0][0][0]||e.O();const n=e.L[0][4],s=e.L[1],o=t.length;let i,c,a,h=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.v=[c=t.slice(0),a=[]],i=o;4*o+28>i;i++){let t=c[i-1];(i%o===0||8===o&&i%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%o===0&&(t=t<<8^t>>>24^h<<24,h=h<<1^283*(h>>7))),c[i]=c[i-o]^t}for(let t=0;i;t++,i--){const e=c[3&t?i:i-4];a[t]=4>=i||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.T(t,0)}decrypt(t){return this.T(t,1)}O(){const t=this.L[0],e=this.L[1],n=t[4],s=e[4],r=[],o=[];let i,c,a,h;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let f=i=0;!n[f];f^=c||1,i=o[i]||1){let o=i^i<<1^i<<2^i<<3^i<<4;o=o>>8^255&o^99,n[f]=o,s[o]=f,h=r[a=r[c=r[f]]];let l=16843009*h^65537*a^257*c^16843008*f,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=u=u<<24^u>>>8,e[n][o]=l=l<<24^l>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}T(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.v[e],s=n.length/4-2,o=[0,0,0,0],i=this.L[e],c=i[0],a=i[1],h=i[2],f=i[3],l=i[4];let u,w,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)u=c[d>>>24]^a[y>>16&255]^h[m>>8&255]^f[255&g]^n[S],w=c[y>>>24]^a[m>>16&255]^h[g>>8&255]^f[255&d]^n[S+1],p=c[m>>>24]^a[g>>16&255]^h[d>>8&255]^f[255&y]^n[S+2],g=c[g>>>24]^a[d>>16&255]^h[y>>8&255]^f[255&m]^n[S+3],S+=4,d=u,y=w,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=l[d>>>24]<<24^l[y>>16&255]<<16^l[m>>8&255]<<8^l[255&g]^n[S++],u=d,d=y,y=m,m=g,g=u;return o}},Q=class{constructor(t,e){this.j=t,this.H=e,this.Z=e}reset(){this.Z=this.H}update(t){return this.F(this.j,t,this.Z)}N(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}q(t){0===(t[0]=this.N(t[0]))&&(t[1]=this.N(t[1]))}F(t,e,n){let s;if(!(s=e.length))return[];const r=x.h(e);for(let r=0;s>r;r+=4){this.q(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return x.l(e,r)}},X=U.M;let Y=F&&q&&typeof N.importKey==k,$=F&&q&&typeof N.deriveBits==k;class tt extends d{constructor({password:t,rawPassword:n,signed:s,encryptionStrength:i,checkPasswordOnly:c}){super({start(){e.assign(this,{ready:new l(t=>this.G=t),password:rt(t,n),signed:s,J:i-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:i,G:a,ready:h}=n;s?(await(async(t,e,n,s)=>{const o=await st(t,e,n,it(s,0,T[e])),i=it(s,T[e]);if(o[0]!=i[0]||o[1]!=i[1])throw new r(M)})(n,i,s,it(t,0,T[i]+2)),t=it(t,T[i]+2),c?e.error(new r(B)):a()):await h;const f=new o(t.length-H-(t.length-H)%W);e.enqueue(nt(n,t,f,0,H,!0))},async flush(t){const{signed:e,X:n,Y:s,pending:i,ready:c}=this;if(s&&n){await c;const a=it(i,0,i.length-H),h=it(i,i.length-H);let f=new o;if(a.length){const t=at(G,a);s.update(t);const e=n.update(t);f=ct(G,e)}if(e){const t=it(ct(G,s.digest()),0,H);for(let e=0;H>e;e++)if(t[e]!=h[e])throw new r(_)}t.enqueue(f)}}})}}class et extends d{constructor({password:t,rawPassword:n,encryptionStrength:s}){let r;super({start(){e.assign(this,{ready:new l(t=>this.G=t),password:rt(t,n),J:s-1,pending:new o})},async transform(t,e){const n=this,{password:s,J:r,G:i,ready:c}=n;let a=new o;s?(a=await(async(t,e,n)=>{const s=D(new o(T[e]));return ot(s,await st(t,e,n,s))})(n,r,s),i()):await c;const h=new o(a.length+t.length-t.length%W);h.set(a,0),e.enqueue(nt(n,t,h,a.length,0))},async flush(t){const{X:e,Y:n,pending:s,ready:i}=this;if(n&&e){await i;let c=new o;if(s.length){const t=e.update(at(G,s));n.update(t),c=ct(G,t)}r.signature=ct(G,n.digest()).slice(0,H),t.enqueue(ot(c,r.signature))}}}),r=this}}function nt(t,e,n,s,r,i){const{X:c,Y:a,pending:h}=t,f=e.length-r;let l;for(h.length&&(e=ot(h,e),n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,f-f%W)),l=0;f-W>=l;l+=W){const t=at(G,it(e,l,l+W));i&&a.update(t);const r=c.update(t);i||a.update(r),n.set(ct(G,r),l+s)}return t.pending=it(e,l),n}async function st(n,s,r,i){n.password=null;const c=await(async(t,e,n,s,r)=>{if(!Y)return U.importKey(e);try{return await N.importKey("raw",e,n,!1,r)}catch{return Y=!1,U.importKey(e)}})(0,r,E,0,O),a=await(async(t,e,n)=>{if(!$)return U._(e,t.salt,L.iterations,n);try{return await N.deriveBits(t,e,n)}catch{return $=!1,U._(e,t.salt,L.iterations,n)}})(e.assign({salt:i},L),c,8*(2*j[s]+2)),h=new o(a),f=at(G,it(h,0,j[s])),l=at(G,it(h,j[s],2*j[s])),u=it(h,2*j[s]);return e.assign(n,{keys:{key:f,$:l,passwordVerification:u},X:new Q(new J(f),t.from(Z)),Y:new X(l)}),u}function rt(t,e){return e===b?(t=>{if(typeof u==v){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new u).encode(t)})(t):e}function ot(t,e){let n=t;return t.length+e.length&&(n=new o(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function it(t,e,n){return t.subarray(e,n)}function ct(t,e){return t.p(e)}function at(t,e){return t.m(e)}class ht extends d{constructor({password:t,passwordVerification:n,checkPasswordOnly:s}){super({start(){e.assign(this,{password:t,passwordVerification:n}),wt(this,t)},transform(t,e){const n=this;if(n.password){const e=lt(n,t.subarray(0,12));if(n.password=null,e.at(-1)!=n.passwordVerification)throw new r(M);t=t.subarray(12)}s?e.error(new r(B)):e.enqueue(lt(n,t))}})}}class ft extends d{constructor({password:t,passwordVerification:n}){super({start(){e.assign(this,{password:t,passwordVerification:n}),wt(this,t)},transform(t,e){const n=this;let s,r;if(n.password){n.password=null;const e=D(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(ut(n,e),0),r=12}else s=new o(t.length),r=0;s.set(ut(n,t),r),e.enqueue(s)}})}}function lt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=dt(t)^e[s],pt(t,n[s]);return n}function ut(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=dt(t)^e[s],pt(t,e[s]);return n}function wt(t,n){const s=[305419896,591751049,878082192];e.assign(t,{keys:s,tt:new C(s[0]),et:new C(s[2])});for(let e=0;e<n.length;e++)pt(t,n.charCodeAt(e))}function pt(t,e){let[n,r,o]=t.keys;t.tt.append([e]),n=~t.tt.get(),r=mt(s.imul(mt(r+yt(n)),134775813)+1),t.et.append([r>>>24]),o=~t.et.get(),t.keys=[n,r,o]}function dt(t){const e=2|t.keys[2];return yt(s.imul(e,1^e)>>>8)}function yt(t){return 255&t}function mt(t){return 4294967295&t}class gt extends d{constructor(t,{chunkSize:e,nt:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:i,zipCrypto:c,signed:a,level:h}=t,l=this;let u,w,p=super.readable;o&&!c||!a||(u=new A,p=kt(p,u)),r&&(p=vt(p,i,{level:h,chunkSize:e},s,n,s)),o&&(c?p=kt(p,new ft(t)):(w=new et(t),p=kt(p,w))),bt(l,p,()=>{let t;o&&!c&&(t=w.signature),o&&!c||!a||(t=new f(u.value.buffer).getUint32(0)),l.signature=t})}}class St extends d{constructor(t,{chunkSize:e,st:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:i,signed:c,signature:a,compressed:h,useCompressionStream:l,rt:u}=t;let w,p,d=super.readable;i&&(o?d=kt(d,new ht(t)):(p=new tt(t),d=kt(d,p))),h&&(d=vt(d,l,{chunkSize:e,rt:u},s,n,s)),i&&!o||!c||(w=new A,d=kt(d,w)),bt(this,d,()=>{if((!i||o)&&c){const t=new f(w.value.buffer);if(a!=t.getUint32(0,!1))throw new r(_)}})}}function bt(t,n,s){n=kt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function vt(t,e,n,s,r,o){const i=e&&s?s:r||o,c=n.rt?"deflate64-raw":"deflate-raw";try{t=kt(t,new i(c,n))}catch(s){if(!e)throw s;if(r)t=kt(t,new r(c,n));else{if(!o)throw s;t=kt(t,new o(c,n))}}return t}function kt(t,e){return t.pipeThrough(e)}const zt="data",Ct="close";class At extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let i;o.startsWith("deflate")?i=gt:o.startsWith("inflate")&&(i=St),s.outputSize=0;let c=0;const a=new i(t,n),h=super.readable,f=new d({transform(t,e){t&&t.length&&(c+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:c})}}),l=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==b&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=a;e.assign(s,{signature:t,inputSize:c})}});e.defineProperty(s,"readable",{get:()=>h.pipeThrough(f).pipeThrough(a).pipeThrough(l)})}}class xt extends d{constructor(t){let e;super({transform:function n(s,r){if(e){const t=new o(e.length+s.length);t.set(e),t.set(s,e.length),s=t,e=null}s.length>t?(r.enqueue(s.slice(0,t)),n(s.slice(t),r)):e=s},flush(t){e&&e.length&&t.enqueue(e)}})}}const It=new h,Rt=new h;let Pt,Ut,Vt,Mt,_t,Bt=0;async function Dt(t){try{const{options:e,config:s}=t;if(!e.useCompressionStream)try{await self.initModule(t.config)}catch{e.useCompressionStream=!0}s.CompressionStream=self.CompressionStream,s.DecompressionStream=self.DecompressionStream;const r={highWaterMark:1},o=t.readable||new y({async pull(t){const e=new l(t=>It.set(Bt,t));Wt({type:"pull",messageId:Bt}),Bt=(Bt+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},r),i=t.writable||new m({async write(t){let e;const s=new l(t=>e=t);Rt.set(Bt,e),Wt({type:zt,value:t,messageId:Bt}),Bt=(Bt+1)%n.MAX_SAFE_INTEGER,await s}},r),c=new At(e,s);Pt=new AbortController;const{signal:a}=Pt;await o.pipeThrough(c).pipeThrough(new xt(s.chunkSize)).pipeTo(i,{signal:a,preventClose:!0,preventAbort:!0}),await i.getWriter().close();const{signature:h,inputSize:f,outputSize:u}=c;Wt({type:Ct,result:{signature:h,inputSize:f,outputSize:u}})}catch(t){t.outputSize=0,Kt(t)}}function Wt(t){let{value:e}=t;if(e)if(e.length)try{e=new o(e),t.value=e.buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t)}function Kt(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:i}=t;p({error:{message:e,stack:n,code:s,name:o,outputSize:i}})}function Et(t,e,n={}){const i="number"==typeof n.level?n.level:-1,c="number"==typeof n.ot?n.ot:65536,a="number"==typeof n.it?n.it:65536;return new d({start(){let n;if(this.ct=Vt(c),this.in=Vt(a),this.it=a,this.ht=new o(c),t?(this.ft=Ut.deflate_process,this.lt=Ut.deflate_last_consumed,this.ut=Ut.deflate_end,this.wt=Ut.deflate_new(),n="gzip"===e?Ut.deflate_init_gzip(this.wt,i):"deflate-raw"===e?Ut.deflate_init_raw(this.wt,i):Ut.deflate_init(this.wt,i)):"deflate64-raw"===e?(this.ft=Ut.inflate9_process,this.lt=Ut.inflate9_last_consumed,this.ut=Ut.inflate9_end,this.wt=Ut.inflate9_new(),n=Ut.inflate9_init_raw(this.wt)):(this.ft=Ut.inflate_process,this.lt=Ut.inflate_last_consumed,this.ut=Ut.inflate_end,this.wt=Ut.inflate_new(),n="deflate-raw"===e?Ut.inflate_init_raw(this.wt):"gzip"===e?Ut.inflate_init_gzip(this.wt):Ut.inflate_init(this.wt)),0!==n)throw new r("init failed:"+n)},transform(e,n){try{const i=e,a=new o(_t.buffer),h=this.ft,f=this.lt,l=this.ct,u=this.ht;let w=0;for(;w<i.length;){const e=s.min(i.length-w,32768);this.in&&this.it>=e||(this.in&&Mt&&Mt(this.in),this.in=Vt(e),this.it=e),a.set(i.subarray(w,w+e),this.in);const o=h(this.wt,this.in,e,l,c,0),p=16777215&o;if(p&&(u.set(a.subarray(l,l+p),0),n.enqueue(u.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=f(this.wt);if(0===d)break;w+=d}}catch(t){this.ut&&this.wt&&this.ut(this.wt),this.in&&Mt&&Mt(this.in),this.ct&&Mt&&Mt(this.ct),n.error(t)}},flush(e){try{const n=new o(_t.buffer),s=this.ft,i=this.ct,a=this.ht;for(;;){const o=s(this.wt,0,0,i,c,4),h=16777215&o,f=o>>24&255;if(!t){const t=128&f?f-256:f;if(0>t)throw new r("process error:"+t)}if(h&&(a.set(n.subarray(i,i+h),0),e.enqueue(a.slice(0,h))),1===f||0===h)break}}catch(t){e.error(t)}finally{if(this.ut&&this.wt){const t=this.ut(this.wt);0!==t&&e.error(new r("end error:"+t))}this.in&&Mt&&Mt(this.in),this.ct&&Mt&&Mt(this.ct)}}})}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&Dt(t),e==zt){const t=It.get(n);It.delete(n),t({value:new o(s),done:r})}if("ack"==e){const t=Rt.get(n);Rt.delete(n),t()}e==Ct&&Pt.abort()}catch(t){Kt(t)}});class Lt{constructor(t="deflate",e){return Et(!0,t,e)}}class Ot{constructor(t="deflate",e){return Et(!1,t,e)}}let Tt=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!Tt){let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(Ut=t,({malloc:Vt,free:Mt,memory:_t}=Ut),"function"!=typeof Vt||"function"!=typeof Mt||!_t)throw Ut=Vt=Mt=_t=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),Tt=!0}})(t.wasmURI,t);return t.nt=Lt,t.st=Ot,e}catch{}}});\n';t({workerURI:t=>{const n="text/javascript";if(t){const t=new Blob([e],{type:n});return URL.createObjectURL(t)}return "data:"+n+","+encodeURIComponent(e)}});}
  178. /*
  179. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  180. Redistribution and use in source and binary forms, with or without
  181. modification, are permitted provided that the following conditions are met:
  182. 1. Redistributions of source code must retain the above copyright notice,
  183. this list of conditions and the following disclaimer.
  184. 2. Redistributions in binary form must reproduce the above copyright
  185. notice, this list of conditions and the following disclaimer in
  186. the documentation and/or other materials provided with the distribution.
  187. 3. The names of the authors may not be used to endorse or promote products
  188. derived from this software without specific prior written permission.
  189. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  190. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  191. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  192. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  193. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  194. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  195. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  196. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  197. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  198. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  199. */
  200. const table$1 = [];
  201. for (let i = 0; i < 256; i++) {
  202. let t = i;
  203. for (let j = 0; j < 8; j++) {
  204. if (t & 1) {
  205. t = (t >>> 1) ^ 0xEDB88320;
  206. } else {
  207. t = t >>> 1;
  208. }
  209. }
  210. table$1[i] = t;
  211. }
  212. class Crc32 {
  213. constructor(crc) {
  214. this.crc = crc || -1;
  215. }
  216. append(data) {
  217. let crc = this.crc | 0;
  218. for (let offset = 0, length = data.length | 0; offset < length; offset++) {
  219. crc = (crc >>> 8) ^ table$1[(crc ^ data[offset]) & 0xFF];
  220. }
  221. this.crc = crc;
  222. }
  223. get() {
  224. return ~this.crc;
  225. }
  226. }
  227. /*
  228. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  229. Redistribution and use in source and binary forms, with or without
  230. modification, are permitted provided that the following conditions are met:
  231. 1. Redistributions of source code must retain the above copyright notice,
  232. this list of conditions and the following disclaimer.
  233. 2. Redistributions in binary form must reproduce the above copyright
  234. notice, this list of conditions and the following disclaimer in
  235. the documentation and/or other materials provided with the distribution.
  236. 3. The names of the authors may not be used to endorse or promote products
  237. derived from this software without specific prior written permission.
  238. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  239. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  240. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  241. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  242. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  243. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  244. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  245. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  246. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  247. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  248. */
  249. class Crc32Stream extends TransformStream {
  250. constructor() {
  251. // deno-lint-ignore prefer-const
  252. let stream;
  253. const crc32 = new Crc32();
  254. super({
  255. transform(chunk, controller) {
  256. crc32.append(chunk);
  257. controller.enqueue(chunk);
  258. },
  259. flush() {
  260. const value = new Uint8Array(4);
  261. const dataView = new DataView(value.buffer);
  262. dataView.setUint32(0, crc32.get());
  263. stream.value = value;
  264. }
  265. });
  266. stream = this;
  267. }
  268. }
  269. /*
  270. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  271. Redistribution and use in source and binary forms, with or without
  272. modification, are permitted provided that the following conditions are met:
  273. 1. Redistributions of source code must retain the above copyright notice,
  274. this list of conditions and the following disclaimer.
  275. 2. Redistributions in binary form must reproduce the above copyright
  276. notice, this list of conditions and the following disclaimer in
  277. the documentation and/or other materials provided with the distribution.
  278. 3. The names of the authors may not be used to endorse or promote products
  279. derived from this software without specific prior written permission.
  280. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  281. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  282. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  283. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  284. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  285. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  286. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  287. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  288. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  289. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  290. */
  291. function encodeText(value) {
  292. // deno-lint-ignore valid-typeof
  293. if (typeof TextEncoder == UNDEFINED_TYPE) {
  294. value = unescape(encodeURIComponent(value));
  295. const result = new Uint8Array(value.length);
  296. for (let i = 0; i < result.length; i++) {
  297. result[i] = value.charCodeAt(i);
  298. }
  299. return result;
  300. } else {
  301. return new TextEncoder().encode(value);
  302. }
  303. }
  304. // Derived from https://github.com/xqdoo00o/jszip/blob/master/lib/sjcl.js and https://github.com/bitwiseshiftleft/sjcl
  305. // deno-lint-ignore-file no-this-alias
  306. /*
  307. * SJCL is open. You can use, modify and redistribute it under a BSD
  308. * license or under the GNU GPL, version 2.0.
  309. */
  310. /** @fileOverview Javascript cryptography implementation.
  311. *
  312. * Crush to remove comments, shorten variable names and
  313. * generally reduce transmission size.
  314. *
  315. * @author Emily Stark
  316. * @author Mike Hamburg
  317. * @author Dan Boneh
  318. */
  319. /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
  320. /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
  321. *
  322. * @author Emily Stark
  323. * @author Mike Hamburg
  324. * @author Dan Boneh
  325. */
  326. /**
  327. * Arrays of bits, encoded as arrays of Numbers.
  328. * @namespace
  329. * @description
  330. * <p>
  331. * These objects are the currency accepted by SJCL's crypto functions.
  332. * </p>
  333. *
  334. * <p>
  335. * Most of our crypto primitives operate on arrays of 4-byte words internally,
  336. * but many of them can take arguments that are not a multiple of 4 bytes.
  337. * This library encodes arrays of bits (whose size need not be a multiple of 8
  338. * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
  339. * array of words, 32 bits at a time. Since the words are double-precision
  340. * floating point numbers, they fit some extra data. We use this (in a private,
  341. * possibly-changing manner) to encode the number of bits actually present
  342. * in the last word of the array.
  343. * </p>
  344. *
  345. * <p>
  346. * Because bitwise ops clear this out-of-band data, these arrays can be passed
  347. * to ciphers like AES which want arrays of words.
  348. * </p>
  349. */
  350. const bitArray = {
  351. /**
  352. * Concatenate two bit arrays.
  353. * @param {bitArray} a1 The first array.
  354. * @param {bitArray} a2 The second array.
  355. * @return {bitArray} The concatenation of a1 and a2.
  356. */
  357. concat(a1, a2) {
  358. if (a1.length === 0 || a2.length === 0) {
  359. return a1.concat(a2);
  360. }
  361. const last = a1[a1.length - 1], shift = bitArray.getPartial(last);
  362. if (shift === 32) {
  363. return a1.concat(a2);
  364. } else {
  365. return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1));
  366. }
  367. },
  368. /**
  369. * Find the length of an array of bits.
  370. * @param {bitArray} a The array.
  371. * @return {Number} The length of a, in bits.
  372. */
  373. bitLength(a) {
  374. const l = a.length;
  375. if (l === 0) {
  376. return 0;
  377. }
  378. const x = a[l - 1];
  379. return (l - 1) * 32 + bitArray.getPartial(x);
  380. },
  381. /**
  382. * Truncate an array.
  383. * @param {bitArray} a The array.
  384. * @param {Number} len The length to truncate to, in bits.
  385. * @return {bitArray} A new array, truncated to len bits.
  386. */
  387. clamp(a, len) {
  388. if (a.length * 32 < len) {
  389. return a;
  390. }
  391. a = a.slice(0, Math.ceil(len / 32));
  392. const l = a.length;
  393. len = len & 31;
  394. if (l > 0 && len) {
  395. a[l - 1] = bitArray.partial(len, a[l - 1] & 0x80000000 >> (len - 1), 1);
  396. }
  397. return a;
  398. },
  399. /**
  400. * Make a partial word for a bit array.
  401. * @param {Number} len The number of bits in the word.
  402. * @param {Number} x The bits.
  403. * @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side.
  404. * @return {Number} The partial word.
  405. */
  406. partial(len, x, _end) {
  407. if (len === 32) {
  408. return x;
  409. }
  410. return (_end ? x | 0 : x << (32 - len)) + len * 0x10000000000;
  411. },
  412. /**
  413. * Get the number of bits used by a partial word.
  414. * @param {Number} x The partial word.
  415. * @return {Number} The number of bits used by the partial word.
  416. */
  417. getPartial(x) {
  418. return Math.round(x / 0x10000000000) || 32;
  419. },
  420. /** Shift an array right.
  421. * @param {bitArray} a The array to shift.
  422. * @param {Number} shift The number of bits to shift.
  423. * @param {Number} [carry=0] A byte to carry in
  424. * @param {bitArray} [out=[]] An array to prepend to the output.
  425. * @private
  426. */
  427. _shiftRight(a, shift, carry, out) {
  428. if (out === undefined) {
  429. out = [];
  430. }
  431. for (; shift >= 32; shift -= 32) {
  432. out.push(carry);
  433. carry = 0;
  434. }
  435. if (shift === 0) {
  436. return out.concat(a);
  437. }
  438. for (let i = 0; i < a.length; i++) {
  439. out.push(carry | a[i] >>> shift);
  440. carry = a[i] << (32 - shift);
  441. }
  442. const last2 = a.length ? a[a.length - 1] : 0;
  443. const shift2 = bitArray.getPartial(last2);
  444. out.push(bitArray.partial(shift + shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(), 1));
  445. return out;
  446. }
  447. };
  448. /** @fileOverview Bit array codec implementations.
  449. *
  450. * @author Emily Stark
  451. * @author Mike Hamburg
  452. * @author Dan Boneh
  453. */
  454. /**
  455. * Arrays of bytes
  456. * @namespace
  457. */
  458. const codec = {
  459. bytes: {
  460. /** Convert from a bitArray to an array of bytes. */
  461. fromBits(arr) {
  462. const bl = bitArray.bitLength(arr);
  463. const byteLength = bl / 8;
  464. const out = new Uint8Array(byteLength);
  465. let tmp;
  466. for (let i = 0; i < byteLength; i++) {
  467. if ((i & 3) === 0) {
  468. tmp = arr[i / 4];
  469. }
  470. out[i] = tmp >>> 24;
  471. tmp <<= 8;
  472. }
  473. return out;
  474. },
  475. /** Convert from an array of bytes to a bitArray. */
  476. toBits(bytes) {
  477. const out = [];
  478. let i;
  479. let tmp = 0;
  480. for (i = 0; i < bytes.length; i++) {
  481. tmp = tmp << 8 | bytes[i];
  482. if ((i & 3) === 3) {
  483. out.push(tmp);
  484. tmp = 0;
  485. }
  486. }
  487. if (i & 3) {
  488. out.push(bitArray.partial(8 * (i & 3), tmp));
  489. }
  490. return out;
  491. }
  492. }
  493. };
  494. const hash = {};
  495. /**
  496. * Context for a SHA-1 operation in progress.
  497. * @constructor
  498. */
  499. hash.sha1 = class {
  500. constructor(hash) {
  501. const sha1 = this;
  502. /**
  503. * The hash's block size, in bits.
  504. * @constant
  505. */
  506. sha1.blockSize = 512;
  507. /**
  508. * The SHA-1 initialization vector.
  509. * @private
  510. */
  511. sha1._init = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
  512. /**
  513. * The SHA-1 hash key.
  514. * @private
  515. */
  516. sha1._key = [0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6];
  517. if (hash) {
  518. sha1._h = hash._h.slice(0);
  519. sha1._buffer = hash._buffer.slice(0);
  520. sha1._length = hash._length;
  521. } else {
  522. sha1.reset();
  523. }
  524. }
  525. /**
  526. * Reset the hash state.
  527. * @return this
  528. */
  529. reset() {
  530. const sha1 = this;
  531. sha1._h = sha1._init.slice(0);
  532. sha1._buffer = [];
  533. sha1._length = 0;
  534. return sha1;
  535. }
  536. /**
  537. * Input several words to the hash.
  538. * @param {bitArray|String} data the data to hash.
  539. * @return this
  540. */
  541. update(data) {
  542. const sha1 = this;
  543. if (typeof data === "string") {
  544. data = codec.utf8String.toBits(data);
  545. }
  546. const b = sha1._buffer = bitArray.concat(sha1._buffer, data);
  547. const ol = sha1._length;
  548. const nl = sha1._length = ol + bitArray.bitLength(data);
  549. if (nl > 9007199254740991) {
  550. throw new Error("Cannot hash more than 2^53 - 1 bits");
  551. }
  552. const c = new Uint32Array(b);
  553. let j = 0;
  554. for (let i = sha1.blockSize + ol - ((sha1.blockSize + ol) & (sha1.blockSize - 1)); i <= nl;
  555. i += sha1.blockSize) {
  556. sha1._block(c.subarray(16 * j, 16 * (j + 1)));
  557. j += 1;
  558. }
  559. b.splice(0, 16 * j);
  560. return sha1;
  561. }
  562. /**
  563. * Complete hashing and output the hash value.
  564. * @return {bitArray} The hash value, an array of 5 big-endian words. TODO
  565. */
  566. finalize() {
  567. const sha1 = this;
  568. let b = sha1._buffer;
  569. const h = sha1._h;
  570. // Round out and push the buffer
  571. b = bitArray.concat(b, [bitArray.partial(1, 1)]);
  572. // Round out the buffer to a multiple of 16 words, less the 2 length words.
  573. for (let i = b.length + 2; i & 15; i++) {
  574. b.push(0);
  575. }
  576. // append the length
  577. b.push(Math.floor(sha1._length / 0x100000000));
  578. b.push(sha1._length | 0);
  579. while (b.length) {
  580. sha1._block(b.splice(0, 16));
  581. }
  582. sha1.reset();
  583. return h;
  584. }
  585. /**
  586. * The SHA-1 logical functions f(0), f(1), ..., f(79).
  587. * @private
  588. */
  589. _f(t, b, c, d) {
  590. if (t <= 19) {
  591. return (b & c) | (~b & d);
  592. } else if (t <= 39) {
  593. return b ^ c ^ d;
  594. } else if (t <= 59) {
  595. return (b & c) | (b & d) | (c & d);
  596. } else if (t <= 79) {
  597. return b ^ c ^ d;
  598. }
  599. }
  600. /**
  601. * Circular left-shift operator.
  602. * @private
  603. */
  604. _S(n, x) {
  605. return (x << n) | (x >>> 32 - n);
  606. }
  607. /**
  608. * Perform one cycle of SHA-1.
  609. * @param {Uint32Array|bitArray} words one block of words.
  610. * @private
  611. */
  612. _block(words) {
  613. const sha1 = this;
  614. const h = sha1._h;
  615. // When words is passed to _block, it has 16 elements. SHA1 _block
  616. // function extends words with new elements (at the end there are 80 elements).
  617. // The problem is that if we use Uint32Array instead of Array,
  618. // the length of Uint32Array cannot be changed. Thus, we replace words with a
  619. // normal Array here.
  620. const w = Array(80); // do not use Uint32Array here as the instantiation is slower
  621. for (let j = 0; j < 16; j++) {
  622. w[j] = words[j];
  623. }
  624. let a = h[0];
  625. let b = h[1];
  626. let c = h[2];
  627. let d = h[3];
  628. let e = h[4];
  629. for (let t = 0; t <= 79; t++) {
  630. if (t >= 16) {
  631. w[t] = sha1._S(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]);
  632. }
  633. const tmp = (sha1._S(5, a) + sha1._f(t, b, c, d) + e + w[t] +
  634. sha1._key[Math.floor(t / 20)]) | 0;
  635. e = d;
  636. d = c;
  637. c = sha1._S(30, b);
  638. b = a;
  639. a = tmp;
  640. }
  641. h[0] = (h[0] + a) | 0;
  642. h[1] = (h[1] + b) | 0;
  643. h[2] = (h[2] + c) | 0;
  644. h[3] = (h[3] + d) | 0;
  645. h[4] = (h[4] + e) | 0;
  646. }
  647. };
  648. /** @fileOverview Low-level AES implementation.
  649. *
  650. * This file contains a low-level implementation of AES, optimized for
  651. * size and for efficiency on several browsers. It is based on
  652. * OpenSSL's aes_core.c, a public-domain implementation by Vincent
  653. * Rijmen, Antoon Bosselaers and Paulo Barreto.
  654. *
  655. * An older version of this implementation is available in the public
  656. * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
  657. * Stanford University 2008-2010 and BSD-licensed for liability
  658. * reasons.
  659. *
  660. * @author Emily Stark
  661. * @author Mike Hamburg
  662. * @author Dan Boneh
  663. */
  664. const cipher = {};
  665. /**
  666. * Schedule out an AES key for both encryption and decryption. This
  667. * is a low-level class. Use a cipher mode to do bulk encryption.
  668. *
  669. * @constructor
  670. * @param {Array} key The key as an array of 4, 6 or 8 words.
  671. */
  672. cipher.aes = class {
  673. constructor(key) {
  674. /**
  675. * The expanded S-box and inverse S-box tables. These will be computed
  676. * on the client so that we don't have to send them down the wire.
  677. *
  678. * There are two tables, _tables[0] is for encryption and
  679. * _tables[1] is for decryption.
  680. *
  681. * The first 4 sub-tables are the expanded S-box with MixColumns. The
  682. * last (_tables[01][4]) is the S-box itself.
  683. *
  684. * @private
  685. */
  686. const aes = this;
  687. aes._tables = [[[], [], [], [], []], [[], [], [], [], []]];
  688. if (!aes._tables[0][0][0]) {
  689. aes._precompute();
  690. }
  691. const sbox = aes._tables[0][4];
  692. const decTable = aes._tables[1];
  693. const keyLen = key.length;
  694. let i, encKey, decKey, rcon = 1;
  695. if (keyLen !== 4 && keyLen !== 6 && keyLen !== 8) {
  696. throw new Error("invalid aes key size");
  697. }
  698. aes._key = [encKey = key.slice(0), decKey = []];
  699. // schedule encryption keys
  700. for (i = keyLen; i < 4 * keyLen + 28; i++) {
  701. let tmp = encKey[i - 1];
  702. // apply sbox
  703. if (i % keyLen === 0 || (keyLen === 8 && i % keyLen === 4)) {
  704. tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255];
  705. // shift rows and add rcon
  706. if (i % keyLen === 0) {
  707. tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24;
  708. rcon = rcon << 1 ^ (rcon >> 7) * 283;
  709. }
  710. }
  711. encKey[i] = encKey[i - keyLen] ^ tmp;
  712. }
  713. // schedule decryption keys
  714. for (let j = 0; i; j++, i--) {
  715. const tmp = encKey[j & 3 ? i : i - 4];
  716. if (i <= 4 || j < 4) {
  717. decKey[j] = tmp;
  718. } else {
  719. decKey[j] = decTable[0][sbox[tmp >>> 24]] ^
  720. decTable[1][sbox[tmp >> 16 & 255]] ^
  721. decTable[2][sbox[tmp >> 8 & 255]] ^
  722. decTable[3][sbox[tmp & 255]];
  723. }
  724. }
  725. }
  726. // public
  727. /* Something like this might appear here eventually
  728. name: "AES",
  729. blockSize: 4,
  730. keySizes: [4,6,8],
  731. */
  732. /**
  733. * Encrypt an array of 4 big-endian words.
  734. * @param {Array} data The plaintext.
  735. * @return {Array} The ciphertext.
  736. */
  737. encrypt(data) {
  738. return this._crypt(data, 0);
  739. }
  740. /**
  741. * Decrypt an array of 4 big-endian words.
  742. * @param {Array} data The ciphertext.
  743. * @return {Array} The plaintext.
  744. */
  745. decrypt(data) {
  746. return this._crypt(data, 1);
  747. }
  748. /**
  749. * Expand the S-box tables.
  750. *
  751. * @private
  752. */
  753. _precompute() {
  754. const encTable = this._tables[0];
  755. const decTable = this._tables[1];
  756. const sbox = encTable[4];
  757. const sboxInv = decTable[4];
  758. const d = [];
  759. const th = [];
  760. let xInv, x2, x4, x8;
  761. // Compute double and third tables
  762. for (let i = 0; i < 256; i++) {
  763. th[(d[i] = i << 1 ^ (i >> 7) * 283) ^ i] = i;
  764. }
  765. for (let x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) {
  766. // Compute sbox
  767. let s = xInv ^ xInv << 1 ^ xInv << 2 ^ xInv << 3 ^ xInv << 4;
  768. s = s >> 8 ^ s & 255 ^ 99;
  769. sbox[x] = s;
  770. sboxInv[s] = x;
  771. // Compute MixColumns
  772. x8 = d[x4 = d[x2 = d[x]]];
  773. let tDec = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
  774. let tEnc = d[s] * 0x101 ^ s * 0x1010100;
  775. for (let i = 0; i < 4; i++) {
  776. encTable[i][x] = tEnc = tEnc << 24 ^ tEnc >>> 8;
  777. decTable[i][s] = tDec = tDec << 24 ^ tDec >>> 8;
  778. }
  779. }
  780. // Compactify. Considerable speedup on Firefox.
  781. for (let i = 0; i < 5; i++) {
  782. encTable[i] = encTable[i].slice(0);
  783. decTable[i] = decTable[i].slice(0);
  784. }
  785. }
  786. /**
  787. * Encryption and decryption core.
  788. * @param {Array} input Four words to be encrypted or decrypted.
  789. * @param dir The direction, 0 for encrypt and 1 for decrypt.
  790. * @return {Array} The four encrypted or decrypted words.
  791. * @private
  792. */
  793. _crypt(input, dir) {
  794. if (input.length !== 4) {
  795. throw new Error("invalid aes block size");
  796. }
  797. const key = this._key[dir];
  798. const nInnerRounds = key.length / 4 - 2;
  799. const out = [0, 0, 0, 0];
  800. const table = this._tables[dir];
  801. // load up the tables
  802. const t0 = table[0];
  803. const t1 = table[1];
  804. const t2 = table[2];
  805. const t3 = table[3];
  806. const sbox = table[4];
  807. // state variables a,b,c,d are loaded with pre-whitened data
  808. let a = input[0] ^ key[0];
  809. let b = input[dir ? 3 : 1] ^ key[1];
  810. let c = input[2] ^ key[2];
  811. let d = input[dir ? 1 : 3] ^ key[3];
  812. let kIndex = 4;
  813. let a2, b2, c2;
  814. // Inner rounds. Cribbed from OpenSSL.
  815. for (let i = 0; i < nInnerRounds; i++) {
  816. a2 = t0[a >>> 24] ^ t1[b >> 16 & 255] ^ t2[c >> 8 & 255] ^ t3[d & 255] ^ key[kIndex];
  817. b2 = t0[b >>> 24] ^ t1[c >> 16 & 255] ^ t2[d >> 8 & 255] ^ t3[a & 255] ^ key[kIndex + 1];
  818. c2 = t0[c >>> 24] ^ t1[d >> 16 & 255] ^ t2[a >> 8 & 255] ^ t3[b & 255] ^ key[kIndex + 2];
  819. d = t0[d >>> 24] ^ t1[a >> 16 & 255] ^ t2[b >> 8 & 255] ^ t3[c & 255] ^ key[kIndex + 3];
  820. kIndex += 4;
  821. a = a2; b = b2; c = c2;
  822. }
  823. // Last round.
  824. for (let i = 0; i < 4; i++) {
  825. out[dir ? 3 & -i : i] =
  826. sbox[a >>> 24] << 24 ^
  827. sbox[b >> 16 & 255] << 16 ^
  828. sbox[c >> 8 & 255] << 8 ^
  829. sbox[d & 255] ^
  830. key[kIndex++];
  831. a2 = a; a = b; b = c; c = d; d = a2;
  832. }
  833. return out;
  834. }
  835. };
  836. /**
  837. * Random values
  838. * @namespace
  839. */
  840. const random = {
  841. /**
  842. * Generate random words with pure js, cryptographically not as strong & safe as native implementation.
  843. * @param {TypedArray} typedArray The array to fill.
  844. * @return {TypedArray} The random values.
  845. */
  846. getRandomValues(typedArray) {
  847. const words = new Uint32Array(typedArray.buffer);
  848. const r = (m_w) => {
  849. let m_z = 0x3ade68b1;
  850. const mask = 0xffffffff;
  851. return function () {
  852. m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  853. m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  854. const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5;
  855. return result * (Math.random() > .5 ? 1 : -1);
  856. };
  857. };
  858. for (let i = 0, rcache; i < typedArray.length; i += 4) {
  859. const _r = r((rcache || Math.random()) * 0x100000000);
  860. rcache = _r() * 0x3ade67b7;
  861. words[i / 4] = (_r() * 0x100000000) | 0;
  862. }
  863. return typedArray;
  864. }
  865. };
  866. /** @fileOverview CTR mode implementation.
  867. *
  868. * Special thanks to Roy Nicholson for pointing out a bug in our
  869. * implementation.
  870. *
  871. * @author Emily Stark
  872. * @author Mike Hamburg
  873. * @author Dan Boneh
  874. */
  875. /** Brian Gladman's CTR Mode.
  876. * @constructor
  877. * @param {Object} _prf The aes instance to generate key.
  878. * @param {bitArray} _iv The iv for ctr mode, it must be 128 bits.
  879. */
  880. const mode = {};
  881. /**
  882. * Brian Gladman's CTR Mode.
  883. * @namespace
  884. */
  885. mode.ctrGladman = class {
  886. constructor(prf, iv) {
  887. this._prf = prf;
  888. this._initIv = iv;
  889. this._iv = iv;
  890. }
  891. reset() {
  892. this._iv = this._initIv;
  893. }
  894. /** Input some data to calculate.
  895. * @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
  896. */
  897. update(data) {
  898. return this.calculate(this._prf, data, this._iv);
  899. }
  900. incWord(word) {
  901. if (((word >> 24) & 0xff) === 0xff) { //overflow
  902. let b1 = (word >> 16) & 0xff;
  903. let b2 = (word >> 8) & 0xff;
  904. let b3 = word & 0xff;
  905. if (b1 === 0xff) { // overflow b1
  906. b1 = 0;
  907. if (b2 === 0xff) {
  908. b2 = 0;
  909. if (b3 === 0xff) {
  910. b3 = 0;
  911. } else {
  912. ++b3;
  913. }
  914. } else {
  915. ++b2;
  916. }
  917. } else {
  918. ++b1;
  919. }
  920. word = 0;
  921. word += (b1 << 16);
  922. word += (b2 << 8);
  923. word += b3;
  924. } else {
  925. word += (0x01 << 24);
  926. }
  927. return word;
  928. }
  929. incCounter(counter) {
  930. if ((counter[0] = this.incWord(counter[0])) === 0) {
  931. // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
  932. counter[1] = this.incWord(counter[1]);
  933. }
  934. }
  935. calculate(prf, data, iv) {
  936. let l;
  937. if (!(l = data.length)) {
  938. return [];
  939. }
  940. const bl = bitArray.bitLength(data);
  941. for (let i = 0; i < l; i += 4) {
  942. this.incCounter(iv);
  943. const e = prf.encrypt(iv);
  944. data[i] ^= e[0];
  945. data[i + 1] ^= e[1];
  946. data[i + 2] ^= e[2];
  947. data[i + 3] ^= e[3];
  948. }
  949. return bitArray.clamp(data, bl);
  950. }
  951. };
  952. const misc = {
  953. importKey(password) {
  954. return new misc.hmacSha1(codec.bytes.toBits(password));
  955. },
  956. pbkdf2(prf, salt, count, length) {
  957. count = count || 10000;
  958. if (length < 0 || count < 0) {
  959. throw new Error("invalid params to pbkdf2");
  960. }
  961. const byteLength = ((length >> 5) + 1) << 2;
  962. let u, ui, i, j, k;
  963. const arrayBuffer = new ArrayBuffer(byteLength);
  964. const out = new DataView(arrayBuffer);
  965. let outLength = 0;
  966. const b = bitArray;
  967. salt = codec.bytes.toBits(salt);
  968. for (k = 1; outLength < (byteLength || 1); k++) {
  969. u = ui = prf.encrypt(b.concat(salt, [k]));
  970. for (i = 1; i < count; i++) {
  971. ui = prf.encrypt(ui);
  972. for (j = 0; j < ui.length; j++) {
  973. u[j] ^= ui[j];
  974. }
  975. }
  976. for (i = 0; outLength < (byteLength || 1) && i < u.length; i++) {
  977. out.setInt32(outLength, u[i]);
  978. outLength += 4;
  979. }
  980. }
  981. return arrayBuffer.slice(0, length / 8);
  982. }
  983. };
  984. /** @fileOverview HMAC implementation.
  985. *
  986. * @author Emily Stark
  987. * @author Mike Hamburg
  988. * @author Dan Boneh
  989. */
  990. /** HMAC with the specified hash function.
  991. * @constructor
  992. * @param {bitArray} key the key for HMAC.
  993. * @param {Object} [Hash=hash.sha1] The hash function to use.
  994. */
  995. misc.hmacSha1 = class {
  996. constructor(key) {
  997. const hmac = this;
  998. const Hash = hmac._hash = hash.sha1;
  999. const exKey = [[], []];
  1000. hmac._baseHash = [new Hash(), new Hash()];
  1001. const bs = hmac._baseHash[0].blockSize / 32;
  1002. if (key.length > bs) {
  1003. key = new Hash().update(key).finalize();
  1004. }
  1005. for (let i = 0; i < bs; i++) {
  1006. exKey[0][i] = key[i] ^ 0x36363636;
  1007. exKey[1][i] = key[i] ^ 0x5C5C5C5C;
  1008. }
  1009. hmac._baseHash[0].update(exKey[0]);
  1010. hmac._baseHash[1].update(exKey[1]);
  1011. hmac._resultHash = new Hash(hmac._baseHash[0]);
  1012. }
  1013. reset() {
  1014. const hmac = this;
  1015. hmac._resultHash = new hmac._hash(hmac._baseHash[0]);
  1016. hmac._updated = false;
  1017. }
  1018. update(data) {
  1019. const hmac = this;
  1020. hmac._updated = true;
  1021. hmac._resultHash.update(data);
  1022. }
  1023. digest() {
  1024. const hmac = this;
  1025. const w = hmac._resultHash.finalize();
  1026. const result = new (hmac._hash)(hmac._baseHash[1]).update(w).finalize();
  1027. hmac.reset();
  1028. return result;
  1029. }
  1030. encrypt(data) {
  1031. if (!this._updated) {
  1032. this.update(data);
  1033. return this.digest(data);
  1034. } else {
  1035. throw new Error("encrypt on already updated hmac called!");
  1036. }
  1037. }
  1038. };
  1039. /*
  1040. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1041. Redistribution and use in source and binary forms, with or without
  1042. modification, are permitted provided that the following conditions are met:
  1043. 1. Redistributions of source code must retain the above copyright notice,
  1044. this list of conditions and the following disclaimer.
  1045. 2. Redistributions in binary form must reproduce the above copyright
  1046. notice, this list of conditions and the following disclaimer in
  1047. the documentation and/or other materials provided with the distribution.
  1048. 3. The names of the authors may not be used to endorse or promote products
  1049. derived from this software without specific prior written permission.
  1050. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1051. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1052. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1053. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1054. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1055. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1056. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1057. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1058. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1059. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1060. */
  1061. const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != UNDEFINED_TYPE && typeof crypto.getRandomValues == FUNCTION_TYPE;
  1062. const ERR_INVALID_PASSWORD = "Invalid password";
  1063. const ERR_INVALID_SIGNATURE = "Invalid signature";
  1064. const ERR_ABORT_CHECK_PASSWORD = "zipjs-abort-check-password";
  1065. function getRandomValues(array) {
  1066. if (GET_RANDOM_VALUES_SUPPORTED) {
  1067. return crypto.getRandomValues(array);
  1068. } else {
  1069. return random.getRandomValues(array);
  1070. }
  1071. }
  1072. /*
  1073. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1074. Redistribution and use in source and binary forms, with or without
  1075. modification, are permitted provided that the following conditions are met:
  1076. 1. Redistributions of source code must retain the above copyright notice,
  1077. this list of conditions and the following disclaimer.
  1078. 2. Redistributions in binary form must reproduce the above copyright
  1079. notice, this list of conditions and the following disclaimer in
  1080. the documentation and/or other materials provided with the distribution.
  1081. 3. The names of the authors may not be used to endorse or promote products
  1082. derived from this software without specific prior written permission.
  1083. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1084. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1085. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1086. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1087. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1088. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1089. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1090. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1091. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1092. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1093. */
  1094. const BLOCK_LENGTH = 16;
  1095. const RAW_FORMAT = "raw";
  1096. const PBKDF2_ALGORITHM = { name: "PBKDF2" };
  1097. const HASH_ALGORITHM = { name: "HMAC" };
  1098. const HASH_FUNCTION = "SHA-1";
  1099. const BASE_KEY_ALGORITHM = Object.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
  1100. const DERIVED_BITS_ALGORITHM = Object.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
  1101. const DERIVED_BITS_USAGE = ["deriveBits"];
  1102. const SALT_LENGTH = [8, 12, 16];
  1103. const KEY_LENGTH = [16, 24, 32];
  1104. const SIGNATURE_LENGTH = 10;
  1105. const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
  1106. // deno-lint-ignore valid-typeof
  1107. const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
  1108. const subtle = CRYPTO_API_SUPPORTED && crypto.subtle;
  1109. const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE;
  1110. const codecBytes = codec.bytes;
  1111. const Aes = cipher.aes;
  1112. const CtrGladman = mode.ctrGladman;
  1113. const HmacSha1 = misc.hmacSha1;
  1114. let IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
  1115. let DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
  1116. class AESDecryptionStream extends TransformStream {
  1117. constructor({ password, rawPassword, signed, encryptionStrength, checkPasswordOnly }) {
  1118. super({
  1119. start() {
  1120. Object.assign(this, {
  1121. ready: new Promise(resolve => this.resolveReady = resolve),
  1122. password: encodePassword(password, rawPassword),
  1123. signed,
  1124. strength: encryptionStrength - 1,
  1125. pending: new Uint8Array()
  1126. });
  1127. },
  1128. async transform(chunk, controller) {
  1129. const aesCrypto = this;
  1130. const {
  1131. password,
  1132. strength,
  1133. resolveReady,
  1134. ready
  1135. } = aesCrypto;
  1136. if (password) {
  1137. await createDecryptionKeys(aesCrypto, strength, password, subarray(chunk, 0, SALT_LENGTH[strength] + 2));
  1138. chunk = subarray(chunk, SALT_LENGTH[strength] + 2);
  1139. if (checkPasswordOnly) {
  1140. controller.error(new Error(ERR_ABORT_CHECK_PASSWORD));
  1141. } else {
  1142. resolveReady();
  1143. }
  1144. } else {
  1145. await ready;
  1146. }
  1147. const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
  1148. controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
  1149. },
  1150. async flush(controller) {
  1151. const {
  1152. signed,
  1153. ctr,
  1154. hmac,
  1155. pending,
  1156. ready
  1157. } = this;
  1158. if (hmac && ctr) {
  1159. await ready;
  1160. const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
  1161. const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
  1162. let decryptedChunkArray = new Uint8Array();
  1163. if (chunkToDecrypt.length) {
  1164. const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
  1165. hmac.update(encryptedChunk);
  1166. const decryptedChunk = ctr.update(encryptedChunk);
  1167. decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
  1168. }
  1169. if (signed) {
  1170. const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
  1171. for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
  1172. if (signature[indexSignature] != originalSignature[indexSignature]) {
  1173. throw new Error(ERR_INVALID_SIGNATURE);
  1174. }
  1175. }
  1176. }
  1177. controller.enqueue(decryptedChunkArray);
  1178. }
  1179. }
  1180. });
  1181. }
  1182. }
  1183. class AESEncryptionStream extends TransformStream {
  1184. constructor({ password, rawPassword, encryptionStrength }) {
  1185. // deno-lint-ignore prefer-const
  1186. let stream;
  1187. super({
  1188. start() {
  1189. Object.assign(this, {
  1190. ready: new Promise(resolve => this.resolveReady = resolve),
  1191. password: encodePassword(password, rawPassword),
  1192. strength: encryptionStrength - 1,
  1193. pending: new Uint8Array()
  1194. });
  1195. },
  1196. async transform(chunk, controller) {
  1197. const aesCrypto = this;
  1198. const {
  1199. password,
  1200. strength,
  1201. resolveReady,
  1202. ready
  1203. } = aesCrypto;
  1204. let preamble = new Uint8Array();
  1205. if (password) {
  1206. preamble = await createEncryptionKeys(aesCrypto, strength, password);
  1207. resolveReady();
  1208. } else {
  1209. await ready;
  1210. }
  1211. const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
  1212. output.set(preamble, 0);
  1213. controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
  1214. },
  1215. async flush(controller) {
  1216. const {
  1217. ctr,
  1218. hmac,
  1219. pending,
  1220. ready
  1221. } = this;
  1222. if (hmac && ctr) {
  1223. await ready;
  1224. let encryptedChunkArray = new Uint8Array();
  1225. if (pending.length) {
  1226. const encryptedChunk = ctr.update(toBits(codecBytes, pending));
  1227. hmac.update(encryptedChunk);
  1228. encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
  1229. }
  1230. stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
  1231. controller.enqueue(concat(encryptedChunkArray, stream.signature));
  1232. }
  1233. }
  1234. });
  1235. stream = this;
  1236. }
  1237. }
  1238. function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
  1239. const {
  1240. ctr,
  1241. hmac,
  1242. pending
  1243. } = aesCrypto;
  1244. const inputLength = input.length - paddingEnd;
  1245. if (pending.length) {
  1246. input = concat(pending, input);
  1247. output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
  1248. }
  1249. let offset;
  1250. for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
  1251. const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
  1252. if (verifySignature) {
  1253. hmac.update(inputChunk);
  1254. }
  1255. const outputChunk = ctr.update(inputChunk);
  1256. if (!verifySignature) {
  1257. hmac.update(outputChunk);
  1258. }
  1259. output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
  1260. }
  1261. aesCrypto.pending = subarray(input, offset);
  1262. return output;
  1263. }
  1264. async function createDecryptionKeys(decrypt, strength, password, preamble) {
  1265. const passwordVerificationKey = await createKeys$1(decrypt, strength, password, subarray(preamble, 0, SALT_LENGTH[strength]));
  1266. const passwordVerification = subarray(preamble, SALT_LENGTH[strength]);
  1267. if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
  1268. throw new Error(ERR_INVALID_PASSWORD);
  1269. }
  1270. }
  1271. async function createEncryptionKeys(encrypt, strength, password) {
  1272. const salt = getRandomValues(new Uint8Array(SALT_LENGTH[strength]));
  1273. const passwordVerification = await createKeys$1(encrypt, strength, password, salt);
  1274. return concat(salt, passwordVerification);
  1275. }
  1276. async function createKeys$1(aesCrypto, strength, password, salt) {
  1277. aesCrypto.password = null;
  1278. const baseKey = await importKey(RAW_FORMAT, password, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
  1279. const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), baseKey, 8 * ((KEY_LENGTH[strength] * 2) + 2));
  1280. const compositeKey = new Uint8Array(derivedBits);
  1281. const key = toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[strength]));
  1282. const authentication = toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[strength], KEY_LENGTH[strength] * 2));
  1283. const passwordVerification = subarray(compositeKey, KEY_LENGTH[strength] * 2);
  1284. Object.assign(aesCrypto, {
  1285. keys: {
  1286. key,
  1287. authentication,
  1288. passwordVerification
  1289. },
  1290. ctr: new CtrGladman(new Aes(key), Array.from(COUNTER_DEFAULT_VALUE)),
  1291. hmac: new HmacSha1(authentication)
  1292. });
  1293. return passwordVerification;
  1294. }
  1295. async function importKey(format, password, algorithm, extractable, keyUsages) {
  1296. if (IMPORT_KEY_SUPPORTED) {
  1297. try {
  1298. return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
  1299. } catch {
  1300. IMPORT_KEY_SUPPORTED = false;
  1301. return misc.importKey(password);
  1302. }
  1303. } else {
  1304. return misc.importKey(password);
  1305. }
  1306. }
  1307. async function deriveBits(algorithm, baseKey, length) {
  1308. if (DERIVE_BITS_SUPPORTED) {
  1309. try {
  1310. return await subtle.deriveBits(algorithm, baseKey, length);
  1311. } catch {
  1312. DERIVE_BITS_SUPPORTED = false;
  1313. return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
  1314. }
  1315. } else {
  1316. return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
  1317. }
  1318. }
  1319. function encodePassword(password, rawPassword) {
  1320. if (rawPassword === UNDEFINED_VALUE) {
  1321. return encodeText(password);
  1322. } else {
  1323. return rawPassword;
  1324. }
  1325. }
  1326. function concat(leftArray, rightArray) {
  1327. let array = leftArray;
  1328. if (leftArray.length + rightArray.length) {
  1329. array = new Uint8Array(leftArray.length + rightArray.length);
  1330. array.set(leftArray, 0);
  1331. array.set(rightArray, leftArray.length);
  1332. }
  1333. return array;
  1334. }
  1335. function expand(inputArray, length) {
  1336. if (length && length > inputArray.length) {
  1337. const array = inputArray;
  1338. inputArray = new Uint8Array(length);
  1339. inputArray.set(array, 0);
  1340. }
  1341. return inputArray;
  1342. }
  1343. function subarray(array, begin, end) {
  1344. return array.subarray(begin, end);
  1345. }
  1346. function fromBits(codecBytes, chunk) {
  1347. return codecBytes.fromBits(chunk);
  1348. }
  1349. function toBits(codecBytes, chunk) {
  1350. return codecBytes.toBits(chunk);
  1351. }
  1352. /*
  1353. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1354. Redistribution and use in source and binary forms, with or without
  1355. modification, are permitted provided that the following conditions are met:
  1356. 1. Redistributions of source code must retain the above copyright notice,
  1357. this list of conditions and the following disclaimer.
  1358. 2. Redistributions in binary form must reproduce the above copyright
  1359. notice, this list of conditions and the following disclaimer in
  1360. the documentation and/or other materials provided with the distribution.
  1361. 3. The names of the authors may not be used to endorse or promote products
  1362. derived from this software without specific prior written permission.
  1363. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1364. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1365. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1366. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1367. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1368. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1369. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1370. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1371. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1372. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1373. */
  1374. const HEADER_LENGTH = 12;
  1375. class ZipCryptoDecryptionStream extends TransformStream {
  1376. constructor({ password, passwordVerification, checkPasswordOnly }) {
  1377. super({
  1378. start() {
  1379. Object.assign(this, {
  1380. password,
  1381. passwordVerification
  1382. });
  1383. createKeys(this, password);
  1384. },
  1385. transform(chunk, controller) {
  1386. const zipCrypto = this;
  1387. if (zipCrypto.password) {
  1388. const decryptedHeader = decrypt(zipCrypto, chunk.subarray(0, HEADER_LENGTH));
  1389. zipCrypto.password = null;
  1390. if (decryptedHeader.at(-1) != zipCrypto.passwordVerification) {
  1391. throw new Error(ERR_INVALID_PASSWORD);
  1392. }
  1393. chunk = chunk.subarray(HEADER_LENGTH);
  1394. }
  1395. if (checkPasswordOnly) {
  1396. controller.error(new Error(ERR_ABORT_CHECK_PASSWORD));
  1397. } else {
  1398. controller.enqueue(decrypt(zipCrypto, chunk));
  1399. }
  1400. }
  1401. });
  1402. }
  1403. }
  1404. class ZipCryptoEncryptionStream extends TransformStream {
  1405. constructor({ password, passwordVerification }) {
  1406. super({
  1407. start() {
  1408. Object.assign(this, {
  1409. password,
  1410. passwordVerification
  1411. });
  1412. createKeys(this, password);
  1413. },
  1414. transform(chunk, controller) {
  1415. const zipCrypto = this;
  1416. let output;
  1417. let offset;
  1418. if (zipCrypto.password) {
  1419. zipCrypto.password = null;
  1420. const header = getRandomValues(new Uint8Array(HEADER_LENGTH));
  1421. header[HEADER_LENGTH - 1] = zipCrypto.passwordVerification;
  1422. output = new Uint8Array(chunk.length + header.length);
  1423. output.set(encrypt(zipCrypto, header), 0);
  1424. offset = HEADER_LENGTH;
  1425. } else {
  1426. output = new Uint8Array(chunk.length);
  1427. offset = 0;
  1428. }
  1429. output.set(encrypt(zipCrypto, chunk), offset);
  1430. controller.enqueue(output);
  1431. }
  1432. });
  1433. }
  1434. }
  1435. function decrypt(target, input) {
  1436. const output = new Uint8Array(input.length);
  1437. for (let index = 0; index < input.length; index++) {
  1438. output[index] = getByte(target) ^ input[index];
  1439. updateKeys(target, output[index]);
  1440. }
  1441. return output;
  1442. }
  1443. function encrypt(target, input) {
  1444. const output = new Uint8Array(input.length);
  1445. for (let index = 0; index < input.length; index++) {
  1446. output[index] = getByte(target) ^ input[index];
  1447. updateKeys(target, input[index]);
  1448. }
  1449. return output;
  1450. }
  1451. function createKeys(target, password) {
  1452. const keys = [0x12345678, 0x23456789, 0x34567890];
  1453. Object.assign(target, {
  1454. keys,
  1455. crcKey0: new Crc32(keys[0]),
  1456. crcKey2: new Crc32(keys[2])
  1457. });
  1458. for (let index = 0; index < password.length; index++) {
  1459. updateKeys(target, password.charCodeAt(index));
  1460. }
  1461. }
  1462. function updateKeys(target, byte) {
  1463. let [key0, key1, key2] = target.keys;
  1464. target.crcKey0.append([byte]);
  1465. key0 = ~target.crcKey0.get();
  1466. key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
  1467. target.crcKey2.append([key1 >>> 24]);
  1468. key2 = ~target.crcKey2.get();
  1469. target.keys = [key0, key1, key2];
  1470. }
  1471. function getByte(target) {
  1472. const temp = target.keys[2] | 2;
  1473. return getInt8(Math.imul(temp, (temp ^ 1)) >>> 8);
  1474. }
  1475. function getInt8(number) {
  1476. return number & 0xFF;
  1477. }
  1478. function getInt32(number) {
  1479. return number & 0xFFFFFFFF;
  1480. }
  1481. /*
  1482. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  1483. Redistribution and use in source and binary forms, with or without
  1484. modification, are permitted provided that the following conditions are met:
  1485. 1. Redistributions of source code must retain the above copyright notice,
  1486. this list of conditions and the following disclaimer.
  1487. 2. Redistributions in binary form must reproduce the above copyright
  1488. notice, this list of conditions and the following disclaimer in
  1489. the documentation and/or other materials provided with the distribution.
  1490. 3. The names of the authors may not be used to endorse or promote products
  1491. derived from this software without specific prior written permission.
  1492. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1493. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1494. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1495. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1496. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1497. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1498. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1499. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1500. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1501. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1502. */
  1503. const ERR_INVALID_UNCOMPRESSED_SIZE = "Invalid uncompressed size";
  1504. const FORMAT_DEFLATE_RAW = "deflate-raw";
  1505. const FORMAT_DEFLATE64_RAW = "deflate64-raw";
  1506. class DeflateStream extends TransformStream {
  1507. constructor(options, { chunkSize, CompressionStreamZlib, CompressionStream }) {
  1508. super({});
  1509. const { compressed, encrypted, useCompressionStream, zipCrypto, signed, level } = options;
  1510. const stream = this;
  1511. let crc32Stream, encryptionStream;
  1512. let readable = super.readable;
  1513. if ((!encrypted || zipCrypto) && signed) {
  1514. crc32Stream = new Crc32Stream();
  1515. readable = pipeThrough(readable, crc32Stream);
  1516. }
  1517. if (compressed) {
  1518. readable = pipeThroughCommpressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStream, CompressionStreamZlib, CompressionStream);
  1519. }
  1520. if (encrypted) {
  1521. if (zipCrypto) {
  1522. readable = pipeThrough(readable, new ZipCryptoEncryptionStream(options));
  1523. } else {
  1524. encryptionStream = new AESEncryptionStream(options);
  1525. readable = pipeThrough(readable, encryptionStream);
  1526. }
  1527. }
  1528. setReadable(stream, readable, () => {
  1529. let signature;
  1530. if (encrypted && !zipCrypto) {
  1531. signature = encryptionStream.signature;
  1532. }
  1533. if ((!encrypted || zipCrypto) && signed) {
  1534. signature = new DataView(crc32Stream.value.buffer).getUint32(0);
  1535. }
  1536. stream.signature = signature;
  1537. });
  1538. }
  1539. }
  1540. class InflateStream extends TransformStream {
  1541. constructor(options, { chunkSize, DecompressionStreamZlib, DecompressionStream }) {
  1542. super({});
  1543. const { zipCrypto, encrypted, signed, signature, compressed, useCompressionStream, deflate64 } = options;
  1544. let crc32Stream, decryptionStream;
  1545. let readable = super.readable;
  1546. if (encrypted) {
  1547. if (zipCrypto) {
  1548. readable = pipeThrough(readable, new ZipCryptoDecryptionStream(options));
  1549. } else {
  1550. decryptionStream = new AESDecryptionStream(options);
  1551. readable = pipeThrough(readable, decryptionStream);
  1552. }
  1553. }
  1554. if (compressed) {
  1555. readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize, deflate64 }, DecompressionStream, DecompressionStreamZlib, DecompressionStream);
  1556. }
  1557. if ((!encrypted || zipCrypto) && signed) {
  1558. crc32Stream = new Crc32Stream();
  1559. readable = pipeThrough(readable, crc32Stream);
  1560. }
  1561. setReadable(this, readable, () => {
  1562. if ((!encrypted || zipCrypto) && signed) {
  1563. const dataViewSignature = new DataView(crc32Stream.value.buffer);
  1564. if (signature != dataViewSignature.getUint32(0, false)) {
  1565. throw new Error(ERR_INVALID_SIGNATURE);
  1566. }
  1567. }
  1568. });
  1569. }
  1570. }
  1571. function setReadable(stream, readable, flush) {
  1572. readable = pipeThrough(readable, new TransformStream({ flush }));
  1573. Object.defineProperty(stream, "readable", {
  1574. get() {
  1575. return readable;
  1576. }
  1577. });
  1578. }
  1579. function pipeThroughCommpressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamZlib, CompressionStream) {
  1580. const Stream = useCompressionStream && CompressionStreamNative ? CompressionStreamNative : CompressionStreamZlib || CompressionStream;
  1581. const format = options.deflate64 ? FORMAT_DEFLATE64_RAW : FORMAT_DEFLATE_RAW;
  1582. try {
  1583. readable = pipeThrough(readable, new Stream(format, options));
  1584. } catch (error) {
  1585. if (useCompressionStream) {
  1586. if (CompressionStreamZlib) {
  1587. readable = pipeThrough(readable, new CompressionStreamZlib(format, options));
  1588. } else if (CompressionStream) {
  1589. readable = pipeThrough(readable, new CompressionStream(format, options));
  1590. } else {
  1591. throw error;
  1592. }
  1593. } else {
  1594. throw error;
  1595. }
  1596. }
  1597. return readable;
  1598. }
  1599. function pipeThrough(readable, transformStream) {
  1600. return readable.pipeThrough(transformStream);
  1601. }
  1602. /*
  1603. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  1604. Redistribution and use in source and binary forms, with or without
  1605. modification, are permitted provided that the following conditions are met:
  1606. 1. Redistributions of source code must retain the above copyright notice,
  1607. this list of conditions and the following disclaimer.
  1608. 2. Redistributions in binary form must reproduce the above copyright
  1609. notice, this list of conditions and the following disclaimer in
  1610. the documentation and/or other materials provided with the distribution.
  1611. 3. The names of the authors may not be used to endorse or promote products
  1612. derived from this software without specific prior written permission.
  1613. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1614. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1615. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1616. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1617. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1618. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1619. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1620. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1621. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1622. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1623. */
  1624. const MESSAGE_EVENT_TYPE = "message";
  1625. const MESSAGE_START = "start";
  1626. const MESSAGE_PULL = "pull";
  1627. const MESSAGE_DATA = "data";
  1628. const MESSAGE_ACK_DATA = "ack";
  1629. const MESSAGE_CLOSE = "close";
  1630. const CODEC_DEFLATE = "deflate";
  1631. const CODEC_INFLATE = "inflate";
  1632. class CodecStream extends TransformStream {
  1633. constructor(options, config) {
  1634. super({});
  1635. const codec = this;
  1636. const { codecType } = options;
  1637. let Stream;
  1638. if (codecType.startsWith(CODEC_DEFLATE)) {
  1639. Stream = DeflateStream;
  1640. } else if (codecType.startsWith(CODEC_INFLATE)) {
  1641. Stream = InflateStream;
  1642. }
  1643. codec.outputSize = 0;
  1644. let inputSize = 0;
  1645. const stream = new Stream(options, config);
  1646. const readable = super.readable;
  1647. const inputSizeStream = new TransformStream({
  1648. transform(chunk, controller) {
  1649. if (chunk && chunk.length) {
  1650. inputSize += chunk.length;
  1651. controller.enqueue(chunk);
  1652. }
  1653. },
  1654. flush() {
  1655. Object.assign(codec, {
  1656. inputSize
  1657. });
  1658. }
  1659. });
  1660. const outputSizeStream = new TransformStream({
  1661. transform(chunk, controller) {
  1662. if (chunk && chunk.length) {
  1663. controller.enqueue(chunk);
  1664. codec.outputSize += chunk.length;
  1665. if (options.outputSize !== UNDEFINED_VALUE && codec.outputSize > options.outputSize) {
  1666. throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
  1667. }
  1668. }
  1669. },
  1670. flush() {
  1671. const { signature } = stream;
  1672. Object.assign(codec, {
  1673. signature,
  1674. inputSize
  1675. });
  1676. }
  1677. });
  1678. Object.defineProperty(codec, "readable", {
  1679. get() {
  1680. return readable.pipeThrough(inputSizeStream).pipeThrough(stream).pipeThrough(outputSizeStream);
  1681. }
  1682. });
  1683. }
  1684. }
  1685. class ChunkStream extends TransformStream {
  1686. constructor(chunkSize) {
  1687. let pendingChunk;
  1688. super({
  1689. transform,
  1690. flush(controller) {
  1691. if (pendingChunk && pendingChunk.length) {
  1692. controller.enqueue(pendingChunk);
  1693. }
  1694. }
  1695. });
  1696. function transform(chunk, controller) {
  1697. if (pendingChunk) {
  1698. const newChunk = new Uint8Array(pendingChunk.length + chunk.length);
  1699. newChunk.set(pendingChunk);
  1700. newChunk.set(chunk, pendingChunk.length);
  1701. chunk = newChunk;
  1702. pendingChunk = null;
  1703. }
  1704. if (chunk.length > chunkSize) {
  1705. controller.enqueue(chunk.slice(0, chunkSize));
  1706. transform(chunk.slice(chunkSize), controller);
  1707. } else {
  1708. pendingChunk = chunk;
  1709. }
  1710. }
  1711. }
  1712. }
  1713. /*
  1714. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  1715. Redistribution and use in source and binary forms, with or without
  1716. modification, are permitted provided that the following conditions are met:
  1717. 1. Redistributions of source code must retain the above copyright notice,
  1718. this list of conditions and the following disclaimer.
  1719. 2. Redistributions in binary form must reproduce the above copyright
  1720. notice, this list of conditions and the following disclaimer in
  1721. the documentation and/or other materials provided with the distribution.
  1722. 3. The names of the authors may not be used to endorse or promote products
  1723. derived from this software without specific prior written permission.
  1724. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  1725. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1726. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  1727. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  1728. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1729. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  1730. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1731. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1732. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1733. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1734. */
  1735. const MODULE_WORKER_OPTIONS = { type: "module" };
  1736. let webWorkerSupported, webWorkerURI, webWorkerOptions;
  1737. let transferStreamsSupported = true;
  1738. try {
  1739. transferStreamsSupported = typeof structuredClone == FUNCTION_TYPE && structuredClone(new DOMException("", "AbortError")).code !== UNDEFINED_VALUE;
  1740. } catch {
  1741. // ignored
  1742. }
  1743. let initModule$1 = () => { };
  1744. function configureWorker({ initModule: initModuleFunction }) {
  1745. initModule$1 = initModuleFunction;
  1746. }
  1747. class CodecWorker {
  1748. constructor(workerData, { readable, writable }, { options, config, streamOptions, useWebWorkers, transferStreams, workerURI }, onTaskFinished) {
  1749. const { signal } = streamOptions;
  1750. Object.assign(workerData, {
  1751. busy: true,
  1752. readable: readable
  1753. .pipeThrough(new ChunkStream(config.chunkSize))
  1754. .pipeThrough(new ProgressWatcherStream(streamOptions), { signal }),
  1755. writable,
  1756. options: Object.assign({}, options),
  1757. workerURI,
  1758. transferStreams,
  1759. terminate() {
  1760. return new Promise(resolve => {
  1761. const { worker, busy } = workerData;
  1762. if (worker) {
  1763. if (busy) {
  1764. workerData.resolveTerminated = resolve;
  1765. } else {
  1766. worker.terminate();
  1767. resolve();
  1768. }
  1769. workerData.interface = null;
  1770. } else {
  1771. resolve();
  1772. }
  1773. });
  1774. },
  1775. onTaskFinished() {
  1776. const { resolveTerminated } = workerData;
  1777. if (resolveTerminated) {
  1778. workerData.resolveTerminated = null;
  1779. workerData.terminated = true;
  1780. workerData.worker.terminate();
  1781. resolveTerminated();
  1782. }
  1783. workerData.busy = false;
  1784. onTaskFinished(workerData);
  1785. }
  1786. });
  1787. if (webWorkerSupported === UNDEFINED_VALUE) {
  1788. // deno-lint-ignore valid-typeof
  1789. webWorkerSupported = typeof Worker != UNDEFINED_TYPE;
  1790. }
  1791. return (useWebWorkers && webWorkerSupported ? createWebWorkerInterface : createWorkerInterface)(workerData, config);
  1792. }
  1793. }
  1794. class ProgressWatcherStream extends TransformStream {
  1795. constructor({ onstart, onprogress, size, onend }) {
  1796. let chunkOffset = 0;
  1797. super({
  1798. async start() {
  1799. if (onstart) {
  1800. await callHandler(onstart, size);
  1801. }
  1802. },
  1803. async transform(chunk, controller) {
  1804. chunkOffset += chunk.length;
  1805. if (onprogress) {
  1806. await callHandler(onprogress, chunkOffset, size);
  1807. }
  1808. controller.enqueue(chunk);
  1809. },
  1810. async flush() {
  1811. if (onend) {
  1812. await callHandler(onend, chunkOffset);
  1813. }
  1814. }
  1815. });
  1816. }
  1817. }
  1818. async function callHandler(handler, ...parameters) {
  1819. try {
  1820. await handler(...parameters);
  1821. } catch {
  1822. // ignored
  1823. }
  1824. }
  1825. function createWorkerInterface(workerData, config) {
  1826. return {
  1827. run: () => runWorker$1(workerData, config)
  1828. };
  1829. }
  1830. function createWebWorkerInterface(workerData, config) {
  1831. const { baseURI, chunkSize } = config;
  1832. let { wasmURI } = config;
  1833. if (!workerData.interface) {
  1834. // deno-lint-ignore valid-typeof
  1835. if (typeof wasmURI == FUNCTION_TYPE) {
  1836. wasmURI = wasmURI();
  1837. }
  1838. let worker;
  1839. try {
  1840. worker = getWebWorker(workerData.workerURI, baseURI, workerData);
  1841. } catch {
  1842. webWorkerSupported = false;
  1843. return createWorkerInterface(workerData, config);
  1844. }
  1845. Object.assign(workerData, {
  1846. worker,
  1847. interface: {
  1848. run: () => runWebWorker(workerData, { chunkSize, wasmURI, baseURI })
  1849. }
  1850. });
  1851. }
  1852. return workerData.interface;
  1853. }
  1854. async function runWorker$1({ options, readable, writable, onTaskFinished }, config) {
  1855. let codecStream;
  1856. try {
  1857. if (!options.useCompressionStream) {
  1858. try {
  1859. await initModule$1(config);
  1860. } catch {
  1861. options.useCompressionStream = true;
  1862. }
  1863. }
  1864. codecStream = new CodecStream(options, config);
  1865. await readable.pipeThrough(codecStream).pipeTo(writable, { preventClose: true, preventAbort: true });
  1866. const {
  1867. signature,
  1868. inputSize,
  1869. outputSize
  1870. } = codecStream;
  1871. return {
  1872. signature,
  1873. inputSize,
  1874. outputSize
  1875. };
  1876. } catch (error) {
  1877. if (codecStream) {
  1878. error.outputSize = codecStream.outputSize;
  1879. }
  1880. throw error;
  1881. } finally {
  1882. onTaskFinished();
  1883. }
  1884. }
  1885. async function runWebWorker(workerData, config) {
  1886. let resolveResult, rejectResult;
  1887. const result = new Promise((resolve, reject) => {
  1888. resolveResult = resolve;
  1889. rejectResult = reject;
  1890. });
  1891. Object.assign(workerData, {
  1892. reader: null,
  1893. writer: null,
  1894. resolveResult,
  1895. rejectResult,
  1896. result
  1897. });
  1898. const { readable, options } = workerData;
  1899. const { writable, closed } = watchClosedStream(workerData.writable);
  1900. const streamsTransferred = sendMessage({
  1901. type: MESSAGE_START,
  1902. options,
  1903. config,
  1904. readable,
  1905. writable
  1906. }, workerData);
  1907. if (!streamsTransferred) {
  1908. Object.assign(workerData, {
  1909. reader: readable.getReader(),
  1910. writer: writable.getWriter()
  1911. });
  1912. }
  1913. const resultValue = await result;
  1914. if (!streamsTransferred) {
  1915. await writable.getWriter().close();
  1916. }
  1917. await closed;
  1918. return resultValue;
  1919. }
  1920. function watchClosedStream(writableSource) {
  1921. const { writable, readable } = new TransformStream();
  1922. const closed = readable.pipeTo(writableSource, { preventClose: true });
  1923. return { writable, closed };
  1924. }
  1925. function getWebWorker(url, baseURI, workerData, isModuleType, useBlobURI = true) {
  1926. let worker, resolvedURI, resolvedOptions;
  1927. if (webWorkerURI === UNDEFINED_VALUE) {
  1928. // deno-lint-ignore valid-typeof
  1929. const isFunctionURI = typeof url == FUNCTION_TYPE;
  1930. if (isFunctionURI) {
  1931. resolvedURI = url(useBlobURI);
  1932. } else {
  1933. resolvedURI = url;
  1934. }
  1935. const isDataURI = resolvedURI.startsWith("data:");
  1936. const isBlobURI = resolvedURI.startsWith("blob:");
  1937. if (isDataURI || isBlobURI) {
  1938. if (isModuleType === UNDEFINED_VALUE) {
  1939. isModuleType = false;
  1940. }
  1941. if (isModuleType) {
  1942. resolvedOptions = MODULE_WORKER_OPTIONS;
  1943. }
  1944. try {
  1945. worker = new Worker(resolvedURI, resolvedOptions);
  1946. } catch (error) {
  1947. if (isBlobURI) {
  1948. try {
  1949. URL.revokeObjectURL(resolvedURI);
  1950. } catch {
  1951. // ignored
  1952. }
  1953. }
  1954. if (isFunctionURI && isBlobURI) {
  1955. return getWebWorker(url, baseURI, workerData, isModuleType, false);
  1956. } else if (!isModuleType) {
  1957. return getWebWorker(url, baseURI, workerData, true, false);
  1958. } else {
  1959. throw error;
  1960. }
  1961. }
  1962. } else {
  1963. if (isModuleType === UNDEFINED_VALUE) {
  1964. isModuleType = true;
  1965. }
  1966. if (isModuleType) {
  1967. resolvedOptions = MODULE_WORKER_OPTIONS;
  1968. }
  1969. try {
  1970. resolvedURI = new URL(resolvedURI, baseURI);
  1971. } catch {
  1972. // ignored
  1973. }
  1974. try {
  1975. worker = new Worker(resolvedURI, resolvedOptions);
  1976. } catch (error) {
  1977. if (!isModuleType) {
  1978. return getWebWorker(url, baseURI, workerData, false, useBlobURI);
  1979. } else {
  1980. throw error;
  1981. }
  1982. }
  1983. }
  1984. webWorkerURI = resolvedURI;
  1985. webWorkerOptions = resolvedOptions;
  1986. } else {
  1987. worker = new Worker(webWorkerURI, webWorkerOptions);
  1988. }
  1989. worker.addEventListener(MESSAGE_EVENT_TYPE, event => onMessage(event, workerData));
  1990. return worker;
  1991. }
  1992. function sendMessage(message, { worker, writer, onTaskFinished, transferStreams }) {
  1993. try {
  1994. const { value, readable, writable } = message;
  1995. const transferables = [];
  1996. if (value) {
  1997. message.value = value;
  1998. transferables.push(message.value.buffer);
  1999. }
  2000. if (transferStreams && transferStreamsSupported) {
  2001. if (readable) {
  2002. transferables.push(readable);
  2003. }
  2004. if (writable) {
  2005. transferables.push(writable);
  2006. }
  2007. } else {
  2008. message.readable = message.writable = null;
  2009. }
  2010. if (transferables.length) {
  2011. try {
  2012. worker.postMessage(message, transferables);
  2013. return true;
  2014. } catch {
  2015. transferStreamsSupported = false;
  2016. message.readable = message.writable = null;
  2017. worker.postMessage(message);
  2018. }
  2019. } else {
  2020. worker.postMessage(message);
  2021. }
  2022. } catch (error) {
  2023. if (writer) {
  2024. writer.releaseLock();
  2025. }
  2026. onTaskFinished();
  2027. throw error;
  2028. }
  2029. }
  2030. async function onMessage({ data }, workerData) {
  2031. const { type, value, messageId, result, error } = data;
  2032. const { reader, writer, resolveResult, rejectResult, onTaskFinished } = workerData;
  2033. try {
  2034. if (error) {
  2035. const { message, stack, code, name, outputSize } = error;
  2036. const responseError = new Error(message);
  2037. Object.assign(responseError, { stack, code, name, outputSize });
  2038. close(responseError);
  2039. } else {
  2040. if (type == MESSAGE_PULL) {
  2041. const { value, done } = await reader.read();
  2042. sendMessage({ type: MESSAGE_DATA, value, done, messageId }, workerData);
  2043. }
  2044. if (type == MESSAGE_DATA) {
  2045. await writer.ready;
  2046. await writer.write(new Uint8Array(value));
  2047. sendMessage({ type: MESSAGE_ACK_DATA, messageId }, workerData);
  2048. }
  2049. if (type == MESSAGE_CLOSE) {
  2050. close(null, result);
  2051. }
  2052. }
  2053. } catch (error) {
  2054. sendMessage({ type: MESSAGE_CLOSE, messageId }, workerData);
  2055. close(error);
  2056. }
  2057. function close(error, result) {
  2058. if (error) {
  2059. rejectResult(error);
  2060. } else {
  2061. resolveResult(result);
  2062. }
  2063. if (writer) {
  2064. writer.releaseLock();
  2065. }
  2066. onTaskFinished();
  2067. }
  2068. }
  2069. /*
  2070. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2071. Redistribution and use in source and binary forms, with or without
  2072. modification, are permitted provided that the following conditions are met:
  2073. 1. Redistributions of source code must retain the above copyright notice,
  2074. this list of conditions and the following disclaimer.
  2075. 2. Redistributions in binary form must reproduce the above copyright
  2076. notice, this list of conditions and the following disclaimer in
  2077. the documentation and/or other materials provided with the distribution.
  2078. 3. The names of the authors may not be used to endorse or promote products
  2079. derived from this software without specific prior written permission.
  2080. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2081. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2082. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2083. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2084. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2085. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2086. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2087. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2088. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2089. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2090. */
  2091. let pool = [];
  2092. const pendingRequests = [];
  2093. let indexWorker = 0;
  2094. async function runWorker(stream, workerOptions) {
  2095. const { options, config } = workerOptions;
  2096. const { transferStreams, useWebWorkers, useCompressionStream, compressed, signed, encrypted } = options;
  2097. const { workerURI, maxWorkers } = config;
  2098. workerOptions.transferStreams = transferStreams || transferStreams === UNDEFINED_VALUE;
  2099. const streamCopy = !compressed && !signed && !encrypted && !workerOptions.transferStreams;
  2100. workerOptions.useWebWorkers = !streamCopy && (useWebWorkers || (useWebWorkers === UNDEFINED_VALUE && config.useWebWorkers));
  2101. workerOptions.workerURI = workerOptions.useWebWorkers && workerURI ? workerURI : UNDEFINED_VALUE;
  2102. options.useCompressionStream = useCompressionStream || (useCompressionStream === UNDEFINED_VALUE && config.useCompressionStream);
  2103. return (await getWorker()).run();
  2104. // deno-lint-ignore require-await
  2105. async function getWorker() {
  2106. const workerData = pool.find(workerData => !workerData.busy);
  2107. if (workerData) {
  2108. clearTerminateTimeout(workerData);
  2109. return new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
  2110. } else if (pool.length < maxWorkers) {
  2111. const workerData = { indexWorker };
  2112. indexWorker++;
  2113. pool.push(workerData);
  2114. return new CodecWorker(workerData, stream, workerOptions, onTaskFinished);
  2115. } else {
  2116. return new Promise(resolve => pendingRequests.push({ resolve, stream, workerOptions }));
  2117. }
  2118. }
  2119. function onTaskFinished(workerData) {
  2120. if (pendingRequests.length) {
  2121. const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
  2122. resolve(new CodecWorker(workerData, stream, workerOptions, onTaskFinished));
  2123. } else if (workerData.worker) {
  2124. clearTerminateTimeout(workerData);
  2125. terminateWorker(workerData, workerOptions);
  2126. } else {
  2127. pool = pool.filter(data => data != workerData);
  2128. }
  2129. }
  2130. }
  2131. function terminateWorker(workerData, workerOptions) {
  2132. const { config } = workerOptions;
  2133. const { terminateWorkerTimeout } = config;
  2134. if (Number.isFinite(terminateWorkerTimeout) && terminateWorkerTimeout >= 0) {
  2135. if (workerData.terminated) {
  2136. workerData.terminated = false;
  2137. } else {
  2138. workerData.terminateTimeout = setTimeout(async () => {
  2139. pool = pool.filter(data => data != workerData);
  2140. try {
  2141. await workerData.terminate();
  2142. } catch {
  2143. // ignored
  2144. }
  2145. }, terminateWorkerTimeout);
  2146. }
  2147. }
  2148. }
  2149. function clearTerminateTimeout(workerData) {
  2150. const { terminateTimeout } = workerData;
  2151. if (terminateTimeout) {
  2152. clearTimeout(terminateTimeout);
  2153. workerData.terminateTimeout = null;
  2154. }
  2155. }
  2156. async function terminateWorkers() {
  2157. await Promise.allSettled(pool.map(workerData => {
  2158. clearTerminateTimeout(workerData);
  2159. return workerData.terminate();
  2160. }));
  2161. }
  2162. /*
  2163. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2164. Redistribution and use in source and binary forms, with or without
  2165. modification, are permitted provided that the following conditions are met:
  2166. 1. Redistributions of source code must retain the above copyright notice,
  2167. this list of conditions and the following disclaimer.
  2168. 2. Redistributions in binary form must reproduce the above copyright
  2169. notice, this list of conditions and the following disclaimer in
  2170. the documentation and/or other materials provided with the distribution.
  2171. 3. The names of the authors may not be used to endorse or promote products
  2172. derived from this software without specific prior written permission.
  2173. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2174. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2175. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2176. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2177. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2178. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2179. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2180. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2181. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2182. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2183. */
  2184. const ERR_HTTP_STATUS = "HTTP error ";
  2185. const ERR_HTTP_RANGE = "HTTP Range not supported";
  2186. const ERR_ITERATOR_COMPLETED_TOO_SOON = "Writer iterator completed too soon";
  2187. const ERR_WRITER_NOT_INITIALIZED = "Writer not initialized";
  2188. const CONTENT_TYPE_TEXT_PLAIN = "text/plain";
  2189. const HTTP_HEADER_CONTENT_LENGTH = "Content-Length";
  2190. const HTTP_HEADER_CONTENT_RANGE = "Content-Range";
  2191. const HTTP_HEADER_ACCEPT_RANGES = "Accept-Ranges";
  2192. const HTTP_HEADER_RANGE = "Range";
  2193. const HTTP_HEADER_CONTENT_TYPE = "Content-Type";
  2194. const HTTP_METHOD_HEAD = "HEAD";
  2195. const HTTP_METHOD_GET = "GET";
  2196. const HTTP_RANGE_UNIT = "bytes";
  2197. const DEFAULT_CHUNK_SIZE = 64 * 1024;
  2198. const DEFAULT_BUFFER_SIZE = 256 * 1024;
  2199. const PROPERTY_NAME_WRITABLE = "writable";
  2200. class Stream {
  2201. constructor() {
  2202. this.size = 0;
  2203. }
  2204. init() {
  2205. this.initialized = true;
  2206. }
  2207. }
  2208. class Reader extends Stream {
  2209. get readable() {
  2210. const reader = this;
  2211. const { chunkSize = DEFAULT_CHUNK_SIZE } = reader;
  2212. const readable = new ReadableStream({
  2213. start() {
  2214. this.chunkOffset = 0;
  2215. },
  2216. async pull(controller) {
  2217. const { offset = 0, size, diskNumberStart } = readable;
  2218. const { chunkOffset } = this;
  2219. const dataSize = size === UNDEFINED_VALUE ? chunkSize : Math.min(chunkSize, size - chunkOffset);
  2220. const data = await readUint8Array(reader, offset + chunkOffset, dataSize, diskNumberStart);
  2221. controller.enqueue(data);
  2222. if ((chunkOffset + chunkSize > size) || (size === UNDEFINED_VALUE && !data.length && dataSize)) {
  2223. controller.close();
  2224. } else {
  2225. this.chunkOffset += chunkSize;
  2226. }
  2227. }
  2228. });
  2229. return readable;
  2230. }
  2231. }
  2232. class Writer extends Stream {
  2233. constructor() {
  2234. super();
  2235. const writer = this;
  2236. const writable = new WritableStream({
  2237. write(chunk) {
  2238. if (!writer.initialized) {
  2239. throw new Error(ERR_WRITER_NOT_INITIALIZED);
  2240. }
  2241. return writer.writeUint8Array(chunk);
  2242. }
  2243. });
  2244. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2245. get() {
  2246. return writable;
  2247. }
  2248. });
  2249. }
  2250. writeUint8Array() {
  2251. // abstract
  2252. }
  2253. }
  2254. class Data64URIReader extends Reader {
  2255. constructor(dataURI) {
  2256. super();
  2257. let dataEnd = dataURI.length;
  2258. while (dataURI.charAt(dataEnd - 1) == "=") {
  2259. dataEnd--;
  2260. }
  2261. const dataStart = dataURI.indexOf(",") + 1;
  2262. Object.assign(this, {
  2263. dataURI,
  2264. dataStart,
  2265. size: Math.floor((dataEnd - dataStart) * 0.75)
  2266. });
  2267. }
  2268. readUint8Array(offset, length) {
  2269. const {
  2270. dataStart,
  2271. dataURI
  2272. } = this;
  2273. const dataArray = new Uint8Array(length);
  2274. const start = Math.floor(offset / 3) * 4;
  2275. const bytes = atob(dataURI.substring(start + dataStart, Math.ceil((offset + length) / 3) * 4 + dataStart));
  2276. const delta = offset - Math.floor(start / 4) * 3;
  2277. let effectiveLength = 0;
  2278. for (let indexByte = delta; indexByte < delta + length && indexByte < bytes.length; indexByte++) {
  2279. dataArray[indexByte - delta] = bytes.charCodeAt(indexByte);
  2280. effectiveLength++;
  2281. }
  2282. if (effectiveLength < dataArray.length) {
  2283. return dataArray.subarray(0, effectiveLength);
  2284. } else {
  2285. return dataArray;
  2286. }
  2287. }
  2288. }
  2289. class Data64URIWriter extends Writer {
  2290. constructor(contentType) {
  2291. super();
  2292. Object.assign(this, {
  2293. data: "data:" + (contentType || "") + ";base64,",
  2294. pending: []
  2295. });
  2296. }
  2297. writeUint8Array(array) {
  2298. const writer = this;
  2299. let indexArray = 0;
  2300. let dataString = writer.pending;
  2301. const delta = writer.pending.length;
  2302. writer.pending = "";
  2303. for (indexArray = 0; indexArray < (Math.floor((delta + array.length) / 3) * 3) - delta; indexArray++) {
  2304. dataString += String.fromCharCode(array[indexArray]);
  2305. }
  2306. for (; indexArray < array.length; indexArray++) {
  2307. writer.pending += String.fromCharCode(array[indexArray]);
  2308. }
  2309. if (dataString.length) {
  2310. if (dataString.length > 2) {
  2311. writer.data += btoa(dataString);
  2312. } else {
  2313. writer.pending += dataString;
  2314. }
  2315. }
  2316. }
  2317. getData() {
  2318. return this.data + btoa(this.pending);
  2319. }
  2320. }
  2321. class BlobReader extends Reader {
  2322. constructor(blob) {
  2323. super();
  2324. Object.assign(this, {
  2325. blob,
  2326. size: blob.size
  2327. });
  2328. }
  2329. async readUint8Array(offset, length) {
  2330. const reader = this;
  2331. const offsetEnd = offset + length;
  2332. const blob = offset || offsetEnd < reader.size ? reader.blob.slice(offset, offsetEnd) : reader.blob;
  2333. let arrayBuffer = await blob.arrayBuffer();
  2334. if (arrayBuffer.byteLength > length) {
  2335. arrayBuffer = arrayBuffer.slice(offset, offsetEnd);
  2336. }
  2337. return new Uint8Array(arrayBuffer);
  2338. }
  2339. }
  2340. class BlobWriter extends Stream {
  2341. constructor(contentType) {
  2342. super();
  2343. const writer = this;
  2344. const transformStream = new TransformStream();
  2345. const headers = [];
  2346. if (contentType) {
  2347. headers.push([HTTP_HEADER_CONTENT_TYPE, contentType]);
  2348. }
  2349. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2350. get() {
  2351. return transformStream.writable;
  2352. }
  2353. });
  2354. writer.blob = new Response(transformStream.readable, { headers }).blob();
  2355. }
  2356. getData() {
  2357. return this.blob;
  2358. }
  2359. }
  2360. class TextReader extends BlobReader {
  2361. constructor(text) {
  2362. super(new Blob([text], { type: CONTENT_TYPE_TEXT_PLAIN }));
  2363. }
  2364. }
  2365. class TextWriter extends BlobWriter {
  2366. constructor(encoding) {
  2367. super(encoding);
  2368. Object.assign(this, {
  2369. encoding,
  2370. utf8: !encoding || encoding.toLowerCase() == "utf-8"
  2371. });
  2372. }
  2373. async getData() {
  2374. const {
  2375. encoding,
  2376. utf8
  2377. } = this;
  2378. const blob = await super.getData();
  2379. if (blob.text && utf8) {
  2380. return blob.text();
  2381. } else {
  2382. const reader = new FileReader();
  2383. return new Promise((resolve, reject) => {
  2384. Object.assign(reader, {
  2385. onload: ({ target }) => resolve(target.result),
  2386. onerror: () => reject(reader.error)
  2387. });
  2388. reader.readAsText(blob, encoding);
  2389. });
  2390. }
  2391. }
  2392. }
  2393. class FetchReader extends Reader {
  2394. constructor(url, options) {
  2395. super();
  2396. createHttpReader(this, url, options);
  2397. }
  2398. async init() {
  2399. await initHttpReader(this, sendFetchRequest, getFetchRequestData);
  2400. super.init();
  2401. }
  2402. readUint8Array(index, length) {
  2403. return readUint8ArrayHttpReader(this, index, length, sendFetchRequest, getFetchRequestData);
  2404. }
  2405. }
  2406. class XHRReader extends Reader {
  2407. constructor(url, options) {
  2408. super();
  2409. createHttpReader(this, url, options);
  2410. }
  2411. async init() {
  2412. await initHttpReader(this, sendXMLHttpRequest, getXMLHttpRequestData);
  2413. super.init();
  2414. }
  2415. readUint8Array(index, length) {
  2416. return readUint8ArrayHttpReader(this, index, length, sendXMLHttpRequest, getXMLHttpRequestData);
  2417. }
  2418. }
  2419. function createHttpReader(httpReader, url, options) {
  2420. const {
  2421. preventHeadRequest,
  2422. useRangeHeader,
  2423. forceRangeRequests,
  2424. combineSizeEocd
  2425. } = options;
  2426. options = Object.assign({}, options);
  2427. delete options.preventHeadRequest;
  2428. delete options.useRangeHeader;
  2429. delete options.forceRangeRequests;
  2430. delete options.combineSizeEocd;
  2431. delete options.useXHR;
  2432. Object.assign(httpReader, {
  2433. url,
  2434. options,
  2435. preventHeadRequest,
  2436. useRangeHeader,
  2437. forceRangeRequests,
  2438. combineSizeEocd
  2439. });
  2440. }
  2441. async function initHttpReader(httpReader, sendRequest, getRequestData) {
  2442. const {
  2443. url,
  2444. preventHeadRequest,
  2445. useRangeHeader,
  2446. forceRangeRequests,
  2447. combineSizeEocd
  2448. } = httpReader;
  2449. if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
  2450. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -END_OF_CENTRAL_DIR_LENGTH : undefined));
  2451. const acceptRanges = response.headers.get(HTTP_HEADER_ACCEPT_RANGES);
  2452. if (!forceRangeRequests && (!acceptRanges || acceptRanges.toLowerCase() != HTTP_RANGE_UNIT)) {
  2453. throw new Error(ERR_HTTP_RANGE);
  2454. } else {
  2455. if (combineSizeEocd) {
  2456. httpReader.eocdCache = new Uint8Array(await response.arrayBuffer());
  2457. }
  2458. let contentSize;
  2459. const contentRangeHeader = response.headers.get(HTTP_HEADER_CONTENT_RANGE);
  2460. if (contentRangeHeader) {
  2461. const splitHeader = contentRangeHeader.trim().split(/\s*\/\s*/);
  2462. if (splitHeader.length) {
  2463. const headerValue = splitHeader[1];
  2464. if (headerValue && headerValue != "*") {
  2465. contentSize = Number(headerValue);
  2466. }
  2467. }
  2468. }
  2469. if (contentSize === UNDEFINED_VALUE) {
  2470. await getContentLength(httpReader, sendRequest, getRequestData);
  2471. } else {
  2472. httpReader.size = contentSize;
  2473. }
  2474. }
  2475. } else {
  2476. await getContentLength(httpReader, sendRequest, getRequestData);
  2477. }
  2478. }
  2479. async function readUint8ArrayHttpReader(httpReader, index, length, sendRequest, getRequestData) {
  2480. const {
  2481. useRangeHeader,
  2482. forceRangeRequests,
  2483. eocdCache,
  2484. size,
  2485. options
  2486. } = httpReader;
  2487. if (useRangeHeader || forceRangeRequests) {
  2488. if (eocdCache && index == size - END_OF_CENTRAL_DIR_LENGTH && length == END_OF_CENTRAL_DIR_LENGTH) {
  2489. return eocdCache;
  2490. }
  2491. if (index >= size || length === 0) {
  2492. return new Uint8Array();
  2493. } else {
  2494. if (index + length > size) {
  2495. length = size - index;
  2496. }
  2497. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, index, length));
  2498. if (response.status != 206) {
  2499. throw new Error(ERR_HTTP_RANGE);
  2500. }
  2501. return new Uint8Array(await response.arrayBuffer());
  2502. }
  2503. } else {
  2504. const { data } = httpReader;
  2505. if (!data) {
  2506. await getRequestData(httpReader, options);
  2507. }
  2508. return new Uint8Array(httpReader.data.subarray(index, index + length));
  2509. }
  2510. }
  2511. function getRangeHeaders(httpReader, index = 0, length = 1) {
  2512. return Object.assign({}, getHeaders(httpReader), { [HTTP_HEADER_RANGE]: HTTP_RANGE_UNIT + "=" + (index < 0 ? index : index + "-" + (index + length - 1)) });
  2513. }
  2514. function getHeaders({ options }) {
  2515. const { headers } = options;
  2516. if (headers) {
  2517. if (Symbol.iterator in headers) {
  2518. return Object.fromEntries(headers);
  2519. } else {
  2520. return headers;
  2521. }
  2522. }
  2523. }
  2524. async function getFetchRequestData(httpReader) {
  2525. await getRequestData(httpReader, sendFetchRequest);
  2526. }
  2527. async function getXMLHttpRequestData(httpReader) {
  2528. await getRequestData(httpReader, sendXMLHttpRequest);
  2529. }
  2530. async function getRequestData(httpReader, sendRequest) {
  2531. const response = await sendRequest(HTTP_METHOD_GET, httpReader, getHeaders(httpReader));
  2532. httpReader.data = new Uint8Array(await response.arrayBuffer());
  2533. if (!httpReader.size) {
  2534. httpReader.size = httpReader.data.length;
  2535. }
  2536. }
  2537. async function getContentLength(httpReader, sendRequest, getRequestData) {
  2538. if (httpReader.preventHeadRequest) {
  2539. await getRequestData(httpReader, httpReader.options);
  2540. } else {
  2541. const response = await sendRequest(HTTP_METHOD_HEAD, httpReader, getHeaders(httpReader));
  2542. const contentLength = response.headers.get(HTTP_HEADER_CONTENT_LENGTH);
  2543. if (contentLength) {
  2544. httpReader.size = Number(contentLength);
  2545. } else {
  2546. await getRequestData(httpReader, httpReader.options);
  2547. }
  2548. }
  2549. }
  2550. async function sendFetchRequest(method, { options, url }, headers) {
  2551. const response = await fetch(url, Object.assign({}, options, { method, headers }));
  2552. if (response.status < 400) {
  2553. return response;
  2554. } else {
  2555. throw response.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (response.statusText || response.status));
  2556. }
  2557. }
  2558. function sendXMLHttpRequest(method, { url }, headers) {
  2559. return new Promise((resolve, reject) => {
  2560. const request = new XMLHttpRequest();
  2561. request.addEventListener("load", () => {
  2562. if (request.status < 400) {
  2563. const headers = [];
  2564. request.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(header => {
  2565. const splitHeader = header.trim().split(/\s*:\s*/);
  2566. splitHeader[0] = splitHeader[0].trim().replace(/^[a-z]|-[a-z]/g, value => value.toUpperCase());
  2567. headers.push(splitHeader);
  2568. });
  2569. resolve({
  2570. status: request.status,
  2571. arrayBuffer: () => request.response,
  2572. headers: new Map(headers)
  2573. });
  2574. } else {
  2575. reject(request.status == 416 ? new Error(ERR_HTTP_RANGE) : new Error(ERR_HTTP_STATUS + (request.statusText || request.status)));
  2576. }
  2577. }, false);
  2578. request.addEventListener("error", event => reject(event.detail ? event.detail.error : new Error("Network error")), false);
  2579. request.open(method, url);
  2580. if (headers) {
  2581. for (const entry of Object.entries(headers)) {
  2582. request.setRequestHeader(entry[0], entry[1]);
  2583. }
  2584. }
  2585. request.responseType = "arraybuffer";
  2586. request.send();
  2587. });
  2588. }
  2589. class HttpReader extends Reader {
  2590. constructor(url, options = {}) {
  2591. super();
  2592. Object.assign(this, {
  2593. url,
  2594. reader: options.useXHR ? new XHRReader(url, options) : new FetchReader(url, options)
  2595. });
  2596. }
  2597. set size(value) {
  2598. // ignored
  2599. }
  2600. get size() {
  2601. return this.reader.size;
  2602. }
  2603. async init() {
  2604. await this.reader.init();
  2605. super.init();
  2606. }
  2607. readUint8Array(index, length) {
  2608. return this.reader.readUint8Array(index, length);
  2609. }
  2610. }
  2611. class HttpRangeReader extends HttpReader {
  2612. constructor(url, options = {}) {
  2613. options.useRangeHeader = true;
  2614. super(url, options);
  2615. }
  2616. }
  2617. class Uint8ArrayReader extends Reader {
  2618. constructor(array) {
  2619. super();
  2620. array = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
  2621. Object.assign(this, {
  2622. array,
  2623. size: array.length
  2624. });
  2625. }
  2626. readUint8Array(index, length) {
  2627. return this.array.slice(index, index + length);
  2628. }
  2629. }
  2630. class Uint8ArrayWriter extends Writer {
  2631. constructor(defaultBufferSize) {
  2632. super();
  2633. this.defaultBufferSize = defaultBufferSize || DEFAULT_BUFFER_SIZE;
  2634. }
  2635. init(initSize = 0) {
  2636. Object.assign(this, {
  2637. offset: 0,
  2638. array: new Uint8Array(initSize > 0 ? initSize : this.defaultBufferSize)
  2639. });
  2640. super.init();
  2641. }
  2642. writeUint8Array(array) {
  2643. const writer = this;
  2644. const requiredLength = writer.offset + array.length;
  2645. if (requiredLength > writer.array.length) {
  2646. let newLength = writer.array.length ? writer.array.length * 2 : writer.defaultBufferSize;
  2647. while (newLength < requiredLength) {
  2648. newLength *= 2;
  2649. }
  2650. const previousArray = writer.array;
  2651. writer.array = new Uint8Array(newLength);
  2652. writer.array.set(previousArray);
  2653. }
  2654. writer.array.set(array, writer.offset);
  2655. writer.offset += array.length;
  2656. }
  2657. getData() {
  2658. if (this.offset === this.array.length) {
  2659. return this.array;
  2660. } else {
  2661. return this.array.slice(0, this.offset);
  2662. }
  2663. }
  2664. }
  2665. class SplitDataReader extends Reader {
  2666. constructor(readers) {
  2667. super();
  2668. this.readers = readers;
  2669. }
  2670. async init() {
  2671. const reader = this;
  2672. const { readers } = reader;
  2673. reader.lastDiskNumber = 0;
  2674. reader.lastDiskOffset = 0;
  2675. await Promise.all(readers.map(async (diskReader, indexDiskReader) => {
  2676. await diskReader.init();
  2677. if (indexDiskReader != readers.length - 1) {
  2678. reader.lastDiskOffset += diskReader.size;
  2679. }
  2680. reader.size += diskReader.size;
  2681. }));
  2682. super.init();
  2683. }
  2684. async readUint8Array(offset, length, diskNumber = 0) {
  2685. const reader = this;
  2686. const { readers } = this;
  2687. let result;
  2688. let currentDiskNumber = diskNumber;
  2689. if (currentDiskNumber == -1) {
  2690. currentDiskNumber = readers.length - 1;
  2691. }
  2692. let currentReaderOffset = offset;
  2693. while (readers[currentDiskNumber] && currentReaderOffset >= readers[currentDiskNumber].size) {
  2694. currentReaderOffset -= readers[currentDiskNumber].size;
  2695. currentDiskNumber++;
  2696. }
  2697. const currentReader = readers[currentDiskNumber];
  2698. if (currentReader) {
  2699. const currentReaderSize = currentReader.size;
  2700. if (currentReaderOffset + length <= currentReaderSize) {
  2701. result = await readUint8Array(currentReader, currentReaderOffset, length);
  2702. } else {
  2703. const chunkLength = currentReaderSize - currentReaderOffset;
  2704. result = new Uint8Array(length);
  2705. const firstPart = await readUint8Array(currentReader, currentReaderOffset, chunkLength);
  2706. result.set(firstPart, 0);
  2707. const secondPart = await reader.readUint8Array(offset + chunkLength, length - chunkLength, diskNumber);
  2708. result.set(secondPart, chunkLength);
  2709. if (firstPart.length + secondPart.length < length) {
  2710. result = result.subarray(0, firstPart.length + secondPart.length);
  2711. }
  2712. }
  2713. } else {
  2714. result = new Uint8Array();
  2715. }
  2716. reader.lastDiskNumber = Math.max(currentDiskNumber, reader.lastDiskNumber);
  2717. return result;
  2718. }
  2719. }
  2720. class SplitDataWriter extends Stream {
  2721. constructor(writerGenerator, maxSize = 4294967295) {
  2722. super();
  2723. const writer = this;
  2724. Object.assign(writer, {
  2725. diskNumber: 0,
  2726. diskOffset: 0,
  2727. size: 0,
  2728. maxSize,
  2729. availableSize: maxSize
  2730. });
  2731. let diskSourceWriter, diskWritable, diskWriter;
  2732. const writable = new WritableStream({
  2733. async write(chunk) {
  2734. const { availableSize } = writer;
  2735. if (!diskWriter) {
  2736. const { value, done } = await writerGenerator.next();
  2737. if (done && !value) {
  2738. throw new Error(ERR_ITERATOR_COMPLETED_TOO_SOON);
  2739. } else {
  2740. diskSourceWriter = value;
  2741. diskSourceWriter.size = 0;
  2742. if (diskSourceWriter.maxSize) {
  2743. writer.maxSize = diskSourceWriter.maxSize;
  2744. }
  2745. writer.availableSize = writer.maxSize;
  2746. await initStream(diskSourceWriter);
  2747. diskWritable = value.writable;
  2748. diskWriter = diskWritable.getWriter();
  2749. }
  2750. await this.write(chunk);
  2751. } else if (chunk.length >= availableSize) {
  2752. await writeChunk(chunk.subarray(0, availableSize));
  2753. await closeDisk();
  2754. writer.diskOffset += diskSourceWriter.size;
  2755. writer.diskNumber++;
  2756. diskWriter = null;
  2757. await this.write(chunk.subarray(availableSize));
  2758. } else {
  2759. await writeChunk(chunk);
  2760. }
  2761. },
  2762. async close() {
  2763. await diskWriter.ready;
  2764. await closeDisk();
  2765. }
  2766. });
  2767. Object.defineProperty(writer, PROPERTY_NAME_WRITABLE, {
  2768. get() {
  2769. return writable;
  2770. }
  2771. });
  2772. async function writeChunk(chunk) {
  2773. const chunkLength = chunk.length;
  2774. if (chunkLength) {
  2775. await diskWriter.ready;
  2776. await diskWriter.write(chunk);
  2777. diskSourceWriter.size += chunkLength;
  2778. writer.size += chunkLength;
  2779. writer.availableSize -= chunkLength;
  2780. }
  2781. }
  2782. async function closeDisk() {
  2783. await diskWriter.close();
  2784. }
  2785. }
  2786. }
  2787. class GenericReader {
  2788. constructor(reader) {
  2789. if (Array.isArray(reader)) {
  2790. reader = new SplitDataReader(reader);
  2791. }
  2792. if (reader instanceof ReadableStream) {
  2793. reader = {
  2794. readable: reader
  2795. };
  2796. }
  2797. return reader;
  2798. }
  2799. }
  2800. class GenericWriter {
  2801. constructor(writer) {
  2802. if (writer.writable === UNDEFINED_VALUE && typeof writer.next == FUNCTION_TYPE) {
  2803. writer = new SplitDataWriter(writer);
  2804. }
  2805. if (writer instanceof WritableStream) {
  2806. writer = {
  2807. writable: writer
  2808. };
  2809. }
  2810. if (writer.size === UNDEFINED_VALUE) {
  2811. writer.size = 0;
  2812. }
  2813. if (!(writer instanceof SplitDataWriter)) {
  2814. Object.assign(writer, {
  2815. diskNumber: 0,
  2816. diskOffset: 0,
  2817. availableSize: INFINITY_VALUE,
  2818. maxSize: INFINITY_VALUE
  2819. });
  2820. }
  2821. return writer;
  2822. }
  2823. }
  2824. function isHttpFamily(url) {
  2825. const { baseURI } = getConfiguration();
  2826. const { protocol } = new URL(url, baseURI);
  2827. return protocol == "http:" || protocol == "https:";
  2828. }
  2829. async function initStream(stream, initSize) {
  2830. if (stream.init && !stream.initialized) {
  2831. await stream.init(initSize);
  2832. } else {
  2833. return Promise.resolve();
  2834. }
  2835. }
  2836. function readUint8Array(reader, offset, size, diskNumber) {
  2837. return reader.readUint8Array(offset, size, diskNumber);
  2838. }
  2839. /*
  2840. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  2841. Redistribution and use in source and binary forms, with or without
  2842. modification, are permitted provided that the following conditions are met:
  2843. 1. Redistributions of source code must retain the above copyright notice,
  2844. this list of conditions and the following disclaimer.
  2845. 2. Redistributions in binary form must reproduce the above copyright
  2846. notice, this list of conditions and the following disclaimer in
  2847. the documentation and/or other materials provided with the distribution.
  2848. 3. The names of the authors may not be used to endorse or promote products
  2849. derived from this software without specific prior written permission.
  2850. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2851. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2852. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2853. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2854. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2855. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2856. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2857. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2858. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2859. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2860. */
  2861. /* global TextDecoder */
  2862. const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
  2863. const VALID_CP437 = CP437.length == 256;
  2864. function decodeCP437(stringValue) {
  2865. if (VALID_CP437) {
  2866. let result = "";
  2867. for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
  2868. result += CP437[stringValue[indexCharacter]];
  2869. }
  2870. return result;
  2871. } else {
  2872. return new TextDecoder().decode(stringValue);
  2873. }
  2874. }
  2875. /*
  2876. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  2877. Redistribution and use in source and binary forms, with or without
  2878. modification, are permitted provided that the following conditions are met:
  2879. 1. Redistributions of source code must retain the above copyright notice,
  2880. this list of conditions and the following disclaimer.
  2881. 2. Redistributions in binary form must reproduce the above copyright
  2882. notice, this list of conditions and the following disclaimer in
  2883. the documentation and/or other materials provided with the distribution.
  2884. 3. The names of the authors may not be used to endorse or promote products
  2885. derived from this software without specific prior written permission.
  2886. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2887. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2888. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2889. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2890. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2891. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2892. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2893. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2894. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2895. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2896. */
  2897. function decodeText(value, encoding) {
  2898. if (encoding && encoding.trim().toLowerCase() == "cp437") {
  2899. return decodeCP437(value);
  2900. } else {
  2901. return new TextDecoder(encoding).decode(value);
  2902. }
  2903. }
  2904. /*
  2905. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  2906. Redistribution and use in source and binary forms, with or without
  2907. modification, are permitted provided that the following conditions are met:
  2908. 1. Redistributions of source code must retain the above copyright notice,
  2909. this list of conditions and the following disclaimer.
  2910. 2. Redistributions in binary form must reproduce the above copyright
  2911. notice, this list of conditions and the following disclaimer in
  2912. the documentation and/or other materials provided with the distribution.
  2913. 3. The names of the authors may not be used to endorse or promote products
  2914. derived from this software without specific prior written permission.
  2915. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  2916. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  2917. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  2918. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  2919. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2920. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  2921. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  2922. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  2923. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  2924. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2925. */
  2926. const PROPERTY_NAME_FILENAME = "filename";
  2927. const PROPERTY_NAME_RAW_FILENAME = "rawFilename";
  2928. const PROPERTY_NAME_COMMENT = "comment";
  2929. const PROPERTY_NAME_RAW_COMMENT = "rawComment";
  2930. const PROPERTY_NAME_UNCOMPRESSED_SIZE = "uncompressedSize";
  2931. const PROPERTY_NAME_COMPRESSED_SIZE = "compressedSize";
  2932. const PROPERTY_NAME_OFFSET = "offset";
  2933. const PROPERTY_NAME_DISK_NUMBER_START = "diskNumberStart";
  2934. const PROPERTY_NAME_LAST_MODIFICATION_DATE = "lastModDate";
  2935. const PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE = "rawLastModDate";
  2936. const PROPERTY_NAME_LAST_ACCESS_DATE = "lastAccessDate";
  2937. const PROPERTY_NAME_RAW_LAST_ACCESS_DATE = "rawLastAccessDate";
  2938. const PROPERTY_NAME_CREATION_DATE = "creationDate";
  2939. const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
  2940. const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
  2941. const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
  2942. const PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW = "msdosAttributesRaw";
  2943. const PROPERTY_NAME_MSDOS_ATTRIBUTES = "msdosAttributes";
  2944. const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
  2945. const PROPERTY_NAME_ZIP64 = "zip64";
  2946. const PROPERTY_NAME_ENCRYPTED = "encrypted";
  2947. const PROPERTY_NAME_VERSION = "version";
  2948. const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
  2949. const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
  2950. const PROPERTY_NAME_DIRECTORY = "directory";
  2951. const PROPERTY_NAME_EXECUTABLE = "executable";
  2952. const PROPERTY_NAME_COMPRESSION_METHOD = "compressionMethod";
  2953. const PROPERTY_NAME_SIGNATURE = "signature";
  2954. const PROPERTY_NAME_EXTRA_FIELD = "extraField";
  2955. const PROPERTY_NAME_EXTRA_FIELD_INFOZIP = "extraFieldInfoZip";
  2956. const PROPERTY_NAME_EXTRA_FIELD_UNIX = "extraFieldUnix";
  2957. const PROPERTY_NAME_UID = "uid";
  2958. const PROPERTY_NAME_GID = "gid";
  2959. const PROPERTY_NAME_UNIX_MODE = "unixMode";
  2960. const PROPERTY_NAME_SETUID = "setuid";
  2961. const PROPERTY_NAME_SETGID = "setgid";
  2962. const PROPERTY_NAME_STICKY = "sticky";
  2963. const PROPERTY_NAME_BITFLAG = "bitFlag";
  2964. const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
  2965. const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
  2966. const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
  2967. const PROPERTY_NAME_EXTRA_FIELD_ZIP64 = "extraFieldZip64";
  2968. const PROPERTY_NAME_EXTRA_FIELD_UNICODE_PATH = "extraFieldUnicodePath";
  2969. const PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT = "extraFieldUnicodeComment";
  2970. const PROPERTY_NAME_EXTRA_FIELD_AES = "extraFieldAES";
  2971. const PROPERTY_NAME_EXTRA_FIELD_NTFS = "extraFieldNTFS";
  2972. const PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP = "extraFieldExtendedTimestamp";
  2973. const PROPERTY_NAMES = [
  2974. PROPERTY_NAME_FILENAME,
  2975. PROPERTY_NAME_RAW_FILENAME,
  2976. PROPERTY_NAME_UNCOMPRESSED_SIZE,
  2977. PROPERTY_NAME_COMPRESSED_SIZE,
  2978. PROPERTY_NAME_LAST_MODIFICATION_DATE,
  2979. PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE,
  2980. PROPERTY_NAME_COMMENT,
  2981. PROPERTY_NAME_RAW_COMMENT,
  2982. PROPERTY_NAME_LAST_ACCESS_DATE,
  2983. PROPERTY_NAME_CREATION_DATE,
  2984. PROPERTY_NAME_RAW_CREATION_DATE,
  2985. PROPERTY_NAME_OFFSET,
  2986. PROPERTY_NAME_DISK_NUMBER_START,
  2987. PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES,
  2988. PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES,
  2989. PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW,
  2990. PROPERTY_NAME_MSDOS_ATTRIBUTES,
  2991. PROPERTY_NAME_MS_DOS_COMPATIBLE,
  2992. PROPERTY_NAME_ZIP64,
  2993. PROPERTY_NAME_ENCRYPTED,
  2994. PROPERTY_NAME_VERSION,
  2995. PROPERTY_NAME_VERSION_MADE_BY,
  2996. PROPERTY_NAME_ZIPCRYPTO,
  2997. PROPERTY_NAME_DIRECTORY,
  2998. PROPERTY_NAME_EXECUTABLE,
  2999. PROPERTY_NAME_COMPRESSION_METHOD,
  3000. PROPERTY_NAME_SIGNATURE,
  3001. PROPERTY_NAME_EXTRA_FIELD,
  3002. PROPERTY_NAME_EXTRA_FIELD_UNIX,
  3003. PROPERTY_NAME_EXTRA_FIELD_INFOZIP,
  3004. PROPERTY_NAME_UID,
  3005. PROPERTY_NAME_GID,
  3006. PROPERTY_NAME_UNIX_MODE,
  3007. PROPERTY_NAME_SETUID,
  3008. PROPERTY_NAME_SETGID,
  3009. PROPERTY_NAME_STICKY,
  3010. PROPERTY_NAME_BITFLAG,
  3011. PROPERTY_NAME_FILENAME_UTF8,
  3012. PROPERTY_NAME_COMMENT_UTF8,
  3013. PROPERTY_NAME_RAW_EXTRA_FIELD,
  3014. PROPERTY_NAME_EXTRA_FIELD_ZIP64,
  3015. PROPERTY_NAME_EXTRA_FIELD_UNICODE_PATH,
  3016. PROPERTY_NAME_EXTRA_FIELD_UNICODE_COMMENT,
  3017. PROPERTY_NAME_EXTRA_FIELD_AES,
  3018. PROPERTY_NAME_EXTRA_FIELD_NTFS,
  3019. PROPERTY_NAME_EXTRA_FIELD_EXTENDED_TIMESTAMP
  3020. ];
  3021. class Entry {
  3022. constructor(data) {
  3023. PROPERTY_NAMES.forEach(name => this[name] = data[name]);
  3024. }
  3025. }
  3026. /*
  3027. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  3028. Redistribution and use in source and binary forms, with or without
  3029. modification, are permitted provided that the following conditions are met:
  3030. 1. Redistributions of source code must retain the above copyright notice,
  3031. this list of conditions and the following disclaimer.
  3032. 2. Redistributions in binary form must reproduce the above copyright
  3033. notice, this list of conditions and the following disclaimer in
  3034. the documentation and/or other materials provided with the distribution.
  3035. 3. The names of the authors may not be used to endorse or promote products
  3036. derived from this software without specific prior written permission.
  3037. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3038. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3039. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3040. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3041. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3042. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3043. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3044. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3045. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3046. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3047. */
  3048. const OPTION_FILENAME_ENCODING = "filenameEncoding";
  3049. const OPTION_COMMENT_ENCODING = "commentEncoding";
  3050. const OPTION_DECODE_TEXT = "decodeText";
  3051. const OPTION_EXTRACT_PREPENDED_DATA = "extractPrependedData";
  3052. const OPTION_EXTRACT_APPENDED_DATA = "extractAppendedData";
  3053. const OPTION_PASSWORD = "password";
  3054. const OPTION_RAW_PASSWORD = "rawPassword";
  3055. const OPTION_PASS_THROUGH = "passThrough";
  3056. const OPTION_SIGNAL = "signal";
  3057. const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
  3058. const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
  3059. const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
  3060. const OPTION_CHECK_SIGNATURE = "checkSignature";
  3061. const OPTION_USE_WEB_WORKERS = "useWebWorkers";
  3062. const OPTION_USE_COMPRESSION_STREAM = "useCompressionStream";
  3063. const OPTION_TRANSFER_STREAMS = "transferStreams";
  3064. const OPTION_PREVENT_CLOSE = "preventClose";
  3065. const OPTION_ENCRYPTION_STRENGTH = "encryptionStrength";
  3066. const OPTION_EXTENDED_TIMESTAMP = "extendedTimestamp";
  3067. const OPTION_KEEP_ORDER = "keepOrder";
  3068. const OPTION_LEVEL = "level";
  3069. const OPTION_BUFFERED_WRITE = "bufferedWrite";
  3070. const OPTION_CREATE_TEMP_STREAM = "createTempStream";
  3071. const OPTION_DATA_DESCRIPTOR_SIGNATURE = "dataDescriptorSignature";
  3072. const OPTION_USE_UNICODE_FILE_NAMES = "useUnicodeFileNames";
  3073. const OPTION_DATA_DESCRIPTOR = "dataDescriptor";
  3074. const OPTION_SUPPORT_ZIP64_SPLIT_FILE = "supportZip64SplitFile";
  3075. const OPTION_ENCODE_TEXT = "encodeText";
  3076. const OPTION_OFFSET = "offset";
  3077. const OPTION_USDZ = "usdz";
  3078. const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
  3079. /*
  3080. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  3081. Redistribution and use in source and binary forms, with or without
  3082. modification, are permitted provided that the following conditions are met:
  3083. 1. Redistributions of source code must retain the above copyright notice,
  3084. this list of conditions and the following disclaimer.
  3085. 2. Redistributions in binary form must reproduce the above copyright
  3086. notice, this list of conditions and the following disclaimer in
  3087. the documentation and/or other materials provided with the distribution.
  3088. 3. The names of the authors may not be used to endorse or promote products
  3089. derived from this software without specific prior written permission.
  3090. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3091. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3092. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3093. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3094. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3095. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3096. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3097. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3098. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3099. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3100. */
  3101. const ERR_BAD_FORMAT = "File format is not recognized";
  3102. const ERR_EOCDR_NOT_FOUND = "End of central directory not found";
  3103. const ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = "End of Zip64 central directory locator not found";
  3104. const ERR_CENTRAL_DIRECTORY_NOT_FOUND = "Central directory header not found";
  3105. const ERR_LOCAL_FILE_HEADER_NOT_FOUND = "Local file header not found";
  3106. const ERR_EXTRAFIELD_ZIP64_NOT_FOUND = "Zip64 extra field not found";
  3107. const ERR_ENCRYPTED = "File contains encrypted entry";
  3108. const ERR_UNSUPPORTED_ENCRYPTION = "Encryption method not supported";
  3109. const ERR_UNSUPPORTED_COMPRESSION = "Compression method not supported";
  3110. const ERR_SPLIT_ZIP_FILE = "Split zip file";
  3111. const ERR_OVERLAPPING_ENTRY = "Overlapping entry found";
  3112. const CHARSET_UTF8 = "utf-8";
  3113. const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
  3114. const CHARSET_CP437 = "cp437";
  3115. const ZIP64_PROPERTIES = [
  3116. [PROPERTY_NAME_UNCOMPRESSED_SIZE, MAX_32_BITS],
  3117. [PROPERTY_NAME_COMPRESSED_SIZE, MAX_32_BITS],
  3118. [PROPERTY_NAME_OFFSET, MAX_32_BITS],
  3119. [PROPERTY_NAME_DISK_NUMBER_START, MAX_16_BITS]
  3120. ];
  3121. const ZIP64_EXTRACTION = {
  3122. [MAX_16_BITS]: {
  3123. getValue: getUint32,
  3124. bytes: 4
  3125. },
  3126. [MAX_32_BITS]: {
  3127. getValue: getBigUint64,
  3128. bytes: 8
  3129. }
  3130. };
  3131. class ZipReader {
  3132. constructor(reader, options = {}) {
  3133. Object.assign(this, {
  3134. reader: new GenericReader(reader),
  3135. options,
  3136. config: getConfiguration(),
  3137. readRanges: []
  3138. });
  3139. }
  3140. async* getEntriesGenerator(options = {}) {
  3141. const zipReader = this;
  3142. let { reader } = zipReader;
  3143. const { config } = zipReader;
  3144. await initStream(reader);
  3145. if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
  3146. reader = new BlobReader(await new Response(reader.readable).blob());
  3147. await initStream(reader);
  3148. }
  3149. if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
  3150. throw new Error(ERR_BAD_FORMAT);
  3151. }
  3152. reader.chunkSize = getChunkSize(config);
  3153. const endOfDirectoryInfo = await seekSignature(reader, END_OF_CENTRAL_DIR_SIGNATURE, reader.size, END_OF_CENTRAL_DIR_LENGTH, MAX_16_BITS * 16);
  3154. if (!endOfDirectoryInfo) {
  3155. const signatureArray = await readUint8Array(reader, 0, 4);
  3156. const signatureView = getDataView$1(signatureArray);
  3157. if (getUint32(signatureView) == SPLIT_ZIP_FILE_SIGNATURE) {
  3158. throw new Error(ERR_SPLIT_ZIP_FILE);
  3159. } else {
  3160. throw new Error(ERR_EOCDR_NOT_FOUND);
  3161. }
  3162. }
  3163. const endOfDirectoryView = getDataView$1(endOfDirectoryInfo);
  3164. let directoryDataLength = getUint32(endOfDirectoryView, 12);
  3165. let directoryDataOffset = getUint32(endOfDirectoryView, 16);
  3166. const commentOffset = endOfDirectoryInfo.offset;
  3167. const commentLength = getUint16(endOfDirectoryView, 20);
  3168. const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
  3169. let lastDiskNumber = getUint16(endOfDirectoryView, 4);
  3170. const expectedLastDiskNumber = reader.lastDiskNumber || 0;
  3171. let diskNumber = getUint16(endOfDirectoryView, 6);
  3172. let filesLength = getUint16(endOfDirectoryView, 8);
  3173. let prependedDataLength = 0;
  3174. let startOffset = 0;
  3175. if (directoryDataOffset == MAX_32_BITS || directoryDataLength == MAX_32_BITS || filesLength == MAX_16_BITS || diskNumber == MAX_16_BITS) {
  3176. const endOfDirectoryLocatorArray = await readUint8Array(reader, endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH);
  3177. const endOfDirectoryLocatorView = getDataView$1(endOfDirectoryLocatorArray);
  3178. if (getUint32(endOfDirectoryLocatorView, 0) == ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) {
  3179. directoryDataOffset = getBigUint64(endOfDirectoryLocatorView, 8);
  3180. let endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH, -1);
  3181. let endOfDirectoryView = getDataView$1(endOfDirectoryArray);
  3182. const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH - ZIP64_END_OF_CENTRAL_DIR_LENGTH;
  3183. if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
  3184. const originalDirectoryDataOffset = directoryDataOffset;
  3185. directoryDataOffset = expectedDirectoryDataOffset;
  3186. if (directoryDataOffset > originalDirectoryDataOffset) {
  3187. prependedDataLength = directoryDataOffset - originalDirectoryDataOffset;
  3188. }
  3189. endOfDirectoryArray = await readUint8Array(reader, directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH, -1);
  3190. endOfDirectoryView = getDataView$1(endOfDirectoryArray);
  3191. }
  3192. if (getUint32(endOfDirectoryView, 0) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) {
  3193. throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND);
  3194. }
  3195. if (lastDiskNumber == MAX_16_BITS) {
  3196. lastDiskNumber = getUint32(endOfDirectoryView, 16);
  3197. }
  3198. if (diskNumber == MAX_16_BITS) {
  3199. diskNumber = getUint32(endOfDirectoryView, 20);
  3200. }
  3201. if (filesLength == MAX_16_BITS) {
  3202. filesLength = getBigUint64(endOfDirectoryView, 32);
  3203. }
  3204. if (directoryDataLength == MAX_32_BITS) {
  3205. directoryDataLength = getBigUint64(endOfDirectoryView, 40);
  3206. }
  3207. directoryDataOffset -= directoryDataLength;
  3208. }
  3209. }
  3210. if (directoryDataOffset >= reader.size) {
  3211. prependedDataLength = reader.size - directoryDataOffset - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
  3212. directoryDataOffset = reader.size - directoryDataLength - END_OF_CENTRAL_DIR_LENGTH;
  3213. }
  3214. if (expectedLastDiskNumber != lastDiskNumber) {
  3215. throw new Error(ERR_SPLIT_ZIP_FILE);
  3216. }
  3217. if (directoryDataOffset < 0) {
  3218. throw new Error(ERR_BAD_FORMAT);
  3219. }
  3220. let offset = 0;
  3221. let directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3222. let directoryView = getDataView$1(directoryArray);
  3223. if (directoryDataLength) {
  3224. const expectedDirectoryDataOffset = endOfDirectoryInfo.offset - directoryDataLength;
  3225. if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE && directoryDataOffset != expectedDirectoryDataOffset) {
  3226. const originalDirectoryDataOffset = directoryDataOffset;
  3227. directoryDataOffset = expectedDirectoryDataOffset;
  3228. if (directoryDataOffset > originalDirectoryDataOffset) {
  3229. prependedDataLength += directoryDataOffset - originalDirectoryDataOffset;
  3230. }
  3231. directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3232. directoryView = getDataView$1(directoryArray);
  3233. }
  3234. }
  3235. const expectedDirectoryDataLength = endOfDirectoryInfo.offset - directoryDataOffset - (reader.lastDiskOffset || 0);
  3236. if (directoryDataLength != expectedDirectoryDataLength && expectedDirectoryDataLength >= 0) {
  3237. directoryDataLength = expectedDirectoryDataLength;
  3238. directoryArray = await readUint8Array(reader, directoryDataOffset, directoryDataLength, diskNumber);
  3239. directoryView = getDataView$1(directoryArray);
  3240. }
  3241. if (directoryDataOffset < 0 || directoryDataOffset >= reader.size) {
  3242. throw new Error(ERR_BAD_FORMAT);
  3243. }
  3244. const filenameEncoding = getOptionValue$1(zipReader, options, OPTION_FILENAME_ENCODING);
  3245. const commentEncoding = getOptionValue$1(zipReader, options, OPTION_COMMENT_ENCODING);
  3246. for (let indexFile = 0; indexFile < filesLength; indexFile++) {
  3247. const fileEntry = new ZipEntry$1(reader, config, zipReader.options);
  3248. if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) {
  3249. throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND);
  3250. }
  3251. readCommonHeader(fileEntry, directoryView, offset + 6);
  3252. const languageEncodingFlag = Boolean(fileEntry.bitFlag.languageEncodingFlag);
  3253. const filenameOffset = offset + 46;
  3254. const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
  3255. const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
  3256. const versionMadeBy = getUint16(directoryView, offset + 4);
  3257. const msDosCompatible = versionMadeBy >> 8 == 0;
  3258. const unixCompatible = versionMadeBy >> 8 == 3;
  3259. const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
  3260. const commentLength = getUint16(directoryView, offset + 32);
  3261. const endOffset = commentOffset + commentLength;
  3262. const rawComment = directoryArray.subarray(commentOffset, endOffset);
  3263. const filenameUTF8 = languageEncodingFlag;
  3264. const commentUTF8 = languageEncodingFlag;
  3265. const externalFileAttributes = getUint32(directoryView, offset + 38);
  3266. const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
  3267. const msdosAttributes = {
  3268. readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
  3269. hidden: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_HIDDEN_MASK),
  3270. system: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_SYSTEM_MASK),
  3271. directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
  3272. archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
  3273. };
  3274. const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
  3275. const decode = getOptionValue$1(zipReader, options, OPTION_DECODE_TEXT) || decodeText;
  3276. const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
  3277. const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
  3278. let filename = decode(rawFilename, rawFilenameEncoding);
  3279. if (filename === UNDEFINED_VALUE) {
  3280. filename = decodeText(rawFilename, rawFilenameEncoding);
  3281. }
  3282. let comment = decode(rawComment, rawCommentEncoding);
  3283. if (comment === UNDEFINED_VALUE) {
  3284. comment = decodeText(rawComment, rawCommentEncoding);
  3285. }
  3286. Object.assign(fileEntry, {
  3287. versionMadeBy,
  3288. msDosCompatible,
  3289. compressedSize: 0,
  3290. uncompressedSize: 0,
  3291. commentLength,
  3292. offset: offsetFileEntry,
  3293. diskNumberStart: getUint16(directoryView, offset + 34),
  3294. internalFileAttributes: getUint16(directoryView, offset + 36),
  3295. externalFileAttributes,
  3296. msdosAttributesRaw,
  3297. msdosAttributes,
  3298. rawFilename,
  3299. filenameUTF8,
  3300. commentUTF8,
  3301. rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
  3302. rawComment,
  3303. filename,
  3304. comment
  3305. });
  3306. startOffset = Math.max(offsetFileEntry, startOffset);
  3307. readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6);
  3308. const unixExternalUpper = (fileEntry.externalFileAttributes >> 16) & MAX_16_BITS;
  3309. if (fileEntry.unixMode === UNDEFINED_VALUE && (unixExternalUpper & (FILE_ATTR_UNIX_DEFAULT_MASK | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_TYPE_DIR)) != 0) {
  3310. fileEntry.unixMode = unixExternalUpper;
  3311. }
  3312. const setuid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETUID_MASK);
  3313. const setgid = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_SETGID_MASK);
  3314. const sticky = Boolean(fileEntry.unixMode & FILE_ATTR_UNIX_STICKY_MASK);
  3315. const executable = (fileEntry.unixMode !== UNDEFINED_VALUE)
  3316. ? ((fileEntry.unixMode & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0)
  3317. : (unixCompatible && ((unixExternalUpper & FILE_ATTR_UNIX_EXECUTABLE_MASK) != 0));
  3318. const modeIsDir = fileEntry.unixMode !== UNDEFINED_VALUE && ((fileEntry.unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
  3319. const upperIsDir = ((unixExternalUpper & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_DIR);
  3320. Object.assign(fileEntry, {
  3321. setuid,
  3322. setgid,
  3323. sticky,
  3324. unixExternalUpper,
  3325. internalFileAttribute: fileEntry.internalFileAttributes,
  3326. externalFileAttribute: fileEntry.externalFileAttributes,
  3327. executable,
  3328. directory: modeIsDir || upperIsDir || (msDosCompatible && msdosAttributes.directory) || (filename.endsWith(DIRECTORY_SIGNATURE) && !fileEntry.uncompressedSize),
  3329. zipCrypto: fileEntry.encrypted && !fileEntry.extraFieldAES
  3330. });
  3331. const entry = new Entry(fileEntry);
  3332. entry.getData = (writer, options) => fileEntry.getData(writer, entry, zipReader.readRanges, options);
  3333. entry.arrayBuffer = async options => {
  3334. const writer = new TransformStream();
  3335. const [arrayBuffer] = await Promise.all([
  3336. new Response(writer.readable).arrayBuffer(),
  3337. fileEntry.getData(writer, entry, zipReader.readRanges, options)]);
  3338. return arrayBuffer;
  3339. };
  3340. offset = endOffset;
  3341. const { onprogress } = options;
  3342. if (onprogress) {
  3343. try {
  3344. await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
  3345. } catch {
  3346. // ignored
  3347. }
  3348. }
  3349. yield entry;
  3350. }
  3351. const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
  3352. const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
  3353. if (extractPrependedData) {
  3354. zipReader.prependedData = startOffset > 0 ? await readUint8Array(reader, 0, startOffset) : new Uint8Array();
  3355. }
  3356. zipReader.comment = commentLength ? await readUint8Array(reader, commentOffset + END_OF_CENTRAL_DIR_LENGTH, commentLength) : new Uint8Array();
  3357. if (extractAppendedData) {
  3358. zipReader.appendedData = appendedDataOffset < reader.size ? await readUint8Array(reader, appendedDataOffset, reader.size - appendedDataOffset) : new Uint8Array();
  3359. }
  3360. return true;
  3361. }
  3362. async getEntries(options = {}) {
  3363. const entries = [];
  3364. for await (const entry of this.getEntriesGenerator(options)) {
  3365. entries.push(entry);
  3366. }
  3367. return entries;
  3368. }
  3369. async close() {
  3370. }
  3371. }
  3372. class ZipReaderStream {
  3373. constructor(options = {}) {
  3374. const { readable, writable } = new TransformStream();
  3375. const gen = new ZipReader(readable, options).getEntriesGenerator();
  3376. this.readable = new ReadableStream({
  3377. async pull(controller) {
  3378. const { done, value } = await gen.next();
  3379. if (done)
  3380. return controller.close();
  3381. const chunk = {
  3382. ...value,
  3383. readable: (function () {
  3384. const { readable, writable } = new TransformStream();
  3385. if (value.getData) {
  3386. value.getData(writable);
  3387. return readable;
  3388. }
  3389. })()
  3390. };
  3391. delete chunk.getData;
  3392. controller.enqueue(chunk);
  3393. }
  3394. });
  3395. this.writable = writable;
  3396. }
  3397. }
  3398. let ZipEntry$1 = class ZipEntry {
  3399. constructor(reader, config, options) {
  3400. Object.assign(this, {
  3401. reader,
  3402. config,
  3403. options
  3404. });
  3405. }
  3406. async getData(writer, fileEntry, readRanges, options = {}) {
  3407. const zipEntry = this;
  3408. const {
  3409. reader,
  3410. offset,
  3411. diskNumberStart,
  3412. extraFieldAES,
  3413. extraFieldZip64,
  3414. compressionMethod,
  3415. config,
  3416. bitFlag,
  3417. signature,
  3418. rawLastModDate,
  3419. uncompressedSize,
  3420. compressedSize
  3421. } = zipEntry;
  3422. const {
  3423. dataDescriptor
  3424. } = bitFlag;
  3425. const localDirectory = fileEntry.localDirectory = {};
  3426. const dataArray = await readUint8Array(reader, offset, HEADER_SIZE, diskNumberStart);
  3427. const dataView = getDataView$1(dataArray);
  3428. let password = getOptionValue$1(zipEntry, options, OPTION_PASSWORD);
  3429. let rawPassword = getOptionValue$1(zipEntry, options, OPTION_RAW_PASSWORD);
  3430. const passThrough = getOptionValue$1(zipEntry, options, OPTION_PASS_THROUGH);
  3431. password = password && password.length && password;
  3432. rawPassword = rawPassword && rawPassword.length && rawPassword;
  3433. if (extraFieldAES) {
  3434. if (extraFieldAES.originalCompressionMethod != COMPRESSION_METHOD_AES) {
  3435. throw new Error(ERR_UNSUPPORTED_COMPRESSION);
  3436. }
  3437. }
  3438. if ((compressionMethod != COMPRESSION_METHOD_STORE && compressionMethod != COMPRESSION_METHOD_DEFLATE && compressionMethod != COMPRESSION_METHOD_DEFLATE_64) && !passThrough) {
  3439. throw new Error(ERR_UNSUPPORTED_COMPRESSION);
  3440. }
  3441. if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) {
  3442. throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND);
  3443. }
  3444. readCommonHeader(localDirectory, dataView, 4);
  3445. const {
  3446. extraFieldLength,
  3447. filenameLength,
  3448. lastAccessDate,
  3449. creationDate
  3450. } = localDirectory;
  3451. localDirectory.rawExtraField = extraFieldLength ?
  3452. await readUint8Array(reader, offset + HEADER_SIZE + filenameLength, extraFieldLength, diskNumberStart) :
  3453. new Uint8Array();
  3454. readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
  3455. Object.assign(fileEntry, { lastAccessDate, creationDate });
  3456. const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
  3457. const zipCrypto = encrypted && !extraFieldAES;
  3458. if (!passThrough) {
  3459. fileEntry.zipCrypto = zipCrypto;
  3460. }
  3461. if (encrypted) {
  3462. if (!zipCrypto && extraFieldAES.strength === UNDEFINED_VALUE) {
  3463. throw new Error(ERR_UNSUPPORTED_ENCRYPTION);
  3464. } else if (!password && !rawPassword) {
  3465. throw new Error(ERR_ENCRYPTED);
  3466. }
  3467. }
  3468. const dataOffset = offset + HEADER_SIZE + filenameLength + extraFieldLength;
  3469. const size = compressedSize;
  3470. const readable = reader.readable;
  3471. Object.assign(readable, {
  3472. diskNumberStart,
  3473. offset: dataOffset,
  3474. size
  3475. });
  3476. const signal = getOptionValue$1(zipEntry, options, OPTION_SIGNAL);
  3477. const checkPasswordOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_PASSWORD_ONLY);
  3478. let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
  3479. const checkOverlappingEntryOnly = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY_ONLY);
  3480. if (checkOverlappingEntryOnly) {
  3481. checkOverlappingEntry = true;
  3482. }
  3483. const { onstart, onprogress, onend } = options;
  3484. const deflate64 = compressionMethod == COMPRESSION_METHOD_DEFLATE_64;
  3485. let useCompressionStream = getOptionValue$1(zipEntry, options, OPTION_USE_COMPRESSION_STREAM);
  3486. if (deflate64) {
  3487. useCompressionStream = false;
  3488. }
  3489. const workerOptions = {
  3490. options: {
  3491. codecType: CODEC_INFLATE,
  3492. password,
  3493. rawPassword,
  3494. zipCrypto,
  3495. encryptionStrength: extraFieldAES && extraFieldAES.strength,
  3496. signed: getOptionValue$1(zipEntry, options, OPTION_CHECK_SIGNATURE) && !passThrough,
  3497. passwordVerification: zipCrypto && (dataDescriptor ? ((rawLastModDate >>> 8) & MAX_8_BITS) : ((signature >>> 24) & MAX_8_BITS)),
  3498. outputSize: passThrough ? compressedSize : uncompressedSize,
  3499. signature,
  3500. compressed: compressionMethod != 0 && !passThrough,
  3501. encrypted: zipEntry.encrypted && !passThrough,
  3502. useWebWorkers: getOptionValue$1(zipEntry, options, OPTION_USE_WEB_WORKERS),
  3503. useCompressionStream,
  3504. transferStreams: getOptionValue$1(zipEntry, options, OPTION_TRANSFER_STREAMS),
  3505. deflate64,
  3506. checkPasswordOnly
  3507. },
  3508. config,
  3509. streamOptions: { signal, size, onstart, onprogress, onend }
  3510. };
  3511. if (checkOverlappingEntry) {
  3512. await detectOverlappingEntry({
  3513. reader,
  3514. fileEntry,
  3515. offset,
  3516. diskNumberStart,
  3517. signature,
  3518. compressedSize,
  3519. uncompressedSize,
  3520. dataOffset,
  3521. dataDescriptor: dataDescriptor || localDirectory.bitFlag.dataDescriptor,
  3522. extraFieldZip64: extraFieldZip64 || localDirectory.extraFieldZip64,
  3523. readRanges
  3524. });
  3525. }
  3526. let writable;
  3527. try {
  3528. if (!checkOverlappingEntryOnly) {
  3529. if (checkPasswordOnly) {
  3530. writer = new WritableStream();
  3531. }
  3532. writer = new GenericWriter(writer);
  3533. await initStream(writer, passThrough ? compressedSize : uncompressedSize);
  3534. ({ writable } = writer);
  3535. const { outputSize } = await runWorker({ readable, writable }, workerOptions);
  3536. writer.size += outputSize;
  3537. if (outputSize != (passThrough ? compressedSize : uncompressedSize)) {
  3538. throw new Error(ERR_INVALID_UNCOMPRESSED_SIZE);
  3539. }
  3540. }
  3541. } catch (error) {
  3542. if (error.outputSize !== UNDEFINED_VALUE) {
  3543. writer.size += error.outputSize;
  3544. }
  3545. if (!checkPasswordOnly || error.message != ERR_ABORT_CHECK_PASSWORD) {
  3546. throw error;
  3547. }
  3548. } finally {
  3549. const preventClose = getOptionValue$1(zipEntry, options, OPTION_PREVENT_CLOSE);
  3550. if (!preventClose && writable && !writable.locked) {
  3551. await writable.getWriter().close();
  3552. }
  3553. }
  3554. return checkPasswordOnly || checkOverlappingEntryOnly ? UNDEFINED_VALUE : writer.getData ? writer.getData() : writable;
  3555. }
  3556. };
  3557. function readCommonHeader(directory, dataView, offset) {
  3558. const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2);
  3559. const encrypted = (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED;
  3560. const rawLastModDate = getUint32(dataView, offset + 6);
  3561. Object.assign(directory, {
  3562. encrypted,
  3563. version: getUint16(dataView, offset),
  3564. bitFlag: {
  3565. level: (rawBitFlag & BITFLAG_LEVEL) >> 1,
  3566. dataDescriptor: (rawBitFlag & BITFLAG_DATA_DESCRIPTOR) == BITFLAG_DATA_DESCRIPTOR,
  3567. languageEncodingFlag: (rawBitFlag & BITFLAG_LANG_ENCODING_FLAG) == BITFLAG_LANG_ENCODING_FLAG
  3568. },
  3569. rawLastModDate,
  3570. lastModDate: getDate(rawLastModDate),
  3571. filenameLength: getUint16(dataView, offset + 22),
  3572. extraFieldLength: getUint16(dataView, offset + 24)
  3573. });
  3574. }
  3575. function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory) {
  3576. const { rawExtraField } = directory;
  3577. const extraField = directory.extraField = new Map();
  3578. const rawExtraFieldView = getDataView$1(new Uint8Array(rawExtraField));
  3579. let offsetExtraField = 0;
  3580. try {
  3581. while (offsetExtraField < rawExtraField.length) {
  3582. const type = getUint16(rawExtraFieldView, offsetExtraField);
  3583. const size = getUint16(rawExtraFieldView, offsetExtraField + 2);
  3584. extraField.set(type, {
  3585. type,
  3586. data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size)
  3587. });
  3588. offsetExtraField += 4 + size;
  3589. }
  3590. } catch {
  3591. // ignored
  3592. }
  3593. const compressionMethod = getUint16(dataView, offset + 4);
  3594. Object.assign(directory, {
  3595. signature: getUint32(dataView, offset + HEADER_OFFSET_SIGNATURE),
  3596. compressedSize: getUint32(dataView, offset + HEADER_OFFSET_COMPRESSED_SIZE),
  3597. uncompressedSize: getUint32(dataView, offset + HEADER_OFFSET_UNCOMPRESSED_SIZE)
  3598. });
  3599. const extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64);
  3600. if (extraFieldZip64) {
  3601. readExtraFieldZip64(extraFieldZip64, directory);
  3602. directory.extraFieldZip64 = extraFieldZip64;
  3603. }
  3604. const extraFieldUnicodePath = extraField.get(EXTRAFIELD_TYPE_UNICODE_PATH);
  3605. if (extraFieldUnicodePath) {
  3606. readExtraFieldUnicode(extraFieldUnicodePath, PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, directory, fileEntry);
  3607. directory.extraFieldUnicodePath = extraFieldUnicodePath;
  3608. }
  3609. const extraFieldUnicodeComment = extraField.get(EXTRAFIELD_TYPE_UNICODE_COMMENT);
  3610. if (extraFieldUnicodeComment) {
  3611. readExtraFieldUnicode(extraFieldUnicodeComment, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT, directory, fileEntry);
  3612. directory.extraFieldUnicodeComment = extraFieldUnicodeComment;
  3613. }
  3614. const extraFieldAES = extraField.get(EXTRAFIELD_TYPE_AES);
  3615. if (extraFieldAES) {
  3616. readExtraFieldAES(extraFieldAES, directory, compressionMethod);
  3617. directory.extraFieldAES = extraFieldAES;
  3618. } else {
  3619. directory.compressionMethod = compressionMethod;
  3620. }
  3621. const extraFieldNTFS = extraField.get(EXTRAFIELD_TYPE_NTFS);
  3622. if (extraFieldNTFS) {
  3623. readExtraFieldNTFS(extraFieldNTFS, directory);
  3624. directory.extraFieldNTFS = extraFieldNTFS;
  3625. }
  3626. const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
  3627. if (extraFieldUnix) {
  3628. readExtraFieldUnix(extraFieldUnix, directory, false);
  3629. directory.extraFieldUnix = extraFieldUnix;
  3630. } else {
  3631. const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
  3632. if (extraFieldInfoZip) {
  3633. readExtraFieldUnix(extraFieldInfoZip, directory, true);
  3634. directory.extraFieldInfoZip = extraFieldInfoZip;
  3635. }
  3636. }
  3637. const extraFieldExtendedTimestamp = extraField.get(EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  3638. if (extraFieldExtendedTimestamp) {
  3639. readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory);
  3640. directory.extraFieldExtendedTimestamp = extraFieldExtendedTimestamp;
  3641. }
  3642. const extraFieldUSDZ = extraField.get(EXTRAFIELD_TYPE_USDZ);
  3643. if (extraFieldUSDZ) {
  3644. directory.extraFieldUSDZ = extraFieldUSDZ;
  3645. }
  3646. }
  3647. function readExtraFieldZip64(extraFieldZip64, directory) {
  3648. directory.zip64 = true;
  3649. const extraFieldView = getDataView$1(extraFieldZip64.data);
  3650. const missingProperties = ZIP64_PROPERTIES.filter(([propertyName, max]) => directory[propertyName] == max);
  3651. for (let indexMissingProperty = 0, offset = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) {
  3652. const [propertyName, max] = missingProperties[indexMissingProperty];
  3653. if (directory[propertyName] == max) {
  3654. const extraction = ZIP64_EXTRACTION[max];
  3655. directory[propertyName] = extraFieldZip64[propertyName] = extraction.getValue(extraFieldView, offset);
  3656. offset += extraction.bytes;
  3657. } else if (extraFieldZip64[propertyName]) {
  3658. throw new Error(ERR_EXTRAFIELD_ZIP64_NOT_FOUND);
  3659. }
  3660. }
  3661. }
  3662. function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) {
  3663. const extraFieldView = getDataView$1(extraFieldUnicode.data);
  3664. const crc32 = new Crc32();
  3665. crc32.append(fileEntry[rawPropertyName]);
  3666. const dataViewSignature = getDataView$1(new Uint8Array(4));
  3667. dataViewSignature.setUint32(0, crc32.get(), true);
  3668. const signature = getUint32(extraFieldView, 1);
  3669. Object.assign(extraFieldUnicode, {
  3670. version: getUint8(extraFieldView, 0),
  3671. [propertyName]: decodeText(extraFieldUnicode.data.subarray(5)),
  3672. valid: !fileEntry.bitFlag.languageEncodingFlag && signature == getUint32(dataViewSignature, 0)
  3673. });
  3674. if (extraFieldUnicode.valid) {
  3675. directory[propertyName] = extraFieldUnicode[propertyName];
  3676. directory[propertyName + PROPERTY_NAME_UTF8_SUFFIX] = true;
  3677. }
  3678. }
  3679. function readExtraFieldAES(extraFieldAES, directory, compressionMethod) {
  3680. const extraFieldView = getDataView$1(extraFieldAES.data);
  3681. const strength = getUint8(extraFieldView, 4);
  3682. Object.assign(extraFieldAES, {
  3683. vendorVersion: getUint8(extraFieldView, 0),
  3684. vendorId: getUint8(extraFieldView, 2),
  3685. strength,
  3686. originalCompressionMethod: compressionMethod,
  3687. compressionMethod: getUint16(extraFieldView, 5)
  3688. });
  3689. directory.compressionMethod = extraFieldAES.compressionMethod;
  3690. }
  3691. function readExtraFieldNTFS(extraFieldNTFS, directory) {
  3692. const extraFieldView = getDataView$1(extraFieldNTFS.data);
  3693. let offsetExtraField = 4;
  3694. let tag1Data;
  3695. try {
  3696. while (offsetExtraField < extraFieldNTFS.data.length && !tag1Data) {
  3697. const tagValue = getUint16(extraFieldView, offsetExtraField);
  3698. const attributeSize = getUint16(extraFieldView, offsetExtraField + 2);
  3699. if (tagValue == EXTRAFIELD_TYPE_NTFS_TAG1) {
  3700. tag1Data = extraFieldNTFS.data.slice(offsetExtraField + 4, offsetExtraField + 4 + attributeSize);
  3701. }
  3702. offsetExtraField += 4 + attributeSize;
  3703. }
  3704. } catch {
  3705. // ignored
  3706. }
  3707. try {
  3708. if (tag1Data && tag1Data.length == 24) {
  3709. const tag1View = getDataView$1(tag1Data);
  3710. const rawLastModDate = tag1View.getBigUint64(0, true);
  3711. const rawLastAccessDate = tag1View.getBigUint64(8, true);
  3712. const rawCreationDate = tag1View.getBigUint64(16, true);
  3713. Object.assign(extraFieldNTFS, {
  3714. rawLastModDate,
  3715. rawLastAccessDate,
  3716. rawCreationDate
  3717. });
  3718. const lastModDate = getDateNTFS(rawLastModDate);
  3719. const lastAccessDate = getDateNTFS(rawLastAccessDate);
  3720. const creationDate = getDateNTFS(rawCreationDate);
  3721. const extraFieldData = { lastModDate, lastAccessDate, creationDate };
  3722. Object.assign(extraFieldNTFS, extraFieldData);
  3723. Object.assign(directory, extraFieldData);
  3724. }
  3725. } catch {
  3726. // ignored
  3727. }
  3728. }
  3729. function readExtraFieldUnix(extraField, directory, isInfoZip) {
  3730. try {
  3731. const view = getDataView$1(new Uint8Array(extraField.data));
  3732. let offset = 0;
  3733. const version = getUint8(view, offset++);
  3734. const uidSize = getUint8(view, offset++);
  3735. const uidBytes = extraField.data.subarray(offset, offset + uidSize);
  3736. offset += uidSize;
  3737. const uid = unpackUnixId(uidBytes);
  3738. const gidSize = getUint8(view, offset++);
  3739. const gidBytes = extraField.data.subarray(offset, offset + gidSize);
  3740. offset += gidSize;
  3741. const gid = unpackUnixId(gidBytes);
  3742. let unixMode = UNDEFINED_VALUE;
  3743. if (!isInfoZip && offset + 2 <= extraField.data.length) {
  3744. const base = extraField.data;
  3745. const modeView = new DataView(base.buffer, base.byteOffset + offset, 2);
  3746. unixMode = modeView.getUint16(0, true);
  3747. }
  3748. Object.assign(extraField, { version, uid, gid, unixMode });
  3749. if (uid !== UNDEFINED_VALUE) {
  3750. directory.uid = uid;
  3751. }
  3752. if (gid !== UNDEFINED_VALUE) {
  3753. directory.gid = gid;
  3754. }
  3755. if (unixMode !== UNDEFINED_VALUE) {
  3756. directory.unixMode = unixMode;
  3757. }
  3758. } catch {
  3759. // ignored
  3760. }
  3761. }
  3762. function unpackUnixId(bytes) {
  3763. const buffer = new Uint8Array(4);
  3764. buffer.set(bytes, 0);
  3765. const view = new DataView(buffer.buffer, buffer.byteOffset, 4);
  3766. return view.getUint32(0, true);
  3767. }
  3768. function readExtraFieldExtendedTimestamp(extraFieldExtendedTimestamp, directory, localDirectory) {
  3769. const extraFieldView = getDataView$1(extraFieldExtendedTimestamp.data);
  3770. const flags = getUint8(extraFieldView, 0);
  3771. const timeProperties = [];
  3772. const timeRawProperties = [];
  3773. if (localDirectory) {
  3774. if ((flags & 0x1) == 0x1) {
  3775. timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
  3776. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
  3777. }
  3778. if ((flags & 0x2) == 0x2) {
  3779. timeProperties.push(PROPERTY_NAME_LAST_ACCESS_DATE);
  3780. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_ACCESS_DATE);
  3781. }
  3782. if ((flags & 0x4) == 0x4) {
  3783. timeProperties.push(PROPERTY_NAME_CREATION_DATE);
  3784. timeRawProperties.push(PROPERTY_NAME_RAW_CREATION_DATE);
  3785. }
  3786. } else if (extraFieldExtendedTimestamp.data.length >= 5) {
  3787. timeProperties.push(PROPERTY_NAME_LAST_MODIFICATION_DATE);
  3788. timeRawProperties.push(PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE);
  3789. }
  3790. let offset = 1;
  3791. timeProperties.forEach((propertyName, indexProperty) => {
  3792. if (extraFieldExtendedTimestamp.data.length >= offset + 4) {
  3793. const time = getUint32(extraFieldView, offset);
  3794. directory[propertyName] = extraFieldExtendedTimestamp[propertyName] = new Date(time * 1000);
  3795. const rawPropertyName = timeRawProperties[indexProperty];
  3796. extraFieldExtendedTimestamp[rawPropertyName] = time;
  3797. }
  3798. offset += 4;
  3799. });
  3800. }
  3801. async function detectOverlappingEntry({
  3802. reader,
  3803. fileEntry,
  3804. offset,
  3805. diskNumberStart,
  3806. signature,
  3807. compressedSize,
  3808. uncompressedSize,
  3809. dataOffset,
  3810. dataDescriptor,
  3811. extraFieldZip64,
  3812. readRanges
  3813. }) {
  3814. let diskOffset = 0;
  3815. if (diskNumberStart) {
  3816. for (let indexReader = 0; indexReader < diskNumberStart; indexReader++) {
  3817. const diskReader = reader.readers[indexReader];
  3818. diskOffset += diskReader.size;
  3819. }
  3820. }
  3821. let dataDescriptorLength = 0;
  3822. if (dataDescriptor) {
  3823. if (extraFieldZip64) {
  3824. dataDescriptorLength = DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH;
  3825. } else {
  3826. dataDescriptorLength = DATA_DESCRIPTOR_RECORD_LENGTH;
  3827. }
  3828. }
  3829. if (dataDescriptorLength) {
  3830. const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, diskNumberStart);
  3831. const dataDescriptorSignature = getUint32(getDataView$1(dataDescriptorArray), 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
  3832. if (dataDescriptorSignature) {
  3833. const readSignature = getUint32(getDataView$1(dataDescriptorArray), 4);
  3834. let readCompressedSize;
  3835. let readUncompressedSize;
  3836. if (extraFieldZip64) {
  3837. readCompressedSize = getBigUint64(getDataView$1(dataDescriptorArray), 8);
  3838. readUncompressedSize = getBigUint64(getDataView$1(dataDescriptorArray), 16);
  3839. } else {
  3840. readCompressedSize = getUint32(getDataView$1(dataDescriptorArray), 8);
  3841. readUncompressedSize = getUint32(getDataView$1(dataDescriptorArray), 12);
  3842. }
  3843. const matchSignature = (fileEntry.encrypted && !fileEntry.zipCrypto) || readSignature == signature;
  3844. if (matchSignature &&
  3845. readCompressedSize == compressedSize &&
  3846. readUncompressedSize == uncompressedSize) {
  3847. dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  3848. }
  3849. }
  3850. }
  3851. const range = {
  3852. start: diskOffset + offset,
  3853. end: diskOffset + dataOffset + compressedSize + dataDescriptorLength,
  3854. fileEntry
  3855. };
  3856. for (const otherRange of readRanges) {
  3857. if (otherRange.fileEntry != fileEntry && range.start >= otherRange.start && range.start < otherRange.end) {
  3858. const error = new Error(ERR_OVERLAPPING_ENTRY);
  3859. error.overlappingEntry = otherRange.fileEntry;
  3860. throw error;
  3861. }
  3862. }
  3863. readRanges.push(range);
  3864. }
  3865. async function seekSignature(reader, signature, startOffset, minimumBytes, maximumLength) {
  3866. const signatureArray = new Uint8Array(4);
  3867. const signatureView = getDataView$1(signatureArray);
  3868. setUint32$1(signatureView, 0, signature);
  3869. const maximumBytes = minimumBytes + maximumLength;
  3870. return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, startOffset));
  3871. async function seek(length) {
  3872. const offset = startOffset - length;
  3873. const bytes = await readUint8Array(reader, offset, length);
  3874. for (let indexByte = bytes.length - minimumBytes; indexByte >= 0; indexByte--) {
  3875. if (bytes[indexByte] == signatureArray[0] && bytes[indexByte + 1] == signatureArray[1] &&
  3876. bytes[indexByte + 2] == signatureArray[2] && bytes[indexByte + 3] == signatureArray[3]) {
  3877. return {
  3878. offset: offset + indexByte,
  3879. buffer: bytes.slice(indexByte, indexByte + minimumBytes).buffer
  3880. };
  3881. }
  3882. }
  3883. }
  3884. }
  3885. function getOptionValue$1(zipReader, options, name) {
  3886. return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];
  3887. }
  3888. function getDate(timeRaw) {
  3889. const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & MAX_16_BITS;
  3890. try {
  3891. return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
  3892. } catch {
  3893. // ignored
  3894. }
  3895. }
  3896. function getDateNTFS(timeRaw) {
  3897. return new Date((Number((timeRaw / BigInt(10000)) - BigInt(11644473600000))));
  3898. }
  3899. function getUint8(view, offset) {
  3900. return view.getUint8(offset);
  3901. }
  3902. function getUint16(view, offset) {
  3903. return view.getUint16(offset, true);
  3904. }
  3905. function getUint32(view, offset) {
  3906. return view.getUint32(offset, true);
  3907. }
  3908. function getBigUint64(view, offset) {
  3909. return Number(view.getBigUint64(offset, true));
  3910. }
  3911. function setUint32$1(view, offset, value) {
  3912. view.setUint32(offset, value, true);
  3913. }
  3914. function getDataView$1(array) {
  3915. return new DataView(array.buffer);
  3916. }
  3917. /*
  3918. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  3919. Redistribution and use in source and binary forms, with or without
  3920. modification, are permitted provided that the following conditions are met:
  3921. 1. Redistributions of source code must retain the above copyright notice,
  3922. this list of conditions and the following disclaimer.
  3923. 2. Redistributions in binary form must reproduce the above copyright
  3924. notice, this list of conditions and the following disclaimer in
  3925. the documentation and/or other materials provided with the distribution.
  3926. 3. The names of the authors may not be used to endorse or promote products
  3927. derived from this software without specific prior written permission.
  3928. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  3929. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  3930. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  3931. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  3932. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  3933. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  3934. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  3935. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3936. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  3937. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3938. */
  3939. const ERR_DUPLICATED_NAME = "File already exists";
  3940. const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
  3941. const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
  3942. const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
  3943. const ERR_INVALID_VERSION = "Version exceeds 65535";
  3944. const ERR_INVALID_ENCRYPTION_STRENGTH = "The strength must equal 1, 2, or 3";
  3945. const ERR_INVALID_EXTRAFIELD_TYPE = "Extra field type exceeds 65535";
  3946. const ERR_INVALID_EXTRAFIELD_DATA = "Extra field data exceeds 64KB";
  3947. const ERR_UNSUPPORTED_FORMAT = "Zip64 is not supported (set the 'zip64' option to 'true')";
  3948. const ERR_UNDEFINED_UNCOMPRESSED_SIZE = "Undefined uncompressed size";
  3949. const ERR_ZIP_NOT_EMPTY = "Zip file not empty";
  3950. const ERR_INVALID_UID = "Invalid uid (must be integer 0..2^32-1)";
  3951. const ERR_INVALID_GID = "Invalid gid (must be integer 0..2^32-1)";
  3952. const ERR_INVALID_UNIX_MODE = "Invalid UNIX mode (must be integer 0..65535)";
  3953. const ERR_INVALID_UNIX_EXTRA_FIELD_TYPE = "Invalid unixExtraFieldType (must be 'infozip' or 'unix')";
  3954. const ERR_INVALID_MSDOS_ATTRIBUTES = "Invalid msdosAttributesRaw (must be integer 0..255)";
  3955. const ERR_INVALID_MSDOS_DATA = "Invalid msdosAttributes (must be an object with boolean flags)";
  3956. const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
  3957. const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
  3958. const UNIX_EXTRA_FIELD_TYPE = "unix";
  3959. let workers = 0;
  3960. const pendingEntries = [];
  3961. class ZipWriter {
  3962. constructor(writer, options = {}) {
  3963. writer = new GenericWriter(writer);
  3964. const addSplitZipSignature =
  3965. writer.availableSize !== UNDEFINED_VALUE && writer.availableSize > 0 && writer.availableSize !== INFINITY_VALUE &&
  3966. writer.maxSize !== UNDEFINED_VALUE && writer.maxSize > 0 && writer.maxSize !== INFINITY_VALUE;
  3967. Object.assign(this, {
  3968. writer,
  3969. addSplitZipSignature,
  3970. options,
  3971. config: getConfiguration(),
  3972. files: new Map(),
  3973. filenames: new Set(),
  3974. offset: options[OPTION_OFFSET] === UNDEFINED_VALUE ? writer.size || writer.writable.size || 0 : options[OPTION_OFFSET],
  3975. pendingEntriesSize: 0,
  3976. pendingAddFileCalls: new Set(),
  3977. bufferedWrites: 0
  3978. });
  3979. }
  3980. async prependZip(reader) {
  3981. if (this.filenames.size) {
  3982. throw new Error(ERR_ZIP_NOT_EMPTY);
  3983. }
  3984. reader = new GenericReader(reader);
  3985. const zipReader = new ZipReader(reader.readable);
  3986. const entries = await zipReader.getEntries();
  3987. await zipReader.close();
  3988. await reader.readable.pipeTo(this.writer.writable, { preventClose: true, preventAbort: true });
  3989. this.writer.size = this.offset = reader.size;
  3990. this.filenames = new Set(entries.map(entry => entry.filename));
  3991. this.files = new Map(entries.map(entry => {
  3992. const {
  3993. version,
  3994. compressionMethod,
  3995. lastModDate,
  3996. lastAccessDate,
  3997. creationDate,
  3998. rawFilename,
  3999. bitFlag,
  4000. encrypted,
  4001. uncompressedSize,
  4002. compressedSize,
  4003. diskOffset,
  4004. diskNumber,
  4005. zip64
  4006. } = entry;
  4007. let {
  4008. rawExtraFieldZip64,
  4009. rawExtraFieldAES,
  4010. rawExtraFieldExtendedTimestamp,
  4011. rawExtraFieldNTFS,
  4012. rawExtraFieldUnix,
  4013. rawExtraField,
  4014. } = entry;
  4015. const { level, languageEncodingFlag, dataDescriptor } = bitFlag;
  4016. rawExtraFieldZip64 = rawExtraFieldZip64 || new Uint8Array();
  4017. rawExtraFieldAES = rawExtraFieldAES || new Uint8Array();
  4018. rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || new Uint8Array();
  4019. rawExtraFieldNTFS = rawExtraFieldNTFS || new Uint8Array();
  4020. rawExtraFieldUnix = entry.rawExtraFieldUnix || new Uint8Array();
  4021. rawExtraField = rawExtraField || new Uint8Array();
  4022. const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  4023. const zip64UncompressedSize = zip64 && uncompressedSize > MAX_32_BITS;
  4024. const zip64CompressedSize = zip64 && compressedSize > MAX_32_BITS;
  4025. const {
  4026. headerArray,
  4027. headerView
  4028. } = getHeaderArrayData({
  4029. version,
  4030. bitFlag: getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod),
  4031. compressionMethod,
  4032. uncompressedSize,
  4033. compressedSize,
  4034. lastModDate,
  4035. rawFilename,
  4036. zip64CompressedSize,
  4037. zip64UncompressedSize,
  4038. extraFieldLength
  4039. });
  4040. Object.assign(entry, {
  4041. zip64UncompressedSize,
  4042. zip64CompressedSize,
  4043. zip64Offset: zip64 && this.offset - diskOffset > MAX_32_BITS,
  4044. zip64DiskNumberStart: zip64 && diskNumber > MAX_16_BITS,
  4045. rawExtraFieldZip64,
  4046. rawExtraFieldAES,
  4047. rawExtraFieldExtendedTimestamp,
  4048. rawExtraFieldNTFS,
  4049. rawExtraFieldUnix,
  4050. rawExtraField,
  4051. extendedTimestamp: rawExtraFieldExtendedTimestamp.length > 0 || rawExtraFieldNTFS.length > 0,
  4052. extraFieldExtendedTimestampFlag: 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0),
  4053. headerArray,
  4054. headerView
  4055. });
  4056. return [entry.filename, entry];
  4057. }));
  4058. }
  4059. async add(name = "", reader, options = {}) {
  4060. const zipWriter = this;
  4061. const {
  4062. pendingAddFileCalls,
  4063. config
  4064. } = zipWriter;
  4065. if (workers < config.maxWorkers) {
  4066. workers++;
  4067. } else {
  4068. await new Promise(resolve => pendingEntries.push(resolve));
  4069. }
  4070. let promiseAddFile;
  4071. try {
  4072. name = name.trim();
  4073. if (zipWriter.filenames.has(name)) {
  4074. throw new Error(ERR_DUPLICATED_NAME);
  4075. }
  4076. zipWriter.filenames.add(name);
  4077. promiseAddFile = addFile(zipWriter, name, reader, options);
  4078. pendingAddFileCalls.add(promiseAddFile);
  4079. return await promiseAddFile;
  4080. } catch (error) {
  4081. zipWriter.filenames.delete(name);
  4082. throw error;
  4083. } finally {
  4084. pendingAddFileCalls.delete(promiseAddFile);
  4085. const pendingEntry = pendingEntries.shift();
  4086. if (pendingEntry) {
  4087. pendingEntry();
  4088. } else {
  4089. workers--;
  4090. }
  4091. }
  4092. }
  4093. remove(entry) {
  4094. const { filenames, files } = this;
  4095. if (typeof entry == "string") {
  4096. entry = files.get(entry);
  4097. }
  4098. if (entry && entry.filename !== UNDEFINED_VALUE) {
  4099. const { filename } = entry;
  4100. if (filenames.has(filename) && files.has(filename)) {
  4101. filenames.delete(filename);
  4102. files.delete(filename);
  4103. return true;
  4104. }
  4105. }
  4106. return false;
  4107. }
  4108. async close(comment = new Uint8Array(), options = {}) {
  4109. const zipWriter = this;
  4110. const { pendingAddFileCalls, writer } = this;
  4111. const { writable } = writer;
  4112. while (pendingAddFileCalls.size) {
  4113. await Promise.allSettled(Array.from(pendingAddFileCalls));
  4114. }
  4115. await closeFile(zipWriter, comment, options);
  4116. const preventClose = getOptionValue(zipWriter, options, OPTION_PREVENT_CLOSE);
  4117. if (!preventClose) {
  4118. await writable.getWriter().close();
  4119. }
  4120. return writer.getData ? writer.getData() : writable;
  4121. }
  4122. }
  4123. class ZipWriterStream {
  4124. constructor(options = {}) {
  4125. const { readable, writable } = new TransformStream();
  4126. this.readable = readable;
  4127. this.zipWriter = new ZipWriter(writable, options);
  4128. }
  4129. transform(path) {
  4130. const { readable, writable } = new TransformStream({
  4131. flush: () => { this.zipWriter.close(); }
  4132. });
  4133. this.zipWriter.add(path, readable);
  4134. return { readable: this.readable, writable };
  4135. }
  4136. writable(path) {
  4137. const { readable, writable } = new TransformStream();
  4138. this.zipWriter.add(path, readable);
  4139. return writable;
  4140. }
  4141. close(comment = UNDEFINED_VALUE, options = {}) {
  4142. return this.zipWriter.close(comment, options);
  4143. }
  4144. }
  4145. async function addFile(zipWriter, name, reader, options) {
  4146. name = name.trim();
  4147. let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
  4148. let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
  4149. const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
  4150. const uid = getOptionValue(zipWriter, options, PROPERTY_NAME_UID);
  4151. const gid = getOptionValue(zipWriter, options, PROPERTY_NAME_GID);
  4152. let unixMode = getOptionValue(zipWriter, options, PROPERTY_NAME_UNIX_MODE);
  4153. const unixExtraFieldType = getOptionValue(zipWriter, options, OPTION_UNIX_EXTRA_FIELD_TYPE);
  4154. let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
  4155. let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
  4156. let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
  4157. if (uid !== UNDEFINED_VALUE && (uid < 0 || uid > MAX_32_BITS)) {
  4158. throw new Error(ERR_INVALID_UID);
  4159. }
  4160. if (gid !== UNDEFINED_VALUE && (gid < 0 || gid > MAX_32_BITS)) {
  4161. throw new Error(ERR_INVALID_GID);
  4162. }
  4163. if (unixMode !== UNDEFINED_VALUE && (unixMode < 0 || unixMode > MAX_16_BITS)) {
  4164. throw new Error(ERR_INVALID_UNIX_MODE);
  4165. }
  4166. if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
  4167. throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
  4168. }
  4169. let msdosAttributesRaw = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES_RAW);
  4170. let msdosAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_MSDOS_ATTRIBUTES);
  4171. const hasUnixMetadata = uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE || unixExtraFieldType;
  4172. const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
  4173. if (hasUnixMetadata) {
  4174. msDosCompatible = false;
  4175. versionMadeBy = (versionMadeBy & MAX_16_BITS) | (3 << 8);
  4176. } else if (hasMsDosProvided) {
  4177. msDosCompatible = true;
  4178. versionMadeBy = (versionMadeBy & MAX_8_BITS);
  4179. }
  4180. if (msdosAttributesRaw !== UNDEFINED_VALUE && (msdosAttributesRaw < 0 || msdosAttributesRaw > MAX_8_BITS)) {
  4181. throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
  4182. }
  4183. if (msdosAttributes && typeof msdosAttributes !== OBJECT_TYPE) {
  4184. throw new Error(ERR_INVALID_MSDOS_DATA);
  4185. }
  4186. if (versionMadeBy > MAX_16_BITS) {
  4187. throw new Error(ERR_INVALID_VERSION);
  4188. }
  4189. let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
  4190. if (!options[PROPERTY_NAME_DIRECTORY] && name.endsWith(DIRECTORY_SIGNATURE)) {
  4191. options[PROPERTY_NAME_DIRECTORY] = true;
  4192. }
  4193. const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
  4194. if (directory) {
  4195. if (!name.endsWith(DIRECTORY_SIGNATURE)) {
  4196. name += DIRECTORY_SIGNATURE;
  4197. }
  4198. if (externalFileAttributes === 0) {
  4199. externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
  4200. if (!msDosCompatible) {
  4201. externalFileAttributes |= (FILE_ATTR_UNIX_TYPE_DIR | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
  4202. }
  4203. }
  4204. } else if (!msDosCompatible && externalFileAttributes === 0) {
  4205. if (executable) {
  4206. externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
  4207. } else {
  4208. externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
  4209. }
  4210. }
  4211. let unixExternalUpper;
  4212. if (!msDosCompatible) {
  4213. unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
  4214. unixMode = unixMode === UNDEFINED_VALUE ? unixExternalUpper : (unixMode & MAX_16_BITS);
  4215. if (setuid) {
  4216. unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
  4217. } else {
  4218. setuid = Boolean(unixMode & FILE_ATTR_UNIX_SETUID_MASK);
  4219. }
  4220. if (setgid) {
  4221. unixMode |= FILE_ATTR_UNIX_SETGID_MASK;
  4222. } else {
  4223. setgid = Boolean(unixMode & FILE_ATTR_UNIX_SETGID_MASK);
  4224. }
  4225. if (sticky) {
  4226. unixMode |= FILE_ATTR_UNIX_STICKY_MASK;
  4227. } else {
  4228. sticky = Boolean(unixMode & FILE_ATTR_UNIX_STICKY_MASK);
  4229. }
  4230. if (directory) {
  4231. unixMode |= FILE_ATTR_UNIX_TYPE_DIR;
  4232. }
  4233. externalFileAttributes = ((unixMode & MAX_16_BITS) << 16) | (externalFileAttributes & MAX_8_BITS);
  4234. }
  4235. ({ msdosAttributesRaw, msdosAttributes } = normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes));
  4236. if (hasMsDosProvided) {
  4237. externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
  4238. }
  4239. const encode = getOptionValue(zipWriter, options, OPTION_ENCODE_TEXT, encodeText);
  4240. let rawFilename = encode(name);
  4241. if (rawFilename === UNDEFINED_VALUE) {
  4242. rawFilename = encodeText(name);
  4243. }
  4244. if (getLength(rawFilename) > MAX_16_BITS) {
  4245. throw new Error(ERR_INVALID_ENTRY_NAME);
  4246. }
  4247. const comment = options[PROPERTY_NAME_COMMENT] || "";
  4248. let rawComment = encode(comment);
  4249. if (rawComment === UNDEFINED_VALUE) {
  4250. rawComment = encodeText(comment);
  4251. }
  4252. if (getLength(rawComment) > MAX_16_BITS) {
  4253. throw new Error(ERR_INVALID_ENTRY_COMMENT);
  4254. }
  4255. const version = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION, VERSION_DEFLATE);
  4256. if (version > MAX_16_BITS) {
  4257. throw new Error(ERR_INVALID_VERSION);
  4258. }
  4259. const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
  4260. const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
  4261. const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
  4262. const internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
  4263. const passThrough = getOptionValue(zipWriter, options, OPTION_PASS_THROUGH);
  4264. let password, rawPassword;
  4265. if (!passThrough) {
  4266. password = getOptionValue(zipWriter, options, OPTION_PASSWORD);
  4267. rawPassword = getOptionValue(zipWriter, options, OPTION_RAW_PASSWORD);
  4268. }
  4269. const encryptionStrength = getOptionValue(zipWriter, options, OPTION_ENCRYPTION_STRENGTH, 3);
  4270. const zipCrypto = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIPCRYPTO);
  4271. const extendedTimestamp = getOptionValue(zipWriter, options, OPTION_EXTENDED_TIMESTAMP, true);
  4272. const keepOrder = getOptionValue(zipWriter, options, OPTION_KEEP_ORDER, true);
  4273. const useWebWorkers = getOptionValue(zipWriter, options, OPTION_USE_WEB_WORKERS);
  4274. const transferStreams = getOptionValue(zipWriter, options, OPTION_TRANSFER_STREAMS, true);
  4275. const bufferedWrite = getOptionValue(zipWriter, options, OPTION_BUFFERED_WRITE);
  4276. const createTempStream = getOptionValue(zipWriter, options, OPTION_CREATE_TEMP_STREAM);
  4277. const dataDescriptorSignature = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR_SIGNATURE, false);
  4278. const signal = getOptionValue(zipWriter, options, OPTION_SIGNAL);
  4279. const useUnicodeFileNames = getOptionValue(zipWriter, options, OPTION_USE_UNICODE_FILE_NAMES, true);
  4280. const compressionMethod = getOptionValue(zipWriter, options, PROPERTY_NAME_COMPRESSION_METHOD);
  4281. let level = getOptionValue(zipWriter, options, OPTION_LEVEL);
  4282. let useCompressionStream = getOptionValue(zipWriter, options, OPTION_USE_COMPRESSION_STREAM);
  4283. let dataDescriptor = getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR);
  4284. if (bufferedWrite && dataDescriptor === UNDEFINED_VALUE) {
  4285. dataDescriptor = false;
  4286. }
  4287. if (dataDescriptor === UNDEFINED_VALUE || zipCrypto) {
  4288. dataDescriptor = true;
  4289. }
  4290. if (level !== UNDEFINED_VALUE && level != 6) {
  4291. useCompressionStream = false;
  4292. }
  4293. if (!useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamZlib === UNDEFINED_VALUE)) {
  4294. level = 0;
  4295. }
  4296. let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
  4297. if (!zipCrypto && (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) && !(encryptionStrength >= 1 && encryptionStrength <= 3)) {
  4298. throw new Error(ERR_INVALID_ENCRYPTION_STRENGTH);
  4299. }
  4300. let rawExtraField = new Uint8Array();
  4301. const extraField = options[PROPERTY_NAME_EXTRA_FIELD];
  4302. if (extraField) {
  4303. let extraFieldSize = 0;
  4304. let offset = 0;
  4305. extraField.forEach(data => extraFieldSize += 4 + getLength(data));
  4306. rawExtraField = new Uint8Array(extraFieldSize);
  4307. extraField.forEach((data, type) => {
  4308. if (type > MAX_16_BITS) {
  4309. throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
  4310. }
  4311. if (getLength(data) > MAX_16_BITS) {
  4312. throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
  4313. }
  4314. arraySet(rawExtraField, new Uint16Array([type]), offset);
  4315. arraySet(rawExtraField, new Uint16Array([getLength(data)]), offset + 2);
  4316. arraySet(rawExtraField, data, offset + 4);
  4317. offset += 4 + getLength(data);
  4318. });
  4319. }
  4320. let maximumCompressedSize = 0;
  4321. let maximumEntrySize = 0;
  4322. let uncompressedSize = 0;
  4323. if (passThrough) {
  4324. uncompressedSize = options[PROPERTY_NAME_UNCOMPRESSED_SIZE];
  4325. if (uncompressedSize === UNDEFINED_VALUE) {
  4326. throw new Error(ERR_UNDEFINED_UNCOMPRESSED_SIZE);
  4327. }
  4328. }
  4329. const zip64Enabled = zip64 === true;
  4330. if (reader) {
  4331. reader = new GenericReader(reader);
  4332. await initStream(reader);
  4333. if (!passThrough) {
  4334. if (reader.size === UNDEFINED_VALUE) {
  4335. dataDescriptor = true;
  4336. if (zip64 || zip64 === UNDEFINED_VALUE) {
  4337. zip64 = true;
  4338. uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
  4339. }
  4340. } else {
  4341. options.uncompressedSize = uncompressedSize = reader.size;
  4342. maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
  4343. }
  4344. } else {
  4345. options.uncompressedSize = uncompressedSize;
  4346. maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
  4347. }
  4348. }
  4349. const { diskOffset, diskNumber } = zipWriter.writer;
  4350. const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
  4351. const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
  4352. if (zip64UncompressedSize || zip64CompressedSize) {
  4353. if (zip64 === false) {
  4354. throw new Error(ERR_UNSUPPORTED_FORMAT);
  4355. } else {
  4356. zip64 = true;
  4357. }
  4358. }
  4359. zip64 = zip64 || false;
  4360. const encrypted = getOptionValue(zipWriter, options, PROPERTY_NAME_ENCRYPTED);
  4361. options = Object.assign({}, options, {
  4362. rawFilename,
  4363. rawComment,
  4364. version,
  4365. versionMadeBy,
  4366. lastModDate,
  4367. lastAccessDate,
  4368. creationDate,
  4369. rawExtraField,
  4370. zip64,
  4371. zip64UncompressedSize,
  4372. zip64CompressedSize,
  4373. password,
  4374. rawPassword,
  4375. level,
  4376. useWebWorkers,
  4377. transferStreams,
  4378. encryptionStrength,
  4379. extendedTimestamp,
  4380. zipCrypto,
  4381. bufferedWrite,
  4382. createTempStream,
  4383. keepOrder,
  4384. useUnicodeFileNames,
  4385. dataDescriptor,
  4386. dataDescriptorSignature,
  4387. signal,
  4388. msDosCompatible,
  4389. internalFileAttribute: internalFileAttributes,
  4390. internalFileAttributes,
  4391. externalFileAttribute: externalFileAttributes,
  4392. externalFileAttributes,
  4393. useCompressionStream,
  4394. passThrough,
  4395. encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
  4396. signature: options[PROPERTY_NAME_SIGNATURE],
  4397. compressionMethod,
  4398. uncompressedSize,
  4399. offset: zipWriter.offset - diskOffset,
  4400. diskNumberStart: diskNumber,
  4401. uid,
  4402. gid,
  4403. setuid,
  4404. setgid,
  4405. sticky,
  4406. unixMode,
  4407. msdosAttributesRaw,
  4408. msdosAttributes,
  4409. unixExternalUpper
  4410. });
  4411. const headerInfo = getHeaderInfo(options);
  4412. const dataDescriptorInfo = getDataDescriptorInfo(options);
  4413. const metadataSize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray);
  4414. maximumEntrySize = metadataSize + maximumCompressedSize;
  4415. if (zipWriter.options[OPTION_USDZ]) {
  4416. maximumEntrySize += maximumEntrySize + 64;
  4417. }
  4418. zipWriter.pendingEntriesSize += maximumEntrySize;
  4419. let fileEntry;
  4420. try {
  4421. fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo, metadataSize }, options);
  4422. } finally {
  4423. zipWriter.pendingEntriesSize -= maximumEntrySize;
  4424. }
  4425. Object.assign(fileEntry, { name, comment, extraField });
  4426. return new Entry(fileEntry);
  4427. }
  4428. async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
  4429. const {
  4430. files,
  4431. writer
  4432. } = zipWriter;
  4433. const {
  4434. keepOrder,
  4435. dataDescriptor,
  4436. signal
  4437. } = options;
  4438. const {
  4439. headerInfo
  4440. } = entryInfo;
  4441. const usdz = zipWriter.options[OPTION_USDZ];
  4442. const previousFileEntry = Array.from(files.values()).pop();
  4443. let fileEntry = {};
  4444. let bufferedWrite;
  4445. let releaseLockWriter;
  4446. let releaseLockCurrentFileEntry;
  4447. let writingBufferedEntryData;
  4448. let writingEntryData;
  4449. let fileWriter;
  4450. files.set(name, fileEntry);
  4451. try {
  4452. let lockPreviousFileEntry;
  4453. if (keepOrder) {
  4454. lockPreviousFileEntry = previousFileEntry && previousFileEntry.lock;
  4455. requestLockCurrentFileEntry();
  4456. }
  4457. if ((options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) && !usdz) {
  4458. if (options.createTempStream) {
  4459. fileWriter = await options.createTempStream();
  4460. } else {
  4461. fileWriter = new TransformStream(UNDEFINED_VALUE, UNDEFINED_VALUE, { highWaterMark: INFINITY_VALUE });
  4462. }
  4463. fileWriter.size = 0;
  4464. bufferedWrite = true;
  4465. zipWriter.bufferedWrites++;
  4466. await initStream(writer);
  4467. } else {
  4468. fileWriter = writer;
  4469. await requestLockWriter();
  4470. }
  4471. await initStream(fileWriter);
  4472. const { writable, diskOffset } = writer;
  4473. if (zipWriter.addSplitZipSignature) {
  4474. delete zipWriter.addSplitZipSignature;
  4475. const signatureArray = new Uint8Array(4);
  4476. const signatureArrayView = getDataView(signatureArray);
  4477. setUint32(signatureArrayView, 0, SPLIT_ZIP_FILE_SIGNATURE);
  4478. await writeData(writer, signatureArray);
  4479. zipWriter.offset += 4;
  4480. }
  4481. if (usdz) {
  4482. appendExtraFieldUSDZ(entryInfo, zipWriter.offset - diskOffset);
  4483. }
  4484. const {
  4485. localHeaderView,
  4486. localHeaderArray
  4487. } = headerInfo;
  4488. if (!bufferedWrite) {
  4489. await lockPreviousFileEntry;
  4490. await skipDiskIfNeeded(writable);
  4491. }
  4492. const { diskNumber } = writer;
  4493. fileEntry.diskNumberStart = diskNumber;
  4494. if (!bufferedWrite) {
  4495. writingEntryData = true;
  4496. await writeData(fileWriter, localHeaderArray);
  4497. }
  4498. fileEntry = await createFileEntry(reader, fileWriter, fileEntry, entryInfo, zipWriter.config, options);
  4499. if (!bufferedWrite) {
  4500. writingEntryData = false;
  4501. }
  4502. files.set(name, fileEntry);
  4503. fileEntry.filename = name;
  4504. if (bufferedWrite) {
  4505. await Promise.all([fileWriter.writable.getWriter().close(), lockPreviousFileEntry]);
  4506. await requestLockWriter();
  4507. writingBufferedEntryData = true;
  4508. fileEntry.diskNumberStart = writer.diskNumber;
  4509. fileEntry.offset = zipWriter.offset - writer.diskOffset;
  4510. updateLocalHeader(fileEntry, localHeaderView, options);
  4511. await skipDiskIfNeeded(writable);
  4512. await writeData(writer, localHeaderArray);
  4513. await fileWriter.readable.pipeTo(writable, { preventClose: true, preventAbort: true, signal });
  4514. writer.size += fileWriter.size;
  4515. writingBufferedEntryData = false;
  4516. } else {
  4517. fileEntry.offset = zipWriter.offset - diskOffset;
  4518. }
  4519. zipWriter.offset += fileEntry.size;
  4520. return fileEntry;
  4521. } catch (error) {
  4522. if (writingBufferedEntryData || writingEntryData) {
  4523. zipWriter.hasCorruptedEntries = true;
  4524. if (error) {
  4525. try {
  4526. error.corruptedEntry = true;
  4527. } catch {
  4528. // ignored
  4529. }
  4530. }
  4531. if (bufferedWrite) {
  4532. zipWriter.offset += fileWriter.size;
  4533. } else {
  4534. zipWriter.offset = fileWriter.size;
  4535. }
  4536. }
  4537. files.delete(name);
  4538. throw error;
  4539. } finally {
  4540. if (bufferedWrite) {
  4541. zipWriter.bufferedWrites--;
  4542. }
  4543. if (releaseLockCurrentFileEntry) {
  4544. releaseLockCurrentFileEntry();
  4545. }
  4546. if (releaseLockWriter) {
  4547. releaseLockWriter();
  4548. }
  4549. }
  4550. function requestLockCurrentFileEntry() {
  4551. fileEntry.lock = new Promise(resolve => releaseLockCurrentFileEntry = resolve);
  4552. }
  4553. async function requestLockWriter() {
  4554. zipWriter.writerLocked = true;
  4555. const { lockWriter } = zipWriter;
  4556. zipWriter.lockWriter = new Promise(resolve => releaseLockWriter = () => {
  4557. zipWriter.writerLocked = false;
  4558. resolve();
  4559. });
  4560. await lockWriter;
  4561. }
  4562. async function skipDiskIfNeeded(writable) {
  4563. if (getLength(headerInfo.localHeaderArray) > writer.availableSize) {
  4564. writer.availableSize = 0;
  4565. await writeData(writable, new Uint8Array());
  4566. }
  4567. }
  4568. }
  4569. async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryInfo, config, options) {
  4570. const {
  4571. headerInfo,
  4572. dataDescriptorInfo,
  4573. metadataSize
  4574. } = entryInfo;
  4575. const {
  4576. headerArray,
  4577. headerView,
  4578. lastModDate,
  4579. rawLastModDate,
  4580. encrypted,
  4581. compressed,
  4582. version,
  4583. compressionMethod,
  4584. rawExtraFieldZip64,
  4585. localExtraFieldZip64Length,
  4586. rawExtraFieldExtendedTimestamp,
  4587. extraFieldExtendedTimestampFlag,
  4588. rawExtraFieldNTFS,
  4589. rawExtraFieldUnix,
  4590. rawExtraFieldAES,
  4591. } = headerInfo;
  4592. const { dataDescriptorArray } = dataDescriptorInfo;
  4593. const {
  4594. rawFilename,
  4595. lastAccessDate,
  4596. creationDate,
  4597. password,
  4598. rawPassword,
  4599. level,
  4600. zip64,
  4601. zip64UncompressedSize,
  4602. zip64CompressedSize,
  4603. zipCrypto,
  4604. dataDescriptor,
  4605. directory,
  4606. executable,
  4607. versionMadeBy,
  4608. rawComment,
  4609. rawExtraField,
  4610. useWebWorkers,
  4611. transferStreams,
  4612. onstart,
  4613. onprogress,
  4614. onend,
  4615. signal,
  4616. encryptionStrength,
  4617. extendedTimestamp,
  4618. msDosCompatible,
  4619. internalFileAttributes,
  4620. externalFileAttributes,
  4621. uid,
  4622. gid,
  4623. unixMode,
  4624. setuid,
  4625. setgid,
  4626. sticky,
  4627. unixExternalUpper,
  4628. msdosAttributesRaw,
  4629. msdosAttributes,
  4630. useCompressionStream,
  4631. passThrough
  4632. } = options;
  4633. const fileEntry = {
  4634. lock,
  4635. versionMadeBy,
  4636. zip64,
  4637. directory: Boolean(directory),
  4638. executable: Boolean(executable),
  4639. filenameUTF8: true,
  4640. rawFilename,
  4641. commentUTF8: true,
  4642. rawComment,
  4643. rawExtraFieldZip64,
  4644. localExtraFieldZip64Length,
  4645. rawExtraFieldExtendedTimestamp,
  4646. rawExtraFieldNTFS,
  4647. rawExtraFieldUnix,
  4648. rawExtraFieldAES,
  4649. rawExtraField,
  4650. extendedTimestamp,
  4651. msDosCompatible,
  4652. internalFileAttributes,
  4653. externalFileAttributes,
  4654. diskNumberStart,
  4655. uid,
  4656. gid,
  4657. unixMode,
  4658. setuid,
  4659. setgid,
  4660. sticky,
  4661. unixExternalUpper,
  4662. msdosAttributesRaw,
  4663. msdosAttributes
  4664. };
  4665. let {
  4666. signature,
  4667. uncompressedSize
  4668. } = options;
  4669. let compressedSize = 0;
  4670. if (!passThrough) {
  4671. uncompressedSize = 0;
  4672. }
  4673. const { writable } = writer;
  4674. if (reader) {
  4675. reader.chunkSize = getChunkSize(config);
  4676. const readable = reader.readable;
  4677. const size = reader.size;
  4678. const workerOptions = {
  4679. options: {
  4680. codecType: CODEC_DEFLATE,
  4681. level,
  4682. rawPassword,
  4683. password,
  4684. encryptionStrength,
  4685. zipCrypto: encrypted && zipCrypto,
  4686. passwordVerification: encrypted && zipCrypto && (rawLastModDate >> 8) & MAX_8_BITS,
  4687. signed: !passThrough,
  4688. compressed: compressed && !passThrough,
  4689. encrypted: encrypted && !passThrough,
  4690. useWebWorkers,
  4691. useCompressionStream,
  4692. transferStreams
  4693. },
  4694. config,
  4695. streamOptions: { signal, size, onstart, onprogress, onend }
  4696. };
  4697. try {
  4698. const result = await runWorker({ readable, writable }, workerOptions);
  4699. compressedSize = result.outputSize;
  4700. writer.size += compressedSize;
  4701. if (!passThrough) {
  4702. uncompressedSize = result.inputSize;
  4703. signature = result.signature;
  4704. }
  4705. } catch (error) {
  4706. if (error.outputSize !== UNDEFINED_VALUE) {
  4707. writer.size += error.outputSize;
  4708. }
  4709. throw error;
  4710. }
  4711. }
  4712. setEntryInfo({
  4713. signature,
  4714. compressedSize,
  4715. uncompressedSize,
  4716. headerInfo,
  4717. dataDescriptorInfo
  4718. }, options);
  4719. if (dataDescriptor) {
  4720. await writeData(writer, dataDescriptorArray);
  4721. }
  4722. Object.assign(fileEntry, {
  4723. uncompressedSize,
  4724. compressedSize,
  4725. lastModDate,
  4726. rawLastModDate,
  4727. creationDate,
  4728. lastAccessDate,
  4729. encrypted,
  4730. zipCrypto,
  4731. size: metadataSize + compressedSize,
  4732. compressionMethod,
  4733. version,
  4734. headerArray,
  4735. headerView,
  4736. signature,
  4737. extraFieldExtendedTimestampFlag,
  4738. zip64UncompressedSize,
  4739. zip64CompressedSize
  4740. });
  4741. return fileEntry;
  4742. }
  4743. function getHeaderInfo(options) {
  4744. const {
  4745. rawFilename,
  4746. lastModDate,
  4747. lastAccessDate,
  4748. creationDate,
  4749. level,
  4750. zip64,
  4751. zipCrypto,
  4752. useUnicodeFileNames,
  4753. dataDescriptor,
  4754. directory,
  4755. rawExtraField,
  4756. encryptionStrength,
  4757. extendedTimestamp,
  4758. passThrough,
  4759. encrypted,
  4760. zip64UncompressedSize,
  4761. zip64CompressedSize,
  4762. uncompressedSize
  4763. } = options;
  4764. let { version, compressionMethod } = options;
  4765. const compressed = !directory && (level > 0 || (level === UNDEFINED_VALUE && compressionMethod !== 0));
  4766. let rawLocalExtraFieldZip64;
  4767. const uncompressedFile = passThrough || !compressed;
  4768. const zip64ExtraFieldComplete = zip64 && (options.bufferedWrite || ((!zip64UncompressedSize && !zip64CompressedSize) || uncompressedFile));
  4769. if (zip64) {
  4770. let rawLocalExtraFieldZip64Length = 4;
  4771. if (zip64UncompressedSize) {
  4772. rawLocalExtraFieldZip64Length += 8;
  4773. }
  4774. if (zip64CompressedSize) {
  4775. rawLocalExtraFieldZip64Length += 8;
  4776. }
  4777. rawLocalExtraFieldZip64 = new Uint8Array(rawLocalExtraFieldZip64Length);
  4778. const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
  4779. setUint16(rawLocalExtraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64);
  4780. setUint16(rawLocalExtraFieldZip64View, 2, getLength(rawLocalExtraFieldZip64) - 4);
  4781. if (zip64ExtraFieldComplete) {
  4782. const rawLocalExtraFieldZip64View = getDataView(rawLocalExtraFieldZip64);
  4783. let rawLocalExtraFieldZip64Offset = 4;
  4784. if (zip64UncompressedSize) {
  4785. setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
  4786. rawLocalExtraFieldZip64Offset += 8;
  4787. }
  4788. if (zip64CompressedSize && uncompressedFile) {
  4789. setBigUint64(rawLocalExtraFieldZip64View, rawLocalExtraFieldZip64Offset, BigInt(uncompressedSize));
  4790. rawLocalExtraFieldZip64Offset += 8;
  4791. }
  4792. if (rawLocalExtraFieldZip64Offset == 4) {
  4793. rawLocalExtraFieldZip64 = new Uint8Array();
  4794. }
  4795. }
  4796. } else {
  4797. rawLocalExtraFieldZip64 = new Uint8Array();
  4798. }
  4799. let rawExtraFieldAES;
  4800. if (encrypted && !zipCrypto) {
  4801. rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
  4802. const extraFieldAESView = getDataView(rawExtraFieldAES);
  4803. setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES);
  4804. arraySet(rawExtraFieldAES, EXTRAFIELD_DATA_AES, 2);
  4805. setUint8(extraFieldAESView, 8, encryptionStrength);
  4806. } else {
  4807. rawExtraFieldAES = new Uint8Array();
  4808. }
  4809. let rawExtraFieldNTFS;
  4810. let rawExtraFieldExtendedTimestamp;
  4811. let extraFieldExtendedTimestampFlag;
  4812. if (extendedTimestamp) {
  4813. rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
  4814. const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
  4815. setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  4816. setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
  4817. extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
  4818. setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
  4819. let offset = 5;
  4820. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastModDate.getTime() / 1000));
  4821. offset += 4;
  4822. if (lastAccessDate) {
  4823. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(lastAccessDate.getTime() / 1000));
  4824. offset += 4;
  4825. }
  4826. if (creationDate) {
  4827. setUint32(extraFieldExtendedTimestampView, offset, Math.floor(creationDate.getTime() / 1000));
  4828. }
  4829. try {
  4830. rawExtraFieldNTFS = new Uint8Array(36);
  4831. const extraFieldNTFSView = getDataView(rawExtraFieldNTFS);
  4832. const lastModTimeNTFS = getTimeNTFS(lastModDate);
  4833. setUint16(extraFieldNTFSView, 0, EXTRAFIELD_TYPE_NTFS);
  4834. setUint16(extraFieldNTFSView, 2, 32);
  4835. setUint16(extraFieldNTFSView, 8, EXTRAFIELD_TYPE_NTFS_TAG1);
  4836. setUint16(extraFieldNTFSView, 10, 24);
  4837. setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
  4838. setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
  4839. setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
  4840. } catch {
  4841. rawExtraFieldNTFS = new Uint8Array();
  4842. }
  4843. } else {
  4844. rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
  4845. }
  4846. let rawExtraFieldUnix;
  4847. try {
  4848. const { uid, gid, unixMode, setuid, setgid, sticky, unixExtraFieldType } = options;
  4849. if (unixExtraFieldType && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE || unixMode !== UNDEFINED_VALUE)) {
  4850. const uidBytes = packUnixId(uid);
  4851. const gidBytes = packUnixId(gid);
  4852. let modeArray = new Uint8Array();
  4853. if (unixExtraFieldType == UNIX_EXTRA_FIELD_TYPE && unixMode !== UNDEFINED_VALUE) {
  4854. let modeToWrite = unixMode & MAX_16_BITS;
  4855. if (setuid) {
  4856. modeToWrite |= FILE_ATTR_UNIX_SETUID_MASK;
  4857. }
  4858. if (setgid) {
  4859. modeToWrite |= FILE_ATTR_UNIX_SETGID_MASK;
  4860. }
  4861. if (sticky) {
  4862. modeToWrite |= FILE_ATTR_UNIX_STICKY_MASK;
  4863. }
  4864. modeArray = new Uint8Array(2);
  4865. const modeDataView = new DataView(modeArray.buffer);
  4866. modeDataView.setUint16(0, modeToWrite, true);
  4867. }
  4868. const payloadLength = 3 + uidBytes.length + gidBytes.length + modeArray.length;
  4869. rawExtraFieldUnix = new Uint8Array(4 + payloadLength);
  4870. const rawExtraFieldUnixView = getDataView(rawExtraFieldUnix);
  4871. setUint16(rawExtraFieldUnixView, 0, unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE ? EXTRAFIELD_TYPE_INFOZIP : EXTRAFIELD_TYPE_UNIX);
  4872. setUint16(rawExtraFieldUnixView, 2, payloadLength);
  4873. setUint8(rawExtraFieldUnixView, 4, 1);
  4874. setUint8(rawExtraFieldUnixView, 5, uidBytes.length);
  4875. let offset = 6;
  4876. arraySet(rawExtraFieldUnix, uidBytes, offset);
  4877. offset += uidBytes.length;
  4878. setUint8(rawExtraFieldUnixView, offset, gidBytes.length);
  4879. offset++;
  4880. arraySet(rawExtraFieldUnix, gidBytes, offset);
  4881. offset += gidBytes.length;
  4882. arraySet(rawExtraFieldUnix, modeArray, offset);
  4883. } else {
  4884. rawExtraFieldUnix = new Uint8Array();
  4885. }
  4886. } catch {
  4887. rawExtraFieldUnix = new Uint8Array();
  4888. }
  4889. if (compressionMethod === UNDEFINED_VALUE) {
  4890. compressionMethod = compressed ? COMPRESSION_METHOD_DEFLATE : COMPRESSION_METHOD_STORE;
  4891. }
  4892. if (zip64) {
  4893. version = version > VERSION_ZIP64 ? version : VERSION_ZIP64;
  4894. }
  4895. if (encrypted && !zipCrypto) {
  4896. version = version > VERSION_AES ? version : VERSION_AES;
  4897. rawExtraFieldAES[9] = compressionMethod;
  4898. compressionMethod = COMPRESSION_METHOD_AES;
  4899. }
  4900. const localExtraFieldZip64Length = zip64ExtraFieldComplete ? getLength(rawLocalExtraFieldZip64) : 0;
  4901. const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  4902. const {
  4903. headerArray,
  4904. headerView,
  4905. rawLastModDate
  4906. } = getHeaderArrayData({
  4907. version,
  4908. bitFlag: getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod),
  4909. compressionMethod,
  4910. uncompressedSize,
  4911. lastModDate: lastModDate < MIN_DATE ? MIN_DATE : lastModDate > MAX_DATE ? MAX_DATE : lastModDate,
  4912. rawFilename,
  4913. zip64CompressedSize,
  4914. zip64UncompressedSize,
  4915. extraFieldLength
  4916. });
  4917. let localHeaderOffset = HEADER_SIZE;
  4918. const localHeaderArray = new Uint8Array(localHeaderOffset + getLength(rawFilename) + extraFieldLength);
  4919. const localHeaderView = getDataView(localHeaderArray);
  4920. setUint32(localHeaderView, 0, LOCAL_FILE_HEADER_SIGNATURE);
  4921. arraySet(localHeaderArray, headerArray, 4);
  4922. arraySet(localHeaderArray, rawFilename, localHeaderOffset);
  4923. localHeaderOffset += getLength(rawFilename);
  4924. if (zip64ExtraFieldComplete) {
  4925. arraySet(localHeaderArray, rawLocalExtraFieldZip64, localHeaderOffset);
  4926. }
  4927. localHeaderOffset += localExtraFieldZip64Length;
  4928. arraySet(localHeaderArray, rawExtraFieldAES, localHeaderOffset);
  4929. localHeaderOffset += getLength(rawExtraFieldAES);
  4930. arraySet(localHeaderArray, rawExtraFieldExtendedTimestamp, localHeaderOffset);
  4931. localHeaderOffset += getLength(rawExtraFieldExtendedTimestamp);
  4932. arraySet(localHeaderArray, rawExtraFieldNTFS, localHeaderOffset);
  4933. localHeaderOffset += getLength(rawExtraFieldNTFS);
  4934. arraySet(localHeaderArray, rawExtraFieldUnix, localHeaderOffset);
  4935. localHeaderOffset += getLength(rawExtraFieldUnix);
  4936. arraySet(localHeaderArray, rawExtraField, localHeaderOffset);
  4937. if (dataDescriptor) {
  4938. setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, 0);
  4939. setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, 0);
  4940. }
  4941. return {
  4942. localHeaderArray,
  4943. localHeaderView,
  4944. headerArray,
  4945. headerView,
  4946. lastModDate,
  4947. rawLastModDate,
  4948. encrypted,
  4949. compressed,
  4950. version,
  4951. compressionMethod,
  4952. extraFieldExtendedTimestampFlag,
  4953. rawExtraFieldZip64: new Uint8Array(),
  4954. localExtraFieldZip64Length,
  4955. rawExtraFieldExtendedTimestamp,
  4956. rawExtraFieldNTFS,
  4957. rawExtraFieldUnix,
  4958. rawExtraFieldAES,
  4959. extraFieldLength
  4960. };
  4961. }
  4962. function appendExtraFieldUSDZ(entryInfo, zipWriterOffset) {
  4963. const { headerInfo } = entryInfo;
  4964. let { localHeaderArray, extraFieldLength } = headerInfo;
  4965. let localHeaderArrayView = getDataView(localHeaderArray);
  4966. let extraBytesLength = 64 - ((zipWriterOffset + getLength(localHeaderArray)) % 64);
  4967. if (extraBytesLength < 4) {
  4968. extraBytesLength += 64;
  4969. }
  4970. const rawExtraFieldUSDZ = new Uint8Array(extraBytesLength);
  4971. const extraFieldUSDZView = getDataView(rawExtraFieldUSDZ);
  4972. setUint16(extraFieldUSDZView, 0, EXTRAFIELD_TYPE_USDZ);
  4973. setUint16(extraFieldUSDZView, 2, extraBytesLength - 2);
  4974. const previousLocalHeaderArray = localHeaderArray;
  4975. headerInfo.localHeaderArray = localHeaderArray = new Uint8Array(getLength(previousLocalHeaderArray) + extraBytesLength);
  4976. arraySet(localHeaderArray, previousLocalHeaderArray);
  4977. arraySet(localHeaderArray, rawExtraFieldUSDZ, getLength(previousLocalHeaderArray));
  4978. localHeaderArrayView = getDataView(localHeaderArray);
  4979. setUint16(localHeaderArrayView, 28, extraFieldLength + extraBytesLength);
  4980. entryInfo.metadataSize += extraBytesLength;
  4981. }
  4982. function packUnixId(id) {
  4983. if (id === UNDEFINED_VALUE) {
  4984. return new Uint8Array();
  4985. } else {
  4986. const dataArray = new Uint8Array(4);
  4987. const dataView = getDataView(dataArray);
  4988. dataView.setUint32(0, id, true);
  4989. let length = 4;
  4990. while (length > 1 && dataArray[length - 1] === 0) {
  4991. length--;
  4992. }
  4993. return dataArray.subarray(0, length);
  4994. }
  4995. }
  4996. function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
  4997. if (msdosAttributesRaw !== UNDEFINED_VALUE) {
  4998. msdosAttributesRaw = msdosAttributesRaw & MAX_8_BITS;
  4999. } else if (msdosAttributes !== UNDEFINED_VALUE) {
  5000. const { readOnly, hidden, system, directory: msdDir, archive } = msdosAttributes;
  5001. let raw = 0;
  5002. if (readOnly) raw |= FILE_ATTR_MSDOS_READONLY_MASK;
  5003. if (hidden) raw |= FILE_ATTR_MSDOS_HIDDEN_MASK;
  5004. if (system) raw |= FILE_ATTR_MSDOS_SYSTEM_MASK;
  5005. if (msdDir) raw |= FILE_ATTR_MSDOS_DIR_MASK;
  5006. if (archive) raw |= FILE_ATTR_MSDOS_ARCHIVE_MASK;
  5007. msdosAttributesRaw = raw & MAX_8_BITS;
  5008. }
  5009. if (msdosAttributes === UNDEFINED_VALUE) {
  5010. msdosAttributes = {
  5011. readOnly: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_READONLY_MASK),
  5012. hidden: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_HIDDEN_MASK),
  5013. system: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_SYSTEM_MASK),
  5014. directory: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_DIR_MASK),
  5015. archive: Boolean(msdosAttributesRaw & FILE_ATTR_MSDOS_ARCHIVE_MASK)
  5016. };
  5017. }
  5018. return { msdosAttributesRaw, msdosAttributes };
  5019. }
  5020. function getDataDescriptorInfo({
  5021. zip64,
  5022. dataDescriptor,
  5023. dataDescriptorSignature
  5024. }) {
  5025. let dataDescriptorArray = new Uint8Array();
  5026. let dataDescriptorView, dataDescriptorOffset = 0;
  5027. let dataDescriptorLength = zip64 ? DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH : DATA_DESCRIPTOR_RECORD_LENGTH;
  5028. if (dataDescriptorSignature) {
  5029. dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  5030. }
  5031. if (dataDescriptor) {
  5032. dataDescriptorArray = new Uint8Array(dataDescriptorLength);
  5033. dataDescriptorView = getDataView(dataDescriptorArray);
  5034. if (dataDescriptorSignature) {
  5035. dataDescriptorOffset = DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
  5036. setUint32(dataDescriptorView, 0, DATA_DESCRIPTOR_RECORD_SIGNATURE);
  5037. }
  5038. }
  5039. return {
  5040. dataDescriptorArray,
  5041. dataDescriptorView,
  5042. dataDescriptorOffset
  5043. };
  5044. }
  5045. function setEntryInfo({
  5046. signature,
  5047. compressedSize,
  5048. uncompressedSize,
  5049. headerInfo,
  5050. dataDescriptorInfo
  5051. }, {
  5052. zip64,
  5053. zipCrypto,
  5054. dataDescriptor
  5055. }) {
  5056. const {
  5057. headerView,
  5058. encrypted
  5059. } = headerInfo;
  5060. const {
  5061. dataDescriptorView,
  5062. dataDescriptorOffset
  5063. } = dataDescriptorInfo;
  5064. if ((!encrypted || zipCrypto) && signature !== UNDEFINED_VALUE) {
  5065. setUint32(headerView, HEADER_OFFSET_SIGNATURE, signature);
  5066. if (dataDescriptor) {
  5067. setUint32(dataDescriptorView, dataDescriptorOffset, signature);
  5068. }
  5069. }
  5070. if (zip64) {
  5071. if (dataDescriptor) {
  5072. setBigUint64(dataDescriptorView, dataDescriptorOffset + 4, BigInt(compressedSize));
  5073. setBigUint64(dataDescriptorView, dataDescriptorOffset + 12, BigInt(uncompressedSize));
  5074. }
  5075. } else {
  5076. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, compressedSize);
  5077. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, uncompressedSize);
  5078. if (dataDescriptor) {
  5079. setUint32(dataDescriptorView, dataDescriptorOffset + 4, compressedSize);
  5080. setUint32(dataDescriptorView, dataDescriptorOffset + 8, uncompressedSize);
  5081. }
  5082. }
  5083. }
  5084. function updateLocalHeader({
  5085. rawFilename,
  5086. encrypted,
  5087. zip64,
  5088. localExtraFieldZip64Length,
  5089. signature,
  5090. compressedSize,
  5091. uncompressedSize,
  5092. zip64UncompressedSize,
  5093. zip64CompressedSize
  5094. }, localHeaderView, { dataDescriptor }) {
  5095. if (!dataDescriptor) {
  5096. if (!encrypted) {
  5097. setUint32(localHeaderView, HEADER_OFFSET_SIGNATURE + 4, signature);
  5098. }
  5099. if (!zip64CompressedSize) {
  5100. setUint32(localHeaderView, HEADER_OFFSET_COMPRESSED_SIZE + 4, compressedSize);
  5101. }
  5102. if (!zip64UncompressedSize) {
  5103. setUint32(localHeaderView, HEADER_OFFSET_UNCOMPRESSED_SIZE + 4, uncompressedSize);
  5104. }
  5105. }
  5106. if (zip64 && localExtraFieldZip64Length) {
  5107. let localHeaderOffset = HEADER_SIZE + getLength(rawFilename) + 4;
  5108. if (zip64UncompressedSize) {
  5109. setBigUint64(localHeaderView, localHeaderOffset, BigInt(uncompressedSize));
  5110. localHeaderOffset += 8;
  5111. }
  5112. if (zip64CompressedSize) {
  5113. setBigUint64(localHeaderView, localHeaderOffset, BigInt(compressedSize));
  5114. localHeaderOffset += 8;
  5115. }
  5116. }
  5117. }
  5118. async function closeFile(zipWriter, comment, options) {
  5119. const { files, writer } = zipWriter;
  5120. const { diskOffset } = writer;
  5121. let { diskNumber } = writer;
  5122. let offset = 0;
  5123. let directoryDataLength = 0;
  5124. let directoryOffset = zipWriter.offset - diskOffset;
  5125. let filesLength = files.size;
  5126. for (const [, fileEntry] of files) {
  5127. const {
  5128. rawFilename,
  5129. rawExtraFieldAES,
  5130. rawComment,
  5131. rawExtraFieldNTFS,
  5132. rawExtraFieldUnix,
  5133. rawExtraField,
  5134. extendedTimestamp,
  5135. extraFieldExtendedTimestampFlag,
  5136. lastModDate,
  5137. zip64UncompressedSize,
  5138. zip64CompressedSize,
  5139. uncompressedSize,
  5140. compressedSize
  5141. } = fileEntry;
  5142. const zip64Offset = fileEntry.offset > MAX_32_BITS;
  5143. const zip64DiskNumberStart = fileEntry.diskNumberStart > MAX_16_BITS;
  5144. let rawExtraFieldZip64;
  5145. if (zip64Offset || zip64DiskNumberStart || zip64UncompressedSize || zip64CompressedSize) {
  5146. let length = 4;
  5147. if (zip64UncompressedSize) length += 8;
  5148. if (zip64CompressedSize) length += 8;
  5149. if (zip64Offset) length += 8;
  5150. if (zip64DiskNumberStart) length += 4;
  5151. rawExtraFieldZip64 = new Uint8Array(length);
  5152. const zip64View = getDataView(rawExtraFieldZip64);
  5153. setUint16(zip64View, 0, EXTRAFIELD_TYPE_ZIP64);
  5154. setUint16(zip64View, 2, length - 4);
  5155. let zip64FieldOffset = 4;
  5156. if (zip64UncompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(uncompressedSize)); zip64FieldOffset += 8; }
  5157. if (zip64CompressedSize) { setBigUint64(zip64View, zip64FieldOffset, BigInt(compressedSize)); zip64FieldOffset += 8; }
  5158. if (zip64Offset) { setBigUint64(zip64View, zip64FieldOffset, BigInt(fileEntry.offset)); zip64FieldOffset += 8; }
  5159. if (zip64DiskNumberStart) { setUint32(zip64View, zip64FieldOffset, fileEntry.diskNumberStart); }
  5160. } else {
  5161. rawExtraFieldZip64 = new Uint8Array();
  5162. }
  5163. fileEntry.rawExtraFieldZip64 = rawExtraFieldZip64;
  5164. fileEntry.zip64Offset = zip64Offset;
  5165. fileEntry.zip64DiskNumberStart = zip64DiskNumberStart;
  5166. let rawExtraFieldTimestamp;
  5167. if (extendedTimestamp) {
  5168. rawExtraFieldTimestamp = new Uint8Array(9);
  5169. const extraFieldExtendedTimestampView = getDataView(rawExtraFieldTimestamp);
  5170. setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
  5171. setUint16(extraFieldExtendedTimestampView, 2, 5);
  5172. setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
  5173. setUint32(extraFieldExtendedTimestampView, 5, Math.floor(lastModDate.getTime() / 1000));
  5174. } else {
  5175. rawExtraFieldTimestamp = new Uint8Array();
  5176. }
  5177. fileEntry.rawExtraFieldExtendedTimestamp = rawExtraFieldTimestamp;
  5178. directoryDataLength += 46 +
  5179. getLength(
  5180. rawFilename,
  5181. rawComment,
  5182. rawExtraFieldZip64,
  5183. rawExtraFieldAES,
  5184. rawExtraFieldNTFS,
  5185. rawExtraFieldUnix,
  5186. rawExtraFieldTimestamp,
  5187. rawExtraField);
  5188. }
  5189. const directoryArray = new Uint8Array(directoryDataLength);
  5190. const directoryView = getDataView(directoryArray);
  5191. await initStream(writer);
  5192. let directoryDiskOffset = 0;
  5193. for (const [indexFileEntry, fileEntry] of Array.from(files.values()).entries()) {
  5194. const {
  5195. offset: fileEntryOffset,
  5196. rawFilename,
  5197. rawExtraFieldZip64,
  5198. rawExtraFieldAES,
  5199. rawExtraFieldExtendedTimestamp,
  5200. rawExtraFieldNTFS,
  5201. rawExtraFieldUnix,
  5202. rawExtraField,
  5203. rawComment,
  5204. versionMadeBy,
  5205. headerArray,
  5206. headerView,
  5207. zip64UncompressedSize,
  5208. zip64CompressedSize,
  5209. zip64DiskNumberStart,
  5210. zip64Offset,
  5211. internalFileAttributes,
  5212. externalFileAttributes,
  5213. diskNumberStart,
  5214. uncompressedSize,
  5215. compressedSize
  5216. } = fileEntry;
  5217. const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
  5218. setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
  5219. setUint16(directoryView, offset + 4, versionMadeBy);
  5220. if (!zip64UncompressedSize) {
  5221. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, uncompressedSize);
  5222. }
  5223. if (!zip64CompressedSize) {
  5224. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, compressedSize);
  5225. }
  5226. arraySet(directoryArray, headerArray, offset + 6);
  5227. let directoryOffset = offset + HEADER_SIZE;
  5228. setUint16(directoryView, directoryOffset, extraFieldLength);
  5229. directoryOffset += 2;
  5230. setUint16(directoryView, directoryOffset, getLength(rawComment));
  5231. directoryOffset += 2;
  5232. setUint16(directoryView, directoryOffset, zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
  5233. directoryOffset += 2;
  5234. setUint16(directoryView, directoryOffset, internalFileAttributes);
  5235. directoryOffset += 2;
  5236. if (externalFileAttributes) {
  5237. setUint32(directoryView, directoryOffset, externalFileAttributes);
  5238. }
  5239. directoryOffset += 4;
  5240. setUint32(directoryView, directoryOffset, zip64Offset ? MAX_32_BITS : fileEntryOffset);
  5241. directoryOffset += 4;
  5242. arraySet(directoryArray, rawFilename, directoryOffset);
  5243. directoryOffset += getLength(rawFilename);
  5244. arraySet(directoryArray, rawExtraFieldZip64, directoryOffset);
  5245. directoryOffset += getLength(rawExtraFieldZip64);
  5246. arraySet(directoryArray, rawExtraFieldAES, directoryOffset);
  5247. directoryOffset += getLength(rawExtraFieldAES);
  5248. arraySet(directoryArray, rawExtraFieldExtendedTimestamp, directoryOffset);
  5249. directoryOffset += getLength(rawExtraFieldExtendedTimestamp);
  5250. arraySet(directoryArray, rawExtraFieldNTFS, directoryOffset);
  5251. directoryOffset += getLength(rawExtraFieldNTFS);
  5252. arraySet(directoryArray, rawExtraFieldUnix, directoryOffset);
  5253. directoryOffset += getLength(rawExtraFieldUnix);
  5254. arraySet(directoryArray, rawExtraField, directoryOffset);
  5255. directoryOffset += getLength(rawExtraField);
  5256. arraySet(directoryArray, rawComment, directoryOffset);
  5257. directoryOffset += getLength(rawComment);
  5258. if (offset - directoryDiskOffset > writer.availableSize) {
  5259. writer.availableSize = 0;
  5260. await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
  5261. directoryDiskOffset = offset;
  5262. }
  5263. offset = directoryOffset;
  5264. if (options.onprogress) {
  5265. try {
  5266. await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
  5267. } catch {
  5268. // ignored
  5269. }
  5270. }
  5271. }
  5272. await writeData(writer, directoryDiskOffset ? directoryArray.slice(directoryDiskOffset) : directoryArray);
  5273. let lastDiskNumber = writer.diskNumber;
  5274. const { availableSize } = writer;
  5275. if (availableSize < END_OF_CENTRAL_DIR_LENGTH) {
  5276. lastDiskNumber++;
  5277. }
  5278. let zip64 = getOptionValue(zipWriter, options, PROPERTY_NAME_ZIP64);
  5279. if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
  5280. if (zip64 === false) {
  5281. throw new Error(ERR_UNSUPPORTED_FORMAT);
  5282. } else {
  5283. zip64 = true;
  5284. }
  5285. }
  5286. const endOfdirectoryArray = new Uint8Array(zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
  5287. const endOfdirectoryView = getDataView(endOfdirectoryArray);
  5288. offset = 0;
  5289. if (zip64) {
  5290. setUint32(endOfdirectoryView, 0, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE);
  5291. setBigUint64(endOfdirectoryView, 4, BigInt(44));
  5292. setUint16(endOfdirectoryView, 12, 45);
  5293. setUint16(endOfdirectoryView, 14, 45);
  5294. setUint32(endOfdirectoryView, 16, lastDiskNumber);
  5295. setUint32(endOfdirectoryView, 20, diskNumber);
  5296. setBigUint64(endOfdirectoryView, 24, BigInt(filesLength));
  5297. setBigUint64(endOfdirectoryView, 32, BigInt(filesLength));
  5298. setBigUint64(endOfdirectoryView, 40, BigInt(directoryDataLength));
  5299. setBigUint64(endOfdirectoryView, 48, BigInt(directoryOffset));
  5300. setUint32(endOfdirectoryView, 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE);
  5301. setBigUint64(endOfdirectoryView, 64, BigInt(directoryOffset) + BigInt(directoryDataLength));
  5302. setUint32(endOfdirectoryView, 72, lastDiskNumber + 1);
  5303. const supportZip64SplitFile = getOptionValue(zipWriter, options, OPTION_SUPPORT_ZIP64_SPLIT_FILE, true);
  5304. if (supportZip64SplitFile) {
  5305. lastDiskNumber = MAX_16_BITS;
  5306. diskNumber = MAX_16_BITS;
  5307. }
  5308. filesLength = MAX_16_BITS;
  5309. directoryOffset = MAX_32_BITS;
  5310. directoryDataLength = MAX_32_BITS;
  5311. offset += ZIP64_END_OF_CENTRAL_DIR_LENGTH + ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH;
  5312. }
  5313. setUint32(endOfdirectoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE);
  5314. setUint16(endOfdirectoryView, offset + 4, lastDiskNumber);
  5315. setUint16(endOfdirectoryView, offset + 6, diskNumber);
  5316. setUint16(endOfdirectoryView, offset + 8, filesLength);
  5317. setUint16(endOfdirectoryView, offset + 10, filesLength);
  5318. setUint32(endOfdirectoryView, offset + 12, directoryDataLength);
  5319. setUint32(endOfdirectoryView, offset + 16, directoryOffset);
  5320. const commentLength = getLength(comment);
  5321. if (commentLength) {
  5322. if (commentLength <= MAX_16_BITS) {
  5323. setUint16(endOfdirectoryView, offset + 20, commentLength);
  5324. } else {
  5325. throw new Error(ERR_INVALID_COMMENT);
  5326. }
  5327. }
  5328. await writeData(writer, endOfdirectoryArray);
  5329. if (commentLength) {
  5330. await writeData(writer, comment);
  5331. }
  5332. }
  5333. async function writeData(writer, array) {
  5334. const { writable } = writer;
  5335. const streamWriter = writable.getWriter();
  5336. try {
  5337. await streamWriter.ready;
  5338. writer.size += getLength(array);
  5339. await streamWriter.write(array);
  5340. } finally {
  5341. streamWriter.releaseLock();
  5342. }
  5343. }
  5344. function getTimeNTFS(date) {
  5345. if (date) {
  5346. return ((BigInt(date.getTime()) + BigInt(11644473600000)) * BigInt(10000));
  5347. }
  5348. }
  5349. function getOptionValue(zipWriter, options, name, defaultValue) {
  5350. const result = options[name] === UNDEFINED_VALUE ? zipWriter.options[name] : options[name];
  5351. return result === UNDEFINED_VALUE ? defaultValue : result;
  5352. }
  5353. function getMaximumCompressedSize(uncompressedSize) {
  5354. return uncompressedSize + (5 * (Math.floor(uncompressedSize / 16383) + 1));
  5355. }
  5356. function setUint8(view, offset, value) {
  5357. view.setUint8(offset, value);
  5358. }
  5359. function setUint16(view, offset, value) {
  5360. view.setUint16(offset, value, true);
  5361. }
  5362. function setUint32(view, offset, value) {
  5363. view.setUint32(offset, value, true);
  5364. }
  5365. function setBigUint64(view, offset, value) {
  5366. view.setBigUint64(offset, value, true);
  5367. }
  5368. function arraySet(array, typedArray, offset) {
  5369. array.set(typedArray, offset);
  5370. }
  5371. function getDataView(array) {
  5372. return new DataView(array.buffer);
  5373. }
  5374. function getLength(...arrayLikes) {
  5375. let result = 0;
  5376. arrayLikes.forEach(arrayLike => arrayLike && (result += arrayLike.length));
  5377. return result;
  5378. }
  5379. function getHeaderArrayData({
  5380. version,
  5381. bitFlag,
  5382. compressionMethod,
  5383. uncompressedSize,
  5384. compressedSize,
  5385. lastModDate,
  5386. rawFilename,
  5387. zip64CompressedSize,
  5388. zip64UncompressedSize,
  5389. extraFieldLength
  5390. }) {
  5391. const headerArray = new Uint8Array(HEADER_SIZE - 4);
  5392. const headerView = getDataView(headerArray);
  5393. setUint16(headerView, 0, version);
  5394. setUint16(headerView, 2, bitFlag);
  5395. setUint16(headerView, 4, compressionMethod);
  5396. const dateArray = new Uint32Array(1);
  5397. const dateView = getDataView(dateArray);
  5398. setUint16(dateView, 0, (((lastModDate.getHours() << 6) | lastModDate.getMinutes()) << 5) | lastModDate.getSeconds() / 2);
  5399. setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
  5400. const rawLastModDate = dateArray[0];
  5401. setUint32(headerView, 6, rawLastModDate);
  5402. if (zip64CompressedSize || compressedSize !== UNDEFINED_VALUE) {
  5403. setUint32(headerView, HEADER_OFFSET_COMPRESSED_SIZE, zip64CompressedSize ? MAX_32_BITS : compressedSize);
  5404. }
  5405. if (zip64UncompressedSize || uncompressedSize !== UNDEFINED_VALUE) {
  5406. setUint32(headerView, HEADER_OFFSET_UNCOMPRESSED_SIZE, zip64UncompressedSize ? MAX_32_BITS : uncompressedSize);
  5407. }
  5408. setUint16(headerView, 22, getLength(rawFilename));
  5409. setUint16(headerView, 24, extraFieldLength);
  5410. return {
  5411. headerArray,
  5412. headerView,
  5413. rawLastModDate
  5414. };
  5415. }
  5416. function getBitFlag(level, useUnicodeFileNames, dataDescriptor, encrypted, compressionMethod) {
  5417. let bitFlag = 0;
  5418. if (useUnicodeFileNames) {
  5419. bitFlag = bitFlag | BITFLAG_LANG_ENCODING_FLAG;
  5420. }
  5421. if (dataDescriptor) {
  5422. bitFlag = bitFlag | BITFLAG_DATA_DESCRIPTOR;
  5423. }
  5424. if (compressionMethod == COMPRESSION_METHOD_DEFLATE || compressionMethod == COMPRESSION_METHOD_DEFLATE_64) {
  5425. if (level >= 0 && level <= 3) {
  5426. bitFlag = bitFlag | BITFLAG_LEVEL_SUPER_FAST_MASK;
  5427. }
  5428. if (level > 3 && level <= 5) {
  5429. bitFlag = bitFlag | BITFLAG_LEVEL_FAST_MASK;
  5430. }
  5431. if (level == 9) {
  5432. bitFlag = bitFlag | BITFLAG_LEVEL_MAX_MASK;
  5433. }
  5434. }
  5435. if (encrypted) {
  5436. bitFlag = bitFlag | BITFLAG_ENCRYPTED;
  5437. }
  5438. return bitFlag;
  5439. }
  5440. /*
  5441. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  5442. Redistribution and use in source and binary forms, with or without
  5443. modification, are permitted provided that the following conditions are met:
  5444. 1. Redistributions of source code must retain the above copyright notice,
  5445. this list of conditions and the following disclaimer.
  5446. 2. Redistributions in binary form must reproduce the above copyright
  5447. notice, this list of conditions and the following disclaimer in
  5448. the documentation and/or other materials provided with the distribution.
  5449. 3. The names of the authors may not be used to endorse or promote products
  5450. derived from this software without specific prior written permission.
  5451. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5452. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5453. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5454. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5455. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5456. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5457. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5458. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5459. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5460. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5461. */
  5462. function getMimeType$1() {
  5463. return "application/octet-stream";
  5464. }
  5465. /*
  5466. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5467. Redistribution and use in source and binary forms, with or without
  5468. modification, are permitted provided that the following conditions are met:
  5469. 1. Redistributions of source code must retain the above copyright notice,
  5470. this list of conditions and the following disclaimer.
  5471. 2. Redistributions in binary form must reproduce the above copyright
  5472. notice, this list of conditions and the following disclaimer in
  5473. the documentation and/or other materials provided with the distribution.
  5474. 3. The names of the authors may not be used to endorse or promote products
  5475. derived from this software without specific prior written permission.
  5476. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5477. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5478. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5479. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5480. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5481. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5482. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5483. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5484. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5485. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5486. */
  5487. try {
  5488. configure({ baseURI: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('zip-fs.js', document.baseURI).href)) });
  5489. } catch {
  5490. // ignored
  5491. }
  5492. const A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function g(g){let B;g({wasmURI:()=>(B||(B="data:application/wasm;base64,"+(g=>{g=(g=>{const B=(g=(g+"").replace(/[^A-Za-z0-9+/=]/g,"")).length,E=[];for(let I=0;B>I;I+=4){const B=A.indexOf(g[I])<<18|A.indexOf(g[I+1])<<12|(63&A.indexOf(g[I+2]))<<6|63&A.indexOf(g[I+3]);E.push(B>>16&255),"="!==g[I+2]&&E.push(B>>8&255),"="!==g[I+3]&&E.push(255&B);}return new Uint8Array(E)})(g);let B=new Uint8Array(1024),E=0;for(let A=0;A<g.length;){const C=g[A++];if(128&C){const Q=3+(127&C),D=g[A++]<<8|g[A++],o=E-D;I(E+Q);for(let A=0;Q>A;A++)B[E++]=B[o+A];}else {const Q=C;I(E+Q);for(let I=0;Q>I&&A<g.length;I++)B[E++]=g[A++];}}return (g=>{let B="";const E=g.length;let I=0;for(;E>I+2;I+=3){const E=g[I]<<16|g[I+1]<<8|g[I+2];B+=A[E>>18&63]+A[E>>12&63]+A[E>>6&63]+A[63&E];}const C=E-I;if(1===C){const E=g[I]<<16;B+=A[E>>18&63]+A[E>>12&63]+"==";}else if(2===C){const E=g[I]<<16|g[I+1]<<8;B+=A[E>>18&63]+A[E>>12&63]+A[E>>6&63]+"=";}return B})(new Uint8Array(B.buffer.slice(0,E)));function I(A){if(B.length<A){let g=2*B.length;for(;A>g;)g*=2;const I=new Uint8Array(g);I.set(B.subarray(0,E)),B=I;}}})("FQBhc20BAAAAAUULYAF/AX9gAn9/AIEABYAACwIDf4IABwEBgAARAQaAAAuDAA6BABUDAGAAgAADgAANAQSBABUDAGAHgwAegAAfEgNCQQcABAEABAgIAAIABQIKAIAAB4EAAwEFgQAHAgICgQA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gAAEASSAAAQBZIAABAEUgAAEAVSAAAQBNIAABAF0gAAEAQOAAEIBg4AABAFDgAAEAcOAAAQBI4AABAGjgAAEAWOAAAQB44AABIC+K4AAdIECxgEFgABcAQWCBUoBFIAABAEMgAAEARyAAASAvlaABEQBBYIGBAEaggXqAQWAA9QBBYADuAEFgAOcgE92gAAEARGAAAQBCYAABAEZgAAEgQACARWAAAQBDYAABAEdgAAEgL59gAKkgQZAAQWAAiyBBaYBBYABtAEFgD3fAxsLTYMfuYcABIC+rooABIEHUYkABAEEjAAEAQWKAAQEQbAcC4C9CosAS40AO4UALwEGhAAEgQWIgQAEgQEKgQAEgQGSgQAEgIS2ggAEAQuEAAQBDIQABIAF24FHeQTgHQsjhQBfhQXLAhARgAVtBgcJBgoFC4A6uAQNAg4BgAclBJQeC2mFAJCFAIiFAICFAHiBAGiBAFyBBh8BEIAABAEUgAAEARiAAAQBHIAABAEggAAEASiAAAQBMIAABAE4gAAEAUCAAAQBUIAABIEGvQFwgAAEAYCAAAQBoIAABAHAgAAEAeCAAG8DHwtyjQBvgQBrgQBngQBjgQBfgQBbgQBXgQBTgQBPgQBLgQBHgQBDgQE8AYCvAEGAUc0CC22BAMcBBIAAAgEIgAAEgQEzgQJLARCAAA6DAAyBnqyAqmuEACSBB3OBAE8BCIAACIEAGIUADIEIt4MADAEggQCUgDKEgQBrAYCBCC8BBIMADIA/SAoBABAMAEGRIQv/gCUfgMDAgIKxBQgJCQoKgEk3gAABAQ2AAAEBDoAAAQEPgAABARCEAAEBEYQAAQEShAABAROEAAEBFIwAAQEVjAABARaMAAEBF4wAAQEYnAABARmcAAEBGpwAAQEbmwABARyBffsEBAQFBYHB1QEHgAABAQiEAAGAXSqCAAEBCowAAYAnsooAAYEBMJkAAYEBTJkAAYEBaLkAAYEBpLkAAYIDdYABzoUBvI0BqJ0BkLwBgAIbHLwAAQEdvAABgA9PgH05A9AqAQ==")),B)});}
  5493. /*
  5494. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5495. Redistribution and use in source and binary forms, with or without
  5496. modification, are permitted provided that the following conditions are met:
  5497. 1. Redistributions of source code must retain the above copyright notice,
  5498. this list of conditions and the following disclaimer.
  5499. 2. Redistributions in binary form must reproduce the above copyright
  5500. notice, this list of conditions and the following disclaimer in
  5501. the documentation and/or other materials provided with the distribution.
  5502. 3. The names of the authors may not be used to endorse or promote products
  5503. derived from this software without specific prior written permission.
  5504. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5505. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5506. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5507. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5508. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5509. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5510. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5511. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5512. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5513. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5514. */
  5515. /* global TransformStream */
  5516. let wasm, malloc, free, memory;
  5517. function setWasmExports(wasmAPI) {
  5518. wasm = wasmAPI;
  5519. ({ malloc, free, memory } = wasm);
  5520. if (typeof malloc !== "function" || typeof free !== "function" || !memory) {
  5521. wasm = malloc = free = memory = null;
  5522. throw new Error("Invalid WASM module");
  5523. }
  5524. }
  5525. function _make(isCompress, type, options = {}) {
  5526. const level = (typeof options.level === "number") ? options.level : -1;
  5527. const outBufferSize = (typeof options.outBuffer === "number") ? options.outBuffer : 64 * 1024;
  5528. const inBufferSize = (typeof options.inBufferSize === "number") ? options.inBufferSize : 64 * 1024;
  5529. return new TransformStream({
  5530. start() {
  5531. let result;
  5532. this.out = malloc(outBufferSize);
  5533. this.in = malloc(inBufferSize);
  5534. this.inBufferSize = inBufferSize;
  5535. this._scratch = new Uint8Array(outBufferSize);
  5536. if (isCompress) {
  5537. this._process = wasm.deflate_process;
  5538. this._last_consumed = wasm.deflate_last_consumed;
  5539. this._end = wasm.deflate_end;
  5540. this.streamHandle = wasm.deflate_new();
  5541. if (type === "gzip") {
  5542. result = wasm.deflate_init_gzip(this.streamHandle, level);
  5543. } else if (type === "deflate-raw") {
  5544. result = wasm.deflate_init_raw(this.streamHandle, level);
  5545. } else {
  5546. result = wasm.deflate_init(this.streamHandle, level);
  5547. }
  5548. } else {
  5549. if (type === "deflate64-raw") {
  5550. this._process = wasm.inflate9_process;
  5551. this._last_consumed = wasm.inflate9_last_consumed;
  5552. this._end = wasm.inflate9_end;
  5553. this.streamHandle = wasm.inflate9_new();
  5554. result = wasm.inflate9_init_raw(this.streamHandle);
  5555. } else {
  5556. this._process = wasm.inflate_process;
  5557. this._last_consumed = wasm.inflate_last_consumed;
  5558. this._end = wasm.inflate_end;
  5559. this.streamHandle = wasm.inflate_new();
  5560. if (type === "deflate-raw") {
  5561. result = wasm.inflate_init_raw(this.streamHandle);
  5562. } else if (type === "gzip") {
  5563. result = wasm.inflate_init_gzip(this.streamHandle);
  5564. } else {
  5565. result = wasm.inflate_init(this.streamHandle);
  5566. }
  5567. }
  5568. }
  5569. if (result !== 0) {
  5570. throw new Error("init failed:" + result);
  5571. }
  5572. },
  5573. transform(chunk, controller) {
  5574. try {
  5575. const buffer = chunk;
  5576. const heap = new Uint8Array(memory.buffer);
  5577. const process = this._process;
  5578. const last_consumed = this._last_consumed;
  5579. const out = this.out;
  5580. const scratch = this._scratch;
  5581. let offset = 0;
  5582. while (offset < buffer.length) {
  5583. const toRead = Math.min(buffer.length - offset, 32 * 1024);
  5584. if (!this.in || this.inBufferSize < toRead) {
  5585. if (this.in && free) {
  5586. free(this.in);
  5587. }
  5588. this.in = malloc(toRead);
  5589. this.inBufferSize = toRead;
  5590. }
  5591. heap.set(buffer.subarray(offset, offset + toRead), this.in);
  5592. const result = process(this.streamHandle, this.in, toRead, out, outBufferSize, 0);
  5593. const prod = result & 0x00ffffff;
  5594. if (prod) {
  5595. scratch.set(heap.subarray(out, out + prod), 0);
  5596. controller.enqueue(scratch.slice(0, prod));
  5597. }
  5598. if (!isCompress) {
  5599. const code = (result >> 24) & 0xff;
  5600. const signedCode = (code & 0x80) ? code - 256 : code;
  5601. if (signedCode < 0) {
  5602. throw new Error("process error:" + signedCode);
  5603. }
  5604. }
  5605. const consumed = last_consumed(this.streamHandle);
  5606. if (consumed === 0) {
  5607. break;
  5608. }
  5609. offset += consumed;
  5610. }
  5611. } catch (error) {
  5612. if (this._end && this.streamHandle) {
  5613. this._end(this.streamHandle);
  5614. }
  5615. if (this.in && free) {
  5616. free(this.in);
  5617. }
  5618. if (this.out && free) {
  5619. free(this.out);
  5620. }
  5621. controller.error(error);
  5622. }
  5623. },
  5624. flush(controller) {
  5625. try {
  5626. const heap = new Uint8Array(memory.buffer);
  5627. const process = this._process;
  5628. const out = this.out;
  5629. const scratch = this._scratch;
  5630. while (true) {
  5631. const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
  5632. const produced = result & 0x00ffffff;
  5633. const code = (result >> 24) & 0xff;
  5634. if (!isCompress) {
  5635. const signedCode = (code & 0x80) ? code - 256 : code;
  5636. if (signedCode < 0) {
  5637. throw new Error("process error:" + signedCode);
  5638. }
  5639. }
  5640. if (produced) {
  5641. scratch.set(heap.subarray(out, out + produced), 0);
  5642. controller.enqueue(scratch.slice(0, produced));
  5643. }
  5644. if (code === 1 || produced === 0) {
  5645. break;
  5646. }
  5647. }
  5648. } catch (error) {
  5649. controller.error(error);
  5650. } finally {
  5651. if (this._end && this.streamHandle) {
  5652. const result = this._end(this.streamHandle);
  5653. if (result !== 0) {
  5654. controller.error(new Error("end error:" + result));
  5655. }
  5656. }
  5657. if (this.in && free) {
  5658. free(this.in);
  5659. }
  5660. if (this.out && free) {
  5661. free(this.out);
  5662. }
  5663. }
  5664. }
  5665. });
  5666. }
  5667. class CompressionStreamZlib {
  5668. constructor(type = "deflate", options) {
  5669. return _make(true, type, options);
  5670. }
  5671. }
  5672. class DecompressionStreamZlib {
  5673. constructor(type = "deflate", options) {
  5674. return _make(false, type, options);
  5675. }
  5676. }
  5677. /*
  5678. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5679. Redistribution and use in source and binary forms, with or without
  5680. modification, are permitted provided that the following conditions are met:
  5681. 1. Redistributions of source code must retain the above copyright notice,
  5682. this list of conditions and the following disclaimer.
  5683. 2. Redistributions in binary form must reproduce the above copyright
  5684. notice, this list of conditions and the following disclaimer in
  5685. the documentation and/or other materials provided with the distribution.
  5686. 3. The names of the authors may not be used to endorse or promote products
  5687. derived from this software without specific prior written permission.
  5688. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5689. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5690. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5691. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5692. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5693. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5694. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5695. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5696. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5697. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5698. */
  5699. let initializedModule = false;
  5700. async function initModule(wasmURI, { baseURI }) {
  5701. if (!initializedModule) {
  5702. let arrayBuffer, uri;
  5703. try {
  5704. try {
  5705. uri = new URL(wasmURI, baseURI);
  5706. } catch {
  5707. // ignored
  5708. }
  5709. const response = await fetch(uri);
  5710. arrayBuffer = await response.arrayBuffer();
  5711. } catch (error) {
  5712. if (wasmURI.startsWith("data:application/wasm;base64,")) {
  5713. arrayBuffer = arrayBufferFromDataURI(wasmURI);
  5714. } else {
  5715. throw error;
  5716. }
  5717. }
  5718. const wasmInstance = await WebAssembly.instantiate(arrayBuffer);
  5719. setWasmExports(wasmInstance.instance.exports);
  5720. initializedModule = true;
  5721. }
  5722. }
  5723. function resetWasmModule() {
  5724. initializedModule = false;
  5725. }
  5726. function arrayBufferFromDataURI(dataURI) {
  5727. const base64 = dataURI.split(",")[1];
  5728. const binary = atob(base64);
  5729. const len = binary.length;
  5730. const bytes = new Uint8Array(len);
  5731. for (let i = 0; i < len; ++i) {
  5732. bytes[i] = binary.charCodeAt(i);
  5733. }
  5734. return bytes.buffer;
  5735. }
  5736. /*
  5737. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  5738. Redistribution and use in source and binary forms, with or without
  5739. modification, are permitted provided that the following conditions are met:
  5740. 1. Redistributions of source code must retain the above copyright notice,
  5741. this list of conditions and the following disclaimer.
  5742. 2. Redistributions in binary form must reproduce the above copyright
  5743. notice, this list of conditions and the following disclaimer in
  5744. the documentation and/or other materials provided with the distribution.
  5745. 3. The names of the authors may not be used to endorse or promote products
  5746. derived from this software without specific prior written permission.
  5747. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5748. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5749. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5750. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5751. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5752. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5753. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5754. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5755. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5756. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5757. */
  5758. let modulePromise;
  5759. g(configure);
  5760. configureWorker({
  5761. initModule: config => {
  5762. if (!modulePromise) {
  5763. let { wasmURI } = config;
  5764. // deno-lint-ignore valid-typeof
  5765. if (typeof wasmURI == FUNCTION_TYPE) {
  5766. wasmURI = wasmURI();
  5767. }
  5768. modulePromise = initModule(wasmURI, config);
  5769. }
  5770. return modulePromise;
  5771. }
  5772. });
  5773. configure({
  5774. CompressionStreamZlib,
  5775. DecompressionStreamZlib
  5776. });
  5777. function terminateWorkersAndModule() {
  5778. modulePromise = null;
  5779. terminateWorkers();
  5780. resetWasmModule();
  5781. }
  5782. /*
  5783. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  5784. Redistribution and use in source and binary forms, with or without
  5785. modification, are permitted provided that the following conditions are met:
  5786. 1. Redistributions of source code must retain the above copyright notice,
  5787. this list of conditions and the following disclaimer.
  5788. 2. Redistributions in binary form must reproduce the above copyright
  5789. notice, this list of conditions and the following disclaimer in
  5790. the documentation and/or other materials provided with the distribution.
  5791. 3. The names of the authors may not be used to endorse or promote products
  5792. derived from this software without specific prior written permission.
  5793. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  5794. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5795. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  5796. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  5797. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5798. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  5799. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  5800. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  5801. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  5802. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5803. */
  5804. class ZipEntry {
  5805. constructor(fs, name, params, parent) {
  5806. const zipEntry = this;
  5807. if (fs.root && parent && parent.getChildByName(name)) {
  5808. throw new Error("Entry filename already exists");
  5809. }
  5810. if (!params) {
  5811. params = {};
  5812. }
  5813. Object.assign(zipEntry, {
  5814. fs,
  5815. name,
  5816. data: params.data,
  5817. options: params.options,
  5818. id: fs.entries.length,
  5819. parent,
  5820. children: [],
  5821. uncompressedSize: params.uncompressedSize || 0,
  5822. passThrough: params.passThrough
  5823. });
  5824. fs.entries.push(zipEntry);
  5825. if (parent) {
  5826. zipEntry.parent.children.push(zipEntry);
  5827. }
  5828. }
  5829. moveTo(target) {
  5830. // deprecated
  5831. const zipEntry = this;
  5832. zipEntry.fs.move(zipEntry, target);
  5833. }
  5834. getFullname() {
  5835. return this.getRelativeName();
  5836. }
  5837. getRelativeName(ancestor = this.fs.root) {
  5838. const zipEntry = this;
  5839. let relativeName = zipEntry.name;
  5840. let entry = zipEntry.parent;
  5841. while (entry && entry != ancestor) {
  5842. relativeName = (entry.name ? entry.name + "/" : "") + relativeName;
  5843. entry = entry.parent;
  5844. }
  5845. return relativeName;
  5846. }
  5847. isDescendantOf(ancestor) {
  5848. let entry = this.parent;
  5849. while (entry && entry.id != ancestor.id) {
  5850. entry = entry.parent;
  5851. }
  5852. return Boolean(entry);
  5853. }
  5854. rename(name) {
  5855. const parent = this.parent;
  5856. if (parent && parent.getChildByName(name)) {
  5857. throw new Error("Entry filename already exists");
  5858. } else {
  5859. this.name = name;
  5860. }
  5861. }
  5862. }
  5863. class ZipFileEntry extends ZipEntry {
  5864. constructor(fs, name, params, parent) {
  5865. super(fs, name, params, parent);
  5866. const zipEntry = this;
  5867. zipEntry.Reader = params.Reader;
  5868. zipEntry.Writer = params.Writer;
  5869. if (params.getData) {
  5870. zipEntry.getData = params.getData;
  5871. }
  5872. }
  5873. clone() {
  5874. return new ZipFileEntry(this.fs, this.name, this);
  5875. }
  5876. async getData(writer, options = {}) {
  5877. const zipEntry = this;
  5878. if (!writer || (writer.constructor == zipEntry.Writer && zipEntry.data)) {
  5879. return zipEntry.data;
  5880. } else {
  5881. const reader = zipEntry.reader = new zipEntry.Reader(zipEntry.data, options);
  5882. const uncompressedSize = zipEntry.data ? zipEntry.data.uncompressedSize : reader.size;
  5883. await Promise.all([initStream(reader), initStream(writer, uncompressedSize)]);
  5884. const { readable } = reader;
  5885. zipEntry.uncompressedSize = reader.size;
  5886. await readable.pipeTo(writer.writable);
  5887. return writer.getData ? writer.getData() : writer.writable;
  5888. }
  5889. }
  5890. isPasswordProtected() {
  5891. return this.data.encrypted;
  5892. }
  5893. async checkPassword(password, options = {}) {
  5894. const zipEntry = this;
  5895. if (zipEntry.isPasswordProtected()) {
  5896. options.password = password;
  5897. options.checkPasswordOnly = true;
  5898. try {
  5899. await zipEntry.data.getData(null, options);
  5900. return true;
  5901. } catch (error) {
  5902. if (error.message == ERR_INVALID_PASSWORD) {
  5903. return false;
  5904. } else {
  5905. throw error;
  5906. }
  5907. }
  5908. } else {
  5909. return true;
  5910. }
  5911. }
  5912. getText(encoding, options) {
  5913. return this.getData(new TextWriter(encoding), options);
  5914. }
  5915. getBlob(mimeType, options) {
  5916. return this.getData(new BlobWriter(mimeType), options);
  5917. }
  5918. getData64URI(mimeType, options) {
  5919. return this.getData(new Data64URIWriter(mimeType), options);
  5920. }
  5921. getUint8Array(options) {
  5922. return this.getData(new Uint8ArrayWriter(), options);
  5923. }
  5924. getWritable(writable = new WritableStream(), options) {
  5925. return this.getData({ writable }, options);
  5926. }
  5927. getArrayBuffer(options) {
  5928. return this.data.arrayBuffer(options);
  5929. }
  5930. replaceBlob(blob) {
  5931. Object.assign(this, {
  5932. data: blob,
  5933. Reader: BlobReader,
  5934. Writer: BlobWriter,
  5935. reader: null
  5936. });
  5937. }
  5938. replaceText(text) {
  5939. Object.assign(this, {
  5940. data: text,
  5941. Reader: TextReader,
  5942. Writer: TextWriter,
  5943. reader: null
  5944. });
  5945. }
  5946. replaceData64URI(dataURI) {
  5947. Object.assign(this, {
  5948. data: dataURI,
  5949. Reader: Data64URIReader,
  5950. Writer: Data64URIWriter,
  5951. reader: null
  5952. });
  5953. }
  5954. replaceUint8Array(array) {
  5955. Object.assign(this, {
  5956. data: array,
  5957. Reader: Uint8ArrayReader,
  5958. Writer: Uint8ArrayWriter,
  5959. reader: null
  5960. });
  5961. }
  5962. replaceReadable(readable) {
  5963. Object.assign(this, {
  5964. data: null,
  5965. Reader: function () { return { readable }; },
  5966. Writer: null,
  5967. reader: null
  5968. });
  5969. }
  5970. }
  5971. class ZipDirectoryEntry extends ZipEntry {
  5972. constructor(fs, name, params, parent) {
  5973. super(fs, name, params, parent);
  5974. this.directory = true;
  5975. }
  5976. clone(deepClone) {
  5977. const zipEntry = this;
  5978. const clonedEntry = new ZipDirectoryEntry(zipEntry.fs, zipEntry.name);
  5979. if (deepClone) {
  5980. clonedEntry.children = zipEntry.children.map(child => {
  5981. const childClone = child.clone(deepClone);
  5982. childClone.parent = clonedEntry;
  5983. return childClone;
  5984. });
  5985. }
  5986. return clonedEntry;
  5987. }
  5988. addDirectory(name, options) {
  5989. return addChild(this, name, { options }, true);
  5990. }
  5991. addText(name, text, options = {}) {
  5992. return addChild(this, name, {
  5993. data: text,
  5994. Reader: TextReader,
  5995. Writer: TextWriter,
  5996. options,
  5997. uncompressedSize: text.length
  5998. });
  5999. }
  6000. addBlob(name, blob, options = {}) {
  6001. return addChild(this, name, {
  6002. data: blob,
  6003. Reader: BlobReader,
  6004. Writer: BlobWriter,
  6005. options,
  6006. uncompressedSize: blob.size
  6007. });
  6008. }
  6009. addData64URI(name, dataURI, options = {}) {
  6010. let dataEnd = dataURI.length;
  6011. while (dataURI.charAt(dataEnd - 1) == "=") {
  6012. dataEnd--;
  6013. }
  6014. const dataStart = dataURI.indexOf(",") + 1;
  6015. return addChild(this, name, {
  6016. data: dataURI,
  6017. Reader: Data64URIReader,
  6018. Writer: Data64URIWriter,
  6019. options,
  6020. uncompressedSize: Math.floor((dataEnd - dataStart) * 0.75)
  6021. });
  6022. }
  6023. addUint8Array(name, array, options = {}) {
  6024. return addChild(this, name, {
  6025. data: array,
  6026. Reader: Uint8ArrayReader,
  6027. Writer: Uint8ArrayWriter,
  6028. options,
  6029. uncompressedSize: array.length
  6030. });
  6031. }
  6032. addHttpContent(name, url, options = {}) {
  6033. return addChild(this, name, {
  6034. data: url,
  6035. Reader: class extends HttpReader {
  6036. constructor(url) {
  6037. super(url, options);
  6038. }
  6039. },
  6040. options
  6041. });
  6042. }
  6043. addReadable(name, readable, options = {}) {
  6044. return addChild(this, name, {
  6045. Reader: function () { return { readable }; },
  6046. options
  6047. });
  6048. }
  6049. addFileSystemEntry(fileSystemEntry, options = {}) {
  6050. return addFileSystemHandle(this, fileSystemEntry, options);
  6051. }
  6052. addFileSystemHandle(handle, options = {}) {
  6053. return addFileSystemHandle(this, handle, options);
  6054. }
  6055. addFile(file, options = {}) {
  6056. if (!options.lastModDate) {
  6057. options.lastModDate = new Date(file.lastModified);
  6058. }
  6059. return addChild(this, file.name, {
  6060. data: file,
  6061. Reader: function () {
  6062. const readable = file.stream();
  6063. const size = file.size;
  6064. return { readable, size };
  6065. },
  6066. options,
  6067. uncompressedSize: file.size
  6068. });
  6069. }
  6070. addData(name, params) {
  6071. return addChild(this, name, params);
  6072. }
  6073. importBlob(blob, options) {
  6074. return this.importZip(new BlobReader(blob), options);
  6075. }
  6076. importData64URI(dataURI, options) {
  6077. return this.importZip(new Data64URIReader(dataURI), options);
  6078. }
  6079. importUint8Array(array, options) {
  6080. return this.importZip(new Uint8ArrayReader(array), options);
  6081. }
  6082. importHttpContent(url, options) {
  6083. return this.importZip(new HttpReader(url, options), options);
  6084. }
  6085. importReadable(readable, options) {
  6086. return this.importZip({ readable }, options);
  6087. }
  6088. exportBlob(options = {}) {
  6089. return this.exportZip(new BlobWriter(options.mimeType || "application/zip"), options);
  6090. }
  6091. exportData64URI(options = {}) {
  6092. return this.exportZip(new Data64URIWriter(options.mimeType || "application/zip"), options);
  6093. }
  6094. exportUint8Array(options = {}) {
  6095. return this.exportZip(new Uint8ArrayWriter(), options);
  6096. }
  6097. async exportWritable(writable = new WritableStream(), options = {}) {
  6098. await this.exportZip({ writable }, options);
  6099. return writable;
  6100. }
  6101. async importZip(reader, options = {}) {
  6102. await initStream(reader);
  6103. const zipReader = new ZipReader(reader, options);
  6104. const importedEntries = [];
  6105. const entries = await zipReader.getEntries();
  6106. for (const entry of entries) {
  6107. let parent = this;
  6108. try {
  6109. const path = entry.filename.split("/");
  6110. const name = path.pop();
  6111. path.forEach((pathPart, pathIndex) => {
  6112. const previousParent = parent;
  6113. parent = parent.getChildByName(pathPart);
  6114. if (!parent) {
  6115. parent = new ZipDirectoryEntry(this.fs, pathPart, { data: pathIndex == path.length - 1 ? entry : null }, previousParent);
  6116. importedEntries.push(parent);
  6117. }
  6118. });
  6119. if (!entry.directory) {
  6120. importedEntries.push(addChild(parent, name, {
  6121. data: entry,
  6122. Reader: getZipBlobReader(Object.assign({}, options)),
  6123. uncompressedSize: entry.uncompressedSize,
  6124. passThrough: options.passThrough
  6125. }));
  6126. }
  6127. } catch (error) {
  6128. try {
  6129. error.cause = {
  6130. entry
  6131. };
  6132. } catch {
  6133. // ignored
  6134. }
  6135. throw error;
  6136. }
  6137. }
  6138. return importedEntries;
  6139. }
  6140. async exportZip(writer, options) {
  6141. const zipEntry = this;
  6142. if (options.bufferedWrite === UNDEFINED_VALUE) {
  6143. options.bufferedWrite = true;
  6144. }
  6145. await Promise.all([initReaders(zipEntry, options.readerOptions), initStream(writer)]);
  6146. const zipWriter = new ZipWriter(writer, options);
  6147. await exportZip(zipWriter, zipEntry, getTotalSize([zipEntry], "uncompressedSize"), options);
  6148. await zipWriter.close();
  6149. return writer.getData ? writer.getData() : writer.writable;
  6150. }
  6151. getChildByName(name) {
  6152. const children = this.children;
  6153. for (let childIndex = 0; childIndex < children.length; childIndex++) {
  6154. const child = children[childIndex];
  6155. if (child.name == name) {
  6156. return child;
  6157. }
  6158. }
  6159. }
  6160. isPasswordProtected() {
  6161. const children = this.children;
  6162. for (let childIndex = 0; childIndex < children.length; childIndex++) {
  6163. const child = children[childIndex];
  6164. if (child.isPasswordProtected()) {
  6165. return true;
  6166. }
  6167. }
  6168. return false;
  6169. }
  6170. async checkPassword(password, options = {}) {
  6171. const children = this.children;
  6172. const result = await Promise.all(children.map(child => child.checkPassword(password, options)));
  6173. return !result.includes(false);
  6174. }
  6175. }
  6176. class FS {
  6177. constructor() {
  6178. resetFS(this);
  6179. }
  6180. get children() {
  6181. return this.root.children;
  6182. }
  6183. remove(entry) {
  6184. detach(entry);
  6185. this.entries[entry.id] = null;
  6186. }
  6187. move(entry, destination) {
  6188. if (entry == this.root) {
  6189. throw new Error("Root directory cannot be moved");
  6190. } else {
  6191. if (destination.directory) {
  6192. if (!destination.isDescendantOf(entry)) {
  6193. if (entry != destination) {
  6194. if (destination.getChildByName(entry.name)) {
  6195. throw new Error("Entry filename already exists");
  6196. }
  6197. detach(entry);
  6198. entry.parent = destination;
  6199. destination.children.push(entry);
  6200. }
  6201. } else {
  6202. throw new Error("Entry is a ancestor of target entry");
  6203. }
  6204. } else {
  6205. throw new Error("Target entry is not a directory");
  6206. }
  6207. }
  6208. }
  6209. find(fullname) {
  6210. const path = fullname.split("/");
  6211. let node = this.root;
  6212. for (let index = 0; node && index < path.length; index++) {
  6213. node = node.getChildByName(path[index]);
  6214. }
  6215. return node;
  6216. }
  6217. getById(id) {
  6218. return this.entries[id];
  6219. }
  6220. getChildByName(name) {
  6221. return this.root.getChildByName(name);
  6222. }
  6223. addDirectory(name, options) {
  6224. return this.root.addDirectory(name, options);
  6225. }
  6226. addText(name, text, options) {
  6227. return this.root.addText(name, text, options);
  6228. }
  6229. addBlob(name, blob, options) {
  6230. return this.root.addBlob(name, blob, options);
  6231. }
  6232. addData64URI(name, dataURI, options) {
  6233. return this.root.addData64URI(name, dataURI, options);
  6234. }
  6235. addUint8Array(name, array, options) {
  6236. return this.root.addUint8Array(name, array, options);
  6237. }
  6238. addHttpContent(name, url, options) {
  6239. return this.root.addHttpContent(name, url, options);
  6240. }
  6241. addReadable(name, readable, options) {
  6242. return this.root.addReadable(name, readable, options);
  6243. }
  6244. addFileSystemEntry(fileSystemEntry, options) {
  6245. return this.root.addFileSystemEntry(fileSystemEntry, options);
  6246. }
  6247. addFileSystemHandle(handle, options) {
  6248. return this.root.addFileSystemHandle(handle, options);
  6249. }
  6250. addFile(file, options) {
  6251. return this.root.addFile(file, options);
  6252. }
  6253. addData(name, params) {
  6254. return this.root.addData(name, params);
  6255. }
  6256. importBlob(blob, options) {
  6257. resetFS(this);
  6258. return this.root.importBlob(blob, options);
  6259. }
  6260. importData64URI(dataURI, options) {
  6261. resetFS(this);
  6262. return this.root.importData64URI(dataURI, options);
  6263. }
  6264. importUint8Array(array, options) {
  6265. resetFS(this);
  6266. return this.root.importUint8Array(array, options);
  6267. }
  6268. importHttpContent(url, options) {
  6269. resetFS(this);
  6270. return this.root.importHttpContent(url, options);
  6271. }
  6272. importReadable(readable, options) {
  6273. resetFS(this);
  6274. return this.root.importReadable(readable, options);
  6275. }
  6276. importZip(reader, options) {
  6277. return this.root.importZip(reader, options);
  6278. }
  6279. exportBlob(options) {
  6280. return this.root.exportBlob(options);
  6281. }
  6282. exportData64URI(options) {
  6283. return this.root.exportData64URI(options);
  6284. }
  6285. exportUint8Array(options) {
  6286. return this.root.exportUint8Array(options);
  6287. }
  6288. exportWritable(writable, options) {
  6289. return this.root.exportWritable(writable, options);
  6290. }
  6291. isPasswordProtected() {
  6292. return this.root.isPasswordProtected();
  6293. }
  6294. checkPassword(password, options) {
  6295. return this.root.checkPassword(password, options);
  6296. }
  6297. }
  6298. const fs = { FS, ZipDirectoryEntry, ZipFileEntry };
  6299. function getTotalSize(entries, propertyName) {
  6300. let size = 0;
  6301. entries.forEach(process);
  6302. return size;
  6303. function process(entry) {
  6304. size += entry[propertyName];
  6305. if (entry.children) {
  6306. entry.children.forEach(process);
  6307. }
  6308. }
  6309. }
  6310. function getZipBlobReader(options) {
  6311. return class extends Reader {
  6312. constructor(entry, options = {}) {
  6313. super();
  6314. this.entry = entry;
  6315. this.options = options;
  6316. }
  6317. async init() {
  6318. const zipBlobReader = this;
  6319. zipBlobReader.size = zipBlobReader.entry.uncompressedSize;
  6320. const data = await zipBlobReader.entry.getData(new BlobWriter(), Object.assign({}, zipBlobReader.options, options));
  6321. zipBlobReader.data = data;
  6322. zipBlobReader.blobReader = new BlobReader(data);
  6323. super.init();
  6324. }
  6325. readUint8Array(index, length) {
  6326. return this.blobReader.readUint8Array(index, length);
  6327. }
  6328. };
  6329. }
  6330. async function initReaders(entry, options) {
  6331. if (entry.children.length) {
  6332. await Promise.all(entry.children.map(async child => {
  6333. if (child.directory) {
  6334. await initReaders(child, options);
  6335. } else {
  6336. const reader = child.reader = new child.Reader(child.data, options);
  6337. try {
  6338. await initStream(reader);
  6339. } catch (error) {
  6340. try {
  6341. error.entryId = child.id;
  6342. error.cause = {
  6343. entry: child
  6344. };
  6345. } catch {
  6346. // ignored
  6347. }
  6348. throw error;
  6349. }
  6350. child.uncompressedSize = reader.size;
  6351. }
  6352. }));
  6353. }
  6354. }
  6355. function detach(entry) {
  6356. if (entry.parent) {
  6357. const children = entry.parent.children;
  6358. children.forEach((child, index) => {
  6359. if (child.id == entry.id) {
  6360. children.splice(index, 1);
  6361. }
  6362. });
  6363. }
  6364. }
  6365. async function exportZip(zipWriter, entry, totalSize, options) {
  6366. const selectedEntry = entry;
  6367. const entryOffsets = new Map();
  6368. await process(zipWriter, entry);
  6369. async function process(zipWriter, entry) {
  6370. await exportChild();
  6371. async function exportChild() {
  6372. if (options.bufferedWrite) {
  6373. await Promise.allSettled(entry.children.map(processChild));
  6374. } else {
  6375. for (const child of entry.children) {
  6376. await processChild(child);
  6377. }
  6378. }
  6379. }
  6380. async function processChild(child) {
  6381. const name = options.relativePath ? child.getRelativeName(selectedEntry) : child.getFullname();
  6382. const childOptions = child.options || {};
  6383. let zipEntryOptions = {};
  6384. if (child.data instanceof Entry) {
  6385. const {
  6386. externalFileAttributes,
  6387. versionMadeBy,
  6388. comment,
  6389. lastModDate,
  6390. creationDate,
  6391. lastAccessDate,
  6392. uncompressedSize,
  6393. encrypted,
  6394. zipCrypto,
  6395. signature,
  6396. compressionMethod,
  6397. extraFieldAES
  6398. } = child.data;
  6399. zipEntryOptions = {
  6400. externalFileAttributes,
  6401. versionMadeBy,
  6402. comment,
  6403. lastModDate,
  6404. creationDate,
  6405. lastAccessDate
  6406. };
  6407. if (child.passThrough) {
  6408. let level, encryptionStrength;
  6409. if (compressionMethod === 0) {
  6410. level = 0;
  6411. }
  6412. if (extraFieldAES) {
  6413. encryptionStrength = extraFieldAES.strength;
  6414. }
  6415. zipEntryOptions = Object.assign(zipEntryOptions, {
  6416. passThrough: true,
  6417. encrypted,
  6418. zipCrypto,
  6419. signature,
  6420. uncompressedSize,
  6421. level,
  6422. encryptionStrength,
  6423. compressionMethod
  6424. });
  6425. }
  6426. }
  6427. await zipWriter.add(name, child.reader, Object.assign({}, options, zipEntryOptions, childOptions, {
  6428. directory: child.directory,
  6429. onprogress: async indexProgress => {
  6430. if (options.onprogress) {
  6431. entryOffsets.set(name, indexProgress);
  6432. try {
  6433. await options.onprogress(Array.from(entryOffsets.values()).reduce((previousValue, currentValue) => previousValue + currentValue), totalSize);
  6434. } catch {
  6435. // ignored
  6436. }
  6437. }
  6438. }
  6439. }));
  6440. await process(zipWriter, child);
  6441. }
  6442. }
  6443. }
  6444. function addFileSystemHandle(zipEntry, handle, options) {
  6445. return addFile(zipEntry, handle, []);
  6446. async function addFile(parentEntry, handle, addedEntries) {
  6447. if (handle) {
  6448. try {
  6449. if (handle.isFile || handle.isDirectory) {
  6450. handle = await transformToFileSystemhandle(handle);
  6451. }
  6452. if (handle.kind == "file") {
  6453. const file = await handle.getFile();
  6454. addedEntries.push(
  6455. parentEntry.addData(file.name, {
  6456. Reader: function () {
  6457. const readable = file.stream();
  6458. const size = file.size;
  6459. return { readable, size };
  6460. },
  6461. options: Object.assign({}, { lastModDate: new Date(file.lastModified) }, options),
  6462. uncompressedSize: file.size
  6463. })
  6464. );
  6465. } else if (handle.kind == "directory") {
  6466. const directoryEntry = parentEntry.addDirectory(handle.name);
  6467. addedEntries.push(directoryEntry);
  6468. for await (const childHandle of handle.values()) {
  6469. await addFile(directoryEntry, childHandle, addedEntries);
  6470. }
  6471. }
  6472. } catch (error) {
  6473. const message = error.message + (handle ? " (" + handle.name + ")" : "");
  6474. throw new Error(message);
  6475. }
  6476. }
  6477. return addedEntries;
  6478. }
  6479. }
  6480. async function transformToFileSystemhandle(entry) {
  6481. const handle = {
  6482. name: entry.name
  6483. };
  6484. if (entry.isFile) {
  6485. handle.kind = "file";
  6486. handle.getFile = () =>
  6487. new Promise((resolve, reject) => entry.file(resolve, reject));
  6488. }
  6489. if (entry.isDirectory) {
  6490. handle.kind = "directory";
  6491. const handles = await transformToFileSystemhandles(entry);
  6492. handle.values = () => handles;
  6493. }
  6494. return handle;
  6495. }
  6496. async function transformToFileSystemhandles(entry) {
  6497. const entries = [];
  6498. function readEntries(directoryReader, resolve, reject) {
  6499. directoryReader.readEntries(async (entriesPart) => {
  6500. if (!entriesPart.length) {
  6501. resolve(entries);
  6502. } else {
  6503. for (const entry of entriesPart) {
  6504. entries.push(await transformToFileSystemhandle(entry));
  6505. }
  6506. readEntries(directoryReader, resolve, reject);
  6507. }
  6508. }, reject);
  6509. }
  6510. await new Promise((resolve, reject) =>
  6511. readEntries(entry.createReader(), resolve, reject)
  6512. );
  6513. return {
  6514. [Symbol.iterator]() {
  6515. let entryIndex = 0;
  6516. return {
  6517. next() {
  6518. const result = {
  6519. value: entries[entryIndex],
  6520. done: entryIndex == entries.length
  6521. };
  6522. entryIndex++;
  6523. return result;
  6524. }
  6525. };
  6526. }
  6527. };
  6528. }
  6529. function resetFS(fs) {
  6530. fs.entries = [];
  6531. fs.root = new ZipDirectoryEntry(fs);
  6532. }
  6533. function addChild(parent, name, params, directory) {
  6534. if (parent.directory) {
  6535. return directory ? new ZipDirectoryEntry(parent.fs, name, params, parent) : new ZipFileEntry(parent.fs, name, params, parent);
  6536. } else {
  6537. throw new Error("Parent entry is not a directory");
  6538. }
  6539. }
  6540. /*
  6541. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  6542. Redistribution and use in source and binary forms, with or without
  6543. modification, are permitted provided that the following conditions are met:
  6544. 1. Redistributions of source code must retain the above copyright notice,
  6545. this list of conditions and the following disclaimer.
  6546. 2. Redistributions in binary form must reproduce the above copyright
  6547. notice, this list of conditions and the following disclaimer in
  6548. the documentation and/or other materials provided with the distribution.
  6549. 3. The names of the authors may not be used to endorse or promote products
  6550. derived from this software without specific prior written permission.
  6551. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  6552. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  6553. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  6554. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  6555. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  6556. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  6557. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  6558. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  6559. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  6560. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6561. */
  6562. const table = {
  6563. "application": {
  6564. "andrew-inset": "ez",
  6565. "annodex": "anx",
  6566. "atom+xml": "atom",
  6567. "atomcat+xml": "atomcat",
  6568. "atomserv+xml": "atomsrv",
  6569. "bbolin": "lin",
  6570. "cu-seeme": "cu",
  6571. "davmount+xml": "davmount",
  6572. "dsptype": "tsp",
  6573. "ecmascript": [
  6574. "es",
  6575. "ecma"
  6576. ],
  6577. "futuresplash": "spl",
  6578. "hta": "hta",
  6579. "java-archive": "jar",
  6580. "java-serialized-object": "ser",
  6581. "java-vm": "class",
  6582. "m3g": "m3g",
  6583. "mac-binhex40": "hqx",
  6584. "mathematica": [
  6585. "nb",
  6586. "ma",
  6587. "mb"
  6588. ],
  6589. "msaccess": "mdb",
  6590. "msword": [
  6591. "doc",
  6592. "dot",
  6593. "wiz"
  6594. ],
  6595. "mxf": "mxf",
  6596. "oda": "oda",
  6597. "ogg": "ogx",
  6598. "pdf": "pdf",
  6599. "pgp-keys": "key",
  6600. "pgp-signature": [
  6601. "asc",
  6602. "sig"
  6603. ],
  6604. "pics-rules": "prf",
  6605. "postscript": [
  6606. "ps",
  6607. "ai",
  6608. "eps",
  6609. "epsi",
  6610. "epsf",
  6611. "eps2",
  6612. "eps3"
  6613. ],
  6614. "rar": "rar",
  6615. "rdf+xml": "rdf",
  6616. "rss+xml": "rss",
  6617. "rtf": "rtf",
  6618. "xhtml+xml": [
  6619. "xhtml",
  6620. "xht"
  6621. ],
  6622. "xml": [
  6623. "xml",
  6624. "xsl",
  6625. "xsd",
  6626. "xpdl"
  6627. ],
  6628. "xspf+xml": "xspf",
  6629. "zip": "zip",
  6630. "vnd.android.package-archive": "apk",
  6631. "vnd.cinderella": "cdy",
  6632. "vnd.google-earth.kml+xml": "kml",
  6633. "vnd.google-earth.kmz": "kmz",
  6634. "vnd.mozilla.xul+xml": "xul",
  6635. "vnd.ms-excel": [
  6636. "xls",
  6637. "xlb",
  6638. "xlt",
  6639. "xlm",
  6640. "xla",
  6641. "xlc",
  6642. "xlw"
  6643. ],
  6644. "vnd.ms-pki.seccat": "cat",
  6645. "vnd.ms-pki.stl": "stl",
  6646. "vnd.ms-powerpoint": [
  6647. "ppt",
  6648. "pps",
  6649. "pot",
  6650. "ppa",
  6651. "pwz"
  6652. ],
  6653. "vnd.oasis.opendocument.chart": "odc",
  6654. "vnd.oasis.opendocument.database": "odb",
  6655. "vnd.oasis.opendocument.formula": "odf",
  6656. "vnd.oasis.opendocument.graphics": "odg",
  6657. "vnd.oasis.opendocument.graphics-template": "otg",
  6658. "vnd.oasis.opendocument.image": "odi",
  6659. "vnd.oasis.opendocument.presentation": "odp",
  6660. "vnd.oasis.opendocument.presentation-template": "otp",
  6661. "vnd.oasis.opendocument.spreadsheet": "ods",
  6662. "vnd.oasis.opendocument.spreadsheet-template": "ots",
  6663. "vnd.oasis.opendocument.text": "odt",
  6664. "vnd.oasis.opendocument.text-master": [
  6665. "odm",
  6666. "otm"
  6667. ],
  6668. "vnd.oasis.opendocument.text-template": "ott",
  6669. "vnd.oasis.opendocument.text-web": "oth",
  6670. "vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
  6671. "vnd.openxmlformats-officedocument.spreadsheetml.template": "xltx",
  6672. "vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
  6673. "vnd.openxmlformats-officedocument.presentationml.slideshow": "ppsx",
  6674. "vnd.openxmlformats-officedocument.presentationml.template": "potx",
  6675. "vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
  6676. "vnd.openxmlformats-officedocument.wordprocessingml.template": "dotx",
  6677. "vnd.smaf": "mmf",
  6678. "vnd.stardivision.calc": "sdc",
  6679. "vnd.stardivision.chart": "sds",
  6680. "vnd.stardivision.draw": "sda",
  6681. "vnd.stardivision.impress": "sdd",
  6682. "vnd.stardivision.math": [
  6683. "sdf",
  6684. "smf"
  6685. ],
  6686. "vnd.stardivision.writer": [
  6687. "sdw",
  6688. "vor"
  6689. ],
  6690. "vnd.stardivision.writer-global": "sgl",
  6691. "vnd.sun.xml.calc": "sxc",
  6692. "vnd.sun.xml.calc.template": "stc",
  6693. "vnd.sun.xml.draw": "sxd",
  6694. "vnd.sun.xml.draw.template": "std",
  6695. "vnd.sun.xml.impress": "sxi",
  6696. "vnd.sun.xml.impress.template": "sti",
  6697. "vnd.sun.xml.math": "sxm",
  6698. "vnd.sun.xml.writer": "sxw",
  6699. "vnd.sun.xml.writer.global": "sxg",
  6700. "vnd.sun.xml.writer.template": "stw",
  6701. "vnd.symbian.install": [
  6702. "sis",
  6703. "sisx"
  6704. ],
  6705. "vnd.visio": [
  6706. "vsd",
  6707. "vst",
  6708. "vss",
  6709. "vsw",
  6710. "vsdx",
  6711. "vssx",
  6712. "vstx",
  6713. "vssm",
  6714. "vstm"
  6715. ],
  6716. "vnd.wap.wbxml": "wbxml",
  6717. "vnd.wap.wmlc": "wmlc",
  6718. "vnd.wap.wmlscriptc": "wmlsc",
  6719. "vnd.wordperfect": "wpd",
  6720. "vnd.wordperfect5.1": "wp5",
  6721. "x-123": "wk",
  6722. "x-7z-compressed": "7z",
  6723. "x-abiword": "abw",
  6724. "x-apple-diskimage": "dmg",
  6725. "x-bcpio": "bcpio",
  6726. "x-bittorrent": "torrent",
  6727. "x-cbr": [
  6728. "cbr",
  6729. "cba",
  6730. "cbt",
  6731. "cb7"
  6732. ],
  6733. "x-cbz": "cbz",
  6734. "x-cdf": [
  6735. "cdf",
  6736. "cda"
  6737. ],
  6738. "x-cdlink": "vcd",
  6739. "x-chess-pgn": "pgn",
  6740. "x-cpio": "cpio",
  6741. "x-csh": "csh",
  6742. "x-director": [
  6743. "dir",
  6744. "dxr",
  6745. "cst",
  6746. "cct",
  6747. "cxt",
  6748. "w3d",
  6749. "fgd",
  6750. "swa"
  6751. ],
  6752. "x-dms": "dms",
  6753. "x-doom": "wad",
  6754. "x-dvi": "dvi",
  6755. "x-httpd-eruby": "rhtml",
  6756. "x-font": "pcf.Z",
  6757. "x-freemind": "mm",
  6758. "x-gnumeric": "gnumeric",
  6759. "x-go-sgf": "sgf",
  6760. "x-graphing-calculator": "gcf",
  6761. "x-gtar": [
  6762. "gtar",
  6763. "taz"
  6764. ],
  6765. "x-hdf": "hdf",
  6766. "x-httpd-php": [
  6767. "phtml",
  6768. "pht",
  6769. "php"
  6770. ],
  6771. "x-httpd-php-source": "phps",
  6772. "x-httpd-php3": "php3",
  6773. "x-httpd-php3-preprocessed": "php3p",
  6774. "x-httpd-php4": "php4",
  6775. "x-httpd-php5": "php5",
  6776. "x-ica": "ica",
  6777. "x-info": "info",
  6778. "x-internet-signup": [
  6779. "ins",
  6780. "isp"
  6781. ],
  6782. "x-iphone": "iii",
  6783. "x-iso9660-image": "iso",
  6784. "x-java-jnlp-file": "jnlp",
  6785. "x-jmol": "jmz",
  6786. "x-killustrator": "kil",
  6787. "x-latex": "latex",
  6788. "x-lyx": "lyx",
  6789. "x-lzx": "lzx",
  6790. "x-maker": [
  6791. "frm",
  6792. "fb",
  6793. "fbdoc"
  6794. ],
  6795. "x-ms-wmd": "wmd",
  6796. "x-msdos-program": [
  6797. "com",
  6798. "exe",
  6799. "bat",
  6800. "dll"
  6801. ],
  6802. "x-netcdf": [
  6803. "nc"
  6804. ],
  6805. "x-ns-proxy-autoconfig": [
  6806. "pac",
  6807. "dat"
  6808. ],
  6809. "x-nwc": "nwc",
  6810. "x-object": "o",
  6811. "x-oz-application": "oza",
  6812. "x-pkcs7-certreqresp": "p7r",
  6813. "x-python-code": [
  6814. "pyc",
  6815. "pyo"
  6816. ],
  6817. "x-qgis": [
  6818. "qgs",
  6819. "shp",
  6820. "shx"
  6821. ],
  6822. "x-quicktimeplayer": "qtl",
  6823. "x-redhat-package-manager": [
  6824. "rpm",
  6825. "rpa"
  6826. ],
  6827. "x-ruby": "rb",
  6828. "x-sh": "sh",
  6829. "x-shar": "shar",
  6830. "x-shockwave-flash": [
  6831. "swf",
  6832. "swfl"
  6833. ],
  6834. "x-silverlight": "scr",
  6835. "x-stuffit": "sit",
  6836. "x-sv4cpio": "sv4cpio",
  6837. "x-sv4crc": "sv4crc",
  6838. "x-tar": "tar",
  6839. "x-tex-gf": "gf",
  6840. "x-tex-pk": "pk",
  6841. "x-texinfo": [
  6842. "texinfo",
  6843. "texi"
  6844. ],
  6845. "x-trash": [
  6846. "~",
  6847. "%",
  6848. "bak",
  6849. "old",
  6850. "sik"
  6851. ],
  6852. "x-ustar": "ustar",
  6853. "x-wais-source": "src",
  6854. "x-wingz": "wz",
  6855. "x-x509-ca-cert": [
  6856. "crt",
  6857. "der",
  6858. "cer"
  6859. ],
  6860. "x-xcf": "xcf",
  6861. "x-xfig": "fig",
  6862. "x-xpinstall": "xpi",
  6863. "applixware": "aw",
  6864. "atomsvc+xml": "atomsvc",
  6865. "ccxml+xml": "ccxml",
  6866. "cdmi-capability": "cdmia",
  6867. "cdmi-container": "cdmic",
  6868. "cdmi-domain": "cdmid",
  6869. "cdmi-object": "cdmio",
  6870. "cdmi-queue": "cdmiq",
  6871. "docbook+xml": "dbk",
  6872. "dssc+der": "dssc",
  6873. "dssc+xml": "xdssc",
  6874. "emma+xml": "emma",
  6875. "epub+zip": "epub",
  6876. "exi": "exi",
  6877. "font-tdpfr": "pfr",
  6878. "gml+xml": "gml",
  6879. "gpx+xml": "gpx",
  6880. "gxf": "gxf",
  6881. "hyperstudio": "stk",
  6882. "inkml+xml": [
  6883. "ink",
  6884. "inkml"
  6885. ],
  6886. "ipfix": "ipfix",
  6887. "jsonml+json": "jsonml",
  6888. "lost+xml": "lostxml",
  6889. "mads+xml": "mads",
  6890. "marc": "mrc",
  6891. "marcxml+xml": "mrcx",
  6892. "mathml+xml": [
  6893. "mathml",
  6894. "mml"
  6895. ],
  6896. "mbox": "mbox",
  6897. "mediaservercontrol+xml": "mscml",
  6898. "metalink+xml": "metalink",
  6899. "metalink4+xml": "meta4",
  6900. "mets+xml": "mets",
  6901. "mods+xml": "mods",
  6902. "mp21": [
  6903. "m21",
  6904. "mp21"
  6905. ],
  6906. "mp4": "mp4s",
  6907. "oebps-package+xml": "opf",
  6908. "omdoc+xml": "omdoc",
  6909. "onenote": [
  6910. "onetoc",
  6911. "onetoc2",
  6912. "onetmp",
  6913. "onepkg"
  6914. ],
  6915. "oxps": "oxps",
  6916. "patch-ops-error+xml": "xer",
  6917. "pgp-encrypted": "pgp",
  6918. "pkcs10": "p10",
  6919. "pkcs7-mime": [
  6920. "p7m",
  6921. "p7c"
  6922. ],
  6923. "pkcs7-signature": "p7s",
  6924. "pkcs8": "p8",
  6925. "pkix-attr-cert": "ac",
  6926. "pkix-crl": "crl",
  6927. "pkix-pkipath": "pkipath",
  6928. "pkixcmp": "pki",
  6929. "pls+xml": "pls",
  6930. "prs.cww": "cww",
  6931. "pskc+xml": "pskcxml",
  6932. "reginfo+xml": "rif",
  6933. "relax-ng-compact-syntax": "rnc",
  6934. "resource-lists+xml": "rl",
  6935. "resource-lists-diff+xml": "rld",
  6936. "rls-services+xml": "rs",
  6937. "rpki-ghostbusters": "gbr",
  6938. "rpki-manifest": "mft",
  6939. "rpki-roa": "roa",
  6940. "rsd+xml": "rsd",
  6941. "sbml+xml": "sbml",
  6942. "scvp-cv-request": "scq",
  6943. "scvp-cv-response": "scs",
  6944. "scvp-vp-request": "spq",
  6945. "scvp-vp-response": "spp",
  6946. "sdp": "sdp",
  6947. "set-payment-initiation": "setpay",
  6948. "set-registration-initiation": "setreg",
  6949. "shf+xml": "shf",
  6950. "sparql-query": "rq",
  6951. "sparql-results+xml": "srx",
  6952. "srgs": "gram",
  6953. "srgs+xml": "grxml",
  6954. "sru+xml": "sru",
  6955. "ssdl+xml": "ssdl",
  6956. "ssml+xml": "ssml",
  6957. "tei+xml": [
  6958. "tei",
  6959. "teicorpus"
  6960. ],
  6961. "thraud+xml": "tfi",
  6962. "timestamped-data": "tsd",
  6963. "vnd.3gpp.pic-bw-large": "plb",
  6964. "vnd.3gpp.pic-bw-small": "psb",
  6965. "vnd.3gpp.pic-bw-var": "pvb",
  6966. "vnd.3gpp2.tcap": "tcap",
  6967. "vnd.3m.post-it-notes": "pwn",
  6968. "vnd.accpac.simply.aso": "aso",
  6969. "vnd.accpac.simply.imp": "imp",
  6970. "vnd.acucobol": "acu",
  6971. "vnd.acucorp": [
  6972. "atc",
  6973. "acutc"
  6974. ],
  6975. "vnd.adobe.air-application-installer-package+zip": "air",
  6976. "vnd.adobe.formscentral.fcdt": "fcdt",
  6977. "vnd.adobe.fxp": [
  6978. "fxp",
  6979. "fxpl"
  6980. ],
  6981. "vnd.adobe.xdp+xml": "xdp",
  6982. "vnd.adobe.xfdf": "xfdf",
  6983. "vnd.ahead.space": "ahead",
  6984. "vnd.airzip.filesecure.azf": "azf",
  6985. "vnd.airzip.filesecure.azs": "azs",
  6986. "vnd.amazon.ebook": "azw",
  6987. "vnd.americandynamics.acc": "acc",
  6988. "vnd.amiga.ami": "ami",
  6989. "vnd.anser-web-certificate-issue-initiation": "cii",
  6990. "vnd.anser-web-funds-transfer-initiation": "fti",
  6991. "vnd.antix.game-component": "atx",
  6992. "vnd.apple.installer+xml": "mpkg",
  6993. "vnd.apple.mpegurl": "m3u8",
  6994. "vnd.aristanetworks.swi": "swi",
  6995. "vnd.astraea-software.iota": "iota",
  6996. "vnd.audiograph": "aep",
  6997. "vnd.blueice.multipass": "mpm",
  6998. "vnd.bmi": "bmi",
  6999. "vnd.businessobjects": "rep",
  7000. "vnd.chemdraw+xml": "cdxml",
  7001. "vnd.chipnuts.karaoke-mmd": "mmd",
  7002. "vnd.claymore": "cla",
  7003. "vnd.cloanto.rp9": "rp9",
  7004. "vnd.clonk.c4group": [
  7005. "c4g",
  7006. "c4d",
  7007. "c4f",
  7008. "c4p",
  7009. "c4u"
  7010. ],
  7011. "vnd.cluetrust.cartomobile-config": "c11amc",
  7012. "vnd.cluetrust.cartomobile-config-pkg": "c11amz",
  7013. "vnd.commonspace": "csp",
  7014. "vnd.contact.cmsg": "cdbcmsg",
  7015. "vnd.cosmocaller": "cmc",
  7016. "vnd.crick.clicker": "clkx",
  7017. "vnd.crick.clicker.keyboard": "clkk",
  7018. "vnd.crick.clicker.palette": "clkp",
  7019. "vnd.crick.clicker.template": "clkt",
  7020. "vnd.crick.clicker.wordbank": "clkw",
  7021. "vnd.criticaltools.wbs+xml": "wbs",
  7022. "vnd.ctc-posml": "pml",
  7023. "vnd.cups-ppd": "ppd",
  7024. "vnd.curl.car": "car",
  7025. "vnd.curl.pcurl": "pcurl",
  7026. "vnd.dart": "dart",
  7027. "vnd.data-vision.rdz": "rdz",
  7028. "vnd.dece.data": [
  7029. "uvf",
  7030. "uvvf",
  7031. "uvd",
  7032. "uvvd"
  7033. ],
  7034. "vnd.dece.ttml+xml": [
  7035. "uvt",
  7036. "uvvt"
  7037. ],
  7038. "vnd.dece.unspecified": [
  7039. "uvx",
  7040. "uvvx"
  7041. ],
  7042. "vnd.dece.zip": [
  7043. "uvz",
  7044. "uvvz"
  7045. ],
  7046. "vnd.denovo.fcselayout-link": "fe_launch",
  7047. "vnd.dna": "dna",
  7048. "vnd.dolby.mlp": "mlp",
  7049. "vnd.dpgraph": "dpg",
  7050. "vnd.dreamfactory": "dfac",
  7051. "vnd.ds-keypoint": "kpxx",
  7052. "vnd.dvb.ait": "ait",
  7053. "vnd.dvb.service": "svc",
  7054. "vnd.dynageo": "geo",
  7055. "vnd.ecowin.chart": "mag",
  7056. "vnd.enliven": "nml",
  7057. "vnd.epson.esf": "esf",
  7058. "vnd.epson.msf": "msf",
  7059. "vnd.epson.quickanime": "qam",
  7060. "vnd.epson.salt": "slt",
  7061. "vnd.epson.ssf": "ssf",
  7062. "vnd.eszigno3+xml": [
  7063. "es3",
  7064. "et3"
  7065. ],
  7066. "vnd.ezpix-album": "ez2",
  7067. "vnd.ezpix-package": "ez3",
  7068. "vnd.fdf": "fdf",
  7069. "vnd.fdsn.mseed": "mseed",
  7070. "vnd.fdsn.seed": [
  7071. "seed",
  7072. "dataless"
  7073. ],
  7074. "vnd.flographit": "gph",
  7075. "vnd.fluxtime.clip": "ftc",
  7076. "vnd.framemaker": [
  7077. "fm",
  7078. "frame",
  7079. "maker",
  7080. "book"
  7081. ],
  7082. "vnd.frogans.fnc": "fnc",
  7083. "vnd.frogans.ltf": "ltf",
  7084. "vnd.fsc.weblaunch": "fsc",
  7085. "vnd.fujitsu.oasys": "oas",
  7086. "vnd.fujitsu.oasys2": "oa2",
  7087. "vnd.fujitsu.oasys3": "oa3",
  7088. "vnd.fujitsu.oasysgp": "fg5",
  7089. "vnd.fujitsu.oasysprs": "bh2",
  7090. "vnd.fujixerox.ddd": "ddd",
  7091. "vnd.fujixerox.docuworks": "xdw",
  7092. "vnd.fujixerox.docuworks.binder": "xbd",
  7093. "vnd.fuzzysheet": "fzs",
  7094. "vnd.genomatix.tuxedo": "txd",
  7095. "vnd.geogebra.file": "ggb",
  7096. "vnd.geogebra.tool": "ggt",
  7097. "vnd.geometry-explorer": [
  7098. "gex",
  7099. "gre"
  7100. ],
  7101. "vnd.geonext": "gxt",
  7102. "vnd.geoplan": "g2w",
  7103. "vnd.geospace": "g3w",
  7104. "vnd.gmx": "gmx",
  7105. "vnd.grafeq": [
  7106. "gqf",
  7107. "gqs"
  7108. ],
  7109. "vnd.groove-account": "gac",
  7110. "vnd.groove-help": "ghf",
  7111. "vnd.groove-identity-message": "gim",
  7112. "vnd.groove-injector": "grv",
  7113. "vnd.groove-tool-message": "gtm",
  7114. "vnd.groove-tool-template": "tpl",
  7115. "vnd.groove-vcard": "vcg",
  7116. "vnd.hal+xml": "hal",
  7117. "vnd.handheld-entertainment+xml": "zmm",
  7118. "vnd.hbci": "hbci",
  7119. "vnd.hhe.lesson-player": "les",
  7120. "vnd.hp-hpgl": "hpgl",
  7121. "vnd.hp-hpid": "hpid",
  7122. "vnd.hp-hps": "hps",
  7123. "vnd.hp-jlyt": "jlt",
  7124. "vnd.hp-pcl": "pcl",
  7125. "vnd.hp-pclxl": "pclxl",
  7126. "vnd.hydrostatix.sof-data": "sfd-hdstx",
  7127. "vnd.ibm.minipay": "mpy",
  7128. "vnd.ibm.modcap": [
  7129. "afp",
  7130. "listafp",
  7131. "list3820"
  7132. ],
  7133. "vnd.ibm.rights-management": "irm",
  7134. "vnd.ibm.secure-container": "sc",
  7135. "vnd.iccprofile": [
  7136. "icc",
  7137. "icm"
  7138. ],
  7139. "vnd.igloader": "igl",
  7140. "vnd.immervision-ivp": "ivp",
  7141. "vnd.immervision-ivu": "ivu",
  7142. "vnd.insors.igm": "igm",
  7143. "vnd.intercon.formnet": [
  7144. "xpw",
  7145. "xpx"
  7146. ],
  7147. "vnd.intergeo": "i2g",
  7148. "vnd.intu.qbo": "qbo",
  7149. "vnd.intu.qfx": "qfx",
  7150. "vnd.ipunplugged.rcprofile": "rcprofile",
  7151. "vnd.irepository.package+xml": "irp",
  7152. "vnd.is-xpr": "xpr",
  7153. "vnd.isac.fcs": "fcs",
  7154. "vnd.jam": "jam",
  7155. "vnd.jcp.javame.midlet-rms": "rms",
  7156. "vnd.jisp": "jisp",
  7157. "vnd.joost.joda-archive": "joda",
  7158. "vnd.kahootz": [
  7159. "ktz",
  7160. "ktr"
  7161. ],
  7162. "vnd.kde.karbon": "karbon",
  7163. "vnd.kde.kchart": "chrt",
  7164. "vnd.kde.kformula": "kfo",
  7165. "vnd.kde.kivio": "flw",
  7166. "vnd.kde.kontour": "kon",
  7167. "vnd.kde.kpresenter": [
  7168. "kpr",
  7169. "kpt"
  7170. ],
  7171. "vnd.kde.kspread": "ksp",
  7172. "vnd.kde.kword": [
  7173. "kwd",
  7174. "kwt"
  7175. ],
  7176. "vnd.kenameaapp": "htke",
  7177. "vnd.kidspiration": "kia",
  7178. "vnd.kinar": [
  7179. "kne",
  7180. "knp"
  7181. ],
  7182. "vnd.koan": [
  7183. "skp",
  7184. "skd",
  7185. "skt",
  7186. "skm"
  7187. ],
  7188. "vnd.kodak-descriptor": "sse",
  7189. "vnd.las.las+xml": "lasxml",
  7190. "vnd.llamagraphics.life-balance.desktop": "lbd",
  7191. "vnd.llamagraphics.life-balance.exchange+xml": "lbe",
  7192. "vnd.lotus-1-2-3": "123",
  7193. "vnd.lotus-approach": "apr",
  7194. "vnd.lotus-freelance": "pre",
  7195. "vnd.lotus-notes": "nsf",
  7196. "vnd.lotus-organizer": "org",
  7197. "vnd.lotus-screencam": "scm",
  7198. "vnd.lotus-wordpro": "lwp",
  7199. "vnd.macports.portpkg": "portpkg",
  7200. "vnd.mcd": "mcd",
  7201. "vnd.medcalcdata": "mc1",
  7202. "vnd.mediastation.cdkey": "cdkey",
  7203. "vnd.mfer": "mwf",
  7204. "vnd.mfmp": "mfm",
  7205. "vnd.micrografx.flo": "flo",
  7206. "vnd.micrografx.igx": "igx",
  7207. "vnd.mif": "mif",
  7208. "vnd.mobius.daf": "daf",
  7209. "vnd.mobius.dis": "dis",
  7210. "vnd.mobius.mbk": "mbk",
  7211. "vnd.mobius.mqy": "mqy",
  7212. "vnd.mobius.msl": "msl",
  7213. "vnd.mobius.plc": "plc",
  7214. "vnd.mobius.txf": "txf",
  7215. "vnd.mophun.application": "mpn",
  7216. "vnd.mophun.certificate": "mpc",
  7217. "vnd.ms-artgalry": "cil",
  7218. "vnd.ms-cab-compressed": "cab",
  7219. "vnd.ms-excel.addin.macroenabled.12": "xlam",
  7220. "vnd.ms-excel.sheet.binary.macroenabled.12": "xlsb",
  7221. "vnd.ms-excel.sheet.macroenabled.12": "xlsm",
  7222. "vnd.ms-excel.template.macroenabled.12": "xltm",
  7223. "vnd.ms-fontobject": "eot",
  7224. "vnd.ms-htmlhelp": "chm",
  7225. "vnd.ms-ims": "ims",
  7226. "vnd.ms-lrm": "lrm",
  7227. "vnd.ms-officetheme": "thmx",
  7228. "vnd.ms-powerpoint.addin.macroenabled.12": "ppam",
  7229. "vnd.ms-powerpoint.presentation.macroenabled.12": "pptm",
  7230. "vnd.ms-powerpoint.slide.macroenabled.12": "sldm",
  7231. "vnd.ms-powerpoint.slideshow.macroenabled.12": "ppsm",
  7232. "vnd.ms-powerpoint.template.macroenabled.12": "potm",
  7233. "vnd.ms-project": [
  7234. "mpp",
  7235. "mpt"
  7236. ],
  7237. "vnd.ms-word.document.macroenabled.12": "docm",
  7238. "vnd.ms-word.template.macroenabled.12": "dotm",
  7239. "vnd.ms-works": [
  7240. "wps",
  7241. "wks",
  7242. "wcm",
  7243. "wdb"
  7244. ],
  7245. "vnd.ms-wpl": "wpl",
  7246. "vnd.ms-xpsdocument": "xps",
  7247. "vnd.mseq": "mseq",
  7248. "vnd.musician": "mus",
  7249. "vnd.muvee.style": "msty",
  7250. "vnd.mynfc": "taglet",
  7251. "vnd.neurolanguage.nlu": "nlu",
  7252. "vnd.nitf": [
  7253. "ntf",
  7254. "nitf"
  7255. ],
  7256. "vnd.noblenet-directory": "nnd",
  7257. "vnd.noblenet-sealer": "nns",
  7258. "vnd.noblenet-web": "nnw",
  7259. "vnd.nokia.n-gage.data": "ngdat",
  7260. "vnd.nokia.n-gage.symbian.install": "n-gage",
  7261. "vnd.nokia.radio-preset": "rpst",
  7262. "vnd.nokia.radio-presets": "rpss",
  7263. "vnd.novadigm.edm": "edm",
  7264. "vnd.novadigm.edx": "edx",
  7265. "vnd.novadigm.ext": "ext",
  7266. "vnd.oasis.opendocument.chart-template": "otc",
  7267. "vnd.oasis.opendocument.formula-template": "odft",
  7268. "vnd.oasis.opendocument.image-template": "oti",
  7269. "vnd.olpc-sugar": "xo",
  7270. "vnd.oma.dd2+xml": "dd2",
  7271. "vnd.openofficeorg.extension": "oxt",
  7272. "vnd.openxmlformats-officedocument.presentationml.slide": "sldx",
  7273. "vnd.osgeo.mapguide.package": "mgp",
  7274. "vnd.osgi.dp": "dp",
  7275. "vnd.osgi.subsystem": "esa",
  7276. "vnd.palm": [
  7277. "pdb",
  7278. "pqa",
  7279. "oprc"
  7280. ],
  7281. "vnd.pawaafile": "paw",
  7282. "vnd.pg.format": "str",
  7283. "vnd.pg.osasli": "ei6",
  7284. "vnd.picsel": "efif",
  7285. "vnd.pmi.widget": "wg",
  7286. "vnd.pocketlearn": "plf",
  7287. "vnd.powerbuilder6": "pbd",
  7288. "vnd.previewsystems.box": "box",
  7289. "vnd.proteus.magazine": "mgz",
  7290. "vnd.publishare-delta-tree": "qps",
  7291. "vnd.pvi.ptid1": "ptid",
  7292. "vnd.quark.quarkxpress": [
  7293. "qxd",
  7294. "qxt",
  7295. "qwd",
  7296. "qwt",
  7297. "qxl",
  7298. "qxb"
  7299. ],
  7300. "vnd.realvnc.bed": "bed",
  7301. "vnd.recordare.musicxml": "mxl",
  7302. "vnd.recordare.musicxml+xml": "musicxml",
  7303. "vnd.rig.cryptonote": "cryptonote",
  7304. "vnd.rn-realmedia": "rm",
  7305. "vnd.rn-realmedia-vbr": "rmvb",
  7306. "vnd.route66.link66+xml": "link66",
  7307. "vnd.sailingtracker.track": "st",
  7308. "vnd.seemail": "see",
  7309. "vnd.sema": "sema",
  7310. "vnd.semd": "semd",
  7311. "vnd.semf": "semf",
  7312. "vnd.shana.informed.formdata": "ifm",
  7313. "vnd.shana.informed.formtemplate": "itp",
  7314. "vnd.shana.informed.interchange": "iif",
  7315. "vnd.shana.informed.package": "ipk",
  7316. "vnd.simtech-mindmapper": [
  7317. "twd",
  7318. "twds"
  7319. ],
  7320. "vnd.smart.teacher": "teacher",
  7321. "vnd.solent.sdkm+xml": [
  7322. "sdkm",
  7323. "sdkd"
  7324. ],
  7325. "vnd.spotfire.dxp": "dxp",
  7326. "vnd.spotfire.sfs": "sfs",
  7327. "vnd.stepmania.package": "smzip",
  7328. "vnd.stepmania.stepchart": "sm",
  7329. "vnd.sus-calendar": [
  7330. "sus",
  7331. "susp"
  7332. ],
  7333. "vnd.svd": "svd",
  7334. "vnd.syncml+xml": "xsm",
  7335. "vnd.syncml.dm+wbxml": "bdm",
  7336. "vnd.syncml.dm+xml": "xdm",
  7337. "vnd.tao.intent-module-archive": "tao",
  7338. "vnd.tcpdump.pcap": [
  7339. "pcap",
  7340. "cap",
  7341. "dmp"
  7342. ],
  7343. "vnd.tmobile-livetv": "tmo",
  7344. "vnd.trid.tpt": "tpt",
  7345. "vnd.triscape.mxs": "mxs",
  7346. "vnd.trueapp": "tra",
  7347. "vnd.ufdl": [
  7348. "ufd",
  7349. "ufdl"
  7350. ],
  7351. "vnd.uiq.theme": "utz",
  7352. "vnd.umajin": "umj",
  7353. "vnd.unity": "unityweb",
  7354. "vnd.uoml+xml": "uoml",
  7355. "vnd.vcx": "vcx",
  7356. "vnd.visionary": "vis",
  7357. "vnd.vsf": "vsf",
  7358. "vnd.webturbo": "wtb",
  7359. "vnd.wolfram.player": "nbp",
  7360. "vnd.wqd": "wqd",
  7361. "vnd.wt.stf": "stf",
  7362. "vnd.xara": "xar",
  7363. "vnd.xfdl": "xfdl",
  7364. "vnd.yamaha.hv-dic": "hvd",
  7365. "vnd.yamaha.hv-script": "hvs",
  7366. "vnd.yamaha.hv-voice": "hvp",
  7367. "vnd.yamaha.openscoreformat": "osf",
  7368. "vnd.yamaha.openscoreformat.osfpvg+xml": "osfpvg",
  7369. "vnd.yamaha.smaf-audio": "saf",
  7370. "vnd.yamaha.smaf-phrase": "spf",
  7371. "vnd.yellowriver-custom-menu": "cmp",
  7372. "vnd.zul": [
  7373. "zir",
  7374. "zirz"
  7375. ],
  7376. "vnd.zzazz.deck+xml": "zaz",
  7377. "voicexml+xml": "vxml",
  7378. "widget": "wgt",
  7379. "winhlp": "hlp",
  7380. "wsdl+xml": "wsdl",
  7381. "wspolicy+xml": "wspolicy",
  7382. "x-ace-compressed": "ace",
  7383. "x-authorware-bin": [
  7384. "aab",
  7385. "x32",
  7386. "u32",
  7387. "vox"
  7388. ],
  7389. "x-authorware-map": "aam",
  7390. "x-authorware-seg": "aas",
  7391. "x-blorb": [
  7392. "blb",
  7393. "blorb"
  7394. ],
  7395. "x-bzip": "bz",
  7396. "x-bzip2": [
  7397. "bz2",
  7398. "boz"
  7399. ],
  7400. "x-cfs-compressed": "cfs",
  7401. "x-chat": "chat",
  7402. "x-conference": "nsc",
  7403. "x-dgc-compressed": "dgc",
  7404. "x-dtbncx+xml": "ncx",
  7405. "x-dtbook+xml": "dtb",
  7406. "x-dtbresource+xml": "res",
  7407. "x-eva": "eva",
  7408. "x-font-bdf": "bdf",
  7409. "x-font-ghostscript": "gsf",
  7410. "x-font-linux-psf": "psf",
  7411. "x-font-pcf": "pcf",
  7412. "x-font-snf": "snf",
  7413. "x-font-ttf": [
  7414. "ttf",
  7415. "ttc"
  7416. ],
  7417. "x-font-type1": [
  7418. "pfa",
  7419. "pfb",
  7420. "pfm",
  7421. "afm"
  7422. ],
  7423. "x-freearc": "arc",
  7424. "x-gca-compressed": "gca",
  7425. "x-glulx": "ulx",
  7426. "x-gramps-xml": "gramps",
  7427. "x-install-instructions": "install",
  7428. "x-lzh-compressed": [
  7429. "lzh",
  7430. "lha"
  7431. ],
  7432. "x-mie": "mie",
  7433. "x-mobipocket-ebook": [
  7434. "prc",
  7435. "mobi"
  7436. ],
  7437. "x-ms-application": "application",
  7438. "x-ms-shortcut": "lnk",
  7439. "x-ms-xbap": "xbap",
  7440. "x-msbinder": "obd",
  7441. "x-mscardfile": "crd",
  7442. "x-msclip": "clp",
  7443. "application/x-ms-installer": "msi",
  7444. "x-msmediaview": [
  7445. "mvb",
  7446. "m13",
  7447. "m14"
  7448. ],
  7449. "x-msmetafile": [
  7450. "wmf",
  7451. "wmz",
  7452. "emf",
  7453. "emz"
  7454. ],
  7455. "x-msmoney": "mny",
  7456. "x-mspublisher": "pub",
  7457. "x-msschedule": "scd",
  7458. "x-msterminal": "trm",
  7459. "x-mswrite": "wri",
  7460. "x-nzb": "nzb",
  7461. "x-pkcs12": [
  7462. "p12",
  7463. "pfx"
  7464. ],
  7465. "x-pkcs7-certificates": [
  7466. "p7b",
  7467. "spc"
  7468. ],
  7469. "x-research-info-systems": "ris",
  7470. "x-silverlight-app": "xap",
  7471. "x-sql": "sql",
  7472. "x-stuffitx": "sitx",
  7473. "x-subrip": "srt",
  7474. "x-t3vm-image": "t3",
  7475. "x-tex-tfm": "tfm",
  7476. "x-tgif": "obj",
  7477. "x-xliff+xml": "xlf",
  7478. "x-xz": "xz",
  7479. "x-zmachine": [
  7480. "z1",
  7481. "z2",
  7482. "z3",
  7483. "z4",
  7484. "z5",
  7485. "z6",
  7486. "z7",
  7487. "z8"
  7488. ],
  7489. "xaml+xml": "xaml",
  7490. "xcap-diff+xml": "xdf",
  7491. "xenc+xml": "xenc",
  7492. "xml-dtd": "dtd",
  7493. "xop+xml": "xop",
  7494. "xproc+xml": "xpl",
  7495. "xslt+xml": "xslt",
  7496. "xv+xml": [
  7497. "mxml",
  7498. "xhvml",
  7499. "xvml",
  7500. "xvm"
  7501. ],
  7502. "yang": "yang",
  7503. "yin+xml": "yin",
  7504. "envoy": "evy",
  7505. "fractals": "fif",
  7506. "internet-property-stream": "acx",
  7507. "olescript": "axs",
  7508. "vnd.ms-outlook": "msg",
  7509. "vnd.ms-pkicertstore": "sst",
  7510. "x-compress": "z",
  7511. "x-perfmon": [
  7512. "pma",
  7513. "pmc",
  7514. "pmr",
  7515. "pmw"
  7516. ],
  7517. "ynd.ms-pkipko": "pko",
  7518. "gzip": [
  7519. "gz",
  7520. "tgz"
  7521. ],
  7522. "smil+xml": [
  7523. "smi",
  7524. "smil"
  7525. ],
  7526. "vnd.debian.binary-package": [
  7527. "deb",
  7528. "udeb"
  7529. ],
  7530. "vnd.hzn-3d-crossword": "x3d",
  7531. "vnd.sqlite3": [
  7532. "db",
  7533. "sqlite",
  7534. "sqlite3",
  7535. "db-wal",
  7536. "sqlite-wal",
  7537. "db-shm",
  7538. "sqlite-shm"
  7539. ],
  7540. "vnd.wap.sic": "sic",
  7541. "vnd.wap.slc": "slc",
  7542. "x-krita": [
  7543. "kra",
  7544. "krz"
  7545. ],
  7546. "x-perl": [
  7547. "pm",
  7548. "pl"
  7549. ],
  7550. "yaml": [
  7551. "yaml",
  7552. "yml"
  7553. ]
  7554. },
  7555. "audio": {
  7556. "amr": "amr",
  7557. "amr-wb": "awb",
  7558. "annodex": "axa",
  7559. "basic": [
  7560. "au",
  7561. "snd"
  7562. ],
  7563. "flac": "flac",
  7564. "midi": [
  7565. "mid",
  7566. "midi",
  7567. "kar",
  7568. "rmi"
  7569. ],
  7570. "mpeg": [
  7571. "mpga",
  7572. "mpega",
  7573. "mp3",
  7574. "m4a",
  7575. "mp2a",
  7576. "m2a",
  7577. "m3a"
  7578. ],
  7579. "mpegurl": "m3u",
  7580. "ogg": [
  7581. "oga",
  7582. "ogg",
  7583. "spx"
  7584. ],
  7585. "prs.sid": "sid",
  7586. "x-aiff": "aifc",
  7587. "x-gsm": "gsm",
  7588. "x-ms-wma": "wma",
  7589. "x-ms-wax": "wax",
  7590. "x-pn-realaudio": "ram",
  7591. "x-realaudio": "ra",
  7592. "x-sd2": "sd2",
  7593. "adpcm": "adp",
  7594. "mp4": "mp4a",
  7595. "s3m": "s3m",
  7596. "silk": "sil",
  7597. "vnd.dece.audio": [
  7598. "uva",
  7599. "uvva"
  7600. ],
  7601. "vnd.digital-winds": "eol",
  7602. "vnd.dra": "dra",
  7603. "vnd.dts": "dts",
  7604. "vnd.dts.hd": "dtshd",
  7605. "vnd.lucent.voice": "lvp",
  7606. "vnd.ms-playready.media.pya": "pya",
  7607. "vnd.nuera.ecelp4800": "ecelp4800",
  7608. "vnd.nuera.ecelp7470": "ecelp7470",
  7609. "vnd.nuera.ecelp9600": "ecelp9600",
  7610. "vnd.rip": "rip",
  7611. "webm": "weba",
  7612. "x-caf": "caf",
  7613. "x-matroska": "mka",
  7614. "x-pn-realaudio-plugin": "rmp",
  7615. "xm": "xm",
  7616. "aac": "aac",
  7617. "aiff": [
  7618. "aiff",
  7619. "aif",
  7620. "aff"
  7621. ],
  7622. "opus": "opus",
  7623. "wav": "wav"
  7624. },
  7625. "chemical": {
  7626. "x-alchemy": "alc",
  7627. "x-cache": [
  7628. "cac",
  7629. "cache"
  7630. ],
  7631. "x-cache-csf": "csf",
  7632. "x-cactvs-binary": [
  7633. "cbin",
  7634. "cascii",
  7635. "ctab"
  7636. ],
  7637. "x-cdx": "cdx",
  7638. "x-chem3d": "c3d",
  7639. "x-cif": "cif",
  7640. "x-cmdf": "cmdf",
  7641. "x-cml": "cml",
  7642. "x-compass": "cpa",
  7643. "x-crossfire": "bsd",
  7644. "x-csml": [
  7645. "csml",
  7646. "csm"
  7647. ],
  7648. "x-ctx": "ctx",
  7649. "x-cxf": [
  7650. "cxf",
  7651. "cef"
  7652. ],
  7653. "x-embl-dl-nucleotide": [
  7654. "emb",
  7655. "embl"
  7656. ],
  7657. "x-gamess-input": [
  7658. "inp",
  7659. "gam",
  7660. "gamin"
  7661. ],
  7662. "x-gaussian-checkpoint": [
  7663. "fch",
  7664. "fchk"
  7665. ],
  7666. "x-gaussian-cube": "cub",
  7667. "x-gaussian-input": [
  7668. "gau",
  7669. "gjc",
  7670. "gjf"
  7671. ],
  7672. "x-gaussian-log": "gal",
  7673. "x-gcg8-sequence": "gcg",
  7674. "x-genbank": "gen",
  7675. "x-hin": "hin",
  7676. "x-isostar": [
  7677. "istr",
  7678. "ist"
  7679. ],
  7680. "x-jcamp-dx": [
  7681. "jdx",
  7682. "dx"
  7683. ],
  7684. "x-kinemage": "kin",
  7685. "x-macmolecule": "mcm",
  7686. "x-macromodel-input": "mmod",
  7687. "x-mdl-molfile": "mol",
  7688. "x-mdl-rdfile": "rd",
  7689. "x-mdl-rxnfile": "rxn",
  7690. "x-mdl-sdfile": "sd",
  7691. "x-mdl-tgf": "tgf",
  7692. "x-mmcif": "mcif",
  7693. "x-mol2": "mol2",
  7694. "x-molconn-Z": "b",
  7695. "x-mopac-graph": "gpt",
  7696. "x-mopac-input": [
  7697. "mop",
  7698. "mopcrt",
  7699. "zmt"
  7700. ],
  7701. "x-mopac-out": "moo",
  7702. "x-ncbi-asn1": "asn",
  7703. "x-ncbi-asn1-ascii": [
  7704. "prt",
  7705. "ent"
  7706. ],
  7707. "x-ncbi-asn1-binary": "val",
  7708. "x-rosdal": "ros",
  7709. "x-swissprot": "sw",
  7710. "x-vamas-iso14976": "vms",
  7711. "x-vmd": "vmd",
  7712. "x-xtel": "xtel",
  7713. "x-xyz": "xyz"
  7714. },
  7715. "font": {
  7716. "otf": "otf",
  7717. "woff": "woff",
  7718. "woff2": "woff2"
  7719. },
  7720. "image": {
  7721. "gif": "gif",
  7722. "ief": "ief",
  7723. "jpeg": [
  7724. "jpeg",
  7725. "jpg",
  7726. "jpe",
  7727. "jfif",
  7728. "jfif-tbnl",
  7729. "jif"
  7730. ],
  7731. "pcx": "pcx",
  7732. "png": "png",
  7733. "svg+xml": [
  7734. "svg",
  7735. "svgz"
  7736. ],
  7737. "tiff": [
  7738. "tiff",
  7739. "tif"
  7740. ],
  7741. "vnd.djvu": [
  7742. "djvu",
  7743. "djv"
  7744. ],
  7745. "vnd.wap.wbmp": "wbmp",
  7746. "x-canon-cr2": "cr2",
  7747. "x-canon-crw": "crw",
  7748. "x-cmu-raster": "ras",
  7749. "x-coreldraw": "cdr",
  7750. "x-coreldrawpattern": "pat",
  7751. "x-coreldrawtemplate": "cdt",
  7752. "x-corelphotopaint": "cpt",
  7753. "x-epson-erf": "erf",
  7754. "x-icon": "ico",
  7755. "x-jg": "art",
  7756. "x-jng": "jng",
  7757. "x-nikon-nef": "nef",
  7758. "x-olympus-orf": "orf",
  7759. "x-portable-anymap": "pnm",
  7760. "x-portable-bitmap": "pbm",
  7761. "x-portable-graymap": "pgm",
  7762. "x-portable-pixmap": "ppm",
  7763. "x-rgb": "rgb",
  7764. "x-xbitmap": "xbm",
  7765. "x-xpixmap": "xpm",
  7766. "x-xwindowdump": "xwd",
  7767. "bmp": "bmp",
  7768. "cgm": "cgm",
  7769. "g3fax": "g3",
  7770. "ktx": "ktx",
  7771. "prs.btif": "btif",
  7772. "sgi": "sgi",
  7773. "vnd.dece.graphic": [
  7774. "uvi",
  7775. "uvvi",
  7776. "uvg",
  7777. "uvvg"
  7778. ],
  7779. "vnd.dwg": "dwg",
  7780. "vnd.dxf": "dxf",
  7781. "vnd.fastbidsheet": "fbs",
  7782. "vnd.fpx": "fpx",
  7783. "vnd.fst": "fst",
  7784. "vnd.fujixerox.edmics-mmr": "mmr",
  7785. "vnd.fujixerox.edmics-rlc": "rlc",
  7786. "vnd.ms-modi": "mdi",
  7787. "vnd.ms-photo": "wdp",
  7788. "vnd.net-fpx": "npx",
  7789. "vnd.xiff": "xif",
  7790. "webp": "webp",
  7791. "x-3ds": "3ds",
  7792. "x-cmx": "cmx",
  7793. "x-freehand": [
  7794. "fh",
  7795. "fhc",
  7796. "fh4",
  7797. "fh5",
  7798. "fh7"
  7799. ],
  7800. "x-pict": [
  7801. "pic",
  7802. "pct"
  7803. ],
  7804. "x-tga": "tga",
  7805. "cis-cod": "cod",
  7806. "avif": "avifs",
  7807. "heic": [
  7808. "heif",
  7809. "heic"
  7810. ],
  7811. "pjpeg": [
  7812. "pjpg"
  7813. ],
  7814. "vnd.adobe.photoshop": "psd",
  7815. "x-adobe-dng": "dng",
  7816. "x-fuji-raf": "raf",
  7817. "x-icns": "icns",
  7818. "x-kodak-dcr": "dcr",
  7819. "x-kodak-k25": "k25",
  7820. "x-kodak-kdc": "kdc",
  7821. "x-minolta-mrw": "mrw",
  7822. "x-panasonic-raw": [
  7823. "raw",
  7824. "rw2",
  7825. "rwl"
  7826. ],
  7827. "x-pentax-pef": [
  7828. "pef",
  7829. "ptx"
  7830. ],
  7831. "x-sigma-x3f": "x3f",
  7832. "x-sony-arw": "arw",
  7833. "x-sony-sr2": "sr2",
  7834. "x-sony-srf": "srf"
  7835. },
  7836. "message": {
  7837. "rfc822": [
  7838. "eml",
  7839. "mime",
  7840. "mht",
  7841. "mhtml",
  7842. "nws"
  7843. ]
  7844. },
  7845. "model": {
  7846. "iges": [
  7847. "igs",
  7848. "iges"
  7849. ],
  7850. "mesh": [
  7851. "msh",
  7852. "mesh",
  7853. "silo"
  7854. ],
  7855. "vrml": [
  7856. "wrl",
  7857. "vrml"
  7858. ],
  7859. "x3d+vrml": [
  7860. "x3dv",
  7861. "x3dvz"
  7862. ],
  7863. "x3d+xml": "x3dz",
  7864. "x3d+binary": [
  7865. "x3db",
  7866. "x3dbz"
  7867. ],
  7868. "vnd.collada+xml": "dae",
  7869. "vnd.dwf": "dwf",
  7870. "vnd.gdl": "gdl",
  7871. "vnd.gtw": "gtw",
  7872. "vnd.mts": "mts",
  7873. "vnd.usdz+zip": "usdz",
  7874. "vnd.vtu": "vtu"
  7875. },
  7876. "text": {
  7877. "cache-manifest": [
  7878. "manifest",
  7879. "appcache"
  7880. ],
  7881. "calendar": [
  7882. "ics",
  7883. "icz",
  7884. "ifb"
  7885. ],
  7886. "css": "css",
  7887. "csv": "csv",
  7888. "h323": "323",
  7889. "html": [
  7890. "html",
  7891. "htm",
  7892. "shtml",
  7893. "stm"
  7894. ],
  7895. "iuls": "uls",
  7896. "plain": [
  7897. "txt",
  7898. "text",
  7899. "brf",
  7900. "conf",
  7901. "def",
  7902. "list",
  7903. "log",
  7904. "in",
  7905. "bas",
  7906. "diff",
  7907. "ksh"
  7908. ],
  7909. "richtext": "rtx",
  7910. "scriptlet": [
  7911. "sct",
  7912. "wsc"
  7913. ],
  7914. "texmacs": "tm",
  7915. "tab-separated-values": "tsv",
  7916. "vnd.sun.j2me.app-descriptor": "jad",
  7917. "vnd.wap.wml": "wml",
  7918. "vnd.wap.wmlscript": "wmls",
  7919. "x-bibtex": "bib",
  7920. "x-boo": "boo",
  7921. "x-c++hdr": [
  7922. "h++",
  7923. "hpp",
  7924. "hxx",
  7925. "hh"
  7926. ],
  7927. "x-c++src": [
  7928. "c++",
  7929. "cpp",
  7930. "cxx",
  7931. "cc"
  7932. ],
  7933. "x-component": "htc",
  7934. "x-dsrc": "d",
  7935. "x-diff": "patch",
  7936. "x-haskell": "hs",
  7937. "x-java": "java",
  7938. "x-literate-haskell": "lhs",
  7939. "x-moc": "moc",
  7940. "x-pascal": [
  7941. "p",
  7942. "pas",
  7943. "pp",
  7944. "inc"
  7945. ],
  7946. "x-pcs-gcd": "gcd",
  7947. "x-python": "py",
  7948. "x-scala": "scala",
  7949. "x-setext": "etx",
  7950. "x-tcl": [
  7951. "tcl",
  7952. "tk"
  7953. ],
  7954. "x-tex": [
  7955. "tex",
  7956. "ltx",
  7957. "sty",
  7958. "cls"
  7959. ],
  7960. "x-vcalendar": "vcs",
  7961. "x-vcard": "vcf",
  7962. "n3": "n3",
  7963. "prs.lines.tag": "dsc",
  7964. "sgml": [
  7965. "sgml",
  7966. "sgm"
  7967. ],
  7968. "troff": [
  7969. "t",
  7970. "tr",
  7971. "roff",
  7972. "man",
  7973. "me",
  7974. "ms"
  7975. ],
  7976. "turtle": "ttl",
  7977. "uri-list": [
  7978. "uri",
  7979. "uris",
  7980. "urls"
  7981. ],
  7982. "vcard": "vcard",
  7983. "vnd.curl": "curl",
  7984. "vnd.curl.dcurl": "dcurl",
  7985. "vnd.curl.scurl": "scurl",
  7986. "vnd.curl.mcurl": "mcurl",
  7987. "vnd.dvb.subtitle": "sub",
  7988. "vnd.fly": "fly",
  7989. "vnd.fmi.flexstor": "flx",
  7990. "vnd.graphviz": "gv",
  7991. "vnd.in3d.3dml": "3dml",
  7992. "vnd.in3d.spot": "spot",
  7993. "x-asm": [
  7994. "s",
  7995. "asm"
  7996. ],
  7997. "x-c": [
  7998. "c",
  7999. "h",
  8000. "dic"
  8001. ],
  8002. "x-fortran": [
  8003. "f",
  8004. "for",
  8005. "f77",
  8006. "f90"
  8007. ],
  8008. "x-opml": "opml",
  8009. "x-nfo": "nfo",
  8010. "x-sfv": "sfv",
  8011. "x-uuencode": "uu",
  8012. "webviewhtml": "htt",
  8013. "javascript": "js",
  8014. "json": "json",
  8015. "markdown": [
  8016. "md",
  8017. "markdown",
  8018. "mdown",
  8019. "markdn"
  8020. ],
  8021. "vnd.wap.si": "si",
  8022. "vnd.wap.sl": "sl"
  8023. },
  8024. "video": {
  8025. "avif": "avif",
  8026. "3gpp": "3gp",
  8027. "annodex": "axv",
  8028. "dl": "dl",
  8029. "dv": [
  8030. "dif",
  8031. "dv"
  8032. ],
  8033. "fli": "fli",
  8034. "gl": "gl",
  8035. "mpeg": [
  8036. "mpeg",
  8037. "mpg",
  8038. "mpe",
  8039. "m1v",
  8040. "m2v",
  8041. "mp2",
  8042. "mpa",
  8043. "mpv2"
  8044. ],
  8045. "mp4": [
  8046. "mp4",
  8047. "mp4v",
  8048. "mpg4"
  8049. ],
  8050. "quicktime": [
  8051. "qt",
  8052. "mov"
  8053. ],
  8054. "ogg": "ogv",
  8055. "vnd.mpegurl": [
  8056. "mxu",
  8057. "m4u"
  8058. ],
  8059. "x-flv": "flv",
  8060. "x-la-asf": [
  8061. "lsf",
  8062. "lsx"
  8063. ],
  8064. "x-mng": "mng",
  8065. "x-ms-asf": [
  8066. "asf",
  8067. "asx",
  8068. "asr"
  8069. ],
  8070. "x-ms-wm": "wm",
  8071. "x-ms-wmv": "wmv",
  8072. "x-ms-wmx": "wmx",
  8073. "x-ms-wvx": "wvx",
  8074. "x-msvideo": "avi",
  8075. "x-sgi-movie": "movie",
  8076. "x-matroska": [
  8077. "mpv",
  8078. "mkv",
  8079. "mk3d",
  8080. "mks"
  8081. ],
  8082. "3gpp2": "3g2",
  8083. "h261": "h261",
  8084. "h263": "h263",
  8085. "h264": "h264",
  8086. "jpeg": "jpgv",
  8087. "jpm": [
  8088. "jpm",
  8089. "jpgm"
  8090. ],
  8091. "mj2": [
  8092. "mj2",
  8093. "mjp2"
  8094. ],
  8095. "vnd.dece.hd": [
  8096. "uvh",
  8097. "uvvh"
  8098. ],
  8099. "vnd.dece.mobile": [
  8100. "uvm",
  8101. "uvvm"
  8102. ],
  8103. "vnd.dece.pd": [
  8104. "uvp",
  8105. "uvvp"
  8106. ],
  8107. "vnd.dece.sd": [
  8108. "uvs",
  8109. "uvvs"
  8110. ],
  8111. "vnd.dece.video": [
  8112. "uvv",
  8113. "uvvv"
  8114. ],
  8115. "vnd.dvb.file": "dvb",
  8116. "vnd.fvt": "fvt",
  8117. "vnd.ms-playready.media.pyv": "pyv",
  8118. "vnd.uvvu.mp4": [
  8119. "uvu",
  8120. "uvvu"
  8121. ],
  8122. "vnd.vivo": "viv",
  8123. "webm": "webm",
  8124. "x-f4v": "f4v",
  8125. "x-m4v": "m4v",
  8126. "x-ms-vob": "vob",
  8127. "x-smv": "smv",
  8128. "mp2t": "ts"
  8129. },
  8130. "x-conference": {
  8131. "x-cooltalk": "ice"
  8132. },
  8133. "x-world": {
  8134. "x-vrml": [
  8135. "vrm",
  8136. "flr",
  8137. "wrz",
  8138. "xaf",
  8139. "xof"
  8140. ]
  8141. }
  8142. };
  8143. const mimeTypes = (() => {
  8144. const mimeTypes = {};
  8145. for (const type of Object.keys(table)) {
  8146. for (const subtype of Object.keys(table[type])) {
  8147. const value = table[type][subtype];
  8148. if (typeof value == "string") {
  8149. mimeTypes[value] = type + "/" + subtype;
  8150. } else {
  8151. for (let indexMimeType = 0; indexMimeType < value.length; indexMimeType++) {
  8152. mimeTypes[value[indexMimeType]] = type + "/" + subtype;
  8153. }
  8154. }
  8155. }
  8156. }
  8157. return mimeTypes;
  8158. })();
  8159. function getMimeType(filename) {
  8160. return filename && mimeTypes[filename.split(".").pop().toLowerCase()] || getMimeType$1();
  8161. }
  8162. /*
  8163. Copyright (c) 2025 Gildas Lormeau. All rights reserved.
  8164. Redistribution and use in source and binary forms, with or without
  8165. modification, are permitted provided that the following conditions are met:
  8166. 1. Redistributions of source code must retain the above copyright notice,
  8167. this list of conditions and the following disclaimer.
  8168. 2. Redistributions in binary form must reproduce the above copyright
  8169. notice, this list of conditions and the following disclaimer in
  8170. the documentation and/or other materials provided with the distribution.
  8171. 3. The names of the authors may not be used to endorse or promote products
  8172. derived from this software without specific prior written permission.
  8173. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  8174. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  8175. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  8176. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  8177. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8178. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  8179. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  8180. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  8181. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  8182. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8183. */
  8184. t(configure);
  8185. exports.BlobReader = BlobReader;
  8186. exports.BlobWriter = BlobWriter;
  8187. exports.Data64URIReader = Data64URIReader;
  8188. exports.Data64URIWriter = Data64URIWriter;
  8189. exports.ERR_BAD_FORMAT = ERR_BAD_FORMAT;
  8190. exports.ERR_CENTRAL_DIRECTORY_NOT_FOUND = ERR_CENTRAL_DIRECTORY_NOT_FOUND;
  8191. exports.ERR_DUPLICATED_NAME = ERR_DUPLICATED_NAME;
  8192. exports.ERR_ENCRYPTED = ERR_ENCRYPTED;
  8193. exports.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND = ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND;
  8194. exports.ERR_EOCDR_NOT_FOUND = ERR_EOCDR_NOT_FOUND;
  8195. exports.ERR_EXTRAFIELD_ZIP64_NOT_FOUND = ERR_EXTRAFIELD_ZIP64_NOT_FOUND;
  8196. exports.ERR_HTTP_RANGE = ERR_HTTP_RANGE;
  8197. exports.ERR_INVALID_COMMENT = ERR_INVALID_COMMENT;
  8198. exports.ERR_INVALID_ENCRYPTION_STRENGTH = ERR_INVALID_ENCRYPTION_STRENGTH;
  8199. exports.ERR_INVALID_ENTRY_COMMENT = ERR_INVALID_ENTRY_COMMENT;
  8200. exports.ERR_INVALID_ENTRY_NAME = ERR_INVALID_ENTRY_NAME;
  8201. exports.ERR_INVALID_EXTRAFIELD_DATA = ERR_INVALID_EXTRAFIELD_DATA;
  8202. exports.ERR_INVALID_EXTRAFIELD_TYPE = ERR_INVALID_EXTRAFIELD_TYPE;
  8203. exports.ERR_INVALID_PASSWORD = ERR_INVALID_PASSWORD;
  8204. exports.ERR_INVALID_SIGNATURE = ERR_INVALID_SIGNATURE;
  8205. exports.ERR_INVALID_UNCOMPRESSED_SIZE = ERR_INVALID_UNCOMPRESSED_SIZE;
  8206. exports.ERR_INVALID_VERSION = ERR_INVALID_VERSION;
  8207. exports.ERR_LOCAL_FILE_HEADER_NOT_FOUND = ERR_LOCAL_FILE_HEADER_NOT_FOUND;
  8208. exports.ERR_OVERLAPPING_ENTRY = ERR_OVERLAPPING_ENTRY;
  8209. exports.ERR_SPLIT_ZIP_FILE = ERR_SPLIT_ZIP_FILE;
  8210. exports.ERR_UNDEFINED_UNCOMPRESSED_SIZE = ERR_UNDEFINED_UNCOMPRESSED_SIZE;
  8211. exports.ERR_UNSUPPORTED_COMPRESSION = ERR_UNSUPPORTED_COMPRESSION;
  8212. exports.ERR_UNSUPPORTED_ENCRYPTION = ERR_UNSUPPORTED_ENCRYPTION;
  8213. exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
  8214. exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
  8215. exports.HttpRangeReader = HttpRangeReader;
  8216. exports.HttpReader = HttpReader;
  8217. exports.Reader = Reader;
  8218. exports.SplitDataReader = SplitDataReader;
  8219. exports.SplitDataWriter = SplitDataWriter;
  8220. exports.TextReader = TextReader;
  8221. exports.TextWriter = TextWriter;
  8222. exports.Uint8ArrayReader = Uint8ArrayReader;
  8223. exports.Uint8ArrayWriter = Uint8ArrayWriter;
  8224. exports.Writer = Writer;
  8225. exports.ZipReader = ZipReader;
  8226. exports.ZipReaderStream = ZipReaderStream;
  8227. exports.ZipWriter = ZipWriter;
  8228. exports.ZipWriterStream = ZipWriterStream;
  8229. exports.configure = configure;
  8230. exports.fs = fs;
  8231. exports.getMimeType = getMimeType;
  8232. exports.terminateWorkers = terminateWorkersAndModule;
  8233. }));