| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["Web"] = factory();
- else
- root["Web"] = factory();
- })(self, function() {
- return /******/ (() => { // webpackBootstrap
- /******/ var __webpack_modules__ = ({
- /***/ "../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js":
- /*!********************************************************************************************!*\
- !*** ../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js ***!
- \********************************************************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "decode": () => (/* binding */ decode),
- /* harmony export */ "encode": () => (/* binding */ encode)
- /* harmony export */ });
- /*
- * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
- * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
- * Released under MIT License
- */
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- // Use a lookup table to find the index.
- var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
- for (var i = 0; i < chars.length; i++) {
- lookup[chars.charCodeAt(i)] = i;
- }
- var encode = function (arraybuffer) {
- var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
- for (i = 0; i < len; i += 3) {
- base64 += chars[bytes[i] >> 2];
- base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
- base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
- base64 += chars[bytes[i + 2] & 63];
- }
- if (len % 3 === 2) {
- base64 = base64.substring(0, base64.length - 1) + '=';
- }
- else if (len % 3 === 1) {
- base64 = base64.substring(0, base64.length - 2) + '==';
- }
- return base64;
- };
- var decode = function (base64) {
- var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
- if (base64[base64.length - 1] === '=') {
- bufferLength--;
- if (base64[base64.length - 2] === '=') {
- bufferLength--;
- }
- }
- var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
- for (i = 0; i < len; i += 4) {
- encoded1 = lookup[base64.charCodeAt(i)];
- encoded2 = lookup[base64.charCodeAt(i + 1)];
- encoded3 = lookup[base64.charCodeAt(i + 2)];
- encoded4 = lookup[base64.charCodeAt(i + 3)];
- bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
- bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
- bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
- }
- return arraybuffer;
- };
- //# sourceMappingURL=base64-arraybuffer.es5.js.map
- /***/ }),
- /***/ "../ot-core/node_modules/@socket.io/component-emitter/index.js":
- /*!*********************************************************************!*\
- !*** ../ot-core/node_modules/@socket.io/component-emitter/index.js ***!
- \*********************************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- /**
- * Expose `Emitter`.
- */
- exports.Emitter = Emitter;
- /**
- * Initialize a new `Emitter`.
- *
- * @api public
- */
- function Emitter(obj) {
- if (obj) return mixin(obj);
- }
- /**
- * Mixin the emitter properties.
- *
- * @param {Object} obj
- * @return {Object}
- * @api private
- */
- function mixin(obj) {
- for (var key in Emitter.prototype) {
- obj[key] = Emitter.prototype[key];
- }
- return obj;
- }
- /**
- * Listen on the given `event` with `fn`.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.on =
- Emitter.prototype.addEventListener = function(event, fn){
- this._callbacks = this._callbacks || {};
- (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
- .push(fn);
- return this;
- };
- /**
- * Adds an `event` listener that will be invoked a single
- * time then automatically removed.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.once = function(event, fn){
- function on() {
- this.off(event, on);
- fn.apply(this, arguments);
- }
- on.fn = fn;
- this.on(event, on);
- return this;
- };
- /**
- * Remove the given callback for `event` or all
- * registered callbacks.
- *
- * @param {String} event
- * @param {Function} fn
- * @return {Emitter}
- * @api public
- */
- Emitter.prototype.off =
- Emitter.prototype.removeListener =
- Emitter.prototype.removeAllListeners =
- Emitter.prototype.removeEventListener = function(event, fn){
- this._callbacks = this._callbacks || {};
- // all
- if (0 == arguments.length) {
- this._callbacks = {};
- return this;
- }
- // specific event
- var callbacks = this._callbacks['$' + event];
- if (!callbacks) return this;
- // remove all handlers
- if (1 == arguments.length) {
- delete this._callbacks['$' + event];
- return this;
- }
- // remove specific handler
- var cb;
- for (var i = 0; i < callbacks.length; i++) {
- cb = callbacks[i];
- if (cb === fn || cb.fn === fn) {
- callbacks.splice(i, 1);
- break;
- }
- }
- // Remove event specific arrays for event types that no
- // one is subscribed for to avoid memory leak.
- if (callbacks.length === 0) {
- delete this._callbacks['$' + event];
- }
- return this;
- };
- /**
- * Emit `event` with the given args.
- *
- * @param {String} event
- * @param {Mixed} ...
- * @return {Emitter}
- */
- Emitter.prototype.emit = function(event){
- this._callbacks = this._callbacks || {};
- var args = new Array(arguments.length - 1)
- , callbacks = this._callbacks['$' + event];
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- if (callbacks) {
- callbacks = callbacks.slice(0);
- for (var i = 0, len = callbacks.length; i < len; ++i) {
- callbacks[i].apply(this, args);
- }
- }
- return this;
- };
- // alias used for reserved events (protected method)
- Emitter.prototype.emitReserved = Emitter.prototype.emit;
- /**
- * Return array of callbacks for `event`.
- *
- * @param {String} event
- * @return {Array}
- * @api public
- */
- Emitter.prototype.listeners = function(event){
- this._callbacks = this._callbacks || {};
- return this._callbacks['$' + event] || [];
- };
- /**
- * Check if this emitter has `event` handlers.
- *
- * @param {String} event
- * @return {Boolean}
- * @api public
- */
- Emitter.prototype.hasListeners = function(event){
- return !! this.listeners(event).length;
- };
- /***/ }),
- /***/ "../ot-core/node_modules/backo2/index.js":
- /*!***********************************************!*\
- !*** ../ot-core/node_modules/backo2/index.js ***!
- \***********************************************/
- /***/ ((module) => {
- /**
- * Expose `Backoff`.
- */
- module.exports = Backoff;
- /**
- * Initialize backoff timer with `opts`.
- *
- * - `min` initial timeout in milliseconds [100]
- * - `max` max timeout [10000]
- * - `jitter` [0]
- * - `factor` [2]
- *
- * @param {Object} opts
- * @api public
- */
- function Backoff(opts) {
- opts = opts || {};
- this.ms = opts.min || 100;
- this.max = opts.max || 10000;
- this.factor = opts.factor || 2;
- this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
- this.attempts = 0;
- }
- /**
- * Return the backoff duration.
- *
- * @return {Number}
- * @api public
- */
- Backoff.prototype.duration = function(){
- var ms = this.ms * Math.pow(this.factor, this.attempts++);
- if (this.jitter) {
- var rand = Math.random();
- var deviation = Math.floor(rand * this.jitter * ms);
- ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
- }
- return Math.min(ms, this.max) | 0;
- };
- /**
- * Reset the number of attempts.
- *
- * @api public
- */
- Backoff.prototype.reset = function(){
- this.attempts = 0;
- };
- /**
- * Set the minimum duration
- *
- * @api public
- */
- Backoff.prototype.setMin = function(min){
- this.ms = min;
- };
- /**
- * Set the maximum duration
- *
- * @api public
- */
- Backoff.prototype.setMax = function(max){
- this.max = max;
- };
- /**
- * Set the jitter
- *
- * @api public
- */
- Backoff.prototype.setJitter = function(jitter){
- this.jitter = jitter;
- };
- /***/ }),
- /***/ "../ot-core/node_modules/debug/src/browser.js":
- /*!****************************************************!*\
- !*** ../ot-core/node_modules/debug/src/browser.js ***!
- \****************************************************/
- /***/ ((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__(/*! ./common */ "../ot-core/node_modules/debug/src/common.js")(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;
- }
- };
- /***/ }),
- /***/ "../ot-core/node_modules/debug/src/common.js":
- /*!***************************************************!*\
- !*** ../ot-core/node_modules/debug/src/common.js ***!
- \***************************************************/
- /***/ ((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__(/*! ms */ "../ot-core/node_modules/ms/index.js");
- 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 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;
- let namespacesCache;
- let enabledCache;
- 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: () => {
- if (enableOverride !== null) {
- return enableOverride;
- }
- if (namespacesCache !== createDebug.namespaces) {
- namespacesCache = createDebug.namespaces;
- enabledCache = createDebug.enabled(namespace);
- }
- return enabledCache;
- },
- 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.namespaces = 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;
- /***/ }),
- /***/ "../ot-core/node_modules/has-cors/index.js":
- /*!*************************************************!*\
- !*** ../ot-core/node_modules/has-cors/index.js ***!
- \*************************************************/
- /***/ ((module) => {
- /**
- * Module exports.
- *
- * Logic borrowed from Modernizr:
- *
- * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
- */
- try {
- module.exports = typeof XMLHttpRequest !== 'undefined' &&
- 'withCredentials' in new XMLHttpRequest();
- } catch (err) {
- // if XMLHttp support is disabled in IE then it will throw
- // when trying to create
- module.exports = false;
- }
- /***/ }),
- /***/ "../ot-core/node_modules/ms/index.js":
- /*!*******************************************!*\
- !*** ../ot-core/node_modules/ms/index.js ***!
- \*******************************************/
- /***/ ((module) => {
- /**
- * Helpers.
- */
- var s = 1000;
- var m = s * 60;
- var h = m * 60;
- var d = h * 24;
- var w = d * 7;
- var y = d * 365.25;
- /**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} [options]
- * @throws {Error} throw an error if val is not a non-empty string or a number
- * @return {String|Number}
- * @api public
- */
- module.exports = function(val, options) {
- options = options || {};
- var type = typeof val;
- if (type === 'string' && val.length > 0) {
- return parse(val);
- } else if (type === 'number' && isFinite(val)) {
- return options.long ? fmtLong(val) : fmtShort(val);
- }
- throw new Error(
- 'val is not a non-empty string or a valid number. val=' +
- JSON.stringify(val)
- );
- };
- /**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
- function parse(str) {
- str = String(str);
- if (str.length > 100) {
- return;
- }
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
- str
- );
- if (!match) {
- return;
- }
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'weeks':
- case 'week':
- case 'w':
- return n * w;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- default:
- return undefined;
- }
- }
- /**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
- function fmtShort(ms) {
- var msAbs = Math.abs(ms);
- if (msAbs >= d) {
- return Math.round(ms / d) + 'd';
- }
- if (msAbs >= h) {
- return Math.round(ms / h) + 'h';
- }
- if (msAbs >= m) {
- return Math.round(ms / m) + 'm';
- }
- if (msAbs >= s) {
- return Math.round(ms / s) + 's';
- }
- return ms + 'ms';
- }
- /**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
- function fmtLong(ms) {
- var msAbs = Math.abs(ms);
- if (msAbs >= d) {
- return plural(ms, msAbs, d, 'day');
- }
- if (msAbs >= h) {
- return plural(ms, msAbs, h, 'hour');
- }
- if (msAbs >= m) {
- return plural(ms, msAbs, m, 'minute');
- }
- if (msAbs >= s) {
- return plural(ms, msAbs, s, 'second');
- }
- return ms + ' ms';
- }
- /**
- * Pluralization helper.
- */
- function plural(ms, msAbs, n, name) {
- var isPlural = msAbs >= n * 1.5;
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
- }
- /***/ }),
- /***/ "../ot-core/node_modules/parseqs/index.js":
- /*!************************************************!*\
- !*** ../ot-core/node_modules/parseqs/index.js ***!
- \************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- /**
- * Compiles a querystring
- * Returns string representation of the object
- *
- * @param {Object}
- * @api private
- */
- exports.encode = function (obj) {
- var str = '';
- for (var i in obj) {
- if (obj.hasOwnProperty(i)) {
- if (str.length) str += '&';
- str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
- }
- }
- return str;
- };
- /**
- * Parses a simple querystring into an object
- *
- * @param {String} qs
- * @api private
- */
- exports.decode = function(qs){
- var qry = {};
- var pairs = qs.split('&');
- for (var i = 0, l = pairs.length; i < l; i++) {
- var pair = pairs[i].split('=');
- qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
- }
- return qry;
- };
- /***/ }),
- /***/ "../ot-core/node_modules/parseuri/index.js":
- /*!*************************************************!*\
- !*** ../ot-core/node_modules/parseuri/index.js ***!
- \*************************************************/
- /***/ ((module) => {
- /**
- * Parses an URI
- *
- * @author Steven Levithan <stevenlevithan.com> (MIT license)
- * @api private
- */
- var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
- var parts = [
- 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
- ];
- module.exports = function parseuri(str) {
- var src = str,
- b = str.indexOf('['),
- e = str.indexOf(']');
- if (b != -1 && e != -1) {
- str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
- }
- var m = re.exec(str || ''),
- uri = {},
- i = 14;
- while (i--) {
- uri[parts[i]] = m[i] || '';
- }
- if (b != -1 && e != -1) {
- uri.source = src;
- uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
- uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
- uri.ipv6uri = true;
- }
- uri.pathNames = pathNames(uri, uri['path']);
- uri.queryKey = queryKey(uri, uri['query']);
- return uri;
- };
- function pathNames(obj, path) {
- var regx = /\/{2,9}/g,
- names = path.replace(regx, "/").split("/");
- if (path.substr(0, 1) == '/' || path.length === 0) {
- names.splice(0, 1);
- }
- if (path.substr(path.length - 1, 1) == '/') {
- names.splice(names.length - 1, 1);
- }
- return names;
- }
- function queryKey(uri, query) {
- var data = {};
- query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
- if ($1) {
- data[$1] = $2;
- }
- });
- return data;
- }
- /***/ }),
- /***/ "../ot-core/node_modules/yeast/index.js":
- /*!**********************************************!*\
- !*** ../ot-core/node_modules/yeast/index.js ***!
- \**********************************************/
- /***/ ((module) => {
- "use strict";
- var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
- , length = 64
- , map = {}
- , seed = 0
- , i = 0
- , prev;
- /**
- * Return a string representing the specified number.
- *
- * @param {Number} num The number to convert.
- * @returns {String} The string representation of the number.
- * @api public
- */
- function encode(num) {
- var encoded = '';
- do {
- encoded = alphabet[num % length] + encoded;
- num = Math.floor(num / length);
- } while (num > 0);
- return encoded;
- }
- /**
- * Return the integer value specified by the given string.
- *
- * @param {String} str The string to convert.
- * @returns {Number} The integer value represented by the string.
- * @api public
- */
- function decode(str) {
- var decoded = 0;
- for (i = 0; i < str.length; i++) {
- decoded = decoded * length + map[str.charAt(i)];
- }
- return decoded;
- }
- /**
- * Yeast: A tiny growing id generator.
- *
- * @returns {String} A unique id.
- * @api public
- */
- function yeast() {
- var now = encode(+new Date());
- if (now !== prev) return seed = 0, prev = now;
- return now +'.'+ encode(seed++);
- }
- //
- // Map each character to its index.
- //
- for (; i < length; i++) map[alphabet[i]] = i;
- //
- // Expose the `yeast`, `encode` and `decode` functions.
- //
- yeast.encode = encode;
- yeast.decode = decode;
- module.exports = yeast;
- /***/ }),
- /***/ "../ot-core/src/basics/Command.ts":
- /*!****************************************!*\
- !*** ../ot-core/src/basics/Command.ts ***!
- \****************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Command = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Command {
- constructor(...parameter) {
- this._describe = 'Command';
- if (internal_1.TransformUtils.hasLength(parameter, 0)) {
- this._groupId = 'default';
- this._operation = [];
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- if (internal_1.TransformUtils.isString(parameter[0])) {
- const groupId = parameter[0];
- this._operation = [];
- this._groupId = groupId;
- return;
- }
- if (internal_1.TransformUtils.isObject(parameter[0])) {
- const serialize = parameter[0];
- this._groupId = serialize.groupId;
- this._operation = internal_1.Deserialize.getInstance().formArray(serialize.operation);
- return;
- }
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const groupId = parameter[0];
- const operation = parameter[1];
- this._groupId = groupId;
- this._operation = operation;
- }
- }
- concat(target) {
- const result = new Command({
- groupId: this._groupId,
- describe: this._describe,
- operation: []
- });
- result._operation = this._operation.concat(target._operation);
- return result;
- }
- apply(resource) {
- const operations = this._operation;
- const sizeof = operations.length;
- for (let i = 0; i < sizeof; i++) {
- const action = operations[i];
- action.apply(resource);
- }
- }
- getOperations() {
- return this._operation;
- }
- getGroupId() {
- return this._groupId;
- }
- addOperation(operation) {
- this._operation.push(operation);
- }
- toJSON() {
- return {
- describe: this._describe,
- groupId: this._groupId,
- operation: this._operation.map(o => o.toJSON())
- };
- }
- }
- exports.Command = Command;
- /***/ }),
- /***/ "../ot-core/src/basics/Conflict.ts":
- /*!*****************************************!*\
- !*** ../ot-core/src/basics/Conflict.ts ***!
- \*****************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Conflict = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Conflict {
- constructor() {
- this._conflict = new Array();
- }
- get(targetOperation, savedOperation) {
- const _conflict = this._conflict;
- const sizeof = _conflict.length;
- for (let i = 0; i < sizeof; i++) {
- const wrapped = _conflict[i];
- const targetFrom = internal_1.TransformUtils.isAssignableFrom(targetOperation, wrapped.targetClass);
- const savedFrom = internal_1.TransformUtils.isAssignableFrom(savedOperation, wrapped.savedClass);
- if (targetFrom && savedFrom) {
- return wrapped;
- }
- }
- return null;
- }
- add(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const wrapped = parameter[0];
- this._conflict.push(wrapped);
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 3)) {
- const targetClass = parameter[0];
- const savedClass = parameter[1];
- const process = parameter[2];
- this._conflict.push({
- targetClass,
- savedClass,
- process
- });
- }
- }
- }
- exports.Conflict = Conflict;
- /***/ }),
- /***/ "../ot-core/src/basics/Deserialize.ts":
- /*!********************************************!*\
- !*** ../ot-core/src/basics/Deserialize.ts ***!
- \********************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Deserialize = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- let singleton;
- class Deserialize {
- constructor() {
- this._storage = new Map();
- }
- static getInstance() {
- if (!internal_1.TransformUtils.isDefine(singleton)) {
- singleton = new Deserialize();
- singleton.addClass('SwapData', internal_1.SwapData);
- singleton.addClass('Command', internal_1.Command);
- }
- return singleton;
- }
- formArray(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const object = parameter[0];
- const length = object.length;
- const result = new Array();
- for (let i = 0; i < length; i++) {
- result.push(this.convert(object[i]));
- }
- return result;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const object = parameter[0];
- const defaultValue = parameter[1];
- if (internal_1.TransformUtils.isDefine(object)) {
- const length = object.length;
- const result = new Array();
- for (let i = 0; i < length; i++) {
- result.push(this.convert(object[i]));
- }
- return result;
- }
- return defaultValue;
- }
- }
- formObject(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const object = parameter[0];
- return this.convert(object);
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const object = parameter[0];
- const defaultValue = parameter[1];
- if (internal_1.TransformUtils.isDefine(object)) {
- return this.convert(object);
- }
- return defaultValue;
- }
- }
- convert(value) {
- if (internal_1.TransformUtils.isDefine(value.describe)) {
- return this.newInstance(value.describe, value);
- }
- return value;
- }
- addClass(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const clazz = parameter[0];
- this._storage.set(clazz.name, clazz);
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const name = parameter[0];
- const clazz = parameter[1];
- this._storage.set(name, clazz);
- }
- }
- newInstance(name, desc) {
- const constructor = this.getClass(name);
- return new constructor(desc);
- }
- getClass(name) {
- const element = this._storage.get(name);
- if (internal_1.TransformUtils.isDefine(element)) {
- return element;
- }
- throw new Error(`not find ${name} Class`);
- }
- }
- exports.Deserialize = Deserialize;
- /***/ }),
- /***/ "../ot-core/src/basics/Operation.ts":
- /*!******************************************!*\
- !*** ../ot-core/src/basics/Operation.ts ***!
- \******************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- /***/ }),
- /***/ "../ot-core/src/basics/SwapData.ts":
- /*!*****************************************!*\
- !*** ../ot-core/src/basics/SwapData.ts ***!
- \*****************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.SwapData = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class SwapData {
- constructor(...parameter) {
- this._describe = 'SwapData';
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- this._data = parameter[0].data;
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 0)) {
- this._data = null;
- }
- }
- setData(_data) {
- this._data = _data;
- }
- getData() {
- return this._data;
- }
- clone() {
- return this;
- }
- toJSON() {
- return {
- describe: this._describe,
- data: this._data
- };
- }
- }
- exports.SwapData = SwapData;
- /***/ }),
- /***/ "../ot-core/src/basics/Transform.ts":
- /*!******************************************!*\
- !*** ../ot-core/src/basics/Transform.ts ***!
- \******************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Transform = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Transform {
- constructor(_conflict) {
- this._conflict = _conflict;
- }
- transfer(targetCommand, savedCommand) {
- const conflict = this._conflict;
- const targetOperations = targetCommand.getOperations();
- const savedOperations = savedCommand.getOperations();
- const sizeof1 = targetOperations.length;
- const sizeof2 = savedOperations.length;
- const newTargetCommand = new internal_1.Command({
- groupId: targetCommand.getGroupId(),
- operation: [],
- describe: 'Command'
- });
- const newSavedCommand = new internal_1.Command({
- groupId: targetCommand.getGroupId(),
- operation: [],
- describe: 'Command'
- });
- for (let i = 0; i < sizeof1; i++) {
- const targetOperation = targetOperations[i];
- for (let j = 0; j < sizeof2; j++) {
- const savedOperation = savedOperations[j];
- const wrapped = conflict.get(targetOperation, savedOperation);
- if (wrapped != null) {
- const transfer = wrapped.process(newTargetCommand, newSavedCommand);
- transfer(targetOperation.clone(), savedOperation.clone());
- continue;
- }
- throw new Error('not found _conflict process');
- }
- }
- return [newTargetCommand, newSavedCommand];
- }
- }
- exports.Transform = Transform;
- /***/ }),
- /***/ "../ot-core/src/client/AwaitingConfirm.ts":
- /*!************************************************!*\
- !*** ../ot-core/src/client/AwaitingConfirm.ts ***!
- \************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.AwaitingConfirm = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class AwaitingConfirm {
- constructor(outstanding) {
- this._outstanding = outstanding;
- }
- applyClient(client, command) {
- return new internal_1.AwaitingWithBuffer(this._outstanding, command);
- }
- serverAck(client) {
- return internal_1.Synchronized.DEFAULT;
- }
- applyServer(client, command) {
- const outstanding = this._outstanding;
- const pair = client.getTransform().transfer(outstanding, command);
- client.applyCommand(pair[1]);
- return new AwaitingConfirm(pair[0]);
- }
- resend(client) {
- client.sendCommand(client.getRevision(), this._outstanding);
- }
- }
- exports.AwaitingConfirm = AwaitingConfirm;
- /***/ }),
- /***/ "../ot-core/src/client/AwaitingWithBuffer.ts":
- /*!***************************************************!*\
- !*** ../ot-core/src/client/AwaitingWithBuffer.ts ***!
- \***************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.AwaitingWithBuffer = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class AwaitingWithBuffer {
- constructor(outstanding, buffer) {
- this._outstanding = outstanding;
- this._buffer = buffer;
- }
- applyClient(client, command) {
- let newBuffer = this._buffer.concat(command);
- return new AwaitingWithBuffer(this._outstanding, newBuffer);
- }
- serverAck(client) {
- client.sendCommand(client.getRevision(), this._buffer);
- return new internal_1.AwaitingConfirm(this._buffer);
- }
- applyServer(client, command) {
- const outstanding = this._outstanding;
- const buffer = this._buffer;
- const pair1 = client.getTransform().transfer(outstanding, command);
- const pair2 = client.getTransform().transfer(buffer, pair1[1]);
- client.applyCommand(pair2[1]);
- return new AwaitingWithBuffer(pair1[0], pair2[0]);
- }
- resend(client) {
- client.sendCommand(client.getRevision(), this._outstanding);
- }
- }
- exports.AwaitingWithBuffer = AwaitingWithBuffer;
- /***/ }),
- /***/ "../ot-core/src/client/Client.ts":
- /*!***************************************!*\
- !*** ../ot-core/src/client/Client.ts ***!
- \***************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Client = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Client {
- constructor(conflict) {
- this._revision = 0;
- this._transform = new internal_1.Transform(conflict);
- this._status = internal_1.Synchronized.DEFAULT;
- this._undoManager = new internal_1.UndoManager(this._transform);
- }
- applyClient(command) {
- this._status = this._status.applyClient(this, command);
- }
- serverAck() {
- this._revision++;
- this._status = this._status.serverAck(this);
- }
- applyServer(command) {
- this._revision++;
- this._status = this._status.applyServer(this, command);
- }
- serverReconnect() {
- this._status.resend(this);
- }
- getTransform() {
- return this._transform;
- }
- getRevision() {
- return this._revision;
- }
- getUndoManager() {
- return this._undoManager;
- }
- }
- exports.Client = Client;
- /***/ }),
- /***/ "../ot-core/src/client/ClientSocket.ts":
- /*!*********************************************!*\
- !*** ../ot-core/src/client/ClientSocket.ts ***!
- \*********************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.ClientSocket = void 0;
- const socket_io_client_1 = __webpack_require__(/*! socket.io-client */ "../ot-core/node_modules/socket.io-client/build/cjs/index.js");
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class ClientSocket extends internal_1.Client {
- constructor(config) {
- super(config.conflict);
- this._config = config;
- this._socket = (0, socket_io_client_1.io)(config.url);
- this._execute = () => {};
- this._initializeListener();
- this._initializeSocket();
- }
- _initializeListener() {
- const observer = this._undoManager.getObserver();
- observer.addOnAddRedoListener({
- onAddRedo: wrapped => {
- wrapped.redo.apply(this._source);
- this.applyClient(wrapped.redo);
- }
- });
- observer.addOnAddUndoListener({
- onAddUndo: wrapped => {
- wrapped.undo.apply(this._source);
- this.applyClient(wrapped.undo);
- }
- });
- }
- _initializeSocket() {
- this._socket.on('open', response => {
- this._revision = response.revision;
- this._users = response.users;
- this._source = response.source;
- this._roomId = response.roomId;
- this._execute();
- });
- this._socket.on('ack', () => {
- this.serverAck();
- });
- this._socket.on('command', (clientId, command) => {
- const deserialize = internal_1.Deserialize.getInstance().formObject(command);
- this.applyServer(deserialize);
- });
- this._socket.on('reconnect', () => {
- this.serverReconnect();
- });
- }
- ready(execute) {
- this._execute = execute;
- }
- sendCommand(revision, command) {
- this._socket.emit('command', revision, command.toJSON());
- }
- applyCommand(command) {
- command.apply(this._source);
- this._undoManager.transform(command);
- }
- }
- exports.ClientSocket = ClientSocket;
- /***/ }),
- /***/ "../ot-core/src/client/Synchronized.ts":
- /*!*********************************************!*\
- !*** ../ot-core/src/client/Synchronized.ts ***!
- \*********************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Synchronized = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Synchronized {
- applyClient(client, command) {
- client.sendCommand(client.getRevision(), command);
- return new internal_1.AwaitingConfirm(command);
- }
- serverAck(client) {
- throw new Error("There is no pending operated.");
- }
- applyServer(client, command) {
- client.applyCommand(command);
- return this;
- }
- resend(client) {}
- }
- exports.Synchronized = Synchronized;
- Synchronized.DEFAULT = new Synchronized();
- /***/ }),
- /***/ "../ot-core/src/client/UndoManager.ts":
- /*!********************************************!*\
- !*** ../ot-core/src/client/UndoManager.ts ***!
- \********************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.UndoManager = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class UndoManager {
- constructor(transform) {
- this._redoStack = [];
- this._undoStack = [];
- this._transform = transform;
- this._observer = new internal_1.UndoManagerObserver();
- }
- _transformStack(stack, command) {
- const transform = this._transform;
- const sizeof = stack.length - 1;
- let redoCommand = command;
- let undoCommand = command;
- for (let i = sizeof; i >= 0; i--) {
- const pair1 = transform.transfer(stack[i].redo, redoCommand);
- const pair2 = transform.transfer(stack[i].undo, undoCommand);
- stack[i].redo = pair1[0];
- stack[i].undo = pair2[0];
- redoCommand = pair1[1];
- undoCommand = pair2[1];
- }
- }
- transform(command) {
- this._transformStack(this._undoStack, command);
- this._transformStack(this._redoStack, command);
- }
- canUndo() {
- return this._undoStack.length !== 0;
- }
- canRedo() {
- return this._redoStack.length !== 0;
- }
- addRedo(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const wrapped = parameter[0];
- this._redoStack.push(wrapped);
- this._observer.dispatchOnAddRedo(wrapped);
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const redo = parameter[0];
- const undo = parameter[1];
- const wrapped = {
- redo,
- undo
- };
- this._redoStack.push(wrapped);
- this._observer.dispatchOnAddRedo(wrapped);
- }
- }
- addUndo(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const wrapped = parameter[0];
- this._undoStack.push(wrapped);
- this._observer.dispatchOnAddUndo(wrapped);
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const redo = parameter[0];
- const undo = parameter[1];
- const wrapped = {
- redo,
- undo
- };
- this._undoStack.push(wrapped);
- this._observer.dispatchOnAddUndo(wrapped);
- }
- }
- performCommand(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const wrapped = parameter[0];
- this.addRedo(wrapped);
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const redo = parameter[0];
- const undo = parameter[1];
- const wrapped = {
- redo,
- undo
- };
- this.addRedo(wrapped);
- }
- }
- performRedo() {
- if (this.canRedo()) {
- const wrapped = this._redoStack.pop();
- this.addUndo(wrapped);
- this._observer.dispatchOnRedo(wrapped);
- }
- }
- performUndo() {
- if (this.canUndo()) {
- const wrapped = this._undoStack.pop();
- this.addRedo(wrapped);
- this._observer.dispatchOnUndo(wrapped);
- }
- }
- getObserver() {
- return this._observer;
- }
- }
- exports.UndoManager = UndoManager;
- /***/ }),
- /***/ "../ot-core/src/client/UndoManagerObserver.ts":
- /*!****************************************************!*\
- !*** ../ot-core/src/client/UndoManagerObserver.ts ***!
- \****************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.UndoManagerObserver = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class UndoManagerObserver {
- dispatchOnAddRedo(wrapped) {
- let listeners = this._onAddRedoListeners;
- if (listeners != null) {
- const sizeof = listeners.sizeof();
- for (let i = 0; i < sizeof; i++) {
- const listener = listeners.get(i);
- listener.onAddRedo(wrapped);
- }
- }
- }
- dispatchOnAddUndo(wrapped) {
- let listeners = this._onAddUndoListeners;
- if (listeners != null) {
- const sizeof = listeners.sizeof();
- for (let i = 0; i < sizeof; i++) {
- const listener = listeners.get(i);
- listener.onAddUndo(wrapped);
- }
- }
- }
- dispatchOnRedo(wrapped) {
- let listeners = this._onRedoListeners;
- if (listeners != null) {
- const sizeof = listeners.sizeof();
- for (let i = 0; i < sizeof; i++) {
- const listener = listeners.get(i);
- listener.onRedo(wrapped);
- }
- }
- }
- dispatchOnUndo(wrapped) {
- let listeners = this._onUndoListeners;
- if (listeners != null) {
- const sizeof = listeners.sizeof();
- for (let i = 0; i < sizeof; i++) {
- const listener = listeners.get(i);
- listener.onUndo(wrapped);
- }
- }
- }
- addOnAddRedoListener(listener) {
- if (this._onAddRedoListeners == null) {
- this._onAddRedoListeners = new internal_1.ArrayList();
- }
- this._onAddRedoListeners.add(listener);
- }
- addOnAddUndoListener(listener) {
- if (this._onAddUndoListeners == null) {
- this._onAddUndoListeners = new internal_1.ArrayList();
- }
- this._onAddUndoListeners.add(listener);
- }
- addOnRedoListener(listener) {
- if (this._onRedoListeners == null) {
- this._onRedoListeners = new internal_1.ArrayList();
- }
- this._onRedoListeners.add(listener);
- }
- addOnUndoListener(listener) {
- if (this._onUndoListeners == null) {
- this._onUndoListeners = new internal_1.ArrayList();
- }
- this._onUndoListeners.add(listener);
- }
- removeOnAddRedoListener(listener) {
- if (this._onAddRedoListeners == null) {
- return;
- }
- this._onAddRedoListeners.remove(listener);
- }
- removeOnAddUndoListener(listener) {
- if (this._onAddUndoListeners == null) {
- return;
- }
- this._onAddUndoListeners.remove(listener);
- }
- removeOnUndoListener(listener) {
- if (this._onUndoListeners == null) {
- return;
- }
- this._onUndoListeners.remove(listener);
- }
- removeOnRedoListener(listener) {
- if (this._onRedoListeners == null) {
- return;
- }
- this._onRedoListeners.remove(listener);
- }
- }
- exports.UndoManagerObserver = UndoManagerObserver;
- /***/ }),
- /***/ "../ot-core/src/config/ClientSocketConfig.ts":
- /*!***************************************************!*\
- !*** ../ot-core/src/config/ClientSocketConfig.ts ***!
- \***************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.ClientSocketConfig = void 0;
- class ClientSocketConfig {}
- exports.ClientSocketConfig = ClientSocketConfig;
- /***/ }),
- /***/ "../ot-core/src/index.ts":
- /*!*******************************!*\
- !*** ../ot-core/src/index.ts ***!
- \*******************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, {
- enumerable: true,
- get: function () {
- return m[k];
- }
- });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- };
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- __exportStar(__webpack_require__(/*! ./internal */ "../ot-core/src/internal.ts"), exports);
- /***/ }),
- /***/ "../ot-core/src/internal.ts":
- /*!**********************************!*\
- !*** ../ot-core/src/internal.ts ***!
- \**********************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- // ================================================= typed
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, {
- enumerable: true,
- get: function () {
- return m[k];
- }
- });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- };
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- __exportStar(__webpack_require__(/*! ./typed/GlobalType */ "../ot-core/src/typed/GlobalType.ts"), exports); // ================================================= utils
- __exportStar(__webpack_require__(/*! ./utils/ArrayUtils */ "../ot-core/src/utils/ArrayUtils.ts"), exports);
- __exportStar(__webpack_require__(/*! ./utils/TransformUtils */ "../ot-core/src/utils/TransformUtils.ts"), exports); // ================================================= config
- __exportStar(__webpack_require__(/*! ./config/ClientSocketConfig */ "../ot-core/src/config/ClientSocketConfig.ts"), exports); // ================================================= library
- __exportStar(__webpack_require__(/*! ./library/ArrayList */ "../ot-core/src/library/ArrayList.ts"), exports); // ================================================= basics
- __exportStar(__webpack_require__(/*! ./basics/Command */ "../ot-core/src/basics/Command.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/Operation */ "../ot-core/src/basics/Operation.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/Conflict */ "../ot-core/src/basics/Conflict.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/Transform */ "../ot-core/src/basics/Transform.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/SwapData */ "../ot-core/src/basics/SwapData.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/Deserialize */ "../ot-core/src/basics/Deserialize.ts"), exports); // ================================================= client
- __exportStar(__webpack_require__(/*! ./client/UndoManager */ "../ot-core/src/client/UndoManager.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/AwaitingConfirm */ "../ot-core/src/client/AwaitingConfirm.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/Synchronized */ "../ot-core/src/client/Synchronized.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/AwaitingWithBuffer */ "../ot-core/src/client/AwaitingWithBuffer.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/UndoManagerObserver */ "../ot-core/src/client/UndoManagerObserver.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/Client */ "../ot-core/src/client/Client.ts"), exports);
- __exportStar(__webpack_require__(/*! ./client/ClientSocket */ "../ot-core/src/client/ClientSocket.ts"), exports); // ================================================= server
- __exportStar(__webpack_require__(/*! ./server/Response */ "../ot-core/src/server/Response.ts"), exports);
- __exportStar(__webpack_require__(/*! ./server/User */ "../ot-core/src/server/User.ts"), exports);
- __exportStar(__webpack_require__(/*! ./server/Server */ "../ot-core/src/server/Server.ts"), exports);
- __exportStar(__webpack_require__(/*! ./server/ServerSocket */ "../ot-core/src/server/ServerSocket.ts"), exports);
- /***/ }),
- /***/ "../ot-core/src/library/ArrayList.ts":
- /*!*******************************************!*\
- !*** ../ot-core/src/library/ArrayList.ts ***!
- \*******************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.ArrayList = void 0;
- const TransformUtils_1 = __webpack_require__(/*! ../utils/TransformUtils */ "../ot-core/src/utils/TransformUtils.ts");
- class ArrayList {
- constructor() {
- this._arraylist = new Array();
- }
- get(index) {
- return this._arraylist[index];
- }
- sizeof() {
- return this._arraylist.length;
- }
- add(value) {
- this._arraylist.push(value);
- }
- remove(...parameter) {
- if (TransformUtils_1.TransformUtils.hasLength(parameter, 1)) {
- if (TransformUtils_1.TransformUtils.isNumber(parameter[0])) {
- const index = parameter[0];
- this._arraylist.splice(index, 1);
- return;
- }
- if (TransformUtils_1.TransformUtils.isObject(parameter[0])) {
- const value = parameter[0];
- const arraylist = this._arraylist;
- const sizeof = arraylist.length;
- for (let i = 0; i < sizeof; i++) {
- const item = arraylist[i];
- if (item === value) {
- this._arraylist.splice(i, 1);
- return;
- }
- }
- }
- }
- }
- }
- exports.ArrayList = ArrayList;
- /***/ }),
- /***/ "../ot-core/src/server/Response.ts":
- /*!*****************************************!*\
- !*** ../ot-core/src/server/Response.ts ***!
- \*****************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- /***/ }),
- /***/ "../ot-core/src/server/Server.ts":
- /*!***************************************!*\
- !*** ../ot-core/src/server/Server.ts ***!
- \***************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Server = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class Server {
- constructor(conflict) {
- this._chronicle = new Array();
- this._transform = new internal_1.Transform(conflict);
- }
- receiveCommand(revision, command) {
- if (revision < 0 || this._chronicle.length < revision) {
- throw new Error("command revision not in history");
- }
- let history = this._chronicle.slice(revision);
- for (let i = 0; i < history.length; i++) {
- const saved = history[i];
- if (command.getGroupId() === saved.getGroupId()) {
- command = this._transform.transfer(command, saved)[0];
- }
- }
- this._chronicle.push(command);
- }
- getRevision() {
- return this._chronicle.length;
- }
- }
- exports.Server = Server;
- /***/ }),
- /***/ "../ot-core/src/server/ServerSocket.ts":
- /*!*********************************************!*\
- !*** ../ot-core/src/server/ServerSocket.ts ***!
- \*********************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.ServerSocket = void 0;
- const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
- class ServerSocket extends internal_1.Server {
- constructor(...parameter) {
- if (internal_1.TransformUtils.hasLength(parameter, 1)) {
- const conflict = parameter[0];
- super(conflict);
- this._roomId = 'empty';
- this._users = [];
- this._source = null;
- return;
- }
- if (internal_1.TransformUtils.hasLength(parameter, 2)) {
- const conflict = parameter[0];
- const source = parameter[1];
- super(conflict);
- this._roomId = 'empty';
- this._users = [];
- this._source = source;
- }
- }
- receiveCommand(revision, command) {
- super.receiveCommand(revision, command);
- command.apply(this._source);
- }
- addSocketClient(client) {
- client.join(this._roomId);
- client.on('command', (revision, command) => {
- this.onCommand(client, revision, command);
- });
- client.on('disconnect', () => {
- this.onDisconnect(client);
- });
- client.emit('open', {
- revision: this.getRevision(),
- clients: this._users,
- roomId: this._roomId,
- source: this._source
- });
- }
- onCommand(client, revision, command) {
- const deserialize = internal_1.Deserialize.getInstance().formObject(command);
- let clientId = client.id;
- this.receiveCommand(revision, deserialize);
- client.emit('ack');
- client.broadcast.in(this._roomId).emit('command', clientId, deserialize.toJSON());
- }
- onDisconnect(client) {
- console.log('Disconnect');
- }
- }
- exports.ServerSocket = ServerSocket;
- /***/ }),
- /***/ "../ot-core/src/server/User.ts":
- /*!*************************************!*\
- !*** ../ot-core/src/server/User.ts ***!
- \*************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.User = void 0;
- class User {}
- exports.User = User;
- /***/ }),
- /***/ "../ot-core/src/typed/GlobalType.ts":
- /*!******************************************!*\
- !*** ../ot-core/src/typed/GlobalType.ts ***!
- \******************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- /***/ }),
- /***/ "../ot-core/src/utils/ArrayUtils.ts":
- /*!******************************************!*\
- !*** ../ot-core/src/utils/ArrayUtils.ts ***!
- \******************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.ArrayUtils = void 0;
- class ArrayUtils {}
- exports.ArrayUtils = ArrayUtils;
- /***/ }),
- /***/ "../ot-core/src/utils/TransformUtils.ts":
- /*!**********************************************!*\
- !*** ../ot-core/src/utils/TransformUtils.ts ***!
- \**********************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.TransformUtils = void 0;
- class TransformUtils {
- static getValueType(value) {
- return Object.prototype.toString.apply(value);
- }
- static isBoolean(value) {
- return this.getValueType(value) === '[object Boolean]';
- }
- static isString(value) {
- return this.getValueType(value) === '[object String]';
- }
- static isFunction(value) {
- return this.getValueType(value) === '[object Function]';
- }
- static isNumber(value) {
- return this.getValueType(value) === '[object Number]';
- }
- static isDefine(value) {
- return value !== undefined && value !== null;
- }
- static unDefine(value) {
- return value === undefined || value === null;
- }
- static isBlank(value) {
- if (!this.isDefine(value)) {
- return true;
- }
- if (this.isString(value)) {
- return value.trim() === '';
- }
- return false;
- }
- static isConstructor(clazz) {
- return clazz.prototype.constructor === clazz;
- }
- static isAssignableFrom(object, clazz) {
- return object instanceof clazz;
- }
- static isObject(value) {
- return this.getValueType(value) === '[object Object]';
- }
- static isPlainObject(value) {
- if (!this.isDefine(value)) {
- return false;
- }
- return Object.getPrototypeOf(value) === Object.getPrototypeOf({});
- }
- static isArray(value, clazz) {
- let type = this.getValueType(value) === '[object Array]';
- if (type) {
- if (TransformUtils.isDefine(clazz)) {
- value = value;
- if (value.length) {
- return value[0] instanceof clazz;
- }
- }
- return true;
- }
- return false;
- }
- static copy(src, target) {
- Object.assign(src, target);
- }
- static hasLength(target, length) {
- return target.length === length;
- }
- }
- exports.TransformUtils = TransformUtils;
- /***/ }),
- /***/ "./src/basics/Bootstrap.ts":
- /*!*********************************!*\
- !*** ./src/basics/Bootstrap.ts ***!
- \*********************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
- var deserialize = ot_core_1.Deserialize.getInstance();
- deserialize.addClass('InsertColumn', internal_1.InsertColumn);
- deserialize.addClass('InsertRow', internal_1.InsertRow);
- deserialize.addClass('RemoveColumn', internal_1.RemoveColumn);
- deserialize.addClass('RemoveRow', internal_1.RemoveRow);
- /***/ }),
- /***/ "./src/basics/CreateConflict.ts":
- /*!**************************************!*\
- !*** ./src/basics/CreateConflict.ts ***!
- \**************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.CreateConflict = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
- function CreateConflict() {
- var conflict = new ot_core_1.Conflict();
- conflict.add(internal_1.InsertRow, internal_1.InsertRow, function (targetCommand, savedCommand) {
- return function (targetOperation, savedOperation) {
- /**
- * 服务端插入的行在当前行的下方
- */
- if (targetOperation.getHeight() <= savedOperation.getIndex()) {
- var offset = savedOperation.getIndex() + targetOperation.getCount();
- savedOperation.setIndex(savedOperation.getIndex() + offset);
- targetCommand.addOperation(targetOperation);
- savedCommand.addOperation(savedOperation);
- }
- /**
- * 服务端插入的行在当前行的上方
- */
- if (targetOperation.getIndex() >= savedOperation.getHeight()) {
- var _offset = targetOperation.getIndex() + savedOperation.getCount();
- targetOperation.setIndex(targetOperation.getIndex() + _offset);
- targetCommand.addOperation(targetOperation);
- savedCommand.addOperation(savedOperation);
- }
- /**
- * 服务端插入的行被当前行包含
- */
- if (targetOperation.getIndex() <= savedOperation.getIndex() && targetOperation.getHeight() >= savedOperation.getHeight()) {
- var spliceCursor = savedOperation.getIndex() - targetOperation.getIndex();
- var prevDataBuffer = targetOperation.getBuffer().getData().splice(0, spliceCursor);
- var nextDataBuffer = targetOperation.getBuffer().getData().splice(spliceCursor);
- var prevOperation = new internal_1.InsertRow({
- describe: 'InsertRowOperation',
- buffer: new ot_core_1.SwapData({
- data: prevDataBuffer,
- describe: 'DataBuffer'
- }),
- index: targetOperation.getIndex(),
- count: savedOperation.getIndex() - targetOperation.getIndex()
- });
- var nextOperation = new internal_1.InsertRow({
- describe: 'InsertRowOperation',
- buffer: new ot_core_1.SwapData({
- data: nextDataBuffer,
- describe: 'DataBuffer'
- }),
- index: savedOperation.getCount(),
- count: targetOperation.getHeight() - savedOperation.getIndex()
- });
- targetCommand.addOperation(prevOperation);
- targetCommand.addOperation(nextOperation);
- }
- /**
- * 服务端插入的行包含当前行
- */
- if (targetOperation.getIndex() >= savedOperation.getIndex() && targetOperation.getHeight() <= savedOperation.getHeight()) {// TODO ....
- }
- /**
- * 服务端插入的行和当前行上交叉
- */
- if (targetOperation.getIndex() > savedOperation.getIndex() && targetOperation.getIndex() < savedOperation.getHeight() && targetOperation.getHeight() >= savedOperation.getHeight()) {// TODO ..
- // ...
- }
- /**
- * 服务端插入的行和当前行下交叉
- */
- if (targetOperation.getIndex() <= savedOperation.getIndex() && targetOperation.getHeight() > savedOperation.getIndex() && targetOperation.getHeight() < savedOperation.getHeight()) {// TODO ...
- //
- }
- };
- });
- return conflict;
- }
- exports.CreateConflict = CreateConflict;
- /***/ }),
- /***/ "./src/client.ts":
- /*!***********************!*\
- !*** ./src/client.ts ***!
- \***********************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, {
- enumerable: true,
- get: function get() {
- return m[k];
- }
- });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) {
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- }
- };
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.SwapData = exports.Command = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- Object.defineProperty(exports, "Command", ({
- enumerable: true,
- get: function get() {
- return ot_core_1.Command;
- }
- }));
- Object.defineProperty(exports, "SwapData", ({
- enumerable: true,
- get: function get() {
- return ot_core_1.SwapData;
- }
- }));
- __exportStar(__webpack_require__(/*! ./client/Client */ "./src/client/Client.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/InsertColumn */ "./src/operated/InsertColumn.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/InsertRow */ "./src/operated/InsertRow.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/RemoveColumn */ "./src/operated/RemoveColumn.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/RemoveRow */ "./src/operated/RemoveRow.ts"), exports);
- /***/ }),
- /***/ "./src/client/Client.ts":
- /*!******************************!*\
- !*** ./src/client/Client.ts ***!
- \******************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.Client = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
- __webpack_require__(/*! ../basics/Bootstrap */ "./src/basics/Bootstrap.ts");
- var Client = /*#__PURE__*/function (_ot_core_1$ClientSock) {
- _inherits(Client, _ot_core_1$ClientSock);
- var _super = _createSuper(Client);
- function Client(post) {
- _classCallCheck(this, Client);
- return _super.call(this, {
- url: post,
- conflict: (0, internal_1.CreateConflict)()
- });
- }
- return _createClass(Client);
- }(ot_core_1.ClientSocket);
- exports.Client = Client;
- /***/ }),
- /***/ "./src/internal.ts":
- /*!*************************!*\
- !*** ./src/internal.ts ***!
- \*************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, {
- enumerable: true,
- get: function get() {
- return m[k];
- }
- });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) {
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- }
- };
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- __exportStar(__webpack_require__(/*! ./operated/InsertColumn */ "./src/operated/InsertColumn.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/InsertRow */ "./src/operated/InsertRow.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/RemoveColumn */ "./src/operated/RemoveColumn.ts"), exports);
- __exportStar(__webpack_require__(/*! ./operated/RemoveRow */ "./src/operated/RemoveRow.ts"), exports);
- __exportStar(__webpack_require__(/*! ./basics/CreateConflict */ "./src/basics/CreateConflict.ts"), exports);
- /***/ }),
- /***/ "./src/operated/InsertColumn.ts":
- /*!**************************************!*\
- !*** ./src/operated/InsertColumn.ts ***!
- \**************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.InsertColumn = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var InsertColumn = /*#__PURE__*/function () {
- function InsertColumn() {
- _classCallCheck(this, InsertColumn);
- this._describe = 'InsertColumn';
- for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
- parameter[_key] = arguments[_key];
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
- this._index = 0;
- this._count = 0;
- this._buffer = new ot_core_1.SwapData();
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
- var serialize = parameter[0];
- this._index = serialize.index;
- this._count = serialize.count;
- this._buffer = ot_core_1.Deserialize.getInstance().formObject(serialize.buffer, new ot_core_1.SwapData());
- }
- }
- _createClass(InsertColumn, [{
- key: "apply",
- value: function apply(resource) {}
- }, {
- key: "setIndex",
- value: function setIndex(index) {
- this._index = index;
- }
- }, {
- key: "setCount",
- value: function setCount(count) {
- this._count = count;
- }
- }, {
- key: "getIndex",
- value: function getIndex() {
- return this._index;
- }
- }, {
- key: "getCount",
- value: function getCount() {
- return this._count;
- }
- }, {
- key: "clone",
- value: function clone() {
- var clone = new InsertColumn();
- clone._index = this._index;
- clone._count = this._count;
- clone._buffer = this._buffer.clone();
- return clone;
- }
- }, {
- key: "toJSON",
- value: function toJSON() {
- return {
- describe: this._describe,
- index: this._index,
- count: this._count,
- buffer: this._buffer
- };
- }
- }]);
- return InsertColumn;
- }();
- exports.InsertColumn = InsertColumn;
- /***/ }),
- /***/ "./src/operated/InsertRow.ts":
- /*!***********************************!*\
- !*** ./src/operated/InsertRow.ts ***!
- \***********************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.InsertRow = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var InsertRow = /*#__PURE__*/function () {
- function InsertRow() {
- _classCallCheck(this, InsertRow);
- this._describe = 'InsertRow';
- for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
- parameter[_key] = arguments[_key];
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
- this._index = 0;
- this._count = 0;
- this._buffer = new ot_core_1.SwapData();
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
- var serialize = parameter[0];
- this._index = serialize.index;
- this._count = serialize.count;
- this._buffer = ot_core_1.Deserialize.getInstance().formObject(serialize.buffer, new ot_core_1.SwapData());
- }
- }
- _createClass(InsertRow, [{
- key: "apply",
- value: function apply(resource) {
- var data = this._buffer.getData();
- var index = this._index;
- var count = this._count;
- if (data) {
- resource.splice.apply(resource, [index, 0].concat(_toConsumableArray(data)));
- } else {
- var empty = new Array(count).fill([]);
- resource.splice.apply(resource, [index, 0].concat(_toConsumableArray(empty)));
- }
- }
- }, {
- key: "setIndex",
- value: function setIndex(index) {
- this._index = index;
- }
- }, {
- key: "setCount",
- value: function setCount(count) {
- this._count = count;
- }
- }, {
- key: "getIndex",
- value: function getIndex() {
- return this._index;
- }
- }, {
- key: "getCount",
- value: function getCount() {
- return this._count;
- }
- }, {
- key: "getHeight",
- value: function getHeight() {
- return this._index + this._count;
- }
- }, {
- key: "getBuffer",
- value: function getBuffer() {
- return this._buffer;
- }
- }, {
- key: "clone",
- value: function clone() {
- var clone = new InsertRow();
- clone._index = this._index;
- clone._count = this._count;
- clone._buffer = this._buffer.clone();
- return clone;
- }
- }, {
- key: "toJSON",
- value: function toJSON() {
- return {
- describe: this._describe,
- index: this._index,
- count: this._count,
- buffer: this._buffer
- };
- }
- }]);
- return InsertRow;
- }();
- exports.InsertRow = InsertRow;
- /***/ }),
- /***/ "./src/operated/RemoveColumn.ts":
- /*!**************************************!*\
- !*** ./src/operated/RemoveColumn.ts ***!
- \**************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.RemoveColumn = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var RemoveColumn = /*#__PURE__*/function () {
- function RemoveColumn() {
- _classCallCheck(this, RemoveColumn);
- this._describe = 'RemoveColumn';
- for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
- parameter[_key] = arguments[_key];
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
- this._index = 0;
- this._count = 0;
- this._buffer = new ot_core_1.SwapData();
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
- var serialize = parameter[0];
- this._index = serialize.index;
- this._count = serialize.count;
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 2)) {
- var _serialize = parameter[0];
- var buffer = parameter[1];
- this._index = _serialize.index;
- this._count = _serialize.count;
- this._buffer = buffer;
- }
- }
- _createClass(RemoveColumn, [{
- key: "apply",
- value: function apply(resource) {}
- }, {
- key: "setIndex",
- value: function setIndex(index) {
- this._index = index;
- }
- }, {
- key: "setCount",
- value: function setCount(count) {
- this._count = count;
- }
- }, {
- key: "getIndex",
- value: function getIndex() {
- return this._index;
- }
- }, {
- key: "getCount",
- value: function getCount() {
- return this._count;
- }
- }, {
- key: "clone",
- value: function clone() {
- var clone = new RemoveColumn();
- clone._index = this._index;
- clone._count = this._count;
- clone._buffer = this._buffer.clone();
- return clone;
- }
- }, {
- key: "toJSON",
- value: function toJSON() {
- return {
- describe: this._describe,
- index: this._index,
- count: this._count
- };
- }
- }]);
- return RemoveColumn;
- }();
- exports.RemoveColumn = RemoveColumn;
- /***/ }),
- /***/ "./src/operated/RemoveRow.ts":
- /*!***********************************!*\
- !*** ./src/operated/RemoveRow.ts ***!
- \***********************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- Object.defineProperty(exports, "__esModule", ({
- value: true
- }));
- exports.RemoveRow = void 0;
- var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
- var RemoveRow = /*#__PURE__*/function () {
- function RemoveRow() {
- _classCallCheck(this, RemoveRow);
- this._describe = 'RemoveRow';
- for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
- parameter[_key] = arguments[_key];
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
- this._index = 0;
- this._count = 0;
- this._buffer = new ot_core_1.SwapData();
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
- var serialize = parameter[0];
- this._index = serialize.index;
- this._count = serialize.count;
- return;
- }
- if (ot_core_1.TransformUtils.hasLength(parameter, 2)) {
- var _serialize = parameter[0];
- var buffer = parameter[1];
- this._index = _serialize.index;
- this._count = _serialize.count;
- this._buffer = buffer;
- }
- }
- _createClass(RemoveRow, [{
- key: "apply",
- value: function apply(resource) {}
- }, {
- key: "setIndex",
- value: function setIndex(index) {
- this._index = index;
- }
- }, {
- key: "setCount",
- value: function setCount(count) {
- this._count = count;
- }
- }, {
- key: "getIndex",
- value: function getIndex() {
- return this._index;
- }
- }, {
- key: "getCount",
- value: function getCount() {
- return this._count;
- }
- }, {
- key: "clone",
- value: function clone() {
- var clone = new RemoveRow();
- clone._index = this._index;
- clone._count = this._count;
- clone._buffer = this._buffer.clone();
- return clone;
- }
- }, {
- key: "toJSON",
- value: function toJSON() {
- return {
- describe: this._describe,
- index: this._index,
- count: this._count
- };
- }
- }]);
- return RemoveRow;
- }();
- exports.RemoveRow = RemoveRow;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js":
- /*!********************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js ***!
- \********************************************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports["default"] = (() => {
- if (typeof self !== "undefined") {
- return self;
- }
- else if (typeof window !== "undefined") {
- return window;
- }
- else {
- return Function("return this")();
- }
- })();
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/index.js":
- /*!*******************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/index.js ***!
- \*******************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.installTimerFunctions = exports.transports = exports.Transport = exports.protocol = exports.Socket = void 0;
- const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/engine.io-client/build/cjs/socket.js");
- Object.defineProperty(exports, "Socket", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));
- exports.protocol = socket_js_1.Socket.protocol;
- var transport_js_1 = __webpack_require__(/*! ./transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
- Object.defineProperty(exports, "Transport", ({ enumerable: true, get: function () { return transport_js_1.Transport; } }));
- var index_js_1 = __webpack_require__(/*! ./transports/index.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js");
- Object.defineProperty(exports, "transports", ({ enumerable: true, get: function () { return index_js_1.transports; } }));
- var util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
- Object.defineProperty(exports, "installTimerFunctions", ({ enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }));
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/socket.js":
- /*!********************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/socket.js ***!
- \********************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Socket = void 0;
- const index_js_1 = __webpack_require__(/*! ./transports/index.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js");
- const util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
- const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
- const parseuri_1 = __importDefault(__webpack_require__(/*! parseuri */ "../ot-core/node_modules/parseuri/index.js"));
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
- const debug = (0, debug_1.default)("engine.io-client:socket"); // debug()
- class Socket extends component_emitter_1.Emitter {
- /**
- * Socket constructor.
- *
- * @param {String|Object} uri or options
- * @param {Object} opts - options
- * @api public
- */
- constructor(uri, opts = {}) {
- super();
- if (uri && "object" === typeof uri) {
- opts = uri;
- uri = null;
- }
- if (uri) {
- uri = (0, parseuri_1.default)(uri);
- opts.hostname = uri.host;
- opts.secure = uri.protocol === "https" || uri.protocol === "wss";
- opts.port = uri.port;
- if (uri.query)
- opts.query = uri.query;
- }
- else if (opts.host) {
- opts.hostname = (0, parseuri_1.default)(opts.host).host;
- }
- (0, util_js_1.installTimerFunctions)(this, opts);
- this.secure =
- null != opts.secure
- ? opts.secure
- : typeof location !== "undefined" && "https:" === location.protocol;
- if (opts.hostname && !opts.port) {
- // if no port is specified manually, use the protocol default
- opts.port = this.secure ? "443" : "80";
- }
- this.hostname =
- opts.hostname ||
- (typeof location !== "undefined" ? location.hostname : "localhost");
- this.port =
- opts.port ||
- (typeof location !== "undefined" && location.port
- ? location.port
- : this.secure
- ? "443"
- : "80");
- this.transports = opts.transports || ["polling", "websocket"];
- this.readyState = "";
- this.writeBuffer = [];
- this.prevBufferLen = 0;
- this.opts = Object.assign({
- path: "/engine.io",
- agent: false,
- withCredentials: false,
- upgrade: true,
- timestampParam: "t",
- rememberUpgrade: false,
- rejectUnauthorized: true,
- perMessageDeflate: {
- threshold: 1024
- },
- transportOptions: {},
- closeOnBeforeunload: true
- }, opts);
- this.opts.path = this.opts.path.replace(/\/$/, "") + "/";
- if (typeof this.opts.query === "string") {
- this.opts.query = parseqs_1.default.decode(this.opts.query);
- }
- // set on handshake
- this.id = null;
- this.upgrades = null;
- this.pingInterval = null;
- this.pingTimeout = null;
- // set on heartbeat
- this.pingTimeoutTimer = null;
- if (typeof addEventListener === "function") {
- if (this.opts.closeOnBeforeunload) {
- // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener
- // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is
- // closed/reloaded)
- addEventListener("beforeunload", () => {
- if (this.transport) {
- // silently close the transport
- this.transport.removeAllListeners();
- this.transport.close();
- }
- }, false);
- }
- if (this.hostname !== "localhost") {
- this.offlineEventListener = () => {
- this.onClose("transport close");
- };
- addEventListener("offline", this.offlineEventListener, false);
- }
- }
- this.open();
- }
- /**
- * Creates transport of the given type.
- *
- * @param {String} transport name
- * @return {Transport}
- * @api private
- */
- createTransport(name) {
- debug('creating transport "%s"', name);
- const query = clone(this.opts.query);
- // append engine.io protocol identifier
- query.EIO = engine_io_parser_1.protocol;
- // transport name
- query.transport = name;
- // session id if we already have one
- if (this.id)
- query.sid = this.id;
- const opts = Object.assign({}, this.opts.transportOptions[name], this.opts, {
- query,
- socket: this,
- hostname: this.hostname,
- secure: this.secure,
- port: this.port
- });
- debug("options: %j", opts);
- return new index_js_1.transports[name](opts);
- }
- /**
- * Initializes transport to use and starts probe.
- *
- * @api private
- */
- open() {
- let transport;
- if (this.opts.rememberUpgrade &&
- Socket.priorWebsocketSuccess &&
- this.transports.indexOf("websocket") !== -1) {
- transport = "websocket";
- }
- else if (0 === this.transports.length) {
- // Emit error on next tick so it can be listened to
- this.setTimeoutFn(() => {
- this.emitReserved("error", "No transports available");
- }, 0);
- return;
- }
- else {
- transport = this.transports[0];
- }
- this.readyState = "opening";
- // Retry with the next transport if the transport is disabled (jsonp: false)
- try {
- transport = this.createTransport(transport);
- }
- catch (e) {
- debug("error while creating transport: %s", e);
- this.transports.shift();
- this.open();
- return;
- }
- transport.open();
- this.setTransport(transport);
- }
- /**
- * Sets the current transport. Disables the existing one (if any).
- *
- * @api private
- */
- setTransport(transport) {
- debug("setting transport %s", transport.name);
- if (this.transport) {
- debug("clearing existing transport %s", this.transport.name);
- this.transport.removeAllListeners();
- }
- // set up transport
- this.transport = transport;
- // set up transport listeners
- transport
- .on("drain", this.onDrain.bind(this))
- .on("packet", this.onPacket.bind(this))
- .on("error", this.onError.bind(this))
- .on("close", () => {
- this.onClose("transport close");
- });
- }
- /**
- * Probes a transport.
- *
- * @param {String} transport name
- * @api private
- */
- probe(name) {
- debug('probing transport "%s"', name);
- let transport = this.createTransport(name);
- let failed = false;
- Socket.priorWebsocketSuccess = false;
- const onTransportOpen = () => {
- if (failed)
- return;
- debug('probe transport "%s" opened', name);
- transport.send([{ type: "ping", data: "probe" }]);
- transport.once("packet", msg => {
- if (failed)
- return;
- if ("pong" === msg.type && "probe" === msg.data) {
- debug('probe transport "%s" pong', name);
- this.upgrading = true;
- this.emitReserved("upgrading", transport);
- if (!transport)
- return;
- Socket.priorWebsocketSuccess = "websocket" === transport.name;
- debug('pausing current transport "%s"', this.transport.name);
- this.transport.pause(() => {
- if (failed)
- return;
- if ("closed" === this.readyState)
- return;
- debug("changing transport and sending upgrade packet");
- cleanup();
- this.setTransport(transport);
- transport.send([{ type: "upgrade" }]);
- this.emitReserved("upgrade", transport);
- transport = null;
- this.upgrading = false;
- this.flush();
- });
- }
- else {
- debug('probe transport "%s" failed', name);
- const err = new Error("probe error");
- // @ts-ignore
- err.transport = transport.name;
- this.emitReserved("upgradeError", err);
- }
- });
- };
- function freezeTransport() {
- if (failed)
- return;
- // Any callback called by transport should be ignored since now
- failed = true;
- cleanup();
- transport.close();
- transport = null;
- }
- // Handle any error that happens while probing
- const onerror = err => {
- const error = new Error("probe error: " + err);
- // @ts-ignore
- error.transport = transport.name;
- freezeTransport();
- debug('probe transport "%s" failed because of error: %s', name, err);
- this.emitReserved("upgradeError", error);
- };
- function onTransportClose() {
- onerror("transport closed");
- }
- // When the socket is closed while we're probing
- function onclose() {
- onerror("socket closed");
- }
- // When the socket is upgraded while we're probing
- function onupgrade(to) {
- if (transport && to.name !== transport.name) {
- debug('"%s" works - aborting "%s"', to.name, transport.name);
- freezeTransport();
- }
- }
- // Remove all listeners on the transport and on self
- const cleanup = () => {
- transport.removeListener("open", onTransportOpen);
- transport.removeListener("error", onerror);
- transport.removeListener("close", onTransportClose);
- this.off("close", onclose);
- this.off("upgrading", onupgrade);
- };
- transport.once("open", onTransportOpen);
- transport.once("error", onerror);
- transport.once("close", onTransportClose);
- this.once("close", onclose);
- this.once("upgrading", onupgrade);
- transport.open();
- }
- /**
- * Called when connection is deemed open.
- *
- * @api private
- */
- onOpen() {
- debug("socket open");
- this.readyState = "open";
- Socket.priorWebsocketSuccess = "websocket" === this.transport.name;
- this.emitReserved("open");
- this.flush();
- // we check for `readyState` in case an `open`
- // listener already closed the socket
- if ("open" === this.readyState &&
- this.opts.upgrade &&
- this.transport.pause) {
- debug("starting upgrade probes");
- let i = 0;
- const l = this.upgrades.length;
- for (; i < l; i++) {
- this.probe(this.upgrades[i]);
- }
- }
- }
- /**
- * Handles a packet.
- *
- * @api private
- */
- onPacket(packet) {
- if ("opening" === this.readyState ||
- "open" === this.readyState ||
- "closing" === this.readyState) {
- debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
- this.emitReserved("packet", packet);
- // Socket is live - any packet counts
- this.emitReserved("heartbeat");
- switch (packet.type) {
- case "open":
- this.onHandshake(JSON.parse(packet.data));
- break;
- case "ping":
- this.resetPingTimeout();
- this.sendPacket("pong");
- this.emitReserved("ping");
- this.emitReserved("pong");
- break;
- case "error":
- const err = new Error("server error");
- // @ts-ignore
- err.code = packet.data;
- this.onError(err);
- break;
- case "message":
- this.emitReserved("data", packet.data);
- this.emitReserved("message", packet.data);
- break;
- }
- }
- else {
- debug('packet received with socket readyState "%s"', this.readyState);
- }
- }
- /**
- * Called upon handshake completion.
- *
- * @param {Object} data - handshake obj
- * @api private
- */
- onHandshake(data) {
- this.emitReserved("handshake", data);
- this.id = data.sid;
- this.transport.query.sid = data.sid;
- this.upgrades = this.filterUpgrades(data.upgrades);
- this.pingInterval = data.pingInterval;
- this.pingTimeout = data.pingTimeout;
- this.onOpen();
- // In case open handler closes socket
- if ("closed" === this.readyState)
- return;
- this.resetPingTimeout();
- }
- /**
- * Sets and resets ping timeout timer based on server pings.
- *
- * @api private
- */
- resetPingTimeout() {
- this.clearTimeoutFn(this.pingTimeoutTimer);
- this.pingTimeoutTimer = this.setTimeoutFn(() => {
- this.onClose("ping timeout");
- }, this.pingInterval + this.pingTimeout);
- if (this.opts.autoUnref) {
- this.pingTimeoutTimer.unref();
- }
- }
- /**
- * Called on `drain` event
- *
- * @api private
- */
- onDrain() {
- this.writeBuffer.splice(0, this.prevBufferLen);
- // setting prevBufferLen = 0 is very important
- // for example, when upgrading, upgrade packet is sent over,
- // and a nonzero prevBufferLen could cause problems on `drain`
- this.prevBufferLen = 0;
- if (0 === this.writeBuffer.length) {
- this.emitReserved("drain");
- }
- else {
- this.flush();
- }
- }
- /**
- * Flush write buffers.
- *
- * @api private
- */
- flush() {
- if ("closed" !== this.readyState &&
- this.transport.writable &&
- !this.upgrading &&
- this.writeBuffer.length) {
- debug("flushing %d packets in socket", this.writeBuffer.length);
- this.transport.send(this.writeBuffer);
- // keep track of current length of writeBuffer
- // splice writeBuffer and callbackBuffer on `drain`
- this.prevBufferLen = this.writeBuffer.length;
- this.emitReserved("flush");
- }
- }
- /**
- * Sends a message.
- *
- * @param {String} message.
- * @param {Function} callback function.
- * @param {Object} options.
- * @return {Socket} for chaining.
- * @api public
- */
- write(msg, options, fn) {
- this.sendPacket("message", msg, options, fn);
- return this;
- }
- send(msg, options, fn) {
- this.sendPacket("message", msg, options, fn);
- return this;
- }
- /**
- * Sends a packet.
- *
- * @param {String} packet type.
- * @param {String} data.
- * @param {Object} options.
- * @param {Function} callback function.
- * @api private
- */
- sendPacket(type, data, options, fn) {
- if ("function" === typeof data) {
- fn = data;
- data = undefined;
- }
- if ("function" === typeof options) {
- fn = options;
- options = null;
- }
- if ("closing" === this.readyState || "closed" === this.readyState) {
- return;
- }
- options = options || {};
- options.compress = false !== options.compress;
- const packet = {
- type: type,
- data: data,
- options: options
- };
- this.emitReserved("packetCreate", packet);
- this.writeBuffer.push(packet);
- if (fn)
- this.once("flush", fn);
- this.flush();
- }
- /**
- * Closes the connection.
- *
- * @api public
- */
- close() {
- const close = () => {
- this.onClose("forced close");
- debug("socket closing - telling transport to close");
- this.transport.close();
- };
- const cleanupAndClose = () => {
- this.off("upgrade", cleanupAndClose);
- this.off("upgradeError", cleanupAndClose);
- close();
- };
- const waitForUpgrade = () => {
- // wait for upgrade to finish since we can't send packets while pausing a transport
- this.once("upgrade", cleanupAndClose);
- this.once("upgradeError", cleanupAndClose);
- };
- if ("opening" === this.readyState || "open" === this.readyState) {
- this.readyState = "closing";
- if (this.writeBuffer.length) {
- this.once("drain", () => {
- if (this.upgrading) {
- waitForUpgrade();
- }
- else {
- close();
- }
- });
- }
- else if (this.upgrading) {
- waitForUpgrade();
- }
- else {
- close();
- }
- }
- return this;
- }
- /**
- * Called upon transport error
- *
- * @api private
- */
- onError(err) {
- debug("socket error %j", err);
- Socket.priorWebsocketSuccess = false;
- this.emitReserved("error", err);
- this.onClose("transport error", err);
- }
- /**
- * Called upon transport close.
- *
- * @api private
- */
- onClose(reason, desc) {
- if ("opening" === this.readyState ||
- "open" === this.readyState ||
- "closing" === this.readyState) {
- debug('socket close with reason: "%s"', reason);
- // clear timers
- this.clearTimeoutFn(this.pingTimeoutTimer);
- // stop event from firing again for transport
- this.transport.removeAllListeners("close");
- // ensure transport won't stay open
- this.transport.close();
- // ignore further transport communication
- this.transport.removeAllListeners();
- if (typeof removeEventListener === "function") {
- removeEventListener("offline", this.offlineEventListener, false);
- }
- // set ready state
- this.readyState = "closed";
- // clear session id
- this.id = null;
- // emit close event
- this.emitReserved("close", reason, desc);
- // clean buffers after, so users can still
- // grab the buffers on `close` event
- this.writeBuffer = [];
- this.prevBufferLen = 0;
- }
- }
- /**
- * Filters upgrades, returning only those matching client transports.
- *
- * @param {Array} server upgrades
- * @api private
- *
- */
- filterUpgrades(upgrades) {
- const filteredUpgrades = [];
- let i = 0;
- const j = upgrades.length;
- for (; i < j; i++) {
- if (~this.transports.indexOf(upgrades[i]))
- filteredUpgrades.push(upgrades[i]);
- }
- return filteredUpgrades;
- }
- }
- exports.Socket = Socket;
- Socket.protocol = engine_io_parser_1.protocol;
- function clone(obj) {
- const o = {};
- for (let i in obj) {
- if (obj.hasOwnProperty(i)) {
- o[i] = obj[i];
- }
- }
- return o;
- }
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js":
- /*!***********************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transport.js ***!
- \***********************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Transport = void 0;
- const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const debug = (0, debug_1.default)("engine.io-client:transport"); // debug()
- class Transport extends component_emitter_1.Emitter {
- /**
- * Transport abstract constructor.
- *
- * @param {Object} options.
- * @api private
- */
- constructor(opts) {
- super();
- this.writable = false;
- (0, util_js_1.installTimerFunctions)(this, opts);
- this.opts = opts;
- this.query = opts.query;
- this.readyState = "";
- this.socket = opts.socket;
- }
- /**
- * Emits an error.
- *
- * @param {String} str
- * @return {Transport} for chaining
- * @api protected
- */
- onError(msg, desc) {
- const err = new Error(msg);
- // @ts-ignore
- err.type = "TransportError";
- // @ts-ignore
- err.description = desc;
- super.emit("error", err);
- return this;
- }
- /**
- * Opens the transport.
- *
- * @api public
- */
- open() {
- if ("closed" === this.readyState || "" === this.readyState) {
- this.readyState = "opening";
- this.doOpen();
- }
- return this;
- }
- /**
- * Closes the transport.
- *
- * @api public
- */
- close() {
- if ("opening" === this.readyState || "open" === this.readyState) {
- this.doClose();
- this.onClose();
- }
- return this;
- }
- /**
- * Sends multiple packets.
- *
- * @param {Array} packets
- * @api public
- */
- send(packets) {
- if ("open" === this.readyState) {
- this.write(packets);
- }
- else {
- // this might happen if the transport was silently closed in the beforeunload event handler
- debug("transport is not open, discarding packets");
- }
- }
- /**
- * Called upon open
- *
- * @api protected
- */
- onOpen() {
- this.readyState = "open";
- this.writable = true;
- super.emit("open");
- }
- /**
- * Called with data.
- *
- * @param {String} data
- * @api protected
- */
- onData(data) {
- const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType);
- this.onPacket(packet);
- }
- /**
- * Called with a decoded packet.
- *
- * @api protected
- */
- onPacket(packet) {
- super.emit("packet", packet);
- }
- /**
- * Called upon close.
- *
- * @api protected
- */
- onClose() {
- this.readyState = "closed";
- super.emit("close");
- }
- }
- exports.Transport = Transport;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js":
- /*!******************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js ***!
- \******************************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.transports = void 0;
- const polling_xhr_js_1 = __webpack_require__(/*! ./polling-xhr.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js");
- const websocket_js_1 = __webpack_require__(/*! ./websocket.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js");
- exports.transports = {
- websocket: websocket_js_1.WS,
- polling: polling_xhr_js_1.XHR
- };
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js":
- /*!************************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js ***!
- \************************************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- /* global attachEvent */
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Request = exports.XHR = void 0;
- const xmlhttprequest_js_1 = __importDefault(__webpack_require__(/*! ./xmlhttprequest.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js"));
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
- const util_js_1 = __webpack_require__(/*! ../util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const polling_js_1 = __webpack_require__(/*! ./polling.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js");
- const debug = (0, debug_1.default)("engine.io-client:polling-xhr"); // debug()
- /**
- * Empty function
- */
- function empty() { }
- const hasXHR2 = (function () {
- const xhr = new xmlhttprequest_js_1.default({
- xdomain: false
- });
- return null != xhr.responseType;
- })();
- class XHR extends polling_js_1.Polling {
- /**
- * XHR Polling constructor.
- *
- * @param {Object} opts
- * @api public
- */
- constructor(opts) {
- super(opts);
- if (typeof location !== "undefined") {
- const isSSL = "https:" === location.protocol;
- let port = location.port;
- // some user agents have empty `location.port`
- if (!port) {
- port = isSSL ? "443" : "80";
- }
- this.xd =
- (typeof location !== "undefined" &&
- opts.hostname !== location.hostname) ||
- port !== opts.port;
- this.xs = opts.secure !== isSSL;
- }
- /**
- * XHR supports binary
- */
- const forceBase64 = opts && opts.forceBase64;
- this.supportsBinary = hasXHR2 && !forceBase64;
- }
- /**
- * Creates a request.
- *
- * @param {String} method
- * @api private
- */
- request(opts = {}) {
- Object.assign(opts, { xd: this.xd, xs: this.xs }, this.opts);
- return new Request(this.uri(), opts);
- }
- /**
- * Sends data.
- *
- * @param {String} data to send.
- * @param {Function} called upon flush.
- * @api private
- */
- doWrite(data, fn) {
- const req = this.request({
- method: "POST",
- data: data
- });
- req.on("success", fn);
- req.on("error", err => {
- this.onError("xhr post error", err);
- });
- }
- /**
- * Starts a poll cycle.
- *
- * @api private
- */
- doPoll() {
- debug("xhr poll");
- const req = this.request();
- req.on("data", this.onData.bind(this));
- req.on("error", err => {
- this.onError("xhr poll error", err);
- });
- this.pollXhr = req;
- }
- }
- exports.XHR = XHR;
- class Request extends component_emitter_1.Emitter {
- /**
- * Request constructor
- *
- * @param {Object} options
- * @api public
- */
- constructor(uri, opts) {
- super();
- (0, util_js_1.installTimerFunctions)(this, opts);
- this.opts = opts;
- this.method = opts.method || "GET";
- this.uri = uri;
- this.async = false !== opts.async;
- this.data = undefined !== opts.data ? opts.data : null;
- this.create();
- }
- /**
- * Creates the XHR object and sends the request.
- *
- * @api private
- */
- create() {
- const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
- opts.xdomain = !!this.opts.xd;
- opts.xscheme = !!this.opts.xs;
- const xhr = (this.xhr = new xmlhttprequest_js_1.default(opts));
- try {
- debug("xhr open %s: %s", this.method, this.uri);
- xhr.open(this.method, this.uri, this.async);
- try {
- if (this.opts.extraHeaders) {
- xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
- for (let i in this.opts.extraHeaders) {
- if (this.opts.extraHeaders.hasOwnProperty(i)) {
- xhr.setRequestHeader(i, this.opts.extraHeaders[i]);
- }
- }
- }
- }
- catch (e) { }
- if ("POST" === this.method) {
- try {
- xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
- }
- catch (e) { }
- }
- try {
- xhr.setRequestHeader("Accept", "*/*");
- }
- catch (e) { }
- // ie6 check
- if ("withCredentials" in xhr) {
- xhr.withCredentials = this.opts.withCredentials;
- }
- if (this.opts.requestTimeout) {
- xhr.timeout = this.opts.requestTimeout;
- }
- xhr.onreadystatechange = () => {
- if (4 !== xhr.readyState)
- return;
- if (200 === xhr.status || 1223 === xhr.status) {
- this.onLoad();
- }
- else {
- // make sure the `error` event handler that's user-set
- // does not throw in the same tick and gets caught here
- this.setTimeoutFn(() => {
- this.onError(typeof xhr.status === "number" ? xhr.status : 0);
- }, 0);
- }
- };
- debug("xhr data %s", this.data);
- xhr.send(this.data);
- }
- catch (e) {
- // Need to defer since .create() is called directly from the constructor
- // and thus the 'error' event can only be only bound *after* this exception
- // occurs. Therefore, also, we cannot throw here at all.
- this.setTimeoutFn(() => {
- this.onError(e);
- }, 0);
- return;
- }
- if (typeof document !== "undefined") {
- this.index = Request.requestsCount++;
- Request.requests[this.index] = this;
- }
- }
- /**
- * Called upon successful response.
- *
- * @api private
- */
- onSuccess() {
- this.emit("success");
- this.cleanup();
- }
- /**
- * Called if we have data.
- *
- * @api private
- */
- onData(data) {
- this.emit("data", data);
- this.onSuccess();
- }
- /**
- * Called upon error.
- *
- * @api private
- */
- onError(err) {
- this.emit("error", err);
- this.cleanup(true);
- }
- /**
- * Cleans up house.
- *
- * @api private
- */
- cleanup(fromError) {
- if ("undefined" === typeof this.xhr || null === this.xhr) {
- return;
- }
- this.xhr.onreadystatechange = empty;
- if (fromError) {
- try {
- this.xhr.abort();
- }
- catch (e) { }
- }
- if (typeof document !== "undefined") {
- delete Request.requests[this.index];
- }
- this.xhr = null;
- }
- /**
- * Called upon load.
- *
- * @api private
- */
- onLoad() {
- const data = this.xhr.responseText;
- if (data !== null) {
- this.onData(data);
- }
- }
- /**
- * Aborts the request.
- *
- * @api public
- */
- abort() {
- this.cleanup();
- }
- }
- exports.Request = Request;
- Request.requestsCount = 0;
- Request.requests = {};
- /**
- * Aborts pending requests when unloading the window. This is needed to prevent
- * memory leaks (e.g. when using IE) and to ensure that no spurious error is
- * emitted.
- */
- if (typeof document !== "undefined") {
- // @ts-ignore
- if (typeof attachEvent === "function") {
- // @ts-ignore
- attachEvent("onunload", unloadHandler);
- }
- else if (typeof addEventListener === "function") {
- const terminationEvent = "onpagehide" in globalThis_js_1.default ? "pagehide" : "unload";
- addEventListener(terminationEvent, unloadHandler, false);
- }
- }
- function unloadHandler() {
- for (let i in Request.requests) {
- if (Request.requests.hasOwnProperty(i)) {
- Request.requests[i].abort();
- }
- }
- }
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js":
- /*!********************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js ***!
- \********************************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Polling = void 0;
- const transport_js_1 = __webpack_require__(/*! ../transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const yeast_1 = __importDefault(__webpack_require__(/*! yeast */ "../ot-core/node_modules/yeast/index.js"));
- const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
- const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
- const debug = (0, debug_1.default)("engine.io-client:polling"); // debug()
- class Polling extends transport_js_1.Transport {
- constructor() {
- super(...arguments);
- this.polling = false;
- }
- /**
- * Transport name.
- */
- get name() {
- return "polling";
- }
- /**
- * Opens the socket (triggers polling). We write a PING message to determine
- * when the transport is open.
- *
- * @api private
- */
- doOpen() {
- this.poll();
- }
- /**
- * Pauses polling.
- *
- * @param {Function} callback upon buffers are flushed and transport is paused
- * @api private
- */
- pause(onPause) {
- this.readyState = "pausing";
- const pause = () => {
- debug("paused");
- this.readyState = "paused";
- onPause();
- };
- if (this.polling || !this.writable) {
- let total = 0;
- if (this.polling) {
- debug("we are currently polling - waiting to pause");
- total++;
- this.once("pollComplete", function () {
- debug("pre-pause polling complete");
- --total || pause();
- });
- }
- if (!this.writable) {
- debug("we are currently writing - waiting to pause");
- total++;
- this.once("drain", function () {
- debug("pre-pause writing complete");
- --total || pause();
- });
- }
- }
- else {
- pause();
- }
- }
- /**
- * Starts polling cycle.
- *
- * @api public
- */
- poll() {
- debug("polling");
- this.polling = true;
- this.doPoll();
- this.emit("poll");
- }
- /**
- * Overloads onData to detect payloads.
- *
- * @api private
- */
- onData(data) {
- debug("polling got data %s", data);
- const callback = packet => {
- // if its the first message we consider the transport open
- if ("opening" === this.readyState && packet.type === "open") {
- this.onOpen();
- }
- // if its a close packet, we close the ongoing requests
- if ("close" === packet.type) {
- this.onClose();
- return false;
- }
- // otherwise bypass onData and handle the message
- this.onPacket(packet);
- };
- // decode payload
- (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback);
- // if an event did not trigger closing
- if ("closed" !== this.readyState) {
- // if we got data we're not polling
- this.polling = false;
- this.emit("pollComplete");
- if ("open" === this.readyState) {
- this.poll();
- }
- else {
- debug('ignoring poll - transport state "%s"', this.readyState);
- }
- }
- }
- /**
- * For polling, send a close packet.
- *
- * @api private
- */
- doClose() {
- const close = () => {
- debug("writing close packet");
- this.write([{ type: "close" }]);
- };
- if ("open" === this.readyState) {
- debug("transport open - closing");
- close();
- }
- else {
- // in case we're trying to close while
- // handshaking is in progress (GH-164)
- debug("transport not open - deferring close");
- this.once("open", close);
- }
- }
- /**
- * Writes a packets payload.
- *
- * @param {Array} data packets
- * @param {Function} drain callback
- * @api private
- */
- write(packets) {
- this.writable = false;
- (0, engine_io_parser_1.encodePayload)(packets, data => {
- this.doWrite(data, () => {
- this.writable = true;
- this.emit("drain");
- });
- });
- }
- /**
- * Generates uri for connection.
- *
- * @api private
- */
- uri() {
- let query = this.query || {};
- const schema = this.opts.secure ? "https" : "http";
- let port = "";
- // cache busting is forced
- if (false !== this.opts.timestampRequests) {
- query[this.opts.timestampParam] = (0, yeast_1.default)();
- }
- if (!this.supportsBinary && !query.sid) {
- query.b64 = 1;
- }
- // avoid port if default for schema
- if (this.opts.port &&
- (("https" === schema && Number(this.opts.port) !== 443) ||
- ("http" === schema && Number(this.opts.port) !== 80))) {
- port = ":" + this.opts.port;
- }
- const encodedQuery = parseqs_1.default.encode(query);
- const ipv6 = this.opts.hostname.indexOf(":") !== -1;
- return (schema +
- "://" +
- (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) +
- port +
- this.opts.path +
- (encodedQuery.length ? "?" + encodedQuery : ""));
- }
- }
- exports.Polling = Polling;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js":
- /*!******************************************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js ***!
- \******************************************************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0;
- const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
- exports.nextTick = (() => {
- const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
- if (isPromiseAvailable) {
- return cb => Promise.resolve().then(cb);
- }
- else {
- return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
- }
- })();
- exports.WebSocket = globalThis_js_1.default.WebSocket || globalThis_js_1.default.MozWebSocket;
- exports.usingBrowserWebSocket = true;
- exports.defaultBinaryType = "arraybuffer";
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js":
- /*!**********************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js ***!
- \**********************************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.WS = void 0;
- const transport_js_1 = __webpack_require__(/*! ../transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
- const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
- const yeast_1 = __importDefault(__webpack_require__(/*! yeast */ "../ot-core/node_modules/yeast/index.js"));
- const util_js_1 = __webpack_require__(/*! ../util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
- const websocket_constructor_js_1 = __webpack_require__(/*! ./websocket-constructor.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js");
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
- const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug()
- // detect ReactNative environment
- const isReactNative = typeof navigator !== "undefined" &&
- typeof navigator.product === "string" &&
- navigator.product.toLowerCase() === "reactnative";
- class WS extends transport_js_1.Transport {
- /**
- * WebSocket transport constructor.
- *
- * @api {Object} connection options
- * @api public
- */
- constructor(opts) {
- super(opts);
- this.supportsBinary = !opts.forceBase64;
- }
- /**
- * Transport name.
- *
- * @api public
- */
- get name() {
- return "websocket";
- }
- /**
- * Opens socket.
- *
- * @api private
- */
- doOpen() {
- if (!this.check()) {
- // let probe timeout
- return;
- }
- const uri = this.uri();
- const protocols = this.opts.protocols;
- // React Native only supports the 'headers' option, and will print a warning if anything else is passed
- const opts = isReactNative
- ? {}
- : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
- if (this.opts.extraHeaders) {
- opts.headers = this.opts.extraHeaders;
- }
- try {
- this.ws =
- websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative
- ? protocols
- ? new websocket_constructor_js_1.WebSocket(uri, protocols)
- : new websocket_constructor_js_1.WebSocket(uri)
- : new websocket_constructor_js_1.WebSocket(uri, protocols, opts);
- }
- catch (err) {
- return this.emit("error", err);
- }
- this.ws.binaryType = this.socket.binaryType || websocket_constructor_js_1.defaultBinaryType;
- this.addEventListeners();
- }
- /**
- * Adds event listeners to the socket
- *
- * @api private
- */
- addEventListeners() {
- this.ws.onopen = () => {
- if (this.opts.autoUnref) {
- this.ws._socket.unref();
- }
- this.onOpen();
- };
- this.ws.onclose = this.onClose.bind(this);
- this.ws.onmessage = ev => this.onData(ev.data);
- this.ws.onerror = e => this.onError("websocket error", e);
- }
- /**
- * Writes data to socket.
- *
- * @param {Array} array of packets.
- * @api private
- */
- write(packets) {
- this.writable = false;
- // encodePacket efficient as it uses WS framing
- // no need for encodePayload
- for (let i = 0; i < packets.length; i++) {
- const packet = packets[i];
- const lastPacket = i === packets.length - 1;
- (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, data => {
- // always create a new object (GH-437)
- const opts = {};
- if (!websocket_constructor_js_1.usingBrowserWebSocket) {
- if (packet.options) {
- opts.compress = packet.options.compress;
- }
- if (this.opts.perMessageDeflate) {
- const len = "string" === typeof data ? Buffer.byteLength(data) : data.length;
- if (len < this.opts.perMessageDeflate.threshold) {
- opts.compress = false;
- }
- }
- }
- // Sometimes the websocket has already been closed but the browser didn't
- // have a chance of informing us about it yet, in that case send will
- // throw an error
- try {
- if (websocket_constructor_js_1.usingBrowserWebSocket) {
- // TypeError is thrown when passing the second argument on Safari
- this.ws.send(data);
- }
- else {
- this.ws.send(data, opts);
- }
- }
- catch (e) {
- debug("websocket closed before onclose event");
- }
- if (lastPacket) {
- // fake drain
- // defer to next tick to allow Socket to clear writeBuffer
- (0, websocket_constructor_js_1.nextTick)(() => {
- this.writable = true;
- this.emit("drain");
- }, this.setTimeoutFn);
- }
- });
- }
- }
- /**
- * Closes socket.
- *
- * @api private
- */
- doClose() {
- if (typeof this.ws !== "undefined") {
- this.ws.close();
- this.ws = null;
- }
- }
- /**
- * Generates uri for connection.
- *
- * @api private
- */
- uri() {
- let query = this.query || {};
- const schema = this.opts.secure ? "wss" : "ws";
- let port = "";
- // avoid port if default for schema
- if (this.opts.port &&
- (("wss" === schema && Number(this.opts.port) !== 443) ||
- ("ws" === schema && Number(this.opts.port) !== 80))) {
- port = ":" + this.opts.port;
- }
- // append timestamp to URI
- if (this.opts.timestampRequests) {
- query[this.opts.timestampParam] = (0, yeast_1.default)();
- }
- // communicate binary support capabilities
- if (!this.supportsBinary) {
- query.b64 = 1;
- }
- const encodedQuery = parseqs_1.default.encode(query);
- const ipv6 = this.opts.hostname.indexOf(":") !== -1;
- return (schema +
- "://" +
- (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) +
- port +
- this.opts.path +
- (encodedQuery.length ? "?" + encodedQuery : ""));
- }
- /**
- * Feature detection for WebSocket.
- *
- * @return {Boolean} whether this transport is available.
- * @api public
- */
- check() {
- return (!!websocket_constructor_js_1.WebSocket &&
- !("__initialize" in websocket_constructor_js_1.WebSocket && this.name === WS.prototype.name));
- }
- }
- exports.WS = WS;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js":
- /*!***********************************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js ***!
- \***********************************************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- // browser shim for xmlhttprequest module
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- const has_cors_1 = __importDefault(__webpack_require__(/*! has-cors */ "../ot-core/node_modules/has-cors/index.js"));
- const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
- function default_1(opts) {
- const xdomain = opts.xdomain;
- // XMLHttpRequest can be disabled on IE
- try {
- if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_1.default)) {
- return new XMLHttpRequest();
- }
- }
- catch (e) { }
- if (!xdomain) {
- try {
- return new globalThis_js_1.default[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
- }
- catch (e) { }
- }
- }
- exports["default"] = default_1;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-client/build/cjs/util.js":
- /*!******************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-client/build/cjs/util.js ***!
- \******************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.installTimerFunctions = exports.pick = void 0;
- const globalThis_js_1 = __importDefault(__webpack_require__(/*! ./globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
- function pick(obj, ...attr) {
- return attr.reduce((acc, k) => {
- if (obj.hasOwnProperty(k)) {
- acc[k] = obj[k];
- }
- return acc;
- }, {});
- }
- exports.pick = pick;
- // Keep a reference to the real timeout functions so they can be used when overridden
- const NATIVE_SET_TIMEOUT = setTimeout;
- const NATIVE_CLEAR_TIMEOUT = clearTimeout;
- function installTimerFunctions(obj, opts) {
- if (opts.useNativeTimers) {
- obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.default);
- obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.default);
- }
- else {
- obj.setTimeoutFn = setTimeout.bind(globalThis_js_1.default);
- obj.clearTimeoutFn = clearTimeout.bind(globalThis_js_1.default);
- }
- }
- exports.installTimerFunctions = installTimerFunctions;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js":
- /*!*********************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-parser/build/cjs/commons.js ***!
- \*********************************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;
- const PACKET_TYPES = Object.create(null); // no Map = no polyfill
- exports.PACKET_TYPES = PACKET_TYPES;
- PACKET_TYPES["open"] = "0";
- PACKET_TYPES["close"] = "1";
- PACKET_TYPES["ping"] = "2";
- PACKET_TYPES["pong"] = "3";
- PACKET_TYPES["message"] = "4";
- PACKET_TYPES["upgrade"] = "5";
- PACKET_TYPES["noop"] = "6";
- const PACKET_TYPES_REVERSE = Object.create(null);
- exports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;
- Object.keys(PACKET_TYPES).forEach(key => {
- PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
- });
- const ERROR_PACKET = { type: "error", data: "parser error" };
- exports.ERROR_PACKET = ERROR_PACKET;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js":
- /*!**********************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js ***!
- \**********************************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- const commons_js_1 = __webpack_require__(/*! ./commons.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js");
- const base64_arraybuffer_1 = __webpack_require__(/*! @socket.io/base64-arraybuffer */ "../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js");
- const withNativeArrayBuffer = typeof ArrayBuffer === "function";
- const decodePacket = (encodedPacket, binaryType) => {
- if (typeof encodedPacket !== "string") {
- return {
- type: "message",
- data: mapBinary(encodedPacket, binaryType)
- };
- }
- const type = encodedPacket.charAt(0);
- if (type === "b") {
- return {
- type: "message",
- data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
- };
- }
- const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];
- if (!packetType) {
- return commons_js_1.ERROR_PACKET;
- }
- return encodedPacket.length > 1
- ? {
- type: commons_js_1.PACKET_TYPES_REVERSE[type],
- data: encodedPacket.substring(1)
- }
- : {
- type: commons_js_1.PACKET_TYPES_REVERSE[type]
- };
- };
- const decodeBase64Packet = (data, binaryType) => {
- if (withNativeArrayBuffer) {
- const decoded = (0, base64_arraybuffer_1.decode)(data);
- return mapBinary(decoded, binaryType);
- }
- else {
- return { base64: true, data }; // fallback for old browsers
- }
- };
- const mapBinary = (data, binaryType) => {
- switch (binaryType) {
- case "blob":
- return data instanceof ArrayBuffer ? new Blob([data]) : data;
- case "arraybuffer":
- default:
- return data; // assuming the data is already an ArrayBuffer
- }
- };
- exports["default"] = decodePacket;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js":
- /*!**********************************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js ***!
- \**********************************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- const commons_js_1 = __webpack_require__(/*! ./commons.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js");
- const withNativeBlob = typeof Blob === "function" ||
- (typeof Blob !== "undefined" &&
- Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
- const withNativeArrayBuffer = typeof ArrayBuffer === "function";
- // ArrayBuffer.isView method is not defined in IE10
- const isView = obj => {
- return typeof ArrayBuffer.isView === "function"
- ? ArrayBuffer.isView(obj)
- : obj && obj.buffer instanceof ArrayBuffer;
- };
- const encodePacket = ({ type, data }, supportsBinary, callback) => {
- if (withNativeBlob && data instanceof Blob) {
- if (supportsBinary) {
- return callback(data);
- }
- else {
- return encodeBlobAsBase64(data, callback);
- }
- }
- else if (withNativeArrayBuffer &&
- (data instanceof ArrayBuffer || isView(data))) {
- if (supportsBinary) {
- return callback(data);
- }
- else {
- return encodeBlobAsBase64(new Blob([data]), callback);
- }
- }
- // plain string
- return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
- };
- const encodeBlobAsBase64 = (data, callback) => {
- const fileReader = new FileReader();
- fileReader.onload = function () {
- const content = fileReader.result.split(",")[1];
- callback("b" + content);
- };
- return fileReader.readAsDataURL(data);
- };
- exports["default"] = encodePacket;
- /***/ }),
- /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js":
- /*!*******************************************************************!*\
- !*** ../ot-core/node_modules/engine.io-parser/build/cjs/index.js ***!
- \*******************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0;
- const encodePacket_js_1 = __webpack_require__(/*! ./encodePacket.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js");
- exports.encodePacket = encodePacket_js_1.default;
- const decodePacket_js_1 = __webpack_require__(/*! ./decodePacket.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js");
- exports.decodePacket = decodePacket_js_1.default;
- const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
- const encodePayload = (packets, callback) => {
- // some packets may be added to the array while encoding, so the initial length must be saved
- const length = packets.length;
- const encodedPackets = new Array(length);
- let count = 0;
- packets.forEach((packet, i) => {
- // force base64 encoding for binary packets
- (0, encodePacket_js_1.default)(packet, false, encodedPacket => {
- encodedPackets[i] = encodedPacket;
- if (++count === length) {
- callback(encodedPackets.join(SEPARATOR));
- }
- });
- });
- };
- exports.encodePayload = encodePayload;
- const decodePayload = (encodedPayload, binaryType) => {
- const encodedPackets = encodedPayload.split(SEPARATOR);
- const packets = [];
- for (let i = 0; i < encodedPackets.length; i++) {
- const decodedPacket = (0, decodePacket_js_1.default)(encodedPackets[i], binaryType);
- packets.push(decodedPacket);
- if (decodedPacket.type === "error") {
- break;
- }
- }
- return packets;
- };
- exports.decodePayload = decodePayload;
- exports.protocol = 4;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/build/cjs/index.js":
- /*!*******************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/build/cjs/index.js ***!
- \*******************************************************************/
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports["default"] = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0;
- const url_js_1 = __webpack_require__(/*! ./url.js */ "../ot-core/node_modules/socket.io-client/build/cjs/url.js");
- const manager_js_1 = __webpack_require__(/*! ./manager.js */ "../ot-core/node_modules/socket.io-client/build/cjs/manager.js");
- Object.defineProperty(exports, "Manager", ({ enumerable: true, get: function () { return manager_js_1.Manager; } }));
- const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js");
- Object.defineProperty(exports, "Socket", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const debug = debug_1.default("socket.io-client"); // debug()
- /**
- * Managers cache.
- */
- const cache = {};
- function lookup(uri, opts) {
- if (typeof uri === "object") {
- opts = uri;
- uri = undefined;
- }
- opts = opts || {};
- const parsed = url_js_1.url(uri, opts.path || "/socket.io");
- const source = parsed.source;
- const id = parsed.id;
- const path = parsed.path;
- const sameNamespace = cache[id] && path in cache[id]["nsps"];
- const newConnection = opts.forceNew ||
- opts["force new connection"] ||
- false === opts.multiplex ||
- sameNamespace;
- let io;
- if (newConnection) {
- debug("ignoring socket cache for %s", source);
- io = new manager_js_1.Manager(source, opts);
- }
- else {
- if (!cache[id]) {
- debug("new io instance for %s", source);
- cache[id] = new manager_js_1.Manager(source, opts);
- }
- io = cache[id];
- }
- if (parsed.query && !opts.query) {
- opts.query = parsed.queryKey;
- }
- return io.socket(parsed.path, opts);
- }
- exports.io = lookup;
- exports.connect = lookup;
- exports["default"] = lookup;
- // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a
- // namespace (e.g. `io.connect(...)`), for backward compatibility
- Object.assign(lookup, {
- Manager: manager_js_1.Manager,
- Socket: socket_js_1.Socket,
- io: lookup,
- connect: lookup,
- });
- /**
- * Protocol version.
- *
- * @public
- */
- var socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js");
- Object.defineProperty(exports, "protocol", ({ enumerable: true, get: function () { return socket_io_parser_1.protocol; } }));
- module.exports = lookup;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/build/cjs/manager.js":
- /*!*********************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/build/cjs/manager.js ***!
- \*********************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Manager = void 0;
- const engine_io_client_1 = __webpack_require__(/*! engine.io-client */ "../ot-core/node_modules/engine.io-client/build/cjs/index.js");
- const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js");
- const parser = __importStar(__webpack_require__(/*! socket.io-parser */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js"));
- const on_js_1 = __webpack_require__(/*! ./on.js */ "../ot-core/node_modules/socket.io-client/build/cjs/on.js");
- const backo2_1 = __importDefault(__webpack_require__(/*! backo2 */ "../ot-core/node_modules/backo2/index.js"));
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const debug = debug_1.default("socket.io-client:manager"); // debug()
- class Manager extends component_emitter_1.Emitter {
- constructor(uri, opts) {
- var _a;
- super();
- this.nsps = {};
- this.subs = [];
- if (uri && "object" === typeof uri) {
- opts = uri;
- uri = undefined;
- }
- opts = opts || {};
- opts.path = opts.path || "/socket.io";
- this.opts = opts;
- engine_io_client_1.installTimerFunctions(this, opts);
- this.reconnection(opts.reconnection !== false);
- this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
- this.reconnectionDelay(opts.reconnectionDelay || 1000);
- this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
- this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
- this.backoff = new backo2_1.default({
- min: this.reconnectionDelay(),
- max: this.reconnectionDelayMax(),
- jitter: this.randomizationFactor(),
- });
- this.timeout(null == opts.timeout ? 20000 : opts.timeout);
- this._readyState = "closed";
- this.uri = uri;
- const _parser = opts.parser || parser;
- this.encoder = new _parser.Encoder();
- this.decoder = new _parser.Decoder();
- this._autoConnect = opts.autoConnect !== false;
- if (this._autoConnect)
- this.open();
- }
- reconnection(v) {
- if (!arguments.length)
- return this._reconnection;
- this._reconnection = !!v;
- return this;
- }
- reconnectionAttempts(v) {
- if (v === undefined)
- return this._reconnectionAttempts;
- this._reconnectionAttempts = v;
- return this;
- }
- reconnectionDelay(v) {
- var _a;
- if (v === undefined)
- return this._reconnectionDelay;
- this._reconnectionDelay = v;
- (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
- return this;
- }
- randomizationFactor(v) {
- var _a;
- if (v === undefined)
- return this._randomizationFactor;
- this._randomizationFactor = v;
- (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
- return this;
- }
- reconnectionDelayMax(v) {
- var _a;
- if (v === undefined)
- return this._reconnectionDelayMax;
- this._reconnectionDelayMax = v;
- (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
- return this;
- }
- timeout(v) {
- if (!arguments.length)
- return this._timeout;
- this._timeout = v;
- return this;
- }
- /**
- * Starts trying to reconnect if reconnection is enabled and we have not
- * started reconnecting yet
- *
- * @private
- */
- maybeReconnectOnOpen() {
- // Only try to reconnect if it's the first time we're connecting
- if (!this._reconnecting &&
- this._reconnection &&
- this.backoff.attempts === 0) {
- // keeps reconnection from firing twice for the same reconnection loop
- this.reconnect();
- }
- }
- /**
- * Sets the current transport `socket`.
- *
- * @param {Function} fn - optional, callback
- * @return self
- * @public
- */
- open(fn) {
- debug("readyState %s", this._readyState);
- if (~this._readyState.indexOf("open"))
- return this;
- debug("opening %s", this.uri);
- this.engine = new engine_io_client_1.Socket(this.uri, this.opts);
- const socket = this.engine;
- const self = this;
- this._readyState = "opening";
- this.skipReconnect = false;
- // emit `open`
- const openSubDestroy = on_js_1.on(socket, "open", function () {
- self.onopen();
- fn && fn();
- });
- // emit `error`
- const errorSub = on_js_1.on(socket, "error", (err) => {
- debug("error");
- self.cleanup();
- self._readyState = "closed";
- this.emitReserved("error", err);
- if (fn) {
- fn(err);
- }
- else {
- // Only do this if there is no fn to handle the error
- self.maybeReconnectOnOpen();
- }
- });
- if (false !== this._timeout) {
- const timeout = this._timeout;
- debug("connect attempt will timeout after %d", timeout);
- if (timeout === 0) {
- openSubDestroy(); // prevents a race condition with the 'open' event
- }
- // set timer
- const timer = this.setTimeoutFn(() => {
- debug("connect attempt timed out after %d", timeout);
- openSubDestroy();
- socket.close();
- // @ts-ignore
- socket.emit("error", new Error("timeout"));
- }, timeout);
- if (this.opts.autoUnref) {
- timer.unref();
- }
- this.subs.push(function subDestroy() {
- clearTimeout(timer);
- });
- }
- this.subs.push(openSubDestroy);
- this.subs.push(errorSub);
- return this;
- }
- /**
- * Alias for open()
- *
- * @return self
- * @public
- */
- connect(fn) {
- return this.open(fn);
- }
- /**
- * Called upon transport open.
- *
- * @private
- */
- onopen() {
- debug("open");
- // clear old subs
- this.cleanup();
- // mark as open
- this._readyState = "open";
- this.emitReserved("open");
- // add new subs
- const socket = this.engine;
- this.subs.push(on_js_1.on(socket, "ping", this.onping.bind(this)), on_js_1.on(socket, "data", this.ondata.bind(this)), on_js_1.on(socket, "error", this.onerror.bind(this)), on_js_1.on(socket, "close", this.onclose.bind(this)), on_js_1.on(this.decoder, "decoded", this.ondecoded.bind(this)));
- }
- /**
- * Called upon a ping.
- *
- * @private
- */
- onping() {
- this.emitReserved("ping");
- }
- /**
- * Called with data.
- *
- * @private
- */
- ondata(data) {
- this.decoder.add(data);
- }
- /**
- * Called when parser fully decodes a packet.
- *
- * @private
- */
- ondecoded(packet) {
- this.emitReserved("packet", packet);
- }
- /**
- * Called upon socket error.
- *
- * @private
- */
- onerror(err) {
- debug("error", err);
- this.emitReserved("error", err);
- }
- /**
- * Creates a new socket for the given `nsp`.
- *
- * @return {Socket}
- * @public
- */
- socket(nsp, opts) {
- let socket = this.nsps[nsp];
- if (!socket) {
- socket = new socket_js_1.Socket(this, nsp, opts);
- this.nsps[nsp] = socket;
- }
- return socket;
- }
- /**
- * Called upon a socket close.
- *
- * @param socket
- * @private
- */
- _destroy(socket) {
- const nsps = Object.keys(this.nsps);
- for (const nsp of nsps) {
- const socket = this.nsps[nsp];
- if (socket.active) {
- debug("socket %s is still active, skipping close", nsp);
- return;
- }
- }
- this._close();
- }
- /**
- * Writes a packet.
- *
- * @param packet
- * @private
- */
- _packet(packet) {
- debug("writing packet %j", packet);
- const encodedPackets = this.encoder.encode(packet);
- for (let i = 0; i < encodedPackets.length; i++) {
- this.engine.write(encodedPackets[i], packet.options);
- }
- }
- /**
- * Clean up transport subscriptions and packet buffer.
- *
- * @private
- */
- cleanup() {
- debug("cleanup");
- this.subs.forEach((subDestroy) => subDestroy());
- this.subs.length = 0;
- this.decoder.destroy();
- }
- /**
- * Close the current socket.
- *
- * @private
- */
- _close() {
- debug("disconnect");
- this.skipReconnect = true;
- this._reconnecting = false;
- if ("opening" === this._readyState) {
- // `onclose` will not fire because
- // an open event never happened
- this.cleanup();
- }
- this.backoff.reset();
- this._readyState = "closed";
- if (this.engine)
- this.engine.close();
- }
- /**
- * Alias for close()
- *
- * @private
- */
- disconnect() {
- return this._close();
- }
- /**
- * Called upon engine close.
- *
- * @private
- */
- onclose(reason) {
- debug("onclose");
- this.cleanup();
- this.backoff.reset();
- this._readyState = "closed";
- this.emitReserved("close", reason);
- if (this._reconnection && !this.skipReconnect) {
- this.reconnect();
- }
- }
- /**
- * Attempt a reconnection.
- *
- * @private
- */
- reconnect() {
- if (this._reconnecting || this.skipReconnect)
- return this;
- const self = this;
- if (this.backoff.attempts >= this._reconnectionAttempts) {
- debug("reconnect failed");
- this.backoff.reset();
- this.emitReserved("reconnect_failed");
- this._reconnecting = false;
- }
- else {
- const delay = this.backoff.duration();
- debug("will wait %dms before reconnect attempt", delay);
- this._reconnecting = true;
- const timer = this.setTimeoutFn(() => {
- if (self.skipReconnect)
- return;
- debug("attempting reconnect");
- this.emitReserved("reconnect_attempt", self.backoff.attempts);
- // check again for the case socket closed in above events
- if (self.skipReconnect)
- return;
- self.open((err) => {
- if (err) {
- debug("reconnect attempt error");
- self._reconnecting = false;
- self.reconnect();
- this.emitReserved("reconnect_error", err);
- }
- else {
- debug("reconnect success");
- self.onreconnect();
- }
- });
- }, delay);
- if (this.opts.autoUnref) {
- timer.unref();
- }
- this.subs.push(function subDestroy() {
- clearTimeout(timer);
- });
- }
- }
- /**
- * Called upon successful reconnect.
- *
- * @private
- */
- onreconnect() {
- const attempt = this.backoff.attempts;
- this._reconnecting = false;
- this.backoff.reset();
- this.emitReserved("reconnect", attempt);
- }
- }
- exports.Manager = Manager;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/build/cjs/on.js":
- /*!****************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/build/cjs/on.js ***!
- \****************************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.on = void 0;
- function on(obj, ev, fn) {
- obj.on(ev, fn);
- return function subDestroy() {
- obj.off(ev, fn);
- };
- }
- exports.on = on;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js":
- /*!********************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/build/cjs/socket.js ***!
- \********************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Socket = void 0;
- const socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js");
- const on_js_1 = __webpack_require__(/*! ./on.js */ "../ot-core/node_modules/socket.io-client/build/cjs/on.js");
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const debug = debug_1.default("socket.io-client:socket"); // debug()
- /**
- * Internal events.
- * These events can't be emitted by the user.
- */
- const RESERVED_EVENTS = Object.freeze({
- connect: 1,
- connect_error: 1,
- disconnect: 1,
- disconnecting: 1,
- // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
- newListener: 1,
- removeListener: 1,
- });
- class Socket extends component_emitter_1.Emitter {
- /**
- * `Socket` constructor.
- *
- * @public
- */
- constructor(io, nsp, opts) {
- super();
- this.connected = false;
- this.disconnected = true;
- this.receiveBuffer = [];
- this.sendBuffer = [];
- this.ids = 0;
- this.acks = {};
- this.flags = {};
- this.io = io;
- this.nsp = nsp;
- if (opts && opts.auth) {
- this.auth = opts.auth;
- }
- if (this.io._autoConnect)
- this.open();
- }
- /**
- * Subscribe to open, close and packet events
- *
- * @private
- */
- subEvents() {
- if (this.subs)
- return;
- const io = this.io;
- this.subs = [
- on_js_1.on(io, "open", this.onopen.bind(this)),
- on_js_1.on(io, "packet", this.onpacket.bind(this)),
- on_js_1.on(io, "error", this.onerror.bind(this)),
- on_js_1.on(io, "close", this.onclose.bind(this)),
- ];
- }
- /**
- * Whether the Socket will try to reconnect when its Manager connects or reconnects
- */
- get active() {
- return !!this.subs;
- }
- /**
- * "Opens" the socket.
- *
- * @public
- */
- connect() {
- if (this.connected)
- return this;
- this.subEvents();
- if (!this.io["_reconnecting"])
- this.io.open(); // ensure open
- if ("open" === this.io._readyState)
- this.onopen();
- return this;
- }
- /**
- * Alias for connect()
- */
- open() {
- return this.connect();
- }
- /**
- * Sends a `message` event.
- *
- * @return self
- * @public
- */
- send(...args) {
- args.unshift("message");
- this.emit.apply(this, args);
- return this;
- }
- /**
- * Override `emit`.
- * If the event is in `events`, it's emitted normally.
- *
- * @return self
- * @public
- */
- emit(ev, ...args) {
- if (RESERVED_EVENTS.hasOwnProperty(ev)) {
- throw new Error('"' + ev + '" is a reserved event name');
- }
- args.unshift(ev);
- const packet = {
- type: socket_io_parser_1.PacketType.EVENT,
- data: args,
- };
- packet.options = {};
- packet.options.compress = this.flags.compress !== false;
- // event ack callback
- if ("function" === typeof args[args.length - 1]) {
- debug("emitting packet with ack id %d", this.ids);
- this.acks[this.ids] = args.pop();
- packet.id = this.ids++;
- }
- const isTransportWritable = this.io.engine &&
- this.io.engine.transport &&
- this.io.engine.transport.writable;
- const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected);
- if (discardPacket) {
- debug("discard packet as the transport is not currently writable");
- }
- else if (this.connected) {
- this.packet(packet);
- }
- else {
- this.sendBuffer.push(packet);
- }
- this.flags = {};
- return this;
- }
- /**
- * Sends a packet.
- *
- * @param packet
- * @private
- */
- packet(packet) {
- packet.nsp = this.nsp;
- this.io._packet(packet);
- }
- /**
- * Called upon engine `open`.
- *
- * @private
- */
- onopen() {
- debug("transport is open - connecting");
- if (typeof this.auth == "function") {
- this.auth((data) => {
- this.packet({ type: socket_io_parser_1.PacketType.CONNECT, data });
- });
- }
- else {
- this.packet({ type: socket_io_parser_1.PacketType.CONNECT, data: this.auth });
- }
- }
- /**
- * Called upon engine or manager `error`.
- *
- * @param err
- * @private
- */
- onerror(err) {
- if (!this.connected) {
- this.emitReserved("connect_error", err);
- }
- }
- /**
- * Called upon engine `close`.
- *
- * @param reason
- * @private
- */
- onclose(reason) {
- debug("close (%s)", reason);
- this.connected = false;
- this.disconnected = true;
- delete this.id;
- this.emitReserved("disconnect", reason);
- }
- /**
- * Called with socket packet.
- *
- * @param packet
- * @private
- */
- onpacket(packet) {
- const sameNamespace = packet.nsp === this.nsp;
- if (!sameNamespace)
- return;
- switch (packet.type) {
- case socket_io_parser_1.PacketType.CONNECT:
- if (packet.data && packet.data.sid) {
- const id = packet.data.sid;
- this.onconnect(id);
- }
- else {
- this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
- }
- break;
- case socket_io_parser_1.PacketType.EVENT:
- this.onevent(packet);
- break;
- case socket_io_parser_1.PacketType.BINARY_EVENT:
- this.onevent(packet);
- break;
- case socket_io_parser_1.PacketType.ACK:
- this.onack(packet);
- break;
- case socket_io_parser_1.PacketType.BINARY_ACK:
- this.onack(packet);
- break;
- case socket_io_parser_1.PacketType.DISCONNECT:
- this.ondisconnect();
- break;
- case socket_io_parser_1.PacketType.CONNECT_ERROR:
- const err = new Error(packet.data.message);
- // @ts-ignore
- err.data = packet.data.data;
- this.emitReserved("connect_error", err);
- break;
- }
- }
- /**
- * Called upon a server event.
- *
- * @param packet
- * @private
- */
- onevent(packet) {
- const args = packet.data || [];
- debug("emitting event %j", args);
- if (null != packet.id) {
- debug("attaching ack callback to event");
- args.push(this.ack(packet.id));
- }
- if (this.connected) {
- this.emitEvent(args);
- }
- else {
- this.receiveBuffer.push(Object.freeze(args));
- }
- }
- emitEvent(args) {
- if (this._anyListeners && this._anyListeners.length) {
- const listeners = this._anyListeners.slice();
- for (const listener of listeners) {
- listener.apply(this, args);
- }
- }
- super.emit.apply(this, args);
- }
- /**
- * Produces an ack callback to emit with an event.
- *
- * @private
- */
- ack(id) {
- const self = this;
- let sent = false;
- return function (...args) {
- // prevent double callbacks
- if (sent)
- return;
- sent = true;
- debug("sending ack %j", args);
- self.packet({
- type: socket_io_parser_1.PacketType.ACK,
- id: id,
- data: args,
- });
- };
- }
- /**
- * Called upon a server acknowlegement.
- *
- * @param packet
- * @private
- */
- onack(packet) {
- const ack = this.acks[packet.id];
- if ("function" === typeof ack) {
- debug("calling ack %s with %j", packet.id, packet.data);
- ack.apply(this, packet.data);
- delete this.acks[packet.id];
- }
- else {
- debug("bad ack %s", packet.id);
- }
- }
- /**
- * Called upon server connect.
- *
- * @private
- */
- onconnect(id) {
- debug("socket connected with id %s", id);
- this.id = id;
- this.connected = true;
- this.disconnected = false;
- this.emitBuffered();
- this.emitReserved("connect");
- }
- /**
- * Emit buffered events (received and emitted).
- *
- * @private
- */
- emitBuffered() {
- this.receiveBuffer.forEach((args) => this.emitEvent(args));
- this.receiveBuffer = [];
- this.sendBuffer.forEach((packet) => this.packet(packet));
- this.sendBuffer = [];
- }
- /**
- * Called upon server disconnect.
- *
- * @private
- */
- ondisconnect() {
- debug("server disconnect (%s)", this.nsp);
- this.destroy();
- this.onclose("io server disconnect");
- }
- /**
- * Called upon forced client/server side disconnections,
- * this method ensures the manager stops tracking us and
- * that reconnections don't get triggered for this.
- *
- * @private
- */
- destroy() {
- if (this.subs) {
- // clean subscriptions to avoid reconnections
- this.subs.forEach((subDestroy) => subDestroy());
- this.subs = undefined;
- }
- this.io["_destroy"](this);
- }
- /**
- * Disconnects the socket manually.
- *
- * @return self
- * @public
- */
- disconnect() {
- if (this.connected) {
- debug("performing disconnect (%s)", this.nsp);
- this.packet({ type: socket_io_parser_1.PacketType.DISCONNECT });
- }
- // remove socket from pool
- this.destroy();
- if (this.connected) {
- // fire events
- this.onclose("io client disconnect");
- }
- return this;
- }
- /**
- * Alias for disconnect()
- *
- * @return self
- * @public
- */
- close() {
- return this.disconnect();
- }
- /**
- * Sets the compress flag.
- *
- * @param compress - if `true`, compresses the sending data
- * @return self
- * @public
- */
- compress(compress) {
- this.flags.compress = compress;
- return this;
- }
- /**
- * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
- * ready to send messages.
- *
- * @returns self
- * @public
- */
- get volatile() {
- this.flags.volatile = true;
- return this;
- }
- /**
- * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
- * callback.
- *
- * @param listener
- * @public
- */
- onAny(listener) {
- this._anyListeners = this._anyListeners || [];
- this._anyListeners.push(listener);
- return this;
- }
- /**
- * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
- * callback. The listener is added to the beginning of the listeners array.
- *
- * @param listener
- * @public
- */
- prependAny(listener) {
- this._anyListeners = this._anyListeners || [];
- this._anyListeners.unshift(listener);
- return this;
- }
- /**
- * Removes the listener that will be fired when any event is emitted.
- *
- * @param listener
- * @public
- */
- offAny(listener) {
- if (!this._anyListeners) {
- return this;
- }
- if (listener) {
- const listeners = this._anyListeners;
- for (let i = 0; i < listeners.length; i++) {
- if (listener === listeners[i]) {
- listeners.splice(i, 1);
- return this;
- }
- }
- }
- else {
- this._anyListeners = [];
- }
- return this;
- }
- /**
- * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
- * e.g. to remove listeners.
- *
- * @public
- */
- listenersAny() {
- return this._anyListeners || [];
- }
- }
- exports.Socket = Socket;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/build/cjs/url.js":
- /*!*****************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/build/cjs/url.js ***!
- \*****************************************************************/
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.url = void 0;
- const parseuri_1 = __importDefault(__webpack_require__(/*! parseuri */ "../ot-core/node_modules/parseuri/index.js"));
- const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
- const debug = debug_1.default("socket.io-client:url"); // debug()
- /**
- * URL parser.
- *
- * @param uri - url
- * @param path - the request path of the connection
- * @param loc - An object meant to mimic window.location.
- * Defaults to window.location.
- * @public
- */
- function url(uri, path = "", loc) {
- let obj = uri;
- // default to window.location
- loc = loc || (typeof location !== "undefined" && location);
- if (null == uri)
- uri = loc.protocol + "//" + loc.host;
- // relative path support
- if (typeof uri === "string") {
- if ("/" === uri.charAt(0)) {
- if ("/" === uri.charAt(1)) {
- uri = loc.protocol + uri;
- }
- else {
- uri = loc.host + uri;
- }
- }
- if (!/^(https?|wss?):\/\//.test(uri)) {
- debug("protocol-less url %s", uri);
- if ("undefined" !== typeof loc) {
- uri = loc.protocol + "//" + uri;
- }
- else {
- uri = "https://" + uri;
- }
- }
- // parse
- debug("parse %s", uri);
- obj = parseuri_1.default(uri);
- }
- // make sure we treat `localhost:80` and `localhost` equally
- if (!obj.port) {
- if (/^(http|ws)$/.test(obj.protocol)) {
- obj.port = "80";
- }
- else if (/^(http|ws)s$/.test(obj.protocol)) {
- obj.port = "443";
- }
- }
- obj.path = obj.path || "/";
- const ipv6 = obj.host.indexOf(":") !== -1;
- const host = ipv6 ? "[" + obj.host + "]" : obj.host;
- // define unique id
- obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
- // define href
- obj.href =
- obj.protocol +
- "://" +
- host +
- (loc && loc.port === obj.port ? "" : ":" + obj.port);
- return obj;
- }
- exports.url = url;
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js":
- /*!**************************************************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js ***!
- \**************************************************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.reconstructPacket = exports.deconstructPacket = void 0;
- const is_binary_js_1 = __webpack_require__(/*! ./is-binary.js */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js");
- /**
- * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
- *
- * @param {Object} packet - socket.io event packet
- * @return {Object} with deconstructed packet and list of buffers
- * @public
- */
- function deconstructPacket(packet) {
- const buffers = [];
- const packetData = packet.data;
- const pack = packet;
- pack.data = _deconstructPacket(packetData, buffers);
- pack.attachments = buffers.length; // number of binary 'attachments'
- return { packet: pack, buffers: buffers };
- }
- exports.deconstructPacket = deconstructPacket;
- function _deconstructPacket(data, buffers) {
- if (!data)
- return data;
- if (is_binary_js_1.isBinary(data)) {
- const placeholder = { _placeholder: true, num: buffers.length };
- buffers.push(data);
- return placeholder;
- }
- else if (Array.isArray(data)) {
- const newData = new Array(data.length);
- for (let i = 0; i < data.length; i++) {
- newData[i] = _deconstructPacket(data[i], buffers);
- }
- return newData;
- }
- else if (typeof data === "object" && !(data instanceof Date)) {
- const newData = {};
- for (const key in data) {
- if (Object.prototype.hasOwnProperty.call(data, key)) {
- newData[key] = _deconstructPacket(data[key], buffers);
- }
- }
- return newData;
- }
- return data;
- }
- /**
- * Reconstructs a binary packet from its placeholder packet and buffers
- *
- * @param {Object} packet - event packet with placeholders
- * @param {Array} buffers - binary buffers to put in placeholder positions
- * @return {Object} reconstructed packet
- * @public
- */
- function reconstructPacket(packet, buffers) {
- packet.data = _reconstructPacket(packet.data, buffers);
- packet.attachments = undefined; // no longer useful
- return packet;
- }
- exports.reconstructPacket = reconstructPacket;
- function _reconstructPacket(data, buffers) {
- if (!data)
- return data;
- if (data && data._placeholder) {
- return buffers[data.num]; // appropriate buffer (should be natural order anyway)
- }
- else if (Array.isArray(data)) {
- for (let i = 0; i < data.length; i++) {
- data[i] = _reconstructPacket(data[i], buffers);
- }
- }
- else if (typeof data === "object") {
- for (const key in data) {
- if (Object.prototype.hasOwnProperty.call(data, key)) {
- data[key] = _reconstructPacket(data[key], buffers);
- }
- }
- }
- return data;
- }
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js":
- /*!*************************************************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js ***!
- \*************************************************************************************************/
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
- const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
- const binary_js_1 = __webpack_require__(/*! ./binary.js */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js");
- const is_binary_js_1 = __webpack_require__(/*! ./is-binary.js */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js");
- const debug_1 = __webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js"); // debug()
- const debug = debug_1.default("socket.io-parser"); // debug()
- /**
- * Protocol version.
- *
- * @public
- */
- exports.protocol = 5;
- var PacketType;
- (function (PacketType) {
- PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
- PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
- PacketType[PacketType["EVENT"] = 2] = "EVENT";
- PacketType[PacketType["ACK"] = 3] = "ACK";
- PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
- PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
- PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
- })(PacketType = exports.PacketType || (exports.PacketType = {}));
- /**
- * A socket.io Encoder instance
- */
- class Encoder {
- /**
- * Encode a packet as a single string if non-binary, or as a
- * buffer sequence, depending on packet type.
- *
- * @param {Object} obj - packet object
- */
- encode(obj) {
- debug("encoding packet %j", obj);
- if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
- if (is_binary_js_1.hasBinary(obj)) {
- obj.type =
- obj.type === PacketType.EVENT
- ? PacketType.BINARY_EVENT
- : PacketType.BINARY_ACK;
- return this.encodeAsBinary(obj);
- }
- }
- return [this.encodeAsString(obj)];
- }
- /**
- * Encode packet as string.
- */
- encodeAsString(obj) {
- // first is type
- let str = "" + obj.type;
- // attachments if we have them
- if (obj.type === PacketType.BINARY_EVENT ||
- obj.type === PacketType.BINARY_ACK) {
- str += obj.attachments + "-";
- }
- // if we have a namespace other than `/`
- // we append it followed by a comma `,`
- if (obj.nsp && "/" !== obj.nsp) {
- str += obj.nsp + ",";
- }
- // immediately followed by the id
- if (null != obj.id) {
- str += obj.id;
- }
- // json data
- if (null != obj.data) {
- str += JSON.stringify(obj.data);
- }
- debug("encoded %j as %s", obj, str);
- return str;
- }
- /**
- * Encode packet as 'buffer sequence' by removing blobs, and
- * deconstructing packet into object with placeholders and
- * a list of buffers.
- */
- encodeAsBinary(obj) {
- const deconstruction = binary_js_1.deconstructPacket(obj);
- const pack = this.encodeAsString(deconstruction.packet);
- const buffers = deconstruction.buffers;
- buffers.unshift(pack); // add packet info to beginning of data list
- return buffers; // write all the buffers
- }
- }
- exports.Encoder = Encoder;
- /**
- * A socket.io Decoder instance
- *
- * @return {Object} decoder
- */
- class Decoder extends component_emitter_1.Emitter {
- constructor() {
- super();
- }
- /**
- * Decodes an encoded packet string into packet JSON.
- *
- * @param {String} obj - encoded packet
- */
- add(obj) {
- let packet;
- if (typeof obj === "string") {
- packet = this.decodeString(obj);
- if (packet.type === PacketType.BINARY_EVENT ||
- packet.type === PacketType.BINARY_ACK) {
- // binary packet's json
- this.reconstructor = new BinaryReconstructor(packet);
- // no attachments, labeled binary but no binary data to follow
- if (packet.attachments === 0) {
- super.emitReserved("decoded", packet);
- }
- }
- else {
- // non-binary full packet
- super.emitReserved("decoded", packet);
- }
- }
- else if (is_binary_js_1.isBinary(obj) || obj.base64) {
- // raw binary data
- if (!this.reconstructor) {
- throw new Error("got binary data when not reconstructing a packet");
- }
- else {
- packet = this.reconstructor.takeBinaryData(obj);
- if (packet) {
- // received final buffer
- this.reconstructor = null;
- super.emitReserved("decoded", packet);
- }
- }
- }
- else {
- throw new Error("Unknown type: " + obj);
- }
- }
- /**
- * Decode a packet String (JSON data)
- *
- * @param {String} str
- * @return {Object} packet
- */
- decodeString(str) {
- let i = 0;
- // look up type
- const p = {
- type: Number(str.charAt(0)),
- };
- if (PacketType[p.type] === undefined) {
- throw new Error("unknown packet type " + p.type);
- }
- // look up attachments if type binary
- if (p.type === PacketType.BINARY_EVENT ||
- p.type === PacketType.BINARY_ACK) {
- const start = i + 1;
- while (str.charAt(++i) !== "-" && i != str.length) { }
- const buf = str.substring(start, i);
- if (buf != Number(buf) || str.charAt(i) !== "-") {
- throw new Error("Illegal attachments");
- }
- p.attachments = Number(buf);
- }
- // look up namespace (if any)
- if ("/" === str.charAt(i + 1)) {
- const start = i + 1;
- while (++i) {
- const c = str.charAt(i);
- if ("," === c)
- break;
- if (i === str.length)
- break;
- }
- p.nsp = str.substring(start, i);
- }
- else {
- p.nsp = "/";
- }
- // look up id
- const next = str.charAt(i + 1);
- if ("" !== next && Number(next) == next) {
- const start = i + 1;
- while (++i) {
- const c = str.charAt(i);
- if (null == c || Number(c) != c) {
- --i;
- break;
- }
- if (i === str.length)
- break;
- }
- p.id = Number(str.substring(start, i + 1));
- }
- // look up json data
- if (str.charAt(++i)) {
- const payload = tryParse(str.substr(i));
- if (Decoder.isPayloadValid(p.type, payload)) {
- p.data = payload;
- }
- else {
- throw new Error("invalid payload");
- }
- }
- debug("decoded %s as %j", str, p);
- return p;
- }
- static isPayloadValid(type, payload) {
- switch (type) {
- case PacketType.CONNECT:
- return typeof payload === "object";
- case PacketType.DISCONNECT:
- return payload === undefined;
- case PacketType.CONNECT_ERROR:
- return typeof payload === "string" || typeof payload === "object";
- case PacketType.EVENT:
- case PacketType.BINARY_EVENT:
- return Array.isArray(payload) && payload.length > 0;
- case PacketType.ACK:
- case PacketType.BINARY_ACK:
- return Array.isArray(payload);
- }
- }
- /**
- * Deallocates a parser's resources
- */
- destroy() {
- if (this.reconstructor) {
- this.reconstructor.finishedReconstruction();
- }
- }
- }
- exports.Decoder = Decoder;
- function tryParse(str) {
- try {
- return JSON.parse(str);
- }
- catch (e) {
- return false;
- }
- }
- /**
- * A manager of a binary event's 'buffer sequence'. Should
- * be constructed whenever a packet of type BINARY_EVENT is
- * decoded.
- *
- * @param {Object} packet
- * @return {BinaryReconstructor} initialized reconstructor
- */
- class BinaryReconstructor {
- constructor(packet) {
- this.packet = packet;
- this.buffers = [];
- this.reconPack = packet;
- }
- /**
- * Method to be called when binary data received from connection
- * after a BINARY_EVENT packet.
- *
- * @param {Buffer | ArrayBuffer} binData - the raw binary data received
- * @return {null | Object} returns null if more binary data is expected or
- * a reconstructed packet object if all buffers have been received.
- */
- takeBinaryData(binData) {
- this.buffers.push(binData);
- if (this.buffers.length === this.reconPack.attachments) {
- // done with buffer list
- const packet = binary_js_1.reconstructPacket(this.reconPack, this.buffers);
- this.finishedReconstruction();
- return packet;
- }
- return null;
- }
- /**
- * Cleans up binary packet reconstruction variables.
- */
- finishedReconstruction() {
- this.reconPack = null;
- this.buffers = [];
- }
- }
- /***/ }),
- /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js":
- /*!*****************************************************************************************************!*\
- !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js ***!
- \*****************************************************************************************************/
- /***/ ((__unused_webpack_module, exports) => {
- "use strict";
- Object.defineProperty(exports, "__esModule", ({ value: true }));
- exports.hasBinary = exports.isBinary = void 0;
- const withNativeArrayBuffer = typeof ArrayBuffer === "function";
- const isView = (obj) => {
- return typeof ArrayBuffer.isView === "function"
- ? ArrayBuffer.isView(obj)
- : obj.buffer instanceof ArrayBuffer;
- };
- const toString = Object.prototype.toString;
- const withNativeBlob = typeof Blob === "function" ||
- (typeof Blob !== "undefined" &&
- toString.call(Blob) === "[object BlobConstructor]");
- const withNativeFile = typeof File === "function" ||
- (typeof File !== "undefined" &&
- toString.call(File) === "[object FileConstructor]");
- /**
- * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
- *
- * @private
- */
- function isBinary(obj) {
- return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
- (withNativeBlob && obj instanceof Blob) ||
- (withNativeFile && obj instanceof File));
- }
- exports.isBinary = isBinary;
- function hasBinary(obj, toJSON) {
- if (!obj || typeof obj !== "object") {
- return false;
- }
- if (Array.isArray(obj)) {
- for (let i = 0, l = obj.length; i < l; i++) {
- if (hasBinary(obj[i])) {
- return true;
- }
- }
- return false;
- }
- if (isBinary(obj)) {
- return true;
- }
- if (obj.toJSON &&
- typeof obj.toJSON === "function" &&
- arguments.length === 1) {
- return hasBinary(obj.toJSON(), true);
- }
- for (const key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
- return true;
- }
- }
- return false;
- }
- exports.hasBinary = hasBinary;
- /***/ })
- /******/ });
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
- /******/ if (cachedModule !== undefined) {
- /******/ return cachedModule.exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ // no module.id needed
- /******/ // no module.loaded needed
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /************************************************************************/
- /******/ /* webpack/runtime/define property getters */
- /******/ (() => {
- /******/ // define getter functions for harmony exports
- /******/ __webpack_require__.d = (exports, definition) => {
- /******/ for(var key in definition) {
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
- /******/ }
- /******/ }
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
- /******/ (() => {
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
- /******/ })();
- /******/
- /******/ /* webpack/runtime/make namespace object */
- /******/ (() => {
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = (exports) => {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/ })();
- /******/
- /************************************************************************/
- /******/
- /******/ // startup
- /******/ // Load entry module and return exports
- /******/ // This entry module is referenced by other modules so it can't be inlined
- /******/ var __webpack_exports__ = __webpack_require__("./src/client.ts");
- /******/
- /******/ return __webpack_exports__;
- /******/ })()
- ;
- });
- //# sourceMappingURL=client.js.map
|