1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187 |
- exports.id = 779;
- exports.ids = [779];
- exports.modules = {
- /***/ 18971:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.execute = void 0;
- const child_process_1 = __webpack_require__(63129);
- // Executes a subprocess.
- // Resolves successfully on exit code 0 with all the info
- // available
- async function execute(command, args, options) {
- const spawnOptions = {
- shell: true,
- detached: true,
- };
- if (options && options.cwd) {
- spawnOptions.cwd = options.cwd;
- }
- const fullCommand = `${command} ${args.join(' ')}`;
- const startTime = Date.now();
- let processId;
- try {
- const worker = child_process_1.spawn(command, args, options);
- processId = worker.pid;
- return await new Promise((resolve, reject) => {
- let stderr = '';
- let stdout = '';
- worker.stdout.on('data', (data) => {
- stdout += data;
- });
- worker.stderr.on('data', (data) => {
- stderr += data;
- });
- worker.on('error', (e) => {
- reject({
- stderr,
- stdout,
- error: e,
- duration: Date.now() - startTime,
- command: fullCommand,
- });
- });
- worker.on('exit', (code) => {
- if (code && code > 0) {
- resolve({
- stderr,
- stdout,
- duration: Date.now() - startTime,
- command: fullCommand,
- exitCode: code,
- });
- }
- else {
- resolve({
- stderr,
- stdout,
- duration: Date.now() - startTime,
- command: fullCommand,
- exitCode: code,
- });
- }
- });
- });
- }
- finally {
- if (processId) {
- // Additional anti-zombie protection.
- // Process here should be already stopped.
- try {
- process.kill(processId, 'SIGKILL');
- }
- catch (e) {
- // Process already stopped.
- }
- }
- }
- }
- exports.execute = execute;
- //# sourceMappingURL=child-process.js.map
- /***/ }),
- /***/ 68026:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- var child_process_1 = __webpack_require__(18971);
- Object.defineProperty(exports, "execute", ({ enumerable: true, get: function () { return child_process_1.execute; } }));
- //# sourceMappingURL=index.js.map
- /***/ }),
- /***/ 21591:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.isPipenvInstalled = exports.extractPipenvVersion = void 0;
- const debugLib = __webpack_require__(92259);
- const child_process_1 = __webpack_require__(68026);
- const debug = debugLib('snyk-fix:python:Pipfile');
- function extractPipenvVersion(stdout) {
- /* stdout example:
- * pipenv, version 2018.11.26\n
- */
- let version = null;
- const re = new RegExp(/^pipenv,\sversion\s([0-9.]+)/, 'g');
- const match = re.exec(stdout);
- if (match) {
- version = match[1];
- }
- return version;
- }
- exports.extractPipenvVersion = extractPipenvVersion;
- async function isPipenvInstalled() {
- let res;
- try {
- res = await child_process_1.execute('pipenv', ['--version'], {});
- }
- catch (e) {
- debug('Execute failed with', e);
- res = e;
- }
- if (res.exitCode !== 0) {
- throw res.error;
- }
- return { version: extractPipenvVersion(res.stdout) };
- }
- exports.isPipenvInstalled = isPipenvInstalled;
- //# sourceMappingURL=check-pip-env-installed.js.map
- /***/ }),
- /***/ 91989:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- var check_pip_env_installed_1 = __webpack_require__(21591);
- Object.defineProperty(exports, "isPipenvInstalled", ({ enumerable: true, get: function () { return check_pip_env_installed_1.isPipenvInstalled; } }));
- var is_pipenv_supported_version_1 = __webpack_require__(97149);
- Object.defineProperty(exports, "isPipenvSupportedVersion", ({ enumerable: true, get: function () { return is_pipenv_supported_version_1.isPipenvSupportedVersion; } }));
- var pipenv_install_1 = __webpack_require__(96194);
- Object.defineProperty(exports, "pipenvInstall", ({ enumerable: true, get: function () { return pipenv_install_1.pipenvInstall; } }));
- //# sourceMappingURL=index.js.map
- /***/ }),
- /***/ 97149:
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.isPipenvSupportedVersion = void 0;
- function isPipenvSupportedVersion(version) {
- // See all versions: https://pipenv.pypa.io/en/latest/changelog/
- // Update SUPPORTED.md when this is updated
- const SUPPORTED_PIPENV_VERSIONS = [
- '2020.11.4',
- '2020.8.13',
- '2020.6.2',
- '2020.5.28',
- '2018.11.26',
- '2018.11.14',
- '2018.10.13',
- '2018.10.9',
- '2018.7.1',
- '2018.6.25',
- ];
- let supported = false;
- if (SUPPORTED_PIPENV_VERSIONS.includes(version)) {
- supported = true;
- }
- return {
- supported,
- versions: SUPPORTED_PIPENV_VERSIONS,
- };
- }
- exports.isPipenvSupportedVersion = isPipenvSupportedVersion;
- //# sourceMappingURL=is-pipenv-supported-version.js.map
- /***/ }),
- /***/ 96194:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.pipenvInstall = void 0;
- const debugLib = __webpack_require__(92259);
- const bottleneck_1 = __webpack_require__(35861);
- const child_process_1 = __webpack_require__(68026);
- const debug = debugLib('snyk-fix:python:Pipfile');
- const limiter = new bottleneck_1.default({
- maxConcurrent: 4,
- });
- // https://pipenv.pypa.io/en/latest/advanced/#changing-default-python-versions
- function getPythonArgs(config) {
- const args = [];
- if (config.python) {
- args.push('--python', config.python); // Performs the installation in a virtualenv using the provided Python interpreter.
- }
- if (process.env.PIPENV_SKIP_LOCK) {
- args.push('--skip-lock');
- }
- return args;
- }
- async function runPipenvInstall(projectPath, requirements, config) {
- const args = ['install', ...requirements];
- const pythonArg = getPythonArgs(config);
- if (pythonArg) {
- args.push(...pythonArg);
- }
- let res;
- try {
- res = await child_process_1.execute('pipenv', args, {
- cwd: projectPath,
- });
- }
- catch (e) {
- debug('Execute failed with', e);
- res = e;
- }
- return res;
- }
- exports.pipenvInstall = limiter.wrap(runPipenvInstall);
- //# sourceMappingURL=pipenv-install.js.map
- /***/ }),
- /***/ 35535:
- /***/ ((module, exports, __webpack_require__) => {
- /* eslint-env browser */
- /**
- * This is the web browser implementation of `debug()`.
- */
- exports.formatArgs = formatArgs;
- exports.save = save;
- exports.load = load;
- exports.useColors = useColors;
- exports.storage = localstorage();
- exports.destroy = (() => {
- let warned = false;
- return () => {
- if (!warned) {
- warned = true;
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
- }
- };
- })();
- /**
- * Colors.
- */
- exports.colors = [
- '#0000CC',
- '#0000FF',
- '#0033CC',
- '#0033FF',
- '#0066CC',
- '#0066FF',
- '#0099CC',
- '#0099FF',
- '#00CC00',
- '#00CC33',
- '#00CC66',
- '#00CC99',
- '#00CCCC',
- '#00CCFF',
- '#3300CC',
- '#3300FF',
- '#3333CC',
- '#3333FF',
- '#3366CC',
- '#3366FF',
- '#3399CC',
- '#3399FF',
- '#33CC00',
- '#33CC33',
- '#33CC66',
- '#33CC99',
- '#33CCCC',
- '#33CCFF',
- '#6600CC',
- '#6600FF',
- '#6633CC',
- '#6633FF',
- '#66CC00',
- '#66CC33',
- '#9900CC',
- '#9900FF',
- '#9933CC',
- '#9933FF',
- '#99CC00',
- '#99CC33',
- '#CC0000',
- '#CC0033',
- '#CC0066',
- '#CC0099',
- '#CC00CC',
- '#CC00FF',
- '#CC3300',
- '#CC3333',
- '#CC3366',
- '#CC3399',
- '#CC33CC',
- '#CC33FF',
- '#CC6600',
- '#CC6633',
- '#CC9900',
- '#CC9933',
- '#CCCC00',
- '#CCCC33',
- '#FF0000',
- '#FF0033',
- '#FF0066',
- '#FF0099',
- '#FF00CC',
- '#FF00FF',
- '#FF3300',
- '#FF3333',
- '#FF3366',
- '#FF3399',
- '#FF33CC',
- '#FF33FF',
- '#FF6600',
- '#FF6633',
- '#FF9900',
- '#FF9933',
- '#FFCC00',
- '#FFCC33'
- ];
- /**
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
- * and the Firebug extension (any Firefox version) are known
- * to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
- // eslint-disable-next-line complexity
- function useColors() {
- // NB: In an Electron preload script, document will be defined but not fully
- // initialized. Since we know we're in Chrome, we'll just detect this case
- // explicitly
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
- return true;
- }
- // Internet Explorer and Edge do not support colors.
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
- return false;
- }
- // Is webkit? http://stackoverflow.com/a/16459606/376773
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
- // Is firebug? http://stackoverflow.com/a/398120/376773
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
- // Is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
- // Double check webkit in userAgent just in case we are in a worker
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
- }
- /**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
- function formatArgs(args) {
- args[0] = (this.useColors ? '%c' : '') +
- this.namespace +
- (this.useColors ? ' %c' : ' ') +
- args[0] +
- (this.useColors ? '%c ' : ' ') +
- '+' + module.exports.humanize(this.diff);
- if (!this.useColors) {
- return;
- }
- const c = 'color: ' + this.color;
- args.splice(1, 0, c, 'color: inherit');
- // The final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- let index = 0;
- let lastC = 0;
- args[0].replace(/%[a-zA-Z%]/g, match => {
- if (match === '%%') {
- return;
- }
- index++;
- if (match === '%c') {
- // We only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
- args.splice(lastC, 0, c);
- }
- /**
- * Invokes `console.debug()` when available.
- * No-op when `console.debug` is not a "function".
- * If `console.debug` is not available, falls back
- * to `console.log`.
- *
- * @api public
- */
- exports.log = console.debug || console.log || (() => {});
- /**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
- function save(namespaces) {
- try {
- if (namespaces) {
- exports.storage.setItem('debug', namespaces);
- } else {
- exports.storage.removeItem('debug');
- }
- } catch (error) {
- // Swallow
- // XXX (@Qix-) should we be logging these?
- }
- }
- /**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
- function load() {
- let r;
- try {
- r = exports.storage.getItem('debug');
- } catch (error) {
- // Swallow
- // XXX (@Qix-) should we be logging these?
- }
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
- if (!r && typeof process !== 'undefined' && 'env' in process) {
- r = process.env.DEBUG;
- }
- return r;
- }
- /**
- * Localstorage attempts to return the localstorage.
- *
- * This is necessary because safari throws
- * when a user disables cookies/localstorage
- * and you attempt to access it.
- *
- * @return {LocalStorage}
- * @api private
- */
- function localstorage() {
- try {
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
- // The Browser also has localStorage in the global context.
- return localStorage;
- } catch (error) {
- // Swallow
- // XXX (@Qix-) should we be logging these?
- }
- }
- module.exports = __webpack_require__(97977)(exports);
- const {formatters} = module.exports;
- /**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
- formatters.j = function (v) {
- try {
- return JSON.stringify(v);
- } catch (error) {
- return '[UnexpectedJSONParseError]: ' + error.message;
- }
- };
- /***/ }),
- /***/ 97977:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- /**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- */
- function setup(env) {
- createDebug.debug = createDebug;
- createDebug.default = createDebug;
- createDebug.coerce = coerce;
- createDebug.disable = disable;
- createDebug.enable = enable;
- createDebug.enabled = enabled;
- createDebug.humanize = __webpack_require__(57824);
- createDebug.destroy = destroy;
- Object.keys(env).forEach(key => {
- createDebug[key] = env[key];
- });
- /**
- * The currently active debug mode names, and names to skip.
- */
- createDebug.names = [];
- createDebug.skips = [];
- /**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
- */
- createDebug.formatters = {};
- /**
- * Selects a color for a debug namespace
- * @param {String} namespace The namespace string for the for the debug instance to be colored
- * @return {Number|String} An ANSI color code for the given namespace
- * @api private
- */
- function selectColor(namespace) {
- let hash = 0;
- for (let i = 0; i < namespace.length; i++) {
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
- hash |= 0; // Convert to 32bit integer
- }
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
- }
- createDebug.selectColor = selectColor;
- /**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
- function createDebug(namespace) {
- let prevTime;
- let enableOverride = null;
- function debug(...args) {
- // Disabled?
- if (!debug.enabled) {
- return;
- }
- const self = debug;
- // Set `diff` timestamp
- const curr = Number(new Date());
- const ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
- args[0] = createDebug.coerce(args[0]);
- if (typeof args[0] !== 'string') {
- // Anything else let's inspect with %O
- args.unshift('%O');
- }
- // Apply any `formatters` transformations
- let index = 0;
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
- // If we encounter an escaped % then don't increase the array index
- if (match === '%%') {
- return '%';
- }
- index++;
- const formatter = createDebug.formatters[format];
- if (typeof formatter === 'function') {
- const val = args[index];
- match = formatter.call(self, val);
- // Now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
- }
- return match;
- });
- // Apply env-specific formatting (colors, etc.)
- createDebug.formatArgs.call(self, args);
- const logFn = self.log || createDebug.log;
- logFn.apply(self, args);
- }
- debug.namespace = namespace;
- debug.useColors = createDebug.useColors();
- debug.color = createDebug.selectColor(namespace);
- debug.extend = extend;
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
- Object.defineProperty(debug, 'enabled', {
- enumerable: true,
- configurable: false,
- get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
- set: v => {
- enableOverride = v;
- }
- });
- // Env-specific initialization logic for debug instances
- if (typeof createDebug.init === 'function') {
- createDebug.init(debug);
- }
- return debug;
- }
- function extend(namespace, delimiter) {
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
- newDebug.log = this.log;
- return newDebug;
- }
- /**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
- function enable(namespaces) {
- createDebug.save(namespaces);
- createDebug.names = [];
- createDebug.skips = [];
- let i;
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
- const len = split.length;
- for (i = 0; i < len; i++) {
- if (!split[i]) {
- // ignore empty strings
- continue;
- }
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
- }
- }
- }
- /**
- * Disable debug output.
- *
- * @return {String} namespaces
- * @api public
- */
- function disable() {
- const namespaces = [
- ...createDebug.names.map(toNamespace),
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
- ].join(',');
- createDebug.enable('');
- return namespaces;
- }
- /**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
- function enabled(name) {
- if (name[name.length - 1] === '*') {
- return true;
- }
- let i;
- let len;
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
- if (createDebug.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = createDebug.names.length; i < len; i++) {
- if (createDebug.names[i].test(name)) {
- return true;
- }
- }
- return false;
- }
- /**
- * Convert regexp to namespace
- *
- * @param {RegExp} regxep
- * @return {String} namespace
- * @api private
- */
- function toNamespace(regexp) {
- return regexp.toString()
- .substring(2, regexp.toString().length - 2)
- .replace(/\.\*\?$/, '*');
- }
- /**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
- function coerce(val) {
- if (val instanceof Error) {
- return val.stack || val.message;
- }
- return val;
- }
- /**
- * XXX DO NOT USE. This is a temporary stub function.
- * XXX It WILL be removed in the next major release.
- */
- function destroy() {
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
- }
- createDebug.enable(createDebug.load());
- return createDebug;
- }
- module.exports = setup;
- /***/ }),
- /***/ 92259:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- /**
- * Detect Electron renderer / nwjs process, which is node, but we should
- * treat as a browser.
- */
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
- module.exports = __webpack_require__(35535);
- } else {
- module.exports = __webpack_require__(66862);
- }
- /***/ }),
- /***/ 66862:
- /***/ ((module, exports, __webpack_require__) => {
- /**
- * Module dependencies.
- */
- const tty = __webpack_require__(33867);
- const util = __webpack_require__(31669);
- /**
- * This is the Node.js implementation of `debug()`.
- */
- exports.init = init;
- exports.log = log;
- exports.formatArgs = formatArgs;
- exports.save = save;
- exports.load = load;
- exports.useColors = useColors;
- exports.destroy = util.deprecate(
- () => {},
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
- );
- /**
- * Colors.
- */
- exports.colors = [6, 2, 3, 4, 5, 1];
- try {
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
- // eslint-disable-next-line import/no-extraneous-dependencies
- const supportsColor = __webpack_require__(92130);
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
- exports.colors = [
- 20,
- 21,
- 26,
- 27,
- 32,
- 33,
- 38,
- 39,
- 40,
- 41,
- 42,
- 43,
- 44,
- 45,
- 56,
- 57,
- 62,
- 63,
- 68,
- 69,
- 74,
- 75,
- 76,
- 77,
- 78,
- 79,
- 80,
- 81,
- 92,
- 93,
- 98,
- 99,
- 112,
- 113,
- 128,
- 129,
- 134,
- 135,
- 148,
- 149,
- 160,
- 161,
- 162,
- 163,
- 164,
- 165,
- 166,
- 167,
- 168,
- 169,
- 170,
- 171,
- 172,
- 173,
- 178,
- 179,
- 184,
- 185,
- 196,
- 197,
- 198,
- 199,
- 200,
- 201,
- 202,
- 203,
- 204,
- 205,
- 206,
- 207,
- 208,
- 209,
- 214,
- 215,
- 220,
- 221
- ];
- }
- } catch (error) {
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
- }
- /**
- * Build up the default `inspectOpts` object from the environment variables.
- *
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
- */
- exports.inspectOpts = Object.keys(process.env).filter(key => {
- return /^debug_/i.test(key);
- }).reduce((obj, key) => {
- // Camel-case
- const prop = key
- .substring(6)
- .toLowerCase()
- .replace(/_([a-z])/g, (_, k) => {
- return k.toUpperCase();
- });
- // Coerce string value into JS value
- let val = process.env[key];
- if (/^(yes|on|true|enabled)$/i.test(val)) {
- val = true;
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
- val = false;
- } else if (val === 'null') {
- val = null;
- } else {
- val = Number(val);
- }
- obj[prop] = val;
- return obj;
- }, {});
- /**
- * Is stdout a TTY? Colored output is enabled when `true`.
- */
- function useColors() {
- return 'colors' in exports.inspectOpts ?
- Boolean(exports.inspectOpts.colors) :
- tty.isatty(process.stderr.fd);
- }
- /**
- * Adds ANSI color escape codes if enabled.
- *
- * @api public
- */
- function formatArgs(args) {
- const {namespace: name, useColors} = this;
- if (useColors) {
- const c = this.color;
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
- } else {
- args[0] = getDate() + name + ' ' + args[0];
- }
- }
- function getDate() {
- if (exports.inspectOpts.hideDate) {
- return '';
- }
- return new Date().toISOString() + ' ';
- }
- /**
- * Invokes `util.format()` with the specified arguments and writes to stderr.
- */
- function log(...args) {
- return process.stderr.write(util.format(...args) + '\n');
- }
- /**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
- function save(namespaces) {
- if (namespaces) {
- process.env.DEBUG = namespaces;
- } else {
- // If you set a process.env field to null or undefined, it gets cast to the
- // string 'null' or 'undefined'. Just delete instead.
- delete process.env.DEBUG;
- }
- }
- /**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
- function load() {
- return process.env.DEBUG;
- }
- /**
- * Init logic for `debug` instances.
- *
- * Create a new `inspectOpts` object in case `useColors` is set
- * differently for a particular `debug` instance.
- */
- function init(debug) {
- debug.inspectOpts = {};
- const keys = Object.keys(exports.inspectOpts);
- for (let i = 0; i < keys.length; i++) {
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
- }
- }
- module.exports = __webpack_require__(97977)(exports);
- const {formatters} = module.exports;
- /**
- * Map %o to `util.inspect()`, all on a single line.
- */
- formatters.o = function (v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts)
- .split('\n')
- .map(str => str.trim())
- .join(' ');
- };
- /**
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
- */
- formatters.O = function (v) {
- this.inspectOpts.colors = this.useColors;
- return util.inspect(v, this.inspectOpts);
- };
- /***/ }),
- /***/ 42925:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.isPoetryInstalled = exports.extractPoetryVersion = void 0;
- const debugLib = __webpack_require__(15158);
- const child_process_1 = __webpack_require__(68026);
- const debug = debugLib('snyk-fix:poetry');
- function extractPoetryVersion(stdout) {
- /* stdout example:
- * Poetry version 1.1.4
- */
- let version = null;
- const re = new RegExp(/^Poetry\sversion\s([0-9.]+)/, 'g');
- const match = re.exec(stdout);
- if (match) {
- version = match[1];
- }
- return version;
- }
- exports.extractPoetryVersion = extractPoetryVersion;
- async function isPoetryInstalled() {
- let res;
- try {
- res = await child_process_1.execute('poetry', ['--version'], {});
- }
- catch (e) {
- debug('Execute failed with', e);
- res = e;
- }
- if (res.exitCode !== 0) {
- throw res.error;
- }
- return { version: extractPoetryVersion(res.stdout) };
- }
- exports.isPoetryInstalled = isPoetryInstalled;
- //# sourceMappingURL=check-poetry-is-installed.js.map
- /***/ }),
- /***/ 69671:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- var check_poetry_is_installed_1 = __webpack_require__(42925);
- Object.defineProperty(exports, "isPoetryInstalled", ({ enumerable: true, get: function () { return check_poetry_is_installed_1.isPoetryInstalled; } }));
- var is_poetry_supported_version_1 = __webpack_require__(29257);
- Object.defineProperty(exports, "isPoetrySupportedVersion", ({ enumerable: true, get: function () { return is_poetry_supported_version_1.isPoetrySupportedVersion; } }));
- var poetry_add_1 = __webpack_require__(10055);
- Object.defineProperty(exports, "poetryAdd", ({ enumerable: true, get: function () { return poetry_add_1.poetryAdd; } }));
- //# sourceMappingURL=index.js.map
- /***/ }),
- /***/ 29257:
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.isPoetrySupportedVersion = void 0;
- function isPoetrySupportedVersion(version) {
- // See all versions: https://github.com/python-poetry/poetry/releases
- // Update SUPPORTED.md when this is updated
- // Not all versions listed below as not all are tested but most likely
- // they are supported
- const SUPPORTED_POETRY_VERSIONS = [
- '1.1.9',
- '1.1.8',
- '1.1.7',
- '1.1.6',
- '1.1.5',
- '1.1.4',
- '1.0.9',
- '1.0.8',
- '1.0.7',
- ];
- let supported = false;
- if (SUPPORTED_POETRY_VERSIONS.includes(version)) {
- supported = true;
- }
- return {
- supported,
- versions: SUPPORTED_POETRY_VERSIONS,
- };
- }
- exports.isPoetrySupportedVersion = isPoetrySupportedVersion;
- //# sourceMappingURL=is-poetry-supported-version.js.map
- /***/ }),
- /***/ 10055:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.poetryAdd = void 0;
- const debugLib = __webpack_require__(15158);
- const bottleneck_1 = __webpack_require__(35861);
- const child_process_1 = __webpack_require__(68026);
- const debug = debugLib('snyk-fix:poetry');
- const limiter = new bottleneck_1.default({
- maxConcurrent: 4,
- });
- async function runPoetryAdd(projectPath, dependencyUpdates, config) {
- const args = ['add', ...dependencyUpdates];
- let res;
- if (config.dev) {
- args.push('--dev');
- }
- if (config.python) {
- try {
- // tell poetry to use the given interpreter
- // https://python-poetry.org/docs/managing-environments/
- await child_process_1.execute('poetry', ['env', 'use', config.python], {
- cwd: projectPath,
- });
- }
- catch (e) {
- debug(`'poetry use env ${config.python}' failed with`, e);
- }
- }
- try {
- res = await child_process_1.execute('poetry', args, {
- cwd: projectPath,
- });
- }
- catch (e) {
- debug('Execute failed with', e);
- res = e;
- }
- if (config.python) {
- try {
- // set it back to system python
- await child_process_1.execute('poetry', ['env', 'use', 'system'], {
- cwd: projectPath,
- });
- }
- catch (e) {
- debug(`'poetry use env system' failed with`, e);
- }
- }
- return res;
- }
- exports.poetryAdd = limiter.wrap(runPoetryAdd);
- //# sourceMappingURL=poetry-add.js.map
- /***/ }),
- /***/ 9526:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- var Batcher, Events, parser;
- parser = __webpack_require__(88092);
- Events = __webpack_require__(33800);
- Batcher = function () {
- class Batcher {
- constructor(options = {}) {
- this.options = options;
- parser.load(this.options, this.defaults, this);
- this.Events = new Events(this);
- this._arr = [];
- this._resetPromise();
- this._lastFlush = Date.now();
- }
- _resetPromise() {
- return this._promise = new this.Promise((res, rej) => {
- return this._resolve = res;
- });
- }
- _flush() {
- clearTimeout(this._timeout);
- this._lastFlush = Date.now();
- this._resolve();
- this.Events.trigger("batch", this._arr);
- this._arr = [];
- return this._resetPromise();
- }
- add(data) {
- var ret;
- this._arr.push(data);
- ret = this._promise;
- if (this._arr.length === this.maxSize) {
- this._flush();
- } else if (this.maxTime != null && this._arr.length === 1) {
- this._timeout = setTimeout(() => {
- return this._flush();
- }, this.maxTime);
- }
- return ret;
- }
- }
- ;
- Batcher.prototype.defaults = {
- maxTime: null,
- maxSize: null,
- Promise: Promise
- };
- return Batcher;
- }.call(void 0);
- module.exports = Batcher;
- /***/ }),
- /***/ 19529:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
- function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var Bottleneck,
- DEFAULT_PRIORITY,
- Events,
- Job,
- LocalDatastore,
- NUM_PRIORITIES,
- Queues,
- RedisDatastore,
- States,
- Sync,
- parser,
- splice = [].splice;
- NUM_PRIORITIES = 10;
- DEFAULT_PRIORITY = 5;
- parser = __webpack_require__(88092);
- Queues = __webpack_require__(21186);
- Job = __webpack_require__(21262);
- LocalDatastore = __webpack_require__(27705);
- RedisDatastore = __webpack_require__(36220);
- Events = __webpack_require__(33800);
- States = __webpack_require__(65376);
- Sync = __webpack_require__(64915);
- Bottleneck = function () {
- class Bottleneck {
- constructor(options = {}, ...invalid) {
- var storeInstanceOptions, storeOptions;
- this._addToQueue = this._addToQueue.bind(this);
- this._validateOptions(options, invalid);
- parser.load(options, this.instanceDefaults, this);
- this._queues = new Queues(NUM_PRIORITIES);
- this._scheduled = {};
- this._states = new States(["RECEIVED", "QUEUED", "RUNNING", "EXECUTING"].concat(this.trackDoneStatus ? ["DONE"] : []));
- this._limiter = null;
- this.Events = new Events(this);
- this._submitLock = new Sync("submit", this.Promise);
- this._registerLock = new Sync("register", this.Promise);
- storeOptions = parser.load(options, this.storeDefaults, {});
- this._store = function () {
- if (this.datastore === "redis" || this.datastore === "ioredis" || this.connection != null) {
- storeInstanceOptions = parser.load(options, this.redisStoreDefaults, {});
- return new RedisDatastore(this, storeOptions, storeInstanceOptions);
- } else if (this.datastore === "local") {
- storeInstanceOptions = parser.load(options, this.localStoreDefaults, {});
- return new LocalDatastore(this, storeOptions, storeInstanceOptions);
- } else {
- throw new Bottleneck.prototype.BottleneckError(`Invalid datastore type: ${this.datastore}`);
- }
- }.call(this);
- this._queues.on("leftzero", () => {
- var ref;
- return (ref = this._store.heartbeat) != null ? typeof ref.ref === "function" ? ref.ref() : void 0 : void 0;
- });
- this._queues.on("zero", () => {
- var ref;
- return (ref = this._store.heartbeat) != null ? typeof ref.unref === "function" ? ref.unref() : void 0 : void 0;
- });
- }
- _validateOptions(options, invalid) {
- if (!(options != null && typeof options === "object" && invalid.length === 0)) {
- throw new Bottleneck.prototype.BottleneckError("Bottleneck v2 takes a single object argument. Refer to https://github.com/SGrondin/bottleneck#upgrading-to-v2 if you're upgrading from Bottleneck v1.");
- }
- }
- ready() {
- return this._store.ready;
- }
- clients() {
- return this._store.clients;
- }
- channel() {
- return `b_${this.id}`;
- }
- channel_client() {
- return `b_${this.id}_${this._store.clientId}`;
- }
- publish(message) {
- return this._store.__publish__(message);
- }
- disconnect(flush = true) {
- return this._store.__disconnect__(flush);
- }
- chain(_limiter) {
- this._limiter = _limiter;
- return this;
- }
- queued(priority) {
- return this._queues.queued(priority);
- }
- clusterQueued() {
- return this._store.__queued__();
- }
- empty() {
- return this.queued() === 0 && this._submitLock.isEmpty();
- }
- running() {
- return this._store.__running__();
- }
- done() {
- return this._store.__done__();
- }
- jobStatus(id) {
- return this._states.jobStatus(id);
- }
- jobs(status) {
- return this._states.statusJobs(status);
- }
- counts() {
- return this._states.statusCounts();
- }
- _randomIndex() {
- return Math.random().toString(36).slice(2);
- }
- check(weight = 1) {
- return this._store.__check__(weight);
- }
- _clearGlobalState(index) {
- if (this._scheduled[index] != null) {
- clearTimeout(this._scheduled[index].expiration);
- delete this._scheduled[index];
- return true;
- } else {
- return false;
- }
- }
- _free(index, job, options, eventInfo) {
- var _this = this;
- return _asyncToGenerator(function* () {
- var e, running;
- try {
- var _ref = yield _this._store.__free__(index, options.weight);
- running = _ref.running;
- _this.Events.trigger("debug", `Freed ${options.id}`, eventInfo);
- if (running === 0 && _this.empty()) {
- return _this.Events.trigger("idle");
- }
- } catch (error1) {
- e = error1;
- return _this.Events.trigger("error", e);
- }
- })();
- }
- _run(index, job, wait) {
- var clearGlobalState, free, run;
- job.doRun();
- clearGlobalState = this._clearGlobalState.bind(this, index);
- run = this._run.bind(this, index, job);
- free = this._free.bind(this, index, job);
- return this._scheduled[index] = {
- timeout: setTimeout(() => {
- return job.doExecute(this._limiter, clearGlobalState, run, free);
- }, wait),
- expiration: job.options.expiration != null ? setTimeout(function () {
- return job.doExpire(clearGlobalState, run, free);
- }, wait + job.options.expiration) : void 0,
- job: job
- };
- }
- _drainOne(capacity) {
- return this._registerLock.schedule(() => {
- var args, index, next, options, queue;
- if (this.queued() === 0) {
- return this.Promise.resolve(null);
- }
- queue = this._queues.getFirst();
- var _next2 = next = queue.first();
- options = _next2.options;
- args = _next2.args;
- if (capacity != null && options.weight > capacity) {
- return this.Promise.resolve(null);
- }
- this.Events.trigger("debug", `Draining ${options.id}`, {
- args,
- options
- });
- index = this._randomIndex();
- return this._store.__register__(index, options.weight, options.expiration).then(({
- success,
- wait,
- reservoir
- }) => {
- var empty;
- this.Events.trigger("debug", `Drained ${options.id}`, {
- success,
- args,
- options
- });
- if (success) {
- queue.shift();
- empty = this.empty();
- if (empty) {
- this.Events.trigger("empty");
- }
- if (reservoir === 0) {
- this.Events.trigger("depleted", empty);
- }
- this._run(index, next, wait);
- return this.Promise.resolve(options.weight);
- } else {
- return this.Promise.resolve(null);
- }
- });
- });
- }
- _drainAll(capacity, total = 0) {
- return this._drainOne(capacity).then(drained => {
- var newCapacity;
- if (drained != null) {
- newCapacity = capacity != null ? capacity - drained : capacity;
- return this._drainAll(newCapacity, total + drained);
- } else {
- return this.Promise.resolve(total);
- }
- }).catch(e => {
- return this.Events.trigger("error", e);
- });
- }
- _dropAllQueued(message) {
- return this._queues.shiftAll(function (job) {
- return job.doDrop({
- message
- });
- });
- }
- stop(options = {}) {
- var done, waitForExecuting;
- options = parser.load(options, this.stopDefaults);
- waitForExecuting = at => {
- var finished;
- finished = () => {
- var counts;
- counts = this._states.counts;
- return counts[0] + counts[1] + counts[2] + counts[3] === at;
- };
- return new this.Promise((resolve, reject) => {
- if (finished()) {
- return resolve();
- } else {
- return this.on("done", () => {
- if (finished()) {
- this.removeAllListeners("done");
- return resolve();
- }
- });
- }
- });
- };
- done = options.dropWaitingJobs ? (this._run = function (index, next) {
- return next.doDrop({
- message: options.dropErrorMessage
- });
- }, this._drainOne = () => {
- return this.Promise.resolve(null);
- }, this._registerLock.schedule(() => {
- return this._submitLock.schedule(() => {
- var k, ref, v;
- ref = this._scheduled;
- for (k in ref) {
- v = ref[k];
- if (this.jobStatus(v.job.options.id) === "RUNNING") {
- clearTimeout(v.timeout);
- clearTimeout(v.expiration);
- v.job.doDrop({
- message: options.dropErrorMessage
- });
- }
- }
- this._dropAllQueued(options.dropErrorMessage);
- return waitForExecuting(0);
- });
- })) : this.schedule({
- priority: NUM_PRIORITIES - 1,
- weight: 0
- }, () => {
- return waitForExecuting(1);
- });
- this._receive = function (job) {
- return job._reject(new Bottleneck.prototype.BottleneckError(options.enqueueErrorMessage));
- };
- this.stop = () => {
- return this.Promise.reject(new Bottleneck.prototype.BottleneckError("stop() has already been called"));
- };
- return done;
- }
- _addToQueue(job) {
- var _this2 = this;
- return _asyncToGenerator(function* () {
- var args, blocked, error, options, reachedHWM, shifted, strategy;
- args = job.args;
- options = job.options;
- try {
- var _ref2 = yield _this2._store.__submit__(_this2.queued(), options.weight);
- reachedHWM = _ref2.reachedHWM;
- blocked = _ref2.blocked;
- strategy = _ref2.strategy;
- } catch (error1) {
- error = error1;
- _this2.Events.trigger("debug", `Could not queue ${options.id}`, {
- args,
- options,
- error
- });
- job.doDrop({
- error
- });
- return false;
- }
- if (blocked) {
- job.doDrop();
- return true;
- } else if (reachedHWM) {
- shifted = strategy === Bottleneck.prototype.strategy.LEAK ? _this2._queues.shiftLastFrom(options.priority) : strategy === Bottleneck.prototype.strategy.OVERFLOW_PRIORITY ? _this2._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck.prototype.strategy.OVERFLOW ? job : void 0;
- if (shifted != null) {
- shifted.doDrop();
- }
- if (shifted == null || strategy === Bottleneck.prototype.strategy.OVERFLOW) {
- if (shifted == null) {
- job.doDrop();
- }
- return reachedHWM;
- }
- }
- job.doQueue(reachedHWM, blocked);
- _this2._queues.push(job);
- yield _this2._drainAll();
- return reachedHWM;
- })();
- }
- _receive(job) {
- if (this._states.jobStatus(job.options.id) != null) {
- job._reject(new Bottleneck.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`));
- return false;
- } else {
- job.doReceive();
- return this._submitLock.schedule(this._addToQueue, job);
- }
- }
- submit(...args) {
- var cb, fn, job, options, ref, ref1, task;
- if (typeof args[0] === "function") {
- var _ref3, _ref4, _splice$call, _splice$call2;
- ref = args, (_ref3 = ref, _ref4 = _toArray(_ref3), fn = _ref4[0], args = _ref4.slice(1), _ref3), (_splice$call = splice.call(args, -1), _splice$call2 = _slicedToArray(_splice$call, 1), cb = _splice$call2[0], _splice$call);
- options = parser.load({}, this.jobDefaults);
- } else {
- var _ref5, _ref6, _splice$call3, _splice$call4;
- ref1 = args, (_ref5 = ref1, _ref6 = _toArray(_ref5), options = _ref6[0], fn = _ref6[1], args = _ref6.slice(2), _ref5), (_splice$call3 = splice.call(args, -1), _splice$call4 = _slicedToArray(_splice$call3, 1), cb = _splice$call4[0], _splice$call3);
- options = parser.load(options, this.jobDefaults);
- }
- task = (...args) => {
- return new this.Promise(function (resolve, reject) {
- return fn(...args, function (...args) {
- return (args[0] != null ? reject : resolve)(args);
- });
- });
- };
- job = new Job(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
- job.promise.then(function (args) {
- return typeof cb === "function" ? cb(...args) : void 0;
- }).catch(function (args) {
- if (Array.isArray(args)) {
- return typeof cb === "function" ? cb(...args) : void 0;
- } else {
- return typeof cb === "function" ? cb(args) : void 0;
- }
- });
- return this._receive(job);
- }
- schedule(...args) {
- var job, options, task;
- if (typeof args[0] === "function") {
- var _args = args;
- var _args2 = _toArray(_args);
- task = _args2[0];
- args = _args2.slice(1);
- options = {};
- } else {
- var _args3 = args;
- var _args4 = _toArray(_args3);
- options = _args4[0];
- task = _args4[1];
- args = _args4.slice(2);
- }
- job = new Job(task, args, options, this.jobDefaults, this.rejectOnDrop, this.Events, this._states, this.Promise);
- this._receive(job);
- return job.promise;
- }
- wrap(fn) {
- var schedule, wrapped;
- schedule = this.schedule.bind(this);
- wrapped = function wrapped(...args) {
- return schedule(fn.bind(this), ...args);
- };
- wrapped.withOptions = function (options, ...args) {
- return schedule(options, fn, ...args);
- };
- return wrapped;
- }
- updateSettings(options = {}) {
- var _this3 = this;
- return _asyncToGenerator(function* () {
- yield _this3._store.__updateSettings__(parser.overwrite(options, _this3.storeDefaults));
- parser.overwrite(options, _this3.instanceDefaults, _this3);
- return _this3;
- })();
- }
- currentReservoir() {
- return this._store.__currentReservoir__();
- }
- incrementReservoir(incr = 0) {
- return this._store.__incrementReservoir__(incr);
- }
- }
- ;
- Bottleneck.default = Bottleneck;
- Bottleneck.Events = Events;
- Bottleneck.version = Bottleneck.prototype.version = __webpack_require__(82636)/* .version */ .i;
- Bottleneck.strategy = Bottleneck.prototype.strategy = {
- LEAK: 1,
- OVERFLOW: 2,
- OVERFLOW_PRIORITY: 4,
- BLOCK: 3
- };
- Bottleneck.BottleneckError = Bottleneck.prototype.BottleneckError = __webpack_require__(34006);
- Bottleneck.Group = Bottleneck.prototype.Group = __webpack_require__(99158);
- Bottleneck.RedisConnection = Bottleneck.prototype.RedisConnection = __webpack_require__(66427);
- Bottleneck.IORedisConnection = Bottleneck.prototype.IORedisConnection = __webpack_require__(9442);
- Bottleneck.Batcher = Bottleneck.prototype.Batcher = __webpack_require__(9526);
- Bottleneck.prototype.jobDefaults = {
- priority: DEFAULT_PRIORITY,
- weight: 1,
- expiration: null,
- id: "<no-id>"
- };
- Bottleneck.prototype.storeDefaults = {
- maxConcurrent: null,
- minTime: 0,
- highWater: null,
- strategy: Bottleneck.prototype.strategy.LEAK,
- penalty: null,
- reservoir: null,
- reservoirRefreshInterval: null,
- reservoirRefreshAmount: null,
- reservoirIncreaseInterval: null,
- reservoirIncreaseAmount: null,
- reservoirIncreaseMaximum: null
- };
- Bottleneck.prototype.localStoreDefaults = {
- Promise: Promise,
- timeout: null,
- heartbeatInterval: 250
- };
- Bottleneck.prototype.redisStoreDefaults = {
- Promise: Promise,
- timeout: null,
- heartbeatInterval: 5000,
- clientTimeout: 10000,
- Redis: null,
- clientOptions: {},
- clusterNodes: null,
- clearDatastore: false,
- connection: null
- };
- Bottleneck.prototype.instanceDefaults = {
- datastore: "local",
- connection: null,
- id: "<no-id>",
- rejectOnDrop: true,
- trackDoneStatus: false,
- Promise: Promise
- };
- Bottleneck.prototype.stopDefaults = {
- enqueueErrorMessage: "This limiter has been stopped and cannot accept new jobs.",
- dropWaitingJobs: true,
- dropErrorMessage: "This limiter has been stopped."
- };
- return Bottleneck;
- }.call(void 0);
- module.exports = Bottleneck;
- /***/ }),
- /***/ 34006:
- /***/ ((module) => {
- "use strict";
- var BottleneckError;
- BottleneckError = class BottleneckError extends Error {};
- module.exports = BottleneckError;
- /***/ }),
- /***/ 70938:
- /***/ ((module) => {
- "use strict";
- var DLList;
- DLList = class DLList {
- constructor(incr, decr) {
- this.incr = incr;
- this.decr = decr;
- this._first = null;
- this._last = null;
- this.length = 0;
- }
- push(value) {
- var node;
- this.length++;
- if (typeof this.incr === "function") {
- this.incr();
- }
- node = {
- value,
- prev: this._last,
- next: null
- };
- if (this._last != null) {
- this._last.next = node;
- this._last = node;
- } else {
- this._first = this._last = node;
- }
- return void 0;
- }
- shift() {
- var value;
- if (this._first == null) {
- return;
- } else {
- this.length--;
- if (typeof this.decr === "function") {
- this.decr();
- }
- }
- value = this._first.value;
- if ((this._first = this._first.next) != null) {
- this._first.prev = null;
- } else {
- this._last = null;
- }
- return value;
- }
- first() {
- if (this._first != null) {
- return this._first.value;
- }
- }
- getArray() {
- var node, ref, results;
- node = this._first;
- results = [];
- while (node != null) {
- results.push((ref = node, node = node.next, ref.value));
- }
- return results;
- }
- forEachShift(cb) {
- var node;
- node = this.shift();
- while (node != null) {
- cb(node), node = this.shift();
- }
- return void 0;
- }
- debug() {
- var node, ref, ref1, ref2, results;
- node = this._first;
- results = [];
- while (node != null) {
- results.push((ref = node, node = node.next, {
- value: ref.value,
- prev: (ref1 = ref.prev) != null ? ref1.value : void 0,
- next: (ref2 = ref.next) != null ? ref2.value : void 0
- }));
- }
- return results;
- }
- };
- module.exports = DLList;
- /***/ }),
- /***/ 33800:
- /***/ ((module) => {
- "use strict";
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var Events;
- Events = class Events {
- constructor(instance) {
- this.instance = instance;
- this._events = {};
- if (this.instance.on != null || this.instance.once != null || this.instance.removeAllListeners != null) {
- throw new Error("An Emitter already exists for this object");
- }
- this.instance.on = (name, cb) => {
- return this._addListener(name, "many", cb);
- };
- this.instance.once = (name, cb) => {
- return this._addListener(name, "once", cb);
- };
- this.instance.removeAllListeners = (name = null) => {
- if (name != null) {
- return delete this._events[name];
- } else {
- return this._events = {};
- }
- };
- }
- _addListener(name, status, cb) {
- var base;
- if ((base = this._events)[name] == null) {
- base[name] = [];
- }
- this._events[name].push({
- cb,
- status
- });
- return this.instance;
- }
- listenerCount(name) {
- if (this._events[name] != null) {
- return this._events[name].length;
- } else {
- return 0;
- }
- }
- trigger(name, ...args) {
- var _this = this;
- return _asyncToGenerator(function* () {
- var e, promises;
- try {
- if (name !== "debug") {
- _this.trigger("debug", `Event triggered: ${name}`, args);
- }
- if (_this._events[name] == null) {
- return;
- }
- _this._events[name] = _this._events[name].filter(function (listener) {
- return listener.status !== "none";
- });
- promises = _this._events[name].map(
- /*#__PURE__*/
- function () {
- var _ref = _asyncToGenerator(function* (listener) {
- var e, returned;
- if (listener.status === "none") {
- return;
- }
- if (listener.status === "once") {
- listener.status = "none";
- }
- try {
- returned = typeof listener.cb === "function" ? listener.cb(...args) : void 0;
- if (typeof (returned != null ? returned.then : void 0) === "function") {
- return yield returned;
- } else {
- return returned;
- }
- } catch (error) {
- e = error;
- if (true) {
- _this.trigger("error", e);
- }
- return null;
- }
- });
- return function (_x) {
- return _ref.apply(this, arguments);
- };
- }());
- return (yield Promise.all(promises)).find(function (x) {
- return x != null;
- });
- } catch (error) {
- e = error;
- if (true) {
- _this.trigger("error", e);
- }
- return null;
- }
- })();
- }
- };
- module.exports = Events;
- /***/ }),
- /***/ 99158:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var Events, Group, IORedisConnection, RedisConnection, Scripts, parser;
- parser = __webpack_require__(88092);
- Events = __webpack_require__(33800);
- RedisConnection = __webpack_require__(66427);
- IORedisConnection = __webpack_require__(9442);
- Scripts = __webpack_require__(40812);
- Group = function () {
- class Group {
- constructor(limiterOptions = {}) {
- this.deleteKey = this.deleteKey.bind(this);
- this.limiterOptions = limiterOptions;
- parser.load(this.limiterOptions, this.defaults, this);
- this.Events = new Events(this);
- this.instances = {};
- this.Bottleneck = __webpack_require__(19529);
- this._startAutoCleanup();
- this.sharedConnection = this.connection != null;
- if (this.connection == null) {
- if (this.limiterOptions.datastore === "redis") {
- this.connection = new RedisConnection(Object.assign({}, this.limiterOptions, {
- Events: this.Events
- }));
- } else if (this.limiterOptions.datastore === "ioredis") {
- this.connection = new IORedisConnection(Object.assign({}, this.limiterOptions, {
- Events: this.Events
- }));
- }
- }
- }
- key(key = "") {
- var ref;
- return (ref = this.instances[key]) != null ? ref : (() => {
- var limiter;
- limiter = this.instances[key] = new this.Bottleneck(Object.assign(this.limiterOptions, {
- id: `${this.id}-${key}`,
- timeout: this.timeout,
- connection: this.connection
- }));
- this.Events.trigger("created", limiter, key);
- return limiter;
- })();
- }
- deleteKey(key = "") {
- var _this = this;
- return _asyncToGenerator(function* () {
- var deleted, instance;
- instance = _this.instances[key];
- if (_this.connection) {
- deleted = yield _this.connection.__runCommand__(['del', ...Scripts.allKeys(`${_this.id}-${key}`)]);
- }
- if (instance != null) {
- delete _this.instances[key];
- yield instance.disconnect();
- }
- return instance != null || deleted > 0;
- })();
- }
- limiters() {
- var k, ref, results, v;
- ref = this.instances;
- results = [];
- for (k in ref) {
- v = ref[k];
- results.push({
- key: k,
- limiter: v
- });
- }
- return results;
- }
- keys() {
- return Object.keys(this.instances);
- }
- clusterKeys() {
- var _this2 = this;
- return _asyncToGenerator(function* () {
- var cursor, end, found, i, k, keys, len, next, start;
- if (_this2.connection == null) {
- return _this2.Promise.resolve(_this2.keys());
- }
- keys = [];
- cursor = null;
- start = `b_${_this2.id}-`.length;
- end = "_settings".length;
- while (cursor !== 0) {
- var _ref = yield _this2.connection.__runCommand__(["scan", cursor != null ? cursor : 0, "match", `b_${_this2.id}-*_settings`, "count", 10000]);
- var _ref2 = _slicedToArray(_ref, 2);
- next = _ref2[0];
- found = _ref2[1];
- cursor = ~~next;
- for (i = 0, len = found.length; i < len; i++) {
- k = found[i];
- keys.push(k.slice(start, -end));
- }
- }
- return keys;
- })();
- }
- _startAutoCleanup() {
- var _this3 = this;
- var base;
- clearInterval(this.interval);
- return typeof (base = this.interval = setInterval(
- /*#__PURE__*/
- _asyncToGenerator(function* () {
- var e, k, ref, results, time, v;
- time = Date.now();
- ref = _this3.instances;
- results = [];
- for (k in ref) {
- v = ref[k];
- try {
- if (yield v._store.__groupCheck__(time)) {
- results.push(_this3.deleteKey(k));
- } else {
- results.push(void 0);
- }
- } catch (error) {
- e = error;
- results.push(v.Events.trigger("error", e));
- }
- }
- return results;
- }), this.timeout / 2)).unref === "function" ? base.unref() : void 0;
- }
- updateSettings(options = {}) {
- parser.overwrite(options, this.defaults, this);
- parser.overwrite(options, options, this.limiterOptions);
- if (options.timeout != null) {
- return this._startAutoCleanup();
- }
- }
- disconnect(flush = true) {
- var ref;
- if (!this.sharedConnection) {
- return (ref = this.connection) != null ? ref.disconnect(flush) : void 0;
- }
- }
- }
- ;
- Group.prototype.defaults = {
- timeout: 1000 * 60 * 5,
- connection: null,
- Promise: Promise,
- id: "group-key"
- };
- return Group;
- }.call(void 0);
- module.exports = Group;
- /***/ }),
- /***/ 9442:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var Events, IORedisConnection, Scripts, parser;
- parser = __webpack_require__(88092);
- Events = __webpack_require__(33800);
- Scripts = __webpack_require__(40812);
- IORedisConnection = function () {
- class IORedisConnection {
- constructor(options = {}) {
- parser.load(options, this.defaults, this);
- if (this.Redis == null) {
- this.Redis = eval("require")("ioredis"); // Obfuscated or else Webpack/Angular will try to inline the optional ioredis module. To override this behavior: pass the ioredis module to Bottleneck as the 'Redis' option.
- }
- if (this.Events == null) {
- this.Events = new Events(this);
- }
- this.terminated = false;
- if (this.clusterNodes != null) {
- this.client = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
- this.subscriber = new this.Redis.Cluster(this.clusterNodes, this.clientOptions);
- } else if (this.client != null && this.client.duplicate == null) {
- this.subscriber = new this.Redis.Cluster(this.client.startupNodes, this.client.options);
- } else {
- if (this.client == null) {
- this.client = new this.Redis(this.clientOptions);
- }
- this.subscriber = this.client.duplicate();
- }
- this.limiters = {};
- this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
- this._loadScripts();
- return {
- client: this.client,
- subscriber: this.subscriber
- };
- });
- }
- _setup(client, sub) {
- client.setMaxListeners(0);
- return new this.Promise((resolve, reject) => {
- client.on("error", e => {
- return this.Events.trigger("error", e);
- });
- if (sub) {
- client.on("message", (channel, message) => {
- var ref;
- return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
- });
- }
- if (client.status === "ready") {
- return resolve();
- } else {
- return client.once("ready", resolve);
- }
- });
- }
- _loadScripts() {
- return Scripts.names.forEach(name => {
- return this.client.defineCommand(name, {
- lua: Scripts.payload(name)
- });
- });
- }
- __runCommand__(cmd) {
- var _this = this;
- return _asyncToGenerator(function* () {
- var _, deleted;
- yield _this.ready;
- var _ref = yield _this.client.pipeline([cmd]).exec();
- var _ref2 = _slicedToArray(_ref, 1);
- var _ref2$ = _slicedToArray(_ref2[0], 2);
- _ = _ref2$[0];
- deleted = _ref2$[1];
- return deleted;
- })();
- }
- __addLimiter__(instance) {
- return this.Promise.all([instance.channel(), instance.channel_client()].map(channel => {
- return new this.Promise((resolve, reject) => {
- return this.subscriber.subscribe(channel, () => {
- this.limiters[channel] = instance;
- return resolve();
- });
- });
- }));
- }
- __removeLimiter__(instance) {
- var _this2 = this;
- return [instance.channel(), instance.channel_client()].forEach(
- /*#__PURE__*/
- function () {
- var _ref3 = _asyncToGenerator(function* (channel) {
- if (!_this2.terminated) {
- yield _this2.subscriber.unsubscribe(channel);
- }
- return delete _this2.limiters[channel];
- });
- return function (_x) {
- return _ref3.apply(this, arguments);
- };
- }());
- }
- __scriptArgs__(name, id, args, cb) {
- var keys;
- keys = Scripts.keys(name, id);
- return [keys.length].concat(keys, args, cb);
- }
- __scriptFn__(name) {
- return this.client[name].bind(this.client);
- }
- disconnect(flush = true) {
- var i, k, len, ref;
- ref = Object.keys(this.limiters);
- for (i = 0, len = ref.length; i < len; i++) {
- k = ref[i];
- clearInterval(this.limiters[k]._store.heartbeat);
- }
- this.limiters = {};
- this.terminated = true;
- if (flush) {
- return this.Promise.all([this.client.quit(), this.subscriber.quit()]);
- } else {
- this.client.disconnect();
- this.subscriber.disconnect();
- return this.Promise.resolve();
- }
- }
- }
- ;
- IORedisConnection.prototype.datastore = "ioredis";
- IORedisConnection.prototype.defaults = {
- Redis: null,
- clientOptions: {},
- clusterNodes: null,
- client: null,
- Promise: Promise,
- Events: null
- };
- return IORedisConnection;
- }.call(void 0);
- module.exports = IORedisConnection;
- /***/ }),
- /***/ 21262:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var BottleneckError, DEFAULT_PRIORITY, Job, NUM_PRIORITIES, parser;
- NUM_PRIORITIES = 10;
- DEFAULT_PRIORITY = 5;
- parser = __webpack_require__(88092);
- BottleneckError = __webpack_require__(34006);
- Job = class Job {
- constructor(task, args, options, jobDefaults, rejectOnDrop, Events, _states, Promise) {
- this.task = task;
- this.args = args;
- this.rejectOnDrop = rejectOnDrop;
- this.Events = Events;
- this._states = _states;
- this.Promise = Promise;
- this.options = parser.load(options, jobDefaults);
- this.options.priority = this._sanitizePriority(this.options.priority);
- if (this.options.id === jobDefaults.id) {
- this.options.id = `${this.options.id}-${this._randomIndex()}`;
- }
- this.promise = new this.Promise((_resolve, _reject) => {
- this._resolve = _resolve;
- this._reject = _reject;
- });
- this.retryCount = 0;
- }
- _sanitizePriority(priority) {
- var sProperty;
- sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority;
- if (sProperty < 0) {
- return 0;
- } else if (sProperty > NUM_PRIORITIES - 1) {
- return NUM_PRIORITIES - 1;
- } else {
- return sProperty;
- }
- }
- _randomIndex() {
- return Math.random().toString(36).slice(2);
- }
- doDrop({
- error,
- message = "This job has been dropped by Bottleneck"
- } = {}) {
- if (this._states.remove(this.options.id)) {
- if (this.rejectOnDrop) {
- this._reject(error != null ? error : new BottleneckError(message));
- }
- this.Events.trigger("dropped", {
- args: this.args,
- options: this.options,
- task: this.task,
- promise: this.promise
- });
- return true;
- } else {
- return false;
- }
- }
- _assertStatus(expected) {
- var status;
- status = this._states.jobStatus(this.options.id);
- if (!(status === expected || expected === "DONE" && status === null)) {
- throw new BottleneckError(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`);
- }
- }
- doReceive() {
- this._states.start(this.options.id);
- return this.Events.trigger("received", {
- args: this.args,
- options: this.options
- });
- }
- doQueue(reachedHWM, blocked) {
- this._assertStatus("RECEIVED");
- this._states.next(this.options.id);
- return this.Events.trigger("queued", {
- args: this.args,
- options: this.options,
- reachedHWM,
- blocked
- });
- }
- doRun() {
- if (this.retryCount === 0) {
- this._assertStatus("QUEUED");
- this._states.next(this.options.id);
- } else {
- this._assertStatus("EXECUTING");
- }
- return this.Events.trigger("scheduled", {
- args: this.args,
- options: this.options
- });
- }
- doExecute(chained, clearGlobalState, run, free) {
- var _this = this;
- return _asyncToGenerator(function* () {
- var error, eventInfo, passed;
- if (_this.retryCount === 0) {
- _this._assertStatus("RUNNING");
- _this._states.next(_this.options.id);
- } else {
- _this._assertStatus("EXECUTING");
- }
- eventInfo = {
- args: _this.args,
- options: _this.options,
- retryCount: _this.retryCount
- };
- _this.Events.trigger("executing", eventInfo);
- try {
- passed = yield chained != null ? chained.schedule(_this.options, _this.task, ..._this.args) : _this.task(..._this.args);
- if (clearGlobalState()) {
- _this.doDone(eventInfo);
- yield free(_this.options, eventInfo);
- _this._assertStatus("DONE");
- return _this._resolve(passed);
- }
- } catch (error1) {
- error = error1;
- return _this._onFailure(error, eventInfo, clearGlobalState, run, free);
- }
- })();
- }
- doExpire(clearGlobalState, run, free) {
- var error, eventInfo;
- if (this._states.jobStatus(this.options.id === "RUNNING")) {
- this._states.next(this.options.id);
- }
- this._assertStatus("EXECUTING");
- eventInfo = {
- args: this.args,
- options: this.options,
- retryCount: this.retryCount
- };
- error = new BottleneckError(`This job timed out after ${this.options.expiration} ms.`);
- return this._onFailure(error, eventInfo, clearGlobalState, run, free);
- }
- _onFailure(error, eventInfo, clearGlobalState, run, free) {
- var _this2 = this;
- return _asyncToGenerator(function* () {
- var retry, retryAfter;
- if (clearGlobalState()) {
- retry = yield _this2.Events.trigger("failed", error, eventInfo);
- if (retry != null) {
- retryAfter = ~~retry;
- _this2.Events.trigger("retry", `Retrying ${_this2.options.id} after ${retryAfter} ms`, eventInfo);
- _this2.retryCount++;
- return run(retryAfter);
- } else {
- _this2.doDone(eventInfo);
- yield free(_this2.options, eventInfo);
- _this2._assertStatus("DONE");
- return _this2._reject(error);
- }
- }
- })();
- }
- doDone(eventInfo) {
- this._assertStatus("EXECUTING");
- this._states.next(this.options.id);
- return this.Events.trigger("done", eventInfo);
- }
- };
- module.exports = Job;
- /***/ }),
- /***/ 27705:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var BottleneckError, LocalDatastore, parser;
- parser = __webpack_require__(88092);
- BottleneckError = __webpack_require__(34006);
- LocalDatastore = class LocalDatastore {
- constructor(instance, storeOptions, storeInstanceOptions) {
- this.instance = instance;
- this.storeOptions = storeOptions;
- this.clientId = this.instance._randomIndex();
- parser.load(storeInstanceOptions, storeInstanceOptions, this);
- this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now();
- this._running = 0;
- this._done = 0;
- this._unblockTime = 0;
- this.ready = this.Promise.resolve();
- this.clients = {};
- this._startHeartbeat();
- }
- _startHeartbeat() {
- var base;
- if (this.heartbeat == null && (this.storeOptions.reservoirRefreshInterval != null && this.storeOptions.reservoirRefreshAmount != null || this.storeOptions.reservoirIncreaseInterval != null && this.storeOptions.reservoirIncreaseAmount != null)) {
- return typeof (base = this.heartbeat = setInterval(() => {
- var amount, incr, maximum, now, reservoir;
- now = Date.now();
- if (this.storeOptions.reservoirRefreshInterval != null && now >= this._lastReservoirRefresh + this.storeOptions.reservoirRefreshInterval) {
- this._lastReservoirRefresh = now;
- this.storeOptions.reservoir = this.storeOptions.reservoirRefreshAmount;
- this.instance._drainAll(this.computeCapacity());
- }
- if (this.storeOptions.reservoirIncreaseInterval != null && now >= this._lastReservoirIncrease + this.storeOptions.reservoirIncreaseInterval) {
- var _this$storeOptions = this.storeOptions;
- amount = _this$storeOptions.reservoirIncreaseAmount;
- maximum = _this$storeOptions.reservoirIncreaseMaximum;
- reservoir = _this$storeOptions.reservoir;
- this._lastReservoirIncrease = now;
- incr = maximum != null ? Math.min(amount, maximum - reservoir) : amount;
- if (incr > 0) {
- this.storeOptions.reservoir += incr;
- return this.instance._drainAll(this.computeCapacity());
- }
- }
- }, this.heartbeatInterval)).unref === "function" ? base.unref() : void 0;
- } else {
- return clearInterval(this.heartbeat);
- }
- }
- __publish__(message) {
- var _this = this;
- return _asyncToGenerator(function* () {
- yield _this.yieldLoop();
- return _this.instance.Events.trigger("message", message.toString());
- })();
- }
- __disconnect__(flush) {
- var _this2 = this;
- return _asyncToGenerator(function* () {
- yield _this2.yieldLoop();
- clearInterval(_this2.heartbeat);
- return _this2.Promise.resolve();
- })();
- }
- yieldLoop(t = 0) {
- return new this.Promise(function (resolve, reject) {
- return setTimeout(resolve, t);
- });
- }
- computePenalty() {
- var ref;
- return (ref = this.storeOptions.penalty) != null ? ref : 15 * this.storeOptions.minTime || 5000;
- }
- __updateSettings__(options) {
- var _this3 = this;
- return _asyncToGenerator(function* () {
- yield _this3.yieldLoop();
- parser.overwrite(options, options, _this3.storeOptions);
- _this3._startHeartbeat();
- _this3.instance._drainAll(_this3.computeCapacity());
- return true;
- })();
- }
- __running__() {
- var _this4 = this;
- return _asyncToGenerator(function* () {
- yield _this4.yieldLoop();
- return _this4._running;
- })();
- }
- __queued__() {
- var _this5 = this;
- return _asyncToGenerator(function* () {
- yield _this5.yieldLoop();
- return _this5.instance.queued();
- })();
- }
- __done__() {
- var _this6 = this;
- return _asyncToGenerator(function* () {
- yield _this6.yieldLoop();
- return _this6._done;
- })();
- }
- __groupCheck__(time) {
- var _this7 = this;
- return _asyncToGenerator(function* () {
- yield _this7.yieldLoop();
- return _this7._nextRequest + _this7.timeout < time;
- })();
- }
- computeCapacity() {
- var maxConcurrent, reservoir;
- var _this$storeOptions2 = this.storeOptions;
- maxConcurrent = _this$storeOptions2.maxConcurrent;
- reservoir = _this$storeOptions2.reservoir;
- if (maxConcurrent != null && reservoir != null) {
- return Math.min(maxConcurrent - this._running, reservoir);
- } else if (maxConcurrent != null) {
- return maxConcurrent - this._running;
- } else if (reservoir != null) {
- return reservoir;
- } else {
- return null;
- }
- }
- conditionsCheck(weight) {
- var capacity;
- capacity = this.computeCapacity();
- return capacity == null || weight <= capacity;
- }
- __incrementReservoir__(incr) {
- var _this8 = this;
- return _asyncToGenerator(function* () {
- var reservoir;
- yield _this8.yieldLoop();
- reservoir = _this8.storeOptions.reservoir += incr;
- _this8.instance._drainAll(_this8.computeCapacity());
- return reservoir;
- })();
- }
- __currentReservoir__() {
- var _this9 = this;
- return _asyncToGenerator(function* () {
- yield _this9.yieldLoop();
- return _this9.storeOptions.reservoir;
- })();
- }
- isBlocked(now) {
- return this._unblockTime >= now;
- }
- check(weight, now) {
- return this.conditionsCheck(weight) && this._nextRequest - now <= 0;
- }
- __check__(weight) {
- var _this10 = this;
- return _asyncToGenerator(function* () {
- var now;
- yield _this10.yieldLoop();
- now = Date.now();
- return _this10.check(weight, now);
- })();
- }
- __register__(index, weight, expiration) {
- var _this11 = this;
- return _asyncToGenerator(function* () {
- var now, wait;
- yield _this11.yieldLoop();
- now = Date.now();
- if (_this11.conditionsCheck(weight)) {
- _this11._running += weight;
- if (_this11.storeOptions.reservoir != null) {
- _this11.storeOptions.reservoir -= weight;
- }
- wait = Math.max(_this11._nextRequest - now, 0);
- _this11._nextRequest = now + wait + _this11.storeOptions.minTime;
- return {
- success: true,
- wait,
- reservoir: _this11.storeOptions.reservoir
- };
- } else {
- return {
- success: false
- };
- }
- })();
- }
- strategyIsBlock() {
- return this.storeOptions.strategy === 3;
- }
- __submit__(queueLength, weight) {
- var _this12 = this;
- return _asyncToGenerator(function* () {
- var blocked, now, reachedHWM;
- yield _this12.yieldLoop();
- if (_this12.storeOptions.maxConcurrent != null && weight > _this12.storeOptions.maxConcurrent) {
- throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${_this12.storeOptions.maxConcurrent}`);
- }
- now = Date.now();
- reachedHWM = _this12.storeOptions.highWater != null && queueLength === _this12.storeOptions.highWater && !_this12.check(weight, now);
- blocked = _this12.strategyIsBlock() && (reachedHWM || _this12.isBlocked(now));
- if (blocked) {
- _this12._unblockTime = now + _this12.computePenalty();
- _this12._nextRequest = _this12._unblockTime + _this12.storeOptions.minTime;
- _this12.instance._dropAllQueued();
- }
- return {
- reachedHWM,
- blocked,
- strategy: _this12.storeOptions.strategy
- };
- })();
- }
- __free__(index, weight) {
- var _this13 = this;
- return _asyncToGenerator(function* () {
- yield _this13.yieldLoop();
- _this13._running -= weight;
- _this13._done += weight;
- _this13.instance._drainAll(_this13.computeCapacity());
- return {
- running: _this13._running
- };
- })();
- }
- };
- module.exports = LocalDatastore;
- /***/ }),
- /***/ 21186:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- var DLList, Events, Queues;
- DLList = __webpack_require__(70938);
- Events = __webpack_require__(33800);
- Queues = class Queues {
- constructor(num_priorities) {
- var i;
- this.Events = new Events(this);
- this._length = 0;
- this._lists = function () {
- var j, ref, results;
- results = [];
- for (i = j = 1, ref = num_priorities; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {
- results.push(new DLList(() => {
- return this.incr();
- }, () => {
- return this.decr();
- }));
- }
- return results;
- }.call(this);
- }
- incr() {
- if (this._length++ === 0) {
- return this.Events.trigger("leftzero");
- }
- }
- decr() {
- if (--this._length === 0) {
- return this.Events.trigger("zero");
- }
- }
- push(job) {
- return this._lists[job.options.priority].push(job);
- }
- queued(priority) {
- if (priority != null) {
- return this._lists[priority].length;
- } else {
- return this._length;
- }
- }
- shiftAll(fn) {
- return this._lists.forEach(function (list) {
- return list.forEachShift(fn);
- });
- }
- getFirst(arr = this._lists) {
- var j, len, list;
- for (j = 0, len = arr.length; j < len; j++) {
- list = arr[j];
- if (list.length > 0) {
- return list;
- }
- }
- return [];
- }
- shiftLastFrom(priority) {
- return this.getFirst(this._lists.slice(priority).reverse()).shift();
- }
- };
- module.exports = Queues;
- /***/ }),
- /***/ 66427:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var Events, RedisConnection, Scripts, parser;
- parser = __webpack_require__(88092);
- Events = __webpack_require__(33800);
- Scripts = __webpack_require__(40812);
- RedisConnection = function () {
- class RedisConnection {
- constructor(options = {}) {
- parser.load(options, this.defaults, this);
- if (this.Redis == null) {
- this.Redis = eval("require")("redis"); // Obfuscated or else Webpack/Angular will try to inline the optional redis module. To override this behavior: pass the redis module to Bottleneck as the 'Redis' option.
- }
- if (this.Events == null) {
- this.Events = new Events(this);
- }
- this.terminated = false;
- if (this.client == null) {
- this.client = this.Redis.createClient(this.clientOptions);
- }
- this.subscriber = this.client.duplicate();
- this.limiters = {};
- this.shas = {};
- this.ready = this.Promise.all([this._setup(this.client, false), this._setup(this.subscriber, true)]).then(() => {
- return this._loadScripts();
- }).then(() => {
- return {
- client: this.client,
- subscriber: this.subscriber
- };
- });
- }
- _setup(client, sub) {
- client.setMaxListeners(0);
- return new this.Promise((resolve, reject) => {
- client.on("error", e => {
- return this.Events.trigger("error", e);
- });
- if (sub) {
- client.on("message", (channel, message) => {
- var ref;
- return (ref = this.limiters[channel]) != null ? ref._store.onMessage(channel, message) : void 0;
- });
- }
- if (client.ready) {
- return resolve();
- } else {
- return client.once("ready", resolve);
- }
- });
- }
- _loadScript(name) {
- return new this.Promise((resolve, reject) => {
- var payload;
- payload = Scripts.payload(name);
- return this.client.multi([["script", "load", payload]]).exec((err, replies) => {
- if (err != null) {
- return reject(err);
- }
- this.shas[name] = replies[0];
- return resolve(replies[0]);
- });
- });
- }
- _loadScripts() {
- return this.Promise.all(Scripts.names.map(k => {
- return this._loadScript(k);
- }));
- }
- __runCommand__(cmd) {
- var _this = this;
- return _asyncToGenerator(function* () {
- yield _this.ready;
- return new _this.Promise((resolve, reject) => {
- return _this.client.multi([cmd]).exec_atomic(function (err, replies) {
- if (err != null) {
- return reject(err);
- } else {
- return resolve(replies[0]);
- }
- });
- });
- })();
- }
- __addLimiter__(instance) {
- return this.Promise.all([instance.channel(), instance.channel_client()].map(channel => {
- return new this.Promise((resolve, reject) => {
- var handler;
- handler = chan => {
- if (chan === channel) {
- this.subscriber.removeListener("subscribe", handler);
- this.limiters[channel] = instance;
- return resolve();
- }
- };
- this.subscriber.on("subscribe", handler);
- return this.subscriber.subscribe(channel);
- });
- }));
- }
- __removeLimiter__(instance) {
- var _this2 = this;
- return this.Promise.all([instance.channel(), instance.channel_client()].map(
- /*#__PURE__*/
- function () {
- var _ref = _asyncToGenerator(function* (channel) {
- if (!_this2.terminated) {
- yield new _this2.Promise((resolve, reject) => {
- return _this2.subscriber.unsubscribe(channel, function (err, chan) {
- if (err != null) {
- return reject(err);
- }
- if (chan === channel) {
- return resolve();
- }
- });
- });
- }
- return delete _this2.limiters[channel];
- });
- return function (_x) {
- return _ref.apply(this, arguments);
- };
- }()));
- }
- __scriptArgs__(name, id, args, cb) {
- var keys;
- keys = Scripts.keys(name, id);
- return [this.shas[name], keys.length].concat(keys, args, cb);
- }
- __scriptFn__(name) {
- return this.client.evalsha.bind(this.client);
- }
- disconnect(flush = true) {
- var i, k, len, ref;
- ref = Object.keys(this.limiters);
- for (i = 0, len = ref.length; i < len; i++) {
- k = ref[i];
- clearInterval(this.limiters[k]._store.heartbeat);
- }
- this.limiters = {};
- this.terminated = true;
- this.client.end(flush);
- this.subscriber.end(flush);
- return this.Promise.resolve();
- }
- }
- ;
- RedisConnection.prototype.datastore = "redis";
- RedisConnection.prototype.defaults = {
- Redis: null,
- clientOptions: {},
- client: null,
- Promise: Promise,
- Events: null
- };
- return RedisConnection;
- }.call(void 0);
- module.exports = RedisConnection;
- /***/ }),
- /***/ 36220:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var BottleneckError, IORedisConnection, RedisConnection, RedisDatastore, parser;
- parser = __webpack_require__(88092);
- BottleneckError = __webpack_require__(34006);
- RedisConnection = __webpack_require__(66427);
- IORedisConnection = __webpack_require__(9442);
- RedisDatastore = class RedisDatastore {
- constructor(instance, storeOptions, storeInstanceOptions) {
- this.instance = instance;
- this.storeOptions = storeOptions;
- this.originalId = this.instance.id;
- this.clientId = this.instance._randomIndex();
- parser.load(storeInstanceOptions, storeInstanceOptions, this);
- this.clients = {};
- this.capacityPriorityCounters = {};
- this.sharedConnection = this.connection != null;
- if (this.connection == null) {
- this.connection = this.instance.datastore === "redis" ? new RedisConnection({
- Redis: this.Redis,
- clientOptions: this.clientOptions,
- Promise: this.Promise,
- Events: this.instance.Events
- }) : this.instance.datastore === "ioredis" ? new IORedisConnection({
- Redis: this.Redis,
- clientOptions: this.clientOptions,
- clusterNodes: this.clusterNodes,
- Promise: this.Promise,
- Events: this.instance.Events
- }) : void 0;
- }
- this.instance.connection = this.connection;
- this.instance.datastore = this.connection.datastore;
- this.ready = this.connection.ready.then(clients => {
- this.clients = clients;
- return this.runScript("init", this.prepareInitSettings(this.clearDatastore));
- }).then(() => {
- return this.connection.__addLimiter__(this.instance);
- }).then(() => {
- return this.runScript("register_client", [this.instance.queued()]);
- }).then(() => {
- var base;
- if (typeof (base = this.heartbeat = setInterval(() => {
- return this.runScript("heartbeat", []).catch(e => {
- return this.instance.Events.trigger("error", e);
- });
- }, this.heartbeatInterval)).unref === "function") {
- base.unref();
- }
- return this.clients;
- });
- }
- __publish__(message) {
- var _this = this;
- return _asyncToGenerator(function* () {
- var client;
- var _ref = yield _this.ready;
- client = _ref.client;
- return client.publish(_this.instance.channel(), `message:${message.toString()}`);
- })();
- }
- onMessage(channel, message) {
- var _this2 = this;
- return _asyncToGenerator(function* () {
- var capacity, counter, data, drained, e, newCapacity, pos, priorityClient, rawCapacity, type;
- try {
- pos = message.indexOf(":");
- var _ref2 = [message.slice(0, pos), message.slice(pos + 1)];
- type = _ref2[0];
- data = _ref2[1];
- if (type === "capacity") {
- return yield _this2.instance._drainAll(data.length > 0 ? ~~data : void 0);
- } else if (type === "capacity-priority") {
- var _data$split = data.split(":");
- var _data$split2 = _slicedToArray(_data$split, 3);
- rawCapacity = _data$split2[0];
- priorityClient = _data$split2[1];
- counter = _data$split2[2];
- capacity = rawCapacity.length > 0 ? ~~rawCapacity : void 0;
- if (priorityClient === _this2.clientId) {
- drained = yield _this2.instance._drainAll(capacity);
- newCapacity = capacity != null ? capacity - (drained || 0) : "";
- return yield _this2.clients.client.publish(_this2.instance.channel(), `capacity-priority:${newCapacity}::${counter}`);
- } else if (priorityClient === "") {
- clearTimeout(_this2.capacityPriorityCounters[counter]);
- delete _this2.capacityPriorityCounters[counter];
- return _this2.instance._drainAll(capacity);
- } else {
- return _this2.capacityPriorityCounters[counter] = setTimeout(
- /*#__PURE__*/
- _asyncToGenerator(function* () {
- var e;
- try {
- delete _this2.capacityPriorityCounters[counter];
- yield _this2.runScript("blacklist_client", [priorityClient]);
- return yield _this2.instance._drainAll(capacity);
- } catch (error) {
- e = error;
- return _this2.instance.Events.trigger("error", e);
- }
- }), 1000);
- }
- } else if (type === "message") {
- return _this2.instance.Events.trigger("message", data);
- } else if (type === "blocked") {
- return yield _this2.instance._dropAllQueued();
- }
- } catch (error) {
- e = error;
- return _this2.instance.Events.trigger("error", e);
- }
- })();
- }
- __disconnect__(flush) {
- clearInterval(this.heartbeat);
- if (this.sharedConnection) {
- return this.connection.__removeLimiter__(this.instance);
- } else {
- return this.connection.disconnect(flush);
- }
- }
- runScript(name, args) {
- var _this3 = this;
- return _asyncToGenerator(function* () {
- if (!(name === "init" || name === "register_client")) {
- yield _this3.ready;
- }
- return new _this3.Promise((resolve, reject) => {
- var all_args, arr;
- all_args = [Date.now(), _this3.clientId].concat(args);
- _this3.instance.Events.trigger("debug", `Calling Redis script: ${name}.lua`, all_args);
- arr = _this3.connection.__scriptArgs__(name, _this3.originalId, all_args, function (err, replies) {
- if (err != null) {
- return reject(err);
- }
- return resolve(replies);
- });
- return _this3.connection.__scriptFn__(name)(...arr);
- }).catch(e => {
- if (e.message === "SETTINGS_KEY_NOT_FOUND") {
- if (name === "heartbeat") {
- return _this3.Promise.resolve();
- } else {
- return _this3.runScript("init", _this3.prepareInitSettings(false)).then(() => {
- return _this3.runScript(name, args);
- });
- }
- } else if (e.message === "UNKNOWN_CLIENT") {
- return _this3.runScript("register_client", [_this3.instance.queued()]).then(() => {
- return _this3.runScript(name, args);
- });
- } else {
- return _this3.Promise.reject(e);
- }
- });
- })();
- }
- prepareArray(arr) {
- var i, len, results, x;
- results = [];
- for (i = 0, len = arr.length; i < len; i++) {
- x = arr[i];
- results.push(x != null ? x.toString() : "");
- }
- return results;
- }
- prepareObject(obj) {
- var arr, k, v;
- arr = [];
- for (k in obj) {
- v = obj[k];
- arr.push(k, v != null ? v.toString() : "");
- }
- return arr;
- }
- prepareInitSettings(clear) {
- var args;
- args = this.prepareObject(Object.assign({}, this.storeOptions, {
- id: this.originalId,
- version: this.instance.version,
- groupTimeout: this.timeout,
- clientTimeout: this.clientTimeout
- }));
- args.unshift(clear ? 1 : 0, this.instance.version);
- return args;
- }
- convertBool(b) {
- return !!b;
- }
- __updateSettings__(options) {
- var _this4 = this;
- return _asyncToGenerator(function* () {
- yield _this4.runScript("update_settings", _this4.prepareObject(options));
- return parser.overwrite(options, options, _this4.storeOptions);
- })();
- }
- __running__() {
- return this.runScript("running", []);
- }
- __queued__() {
- return this.runScript("queued", []);
- }
- __done__() {
- return this.runScript("done", []);
- }
- __groupCheck__() {
- var _this5 = this;
- return _asyncToGenerator(function* () {
- return _this5.convertBool((yield _this5.runScript("group_check", [])));
- })();
- }
- __incrementReservoir__(incr) {
- return this.runScript("increment_reservoir", [incr]);
- }
- __currentReservoir__() {
- return this.runScript("current_reservoir", []);
- }
- __check__(weight) {
- var _this6 = this;
- return _asyncToGenerator(function* () {
- return _this6.convertBool((yield _this6.runScript("check", _this6.prepareArray([weight]))));
- })();
- }
- __register__(index, weight, expiration) {
- var _this7 = this;
- return _asyncToGenerator(function* () {
- var reservoir, success, wait;
- var _ref4 = yield _this7.runScript("register", _this7.prepareArray([index, weight, expiration]));
- var _ref5 = _slicedToArray(_ref4, 3);
- success = _ref5[0];
- wait = _ref5[1];
- reservoir = _ref5[2];
- return {
- success: _this7.convertBool(success),
- wait,
- reservoir
- };
- })();
- }
- __submit__(queueLength, weight) {
- var _this8 = this;
- return _asyncToGenerator(function* () {
- var blocked, e, maxConcurrent, overweight, reachedHWM, strategy;
- try {
- var _ref6 = yield _this8.runScript("submit", _this8.prepareArray([queueLength, weight]));
- var _ref7 = _slicedToArray(_ref6, 3);
- reachedHWM = _ref7[0];
- blocked = _ref7[1];
- strategy = _ref7[2];
- return {
- reachedHWM: _this8.convertBool(reachedHWM),
- blocked: _this8.convertBool(blocked),
- strategy
- };
- } catch (error) {
- e = error;
- if (e.message.indexOf("OVERWEIGHT") === 0) {
- var _e$message$split = e.message.split(":");
- var _e$message$split2 = _slicedToArray(_e$message$split, 3);
- overweight = _e$message$split2[0];
- weight = _e$message$split2[1];
- maxConcurrent = _e$message$split2[2];
- throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${maxConcurrent}`);
- } else {
- throw e;
- }
- }
- })();
- }
- __free__(index, weight) {
- var _this9 = this;
- return _asyncToGenerator(function* () {
- var running;
- running = yield _this9.runScript("free", _this9.prepareArray([index]));
- return {
- running
- };
- })();
- }
- };
- module.exports = RedisDatastore;
- /***/ }),
- /***/ 40812:
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- var headers, lua, templates;
- lua = __webpack_require__(31936);
- headers = {
- refs: lua["refs.lua"],
- validate_keys: lua["validate_keys.lua"],
- validate_client: lua["validate_client.lua"],
- refresh_expiration: lua["refresh_expiration.lua"],
- process_tick: lua["process_tick.lua"],
- conditions_check: lua["conditions_check.lua"],
- get_time: lua["get_time.lua"]
- };
- exports.allKeys = function (id) {
- return [
- /*
- HASH
- */
- `b_${id}_settings`,
- /*
- HASH
- job index -> weight
- */
- `b_${id}_job_weights`,
- /*
- ZSET
- job index -> expiration
- */
- `b_${id}_job_expirations`,
- /*
- HASH
- job index -> client
- */
- `b_${id}_job_clients`,
- /*
- ZSET
- client -> sum running
- */
- `b_${id}_client_running`,
- /*
- HASH
- client -> num queued
- */
- `b_${id}_client_num_queued`,
- /*
- ZSET
- client -> last job registered
- */
- `b_${id}_client_last_registered`,
- /*
- ZSET
- client -> last seen
- */
- `b_${id}_client_last_seen`];
- };
- templates = {
- init: {
- keys: exports.allKeys,
- headers: ["process_tick"],
- refresh_expiration: true,
- code: lua["init.lua"]
- },
- group_check: {
- keys: exports.allKeys,
- headers: [],
- refresh_expiration: false,
- code: lua["group_check.lua"]
- },
- register_client: {
- keys: exports.allKeys,
- headers: ["validate_keys"],
- refresh_expiration: false,
- code: lua["register_client.lua"]
- },
- blacklist_client: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client"],
- refresh_expiration: false,
- code: lua["blacklist_client.lua"]
- },
- heartbeat: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: false,
- code: lua["heartbeat.lua"]
- },
- update_settings: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: true,
- code: lua["update_settings.lua"]
- },
- running: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: false,
- code: lua["running.lua"]
- },
- queued: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client"],
- refresh_expiration: false,
- code: lua["queued.lua"]
- },
- done: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: false,
- code: lua["done.lua"]
- },
- check: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
- refresh_expiration: false,
- code: lua["check.lua"]
- },
- submit: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
- refresh_expiration: true,
- code: lua["submit.lua"]
- },
- register: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"],
- refresh_expiration: true,
- code: lua["register.lua"]
- },
- free: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: true,
- code: lua["free.lua"]
- },
- current_reservoir: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: false,
- code: lua["current_reservoir.lua"]
- },
- increment_reservoir: {
- keys: exports.allKeys,
- headers: ["validate_keys", "validate_client", "process_tick"],
- refresh_expiration: true,
- code: lua["increment_reservoir.lua"]
- }
- };
- exports.names = Object.keys(templates);
- exports.keys = function (name, id) {
- return templates[name].keys(id);
- };
- exports.payload = function (name) {
- var template;
- template = templates[name];
- return Array.prototype.concat(headers.refs, template.headers.map(function (h) {
- return headers[h];
- }), template.refresh_expiration ? headers.refresh_expiration : "", template.code).join("\n");
- };
- /***/ }),
- /***/ 65376:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- var BottleneckError, States;
- BottleneckError = __webpack_require__(34006);
- States = class States {
- constructor(status1) {
- this.status = status1;
- this._jobs = {};
- this.counts = this.status.map(function () {
- return 0;
- });
- }
- next(id) {
- var current, next;
- current = this._jobs[id];
- next = current + 1;
- if (current != null && next < this.status.length) {
- this.counts[current]--;
- this.counts[next]++;
- return this._jobs[id]++;
- } else if (current != null) {
- this.counts[current]--;
- return delete this._jobs[id];
- }
- }
- start(id) {
- var initial;
- initial = 0;
- this._jobs[id] = initial;
- return this.counts[initial]++;
- }
- remove(id) {
- var current;
- current = this._jobs[id];
- if (current != null) {
- this.counts[current]--;
- delete this._jobs[id];
- }
- return current != null;
- }
- jobStatus(id) {
- var ref;
- return (ref = this.status[this._jobs[id]]) != null ? ref : null;
- }
- statusJobs(status) {
- var k, pos, ref, results, v;
- if (status != null) {
- pos = this.status.indexOf(status);
- if (pos < 0) {
- throw new BottleneckError(`status must be one of ${this.status.join(', ')}`);
- }
- ref = this._jobs;
- results = [];
- for (k in ref) {
- v = ref[k];
- if (v === pos) {
- results.push(k);
- }
- }
- return results;
- } else {
- return Object.keys(this._jobs);
- }
- }
- statusCounts() {
- return this.counts.reduce((acc, v, i) => {
- acc[this.status[i]] = v;
- return acc;
- }, {});
- }
- };
- module.exports = States;
- /***/ }),
- /***/ 64915:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
- var DLList, Sync;
- DLList = __webpack_require__(70938);
- Sync = class Sync {
- constructor(name, Promise) {
- this.schedule = this.schedule.bind(this);
- this.name = name;
- this.Promise = Promise;
- this._running = 0;
- this._queue = new DLList();
- }
- isEmpty() {
- return this._queue.length === 0;
- }
- _tryToRun() {
- var _this = this;
- return _asyncToGenerator(function* () {
- var args, cb, error, reject, resolve, returned, task;
- if (_this._running < 1 && _this._queue.length > 0) {
- _this._running++;
- var _this$_queue$shift = _this._queue.shift();
- task = _this$_queue$shift.task;
- args = _this$_queue$shift.args;
- resolve = _this$_queue$shift.resolve;
- reject = _this$_queue$shift.reject;
- cb = yield _asyncToGenerator(function* () {
- try {
- returned = yield task(...args);
- return function () {
- return resolve(returned);
- };
- } catch (error1) {
- error = error1;
- return function () {
- return reject(error);
- };
- }
- })();
- _this._running--;
- _this._tryToRun();
- return cb();
- }
- })();
- }
- schedule(task, ...args) {
- var promise, reject, resolve;
- resolve = reject = null;
- promise = new this.Promise(function (_resolve, _reject) {
- resolve = _resolve;
- return reject = _reject;
- });
- this._queue.push({
- task,
- args,
- resolve,
- reject
- });
- this._tryToRun();
- return promise;
- }
- };
- module.exports = Sync;
- /***/ }),
- /***/ 35861:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- module.exports = __webpack_require__(19529);
- /***/ }),
- /***/ 88092:
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- exports.load = function (received, defaults, onto = {}) {
- var k, ref, v;
- for (k in defaults) {
- v = defaults[k];
- onto[k] = (ref = received[k]) != null ? ref : v;
- }
- return onto;
- };
- exports.overwrite = function (received, defaults, onto = {}) {
- var k, v;
- for (k in received) {
- v = received[k];
- if (defaults[k] !== void 0) {
- onto[k] = v;
- }
- }
- return onto;
- };
- /***/ }),
- /***/ 76158:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- /* module decorator */ module = __webpack_require__.nmd(module);
- const wrapAnsi16 = (fn, offset) => (...args) => {
- const code = fn(...args);
- return `\u001B[${code + offset}m`;
- };
- const wrapAnsi256 = (fn, offset) => (...args) => {
- const code = fn(...args);
- return `\u001B[${38 + offset};5;${code}m`;
- };
- const wrapAnsi16m = (fn, offset) => (...args) => {
- const rgb = fn(...args);
- return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
- };
- const ansi2ansi = n => n;
- const rgb2rgb = (r, g, b) => [r, g, b];
- const setLazyProperty = (object, property, get) => {
- Object.defineProperty(object, property, {
- get: () => {
- const value = get();
- Object.defineProperty(object, property, {
- value,
- enumerable: true,
- configurable: true
- });
- return value;
- },
- enumerable: true,
- configurable: true
- });
- };
- /** @type {typeof import('color-convert')} */
- let colorConvert;
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
- if (colorConvert === undefined) {
- colorConvert = __webpack_require__(91497);
- }
- const offset = isBackground ? 10 : 0;
- const styles = {};
- for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
- const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
- if (sourceSpace === targetSpace) {
- styles[name] = wrap(identity, offset);
- } else if (typeof suite === 'object') {
- styles[name] = wrap(suite[targetSpace], offset);
- }
- }
- return styles;
- };
- function assembleStyles() {
- const codes = new Map();
- const styles = {
- modifier: {
- reset: [0, 0],
- // 21 isn't widely supported and 22 does the same thing
- bold: [1, 22],
- dim: [2, 22],
- italic: [3, 23],
- underline: [4, 24],
- inverse: [7, 27],
- hidden: [8, 28],
- strikethrough: [9, 29]
- },
- color: {
- black: [30, 39],
- red: [31, 39],
- green: [32, 39],
- yellow: [33, 39],
- blue: [34, 39],
- magenta: [35, 39],
- cyan: [36, 39],
- white: [37, 39],
- // Bright color
- blackBright: [90, 39],
- redBright: [91, 39],
- greenBright: [92, 39],
- yellowBright: [93, 39],
- blueBright: [94, 39],
- magentaBright: [95, 39],
- cyanBright: [96, 39],
- whiteBright: [97, 39]
- },
- bgColor: {
- bgBlack: [40, 49],
- bgRed: [41, 49],
- bgGreen: [42, 49],
- bgYellow: [43, 49],
- bgBlue: [44, 49],
- bgMagenta: [45, 49],
- bgCyan: [46, 49],
- bgWhite: [47, 49],
- // Bright color
- bgBlackBright: [100, 49],
- bgRedBright: [101, 49],
- bgGreenBright: [102, 49],
- bgYellowBright: [103, 49],
- bgBlueBright: [104, 49],
- bgMagentaBright: [105, 49],
- bgCyanBright: [106, 49],
- bgWhiteBright: [107, 49]
- }
- };
- // Alias bright black as gray (and grey)
- styles.color.gray = styles.color.blackBright;
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
- styles.color.grey = styles.color.blackBright;
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
- for (const [groupName, group] of Object.entries(styles)) {
- for (const [styleName, style] of Object.entries(group)) {
- styles[styleName] = {
- open: `\u001B[${style[0]}m`,
- close: `\u001B[${style[1]}m`
- };
- group[styleName] = styles[styleName];
- codes.set(style[0], style[1]);
- }
- Object.defineProperty(styles, groupName, {
- value: group,
- enumerable: false
- });
- }
- Object.defineProperty(styles, 'codes', {
- value: codes,
- enumerable: false
- });
- styles.color.close = '\u001B[39m';
- styles.bgColor.close = '\u001B[49m';
- setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
- setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
- setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
- setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
- setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
- setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
- return styles;
- }
- // Make the export immutable
- Object.defineProperty(module, 'exports', {
- enumerable: true,
- get: assembleStyles
- });
- /***/ }),
- /***/ 98250:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const ansiStyles = __webpack_require__(76158);
- const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(8442);
- const {
- stringReplaceAll,
- stringEncaseCRLFWithFirstIndex
- } = __webpack_require__(45173);
- const {isArray} = Array;
- // `supportsColor.level` → `ansiStyles.color[name]` mapping
- const levelMapping = [
- 'ansi',
- 'ansi',
- 'ansi256',
- 'ansi16m'
- ];
- const styles = Object.create(null);
- const applyOptions = (object, options = {}) => {
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
- throw new Error('The `level` option should be an integer from 0 to 3');
- }
- // Detect level if not set manually
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
- object.level = options.level === undefined ? colorLevel : options.level;
- };
- class ChalkClass {
- constructor(options) {
- // eslint-disable-next-line no-constructor-return
- return chalkFactory(options);
- }
- }
- const chalkFactory = options => {
- const chalk = {};
- applyOptions(chalk, options);
- chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
- Object.setPrototypeOf(chalk, Chalk.prototype);
- Object.setPrototypeOf(chalk.template, chalk);
- chalk.template.constructor = () => {
- throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
- };
- chalk.template.Instance = ChalkClass;
- return chalk.template;
- };
- function Chalk(options) {
- return chalkFactory(options);
- }
- for (const [styleName, style] of Object.entries(ansiStyles)) {
- styles[styleName] = {
- get() {
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
- Object.defineProperty(this, styleName, {value: builder});
- return builder;
- }
- };
- }
- styles.visible = {
- get() {
- const builder = createBuilder(this, this._styler, true);
- Object.defineProperty(this, 'visible', {value: builder});
- return builder;
- }
- };
- const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
- for (const model of usedModels) {
- styles[model] = {
- get() {
- const {level} = this;
- return function (...arguments_) {
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
- return createBuilder(this, styler, this._isEmpty);
- };
- }
- };
- }
- for (const model of usedModels) {
- const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
- styles[bgModel] = {
- get() {
- const {level} = this;
- return function (...arguments_) {
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
- return createBuilder(this, styler, this._isEmpty);
- };
- }
- };
- }
- const proto = Object.defineProperties(() => {}, {
- ...styles,
- level: {
- enumerable: true,
- get() {
- return this._generator.level;
- },
- set(level) {
- this._generator.level = level;
- }
- }
- });
- const createStyler = (open, close, parent) => {
- let openAll;
- let closeAll;
- if (parent === undefined) {
- openAll = open;
- closeAll = close;
- } else {
- openAll = parent.openAll + open;
- closeAll = close + parent.closeAll;
- }
- return {
- open,
- close,
- openAll,
- closeAll,
- parent
- };
- };
- const createBuilder = (self, _styler, _isEmpty) => {
- const builder = (...arguments_) => {
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
- // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
- return applyStyle(builder, chalkTag(builder, ...arguments_));
- }
- // Single argument is hot path, implicit coercion is faster than anything
- // eslint-disable-next-line no-implicit-coercion
- return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
- };
- // We alter the prototype because we must return a function, but there is
- // no way to create a function with a different prototype
- Object.setPrototypeOf(builder, proto);
- builder._generator = self;
- builder._styler = _styler;
- builder._isEmpty = _isEmpty;
- return builder;
- };
- const applyStyle = (self, string) => {
- if (self.level <= 0 || !string) {
- return self._isEmpty ? '' : string;
- }
- let styler = self._styler;
- if (styler === undefined) {
- return string;
- }
- const {openAll, closeAll} = styler;
- if (string.indexOf('\u001B') !== -1) {
- while (styler !== undefined) {
- // Replace any instances already present with a re-opening code
- // otherwise only the part of the string until said closing code
- // will be colored, and the rest will simply be 'plain'.
- string = stringReplaceAll(string, styler.close, styler.open);
- styler = styler.parent;
- }
- }
- // We can move both next actions out of loop, because remaining actions in loop won't have
- // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
- // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
- const lfIndex = string.indexOf('\n');
- if (lfIndex !== -1) {
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
- }
- return openAll + string + closeAll;
- };
- let template;
- const chalkTag = (chalk, ...strings) => {
- const [firstString] = strings;
- if (!isArray(firstString) || !isArray(firstString.raw)) {
- // If chalk() was called by itself or with a string,
- // return the string itself as a string.
- return strings.join(' ');
- }
- const arguments_ = strings.slice(1);
- const parts = [firstString.raw[0]];
- for (let i = 1; i < firstString.length; i++) {
- parts.push(
- String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
- String(firstString.raw[i])
- );
- }
- if (template === undefined) {
- template = __webpack_require__(68452);
- }
- return template(chalk, parts.join(''));
- };
- Object.defineProperties(Chalk.prototype, styles);
- const chalk = Chalk(); // eslint-disable-line new-cap
- chalk.supportsColor = stdoutColor;
- chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
- chalk.stderr.supportsColor = stderrColor;
- module.exports = chalk;
- /***/ }),
- /***/ 68452:
- /***/ ((module) => {
- "use strict";
- const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
- const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
- const ESCAPES = new Map([
- ['n', '\n'],
- ['r', '\r'],
- ['t', '\t'],
- ['b', '\b'],
- ['f', '\f'],
- ['v', '\v'],
- ['0', '\0'],
- ['\\', '\\'],
- ['e', '\u001B'],
- ['a', '\u0007']
- ]);
- function unescape(c) {
- const u = c[0] === 'u';
- const bracket = c[1] === '{';
- if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
- return String.fromCharCode(parseInt(c.slice(1), 16));
- }
- if (u && bracket) {
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
- }
- return ESCAPES.get(c) || c;
- }
- function parseArguments(name, arguments_) {
- const results = [];
- const chunks = arguments_.trim().split(/\s*,\s*/g);
- let matches;
- for (const chunk of chunks) {
- const number = Number(chunk);
- if (!Number.isNaN(number)) {
- results.push(number);
- } else if ((matches = chunk.match(STRING_REGEX))) {
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
- } else {
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
- }
- }
- return results;
- }
- function parseStyle(style) {
- STYLE_REGEX.lastIndex = 0;
- const results = [];
- let matches;
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
- const name = matches[1];
- if (matches[2]) {
- const args = parseArguments(name, matches[2]);
- results.push([name].concat(args));
- } else {
- results.push([name]);
- }
- }
- return results;
- }
- function buildStyle(chalk, styles) {
- const enabled = {};
- for (const layer of styles) {
- for (const style of layer.styles) {
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
- }
- }
- let current = chalk;
- for (const [styleName, styles] of Object.entries(enabled)) {
- if (!Array.isArray(styles)) {
- continue;
- }
- if (!(styleName in current)) {
- throw new Error(`Unknown Chalk style: ${styleName}`);
- }
- current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
- }
- return current;
- }
- module.exports = (chalk, temporary) => {
- const styles = [];
- const chunks = [];
- let chunk = [];
- // eslint-disable-next-line max-params
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
- if (escapeCharacter) {
- chunk.push(unescape(escapeCharacter));
- } else if (style) {
- const string = chunk.join('');
- chunk = [];
- chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
- styles.push({inverse, styles: parseStyle(style)});
- } else if (close) {
- if (styles.length === 0) {
- throw new Error('Found extraneous } in Chalk template literal');
- }
- chunks.push(buildStyle(chalk, styles)(chunk.join('')));
- chunk = [];
- styles.pop();
- } else {
- chunk.push(character);
- }
- });
- chunks.push(chunk.join(''));
- if (styles.length > 0) {
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
- throw new Error(errMessage);
- }
- return chunks.join('');
- };
- /***/ }),
- /***/ 45173:
- /***/ ((module) => {
- "use strict";
- const stringReplaceAll = (string, substring, replacer) => {
- let index = string.indexOf(substring);
- if (index === -1) {
- return string;
- }
- const substringLength = substring.length;
- let endIndex = 0;
- let returnValue = '';
- do {
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
- endIndex = index + substringLength;
- index = string.indexOf(substring, endIndex);
- } while (index !== -1);
- returnValue += string.substr(endIndex);
- return returnValue;
- };
- const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
- let endIndex = 0;
- let returnValue = '';
- do {
- const gotCR = string[index - 1] === '\r';
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
- endIndex = index + 1;
- index = string.indexOf('\n', endIndex);
- } while (index !== -1);
- returnValue += string.substr(endIndex);
- return returnValue;
- };
- module.exports = {
- stringReplaceAll,
- stringEncaseCRLFWithFirstIndex
- };
- /***/ }),
- /***/ 53302:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- /* MIT license */
- /* eslint-disable no-mixed-operators */
- const cssKeywords = __webpack_require__(65460);
- // NOTE: conversions should only return primitive values (i.e. arrays, or
- // values that give correct `typeof` results).
- // do not use box values types (i.e. Number(), String(), etc.)
- const reverseKeywords = {};
- for (const key of Object.keys(cssKeywords)) {
- reverseKeywords[cssKeywords[key]] = key;
- }
- const convert = {
- rgb: {channels: 3, labels: 'rgb'},
- hsl: {channels: 3, labels: 'hsl'},
- hsv: {channels: 3, labels: 'hsv'},
- hwb: {channels: 3, labels: 'hwb'},
- cmyk: {channels: 4, labels: 'cmyk'},
- xyz: {channels: 3, labels: 'xyz'},
- lab: {channels: 3, labels: 'lab'},
- lch: {channels: 3, labels: 'lch'},
- hex: {channels: 1, labels: ['hex']},
- keyword: {channels: 1, labels: ['keyword']},
- ansi16: {channels: 1, labels: ['ansi16']},
- ansi256: {channels: 1, labels: ['ansi256']},
- hcg: {channels: 3, labels: ['h', 'c', 'g']},
- apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
- gray: {channels: 1, labels: ['gray']}
- };
- module.exports = convert;
- // Hide .channels and .labels properties
- for (const model of Object.keys(convert)) {
- if (!('channels' in convert[model])) {
- throw new Error('missing channels property: ' + model);
- }
- if (!('labels' in convert[model])) {
- throw new Error('missing channel labels property: ' + model);
- }
- if (convert[model].labels.length !== convert[model].channels) {
- throw new Error('channel and label counts mismatch: ' + model);
- }
- const {channels, labels} = convert[model];
- delete convert[model].channels;
- delete convert[model].labels;
- Object.defineProperty(convert[model], 'channels', {value: channels});
- Object.defineProperty(convert[model], 'labels', {value: labels});
- }
- convert.rgb.hsl = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const min = Math.min(r, g, b);
- const max = Math.max(r, g, b);
- const delta = max - min;
- let h;
- let s;
- if (max === min) {
- h = 0;
- } else if (r === max) {
- h = (g - b) / delta;
- } else if (g === max) {
- h = 2 + (b - r) / delta;
- } else if (b === max) {
- h = 4 + (r - g) / delta;
- }
- h = Math.min(h * 60, 360);
- if (h < 0) {
- h += 360;
- }
- const l = (min + max) / 2;
- if (max === min) {
- s = 0;
- } else if (l <= 0.5) {
- s = delta / (max + min);
- } else {
- s = delta / (2 - max - min);
- }
- return [h, s * 100, l * 100];
- };
- convert.rgb.hsv = function (rgb) {
- let rdif;
- let gdif;
- let bdif;
- let h;
- let s;
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const v = Math.max(r, g, b);
- const diff = v - Math.min(r, g, b);
- const diffc = function (c) {
- return (v - c) / 6 / diff + 1 / 2;
- };
- if (diff === 0) {
- h = 0;
- s = 0;
- } else {
- s = diff / v;
- rdif = diffc(r);
- gdif = diffc(g);
- bdif = diffc(b);
- if (r === v) {
- h = bdif - gdif;
- } else if (g === v) {
- h = (1 / 3) + rdif - bdif;
- } else if (b === v) {
- h = (2 / 3) + gdif - rdif;
- }
- if (h < 0) {
- h += 1;
- } else if (h > 1) {
- h -= 1;
- }
- }
- return [
- h * 360,
- s * 100,
- v * 100
- ];
- };
- convert.rgb.hwb = function (rgb) {
- const r = rgb[0];
- const g = rgb[1];
- let b = rgb[2];
- const h = convert.rgb.hsl(rgb)[0];
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
- return [h, w * 100, b * 100];
- };
- convert.rgb.cmyk = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const k = Math.min(1 - r, 1 - g, 1 - b);
- const c = (1 - r - k) / (1 - k) || 0;
- const m = (1 - g - k) / (1 - k) || 0;
- const y = (1 - b - k) / (1 - k) || 0;
- return [c * 100, m * 100, y * 100, k * 100];
- };
- function comparativeDistance(x, y) {
- /*
- See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
- */
- return (
- ((x[0] - y[0]) ** 2) +
- ((x[1] - y[1]) ** 2) +
- ((x[2] - y[2]) ** 2)
- );
- }
- convert.rgb.keyword = function (rgb) {
- const reversed = reverseKeywords[rgb];
- if (reversed) {
- return reversed;
- }
- let currentClosestDistance = Infinity;
- let currentClosestKeyword;
- for (const keyword of Object.keys(cssKeywords)) {
- const value = cssKeywords[keyword];
- // Compute comparative distance
- const distance = comparativeDistance(rgb, value);
- // Check if its less, if so set as closest
- if (distance < currentClosestDistance) {
- currentClosestDistance = distance;
- currentClosestKeyword = keyword;
- }
- }
- return currentClosestKeyword;
- };
- convert.keyword.rgb = function (keyword) {
- return cssKeywords[keyword];
- };
- convert.rgb.xyz = function (rgb) {
- let r = rgb[0] / 255;
- let g = rgb[1] / 255;
- let b = rgb[2] / 255;
- // Assume sRGB
- r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
- g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
- b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
- const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
- const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
- const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
- return [x * 100, y * 100, z * 100];
- };
- convert.rgb.lab = function (rgb) {
- const xyz = convert.rgb.xyz(rgb);
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
- x /= 95.047;
- y /= 100;
- z /= 108.883;
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
- return [l, a, b];
- };
- convert.hsl.rgb = function (hsl) {
- const h = hsl[0] / 360;
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
- let t2;
- let t3;
- let val;
- if (s === 0) {
- val = l * 255;
- return [val, val, val];
- }
- if (l < 0.5) {
- t2 = l * (1 + s);
- } else {
- t2 = l + s - l * s;
- }
- const t1 = 2 * l - t2;
- const rgb = [0, 0, 0];
- for (let i = 0; i < 3; i++) {
- t3 = h + 1 / 3 * -(i - 1);
- if (t3 < 0) {
- t3++;
- }
- if (t3 > 1) {
- t3--;
- }
- if (6 * t3 < 1) {
- val = t1 + (t2 - t1) * 6 * t3;
- } else if (2 * t3 < 1) {
- val = t2;
- } else if (3 * t3 < 2) {
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
- } else {
- val = t1;
- }
- rgb[i] = val * 255;
- }
- return rgb;
- };
- convert.hsl.hsv = function (hsl) {
- const h = hsl[0];
- let s = hsl[1] / 100;
- let l = hsl[2] / 100;
- let smin = s;
- const lmin = Math.max(l, 0.01);
- l *= 2;
- s *= (l <= 1) ? l : 2 - l;
- smin *= lmin <= 1 ? lmin : 2 - lmin;
- const v = (l + s) / 2;
- const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
- return [h, sv * 100, v * 100];
- };
- convert.hsv.rgb = function (hsv) {
- const h = hsv[0] / 60;
- const s = hsv[1] / 100;
- let v = hsv[2] / 100;
- const hi = Math.floor(h) % 6;
- const f = h - Math.floor(h);
- const p = 255 * v * (1 - s);
- const q = 255 * v * (1 - (s * f));
- const t = 255 * v * (1 - (s * (1 - f)));
- v *= 255;
- switch (hi) {
- case 0:
- return [v, t, p];
- case 1:
- return [q, v, p];
- case 2:
- return [p, v, t];
- case 3:
- return [p, q, v];
- case 4:
- return [t, p, v];
- case 5:
- return [v, p, q];
- }
- };
- convert.hsv.hsl = function (hsv) {
- const h = hsv[0];
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
- const vmin = Math.max(v, 0.01);
- let sl;
- let l;
- l = (2 - s) * v;
- const lmin = (2 - s) * vmin;
- sl = s * vmin;
- sl /= (lmin <= 1) ? lmin : 2 - lmin;
- sl = sl || 0;
- l /= 2;
- return [h, sl * 100, l * 100];
- };
- // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
- convert.hwb.rgb = function (hwb) {
- const h = hwb[0] / 360;
- let wh = hwb[1] / 100;
- let bl = hwb[2] / 100;
- const ratio = wh + bl;
- let f;
- // Wh + bl cant be > 1
- if (ratio > 1) {
- wh /= ratio;
- bl /= ratio;
- }
- const i = Math.floor(6 * h);
- const v = 1 - bl;
- f = 6 * h - i;
- if ((i & 0x01) !== 0) {
- f = 1 - f;
- }
- const n = wh + f * (v - wh); // Linear interpolation
- let r;
- let g;
- let b;
- /* eslint-disable max-statements-per-line,no-multi-spaces */
- switch (i) {
- default:
- case 6:
- case 0: r = v; g = n; b = wh; break;
- case 1: r = n; g = v; b = wh; break;
- case 2: r = wh; g = v; b = n; break;
- case 3: r = wh; g = n; b = v; break;
- case 4: r = n; g = wh; b = v; break;
- case 5: r = v; g = wh; b = n; break;
- }
- /* eslint-enable max-statements-per-line,no-multi-spaces */
- return [r * 255, g * 255, b * 255];
- };
- convert.cmyk.rgb = function (cmyk) {
- const c = cmyk[0] / 100;
- const m = cmyk[1] / 100;
- const y = cmyk[2] / 100;
- const k = cmyk[3] / 100;
- const r = 1 - Math.min(1, c * (1 - k) + k);
- const g = 1 - Math.min(1, m * (1 - k) + k);
- const b = 1 - Math.min(1, y * (1 - k) + k);
- return [r * 255, g * 255, b * 255];
- };
- convert.xyz.rgb = function (xyz) {
- const x = xyz[0] / 100;
- const y = xyz[1] / 100;
- const z = xyz[2] / 100;
- let r;
- let g;
- let b;
- r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
- g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
- b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
- // Assume sRGB
- r = r > 0.0031308
- ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
- : r * 12.92;
- g = g > 0.0031308
- ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
- : g * 12.92;
- b = b > 0.0031308
- ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
- : b * 12.92;
- r = Math.min(Math.max(0, r), 1);
- g = Math.min(Math.max(0, g), 1);
- b = Math.min(Math.max(0, b), 1);
- return [r * 255, g * 255, b * 255];
- };
- convert.xyz.lab = function (xyz) {
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
- x /= 95.047;
- y /= 100;
- z /= 108.883;
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
- return [l, a, b];
- };
- convert.lab.xyz = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let x;
- let y;
- let z;
- y = (l + 16) / 116;
- x = a / 500 + y;
- z = y - b / 200;
- const y2 = y ** 3;
- const x2 = x ** 3;
- const z2 = z ** 3;
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
- x *= 95.047;
- y *= 100;
- z *= 108.883;
- return [x, y, z];
- };
- convert.lab.lch = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let h;
- const hr = Math.atan2(b, a);
- h = hr * 360 / 2 / Math.PI;
- if (h < 0) {
- h += 360;
- }
- const c = Math.sqrt(a * a + b * b);
- return [l, c, h];
- };
- convert.lch.lab = function (lch) {
- const l = lch[0];
- const c = lch[1];
- const h = lch[2];
- const hr = h / 360 * 2 * Math.PI;
- const a = c * Math.cos(hr);
- const b = c * Math.sin(hr);
- return [l, a, b];
- };
- convert.rgb.ansi16 = function (args, saturation = null) {
- const [r, g, b] = args;
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
- value = Math.round(value / 50);
- if (value === 0) {
- return 30;
- }
- let ansi = 30
- + ((Math.round(b / 255) << 2)
- | (Math.round(g / 255) << 1)
- | Math.round(r / 255));
- if (value === 2) {
- ansi += 60;
- }
- return ansi;
- };
- convert.hsv.ansi16 = function (args) {
- // Optimization here; we already know the value and don't need to get
- // it converted for us.
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
- };
- convert.rgb.ansi256 = function (args) {
- const r = args[0];
- const g = args[1];
- const b = args[2];
- // We use the extended greyscale palette here, with the exception of
- // black and white. normal palette only has 4 greyscale shades.
- if (r === g && g === b) {
- if (r < 8) {
- return 16;
- }
- if (r > 248) {
- return 231;
- }
- return Math.round(((r - 8) / 247) * 24) + 232;
- }
- const ansi = 16
- + (36 * Math.round(r / 255 * 5))
- + (6 * Math.round(g / 255 * 5))
- + Math.round(b / 255 * 5);
- return ansi;
- };
- convert.ansi16.rgb = function (args) {
- let color = args % 10;
- // Handle greyscale
- if (color === 0 || color === 7) {
- if (args > 50) {
- color += 3.5;
- }
- color = color / 10.5 * 255;
- return [color, color, color];
- }
- const mult = (~~(args > 50) + 1) * 0.5;
- const r = ((color & 1) * mult) * 255;
- const g = (((color >> 1) & 1) * mult) * 255;
- const b = (((color >> 2) & 1) * mult) * 255;
- return [r, g, b];
- };
- convert.ansi256.rgb = function (args) {
- // Handle greyscale
- if (args >= 232) {
- const c = (args - 232) * 10 + 8;
- return [c, c, c];
- }
- args -= 16;
- let rem;
- const r = Math.floor(args / 36) / 5 * 255;
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
- const b = (rem % 6) / 5 * 255;
- return [r, g, b];
- };
- convert.rgb.hex = function (args) {
- const integer = ((Math.round(args[0]) & 0xFF) << 16)
- + ((Math.round(args[1]) & 0xFF) << 8)
- + (Math.round(args[2]) & 0xFF);
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
- convert.hex.rgb = function (args) {
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
- if (!match) {
- return [0, 0, 0];
- }
- let colorString = match[0];
- if (match[0].length === 3) {
- colorString = colorString.split('').map(char => {
- return char + char;
- }).join('');
- }
- const integer = parseInt(colorString, 16);
- const r = (integer >> 16) & 0xFF;
- const g = (integer >> 8) & 0xFF;
- const b = integer & 0xFF;
- return [r, g, b];
- };
- convert.rgb.hcg = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const max = Math.max(Math.max(r, g), b);
- const min = Math.min(Math.min(r, g), b);
- const chroma = (max - min);
- let grayscale;
- let hue;
- if (chroma < 1) {
- grayscale = min / (1 - chroma);
- } else {
- grayscale = 0;
- }
- if (chroma <= 0) {
- hue = 0;
- } else
- if (max === r) {
- hue = ((g - b) / chroma) % 6;
- } else
- if (max === g) {
- hue = 2 + (b - r) / chroma;
- } else {
- hue = 4 + (r - g) / chroma;
- }
- hue /= 6;
- hue %= 1;
- return [hue * 360, chroma * 100, grayscale * 100];
- };
- convert.hsl.hcg = function (hsl) {
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
- const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
- let f = 0;
- if (c < 1.0) {
- f = (l - 0.5 * c) / (1.0 - c);
- }
- return [hsl[0], c * 100, f * 100];
- };
- convert.hsv.hcg = function (hsv) {
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
- const c = s * v;
- let f = 0;
- if (c < 1.0) {
- f = (v - c) / (1 - c);
- }
- return [hsv[0], c * 100, f * 100];
- };
- convert.hcg.rgb = function (hcg) {
- const h = hcg[0] / 360;
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- if (c === 0.0) {
- return [g * 255, g * 255, g * 255];
- }
- const pure = [0, 0, 0];
- const hi = (h % 1) * 6;
- const v = hi % 1;
- const w = 1 - v;
- let mg = 0;
- /* eslint-disable max-statements-per-line */
- switch (Math.floor(hi)) {
- case 0:
- pure[0] = 1; pure[1] = v; pure[2] = 0; break;
- case 1:
- pure[0] = w; pure[1] = 1; pure[2] = 0; break;
- case 2:
- pure[0] = 0; pure[1] = 1; pure[2] = v; break;
- case 3:
- pure[0] = 0; pure[1] = w; pure[2] = 1; break;
- case 4:
- pure[0] = v; pure[1] = 0; pure[2] = 1; break;
- default:
- pure[0] = 1; pure[1] = 0; pure[2] = w;
- }
- /* eslint-enable max-statements-per-line */
- mg = (1.0 - c) * g;
- return [
- (c * pure[0] + mg) * 255,
- (c * pure[1] + mg) * 255,
- (c * pure[2] + mg) * 255
- ];
- };
- convert.hcg.hsv = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const v = c + g * (1.0 - c);
- let f = 0;
- if (v > 0.0) {
- f = c / v;
- }
- return [hcg[0], f * 100, v * 100];
- };
- convert.hcg.hsl = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const l = g * (1.0 - c) + 0.5 * c;
- let s = 0;
- if (l > 0.0 && l < 0.5) {
- s = c / (2 * l);
- } else
- if (l >= 0.5 && l < 1.0) {
- s = c / (2 * (1 - l));
- }
- return [hcg[0], s * 100, l * 100];
- };
- convert.hcg.hwb = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const v = c + g * (1.0 - c);
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
- };
- convert.hwb.hcg = function (hwb) {
- const w = hwb[1] / 100;
- const b = hwb[2] / 100;
- const v = 1 - b;
- const c = v - w;
- let g = 0;
- if (c < 1) {
- g = (v - c) / (1 - c);
- }
- return [hwb[0], c * 100, g * 100];
- };
- convert.apple.rgb = function (apple) {
- return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
- };
- convert.rgb.apple = function (rgb) {
- return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
- };
- convert.gray.rgb = function (args) {
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
- };
- convert.gray.hsl = function (args) {
- return [0, 0, args[0]];
- };
- convert.gray.hsv = convert.gray.hsl;
- convert.gray.hwb = function (gray) {
- return [0, 100, gray[0]];
- };
- convert.gray.cmyk = function (gray) {
- return [0, 0, 0, gray[0]];
- };
- convert.gray.lab = function (gray) {
- return [gray[0], 0, 0];
- };
- convert.gray.hex = function (gray) {
- const val = Math.round(gray[0] / 100 * 255) & 0xFF;
- const integer = (val << 16) + (val << 8) + val;
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
- convert.rgb.gray = function (rgb) {
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
- return [val / 255 * 100];
- };
- /***/ }),
- /***/ 91497:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- const conversions = __webpack_require__(53302);
- const route = __webpack_require__(60091);
- const convert = {};
- const models = Object.keys(conversions);
- function wrapRaw(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
- if (arg0.length > 1) {
- args = arg0;
- }
- return fn(args);
- };
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
- return wrappedFn;
- }
- function wrapRounded(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
- if (arg0.length > 1) {
- args = arg0;
- }
- const result = fn(args);
- // We're assuming the result is an array here.
- // see notice in conversions.js; don't use box types
- // in conversion functions.
- if (typeof result === 'object') {
- for (let len = result.length, i = 0; i < len; i++) {
- result[i] = Math.round(result[i]);
- }
- }
- return result;
- };
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
- return wrappedFn;
- }
- models.forEach(fromModel => {
- convert[fromModel] = {};
- Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
- Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
- const routes = route(fromModel);
- const routeModels = Object.keys(routes);
- routeModels.forEach(toModel => {
- const fn = routes[toModel];
- convert[fromModel][toModel] = wrapRounded(fn);
- convert[fromModel][toModel].raw = wrapRaw(fn);
- });
- });
- module.exports = convert;
- /***/ }),
- /***/ 60091:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- const conversions = __webpack_require__(53302);
- /*
- This function routes a model to all other models.
- all functions that are routed have a property `.conversion` attached
- to the returned synthetic function. This property is an array
- of strings, each with the steps in between the 'from' and 'to'
- color models (inclusive).
- conversions that are not possible simply are not included.
- */
- function buildGraph() {
- const graph = {};
- // https://jsperf.com/object-keys-vs-for-in-with-closure/3
- const models = Object.keys(conversions);
- for (let len = models.length, i = 0; i < len; i++) {
- graph[models[i]] = {
- // http://jsperf.com/1-vs-infinity
- // micro-opt, but this is simple.
- distance: -1,
- parent: null
- };
- }
- return graph;
- }
- // https://en.wikipedia.org/wiki/Breadth-first_search
- function deriveBFS(fromModel) {
- const graph = buildGraph();
- const queue = [fromModel]; // Unshift -> queue -> pop
- graph[fromModel].distance = 0;
- while (queue.length) {
- const current = queue.pop();
- const adjacents = Object.keys(conversions[current]);
- for (let len = adjacents.length, i = 0; i < len; i++) {
- const adjacent = adjacents[i];
- const node = graph[adjacent];
- if (node.distance === -1) {
- node.distance = graph[current].distance + 1;
- node.parent = current;
- queue.unshift(adjacent);
- }
- }
- }
- return graph;
- }
- function link(from, to) {
- return function (args) {
- return to(from(args));
- };
- }
- function wrapConversion(toModel, graph) {
- const path = [graph[toModel].parent, toModel];
- let fn = conversions[graph[toModel].parent][toModel];
- let cur = graph[toModel].parent;
- while (graph[cur].parent) {
- path.unshift(graph[cur].parent);
- fn = link(conversions[graph[cur].parent][cur], fn);
- cur = graph[cur].parent;
- }
- fn.conversion = path;
- return fn;
- }
- module.exports = function (fromModel) {
- const graph = deriveBFS(fromModel);
- const conversion = {};
- const models = Object.keys(graph);
- for (let len = models.length, i = 0; i < len; i++) {
- const toModel = models[i];
- const node = graph[toModel];
- if (node.parent === null) {
- // No possible conversion, or this node is the source model.
- continue;
- }
- conversion[toModel] = wrapConversion(toModel, graph);
- }
- return conversion;
- };
- /***/ }),
- /***/ 65460:
- /***/ ((module) => {
- "use strict";
- module.exports = {
- "aliceblue": [240, 248, 255],
- "antiquewhite": [250, 235, 215],
- "aqua": [0, 255, 255],
- "aquamarine": [127, 255, 212],
- "azure": [240, 255, 255],
- "beige": [245, 245, 220],
- "bisque": [255, 228, 196],
- "black": [0, 0, 0],
- "blanchedalmond": [255, 235, 205],
- "blue": [0, 0, 255],
- "blueviolet": [138, 43, 226],
- "brown": [165, 42, 42],
- "burlywood": [222, 184, 135],
- "cadetblue": [95, 158, 160],
- "chartreuse": [127, 255, 0],
- "chocolate": [210, 105, 30],
- "coral": [255, 127, 80],
- "cornflowerblue": [100, 149, 237],
- "cornsilk": [255, 248, 220],
- "crimson": [220, 20, 60],
- "cyan": [0, 255, 255],
- "darkblue": [0, 0, 139],
- "darkcyan": [0, 139, 139],
- "darkgoldenrod": [184, 134, 11],
- "darkgray": [169, 169, 169],
- "darkgreen": [0, 100, 0],
- "darkgrey": [169, 169, 169],
- "darkkhaki": [189, 183, 107],
- "darkmagenta": [139, 0, 139],
- "darkolivegreen": [85, 107, 47],
- "darkorange": [255, 140, 0],
- "darkorchid": [153, 50, 204],
- "darkred": [139, 0, 0],
- "darksalmon": [233, 150, 122],
- "darkseagreen": [143, 188, 143],
- "darkslateblue": [72, 61, 139],
- "darkslategray": [47, 79, 79],
- "darkslategrey": [47, 79, 79],
- "darkturquoise": [0, 206, 209],
- "darkviolet": [148, 0, 211],
- "deeppink": [255, 20, 147],
- "deepskyblue": [0, 191, 255],
- "dimgray": [105, 105, 105],
- "dimgrey": [105, 105, 105],
- "dodgerblue": [30, 144, 255],
- "firebrick": [178, 34, 34],
- "floralwhite": [255, 250, 240],
- "forestgreen": [34, 139, 34],
- "fuchsia": [255, 0, 255],
- "gainsboro": [220, 220, 220],
- "ghostwhite": [248, 248, 255],
- "gold": [255, 215, 0],
- "goldenrod": [218, 165, 32],
- "gray": [128, 128, 128],
- "green": [0, 128, 0],
- "greenyellow": [173, 255, 47],
- "grey": [128, 128, 128],
- "honeydew": [240, 255, 240],
- "hotpink": [255, 105, 180],
- "indianred": [205, 92, 92],
- "indigo": [75, 0, 130],
- "ivory": [255, 255, 240],
- "khaki": [240, 230, 140],
- "lavender": [230, 230, 250],
- "lavenderblush": [255, 240, 245],
- "lawngreen": [124, 252, 0],
- "lemonchiffon": [255, 250, 205],
- "lightblue": [173, 216, 230],
- "lightcoral": [240, 128, 128],
- "lightcyan": [224, 255, 255],
- "lightgoldenrodyellow": [250, 250, 210],
- "lightgray": [211, 211, 211],
- "lightgreen": [144, 238, 144],
- "lightgrey": [211, 211, 211],
- "lightpink": [255, 182, 193],
- "lightsalmon": [255, 160, 122],
- "lightseagreen": [32, 178, 170],
- "lightskyblue": [135, 206, 250],
- "lightslategray": [119, 136, 153],
- "lightslategrey": [119, 136, 153],
- "lightsteelblue": [176, 196, 222],
- "lightyellow": [255, 255, 224],
- "lime": [0, 255, 0],
- "limegreen": [50, 205, 50],
- "linen": [250, 240, 230],
- "magenta": [255, 0, 255],
- "maroon": [128, 0, 0],
- "mediumaquamarine": [102, 205, 170],
- "mediumblue": [0, 0, 205],
- "mediumorchid": [186, 85, 211],
- "mediumpurple": [147, 112, 219],
- "mediumseagreen": [60, 179, 113],
- "mediumslateblue": [123, 104, 238],
- "mediumspringgreen": [0, 250, 154],
- "mediumturquoise": [72, 209, 204],
- "mediumvioletred": [199, 21, 133],
- "midnightblue": [25, 25, 112],
- "mintcream": [245, 255, 250],
- "mistyrose": [255, 228, 225],
- "moccasin": [255, 228, 181],
- "navajowhite": [255, 222, 173],
- "navy": [0, 0, 128],
- "oldlace": [253, 245, 230],
- "olive": [128, 128, 0],
- "olivedrab": [107, 142, 35],
- "orange": [255, 165, 0],
- "orangered": [255, 69, 0],
- "orchid": [218, 112, 214],
- "palegoldenrod": [238, 232, 170],
- "palegreen": [152, 251, 152],
- "paleturquoise": [175, 238, 238],
- "palevioletred": [219, 112, 147],
- "papayawhip": [255, 239, 213],
- "peachpuff": [255, 218, 185],
- "peru": [205, 133, 63],
- "pink": [255, 192, 203],
- "plum": [221, 160, 221],
- "powderblue": [176, 224, 230],
- "purple": [128, 0, 128],
- "rebeccapurple": [102, 51, 153],
- "red": [255, 0, 0],
- "rosybrown": [188, 143, 143],
- "royalblue": [65, 105, 225],
- "saddlebrown": [139, 69, 19],
- "salmon": [250, 128, 114],
- "sandybrown": [244, 164, 96],
- "seagreen": [46, 139, 87],
- "seashell": [255, 245, 238],
- "sienna": [160, 82, 45],
- "silver": [192, 192, 192],
- "skyblue": [135, 206, 235],
- "slateblue": [106, 90, 205],
- "slategray": [112, 128, 144],
- "slategrey": [112, 128, 144],
- "snow": [255, 250, 250],
- "springgreen": [0, 255, 127],
- "steelblue": [70, 130, 180],
- "tan": [210, 180, 140],
- "teal": [0, 128, 128],
- "thistle": [216, 191, 216],
- "tomato": [255, 99, 71],
- "turquoise": [64, 224, 208],
- "violet": [238, 130, 238],
- "wheat": [245, 222, 179],
- "white": [255, 255, 255],
- "whitesmoke": [245, 245, 245],
- "yellow": [255, 255, 0],
- "yellowgreen": [154, 205, 50]
- };
- /***/ }),
- /***/ 19835:
- /***/ ((module) => {
- "use strict";
- module.exports = (flag, argv = process.argv) => {
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
- const position = argv.indexOf(prefix + flag);
- const terminatorPosition = argv.indexOf('--');
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
- };
- /***/ }),
- /***/ 54270:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const AggregateError = __webpack_require__(56455);
- module.exports = async (
- iterable,
- mapper,
- {
- concurrency = Infinity,
- stopOnError = true
- } = {}
- ) => {
- return new Promise((resolve, reject) => {
- if (typeof mapper !== 'function') {
- throw new TypeError('Mapper function is required');
- }
- if (!((Number.isSafeInteger(concurrency) || concurrency === Infinity) && concurrency >= 1)) {
- throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
- }
- const result = [];
- const errors = [];
- const iterator = iterable[Symbol.iterator]();
- let isRejected = false;
- let isIterableDone = false;
- let resolvingCount = 0;
- let currentIndex = 0;
- const next = () => {
- if (isRejected) {
- return;
- }
- const nextItem = iterator.next();
- const index = currentIndex;
- currentIndex++;
- if (nextItem.done) {
- isIterableDone = true;
- if (resolvingCount === 0) {
- if (!stopOnError && errors.length !== 0) {
- reject(new AggregateError(errors));
- } else {
- resolve(result);
- }
- }
- return;
- }
- resolvingCount++;
- (async () => {
- try {
- const element = await nextItem.value;
- result[index] = await mapper(element, index);
- resolvingCount--;
- next();
- } catch (error) {
- if (stopOnError) {
- isRejected = true;
- reject(error);
- } else {
- errors.push(error);
- resolvingCount--;
- next();
- }
- }
- })();
- };
- for (let i = 0; i < concurrency; i++) {
- next();
- if (isIterableDone) {
- break;
- }
- }
- });
- };
- /***/ }),
- /***/ 71990:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const ansiRegex = __webpack_require__(14277);
- module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
- /***/ }),
- /***/ 8442:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- "use strict";
- const os = __webpack_require__(12087);
- const tty = __webpack_require__(33867);
- const hasFlag = __webpack_require__(19835);
- const {env} = process;
- let forceColor;
- if (hasFlag('no-color') ||
- hasFlag('no-colors') ||
- hasFlag('color=false') ||
- hasFlag('color=never')) {
- forceColor = 0;
- } else if (hasFlag('color') ||
- hasFlag('colors') ||
- hasFlag('color=true') ||
- hasFlag('color=always')) {
- forceColor = 1;
- }
- if ('FORCE_COLOR' in env) {
- if (env.FORCE_COLOR === 'true') {
- forceColor = 1;
- } else if (env.FORCE_COLOR === 'false') {
- forceColor = 0;
- } else {
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
- }
- }
- function translateLevel(level) {
- if (level === 0) {
- return false;
- }
- return {
- level,
- hasBasic: true,
- has256: level >= 2,
- has16m: level >= 3
- };
- }
- function supportsColor(haveStream, streamIsTTY) {
- if (forceColor === 0) {
- return 0;
- }
- if (hasFlag('color=16m') ||
- hasFlag('color=full') ||
- hasFlag('color=truecolor')) {
- return 3;
- }
- if (hasFlag('color=256')) {
- return 2;
- }
- if (haveStream && !streamIsTTY && forceColor === undefined) {
- return 0;
- }
- const min = forceColor || 0;
- if (env.TERM === 'dumb') {
- return min;
- }
- if (process.platform === 'win32') {
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
- const osRelease = os.release().split('.');
- if (
- Number(osRelease[0]) >= 10 &&
- Number(osRelease[2]) >= 10586
- ) {
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
- }
- return 1;
- }
- if ('CI' in env) {
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
- return 1;
- }
- return min;
- }
- if ('TEAMCITY_VERSION' in env) {
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
- }
- if (env.COLORTERM === 'truecolor') {
- return 3;
- }
- if ('TERM_PROGRAM' in env) {
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
- switch (env.TERM_PROGRAM) {
- case 'iTerm.app':
- return version >= 3 ? 3 : 2;
- case 'Apple_Terminal':
- return 2;
- // No default
- }
- }
- if (/-256(color)?$/i.test(env.TERM)) {
- return 2;
- }
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
- return 1;
- }
- if ('COLORTERM' in env) {
- return 1;
- }
- return min;
- }
- function getSupportLevel(stream) {
- const level = supportsColor(stream, stream && stream.isTTY);
- return translateLevel(level);
- }
- module.exports = {
- supportsColor: getSupportLevel,
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
- };
- /***/ }),
- /***/ 31936:
- /***/ ((module) => {
- "use strict";
- module.exports = JSON.parse('{"blacklist_client.lua":"local blacklist = ARGV[num_static_argv + 1]\\n\\nif redis.call(\'zscore\', client_last_seen_key, blacklist) then\\n redis.call(\'zadd\', client_last_seen_key, 0, blacklist)\\nend\\n\\n\\nreturn {}\\n","check.lua":"local weight = tonumber(ARGV[num_static_argv + 1])\\n\\nlocal capacity = process_tick(now, false)[\'capacity\']\\nlocal nextRequest = tonumber(redis.call(\'hget\', settings_key, \'nextRequest\'))\\n\\nreturn conditions_check(capacity, weight) and nextRequest - now <= 0\\n","conditions_check.lua":"local conditions_check = function (capacity, weight)\\n return capacity == nil or weight <= capacity\\nend\\n","current_reservoir.lua":"return process_tick(now, false)[\'reservoir\']\\n","done.lua":"process_tick(now, false)\\n\\nreturn tonumber(redis.call(\'hget\', settings_key, \'done\'))\\n","free.lua":"local index = ARGV[num_static_argv + 1]\\n\\nredis.call(\'zadd\', job_expirations_key, 0, index)\\n\\nreturn process_tick(now, false)[\'running\']\\n","get_time.lua":"redis.replicate_commands()\\n\\nlocal get_time = function ()\\n local time = redis.call(\'time\')\\n\\n return tonumber(time[1]..string.sub(time[2], 1, 3))\\nend\\n","group_check.lua":"return not (redis.call(\'exists\', settings_key) == 1)\\n","heartbeat.lua":"process_tick(now, true)\\n","increment_reservoir.lua":"local incr = tonumber(ARGV[num_static_argv + 1])\\n\\nredis.call(\'hincrby\', settings_key, \'reservoir\', incr)\\n\\nlocal reservoir = process_tick(now, true)[\'reservoir\']\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn reservoir\\n","init.lua":"local clear = tonumber(ARGV[num_static_argv + 1])\\nlocal limiter_version = ARGV[num_static_argv + 2]\\nlocal num_local_argv = num_static_argv + 2\\n\\nif clear == 1 then\\n redis.call(\'del\', unpack(KEYS))\\nend\\n\\nif redis.call(\'exists\', settings_key) == 0 then\\n -- Create\\n local args = {\'hmset\', settings_key}\\n\\n for i = num_local_argv + 1, #ARGV do\\n table.insert(args, ARGV[i])\\n end\\n\\n redis.call(unpack(args))\\n redis.call(\'hmset\', settings_key,\\n \'nextRequest\', now,\\n \'lastReservoirRefresh\', now,\\n \'lastReservoirIncrease\', now,\\n \'running\', 0,\\n \'done\', 0,\\n \'unblockTime\', 0,\\n \'capacityPriorityCounter\', 0\\n )\\n\\nelse\\n -- Apply migrations\\n local settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'version\'\\n )\\n local id = settings[1]\\n local current_version = settings[2]\\n\\n if current_version ~= limiter_version then\\n local version_digits = {}\\n for k, v in string.gmatch(current_version, \\"([^.]+)\\") do\\n table.insert(version_digits, tonumber(k))\\n end\\n\\n -- 2.10.0\\n if version_digits[2] < 10 then\\n redis.call(\'hsetnx\', settings_key, \'reservoirRefreshInterval\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirRefreshAmount\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'lastReservoirRefresh\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'done\', 0)\\n redis.call(\'hset\', settings_key, \'version\', \'2.10.0\')\\n end\\n\\n -- 2.11.1\\n if version_digits[2] < 11 or (version_digits[2] == 11 and version_digits[3] < 1) then\\n if redis.call(\'hstrlen\', settings_key, \'lastReservoirRefresh\') == 0 then\\n redis.call(\'hmset\', settings_key,\\n \'lastReservoirRefresh\', now,\\n \'version\', \'2.11.1\'\\n )\\n end\\n end\\n\\n -- 2.14.0\\n if version_digits[2] < 14 then\\n local old_running_key = \'b_\'..id..\'_running\'\\n local old_executing_key = \'b_\'..id..\'_executing\'\\n\\n if redis.call(\'exists\', old_running_key) == 1 then\\n redis.call(\'rename\', old_running_key, job_weights_key)\\n end\\n if redis.call(\'exists\', old_executing_key) == 1 then\\n redis.call(\'rename\', old_executing_key, job_expirations_key)\\n end\\n redis.call(\'hset\', settings_key, \'version\', \'2.14.0\')\\n end\\n\\n -- 2.15.2\\n if version_digits[2] < 15 or (version_digits[2] == 15 and version_digits[3] < 2) then\\n redis.call(\'hsetnx\', settings_key, \'capacityPriorityCounter\', 0)\\n redis.call(\'hset\', settings_key, \'version\', \'2.15.2\')\\n end\\n\\n -- 2.17.0\\n if version_digits[2] < 17 then\\n redis.call(\'hsetnx\', settings_key, \'clientTimeout\', 10000)\\n redis.call(\'hset\', settings_key, \'version\', \'2.17.0\')\\n end\\n\\n -- 2.18.0\\n if version_digits[2] < 18 then\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseInterval\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseAmount\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'reservoirIncreaseMaximum\', \'\')\\n redis.call(\'hsetnx\', settings_key, \'lastReservoirIncrease\', now)\\n redis.call(\'hset\', settings_key, \'version\', \'2.18.0\')\\n end\\n\\n end\\n\\n process_tick(now, false)\\nend\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn {}\\n","process_tick.lua":"local process_tick = function (now, always_publish)\\n\\n local compute_capacity = function (maxConcurrent, running, reservoir)\\n if maxConcurrent ~= nil and reservoir ~= nil then\\n return math.min((maxConcurrent - running), reservoir)\\n elseif maxConcurrent ~= nil then\\n return maxConcurrent - running\\n elseif reservoir ~= nil then\\n return reservoir\\n else\\n return nil\\n end\\n end\\n\\n local settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'maxConcurrent\',\\n \'running\',\\n \'reservoir\',\\n \'reservoirRefreshInterval\',\\n \'reservoirRefreshAmount\',\\n \'lastReservoirRefresh\',\\n \'reservoirIncreaseInterval\',\\n \'reservoirIncreaseAmount\',\\n \'reservoirIncreaseMaximum\',\\n \'lastReservoirIncrease\',\\n \'capacityPriorityCounter\',\\n \'clientTimeout\'\\n )\\n local id = settings[1]\\n local maxConcurrent = tonumber(settings[2])\\n local running = tonumber(settings[3])\\n local reservoir = tonumber(settings[4])\\n local reservoirRefreshInterval = tonumber(settings[5])\\n local reservoirRefreshAmount = tonumber(settings[6])\\n local lastReservoirRefresh = tonumber(settings[7])\\n local reservoirIncreaseInterval = tonumber(settings[8])\\n local reservoirIncreaseAmount = tonumber(settings[9])\\n local reservoirIncreaseMaximum = tonumber(settings[10])\\n local lastReservoirIncrease = tonumber(settings[11])\\n local capacityPriorityCounter = tonumber(settings[12])\\n local clientTimeout = tonumber(settings[13])\\n\\n local initial_capacity = compute_capacity(maxConcurrent, running, reservoir)\\n\\n --\\n -- Process \'running\' changes\\n --\\n local expired = redis.call(\'zrangebyscore\', job_expirations_key, \'-inf\', \'(\'..now)\\n\\n if #expired > 0 then\\n redis.call(\'zremrangebyscore\', job_expirations_key, \'-inf\', \'(\'..now)\\n\\n local flush_batch = function (batch, acc)\\n local weights = redis.call(\'hmget\', job_weights_key, unpack(batch))\\n redis.call(\'hdel\', job_weights_key, unpack(batch))\\n local clients = redis.call(\'hmget\', job_clients_key, unpack(batch))\\n redis.call(\'hdel\', job_clients_key, unpack(batch))\\n\\n -- Calculate sum of removed weights\\n for i = 1, #weights do\\n acc[\'total\'] = acc[\'total\'] + (tonumber(weights[i]) or 0)\\n end\\n\\n -- Calculate sum of removed weights by client\\n local client_weights = {}\\n for i = 1, #clients do\\n local removed = tonumber(weights[i]) or 0\\n if removed > 0 then\\n acc[\'client_weights\'][clients[i]] = (acc[\'client_weights\'][clients[i]] or 0) + removed\\n end\\n end\\n end\\n\\n local acc = {\\n [\'total\'] = 0,\\n [\'client_weights\'] = {}\\n }\\n local batch_size = 1000\\n\\n -- Compute changes to Zsets and apply changes to Hashes\\n for i = 1, #expired, batch_size do\\n local batch = {}\\n for j = i, math.min(i + batch_size - 1, #expired) do\\n table.insert(batch, expired[j])\\n end\\n\\n flush_batch(batch, acc)\\n end\\n\\n -- Apply changes to Zsets\\n if acc[\'total\'] > 0 then\\n redis.call(\'hincrby\', settings_key, \'done\', acc[\'total\'])\\n running = tonumber(redis.call(\'hincrby\', settings_key, \'running\', -acc[\'total\']))\\n end\\n\\n for client, weight in pairs(acc[\'client_weights\']) do\\n redis.call(\'zincrby\', client_running_key, -weight, client)\\n end\\n end\\n\\n --\\n -- Process \'reservoir\' changes\\n --\\n local reservoirRefreshActive = reservoirRefreshInterval ~= nil and reservoirRefreshAmount ~= nil\\n if reservoirRefreshActive and now >= lastReservoirRefresh + reservoirRefreshInterval then\\n reservoir = reservoirRefreshAmount\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'lastReservoirRefresh\', now\\n )\\n end\\n\\n local reservoirIncreaseActive = reservoirIncreaseInterval ~= nil and reservoirIncreaseAmount ~= nil\\n if reservoirIncreaseActive and now >= lastReservoirIncrease + reservoirIncreaseInterval then\\n local num_intervals = math.floor((now - lastReservoirIncrease) / reservoirIncreaseInterval)\\n local incr = reservoirIncreaseAmount * num_intervals\\n if reservoirIncreaseMaximum ~= nil then\\n incr = math.min(incr, reservoirIncreaseMaximum - (reservoir or 0))\\n end\\n if incr > 0 then\\n reservoir = (reservoir or 0) + incr\\n end\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'lastReservoirIncrease\', lastReservoirIncrease + (num_intervals * reservoirIncreaseInterval)\\n )\\n end\\n\\n --\\n -- Clear unresponsive clients\\n --\\n local unresponsive = redis.call(\'zrangebyscore\', client_last_seen_key, \'-inf\', (now - clientTimeout))\\n local unresponsive_lookup = {}\\n local terminated_clients = {}\\n for i = 1, #unresponsive do\\n unresponsive_lookup[unresponsive[i]] = true\\n if tonumber(redis.call(\'zscore\', client_running_key, unresponsive[i])) == 0 then\\n table.insert(terminated_clients, unresponsive[i])\\n end\\n end\\n if #terminated_clients > 0 then\\n redis.call(\'zrem\', client_running_key, unpack(terminated_clients))\\n redis.call(\'hdel\', client_num_queued_key, unpack(terminated_clients))\\n redis.call(\'zrem\', client_last_registered_key, unpack(terminated_clients))\\n redis.call(\'zrem\', client_last_seen_key, unpack(terminated_clients))\\n end\\n\\n --\\n -- Broadcast capacity changes\\n --\\n local final_capacity = compute_capacity(maxConcurrent, running, reservoir)\\n\\n if always_publish or (initial_capacity ~= nil and final_capacity == nil) then\\n -- always_publish or was not unlimited, now unlimited\\n redis.call(\'publish\', \'b_\'..id, \'capacity:\'..(final_capacity or \'\'))\\n\\n elseif initial_capacity ~= nil and final_capacity ~= nil and final_capacity > initial_capacity then\\n -- capacity was increased\\n -- send the capacity message to the limiter having the lowest number of running jobs\\n -- the tiebreaker is the limiter having not registered a job in the longest time\\n\\n local lowest_concurrency_value = nil\\n local lowest_concurrency_clients = {}\\n local lowest_concurrency_last_registered = {}\\n local client_concurrencies = redis.call(\'zrange\', client_running_key, 0, -1, \'withscores\')\\n\\n for i = 1, #client_concurrencies, 2 do\\n local client = client_concurrencies[i]\\n local concurrency = tonumber(client_concurrencies[i+1])\\n\\n if (\\n lowest_concurrency_value == nil or lowest_concurrency_value == concurrency\\n ) and (\\n not unresponsive_lookup[client]\\n ) and (\\n tonumber(redis.call(\'hget\', client_num_queued_key, client)) > 0\\n ) then\\n lowest_concurrency_value = concurrency\\n table.insert(lowest_concurrency_clients, client)\\n local last_registered = tonumber(redis.call(\'zscore\', client_last_registered_key, client))\\n table.insert(lowest_concurrency_last_registered, last_registered)\\n end\\n end\\n\\n if #lowest_concurrency_clients > 0 then\\n local position = 1\\n local earliest = lowest_concurrency_last_registered[1]\\n\\n for i,v in ipairs(lowest_concurrency_last_registered) do\\n if v < earliest then\\n position = i\\n earliest = v\\n end\\n end\\n\\n local next_client = lowest_concurrency_clients[position]\\n redis.call(\'publish\', \'b_\'..id,\\n \'capacity-priority:\'..(final_capacity or \'\')..\\n \':\'..next_client..\\n \':\'..capacityPriorityCounter\\n )\\n redis.call(\'hincrby\', settings_key, \'capacityPriorityCounter\', \'1\')\\n else\\n redis.call(\'publish\', \'b_\'..id, \'capacity:\'..(final_capacity or \'\'))\\n end\\n end\\n\\n return {\\n [\'capacity\'] = final_capacity,\\n [\'running\'] = running,\\n [\'reservoir\'] = reservoir\\n }\\nend\\n","queued.lua":"local clientTimeout = tonumber(redis.call(\'hget\', settings_key, \'clientTimeout\'))\\nlocal valid_clients = redis.call(\'zrangebyscore\', client_last_seen_key, (now - clientTimeout), \'inf\')\\nlocal client_queued = redis.call(\'hmget\', client_num_queued_key, unpack(valid_clients))\\n\\nlocal sum = 0\\nfor i = 1, #client_queued do\\n sum = sum + tonumber(client_queued[i])\\nend\\n\\nreturn sum\\n","refresh_expiration.lua":"local refresh_expiration = function (now, nextRequest, groupTimeout)\\n\\n if groupTimeout ~= nil then\\n local ttl = (nextRequest + groupTimeout) - now\\n\\n for i = 1, #KEYS do\\n redis.call(\'pexpire\', KEYS[i], ttl)\\n end\\n end\\n\\nend\\n","refs.lua":"local settings_key = KEYS[1]\\nlocal job_weights_key = KEYS[2]\\nlocal job_expirations_key = KEYS[3]\\nlocal job_clients_key = KEYS[4]\\nlocal client_running_key = KEYS[5]\\nlocal client_num_queued_key = KEYS[6]\\nlocal client_last_registered_key = KEYS[7]\\nlocal client_last_seen_key = KEYS[8]\\n\\nlocal now = tonumber(ARGV[1])\\nlocal client = ARGV[2]\\n\\nlocal num_static_argv = 2\\n","register.lua":"local index = ARGV[num_static_argv + 1]\\nlocal weight = tonumber(ARGV[num_static_argv + 2])\\nlocal expiration = tonumber(ARGV[num_static_argv + 3])\\n\\nlocal state = process_tick(now, false)\\nlocal capacity = state[\'capacity\']\\nlocal reservoir = state[\'reservoir\']\\n\\nlocal settings = redis.call(\'hmget\', settings_key,\\n \'nextRequest\',\\n \'minTime\',\\n \'groupTimeout\'\\n)\\nlocal nextRequest = tonumber(settings[1])\\nlocal minTime = tonumber(settings[2])\\nlocal groupTimeout = tonumber(settings[3])\\n\\nif conditions_check(capacity, weight) then\\n\\n redis.call(\'hincrby\', settings_key, \'running\', weight)\\n redis.call(\'hset\', job_weights_key, index, weight)\\n if expiration ~= nil then\\n redis.call(\'zadd\', job_expirations_key, now + expiration, index)\\n end\\n redis.call(\'hset\', job_clients_key, index, client)\\n redis.call(\'zincrby\', client_running_key, weight, client)\\n redis.call(\'hincrby\', client_num_queued_key, client, -1)\\n redis.call(\'zadd\', client_last_registered_key, now, client)\\n\\n local wait = math.max(nextRequest - now, 0)\\n local newNextRequest = now + wait + minTime\\n\\n if reservoir == nil then\\n redis.call(\'hset\', settings_key,\\n \'nextRequest\', newNextRequest\\n )\\n else\\n reservoir = reservoir - weight\\n redis.call(\'hmset\', settings_key,\\n \'reservoir\', reservoir,\\n \'nextRequest\', newNextRequest\\n )\\n end\\n\\n refresh_expiration(now, newNextRequest, groupTimeout)\\n\\n return {true, wait, reservoir}\\n\\nelse\\n return {false}\\nend\\n","register_client.lua":"local queued = tonumber(ARGV[num_static_argv + 1])\\n\\n-- Could have been re-registered concurrently\\nif not redis.call(\'zscore\', client_last_seen_key, client) then\\n redis.call(\'zadd\', client_running_key, 0, client)\\n redis.call(\'hset\', client_num_queued_key, client, queued)\\n redis.call(\'zadd\', client_last_registered_key, 0, client)\\nend\\n\\nredis.call(\'zadd\', client_last_seen_key, now, client)\\n\\nreturn {}\\n","running.lua":"return process_tick(now, false)[\'running\']\\n","submit.lua":"local queueLength = tonumber(ARGV[num_static_argv + 1])\\nlocal weight = tonumber(ARGV[num_static_argv + 2])\\n\\nlocal capacity = process_tick(now, false)[\'capacity\']\\n\\nlocal settings = redis.call(\'hmget\', settings_key,\\n \'id\',\\n \'maxConcurrent\',\\n \'highWater\',\\n \'nextRequest\',\\n \'strategy\',\\n \'unblockTime\',\\n \'penalty\',\\n \'minTime\',\\n \'groupTimeout\'\\n)\\nlocal id = settings[1]\\nlocal maxConcurrent = tonumber(settings[2])\\nlocal highWater = tonumber(settings[3])\\nlocal nextRequest = tonumber(settings[4])\\nlocal strategy = tonumber(settings[5])\\nlocal unblockTime = tonumber(settings[6])\\nlocal penalty = tonumber(settings[7])\\nlocal minTime = tonumber(settings[8])\\nlocal groupTimeout = tonumber(settings[9])\\n\\nif maxConcurrent ~= nil and weight > maxConcurrent then\\n return redis.error_reply(\'OVERWEIGHT:\'..weight..\':\'..maxConcurrent)\\nend\\n\\nlocal reachedHWM = (highWater ~= nil and queueLength == highWater\\n and not (\\n conditions_check(capacity, weight)\\n and nextRequest - now <= 0\\n )\\n)\\n\\nlocal blocked = strategy == 3 and (reachedHWM or unblockTime >= now)\\n\\nif blocked then\\n local computedPenalty = penalty\\n if computedPenalty == nil then\\n if minTime == 0 then\\n computedPenalty = 5000\\n else\\n computedPenalty = 15 * minTime\\n end\\n end\\n\\n local newNextRequest = now + computedPenalty + minTime\\n\\n redis.call(\'hmset\', settings_key,\\n \'unblockTime\', now + computedPenalty,\\n \'nextRequest\', newNextRequest\\n )\\n\\n local clients_queued_reset = redis.call(\'hkeys\', client_num_queued_key)\\n local queued_reset = {}\\n for i = 1, #clients_queued_reset do\\n table.insert(queued_reset, clients_queued_reset[i])\\n table.insert(queued_reset, 0)\\n end\\n redis.call(\'hmset\', client_num_queued_key, unpack(queued_reset))\\n\\n redis.call(\'publish\', \'b_\'..id, \'blocked:\')\\n\\n refresh_expiration(now, newNextRequest, groupTimeout)\\nend\\n\\nif not blocked and not reachedHWM then\\n redis.call(\'hincrby\', client_num_queued_key, client, 1)\\nend\\n\\nreturn {reachedHWM, blocked, strategy}\\n","update_settings.lua":"local args = {\'hmset\', settings_key}\\n\\nfor i = num_static_argv + 1, #ARGV do\\n table.insert(args, ARGV[i])\\nend\\n\\nredis.call(unpack(args))\\n\\nprocess_tick(now, true)\\n\\nlocal groupTimeout = tonumber(redis.call(\'hget\', settings_key, \'groupTimeout\'))\\nrefresh_expiration(0, 0, groupTimeout)\\n\\nreturn {}\\n","validate_client.lua":"if not redis.call(\'zscore\', client_last_seen_key, client) then\\n return redis.error_reply(\'UNKNOWN_CLIENT\')\\nend\\n\\nredis.call(\'zadd\', client_last_seen_key, now, client)\\n","validate_keys.lua":"if not (redis.call(\'exists\', settings_key) == 1) then\\n return redis.error_reply(\'SETTINGS_KEY_NOT_FOUND\')\\nend\\n"}');
- /***/ }),
- /***/ 82636:
- /***/ ((module) => {
- "use strict";
- module.exports = {"i":"2.19.5"};
- /***/ })
- };
- ;
- //# sourceMappingURL=779.index.js.map
|