client.js 202 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["Web"] = factory();
  8. else
  9. root["Web"] = factory();
  10. })(self, function() {
  11. return /******/ (() => { // webpackBootstrap
  12. /******/ var __webpack_modules__ = ({
  13. /***/ "../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js":
  14. /*!********************************************************************************************!*\
  15. !*** ../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js ***!
  16. \********************************************************************************************/
  17. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  18. "use strict";
  19. __webpack_require__.r(__webpack_exports__);
  20. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  21. /* harmony export */ "decode": () => (/* binding */ decode),
  22. /* harmony export */ "encode": () => (/* binding */ encode)
  23. /* harmony export */ });
  24. /*
  25. * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
  26. * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
  27. * Released under MIT License
  28. */
  29. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  30. // Use a lookup table to find the index.
  31. var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
  32. for (var i = 0; i < chars.length; i++) {
  33. lookup[chars.charCodeAt(i)] = i;
  34. }
  35. var encode = function (arraybuffer) {
  36. var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
  37. for (i = 0; i < len; i += 3) {
  38. base64 += chars[bytes[i] >> 2];
  39. base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
  40. base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
  41. base64 += chars[bytes[i + 2] & 63];
  42. }
  43. if (len % 3 === 2) {
  44. base64 = base64.substring(0, base64.length - 1) + '=';
  45. }
  46. else if (len % 3 === 1) {
  47. base64 = base64.substring(0, base64.length - 2) + '==';
  48. }
  49. return base64;
  50. };
  51. var decode = function (base64) {
  52. var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  53. if (base64[base64.length - 1] === '=') {
  54. bufferLength--;
  55. if (base64[base64.length - 2] === '=') {
  56. bufferLength--;
  57. }
  58. }
  59. var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  60. for (i = 0; i < len; i += 4) {
  61. encoded1 = lookup[base64.charCodeAt(i)];
  62. encoded2 = lookup[base64.charCodeAt(i + 1)];
  63. encoded3 = lookup[base64.charCodeAt(i + 2)];
  64. encoded4 = lookup[base64.charCodeAt(i + 3)];
  65. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  66. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  67. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  68. }
  69. return arraybuffer;
  70. };
  71. //# sourceMappingURL=base64-arraybuffer.es5.js.map
  72. /***/ }),
  73. /***/ "../ot-core/node_modules/@socket.io/component-emitter/index.js":
  74. /*!*********************************************************************!*\
  75. !*** ../ot-core/node_modules/@socket.io/component-emitter/index.js ***!
  76. \*********************************************************************/
  77. /***/ ((__unused_webpack_module, exports) => {
  78. /**
  79. * Expose `Emitter`.
  80. */
  81. exports.Emitter = Emitter;
  82. /**
  83. * Initialize a new `Emitter`.
  84. *
  85. * @api public
  86. */
  87. function Emitter(obj) {
  88. if (obj) return mixin(obj);
  89. }
  90. /**
  91. * Mixin the emitter properties.
  92. *
  93. * @param {Object} obj
  94. * @return {Object}
  95. * @api private
  96. */
  97. function mixin(obj) {
  98. for (var key in Emitter.prototype) {
  99. obj[key] = Emitter.prototype[key];
  100. }
  101. return obj;
  102. }
  103. /**
  104. * Listen on the given `event` with `fn`.
  105. *
  106. * @param {String} event
  107. * @param {Function} fn
  108. * @return {Emitter}
  109. * @api public
  110. */
  111. Emitter.prototype.on =
  112. Emitter.prototype.addEventListener = function(event, fn){
  113. this._callbacks = this._callbacks || {};
  114. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  115. .push(fn);
  116. return this;
  117. };
  118. /**
  119. * Adds an `event` listener that will be invoked a single
  120. * time then automatically removed.
  121. *
  122. * @param {String} event
  123. * @param {Function} fn
  124. * @return {Emitter}
  125. * @api public
  126. */
  127. Emitter.prototype.once = function(event, fn){
  128. function on() {
  129. this.off(event, on);
  130. fn.apply(this, arguments);
  131. }
  132. on.fn = fn;
  133. this.on(event, on);
  134. return this;
  135. };
  136. /**
  137. * Remove the given callback for `event` or all
  138. * registered callbacks.
  139. *
  140. * @param {String} event
  141. * @param {Function} fn
  142. * @return {Emitter}
  143. * @api public
  144. */
  145. Emitter.prototype.off =
  146. Emitter.prototype.removeListener =
  147. Emitter.prototype.removeAllListeners =
  148. Emitter.prototype.removeEventListener = function(event, fn){
  149. this._callbacks = this._callbacks || {};
  150. // all
  151. if (0 == arguments.length) {
  152. this._callbacks = {};
  153. return this;
  154. }
  155. // specific event
  156. var callbacks = this._callbacks['$' + event];
  157. if (!callbacks) return this;
  158. // remove all handlers
  159. if (1 == arguments.length) {
  160. delete this._callbacks['$' + event];
  161. return this;
  162. }
  163. // remove specific handler
  164. var cb;
  165. for (var i = 0; i < callbacks.length; i++) {
  166. cb = callbacks[i];
  167. if (cb === fn || cb.fn === fn) {
  168. callbacks.splice(i, 1);
  169. break;
  170. }
  171. }
  172. // Remove event specific arrays for event types that no
  173. // one is subscribed for to avoid memory leak.
  174. if (callbacks.length === 0) {
  175. delete this._callbacks['$' + event];
  176. }
  177. return this;
  178. };
  179. /**
  180. * Emit `event` with the given args.
  181. *
  182. * @param {String} event
  183. * @param {Mixed} ...
  184. * @return {Emitter}
  185. */
  186. Emitter.prototype.emit = function(event){
  187. this._callbacks = this._callbacks || {};
  188. var args = new Array(arguments.length - 1)
  189. , callbacks = this._callbacks['$' + event];
  190. for (var i = 1; i < arguments.length; i++) {
  191. args[i - 1] = arguments[i];
  192. }
  193. if (callbacks) {
  194. callbacks = callbacks.slice(0);
  195. for (var i = 0, len = callbacks.length; i < len; ++i) {
  196. callbacks[i].apply(this, args);
  197. }
  198. }
  199. return this;
  200. };
  201. // alias used for reserved events (protected method)
  202. Emitter.prototype.emitReserved = Emitter.prototype.emit;
  203. /**
  204. * Return array of callbacks for `event`.
  205. *
  206. * @param {String} event
  207. * @return {Array}
  208. * @api public
  209. */
  210. Emitter.prototype.listeners = function(event){
  211. this._callbacks = this._callbacks || {};
  212. return this._callbacks['$' + event] || [];
  213. };
  214. /**
  215. * Check if this emitter has `event` handlers.
  216. *
  217. * @param {String} event
  218. * @return {Boolean}
  219. * @api public
  220. */
  221. Emitter.prototype.hasListeners = function(event){
  222. return !! this.listeners(event).length;
  223. };
  224. /***/ }),
  225. /***/ "../ot-core/node_modules/backo2/index.js":
  226. /*!***********************************************!*\
  227. !*** ../ot-core/node_modules/backo2/index.js ***!
  228. \***********************************************/
  229. /***/ ((module) => {
  230. /**
  231. * Expose `Backoff`.
  232. */
  233. module.exports = Backoff;
  234. /**
  235. * Initialize backoff timer with `opts`.
  236. *
  237. * - `min` initial timeout in milliseconds [100]
  238. * - `max` max timeout [10000]
  239. * - `jitter` [0]
  240. * - `factor` [2]
  241. *
  242. * @param {Object} opts
  243. * @api public
  244. */
  245. function Backoff(opts) {
  246. opts = opts || {};
  247. this.ms = opts.min || 100;
  248. this.max = opts.max || 10000;
  249. this.factor = opts.factor || 2;
  250. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  251. this.attempts = 0;
  252. }
  253. /**
  254. * Return the backoff duration.
  255. *
  256. * @return {Number}
  257. * @api public
  258. */
  259. Backoff.prototype.duration = function(){
  260. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  261. if (this.jitter) {
  262. var rand = Math.random();
  263. var deviation = Math.floor(rand * this.jitter * ms);
  264. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  265. }
  266. return Math.min(ms, this.max) | 0;
  267. };
  268. /**
  269. * Reset the number of attempts.
  270. *
  271. * @api public
  272. */
  273. Backoff.prototype.reset = function(){
  274. this.attempts = 0;
  275. };
  276. /**
  277. * Set the minimum duration
  278. *
  279. * @api public
  280. */
  281. Backoff.prototype.setMin = function(min){
  282. this.ms = min;
  283. };
  284. /**
  285. * Set the maximum duration
  286. *
  287. * @api public
  288. */
  289. Backoff.prototype.setMax = function(max){
  290. this.max = max;
  291. };
  292. /**
  293. * Set the jitter
  294. *
  295. * @api public
  296. */
  297. Backoff.prototype.setJitter = function(jitter){
  298. this.jitter = jitter;
  299. };
  300. /***/ }),
  301. /***/ "../ot-core/node_modules/debug/src/browser.js":
  302. /*!****************************************************!*\
  303. !*** ../ot-core/node_modules/debug/src/browser.js ***!
  304. \****************************************************/
  305. /***/ ((module, exports, __webpack_require__) => {
  306. /* eslint-env browser */
  307. /**
  308. * This is the web browser implementation of `debug()`.
  309. */
  310. exports.formatArgs = formatArgs;
  311. exports.save = save;
  312. exports.load = load;
  313. exports.useColors = useColors;
  314. exports.storage = localstorage();
  315. exports.destroy = (() => {
  316. let warned = false;
  317. return () => {
  318. if (!warned) {
  319. warned = true;
  320. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  321. }
  322. };
  323. })();
  324. /**
  325. * Colors.
  326. */
  327. exports.colors = [
  328. '#0000CC',
  329. '#0000FF',
  330. '#0033CC',
  331. '#0033FF',
  332. '#0066CC',
  333. '#0066FF',
  334. '#0099CC',
  335. '#0099FF',
  336. '#00CC00',
  337. '#00CC33',
  338. '#00CC66',
  339. '#00CC99',
  340. '#00CCCC',
  341. '#00CCFF',
  342. '#3300CC',
  343. '#3300FF',
  344. '#3333CC',
  345. '#3333FF',
  346. '#3366CC',
  347. '#3366FF',
  348. '#3399CC',
  349. '#3399FF',
  350. '#33CC00',
  351. '#33CC33',
  352. '#33CC66',
  353. '#33CC99',
  354. '#33CCCC',
  355. '#33CCFF',
  356. '#6600CC',
  357. '#6600FF',
  358. '#6633CC',
  359. '#6633FF',
  360. '#66CC00',
  361. '#66CC33',
  362. '#9900CC',
  363. '#9900FF',
  364. '#9933CC',
  365. '#9933FF',
  366. '#99CC00',
  367. '#99CC33',
  368. '#CC0000',
  369. '#CC0033',
  370. '#CC0066',
  371. '#CC0099',
  372. '#CC00CC',
  373. '#CC00FF',
  374. '#CC3300',
  375. '#CC3333',
  376. '#CC3366',
  377. '#CC3399',
  378. '#CC33CC',
  379. '#CC33FF',
  380. '#CC6600',
  381. '#CC6633',
  382. '#CC9900',
  383. '#CC9933',
  384. '#CCCC00',
  385. '#CCCC33',
  386. '#FF0000',
  387. '#FF0033',
  388. '#FF0066',
  389. '#FF0099',
  390. '#FF00CC',
  391. '#FF00FF',
  392. '#FF3300',
  393. '#FF3333',
  394. '#FF3366',
  395. '#FF3399',
  396. '#FF33CC',
  397. '#FF33FF',
  398. '#FF6600',
  399. '#FF6633',
  400. '#FF9900',
  401. '#FF9933',
  402. '#FFCC00',
  403. '#FFCC33'
  404. ];
  405. /**
  406. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  407. * and the Firebug extension (any Firefox version) are known
  408. * to support "%c" CSS customizations.
  409. *
  410. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  411. */
  412. // eslint-disable-next-line complexity
  413. function useColors() {
  414. // NB: In an Electron preload script, document will be defined but not fully
  415. // initialized. Since we know we're in Chrome, we'll just detect this case
  416. // explicitly
  417. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  418. return true;
  419. }
  420. // Internet Explorer and Edge do not support colors.
  421. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  422. return false;
  423. }
  424. // Is webkit? http://stackoverflow.com/a/16459606/376773
  425. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  426. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  427. // Is firebug? http://stackoverflow.com/a/398120/376773
  428. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  429. // Is firefox >= v31?
  430. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  431. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  432. // Double check webkit in userAgent just in case we are in a worker
  433. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  434. }
  435. /**
  436. * Colorize log arguments if enabled.
  437. *
  438. * @api public
  439. */
  440. function formatArgs(args) {
  441. args[0] = (this.useColors ? '%c' : '') +
  442. this.namespace +
  443. (this.useColors ? ' %c' : ' ') +
  444. args[0] +
  445. (this.useColors ? '%c ' : ' ') +
  446. '+' + module.exports.humanize(this.diff);
  447. if (!this.useColors) {
  448. return;
  449. }
  450. const c = 'color: ' + this.color;
  451. args.splice(1, 0, c, 'color: inherit');
  452. // The final "%c" is somewhat tricky, because there could be other
  453. // arguments passed either before or after the %c, so we need to
  454. // figure out the correct index to insert the CSS into
  455. let index = 0;
  456. let lastC = 0;
  457. args[0].replace(/%[a-zA-Z%]/g, match => {
  458. if (match === '%%') {
  459. return;
  460. }
  461. index++;
  462. if (match === '%c') {
  463. // We only are interested in the *last* %c
  464. // (the user may have provided their own)
  465. lastC = index;
  466. }
  467. });
  468. args.splice(lastC, 0, c);
  469. }
  470. /**
  471. * Invokes `console.debug()` when available.
  472. * No-op when `console.debug` is not a "function".
  473. * If `console.debug` is not available, falls back
  474. * to `console.log`.
  475. *
  476. * @api public
  477. */
  478. exports.log = console.debug || console.log || (() => {});
  479. /**
  480. * Save `namespaces`.
  481. *
  482. * @param {String} namespaces
  483. * @api private
  484. */
  485. function save(namespaces) {
  486. try {
  487. if (namespaces) {
  488. exports.storage.setItem('debug', namespaces);
  489. } else {
  490. exports.storage.removeItem('debug');
  491. }
  492. } catch (error) {
  493. // Swallow
  494. // XXX (@Qix-) should we be logging these?
  495. }
  496. }
  497. /**
  498. * Load `namespaces`.
  499. *
  500. * @return {String} returns the previously persisted debug modes
  501. * @api private
  502. */
  503. function load() {
  504. let r;
  505. try {
  506. r = exports.storage.getItem('debug');
  507. } catch (error) {
  508. // Swallow
  509. // XXX (@Qix-) should we be logging these?
  510. }
  511. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  512. if (!r && typeof process !== 'undefined' && 'env' in process) {
  513. r = process.env.DEBUG;
  514. }
  515. return r;
  516. }
  517. /**
  518. * Localstorage attempts to return the localstorage.
  519. *
  520. * This is necessary because safari throws
  521. * when a user disables cookies/localstorage
  522. * and you attempt to access it.
  523. *
  524. * @return {LocalStorage}
  525. * @api private
  526. */
  527. function localstorage() {
  528. try {
  529. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  530. // The Browser also has localStorage in the global context.
  531. return localStorage;
  532. } catch (error) {
  533. // Swallow
  534. // XXX (@Qix-) should we be logging these?
  535. }
  536. }
  537. module.exports = __webpack_require__(/*! ./common */ "../ot-core/node_modules/debug/src/common.js")(exports);
  538. const {formatters} = module.exports;
  539. /**
  540. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  541. */
  542. formatters.j = function (v) {
  543. try {
  544. return JSON.stringify(v);
  545. } catch (error) {
  546. return '[UnexpectedJSONParseError]: ' + error.message;
  547. }
  548. };
  549. /***/ }),
  550. /***/ "../ot-core/node_modules/debug/src/common.js":
  551. /*!***************************************************!*\
  552. !*** ../ot-core/node_modules/debug/src/common.js ***!
  553. \***************************************************/
  554. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  555. /**
  556. * This is the common logic for both the Node.js and web browser
  557. * implementations of `debug()`.
  558. */
  559. function setup(env) {
  560. createDebug.debug = createDebug;
  561. createDebug.default = createDebug;
  562. createDebug.coerce = coerce;
  563. createDebug.disable = disable;
  564. createDebug.enable = enable;
  565. createDebug.enabled = enabled;
  566. createDebug.humanize = __webpack_require__(/*! ms */ "../ot-core/node_modules/ms/index.js");
  567. createDebug.destroy = destroy;
  568. Object.keys(env).forEach(key => {
  569. createDebug[key] = env[key];
  570. });
  571. /**
  572. * The currently active debug mode names, and names to skip.
  573. */
  574. createDebug.names = [];
  575. createDebug.skips = [];
  576. /**
  577. * Map of special "%n" handling functions, for the debug "format" argument.
  578. *
  579. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  580. */
  581. createDebug.formatters = {};
  582. /**
  583. * Selects a color for a debug namespace
  584. * @param {String} namespace The namespace string for the debug instance to be colored
  585. * @return {Number|String} An ANSI color code for the given namespace
  586. * @api private
  587. */
  588. function selectColor(namespace) {
  589. let hash = 0;
  590. for (let i = 0; i < namespace.length; i++) {
  591. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  592. hash |= 0; // Convert to 32bit integer
  593. }
  594. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  595. }
  596. createDebug.selectColor = selectColor;
  597. /**
  598. * Create a debugger with the given `namespace`.
  599. *
  600. * @param {String} namespace
  601. * @return {Function}
  602. * @api public
  603. */
  604. function createDebug(namespace) {
  605. let prevTime;
  606. let enableOverride = null;
  607. let namespacesCache;
  608. let enabledCache;
  609. function debug(...args) {
  610. // Disabled?
  611. if (!debug.enabled) {
  612. return;
  613. }
  614. const self = debug;
  615. // Set `diff` timestamp
  616. const curr = Number(new Date());
  617. const ms = curr - (prevTime || curr);
  618. self.diff = ms;
  619. self.prev = prevTime;
  620. self.curr = curr;
  621. prevTime = curr;
  622. args[0] = createDebug.coerce(args[0]);
  623. if (typeof args[0] !== 'string') {
  624. // Anything else let's inspect with %O
  625. args.unshift('%O');
  626. }
  627. // Apply any `formatters` transformations
  628. let index = 0;
  629. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  630. // If we encounter an escaped % then don't increase the array index
  631. if (match === '%%') {
  632. return '%';
  633. }
  634. index++;
  635. const formatter = createDebug.formatters[format];
  636. if (typeof formatter === 'function') {
  637. const val = args[index];
  638. match = formatter.call(self, val);
  639. // Now we need to remove `args[index]` since it's inlined in the `format`
  640. args.splice(index, 1);
  641. index--;
  642. }
  643. return match;
  644. });
  645. // Apply env-specific formatting (colors, etc.)
  646. createDebug.formatArgs.call(self, args);
  647. const logFn = self.log || createDebug.log;
  648. logFn.apply(self, args);
  649. }
  650. debug.namespace = namespace;
  651. debug.useColors = createDebug.useColors();
  652. debug.color = createDebug.selectColor(namespace);
  653. debug.extend = extend;
  654. debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
  655. Object.defineProperty(debug, 'enabled', {
  656. enumerable: true,
  657. configurable: false,
  658. get: () => {
  659. if (enableOverride !== null) {
  660. return enableOverride;
  661. }
  662. if (namespacesCache !== createDebug.namespaces) {
  663. namespacesCache = createDebug.namespaces;
  664. enabledCache = createDebug.enabled(namespace);
  665. }
  666. return enabledCache;
  667. },
  668. set: v => {
  669. enableOverride = v;
  670. }
  671. });
  672. // Env-specific initialization logic for debug instances
  673. if (typeof createDebug.init === 'function') {
  674. createDebug.init(debug);
  675. }
  676. return debug;
  677. }
  678. function extend(namespace, delimiter) {
  679. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  680. newDebug.log = this.log;
  681. return newDebug;
  682. }
  683. /**
  684. * Enables a debug mode by namespaces. This can include modes
  685. * separated by a colon and wildcards.
  686. *
  687. * @param {String} namespaces
  688. * @api public
  689. */
  690. function enable(namespaces) {
  691. createDebug.save(namespaces);
  692. createDebug.namespaces = namespaces;
  693. createDebug.names = [];
  694. createDebug.skips = [];
  695. let i;
  696. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  697. const len = split.length;
  698. for (i = 0; i < len; i++) {
  699. if (!split[i]) {
  700. // ignore empty strings
  701. continue;
  702. }
  703. namespaces = split[i].replace(/\*/g, '.*?');
  704. if (namespaces[0] === '-') {
  705. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  706. } else {
  707. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  708. }
  709. }
  710. }
  711. /**
  712. * Disable debug output.
  713. *
  714. * @return {String} namespaces
  715. * @api public
  716. */
  717. function disable() {
  718. const namespaces = [
  719. ...createDebug.names.map(toNamespace),
  720. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  721. ].join(',');
  722. createDebug.enable('');
  723. return namespaces;
  724. }
  725. /**
  726. * Returns true if the given mode name is enabled, false otherwise.
  727. *
  728. * @param {String} name
  729. * @return {Boolean}
  730. * @api public
  731. */
  732. function enabled(name) {
  733. if (name[name.length - 1] === '*') {
  734. return true;
  735. }
  736. let i;
  737. let len;
  738. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  739. if (createDebug.skips[i].test(name)) {
  740. return false;
  741. }
  742. }
  743. for (i = 0, len = createDebug.names.length; i < len; i++) {
  744. if (createDebug.names[i].test(name)) {
  745. return true;
  746. }
  747. }
  748. return false;
  749. }
  750. /**
  751. * Convert regexp to namespace
  752. *
  753. * @param {RegExp} regxep
  754. * @return {String} namespace
  755. * @api private
  756. */
  757. function toNamespace(regexp) {
  758. return regexp.toString()
  759. .substring(2, regexp.toString().length - 2)
  760. .replace(/\.\*\?$/, '*');
  761. }
  762. /**
  763. * Coerce `val`.
  764. *
  765. * @param {Mixed} val
  766. * @return {Mixed}
  767. * @api private
  768. */
  769. function coerce(val) {
  770. if (val instanceof Error) {
  771. return val.stack || val.message;
  772. }
  773. return val;
  774. }
  775. /**
  776. * XXX DO NOT USE. This is a temporary stub function.
  777. * XXX It WILL be removed in the next major release.
  778. */
  779. function destroy() {
  780. console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
  781. }
  782. createDebug.enable(createDebug.load());
  783. return createDebug;
  784. }
  785. module.exports = setup;
  786. /***/ }),
  787. /***/ "../ot-core/node_modules/has-cors/index.js":
  788. /*!*************************************************!*\
  789. !*** ../ot-core/node_modules/has-cors/index.js ***!
  790. \*************************************************/
  791. /***/ ((module) => {
  792. /**
  793. * Module exports.
  794. *
  795. * Logic borrowed from Modernizr:
  796. *
  797. * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
  798. */
  799. try {
  800. module.exports = typeof XMLHttpRequest !== 'undefined' &&
  801. 'withCredentials' in new XMLHttpRequest();
  802. } catch (err) {
  803. // if XMLHttp support is disabled in IE then it will throw
  804. // when trying to create
  805. module.exports = false;
  806. }
  807. /***/ }),
  808. /***/ "../ot-core/node_modules/ms/index.js":
  809. /*!*******************************************!*\
  810. !*** ../ot-core/node_modules/ms/index.js ***!
  811. \*******************************************/
  812. /***/ ((module) => {
  813. /**
  814. * Helpers.
  815. */
  816. var s = 1000;
  817. var m = s * 60;
  818. var h = m * 60;
  819. var d = h * 24;
  820. var w = d * 7;
  821. var y = d * 365.25;
  822. /**
  823. * Parse or format the given `val`.
  824. *
  825. * Options:
  826. *
  827. * - `long` verbose formatting [false]
  828. *
  829. * @param {String|Number} val
  830. * @param {Object} [options]
  831. * @throws {Error} throw an error if val is not a non-empty string or a number
  832. * @return {String|Number}
  833. * @api public
  834. */
  835. module.exports = function(val, options) {
  836. options = options || {};
  837. var type = typeof val;
  838. if (type === 'string' && val.length > 0) {
  839. return parse(val);
  840. } else if (type === 'number' && isFinite(val)) {
  841. return options.long ? fmtLong(val) : fmtShort(val);
  842. }
  843. throw new Error(
  844. 'val is not a non-empty string or a valid number. val=' +
  845. JSON.stringify(val)
  846. );
  847. };
  848. /**
  849. * Parse the given `str` and return milliseconds.
  850. *
  851. * @param {String} str
  852. * @return {Number}
  853. * @api private
  854. */
  855. function parse(str) {
  856. str = String(str);
  857. if (str.length > 100) {
  858. return;
  859. }
  860. 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(
  861. str
  862. );
  863. if (!match) {
  864. return;
  865. }
  866. var n = parseFloat(match[1]);
  867. var type = (match[2] || 'ms').toLowerCase();
  868. switch (type) {
  869. case 'years':
  870. case 'year':
  871. case 'yrs':
  872. case 'yr':
  873. case 'y':
  874. return n * y;
  875. case 'weeks':
  876. case 'week':
  877. case 'w':
  878. return n * w;
  879. case 'days':
  880. case 'day':
  881. case 'd':
  882. return n * d;
  883. case 'hours':
  884. case 'hour':
  885. case 'hrs':
  886. case 'hr':
  887. case 'h':
  888. return n * h;
  889. case 'minutes':
  890. case 'minute':
  891. case 'mins':
  892. case 'min':
  893. case 'm':
  894. return n * m;
  895. case 'seconds':
  896. case 'second':
  897. case 'secs':
  898. case 'sec':
  899. case 's':
  900. return n * s;
  901. case 'milliseconds':
  902. case 'millisecond':
  903. case 'msecs':
  904. case 'msec':
  905. case 'ms':
  906. return n;
  907. default:
  908. return undefined;
  909. }
  910. }
  911. /**
  912. * Short format for `ms`.
  913. *
  914. * @param {Number} ms
  915. * @return {String}
  916. * @api private
  917. */
  918. function fmtShort(ms) {
  919. var msAbs = Math.abs(ms);
  920. if (msAbs >= d) {
  921. return Math.round(ms / d) + 'd';
  922. }
  923. if (msAbs >= h) {
  924. return Math.round(ms / h) + 'h';
  925. }
  926. if (msAbs >= m) {
  927. return Math.round(ms / m) + 'm';
  928. }
  929. if (msAbs >= s) {
  930. return Math.round(ms / s) + 's';
  931. }
  932. return ms + 'ms';
  933. }
  934. /**
  935. * Long format for `ms`.
  936. *
  937. * @param {Number} ms
  938. * @return {String}
  939. * @api private
  940. */
  941. function fmtLong(ms) {
  942. var msAbs = Math.abs(ms);
  943. if (msAbs >= d) {
  944. return plural(ms, msAbs, d, 'day');
  945. }
  946. if (msAbs >= h) {
  947. return plural(ms, msAbs, h, 'hour');
  948. }
  949. if (msAbs >= m) {
  950. return plural(ms, msAbs, m, 'minute');
  951. }
  952. if (msAbs >= s) {
  953. return plural(ms, msAbs, s, 'second');
  954. }
  955. return ms + ' ms';
  956. }
  957. /**
  958. * Pluralization helper.
  959. */
  960. function plural(ms, msAbs, n, name) {
  961. var isPlural = msAbs >= n * 1.5;
  962. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  963. }
  964. /***/ }),
  965. /***/ "../ot-core/node_modules/parseqs/index.js":
  966. /*!************************************************!*\
  967. !*** ../ot-core/node_modules/parseqs/index.js ***!
  968. \************************************************/
  969. /***/ ((__unused_webpack_module, exports) => {
  970. /**
  971. * Compiles a querystring
  972. * Returns string representation of the object
  973. *
  974. * @param {Object}
  975. * @api private
  976. */
  977. exports.encode = function (obj) {
  978. var str = '';
  979. for (var i in obj) {
  980. if (obj.hasOwnProperty(i)) {
  981. if (str.length) str += '&';
  982. str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
  983. }
  984. }
  985. return str;
  986. };
  987. /**
  988. * Parses a simple querystring into an object
  989. *
  990. * @param {String} qs
  991. * @api private
  992. */
  993. exports.decode = function(qs){
  994. var qry = {};
  995. var pairs = qs.split('&');
  996. for (var i = 0, l = pairs.length; i < l; i++) {
  997. var pair = pairs[i].split('=');
  998. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  999. }
  1000. return qry;
  1001. };
  1002. /***/ }),
  1003. /***/ "../ot-core/node_modules/parseuri/index.js":
  1004. /*!*************************************************!*\
  1005. !*** ../ot-core/node_modules/parseuri/index.js ***!
  1006. \*************************************************/
  1007. /***/ ((module) => {
  1008. /**
  1009. * Parses an URI
  1010. *
  1011. * @author Steven Levithan <stevenlevithan.com> (MIT license)
  1012. * @api private
  1013. */
  1014. var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  1015. var parts = [
  1016. 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
  1017. ];
  1018. module.exports = function parseuri(str) {
  1019. var src = str,
  1020. b = str.indexOf('['),
  1021. e = str.indexOf(']');
  1022. if (b != -1 && e != -1) {
  1023. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
  1024. }
  1025. var m = re.exec(str || ''),
  1026. uri = {},
  1027. i = 14;
  1028. while (i--) {
  1029. uri[parts[i]] = m[i] || '';
  1030. }
  1031. if (b != -1 && e != -1) {
  1032. uri.source = src;
  1033. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
  1034. uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
  1035. uri.ipv6uri = true;
  1036. }
  1037. uri.pathNames = pathNames(uri, uri['path']);
  1038. uri.queryKey = queryKey(uri, uri['query']);
  1039. return uri;
  1040. };
  1041. function pathNames(obj, path) {
  1042. var regx = /\/{2,9}/g,
  1043. names = path.replace(regx, "/").split("/");
  1044. if (path.substr(0, 1) == '/' || path.length === 0) {
  1045. names.splice(0, 1);
  1046. }
  1047. if (path.substr(path.length - 1, 1) == '/') {
  1048. names.splice(names.length - 1, 1);
  1049. }
  1050. return names;
  1051. }
  1052. function queryKey(uri, query) {
  1053. var data = {};
  1054. query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
  1055. if ($1) {
  1056. data[$1] = $2;
  1057. }
  1058. });
  1059. return data;
  1060. }
  1061. /***/ }),
  1062. /***/ "../ot-core/node_modules/yeast/index.js":
  1063. /*!**********************************************!*\
  1064. !*** ../ot-core/node_modules/yeast/index.js ***!
  1065. \**********************************************/
  1066. /***/ ((module) => {
  1067. "use strict";
  1068. var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
  1069. , length = 64
  1070. , map = {}
  1071. , seed = 0
  1072. , i = 0
  1073. , prev;
  1074. /**
  1075. * Return a string representing the specified number.
  1076. *
  1077. * @param {Number} num The number to convert.
  1078. * @returns {String} The string representation of the number.
  1079. * @api public
  1080. */
  1081. function encode(num) {
  1082. var encoded = '';
  1083. do {
  1084. encoded = alphabet[num % length] + encoded;
  1085. num = Math.floor(num / length);
  1086. } while (num > 0);
  1087. return encoded;
  1088. }
  1089. /**
  1090. * Return the integer value specified by the given string.
  1091. *
  1092. * @param {String} str The string to convert.
  1093. * @returns {Number} The integer value represented by the string.
  1094. * @api public
  1095. */
  1096. function decode(str) {
  1097. var decoded = 0;
  1098. for (i = 0; i < str.length; i++) {
  1099. decoded = decoded * length + map[str.charAt(i)];
  1100. }
  1101. return decoded;
  1102. }
  1103. /**
  1104. * Yeast: A tiny growing id generator.
  1105. *
  1106. * @returns {String} A unique id.
  1107. * @api public
  1108. */
  1109. function yeast() {
  1110. var now = encode(+new Date());
  1111. if (now !== prev) return seed = 0, prev = now;
  1112. return now +'.'+ encode(seed++);
  1113. }
  1114. //
  1115. // Map each character to its index.
  1116. //
  1117. for (; i < length; i++) map[alphabet[i]] = i;
  1118. //
  1119. // Expose the `yeast`, `encode` and `decode` functions.
  1120. //
  1121. yeast.encode = encode;
  1122. yeast.decode = decode;
  1123. module.exports = yeast;
  1124. /***/ }),
  1125. /***/ "../ot-core/src/basics/Command.ts":
  1126. /*!****************************************!*\
  1127. !*** ../ot-core/src/basics/Command.ts ***!
  1128. \****************************************/
  1129. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1130. "use strict";
  1131. Object.defineProperty(exports, "__esModule", ({
  1132. value: true
  1133. }));
  1134. exports.Command = void 0;
  1135. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1136. class Command {
  1137. constructor(...parameter) {
  1138. this._describe = 'Command';
  1139. if (internal_1.TransformUtils.hasLength(parameter, 0)) {
  1140. this._groupId = 'default';
  1141. this._operation = [];
  1142. return;
  1143. }
  1144. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1145. if (internal_1.TransformUtils.isString(parameter[0])) {
  1146. const groupId = parameter[0];
  1147. this._operation = [];
  1148. this._groupId = groupId;
  1149. return;
  1150. }
  1151. if (internal_1.TransformUtils.isObject(parameter[0])) {
  1152. const serialize = parameter[0];
  1153. this._groupId = serialize.groupId;
  1154. this._operation = internal_1.Deserialize.getInstance().formArray(serialize.operation);
  1155. return;
  1156. }
  1157. }
  1158. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1159. const groupId = parameter[0];
  1160. const operation = parameter[1];
  1161. this._groupId = groupId;
  1162. this._operation = operation;
  1163. }
  1164. }
  1165. concat(target) {
  1166. const result = new Command({
  1167. groupId: this._groupId,
  1168. describe: this._describe,
  1169. operation: []
  1170. });
  1171. result._operation = this._operation.concat(target._operation);
  1172. return result;
  1173. }
  1174. apply(resource) {
  1175. const operations = this._operation;
  1176. const sizeof = operations.length;
  1177. for (let i = 0; i < sizeof; i++) {
  1178. const action = operations[i];
  1179. action.apply(resource);
  1180. }
  1181. }
  1182. getOperations() {
  1183. return this._operation;
  1184. }
  1185. getGroupId() {
  1186. return this._groupId;
  1187. }
  1188. addOperation(operation) {
  1189. this._operation.push(operation);
  1190. }
  1191. toJSON() {
  1192. return {
  1193. describe: this._describe,
  1194. groupId: this._groupId,
  1195. operation: this._operation.map(o => o.toJSON())
  1196. };
  1197. }
  1198. }
  1199. exports.Command = Command;
  1200. /***/ }),
  1201. /***/ "../ot-core/src/basics/Conflict.ts":
  1202. /*!*****************************************!*\
  1203. !*** ../ot-core/src/basics/Conflict.ts ***!
  1204. \*****************************************/
  1205. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1206. "use strict";
  1207. Object.defineProperty(exports, "__esModule", ({
  1208. value: true
  1209. }));
  1210. exports.Conflict = void 0;
  1211. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1212. class Conflict {
  1213. constructor() {
  1214. this._conflict = new Array();
  1215. }
  1216. get(targetOperation, savedOperation) {
  1217. const _conflict = this._conflict;
  1218. const sizeof = _conflict.length;
  1219. for (let i = 0; i < sizeof; i++) {
  1220. const wrapped = _conflict[i];
  1221. const targetFrom = internal_1.TransformUtils.isAssignableFrom(targetOperation, wrapped.targetClass);
  1222. const savedFrom = internal_1.TransformUtils.isAssignableFrom(savedOperation, wrapped.savedClass);
  1223. if (targetFrom && savedFrom) {
  1224. return wrapped;
  1225. }
  1226. }
  1227. return null;
  1228. }
  1229. add(...parameter) {
  1230. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1231. const wrapped = parameter[0];
  1232. this._conflict.push(wrapped);
  1233. return;
  1234. }
  1235. if (internal_1.TransformUtils.hasLength(parameter, 3)) {
  1236. const targetClass = parameter[0];
  1237. const savedClass = parameter[1];
  1238. const process = parameter[2];
  1239. this._conflict.push({
  1240. targetClass,
  1241. savedClass,
  1242. process
  1243. });
  1244. }
  1245. }
  1246. }
  1247. exports.Conflict = Conflict;
  1248. /***/ }),
  1249. /***/ "../ot-core/src/basics/Deserialize.ts":
  1250. /*!********************************************!*\
  1251. !*** ../ot-core/src/basics/Deserialize.ts ***!
  1252. \********************************************/
  1253. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1254. "use strict";
  1255. Object.defineProperty(exports, "__esModule", ({
  1256. value: true
  1257. }));
  1258. exports.Deserialize = void 0;
  1259. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1260. let singleton;
  1261. class Deserialize {
  1262. constructor() {
  1263. this._storage = new Map();
  1264. }
  1265. static getInstance() {
  1266. if (!internal_1.TransformUtils.isDefine(singleton)) {
  1267. singleton = new Deserialize();
  1268. singleton.addClass('SwapData', internal_1.SwapData);
  1269. singleton.addClass('Command', internal_1.Command);
  1270. }
  1271. return singleton;
  1272. }
  1273. formArray(...parameter) {
  1274. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1275. const object = parameter[0];
  1276. const length = object.length;
  1277. const result = new Array();
  1278. for (let i = 0; i < length; i++) {
  1279. result.push(this.convert(object[i]));
  1280. }
  1281. return result;
  1282. }
  1283. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1284. const object = parameter[0];
  1285. const defaultValue = parameter[1];
  1286. if (internal_1.TransformUtils.isDefine(object)) {
  1287. const length = object.length;
  1288. const result = new Array();
  1289. for (let i = 0; i < length; i++) {
  1290. result.push(this.convert(object[i]));
  1291. }
  1292. return result;
  1293. }
  1294. return defaultValue;
  1295. }
  1296. }
  1297. formObject(...parameter) {
  1298. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1299. const object = parameter[0];
  1300. return this.convert(object);
  1301. }
  1302. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1303. const object = parameter[0];
  1304. const defaultValue = parameter[1];
  1305. if (internal_1.TransformUtils.isDefine(object)) {
  1306. return this.convert(object);
  1307. }
  1308. return defaultValue;
  1309. }
  1310. }
  1311. convert(value) {
  1312. if (internal_1.TransformUtils.isDefine(value.describe)) {
  1313. return this.newInstance(value.describe, value);
  1314. }
  1315. return value;
  1316. }
  1317. addClass(...parameter) {
  1318. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1319. const clazz = parameter[0];
  1320. this._storage.set(clazz.name, clazz);
  1321. return;
  1322. }
  1323. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1324. const name = parameter[0];
  1325. const clazz = parameter[1];
  1326. this._storage.set(name, clazz);
  1327. }
  1328. }
  1329. newInstance(name, desc) {
  1330. const constructor = this.getClass(name);
  1331. return new constructor(desc);
  1332. }
  1333. getClass(name) {
  1334. const element = this._storage.get(name);
  1335. if (internal_1.TransformUtils.isDefine(element)) {
  1336. return element;
  1337. }
  1338. throw new Error(`not find ${name} Class`);
  1339. }
  1340. }
  1341. exports.Deserialize = Deserialize;
  1342. /***/ }),
  1343. /***/ "../ot-core/src/basics/Operation.ts":
  1344. /*!******************************************!*\
  1345. !*** ../ot-core/src/basics/Operation.ts ***!
  1346. \******************************************/
  1347. /***/ ((__unused_webpack_module, exports) => {
  1348. "use strict";
  1349. Object.defineProperty(exports, "__esModule", ({
  1350. value: true
  1351. }));
  1352. /***/ }),
  1353. /***/ "../ot-core/src/basics/SwapData.ts":
  1354. /*!*****************************************!*\
  1355. !*** ../ot-core/src/basics/SwapData.ts ***!
  1356. \*****************************************/
  1357. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1358. "use strict";
  1359. Object.defineProperty(exports, "__esModule", ({
  1360. value: true
  1361. }));
  1362. exports.SwapData = void 0;
  1363. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1364. class SwapData {
  1365. constructor(...parameter) {
  1366. this._describe = 'SwapData';
  1367. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1368. this._data = parameter[0].data;
  1369. return;
  1370. }
  1371. if (internal_1.TransformUtils.hasLength(parameter, 0)) {
  1372. this._data = null;
  1373. }
  1374. }
  1375. setData(_data) {
  1376. this._data = _data;
  1377. }
  1378. getData() {
  1379. return this._data;
  1380. }
  1381. clone() {
  1382. return this;
  1383. }
  1384. toJSON() {
  1385. return {
  1386. describe: this._describe,
  1387. data: this._data
  1388. };
  1389. }
  1390. }
  1391. exports.SwapData = SwapData;
  1392. /***/ }),
  1393. /***/ "../ot-core/src/basics/Transform.ts":
  1394. /*!******************************************!*\
  1395. !*** ../ot-core/src/basics/Transform.ts ***!
  1396. \******************************************/
  1397. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1398. "use strict";
  1399. Object.defineProperty(exports, "__esModule", ({
  1400. value: true
  1401. }));
  1402. exports.Transform = void 0;
  1403. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1404. class Transform {
  1405. constructor(_conflict) {
  1406. this._conflict = _conflict;
  1407. }
  1408. transfer(targetCommand, savedCommand) {
  1409. const conflict = this._conflict;
  1410. const targetOperations = targetCommand.getOperations();
  1411. const savedOperations = savedCommand.getOperations();
  1412. const sizeof1 = targetOperations.length;
  1413. const sizeof2 = savedOperations.length;
  1414. const newTargetCommand = new internal_1.Command({
  1415. groupId: targetCommand.getGroupId(),
  1416. operation: [],
  1417. describe: 'Command'
  1418. });
  1419. const newSavedCommand = new internal_1.Command({
  1420. groupId: targetCommand.getGroupId(),
  1421. operation: [],
  1422. describe: 'Command'
  1423. });
  1424. for (let i = 0; i < sizeof1; i++) {
  1425. const targetOperation = targetOperations[i];
  1426. for (let j = 0; j < sizeof2; j++) {
  1427. const savedOperation = savedOperations[j];
  1428. const wrapped = conflict.get(targetOperation, savedOperation);
  1429. if (wrapped != null) {
  1430. const transfer = wrapped.process(newTargetCommand, newSavedCommand);
  1431. transfer(targetOperation.clone(), savedOperation.clone());
  1432. continue;
  1433. }
  1434. throw new Error('not found _conflict process');
  1435. }
  1436. }
  1437. return [newTargetCommand, newSavedCommand];
  1438. }
  1439. }
  1440. exports.Transform = Transform;
  1441. /***/ }),
  1442. /***/ "../ot-core/src/client/AwaitingConfirm.ts":
  1443. /*!************************************************!*\
  1444. !*** ../ot-core/src/client/AwaitingConfirm.ts ***!
  1445. \************************************************/
  1446. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1447. "use strict";
  1448. Object.defineProperty(exports, "__esModule", ({
  1449. value: true
  1450. }));
  1451. exports.AwaitingConfirm = void 0;
  1452. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1453. class AwaitingConfirm {
  1454. constructor(outstanding) {
  1455. this._outstanding = outstanding;
  1456. }
  1457. applyClient(client, command) {
  1458. return new internal_1.AwaitingWithBuffer(this._outstanding, command);
  1459. }
  1460. serverAck(client) {
  1461. return internal_1.Synchronized.DEFAULT;
  1462. }
  1463. applyServer(client, command) {
  1464. const outstanding = this._outstanding;
  1465. const pair = client.getTransform().transfer(outstanding, command);
  1466. client.applyCommand(pair[1]);
  1467. return new AwaitingConfirm(pair[0]);
  1468. }
  1469. resend(client) {
  1470. client.sendCommand(client.getRevision(), this._outstanding);
  1471. }
  1472. }
  1473. exports.AwaitingConfirm = AwaitingConfirm;
  1474. /***/ }),
  1475. /***/ "../ot-core/src/client/AwaitingWithBuffer.ts":
  1476. /*!***************************************************!*\
  1477. !*** ../ot-core/src/client/AwaitingWithBuffer.ts ***!
  1478. \***************************************************/
  1479. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1480. "use strict";
  1481. Object.defineProperty(exports, "__esModule", ({
  1482. value: true
  1483. }));
  1484. exports.AwaitingWithBuffer = void 0;
  1485. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1486. class AwaitingWithBuffer {
  1487. constructor(outstanding, buffer) {
  1488. this._outstanding = outstanding;
  1489. this._buffer = buffer;
  1490. }
  1491. applyClient(client, command) {
  1492. let newBuffer = this._buffer.concat(command);
  1493. return new AwaitingWithBuffer(this._outstanding, newBuffer);
  1494. }
  1495. serverAck(client) {
  1496. client.sendCommand(client.getRevision(), this._buffer);
  1497. return new internal_1.AwaitingConfirm(this._buffer);
  1498. }
  1499. applyServer(client, command) {
  1500. const outstanding = this._outstanding;
  1501. const buffer = this._buffer;
  1502. const pair1 = client.getTransform().transfer(outstanding, command);
  1503. const pair2 = client.getTransform().transfer(buffer, pair1[1]);
  1504. client.applyCommand(pair2[1]);
  1505. return new AwaitingWithBuffer(pair1[0], pair2[0]);
  1506. }
  1507. resend(client) {
  1508. client.sendCommand(client.getRevision(), this._outstanding);
  1509. }
  1510. }
  1511. exports.AwaitingWithBuffer = AwaitingWithBuffer;
  1512. /***/ }),
  1513. /***/ "../ot-core/src/client/Client.ts":
  1514. /*!***************************************!*\
  1515. !*** ../ot-core/src/client/Client.ts ***!
  1516. \***************************************/
  1517. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1518. "use strict";
  1519. Object.defineProperty(exports, "__esModule", ({
  1520. value: true
  1521. }));
  1522. exports.Client = void 0;
  1523. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1524. class Client {
  1525. constructor(conflict) {
  1526. this._revision = 0;
  1527. this._transform = new internal_1.Transform(conflict);
  1528. this._status = internal_1.Synchronized.DEFAULT;
  1529. this._undoManager = new internal_1.UndoManager(this._transform);
  1530. }
  1531. applyClient(command) {
  1532. this._status = this._status.applyClient(this, command);
  1533. }
  1534. serverAck() {
  1535. this._revision++;
  1536. this._status = this._status.serverAck(this);
  1537. }
  1538. applyServer(command) {
  1539. this._revision++;
  1540. this._status = this._status.applyServer(this, command);
  1541. }
  1542. serverReconnect() {
  1543. this._status.resend(this);
  1544. }
  1545. getTransform() {
  1546. return this._transform;
  1547. }
  1548. getRevision() {
  1549. return this._revision;
  1550. }
  1551. getUndoManager() {
  1552. return this._undoManager;
  1553. }
  1554. }
  1555. exports.Client = Client;
  1556. /***/ }),
  1557. /***/ "../ot-core/src/client/ClientSocket.ts":
  1558. /*!*********************************************!*\
  1559. !*** ../ot-core/src/client/ClientSocket.ts ***!
  1560. \*********************************************/
  1561. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1562. "use strict";
  1563. Object.defineProperty(exports, "__esModule", ({
  1564. value: true
  1565. }));
  1566. exports.ClientSocket = void 0;
  1567. const socket_io_client_1 = __webpack_require__(/*! socket.io-client */ "../ot-core/node_modules/socket.io-client/build/cjs/index.js");
  1568. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1569. class ClientSocket extends internal_1.Client {
  1570. constructor(config) {
  1571. super(config.conflict);
  1572. this._config = config;
  1573. this._socket = (0, socket_io_client_1.io)(config.url);
  1574. this._execute = () => {};
  1575. this._initializeListener();
  1576. this._initializeSocket();
  1577. }
  1578. _initializeListener() {
  1579. const observer = this._undoManager.getObserver();
  1580. observer.addOnAddRedoListener({
  1581. onAddRedo: wrapped => {
  1582. wrapped.redo.apply(this._source);
  1583. this.applyClient(wrapped.redo);
  1584. }
  1585. });
  1586. observer.addOnAddUndoListener({
  1587. onAddUndo: wrapped => {
  1588. wrapped.undo.apply(this._source);
  1589. this.applyClient(wrapped.undo);
  1590. }
  1591. });
  1592. }
  1593. _initializeSocket() {
  1594. this._socket.on('open', response => {
  1595. this._revision = response.revision;
  1596. this._users = response.users;
  1597. this._source = response.source;
  1598. this._roomId = response.roomId;
  1599. this._execute();
  1600. });
  1601. this._socket.on('ack', () => {
  1602. this.serverAck();
  1603. });
  1604. this._socket.on('command', (clientId, command) => {
  1605. const deserialize = internal_1.Deserialize.getInstance().formObject(command);
  1606. this.applyServer(deserialize);
  1607. });
  1608. this._socket.on('reconnect', () => {
  1609. this.serverReconnect();
  1610. });
  1611. }
  1612. ready(execute) {
  1613. this._execute = execute;
  1614. }
  1615. sendCommand(revision, command) {
  1616. this._socket.emit('command', revision, command.toJSON());
  1617. }
  1618. applyCommand(command) {
  1619. command.apply(this._source);
  1620. this._undoManager.transform(command);
  1621. }
  1622. }
  1623. exports.ClientSocket = ClientSocket;
  1624. /***/ }),
  1625. /***/ "../ot-core/src/client/Synchronized.ts":
  1626. /*!*********************************************!*\
  1627. !*** ../ot-core/src/client/Synchronized.ts ***!
  1628. \*********************************************/
  1629. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1630. "use strict";
  1631. Object.defineProperty(exports, "__esModule", ({
  1632. value: true
  1633. }));
  1634. exports.Synchronized = void 0;
  1635. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1636. class Synchronized {
  1637. applyClient(client, command) {
  1638. client.sendCommand(client.getRevision(), command);
  1639. return new internal_1.AwaitingConfirm(command);
  1640. }
  1641. serverAck(client) {
  1642. throw new Error("There is no pending operated.");
  1643. }
  1644. applyServer(client, command) {
  1645. client.applyCommand(command);
  1646. return this;
  1647. }
  1648. resend(client) {}
  1649. }
  1650. exports.Synchronized = Synchronized;
  1651. Synchronized.DEFAULT = new Synchronized();
  1652. /***/ }),
  1653. /***/ "../ot-core/src/client/UndoManager.ts":
  1654. /*!********************************************!*\
  1655. !*** ../ot-core/src/client/UndoManager.ts ***!
  1656. \********************************************/
  1657. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1658. "use strict";
  1659. Object.defineProperty(exports, "__esModule", ({
  1660. value: true
  1661. }));
  1662. exports.UndoManager = void 0;
  1663. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1664. class UndoManager {
  1665. constructor(transform) {
  1666. this._redoStack = [];
  1667. this._undoStack = [];
  1668. this._transform = transform;
  1669. this._observer = new internal_1.UndoManagerObserver();
  1670. }
  1671. _transformStack(stack, command) {
  1672. const transform = this._transform;
  1673. const sizeof = stack.length - 1;
  1674. let redoCommand = command;
  1675. let undoCommand = command;
  1676. for (let i = sizeof; i >= 0; i--) {
  1677. const pair1 = transform.transfer(stack[i].redo, redoCommand);
  1678. const pair2 = transform.transfer(stack[i].undo, undoCommand);
  1679. stack[i].redo = pair1[0];
  1680. stack[i].undo = pair2[0];
  1681. redoCommand = pair1[1];
  1682. undoCommand = pair2[1];
  1683. }
  1684. }
  1685. transform(command) {
  1686. this._transformStack(this._undoStack, command);
  1687. this._transformStack(this._redoStack, command);
  1688. }
  1689. canUndo() {
  1690. return this._undoStack.length !== 0;
  1691. }
  1692. canRedo() {
  1693. return this._redoStack.length !== 0;
  1694. }
  1695. addRedo(...parameter) {
  1696. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1697. const wrapped = parameter[0];
  1698. this._redoStack.push(wrapped);
  1699. this._observer.dispatchOnAddRedo(wrapped);
  1700. return;
  1701. }
  1702. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1703. const redo = parameter[0];
  1704. const undo = parameter[1];
  1705. const wrapped = {
  1706. redo,
  1707. undo
  1708. };
  1709. this._redoStack.push(wrapped);
  1710. this._observer.dispatchOnAddRedo(wrapped);
  1711. }
  1712. }
  1713. addUndo(...parameter) {
  1714. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1715. const wrapped = parameter[0];
  1716. this._undoStack.push(wrapped);
  1717. this._observer.dispatchOnAddUndo(wrapped);
  1718. return;
  1719. }
  1720. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1721. const redo = parameter[0];
  1722. const undo = parameter[1];
  1723. const wrapped = {
  1724. redo,
  1725. undo
  1726. };
  1727. this._undoStack.push(wrapped);
  1728. this._observer.dispatchOnAddUndo(wrapped);
  1729. }
  1730. }
  1731. performCommand(...parameter) {
  1732. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  1733. const wrapped = parameter[0];
  1734. this.addRedo(wrapped);
  1735. return;
  1736. }
  1737. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  1738. const redo = parameter[0];
  1739. const undo = parameter[1];
  1740. const wrapped = {
  1741. redo,
  1742. undo
  1743. };
  1744. this.addRedo(wrapped);
  1745. }
  1746. }
  1747. performRedo() {
  1748. if (this.canRedo()) {
  1749. const wrapped = this._redoStack.pop();
  1750. this.addUndo(wrapped);
  1751. this._observer.dispatchOnRedo(wrapped);
  1752. }
  1753. }
  1754. performUndo() {
  1755. if (this.canUndo()) {
  1756. const wrapped = this._undoStack.pop();
  1757. this.addRedo(wrapped);
  1758. this._observer.dispatchOnUndo(wrapped);
  1759. }
  1760. }
  1761. getObserver() {
  1762. return this._observer;
  1763. }
  1764. }
  1765. exports.UndoManager = UndoManager;
  1766. /***/ }),
  1767. /***/ "../ot-core/src/client/UndoManagerObserver.ts":
  1768. /*!****************************************************!*\
  1769. !*** ../ot-core/src/client/UndoManagerObserver.ts ***!
  1770. \****************************************************/
  1771. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1772. "use strict";
  1773. Object.defineProperty(exports, "__esModule", ({
  1774. value: true
  1775. }));
  1776. exports.UndoManagerObserver = void 0;
  1777. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  1778. class UndoManagerObserver {
  1779. dispatchOnAddRedo(wrapped) {
  1780. let listeners = this._onAddRedoListeners;
  1781. if (listeners != null) {
  1782. const sizeof = listeners.sizeof();
  1783. for (let i = 0; i < sizeof; i++) {
  1784. const listener = listeners.get(i);
  1785. listener.onAddRedo(wrapped);
  1786. }
  1787. }
  1788. }
  1789. dispatchOnAddUndo(wrapped) {
  1790. let listeners = this._onAddUndoListeners;
  1791. if (listeners != null) {
  1792. const sizeof = listeners.sizeof();
  1793. for (let i = 0; i < sizeof; i++) {
  1794. const listener = listeners.get(i);
  1795. listener.onAddUndo(wrapped);
  1796. }
  1797. }
  1798. }
  1799. dispatchOnRedo(wrapped) {
  1800. let listeners = this._onRedoListeners;
  1801. if (listeners != null) {
  1802. const sizeof = listeners.sizeof();
  1803. for (let i = 0; i < sizeof; i++) {
  1804. const listener = listeners.get(i);
  1805. listener.onRedo(wrapped);
  1806. }
  1807. }
  1808. }
  1809. dispatchOnUndo(wrapped) {
  1810. let listeners = this._onUndoListeners;
  1811. if (listeners != null) {
  1812. const sizeof = listeners.sizeof();
  1813. for (let i = 0; i < sizeof; i++) {
  1814. const listener = listeners.get(i);
  1815. listener.onUndo(wrapped);
  1816. }
  1817. }
  1818. }
  1819. addOnAddRedoListener(listener) {
  1820. if (this._onAddRedoListeners == null) {
  1821. this._onAddRedoListeners = new internal_1.ArrayList();
  1822. }
  1823. this._onAddRedoListeners.add(listener);
  1824. }
  1825. addOnAddUndoListener(listener) {
  1826. if (this._onAddUndoListeners == null) {
  1827. this._onAddUndoListeners = new internal_1.ArrayList();
  1828. }
  1829. this._onAddUndoListeners.add(listener);
  1830. }
  1831. addOnRedoListener(listener) {
  1832. if (this._onRedoListeners == null) {
  1833. this._onRedoListeners = new internal_1.ArrayList();
  1834. }
  1835. this._onRedoListeners.add(listener);
  1836. }
  1837. addOnUndoListener(listener) {
  1838. if (this._onUndoListeners == null) {
  1839. this._onUndoListeners = new internal_1.ArrayList();
  1840. }
  1841. this._onUndoListeners.add(listener);
  1842. }
  1843. removeOnAddRedoListener(listener) {
  1844. if (this._onAddRedoListeners == null) {
  1845. return;
  1846. }
  1847. this._onAddRedoListeners.remove(listener);
  1848. }
  1849. removeOnAddUndoListener(listener) {
  1850. if (this._onAddUndoListeners == null) {
  1851. return;
  1852. }
  1853. this._onAddUndoListeners.remove(listener);
  1854. }
  1855. removeOnUndoListener(listener) {
  1856. if (this._onUndoListeners == null) {
  1857. return;
  1858. }
  1859. this._onUndoListeners.remove(listener);
  1860. }
  1861. removeOnRedoListener(listener) {
  1862. if (this._onRedoListeners == null) {
  1863. return;
  1864. }
  1865. this._onRedoListeners.remove(listener);
  1866. }
  1867. }
  1868. exports.UndoManagerObserver = UndoManagerObserver;
  1869. /***/ }),
  1870. /***/ "../ot-core/src/config/ClientSocketConfig.ts":
  1871. /*!***************************************************!*\
  1872. !*** ../ot-core/src/config/ClientSocketConfig.ts ***!
  1873. \***************************************************/
  1874. /***/ ((__unused_webpack_module, exports) => {
  1875. "use strict";
  1876. Object.defineProperty(exports, "__esModule", ({
  1877. value: true
  1878. }));
  1879. exports.ClientSocketConfig = void 0;
  1880. class ClientSocketConfig {}
  1881. exports.ClientSocketConfig = ClientSocketConfig;
  1882. /***/ }),
  1883. /***/ "../ot-core/src/index.ts":
  1884. /*!*******************************!*\
  1885. !*** ../ot-core/src/index.ts ***!
  1886. \*******************************/
  1887. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1888. "use strict";
  1889. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  1890. if (k2 === undefined) k2 = k;
  1891. Object.defineProperty(o, k2, {
  1892. enumerable: true,
  1893. get: function () {
  1894. return m[k];
  1895. }
  1896. });
  1897. } : function (o, m, k, k2) {
  1898. if (k2 === undefined) k2 = k;
  1899. o[k2] = m[k];
  1900. });
  1901. var __exportStar = this && this.__exportStar || function (m, exports) {
  1902. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  1903. };
  1904. Object.defineProperty(exports, "__esModule", ({
  1905. value: true
  1906. }));
  1907. __exportStar(__webpack_require__(/*! ./internal */ "../ot-core/src/internal.ts"), exports);
  1908. /***/ }),
  1909. /***/ "../ot-core/src/internal.ts":
  1910. /*!**********************************!*\
  1911. !*** ../ot-core/src/internal.ts ***!
  1912. \**********************************/
  1913. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1914. "use strict";
  1915. // ================================================= typed
  1916. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  1917. if (k2 === undefined) k2 = k;
  1918. Object.defineProperty(o, k2, {
  1919. enumerable: true,
  1920. get: function () {
  1921. return m[k];
  1922. }
  1923. });
  1924. } : function (o, m, k, k2) {
  1925. if (k2 === undefined) k2 = k;
  1926. o[k2] = m[k];
  1927. });
  1928. var __exportStar = this && this.__exportStar || function (m, exports) {
  1929. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  1930. };
  1931. Object.defineProperty(exports, "__esModule", ({
  1932. value: true
  1933. }));
  1934. __exportStar(__webpack_require__(/*! ./typed/GlobalType */ "../ot-core/src/typed/GlobalType.ts"), exports); // ================================================= utils
  1935. __exportStar(__webpack_require__(/*! ./utils/ArrayUtils */ "../ot-core/src/utils/ArrayUtils.ts"), exports);
  1936. __exportStar(__webpack_require__(/*! ./utils/TransformUtils */ "../ot-core/src/utils/TransformUtils.ts"), exports); // ================================================= config
  1937. __exportStar(__webpack_require__(/*! ./config/ClientSocketConfig */ "../ot-core/src/config/ClientSocketConfig.ts"), exports); // ================================================= library
  1938. __exportStar(__webpack_require__(/*! ./library/ArrayList */ "../ot-core/src/library/ArrayList.ts"), exports); // ================================================= basics
  1939. __exportStar(__webpack_require__(/*! ./basics/Command */ "../ot-core/src/basics/Command.ts"), exports);
  1940. __exportStar(__webpack_require__(/*! ./basics/Operation */ "../ot-core/src/basics/Operation.ts"), exports);
  1941. __exportStar(__webpack_require__(/*! ./basics/Conflict */ "../ot-core/src/basics/Conflict.ts"), exports);
  1942. __exportStar(__webpack_require__(/*! ./basics/Transform */ "../ot-core/src/basics/Transform.ts"), exports);
  1943. __exportStar(__webpack_require__(/*! ./basics/SwapData */ "../ot-core/src/basics/SwapData.ts"), exports);
  1944. __exportStar(__webpack_require__(/*! ./basics/Deserialize */ "../ot-core/src/basics/Deserialize.ts"), exports); // ================================================= client
  1945. __exportStar(__webpack_require__(/*! ./client/UndoManager */ "../ot-core/src/client/UndoManager.ts"), exports);
  1946. __exportStar(__webpack_require__(/*! ./client/AwaitingConfirm */ "../ot-core/src/client/AwaitingConfirm.ts"), exports);
  1947. __exportStar(__webpack_require__(/*! ./client/Synchronized */ "../ot-core/src/client/Synchronized.ts"), exports);
  1948. __exportStar(__webpack_require__(/*! ./client/AwaitingWithBuffer */ "../ot-core/src/client/AwaitingWithBuffer.ts"), exports);
  1949. __exportStar(__webpack_require__(/*! ./client/UndoManagerObserver */ "../ot-core/src/client/UndoManagerObserver.ts"), exports);
  1950. __exportStar(__webpack_require__(/*! ./client/Client */ "../ot-core/src/client/Client.ts"), exports);
  1951. __exportStar(__webpack_require__(/*! ./client/ClientSocket */ "../ot-core/src/client/ClientSocket.ts"), exports); // ================================================= server
  1952. __exportStar(__webpack_require__(/*! ./server/Response */ "../ot-core/src/server/Response.ts"), exports);
  1953. __exportStar(__webpack_require__(/*! ./server/User */ "../ot-core/src/server/User.ts"), exports);
  1954. __exportStar(__webpack_require__(/*! ./server/Server */ "../ot-core/src/server/Server.ts"), exports);
  1955. __exportStar(__webpack_require__(/*! ./server/ServerSocket */ "../ot-core/src/server/ServerSocket.ts"), exports);
  1956. /***/ }),
  1957. /***/ "../ot-core/src/library/ArrayList.ts":
  1958. /*!*******************************************!*\
  1959. !*** ../ot-core/src/library/ArrayList.ts ***!
  1960. \*******************************************/
  1961. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1962. "use strict";
  1963. Object.defineProperty(exports, "__esModule", ({
  1964. value: true
  1965. }));
  1966. exports.ArrayList = void 0;
  1967. const TransformUtils_1 = __webpack_require__(/*! ../utils/TransformUtils */ "../ot-core/src/utils/TransformUtils.ts");
  1968. class ArrayList {
  1969. constructor() {
  1970. this._arraylist = new Array();
  1971. }
  1972. get(index) {
  1973. return this._arraylist[index];
  1974. }
  1975. sizeof() {
  1976. return this._arraylist.length;
  1977. }
  1978. add(value) {
  1979. this._arraylist.push(value);
  1980. }
  1981. remove(...parameter) {
  1982. if (TransformUtils_1.TransformUtils.hasLength(parameter, 1)) {
  1983. if (TransformUtils_1.TransformUtils.isNumber(parameter[0])) {
  1984. const index = parameter[0];
  1985. this._arraylist.splice(index, 1);
  1986. return;
  1987. }
  1988. if (TransformUtils_1.TransformUtils.isObject(parameter[0])) {
  1989. const value = parameter[0];
  1990. const arraylist = this._arraylist;
  1991. const sizeof = arraylist.length;
  1992. for (let i = 0; i < sizeof; i++) {
  1993. const item = arraylist[i];
  1994. if (item === value) {
  1995. this._arraylist.splice(i, 1);
  1996. return;
  1997. }
  1998. }
  1999. }
  2000. }
  2001. }
  2002. }
  2003. exports.ArrayList = ArrayList;
  2004. /***/ }),
  2005. /***/ "../ot-core/src/server/Response.ts":
  2006. /*!*****************************************!*\
  2007. !*** ../ot-core/src/server/Response.ts ***!
  2008. \*****************************************/
  2009. /***/ ((__unused_webpack_module, exports) => {
  2010. "use strict";
  2011. Object.defineProperty(exports, "__esModule", ({
  2012. value: true
  2013. }));
  2014. /***/ }),
  2015. /***/ "../ot-core/src/server/Server.ts":
  2016. /*!***************************************!*\
  2017. !*** ../ot-core/src/server/Server.ts ***!
  2018. \***************************************/
  2019. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2020. "use strict";
  2021. Object.defineProperty(exports, "__esModule", ({
  2022. value: true
  2023. }));
  2024. exports.Server = void 0;
  2025. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  2026. class Server {
  2027. constructor(conflict) {
  2028. this._chronicle = new Array();
  2029. this._transform = new internal_1.Transform(conflict);
  2030. }
  2031. receiveCommand(revision, command) {
  2032. if (revision < 0 || this._chronicle.length < revision) {
  2033. throw new Error("command revision not in history");
  2034. }
  2035. let history = this._chronicle.slice(revision);
  2036. for (let i = 0; i < history.length; i++) {
  2037. const saved = history[i];
  2038. if (command.getGroupId() === saved.getGroupId()) {
  2039. command = this._transform.transfer(command, saved)[0];
  2040. }
  2041. }
  2042. this._chronicle.push(command);
  2043. }
  2044. getRevision() {
  2045. return this._chronicle.length;
  2046. }
  2047. }
  2048. exports.Server = Server;
  2049. /***/ }),
  2050. /***/ "../ot-core/src/server/ServerSocket.ts":
  2051. /*!*********************************************!*\
  2052. !*** ../ot-core/src/server/ServerSocket.ts ***!
  2053. \*********************************************/
  2054. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2055. "use strict";
  2056. Object.defineProperty(exports, "__esModule", ({
  2057. value: true
  2058. }));
  2059. exports.ServerSocket = void 0;
  2060. const internal_1 = __webpack_require__(/*! ../internal */ "../ot-core/src/internal.ts");
  2061. class ServerSocket extends internal_1.Server {
  2062. constructor(...parameter) {
  2063. if (internal_1.TransformUtils.hasLength(parameter, 1)) {
  2064. const conflict = parameter[0];
  2065. super(conflict);
  2066. this._roomId = 'empty';
  2067. this._users = [];
  2068. this._source = null;
  2069. return;
  2070. }
  2071. if (internal_1.TransformUtils.hasLength(parameter, 2)) {
  2072. const conflict = parameter[0];
  2073. const source = parameter[1];
  2074. super(conflict);
  2075. this._roomId = 'empty';
  2076. this._users = [];
  2077. this._source = source;
  2078. }
  2079. }
  2080. receiveCommand(revision, command) {
  2081. super.receiveCommand(revision, command);
  2082. command.apply(this._source);
  2083. }
  2084. addSocketClient(client) {
  2085. client.join(this._roomId);
  2086. client.on('command', (revision, command) => {
  2087. this.onCommand(client, revision, command);
  2088. });
  2089. client.on('disconnect', () => {
  2090. this.onDisconnect(client);
  2091. });
  2092. client.emit('open', {
  2093. revision: this.getRevision(),
  2094. clients: this._users,
  2095. roomId: this._roomId,
  2096. source: this._source
  2097. });
  2098. }
  2099. onCommand(client, revision, command) {
  2100. const deserialize = internal_1.Deserialize.getInstance().formObject(command);
  2101. let clientId = client.id;
  2102. this.receiveCommand(revision, deserialize);
  2103. client.emit('ack');
  2104. client.broadcast.in(this._roomId).emit('command', clientId, deserialize.toJSON());
  2105. }
  2106. onDisconnect(client) {
  2107. console.log('Disconnect');
  2108. }
  2109. }
  2110. exports.ServerSocket = ServerSocket;
  2111. /***/ }),
  2112. /***/ "../ot-core/src/server/User.ts":
  2113. /*!*************************************!*\
  2114. !*** ../ot-core/src/server/User.ts ***!
  2115. \*************************************/
  2116. /***/ ((__unused_webpack_module, exports) => {
  2117. "use strict";
  2118. Object.defineProperty(exports, "__esModule", ({
  2119. value: true
  2120. }));
  2121. exports.User = void 0;
  2122. class User {}
  2123. exports.User = User;
  2124. /***/ }),
  2125. /***/ "../ot-core/src/typed/GlobalType.ts":
  2126. /*!******************************************!*\
  2127. !*** ../ot-core/src/typed/GlobalType.ts ***!
  2128. \******************************************/
  2129. /***/ ((__unused_webpack_module, exports) => {
  2130. "use strict";
  2131. Object.defineProperty(exports, "__esModule", ({
  2132. value: true
  2133. }));
  2134. /***/ }),
  2135. /***/ "../ot-core/src/utils/ArrayUtils.ts":
  2136. /*!******************************************!*\
  2137. !*** ../ot-core/src/utils/ArrayUtils.ts ***!
  2138. \******************************************/
  2139. /***/ ((__unused_webpack_module, exports) => {
  2140. "use strict";
  2141. Object.defineProperty(exports, "__esModule", ({
  2142. value: true
  2143. }));
  2144. exports.ArrayUtils = void 0;
  2145. class ArrayUtils {}
  2146. exports.ArrayUtils = ArrayUtils;
  2147. /***/ }),
  2148. /***/ "../ot-core/src/utils/TransformUtils.ts":
  2149. /*!**********************************************!*\
  2150. !*** ../ot-core/src/utils/TransformUtils.ts ***!
  2151. \**********************************************/
  2152. /***/ ((__unused_webpack_module, exports) => {
  2153. "use strict";
  2154. Object.defineProperty(exports, "__esModule", ({
  2155. value: true
  2156. }));
  2157. exports.TransformUtils = void 0;
  2158. class TransformUtils {
  2159. static getValueType(value) {
  2160. return Object.prototype.toString.apply(value);
  2161. }
  2162. static isBoolean(value) {
  2163. return this.getValueType(value) === '[object Boolean]';
  2164. }
  2165. static isString(value) {
  2166. return this.getValueType(value) === '[object String]';
  2167. }
  2168. static isFunction(value) {
  2169. return this.getValueType(value) === '[object Function]';
  2170. }
  2171. static isNumber(value) {
  2172. return this.getValueType(value) === '[object Number]';
  2173. }
  2174. static isDefine(value) {
  2175. return value !== undefined && value !== null;
  2176. }
  2177. static unDefine(value) {
  2178. return value === undefined || value === null;
  2179. }
  2180. static isBlank(value) {
  2181. if (!this.isDefine(value)) {
  2182. return true;
  2183. }
  2184. if (this.isString(value)) {
  2185. return value.trim() === '';
  2186. }
  2187. return false;
  2188. }
  2189. static isConstructor(clazz) {
  2190. return clazz.prototype.constructor === clazz;
  2191. }
  2192. static isAssignableFrom(object, clazz) {
  2193. return object instanceof clazz;
  2194. }
  2195. static isObject(value) {
  2196. return this.getValueType(value) === '[object Object]';
  2197. }
  2198. static isPlainObject(value) {
  2199. if (!this.isDefine(value)) {
  2200. return false;
  2201. }
  2202. return Object.getPrototypeOf(value) === Object.getPrototypeOf({});
  2203. }
  2204. static isArray(value, clazz) {
  2205. let type = this.getValueType(value) === '[object Array]';
  2206. if (type) {
  2207. if (TransformUtils.isDefine(clazz)) {
  2208. value = value;
  2209. if (value.length) {
  2210. return value[0] instanceof clazz;
  2211. }
  2212. }
  2213. return true;
  2214. }
  2215. return false;
  2216. }
  2217. static copy(src, target) {
  2218. Object.assign(src, target);
  2219. }
  2220. static hasLength(target, length) {
  2221. return target.length === length;
  2222. }
  2223. }
  2224. exports.TransformUtils = TransformUtils;
  2225. /***/ }),
  2226. /***/ "./src/basics/Bootstrap.ts":
  2227. /*!*********************************!*\
  2228. !*** ./src/basics/Bootstrap.ts ***!
  2229. \*********************************/
  2230. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2231. "use strict";
  2232. Object.defineProperty(exports, "__esModule", ({
  2233. value: true
  2234. }));
  2235. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2236. var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
  2237. var deserialize = ot_core_1.Deserialize.getInstance();
  2238. deserialize.addClass('InsertColumn', internal_1.InsertColumn);
  2239. deserialize.addClass('InsertRow', internal_1.InsertRow);
  2240. deserialize.addClass('RemoveColumn', internal_1.RemoveColumn);
  2241. deserialize.addClass('RemoveRow', internal_1.RemoveRow);
  2242. /***/ }),
  2243. /***/ "./src/basics/CreateConflict.ts":
  2244. /*!**************************************!*\
  2245. !*** ./src/basics/CreateConflict.ts ***!
  2246. \**************************************/
  2247. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2248. "use strict";
  2249. Object.defineProperty(exports, "__esModule", ({
  2250. value: true
  2251. }));
  2252. exports.CreateConflict = void 0;
  2253. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2254. var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
  2255. function CreateConflict() {
  2256. var conflict = new ot_core_1.Conflict();
  2257. conflict.add(internal_1.InsertRow, internal_1.InsertRow, function (targetCommand, savedCommand) {
  2258. return function (targetOperation, savedOperation) {
  2259. /**
  2260. * 服务端插入的行在当前行的下方
  2261. */
  2262. if (targetOperation.getHeight() <= savedOperation.getIndex()) {
  2263. var offset = savedOperation.getIndex() + targetOperation.getCount();
  2264. savedOperation.setIndex(savedOperation.getIndex() + offset);
  2265. targetCommand.addOperation(targetOperation);
  2266. savedCommand.addOperation(savedOperation);
  2267. }
  2268. /**
  2269. * 服务端插入的行在当前行的上方
  2270. */
  2271. if (targetOperation.getIndex() >= savedOperation.getHeight()) {
  2272. var _offset = targetOperation.getIndex() + savedOperation.getCount();
  2273. targetOperation.setIndex(targetOperation.getIndex() + _offset);
  2274. targetCommand.addOperation(targetOperation);
  2275. savedCommand.addOperation(savedOperation);
  2276. }
  2277. /**
  2278. * 服务端插入的行被当前行包含
  2279. */
  2280. if (targetOperation.getIndex() <= savedOperation.getIndex() && targetOperation.getHeight() >= savedOperation.getHeight()) {
  2281. var spliceCursor = savedOperation.getIndex() - targetOperation.getIndex();
  2282. var prevDataBuffer = targetOperation.getBuffer().getData().splice(0, spliceCursor);
  2283. var nextDataBuffer = targetOperation.getBuffer().getData().splice(spliceCursor);
  2284. var prevOperation = new internal_1.InsertRow({
  2285. describe: 'InsertRowOperation',
  2286. buffer: new ot_core_1.SwapData({
  2287. data: prevDataBuffer,
  2288. describe: 'DataBuffer'
  2289. }),
  2290. index: targetOperation.getIndex(),
  2291. count: savedOperation.getIndex() - targetOperation.getIndex()
  2292. });
  2293. var nextOperation = new internal_1.InsertRow({
  2294. describe: 'InsertRowOperation',
  2295. buffer: new ot_core_1.SwapData({
  2296. data: nextDataBuffer,
  2297. describe: 'DataBuffer'
  2298. }),
  2299. index: savedOperation.getCount(),
  2300. count: targetOperation.getHeight() - savedOperation.getIndex()
  2301. });
  2302. targetCommand.addOperation(prevOperation);
  2303. targetCommand.addOperation(nextOperation);
  2304. }
  2305. /**
  2306. * 服务端插入的行包含当前行
  2307. */
  2308. if (targetOperation.getIndex() >= savedOperation.getIndex() && targetOperation.getHeight() <= savedOperation.getHeight()) {// TODO ....
  2309. }
  2310. /**
  2311. * 服务端插入的行和当前行上交叉
  2312. */
  2313. if (targetOperation.getIndex() > savedOperation.getIndex() && targetOperation.getIndex() < savedOperation.getHeight() && targetOperation.getHeight() >= savedOperation.getHeight()) {// TODO ..
  2314. // ...
  2315. }
  2316. /**
  2317. * 服务端插入的行和当前行下交叉
  2318. */
  2319. if (targetOperation.getIndex() <= savedOperation.getIndex() && targetOperation.getHeight() > savedOperation.getIndex() && targetOperation.getHeight() < savedOperation.getHeight()) {// TODO ...
  2320. //
  2321. }
  2322. };
  2323. });
  2324. return conflict;
  2325. }
  2326. exports.CreateConflict = CreateConflict;
  2327. /***/ }),
  2328. /***/ "./src/client.ts":
  2329. /*!***********************!*\
  2330. !*** ./src/client.ts ***!
  2331. \***********************/
  2332. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  2333. "use strict";
  2334. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  2335. if (k2 === undefined) k2 = k;
  2336. Object.defineProperty(o, k2, {
  2337. enumerable: true,
  2338. get: function get() {
  2339. return m[k];
  2340. }
  2341. });
  2342. } : function (o, m, k, k2) {
  2343. if (k2 === undefined) k2 = k;
  2344. o[k2] = m[k];
  2345. });
  2346. var __exportStar = this && this.__exportStar || function (m, exports) {
  2347. for (var p in m) {
  2348. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  2349. }
  2350. };
  2351. Object.defineProperty(exports, "__esModule", ({
  2352. value: true
  2353. }));
  2354. exports.SwapData = exports.Command = void 0;
  2355. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2356. Object.defineProperty(exports, "Command", ({
  2357. enumerable: true,
  2358. get: function get() {
  2359. return ot_core_1.Command;
  2360. }
  2361. }));
  2362. Object.defineProperty(exports, "SwapData", ({
  2363. enumerable: true,
  2364. get: function get() {
  2365. return ot_core_1.SwapData;
  2366. }
  2367. }));
  2368. __exportStar(__webpack_require__(/*! ./client/Client */ "./src/client/Client.ts"), exports);
  2369. __exportStar(__webpack_require__(/*! ./operated/InsertColumn */ "./src/operated/InsertColumn.ts"), exports);
  2370. __exportStar(__webpack_require__(/*! ./operated/InsertRow */ "./src/operated/InsertRow.ts"), exports);
  2371. __exportStar(__webpack_require__(/*! ./operated/RemoveColumn */ "./src/operated/RemoveColumn.ts"), exports);
  2372. __exportStar(__webpack_require__(/*! ./operated/RemoveRow */ "./src/operated/RemoveRow.ts"), exports);
  2373. /***/ }),
  2374. /***/ "./src/client/Client.ts":
  2375. /*!******************************!*\
  2376. !*** ./src/client/Client.ts ***!
  2377. \******************************/
  2378. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2379. "use strict";
  2380. 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); }
  2381. 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); } }
  2382. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2383. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2384. 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); }
  2385. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2386. 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); }; }
  2387. 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); }
  2388. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2389. 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; } }
  2390. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2391. Object.defineProperty(exports, "__esModule", ({
  2392. value: true
  2393. }));
  2394. exports.Client = void 0;
  2395. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2396. var internal_1 = __webpack_require__(/*! ../internal */ "./src/internal.ts");
  2397. __webpack_require__(/*! ../basics/Bootstrap */ "./src/basics/Bootstrap.ts");
  2398. var Client = /*#__PURE__*/function (_ot_core_1$ClientSock) {
  2399. _inherits(Client, _ot_core_1$ClientSock);
  2400. var _super = _createSuper(Client);
  2401. function Client(post) {
  2402. _classCallCheck(this, Client);
  2403. return _super.call(this, {
  2404. url: post,
  2405. conflict: (0, internal_1.CreateConflict)()
  2406. });
  2407. }
  2408. return _createClass(Client);
  2409. }(ot_core_1.ClientSocket);
  2410. exports.Client = Client;
  2411. /***/ }),
  2412. /***/ "./src/internal.ts":
  2413. /*!*************************!*\
  2414. !*** ./src/internal.ts ***!
  2415. \*************************/
  2416. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  2417. "use strict";
  2418. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  2419. if (k2 === undefined) k2 = k;
  2420. Object.defineProperty(o, k2, {
  2421. enumerable: true,
  2422. get: function get() {
  2423. return m[k];
  2424. }
  2425. });
  2426. } : function (o, m, k, k2) {
  2427. if (k2 === undefined) k2 = k;
  2428. o[k2] = m[k];
  2429. });
  2430. var __exportStar = this && this.__exportStar || function (m, exports) {
  2431. for (var p in m) {
  2432. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  2433. }
  2434. };
  2435. Object.defineProperty(exports, "__esModule", ({
  2436. value: true
  2437. }));
  2438. __exportStar(__webpack_require__(/*! ./operated/InsertColumn */ "./src/operated/InsertColumn.ts"), exports);
  2439. __exportStar(__webpack_require__(/*! ./operated/InsertRow */ "./src/operated/InsertRow.ts"), exports);
  2440. __exportStar(__webpack_require__(/*! ./operated/RemoveColumn */ "./src/operated/RemoveColumn.ts"), exports);
  2441. __exportStar(__webpack_require__(/*! ./operated/RemoveRow */ "./src/operated/RemoveRow.ts"), exports);
  2442. __exportStar(__webpack_require__(/*! ./basics/CreateConflict */ "./src/basics/CreateConflict.ts"), exports);
  2443. /***/ }),
  2444. /***/ "./src/operated/InsertColumn.ts":
  2445. /*!**************************************!*\
  2446. !*** ./src/operated/InsertColumn.ts ***!
  2447. \**************************************/
  2448. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2449. "use strict";
  2450. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2451. 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); } }
  2452. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2453. Object.defineProperty(exports, "__esModule", ({
  2454. value: true
  2455. }));
  2456. exports.InsertColumn = void 0;
  2457. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2458. var InsertColumn = /*#__PURE__*/function () {
  2459. function InsertColumn() {
  2460. _classCallCheck(this, InsertColumn);
  2461. this._describe = 'InsertColumn';
  2462. for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
  2463. parameter[_key] = arguments[_key];
  2464. }
  2465. if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
  2466. this._index = 0;
  2467. this._count = 0;
  2468. this._buffer = new ot_core_1.SwapData();
  2469. return;
  2470. }
  2471. if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
  2472. var serialize = parameter[0];
  2473. this._index = serialize.index;
  2474. this._count = serialize.count;
  2475. this._buffer = ot_core_1.Deserialize.getInstance().formObject(serialize.buffer, new ot_core_1.SwapData());
  2476. }
  2477. }
  2478. _createClass(InsertColumn, [{
  2479. key: "apply",
  2480. value: function apply(resource) {}
  2481. }, {
  2482. key: "setIndex",
  2483. value: function setIndex(index) {
  2484. this._index = index;
  2485. }
  2486. }, {
  2487. key: "setCount",
  2488. value: function setCount(count) {
  2489. this._count = count;
  2490. }
  2491. }, {
  2492. key: "getIndex",
  2493. value: function getIndex() {
  2494. return this._index;
  2495. }
  2496. }, {
  2497. key: "getCount",
  2498. value: function getCount() {
  2499. return this._count;
  2500. }
  2501. }, {
  2502. key: "clone",
  2503. value: function clone() {
  2504. var clone = new InsertColumn();
  2505. clone._index = this._index;
  2506. clone._count = this._count;
  2507. clone._buffer = this._buffer.clone();
  2508. return clone;
  2509. }
  2510. }, {
  2511. key: "toJSON",
  2512. value: function toJSON() {
  2513. return {
  2514. describe: this._describe,
  2515. index: this._index,
  2516. count: this._count,
  2517. buffer: this._buffer
  2518. };
  2519. }
  2520. }]);
  2521. return InsertColumn;
  2522. }();
  2523. exports.InsertColumn = InsertColumn;
  2524. /***/ }),
  2525. /***/ "./src/operated/InsertRow.ts":
  2526. /*!***********************************!*\
  2527. !*** ./src/operated/InsertRow.ts ***!
  2528. \***********************************/
  2529. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2530. "use strict";
  2531. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  2532. 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."); }
  2533. 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); }
  2534. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  2535. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  2536. 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; }
  2537. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2538. 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); } }
  2539. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2540. Object.defineProperty(exports, "__esModule", ({
  2541. value: true
  2542. }));
  2543. exports.InsertRow = void 0;
  2544. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2545. var InsertRow = /*#__PURE__*/function () {
  2546. function InsertRow() {
  2547. _classCallCheck(this, InsertRow);
  2548. this._describe = 'InsertRow';
  2549. for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
  2550. parameter[_key] = arguments[_key];
  2551. }
  2552. if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
  2553. this._index = 0;
  2554. this._count = 0;
  2555. this._buffer = new ot_core_1.SwapData();
  2556. return;
  2557. }
  2558. if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
  2559. var serialize = parameter[0];
  2560. this._index = serialize.index;
  2561. this._count = serialize.count;
  2562. this._buffer = ot_core_1.Deserialize.getInstance().formObject(serialize.buffer, new ot_core_1.SwapData());
  2563. }
  2564. }
  2565. _createClass(InsertRow, [{
  2566. key: "apply",
  2567. value: function apply(resource) {
  2568. var data = this._buffer.getData();
  2569. var index = this._index;
  2570. var count = this._count;
  2571. if (data) {
  2572. resource.splice.apply(resource, [index, 0].concat(_toConsumableArray(data)));
  2573. } else {
  2574. var empty = new Array(count).fill([]);
  2575. resource.splice.apply(resource, [index, 0].concat(_toConsumableArray(empty)));
  2576. }
  2577. }
  2578. }, {
  2579. key: "setIndex",
  2580. value: function setIndex(index) {
  2581. this._index = index;
  2582. }
  2583. }, {
  2584. key: "setCount",
  2585. value: function setCount(count) {
  2586. this._count = count;
  2587. }
  2588. }, {
  2589. key: "getIndex",
  2590. value: function getIndex() {
  2591. return this._index;
  2592. }
  2593. }, {
  2594. key: "getCount",
  2595. value: function getCount() {
  2596. return this._count;
  2597. }
  2598. }, {
  2599. key: "getHeight",
  2600. value: function getHeight() {
  2601. return this._index + this._count;
  2602. }
  2603. }, {
  2604. key: "getBuffer",
  2605. value: function getBuffer() {
  2606. return this._buffer;
  2607. }
  2608. }, {
  2609. key: "clone",
  2610. value: function clone() {
  2611. var clone = new InsertRow();
  2612. clone._index = this._index;
  2613. clone._count = this._count;
  2614. clone._buffer = this._buffer.clone();
  2615. return clone;
  2616. }
  2617. }, {
  2618. key: "toJSON",
  2619. value: function toJSON() {
  2620. return {
  2621. describe: this._describe,
  2622. index: this._index,
  2623. count: this._count,
  2624. buffer: this._buffer
  2625. };
  2626. }
  2627. }]);
  2628. return InsertRow;
  2629. }();
  2630. exports.InsertRow = InsertRow;
  2631. /***/ }),
  2632. /***/ "./src/operated/RemoveColumn.ts":
  2633. /*!**************************************!*\
  2634. !*** ./src/operated/RemoveColumn.ts ***!
  2635. \**************************************/
  2636. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2637. "use strict";
  2638. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2639. 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); } }
  2640. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2641. Object.defineProperty(exports, "__esModule", ({
  2642. value: true
  2643. }));
  2644. exports.RemoveColumn = void 0;
  2645. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2646. var RemoveColumn = /*#__PURE__*/function () {
  2647. function RemoveColumn() {
  2648. _classCallCheck(this, RemoveColumn);
  2649. this._describe = 'RemoveColumn';
  2650. for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
  2651. parameter[_key] = arguments[_key];
  2652. }
  2653. if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
  2654. this._index = 0;
  2655. this._count = 0;
  2656. this._buffer = new ot_core_1.SwapData();
  2657. return;
  2658. }
  2659. if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
  2660. var serialize = parameter[0];
  2661. this._index = serialize.index;
  2662. this._count = serialize.count;
  2663. return;
  2664. }
  2665. if (ot_core_1.TransformUtils.hasLength(parameter, 2)) {
  2666. var _serialize = parameter[0];
  2667. var buffer = parameter[1];
  2668. this._index = _serialize.index;
  2669. this._count = _serialize.count;
  2670. this._buffer = buffer;
  2671. }
  2672. }
  2673. _createClass(RemoveColumn, [{
  2674. key: "apply",
  2675. value: function apply(resource) {}
  2676. }, {
  2677. key: "setIndex",
  2678. value: function setIndex(index) {
  2679. this._index = index;
  2680. }
  2681. }, {
  2682. key: "setCount",
  2683. value: function setCount(count) {
  2684. this._count = count;
  2685. }
  2686. }, {
  2687. key: "getIndex",
  2688. value: function getIndex() {
  2689. return this._index;
  2690. }
  2691. }, {
  2692. key: "getCount",
  2693. value: function getCount() {
  2694. return this._count;
  2695. }
  2696. }, {
  2697. key: "clone",
  2698. value: function clone() {
  2699. var clone = new RemoveColumn();
  2700. clone._index = this._index;
  2701. clone._count = this._count;
  2702. clone._buffer = this._buffer.clone();
  2703. return clone;
  2704. }
  2705. }, {
  2706. key: "toJSON",
  2707. value: function toJSON() {
  2708. return {
  2709. describe: this._describe,
  2710. index: this._index,
  2711. count: this._count
  2712. };
  2713. }
  2714. }]);
  2715. return RemoveColumn;
  2716. }();
  2717. exports.RemoveColumn = RemoveColumn;
  2718. /***/ }),
  2719. /***/ "./src/operated/RemoveRow.ts":
  2720. /*!***********************************!*\
  2721. !*** ./src/operated/RemoveRow.ts ***!
  2722. \***********************************/
  2723. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2724. "use strict";
  2725. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2726. 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); } }
  2727. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  2728. Object.defineProperty(exports, "__esModule", ({
  2729. value: true
  2730. }));
  2731. exports.RemoveRow = void 0;
  2732. var ot_core_1 = __webpack_require__(/*! ot-core */ "../ot-core/src/index.ts");
  2733. var RemoveRow = /*#__PURE__*/function () {
  2734. function RemoveRow() {
  2735. _classCallCheck(this, RemoveRow);
  2736. this._describe = 'RemoveRow';
  2737. for (var _len = arguments.length, parameter = new Array(_len), _key = 0; _key < _len; _key++) {
  2738. parameter[_key] = arguments[_key];
  2739. }
  2740. if (ot_core_1.TransformUtils.hasLength(parameter, 0)) {
  2741. this._index = 0;
  2742. this._count = 0;
  2743. this._buffer = new ot_core_1.SwapData();
  2744. return;
  2745. }
  2746. if (ot_core_1.TransformUtils.hasLength(parameter, 1)) {
  2747. var serialize = parameter[0];
  2748. this._index = serialize.index;
  2749. this._count = serialize.count;
  2750. return;
  2751. }
  2752. if (ot_core_1.TransformUtils.hasLength(parameter, 2)) {
  2753. var _serialize = parameter[0];
  2754. var buffer = parameter[1];
  2755. this._index = _serialize.index;
  2756. this._count = _serialize.count;
  2757. this._buffer = buffer;
  2758. }
  2759. }
  2760. _createClass(RemoveRow, [{
  2761. key: "apply",
  2762. value: function apply(resource) {}
  2763. }, {
  2764. key: "setIndex",
  2765. value: function setIndex(index) {
  2766. this._index = index;
  2767. }
  2768. }, {
  2769. key: "setCount",
  2770. value: function setCount(count) {
  2771. this._count = count;
  2772. }
  2773. }, {
  2774. key: "getIndex",
  2775. value: function getIndex() {
  2776. return this._index;
  2777. }
  2778. }, {
  2779. key: "getCount",
  2780. value: function getCount() {
  2781. return this._count;
  2782. }
  2783. }, {
  2784. key: "clone",
  2785. value: function clone() {
  2786. var clone = new RemoveRow();
  2787. clone._index = this._index;
  2788. clone._count = this._count;
  2789. clone._buffer = this._buffer.clone();
  2790. return clone;
  2791. }
  2792. }, {
  2793. key: "toJSON",
  2794. value: function toJSON() {
  2795. return {
  2796. describe: this._describe,
  2797. index: this._index,
  2798. count: this._count
  2799. };
  2800. }
  2801. }]);
  2802. return RemoveRow;
  2803. }();
  2804. exports.RemoveRow = RemoveRow;
  2805. /***/ }),
  2806. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js":
  2807. /*!********************************************************************************!*\
  2808. !*** ../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js ***!
  2809. \********************************************************************************/
  2810. /***/ ((__unused_webpack_module, exports) => {
  2811. "use strict";
  2812. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2813. exports["default"] = (() => {
  2814. if (typeof self !== "undefined") {
  2815. return self;
  2816. }
  2817. else if (typeof window !== "undefined") {
  2818. return window;
  2819. }
  2820. else {
  2821. return Function("return this")();
  2822. }
  2823. })();
  2824. /***/ }),
  2825. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/index.js":
  2826. /*!*******************************************************************!*\
  2827. !*** ../ot-core/node_modules/engine.io-client/build/cjs/index.js ***!
  2828. \*******************************************************************/
  2829. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2830. "use strict";
  2831. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2832. exports.installTimerFunctions = exports.transports = exports.Transport = exports.protocol = exports.Socket = void 0;
  2833. const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/engine.io-client/build/cjs/socket.js");
  2834. Object.defineProperty(exports, "Socket", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));
  2835. exports.protocol = socket_js_1.Socket.protocol;
  2836. var transport_js_1 = __webpack_require__(/*! ./transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
  2837. Object.defineProperty(exports, "Transport", ({ enumerable: true, get: function () { return transport_js_1.Transport; } }));
  2838. var index_js_1 = __webpack_require__(/*! ./transports/index.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js");
  2839. Object.defineProperty(exports, "transports", ({ enumerable: true, get: function () { return index_js_1.transports; } }));
  2840. var util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
  2841. Object.defineProperty(exports, "installTimerFunctions", ({ enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }));
  2842. /***/ }),
  2843. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/socket.js":
  2844. /*!********************************************************************!*\
  2845. !*** ../ot-core/node_modules/engine.io-client/build/cjs/socket.js ***!
  2846. \********************************************************************/
  2847. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  2848. "use strict";
  2849. var __importDefault = (this && this.__importDefault) || function (mod) {
  2850. return (mod && mod.__esModule) ? mod : { "default": mod };
  2851. };
  2852. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2853. exports.Socket = void 0;
  2854. const index_js_1 = __webpack_require__(/*! ./transports/index.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js");
  2855. const util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
  2856. const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
  2857. const parseuri_1 = __importDefault(__webpack_require__(/*! parseuri */ "../ot-core/node_modules/parseuri/index.js"));
  2858. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  2859. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  2860. const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
  2861. const debug = (0, debug_1.default)("engine.io-client:socket"); // debug()
  2862. class Socket extends component_emitter_1.Emitter {
  2863. /**
  2864. * Socket constructor.
  2865. *
  2866. * @param {String|Object} uri or options
  2867. * @param {Object} opts - options
  2868. * @api public
  2869. */
  2870. constructor(uri, opts = {}) {
  2871. super();
  2872. if (uri && "object" === typeof uri) {
  2873. opts = uri;
  2874. uri = null;
  2875. }
  2876. if (uri) {
  2877. uri = (0, parseuri_1.default)(uri);
  2878. opts.hostname = uri.host;
  2879. opts.secure = uri.protocol === "https" || uri.protocol === "wss";
  2880. opts.port = uri.port;
  2881. if (uri.query)
  2882. opts.query = uri.query;
  2883. }
  2884. else if (opts.host) {
  2885. opts.hostname = (0, parseuri_1.default)(opts.host).host;
  2886. }
  2887. (0, util_js_1.installTimerFunctions)(this, opts);
  2888. this.secure =
  2889. null != opts.secure
  2890. ? opts.secure
  2891. : typeof location !== "undefined" && "https:" === location.protocol;
  2892. if (opts.hostname && !opts.port) {
  2893. // if no port is specified manually, use the protocol default
  2894. opts.port = this.secure ? "443" : "80";
  2895. }
  2896. this.hostname =
  2897. opts.hostname ||
  2898. (typeof location !== "undefined" ? location.hostname : "localhost");
  2899. this.port =
  2900. opts.port ||
  2901. (typeof location !== "undefined" && location.port
  2902. ? location.port
  2903. : this.secure
  2904. ? "443"
  2905. : "80");
  2906. this.transports = opts.transports || ["polling", "websocket"];
  2907. this.readyState = "";
  2908. this.writeBuffer = [];
  2909. this.prevBufferLen = 0;
  2910. this.opts = Object.assign({
  2911. path: "/engine.io",
  2912. agent: false,
  2913. withCredentials: false,
  2914. upgrade: true,
  2915. timestampParam: "t",
  2916. rememberUpgrade: false,
  2917. rejectUnauthorized: true,
  2918. perMessageDeflate: {
  2919. threshold: 1024
  2920. },
  2921. transportOptions: {},
  2922. closeOnBeforeunload: true
  2923. }, opts);
  2924. this.opts.path = this.opts.path.replace(/\/$/, "") + "/";
  2925. if (typeof this.opts.query === "string") {
  2926. this.opts.query = parseqs_1.default.decode(this.opts.query);
  2927. }
  2928. // set on handshake
  2929. this.id = null;
  2930. this.upgrades = null;
  2931. this.pingInterval = null;
  2932. this.pingTimeout = null;
  2933. // set on heartbeat
  2934. this.pingTimeoutTimer = null;
  2935. if (typeof addEventListener === "function") {
  2936. if (this.opts.closeOnBeforeunload) {
  2937. // Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener
  2938. // ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is
  2939. // closed/reloaded)
  2940. addEventListener("beforeunload", () => {
  2941. if (this.transport) {
  2942. // silently close the transport
  2943. this.transport.removeAllListeners();
  2944. this.transport.close();
  2945. }
  2946. }, false);
  2947. }
  2948. if (this.hostname !== "localhost") {
  2949. this.offlineEventListener = () => {
  2950. this.onClose("transport close");
  2951. };
  2952. addEventListener("offline", this.offlineEventListener, false);
  2953. }
  2954. }
  2955. this.open();
  2956. }
  2957. /**
  2958. * Creates transport of the given type.
  2959. *
  2960. * @param {String} transport name
  2961. * @return {Transport}
  2962. * @api private
  2963. */
  2964. createTransport(name) {
  2965. debug('creating transport "%s"', name);
  2966. const query = clone(this.opts.query);
  2967. // append engine.io protocol identifier
  2968. query.EIO = engine_io_parser_1.protocol;
  2969. // transport name
  2970. query.transport = name;
  2971. // session id if we already have one
  2972. if (this.id)
  2973. query.sid = this.id;
  2974. const opts = Object.assign({}, this.opts.transportOptions[name], this.opts, {
  2975. query,
  2976. socket: this,
  2977. hostname: this.hostname,
  2978. secure: this.secure,
  2979. port: this.port
  2980. });
  2981. debug("options: %j", opts);
  2982. return new index_js_1.transports[name](opts);
  2983. }
  2984. /**
  2985. * Initializes transport to use and starts probe.
  2986. *
  2987. * @api private
  2988. */
  2989. open() {
  2990. let transport;
  2991. if (this.opts.rememberUpgrade &&
  2992. Socket.priorWebsocketSuccess &&
  2993. this.transports.indexOf("websocket") !== -1) {
  2994. transport = "websocket";
  2995. }
  2996. else if (0 === this.transports.length) {
  2997. // Emit error on next tick so it can be listened to
  2998. this.setTimeoutFn(() => {
  2999. this.emitReserved("error", "No transports available");
  3000. }, 0);
  3001. return;
  3002. }
  3003. else {
  3004. transport = this.transports[0];
  3005. }
  3006. this.readyState = "opening";
  3007. // Retry with the next transport if the transport is disabled (jsonp: false)
  3008. try {
  3009. transport = this.createTransport(transport);
  3010. }
  3011. catch (e) {
  3012. debug("error while creating transport: %s", e);
  3013. this.transports.shift();
  3014. this.open();
  3015. return;
  3016. }
  3017. transport.open();
  3018. this.setTransport(transport);
  3019. }
  3020. /**
  3021. * Sets the current transport. Disables the existing one (if any).
  3022. *
  3023. * @api private
  3024. */
  3025. setTransport(transport) {
  3026. debug("setting transport %s", transport.name);
  3027. if (this.transport) {
  3028. debug("clearing existing transport %s", this.transport.name);
  3029. this.transport.removeAllListeners();
  3030. }
  3031. // set up transport
  3032. this.transport = transport;
  3033. // set up transport listeners
  3034. transport
  3035. .on("drain", this.onDrain.bind(this))
  3036. .on("packet", this.onPacket.bind(this))
  3037. .on("error", this.onError.bind(this))
  3038. .on("close", () => {
  3039. this.onClose("transport close");
  3040. });
  3041. }
  3042. /**
  3043. * Probes a transport.
  3044. *
  3045. * @param {String} transport name
  3046. * @api private
  3047. */
  3048. probe(name) {
  3049. debug('probing transport "%s"', name);
  3050. let transport = this.createTransport(name);
  3051. let failed = false;
  3052. Socket.priorWebsocketSuccess = false;
  3053. const onTransportOpen = () => {
  3054. if (failed)
  3055. return;
  3056. debug('probe transport "%s" opened', name);
  3057. transport.send([{ type: "ping", data: "probe" }]);
  3058. transport.once("packet", msg => {
  3059. if (failed)
  3060. return;
  3061. if ("pong" === msg.type && "probe" === msg.data) {
  3062. debug('probe transport "%s" pong', name);
  3063. this.upgrading = true;
  3064. this.emitReserved("upgrading", transport);
  3065. if (!transport)
  3066. return;
  3067. Socket.priorWebsocketSuccess = "websocket" === transport.name;
  3068. debug('pausing current transport "%s"', this.transport.name);
  3069. this.transport.pause(() => {
  3070. if (failed)
  3071. return;
  3072. if ("closed" === this.readyState)
  3073. return;
  3074. debug("changing transport and sending upgrade packet");
  3075. cleanup();
  3076. this.setTransport(transport);
  3077. transport.send([{ type: "upgrade" }]);
  3078. this.emitReserved("upgrade", transport);
  3079. transport = null;
  3080. this.upgrading = false;
  3081. this.flush();
  3082. });
  3083. }
  3084. else {
  3085. debug('probe transport "%s" failed', name);
  3086. const err = new Error("probe error");
  3087. // @ts-ignore
  3088. err.transport = transport.name;
  3089. this.emitReserved("upgradeError", err);
  3090. }
  3091. });
  3092. };
  3093. function freezeTransport() {
  3094. if (failed)
  3095. return;
  3096. // Any callback called by transport should be ignored since now
  3097. failed = true;
  3098. cleanup();
  3099. transport.close();
  3100. transport = null;
  3101. }
  3102. // Handle any error that happens while probing
  3103. const onerror = err => {
  3104. const error = new Error("probe error: " + err);
  3105. // @ts-ignore
  3106. error.transport = transport.name;
  3107. freezeTransport();
  3108. debug('probe transport "%s" failed because of error: %s', name, err);
  3109. this.emitReserved("upgradeError", error);
  3110. };
  3111. function onTransportClose() {
  3112. onerror("transport closed");
  3113. }
  3114. // When the socket is closed while we're probing
  3115. function onclose() {
  3116. onerror("socket closed");
  3117. }
  3118. // When the socket is upgraded while we're probing
  3119. function onupgrade(to) {
  3120. if (transport && to.name !== transport.name) {
  3121. debug('"%s" works - aborting "%s"', to.name, transport.name);
  3122. freezeTransport();
  3123. }
  3124. }
  3125. // Remove all listeners on the transport and on self
  3126. const cleanup = () => {
  3127. transport.removeListener("open", onTransportOpen);
  3128. transport.removeListener("error", onerror);
  3129. transport.removeListener("close", onTransportClose);
  3130. this.off("close", onclose);
  3131. this.off("upgrading", onupgrade);
  3132. };
  3133. transport.once("open", onTransportOpen);
  3134. transport.once("error", onerror);
  3135. transport.once("close", onTransportClose);
  3136. this.once("close", onclose);
  3137. this.once("upgrading", onupgrade);
  3138. transport.open();
  3139. }
  3140. /**
  3141. * Called when connection is deemed open.
  3142. *
  3143. * @api private
  3144. */
  3145. onOpen() {
  3146. debug("socket open");
  3147. this.readyState = "open";
  3148. Socket.priorWebsocketSuccess = "websocket" === this.transport.name;
  3149. this.emitReserved("open");
  3150. this.flush();
  3151. // we check for `readyState` in case an `open`
  3152. // listener already closed the socket
  3153. if ("open" === this.readyState &&
  3154. this.opts.upgrade &&
  3155. this.transport.pause) {
  3156. debug("starting upgrade probes");
  3157. let i = 0;
  3158. const l = this.upgrades.length;
  3159. for (; i < l; i++) {
  3160. this.probe(this.upgrades[i]);
  3161. }
  3162. }
  3163. }
  3164. /**
  3165. * Handles a packet.
  3166. *
  3167. * @api private
  3168. */
  3169. onPacket(packet) {
  3170. if ("opening" === this.readyState ||
  3171. "open" === this.readyState ||
  3172. "closing" === this.readyState) {
  3173. debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
  3174. this.emitReserved("packet", packet);
  3175. // Socket is live - any packet counts
  3176. this.emitReserved("heartbeat");
  3177. switch (packet.type) {
  3178. case "open":
  3179. this.onHandshake(JSON.parse(packet.data));
  3180. break;
  3181. case "ping":
  3182. this.resetPingTimeout();
  3183. this.sendPacket("pong");
  3184. this.emitReserved("ping");
  3185. this.emitReserved("pong");
  3186. break;
  3187. case "error":
  3188. const err = new Error("server error");
  3189. // @ts-ignore
  3190. err.code = packet.data;
  3191. this.onError(err);
  3192. break;
  3193. case "message":
  3194. this.emitReserved("data", packet.data);
  3195. this.emitReserved("message", packet.data);
  3196. break;
  3197. }
  3198. }
  3199. else {
  3200. debug('packet received with socket readyState "%s"', this.readyState);
  3201. }
  3202. }
  3203. /**
  3204. * Called upon handshake completion.
  3205. *
  3206. * @param {Object} data - handshake obj
  3207. * @api private
  3208. */
  3209. onHandshake(data) {
  3210. this.emitReserved("handshake", data);
  3211. this.id = data.sid;
  3212. this.transport.query.sid = data.sid;
  3213. this.upgrades = this.filterUpgrades(data.upgrades);
  3214. this.pingInterval = data.pingInterval;
  3215. this.pingTimeout = data.pingTimeout;
  3216. this.onOpen();
  3217. // In case open handler closes socket
  3218. if ("closed" === this.readyState)
  3219. return;
  3220. this.resetPingTimeout();
  3221. }
  3222. /**
  3223. * Sets and resets ping timeout timer based on server pings.
  3224. *
  3225. * @api private
  3226. */
  3227. resetPingTimeout() {
  3228. this.clearTimeoutFn(this.pingTimeoutTimer);
  3229. this.pingTimeoutTimer = this.setTimeoutFn(() => {
  3230. this.onClose("ping timeout");
  3231. }, this.pingInterval + this.pingTimeout);
  3232. if (this.opts.autoUnref) {
  3233. this.pingTimeoutTimer.unref();
  3234. }
  3235. }
  3236. /**
  3237. * Called on `drain` event
  3238. *
  3239. * @api private
  3240. */
  3241. onDrain() {
  3242. this.writeBuffer.splice(0, this.prevBufferLen);
  3243. // setting prevBufferLen = 0 is very important
  3244. // for example, when upgrading, upgrade packet is sent over,
  3245. // and a nonzero prevBufferLen could cause problems on `drain`
  3246. this.prevBufferLen = 0;
  3247. if (0 === this.writeBuffer.length) {
  3248. this.emitReserved("drain");
  3249. }
  3250. else {
  3251. this.flush();
  3252. }
  3253. }
  3254. /**
  3255. * Flush write buffers.
  3256. *
  3257. * @api private
  3258. */
  3259. flush() {
  3260. if ("closed" !== this.readyState &&
  3261. this.transport.writable &&
  3262. !this.upgrading &&
  3263. this.writeBuffer.length) {
  3264. debug("flushing %d packets in socket", this.writeBuffer.length);
  3265. this.transport.send(this.writeBuffer);
  3266. // keep track of current length of writeBuffer
  3267. // splice writeBuffer and callbackBuffer on `drain`
  3268. this.prevBufferLen = this.writeBuffer.length;
  3269. this.emitReserved("flush");
  3270. }
  3271. }
  3272. /**
  3273. * Sends a message.
  3274. *
  3275. * @param {String} message.
  3276. * @param {Function} callback function.
  3277. * @param {Object} options.
  3278. * @return {Socket} for chaining.
  3279. * @api public
  3280. */
  3281. write(msg, options, fn) {
  3282. this.sendPacket("message", msg, options, fn);
  3283. return this;
  3284. }
  3285. send(msg, options, fn) {
  3286. this.sendPacket("message", msg, options, fn);
  3287. return this;
  3288. }
  3289. /**
  3290. * Sends a packet.
  3291. *
  3292. * @param {String} packet type.
  3293. * @param {String} data.
  3294. * @param {Object} options.
  3295. * @param {Function} callback function.
  3296. * @api private
  3297. */
  3298. sendPacket(type, data, options, fn) {
  3299. if ("function" === typeof data) {
  3300. fn = data;
  3301. data = undefined;
  3302. }
  3303. if ("function" === typeof options) {
  3304. fn = options;
  3305. options = null;
  3306. }
  3307. if ("closing" === this.readyState || "closed" === this.readyState) {
  3308. return;
  3309. }
  3310. options = options || {};
  3311. options.compress = false !== options.compress;
  3312. const packet = {
  3313. type: type,
  3314. data: data,
  3315. options: options
  3316. };
  3317. this.emitReserved("packetCreate", packet);
  3318. this.writeBuffer.push(packet);
  3319. if (fn)
  3320. this.once("flush", fn);
  3321. this.flush();
  3322. }
  3323. /**
  3324. * Closes the connection.
  3325. *
  3326. * @api public
  3327. */
  3328. close() {
  3329. const close = () => {
  3330. this.onClose("forced close");
  3331. debug("socket closing - telling transport to close");
  3332. this.transport.close();
  3333. };
  3334. const cleanupAndClose = () => {
  3335. this.off("upgrade", cleanupAndClose);
  3336. this.off("upgradeError", cleanupAndClose);
  3337. close();
  3338. };
  3339. const waitForUpgrade = () => {
  3340. // wait for upgrade to finish since we can't send packets while pausing a transport
  3341. this.once("upgrade", cleanupAndClose);
  3342. this.once("upgradeError", cleanupAndClose);
  3343. };
  3344. if ("opening" === this.readyState || "open" === this.readyState) {
  3345. this.readyState = "closing";
  3346. if (this.writeBuffer.length) {
  3347. this.once("drain", () => {
  3348. if (this.upgrading) {
  3349. waitForUpgrade();
  3350. }
  3351. else {
  3352. close();
  3353. }
  3354. });
  3355. }
  3356. else if (this.upgrading) {
  3357. waitForUpgrade();
  3358. }
  3359. else {
  3360. close();
  3361. }
  3362. }
  3363. return this;
  3364. }
  3365. /**
  3366. * Called upon transport error
  3367. *
  3368. * @api private
  3369. */
  3370. onError(err) {
  3371. debug("socket error %j", err);
  3372. Socket.priorWebsocketSuccess = false;
  3373. this.emitReserved("error", err);
  3374. this.onClose("transport error", err);
  3375. }
  3376. /**
  3377. * Called upon transport close.
  3378. *
  3379. * @api private
  3380. */
  3381. onClose(reason, desc) {
  3382. if ("opening" === this.readyState ||
  3383. "open" === this.readyState ||
  3384. "closing" === this.readyState) {
  3385. debug('socket close with reason: "%s"', reason);
  3386. // clear timers
  3387. this.clearTimeoutFn(this.pingTimeoutTimer);
  3388. // stop event from firing again for transport
  3389. this.transport.removeAllListeners("close");
  3390. // ensure transport won't stay open
  3391. this.transport.close();
  3392. // ignore further transport communication
  3393. this.transport.removeAllListeners();
  3394. if (typeof removeEventListener === "function") {
  3395. removeEventListener("offline", this.offlineEventListener, false);
  3396. }
  3397. // set ready state
  3398. this.readyState = "closed";
  3399. // clear session id
  3400. this.id = null;
  3401. // emit close event
  3402. this.emitReserved("close", reason, desc);
  3403. // clean buffers after, so users can still
  3404. // grab the buffers on `close` event
  3405. this.writeBuffer = [];
  3406. this.prevBufferLen = 0;
  3407. }
  3408. }
  3409. /**
  3410. * Filters upgrades, returning only those matching client transports.
  3411. *
  3412. * @param {Array} server upgrades
  3413. * @api private
  3414. *
  3415. */
  3416. filterUpgrades(upgrades) {
  3417. const filteredUpgrades = [];
  3418. let i = 0;
  3419. const j = upgrades.length;
  3420. for (; i < j; i++) {
  3421. if (~this.transports.indexOf(upgrades[i]))
  3422. filteredUpgrades.push(upgrades[i]);
  3423. }
  3424. return filteredUpgrades;
  3425. }
  3426. }
  3427. exports.Socket = Socket;
  3428. Socket.protocol = engine_io_parser_1.protocol;
  3429. function clone(obj) {
  3430. const o = {};
  3431. for (let i in obj) {
  3432. if (obj.hasOwnProperty(i)) {
  3433. o[i] = obj[i];
  3434. }
  3435. }
  3436. return o;
  3437. }
  3438. /***/ }),
  3439. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js":
  3440. /*!***********************************************************************!*\
  3441. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transport.js ***!
  3442. \***********************************************************************/
  3443. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  3444. "use strict";
  3445. var __importDefault = (this && this.__importDefault) || function (mod) {
  3446. return (mod && mod.__esModule) ? mod : { "default": mod };
  3447. };
  3448. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3449. exports.Transport = void 0;
  3450. const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
  3451. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  3452. const util_js_1 = __webpack_require__(/*! ./util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
  3453. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  3454. const debug = (0, debug_1.default)("engine.io-client:transport"); // debug()
  3455. class Transport extends component_emitter_1.Emitter {
  3456. /**
  3457. * Transport abstract constructor.
  3458. *
  3459. * @param {Object} options.
  3460. * @api private
  3461. */
  3462. constructor(opts) {
  3463. super();
  3464. this.writable = false;
  3465. (0, util_js_1.installTimerFunctions)(this, opts);
  3466. this.opts = opts;
  3467. this.query = opts.query;
  3468. this.readyState = "";
  3469. this.socket = opts.socket;
  3470. }
  3471. /**
  3472. * Emits an error.
  3473. *
  3474. * @param {String} str
  3475. * @return {Transport} for chaining
  3476. * @api protected
  3477. */
  3478. onError(msg, desc) {
  3479. const err = new Error(msg);
  3480. // @ts-ignore
  3481. err.type = "TransportError";
  3482. // @ts-ignore
  3483. err.description = desc;
  3484. super.emit("error", err);
  3485. return this;
  3486. }
  3487. /**
  3488. * Opens the transport.
  3489. *
  3490. * @api public
  3491. */
  3492. open() {
  3493. if ("closed" === this.readyState || "" === this.readyState) {
  3494. this.readyState = "opening";
  3495. this.doOpen();
  3496. }
  3497. return this;
  3498. }
  3499. /**
  3500. * Closes the transport.
  3501. *
  3502. * @api public
  3503. */
  3504. close() {
  3505. if ("opening" === this.readyState || "open" === this.readyState) {
  3506. this.doClose();
  3507. this.onClose();
  3508. }
  3509. return this;
  3510. }
  3511. /**
  3512. * Sends multiple packets.
  3513. *
  3514. * @param {Array} packets
  3515. * @api public
  3516. */
  3517. send(packets) {
  3518. if ("open" === this.readyState) {
  3519. this.write(packets);
  3520. }
  3521. else {
  3522. // this might happen if the transport was silently closed in the beforeunload event handler
  3523. debug("transport is not open, discarding packets");
  3524. }
  3525. }
  3526. /**
  3527. * Called upon open
  3528. *
  3529. * @api protected
  3530. */
  3531. onOpen() {
  3532. this.readyState = "open";
  3533. this.writable = true;
  3534. super.emit("open");
  3535. }
  3536. /**
  3537. * Called with data.
  3538. *
  3539. * @param {String} data
  3540. * @api protected
  3541. */
  3542. onData(data) {
  3543. const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType);
  3544. this.onPacket(packet);
  3545. }
  3546. /**
  3547. * Called with a decoded packet.
  3548. *
  3549. * @api protected
  3550. */
  3551. onPacket(packet) {
  3552. super.emit("packet", packet);
  3553. }
  3554. /**
  3555. * Called upon close.
  3556. *
  3557. * @api protected
  3558. */
  3559. onClose() {
  3560. this.readyState = "closed";
  3561. super.emit("close");
  3562. }
  3563. }
  3564. exports.Transport = Transport;
  3565. /***/ }),
  3566. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js":
  3567. /*!******************************************************************************!*\
  3568. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/index.js ***!
  3569. \******************************************************************************/
  3570. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3571. "use strict";
  3572. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3573. exports.transports = void 0;
  3574. const polling_xhr_js_1 = __webpack_require__(/*! ./polling-xhr.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js");
  3575. const websocket_js_1 = __webpack_require__(/*! ./websocket.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js");
  3576. exports.transports = {
  3577. websocket: websocket_js_1.WS,
  3578. polling: polling_xhr_js_1.XHR
  3579. };
  3580. /***/ }),
  3581. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js":
  3582. /*!************************************************************************************!*\
  3583. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js ***!
  3584. \************************************************************************************/
  3585. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  3586. "use strict";
  3587. /* global attachEvent */
  3588. var __importDefault = (this && this.__importDefault) || function (mod) {
  3589. return (mod && mod.__esModule) ? mod : { "default": mod };
  3590. };
  3591. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3592. exports.Request = exports.XHR = void 0;
  3593. const xmlhttprequest_js_1 = __importDefault(__webpack_require__(/*! ./xmlhttprequest.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js"));
  3594. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  3595. const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
  3596. const util_js_1 = __webpack_require__(/*! ../util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
  3597. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  3598. const polling_js_1 = __webpack_require__(/*! ./polling.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js");
  3599. const debug = (0, debug_1.default)("engine.io-client:polling-xhr"); // debug()
  3600. /**
  3601. * Empty function
  3602. */
  3603. function empty() { }
  3604. const hasXHR2 = (function () {
  3605. const xhr = new xmlhttprequest_js_1.default({
  3606. xdomain: false
  3607. });
  3608. return null != xhr.responseType;
  3609. })();
  3610. class XHR extends polling_js_1.Polling {
  3611. /**
  3612. * XHR Polling constructor.
  3613. *
  3614. * @param {Object} opts
  3615. * @api public
  3616. */
  3617. constructor(opts) {
  3618. super(opts);
  3619. if (typeof location !== "undefined") {
  3620. const isSSL = "https:" === location.protocol;
  3621. let port = location.port;
  3622. // some user agents have empty `location.port`
  3623. if (!port) {
  3624. port = isSSL ? "443" : "80";
  3625. }
  3626. this.xd =
  3627. (typeof location !== "undefined" &&
  3628. opts.hostname !== location.hostname) ||
  3629. port !== opts.port;
  3630. this.xs = opts.secure !== isSSL;
  3631. }
  3632. /**
  3633. * XHR supports binary
  3634. */
  3635. const forceBase64 = opts && opts.forceBase64;
  3636. this.supportsBinary = hasXHR2 && !forceBase64;
  3637. }
  3638. /**
  3639. * Creates a request.
  3640. *
  3641. * @param {String} method
  3642. * @api private
  3643. */
  3644. request(opts = {}) {
  3645. Object.assign(opts, { xd: this.xd, xs: this.xs }, this.opts);
  3646. return new Request(this.uri(), opts);
  3647. }
  3648. /**
  3649. * Sends data.
  3650. *
  3651. * @param {String} data to send.
  3652. * @param {Function} called upon flush.
  3653. * @api private
  3654. */
  3655. doWrite(data, fn) {
  3656. const req = this.request({
  3657. method: "POST",
  3658. data: data
  3659. });
  3660. req.on("success", fn);
  3661. req.on("error", err => {
  3662. this.onError("xhr post error", err);
  3663. });
  3664. }
  3665. /**
  3666. * Starts a poll cycle.
  3667. *
  3668. * @api private
  3669. */
  3670. doPoll() {
  3671. debug("xhr poll");
  3672. const req = this.request();
  3673. req.on("data", this.onData.bind(this));
  3674. req.on("error", err => {
  3675. this.onError("xhr poll error", err);
  3676. });
  3677. this.pollXhr = req;
  3678. }
  3679. }
  3680. exports.XHR = XHR;
  3681. class Request extends component_emitter_1.Emitter {
  3682. /**
  3683. * Request constructor
  3684. *
  3685. * @param {Object} options
  3686. * @api public
  3687. */
  3688. constructor(uri, opts) {
  3689. super();
  3690. (0, util_js_1.installTimerFunctions)(this, opts);
  3691. this.opts = opts;
  3692. this.method = opts.method || "GET";
  3693. this.uri = uri;
  3694. this.async = false !== opts.async;
  3695. this.data = undefined !== opts.data ? opts.data : null;
  3696. this.create();
  3697. }
  3698. /**
  3699. * Creates the XHR object and sends the request.
  3700. *
  3701. * @api private
  3702. */
  3703. create() {
  3704. const opts = (0, util_js_1.pick)(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
  3705. opts.xdomain = !!this.opts.xd;
  3706. opts.xscheme = !!this.opts.xs;
  3707. const xhr = (this.xhr = new xmlhttprequest_js_1.default(opts));
  3708. try {
  3709. debug("xhr open %s: %s", this.method, this.uri);
  3710. xhr.open(this.method, this.uri, this.async);
  3711. try {
  3712. if (this.opts.extraHeaders) {
  3713. xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
  3714. for (let i in this.opts.extraHeaders) {
  3715. if (this.opts.extraHeaders.hasOwnProperty(i)) {
  3716. xhr.setRequestHeader(i, this.opts.extraHeaders[i]);
  3717. }
  3718. }
  3719. }
  3720. }
  3721. catch (e) { }
  3722. if ("POST" === this.method) {
  3723. try {
  3724. xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
  3725. }
  3726. catch (e) { }
  3727. }
  3728. try {
  3729. xhr.setRequestHeader("Accept", "*/*");
  3730. }
  3731. catch (e) { }
  3732. // ie6 check
  3733. if ("withCredentials" in xhr) {
  3734. xhr.withCredentials = this.opts.withCredentials;
  3735. }
  3736. if (this.opts.requestTimeout) {
  3737. xhr.timeout = this.opts.requestTimeout;
  3738. }
  3739. xhr.onreadystatechange = () => {
  3740. if (4 !== xhr.readyState)
  3741. return;
  3742. if (200 === xhr.status || 1223 === xhr.status) {
  3743. this.onLoad();
  3744. }
  3745. else {
  3746. // make sure the `error` event handler that's user-set
  3747. // does not throw in the same tick and gets caught here
  3748. this.setTimeoutFn(() => {
  3749. this.onError(typeof xhr.status === "number" ? xhr.status : 0);
  3750. }, 0);
  3751. }
  3752. };
  3753. debug("xhr data %s", this.data);
  3754. xhr.send(this.data);
  3755. }
  3756. catch (e) {
  3757. // Need to defer since .create() is called directly from the constructor
  3758. // and thus the 'error' event can only be only bound *after* this exception
  3759. // occurs. Therefore, also, we cannot throw here at all.
  3760. this.setTimeoutFn(() => {
  3761. this.onError(e);
  3762. }, 0);
  3763. return;
  3764. }
  3765. if (typeof document !== "undefined") {
  3766. this.index = Request.requestsCount++;
  3767. Request.requests[this.index] = this;
  3768. }
  3769. }
  3770. /**
  3771. * Called upon successful response.
  3772. *
  3773. * @api private
  3774. */
  3775. onSuccess() {
  3776. this.emit("success");
  3777. this.cleanup();
  3778. }
  3779. /**
  3780. * Called if we have data.
  3781. *
  3782. * @api private
  3783. */
  3784. onData(data) {
  3785. this.emit("data", data);
  3786. this.onSuccess();
  3787. }
  3788. /**
  3789. * Called upon error.
  3790. *
  3791. * @api private
  3792. */
  3793. onError(err) {
  3794. this.emit("error", err);
  3795. this.cleanup(true);
  3796. }
  3797. /**
  3798. * Cleans up house.
  3799. *
  3800. * @api private
  3801. */
  3802. cleanup(fromError) {
  3803. if ("undefined" === typeof this.xhr || null === this.xhr) {
  3804. return;
  3805. }
  3806. this.xhr.onreadystatechange = empty;
  3807. if (fromError) {
  3808. try {
  3809. this.xhr.abort();
  3810. }
  3811. catch (e) { }
  3812. }
  3813. if (typeof document !== "undefined") {
  3814. delete Request.requests[this.index];
  3815. }
  3816. this.xhr = null;
  3817. }
  3818. /**
  3819. * Called upon load.
  3820. *
  3821. * @api private
  3822. */
  3823. onLoad() {
  3824. const data = this.xhr.responseText;
  3825. if (data !== null) {
  3826. this.onData(data);
  3827. }
  3828. }
  3829. /**
  3830. * Aborts the request.
  3831. *
  3832. * @api public
  3833. */
  3834. abort() {
  3835. this.cleanup();
  3836. }
  3837. }
  3838. exports.Request = Request;
  3839. Request.requestsCount = 0;
  3840. Request.requests = {};
  3841. /**
  3842. * Aborts pending requests when unloading the window. This is needed to prevent
  3843. * memory leaks (e.g. when using IE) and to ensure that no spurious error is
  3844. * emitted.
  3845. */
  3846. if (typeof document !== "undefined") {
  3847. // @ts-ignore
  3848. if (typeof attachEvent === "function") {
  3849. // @ts-ignore
  3850. attachEvent("onunload", unloadHandler);
  3851. }
  3852. else if (typeof addEventListener === "function") {
  3853. const terminationEvent = "onpagehide" in globalThis_js_1.default ? "pagehide" : "unload";
  3854. addEventListener(terminationEvent, unloadHandler, false);
  3855. }
  3856. }
  3857. function unloadHandler() {
  3858. for (let i in Request.requests) {
  3859. if (Request.requests.hasOwnProperty(i)) {
  3860. Request.requests[i].abort();
  3861. }
  3862. }
  3863. }
  3864. /***/ }),
  3865. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js":
  3866. /*!********************************************************************************!*\
  3867. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/polling.js ***!
  3868. \********************************************************************************/
  3869. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  3870. "use strict";
  3871. var __importDefault = (this && this.__importDefault) || function (mod) {
  3872. return (mod && mod.__esModule) ? mod : { "default": mod };
  3873. };
  3874. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3875. exports.Polling = void 0;
  3876. const transport_js_1 = __webpack_require__(/*! ../transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
  3877. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  3878. const yeast_1 = __importDefault(__webpack_require__(/*! yeast */ "../ot-core/node_modules/yeast/index.js"));
  3879. const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
  3880. const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
  3881. const debug = (0, debug_1.default)("engine.io-client:polling"); // debug()
  3882. class Polling extends transport_js_1.Transport {
  3883. constructor() {
  3884. super(...arguments);
  3885. this.polling = false;
  3886. }
  3887. /**
  3888. * Transport name.
  3889. */
  3890. get name() {
  3891. return "polling";
  3892. }
  3893. /**
  3894. * Opens the socket (triggers polling). We write a PING message to determine
  3895. * when the transport is open.
  3896. *
  3897. * @api private
  3898. */
  3899. doOpen() {
  3900. this.poll();
  3901. }
  3902. /**
  3903. * Pauses polling.
  3904. *
  3905. * @param {Function} callback upon buffers are flushed and transport is paused
  3906. * @api private
  3907. */
  3908. pause(onPause) {
  3909. this.readyState = "pausing";
  3910. const pause = () => {
  3911. debug("paused");
  3912. this.readyState = "paused";
  3913. onPause();
  3914. };
  3915. if (this.polling || !this.writable) {
  3916. let total = 0;
  3917. if (this.polling) {
  3918. debug("we are currently polling - waiting to pause");
  3919. total++;
  3920. this.once("pollComplete", function () {
  3921. debug("pre-pause polling complete");
  3922. --total || pause();
  3923. });
  3924. }
  3925. if (!this.writable) {
  3926. debug("we are currently writing - waiting to pause");
  3927. total++;
  3928. this.once("drain", function () {
  3929. debug("pre-pause writing complete");
  3930. --total || pause();
  3931. });
  3932. }
  3933. }
  3934. else {
  3935. pause();
  3936. }
  3937. }
  3938. /**
  3939. * Starts polling cycle.
  3940. *
  3941. * @api public
  3942. */
  3943. poll() {
  3944. debug("polling");
  3945. this.polling = true;
  3946. this.doPoll();
  3947. this.emit("poll");
  3948. }
  3949. /**
  3950. * Overloads onData to detect payloads.
  3951. *
  3952. * @api private
  3953. */
  3954. onData(data) {
  3955. debug("polling got data %s", data);
  3956. const callback = packet => {
  3957. // if its the first message we consider the transport open
  3958. if ("opening" === this.readyState && packet.type === "open") {
  3959. this.onOpen();
  3960. }
  3961. // if its a close packet, we close the ongoing requests
  3962. if ("close" === packet.type) {
  3963. this.onClose();
  3964. return false;
  3965. }
  3966. // otherwise bypass onData and handle the message
  3967. this.onPacket(packet);
  3968. };
  3969. // decode payload
  3970. (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback);
  3971. // if an event did not trigger closing
  3972. if ("closed" !== this.readyState) {
  3973. // if we got data we're not polling
  3974. this.polling = false;
  3975. this.emit("pollComplete");
  3976. if ("open" === this.readyState) {
  3977. this.poll();
  3978. }
  3979. else {
  3980. debug('ignoring poll - transport state "%s"', this.readyState);
  3981. }
  3982. }
  3983. }
  3984. /**
  3985. * For polling, send a close packet.
  3986. *
  3987. * @api private
  3988. */
  3989. doClose() {
  3990. const close = () => {
  3991. debug("writing close packet");
  3992. this.write([{ type: "close" }]);
  3993. };
  3994. if ("open" === this.readyState) {
  3995. debug("transport open - closing");
  3996. close();
  3997. }
  3998. else {
  3999. // in case we're trying to close while
  4000. // handshaking is in progress (GH-164)
  4001. debug("transport not open - deferring close");
  4002. this.once("open", close);
  4003. }
  4004. }
  4005. /**
  4006. * Writes a packets payload.
  4007. *
  4008. * @param {Array} data packets
  4009. * @param {Function} drain callback
  4010. * @api private
  4011. */
  4012. write(packets) {
  4013. this.writable = false;
  4014. (0, engine_io_parser_1.encodePayload)(packets, data => {
  4015. this.doWrite(data, () => {
  4016. this.writable = true;
  4017. this.emit("drain");
  4018. });
  4019. });
  4020. }
  4021. /**
  4022. * Generates uri for connection.
  4023. *
  4024. * @api private
  4025. */
  4026. uri() {
  4027. let query = this.query || {};
  4028. const schema = this.opts.secure ? "https" : "http";
  4029. let port = "";
  4030. // cache busting is forced
  4031. if (false !== this.opts.timestampRequests) {
  4032. query[this.opts.timestampParam] = (0, yeast_1.default)();
  4033. }
  4034. if (!this.supportsBinary && !query.sid) {
  4035. query.b64 = 1;
  4036. }
  4037. // avoid port if default for schema
  4038. if (this.opts.port &&
  4039. (("https" === schema && Number(this.opts.port) !== 443) ||
  4040. ("http" === schema && Number(this.opts.port) !== 80))) {
  4041. port = ":" + this.opts.port;
  4042. }
  4043. const encodedQuery = parseqs_1.default.encode(query);
  4044. const ipv6 = this.opts.hostname.indexOf(":") !== -1;
  4045. return (schema +
  4046. "://" +
  4047. (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) +
  4048. port +
  4049. this.opts.path +
  4050. (encodedQuery.length ? "?" + encodedQuery : ""));
  4051. }
  4052. }
  4053. exports.Polling = Polling;
  4054. /***/ }),
  4055. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js":
  4056. /*!******************************************************************************************************!*\
  4057. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js ***!
  4058. \******************************************************************************************************/
  4059. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  4060. "use strict";
  4061. var __importDefault = (this && this.__importDefault) || function (mod) {
  4062. return (mod && mod.__esModule) ? mod : { "default": mod };
  4063. };
  4064. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4065. exports.defaultBinaryType = exports.usingBrowserWebSocket = exports.WebSocket = exports.nextTick = void 0;
  4066. const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
  4067. exports.nextTick = (() => {
  4068. const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
  4069. if (isPromiseAvailable) {
  4070. return cb => Promise.resolve().then(cb);
  4071. }
  4072. else {
  4073. return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
  4074. }
  4075. })();
  4076. exports.WebSocket = globalThis_js_1.default.WebSocket || globalThis_js_1.default.MozWebSocket;
  4077. exports.usingBrowserWebSocket = true;
  4078. exports.defaultBinaryType = "arraybuffer";
  4079. /***/ }),
  4080. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js":
  4081. /*!**********************************************************************************!*\
  4082. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket.js ***!
  4083. \**********************************************************************************/
  4084. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  4085. "use strict";
  4086. var __importDefault = (this && this.__importDefault) || function (mod) {
  4087. return (mod && mod.__esModule) ? mod : { "default": mod };
  4088. };
  4089. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4090. exports.WS = void 0;
  4091. const transport_js_1 = __webpack_require__(/*! ../transport.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transport.js");
  4092. const parseqs_1 = __importDefault(__webpack_require__(/*! parseqs */ "../ot-core/node_modules/parseqs/index.js"));
  4093. const yeast_1 = __importDefault(__webpack_require__(/*! yeast */ "../ot-core/node_modules/yeast/index.js"));
  4094. const util_js_1 = __webpack_require__(/*! ../util.js */ "../ot-core/node_modules/engine.io-client/build/cjs/util.js");
  4095. const websocket_constructor_js_1 = __webpack_require__(/*! ./websocket-constructor.js */ "../ot-core/node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js");
  4096. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  4097. const engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js");
  4098. const debug = (0, debug_1.default)("engine.io-client:websocket"); // debug()
  4099. // detect ReactNative environment
  4100. const isReactNative = typeof navigator !== "undefined" &&
  4101. typeof navigator.product === "string" &&
  4102. navigator.product.toLowerCase() === "reactnative";
  4103. class WS extends transport_js_1.Transport {
  4104. /**
  4105. * WebSocket transport constructor.
  4106. *
  4107. * @api {Object} connection options
  4108. * @api public
  4109. */
  4110. constructor(opts) {
  4111. super(opts);
  4112. this.supportsBinary = !opts.forceBase64;
  4113. }
  4114. /**
  4115. * Transport name.
  4116. *
  4117. * @api public
  4118. */
  4119. get name() {
  4120. return "websocket";
  4121. }
  4122. /**
  4123. * Opens socket.
  4124. *
  4125. * @api private
  4126. */
  4127. doOpen() {
  4128. if (!this.check()) {
  4129. // let probe timeout
  4130. return;
  4131. }
  4132. const uri = this.uri();
  4133. const protocols = this.opts.protocols;
  4134. // React Native only supports the 'headers' option, and will print a warning if anything else is passed
  4135. const opts = isReactNative
  4136. ? {}
  4137. : (0, util_js_1.pick)(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
  4138. if (this.opts.extraHeaders) {
  4139. opts.headers = this.opts.extraHeaders;
  4140. }
  4141. try {
  4142. this.ws =
  4143. websocket_constructor_js_1.usingBrowserWebSocket && !isReactNative
  4144. ? protocols
  4145. ? new websocket_constructor_js_1.WebSocket(uri, protocols)
  4146. : new websocket_constructor_js_1.WebSocket(uri)
  4147. : new websocket_constructor_js_1.WebSocket(uri, protocols, opts);
  4148. }
  4149. catch (err) {
  4150. return this.emit("error", err);
  4151. }
  4152. this.ws.binaryType = this.socket.binaryType || websocket_constructor_js_1.defaultBinaryType;
  4153. this.addEventListeners();
  4154. }
  4155. /**
  4156. * Adds event listeners to the socket
  4157. *
  4158. * @api private
  4159. */
  4160. addEventListeners() {
  4161. this.ws.onopen = () => {
  4162. if (this.opts.autoUnref) {
  4163. this.ws._socket.unref();
  4164. }
  4165. this.onOpen();
  4166. };
  4167. this.ws.onclose = this.onClose.bind(this);
  4168. this.ws.onmessage = ev => this.onData(ev.data);
  4169. this.ws.onerror = e => this.onError("websocket error", e);
  4170. }
  4171. /**
  4172. * Writes data to socket.
  4173. *
  4174. * @param {Array} array of packets.
  4175. * @api private
  4176. */
  4177. write(packets) {
  4178. this.writable = false;
  4179. // encodePacket efficient as it uses WS framing
  4180. // no need for encodePayload
  4181. for (let i = 0; i < packets.length; i++) {
  4182. const packet = packets[i];
  4183. const lastPacket = i === packets.length - 1;
  4184. (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, data => {
  4185. // always create a new object (GH-437)
  4186. const opts = {};
  4187. if (!websocket_constructor_js_1.usingBrowserWebSocket) {
  4188. if (packet.options) {
  4189. opts.compress = packet.options.compress;
  4190. }
  4191. if (this.opts.perMessageDeflate) {
  4192. const len = "string" === typeof data ? Buffer.byteLength(data) : data.length;
  4193. if (len < this.opts.perMessageDeflate.threshold) {
  4194. opts.compress = false;
  4195. }
  4196. }
  4197. }
  4198. // Sometimes the websocket has already been closed but the browser didn't
  4199. // have a chance of informing us about it yet, in that case send will
  4200. // throw an error
  4201. try {
  4202. if (websocket_constructor_js_1.usingBrowserWebSocket) {
  4203. // TypeError is thrown when passing the second argument on Safari
  4204. this.ws.send(data);
  4205. }
  4206. else {
  4207. this.ws.send(data, opts);
  4208. }
  4209. }
  4210. catch (e) {
  4211. debug("websocket closed before onclose event");
  4212. }
  4213. if (lastPacket) {
  4214. // fake drain
  4215. // defer to next tick to allow Socket to clear writeBuffer
  4216. (0, websocket_constructor_js_1.nextTick)(() => {
  4217. this.writable = true;
  4218. this.emit("drain");
  4219. }, this.setTimeoutFn);
  4220. }
  4221. });
  4222. }
  4223. }
  4224. /**
  4225. * Closes socket.
  4226. *
  4227. * @api private
  4228. */
  4229. doClose() {
  4230. if (typeof this.ws !== "undefined") {
  4231. this.ws.close();
  4232. this.ws = null;
  4233. }
  4234. }
  4235. /**
  4236. * Generates uri for connection.
  4237. *
  4238. * @api private
  4239. */
  4240. uri() {
  4241. let query = this.query || {};
  4242. const schema = this.opts.secure ? "wss" : "ws";
  4243. let port = "";
  4244. // avoid port if default for schema
  4245. if (this.opts.port &&
  4246. (("wss" === schema && Number(this.opts.port) !== 443) ||
  4247. ("ws" === schema && Number(this.opts.port) !== 80))) {
  4248. port = ":" + this.opts.port;
  4249. }
  4250. // append timestamp to URI
  4251. if (this.opts.timestampRequests) {
  4252. query[this.opts.timestampParam] = (0, yeast_1.default)();
  4253. }
  4254. // communicate binary support capabilities
  4255. if (!this.supportsBinary) {
  4256. query.b64 = 1;
  4257. }
  4258. const encodedQuery = parseqs_1.default.encode(query);
  4259. const ipv6 = this.opts.hostname.indexOf(":") !== -1;
  4260. return (schema +
  4261. "://" +
  4262. (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) +
  4263. port +
  4264. this.opts.path +
  4265. (encodedQuery.length ? "?" + encodedQuery : ""));
  4266. }
  4267. /**
  4268. * Feature detection for WebSocket.
  4269. *
  4270. * @return {Boolean} whether this transport is available.
  4271. * @api public
  4272. */
  4273. check() {
  4274. return (!!websocket_constructor_js_1.WebSocket &&
  4275. !("__initialize" in websocket_constructor_js_1.WebSocket && this.name === WS.prototype.name));
  4276. }
  4277. }
  4278. exports.WS = WS;
  4279. /***/ }),
  4280. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js":
  4281. /*!***********************************************************************************************!*\
  4282. !*** ../ot-core/node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js ***!
  4283. \***********************************************************************************************/
  4284. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  4285. "use strict";
  4286. // browser shim for xmlhttprequest module
  4287. var __importDefault = (this && this.__importDefault) || function (mod) {
  4288. return (mod && mod.__esModule) ? mod : { "default": mod };
  4289. };
  4290. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4291. const has_cors_1 = __importDefault(__webpack_require__(/*! has-cors */ "../ot-core/node_modules/has-cors/index.js"));
  4292. const globalThis_js_1 = __importDefault(__webpack_require__(/*! ../globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
  4293. function default_1(opts) {
  4294. const xdomain = opts.xdomain;
  4295. // XMLHttpRequest can be disabled on IE
  4296. try {
  4297. if ("undefined" !== typeof XMLHttpRequest && (!xdomain || has_cors_1.default)) {
  4298. return new XMLHttpRequest();
  4299. }
  4300. }
  4301. catch (e) { }
  4302. if (!xdomain) {
  4303. try {
  4304. return new globalThis_js_1.default[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
  4305. }
  4306. catch (e) { }
  4307. }
  4308. }
  4309. exports["default"] = default_1;
  4310. /***/ }),
  4311. /***/ "../ot-core/node_modules/engine.io-client/build/cjs/util.js":
  4312. /*!******************************************************************!*\
  4313. !*** ../ot-core/node_modules/engine.io-client/build/cjs/util.js ***!
  4314. \******************************************************************/
  4315. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  4316. "use strict";
  4317. var __importDefault = (this && this.__importDefault) || function (mod) {
  4318. return (mod && mod.__esModule) ? mod : { "default": mod };
  4319. };
  4320. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4321. exports.installTimerFunctions = exports.pick = void 0;
  4322. const globalThis_js_1 = __importDefault(__webpack_require__(/*! ./globalThis.js */ "../ot-core/node_modules/engine.io-client/build/cjs/globalThis.browser.js"));
  4323. function pick(obj, ...attr) {
  4324. return attr.reduce((acc, k) => {
  4325. if (obj.hasOwnProperty(k)) {
  4326. acc[k] = obj[k];
  4327. }
  4328. return acc;
  4329. }, {});
  4330. }
  4331. exports.pick = pick;
  4332. // Keep a reference to the real timeout functions so they can be used when overridden
  4333. const NATIVE_SET_TIMEOUT = setTimeout;
  4334. const NATIVE_CLEAR_TIMEOUT = clearTimeout;
  4335. function installTimerFunctions(obj, opts) {
  4336. if (opts.useNativeTimers) {
  4337. obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.default);
  4338. obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.default);
  4339. }
  4340. else {
  4341. obj.setTimeoutFn = setTimeout.bind(globalThis_js_1.default);
  4342. obj.clearTimeoutFn = clearTimeout.bind(globalThis_js_1.default);
  4343. }
  4344. }
  4345. exports.installTimerFunctions = installTimerFunctions;
  4346. /***/ }),
  4347. /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js":
  4348. /*!*********************************************************************!*\
  4349. !*** ../ot-core/node_modules/engine.io-parser/build/cjs/commons.js ***!
  4350. \*********************************************************************/
  4351. /***/ ((__unused_webpack_module, exports) => {
  4352. "use strict";
  4353. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4354. exports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;
  4355. const PACKET_TYPES = Object.create(null); // no Map = no polyfill
  4356. exports.PACKET_TYPES = PACKET_TYPES;
  4357. PACKET_TYPES["open"] = "0";
  4358. PACKET_TYPES["close"] = "1";
  4359. PACKET_TYPES["ping"] = "2";
  4360. PACKET_TYPES["pong"] = "3";
  4361. PACKET_TYPES["message"] = "4";
  4362. PACKET_TYPES["upgrade"] = "5";
  4363. PACKET_TYPES["noop"] = "6";
  4364. const PACKET_TYPES_REVERSE = Object.create(null);
  4365. exports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;
  4366. Object.keys(PACKET_TYPES).forEach(key => {
  4367. PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
  4368. });
  4369. const ERROR_PACKET = { type: "error", data: "parser error" };
  4370. exports.ERROR_PACKET = ERROR_PACKET;
  4371. /***/ }),
  4372. /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js":
  4373. /*!**********************************************************************************!*\
  4374. !*** ../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js ***!
  4375. \**********************************************************************************/
  4376. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4377. "use strict";
  4378. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4379. const commons_js_1 = __webpack_require__(/*! ./commons.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js");
  4380. const base64_arraybuffer_1 = __webpack_require__(/*! @socket.io/base64-arraybuffer */ "../ot-core/node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js");
  4381. const withNativeArrayBuffer = typeof ArrayBuffer === "function";
  4382. const decodePacket = (encodedPacket, binaryType) => {
  4383. if (typeof encodedPacket !== "string") {
  4384. return {
  4385. type: "message",
  4386. data: mapBinary(encodedPacket, binaryType)
  4387. };
  4388. }
  4389. const type = encodedPacket.charAt(0);
  4390. if (type === "b") {
  4391. return {
  4392. type: "message",
  4393. data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
  4394. };
  4395. }
  4396. const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];
  4397. if (!packetType) {
  4398. return commons_js_1.ERROR_PACKET;
  4399. }
  4400. return encodedPacket.length > 1
  4401. ? {
  4402. type: commons_js_1.PACKET_TYPES_REVERSE[type],
  4403. data: encodedPacket.substring(1)
  4404. }
  4405. : {
  4406. type: commons_js_1.PACKET_TYPES_REVERSE[type]
  4407. };
  4408. };
  4409. const decodeBase64Packet = (data, binaryType) => {
  4410. if (withNativeArrayBuffer) {
  4411. const decoded = (0, base64_arraybuffer_1.decode)(data);
  4412. return mapBinary(decoded, binaryType);
  4413. }
  4414. else {
  4415. return { base64: true, data }; // fallback for old browsers
  4416. }
  4417. };
  4418. const mapBinary = (data, binaryType) => {
  4419. switch (binaryType) {
  4420. case "blob":
  4421. return data instanceof ArrayBuffer ? new Blob([data]) : data;
  4422. case "arraybuffer":
  4423. default:
  4424. return data; // assuming the data is already an ArrayBuffer
  4425. }
  4426. };
  4427. exports["default"] = decodePacket;
  4428. /***/ }),
  4429. /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js":
  4430. /*!**********************************************************************************!*\
  4431. !*** ../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js ***!
  4432. \**********************************************************************************/
  4433. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4434. "use strict";
  4435. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4436. const commons_js_1 = __webpack_require__(/*! ./commons.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/commons.js");
  4437. const withNativeBlob = typeof Blob === "function" ||
  4438. (typeof Blob !== "undefined" &&
  4439. Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
  4440. const withNativeArrayBuffer = typeof ArrayBuffer === "function";
  4441. // ArrayBuffer.isView method is not defined in IE10
  4442. const isView = obj => {
  4443. return typeof ArrayBuffer.isView === "function"
  4444. ? ArrayBuffer.isView(obj)
  4445. : obj && obj.buffer instanceof ArrayBuffer;
  4446. };
  4447. const encodePacket = ({ type, data }, supportsBinary, callback) => {
  4448. if (withNativeBlob && data instanceof Blob) {
  4449. if (supportsBinary) {
  4450. return callback(data);
  4451. }
  4452. else {
  4453. return encodeBlobAsBase64(data, callback);
  4454. }
  4455. }
  4456. else if (withNativeArrayBuffer &&
  4457. (data instanceof ArrayBuffer || isView(data))) {
  4458. if (supportsBinary) {
  4459. return callback(data);
  4460. }
  4461. else {
  4462. return encodeBlobAsBase64(new Blob([data]), callback);
  4463. }
  4464. }
  4465. // plain string
  4466. return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
  4467. };
  4468. const encodeBlobAsBase64 = (data, callback) => {
  4469. const fileReader = new FileReader();
  4470. fileReader.onload = function () {
  4471. const content = fileReader.result.split(",")[1];
  4472. callback("b" + content);
  4473. };
  4474. return fileReader.readAsDataURL(data);
  4475. };
  4476. exports["default"] = encodePacket;
  4477. /***/ }),
  4478. /***/ "../ot-core/node_modules/engine.io-parser/build/cjs/index.js":
  4479. /*!*******************************************************************!*\
  4480. !*** ../ot-core/node_modules/engine.io-parser/build/cjs/index.js ***!
  4481. \*******************************************************************/
  4482. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4483. "use strict";
  4484. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4485. exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0;
  4486. const encodePacket_js_1 = __webpack_require__(/*! ./encodePacket.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js");
  4487. exports.encodePacket = encodePacket_js_1.default;
  4488. const decodePacket_js_1 = __webpack_require__(/*! ./decodePacket.js */ "../ot-core/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js");
  4489. exports.decodePacket = decodePacket_js_1.default;
  4490. const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
  4491. const encodePayload = (packets, callback) => {
  4492. // some packets may be added to the array while encoding, so the initial length must be saved
  4493. const length = packets.length;
  4494. const encodedPackets = new Array(length);
  4495. let count = 0;
  4496. packets.forEach((packet, i) => {
  4497. // force base64 encoding for binary packets
  4498. (0, encodePacket_js_1.default)(packet, false, encodedPacket => {
  4499. encodedPackets[i] = encodedPacket;
  4500. if (++count === length) {
  4501. callback(encodedPackets.join(SEPARATOR));
  4502. }
  4503. });
  4504. });
  4505. };
  4506. exports.encodePayload = encodePayload;
  4507. const decodePayload = (encodedPayload, binaryType) => {
  4508. const encodedPackets = encodedPayload.split(SEPARATOR);
  4509. const packets = [];
  4510. for (let i = 0; i < encodedPackets.length; i++) {
  4511. const decodedPacket = (0, decodePacket_js_1.default)(encodedPackets[i], binaryType);
  4512. packets.push(decodedPacket);
  4513. if (decodedPacket.type === "error") {
  4514. break;
  4515. }
  4516. }
  4517. return packets;
  4518. };
  4519. exports.decodePayload = decodePayload;
  4520. exports.protocol = 4;
  4521. /***/ }),
  4522. /***/ "../ot-core/node_modules/socket.io-client/build/cjs/index.js":
  4523. /*!*******************************************************************!*\
  4524. !*** ../ot-core/node_modules/socket.io-client/build/cjs/index.js ***!
  4525. \*******************************************************************/
  4526. /***/ (function(module, exports, __webpack_require__) {
  4527. "use strict";
  4528. var __importDefault = (this && this.__importDefault) || function (mod) {
  4529. return (mod && mod.__esModule) ? mod : { "default": mod };
  4530. };
  4531. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4532. exports["default"] = exports.connect = exports.io = exports.Socket = exports.Manager = exports.protocol = void 0;
  4533. const url_js_1 = __webpack_require__(/*! ./url.js */ "../ot-core/node_modules/socket.io-client/build/cjs/url.js");
  4534. const manager_js_1 = __webpack_require__(/*! ./manager.js */ "../ot-core/node_modules/socket.io-client/build/cjs/manager.js");
  4535. Object.defineProperty(exports, "Manager", ({ enumerable: true, get: function () { return manager_js_1.Manager; } }));
  4536. const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js");
  4537. Object.defineProperty(exports, "Socket", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));
  4538. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  4539. const debug = debug_1.default("socket.io-client"); // debug()
  4540. /**
  4541. * Managers cache.
  4542. */
  4543. const cache = {};
  4544. function lookup(uri, opts) {
  4545. if (typeof uri === "object") {
  4546. opts = uri;
  4547. uri = undefined;
  4548. }
  4549. opts = opts || {};
  4550. const parsed = url_js_1.url(uri, opts.path || "/socket.io");
  4551. const source = parsed.source;
  4552. const id = parsed.id;
  4553. const path = parsed.path;
  4554. const sameNamespace = cache[id] && path in cache[id]["nsps"];
  4555. const newConnection = opts.forceNew ||
  4556. opts["force new connection"] ||
  4557. false === opts.multiplex ||
  4558. sameNamespace;
  4559. let io;
  4560. if (newConnection) {
  4561. debug("ignoring socket cache for %s", source);
  4562. io = new manager_js_1.Manager(source, opts);
  4563. }
  4564. else {
  4565. if (!cache[id]) {
  4566. debug("new io instance for %s", source);
  4567. cache[id] = new manager_js_1.Manager(source, opts);
  4568. }
  4569. io = cache[id];
  4570. }
  4571. if (parsed.query && !opts.query) {
  4572. opts.query = parsed.queryKey;
  4573. }
  4574. return io.socket(parsed.path, opts);
  4575. }
  4576. exports.io = lookup;
  4577. exports.connect = lookup;
  4578. exports["default"] = lookup;
  4579. // so that "lookup" can be used both as a function (e.g. `io(...)`) and as a
  4580. // namespace (e.g. `io.connect(...)`), for backward compatibility
  4581. Object.assign(lookup, {
  4582. Manager: manager_js_1.Manager,
  4583. Socket: socket_js_1.Socket,
  4584. io: lookup,
  4585. connect: lookup,
  4586. });
  4587. /**
  4588. * Protocol version.
  4589. *
  4590. * @public
  4591. */
  4592. 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");
  4593. Object.defineProperty(exports, "protocol", ({ enumerable: true, get: function () { return socket_io_parser_1.protocol; } }));
  4594. module.exports = lookup;
  4595. /***/ }),
  4596. /***/ "../ot-core/node_modules/socket.io-client/build/cjs/manager.js":
  4597. /*!*********************************************************************!*\
  4598. !*** ../ot-core/node_modules/socket.io-client/build/cjs/manager.js ***!
  4599. \*********************************************************************/
  4600. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  4601. "use strict";
  4602. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  4603. if (k2 === undefined) k2 = k;
  4604. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  4605. }) : (function(o, m, k, k2) {
  4606. if (k2 === undefined) k2 = k;
  4607. o[k2] = m[k];
  4608. }));
  4609. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  4610. Object.defineProperty(o, "default", { enumerable: true, value: v });
  4611. }) : function(o, v) {
  4612. o["default"] = v;
  4613. });
  4614. var __importStar = (this && this.__importStar) || function (mod) {
  4615. if (mod && mod.__esModule) return mod;
  4616. var result = {};
  4617. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  4618. __setModuleDefault(result, mod);
  4619. return result;
  4620. };
  4621. var __importDefault = (this && this.__importDefault) || function (mod) {
  4622. return (mod && mod.__esModule) ? mod : { "default": mod };
  4623. };
  4624. Object.defineProperty(exports, "__esModule", ({ value: true }));
  4625. exports.Manager = void 0;
  4626. const engine_io_client_1 = __webpack_require__(/*! engine.io-client */ "../ot-core/node_modules/engine.io-client/build/cjs/index.js");
  4627. const socket_js_1 = __webpack_require__(/*! ./socket.js */ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js");
  4628. const parser = __importStar(__webpack_require__(/*! socket.io-parser */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js"));
  4629. const on_js_1 = __webpack_require__(/*! ./on.js */ "../ot-core/node_modules/socket.io-client/build/cjs/on.js");
  4630. const backo2_1 = __importDefault(__webpack_require__(/*! backo2 */ "../ot-core/node_modules/backo2/index.js"));
  4631. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  4632. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  4633. const debug = debug_1.default("socket.io-client:manager"); // debug()
  4634. class Manager extends component_emitter_1.Emitter {
  4635. constructor(uri, opts) {
  4636. var _a;
  4637. super();
  4638. this.nsps = {};
  4639. this.subs = [];
  4640. if (uri && "object" === typeof uri) {
  4641. opts = uri;
  4642. uri = undefined;
  4643. }
  4644. opts = opts || {};
  4645. opts.path = opts.path || "/socket.io";
  4646. this.opts = opts;
  4647. engine_io_client_1.installTimerFunctions(this, opts);
  4648. this.reconnection(opts.reconnection !== false);
  4649. this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
  4650. this.reconnectionDelay(opts.reconnectionDelay || 1000);
  4651. this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
  4652. this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
  4653. this.backoff = new backo2_1.default({
  4654. min: this.reconnectionDelay(),
  4655. max: this.reconnectionDelayMax(),
  4656. jitter: this.randomizationFactor(),
  4657. });
  4658. this.timeout(null == opts.timeout ? 20000 : opts.timeout);
  4659. this._readyState = "closed";
  4660. this.uri = uri;
  4661. const _parser = opts.parser || parser;
  4662. this.encoder = new _parser.Encoder();
  4663. this.decoder = new _parser.Decoder();
  4664. this._autoConnect = opts.autoConnect !== false;
  4665. if (this._autoConnect)
  4666. this.open();
  4667. }
  4668. reconnection(v) {
  4669. if (!arguments.length)
  4670. return this._reconnection;
  4671. this._reconnection = !!v;
  4672. return this;
  4673. }
  4674. reconnectionAttempts(v) {
  4675. if (v === undefined)
  4676. return this._reconnectionAttempts;
  4677. this._reconnectionAttempts = v;
  4678. return this;
  4679. }
  4680. reconnectionDelay(v) {
  4681. var _a;
  4682. if (v === undefined)
  4683. return this._reconnectionDelay;
  4684. this._reconnectionDelay = v;
  4685. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
  4686. return this;
  4687. }
  4688. randomizationFactor(v) {
  4689. var _a;
  4690. if (v === undefined)
  4691. return this._randomizationFactor;
  4692. this._randomizationFactor = v;
  4693. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
  4694. return this;
  4695. }
  4696. reconnectionDelayMax(v) {
  4697. var _a;
  4698. if (v === undefined)
  4699. return this._reconnectionDelayMax;
  4700. this._reconnectionDelayMax = v;
  4701. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
  4702. return this;
  4703. }
  4704. timeout(v) {
  4705. if (!arguments.length)
  4706. return this._timeout;
  4707. this._timeout = v;
  4708. return this;
  4709. }
  4710. /**
  4711. * Starts trying to reconnect if reconnection is enabled and we have not
  4712. * started reconnecting yet
  4713. *
  4714. * @private
  4715. */
  4716. maybeReconnectOnOpen() {
  4717. // Only try to reconnect if it's the first time we're connecting
  4718. if (!this._reconnecting &&
  4719. this._reconnection &&
  4720. this.backoff.attempts === 0) {
  4721. // keeps reconnection from firing twice for the same reconnection loop
  4722. this.reconnect();
  4723. }
  4724. }
  4725. /**
  4726. * Sets the current transport `socket`.
  4727. *
  4728. * @param {Function} fn - optional, callback
  4729. * @return self
  4730. * @public
  4731. */
  4732. open(fn) {
  4733. debug("readyState %s", this._readyState);
  4734. if (~this._readyState.indexOf("open"))
  4735. return this;
  4736. debug("opening %s", this.uri);
  4737. this.engine = new engine_io_client_1.Socket(this.uri, this.opts);
  4738. const socket = this.engine;
  4739. const self = this;
  4740. this._readyState = "opening";
  4741. this.skipReconnect = false;
  4742. // emit `open`
  4743. const openSubDestroy = on_js_1.on(socket, "open", function () {
  4744. self.onopen();
  4745. fn && fn();
  4746. });
  4747. // emit `error`
  4748. const errorSub = on_js_1.on(socket, "error", (err) => {
  4749. debug("error");
  4750. self.cleanup();
  4751. self._readyState = "closed";
  4752. this.emitReserved("error", err);
  4753. if (fn) {
  4754. fn(err);
  4755. }
  4756. else {
  4757. // Only do this if there is no fn to handle the error
  4758. self.maybeReconnectOnOpen();
  4759. }
  4760. });
  4761. if (false !== this._timeout) {
  4762. const timeout = this._timeout;
  4763. debug("connect attempt will timeout after %d", timeout);
  4764. if (timeout === 0) {
  4765. openSubDestroy(); // prevents a race condition with the 'open' event
  4766. }
  4767. // set timer
  4768. const timer = this.setTimeoutFn(() => {
  4769. debug("connect attempt timed out after %d", timeout);
  4770. openSubDestroy();
  4771. socket.close();
  4772. // @ts-ignore
  4773. socket.emit("error", new Error("timeout"));
  4774. }, timeout);
  4775. if (this.opts.autoUnref) {
  4776. timer.unref();
  4777. }
  4778. this.subs.push(function subDestroy() {
  4779. clearTimeout(timer);
  4780. });
  4781. }
  4782. this.subs.push(openSubDestroy);
  4783. this.subs.push(errorSub);
  4784. return this;
  4785. }
  4786. /**
  4787. * Alias for open()
  4788. *
  4789. * @return self
  4790. * @public
  4791. */
  4792. connect(fn) {
  4793. return this.open(fn);
  4794. }
  4795. /**
  4796. * Called upon transport open.
  4797. *
  4798. * @private
  4799. */
  4800. onopen() {
  4801. debug("open");
  4802. // clear old subs
  4803. this.cleanup();
  4804. // mark as open
  4805. this._readyState = "open";
  4806. this.emitReserved("open");
  4807. // add new subs
  4808. const socket = this.engine;
  4809. 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)));
  4810. }
  4811. /**
  4812. * Called upon a ping.
  4813. *
  4814. * @private
  4815. */
  4816. onping() {
  4817. this.emitReserved("ping");
  4818. }
  4819. /**
  4820. * Called with data.
  4821. *
  4822. * @private
  4823. */
  4824. ondata(data) {
  4825. this.decoder.add(data);
  4826. }
  4827. /**
  4828. * Called when parser fully decodes a packet.
  4829. *
  4830. * @private
  4831. */
  4832. ondecoded(packet) {
  4833. this.emitReserved("packet", packet);
  4834. }
  4835. /**
  4836. * Called upon socket error.
  4837. *
  4838. * @private
  4839. */
  4840. onerror(err) {
  4841. debug("error", err);
  4842. this.emitReserved("error", err);
  4843. }
  4844. /**
  4845. * Creates a new socket for the given `nsp`.
  4846. *
  4847. * @return {Socket}
  4848. * @public
  4849. */
  4850. socket(nsp, opts) {
  4851. let socket = this.nsps[nsp];
  4852. if (!socket) {
  4853. socket = new socket_js_1.Socket(this, nsp, opts);
  4854. this.nsps[nsp] = socket;
  4855. }
  4856. return socket;
  4857. }
  4858. /**
  4859. * Called upon a socket close.
  4860. *
  4861. * @param socket
  4862. * @private
  4863. */
  4864. _destroy(socket) {
  4865. const nsps = Object.keys(this.nsps);
  4866. for (const nsp of nsps) {
  4867. const socket = this.nsps[nsp];
  4868. if (socket.active) {
  4869. debug("socket %s is still active, skipping close", nsp);
  4870. return;
  4871. }
  4872. }
  4873. this._close();
  4874. }
  4875. /**
  4876. * Writes a packet.
  4877. *
  4878. * @param packet
  4879. * @private
  4880. */
  4881. _packet(packet) {
  4882. debug("writing packet %j", packet);
  4883. const encodedPackets = this.encoder.encode(packet);
  4884. for (let i = 0; i < encodedPackets.length; i++) {
  4885. this.engine.write(encodedPackets[i], packet.options);
  4886. }
  4887. }
  4888. /**
  4889. * Clean up transport subscriptions and packet buffer.
  4890. *
  4891. * @private
  4892. */
  4893. cleanup() {
  4894. debug("cleanup");
  4895. this.subs.forEach((subDestroy) => subDestroy());
  4896. this.subs.length = 0;
  4897. this.decoder.destroy();
  4898. }
  4899. /**
  4900. * Close the current socket.
  4901. *
  4902. * @private
  4903. */
  4904. _close() {
  4905. debug("disconnect");
  4906. this.skipReconnect = true;
  4907. this._reconnecting = false;
  4908. if ("opening" === this._readyState) {
  4909. // `onclose` will not fire because
  4910. // an open event never happened
  4911. this.cleanup();
  4912. }
  4913. this.backoff.reset();
  4914. this._readyState = "closed";
  4915. if (this.engine)
  4916. this.engine.close();
  4917. }
  4918. /**
  4919. * Alias for close()
  4920. *
  4921. * @private
  4922. */
  4923. disconnect() {
  4924. return this._close();
  4925. }
  4926. /**
  4927. * Called upon engine close.
  4928. *
  4929. * @private
  4930. */
  4931. onclose(reason) {
  4932. debug("onclose");
  4933. this.cleanup();
  4934. this.backoff.reset();
  4935. this._readyState = "closed";
  4936. this.emitReserved("close", reason);
  4937. if (this._reconnection && !this.skipReconnect) {
  4938. this.reconnect();
  4939. }
  4940. }
  4941. /**
  4942. * Attempt a reconnection.
  4943. *
  4944. * @private
  4945. */
  4946. reconnect() {
  4947. if (this._reconnecting || this.skipReconnect)
  4948. return this;
  4949. const self = this;
  4950. if (this.backoff.attempts >= this._reconnectionAttempts) {
  4951. debug("reconnect failed");
  4952. this.backoff.reset();
  4953. this.emitReserved("reconnect_failed");
  4954. this._reconnecting = false;
  4955. }
  4956. else {
  4957. const delay = this.backoff.duration();
  4958. debug("will wait %dms before reconnect attempt", delay);
  4959. this._reconnecting = true;
  4960. const timer = this.setTimeoutFn(() => {
  4961. if (self.skipReconnect)
  4962. return;
  4963. debug("attempting reconnect");
  4964. this.emitReserved("reconnect_attempt", self.backoff.attempts);
  4965. // check again for the case socket closed in above events
  4966. if (self.skipReconnect)
  4967. return;
  4968. self.open((err) => {
  4969. if (err) {
  4970. debug("reconnect attempt error");
  4971. self._reconnecting = false;
  4972. self.reconnect();
  4973. this.emitReserved("reconnect_error", err);
  4974. }
  4975. else {
  4976. debug("reconnect success");
  4977. self.onreconnect();
  4978. }
  4979. });
  4980. }, delay);
  4981. if (this.opts.autoUnref) {
  4982. timer.unref();
  4983. }
  4984. this.subs.push(function subDestroy() {
  4985. clearTimeout(timer);
  4986. });
  4987. }
  4988. }
  4989. /**
  4990. * Called upon successful reconnect.
  4991. *
  4992. * @private
  4993. */
  4994. onreconnect() {
  4995. const attempt = this.backoff.attempts;
  4996. this._reconnecting = false;
  4997. this.backoff.reset();
  4998. this.emitReserved("reconnect", attempt);
  4999. }
  5000. }
  5001. exports.Manager = Manager;
  5002. /***/ }),
  5003. /***/ "../ot-core/node_modules/socket.io-client/build/cjs/on.js":
  5004. /*!****************************************************************!*\
  5005. !*** ../ot-core/node_modules/socket.io-client/build/cjs/on.js ***!
  5006. \****************************************************************/
  5007. /***/ ((__unused_webpack_module, exports) => {
  5008. "use strict";
  5009. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5010. exports.on = void 0;
  5011. function on(obj, ev, fn) {
  5012. obj.on(ev, fn);
  5013. return function subDestroy() {
  5014. obj.off(ev, fn);
  5015. };
  5016. }
  5017. exports.on = on;
  5018. /***/ }),
  5019. /***/ "../ot-core/node_modules/socket.io-client/build/cjs/socket.js":
  5020. /*!********************************************************************!*\
  5021. !*** ../ot-core/node_modules/socket.io-client/build/cjs/socket.js ***!
  5022. \********************************************************************/
  5023. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  5024. "use strict";
  5025. var __importDefault = (this && this.__importDefault) || function (mod) {
  5026. return (mod && mod.__esModule) ? mod : { "default": mod };
  5027. };
  5028. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5029. exports.Socket = void 0;
  5030. 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");
  5031. const on_js_1 = __webpack_require__(/*! ./on.js */ "../ot-core/node_modules/socket.io-client/build/cjs/on.js");
  5032. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  5033. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  5034. const debug = debug_1.default("socket.io-client:socket"); // debug()
  5035. /**
  5036. * Internal events.
  5037. * These events can't be emitted by the user.
  5038. */
  5039. const RESERVED_EVENTS = Object.freeze({
  5040. connect: 1,
  5041. connect_error: 1,
  5042. disconnect: 1,
  5043. disconnecting: 1,
  5044. // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
  5045. newListener: 1,
  5046. removeListener: 1,
  5047. });
  5048. class Socket extends component_emitter_1.Emitter {
  5049. /**
  5050. * `Socket` constructor.
  5051. *
  5052. * @public
  5053. */
  5054. constructor(io, nsp, opts) {
  5055. super();
  5056. this.connected = false;
  5057. this.disconnected = true;
  5058. this.receiveBuffer = [];
  5059. this.sendBuffer = [];
  5060. this.ids = 0;
  5061. this.acks = {};
  5062. this.flags = {};
  5063. this.io = io;
  5064. this.nsp = nsp;
  5065. if (opts && opts.auth) {
  5066. this.auth = opts.auth;
  5067. }
  5068. if (this.io._autoConnect)
  5069. this.open();
  5070. }
  5071. /**
  5072. * Subscribe to open, close and packet events
  5073. *
  5074. * @private
  5075. */
  5076. subEvents() {
  5077. if (this.subs)
  5078. return;
  5079. const io = this.io;
  5080. this.subs = [
  5081. on_js_1.on(io, "open", this.onopen.bind(this)),
  5082. on_js_1.on(io, "packet", this.onpacket.bind(this)),
  5083. on_js_1.on(io, "error", this.onerror.bind(this)),
  5084. on_js_1.on(io, "close", this.onclose.bind(this)),
  5085. ];
  5086. }
  5087. /**
  5088. * Whether the Socket will try to reconnect when its Manager connects or reconnects
  5089. */
  5090. get active() {
  5091. return !!this.subs;
  5092. }
  5093. /**
  5094. * "Opens" the socket.
  5095. *
  5096. * @public
  5097. */
  5098. connect() {
  5099. if (this.connected)
  5100. return this;
  5101. this.subEvents();
  5102. if (!this.io["_reconnecting"])
  5103. this.io.open(); // ensure open
  5104. if ("open" === this.io._readyState)
  5105. this.onopen();
  5106. return this;
  5107. }
  5108. /**
  5109. * Alias for connect()
  5110. */
  5111. open() {
  5112. return this.connect();
  5113. }
  5114. /**
  5115. * Sends a `message` event.
  5116. *
  5117. * @return self
  5118. * @public
  5119. */
  5120. send(...args) {
  5121. args.unshift("message");
  5122. this.emit.apply(this, args);
  5123. return this;
  5124. }
  5125. /**
  5126. * Override `emit`.
  5127. * If the event is in `events`, it's emitted normally.
  5128. *
  5129. * @return self
  5130. * @public
  5131. */
  5132. emit(ev, ...args) {
  5133. if (RESERVED_EVENTS.hasOwnProperty(ev)) {
  5134. throw new Error('"' + ev + '" is a reserved event name');
  5135. }
  5136. args.unshift(ev);
  5137. const packet = {
  5138. type: socket_io_parser_1.PacketType.EVENT,
  5139. data: args,
  5140. };
  5141. packet.options = {};
  5142. packet.options.compress = this.flags.compress !== false;
  5143. // event ack callback
  5144. if ("function" === typeof args[args.length - 1]) {
  5145. debug("emitting packet with ack id %d", this.ids);
  5146. this.acks[this.ids] = args.pop();
  5147. packet.id = this.ids++;
  5148. }
  5149. const isTransportWritable = this.io.engine &&
  5150. this.io.engine.transport &&
  5151. this.io.engine.transport.writable;
  5152. const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected);
  5153. if (discardPacket) {
  5154. debug("discard packet as the transport is not currently writable");
  5155. }
  5156. else if (this.connected) {
  5157. this.packet(packet);
  5158. }
  5159. else {
  5160. this.sendBuffer.push(packet);
  5161. }
  5162. this.flags = {};
  5163. return this;
  5164. }
  5165. /**
  5166. * Sends a packet.
  5167. *
  5168. * @param packet
  5169. * @private
  5170. */
  5171. packet(packet) {
  5172. packet.nsp = this.nsp;
  5173. this.io._packet(packet);
  5174. }
  5175. /**
  5176. * Called upon engine `open`.
  5177. *
  5178. * @private
  5179. */
  5180. onopen() {
  5181. debug("transport is open - connecting");
  5182. if (typeof this.auth == "function") {
  5183. this.auth((data) => {
  5184. this.packet({ type: socket_io_parser_1.PacketType.CONNECT, data });
  5185. });
  5186. }
  5187. else {
  5188. this.packet({ type: socket_io_parser_1.PacketType.CONNECT, data: this.auth });
  5189. }
  5190. }
  5191. /**
  5192. * Called upon engine or manager `error`.
  5193. *
  5194. * @param err
  5195. * @private
  5196. */
  5197. onerror(err) {
  5198. if (!this.connected) {
  5199. this.emitReserved("connect_error", err);
  5200. }
  5201. }
  5202. /**
  5203. * Called upon engine `close`.
  5204. *
  5205. * @param reason
  5206. * @private
  5207. */
  5208. onclose(reason) {
  5209. debug("close (%s)", reason);
  5210. this.connected = false;
  5211. this.disconnected = true;
  5212. delete this.id;
  5213. this.emitReserved("disconnect", reason);
  5214. }
  5215. /**
  5216. * Called with socket packet.
  5217. *
  5218. * @param packet
  5219. * @private
  5220. */
  5221. onpacket(packet) {
  5222. const sameNamespace = packet.nsp === this.nsp;
  5223. if (!sameNamespace)
  5224. return;
  5225. switch (packet.type) {
  5226. case socket_io_parser_1.PacketType.CONNECT:
  5227. if (packet.data && packet.data.sid) {
  5228. const id = packet.data.sid;
  5229. this.onconnect(id);
  5230. }
  5231. else {
  5232. 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/)"));
  5233. }
  5234. break;
  5235. case socket_io_parser_1.PacketType.EVENT:
  5236. this.onevent(packet);
  5237. break;
  5238. case socket_io_parser_1.PacketType.BINARY_EVENT:
  5239. this.onevent(packet);
  5240. break;
  5241. case socket_io_parser_1.PacketType.ACK:
  5242. this.onack(packet);
  5243. break;
  5244. case socket_io_parser_1.PacketType.BINARY_ACK:
  5245. this.onack(packet);
  5246. break;
  5247. case socket_io_parser_1.PacketType.DISCONNECT:
  5248. this.ondisconnect();
  5249. break;
  5250. case socket_io_parser_1.PacketType.CONNECT_ERROR:
  5251. const err = new Error(packet.data.message);
  5252. // @ts-ignore
  5253. err.data = packet.data.data;
  5254. this.emitReserved("connect_error", err);
  5255. break;
  5256. }
  5257. }
  5258. /**
  5259. * Called upon a server event.
  5260. *
  5261. * @param packet
  5262. * @private
  5263. */
  5264. onevent(packet) {
  5265. const args = packet.data || [];
  5266. debug("emitting event %j", args);
  5267. if (null != packet.id) {
  5268. debug("attaching ack callback to event");
  5269. args.push(this.ack(packet.id));
  5270. }
  5271. if (this.connected) {
  5272. this.emitEvent(args);
  5273. }
  5274. else {
  5275. this.receiveBuffer.push(Object.freeze(args));
  5276. }
  5277. }
  5278. emitEvent(args) {
  5279. if (this._anyListeners && this._anyListeners.length) {
  5280. const listeners = this._anyListeners.slice();
  5281. for (const listener of listeners) {
  5282. listener.apply(this, args);
  5283. }
  5284. }
  5285. super.emit.apply(this, args);
  5286. }
  5287. /**
  5288. * Produces an ack callback to emit with an event.
  5289. *
  5290. * @private
  5291. */
  5292. ack(id) {
  5293. const self = this;
  5294. let sent = false;
  5295. return function (...args) {
  5296. // prevent double callbacks
  5297. if (sent)
  5298. return;
  5299. sent = true;
  5300. debug("sending ack %j", args);
  5301. self.packet({
  5302. type: socket_io_parser_1.PacketType.ACK,
  5303. id: id,
  5304. data: args,
  5305. });
  5306. };
  5307. }
  5308. /**
  5309. * Called upon a server acknowlegement.
  5310. *
  5311. * @param packet
  5312. * @private
  5313. */
  5314. onack(packet) {
  5315. const ack = this.acks[packet.id];
  5316. if ("function" === typeof ack) {
  5317. debug("calling ack %s with %j", packet.id, packet.data);
  5318. ack.apply(this, packet.data);
  5319. delete this.acks[packet.id];
  5320. }
  5321. else {
  5322. debug("bad ack %s", packet.id);
  5323. }
  5324. }
  5325. /**
  5326. * Called upon server connect.
  5327. *
  5328. * @private
  5329. */
  5330. onconnect(id) {
  5331. debug("socket connected with id %s", id);
  5332. this.id = id;
  5333. this.connected = true;
  5334. this.disconnected = false;
  5335. this.emitBuffered();
  5336. this.emitReserved("connect");
  5337. }
  5338. /**
  5339. * Emit buffered events (received and emitted).
  5340. *
  5341. * @private
  5342. */
  5343. emitBuffered() {
  5344. this.receiveBuffer.forEach((args) => this.emitEvent(args));
  5345. this.receiveBuffer = [];
  5346. this.sendBuffer.forEach((packet) => this.packet(packet));
  5347. this.sendBuffer = [];
  5348. }
  5349. /**
  5350. * Called upon server disconnect.
  5351. *
  5352. * @private
  5353. */
  5354. ondisconnect() {
  5355. debug("server disconnect (%s)", this.nsp);
  5356. this.destroy();
  5357. this.onclose("io server disconnect");
  5358. }
  5359. /**
  5360. * Called upon forced client/server side disconnections,
  5361. * this method ensures the manager stops tracking us and
  5362. * that reconnections don't get triggered for this.
  5363. *
  5364. * @private
  5365. */
  5366. destroy() {
  5367. if (this.subs) {
  5368. // clean subscriptions to avoid reconnections
  5369. this.subs.forEach((subDestroy) => subDestroy());
  5370. this.subs = undefined;
  5371. }
  5372. this.io["_destroy"](this);
  5373. }
  5374. /**
  5375. * Disconnects the socket manually.
  5376. *
  5377. * @return self
  5378. * @public
  5379. */
  5380. disconnect() {
  5381. if (this.connected) {
  5382. debug("performing disconnect (%s)", this.nsp);
  5383. this.packet({ type: socket_io_parser_1.PacketType.DISCONNECT });
  5384. }
  5385. // remove socket from pool
  5386. this.destroy();
  5387. if (this.connected) {
  5388. // fire events
  5389. this.onclose("io client disconnect");
  5390. }
  5391. return this;
  5392. }
  5393. /**
  5394. * Alias for disconnect()
  5395. *
  5396. * @return self
  5397. * @public
  5398. */
  5399. close() {
  5400. return this.disconnect();
  5401. }
  5402. /**
  5403. * Sets the compress flag.
  5404. *
  5405. * @param compress - if `true`, compresses the sending data
  5406. * @return self
  5407. * @public
  5408. */
  5409. compress(compress) {
  5410. this.flags.compress = compress;
  5411. return this;
  5412. }
  5413. /**
  5414. * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
  5415. * ready to send messages.
  5416. *
  5417. * @returns self
  5418. * @public
  5419. */
  5420. get volatile() {
  5421. this.flags.volatile = true;
  5422. return this;
  5423. }
  5424. /**
  5425. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  5426. * callback.
  5427. *
  5428. * @param listener
  5429. * @public
  5430. */
  5431. onAny(listener) {
  5432. this._anyListeners = this._anyListeners || [];
  5433. this._anyListeners.push(listener);
  5434. return this;
  5435. }
  5436. /**
  5437. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  5438. * callback. The listener is added to the beginning of the listeners array.
  5439. *
  5440. * @param listener
  5441. * @public
  5442. */
  5443. prependAny(listener) {
  5444. this._anyListeners = this._anyListeners || [];
  5445. this._anyListeners.unshift(listener);
  5446. return this;
  5447. }
  5448. /**
  5449. * Removes the listener that will be fired when any event is emitted.
  5450. *
  5451. * @param listener
  5452. * @public
  5453. */
  5454. offAny(listener) {
  5455. if (!this._anyListeners) {
  5456. return this;
  5457. }
  5458. if (listener) {
  5459. const listeners = this._anyListeners;
  5460. for (let i = 0; i < listeners.length; i++) {
  5461. if (listener === listeners[i]) {
  5462. listeners.splice(i, 1);
  5463. return this;
  5464. }
  5465. }
  5466. }
  5467. else {
  5468. this._anyListeners = [];
  5469. }
  5470. return this;
  5471. }
  5472. /**
  5473. * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
  5474. * e.g. to remove listeners.
  5475. *
  5476. * @public
  5477. */
  5478. listenersAny() {
  5479. return this._anyListeners || [];
  5480. }
  5481. }
  5482. exports.Socket = Socket;
  5483. /***/ }),
  5484. /***/ "../ot-core/node_modules/socket.io-client/build/cjs/url.js":
  5485. /*!*****************************************************************!*\
  5486. !*** ../ot-core/node_modules/socket.io-client/build/cjs/url.js ***!
  5487. \*****************************************************************/
  5488. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  5489. "use strict";
  5490. var __importDefault = (this && this.__importDefault) || function (mod) {
  5491. return (mod && mod.__esModule) ? mod : { "default": mod };
  5492. };
  5493. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5494. exports.url = void 0;
  5495. const parseuri_1 = __importDefault(__webpack_require__(/*! parseuri */ "../ot-core/node_modules/parseuri/index.js"));
  5496. const debug_1 = __importDefault(__webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js")); // debug()
  5497. const debug = debug_1.default("socket.io-client:url"); // debug()
  5498. /**
  5499. * URL parser.
  5500. *
  5501. * @param uri - url
  5502. * @param path - the request path of the connection
  5503. * @param loc - An object meant to mimic window.location.
  5504. * Defaults to window.location.
  5505. * @public
  5506. */
  5507. function url(uri, path = "", loc) {
  5508. let obj = uri;
  5509. // default to window.location
  5510. loc = loc || (typeof location !== "undefined" && location);
  5511. if (null == uri)
  5512. uri = loc.protocol + "//" + loc.host;
  5513. // relative path support
  5514. if (typeof uri === "string") {
  5515. if ("/" === uri.charAt(0)) {
  5516. if ("/" === uri.charAt(1)) {
  5517. uri = loc.protocol + uri;
  5518. }
  5519. else {
  5520. uri = loc.host + uri;
  5521. }
  5522. }
  5523. if (!/^(https?|wss?):\/\//.test(uri)) {
  5524. debug("protocol-less url %s", uri);
  5525. if ("undefined" !== typeof loc) {
  5526. uri = loc.protocol + "//" + uri;
  5527. }
  5528. else {
  5529. uri = "https://" + uri;
  5530. }
  5531. }
  5532. // parse
  5533. debug("parse %s", uri);
  5534. obj = parseuri_1.default(uri);
  5535. }
  5536. // make sure we treat `localhost:80` and `localhost` equally
  5537. if (!obj.port) {
  5538. if (/^(http|ws)$/.test(obj.protocol)) {
  5539. obj.port = "80";
  5540. }
  5541. else if (/^(http|ws)s$/.test(obj.protocol)) {
  5542. obj.port = "443";
  5543. }
  5544. }
  5545. obj.path = obj.path || "/";
  5546. const ipv6 = obj.host.indexOf(":") !== -1;
  5547. const host = ipv6 ? "[" + obj.host + "]" : obj.host;
  5548. // define unique id
  5549. obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
  5550. // define href
  5551. obj.href =
  5552. obj.protocol +
  5553. "://" +
  5554. host +
  5555. (loc && loc.port === obj.port ? "" : ":" + obj.port);
  5556. return obj;
  5557. }
  5558. exports.url = url;
  5559. /***/ }),
  5560. /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js":
  5561. /*!**************************************************************************************************!*\
  5562. !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js ***!
  5563. \**************************************************************************************************/
  5564. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5565. "use strict";
  5566. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5567. exports.reconstructPacket = exports.deconstructPacket = void 0;
  5568. 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");
  5569. /**
  5570. * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
  5571. *
  5572. * @param {Object} packet - socket.io event packet
  5573. * @return {Object} with deconstructed packet and list of buffers
  5574. * @public
  5575. */
  5576. function deconstructPacket(packet) {
  5577. const buffers = [];
  5578. const packetData = packet.data;
  5579. const pack = packet;
  5580. pack.data = _deconstructPacket(packetData, buffers);
  5581. pack.attachments = buffers.length; // number of binary 'attachments'
  5582. return { packet: pack, buffers: buffers };
  5583. }
  5584. exports.deconstructPacket = deconstructPacket;
  5585. function _deconstructPacket(data, buffers) {
  5586. if (!data)
  5587. return data;
  5588. if (is_binary_js_1.isBinary(data)) {
  5589. const placeholder = { _placeholder: true, num: buffers.length };
  5590. buffers.push(data);
  5591. return placeholder;
  5592. }
  5593. else if (Array.isArray(data)) {
  5594. const newData = new Array(data.length);
  5595. for (let i = 0; i < data.length; i++) {
  5596. newData[i] = _deconstructPacket(data[i], buffers);
  5597. }
  5598. return newData;
  5599. }
  5600. else if (typeof data === "object" && !(data instanceof Date)) {
  5601. const newData = {};
  5602. for (const key in data) {
  5603. if (Object.prototype.hasOwnProperty.call(data, key)) {
  5604. newData[key] = _deconstructPacket(data[key], buffers);
  5605. }
  5606. }
  5607. return newData;
  5608. }
  5609. return data;
  5610. }
  5611. /**
  5612. * Reconstructs a binary packet from its placeholder packet and buffers
  5613. *
  5614. * @param {Object} packet - event packet with placeholders
  5615. * @param {Array} buffers - binary buffers to put in placeholder positions
  5616. * @return {Object} reconstructed packet
  5617. * @public
  5618. */
  5619. function reconstructPacket(packet, buffers) {
  5620. packet.data = _reconstructPacket(packet.data, buffers);
  5621. packet.attachments = undefined; // no longer useful
  5622. return packet;
  5623. }
  5624. exports.reconstructPacket = reconstructPacket;
  5625. function _reconstructPacket(data, buffers) {
  5626. if (!data)
  5627. return data;
  5628. if (data && data._placeholder) {
  5629. return buffers[data.num]; // appropriate buffer (should be natural order anyway)
  5630. }
  5631. else if (Array.isArray(data)) {
  5632. for (let i = 0; i < data.length; i++) {
  5633. data[i] = _reconstructPacket(data[i], buffers);
  5634. }
  5635. }
  5636. else if (typeof data === "object") {
  5637. for (const key in data) {
  5638. if (Object.prototype.hasOwnProperty.call(data, key)) {
  5639. data[key] = _reconstructPacket(data[key], buffers);
  5640. }
  5641. }
  5642. }
  5643. return data;
  5644. }
  5645. /***/ }),
  5646. /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js":
  5647. /*!*************************************************************************************************!*\
  5648. !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/index.js ***!
  5649. \*************************************************************************************************/
  5650. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5651. "use strict";
  5652. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5653. exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
  5654. const component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ "../ot-core/node_modules/@socket.io/component-emitter/index.js");
  5655. const binary_js_1 = __webpack_require__(/*! ./binary.js */ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/binary.js");
  5656. 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");
  5657. const debug_1 = __webpack_require__(/*! debug */ "../ot-core/node_modules/debug/src/browser.js"); // debug()
  5658. const debug = debug_1.default("socket.io-parser"); // debug()
  5659. /**
  5660. * Protocol version.
  5661. *
  5662. * @public
  5663. */
  5664. exports.protocol = 5;
  5665. var PacketType;
  5666. (function (PacketType) {
  5667. PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
  5668. PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
  5669. PacketType[PacketType["EVENT"] = 2] = "EVENT";
  5670. PacketType[PacketType["ACK"] = 3] = "ACK";
  5671. PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
  5672. PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
  5673. PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
  5674. })(PacketType = exports.PacketType || (exports.PacketType = {}));
  5675. /**
  5676. * A socket.io Encoder instance
  5677. */
  5678. class Encoder {
  5679. /**
  5680. * Encode a packet as a single string if non-binary, or as a
  5681. * buffer sequence, depending on packet type.
  5682. *
  5683. * @param {Object} obj - packet object
  5684. */
  5685. encode(obj) {
  5686. debug("encoding packet %j", obj);
  5687. if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
  5688. if (is_binary_js_1.hasBinary(obj)) {
  5689. obj.type =
  5690. obj.type === PacketType.EVENT
  5691. ? PacketType.BINARY_EVENT
  5692. : PacketType.BINARY_ACK;
  5693. return this.encodeAsBinary(obj);
  5694. }
  5695. }
  5696. return [this.encodeAsString(obj)];
  5697. }
  5698. /**
  5699. * Encode packet as string.
  5700. */
  5701. encodeAsString(obj) {
  5702. // first is type
  5703. let str = "" + obj.type;
  5704. // attachments if we have them
  5705. if (obj.type === PacketType.BINARY_EVENT ||
  5706. obj.type === PacketType.BINARY_ACK) {
  5707. str += obj.attachments + "-";
  5708. }
  5709. // if we have a namespace other than `/`
  5710. // we append it followed by a comma `,`
  5711. if (obj.nsp && "/" !== obj.nsp) {
  5712. str += obj.nsp + ",";
  5713. }
  5714. // immediately followed by the id
  5715. if (null != obj.id) {
  5716. str += obj.id;
  5717. }
  5718. // json data
  5719. if (null != obj.data) {
  5720. str += JSON.stringify(obj.data);
  5721. }
  5722. debug("encoded %j as %s", obj, str);
  5723. return str;
  5724. }
  5725. /**
  5726. * Encode packet as 'buffer sequence' by removing blobs, and
  5727. * deconstructing packet into object with placeholders and
  5728. * a list of buffers.
  5729. */
  5730. encodeAsBinary(obj) {
  5731. const deconstruction = binary_js_1.deconstructPacket(obj);
  5732. const pack = this.encodeAsString(deconstruction.packet);
  5733. const buffers = deconstruction.buffers;
  5734. buffers.unshift(pack); // add packet info to beginning of data list
  5735. return buffers; // write all the buffers
  5736. }
  5737. }
  5738. exports.Encoder = Encoder;
  5739. /**
  5740. * A socket.io Decoder instance
  5741. *
  5742. * @return {Object} decoder
  5743. */
  5744. class Decoder extends component_emitter_1.Emitter {
  5745. constructor() {
  5746. super();
  5747. }
  5748. /**
  5749. * Decodes an encoded packet string into packet JSON.
  5750. *
  5751. * @param {String} obj - encoded packet
  5752. */
  5753. add(obj) {
  5754. let packet;
  5755. if (typeof obj === "string") {
  5756. packet = this.decodeString(obj);
  5757. if (packet.type === PacketType.BINARY_EVENT ||
  5758. packet.type === PacketType.BINARY_ACK) {
  5759. // binary packet's json
  5760. this.reconstructor = new BinaryReconstructor(packet);
  5761. // no attachments, labeled binary but no binary data to follow
  5762. if (packet.attachments === 0) {
  5763. super.emitReserved("decoded", packet);
  5764. }
  5765. }
  5766. else {
  5767. // non-binary full packet
  5768. super.emitReserved("decoded", packet);
  5769. }
  5770. }
  5771. else if (is_binary_js_1.isBinary(obj) || obj.base64) {
  5772. // raw binary data
  5773. if (!this.reconstructor) {
  5774. throw new Error("got binary data when not reconstructing a packet");
  5775. }
  5776. else {
  5777. packet = this.reconstructor.takeBinaryData(obj);
  5778. if (packet) {
  5779. // received final buffer
  5780. this.reconstructor = null;
  5781. super.emitReserved("decoded", packet);
  5782. }
  5783. }
  5784. }
  5785. else {
  5786. throw new Error("Unknown type: " + obj);
  5787. }
  5788. }
  5789. /**
  5790. * Decode a packet String (JSON data)
  5791. *
  5792. * @param {String} str
  5793. * @return {Object} packet
  5794. */
  5795. decodeString(str) {
  5796. let i = 0;
  5797. // look up type
  5798. const p = {
  5799. type: Number(str.charAt(0)),
  5800. };
  5801. if (PacketType[p.type] === undefined) {
  5802. throw new Error("unknown packet type " + p.type);
  5803. }
  5804. // look up attachments if type binary
  5805. if (p.type === PacketType.BINARY_EVENT ||
  5806. p.type === PacketType.BINARY_ACK) {
  5807. const start = i + 1;
  5808. while (str.charAt(++i) !== "-" && i != str.length) { }
  5809. const buf = str.substring(start, i);
  5810. if (buf != Number(buf) || str.charAt(i) !== "-") {
  5811. throw new Error("Illegal attachments");
  5812. }
  5813. p.attachments = Number(buf);
  5814. }
  5815. // look up namespace (if any)
  5816. if ("/" === str.charAt(i + 1)) {
  5817. const start = i + 1;
  5818. while (++i) {
  5819. const c = str.charAt(i);
  5820. if ("," === c)
  5821. break;
  5822. if (i === str.length)
  5823. break;
  5824. }
  5825. p.nsp = str.substring(start, i);
  5826. }
  5827. else {
  5828. p.nsp = "/";
  5829. }
  5830. // look up id
  5831. const next = str.charAt(i + 1);
  5832. if ("" !== next && Number(next) == next) {
  5833. const start = i + 1;
  5834. while (++i) {
  5835. const c = str.charAt(i);
  5836. if (null == c || Number(c) != c) {
  5837. --i;
  5838. break;
  5839. }
  5840. if (i === str.length)
  5841. break;
  5842. }
  5843. p.id = Number(str.substring(start, i + 1));
  5844. }
  5845. // look up json data
  5846. if (str.charAt(++i)) {
  5847. const payload = tryParse(str.substr(i));
  5848. if (Decoder.isPayloadValid(p.type, payload)) {
  5849. p.data = payload;
  5850. }
  5851. else {
  5852. throw new Error("invalid payload");
  5853. }
  5854. }
  5855. debug("decoded %s as %j", str, p);
  5856. return p;
  5857. }
  5858. static isPayloadValid(type, payload) {
  5859. switch (type) {
  5860. case PacketType.CONNECT:
  5861. return typeof payload === "object";
  5862. case PacketType.DISCONNECT:
  5863. return payload === undefined;
  5864. case PacketType.CONNECT_ERROR:
  5865. return typeof payload === "string" || typeof payload === "object";
  5866. case PacketType.EVENT:
  5867. case PacketType.BINARY_EVENT:
  5868. return Array.isArray(payload) && payload.length > 0;
  5869. case PacketType.ACK:
  5870. case PacketType.BINARY_ACK:
  5871. return Array.isArray(payload);
  5872. }
  5873. }
  5874. /**
  5875. * Deallocates a parser's resources
  5876. */
  5877. destroy() {
  5878. if (this.reconstructor) {
  5879. this.reconstructor.finishedReconstruction();
  5880. }
  5881. }
  5882. }
  5883. exports.Decoder = Decoder;
  5884. function tryParse(str) {
  5885. try {
  5886. return JSON.parse(str);
  5887. }
  5888. catch (e) {
  5889. return false;
  5890. }
  5891. }
  5892. /**
  5893. * A manager of a binary event's 'buffer sequence'. Should
  5894. * be constructed whenever a packet of type BINARY_EVENT is
  5895. * decoded.
  5896. *
  5897. * @param {Object} packet
  5898. * @return {BinaryReconstructor} initialized reconstructor
  5899. */
  5900. class BinaryReconstructor {
  5901. constructor(packet) {
  5902. this.packet = packet;
  5903. this.buffers = [];
  5904. this.reconPack = packet;
  5905. }
  5906. /**
  5907. * Method to be called when binary data received from connection
  5908. * after a BINARY_EVENT packet.
  5909. *
  5910. * @param {Buffer | ArrayBuffer} binData - the raw binary data received
  5911. * @return {null | Object} returns null if more binary data is expected or
  5912. * a reconstructed packet object if all buffers have been received.
  5913. */
  5914. takeBinaryData(binData) {
  5915. this.buffers.push(binData);
  5916. if (this.buffers.length === this.reconPack.attachments) {
  5917. // done with buffer list
  5918. const packet = binary_js_1.reconstructPacket(this.reconPack, this.buffers);
  5919. this.finishedReconstruction();
  5920. return packet;
  5921. }
  5922. return null;
  5923. }
  5924. /**
  5925. * Cleans up binary packet reconstruction variables.
  5926. */
  5927. finishedReconstruction() {
  5928. this.reconPack = null;
  5929. this.buffers = [];
  5930. }
  5931. }
  5932. /***/ }),
  5933. /***/ "../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js":
  5934. /*!*****************************************************************************************************!*\
  5935. !*** ../ot-core/node_modules/socket.io-client/node_modules/socket.io-parser/build/cjs/is-binary.js ***!
  5936. \*****************************************************************************************************/
  5937. /***/ ((__unused_webpack_module, exports) => {
  5938. "use strict";
  5939. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5940. exports.hasBinary = exports.isBinary = void 0;
  5941. const withNativeArrayBuffer = typeof ArrayBuffer === "function";
  5942. const isView = (obj) => {
  5943. return typeof ArrayBuffer.isView === "function"
  5944. ? ArrayBuffer.isView(obj)
  5945. : obj.buffer instanceof ArrayBuffer;
  5946. };
  5947. const toString = Object.prototype.toString;
  5948. const withNativeBlob = typeof Blob === "function" ||
  5949. (typeof Blob !== "undefined" &&
  5950. toString.call(Blob) === "[object BlobConstructor]");
  5951. const withNativeFile = typeof File === "function" ||
  5952. (typeof File !== "undefined" &&
  5953. toString.call(File) === "[object FileConstructor]");
  5954. /**
  5955. * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
  5956. *
  5957. * @private
  5958. */
  5959. function isBinary(obj) {
  5960. return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
  5961. (withNativeBlob && obj instanceof Blob) ||
  5962. (withNativeFile && obj instanceof File));
  5963. }
  5964. exports.isBinary = isBinary;
  5965. function hasBinary(obj, toJSON) {
  5966. if (!obj || typeof obj !== "object") {
  5967. return false;
  5968. }
  5969. if (Array.isArray(obj)) {
  5970. for (let i = 0, l = obj.length; i < l; i++) {
  5971. if (hasBinary(obj[i])) {
  5972. return true;
  5973. }
  5974. }
  5975. return false;
  5976. }
  5977. if (isBinary(obj)) {
  5978. return true;
  5979. }
  5980. if (obj.toJSON &&
  5981. typeof obj.toJSON === "function" &&
  5982. arguments.length === 1) {
  5983. return hasBinary(obj.toJSON(), true);
  5984. }
  5985. for (const key in obj) {
  5986. if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
  5987. return true;
  5988. }
  5989. }
  5990. return false;
  5991. }
  5992. exports.hasBinary = hasBinary;
  5993. /***/ })
  5994. /******/ });
  5995. /************************************************************************/
  5996. /******/ // The module cache
  5997. /******/ var __webpack_module_cache__ = {};
  5998. /******/
  5999. /******/ // The require function
  6000. /******/ function __webpack_require__(moduleId) {
  6001. /******/ // Check if module is in cache
  6002. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6003. /******/ if (cachedModule !== undefined) {
  6004. /******/ return cachedModule.exports;
  6005. /******/ }
  6006. /******/ // Create a new module (and put it into the cache)
  6007. /******/ var module = __webpack_module_cache__[moduleId] = {
  6008. /******/ // no module.id needed
  6009. /******/ // no module.loaded needed
  6010. /******/ exports: {}
  6011. /******/ };
  6012. /******/
  6013. /******/ // Execute the module function
  6014. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  6015. /******/
  6016. /******/ // Return the exports of the module
  6017. /******/ return module.exports;
  6018. /******/ }
  6019. /******/
  6020. /************************************************************************/
  6021. /******/ /* webpack/runtime/define property getters */
  6022. /******/ (() => {
  6023. /******/ // define getter functions for harmony exports
  6024. /******/ __webpack_require__.d = (exports, definition) => {
  6025. /******/ for(var key in definition) {
  6026. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  6027. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  6028. /******/ }
  6029. /******/ }
  6030. /******/ };
  6031. /******/ })();
  6032. /******/
  6033. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  6034. /******/ (() => {
  6035. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  6036. /******/ })();
  6037. /******/
  6038. /******/ /* webpack/runtime/make namespace object */
  6039. /******/ (() => {
  6040. /******/ // define __esModule on exports
  6041. /******/ __webpack_require__.r = (exports) => {
  6042. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  6043. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  6044. /******/ }
  6045. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  6046. /******/ };
  6047. /******/ })();
  6048. /******/
  6049. /************************************************************************/
  6050. /******/
  6051. /******/ // startup
  6052. /******/ // Load entry module and return exports
  6053. /******/ // This entry module is referenced by other modules so it can't be inlined
  6054. /******/ var __webpack_exports__ = __webpack_require__("./src/client.ts");
  6055. /******/
  6056. /******/ return __webpack_exports__;
  6057. /******/ })()
  6058. ;
  6059. });
  6060. //# sourceMappingURL=client.js.map