sails.io.js 224 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856
  1. /* eslint-disable */
  2. /**
  3. * To use sails.io.js in an AMD environment (e.g. with require.js),
  4. * replace this file with the sails.io.js file from the root of:
  5. * https://github.com/balderdashy/sails.io.js
  6. * and download a standalone copy of socket.io-client from:
  7. * https://github.com/socketio/socket.io-client
  8. * then follow the instructions at:
  9. * https://github.com/balderdashy/sails.io.js#requirejsamd-usage
  10. */
  11. // socket.io-client version 1.7.3
  12. // https://github.com/socketio/socket.io-client
  13. !
  14. function(a, b) {
  15. "object" == typeof exports && "object" == typeof module ? module.exports = b() : "function" == typeof define && define.amd ? define([], b) : "object" == typeof exports ? exports.io = b() : a.io = b()
  16. } (this,
  17. function() {
  18. return function(a) {
  19. function b(d) {
  20. if (c[d]) return c[d].exports;
  21. var e = c[d] = {
  22. exports: {},
  23. id: d,
  24. loaded: !1
  25. };
  26. return a[d].call(e.exports, e, e.exports, b),
  27. e.loaded = !0,
  28. e.exports
  29. }
  30. var c = {};
  31. return b.m = a,
  32. b.c = c,
  33. b.p = "",
  34. b(0)
  35. } ([function(a, b, c) {
  36. "use strict";
  37. function d(a, b) {
  38. "object" === ("undefined" == typeof a ? "undefined": f(a)) && (b = a, a = void 0),
  39. b = b || {};
  40. var c, d = g(a),
  41. h = d.source,
  42. l = d.id,
  43. m = d.path,
  44. n = k[l] && m in k[l].nsps,
  45. o = b.forceNew || b["force new connection"] || !1 === b.multiplex || n;
  46. return o ? (j("ignoring socket cache for %s", h), c = i(h, b)) : (k[l] || (j("new io instance for %s", h), k[l] = i(h, b)), c = k[l]),
  47. d.query && !b.query ? b.query = d.query: b && "object" === f(b.query) && (b.query = e(b.query)),
  48. c.socket(d.path, b)
  49. }
  50. function e(a) {
  51. var b = [];
  52. for (var c in a) a.hasOwnProperty(c) && b.push(encodeURIComponent(c) + "=" + encodeURIComponent(a[c]));
  53. return b.join("&")
  54. }
  55. var f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  56. function(a) {
  57. return typeof a
  58. }: function(a) {
  59. return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol": typeof a
  60. },
  61. g = c(1),
  62. h = c(7),
  63. i = c(17),
  64. j = c(3)("socket.io-client");
  65. a.exports = b = d;
  66. var k = b.managers = {};
  67. b.protocol = h.protocol,
  68. b.connect = d,
  69. b.Manager = c(17),
  70. b.Socket = c(44)
  71. },
  72. function(a, b, c) { (function(b) {
  73. "use strict";
  74. function d(a, c) {
  75. var d = a;
  76. c = c || b.location,
  77. null == a && (a = c.protocol + "//" + c.host),
  78. "string" == typeof a && ("/" === a.charAt(0) && (a = "/" === a.charAt(1) ? c.protocol + a: c.host + a), /^(https?|wss?):\/\//.test(a) || (f("protocol-less url %s", a), a = "undefined" != typeof c ? c.protocol + "//" + a: "https://" + a), f("parse %s", a), d = e(a)),
  79. d.port || (/^(http|ws)$/.test(d.protocol) ? d.port = "80": /^(http|ws)s$/.test(d.protocol) && (d.port = "443")),
  80. d.path = d.path || "/";
  81. var g = d.host.indexOf(":") !== -1,
  82. h = g ? "[" + d.host + "]": d.host;
  83. return d.id = d.protocol + "://" + h + ":" + d.port,
  84. d.href = d.protocol + "://" + h + (c && c.port === d.port ? "": ":" + d.port),
  85. d
  86. }
  87. var e = c(2),
  88. f = c(3)("socket.io-client:url");
  89. a.exports = d
  90. }).call(b,
  91. function() {
  92. return this
  93. } ())
  94. },
  95. function(a, b) {
  96. var c = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
  97. d = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"];
  98. a.exports = function(a) {
  99. var b = a,
  100. e = a.indexOf("["),
  101. f = a.indexOf("]");
  102. e != -1 && f != -1 && (a = a.substring(0, e) + a.substring(e, f).replace(/:/g, ";") + a.substring(f, a.length));
  103. for (var g = c.exec(a || ""), h = {},
  104. i = 14; i--;) h[d[i]] = g[i] || "";
  105. return e != -1 && f != -1 && (h.source = b, h.host = h.host.substring(1, h.host.length - 1).replace(/;/g, ":"), h.authority = h.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), h.ipv6uri = !0),
  106. h
  107. }
  108. },
  109. function(a, b, c) { (function(d) {
  110. function e() {
  111. return "undefined" != typeof document && "WebkitAppearance" in document.documentElement.style || window.console && (console.firebug || console.exception && console.table) || navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31
  112. }
  113. function f() {
  114. var a = arguments,
  115. c = this.useColors;
  116. if (a[0] = (c ? "%c": "") + this.namespace + (c ? " %c": " ") + a[0] + (c ? "%c ": " ") + "+" + b.humanize(this.diff), !c) return a;
  117. var d = "color: " + this.color;
  118. a = [a[0], d, "color: inherit"].concat(Array.prototype.slice.call(a, 1));
  119. var e = 0,
  120. f = 0;
  121. return a[0].replace(/%[a-z%]/g,
  122. function(a) {
  123. "%%" !== a && (e++, "%c" === a && (f = e))
  124. }),
  125. a.splice(f, 0, d),
  126. a
  127. }
  128. function g() {
  129. return "object" == typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments)
  130. }
  131. function h(a) {
  132. try {
  133. null == a ? b.storage.removeItem("debug") : b.storage.debug = a
  134. } catch(c) {}
  135. }
  136. function i() {
  137. try {
  138. return b.storage.debug
  139. } catch(a) {}
  140. if ("undefined" != typeof d && "env" in d) return d.env.DEBUG
  141. }
  142. function j() {
  143. try {
  144. return window.localStorage
  145. } catch(a) {}
  146. }
  147. b = a.exports = c(5),
  148. b.log = g,
  149. b.formatArgs = f,
  150. b.save = h,
  151. b.load = i,
  152. b.useColors = e,
  153. b.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local: j(),
  154. b.colors = ["lightseagreen", "forestgreen", "goldenrod", "dodgerblue", "darkorchid", "crimson"],
  155. b.formatters.j = function(a) {
  156. try {
  157. return JSON.stringify(a)
  158. } catch(b) {
  159. return "[UnexpectedJSONParseError]: " + b.message
  160. }
  161. },
  162. b.enable(i())
  163. }).call(b, c(4))
  164. },
  165. function(a, b) {
  166. function c() {
  167. throw new Error("setTimeout has not been defined")
  168. }
  169. function d() {
  170. throw new Error("clearTimeout has not been defined")
  171. }
  172. function e(a) {
  173. if (k === setTimeout) return setTimeout(a, 0);
  174. if ((k === c || !k) && setTimeout) return k = setTimeout,
  175. setTimeout(a, 0);
  176. try {
  177. return k(a, 0)
  178. } catch(b) {
  179. try {
  180. return k.call(null, a, 0)
  181. } catch(b) {
  182. return k.call(this, a, 0)
  183. }
  184. }
  185. }
  186. function f(a) {
  187. if (l === clearTimeout) return clearTimeout(a);
  188. if ((l === d || !l) && clearTimeout) return l = clearTimeout,
  189. clearTimeout(a);
  190. try {
  191. return l(a)
  192. } catch(b) {
  193. try {
  194. return l.call(null, a)
  195. } catch(b) {
  196. return l.call(this, a)
  197. }
  198. }
  199. }
  200. function g() {
  201. p && n && (p = !1, n.length ? o = n.concat(o) : q = -1, o.length && h())
  202. }
  203. function h() {
  204. if (!p) {
  205. var a = e(g);
  206. p = !0;
  207. for (var b = o.length; b;) {
  208. for (n = o, o = []; ++q < b;) n && n[q].run();
  209. q = -1,
  210. b = o.length
  211. }
  212. n = null,
  213. p = !1,
  214. f(a)
  215. }
  216. }
  217. function i(a, b) {
  218. this.fun = a,
  219. this.array = b
  220. }
  221. function j() {}
  222. var k, l, m = a.exports = {}; !
  223. function() {
  224. try {
  225. k = "function" == typeof setTimeout ? setTimeout: c
  226. } catch(a) {
  227. k = c
  228. }
  229. try {
  230. l = "function" == typeof clearTimeout ? clearTimeout: d
  231. } catch(a) {
  232. l = d
  233. }
  234. } ();
  235. var n, o = [],
  236. p = !1,
  237. q = -1;
  238. m.nextTick = function(a) {
  239. var b = new Array(arguments.length - 1);
  240. if (arguments.length > 1) for (var c = 1; c < arguments.length; c++) b[c - 1] = arguments[c];
  241. o.push(new i(a, b)),
  242. 1 !== o.length || p || e(h)
  243. },
  244. i.prototype.run = function() {
  245. this.fun.apply(null, this.array)
  246. },
  247. m.title = "browser",
  248. m.browser = !0,
  249. m.env = {},
  250. m.argv = [],
  251. m.version = "",
  252. m.versions = {},
  253. m.on = j,
  254. m.addListener = j,
  255. m.once = j,
  256. m.off = j,
  257. m.removeListener = j,
  258. m.removeAllListeners = j,
  259. m.emit = j,
  260. m.binding = function(a) {
  261. throw new Error("process.binding is not supported")
  262. },
  263. m.cwd = function() {
  264. return "/"
  265. },
  266. m.chdir = function(a) {
  267. throw new Error("process.chdir is not supported")
  268. },
  269. m.umask = function() {
  270. return 0
  271. }
  272. },
  273. function(a, b, c) {
  274. function d() {
  275. return b.colors[k++%b.colors.length]
  276. }
  277. function e(a) {
  278. function c() {}
  279. function e() {
  280. var a = e,
  281. c = +new Date,
  282. f = c - (j || c);
  283. a.diff = f,
  284. a.prev = j,
  285. a.curr = c,
  286. j = c,
  287. null == a.useColors && (a.useColors = b.useColors()),
  288. null == a.color && a.useColors && (a.color = d());
  289. for (var g = new Array(arguments.length), h = 0; h < g.length; h++) g[h] = arguments[h];
  290. g[0] = b.coerce(g[0]),
  291. "string" != typeof g[0] && (g = ["%o"].concat(g));
  292. var i = 0;
  293. g[0] = g[0].replace(/%([a-z%])/g,
  294. function(c, d) {
  295. if ("%%" === c) return c;
  296. i++;
  297. var e = b.formatters[d];
  298. if ("function" == typeof e) {
  299. var f = g[i];
  300. c = e.call(a, f),
  301. g.splice(i, 1),
  302. i--
  303. }
  304. return c
  305. }),
  306. g = b.formatArgs.apply(a, g);
  307. var k = e.log || b.log || console.log.bind(console);
  308. k.apply(a, g)
  309. }
  310. c.enabled = !1,
  311. e.enabled = !0;
  312. var f = b.enabled(a) ? e: c;
  313. return f.namespace = a,
  314. f
  315. }
  316. function f(a) {
  317. b.save(a);
  318. for (var c = (a || "").split(/[\s,]+/), d = c.length, e = 0; e < d; e++) c[e] && (a = c[e].replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*?"), "-" === a[0] ? b.skips.push(new RegExp("^" + a.substr(1) + "$")) : b.names.push(new RegExp("^" + a + "$")))
  319. }
  320. function g() {
  321. b.enable("")
  322. }
  323. function h(a) {
  324. var c, d;
  325. for (c = 0, d = b.skips.length; c < d; c++) if (b.skips[c].test(a)) return ! 1;
  326. for (c = 0, d = b.names.length; c < d; c++) if (b.names[c].test(a)) return ! 0;
  327. return ! 1
  328. }
  329. function i(a) {
  330. return a instanceof Error ? a.stack || a.message: a
  331. }
  332. b = a.exports = e.debug = e,
  333. b.coerce = i,
  334. b.disable = g,
  335. b.enable = f,
  336. b.enabled = h,
  337. b.humanize = c(6),
  338. b.names = [],
  339. b.skips = [],
  340. b.formatters = {};
  341. var j, k = 0
  342. },
  343. function(a, b) {
  344. function c(a) {
  345. if (a = String(a), !(a.length > 1e4)) {
  346. var b = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);
  347. if (b) {
  348. var c = parseFloat(b[1]),
  349. d = (b[2] || "ms").toLowerCase();
  350. switch (d) {
  351. case "years":
  352. case "year":
  353. case "yrs":
  354. case "yr":
  355. case "y":
  356. return c * k;
  357. case "days":
  358. case "day":
  359. case "d":
  360. return c * j;
  361. case "hours":
  362. case "hour":
  363. case "hrs":
  364. case "hr":
  365. case "h":
  366. return c * i;
  367. case "minutes":
  368. case "minute":
  369. case "mins":
  370. case "min":
  371. case "m":
  372. return c * h;
  373. case "seconds":
  374. case "second":
  375. case "secs":
  376. case "sec":
  377. case "s":
  378. return c * g;
  379. case "milliseconds":
  380. case "millisecond":
  381. case "msecs":
  382. case "msec":
  383. case "ms":
  384. return c;
  385. default:
  386. return
  387. }
  388. }
  389. }
  390. }
  391. function d(a) {
  392. return a >= j ? Math.round(a / j) + "d": a >= i ? Math.round(a / i) + "h": a >= h ? Math.round(a / h) + "m": a >= g ? Math.round(a / g) + "s": a + "ms"
  393. }
  394. function e(a) {
  395. return f(a, j, "day") || f(a, i, "hour") || f(a, h, "minute") || f(a, g, "second") || a + " ms"
  396. }
  397. function f(a, b, c) {
  398. if (! (a < b)) return a < 1.5 * b ? Math.floor(a / b) + " " + c: Math.ceil(a / b) + " " + c + "s"
  399. }
  400. var g = 1e3,
  401. h = 60 * g,
  402. i = 60 * h,
  403. j = 24 * i,
  404. k = 365.25 * j;
  405. a.exports = function(a, b) {
  406. b = b || {};
  407. var f = typeof a;
  408. if ("string" === f && a.length > 0) return c(a);
  409. if ("number" === f && isNaN(a) === !1) return b["long"] ? e(a) : d(a);
  410. throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(a))
  411. }
  412. },
  413. function(a, b, c) {
  414. function d() {}
  415. function e(a) {
  416. var c = "",
  417. d = !1;
  418. return c += a.type,
  419. b.BINARY_EVENT != a.type && b.BINARY_ACK != a.type || (c += a.attachments, c += "-"),
  420. a.nsp && "/" != a.nsp && (d = !0, c += a.nsp),
  421. null != a.id && (d && (c += ",", d = !1), c += a.id),
  422. null != a.data && (d && (c += ","), c += m.stringify(a.data)),
  423. l("encoded %j as %s", a, c),
  424. c
  425. }
  426. function f(a, b) {
  427. function c(a) {
  428. var c = o.deconstructPacket(a),
  429. d = e(c.packet),
  430. f = c.buffers;
  431. f.unshift(d),
  432. b(f)
  433. }
  434. o.removeBlobs(a, c)
  435. }
  436. function g() {
  437. this.reconstructor = null
  438. }
  439. function h(a) {
  440. var c = {},
  441. d = 0;
  442. if (c.type = Number(a.charAt(0)), null == b.types[c.type]) return k();
  443. if (b.BINARY_EVENT == c.type || b.BINARY_ACK == c.type) {
  444. for (var e = "";
  445. "-" != a.charAt(++d) && (e += a.charAt(d), d != a.length););
  446. if (e != Number(e) || "-" != a.charAt(d)) throw new Error("Illegal attachments");
  447. c.attachments = Number(e)
  448. }
  449. if ("/" == a.charAt(d + 1)) for (c.nsp = ""; ++d;) {
  450. var f = a.charAt(d);
  451. if ("," == f) break;
  452. if (c.nsp += f, d == a.length) break
  453. } else c.nsp = "/";
  454. var g = a.charAt(d + 1);
  455. if ("" !== g && Number(g) == g) {
  456. for (c.id = ""; ++d;) {
  457. var f = a.charAt(d);
  458. if (null == f || Number(f) != f) {--d;
  459. break
  460. }
  461. if (c.id += a.charAt(d), d == a.length) break
  462. }
  463. c.id = Number(c.id)
  464. }
  465. return a.charAt(++d) && (c = i(c, a.substr(d))),
  466. l("decoded %s as %j", a, c),
  467. c
  468. }
  469. function i(a, b) {
  470. try {
  471. a.data = m.parse(b)
  472. } catch(c) {
  473. return k()
  474. }
  475. return a
  476. }
  477. function j(a) {
  478. this.reconPack = a,
  479. this.buffers = []
  480. }
  481. function k(a) {
  482. return {
  483. type: b.ERROR,
  484. data: "parser error"
  485. }
  486. }
  487. var l = c(8)("socket.io-parser"),
  488. m = c(11),
  489. n = c(13),
  490. o = c(14),
  491. p = c(16);
  492. b.protocol = 4,
  493. b.types = ["CONNECT", "DISCONNECT", "EVENT", "ACK", "ERROR", "BINARY_EVENT", "BINARY_ACK"],
  494. b.CONNECT = 0,
  495. b.DISCONNECT = 1,
  496. b.EVENT = 2,
  497. b.ACK = 3,
  498. b.ERROR = 4,
  499. b.BINARY_EVENT = 5,
  500. b.BINARY_ACK = 6,
  501. b.Encoder = d,
  502. b.Decoder = g,
  503. d.prototype.encode = function(a, c) {
  504. if (l("encoding packet %j", a), b.BINARY_EVENT == a.type || b.BINARY_ACK == a.type) f(a, c);
  505. else {
  506. var d = e(a);
  507. c([d])
  508. }
  509. },
  510. n(g.prototype),
  511. g.prototype.add = function(a) {
  512. var c;
  513. if ("string" == typeof a) c = h(a),
  514. b.BINARY_EVENT == c.type || b.BINARY_ACK == c.type ? (this.reconstructor = new j(c), 0 === this.reconstructor.reconPack.attachments && this.emit("decoded", c)) : this.emit("decoded", c);
  515. else {
  516. if (!p(a) && !a.base64) throw new Error("Unknown type: " + a);
  517. if (!this.reconstructor) throw new Error("got binary data when not reconstructing a packet");
  518. c = this.reconstructor.takeBinaryData(a),
  519. c && (this.reconstructor = null, this.emit("decoded", c))
  520. }
  521. },
  522. g.prototype.destroy = function() {
  523. this.reconstructor && this.reconstructor.finishedReconstruction()
  524. },
  525. j.prototype.takeBinaryData = function(a) {
  526. if (this.buffers.push(a), this.buffers.length == this.reconPack.attachments) {
  527. var b = o.reconstructPacket(this.reconPack, this.buffers);
  528. return this.finishedReconstruction(),
  529. b
  530. }
  531. return null
  532. },
  533. j.prototype.finishedReconstruction = function() {
  534. this.reconPack = null,
  535. this.buffers = []
  536. }
  537. },
  538. function(a, b, c) {
  539. function d() {
  540. return "WebkitAppearance" in document.documentElement.style || window.console && (console.firebug || console.exception && console.table) || navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31
  541. }
  542. function e() {
  543. var a = arguments,
  544. c = this.useColors;
  545. if (a[0] = (c ? "%c": "") + this.namespace + (c ? " %c": " ") + a[0] + (c ? "%c ": " ") + "+" + b.humanize(this.diff), !c) return a;
  546. var d = "color: " + this.color;
  547. a = [a[0], d, "color: inherit"].concat(Array.prototype.slice.call(a, 1));
  548. var e = 0,
  549. f = 0;
  550. return a[0].replace(/%[a-z%]/g,
  551. function(a) {
  552. "%%" !== a && (e++, "%c" === a && (f = e))
  553. }),
  554. a.splice(f, 0, d),
  555. a
  556. }
  557. function f() {
  558. return "object" == typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments)
  559. }
  560. function g(a) {
  561. try {
  562. null == a ? b.storage.removeItem("debug") : b.storage.debug = a
  563. } catch(c) {}
  564. }
  565. function h() {
  566. var a;
  567. try {
  568. a = b.storage.debug
  569. } catch(c) {}
  570. return a
  571. }
  572. function i() {
  573. try {
  574. return window.localStorage
  575. } catch(a) {}
  576. }
  577. b = a.exports = c(9),
  578. b.log = f,
  579. b.formatArgs = e,
  580. b.save = g,
  581. b.load = h,
  582. b.useColors = d,
  583. b.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local: i(),
  584. b.colors = ["lightseagreen", "forestgreen", "goldenrod", "dodgerblue", "darkorchid", "crimson"],
  585. b.formatters.j = function(a) {
  586. return JSON.stringify(a)
  587. },
  588. b.enable(h())
  589. },
  590. function(a, b, c) {
  591. function d() {
  592. return b.colors[k++%b.colors.length]
  593. }
  594. function e(a) {
  595. function c() {}
  596. function e() {
  597. var a = e,
  598. c = +new Date,
  599. f = c - (j || c);
  600. a.diff = f,
  601. a.prev = j,
  602. a.curr = c,
  603. j = c,
  604. null == a.useColors && (a.useColors = b.useColors()),
  605. null == a.color && a.useColors && (a.color = d());
  606. var g = Array.prototype.slice.call(arguments);
  607. g[0] = b.coerce(g[0]),
  608. "string" != typeof g[0] && (g = ["%o"].concat(g));
  609. var h = 0;
  610. g[0] = g[0].replace(/%([a-z%])/g,
  611. function(c, d) {
  612. if ("%%" === c) return c;
  613. h++;
  614. var e = b.formatters[d];
  615. if ("function" == typeof e) {
  616. var f = g[h];
  617. c = e.call(a, f),
  618. g.splice(h, 1),
  619. h--
  620. }
  621. return c
  622. }),
  623. "function" == typeof b.formatArgs && (g = b.formatArgs.apply(a, g));
  624. var i = e.log || b.log || console.log.bind(console);
  625. i.apply(a, g)
  626. }
  627. c.enabled = !1,
  628. e.enabled = !0;
  629. var f = b.enabled(a) ? e: c;
  630. return f.namespace = a,
  631. f
  632. }
  633. function f(a) {
  634. b.save(a);
  635. for (var c = (a || "").split(/[\s,]+/), d = c.length, e = 0; e < d; e++) c[e] && (a = c[e].replace(/\*/g, ".*?"), "-" === a[0] ? b.skips.push(new RegExp("^" + a.substr(1) + "$")) : b.names.push(new RegExp("^" + a + "$")))
  636. }
  637. function g() {
  638. b.enable("")
  639. }
  640. function h(a) {
  641. var c, d;
  642. for (c = 0, d = b.skips.length; c < d; c++) if (b.skips[c].test(a)) return ! 1;
  643. for (c = 0, d = b.names.length; c < d; c++) if (b.names[c].test(a)) return ! 0;
  644. return ! 1
  645. }
  646. function i(a) {
  647. return a instanceof Error ? a.stack || a.message: a
  648. }
  649. b = a.exports = e,
  650. b.coerce = i,
  651. b.disable = g,
  652. b.enable = f,
  653. b.enabled = h,
  654. b.humanize = c(10),
  655. b.names = [],
  656. b.skips = [],
  657. b.formatters = {};
  658. var j, k = 0
  659. },
  660. function(a, b) {
  661. function c(a) {
  662. if (a = "" + a, !(a.length > 1e4)) {
  663. var b = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);
  664. if (b) {
  665. var c = parseFloat(b[1]),
  666. d = (b[2] || "ms").toLowerCase();
  667. switch (d) {
  668. case "years":
  669. case "year":
  670. case "yrs":
  671. case "yr":
  672. case "y":
  673. return c * k;
  674. case "days":
  675. case "day":
  676. case "d":
  677. return c * j;
  678. case "hours":
  679. case "hour":
  680. case "hrs":
  681. case "hr":
  682. case "h":
  683. return c * i;
  684. case "minutes":
  685. case "minute":
  686. case "mins":
  687. case "min":
  688. case "m":
  689. return c * h;
  690. case "seconds":
  691. case "second":
  692. case "secs":
  693. case "sec":
  694. case "s":
  695. return c * g;
  696. case "milliseconds":
  697. case "millisecond":
  698. case "msecs":
  699. case "msec":
  700. case "ms":
  701. return c
  702. }
  703. }
  704. }
  705. }
  706. function d(a) {
  707. return a >= j ? Math.round(a / j) + "d": a >= i ? Math.round(a / i) + "h": a >= h ? Math.round(a / h) + "m": a >= g ? Math.round(a / g) + "s": a + "ms"
  708. }
  709. function e(a) {
  710. return f(a, j, "day") || f(a, i, "hour") || f(a, h, "minute") || f(a, g, "second") || a + " ms"
  711. }
  712. function f(a, b, c) {
  713. if (! (a < b)) return a < 1.5 * b ? Math.floor(a / b) + " " + c: Math.ceil(a / b) + " " + c + "s"
  714. }
  715. var g = 1e3,
  716. h = 60 * g,
  717. i = 60 * h,
  718. j = 24 * i,
  719. k = 365.25 * j;
  720. a.exports = function(a, b) {
  721. return b = b || {},
  722. "string" == typeof a ? c(a) : b["long"] ? e(a) : d(a)
  723. }
  724. },
  725. function(a, b, c) { (function(a, c) {
  726. var d = !1; (function() {
  727. function e(a, b) {
  728. function c(a) {
  729. if (c[a] !== q) return c[a];
  730. var e;
  731. if ("bug-string-char-index" == a) e = "a" != "a" [0];
  732. else if ("json" == a) e = c("json-stringify") && c("json-parse");
  733. else {
  734. var g, h = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
  735. if ("json-stringify" == a) {
  736. var i = b.stringify,
  737. k = "function" == typeof i && t;
  738. if (k) { (g = function() {
  739. return 1
  740. }).toJSON = g;
  741. try {
  742. k = "0" === i(0) && "0" === i(new d) && '""' == i(new f) && i(s) === q && i(q) === q && i() === q && "1" === i(g) && "[1]" == i([g]) && "[null]" == i([q]) && "null" == i(null) && "[null,null,null]" == i([q, s, null]) && i({
  743. a: [g, !0, !1, null, "\0\b\n\f\r\t"]
  744. }) == h && "1" === i(null, g) && "[\n 1,\n 2\n]" == i([1, 2], null, 1) && '"-271821-04-20T00:00:00.000Z"' == i(new j(( - 864e13))) && '"+275760-09-13T00:00:00.000Z"' == i(new j(864e13)) && '"-000001-01-01T00:00:00.000Z"' == i(new j(( - 621987552e5))) && '"1969-12-31T23:59:59.999Z"' == i(new j(( - 1)))
  745. } catch(l) {
  746. k = !1
  747. }
  748. }
  749. e = k
  750. }
  751. if ("json-parse" == a) {
  752. var m = b.parse;
  753. if ("function" == typeof m) try {
  754. if (0 === m("0") && !m(!1)) {
  755. g = m(h);
  756. var n = 5 == g.a.length && 1 === g.a[0];
  757. if (n) {
  758. try {
  759. n = !m('"\t"')
  760. } catch(l) {}
  761. if (n) try {
  762. n = 1 !== m("01")
  763. } catch(l) {}
  764. if (n) try {
  765. n = 1 !== m("1.")
  766. } catch(l) {}
  767. }
  768. }
  769. } catch(l) {
  770. n = !1
  771. }
  772. e = n
  773. }
  774. }
  775. return c[a] = !!e
  776. }
  777. a || (a = i.Object()),
  778. b || (b = i.Object());
  779. var d = a.Number || i.Number,
  780. f = a.String || i.String,
  781. h = a.Object || i.Object,
  782. j = a.Date || i.Date,
  783. k = a.SyntaxError || i.SyntaxError,
  784. l = a.TypeError || i.TypeError,
  785. m = a.Math || i.Math,
  786. n = a.JSON || i.JSON;
  787. "object" == typeof n && n && (b.stringify = n.stringify, b.parse = n.parse);
  788. var o, p, q, r = h.prototype,
  789. s = r.toString,
  790. t = new j(( - 0xc782b5b800cec));
  791. try {
  792. t = t.getUTCFullYear() == -109252 && 0 === t.getUTCMonth() && 1 === t.getUTCDate() && 10 == t.getUTCHours() && 37 == t.getUTCMinutes() && 6 == t.getUTCSeconds() && 708 == t.getUTCMilliseconds()
  793. } catch(u) {}
  794. if (!c("json")) {
  795. var v = "[object Function]",
  796. w = "[object Date]",
  797. x = "[object Number]",
  798. y = "[object String]",
  799. z = "[object Array]",
  800. A = "[object Boolean]",
  801. B = c("bug-string-char-index");
  802. if (!t) var C = m.floor,
  803. D = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
  804. E = function(a, b) {
  805. return D[b] + 365 * (a - 1970) + C((a - 1969 + (b = +(b > 1))) / 4) - C((a - 1901 + b) / 100) + C((a - 1601 + b) / 400)
  806. };
  807. if ((o = r.hasOwnProperty) || (o = function(a) {
  808. var b, c = {};
  809. return (c.__proto__ = null, c.__proto__ = {
  810. toString: 1
  811. },
  812. c).toString != s ? o = function(a) {
  813. var b = this.__proto__,
  814. c = a in (this.__proto__ = null, this);
  815. return this.__proto__ = b,
  816. c
  817. }: (b = c.constructor, o = function(a) {
  818. var c = (this.constructor || b).prototype;
  819. return a in this && !(a in c && this[a] === c[a])
  820. }),
  821. c = null,
  822. o.call(this, a)
  823. }), p = function(a, b) {
  824. var c, d, e, f = 0; (c = function() {
  825. this.valueOf = 0
  826. }).prototype.valueOf = 0,
  827. d = new c;
  828. for (e in d) o.call(d, e) && f++;
  829. return c = d = null,
  830. f ? p = 2 == f ?
  831. function(a, b) {
  832. var c, d = {},
  833. e = s.call(a) == v;
  834. for (c in a) e && "prototype" == c || o.call(d, c) || !(d[c] = 1) || !o.call(a, c) || b(c)
  835. }: function(a, b) {
  836. var c, d, e = s.call(a) == v;
  837. for (c in a) e && "prototype" == c || !o.call(a, c) || (d = "constructor" === c) || b(c); (d || o.call(a, c = "constructor")) && b(c)
  838. }: (d = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"], p = function(a, b) {
  839. var c, e, f = s.call(a) == v,
  840. h = !f && "function" != typeof a.constructor && g[typeof a.hasOwnProperty] && a.hasOwnProperty || o;
  841. for (c in a) f && "prototype" == c || !h.call(a, c) || b(c);
  842. for (e = d.length; c = d[--e]; h.call(a, c) && b(c));
  843. }),
  844. p(a, b)
  845. },
  846. !c("json-stringify")) {
  847. var F = {
  848. 92 : "\\\\",
  849. 34 : '\\"',
  850. 8 : "\\b",
  851. 12 : "\\f",
  852. 10 : "\\n",
  853. 13 : "\\r",
  854. 9 : "\\t"
  855. },
  856. G = "000000",
  857. H = function(a, b) {
  858. return (G + (b || 0)).slice( - a)
  859. },
  860. I = "\\u00",
  861. J = function(a) {
  862. for (var b = '"',
  863. c = 0,
  864. d = a.length,
  865. e = !B || d > 10,
  866. f = e && (B ? a.split("") : a); c < d; c++) {
  867. var g = a.charCodeAt(c);
  868. switch (g) {
  869. case 8:
  870. case 9:
  871. case 10:
  872. case 12:
  873. case 13:
  874. case 34:
  875. case 92:
  876. b += F[g];
  877. break;
  878. default:
  879. if (g < 32) {
  880. b += I + H(2, g.toString(16));
  881. break
  882. }
  883. b += e ? f[c] : a.charAt(c)
  884. }
  885. }
  886. return b + '"'
  887. },
  888. K = function(a, b, c, d, e, f, g) {
  889. var h, i, j, k, m, n, r, t, u, v, B, D, F, G, I, L;
  890. try {
  891. h = b[a]
  892. } catch(M) {}
  893. if ("object" == typeof h && h) if (i = s.call(h), i != w || o.call(h, "toJSON"))"function" == typeof h.toJSON && (i != x && i != y && i != z || o.call(h, "toJSON")) && (h = h.toJSON(a));
  894. else if (h > -1 / 0 && h < 1 / 0) {
  895. if (E) {
  896. for (m = C(h / 864e5), j = C(m / 365.2425) + 1970 - 1; E(j + 1, 0) <= m; j++);
  897. for (k = C((m - E(j, 0)) / 30.42); E(j, k + 1) <= m; k++);
  898. m = 1 + m - E(j, k),
  899. n = (h % 864e5 + 864e5) % 864e5,
  900. r = C(n / 36e5) % 24,
  901. t = C(n / 6e4) % 60,
  902. u = C(n / 1e3) % 60,
  903. v = n % 1e3
  904. } else j = h.getUTCFullYear(),
  905. k = h.getUTCMonth(),
  906. m = h.getUTCDate(),
  907. r = h.getUTCHours(),
  908. t = h.getUTCMinutes(),
  909. u = h.getUTCSeconds(),
  910. v = h.getUTCMilliseconds();
  911. h = (j <= 0 || j >= 1e4 ? (j < 0 ? "-": "+") + H(6, j < 0 ? -j: j) : H(4, j)) + "-" + H(2, k + 1) + "-" + H(2, m) + "T" + H(2, r) + ":" + H(2, t) + ":" + H(2, u) + "." + H(3, v) + "Z"
  912. } else h = null;
  913. if (c && (h = c.call(b, a, h)), null === h) return "null";
  914. if (i = s.call(h), i == A) return "" + h;
  915. if (i == x) return h > -1 / 0 && h < 1 / 0 ? "" + h: "null";
  916. if (i == y) return J("" + h);
  917. if ("object" == typeof h) {
  918. for (G = g.length; G--;) if (g[G] === h) throw l();
  919. if (g.push(h), B = [], I = f, f += e, i == z) {
  920. for (F = 0, G = h.length; F < G; F++) D = K(F, h, c, d, e, f, g),
  921. B.push(D === q ? "null": D);
  922. L = B.length ? e ? "[\n" + f + B.join(",\n" + f) + "\n" + I + "]": "[" + B.join(",") + "]": "[]"
  923. } else p(d || h,
  924. function(a) {
  925. var b = K(a, h, c, d, e, f, g);
  926. b !== q && B.push(J(a) + ":" + (e ? " ": "") + b)
  927. }),
  928. L = B.length ? e ? "{\n" + f + B.join(",\n" + f) + "\n" + I + "}": "{" + B.join(",") + "}": "{}";
  929. return g.pop(),
  930. L
  931. }
  932. };
  933. b.stringify = function(a, b, c) {
  934. var d, e, f, h;
  935. if (g[typeof b] && b) if ((h = s.call(b)) == v) e = b;
  936. else if (h == z) {
  937. f = {};
  938. for (var i, j = 0,
  939. k = b.length; j < k; i = b[j++], h = s.call(i), (h == y || h == x) && (f[i] = 1));
  940. }
  941. if (c) if ((h = s.call(c)) == x) {
  942. if ((c -= c % 1) > 0) for (d = "", c > 10 && (c = 10); d.length < c; d += " ");
  943. } else h == y && (d = c.length <= 10 ? c: c.slice(0, 10));
  944. return K("", (i = {},
  945. i[""] = a, i), e, f, d, "", [])
  946. }
  947. }
  948. if (!c("json-parse")) {
  949. var L, M, N = f.fromCharCode,
  950. O = {
  951. 92 : "\\",
  952. 34 : '"',
  953. 47 : "/",
  954. 98 : "\b",
  955. 116 : "\t",
  956. 110 : "\n",
  957. 102 : "\f",
  958. 114 : "\r"
  959. },
  960. P = function() {
  961. throw L = M = null,
  962. k()
  963. },
  964. Q = function() {
  965. for (var a, b, c, d, e, f = M,
  966. g = f.length; L < g;) switch (e = f.charCodeAt(L)) {
  967. case 9:
  968. case 10:
  969. case 13:
  970. case 32:
  971. L++;
  972. break;
  973. case 123:
  974. case 125:
  975. case 91:
  976. case 93:
  977. case 58:
  978. case 44:
  979. return a = B ? f.charAt(L) : f[L],
  980. L++,
  981. a;
  982. case 34:
  983. for (a = "@", L++; L < g;) if (e = f.charCodeAt(L), e < 32) P();
  984. else if (92 == e) switch (e = f.charCodeAt(++L)) {
  985. case 92:
  986. case 34:
  987. case 47:
  988. case 98:
  989. case 116:
  990. case 110:
  991. case 102:
  992. case 114:
  993. a += O[e],
  994. L++;
  995. break;
  996. case 117:
  997. for (b = ++L, c = L + 4; L < c; L++) e = f.charCodeAt(L),
  998. e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70 || P();
  999. a += N("0x" + f.slice(b, L));
  1000. break;
  1001. default:
  1002. P()
  1003. } else {
  1004. if (34 == e) break;
  1005. for (e = f.charCodeAt(L), b = L; e >= 32 && 92 != e && 34 != e;) e = f.charCodeAt(++L);
  1006. a += f.slice(b, L)
  1007. }
  1008. if (34 == f.charCodeAt(L)) return L++,
  1009. a;
  1010. P();
  1011. default:
  1012. if (b = L, 45 == e && (d = !0, e = f.charCodeAt(++L)), e >= 48 && e <= 57) {
  1013. for (48 == e && (e = f.charCodeAt(L + 1), e >= 48 && e <= 57) && P(), d = !1; L < g && (e = f.charCodeAt(L), e >= 48 && e <= 57); L++);
  1014. if (46 == f.charCodeAt(L)) {
  1015. for (c = ++L; c < g && (e = f.charCodeAt(c), e >= 48 && e <= 57); c++);
  1016. c == L && P(),
  1017. L = c
  1018. }
  1019. if (e = f.charCodeAt(L), 101 == e || 69 == e) {
  1020. for (e = f.charCodeAt(++L), 43 != e && 45 != e || L++, c = L; c < g && (e = f.charCodeAt(c), e >= 48 && e <= 57); c++);
  1021. c == L && P(),
  1022. L = c
  1023. }
  1024. return + f.slice(b, L)
  1025. }
  1026. if (d && P(), "true" == f.slice(L, L + 4)) return L += 4,
  1027. !0;
  1028. if ("false" == f.slice(L, L + 5)) return L += 5,
  1029. !1;
  1030. if ("null" == f.slice(L, L + 4)) return L += 4,
  1031. null;
  1032. P()
  1033. }
  1034. return "$"
  1035. },
  1036. R = function(a) {
  1037. var b, c;
  1038. if ("$" == a && P(), "string" == typeof a) {
  1039. if ("@" == (B ? a.charAt(0) : a[0])) return a.slice(1);
  1040. if ("[" == a) {
  1041. for (b = []; a = Q(), "]" != a; c || (c = !0)) c && ("," == a ? (a = Q(), "]" == a && P()) : P()),
  1042. "," == a && P(),
  1043. b.push(R(a));
  1044. return b
  1045. }
  1046. if ("{" == a) {
  1047. for (b = {}; a = Q(), "}" != a; c || (c = !0)) c && ("," == a ? (a = Q(), "}" == a && P()) : P()),
  1048. "," != a && "string" == typeof a && "@" == (B ? a.charAt(0) : a[0]) && ":" == Q() || P(),
  1049. b[a.slice(1)] = R(Q());
  1050. return b
  1051. }
  1052. P()
  1053. }
  1054. return a
  1055. },
  1056. S = function(a, b, c) {
  1057. var d = T(a, b, c);
  1058. d === q ? delete a[b] : a[b] = d
  1059. },
  1060. T = function(a, b, c) {
  1061. var d, e = a[b];
  1062. if ("object" == typeof e && e) if (s.call(e) == z) for (d = e.length; d--;) S(e, d, c);
  1063. else p(e,
  1064. function(a) {
  1065. S(e, a, c)
  1066. });
  1067. return c.call(a, b, e)
  1068. };
  1069. b.parse = function(a, b) {
  1070. var c, d;
  1071. return L = 0,
  1072. M = "" + a,
  1073. c = R(Q()),
  1074. "$" != Q() && P(),
  1075. L = M = null,
  1076. b && s.call(b) == v ? T((d = {},
  1077. d[""] = c, d), "", b) : c
  1078. }
  1079. }
  1080. }
  1081. return b.runInContext = e,
  1082. b
  1083. }
  1084. var f = "function" == typeof d && d.amd,
  1085. g = {
  1086. "function": !0,
  1087. object: !0
  1088. },
  1089. h = g[typeof b] && b && !b.nodeType && b,
  1090. i = g[typeof window] && window || this,
  1091. j = h && g[typeof a] && a && !a.nodeType && "object" == typeof c && c;
  1092. if (!j || j.global !== j && j.window !== j && j.self !== j || (i = j), h && !f) e(i, h);
  1093. else {
  1094. var k = i.JSON,
  1095. l = i.JSON3,
  1096. m = !1,
  1097. n = e(i, i.JSON3 = {
  1098. noConflict: function() {
  1099. return m || (m = !0, i.JSON = k, i.JSON3 = l, k = l = null),
  1100. n
  1101. }
  1102. });
  1103. i.JSON = {
  1104. parse: n.parse,
  1105. stringify: n.stringify
  1106. }
  1107. }
  1108. f && d(function() {
  1109. return n
  1110. })
  1111. }).call(this)
  1112. }).call(b, c(12)(a),
  1113. function() {
  1114. return this
  1115. } ())
  1116. },
  1117. function(a, b) {
  1118. a.exports = function(a) {
  1119. return a.webpackPolyfill || (a.deprecate = function() {},
  1120. a.paths = [], a.children = [], a.webpackPolyfill = 1),
  1121. a
  1122. }
  1123. },
  1124. function(a, b) {
  1125. function c(a) {
  1126. if (a) return d(a)
  1127. }
  1128. function d(a) {
  1129. for (var b in c.prototype) a[b] = c.prototype[b];
  1130. return a
  1131. }
  1132. a.exports = c,
  1133. c.prototype.on = c.prototype.addEventListener = function(a, b) {
  1134. return this._callbacks = this._callbacks || {},
  1135. (this._callbacks[a] = this._callbacks[a] || []).push(b),
  1136. this
  1137. },
  1138. c.prototype.once = function(a, b) {
  1139. function c() {
  1140. d.off(a, c),
  1141. b.apply(this, arguments)
  1142. }
  1143. var d = this;
  1144. return this._callbacks = this._callbacks || {},
  1145. c.fn = b,
  1146. this.on(a, c),
  1147. this
  1148. },
  1149. c.prototype.off = c.prototype.removeListener = c.prototype.removeAllListeners = c.prototype.removeEventListener = function(a, b) {
  1150. if (this._callbacks = this._callbacks || {},
  1151. 0 == arguments.length) return this._callbacks = {},
  1152. this;
  1153. var c = this._callbacks[a];
  1154. if (!c) return this;
  1155. if (1 == arguments.length) return delete this._callbacks[a],
  1156. this;
  1157. for (var d, e = 0; e < c.length; e++) if (d = c[e], d === b || d.fn === b) {
  1158. c.splice(e, 1);
  1159. break
  1160. }
  1161. return this
  1162. },
  1163. c.prototype.emit = function(a) {
  1164. this._callbacks = this._callbacks || {};
  1165. var b = [].slice.call(arguments, 1),
  1166. c = this._callbacks[a];
  1167. if (c) {
  1168. c = c.slice(0);
  1169. for (var d = 0,
  1170. e = c.length; d < e; ++d) c[d].apply(this, b)
  1171. }
  1172. return this
  1173. },
  1174. c.prototype.listeners = function(a) {
  1175. return this._callbacks = this._callbacks || {},
  1176. this._callbacks[a] || []
  1177. },
  1178. c.prototype.hasListeners = function(a) {
  1179. return !! this.listeners(a).length
  1180. }
  1181. },
  1182. function(a, b, c) { (function(a) {
  1183. var d = c(15),
  1184. e = c(16);
  1185. b.deconstructPacket = function(a) {
  1186. function b(a) {
  1187. if (!a) return a;
  1188. if (e(a)) {
  1189. var f = {
  1190. _placeholder: !0,
  1191. num: c.length
  1192. };
  1193. return c.push(a),
  1194. f
  1195. }
  1196. if (d(a)) {
  1197. for (var g = new Array(a.length), h = 0; h < a.length; h++) g[h] = b(a[h]);
  1198. return g
  1199. }
  1200. if ("object" == typeof a && !(a instanceof Date)) {
  1201. var g = {};
  1202. for (var i in a) g[i] = b(a[i]);
  1203. return g
  1204. }
  1205. return a
  1206. }
  1207. var c = [],
  1208. f = a.data,
  1209. g = a;
  1210. return g.data = b(f),
  1211. g.attachments = c.length,
  1212. {
  1213. packet: g,
  1214. buffers: c
  1215. }
  1216. },
  1217. b.reconstructPacket = function(a, b) {
  1218. function c(a) {
  1219. if (a && a._placeholder) {
  1220. var e = b[a.num];
  1221. return e
  1222. }
  1223. if (d(a)) {
  1224. for (var f = 0; f < a.length; f++) a[f] = c(a[f]);
  1225. return a
  1226. }
  1227. if (a && "object" == typeof a) {
  1228. for (var g in a) a[g] = c(a[g]);
  1229. return a
  1230. }
  1231. return a
  1232. }
  1233. return a.data = c(a.data),
  1234. a.attachments = void 0,
  1235. a
  1236. },
  1237. b.removeBlobs = function(b, c) {
  1238. function f(b, i, j) {
  1239. if (!b) return b;
  1240. if (a.Blob && b instanceof Blob || a.File && b instanceof File) {
  1241. g++;
  1242. var k = new FileReader;
  1243. k.onload = function() {
  1244. j ? j[i] = this.result: h = this.result,
  1245. --g || c(h)
  1246. },
  1247. k.readAsArrayBuffer(b)
  1248. } else if (d(b)) for (var l = 0; l < b.length; l++) f(b[l], l, b);
  1249. else if (b && "object" == typeof b && !e(b)) for (var m in b) f(b[m], m, b)
  1250. }
  1251. var g = 0,
  1252. h = b;
  1253. f(h),
  1254. g || c(h)
  1255. }
  1256. }).call(b,
  1257. function() {
  1258. return this
  1259. } ())
  1260. },
  1261. function(a, b) {
  1262. a.exports = Array.isArray ||
  1263. function(a) {
  1264. return "[object Array]" == Object.prototype.toString.call(a)
  1265. }
  1266. },
  1267. function(a, b) { (function(b) {
  1268. function c(a) {
  1269. return b.Buffer && b.Buffer.isBuffer(a) || b.ArrayBuffer && a instanceof ArrayBuffer
  1270. }
  1271. a.exports = c
  1272. }).call(b,
  1273. function() {
  1274. return this
  1275. } ())
  1276. },
  1277. function(a, b, c) {
  1278. "use strict";
  1279. function d(a, b) {
  1280. return this instanceof d ? (a && "object" === ("undefined" == typeof a ? "undefined": e(a)) && (b = a, a = void 0), b = b || {},
  1281. b.path = b.path || "/socket.io", this.nsps = {},
  1282. this.subs = [], this.opts = b, this.reconnection(b.reconnection !== !1), this.reconnectionAttempts(b.reconnectionAttempts || 1 / 0), this.reconnectionDelay(b.reconnectionDelay || 1e3), this.reconnectionDelayMax(b.reconnectionDelayMax || 5e3), this.randomizationFactor(b.randomizationFactor || .5), this.backoff = new n({
  1283. min: this.reconnectionDelay(),
  1284. max: this.reconnectionDelayMax(),
  1285. jitter: this.randomizationFactor()
  1286. }), this.timeout(null == b.timeout ? 2e4: b.timeout), this.readyState = "closed", this.uri = a, this.connecting = [], this.lastPing = null, this.encoding = !1, this.packetBuffer = [], this.encoder = new i.Encoder, this.decoder = new i.Decoder, this.autoConnect = b.autoConnect !== !1, void(this.autoConnect && this.open())) : new d(a, b)
  1287. }
  1288. var e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  1289. function(a) {
  1290. return typeof a
  1291. }: function(a) {
  1292. return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol": typeof a
  1293. },
  1294. f = c(18),
  1295. g = c(44),
  1296. h = c(35),
  1297. i = c(7),
  1298. j = c(46),
  1299. k = c(47),
  1300. l = c(3)("socket.io-client:manager"),
  1301. m = c(42),
  1302. n = c(48),
  1303. o = Object.prototype.hasOwnProperty;
  1304. a.exports = d,
  1305. d.prototype.emitAll = function() {
  1306. this.emit.apply(this, arguments);
  1307. for (var a in this.nsps) o.call(this.nsps, a) && this.nsps[a].emit.apply(this.nsps[a], arguments)
  1308. },
  1309. d.prototype.updateSocketIds = function() {
  1310. for (var a in this.nsps) o.call(this.nsps, a) && (this.nsps[a].id = this.engine.id)
  1311. },
  1312. h(d.prototype),
  1313. d.prototype.reconnection = function(a) {
  1314. return arguments.length ? (this._reconnection = !!a, this) : this._reconnection
  1315. },
  1316. d.prototype.reconnectionAttempts = function(a) {
  1317. return arguments.length ? (this._reconnectionAttempts = a, this) : this._reconnectionAttempts
  1318. },
  1319. d.prototype.reconnectionDelay = function(a) {
  1320. return arguments.length ? (this._reconnectionDelay = a, this.backoff && this.backoff.setMin(a), this) : this._reconnectionDelay
  1321. },
  1322. d.prototype.randomizationFactor = function(a) {
  1323. return arguments.length ? (this._randomizationFactor = a, this.backoff && this.backoff.setJitter(a), this) : this._randomizationFactor
  1324. },
  1325. d.prototype.reconnectionDelayMax = function(a) {
  1326. return arguments.length ? (this._reconnectionDelayMax = a, this.backoff && this.backoff.setMax(a), this) : this._reconnectionDelayMax
  1327. },
  1328. d.prototype.timeout = function(a) {
  1329. return arguments.length ? (this._timeout = a, this) : this._timeout
  1330. },
  1331. d.prototype.maybeReconnectOnOpen = function() { ! this.reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect()
  1332. },
  1333. d.prototype.open = d.prototype.connect = function(a, b) {
  1334. if (l("readyState %s", this.readyState), ~this.readyState.indexOf("open")) return this;
  1335. l("opening %s", this.uri),
  1336. this.engine = f(this.uri, this.opts);
  1337. var c = this.engine,
  1338. d = this;
  1339. this.readyState = "opening",
  1340. this.skipReconnect = !1;
  1341. var e = j(c, "open",
  1342. function() {
  1343. d.onopen(),
  1344. a && a()
  1345. }),
  1346. g = j(c, "error",
  1347. function(b) {
  1348. if (l("connect_error"), d.cleanup(), d.readyState = "closed", d.emitAll("connect_error", b), a) {
  1349. var c = new Error("Connection error");
  1350. c.data = b,
  1351. a(c)
  1352. } else d.maybeReconnectOnOpen()
  1353. });
  1354. if (!1 !== this._timeout) {
  1355. var h = this._timeout;
  1356. l("connect attempt will timeout after %d", h);
  1357. var i = setTimeout(function() {
  1358. l("connect attempt timed out after %d", h),
  1359. e.destroy(),
  1360. c.close(),
  1361. c.emit("error", "timeout"),
  1362. d.emitAll("connect_timeout", h)
  1363. },
  1364. h);
  1365. this.subs.push({
  1366. destroy: function() {
  1367. clearTimeout(i)
  1368. }
  1369. })
  1370. }
  1371. return this.subs.push(e),
  1372. this.subs.push(g),
  1373. this
  1374. },
  1375. d.prototype.onopen = function() {
  1376. l("open"),
  1377. this.cleanup(),
  1378. this.readyState = "open",
  1379. this.emit("open");
  1380. var a = this.engine;
  1381. this.subs.push(j(a, "data", k(this, "ondata"))),
  1382. this.subs.push(j(a, "ping", k(this, "onping"))),
  1383. this.subs.push(j(a, "pong", k(this, "onpong"))),
  1384. this.subs.push(j(a, "error", k(this, "onerror"))),
  1385. this.subs.push(j(a, "close", k(this, "onclose"))),
  1386. this.subs.push(j(this.decoder, "decoded", k(this, "ondecoded")))
  1387. },
  1388. d.prototype.onping = function() {
  1389. this.lastPing = new Date,
  1390. this.emitAll("ping")
  1391. },
  1392. d.prototype.onpong = function() {
  1393. this.emitAll("pong", new Date - this.lastPing)
  1394. },
  1395. d.prototype.ondata = function(a) {
  1396. this.decoder.add(a)
  1397. },
  1398. d.prototype.ondecoded = function(a) {
  1399. this.emit("packet", a)
  1400. },
  1401. d.prototype.onerror = function(a) {
  1402. l("error", a),
  1403. this.emitAll("error", a)
  1404. },
  1405. d.prototype.socket = function(a, b) {
  1406. function c() {~m(e.connecting, d) || e.connecting.push(d)
  1407. }
  1408. var d = this.nsps[a];
  1409. if (!d) {
  1410. d = new g(this, a, b),
  1411. this.nsps[a] = d;
  1412. var e = this;
  1413. d.on("connecting", c),
  1414. d.on("connect",
  1415. function() {
  1416. d.id = e.engine.id
  1417. }),
  1418. this.autoConnect && c()
  1419. }
  1420. return d
  1421. },
  1422. d.prototype.destroy = function(a) {
  1423. var b = m(this.connecting, a);~b && this.connecting.splice(b, 1),
  1424. this.connecting.length || this.close()
  1425. },
  1426. d.prototype.packet = function(a) {
  1427. l("writing packet %j", a);
  1428. var b = this;
  1429. a.query && 0 === a.type && (a.nsp += "?" + a.query),
  1430. b.encoding ? b.packetBuffer.push(a) : (b.encoding = !0, this.encoder.encode(a,
  1431. function(c) {
  1432. for (var d = 0; d < c.length; d++) b.engine.write(c[d], a.options);
  1433. b.encoding = !1,
  1434. b.processPacketQueue()
  1435. }))
  1436. },
  1437. d.prototype.processPacketQueue = function() {
  1438. if (this.packetBuffer.length > 0 && !this.encoding) {
  1439. var a = this.packetBuffer.shift();
  1440. this.packet(a)
  1441. }
  1442. },
  1443. d.prototype.cleanup = function() {
  1444. l("cleanup");
  1445. for (var a = this.subs.length,
  1446. b = 0; b < a; b++) {
  1447. var c = this.subs.shift();
  1448. c.destroy()
  1449. }
  1450. this.packetBuffer = [],
  1451. this.encoding = !1,
  1452. this.lastPing = null,
  1453. this.decoder.destroy()
  1454. },
  1455. d.prototype.close = d.prototype.disconnect = function() {
  1456. l("disconnect"),
  1457. this.skipReconnect = !0,
  1458. this.reconnecting = !1,
  1459. "opening" === this.readyState && this.cleanup(),
  1460. this.backoff.reset(),
  1461. this.readyState = "closed",
  1462. this.engine && this.engine.close()
  1463. },
  1464. d.prototype.onclose = function(a) {
  1465. l("onclose"),
  1466. this.cleanup(),
  1467. this.backoff.reset(),
  1468. this.readyState = "closed",
  1469. this.emit("close", a),
  1470. this._reconnection && !this.skipReconnect && this.reconnect()
  1471. },
  1472. d.prototype.reconnect = function() {
  1473. if (this.reconnecting || this.skipReconnect) return this;
  1474. var a = this;
  1475. if (this.backoff.attempts >= this._reconnectionAttempts) l("reconnect failed"),
  1476. this.backoff.reset(),
  1477. this.emitAll("reconnect_failed"),
  1478. this.reconnecting = !1;
  1479. else {
  1480. var b = this.backoff.duration();
  1481. l("will wait %dms before reconnect attempt", b),
  1482. this.reconnecting = !0;
  1483. var c = setTimeout(function() {
  1484. a.skipReconnect || (l("attempting reconnect"), a.emitAll("reconnect_attempt", a.backoff.attempts), a.emitAll("reconnecting", a.backoff.attempts), a.skipReconnect || a.open(function(b) {
  1485. b ? (l("reconnect attempt error"), a.reconnecting = !1, a.reconnect(), a.emitAll("reconnect_error", b.data)) : (l("reconnect success"), a.onreconnect())
  1486. }))
  1487. },
  1488. b);
  1489. this.subs.push({
  1490. destroy: function() {
  1491. clearTimeout(c)
  1492. }
  1493. })
  1494. }
  1495. },
  1496. d.prototype.onreconnect = function() {
  1497. var a = this.backoff.attempts;
  1498. this.reconnecting = !1,
  1499. this.backoff.reset(),
  1500. this.updateSocketIds(),
  1501. this.emitAll("reconnect", a)
  1502. }
  1503. },
  1504. function(a, b, c) {
  1505. a.exports = c(19)
  1506. },
  1507. function(a, b, c) {
  1508. a.exports = c(20),
  1509. a.exports.parser = c(27)
  1510. },
  1511. function(a, b, c) { (function(b) {
  1512. function d(a, c) {
  1513. if (! (this instanceof d)) return new d(a, c);
  1514. c = c || {},
  1515. a && "object" == typeof a && (c = a, a = null),
  1516. a ? (a = k(a), c.hostname = a.host, c.secure = "https" === a.protocol || "wss" === a.protocol, c.port = a.port, a.query && (c.query = a.query)) : c.host && (c.hostname = k(c.host).host),
  1517. this.secure = null != c.secure ? c.secure: b.location && "https:" === location.protocol,
  1518. c.hostname && !c.port && (c.port = this.secure ? "443": "80"),
  1519. this.agent = c.agent || !1,
  1520. this.hostname = c.hostname || (b.location ? location.hostname: "localhost"),
  1521. this.port = c.port || (b.location && location.port ? location.port: this.secure ? 443 : 80),
  1522. this.query = c.query || {},
  1523. "string" == typeof this.query && (this.query = m.decode(this.query)),
  1524. this.upgrade = !1 !== c.upgrade,
  1525. this.path = (c.path || "/engine.io").replace(/\/$/, "") + "/",
  1526. this.forceJSONP = !!c.forceJSONP,
  1527. this.jsonp = !1 !== c.jsonp,
  1528. this.forceBase64 = !!c.forceBase64,
  1529. this.enablesXDR = !!c.enablesXDR,
  1530. this.timestampParam = c.timestampParam || "t",
  1531. this.timestampRequests = c.timestampRequests,
  1532. this.transports = c.transports || ["polling", "websocket"],
  1533. this.readyState = "",
  1534. this.writeBuffer = [],
  1535. this.prevBufferLen = 0,
  1536. this.policyPort = c.policyPort || 843,
  1537. this.rememberUpgrade = c.rememberUpgrade || !1,
  1538. this.binaryType = null,
  1539. this.onlyBinaryUpgrades = c.onlyBinaryUpgrades,
  1540. this.perMessageDeflate = !1 !== c.perMessageDeflate && (c.perMessageDeflate || {}),
  1541. !0 === this.perMessageDeflate && (this.perMessageDeflate = {}),
  1542. this.perMessageDeflate && null == this.perMessageDeflate.threshold && (this.perMessageDeflate.threshold = 1024),
  1543. this.pfx = c.pfx || null,
  1544. this.key = c.key || null,
  1545. this.passphrase = c.passphrase || null,
  1546. this.cert = c.cert || null,
  1547. this.ca = c.ca || null,
  1548. this.ciphers = c.ciphers || null,
  1549. this.rejectUnauthorized = void 0 === c.rejectUnauthorized ? null: c.rejectUnauthorized,
  1550. this.forceNode = !!c.forceNode;
  1551. var e = "object" == typeof b && b;
  1552. e.global === e && (c.extraHeaders && Object.keys(c.extraHeaders).length > 0 && (this.extraHeaders = c.extraHeaders), c.localAddress && (this.localAddress = c.localAddress)),
  1553. this.id = null,
  1554. this.upgrades = null,
  1555. this.pingInterval = null,
  1556. this.pingTimeout = null,
  1557. this.pingIntervalTimer = null,
  1558. this.pingTimeoutTimer = null,
  1559. this.open()
  1560. }
  1561. function e(a) {
  1562. var b = {};
  1563. for (var c in a) a.hasOwnProperty(c) && (b[c] = a[c]);
  1564. return b
  1565. }
  1566. var f = c(21),
  1567. g = c(35),
  1568. h = c(3)("engine.io-client:socket"),
  1569. i = c(42),
  1570. j = c(27),
  1571. k = c(2),
  1572. l = c(43),
  1573. m = c(36);
  1574. a.exports = d,
  1575. d.priorWebsocketSuccess = !1,
  1576. g(d.prototype),
  1577. d.protocol = j.protocol,
  1578. d.Socket = d,
  1579. d.Transport = c(26),
  1580. d.transports = c(21),
  1581. d.parser = c(27),
  1582. d.prototype.createTransport = function(a) {
  1583. h('creating transport "%s"', a);
  1584. var b = e(this.query);
  1585. b.EIO = j.protocol,
  1586. b.transport = a,
  1587. this.id && (b.sid = this.id);
  1588. var c = new f[a]({
  1589. agent: this.agent,
  1590. hostname: this.hostname,
  1591. port: this.port,
  1592. secure: this.secure,
  1593. path: this.path,
  1594. query: b,
  1595. forceJSONP: this.forceJSONP,
  1596. jsonp: this.jsonp,
  1597. forceBase64: this.forceBase64,
  1598. enablesXDR: this.enablesXDR,
  1599. timestampRequests: this.timestampRequests,
  1600. timestampParam: this.timestampParam,
  1601. policyPort: this.policyPort,
  1602. socket: this,
  1603. pfx: this.pfx,
  1604. key: this.key,
  1605. passphrase: this.passphrase,
  1606. cert: this.cert,
  1607. ca: this.ca,
  1608. ciphers: this.ciphers,
  1609. rejectUnauthorized: this.rejectUnauthorized,
  1610. perMessageDeflate: this.perMessageDeflate,
  1611. extraHeaders: this.extraHeaders,
  1612. forceNode: this.forceNode,
  1613. localAddress: this.localAddress
  1614. });
  1615. return c
  1616. },
  1617. d.prototype.open = function() {
  1618. var a;
  1619. if (this.rememberUpgrade && d.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) a = "websocket";
  1620. else {
  1621. if (0 === this.transports.length) {
  1622. var b = this;
  1623. return void setTimeout(function() {
  1624. b.emit("error", "No transports available")
  1625. },
  1626. 0)
  1627. }
  1628. a = this.transports[0]
  1629. }
  1630. this.readyState = "opening";
  1631. try {
  1632. a = this.createTransport(a)
  1633. } catch(c) {
  1634. return this.transports.shift(),
  1635. void this.open()
  1636. }
  1637. a.open(),
  1638. this.setTransport(a)
  1639. },
  1640. d.prototype.setTransport = function(a) {
  1641. h("setting transport %s", a.name);
  1642. var b = this;
  1643. this.transport && (h("clearing existing transport %s", this.transport.name), this.transport.removeAllListeners()),
  1644. this.transport = a,
  1645. a.on("drain",
  1646. function() {
  1647. b.onDrain()
  1648. }).on("packet",
  1649. function(a) {
  1650. b.onPacket(a)
  1651. }).on("error",
  1652. function(a) {
  1653. b.onError(a)
  1654. }).on("close",
  1655. function() {
  1656. b.onClose("transport close")
  1657. })
  1658. },
  1659. d.prototype.probe = function(a) {
  1660. function b() {
  1661. if (m.onlyBinaryUpgrades) {
  1662. var b = !this.supportsBinary && m.transport.supportsBinary;
  1663. l = l || b
  1664. }
  1665. l || (h('probe transport "%s" opened', a), k.send([{
  1666. type: "ping",
  1667. data: "probe"
  1668. }]), k.once("packet",
  1669. function(b) {
  1670. if (!l) if ("pong" === b.type && "probe" === b.data) {
  1671. if (h('probe transport "%s" pong', a), m.upgrading = !0, m.emit("upgrading", k), !k) return;
  1672. d.priorWebsocketSuccess = "websocket" === k.name,
  1673. h('pausing current transport "%s"', m.transport.name),
  1674. m.transport.pause(function() {
  1675. l || "closed" !== m.readyState && (h("changing transport and sending upgrade packet"), j(), m.setTransport(k), k.send([{
  1676. type: "upgrade"
  1677. }]), m.emit("upgrade", k), k = null, m.upgrading = !1, m.flush())
  1678. })
  1679. } else {
  1680. h('probe transport "%s" failed', a);
  1681. var c = new Error("probe error");
  1682. c.transport = k.name,
  1683. m.emit("upgradeError", c)
  1684. }
  1685. }))
  1686. }
  1687. function c() {
  1688. l || (l = !0, j(), k.close(), k = null)
  1689. }
  1690. function e(b) {
  1691. var d = new Error("probe error: " + b);
  1692. d.transport = k.name,
  1693. c(),
  1694. h('probe transport "%s" failed because of error: %s', a, b),
  1695. m.emit("upgradeError", d)
  1696. }
  1697. function f() {
  1698. e("transport closed")
  1699. }
  1700. function g() {
  1701. e("socket closed")
  1702. }
  1703. function i(a) {
  1704. k && a.name !== k.name && (h('"%s" works - aborting "%s"', a.name, k.name), c())
  1705. }
  1706. function j() {
  1707. k.removeListener("open", b),
  1708. k.removeListener("error", e),
  1709. k.removeListener("close", f),
  1710. m.removeListener("close", g),
  1711. m.removeListener("upgrading", i)
  1712. }
  1713. h('probing transport "%s"', a);
  1714. var k = this.createTransport(a, {
  1715. probe: 1
  1716. }),
  1717. l = !1,
  1718. m = this;
  1719. d.priorWebsocketSuccess = !1,
  1720. k.once("open", b),
  1721. k.once("error", e),
  1722. k.once("close", f),
  1723. this.once("close", g),
  1724. this.once("upgrading", i),
  1725. k.open()
  1726. },
  1727. d.prototype.onOpen = function() {
  1728. if (h("socket open"), this.readyState = "open", d.priorWebsocketSuccess = "websocket" === this.transport.name, this.emit("open"), this.flush(), "open" === this.readyState && this.upgrade && this.transport.pause) {
  1729. h("starting upgrade probes");
  1730. for (var a = 0,
  1731. b = this.upgrades.length; a < b; a++) this.probe(this.upgrades[a])
  1732. }
  1733. },
  1734. d.prototype.onPacket = function(a) {
  1735. if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) switch (h('socket receive: type "%s", data "%s"', a.type, a.data), this.emit("packet", a), this.emit("heartbeat"), a.type) {
  1736. case "open":
  1737. this.onHandshake(l(a.data));
  1738. break;
  1739. case "pong":
  1740. this.setPing(),
  1741. this.emit("pong");
  1742. break;
  1743. case "error":
  1744. var b = new Error("server error");
  1745. b.code = a.data,
  1746. this.onError(b);
  1747. break;
  1748. case "message":
  1749. this.emit("data", a.data),
  1750. this.emit("message", a.data)
  1751. } else h('packet received with socket readyState "%s"', this.readyState)
  1752. },
  1753. d.prototype.onHandshake = function(a) {
  1754. this.emit("handshake", a),
  1755. this.id = a.sid,
  1756. this.transport.query.sid = a.sid,
  1757. this.upgrades = this.filterUpgrades(a.upgrades),
  1758. this.pingInterval = a.pingInterval,
  1759. this.pingTimeout = a.pingTimeout,
  1760. this.onOpen(),
  1761. "closed" !== this.readyState && (this.setPing(), this.removeListener("heartbeat", this.onHeartbeat), this.on("heartbeat", this.onHeartbeat))
  1762. },
  1763. d.prototype.onHeartbeat = function(a) {
  1764. clearTimeout(this.pingTimeoutTimer);
  1765. var b = this;
  1766. b.pingTimeoutTimer = setTimeout(function() {
  1767. "closed" !== b.readyState && b.onClose("ping timeout")
  1768. },
  1769. a || b.pingInterval + b.pingTimeout)
  1770. },
  1771. d.prototype.setPing = function() {
  1772. var a = this;
  1773. clearTimeout(a.pingIntervalTimer),
  1774. a.pingIntervalTimer = setTimeout(function() {
  1775. h("writing ping packet - expecting pong within %sms", a.pingTimeout),
  1776. a.ping(),
  1777. a.onHeartbeat(a.pingTimeout)
  1778. },
  1779. a.pingInterval)
  1780. },
  1781. d.prototype.ping = function() {
  1782. var a = this;
  1783. this.sendPacket("ping",
  1784. function() {
  1785. a.emit("ping")
  1786. })
  1787. },
  1788. d.prototype.onDrain = function() {
  1789. this.writeBuffer.splice(0, this.prevBufferLen),
  1790. this.prevBufferLen = 0,
  1791. 0 === this.writeBuffer.length ? this.emit("drain") : this.flush()
  1792. },
  1793. d.prototype.flush = function() {
  1794. "closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length && (h("flushing %d packets in socket", this.writeBuffer.length), this.transport.send(this.writeBuffer), this.prevBufferLen = this.writeBuffer.length, this.emit("flush"))
  1795. },
  1796. d.prototype.write = d.prototype.send = function(a, b, c) {
  1797. return this.sendPacket("message", a, b, c),
  1798. this
  1799. },
  1800. d.prototype.sendPacket = function(a, b, c, d) {
  1801. if ("function" == typeof b && (d = b, b = void 0), "function" == typeof c && (d = c, c = null), "closing" !== this.readyState && "closed" !== this.readyState) {
  1802. c = c || {},
  1803. c.compress = !1 !== c.compress;
  1804. var e = {
  1805. type: a,
  1806. data: b,
  1807. options: c
  1808. };
  1809. this.emit("packetCreate", e),
  1810. this.writeBuffer.push(e),
  1811. d && this.once("flush", d),
  1812. this.flush()
  1813. }
  1814. },
  1815. d.prototype.close = function() {
  1816. function a() {
  1817. d.onClose("forced close"),
  1818. h("socket closing - telling transport to close"),
  1819. d.transport.close()
  1820. }
  1821. function b() {
  1822. d.removeListener("upgrade", b),
  1823. d.removeListener("upgradeError", b),
  1824. a()
  1825. }
  1826. function c() {
  1827. d.once("upgrade", b),
  1828. d.once("upgradeError", b)
  1829. }
  1830. if ("opening" === this.readyState || "open" === this.readyState) {
  1831. this.readyState = "closing";
  1832. var d = this;
  1833. this.writeBuffer.length ? this.once("drain",
  1834. function() {
  1835. this.upgrading ? c() : a()
  1836. }) : this.upgrading ? c() : a()
  1837. }
  1838. return this
  1839. },
  1840. d.prototype.onError = function(a) {
  1841. h("socket error %j", a),
  1842. d.priorWebsocketSuccess = !1,
  1843. this.emit("error", a),
  1844. this.onClose("transport error", a)
  1845. },
  1846. d.prototype.onClose = function(a, b) {
  1847. if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
  1848. h('socket close with reason: "%s"', a);
  1849. var c = this;
  1850. clearTimeout(this.pingIntervalTimer),
  1851. clearTimeout(this.pingTimeoutTimer),
  1852. this.transport.removeAllListeners("close"),
  1853. this.transport.close(),
  1854. this.transport.removeAllListeners(),
  1855. this.readyState = "closed",
  1856. this.id = null,
  1857. this.emit("close", a, b),
  1858. c.writeBuffer = [],
  1859. c.prevBufferLen = 0
  1860. }
  1861. },
  1862. d.prototype.filterUpgrades = function(a) {
  1863. for (var b = [], c = 0, d = a.length; c < d; c++)~i(this.transports, a[c]) && b.push(a[c]);
  1864. return b
  1865. }
  1866. }).call(b,
  1867. function() {
  1868. return this
  1869. } ())
  1870. },
  1871. function(a, b, c) { (function(a) {
  1872. function d(b) {
  1873. var c, d = !1,
  1874. h = !1,
  1875. i = !1 !== b.jsonp;
  1876. if (a.location) {
  1877. var j = "https:" === location.protocol,
  1878. k = location.port;
  1879. k || (k = j ? 443 : 80),
  1880. d = b.hostname !== location.hostname || k !== b.port,
  1881. h = b.secure !== j
  1882. }
  1883. if (b.xdomain = d, b.xscheme = h, c = new e(b), "open" in c && !b.forceJSONP) return new f(b);
  1884. if (!i) throw new Error("JSONP disabled");
  1885. return new g(b)
  1886. }
  1887. var e = c(22),
  1888. f = c(24),
  1889. g = c(39),
  1890. h = c(40);
  1891. b.polling = d,
  1892. b.websocket = h
  1893. }).call(b,
  1894. function() {
  1895. return this
  1896. } ())
  1897. },
  1898. function(a, b, c) { (function(b) {
  1899. var d = c(23);
  1900. a.exports = function(a) {
  1901. var c = a.xdomain,
  1902. e = a.xscheme,
  1903. f = a.enablesXDR;
  1904. try {
  1905. if ("undefined" != typeof XMLHttpRequest && (!c || d)) return new XMLHttpRequest
  1906. } catch(g) {}
  1907. try {
  1908. if ("undefined" != typeof XDomainRequest && !e && f) return new XDomainRequest
  1909. } catch(g) {}
  1910. if (!c) try {
  1911. return new(b[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")
  1912. } catch(g) {}
  1913. }
  1914. }).call(b,
  1915. function() {
  1916. return this
  1917. } ())
  1918. },
  1919. function(a, b) {
  1920. try {
  1921. a.exports = "undefined" != typeof XMLHttpRequest && "withCredentials" in new XMLHttpRequest
  1922. } catch(c) {
  1923. a.exports = !1
  1924. }
  1925. },
  1926. function(a, b, c) { (function(b) {
  1927. function d() {}
  1928. function e(a) {
  1929. if (i.call(this, a), this.requestTimeout = a.requestTimeout, b.location) {
  1930. var c = "https:" === location.protocol,
  1931. d = location.port;
  1932. d || (d = c ? 443 : 80),
  1933. this.xd = a.hostname !== b.location.hostname || d !== a.port,
  1934. this.xs = a.secure !== c
  1935. } else this.extraHeaders = a.extraHeaders
  1936. }
  1937. function f(a) {
  1938. this.method = a.method || "GET",
  1939. this.uri = a.uri,
  1940. this.xd = !!a.xd,
  1941. this.xs = !!a.xs,
  1942. this.async = !1 !== a.async,
  1943. this.data = void 0 !== a.data ? a.data: null,
  1944. this.agent = a.agent,
  1945. this.isBinary = a.isBinary,
  1946. this.supportsBinary = a.supportsBinary,
  1947. this.enablesXDR = a.enablesXDR,
  1948. this.requestTimeout = a.requestTimeout,
  1949. this.pfx = a.pfx,
  1950. this.key = a.key,
  1951. this.passphrase = a.passphrase,
  1952. this.cert = a.cert,
  1953. this.ca = a.ca,
  1954. this.ciphers = a.ciphers,
  1955. this.rejectUnauthorized = a.rejectUnauthorized,
  1956. this.extraHeaders = a.extraHeaders,
  1957. this.create()
  1958. }
  1959. function g() {
  1960. for (var a in f.requests) f.requests.hasOwnProperty(a) && f.requests[a].abort()
  1961. }
  1962. var h = c(22),
  1963. i = c(25),
  1964. j = c(35),
  1965. k = c(37),
  1966. l = c(3)("engine.io-client:polling-xhr");
  1967. a.exports = e,
  1968. a.exports.Request = f,
  1969. k(e, i),
  1970. e.prototype.supportsBinary = !0,
  1971. e.prototype.request = function(a) {
  1972. return a = a || {},
  1973. a.uri = this.uri(),
  1974. a.xd = this.xd,
  1975. a.xs = this.xs,
  1976. a.agent = this.agent || !1,
  1977. a.supportsBinary = this.supportsBinary,
  1978. a.enablesXDR = this.enablesXDR,
  1979. a.pfx = this.pfx,
  1980. a.key = this.key,
  1981. a.passphrase = this.passphrase,
  1982. a.cert = this.cert,
  1983. a.ca = this.ca,
  1984. a.ciphers = this.ciphers,
  1985. a.rejectUnauthorized = this.rejectUnauthorized,
  1986. a.requestTimeout = this.requestTimeout,
  1987. a.extraHeaders = this.extraHeaders,
  1988. new f(a)
  1989. },
  1990. e.prototype.doWrite = function(a, b) {
  1991. var c = "string" != typeof a && void 0 !== a,
  1992. d = this.request({
  1993. method: "POST",
  1994. data: a,
  1995. isBinary: c
  1996. }),
  1997. e = this;
  1998. d.on("success", b),
  1999. d.on("error",
  2000. function(a) {
  2001. e.onError("xhr post error", a)
  2002. }),
  2003. this.sendXhr = d
  2004. },
  2005. e.prototype.doPoll = function() {
  2006. l("xhr poll");
  2007. var a = this.request(),
  2008. b = this;
  2009. a.on("data",
  2010. function(a) {
  2011. b.onData(a)
  2012. }),
  2013. a.on("error",
  2014. function(a) {
  2015. b.onError("xhr poll error", a)
  2016. }),
  2017. this.pollXhr = a
  2018. },
  2019. j(f.prototype),
  2020. f.prototype.create = function() {
  2021. var a = {
  2022. agent: this.agent,
  2023. xdomain: this.xd,
  2024. xscheme: this.xs,
  2025. enablesXDR: this.enablesXDR
  2026. };
  2027. a.pfx = this.pfx,
  2028. a.key = this.key,
  2029. a.passphrase = this.passphrase,
  2030. a.cert = this.cert,
  2031. a.ca = this.ca,
  2032. a.ciphers = this.ciphers,
  2033. a.rejectUnauthorized = this.rejectUnauthorized;
  2034. var c = this.xhr = new h(a),
  2035. d = this;
  2036. try {
  2037. l("xhr open %s: %s", this.method, this.uri),
  2038. c.open(this.method, this.uri, this.async);
  2039. try {
  2040. if (this.extraHeaders) {
  2041. c.setDisableHeaderCheck(!0);
  2042. for (var e in this.extraHeaders) this.extraHeaders.hasOwnProperty(e) && c.setRequestHeader(e, this.extraHeaders[e])
  2043. }
  2044. } catch(g) {}
  2045. if (this.supportsBinary && (c.responseType = "arraybuffer"), "POST" === this.method) try {
  2046. this.isBinary ? c.setRequestHeader("Content-type", "application/octet-stream") : c.setRequestHeader("Content-type", "text/plain;charset=UTF-8")
  2047. } catch(g) {}
  2048. try {
  2049. c.setRequestHeader("Accept", "*/*")
  2050. } catch(g) {}
  2051. "withCredentials" in c && (c.withCredentials = !0),
  2052. this.requestTimeout && (c.timeout = this.requestTimeout),
  2053. this.hasXDR() ? (c.onload = function() {
  2054. d.onLoad()
  2055. },
  2056. c.onerror = function() {
  2057. d.onError(c.responseText)
  2058. }) : c.onreadystatechange = function() {
  2059. 4 === c.readyState && (200 === c.status || 1223 === c.status ? d.onLoad() : setTimeout(function() {
  2060. d.onError(c.status)
  2061. },
  2062. 0))
  2063. },
  2064. l("xhr data %s", this.data),
  2065. c.send(this.data)
  2066. } catch(g) {
  2067. return void setTimeout(function() {
  2068. d.onError(g)
  2069. },
  2070. 0)
  2071. }
  2072. b.document && (this.index = f.requestsCount++, f.requests[this.index] = this)
  2073. },
  2074. f.prototype.onSuccess = function() {
  2075. this.emit("success"),
  2076. this.cleanup()
  2077. },
  2078. f.prototype.onData = function(a) {
  2079. this.emit("data", a),
  2080. this.onSuccess()
  2081. },
  2082. f.prototype.onError = function(a) {
  2083. this.emit("error", a),
  2084. this.cleanup(!0)
  2085. },
  2086. f.prototype.cleanup = function(a) {
  2087. if ("undefined" != typeof this.xhr && null !== this.xhr) {
  2088. if (this.hasXDR() ? this.xhr.onload = this.xhr.onerror = d: this.xhr.onreadystatechange = d, a) try {
  2089. this.xhr.abort()
  2090. } catch(c) {}
  2091. b.document && delete f.requests[this.index],
  2092. this.xhr = null
  2093. }
  2094. },
  2095. f.prototype.onLoad = function() {
  2096. var a;
  2097. try {
  2098. var b;
  2099. try {
  2100. b = this.xhr.getResponseHeader("Content-Type").split(";")[0]
  2101. } catch(c) {}
  2102. if ("application/octet-stream" === b) a = this.xhr.response || this.xhr.responseText;
  2103. else if (this.supportsBinary) try {
  2104. a = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response))
  2105. } catch(c) {
  2106. for (var d = new Uint8Array(this.xhr.response), e = [], f = 0, g = d.length; f < g; f++) e.push(d[f]);
  2107. a = String.fromCharCode.apply(null, e)
  2108. } else a = this.xhr.responseText
  2109. } catch(c) {
  2110. this.onError(c)
  2111. }
  2112. null != a && this.onData(a)
  2113. },
  2114. f.prototype.hasXDR = function() {
  2115. return "undefined" != typeof b.XDomainRequest && !this.xs && this.enablesXDR
  2116. },
  2117. f.prototype.abort = function() {
  2118. this.cleanup()
  2119. },
  2120. f.requestsCount = 0,
  2121. f.requests = {},
  2122. b.document && (b.attachEvent ? b.attachEvent("onunload", g) : b.addEventListener && b.addEventListener("beforeunload", g, !1))
  2123. }).call(b,
  2124. function() {
  2125. return this
  2126. } ())
  2127. },
  2128. function(a, b, c) {
  2129. function d(a) {
  2130. var b = a && a.forceBase64;
  2131. k && !b || (this.supportsBinary = !1),
  2132. e.call(this, a)
  2133. }
  2134. var e = c(26),
  2135. f = c(36),
  2136. g = c(27),
  2137. h = c(37),
  2138. i = c(38),
  2139. j = c(3)("engine.io-client:polling");
  2140. a.exports = d;
  2141. var k = function() {
  2142. var a = c(22),
  2143. b = new a({
  2144. xdomain: !1
  2145. });
  2146. return null != b.responseType
  2147. } ();
  2148. h(d, e),
  2149. d.prototype.name = "polling",
  2150. d.prototype.doOpen = function() {
  2151. this.poll()
  2152. },
  2153. d.prototype.pause = function(a) {
  2154. function b() {
  2155. j("paused"),
  2156. c.readyState = "paused",
  2157. a()
  2158. }
  2159. var c = this;
  2160. if (this.readyState = "pausing", this.polling || !this.writable) {
  2161. var d = 0;
  2162. this.polling && (j("we are currently polling - waiting to pause"), d++, this.once("pollComplete",
  2163. function() {
  2164. j("pre-pause polling complete"),
  2165. --d || b()
  2166. })),
  2167. this.writable || (j("we are currently writing - waiting to pause"), d++, this.once("drain",
  2168. function() {
  2169. j("pre-pause writing complete"),
  2170. --d || b()
  2171. }))
  2172. } else b()
  2173. },
  2174. d.prototype.poll = function() {
  2175. j("polling"),
  2176. this.polling = !0,
  2177. this.doPoll(),
  2178. this.emit("poll")
  2179. },
  2180. d.prototype.onData = function(a) {
  2181. var b = this;
  2182. j("polling got data %s", a);
  2183. var c = function(a, c, d) {
  2184. return "opening" === b.readyState && b.onOpen(),
  2185. "close" === a.type ? (b.onClose(), !1) : void b.onPacket(a)
  2186. };
  2187. g.decodePayload(a, this.socket.binaryType, c),
  2188. "closed" !== this.readyState && (this.polling = !1, this.emit("pollComplete"), "open" === this.readyState ? this.poll() : j('ignoring poll - transport state "%s"', this.readyState))
  2189. },
  2190. d.prototype.doClose = function() {
  2191. function a() {
  2192. j("writing close packet"),
  2193. b.write([{
  2194. type: "close"
  2195. }])
  2196. }
  2197. var b = this;
  2198. "open" === this.readyState ? (j("transport open - closing"), a()) : (j("transport not open - deferring close"), this.once("open", a))
  2199. },
  2200. d.prototype.write = function(a) {
  2201. var b = this;
  2202. this.writable = !1;
  2203. var c = function() {
  2204. b.writable = !0,
  2205. b.emit("drain")
  2206. };
  2207. g.encodePayload(a, this.supportsBinary,
  2208. function(a) {
  2209. b.doWrite(a, c)
  2210. })
  2211. },
  2212. d.prototype.uri = function() {
  2213. var a = this.query || {},
  2214. b = this.secure ? "https": "http",
  2215. c = ""; ! 1 !== this.timestampRequests && (a[this.timestampParam] = i()),
  2216. this.supportsBinary || a.sid || (a.b64 = 1),
  2217. a = f.encode(a),
  2218. this.port && ("https" === b && 443 !== Number(this.port) || "http" === b && 80 !== Number(this.port)) && (c = ":" + this.port),
  2219. a.length && (a = "?" + a);
  2220. var d = this.hostname.indexOf(":") !== -1;
  2221. return b + "://" + (d ? "[" + this.hostname + "]": this.hostname) + c + this.path + a
  2222. }
  2223. },
  2224. function(a, b, c) {
  2225. function d(a) {
  2226. this.path = a.path,
  2227. this.hostname = a.hostname,
  2228. this.port = a.port,
  2229. this.secure = a.secure,
  2230. this.query = a.query,
  2231. this.timestampParam = a.timestampParam,
  2232. this.timestampRequests = a.timestampRequests,
  2233. this.readyState = "",
  2234. this.agent = a.agent || !1,
  2235. this.socket = a.socket,
  2236. this.enablesXDR = a.enablesXDR,
  2237. this.pfx = a.pfx,
  2238. this.key = a.key,
  2239. this.passphrase = a.passphrase,
  2240. this.cert = a.cert,
  2241. this.ca = a.ca,
  2242. this.ciphers = a.ciphers,
  2243. this.rejectUnauthorized = a.rejectUnauthorized,
  2244. this.forceNode = a.forceNode,
  2245. this.extraHeaders = a.extraHeaders,
  2246. this.localAddress = a.localAddress
  2247. }
  2248. var e = c(27),
  2249. f = c(35);
  2250. a.exports = d,
  2251. f(d.prototype),
  2252. d.prototype.onError = function(a, b) {
  2253. var c = new Error(a);
  2254. return c.type = "TransportError",
  2255. c.description = b,
  2256. this.emit("error", c),
  2257. this
  2258. },
  2259. d.prototype.open = function() {
  2260. return "closed" !== this.readyState && "" !== this.readyState || (this.readyState = "opening", this.doOpen()),
  2261. this
  2262. },
  2263. d.prototype.close = function() {
  2264. return "opening" !== this.readyState && "open" !== this.readyState || (this.doClose(), this.onClose()),
  2265. this
  2266. },
  2267. d.prototype.send = function(a) {
  2268. if ("open" !== this.readyState) throw new Error("Transport not open");
  2269. this.write(a)
  2270. },
  2271. d.prototype.onOpen = function() {
  2272. this.readyState = "open",
  2273. this.writable = !0,
  2274. this.emit("open")
  2275. },
  2276. d.prototype.onData = function(a) {
  2277. var b = e.decodePacket(a, this.socket.binaryType);
  2278. this.onPacket(b)
  2279. },
  2280. d.prototype.onPacket = function(a) {
  2281. this.emit("packet", a)
  2282. },
  2283. d.prototype.onClose = function() {
  2284. this.readyState = "closed",
  2285. this.emit("close")
  2286. }
  2287. },
  2288. function(a, b, c) { (function(a) {
  2289. function d(a, c) {
  2290. var d = "b" + b.packets[a.type] + a.data.data;
  2291. return c(d)
  2292. }
  2293. function e(a, c, d) {
  2294. if (!c) return b.encodeBase64Packet(a, d);
  2295. var e = a.data,
  2296. f = new Uint8Array(e),
  2297. g = new Uint8Array(1 + e.byteLength);
  2298. g[0] = s[a.type];
  2299. for (var h = 0; h < f.length; h++) g[h + 1] = f[h];
  2300. return d(g.buffer)
  2301. }
  2302. function f(a, c, d) {
  2303. if (!c) return b.encodeBase64Packet(a, d);
  2304. var e = new FileReader;
  2305. return e.onload = function() {
  2306. a.data = e.result,
  2307. b.encodePacket(a, c, !0, d)
  2308. },
  2309. e.readAsArrayBuffer(a.data)
  2310. }
  2311. function g(a, c, d) {
  2312. if (!c) return b.encodeBase64Packet(a, d);
  2313. if (r) return f(a, c, d);
  2314. var e = new Uint8Array(1);
  2315. e[0] = s[a.type];
  2316. var g = new v([e.buffer, a.data]);
  2317. return d(g)
  2318. }
  2319. function h(a) {
  2320. try {
  2321. a = o.decode(a)
  2322. } catch(b) {
  2323. return ! 1
  2324. }
  2325. return a
  2326. }
  2327. function i(a, b, c) {
  2328. for (var d = new Array(a.length), e = n(a.length, c), f = function(a, c, e) {
  2329. b(c,
  2330. function(b, c) {
  2331. d[a] = c,
  2332. e(b, d)
  2333. })
  2334. },
  2335. g = 0; g < a.length; g++) f(g, a[g], e)
  2336. }
  2337. var j, k = c(28),
  2338. l = c(29),
  2339. m = c(30),
  2340. n = c(31),
  2341. o = c(32);
  2342. a && a.ArrayBuffer && (j = c(33));
  2343. var p = "undefined" != typeof navigator && /Android/i.test(navigator.userAgent),
  2344. q = "undefined" != typeof navigator && /PhantomJS/i.test(navigator.userAgent),
  2345. r = p || q;
  2346. b.protocol = 3;
  2347. var s = b.packets = {
  2348. open: 0,
  2349. close: 1,
  2350. ping: 2,
  2351. pong: 3,
  2352. message: 4,
  2353. upgrade: 5,
  2354. noop: 6
  2355. },
  2356. t = k(s),
  2357. u = {
  2358. type: "error",
  2359. data: "parser error"
  2360. },
  2361. v = c(34);
  2362. b.encodePacket = function(b, c, f, h) {
  2363. "function" == typeof c && (h = c, c = !1),
  2364. "function" == typeof f && (h = f, f = null);
  2365. var i = void 0 === b.data ? void 0 : b.data.buffer || b.data;
  2366. if (a.ArrayBuffer && i instanceof ArrayBuffer) return e(b, c, h);
  2367. if (v && i instanceof a.Blob) return g(b, c, h);
  2368. if (i && i.base64) return d(b, h);
  2369. var j = s[b.type];
  2370. return void 0 !== b.data && (j += f ? o.encode(String(b.data)) : String(b.data)),
  2371. h("" + j)
  2372. },
  2373. b.encodeBase64Packet = function(c, d) {
  2374. var e = "b" + b.packets[c.type];
  2375. if (v && c.data instanceof a.Blob) {
  2376. var f = new FileReader;
  2377. return f.onload = function() {
  2378. var a = f.result.split(",")[1];
  2379. d(e + a)
  2380. },
  2381. f.readAsDataURL(c.data)
  2382. }
  2383. var g;
  2384. try {
  2385. g = String.fromCharCode.apply(null, new Uint8Array(c.data))
  2386. } catch(h) {
  2387. for (var i = new Uint8Array(c.data), j = new Array(i.length), k = 0; k < i.length; k++) j[k] = i[k];
  2388. g = String.fromCharCode.apply(null, j)
  2389. }
  2390. return e += a.btoa(g),
  2391. d(e)
  2392. },
  2393. b.decodePacket = function(a, c, d) {
  2394. if (void 0 === a) return u;
  2395. if ("string" == typeof a) {
  2396. if ("b" == a.charAt(0)) return b.decodeBase64Packet(a.substr(1), c);
  2397. if (d && (a = h(a), a === !1)) return u;
  2398. var e = a.charAt(0);
  2399. return Number(e) == e && t[e] ? a.length > 1 ? {
  2400. type: t[e],
  2401. data: a.substring(1)
  2402. }: {
  2403. type: t[e]
  2404. }: u
  2405. }
  2406. var f = new Uint8Array(a),
  2407. e = f[0],
  2408. g = m(a, 1);
  2409. return v && "blob" === c && (g = new v([g])),
  2410. {
  2411. type: t[e],
  2412. data: g
  2413. }
  2414. },
  2415. b.decodeBase64Packet = function(a, b) {
  2416. var c = t[a.charAt(0)];
  2417. if (!j) return {
  2418. type: c,
  2419. data: {
  2420. base64: !0,
  2421. data: a.substr(1)
  2422. }
  2423. };
  2424. var d = j.decode(a.substr(1));
  2425. return "blob" === b && v && (d = new v([d])),
  2426. {
  2427. type: c,
  2428. data: d
  2429. }
  2430. },
  2431. b.encodePayload = function(a, c, d) {
  2432. function e(a) {
  2433. return a.length + ":" + a
  2434. }
  2435. function f(a, d) {
  2436. b.encodePacket(a, !!g && c, !0,
  2437. function(a) {
  2438. d(null, e(a))
  2439. })
  2440. }
  2441. "function" == typeof c && (d = c, c = null);
  2442. var g = l(a);
  2443. return c && g ? v && !r ? b.encodePayloadAsBlob(a, d) : b.encodePayloadAsArrayBuffer(a, d) : a.length ? void i(a, f,
  2444. function(a, b) {
  2445. return d(b.join(""))
  2446. }) : d("0:")
  2447. },
  2448. b.decodePayload = function(a, c, d) {
  2449. if ("string" != typeof a) return b.decodePayloadAsBinary(a, c, d);
  2450. "function" == typeof c && (d = c, c = null);
  2451. var e;
  2452. if ("" == a) return d(u, 0, 1);
  2453. for (var f, g, h = "",
  2454. i = 0,
  2455. j = a.length; i < j; i++) {
  2456. var k = a.charAt(i);
  2457. if (":" != k) h += k;
  2458. else {
  2459. if ("" == h || h != (f = Number(h))) return d(u, 0, 1);
  2460. if (g = a.substr(i + 1, f), h != g.length) return d(u, 0, 1);
  2461. if (g.length) {
  2462. if (e = b.decodePacket(g, c, !0), u.type == e.type && u.data == e.data) return d(u, 0, 1);
  2463. var l = d(e, i + f, j);
  2464. if (!1 === l) return
  2465. }
  2466. i += f,
  2467. h = ""
  2468. }
  2469. }
  2470. return "" != h ? d(u, 0, 1) : void 0
  2471. },
  2472. b.encodePayloadAsArrayBuffer = function(a, c) {
  2473. function d(a, c) {
  2474. b.encodePacket(a, !0, !0,
  2475. function(a) {
  2476. return c(null, a)
  2477. })
  2478. }
  2479. return a.length ? void i(a, d,
  2480. function(a, b) {
  2481. var d = b.reduce(function(a, b) {
  2482. var c;
  2483. return c = "string" == typeof b ? b.length: b.byteLength,
  2484. a + c.toString().length + c + 2
  2485. },
  2486. 0),
  2487. e = new Uint8Array(d),
  2488. f = 0;
  2489. return b.forEach(function(a) {
  2490. var b = "string" == typeof a,
  2491. c = a;
  2492. if (b) {
  2493. for (var d = new Uint8Array(a.length), g = 0; g < a.length; g++) d[g] = a.charCodeAt(g);
  2494. c = d.buffer
  2495. }
  2496. b ? e[f++] = 0 : e[f++] = 1;
  2497. for (var h = c.byteLength.toString(), g = 0; g < h.length; g++) e[f++] = parseInt(h[g]);
  2498. e[f++] = 255;
  2499. for (var d = new Uint8Array(c), g = 0; g < d.length; g++) e[f++] = d[g]
  2500. }),
  2501. c(e.buffer)
  2502. }) : c(new ArrayBuffer(0))
  2503. },
  2504. b.encodePayloadAsBlob = function(a, c) {
  2505. function d(a, c) {
  2506. b.encodePacket(a, !0, !0,
  2507. function(a) {
  2508. var b = new Uint8Array(1);
  2509. if (b[0] = 1, "string" == typeof a) {
  2510. for (var d = new Uint8Array(a.length), e = 0; e < a.length; e++) d[e] = a.charCodeAt(e);
  2511. a = d.buffer,
  2512. b[0] = 0
  2513. }
  2514. for (var f = a instanceof ArrayBuffer ? a.byteLength: a.size, g = f.toString(), h = new Uint8Array(g.length + 1), e = 0; e < g.length; e++) h[e] = parseInt(g[e]);
  2515. if (h[g.length] = 255, v) {
  2516. var i = new v([b.buffer, h.buffer, a]);
  2517. c(null, i)
  2518. }
  2519. })
  2520. }
  2521. i(a, d,
  2522. function(a, b) {
  2523. return c(new v(b))
  2524. })
  2525. },
  2526. b.decodePayloadAsBinary = function(a, c, d) {
  2527. "function" == typeof c && (d = c, c = null);
  2528. for (var e = a,
  2529. f = [], g = !1; e.byteLength > 0;) {
  2530. for (var h = new Uint8Array(e), i = 0 === h[0], j = "", k = 1; 255 != h[k]; k++) {
  2531. if (j.length > 310) {
  2532. g = !0;
  2533. break
  2534. }
  2535. j += h[k]
  2536. }
  2537. if (g) return d(u, 0, 1);
  2538. e = m(e, 2 + j.length),
  2539. j = parseInt(j);
  2540. var l = m(e, 0, j);
  2541. if (i) try {
  2542. l = String.fromCharCode.apply(null, new Uint8Array(l))
  2543. } catch(n) {
  2544. var o = new Uint8Array(l);
  2545. l = "";
  2546. for (var k = 0; k < o.length; k++) l += String.fromCharCode(o[k])
  2547. }
  2548. f.push(l),
  2549. e = m(e, j)
  2550. }
  2551. var p = f.length;
  2552. f.forEach(function(a, e) {
  2553. d(b.decodePacket(a, c, !0), e, p)
  2554. })
  2555. }
  2556. }).call(b,
  2557. function() {
  2558. return this
  2559. } ())
  2560. },
  2561. function(a, b) {
  2562. a.exports = Object.keys ||
  2563. function(a) {
  2564. var b = [],
  2565. c = Object.prototype.hasOwnProperty;
  2566. for (var d in a) c.call(a, d) && b.push(d);
  2567. return b
  2568. }
  2569. },
  2570. function(a, b, c) { (function(b) {
  2571. function d(a) {
  2572. function c(a) {
  2573. if (!a) return ! 1;
  2574. if (b.Buffer && b.Buffer.isBuffer && b.Buffer.isBuffer(a) || b.ArrayBuffer && a instanceof ArrayBuffer || b.Blob && a instanceof Blob || b.File && a instanceof File) return ! 0;
  2575. if (e(a)) {
  2576. for (var d = 0; d < a.length; d++) if (c(a[d])) return ! 0
  2577. } else if (a && "object" == typeof a) {
  2578. a.toJSON && "function" == typeof a.toJSON && (a = a.toJSON());
  2579. for (var f in a) if (Object.prototype.hasOwnProperty.call(a, f) && c(a[f])) return ! 0
  2580. }
  2581. return ! 1
  2582. }
  2583. return c(a)
  2584. }
  2585. var e = c(15);
  2586. a.exports = d
  2587. }).call(b,
  2588. function() {
  2589. return this
  2590. } ())
  2591. },
  2592. function(a, b) {
  2593. a.exports = function(a, b, c) {
  2594. var d = a.byteLength;
  2595. if (b = b || 0, c = c || d, a.slice) return a.slice(b, c);
  2596. if (b < 0 && (b += d), c < 0 && (c += d), c > d && (c = d), b >= d || b >= c || 0 === d) return new ArrayBuffer(0);
  2597. for (var e = new Uint8Array(a), f = new Uint8Array(c - b), g = b, h = 0; g < c; g++, h++) f[h] = e[g];
  2598. return f.buffer
  2599. }
  2600. },
  2601. function(a, b) {
  2602. function c(a, b, c) {
  2603. function e(a, d) {
  2604. if (e.count <= 0) throw new Error("after called too many times"); --e.count,
  2605. a ? (f = !0, b(a), b = c) : 0 !== e.count || f || b(null, d)
  2606. }
  2607. var f = !1;
  2608. return c = c || d,
  2609. e.count = a,
  2610. 0 === a ? b() : e
  2611. }
  2612. function d() {}
  2613. a.exports = c
  2614. },
  2615. function(a, b, c) {
  2616. var d; (function(a, e) { !
  2617. function(f) {
  2618. function g(a) {
  2619. for (var b, c, d = [], e = 0, f = a.length; e < f;) b = a.charCodeAt(e++),
  2620. b >= 55296 && b <= 56319 && e < f ? (c = a.charCodeAt(e++), 56320 == (64512 & c) ? d.push(((1023 & b) << 10) + (1023 & c) + 65536) : (d.push(b), e--)) : d.push(b);
  2621. return d
  2622. }
  2623. function h(a) {
  2624. for (var b, c = a.length,
  2625. d = -1,
  2626. e = ""; ++d < c;) b = a[d],
  2627. b > 65535 && (b -= 65536, e += t(b >>> 10 & 1023 | 55296), b = 56320 | 1023 & b),
  2628. e += t(b);
  2629. return e
  2630. }
  2631. function i(a, b) {
  2632. return t(a >> b & 63 | 128)
  2633. }
  2634. function j(a) {
  2635. if (0 == (4294967168 & a)) return t(a);
  2636. var b = "";
  2637. return 0 == (4294965248 & a) ? b = t(a >> 6 & 31 | 192) : 0 == (4294901760 & a) ? (b = t(a >> 12 & 15 | 224), b += i(a, 6)) : 0 == (4292870144 & a) && (b = t(a >> 18 & 7 | 240), b += i(a, 12), b += i(a, 6)),
  2638. b += t(63 & a | 128)
  2639. }
  2640. function k(a) {
  2641. for (var b, c = g(a), d = c.length, e = -1, f = ""; ++e < d;) b = c[e],
  2642. f += j(b);
  2643. return f
  2644. }
  2645. function l() {
  2646. if (s >= r) throw Error("Invalid byte index");
  2647. var a = 255 & q[s];
  2648. if (s++, 128 == (192 & a)) return 63 & a;
  2649. throw Error("Invalid continuation byte")
  2650. }
  2651. function m() {
  2652. var a, b, c, d, e;
  2653. if (s > r) throw Error("Invalid byte index");
  2654. if (s == r) return ! 1;
  2655. if (a = 255 & q[s], s++, 0 == (128 & a)) return a;
  2656. if (192 == (224 & a)) {
  2657. var b = l();
  2658. if (e = (31 & a) << 6 | b, e >= 128) return e;
  2659. throw Error("Invalid continuation byte")
  2660. }
  2661. if (224 == (240 & a)) {
  2662. if (b = l(), c = l(), e = (15 & a) << 12 | b << 6 | c, e >= 2048) return e;
  2663. throw Error("Invalid continuation byte")
  2664. }
  2665. if (240 == (248 & a) && (b = l(), c = l(), d = l(), e = (15 & a) << 18 | b << 12 | c << 6 | d, e >= 65536 && e <= 1114111)) return e;
  2666. throw Error("Invalid WTF-8 detected")
  2667. }
  2668. function n(a) {
  2669. q = g(a),
  2670. r = q.length,
  2671. s = 0;
  2672. for (var b, c = []; (b = m()) !== !1;) c.push(b);
  2673. return h(c)
  2674. }
  2675. var o = "object" == typeof b && b,
  2676. p = ("object" == typeof a && a && a.exports == o && a, "object" == typeof e && e);
  2677. p.global !== p && p.window !== p || (f = p);
  2678. var q, r, s, t = String.fromCharCode,
  2679. u = {
  2680. version: "1.0.0",
  2681. encode: k,
  2682. decode: n
  2683. };
  2684. d = function() {
  2685. return u
  2686. }.call(b, c, b, a),
  2687. !(void 0 !== d && (a.exports = d))
  2688. } (this)
  2689. }).call(b, c(12)(a),
  2690. function() {
  2691. return this
  2692. } ())
  2693. },
  2694. function(a, b) { !
  2695. function() {
  2696. "use strict";
  2697. for (var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
  2698. c = new Uint8Array(256), d = 0; d < a.length; d++) c[a.charCodeAt(d)] = d;
  2699. b.encode = function(b) {
  2700. var c, d = new Uint8Array(b),
  2701. e = d.length,
  2702. f = "";
  2703. for (c = 0; c < e; c += 3) f += a[d[c] >> 2],
  2704. f += a[(3 & d[c]) << 4 | d[c + 1] >> 4],
  2705. f += a[(15 & d[c + 1]) << 2 | d[c + 2] >> 6],
  2706. f += a[63 & d[c + 2]];
  2707. return e % 3 === 2 ? f = f.substring(0, f.length - 1) + "=": e % 3 === 1 && (f = f.substring(0, f.length - 2) + "=="),
  2708. f
  2709. },
  2710. b.decode = function(a) {
  2711. var b, d, e, f, g, h = .75 * a.length,
  2712. i = a.length,
  2713. j = 0;
  2714. "=" === a[a.length - 1] && (h--, "=" === a[a.length - 2] && h--);
  2715. var k = new ArrayBuffer(h),
  2716. l = new Uint8Array(k);
  2717. for (b = 0; b < i; b += 4) d = c[a.charCodeAt(b)],
  2718. e = c[a.charCodeAt(b + 1)],
  2719. f = c[a.charCodeAt(b + 2)],
  2720. g = c[a.charCodeAt(b + 3)],
  2721. l[j++] = d << 2 | e >> 4,
  2722. l[j++] = (15 & e) << 4 | f >> 2,
  2723. l[j++] = (3 & f) << 6 | 63 & g;
  2724. return k
  2725. }
  2726. } ()
  2727. },
  2728. function(a, b) { (function(b) {
  2729. function c(a) {
  2730. for (var b = 0; b < a.length; b++) {
  2731. var c = a[b];
  2732. if (c.buffer instanceof ArrayBuffer) {
  2733. var d = c.buffer;
  2734. if (c.byteLength !== d.byteLength) {
  2735. var e = new Uint8Array(c.byteLength);
  2736. e.set(new Uint8Array(d, c.byteOffset, c.byteLength)),
  2737. d = e.buffer
  2738. }
  2739. a[b] = d
  2740. }
  2741. }
  2742. }
  2743. function d(a, b) {
  2744. b = b || {};
  2745. var d = new f;
  2746. c(a);
  2747. for (var e = 0; e < a.length; e++) d.append(a[e]);
  2748. return b.type ? d.getBlob(b.type) : d.getBlob()
  2749. }
  2750. function e(a, b) {
  2751. return c(a),
  2752. new Blob(a, b || {})
  2753. }
  2754. var f = b.BlobBuilder || b.WebKitBlobBuilder || b.MSBlobBuilder || b.MozBlobBuilder,
  2755. g = function() {
  2756. try {
  2757. var a = new Blob(["hi"]);
  2758. return 2 === a.size
  2759. } catch(b) {
  2760. return ! 1
  2761. }
  2762. } (),
  2763. h = g &&
  2764. function() {
  2765. try {
  2766. var a = new Blob([new Uint8Array([1, 2])]);
  2767. return 2 === a.size
  2768. } catch(b) {
  2769. return ! 1
  2770. }
  2771. } (),
  2772. i = f && f.prototype.append && f.prototype.getBlob;
  2773. a.exports = function() {
  2774. return g ? h ? b.Blob: e: i ? d: void 0
  2775. } ()
  2776. }).call(b,
  2777. function() {
  2778. return this
  2779. } ())
  2780. },
  2781. function(a, b, c) {
  2782. function d(a) {
  2783. if (a) return e(a)
  2784. }
  2785. function e(a) {
  2786. for (var b in d.prototype) a[b] = d.prototype[b];
  2787. return a
  2788. }
  2789. a.exports = d,
  2790. d.prototype.on = d.prototype.addEventListener = function(a, b) {
  2791. return this._callbacks = this._callbacks || {},
  2792. (this._callbacks["$" + a] = this._callbacks["$" + a] || []).push(b),
  2793. this
  2794. },
  2795. d.prototype.once = function(a, b) {
  2796. function c() {
  2797. this.off(a, c),
  2798. b.apply(this, arguments)
  2799. }
  2800. return c.fn = b,
  2801. this.on(a, c),
  2802. this
  2803. },
  2804. d.prototype.off = d.prototype.removeListener = d.prototype.removeAllListeners = d.prototype.removeEventListener = function(a, b) {
  2805. if (this._callbacks = this._callbacks || {},
  2806. 0 == arguments.length) return this._callbacks = {},
  2807. this;
  2808. var c = this._callbacks["$" + a];
  2809. if (!c) return this;
  2810. if (1 == arguments.length) return delete this._callbacks["$" + a],
  2811. this;
  2812. for (var d, e = 0; e < c.length; e++) if (d = c[e], d === b || d.fn === b) {
  2813. c.splice(e, 1);
  2814. break
  2815. }
  2816. return this
  2817. },
  2818. d.prototype.emit = function(a) {
  2819. this._callbacks = this._callbacks || {};
  2820. var b = [].slice.call(arguments, 1),
  2821. c = this._callbacks["$" + a];
  2822. if (c) {
  2823. c = c.slice(0);
  2824. for (var d = 0,
  2825. e = c.length; d < e; ++d) c[d].apply(this, b)
  2826. }
  2827. return this
  2828. },
  2829. d.prototype.listeners = function(a) {
  2830. return this._callbacks = this._callbacks || {},
  2831. this._callbacks["$" + a] || []
  2832. },
  2833. d.prototype.hasListeners = function(a) {
  2834. return !! this.listeners(a).length
  2835. }
  2836. },
  2837. function(a, b) {
  2838. b.encode = function(a) {
  2839. var b = "";
  2840. for (var c in a) a.hasOwnProperty(c) && (b.length && (b += "&"), b += encodeURIComponent(c) + "=" + encodeURIComponent(a[c]));
  2841. return b
  2842. },
  2843. b.decode = function(a) {
  2844. for (var b = {},
  2845. c = a.split("&"), d = 0, e = c.length; d < e; d++) {
  2846. var f = c[d].split("=");
  2847. b[decodeURIComponent(f[0])] = decodeURIComponent(f[1])
  2848. }
  2849. return b
  2850. }
  2851. },
  2852. function(a, b) {
  2853. a.exports = function(a, b) {
  2854. var c = function() {};
  2855. c.prototype = b.prototype,
  2856. a.prototype = new c,
  2857. a.prototype.constructor = a
  2858. }
  2859. },
  2860. function(a, b) {
  2861. "use strict";
  2862. function c(a) {
  2863. var b = "";
  2864. do b = g[a % h] + b,
  2865. a = Math.floor(a / h);
  2866. while (a > 0);
  2867. return b
  2868. }
  2869. function d(a) {
  2870. var b = 0;
  2871. for (k = 0; k < a.length; k++) b = b * h + i[a.charAt(k)];
  2872. return b
  2873. }
  2874. function e() {
  2875. var a = c( + new Date);
  2876. return a !== f ? (j = 0, f = a) : a + "." + c(j++)
  2877. }
  2878. for (var f, g = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), h = 64, i = {},
  2879. j = 0, k = 0; k < h; k++) i[g[k]] = k;
  2880. e.encode = c,
  2881. e.decode = d,
  2882. a.exports = e
  2883. },
  2884. function(a, b, c) { (function(b) {
  2885. function d() {}
  2886. function e(a) {
  2887. f.call(this, a),
  2888. this.query = this.query || {},
  2889. h || (b.___eio || (b.___eio = []), h = b.___eio),
  2890. this.index = h.length;
  2891. var c = this;
  2892. h.push(function(a) {
  2893. c.onData(a)
  2894. }),
  2895. this.query.j = this.index,
  2896. b.document && b.addEventListener && b.addEventListener("beforeunload",
  2897. function() {
  2898. c.script && (c.script.onerror = d)
  2899. },
  2900. !1)
  2901. }
  2902. var f = c(25),
  2903. g = c(37);
  2904. a.exports = e;
  2905. var h, i = /\n/g,
  2906. j = /\\n/g;
  2907. g(e, f),
  2908. e.prototype.supportsBinary = !1,
  2909. e.prototype.doClose = function() {
  2910. this.script && (this.script.parentNode.removeChild(this.script), this.script = null),
  2911. this.form && (this.form.parentNode.removeChild(this.form), this.form = null, this.iframe = null),
  2912. f.prototype.doClose.call(this)
  2913. },
  2914. e.prototype.doPoll = function() {
  2915. var a = this,
  2916. b = document.createElement("script");
  2917. this.script && (this.script.parentNode.removeChild(this.script), this.script = null),
  2918. b.async = !0,
  2919. b.src = this.uri(),
  2920. b.onerror = function(b) {
  2921. a.onError("jsonp poll error", b)
  2922. };
  2923. var c = document.getElementsByTagName("script")[0];
  2924. c ? c.parentNode.insertBefore(b, c) : (document.head || document.body).appendChild(b),
  2925. this.script = b;
  2926. var d = "undefined" != typeof navigator && /gecko/i.test(navigator.userAgent);
  2927. d && setTimeout(function() {
  2928. var a = document.createElement("iframe");
  2929. document.body.appendChild(a),
  2930. document.body.removeChild(a)
  2931. },
  2932. 100)
  2933. },
  2934. e.prototype.doWrite = function(a, b) {
  2935. function c() {
  2936. d(),
  2937. b()
  2938. }
  2939. function d() {
  2940. if (e.iframe) try {
  2941. e.form.removeChild(e.iframe)
  2942. } catch(a) {
  2943. e.onError("jsonp polling iframe removal error", a)
  2944. }
  2945. try {
  2946. var b = '<iframe src="javascript:0" name="' + e.iframeId + '">';
  2947. f = document.createElement(b)
  2948. } catch(a) {
  2949. f = document.createElement("iframe"),
  2950. f.name = e.iframeId,
  2951. f.src = "javascript:0"
  2952. }
  2953. f.id = e.iframeId,
  2954. e.form.appendChild(f),
  2955. e.iframe = f
  2956. }
  2957. var e = this;
  2958. if (!this.form) {
  2959. var f, g = document.createElement("form"),
  2960. h = document.createElement("textarea"),
  2961. k = this.iframeId = "eio_iframe_" + this.index;
  2962. g.className = "socketio",
  2963. g.style.position = "absolute",
  2964. g.style.top = "-1000px",
  2965. g.style.left = "-1000px",
  2966. g.target = k,
  2967. g.method = "POST",
  2968. g.setAttribute("accept-charset", "utf-8"),
  2969. h.name = "d",
  2970. g.appendChild(h),
  2971. document.body.appendChild(g),
  2972. this.form = g,
  2973. this.area = h
  2974. }
  2975. this.form.action = this.uri(),
  2976. d(),
  2977. a = a.replace(j, "\\\n"),
  2978. this.area.value = a.replace(i, "\\n");
  2979. try {
  2980. this.form.submit()
  2981. } catch(l) {}
  2982. this.iframe.attachEvent ? this.iframe.onreadystatechange = function() {
  2983. "complete" === e.iframe.readyState && c()
  2984. }: this.iframe.onload = c
  2985. }
  2986. }).call(b,
  2987. function() {
  2988. return this
  2989. } ())
  2990. },
  2991. function(a, b, c) { (function(b) {
  2992. function d(a) {
  2993. var b = a && a.forceBase64;
  2994. b && (this.supportsBinary = !1),
  2995. this.perMessageDeflate = a.perMessageDeflate,
  2996. this.usingBrowserWebSocket = l && !a.forceNode,
  2997. this.usingBrowserWebSocket || (n = e),
  2998. f.call(this, a)
  2999. }
  3000. var e, f = c(26),
  3001. g = c(27),
  3002. h = c(36),
  3003. i = c(37),
  3004. j = c(38),
  3005. k = c(3)("engine.io-client:websocket"),
  3006. l = b.WebSocket || b.MozWebSocket;
  3007. if ("undefined" == typeof window) try {
  3008. e = c(41)
  3009. } catch(m) {}
  3010. var n = l;
  3011. n || "undefined" != typeof window || (n = e),
  3012. a.exports = d,
  3013. i(d, f),
  3014. d.prototype.name = "websocket",
  3015. d.prototype.supportsBinary = !0,
  3016. d.prototype.doOpen = function() {
  3017. if (this.check()) {
  3018. var a = this.uri(),
  3019. b = void 0,
  3020. c = {
  3021. agent: this.agent,
  3022. perMessageDeflate: this.perMessageDeflate
  3023. };
  3024. c.pfx = this.pfx,
  3025. c.key = this.key,
  3026. c.passphrase = this.passphrase,
  3027. c.cert = this.cert,
  3028. c.ca = this.ca,
  3029. c.ciphers = this.ciphers,
  3030. c.rejectUnauthorized = this.rejectUnauthorized,
  3031. this.extraHeaders && (c.headers = this.extraHeaders),
  3032. this.localAddress && (c.localAddress = this.localAddress);
  3033. try {
  3034. this.ws = this.usingBrowserWebSocket ? new n(a) : new n(a, b, c)
  3035. } catch(d) {
  3036. return this.emit("error", d)
  3037. }
  3038. void 0 === this.ws.binaryType && (this.supportsBinary = !1),
  3039. this.ws.supports && this.ws.supports.binary ? (this.supportsBinary = !0, this.ws.binaryType = "nodebuffer") : this.ws.binaryType = "arraybuffer",
  3040. this.addEventListeners()
  3041. }
  3042. },
  3043. d.prototype.addEventListeners = function() {
  3044. var a = this;
  3045. this.ws.onopen = function() {
  3046. a.onOpen()
  3047. },
  3048. this.ws.onclose = function() {
  3049. a.onClose()
  3050. },
  3051. this.ws.onmessage = function(b) {
  3052. a.onData(b.data)
  3053. },
  3054. this.ws.onerror = function(b) {
  3055. a.onError("websocket error", b)
  3056. }
  3057. },
  3058. d.prototype.write = function(a) {
  3059. function c() {
  3060. d.emit("flush"),
  3061. setTimeout(function() {
  3062. d.writable = !0,
  3063. d.emit("drain")
  3064. },
  3065. 0)
  3066. }
  3067. var d = this;
  3068. this.writable = !1;
  3069. for (var e = a.length,
  3070. f = 0,
  3071. h = e; f < h; f++) !
  3072. function(a) {
  3073. g.encodePacket(a, d.supportsBinary,
  3074. function(f) {
  3075. if (!d.usingBrowserWebSocket) {
  3076. var g = {};
  3077. if (a.options && (g.compress = a.options.compress), d.perMessageDeflate) {
  3078. var h = "string" == typeof f ? b.Buffer.byteLength(f) : f.length;
  3079. h < d.perMessageDeflate.threshold && (g.compress = !1)
  3080. }
  3081. }
  3082. try {
  3083. d.usingBrowserWebSocket ? d.ws.send(f) : d.ws.send(f, g)
  3084. } catch(i) {
  3085. k("websocket closed before onclose event")
  3086. }--e || c()
  3087. })
  3088. } (a[f])
  3089. },
  3090. d.prototype.onClose = function() {
  3091. f.prototype.onClose.call(this)
  3092. },
  3093. d.prototype.doClose = function() {
  3094. "undefined" != typeof this.ws && this.ws.close()
  3095. },
  3096. d.prototype.uri = function() {
  3097. var a = this.query || {},
  3098. b = this.secure ? "wss": "ws",
  3099. c = "";
  3100. this.port && ("wss" === b && 443 !== Number(this.port) || "ws" === b && 80 !== Number(this.port)) && (c = ":" + this.port),
  3101. this.timestampRequests && (a[this.timestampParam] = j()),
  3102. this.supportsBinary || (a.b64 = 1),
  3103. a = h.encode(a),
  3104. a.length && (a = "?" + a);
  3105. var d = this.hostname.indexOf(":") !== -1;
  3106. return b + "://" + (d ? "[" + this.hostname + "]": this.hostname) + c + this.path + a
  3107. },
  3108. d.prototype.check = function() {
  3109. return ! (!n || "__initialize" in n && this.name === d.prototype.name)
  3110. }
  3111. }).call(b,
  3112. function() {
  3113. return this
  3114. } ())
  3115. },
  3116. function(a, b) {},
  3117. function(a, b) {
  3118. var c = [].indexOf;
  3119. a.exports = function(a, b) {
  3120. if (c) return a.indexOf(b);
  3121. for (var d = 0; d < a.length; ++d) if (a[d] === b) return d;
  3122. return - 1
  3123. }
  3124. },
  3125. function(a, b) { (function(b) {
  3126. var c = /^[\],:{}\s]*$/,
  3127. d = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  3128. e = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  3129. f = /(?:^|:|,)(?:\s*\[)+/g,
  3130. g = /^\s+/,
  3131. h = /\s+$/;
  3132. a.exports = function(a) {
  3133. return "string" == typeof a && a ? (a = a.replace(g, "").replace(h, ""), b.JSON && JSON.parse ? JSON.parse(a) : c.test(a.replace(d, "@").replace(e, "]").replace(f, "")) ? new Function("return " + a)() : void 0) : null
  3134. }
  3135. }).call(b,
  3136. function() {
  3137. return this
  3138. } ())
  3139. },
  3140. function(a, b, c) {
  3141. "use strict";
  3142. function d(a, b, c) {
  3143. this.io = a,
  3144. this.nsp = b,
  3145. this.json = this,
  3146. this.ids = 0,
  3147. this.acks = {},
  3148. this.receiveBuffer = [],
  3149. this.sendBuffer = [],
  3150. this.connected = !1,
  3151. this.disconnected = !0,
  3152. c && c.query && (this.query = c.query),
  3153. this.io.autoConnect && this.open()
  3154. }
  3155. var e = c(7),
  3156. f = c(35),
  3157. g = c(45),
  3158. h = c(46),
  3159. i = c(47),
  3160. j = c(3)("socket.io-client:socket"),
  3161. k = c(29);
  3162. a.exports = b = d;
  3163. var l = {
  3164. connect: 1,
  3165. connect_error: 1,
  3166. connect_timeout: 1,
  3167. connecting: 1,
  3168. disconnect: 1,
  3169. error: 1,
  3170. reconnect: 1,
  3171. reconnect_attempt: 1,
  3172. reconnect_failed: 1,
  3173. reconnect_error: 1,
  3174. reconnecting: 1,
  3175. ping: 1,
  3176. pong: 1
  3177. },
  3178. m = f.prototype.emit;
  3179. f(d.prototype),
  3180. d.prototype.subEvents = function() {
  3181. if (!this.subs) {
  3182. var a = this.io;
  3183. this.subs = [h(a, "open", i(this, "onopen")), h(a, "packet", i(this, "onpacket")), h(a, "close", i(this, "onclose"))]
  3184. }
  3185. },
  3186. d.prototype.open = d.prototype.connect = function() {
  3187. return this.connected ? this: (this.subEvents(), this.io.open(), "open" === this.io.readyState && this.onopen(), this.emit("connecting"), this)
  3188. },
  3189. d.prototype.send = function() {
  3190. var a = g(arguments);
  3191. return a.unshift("message"),
  3192. this.emit.apply(this, a),
  3193. this
  3194. },
  3195. d.prototype.emit = function(a) {
  3196. if (l.hasOwnProperty(a)) return m.apply(this, arguments),
  3197. this;
  3198. var b = g(arguments),
  3199. c = e.EVENT;
  3200. k(b) && (c = e.BINARY_EVENT);
  3201. var d = {
  3202. type: c,
  3203. data: b
  3204. };
  3205. return d.options = {},
  3206. d.options.compress = !this.flags || !1 !== this.flags.compress,
  3207. "function" == typeof b[b.length - 1] && (j("emitting packet with ack id %d", this.ids), this.acks[this.ids] = b.pop(), d.id = this.ids++),
  3208. this.connected ? this.packet(d) : this.sendBuffer.push(d),
  3209. delete this.flags,
  3210. this
  3211. },
  3212. d.prototype.packet = function(a) {
  3213. a.nsp = this.nsp,
  3214. this.io.packet(a)
  3215. },
  3216. d.prototype.onopen = function() {
  3217. j("transport is open - connecting"),
  3218. "/" !== this.nsp && (this.query ? this.packet({
  3219. type: e.CONNECT,
  3220. query: this.query
  3221. }) : this.packet({
  3222. type: e.CONNECT
  3223. }))
  3224. },
  3225. d.prototype.onclose = function(a) {
  3226. j("close (%s)", a),
  3227. this.connected = !1,
  3228. this.disconnected = !0,
  3229. delete this.id,
  3230. this.emit("disconnect", a)
  3231. },
  3232. d.prototype.onpacket = function(a) {
  3233. if (a.nsp === this.nsp) switch (a.type) {
  3234. case e.CONNECT:
  3235. this.onconnect();
  3236. break;
  3237. case e.EVENT:
  3238. this.onevent(a);
  3239. break;
  3240. case e.BINARY_EVENT:
  3241. this.onevent(a);
  3242. break;
  3243. case e.ACK:
  3244. this.onack(a);
  3245. break;
  3246. case e.BINARY_ACK:
  3247. this.onack(a);
  3248. break;
  3249. case e.DISCONNECT:
  3250. this.ondisconnect();
  3251. break;
  3252. case e.ERROR:
  3253. this.emit("error", a.data)
  3254. }
  3255. },
  3256. d.prototype.onevent = function(a) {
  3257. var b = a.data || [];
  3258. j("emitting event %j", b),
  3259. null != a.id && (j("attaching ack callback to event"), b.push(this.ack(a.id))),
  3260. this.connected ? m.apply(this, b) : this.receiveBuffer.push(b)
  3261. },
  3262. d.prototype.ack = function(a) {
  3263. var b = this,
  3264. c = !1;
  3265. return function() {
  3266. if (!c) {
  3267. c = !0;
  3268. var d = g(arguments);
  3269. j("sending ack %j", d);
  3270. var f = k(d) ? e.BINARY_ACK: e.ACK;
  3271. b.packet({
  3272. type: f,
  3273. id: a,
  3274. data: d
  3275. })
  3276. }
  3277. }
  3278. },
  3279. d.prototype.onack = function(a) {
  3280. var b = this.acks[a.id];
  3281. "function" == typeof b ? (j("calling ack %s with %j", a.id, a.data), b.apply(this, a.data), delete this.acks[a.id]) : j("bad ack %s", a.id)
  3282. },
  3283. d.prototype.onconnect = function() {
  3284. this.connected = !0,
  3285. this.disconnected = !1,
  3286. this.emit("connect"),
  3287. this.emitBuffered()
  3288. },
  3289. d.prototype.emitBuffered = function() {
  3290. var a;
  3291. for (a = 0; a < this.receiveBuffer.length; a++) m.apply(this, this.receiveBuffer[a]);
  3292. for (this.receiveBuffer = [], a = 0; a < this.sendBuffer.length; a++) this.packet(this.sendBuffer[a]);
  3293. this.sendBuffer = []
  3294. },
  3295. d.prototype.ondisconnect = function() {
  3296. j("server disconnect (%s)", this.nsp),
  3297. this.destroy(),
  3298. this.onclose("io server disconnect")
  3299. },
  3300. d.prototype.destroy = function() {
  3301. if (this.subs) {
  3302. for (var a = 0; a < this.subs.length; a++) this.subs[a].destroy();
  3303. this.subs = null
  3304. }
  3305. this.io.destroy(this)
  3306. },
  3307. d.prototype.close = d.prototype.disconnect = function() {
  3308. return this.connected && (j("performing disconnect (%s)", this.nsp), this.packet({
  3309. type: e.DISCONNECT
  3310. })),
  3311. this.destroy(),
  3312. this.connected && this.onclose("io client disconnect"),
  3313. this
  3314. },
  3315. d.prototype.compress = function(a) {
  3316. return this.flags = this.flags || {},
  3317. this.flags.compress = a,
  3318. this
  3319. }
  3320. },
  3321. function(a, b) {
  3322. function c(a, b) {
  3323. var c = [];
  3324. b = b || 0;
  3325. for (var d = b || 0; d < a.length; d++) c[d - b] = a[d];
  3326. return c
  3327. }
  3328. a.exports = c
  3329. },
  3330. function(a, b) {
  3331. "use strict";
  3332. function c(a, b, c) {
  3333. return a.on(b, c),
  3334. {
  3335. destroy: function() {
  3336. a.removeListener(b, c)
  3337. }
  3338. }
  3339. }
  3340. a.exports = c
  3341. },
  3342. function(a, b) {
  3343. var c = [].slice;
  3344. a.exports = function(a, b) {
  3345. if ("string" == typeof b && (b = a[b]), "function" != typeof b) throw new Error("bind() requires a function");
  3346. var d = c.call(arguments, 2);
  3347. return function() {
  3348. return b.apply(a, d.concat(c.call(arguments)))
  3349. }
  3350. }
  3351. },
  3352. function(a, b) {
  3353. function c(a) {
  3354. a = a || {},
  3355. this.ms = a.min || 100,
  3356. this.max = a.max || 1e4,
  3357. this.factor = a.factor || 2,
  3358. this.jitter = a.jitter > 0 && a.jitter <= 1 ? a.jitter: 0,
  3359. this.attempts = 0
  3360. }
  3361. a.exports = c,
  3362. c.prototype.duration = function() {
  3363. var a = this.ms * Math.pow(this.factor, this.attempts++);
  3364. if (this.jitter) {
  3365. var b = Math.random(),
  3366. c = Math.floor(b * this.jitter * a);
  3367. a = 0 == (1 & Math.floor(10 * b)) ? a - c: a + c
  3368. }
  3369. return 0 | Math.min(a, this.max)
  3370. },
  3371. c.prototype.reset = function() {
  3372. this.attempts = 0
  3373. },
  3374. c.prototype.setMin = function(a) {
  3375. this.ms = a
  3376. },
  3377. c.prototype.setMax = function(a) {
  3378. this.max = a
  3379. },
  3380. c.prototype.setJitter = function(a) {
  3381. this.jitter = a
  3382. }
  3383. }])
  3384. });;
  3385. //////////////////////////////////////////////////////////////////////////////////////
  3386. // //
  3387. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� //
  3388. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺� //
  3389. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� //
  3390. // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺� //
  3391. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺椻枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳 //
  3392. // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 //
  3393. // //
  3394. // 鈺︹晹鈺愨晽鈺� 鈺︹晹鈺愨晽鈺斺晲鈺椻晹鈺愨晽鈺︹晲鈺椻暒鈺斺晲鈺椻晹鈺︹晽 鈺斺晲鈺椻暒 鈺︹晹鈺愨晽鈺斺晽鈺斺晹鈺︹晽 鈺斺晲鈺椻晹鈺︹晽鈺︹晹鈺� //
  3395. // 鈺戔暊鈺愨暎鈺氣晽鈺斺暆鈺犫晲鈺b暁鈺愨晽鈺� 鈺犫暒鈺濃晳鈺犫晲鈺� 鈺� 鈺� 鈺� 鈺戔晳鈺� 鈺戔晳鈺� 鈺� 鈺氣晲鈺� 鈺戔晳鈺犫暕鈺� //
  3396. // 鈺氣暆鈺� 鈺� 鈺氣暆 鈺� 鈺┾暁鈺愨暆鈺氣晲鈺濃暕鈺氣晲鈺┾暕 鈺� 鈺氣晲鈺濃暕鈺愨暆鈺┾暁鈺愨暆鈺濃暁鈺� 鈺� 鈺氣晲鈺濃晲鈺┾暆鈺� 鈺� //
  3397. // 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹� 鈹屸攼鈹屸攲鈹€鈹愨攲鈹攼鈹屸攢鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹愨攲鈹屸敩鈹� 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈹屸攼 鈹攢鈹愨攲鈹€鈹愨敩 鈹攲鈹€鈹愨攲鈹€鈹愨敩鈹€鈹� //
  3398. // 鈹溾敜 鈹� 鈹傗敎鈹敇 鈹傗攤鈹傗攤 鈹� 鈹傗攤鈹溾敜 鈹傗敂鈹€鈹� 鈹溾攢鈹も攤鈹傗攤 鈹傗攤 鈹� 鈹溾攢鈹も敎鈹� 鈹溾敶鈹愨敎鈹敇鈹� 鈹傗攤鈹傗攤鈹斺攢鈹愨敎鈹� 鈹溾敩鈹� //
  3399. // 鈹� 鈹斺攢鈹樷敶鈹斺攢 鈹樷敂鈹樷敂鈹€鈹樷攢鈹粹敇鈹斺攢鈹榦鈹斺敇鈹斺攢鈹� 鈹� 鈹粹敇鈹斺敇鈹€鈹粹敇 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹斺攢鈹樷敶鈹斺攢鈹斺攢鈹樷敂鈹粹敇鈹斺攢鈹樷敂鈹€鈹樷敶鈹斺攢 //
  3400. // //
  3401. //////////////////////////////////////////////////////////////////////////////////////
  3402. /**
  3403. * sails.io.js
  3404. * v1.1.12
  3405. * ------------------------------------------------------------------------
  3406. * JavaScript Client (SDK) for communicating with Sails.
  3407. *
  3408. * Note that this script is completely optional, but it is handy if you're
  3409. * using WebSockets from the browser to talk to your Sails server.
  3410. *
  3411. * For tips and documentation, visit:
  3412. * http://sailsjs.com/documentation/reference/web-sockets/socket-client
  3413. * ------------------------------------------------------------------------
  3414. *
  3415. * This file allows you to send and receive socket.io messages to & from Sails
  3416. * by simulating a REST client interface on top of socket.io. It models its API
  3417. * after the $.ajax pattern from jQuery you might already be familiar with.
  3418. *
  3419. * So if you're switching from using AJAX to sockets, instead of:
  3420. * `$.post( url, [data], [cb] )`
  3421. *
  3422. * You would use:
  3423. * `socket.post( url, [data], [cb] )`
  3424. */
  3425. (function() {
  3426. // 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3427. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆
  3428. // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3429. // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
  3430. // 鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳
  3431. // 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆
  3432. //
  3433. /**
  3434. * Constant containing the names of all available options
  3435. * for individual sockets.
  3436. *
  3437. * @type {Array}
  3438. */
  3439. var SOCKET_OPTIONS = ['useCORSRouteToGetCookie', 'url', 'multiplex', 'transports', 'query', 'path', 'headers', 'initialConnectionHeaders', 'reconnection', 'reconnectionAttempts', 'reconnectionDelay', 'reconnectionDelayMax', 'rejectUnauthorized', 'randomizationFactor', 'timeout'];
  3440. /**
  3441. * Constant containing the names of properties on `io.sails` which
  3442. * may be configured using HTML attributes on the script tag which
  3443. * loaded this file.
  3444. *
  3445. * @type {Array}
  3446. *
  3447. * (this is unused if loading from node.js)
  3448. */
  3449. var CONFIGURABLE_VIA_HTML_ATTR = ['autoConnect', 'reconnection', 'environment', 'headers', 'url', 'transports', 'path'];
  3450. /**
  3451. * Constant containing the names of querystring
  3452. * parameters sent when connecting any SailsSocket.
  3453. *
  3454. * @type {Dictionary}
  3455. */
  3456. var CONNECTION_METADATA_PARAMS = {
  3457. version: '__sails_io_sdk_version',
  3458. platform: '__sails_io_sdk_platform',
  3459. language: '__sails_io_sdk_language'
  3460. };
  3461. /**
  3462. * Constant containing metadata about the platform, language, and
  3463. * current version of this SDK.
  3464. *
  3465. * @type {Dictionary}
  3466. */
  3467. var SDK_INFO = {
  3468. version: '1.1.12',
  3469. // <-- pulled automatically from package.json, do not change!
  3470. language: 'javascript',
  3471. platform: (function() {
  3472. if (typeof module === 'object' && typeof module.exports !== 'undefined') {
  3473. return 'node';
  3474. } else {
  3475. return 'browser';
  3476. }
  3477. })()
  3478. };
  3479. // Build `versionString` (a querystring snippet) by
  3480. // combining SDK_INFO and CONNECTION_METADATA_PARAMS.
  3481. SDK_INFO.versionString = CONNECTION_METADATA_PARAMS.version + '=' + SDK_INFO.version + '&' + CONNECTION_METADATA_PARAMS.platform + '=' + SDK_INFO.platform + '&' + CONNECTION_METADATA_PARAMS.language + '=' + SDK_INFO.language;
  3482. // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚晽 鈻堚枅鈻堚晽鈻堚枅鈺�
  3483. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晳
  3484. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺斺枅鈻堚枅鈻堚晹鈻堚枅鈺戔枅鈻堚晳
  3485. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚晳
  3486. // 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺�
  3487. // 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺�
  3488. //
  3489. // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3490. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺濃暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆
  3491. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3492. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
  3493. // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳
  3494. // 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆
  3495. //
  3496. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽
  3497. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈺� 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈺氣枅鈻堚晽
  3498. // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈻堚枅鈺斺枅鈻堚晳 鈻堚枅鈺斺暆 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈺氣枅鈻堚晽
  3499. // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚晽 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨暆 鈻堚枅鈺� 鈻堚枅鈺斺暆
  3500. // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺� 鈺氣枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺暆
  3501. // 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺�
  3502. //
  3503. //
  3504. // If available, grab the DOM element for the script tag which imported this file.
  3505. // (skip this if this SDK is being used outside of the DOM, i.e. in a Node process)
  3506. //
  3507. // This is used below to parse client-side sails.io.js configuration encoded as
  3508. // HTML attributes, as well as grabbing hold of the URL from whence the SDK was fetched.
  3509. var thisScriptTag = (function() {
  3510. if (typeof window !== 'object' || typeof window.document !== 'object' || typeof window.document.getElementsByTagName !== 'function') {
  3511. return null;
  3512. }
  3513. // Return the URL of the last script loaded (i.e. this one)
  3514. // (this must run before nextTick; see http://stackoverflow.com/a/2976714/486547)
  3515. var allScriptsCurrentlyInDOM = window.document.getElementsByTagName('script');
  3516. return allScriptsCurrentlyInDOM[allScriptsCurrentlyInDOM.length - 1];
  3517. })();
  3518. // Variables to contain src URL and other script tag config (for use below).
  3519. var urlThisScriptWasFetchedFrom = '';
  3520. var scriptTagConfig = {};
  3521. if (thisScriptTag) {
  3522. // Save the URL that this script was fetched from.
  3523. urlThisScriptWasFetchedFrom = thisScriptTag.src;
  3524. // Now parse the most common client-side configuration settings
  3525. // from the script tag where they may be encoded as HTML attributes.
  3526. //
  3527. // Any configuration which may be provided as an HTML attribute may
  3528. // also be provided prefixed with `data-`. This is for folks who
  3529. // need to support browsers that have issues with nonstandard
  3530. // HTML attributes (or if the idea of using nonstandard HTML attributes
  3531. // just creeps you out)
  3532. //
  3533. // If a `data-` prefixed attr is provided, it takes precedence.
  3534. // (this is so that if you are already using one of these HTML
  3535. // attrs for some reason, you can keep it as-is and override
  3536. // it using `data-`. If you are using the `data-` prefixed version
  3537. // for some other purpose... well, in that case you'll just have to
  3538. // configure programmatically using `io.sails` instead.)
  3539. CONFIGURABLE_VIA_HTML_ATTR.forEach(function(configKey) {
  3540. scriptTagConfig[configKey] = (function() {
  3541. // Support 'data-' prefixed or normal attributes.
  3542. // (prefixed versions take precedence if provided)
  3543. var htmlAttrVal = thisScriptTag.getAttribute('data-' + configKey);
  3544. if (!htmlAttrVal) {
  3545. htmlAttrVal = thisScriptTag.getAttribute(configKey);
  3546. }
  3547. // The HTML attribute value should always be a string or `null`.
  3548. // We'll try to parse it as JSON and use that, but worst case fall back
  3549. // to the default situation of it being a string.
  3550. if (typeof htmlAttrVal === 'string') {
  3551. try {
  3552. return JSON.parse(htmlAttrVal);
  3553. } catch(e) {
  3554. return htmlAttrVal;
  3555. }
  3556. }
  3557. // If `null` was returned from getAttribute(), it means that the HTML attribute
  3558. // was not specified, so we treat it as undefined (which will cause the property
  3559. // to be removed below)
  3560. else if (htmlAttrVal === null) {
  3561. return undefined;
  3562. }
  3563. // Any other contingency shouldn't be possible:
  3564. // - if no quotes are used in the HTML attribute, it still comes in as a string.
  3565. // - if no RHS is provided for the attribute, it still comes in as "" (empty string)
  3566. // (but we still handle this with an explicit error just in case--for debugging and support purposes)
  3567. else throw new Error('sails.io.js :: Unexpected/invalid script tag configuration for `' + configKey + '`: `' + htmlAttrVal + '` (a `' + typeof htmlAttrVal + '`). Should be a string.');
  3568. })();
  3569. if (scriptTagConfig[configKey] === undefined) {
  3570. delete scriptTagConfig[configKey];
  3571. }
  3572. });
  3573. // Now that they've been parsed, do an extremely lean version of
  3574. // logical type validation/coercion of provided values.
  3575. //////////////////////////////////////////////////////////////////
  3576. // `autoConnect`
  3577. if (typeof scriptTagConfig.autoConnect !== 'undefined') {
  3578. if (scriptTagConfig.autoConnect === '') {
  3579. // Special case for empty string. It means `true` (see above).
  3580. scriptTagConfig.autoConnect = true;
  3581. } else if (typeof scriptTagConfig.autoConnect !== 'boolean') {
  3582. throw new Error('sails.io.js :: Unexpected/invalid configuration for `autoConnect` provided in script tag: `' + scriptTagConfig.autoConnect + '` (a `' + typeof scriptTagConfig.autoConnect + '`). Should be a boolean.');
  3583. }
  3584. }
  3585. // `environment`
  3586. if (typeof scriptTagConfig.environment !== 'undefined') {
  3587. if (typeof scriptTagConfig.environment !== 'string') {
  3588. throw new Error('sails.io.js :: Unexpected/invalid configuration for `environment` provided in script tag: `' + scriptTagConfig.environment + '` (a `' + typeof scriptTagConfig.environment + '`). Should be a string.');
  3589. }
  3590. }
  3591. // `headers`
  3592. if (typeof scriptTagConfig.headers !== 'undefined') {
  3593. if (typeof scriptTagConfig.headers !== 'object' || Array.isArray(scriptTagConfig.headers)) {
  3594. throw new Error('sails.io.js :: Unexpected/invalid configuration for `headers` provided in script tag: `' + scriptTagConfig.headers + '` (a `' + typeof scriptTagConfig.headers + '`). Should be a JSON-compatible dictionary (i.e. `{}`). Don\'t forget those double quotes (""), even on key names! Use single quotes (\'\') to wrap the HTML attribute value; e.g. `headers=\'{"X-Auth": "foo"}\'`');
  3595. }
  3596. }
  3597. // `url`
  3598. if (typeof scriptTagConfig.url !== 'undefined') {
  3599. if (typeof scriptTagConfig.url !== 'string') {
  3600. throw new Error('sails.io.js :: Unexpected/invalid configuration for `url` provided in script tag: `' + scriptTagConfig.url + '` (a `' + typeof scriptTagConfig.url + '`). Should be a string.');
  3601. }
  3602. }
  3603. // OTHER `io.sails` options are NOT CURRENTLY SUPPORTED VIA HTML ATTRIBUTES.
  3604. }
  3605. // Grab a reference to the global socket.io client (if one is available).
  3606. // This is used via closure below to determine which `io` to use when the
  3607. // socket.io client instance (`io`) is augmented to become the Sails client
  3608. // SDK instance (still `io`).
  3609. var _existingGlobalSocketIO = (typeof io !== 'undefined') ? io: undefined;
  3610. //////////////////////////////////////////////////////////////
  3611. /////
  3612. ///// NOW FOR BUNCHES OF:
  3613. ///// - PRIVATE FUNCTION DEFINITIONS
  3614. ///// - CONSTRUCTORS
  3615. ///// - AND METHODS
  3616. /////
  3617. //////////////////////////////////////////////////////////////
  3618. //
  3619. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3620. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚枅鈻堚晽 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆
  3621. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺�
  3622. // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈺氣晲鈺愨晲鈺愨暆鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺�
  3623. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆 鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈻堚枅鈺�
  3624. // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺�
  3625. //
  3626. /**
  3627. * SailsIOClient()
  3628. *
  3629. * Augment the provided Socket.io client object (`io`) with methods for
  3630. * talking and listening to one or more Sails backend(s). If no `io` was
  3631. * provided (i.e. in a browser setting), then attempt to use the global.
  3632. *
  3633. * This absorbs implicit `io.sails` configuration, sets a timer for
  3634. * automatically connecting a socket (if `io.sails.autoConnect` is enabled)
  3635. * and returns the augmented `io`.
  3636. *
  3637. * Note:
  3638. * The automatically-connected socket is exposed as `io.socket`. If this
  3639. * socket attempts to bind event listeners or send requests before it is
  3640. * connected, it will be queued up and replayed when the connection is
  3641. * successfully opened.
  3642. *
  3643. * @param {SocketIO} io
  3644. * @returns {SailsIOClient} [also called `io`]
  3645. */
  3646. function SailsIOClient(_providedSocketIO) {
  3647. // First, determine which `io` we're augmenting.
  3648. //
  3649. // Prefer the passed-in `io` instance, but fall back to the
  3650. // global one if we've got it.
  3651. var io;
  3652. if (_providedSocketIO) {
  3653. io = _providedSocketIO;
  3654. } else {
  3655. io = _existingGlobalSocketIO;
  3656. }
  3657. // (note that for readability, we deliberately do not short circuit or use the tertiary operator above)
  3658. // If a socket.io client (`io`) is not available, none of this will work.
  3659. if (!io) {
  3660. // If node:
  3661. if (SDK_INFO.platform === 'node') {
  3662. throw new Error('No socket.io client available. When requiring `sails.io.js` from Node.js, a socket.io client (`io`) must be passed in; e.g.:\n```\nvar io = require(\'sails.io.js\')( require(\'socket.io-client\') )\n```\n(see https://github.com/balderdashy/sails.io.js/tree/master/test for more examples)');
  3663. }
  3664. // Otherwise, this is a web browser:
  3665. else {
  3666. throw new Error('The Sails socket SDK depends on the socket.io client, but the socket.io global (`io`) was not available when `sails.io.js` loaded. Normally, the socket.io client code is bundled with sails.io.js, so something is a little off. Please check to be sure this version of `sails.io.js` has the minified Socket.io client at the top of the file.');
  3667. }
  3668. }
  3669. // If the chosen socket.io client (`io`) has ALREADY BEEN AUGMENTED by this SDK,
  3670. // (i.e. if it already has a `.sails` property) then throw an error.
  3671. if (io.sails) {
  3672. // If node:
  3673. if (SDK_INFO.platform === 'node') {
  3674. throw new Error('The provided socket.io client (`io`) has already been augmented into a Sails socket SDK instance (it has `io.sails`).');
  3675. }
  3676. // Otherwise, this is a web browser:
  3677. else {
  3678. throw new Error('The socket.io client (`io`) has already been augmented into a Sails socket SDK instance. Usually, this means you are bringing `sails.io.js` onto the page more than once.');
  3679. }
  3680. }
  3681. /**
  3682. * A little logger for this library to use internally.
  3683. * Basically just a wrapper around `console.log` with
  3684. * support for feature-detection.
  3685. *
  3686. * @api private
  3687. * @factory
  3688. */
  3689. function LoggerFactory(options) {
  3690. options = options || {
  3691. prefix: true
  3692. };
  3693. // If `console.log` is not accessible, `log` is a noop.
  3694. if (typeof console !== 'object' || typeof console.log !== 'function' || typeof console.log.bind !== 'function') {
  3695. return function noop() {};
  3696. }
  3697. return function log() {
  3698. var args = Array.prototype.slice.call(arguments);
  3699. // All logs are disabled when `io.sails.environment = 'production'`.
  3700. if (io.sails.environment === 'production') return;
  3701. // Add prefix to log messages (unless disabled)
  3702. var PREFIX = '';
  3703. if (options.prefix) {
  3704. args.unshift(PREFIX);
  3705. }
  3706. // Call wrapped logger
  3707. console.log.bind(console).apply(this, args);
  3708. };
  3709. } //</LoggerFactory>
  3710. // Create a private logger instance
  3711. var consolog = LoggerFactory();
  3712. consolog.noPrefix = LoggerFactory({
  3713. prefix: false
  3714. });
  3715. /**
  3716. * What is the `requestQueue`?
  3717. *
  3718. * The request queue is used to simplify app-level connection logic--
  3719. * i.e. so you don't have to wait for the socket to be connected
  3720. * to start trying to synchronize data.
  3721. *
  3722. * @api private
  3723. * @param {SailsSocket} socket
  3724. */
  3725. function runRequestQueue(socket) {
  3726. var queue = socket.requestQueue;
  3727. if (!queue) return;
  3728. for (var i in queue) {
  3729. // Double-check that `queue[i]` will not
  3730. // inadvertently discover extra properties attached to the Object
  3731. // and/or Array prototype by other libraries/frameworks/tools.
  3732. // (e.g. Ember does this. See https://github.com/balderdashy/sails.io.js/pull/5)
  3733. var isSafeToDereference = ({}).hasOwnProperty.call(queue, i);
  3734. if (isSafeToDereference) {
  3735. // Get the arguments that were originally made to the "request" method
  3736. var requestArgs = queue[i];
  3737. // Call the request method again in the context of the socket, with the original args
  3738. socket.request.apply(socket, requestArgs);
  3739. }
  3740. }
  3741. // Now empty the queue to remove it as a source of additional complexity.
  3742. socket.requestQueue = null;
  3743. }
  3744. /**
  3745. * Send a JSONP request.
  3746. *
  3747. * @param {Object} opts [optional]
  3748. * @param {Function} cb
  3749. * @return {XMLHttpRequest}
  3750. */
  3751. function jsonp(opts, cb) {
  3752. opts = opts || {};
  3753. if (typeof window === 'undefined') {
  3754. // FUTURE: refactor node usage to live in here
  3755. return cb();
  3756. }
  3757. var scriptEl = document.createElement('script');
  3758. window._sailsIoJSConnect = function(response) {
  3759. // In rare circumstances our script may have been vaporised.
  3760. // Remove it, but only if it still exists
  3761. // https://github.com/balderdashy/sails.io.js/issues/92
  3762. if (scriptEl && scriptEl.parentNode) {
  3763. scriptEl.parentNode.removeChild(scriptEl);
  3764. }
  3765. cb(response);
  3766. };
  3767. scriptEl.src = opts.url;
  3768. document.getElementsByTagName('head')[0].appendChild(scriptEl);
  3769. }
  3770. // 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3771. // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺� 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
  3772. // 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚晽 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
  3773. // 鈻堚枅 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈺濃枅鈻堚晳鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
  3774. // 鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈺氣枅鈻堚枅鈺斺枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃暁鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
  3775. // 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺愨暆鈺氣晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
  3776. //
  3777. // 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
  3778. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺� 鈻堚枅鈺斺暆 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻暁鈻堚枅鈺�
  3779. // 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚晽 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺�
  3780. // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨暆 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺�
  3781. // 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚晳 鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈺氣枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈺斺枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺�
  3782. // 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨暆鈺氣晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆
  3783. //
  3784. /**
  3785. * The JWR (JSON WebSocket Response) received from a Sails server.
  3786. *
  3787. * @api public
  3788. * @param {Object} responseCtx
  3789. * => :body
  3790. * => :statusCode
  3791. * => :headers
  3792. *
  3793. * @constructor
  3794. */
  3795. function JWR(responseCtx) {
  3796. this.body = responseCtx.body;
  3797. this.headers = responseCtx.headers || {};
  3798. this.statusCode = (typeof responseCtx.statusCode === 'undefined') ? 200 : responseCtx.statusCode;
  3799. // FUTURE: Replace this typeof short-circuit with an assertion (statusCode should always be set)
  3800. if (this.statusCode < 200 || this.statusCode >= 400) {
  3801. // Determine the appropriate error message.
  3802. var msg;
  3803. if (this.statusCode === 0) {
  3804. msg = 'The socket request failed.';
  3805. } else {
  3806. msg = 'Server responded with a ' + this.statusCode + ' status code';
  3807. msg += ':\n```\n' + JSON.stringify(this.body, null, 2) + '\n```';
  3808. // (^^Note that we should always be able to rely on socket.io to give us
  3809. // non-circular data here, so we don't have to worry about wrapping the
  3810. // above in a try...catch)
  3811. }
  3812. // Now build and attach Error instance.
  3813. this.error = new Error(msg);
  3814. }
  3815. }
  3816. JWR.prototype.toString = function() {
  3817. return '[ResponseFromSails]' + ' -- ' + 'Status: ' + this.statusCode + ' -- ' + 'Headers: ' + this.headers + ' -- ' + 'Body: ' + this.body;
  3818. };
  3819. JWR.prototype.toPOJO = function() {
  3820. return {
  3821. body: this.body,
  3822. headers: this.headers,
  3823. statusCode: this.statusCode
  3824. };
  3825. };
  3826. JWR.prototype.pipe = function() {
  3827. // FUTURE: look at substack's stuff
  3828. return new Error('Client-side streaming support not implemented yet.');
  3829. };
  3830. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚晽 鈻堚枅鈻堚晽鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽
  3831. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晳鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晹鈺濃暁鈻堚枅鈺�
  3832. // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺斺枅鈻堚枅鈻堚晹鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈻堚枅鈺斺枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺�
  3833. // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺戔暁鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晹鈺濃枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺�
  3834. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晹鈺�
  3835. // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆
  3836. //
  3837. /**
  3838. * @api private
  3839. * @param {SailsSocket} socket [description]
  3840. * @param {Object} requestCtx [description]
  3841. */
  3842. function _emitFrom(socket, requestCtx) {
  3843. if (!socket._raw) {
  3844. throw new Error('Failed to emit from socket- raw SIO socket is missing.');
  3845. }
  3846. // Since callback is embedded in requestCtx,
  3847. // retrieve it and delete the key before continuing.
  3848. var cb = requestCtx.cb;
  3849. delete requestCtx.cb;
  3850. // Name of the appropriate socket.io listener on the server
  3851. // ( === the request method or "verb", e.g. 'get', 'post', 'put', etc. )
  3852. var sailsEndpoint = requestCtx.method;
  3853. socket._raw.emit(sailsEndpoint, requestCtx,
  3854. function serverResponded(responseCtx) {
  3855. // Send back (emulatedHTTPBody, jsonWebSocketResponse)
  3856. if (cb) {
  3857. cb(responseCtx.body, new JWR(responseCtx));
  3858. }
  3859. });
  3860. }
  3861. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  3862. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
  3863. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
  3864. // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
  3865. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃暁鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
  3866. // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
  3867. //
  3868. /**
  3869. * SailsSocket
  3870. *
  3871. * A wrapper for an underlying Socket instance that communicates directly
  3872. * to the Socket.io server running inside of Sails.
  3873. *
  3874. * If no `socket` option is provied, SailsSocket will function as a mock. It will queue socket
  3875. * requests and event handler bindings, replaying them when the raw underlying socket actually
  3876. * connects. This is handy when we don't necessarily have the valid configuration to know
  3877. * WHICH SERVER to talk to yet, etc. It is also used by `io.socket` for your convenience.
  3878. *
  3879. * @constructor
  3880. * @api private
  3881. *
  3882. * ----------------------------------------------------------------------
  3883. * Note: This constructor should not be used directly. To obtain a `SailsSocket`
  3884. * instance of your very own, run:
  3885. * ```
  3886. * var mySocket = io.sails.connect();
  3887. * ```
  3888. * ----------------------------------------------------------------------
  3889. */
  3890. function SailsSocket(opts) {
  3891. var self = this;
  3892. opts = opts || {};
  3893. // Initialize private properties
  3894. self._isConnecting = false;
  3895. self._mightBeAboutToAutoConnect = false;
  3896. // Set up connection options so that they can only be changed when socket is disconnected.
  3897. var _opts = {};
  3898. SOCKET_OPTIONS.forEach(function(option) {
  3899. // Okay to change global headers while socket is connected
  3900. if (option == 'headers') {
  3901. return;
  3902. }
  3903. Object.defineProperty(self, option, {
  3904. get: function() {
  3905. if (option == 'url') {
  3906. return _opts[option] || (self._raw && self._raw.io && self._raw.io.uri);
  3907. }
  3908. return _opts[option];
  3909. },
  3910. set: function(value) {
  3911. // Don't allow value to be changed while socket is connected
  3912. if (self.isConnected() && io.sails.strict !== false && value != _opts[option]) {
  3913. throw new Error('Cannot change value of `' + option + '` while socket is connected.');
  3914. }
  3915. // If socket is attempting to reconnect, stop it.
  3916. if (self._raw && self._raw.io && self._raw.io.reconnecting && !self._raw.io.skipReconnect) {
  3917. self._raw.io.skipReconnect = true;
  3918. consolog('Stopping reconnect; use .reconnect() to connect socket after changing options.');
  3919. }
  3920. _opts[option] = value;
  3921. }
  3922. });
  3923. });
  3924. // Absorb opts into SailsSocket instance
  3925. // See http://sailsjs.com/documentation/reference/web-sockets/socket-client/sails-socket/properties
  3926. // for description of options
  3927. SOCKET_OPTIONS.forEach(function(option) {
  3928. self[option] = opts[option];
  3929. });
  3930. // Set up "eventQueue" to hold event handlers which have not been set on the actual raw socket yet.
  3931. self.eventQueue = {};
  3932. // Listen for special `parseError` event sent from sockets hook on the backend
  3933. // if an error occurs but a valid callback was not received from the client
  3934. // (i.e. so the server had no other way to send back the error information)
  3935. self.on('sails:parseError',
  3936. function(err) {
  3937. consolog('Sails encountered an error parsing a socket message sent from this client, and did not have access to a callback function to respond with.');
  3938. consolog('Error details:', err);
  3939. });
  3940. // FUTURE:
  3941. // Listen for a special private message on any connected that allows the server
  3942. // to set the environment (giving us 100% certainty that we guessed right)
  3943. // However, note that the `console.log`s called before and after connection
  3944. // are still forced to rely on our existing heuristics (to disable, tack #production
  3945. // onto the URL used to fetch this file.)
  3946. } //</SailsSocket>
  3947. /**
  3948. * `SailsSocket.prototype._connect()`
  3949. *
  3950. * Begin connecting this socket to the server.
  3951. *
  3952. * @api private
  3953. */
  3954. SailsSocket.prototype._connect = function() {
  3955. var self = this;
  3956. self._isConnecting = true;
  3957. // Apply `io.sails` config as defaults
  3958. // (now that at least one tick has elapsed)
  3959. // See http://sailsjs.com/documentation/reference/web-sockets/socket-client/sails-socket/properties
  3960. // for description of options and default values
  3961. SOCKET_OPTIONS.forEach(function(option) {
  3962. if ('undefined' == typeof self[option]) {
  3963. self[option] = io.sails[option];
  3964. }
  3965. });
  3966. // Headers that will be sent with the initial request to /socket.io (Node.js only)
  3967. self.extraHeaders = self.initialConnectionHeaders || {};
  3968. // Log a warning if non-Node.js platform attempts to use `initialConnectionHeaders`
  3969. if (self.initialConnectionHeaders && SDK_INFO.platform !== 'node') {
  3970. if (typeof console === 'object' && typeof console.warn === 'function') {
  3971. console.warn('initialConnectionHeaders option available in Node.js only!');
  3972. }
  3973. }
  3974. // Ensure URL has no trailing slash
  3975. self.url = self.url ? self.url.replace(/(\/)$/, '') : undefined;
  3976. // Mix the current SDK version into the query string in
  3977. // the connection request to the server:
  3978. if (typeof self.query === 'string') {
  3979. // (If provided as a string, trim leading question mark,
  3980. // just in case one was provided.)
  3981. self.query = self.query.replace(/^\?/, '');
  3982. self.query += '&' + SDK_INFO.versionString;
  3983. } else if (self.query && typeof self.query === 'object') {
  3984. throw new Error('`query` setting does not currently support configuration as a dictionary (`{}`). Instead, it must be specified as a string like `foo=89&bar=hi`');
  3985. } else if (!self.query) {
  3986. self.query = SDK_INFO.versionString;
  3987. } else {
  3988. throw new Error('Unexpected data type provided for `query` setting: ' + self.query);
  3989. }
  3990. // Determine whether this is a cross-origin socket by examining the
  3991. // hostname and port on the `window.location` object. If it's cross-origin,
  3992. // we'll attempt to get a cookie for the domain so that a Sails session can
  3993. // be established.
  3994. var isXOrigin = (function() {
  3995. // If `window` doesn't exist (i.e. being used from Node.js), then
  3996. // we won't bother attempting to get a cookie. If you're using sockets
  3997. // from Node.js and find you need to share a session between multiple
  3998. // socket connections, you'll need to make an HTTP request to the /__getcookie
  3999. // endpoint of the Sails server (or any endpoint that returns a set-cookie header)
  4000. // and then use the cookie value in the `initialConnectionHeaders` option to
  4001. // io.sails.connect()
  4002. if (typeof window === 'undefined' || typeof window.location === 'undefined') {
  4003. return false;
  4004. }
  4005. // If `self.url` (aka "target") is falsy, then we don't need to worry about it.
  4006. if (typeof self.url !== 'string') {
  4007. return false;
  4008. }
  4009. // Get information about the "target" (`self.url`)
  4010. var targetProtocol = (function() {
  4011. try {
  4012. targetProtocol = self.url.match(/^([a-z]+:\/\/)/i)[1].toLowerCase();
  4013. } catch(e) {}
  4014. targetProtocol = targetProtocol || 'http://';
  4015. return targetProtocol;
  4016. })();
  4017. var isTargetSSL = !!self.url.match('^https');
  4018. var targetPort = (function() {
  4019. try {
  4020. return self.url.match(/^[a-z]+:\/\/[^:]*:([0-9]*)/i)[1];
  4021. } catch(e) {}
  4022. return isTargetSSL ? '443': '80';
  4023. })();
  4024. var targetAfterProtocol = self.url.replace(/^([a-z]+:\/\/)/i, '');
  4025. // If target protocol is different than the actual protocol,
  4026. // then we'll consider this cross-origin.
  4027. if (targetProtocol.replace(/[:\/]/g, '') !== window.location.protocol.replace(/[:\/]/g, '')) {
  4028. return true;
  4029. }
  4030. // If target hostname is different than actual hostname, we'll consider this cross-origin.
  4031. var hasSameHostname = targetAfterProtocol.search(window.location.hostname) === 0;
  4032. if (!hasSameHostname) {
  4033. return true;
  4034. }
  4035. // If no actual port is explicitly set on the `window.location` object,
  4036. // we'll assume either 80 or 443.
  4037. var isLocationSSL = window.location.protocol.match(/https/i);
  4038. var locationPort = (window.location.port + '') || (isLocationSSL ? '443': '80');
  4039. // Finally, if ports don't match, we'll consider this cross-origin.
  4040. if (targetPort !== locationPort) {
  4041. return true;
  4042. }
  4043. // Otherwise, it's the same origin.
  4044. return false;
  4045. })();
  4046. // Prepare to start connecting the socket
  4047. (function selfInvoking(cb) {
  4048. // If this is an attempt at a cross-origin or cross-port
  4049. // socket connection via a browswe, send a JSONP request
  4050. // first to ensure that a valid cookie is available.
  4051. // This can be disabled by setting `io.sails.useCORSRouteToGetCookie`
  4052. // to false.
  4053. //
  4054. // Otherwise, skip the stuff below.
  4055. //
  4056. if (! (self.useCORSRouteToGetCookie && isXOrigin)) {
  4057. return cb();
  4058. }
  4059. // Figure out the x-origin CORS route
  4060. // (Sails provides a default)
  4061. var xOriginCookieURL = self.url;
  4062. if (typeof self.useCORSRouteToGetCookie === 'string') {
  4063. xOriginCookieURL += self.useCORSRouteToGetCookie;
  4064. } else {
  4065. xOriginCookieURL += '/__getcookie';
  4066. }
  4067. // Make the AJAX request (CORS)
  4068. jsonp({
  4069. url: xOriginCookieURL,
  4070. method: 'GET'
  4071. },
  4072. cb);
  4073. })(function goAheadAndActuallyConnect() {
  4074. // Now that we're ready to connect, create a raw underlying Socket
  4075. // using Socket.io and save it as `_raw` (this will start it connecting)
  4076. self._raw = io(self.url, self);
  4077. // If the low-level transport throws an error _while connecting_, then set the _isConnecting flag
  4078. // to false (since we're no longer connecting with any chance of success anyway).
  4079. // Also, in this case (and in dev mode only) log a helpful message.
  4080. self._raw.io.engine.transport.on('error',
  4081. function(err) {
  4082. if (!self._isConnecting) {
  4083. return;
  4084. }
  4085. self._isConnecting = false;
  4086. // Development-only message:
  4087. consolog('=============================================================================');
  4088. consolog('The socket was unable to connect. The server may be offline, or the socket ');
  4089. consolog('may have failed authorization based on its origin or other factors.');
  4090. consolog('You may want to check the values of `sails.config.sockets.beforeConnect` and');
  4091. consolog('`sails.config.sockets.onlyAllowOrigins` in your app.');
  4092. consolog('More info: https://sailsjs.com/config/sockets');
  4093. consolog('');
  4094. consolog('Technical details:');
  4095. consolog(err);
  4096. consolog('=============================================================================');
  4097. });
  4098. // Replay event bindings from the eager socket
  4099. self.replay();
  4100. /**
  4101. * 'connect' event is triggered when the socket establishes a connection
  4102. * successfully.
  4103. */
  4104. self.on('connect',
  4105. function socketConnected() {
  4106. self._isConnecting = false;
  4107. consolog.noPrefix('\n' + '\n' +
  4108. // ' |> ' + '\n' +
  4109. // ' \\___/ '+锔�
  4110. // '\n'+
  4111. ' |> Now connected to Sails.' + '\n' + '\\___/ For help, see: http://bit.ly/1DmTvgK' + '\n' + ' (using sails.io.js ' + io.sails.sdk.platform + ' SDK @v' + io.sails.sdk.version + ')' + '\n' + '\n' + '\n' +
  4112. // '\n'+
  4113. ''
  4114. // ' 鈿擄笌 (development mode)'
  4115. // 'e.g. to send a GET request to Sails via WebSockets, run:'+ '\n' +
  4116. // '`io.socket.get("/foo", function serverRespondedWith (body, jwr) { console.log(body); })`'+ '\n' +
  4117. );
  4118. });
  4119. self.on('disconnect',
  4120. function() {
  4121. self.connectionLostTimestamp = (new Date()).getTime();
  4122. consolog('====================================');
  4123. consolog('Socket was disconnected from Sails.');
  4124. consolog('Usually, this is due to one of the following reasons:' + '\n' + ' -> the server ' + (self.url ? self.url + ' ': '') + 'was taken down' + '\n' + ' -> your browser lost internet connectivity');
  4125. consolog('====================================');
  4126. });
  4127. self.on('reconnecting',
  4128. function(numAttempts) {
  4129. consolog('\n' + ' Socket is trying to reconnect to Sails...\n' + '_-|>_- (attempt #' + numAttempts + ')' + '\n' + '\n');
  4130. });
  4131. self.on('reconnect',
  4132. function(transport, numAttempts) {
  4133. if (!self._isConnecting) {
  4134. self.on('connect', runRequestQueue.bind(self, self));
  4135. }
  4136. var msSinceConnectionLost = ((new Date()).getTime() - self.connectionLostTimestamp);
  4137. var numSecsOffline = (msSinceConnectionLost / 1000);
  4138. consolog('\n' + ' |> Socket reconnected successfully after' + '\n' + '\\___/ being offline for ~' + numSecsOffline + ' seconds.' + '\n' + '\n');
  4139. });
  4140. // 'error' event is triggered if connection can not be established.
  4141. // (usually because of a failed authorization, which is in turn
  4142. // usually due to a missing or invalid cookie)
  4143. self.on('error',
  4144. function failedToConnect(err) {
  4145. self._isConnecting = false;
  4146. ////////////////////////////////////////////////////////////////////////////////////
  4147. // Note:
  4148. // In the future, we could provide a separate event for when a socket cannot connect
  4149. // due to a failed `beforeConnect` (aka "authorization" if you're old school).
  4150. // this could probably be implemented by emitting a special event from the server.
  4151. ////////////////////////////////////////////////////////////////////////////////////
  4152. consolog('Failed to connect socket (possibly due to failed `beforeConnect` on server)', 'Error:', err);
  4153. });
  4154. });
  4155. };
  4156. /**
  4157. * Reconnect the underlying socket.
  4158. *
  4159. * @api public
  4160. */
  4161. SailsSocket.prototype.reconnect = function() {
  4162. if (this._isConnecting) {
  4163. throw new Error('Cannot connect- socket is already connecting');
  4164. }
  4165. if (this.isConnected()) {
  4166. throw new Error('Cannot connect- socket is already connected');
  4167. }
  4168. return this._connect();
  4169. };
  4170. /**
  4171. * Disconnect the underlying socket.
  4172. *
  4173. * @api public
  4174. */
  4175. SailsSocket.prototype.disconnect = function() {
  4176. this._isConnecting = false;
  4177. if (!this.isConnected()) {
  4178. throw new Error('Cannot disconnect- socket is already disconnected');
  4179. }
  4180. return this._raw.disconnect();
  4181. };
  4182. /**
  4183. * isConnected
  4184. *
  4185. * @return {Boolean} whether the socket is connected and able to
  4186. * communicate w/ the server.
  4187. */
  4188. SailsSocket.prototype.isConnected = function() {
  4189. if (!this._raw) {
  4190. return false;
  4191. }
  4192. return !! this._raw.connected;
  4193. };
  4194. /**
  4195. * isConnecting
  4196. *
  4197. * @return {Boolean} whether the socket is in the process of connecting
  4198. * to the server.
  4199. */
  4200. SailsSocket.prototype.isConnecting = function() {
  4201. return this._isConnecting;
  4202. };
  4203. /**
  4204. * isConnecting
  4205. *
  4206. * @return {Boolean} flag that is `true` after a SailsSocket instance is
  4207. * initialized but before one tick of the event loop
  4208. * has passed (so that it hasn't attempted to connect
  4209. * yet, if autoConnect ends up being configured `true`)
  4210. */
  4211. SailsSocket.prototype.mightBeAboutToAutoConnect = function() {
  4212. return this._mightBeAboutToAutoConnect;
  4213. };
  4214. /**
  4215. * [replay description]
  4216. * @return {[type]} [description]
  4217. */
  4218. SailsSocket.prototype.replay = function() {
  4219. var self = this;
  4220. // Pass events and a reference to the request queue
  4221. // off to the self._raw for consumption
  4222. for (var evName in self.eventQueue) {
  4223. for (var i in self.eventQueue[evName]) {
  4224. self._raw.on(evName, self.eventQueue[evName][i]);
  4225. }
  4226. }
  4227. // Bind a one-time function to run the request queue
  4228. // when the self._raw connects.
  4229. if (!self.isConnected()) {
  4230. self._raw.once('connect', runRequestQueue.bind(self, self));
  4231. }
  4232. // Or run it immediately if self._raw is already connected
  4233. else {
  4234. runRequestQueue(self);
  4235. }
  4236. return self;
  4237. };
  4238. /**
  4239. * Chainable method to bind an event to the socket.
  4240. *
  4241. * @param {String} evName [event name]
  4242. * @param {Function} fn [event handler function]
  4243. * @return {SailsSocket}
  4244. */
  4245. SailsSocket.prototype.on = function(evName, fn) {
  4246. // Bind the event to the raw underlying socket if possible.
  4247. if (this._raw) {
  4248. this._raw.on(evName, fn);
  4249. return this;
  4250. }
  4251. // Otherwise queue the event binding.
  4252. if (!this.eventQueue[evName]) {
  4253. this.eventQueue[evName] = [fn];
  4254. } else {
  4255. this.eventQueue[evName].push(fn);
  4256. }
  4257. return this;
  4258. };
  4259. /**
  4260. * Chainable method to unbind an event from the socket.
  4261. *
  4262. * @param {String} evName [event name]
  4263. * @param {Function} fn [event handler function]
  4264. * @return {SailsSocket}
  4265. */
  4266. SailsSocket.prototype.off = function(evName, fn) {
  4267. // Bind the event to the raw underlying socket if possible.
  4268. if (this._raw) {
  4269. this._raw.off(evName, fn);
  4270. return this;
  4271. }
  4272. // Otherwise queue the event binding.
  4273. if (this.eventQueue[evName] && this.eventQueue[evName].indexOf(fn) > -1) {
  4274. this.eventQueue[evName].splice(this.eventQueue[evName].indexOf(fn), 1);
  4275. }
  4276. return this;
  4277. };
  4278. /**
  4279. * Chainable method to unbind all events from the socket.
  4280. *
  4281. * @return {SailsSocket}
  4282. */
  4283. SailsSocket.prototype.removeAllListeners = function() {
  4284. // Bind the event to the raw underlying socket if possible.
  4285. if (this._raw) {
  4286. this._raw.removeAllListeners();
  4287. return this;
  4288. }
  4289. // Otherwise queue the event binding.
  4290. this.eventQueue = {};
  4291. return this;
  4292. };
  4293. /**
  4294. * Simulate a GET request to sails
  4295. * e.g.
  4296. * `socket.get('/user/3', Stats.populate)`
  4297. *
  4298. * @api public
  4299. * @param {String} url :: destination URL
  4300. * @param {Object} data :: parameters to send with the request [optional]
  4301. * @param {Function} cb :: callback function to call when finished [optional]
  4302. */
  4303. SailsSocket.prototype.get = function(url, data, cb) {
  4304. // `data` is optional
  4305. if (typeof data === 'function') {
  4306. cb = data;
  4307. data = {};
  4308. }
  4309. return this.request({
  4310. method: 'get',
  4311. params: data,
  4312. url: url
  4313. },
  4314. cb);
  4315. };
  4316. /**
  4317. * Simulate a POST request to sails
  4318. * e.g.
  4319. * `socket.post('/event', newMeeting, $spinner.hide)`
  4320. *
  4321. * @api public
  4322. * @param {String} url :: destination URL
  4323. * @param {Object} data :: parameters to send with the request [optional]
  4324. * @param {Function} cb :: callback function to call when finished [optional]
  4325. */
  4326. SailsSocket.prototype.post = function(url, data, cb) {
  4327. // `data` is optional
  4328. if (typeof data === 'function') {
  4329. cb = data;
  4330. data = {};
  4331. }
  4332. return this.request({
  4333. method: 'post',
  4334. data: data,
  4335. url: url
  4336. },
  4337. cb);
  4338. };
  4339. /**
  4340. * Simulate a PUT request to sails
  4341. * e.g.
  4342. * `socket.post('/event/3', changedFields, $spinner.hide)`
  4343. *
  4344. * @api public
  4345. * @param {String} url :: destination URL
  4346. * @param {Object} data :: parameters to send with the request [optional]
  4347. * @param {Function} cb :: callback function to call when finished [optional]
  4348. */
  4349. SailsSocket.prototype.put = function(url, data, cb) {
  4350. // `data` is optional
  4351. if (typeof data === 'function') {
  4352. cb = data;
  4353. data = {};
  4354. }
  4355. return this.request({
  4356. method: 'put',
  4357. params: data,
  4358. url: url
  4359. },
  4360. cb);
  4361. };
  4362. /**
  4363. * Simulate a PATCH request to sails
  4364. * e.g.
  4365. * `socket.patch('/event/3', changedFields, $spinner.hide)`
  4366. *
  4367. * @api public
  4368. * @param {String} url :: destination URL
  4369. * @param {Object} data :: parameters to send with the request [optional]
  4370. * @param {Function} cb :: callback function to call when finished [optional]
  4371. */
  4372. SailsSocket.prototype.patch = function(url, data, cb) {
  4373. // `data` is optional
  4374. if (typeof data === 'function') {
  4375. cb = data;
  4376. data = {};
  4377. }
  4378. return this.request({
  4379. method: 'patch',
  4380. params: data,
  4381. url: url
  4382. },
  4383. cb);
  4384. };
  4385. /**
  4386. * Simulate a DELETE request to sails
  4387. * e.g.
  4388. * `socket.delete('/event', $spinner.hide)`
  4389. *
  4390. * @api public
  4391. * @param {String} url :: destination URL
  4392. * @param {Object} data :: parameters to send with the request [optional]
  4393. * @param {Function} cb :: callback function to call when finished [optional]
  4394. */
  4395. SailsSocket.prototype['delete'] = function(url, data, cb) {
  4396. // `data` is optional
  4397. if (typeof data === 'function') {
  4398. cb = data;
  4399. data = {};
  4400. }
  4401. return this.request({
  4402. method: 'delete',
  4403. params: data,
  4404. url: url
  4405. },
  4406. cb);
  4407. };
  4408. /**
  4409. * Simulate an HTTP request to sails
  4410. * e.g.
  4411. * ```
  4412. * socket.request({
  4413. * url:'/user',
  4414. * params: {},
  4415. * method: 'POST',
  4416. * headers: {}
  4417. * }, function (responseBody, JWR) {
  4418. * // ...
  4419. * });
  4420. * ```
  4421. *
  4422. * @api public
  4423. * @option {String} url :: destination URL
  4424. * @option {Object} params :: parameters to send with the request [optional]
  4425. * @option {Object} headers:: headers to send with the request [optional]
  4426. * @option {Function} cb :: callback function to call when finished [optional]
  4427. * @option {String} method :: HTTP request method [optional]
  4428. */
  4429. SailsSocket.prototype.request = function(options, cb) {
  4430. var usage = 'Usage:\n' + 'socket.request( options, [fnToCallWhenComplete] )\n\n' + 'options.url :: e.g. "/foo/bar"' + '\n' + 'options.method :: e.g. "get", "post", "put", or "delete", etc.' + '\n' + 'options.params :: e.g. { emailAddress: "mike@example.com" }' + '\n' + 'options.headers :: e.g. { "x-my-custom-header": "some string" }';
  4431. // Old usage:
  4432. // var usage = 'Usage:\n socket.'+(options.method||'request')+'('+
  4433. // ' destinationURL, [dataToSend], [fnToCallWhenComplete] )';
  4434. // Validate options and callback
  4435. if (typeof cb !== 'undefined' && typeof cb !== 'function') {
  4436. throw new Error('Invalid callback function!\n' + usage);
  4437. }
  4438. if (typeof options !== 'object' || typeof options.url !== 'string') {
  4439. throw new Error('Invalid or missing URL!\n' + usage);
  4440. }
  4441. if (options.method && typeof options.method !== 'string') {
  4442. throw new Error('Invalid `method` provided (should be a string like "post" or "put")\n' + usage);
  4443. }
  4444. if (options.headers && typeof options.headers !== 'object') {
  4445. throw new Error('Invalid `headers` provided (should be a dictionary with string values)\n' + usage);
  4446. }
  4447. if (options.params && typeof options.params !== 'object') {
  4448. throw new Error('Invalid `params` provided (should be a dictionary with JSON-serializable values)\n' + usage);
  4449. }
  4450. if (options.data && typeof options.data !== 'object') {
  4451. throw new Error('Invalid `data` provided (should be a dictionary with JSON-serializable values)\n' + usage);
  4452. }
  4453. // Accept either `params` or `data` for backwards compatibility (but not both!)
  4454. if (options.data && options.params) {
  4455. throw new Error('Cannot specify both `params` and `data`! They are aliases of each other.\n' + usage);
  4456. } else if (options.data) {
  4457. options.params = options.data;
  4458. delete options.data;
  4459. }
  4460. // If this socket is not connected yet, queue up this request
  4461. // instead of sending it.
  4462. // (so it can be replayed when the socket comes online.)
  4463. if (!this.isConnected()) {
  4464. // If no queue array exists for this socket yet, create it.
  4465. this.requestQueue = this.requestQueue || [];
  4466. this.requestQueue.push([options, cb]);
  4467. return;
  4468. }
  4469. // Otherwise, our socket is connected, so continue prepping
  4470. // the request.
  4471. // Default headers to an empty object
  4472. options.headers = options.headers || {};
  4473. // Build a simulated request object
  4474. // (and sanitize/marshal options along the way)
  4475. var requestCtx = {
  4476. method: (options.method || 'get').toLowerCase(),
  4477. headers: options.headers,
  4478. data: options.params || options.data || {},
  4479. // Remove trailing slashes and spaces to make packets smaller.
  4480. url: options.url.replace(/^(.+)\/*\s*$/, '$1'),
  4481. cb: cb
  4482. };
  4483. // Merge global headers in, if there are any.
  4484. if (this.headers && 'object' === typeof this.headers) {
  4485. for (var header in this.headers) {
  4486. if (!options.headers.hasOwnProperty(header)) {
  4487. options.headers[header] = this.headers[header];
  4488. }
  4489. }
  4490. }
  4491. // Send the request.
  4492. _emitFrom(this, requestCtx);
  4493. };
  4494. /**
  4495. * Socket.prototype._request
  4496. *
  4497. * Simulate HTTP over Socket.io.
  4498. *
  4499. * @api private
  4500. * @param {[type]} options [description]
  4501. * @param {Function} cb [description]
  4502. */
  4503. SailsSocket.prototype._request = function(options, cb) {
  4504. throw new Error('`_request()` was a private API deprecated as of v0.11 of the sails.io.js client. Use `.request()` instead.');
  4505. };
  4506. // 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  4507. // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆
  4508. // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  4509. // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
  4510. // 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳
  4511. // 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆
  4512. //
  4513. // Set an `io.sails` object that may be used for configuration before the
  4514. // first socket connects (i.e. to allow auto-connect behavior to be
  4515. // prevented by setting `io.sails.autoConnect` in an inline script
  4516. // directly after the script tag which loaded this file).
  4517. // 鈹屸攢鈹愨攲鈹€鈹愨攲鈹攼 鈹� 鈹攲鈹€鈹� 鈺斺暒鈺椻晹鈺愨晽鈺斺晲鈺椻晹鈺愨晽鈺� 鈺︹暒 鈺斺暒鈺椻晹鈺愨晽 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹�
  4518. // 鈹斺攢鈹愨敎鈹� 鈹� 鈹� 鈹傗敎鈹€鈹� 鈺戔晳鈺戔暎 鈺犫暎 鈺犫晲鈺b晳 鈺戔晳 鈺� 鈺氣晲鈺� 鈹溾敜 鈹� 鈹傗敎鈹敇 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹�
  4519. // 鈹斺攢鈹樷敂鈹€鈹� 鈹� 鈹斺攢鈹樷敶 鈺愨暕鈺濃暁鈺愨暆鈺� 鈺� 鈺┾暁鈺愨暆鈺┾晲鈺濃暕 鈺氣晲鈺� 鈹� 鈹斺攢鈹樷敶鈹斺攢 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹�
  4520. io.sails = {
  4521. // Whether to automatically connect a socket and save it as `io.socket`.
  4522. autoConnect: true,
  4523. // Whether to automatically try to reconnect after connection is lost
  4524. reconnection: false,
  4525. // The route (path) to hit to get a x-origin (CORS) cookie
  4526. // (or true to use the default: '/__getcookie')
  4527. useCORSRouteToGetCookie: true,
  4528. // The environment we're running in.
  4529. // (logs are not displayed when this is set to 'production')
  4530. //
  4531. // Defaults to development unless this script was fetched from a URL
  4532. // that ends in `*.min.js` or '#production' (may also be manually overridden.)
  4533. //
  4534. environment: urlThisScriptWasFetchedFrom.match(/(\#production|\.min\.js)/g) ? 'production': 'development',
  4535. // The version of this sails.io.js client SDK
  4536. sdk: SDK_INFO,
  4537. // Transports to use when communicating with the server, in the order they will be tried
  4538. transports: ['websocket']
  4539. };
  4540. // 鈹屸攢鈹愨攢鈹� 鈹攲鈹攼鈹屸攢鈹愨攲鈹愨攲鈹屸敩鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹� 鈹屸敩鈹愨攲鈹€鈹愨攲鈹€鈹愨攲鈹€鈹愨敩 鈹敩 鈹屸敩鈹愨攲鈹€鈹�
  4541. // 鈹溾敜 鈹屸敶鈹敇 鈹� 鈹溾敜 鈹傗攤鈹� 鈹傗攤 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹� 鈹傗攤鈹溾敜 鈹溾敜 鈹溾攢鈹も攤 鈹傗攤 鈹� 鈹斺攢鈹�
  4542. // 鈹斺攢鈹樷敶 鈹斺攢 鈹� 鈹斺攢鈹樷敇鈹斺敇鈹€鈹粹敇 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹� 鈹€鈹粹敇鈹斺攢鈹樷敂 鈹� 鈹粹敂鈹€鈹樷敶鈹€鈹樷敶 鈹斺攢鈹�
  4543. // 鈹� 鈹敩鈹屸敩鈹愨敩 鈹� 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈺� 鈺︹晹鈺︹晽鈺斺暒鈺椻暒 鈺斺晲鈺椻晹鈺︹晽鈺斺暒鈺椻暒鈺愨晽鈺︹晹鈺� 鈺� 鈺︹晹鈺︹晽鈺斺晲鈺椻晹鈺愨晽
  4544. // 鈹傗攤鈹傗攤 鈹� 鈹溾攢鈹� 鈹� 鈹溾攢鈹も敎鈹� 鈺犫晲鈺� 鈺� 鈺戔晳鈺戔晳 鈺犫晲鈺� 鈺� 鈺� 鈺犫暒鈺濃晳鈺犫暕鈺椻晳 鈺� 鈺� 鈺戔暎 鈺氣晲鈺�
  4545. // 鈹斺敶鈹樷敶 鈹� 鈹� 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈺� 鈺� 鈺� 鈺� 鈺┾暕鈺愨暆 鈺� 鈺� 鈺� 鈺� 鈺┾暁鈺愨暕鈺氣晲鈺濃暁鈺愨暆 鈺� 鈺氣晲鈺濃暁鈺愨暆
  4546. // 鈹屸攢鈹愨敩鈹€鈹愨攲鈹€鈹愨攲鈹攼 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹愨敩鈹屸攢鈹愨攲鈹攼 鈹屸敩鈹愨攲鈹€鈹愨攲鈹€鈹�
  4547. // 鈹溾敜 鈹溾敩鈹樷攤 鈹傗攤鈹傗攤 鈹� 鈹溾攢鈹も敎鈹� 鈹斺攢鈹愨攤 鈹溾敩鈹樷攤鈹溾攢鈹� 鈹� 鈹� 鈹溾攢鈹も攤 鈹�
  4548. // 鈹� 鈹粹敂鈹€鈹斺攢鈹樷敶 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹斺攢鈹樷敂鈹€鈹樷敶鈹斺攢鈹粹敶 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹�
  4549. //
  4550. // Now fold in config provided as HTML attributes on the script tag:
  4551. // (note that if `io.sails.*` is changed after this script, those changes
  4552. // will still take precedence)
  4553. CONFIGURABLE_VIA_HTML_ATTR.forEach(function(configKey) {
  4554. if (typeof scriptTagConfig[configKey] !== 'undefined') {
  4555. io.sails[configKey] = scriptTagConfig[configKey];
  4556. }
  4557. });
  4558. //////////////////////////////////////////////////////////////////////////////
  4559. // Note that the new HTML attribute configuration style may eventually
  4560. // completely replace the original approach of setting `io.sails` properties,
  4561. // since the new strategy is easier to reason about. Also, it would allow us
  4562. // to remove the timeout below someday.
  4563. //////////////////////////////////////////////////////////////////////////////
  4564. // 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹� 鈺斺晲鈺椻晹鈺愨晽鈺斺晽鈺斺晹鈺椻晹鈺斺晲鈺椻晹鈺愨晽鈺斺暒鈺� / \
  4565. // 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹� 鈺� 鈺� 鈺戔晳鈺戔晳鈺戔晳鈺戔晳鈺� 鈺� 鈺� / /
  4566. // 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹榦鈺氣晲鈺濃暁鈺愨暆鈺濃暁鈺濃暆鈺氣暆鈺氣晲鈺濃暁鈺愨暆 鈺� \ /
  4567. /**
  4568. * Add `io.sails.connect` function as a wrapper for the built-in `io()` aka `io.connect()`
  4569. * method, returning a SailsSocket. This special function respects the configured io.sails
  4570. * connection URL, as well as sending other identifying information (most importantly, the
  4571. * current version of this SDK).
  4572. *
  4573. * @param {String} url [optional]
  4574. * @param {Object} opts [optional]
  4575. * @return {Socket}
  4576. */
  4577. io.sails.connect = function(url, opts) {
  4578. // Make URL optional
  4579. if ('object' === typeof url) {
  4580. opts = url;
  4581. url = null;
  4582. }
  4583. // Default opts to empty object
  4584. opts = opts || {};
  4585. // If explicit connection url is specified, save it to options
  4586. opts.url = url || opts.url || undefined;
  4587. // Instantiate and return a new SailsSocket- and try to connect immediately.
  4588. var socket = new SailsSocket(opts);
  4589. socket._connect();
  4590. return socket;
  4591. };
  4592. // 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
  4593. // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
  4594. // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
  4595. // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
  4596. // 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
  4597. // 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
  4598. //
  4599. // io.socket
  4600. //
  4601. // The eager instance of Socket which will automatically try to connect
  4602. // using the host that this js file was served from.
  4603. //
  4604. // This can be disabled or configured by setting properties on `io.sails.*` within the
  4605. // first cycle of the event loop.
  4606. //
  4607. // Build `io.socket` so it exists
  4608. // (note that this DOES NOT start the connection process)
  4609. io.socket = new SailsSocket();
  4610. //
  4611. // This socket is not connected yet, and has not even _started_ connecting.
  4612. //
  4613. // But in the mean time, this eager socket will be queue events bound by the user
  4614. // before the first cycle of the event loop (using `.on()`), which will later
  4615. // be rebound on the raw underlying socket.
  4616. // 鈹屸攢鈹愨攲鈹€鈹愨攲鈹攼 鈹屸攢鈹愨敩 鈹攲鈹攼鈹屸攢鈹� 鈹屸攢鈹愨攲鈹€鈹愨攲鈹愨攲鈹屸攼鈹屸攲鈹€鈹愨攲鈹€鈹愨攲鈹攼 鈹屸敩鈹愨敩鈹屸敩鈹愨攲鈹€鈹愨敩鈹€鈹�
  4617. // 鈹斺攢鈹愨敎鈹� 鈹� 鈹溾攢鈹も攤 鈹� 鈹� 鈹� 鈹傗攢鈹€鈹€鈹� 鈹� 鈹傗攤鈹傗攤鈹傗攤鈹傗敎鈹� 鈹� 鈹� 鈹� 鈹傗攤鈹傗攤鈹溾敜 鈹溾敩鈹�
  4618. // 鈹斺攢鈹樷敂鈹€鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹� 鈹斺攢鈹� 鈹斺攢鈹樷敂鈹€鈹樷敇鈹斺敇鈹樷敂鈹樷敂鈹€鈹樷敂鈹€鈹� 鈹� 鈹� 鈹粹敶 鈹粹敂鈹€鈹樷敶鈹斺攢
  4619. // If configured to do so, start auto-connecting after the first cycle of the event loop
  4620. // has completed (to allow time for this behavior to be configured/disabled
  4621. // by specifying properties on `io.sails`)
  4622. // Indicate that the autoConnect timer has started.
  4623. io.socket._mightBeAboutToAutoConnect = true;
  4624. setTimeout(function() {
  4625. // Indicate that the autoConect timer fired.
  4626. io.socket._mightBeAboutToAutoConnect = false;
  4627. // If autoConnect is disabled, delete the eager socket (io.socket) and bail out.
  4628. if (io.sails.autoConnect === false || io.sails.autoconnect === false) {
  4629. delete io.socket;
  4630. return;
  4631. }
  4632. // consolog('Eagerly auto-connecting socket to Sails... (requests will be queued in the mean-time)');
  4633. io.socket._connect();
  4634. },
  4635. 0); // </setTimeout>
  4636. // Return the `io` object.
  4637. return io;
  4638. } //</SailsIOClient>
  4639. //
  4640. /////////////////////////////////////////////////////////////////////////////////
  4641. ///// </bunches of private function definitions, constructors, and methods>
  4642. /////////////////////////////////////////////////////////////////////////////////
  4643. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺�
  4644. // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣枅鈻堚晽鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺� 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺斺暆
  4645. // 鈻堚枅鈻堚枅鈻堚晽 鈺氣枅鈻堚枅鈺斺暆 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺斺暆
  4646. // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨枅鈻堚晽
  4647. // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺斺暆 鈻堚枅鈺椻枅鈻堚晳 鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺�
  4648. // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺�
  4649. //
  4650. // Add CommonJS support to allow this client SDK to be used from Node.js.
  4651. if (SDK_INFO.platform === 'node') {
  4652. module.exports = SailsIOClient;
  4653. }
  4654. // Add AMD support, registering this client SDK as an anonymous module.
  4655. else if (typeof define === 'function' && define.amd) {
  4656. define([],
  4657. function() {
  4658. return SailsIOClient;
  4659. });
  4660. } else {
  4661. // Otherwise, try to instantiate the client using the global `io`:
  4662. SailsIOClient();
  4663. // Note:
  4664. // If you are modifying this file manually to wrap an existing socket.io client
  4665. // (e.g. to prevent pollution of the global namespace), you can replace the global
  4666. // `io` with your own `io` instance above.
  4667. }
  4668. })();;
  4669. /* eslint-enable */