faye 1.0.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["webpack://Faye/webpack/bootstrap","webpack://Faye/./node_modules/asap/browser-asap.js","webpack://Faye/./node_modules/asap/browser-raw.js","webpack://Faye/(webpack)/buildin/global.js","webpack://Faye/./src/faye_browser.js","webpack://Faye/./src/mixins/deferrable.js","webpack://Faye/./src/mixins/logging.js","webpack://Faye/./src/mixins/publisher.js","webpack://Faye/./src/mixins/timeouts.js","webpack://Faye/./src/protocol/channel.js","webpack://Faye/./src/protocol/client.js","webpack://Faye/./src/protocol/dispatcher.js","webpack://Faye/./src/protocol/error.js","webpack://Faye/./src/protocol/extensible.js","webpack://Faye/./src/protocol/grammar.js","webpack://Faye/./src/protocol/publication.js","webpack://Faye/./src/protocol/scheduler.js","webpack://Faye/./src/protocol/subscription.js","webpack://Faye/./src/transport/browser_transports.js","webpack://Faye/./src/transport/cors.js","webpack://Faye/./src/transport/event_source.js","webpack://Faye/./src/transport/jsonp.js","webpack://Faye/./src/transport/transport.js","webpack://Faye/./src/transport/web_socket.js","webpack://Faye/./src/transport/xhr.js","webpack://Faye/./src/util/array.js","webpack://Faye/./src/util/assign.js","webpack://Faye/./src/util/browser/event.js","webpack://Faye/./src/util/class.js","webpack://Faye/./src/util/constants.js","webpack://Faye/./src/util/cookies/browser_cookies.js","webpack://Faye/./src/util/copy_object.js","webpack://Faye/./src/util/event_emitter.js","webpack://Faye/./src/util/promise.js","webpack://Faye/./src/util/set.js","webpack://Faye/./src/util/to_json.js","webpack://Faye/./src/util/uri.js","webpack://Faye/./src/util/validate_options.js","webpack://Faye/./src/util/websocket/browser_websocket.js"],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb;AACA,cAAc,mBAAO,CAAC,iDAAO;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;;;;;;;;;;;;ACjEA,8CAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE,kBAAkB;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAoB;AAChD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AC9NA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;;;;;;;ACnBa;;AAEb,gBAAgB,mBAAO,CAAC,iDAAkB;AAC1C,gBAAgB,mBAAO,CAAC,iDAAkB;;AAE1C;AACA;;AAEA,cAAc,mBAAO,CAAC,mDAAmB;AACzC,cAAc,mBAAO,CAAC,yDAAsB;AAC5C;;AAEA;;AAEA;;;;;;;;;;;;;ACdA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,8CAAiB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA,sCAAsC,gCAAgC;AACtE,GAAG;;AAEH;AACA,6CAA6C,iCAAiC;AAC9E,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;AC/Ca;;AAEb,aAAa,mBAAO,CAAC,8CAAiB;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;;;;;;;;;;;;;AC9Ca;;AAEb,mBAAmB,mBAAO,CAAC,4CAAgB;AAC3C,mBAAmB,mBAAO,CAAC,0DAAuB;;AAElD;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,8BAA8B;;AAE9B;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;;ACpCA,8CAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACzBa;;AAEb,gBAAgB,mBAAO,CAAC,0CAAe;AACvC,gBAAgB,mBAAO,CAAC,4CAAgB;AACxC,gBAAgB,mBAAO,CAAC,sDAAqB;AAC7C,gBAAgB,mBAAO,CAAC,4CAAW;;AAEnC;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA,uCAAuC,OAAO;AAC9C;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;;AAEA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;;;;;;;;;;;;;ACnIA,8CAAa;;AAEb,sBAAsB,mBAAO,CAAC,iDAAM;AACpC,sBAAsB,mBAAO,CAAC,0CAAe;AAC7C,sBAAsB,mBAAO,CAAC,8CAAiB;AAC/C,sBAAsB,mBAAO,CAAC,0CAAe;AAC7C,sBAAsB,mBAAO,CAAC,oDAAiB;AAC/C,sBAAsB,mBAAO,CAAC,kDAAmB;AACjD,sBAAsB,mBAAO,CAAC,4CAAgB;AAC9C,sBAAsB,mBAAO,CAAC,gEAA0B;AACxD,sBAAsB,mBAAO,CAAC,wDAAsB;AACpD,sBAAsB,mBAAO,CAAC,kDAAmB;AACjD,sBAAsB,mBAAO,CAAC,sDAAqB;AACnD,sBAAsB,mBAAO,CAAC,4CAAW;AACzC,sBAAsB,mBAAO,CAAC,kDAAc;AAC5C,sBAAsB,mBAAO,CAAC,wCAAS;AACvC,sBAAsB,mBAAO,CAAC,kDAAc;AAC5C,sBAAsB,mBAAO,CAAC,oDAAe;AAC7C,sBAAsB,mBAAO,CAAC,sDAAgB;;AAE9C,oBAAoB;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,KAAK,IAAI;;AAET;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA,uCAAuC,yBAAyB;;AAEhE,OAAO;AACP;AACA,sCAAsC,oCAAoC;AAC1E;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wCAAwC,kCAAkC;;AAE1E;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA,KAAK,IAAI;AACT,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,KAAK,IAAI;AACT;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,OAAO,IAAI;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,OAAO,IAAI;AACX;;AAEA;AACA;AACA,OAAO;AACP,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,kEAAkE;AAClE,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,iBAAiB;AACnD;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;AChYA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,0CAAe;AACvC,gBAAgB,mBAAO,CAAC,sCAAa;AACrC,gBAAgB,mBAAO,CAAC,8DAAiB;AACzC,gBAAgB,mBAAO,CAAC,4CAAgB;AACxC,gBAAgB,mBAAO,CAAC,kDAAmB;AAC3C,gBAAgB,mBAAO,CAAC,sDAAqB;AAC7C,gBAAgB,mBAAO,CAAC,2DAAc;AACtC,gBAAgB,mBAAO,CAAC,gDAAa;;AAErC,wBAAwB;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wDAAwD;;AAExD;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,iFAAiF;AACjI,yCAAyC;AACzC;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;;;ACzLa;;AAEb,cAAc,mBAAO,CAAC,0CAAe;AACrC,cAAc,mBAAO,CAAC,4CAAW;;AAEjC;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;;;;;;;;;;;;;ACtDa;;AAEb,cAAc,mBAAO,CAAC,4CAAgB;AACtC,cAAc,mBAAO,CAAC,kDAAmB;;AAEzC;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;;AC9Ca;;AAEb;AACA;AACA,oFAAoF,IAAI;AACxF;AACA;AACA;;;;;;;;;;;;;ACPa;;AAEb,iBAAiB,mBAAO,CAAC,0CAAe;AACxC,iBAAiB,mBAAO,CAAC,wDAAsB;;AAE/C;;;;;;;;;;;;;ACLa;;AAEb,aAAa,mBAAO,CAAC,4CAAgB;;AAErC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA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AChKA,8CAAa;;AAEb,gBAAgB,mBAAO,CAAC,0CAAe;AACvC,gBAAgB,mBAAO,CAAC,sCAAa;AACrC,gBAAgB,mBAAO,CAAC,oDAAiB;AACzC,gBAAgB,mBAAO,CAAC,4CAAgB;AACxC,gBAAgB,mBAAO,CAAC,8CAAiB;AACzC,gBAAgB,mBAAO,CAAC,iDAAa;;AAErC;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,4BAA4B;AAC5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;;;;;;;;;;;;;;ACjFa;;AAEb;AACA;AACA,qCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,qCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACzEa;;AAEb;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;;;;;;;;;;;;ACfA,8CAAa;;AAEb;AACA;;AAEA;AACA,8BAA8B;;AAE9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;;;ACjDa;;AAEb,aAAa,mBAAO,CAAC,sCAAU;;AAE/B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;ACtBA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACTa;;AAEb;;;;;;;;;;;;;ACFa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;;;;;;;;;;;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,GAAG;AACH;;AAEA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;;AAEA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AC1Ka;;AAEb,WAAW,mBAAO,CAAC,iDAAM;;AAEzB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA,gDAAgD,iBAAiB;AACjE;;AAEA;AACA,gDAAgD,iBAAiB;AACjE;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA,eAAe,OAAO;AACtB,GAAG;AACH;;AAEA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA,GAAG;AACH;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;;;;;;;;;;;;;AC3Ka;;AAEb,YAAY,mBAAO,CAAC,oCAAS;;AAE7B;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,iCAAiC,mBAAmB;AACpD;AACA;AACA,CAAC;;;;;;;;;;;;;ACjDY;;AAEb;;AAEA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;ACRa;;AAEb;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,gBAAgB;;AAEhB;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,iCAAiC,OAAO;AACxC;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACzFa;;AAEb,YAAY,mBAAO,CAAC,oCAAS;;AAE7B;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACTA,8CAAa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA","file":"build/client/faye-browser.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/faye_browser.js\");\n","\"use strict\";\n\n// rawAsap provides everything we need except exception management.\nvar rawAsap = require(\"./raw\");\n// RawTasks are recycled to reduce GC churn.\nvar freeTasks = [];\n// We queue errors to ensure they are thrown in right order (FIFO).\n// Array-as-queue is good enough here, since we are just dealing with exceptions.\nvar pendingErrors = [];\nvar requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);\n\nfunction throwFirstError() {\n if (pendingErrors.length) {\n throw pendingErrors.shift();\n }\n}\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nmodule.exports = asap;\nfunction asap(task) {\n var rawTask;\n if (freeTasks.length) {\n rawTask = freeTasks.pop();\n } else {\n rawTask = new RawTask();\n }\n rawTask.task = task;\n rawAsap(rawTask);\n}\n\n// We wrap tasks with recyclable task objects. A task object implements\n// `call`, just like a function.\nfunction RawTask() {\n this.task = null;\n}\n\n// The sole purpose of wrapping the task is to catch the exception and recycle\n// the task object after its single use.\nRawTask.prototype.call = function () {\n try {\n this.task.call();\n } catch (error) {\n if (asap.onerror) {\n // This hook exists purely for testing purposes.\n // Its name will be periodically randomized to break any code that\n // depends on its existence.\n asap.onerror(error);\n } else {\n // In a web browser, exceptions are not fatal. However, to avoid\n // slowing down the queue of pending tasks, we rethrow the error in a\n // lower priority turn.\n pendingErrors.push(error);\n requestErrorThrow();\n }\n } finally {\n this.task = null;\n freeTasks[freeTasks.length] = this;\n }\n};\n","\"use strict\";\n\n// Use the fastest means possible to execute a task in its own turn, with\n// priority over other events including IO, animation, reflow, and redraw\n// events in browsers.\n//\n// An exception thrown by a task will permanently interrupt the processing of\n// subsequent tasks. The higher level `asap` function ensures that if an\n// exception is thrown by a task, that the task queue will continue flushing as\n// soon as possible, but if you use `rawAsap` directly, you are responsible to\n// either ensure that no exceptions are thrown from your task, or to manually\n// call `rawAsap.requestFlush` if an exception is thrown.\nmodule.exports = rawAsap;\nfunction rawAsap(task) {\n if (!queue.length) {\n requestFlush();\n flushing = true;\n }\n // Equivalent to push, but avoids a function call.\n queue[queue.length] = task;\n}\n\nvar queue = [];\n// Once a flush has been requested, no further calls to `requestFlush` are\n// necessary until the next `flush` completes.\nvar flushing = false;\n// `requestFlush` is an implementation-specific method that attempts to kick\n// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n// the event queue before yielding to the browser's own event loop.\nvar requestFlush;\n// The position of the next task to execute in the task queue. This is\n// preserved between calls to `flush` so that it can be resumed if\n// a task throws an exception.\nvar index = 0;\n// If a task schedules additional tasks recursively, the task queue can grow\n// unbounded. To prevent memory exhaustion, the task queue will periodically\n// truncate already-completed tasks.\nvar capacity = 1024;\n\n// The flush function processes all tasks that have been scheduled with\n// `rawAsap` unless and until one of those tasks throws an exception.\n// If a task throws an exception, `flush` ensures that its state will remain\n// consistent and will resume where it left off when called again.\n// However, `flush` does not make any arrangements to be called again if an\n// exception is thrown.\nfunction flush() {\n while (index < queue.length) {\n var currentIndex = index;\n // Advance the index before calling the task. This ensures that we will\n // begin flushing on the next task the task throws an error.\n index = index + 1;\n queue[currentIndex].call();\n // Prevent leaking memory for long chains of recursive calls to `asap`.\n // If we call `asap` within tasks scheduled by `asap`, the queue will\n // grow, but to avoid an O(n) walk for every task we execute, we don't\n // shift tasks off the queue after they have been executed.\n // Instead, we periodically shift 1024 tasks off the queue.\n if (index > capacity) {\n // Manually shift all values starting at the index back to the\n // beginning of the queue.\n for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {\n queue[scan] = queue[scan + index];\n }\n queue.length -= index;\n index = 0;\n }\n }\n queue.length = 0;\n index = 0;\n flushing = false;\n}\n\n// `requestFlush` is implemented using a strategy based on data collected from\n// every available SauceLabs Selenium web driver worker at time of writing.\n// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\n// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` or `self` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\n\n/* globals self */\nvar scope = typeof global !== \"undefined\" ? global : self;\nvar BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;\n\n// MutationObservers are desirable because they have high priority and work\n// reliably everywhere they are implemented.\n// They are implemented in all modern browsers.\n//\n// - Android 4-4.3\n// - Chrome 26-34\n// - Firefox 14-29\n// - Internet Explorer 11\n// - iPad Safari 6-7.1\n// - iPhone Safari 7-7.1\n// - Safari 6-7\nif (typeof BrowserMutationObserver === \"function\") {\n requestFlush = makeRequestCallFromMutationObserver(flush);\n\n// MessageChannels are desirable because they give direct access to the HTML\n// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n// 11-12, and in web workers in many engines.\n// Although message channels yield to any queued rendering and IO tasks, they\n// would be better than imposing the 4ms delay of timers.\n// However, they do not work reliably in Internet Explorer or Safari.\n\n// Internet Explorer 10 is the only browser that has setImmediate but does\n// not have MutationObservers.\n// Although setImmediate yields to the browser's renderer, it would be\n// preferrable to falling back to setTimeout since it does not have\n// the minimum 4ms penalty.\n// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n// Desktop to a lesser extent) that renders both setImmediate and\n// MessageChannel useless for the purposes of ASAP.\n// https://github.com/kriskowal/q/issues/396\n\n// Timers are implemented universally.\n// We fall back to timers in workers in most engines, and in foreground\n// contexts in the following browsers.\n// However, note that even this simple case requires nuances to operate in a\n// broad spectrum of browsers.\n//\n// - Firefox 3-13\n// - Internet Explorer 6-9\n// - iPad Safari 4.3\n// - Lynx 2.8.7\n} else {\n requestFlush = makeRequestCallFromTimer(flush);\n}\n\n// `requestFlush` requests that the high priority event queue be flushed as\n// soon as possible.\n// This is useful to prevent an error thrown in a task from stalling the event\n// queue if the exception handled by Node.js’s\n// `process.on(\"uncaughtException\")` or by a domain.\nrawAsap.requestFlush = requestFlush;\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nfunction makeRequestCallFromMutationObserver(callback) {\n var toggle = 1;\n var observer = new BrowserMutationObserver(callback);\n var node = document.createTextNode(\"\");\n observer.observe(node, {characterData: true});\n return function requestCall() {\n toggle = -toggle;\n node.data = toggle;\n };\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\nfunction makeRequestCallFromTimer(callback) {\n return function requestCall() {\n // We dispatch a timeout with a specified delay of 0 for engines that\n // can reliably accommodate that request. This will usually be snapped\n // to a 4 milisecond delay, but once we're flushing, there's no delay\n // between events.\n var timeoutHandle = setTimeout(handleTimer, 0);\n // However, since this timer gets frequently dropped in Firefox\n // workers, we enlist an interval handle that will try to fire\n // an event 20 times per second until it succeeds.\n var intervalHandle = setInterval(handleTimer, 50);\n\n function handleTimer() {\n // Whichever timer succeeds will cancel both timers and\n // execute the callback.\n clearTimeout(timeoutHandle);\n clearInterval(intervalHandle);\n callback();\n }\n };\n}\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// its existence.\nrawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict';\n\nvar constants = require('./util/constants'),\n Logging = require('./mixins/logging');\n\nvar Faye = {\n VERSION: constants.VERSION,\n\n Client: require('./protocol/client'),\n Scheduler: require('./protocol/scheduler')\n};\n\nLogging.wrapper = Faye;\n\nmodule.exports = Faye;\n","'use strict';\n\nvar Promise = require('../util/promise');\n\nmodule.exports = {\n then: function(callback, errback) {\n var self = this;\n if (!this._promise)\n this._promise = new Promise(function(resolve, reject) {\n self._resolve = resolve;\n self._reject = reject;\n });\n\n if (arguments.length === 0)\n return this._promise;\n else\n return this._promise.then(callback, errback);\n },\n\n callback: function(callback, context) {\n return this.then(function(value) { callback.call(context, value) });\n },\n\n errback: function(callback, context) {\n return this.then(null, function(reason) { callback.call(context, reason) });\n },\n\n timeout: function(seconds, message) {\n this.then();\n var self = this;\n this._timer = global.setTimeout(function() {\n self._reject(message);\n }, seconds * 1000);\n },\n\n setDeferredStatus: function(status, value) {\n if (this._timer) global.clearTimeout(this._timer);\n\n this.then();\n\n if (status === 'succeeded')\n this._resolve(value);\n else if (status === 'failed')\n this._reject(value);\n else\n delete this._promise;\n }\n};\n","'use strict';\n\nvar toJSON = require('../util/to_json');\n\nvar Logging = {\n LOG_LEVELS: {\n fatal: 4,\n error: 3,\n warn: 2,\n info: 1,\n debug: 0\n },\n\n writeLog: function(messageArgs, level) {\n var logger = Logging.logger || (Logging.wrapper || Logging).logger;\n if (!logger) return;\n\n var args = Array.prototype.slice.apply(messageArgs),\n banner = '[Faye',\n klass = this.className,\n\n message = args.shift().replace(/\\?/g, function() {\n try {\n return toJSON(args.shift());\n } catch (error) {\n return '[Object]';\n }\n });\n\n if (klass) banner += '.' + klass;\n banner += '] ';\n\n if (typeof logger[level] === 'function')\n logger[level](banner + message);\n else if (typeof logger === 'function')\n logger(banner + message);\n }\n};\n\nfor (var key in Logging.LOG_LEVELS)\n (function(level) {\n Logging[level] = function() {\n this.writeLog(arguments, level);\n };\n })(key);\n\nmodule.exports = Logging;\n","'use strict';\n\nvar assign = require('../util/assign'),\n EventEmitter = require('../util/event_emitter');\n\nvar Publisher = {\n countListeners: function(eventType) {\n return this.listeners(eventType).length;\n },\n\n bind: function(eventType, listener, context) {\n var slice = Array.prototype.slice,\n handler = function() { listener.apply(context, slice.call(arguments)) };\n\n this._listeners = this._listeners || [];\n this._listeners.push([eventType, listener, context, handler]);\n return this.on(eventType, handler);\n },\n\n unbind: function(eventType, listener, context) {\n this._listeners = this._listeners || [];\n var n = this._listeners.length, tuple;\n\n while (n--) {\n tuple = this._listeners[n];\n if (tuple[0] !== eventType) continue;\n if (listener && (tuple[1] !== listener || tuple[2] !== context)) continue;\n this._listeners.splice(n, 1);\n this.removeListener(eventType, tuple[3]);\n }\n }\n};\n\nassign(Publisher, EventEmitter.prototype);\nPublisher.trigger = Publisher.emit;\n\nmodule.exports = Publisher;\n","'use strict';\n\nmodule.exports = {\n addTimeout: function(name, delay, callback, context) {\n this._timeouts = this._timeouts || {};\n if (this._timeouts.hasOwnProperty(name)) return;\n var self = this;\n this._timeouts[name] = global.setTimeout(function() {\n delete self._timeouts[name];\n callback.call(context);\n }, 1000 * delay);\n },\n\n removeTimeout: function(name) {\n this._timeouts = this._timeouts || {};\n var timeout = this._timeouts[name];\n if (!timeout) return;\n global.clearTimeout(timeout);\n delete this._timeouts[name];\n },\n\n removeAllTimeouts: function() {\n this._timeouts = this._timeouts || {};\n for (var name in this._timeouts) this.removeTimeout(name);\n }\n};\n","'use strict';\n\nvar Class = require('../util/class'),\n assign = require('../util/assign'),\n Publisher = require('../mixins/publisher'),\n Grammar = require('./grammar');\n\nvar Channel = Class({\n initialize: function(name) {\n this.id = this.name = name;\n },\n\n push: function(message) {\n this.trigger('message', message);\n },\n\n isUnused: function() {\n return this.countListeners('message') === 0;\n }\n});\n\nassign(Channel.prototype, Publisher);\n\nassign(Channel, {\n HANDSHAKE: '/meta/handshake',\n CONNECT: '/meta/connect',\n SUBSCRIBE: '/meta/subscribe',\n UNSUBSCRIBE: '/meta/unsubscribe',\n DISCONNECT: '/meta/disconnect',\n\n META: 'meta',\n SERVICE: 'service',\n\n expand: function(name) {\n var segments = this.parse(name),\n channels = ['/**', name];\n\n var copy = segments.slice();\n copy[copy.length - 1] = '*';\n channels.push(this.unparse(copy));\n\n for (var i = 1, n = segments.length; i < n; i++) {\n copy = segments.slice(0, i);\n copy.push('**');\n channels.push(this.unparse(copy));\n }\n\n return channels;\n },\n\n isValid: function(name) {\n return Grammar.CHANNEL_NAME.test(name) ||\n Grammar.CHANNEL_PATTERN.test(name);\n },\n\n parse: function(name) {\n if (!this.isValid(name)) return null;\n return name.split('/').slice(1);\n },\n\n unparse: function(segments) {\n return '/' + segments.join('/');\n },\n\n isMeta: function(name) {\n var segments = this.parse(name);\n return segments ? (segments[0] === this.META) : null;\n },\n\n isService: function(name) {\n var segments = this.parse(name);\n return segments ? (segments[0] === this.SERVICE) : null;\n },\n\n isSubscribable: function(name) {\n if (!this.isValid(name)) return null;\n return !this.isMeta(name) && !this.isService(name);\n },\n\n Set: Class({\n initialize: function() {\n this._channels = {};\n },\n\n getKeys: function() {\n var keys = [];\n for (var key in this._channels) keys.push(key);\n return keys;\n },\n\n remove: function(name) {\n delete this._channels[name];\n },\n\n hasSubscription: function(name) {\n return this._channels.hasOwnProperty(name);\n },\n\n subscribe: function(names, subscription) {\n var name;\n for (var i = 0, n = names.length; i < n; i++) {\n name = names[i];\n var channel = this._channels[name] = this._channels[name] || new Channel(name);\n channel.bind('message', subscription);\n }\n },\n\n unsubscribe: function(name, subscription) {\n var channel = this._channels[name];\n if (!channel) return false;\n channel.unbind('message', subscription);\n\n if (channel.isUnused()) {\n this.remove(name);\n return true;\n } else {\n return false;\n }\n },\n\n distributeMessage: function(message) {\n var channels = Channel.expand(message.channel);\n\n for (var i = 0, n = channels.length; i < n; i++) {\n var channel = this._channels[channels[i]];\n if (channel) channel.trigger('message', message);\n }\n }\n })\n});\n\nmodule.exports = Channel;\n","'use strict';\n\nvar asap = require('asap'),\n Class = require('../util/class'),\n Promise = require('../util/promise'),\n array = require('../util/array'),\n browser = require('../util/browser'),\n constants = require('../util/constants'),\n assign = require('../util/assign'),\n validateOptions = require('../util/validate_options'),\n Deferrable = require('../mixins/deferrable'),\n Logging = require('../mixins/logging'),\n Publisher = require('../mixins/publisher'),\n Channel = require('./channel'),\n Dispatcher = require('./dispatcher'),\n Error = require('./error'),\n Extensible = require('./extensible'),\n Publication = require('./publication'),\n Subscription = require('./subscription');\n\nvar Client = Class({ className: 'Client',\n UNCONNECTED: 1,\n CONNECTING: 2,\n CONNECTED: 3,\n DISCONNECTED: 4,\n\n HANDSHAKE: 'handshake',\n RETRY: 'retry',\n NONE: 'none',\n\n CONNECTION_TIMEOUT: 60,\n\n DEFAULT_ENDPOINT: '/bayeux',\n INTERVAL: 0,\n\n initialize: function(endpoint, options) {\n this.info('New client created for ?', endpoint);\n options = options || {};\n\n validateOptions(options, ['interval', 'timeout', 'endpoints', 'proxy', 'retry', 'scheduler', 'websocketExtensions', 'tls', 'ca']);\n\n this._channels = new Channel.Set();\n this._dispatcher = Dispatcher.create(this, endpoint || this.DEFAULT_ENDPOINT, options);\n\n this._messageId = 0;\n this._state = this.UNCONNECTED;\n\n this._responseCallbacks = {};\n\n this._advice = {\n reconnect: this.RETRY,\n interval: 1000 * (options.interval || this.INTERVAL),\n timeout: 1000 * (options.timeout || this.CONNECTION_TIMEOUT)\n };\n this._dispatcher.timeout = this._advice.timeout / 1000;\n\n this._dispatcher.bind('message', this._receiveMessage, this);\n\n if (browser.Event && global.onbeforeunload !== undefined)\n browser.Event.on(global, 'beforeunload', function() {\n if (array.indexOf(this._dispatcher._disabled, 'autodisconnect') < 0)\n this.disconnect();\n }, this);\n },\n\n addWebsocketExtension: function(extension) {\n return this._dispatcher.addWebsocketExtension(extension);\n },\n\n disable: function(feature) {\n return this._dispatcher.disable(feature);\n },\n\n setHeader: function(name, value) {\n return this._dispatcher.setHeader(name, value);\n },\n\n // Request\n // MUST include: * channel\n // * version\n // * supportedConnectionTypes\n // MAY include: * minimumVersion\n // * ext\n // * id\n //\n // Success Response Failed Response\n // MUST include: * channel MUST include: * channel\n // * version * successful\n // * supportedConnectionTypes * error\n // * clientId MAY include: * supportedConnectionTypes\n // * successful * advice\n // MAY include: * minimumVersion * version\n // * advice * minimumVersion\n // * ext * ext\n // * id * id\n // * authSuccessful\n handshake: function(callback, context) {\n if (this._advice.reconnect === this.NONE) return;\n if (this._state !== this.UNCONNECTED) return;\n\n this._state = this.CONNECTING;\n var self = this;\n\n this.info('Initiating handshake with ?', this._dispatcher.endpoint.href);\n this._dispatcher.selectTransport(constants.MANDATORY_CONNECTION_TYPES);\n\n this._sendMessage({\n channel: Channel.HANDSHAKE,\n version: constants.BAYEUX_VERSION,\n supportedConnectionTypes: this._dispatcher.getConnectionTypes()\n\n }, {}, function(response) {\n\n if (response.successful) {\n this._state = this.CONNECTED;\n this._dispatcher.clientId = response.clientId;\n\n this._dispatcher.selectTransport(response.supportedConnectionTypes);\n\n this.info('Handshake successful: ?', this._dispatcher.clientId);\n\n this.subscribe(this._channels.getKeys(), true);\n if (callback) asap(function() { callback.call(context) });\n\n } else {\n this.info('Handshake unsuccessful');\n global.setTimeout(function() { self.handshake(callback, context) }, this._dispatcher.retry * 1000);\n this._state = this.UNCONNECTED;\n }\n }, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * connectionType * clientId\n // MAY include: * ext MAY include: * error\n // * id * advice\n // * ext\n // * id\n // * timestamp\n connect: function(callback, context) {\n if (this._advice.reconnect === this.NONE) return;\n if (this._state === this.DISCONNECTED) return;\n\n if (this._state === this.UNCONNECTED)\n return this.handshake(function() { this.connect(callback, context) }, this);\n\n this.callback(callback, context);\n if (this._state !== this.CONNECTED) return;\n\n this.info('Calling deferred actions for ?', this._dispatcher.clientId);\n this.setDeferredStatus('succeeded');\n this.setDeferredStatus('unknown');\n\n if (this._connectRequest) return;\n this._connectRequest = true;\n\n this.info('Initiating connection for ?', this._dispatcher.clientId);\n\n this._sendMessage({\n channel: Channel.CONNECT,\n clientId: this._dispatcher.clientId,\n connectionType: this._dispatcher.connectionType\n\n }, {}, this._cycleConnection, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // MAY include: * ext * clientId\n // * id MAY include: * error\n // * ext\n // * id\n disconnect: function() {\n if (this._state !== this.CONNECTED) return;\n this._state = this.DISCONNECTED;\n\n this.info('Disconnecting ?', this._dispatcher.clientId);\n var promise = new Publication();\n\n this._sendMessage({\n channel: Channel.DISCONNECT,\n clientId: this._dispatcher.clientId\n\n }, {}, function(response) {\n if (response.successful) {\n this._dispatcher.close();\n promise.setDeferredStatus('succeeded');\n } else {\n promise.setDeferredStatus('failed', Error.parse(response.error));\n }\n }, this);\n\n this.info('Clearing channel listeners for ?', this._dispatcher.clientId);\n this._channels = new Channel.Set();\n\n return promise;\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * subscription * clientId\n // MAY include: * ext * subscription\n // * id MAY include: * error\n // * advice\n // * ext\n // * id\n // * timestamp\n subscribe: function(channel, callback, context) {\n if (channel instanceof Array)\n return array.map(channel, function(c) {\n return this.subscribe(c, callback, context);\n }, this);\n\n var subscription = new Subscription(this, channel, callback, context),\n force = (callback === true),\n hasSubscribe = this._channels.hasSubscription(channel);\n\n if (hasSubscribe && !force) {\n this._channels.subscribe([channel], subscription);\n subscription.setDeferredStatus('succeeded');\n return subscription;\n }\n\n this.connect(function() {\n this.info('Client ? attempting to subscribe to ?', this._dispatcher.clientId, channel);\n if (!force) this._channels.subscribe([channel], subscription);\n\n this._sendMessage({\n channel: Channel.SUBSCRIBE,\n clientId: this._dispatcher.clientId,\n subscription: channel\n\n }, {}, function(response) {\n if (!response.successful) {\n subscription.setDeferredStatus('failed', Error.parse(response.error));\n return this._channels.unsubscribe(channel, subscription);\n }\n\n var channels = [].concat(response.subscription);\n this.info('Subscription acknowledged for ? to ?', this._dispatcher.clientId, channels);\n subscription.setDeferredStatus('succeeded');\n }, this);\n }, this);\n\n return subscription;\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * clientId * successful\n // * subscription * clientId\n // MAY include: * ext * subscription\n // * id MAY include: * error\n // * advice\n // * ext\n // * id\n // * timestamp\n unsubscribe: function(channel, subscription) {\n if (channel instanceof Array)\n return array.map(channel, function(c) {\n return this.unsubscribe(c, subscription);\n }, this);\n\n var dead = this._channels.unsubscribe(channel, subscription);\n if (!dead) return;\n\n this.connect(function() {\n this.info('Client ? attempting to unsubscribe from ?', this._dispatcher.clientId, channel);\n\n this._sendMessage({\n channel: Channel.UNSUBSCRIBE,\n clientId: this._dispatcher.clientId,\n subscription: channel\n\n }, {}, function(response) {\n if (!response.successful) return;\n\n var channels = [].concat(response.subscription);\n this.info('Unsubscription acknowledged for ? from ?', this._dispatcher.clientId, channels);\n }, this);\n }, this);\n },\n\n // Request Response\n // MUST include: * channel MUST include: * channel\n // * data * successful\n // MAY include: * clientId MAY include: * id\n // * id * error\n // * ext * ext\n publish: function(channel, data, options) {\n validateOptions(options || {}, ['attempts', 'deadline']);\n var publication = new Publication();\n\n this.connect(function() {\n this.info('Client ? queueing published message to ?: ?', this._dispatcher.clientId, channel, data);\n\n this._sendMessage({\n channel: channel,\n data: data,\n clientId: this._dispatcher.clientId\n\n }, options, function(response) {\n if (response.successful)\n publication.setDeferredStatus('succeeded');\n else\n publication.setDeferredStatus('failed', Error.parse(response.error));\n }, this);\n }, this);\n\n return publication;\n },\n\n _sendMessage: function(message, options, callback, context) {\n message.id = this._generateMessageId();\n\n var timeout = this._advice.timeout\n ? 1.2 * this._advice.timeout / 1000\n : 1.2 * this._dispatcher.retry;\n\n this.pipeThroughExtensions('outgoing', message, null, function(message) {\n if (!message) return;\n if (callback) this._responseCallbacks[message.id] = [callback, context];\n this._dispatcher.sendMessage(message, timeout, options || {});\n }, this);\n },\n\n _generateMessageId: function() {\n this._messageId += 1;\n if (this._messageId >= Math.pow(2,32)) this._messageId = 0;\n return this._messageId.toString(36);\n },\n\n _receiveMessage: function(message) {\n var id = message.id, callback;\n\n if (message.successful !== undefined) {\n callback = this._responseCallbacks[id];\n delete this._responseCallbacks[id];\n }\n\n this.pipeThroughExtensions('incoming', message, null, function(message) {\n if (!message) return;\n if (message.advice) this._handleAdvice(message.advice);\n this._deliverMessage(message);\n if (callback) callback[0].call(callback[1], message);\n }, this);\n },\n\n _handleAdvice: function(advice) {\n assign(this._advice, advice);\n this._dispatcher.timeout = this._advice.timeout / 1000;\n\n if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {\n this._state = this.UNCONNECTED;\n this._dispatcher.clientId = null;\n this._cycleConnection();\n }\n },\n\n _deliverMessage: function(message) {\n if (!message.channel || message.data === undefined) return;\n this.info('Client ? calling listeners for ? with ?', this._dispatcher.clientId, message.channel, message.data);\n this._channels.distributeMessage(message);\n },\n\n _cycleConnection: function() {\n if (this._connectRequest) {\n this._connectRequest = null;\n this.info('Closed connection for ?', this._dispatcher.clientId);\n }\n var self = this;\n global.setTimeout(function() { self.connect() }, this._advice.interval);\n }\n});\n\nassign(Client.prototype, Deferrable);\nassign(Client.prototype, Publisher);\nassign(Client.prototype, Logging);\nassign(Client.prototype, Extensible);\n\nmodule.exports = Client;\n","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n cookies = require('../util/cookies'),\n assign = require('../util/assign'),\n Logging = require('../mixins/logging'),\n Publisher = require('../mixins/publisher'),\n Transport = require('../transport'),\n Scheduler = require('./scheduler');\n\nvar Dispatcher = Class({ className: 'Dispatcher',\n MAX_REQUEST_SIZE: 2048,\n DEFAULT_RETRY: 5,\n\n UP: 1,\n DOWN: 2,\n\n initialize: function(client, endpoint, options) {\n this._client = client;\n this.endpoint = URI.parse(endpoint);\n this._alternates = options.endpoints || {};\n\n this.cookies = cookies.CookieJar && new cookies.CookieJar();\n this._disabled = [];\n this._envelopes = {};\n this.headers = {};\n this.retry = options.retry || this.DEFAULT_RETRY;\n this._scheduler = options.scheduler || Scheduler;\n this._state = 0;\n this.transports = {};\n this.wsExtensions = [];\n\n this.proxy = options.proxy || {};\n if (typeof this._proxy === 'string') this._proxy = { origin: this._proxy };\n\n var exts = options.websocketExtensions;\n if (exts) {\n exts = [].concat(exts);\n for (var i = 0, n = exts.length; i < n; i++)\n this.addWebsocketExtension(exts[i]);\n }\n\n this.tls = options.tls || {};\n this.tls.ca = this.tls.ca || options.ca;\n\n for (var type in this._alternates)\n this._alternates[type] = URI.parse(this._alternates[type]);\n\n this.maxRequestSize = this.MAX_REQUEST_SIZE;\n },\n\n endpointFor: function(connectionType) {\n return this._alternates[connectionType] || this.endpoint;\n },\n\n addWebsocketExtension: function(extension) {\n this.wsExtensions.push(extension);\n },\n\n disable: function(feature) {\n this._disabled.push(feature);\n Transport.disable(feature);\n },\n\n setHeader: function(name, value) {\n this.headers[name] = value;\n },\n\n close: function() {\n var transport = this._transport;\n delete this._transport;\n if (transport) transport.close();\n },\n\n getConnectionTypes: function() {\n return Transport.getConnectionTypes();\n },\n\n selectTransport: function(transportTypes) {\n Transport.get(this, transportTypes, this._disabled, function(transport) {\n this.debug('Selected ? transport for ?', transport.connectionType, transport.endpoint.href);\n\n if (transport === this._transport) return;\n if (this._transport) this._transport.close();\n\n this._transport = transport;\n this.connectionType = transport.connectionType;\n }, this);\n },\n\n sendMessage: function(message, timeout, options) {\n options = options || {};\n\n var id = message.id,\n attempts = options.attempts,\n deadline = options.deadline && new Date().getTime() + (options.deadline * 1000),\n envelope = this._envelopes[id],\n scheduler;\n\n if (!envelope) {\n scheduler = new this._scheduler(message, { timeout: timeout, interval: this.retry, attempts: attempts, deadline: deadline });\n envelope = this._envelopes[id] = { message: message, scheduler: scheduler };\n }\n\n this._sendEnvelope(envelope);\n },\n\n _sendEnvelope: function(envelope) {\n if (!this._transport) return;\n if (envelope.request || envelope.timer) return;\n\n var message = envelope.message,\n scheduler = envelope.scheduler,\n self = this;\n\n if (!scheduler.isDeliverable()) {\n scheduler.abort();\n delete this._envelopes[message.id];\n return;\n }\n\n envelope.timer = global.setTimeout(function() {\n self.handleError(message);\n }, scheduler.getTimeout() * 1000);\n\n scheduler.send();\n envelope.request = this._transport.sendMessage(message);\n },\n\n handleResponse: function(reply) {\n var envelope = this._envelopes[reply.id];\n\n if (reply.successful !== undefined && envelope) {\n envelope.scheduler.succeed();\n delete this._envelopes[reply.id];\n global.clearTimeout(envelope.timer);\n }\n\n this.trigger('message', reply);\n\n if (this._state === this.UP) return;\n this._state = this.UP;\n this._client.trigger('transport:up');\n },\n\n handleError: function(message, immediate) {\n var envelope = this._envelopes[message.id],\n request = envelope && envelope.request,\n self = this;\n\n if (!request) return;\n\n request.then(function(req) {\n if (req && req.abort) req.abort();\n });\n\n var scheduler = envelope.scheduler;\n scheduler.fail();\n\n global.clearTimeout(envelope.timer);\n envelope.request = envelope.timer = null;\n\n if (immediate) {\n this._sendEnvelope(envelope);\n } else {\n envelope.timer = global.setTimeout(function() {\n envelope.timer = null;\n self._sendEnvelope(envelope);\n }, scheduler.getInterval() * 1000);\n }\n\n if (this._state === this.DOWN) return;\n this._state = this.DOWN;\n this._client.trigger('transport:down');\n }\n});\n\nDispatcher.create = function(client, endpoint, options) {\n return new Dispatcher(client, endpoint, options);\n};\n\nassign(Dispatcher.prototype, Publisher);\nassign(Dispatcher.prototype, Logging);\n\nmodule.exports = Dispatcher;\n","'use strict';\n\nvar Class = require('../util/class'),\n Grammar = require('./grammar');\n\nvar Error = Class({\n initialize: function(code, params, message) {\n this.code = code;\n this.params = Array.prototype.slice.call(params);\n this.message = message;\n },\n\n toString: function() {\n return this.code + ':' +\n this.params.join(',') + ':' +\n this.message;\n }\n});\n\nError.parse = function(message) {\n message = message || '';\n if (!Grammar.ERROR.test(message)) return new Error(null, [], message);\n\n var parts = message.split(':'),\n code = parseInt(parts[0]),\n params = parts[1].split(','),\n message = parts[2];\n\n return new Error(code, params, message);\n};\n\n// http://code.google.com/p/cometd/wiki/BayeuxCodes\nvar errors = {\n versionMismatch: [300, 'Version mismatch'],\n conntypeMismatch: [301, 'Connection types not supported'],\n extMismatch: [302, 'Extension mismatch'],\n badRequest: [400, 'Bad request'],\n clientUnknown: [401, 'Unknown client'],\n parameterMissing: [402, 'Missing required parameter'],\n channelForbidden: [403, 'Forbidden channel'],\n channelUnknown: [404, 'Unknown channel'],\n channelInvalid: [405, 'Invalid channel'],\n extUnknown: [406, 'Unknown extension'],\n publishFailed: [407, 'Failed to publish'],\n serverError: [500, 'Internal server error']\n};\n\nfor (var name in errors)\n (function(name) {\n Error[name] = function() {\n return new Error(errors[name][0], arguments, errors[name][1]).toString();\n };\n })(name);\n\nmodule.exports = Error;\n","'use strict';\n\nvar assign = require('../util/assign'),\n Logging = require('../mixins/logging');\n\nvar Extensible = {\n addExtension: function(extension) {\n this._extensions = this._extensions || [];\n this._extensions.push(extension);\n if (extension.added) extension.added(this);\n },\n\n removeExtension: function(extension) {\n if (!this._extensions) return;\n var i = this._extensions.length;\n while (i--) {\n if (this._extensions[i] !== extension) continue;\n this._extensions.splice(i,1);\n if (extension.removed) extension.removed(this);\n }\n },\n\n pipeThroughExtensions: function(stage, message, request, callback, context) {\n this.debug('Passing through ? extensions: ?', stage, message);\n\n if (!this._extensions) return callback.call(context, message);\n var extensions = this._extensions.slice();\n\n var pipe = function(message) {\n if (!message) return callback.call(context, message);\n\n var extension = extensions.shift();\n if (!extension) return callback.call(context, message);\n\n var fn = extension[stage];\n if (!fn) return pipe(message);\n\n if (fn.length >= 3) extension[stage](message, request, pipe);\n else extension[stage](message, pipe);\n };\n pipe(message);\n }\n};\n\nassign(Extensible, Logging);\n\nmodule.exports = Extensible;\n","'use strict';\n\nmodule.exports = {\n CHANNEL_NAME: /^\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+(\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+)*$/,\n CHANNEL_PATTERN: /^(\\/(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)))+)*\\/\\*{1,2}$/,\n ERROR: /^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)| |\\/|\\*|\\.))*(,(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)| |\\/|\\*|\\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)| |\\/|\\*|\\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\\-|\\_|\\!|\\~|\\(|\\)|\\$|\\@)| |\\/|\\*|\\.))*)$/,\n VERSION: /^([0-9])+(\\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\\-|\\_))*)*$/\n};\n","'use strict';\n\nvar Class = require('../util/class'),\n Deferrable = require('../mixins/deferrable');\n\nmodule.exports = Class(Deferrable);\n","'use strict';\n\nvar assign = require('../util/assign');\n\nvar Scheduler = function(message, options) {\n this.message = message;\n this.options = options;\n this.attempts = 0;\n};\n\nassign(Scheduler.prototype, {\n getTimeout: function() {\n return this.options.timeout;\n },\n\n getInterval: function() {\n return this.options.interval;\n },\n\n isDeliverable: function() {\n var attempts = this.options.attempts,\n made = this.attempts,\n deadline = this.options.deadline,\n now = new Date().getTime();\n\n if (attempts !== undefined && made >= attempts)\n return false;\n\n if (deadline !== undefined && now > deadline)\n return false;\n\n return true;\n },\n\n send: function() {\n this.attempts += 1;\n },\n\n succeed: function() {},\n\n fail: function() {},\n\n abort: function() {}\n});\n\nmodule.exports = Scheduler;\n","'use strict';\n\nvar Class = require('../util/class'),\n assign = require('../util/assign'),\n Deferrable = require('../mixins/deferrable');\n\nvar Subscription = Class({\n initialize: function(client, channels, callback, context) {\n this._client = client;\n this._channels = channels;\n this._callback = callback;\n this._context = context;\n this._cancelled = false;\n },\n\n withChannel: function(callback, context) {\n this._withChannel = [callback, context];\n return this;\n },\n\n apply: function(context, args) {\n var message = args[0];\n\n if (this._callback)\n this._callback.call(this._context, message.data);\n\n if (this._withChannel)\n this._withChannel[0].call(this._withChannel[1], message.channel, message.data);\n },\n\n cancel: function() {\n if (this._cancelled) return;\n this._client.unsubscribe(this._channels, this);\n this._cancelled = true;\n },\n\n unsubscribe: function() {\n this.cancel();\n }\n});\n\nassign(Subscription.prototype, Deferrable);\n\nmodule.exports = Subscription;\n","'use strict';\n\nvar Transport = require('./transport');\n\nTransport.register('websocket', require('./web_socket'));\nTransport.register('eventsource', require('./event_source'));\nTransport.register('long-polling', require('./xhr'));\nTransport.register('cross-origin-long-polling', require('./cors'));\nTransport.register('callback-polling', require('./jsonp'));\n\nmodule.exports = Transport;\n","'use strict';\n\nvar Class = require('../util/class'),\n Set = require('../util/set'),\n URI = require('../util/uri'),\n assign = require('../util/assign'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar CORS = assign(Class(Transport, {\n encode: function(messages) {\n return 'message=' + encodeURIComponent(toJSON(messages));\n },\n\n request: function(messages) {\n var xhrClass = global.XDomainRequest ? XDomainRequest : XMLHttpRequest,\n xhr = new xhrClass(),\n id = ++CORS._id,\n headers = this._dispatcher.headers,\n self = this,\n key;\n\n xhr.open('POST', this.endpoint.href, true);\n xhr.withCredentials = true;\n\n if (xhr.setRequestHeader) {\n xhr.setRequestHeader('Pragma', 'no-cache');\n for (key in headers) {\n if (!headers.hasOwnProperty(key)) continue;\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n\n var cleanUp = function() {\n if (!xhr) return false;\n CORS._pending.remove(id);\n xhr.onload = xhr.onerror = xhr.ontimeout = xhr.onprogress = null;\n xhr = null;\n };\n\n xhr.onload = function() {\n var replies;\n try { replies = JSON.parse(xhr.responseText) } catch (error) {}\n\n cleanUp();\n\n if (replies)\n self._receive(replies);\n else\n self._handleError(messages);\n };\n\n xhr.onerror = xhr.ontimeout = function() {\n cleanUp();\n self._handleError(messages);\n };\n\n xhr.onprogress = function() {};\n\n if (xhrClass === global.XDomainRequest)\n CORS._pending.add({ id: id, xhr: xhr });\n\n xhr.send(this.encode(messages));\n return xhr;\n }\n}), {\n _id: 0,\n _pending: new Set(),\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n if (URI.isSameOrigin(endpoint))\n return callback.call(context, false);\n\n if (global.XDomainRequest)\n return callback.call(context, endpoint.protocol === location.protocol);\n\n if (global.XMLHttpRequest) {\n var xhr = new XMLHttpRequest();\n return callback.call(context, xhr.withCredentials !== undefined);\n }\n return callback.call(context, false);\n }\n});\n\nmodule.exports = CORS;\n","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n copyObject = require('../util/copy_object'),\n assign = require('../util/assign'),\n Deferrable = require('../mixins/deferrable'),\n Transport = require('./transport'),\n XHR = require('./xhr');\n\nvar EventSource = assign(Class(Transport, {\n initialize: function(dispatcher, endpoint) {\n Transport.prototype.initialize.call(this, dispatcher, endpoint);\n if (!global.EventSource) return this.setDeferredStatus('failed');\n\n this._xhr = new XHR(dispatcher, endpoint);\n\n endpoint = copyObject(endpoint);\n endpoint.pathname += '/' + dispatcher.clientId;\n\n var socket = new global.EventSource(URI.stringify(endpoint)),\n self = this;\n\n socket.onopen = function() {\n self._everConnected = true;\n self.setDeferredStatus('succeeded');\n };\n\n socket.onerror = function() {\n if (self._everConnected) {\n self._handleError([]);\n } else {\n self.setDeferredStatus('failed');\n socket.close();\n }\n };\n\n socket.onmessage = function(event) {\n var replies;\n try { replies = JSON.parse(event.data) } catch (error) {}\n\n if (replies)\n self._receive(replies);\n else\n self._handleError([]);\n };\n\n this._socket = socket;\n },\n\n close: function() {\n if (!this._socket) return;\n this._socket.onopen = this._socket.onerror = this._socket.onmessage = null;\n this._socket.close();\n delete this._socket;\n },\n\n isUsable: function(callback, context) {\n this.callback(function() { callback.call(context, true) });\n this.errback(function() { callback.call(context, false) });\n },\n\n encode: function(messages) {\n return this._xhr.encode(messages);\n },\n\n request: function(messages) {\n return this._xhr.request(messages);\n }\n\n}), {\n isUsable: function(dispatcher, endpoint, callback, context) {\n var id = dispatcher.clientId;\n if (!id) return callback.call(context, false);\n\n XHR.isUsable(dispatcher, endpoint, function(usable) {\n if (!usable) return callback.call(context, false);\n this.create(dispatcher, endpoint).isUsable(callback, context);\n }, this);\n },\n\n create: function(dispatcher, endpoint) {\n var sockets = dispatcher.transports.eventsource = dispatcher.transports.eventsource || {},\n id = dispatcher.clientId;\n\n var url = copyObject(endpoint);\n url.pathname += '/' + (id || '');\n url = URI.stringify(url);\n\n sockets[url] = sockets[url] || new this(dispatcher, endpoint);\n return sockets[url];\n }\n});\n\nassign(EventSource.prototype, Deferrable);\n\nmodule.exports = EventSource;\n","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n copyObject = require('../util/copy_object'),\n assign = require('../util/assign'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar JSONP = assign(Class(Transport, {\n encode: function(messages) {\n var url = copyObject(this.endpoint);\n url.query.message = toJSON(messages);\n url.query.jsonp = '__jsonp' + JSONP._cbCount + '__';\n return URI.stringify(url);\n },\n\n request: function(messages) {\n var head = document.getElementsByTagName('head')[0],\n script = document.createElement('script'),\n callbackName = JSONP.getCallbackName(),\n endpoint = copyObject(this.endpoint),\n self = this;\n\n endpoint.query.message = toJSON(messages);\n endpoint.query.jsonp = callbackName;\n\n var cleanup = function() {\n if (!global[callbackName]) return false;\n global[callbackName] = undefined;\n try { delete global[callbackName] } catch (error) {}\n script.parentNode.removeChild(script);\n };\n\n global[callbackName] = function(replies) {\n cleanup();\n self._receive(replies);\n };\n\n script.type = 'text/javascript';\n script.src = URI.stringify(endpoint);\n head.appendChild(script);\n\n script.onerror = function() {\n cleanup();\n self._handleError(messages);\n };\n\n return { abort: cleanup };\n }\n}), {\n _cbCount: 0,\n\n getCallbackName: function() {\n this._cbCount += 1;\n return '__jsonp' + this._cbCount + '__';\n },\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n callback.call(context, true);\n }\n});\n\nmodule.exports = JSONP;\n","'use strict';\n\nvar Class = require('../util/class'),\n Cookie = require('../util/cookies').Cookie,\n Promise = require('../util/promise'),\n array = require('../util/array'),\n assign = require('../util/assign'),\n Logging = require('../mixins/logging'),\n Timeouts = require('../mixins/timeouts'),\n Channel = require('../protocol/channel');\n\nvar Transport = assign(Class({ className: 'Transport',\n DEFAULT_PORTS: { 'http:': 80, 'https:': 443, 'ws:': 80, 'wss:': 443 },\n MAX_DELAY: 0,\n\n batching: true,\n\n initialize: function(dispatcher, endpoint) {\n this._dispatcher = dispatcher;\n this.endpoint = endpoint;\n this._outbox = [];\n this._proxy = assign({}, this._dispatcher.proxy);\n\n if (!this._proxy.origin)\n this._proxy.origin = this._findProxy();\n },\n\n close: function() {},\n\n encode: function(messages) {\n return '';\n },\n\n sendMessage: function(message) {\n this.debug('Client ? sending message to ?: ?',\n this._dispatcher.clientId, this.endpoint.href, message);\n\n if (!this.batching) return Promise.resolve(this.request([message]));\n\n this._outbox.push(message);\n this._flushLargeBatch();\n\n if (message.channel === Channel.HANDSHAKE)\n return this._publish(0.01);\n\n if (message.channel === Channel.CONNECT)\n this._connectMessage = message;\n\n return this._publish(this.MAX_DELAY);\n },\n\n _makePromise: function() {\n var self = this;\n\n this._requestPromise = this._requestPromise || new Promise(function(resolve) {\n self._resolvePromise = resolve;\n });\n },\n\n _publish: function(delay) {\n this._makePromise();\n\n this.addTimeout('publish', delay, function() {\n this._flush();\n delete this._requestPromise;\n }, this);\n\n return this._requestPromise;\n },\n\n _flush: function() {\n this.removeTimeout('publish');\n\n if (this._outbox.length > 1 && this._connectMessage)\n this._connectMessage.advice = { timeout: 0 };\n\n this._resolvePromise(this.request(this._outbox));\n\n this._connectMessage = null;\n this._outbox = [];\n },\n\n _flushLargeBatch: function() {\n var string = this.encode(this._outbox);\n if (string.length < this._dispatcher.maxRequestSize) return;\n var last = this._outbox.pop();\n\n this._makePromise();\n this._flush();\n\n if (last) this._outbox.push(last);\n },\n\n _receive: function(replies) {\n if (!replies) return;\n replies = [].concat(replies);\n\n this.debug('Client ? received from ? via ?: ?',\n this._dispatcher.clientId, this.endpoint.href, this.connectionType, replies);\n\n for (var i = 0, n = replies.length; i < n; i++)\n this._dispatcher.handleResponse(replies[i]);\n },\n\n _handleError: function(messages, immediate) {\n messages = [].concat(messages);\n\n this.debug('Client ? failed to send to ? via ?: ?',\n this._dispatcher.clientId, this.endpoint.href, this.connectionType, messages);\n\n for (var i = 0, n = messages.length; i < n; i++)\n this._dispatcher.handleError(messages[i]);\n },\n\n _getCookies: function() {\n var cookies = this._dispatcher.cookies,\n url = this.endpoint.href;\n\n if (!cookies) return '';\n\n return array.map(cookies.getCookiesSync(url), function(cookie) {\n return cookie.cookieString();\n }).join('; ');\n },\n\n _storeCookies: function(setCookie) {\n var cookies = this._dispatcher.cookies,\n url = this.endpoint.href,\n cookie;\n\n if (!setCookie || !cookies) return;\n setCookie = [].concat(setCookie);\n\n for (var i = 0, n = setCookie.length; i < n; i++) {\n cookie = Cookie.parse(setCookie[i]);\n cookies.setCookieSync(cookie, url);\n }\n },\n\n _findProxy: function() {\n if (typeof process === 'undefined') return undefined;\n\n var protocol = this.endpoint.protocol;\n if (!protocol) return undefined;\n\n var name = protocol.replace(/:$/, '').toLowerCase() + '_proxy',\n upcase = name.toUpperCase(),\n env = process.env,\n keys, proxy;\n\n if (name === 'http_proxy' && env.REQUEST_METHOD) {\n keys = Object.keys(env).filter(function(k) { return /^http_proxy$/i.test(k) });\n if (keys.length === 1) {\n if (keys[0] === name && env[upcase] === undefined)\n proxy = env[name];\n } else if (keys.length > 1) {\n proxy = env[name];\n }\n proxy = proxy || env['CGI_' + upcase];\n } else {\n proxy = env[name] || env[upcase];\n if (proxy && !env[name])\n console.warn('The environment variable ' + upcase +\n ' is discouraged. Use ' + name + '.');\n }\n return proxy;\n }\n\n}), {\n get: function(dispatcher, allowed, disabled, callback, context) {\n var endpoint = dispatcher.endpoint;\n\n array.asyncEach(this._transports, function(pair, resume) {\n var connType = pair[0], klass = pair[1],\n connEndpoint = dispatcher.endpointFor(connType);\n\n if (array.indexOf(disabled, connType) >= 0)\n return resume();\n\n if (array.indexOf(allowed, connType) < 0) {\n klass.isUsable(dispatcher, connEndpoint, function() {});\n return resume();\n }\n\n klass.isUsable(dispatcher, connEndpoint, function(isUsable) {\n if (!isUsable) return resume();\n var transport = klass.hasOwnProperty('create') ? klass.create(dispatcher, connEndpoint) : new klass(dispatcher, connEndpoint);\n callback.call(context, transport);\n });\n }, function() {\n throw new Error('Could not find a usable connection type for ' + endpoint.href);\n });\n },\n\n register: function(type, klass) {\n this._transports.push([type, klass]);\n klass.prototype.connectionType = type;\n },\n\n getConnectionTypes: function() {\n return array.map(this._transports, function(t) { return t[0] });\n },\n\n disable: function(feature) {\n if (feature !== 'autodisconnect') return;\n\n for (var i = 0; i < this._transports.length; i++)\n this._transports[i][1]._unloaded = false;\n },\n\n _transports: []\n});\n\nassign(Transport.prototype, Logging);\nassign(Transport.prototype, Timeouts);\n\nmodule.exports = Transport;\n","'use strict';\n\nvar Class = require('../util/class'),\n Promise = require('../util/promise'),\n Set = require('../util/set'),\n URI = require('../util/uri'),\n browser = require('../util/browser'),\n copyObject = require('../util/copy_object'),\n assign = require('../util/assign'),\n toJSON = require('../util/to_json'),\n ws = require('../util/websocket'),\n Deferrable = require('../mixins/deferrable'),\n Transport = require('./transport');\n\nvar WebSocket = assign(Class(Transport, {\n UNCONNECTED: 1,\n CONNECTING: 2,\n CONNECTED: 3,\n\n batching: false,\n\n isUsable: function(callback, context) {\n this.callback(function() { callback.call(context, true) });\n this.errback(function() { callback.call(context, false) });\n this.connect();\n },\n\n request: function(messages) {\n this._pending = this._pending || new Set();\n for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);\n\n var self = this;\n\n var promise = new Promise(function(resolve, reject) {\n self.callback(function(socket) {\n if (!socket || socket.readyState !== 1) return;\n socket.send(toJSON(messages));\n resolve(socket);\n });\n\n self.connect();\n });\n\n return {\n abort: function() { promise.then(function(ws) { ws.close() }) }\n };\n },\n\n connect: function() {\n if (WebSocket._unloaded) return;\n\n this._state = this._state || this.UNCONNECTED;\n if (this._state !== this.UNCONNECTED) return;\n this._state = this.CONNECTING;\n\n var socket = this._createSocket();\n if (!socket) return this.setDeferredStatus('failed');\n\n var self = this;\n\n socket.onopen = function() {\n if (socket.headers) self._storeCookies(socket.headers['set-cookie']);\n self._socket = socket;\n self._state = self.CONNECTED;\n self._everConnected = true;\n self.setDeferredStatus('succeeded', socket);\n };\n\n var closed = false;\n socket.onclose = socket.onerror = function() {\n if (closed) return;\n closed = true;\n\n var wasConnected = (self._state === self.CONNECTED);\n socket.onopen = socket.onclose = socket.onerror = socket.onmessage = null;\n\n delete self._socket;\n self._state = self.UNCONNECTED;\n\n var pending = self._pending ? self._pending.toArray() : [];\n delete self._pending;\n\n if (wasConnected || self._everConnected) {\n self.setDeferredStatus('unknown');\n self._handleError(pending, wasConnected);\n } else {\n self.setDeferredStatus('failed');\n }\n };\n\n socket.onmessage = function(event) {\n var replies;\n try { replies = JSON.parse(event.data) } catch (error) {}\n\n if (!replies) return;\n\n replies = [].concat(replies);\n\n for (var i = 0, n = replies.length; i < n; i++) {\n if (replies[i].successful === undefined) continue;\n self._pending.remove(replies[i]);\n }\n self._receive(replies);\n };\n },\n\n close: function() {\n if (!this._socket) return;\n this._socket.close();\n },\n\n _createSocket: function() {\n var url = WebSocket.getSocketUrl(this.endpoint),\n headers = this._dispatcher.headers,\n extensions = this._dispatcher.wsExtensions,\n cookie = this._getCookies(),\n tls = this._dispatcher.tls,\n options = { extensions: extensions, headers: headers, proxy: this._proxy, tls: tls };\n\n if (cookie !== '') options.headers['Cookie'] = cookie;\n\n try {\n return ws.create(url, [], options);\n } catch (e) {\n // catch CSP error to allow transport to fallback to next connType\n }\n }\n\n}), {\n PROTOCOLS: {\n 'http:': 'ws:',\n 'https:': 'wss:'\n },\n\n create: function(dispatcher, endpoint) {\n var sockets = dispatcher.transports.websocket = dispatcher.transports.websocket || {};\n sockets[endpoint.href] = sockets[endpoint.href] || new this(dispatcher, endpoint);\n return sockets[endpoint.href];\n },\n\n getSocketUrl: function(endpoint) {\n endpoint = copyObject(endpoint);\n endpoint.protocol = this.PROTOCOLS[endpoint.protocol];\n return URI.stringify(endpoint);\n },\n\n isUsable: function(dispatcher, endpoint, callback, context) {\n this.create(dispatcher, endpoint).isUsable(callback, context);\n }\n});\n\nassign(WebSocket.prototype, Deferrable);\n\nif (browser.Event && global.onbeforeunload !== undefined) {\n browser.Event.on(global, 'beforeunload', function() {\n if (WebSocket._unloaded === undefined)\n WebSocket._unloaded = true;\n });\n}\n\nmodule.exports = WebSocket;\n","'use strict';\n\nvar Class = require('../util/class'),\n URI = require('../util/uri'),\n browser = require('../util/browser'),\n assign = require('../util/assign'),\n toJSON = require('../util/to_json'),\n Transport = require('./transport');\n\nvar XHR = assign(Class(Transport, {\n encode: function(messages) {\n return toJSON(messages);\n },\n\n request: function(messages) {\n var href = this.endpoint.href,\n self = this,\n xhr;\n\n // Prefer XMLHttpRequest over ActiveXObject if they both exist\n if (global.XMLHttpRequest) {\n xhr = new XMLHttpRequest();\n } else if (global.ActiveXObject) {\n xhr = new ActiveXObject('Microsoft.XMLHTTP');\n } else {\n return this._handleError(messages);\n }\n\n xhr.open('POST', href, true);\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.setRequestHeader('Pragma', 'no-cache');\n xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n\n var headers = this._dispatcher.headers;\n for (var key in headers) {\n if (!headers.hasOwnProperty(key)) continue;\n xhr.setRequestHeader(key, headers[key]);\n }\n\n var abort = function() { xhr.abort() };\n if (global.onbeforeunload !== undefined)\n browser.Event.on(global, 'beforeunload', abort);\n\n xhr.onreadystatechange = function() {\n if (!xhr || xhr.readyState !== 4) return;\n\n var replies = null,\n status = xhr.status,\n text = xhr.responseText,\n successful = (status >= 200 && status < 300) || status === 304 || status === 1223;\n\n if (global.onbeforeunload !== undefined)\n browser.Event.detach(global, 'beforeunload', abort);\n\n xhr.onreadystatechange = function() {};\n xhr = null;\n\n if (!successful) return self._handleError(messages);\n\n try {\n replies = JSON.parse(text);\n } catch (error) {}\n\n if (replies)\n self._receive(replies);\n else\n self._handleError(messages);\n };\n\n xhr.send(this.encode(messages));\n return xhr;\n }\n}), {\n isUsable: function(dispatcher, endpoint, callback, context) {\n var usable = (navigator.product === 'ReactNative')\n || URI.isSameOrigin(endpoint);\n\n callback.call(context, usable);\n }\n});\n\nmodule.exports = XHR;\n","'use strict';\n\nmodule.exports = {\n commonElement: function(lista, listb) {\n for (var i = 0, n = lista.length; i < n; i++) {\n if (this.indexOf(listb, lista[i]) !== -1)\n return lista[i];\n }\n return null;\n },\n\n indexOf: function(list, needle) {\n if (list.indexOf) return list.indexOf(needle);\n\n for (var i = 0, n = list.length; i < n; i++) {\n if (list[i] === needle) return i;\n }\n return -1;\n },\n\n map: function(object, callback, context) {\n if (object.map) return object.map(callback, context);\n var result = [];\n\n if (object instanceof Array) {\n for (var i = 0, n = object.length; i < n; i++) {\n result.push(callback.call(context || null, object[i], i));\n }\n } else {\n for (var key in object) {\n if (!object.hasOwnProperty(key)) continue;\n result.push(callback.call(context || null, key, object[key]));\n }\n }\n return result;\n },\n\n filter: function(array, callback, context) {\n if (array.filter) return array.filter(callback, context);\n var result = [];\n for (var i = 0, n = array.length; i < n; i++) {\n if (callback.call(context || null, array[i], i))\n result.push(array[i]);\n }\n return result;\n },\n\n asyncEach: function(list, iterator, callback, context) {\n var n = list.length,\n i = -1,\n calls = 0,\n looping = false;\n\n var iterate = function() {\n calls -= 1;\n i += 1;\n if (i === n) return callback && callback.call(context);\n iterator(list[i], resume);\n };\n\n var loop = function() {\n if (looping) return;\n looping = true;\n while (calls > 0) iterate();\n looping = false;\n };\n\n var resume = function() {\n calls += 1;\n loop();\n };\n resume();\n }\n};\n","'use strict';\n\nvar forEach = Array.prototype.forEach,\n hasOwn = Object.prototype.hasOwnProperty;\n\nmodule.exports = function(target) {\n forEach.call(arguments, function(source, i) {\n if (i === 0) return;\n\n for (var key in source) {\n if (hasOwn.call(source, key)) target[key] = source[key];\n }\n });\n\n return target;\n};\n","'use strict';\n\nvar Event = {\n _registry: [],\n\n on: function(element, eventName, callback, context) {\n var wrapped = function() { callback.call(context) };\n\n if (element.addEventListener)\n element.addEventListener(eventName, wrapped, false);\n else\n element.attachEvent('on' + eventName, wrapped);\n\n this._registry.push({\n _element: element,\n _type: eventName,\n _callback: callback,\n _context: context,\n _handler: wrapped\n });\n },\n\n detach: function(element, eventName, callback, context) {\n var i = this._registry.length, register;\n while (i--) {\n register = this._registry[i];\n\n if ((element && element !== register._element) ||\n (eventName && eventName !== register._type) ||\n (callback && callback !== register._callback) ||\n (context && context !== register._context))\n continue;\n\n if (register._element.removeEventListener)\n register._element.removeEventListener(register._type, register._handler, false);\n else\n register._element.detachEvent('on' + register._type, register._handler);\n\n this._registry.splice(i,1);\n register = null;\n }\n }\n};\n\nif (global.onunload !== undefined)\n Event.on(global, 'unload', Event.detach, Event);\n\nmodule.exports = {\n Event: Event\n};\n","'use strict';\n\nvar assign = require('./assign');\n\nmodule.exports = function(parent, methods) {\n if (typeof parent !== 'function') {\n methods = parent;\n parent = Object;\n }\n\n var klass = function() {\n if (!this.initialize) return this;\n return this.initialize.apply(this, arguments) || this;\n };\n\n var bridge = function() {};\n bridge.prototype = parent.prototype;\n\n klass.prototype = new bridge();\n assign(klass.prototype, methods);\n\n return klass;\n};\n","module.exports = {\n VERSION: '1.4.0',\n\n BAYEUX_VERSION: '1.0',\n ID_LENGTH: 160,\n JSONP_CALLBACK: 'jsonpcallback',\n CONNECTION_TYPES: ['long-polling', 'cross-origin-long-polling', 'callback-polling', 'websocket', 'eventsource', 'in-process'],\n\n MANDATORY_CONNECTION_TYPES: ['long-polling', 'callback-polling', 'in-process']\n};\n","'use strict';\n\nmodule.exports = {};\n","'use strict';\n\nvar copyObject = function(object) {\n var clone, i, key;\n if (object instanceof Array) {\n clone = [];\n i = object.length;\n while (i--) clone[i] = copyObject(object[i]);\n return clone;\n } else if (typeof object === 'object') {\n clone = (object === null) ? null : {};\n for (key in object) clone[key] = copyObject(object[key]);\n return clone;\n } else {\n return object;\n }\n};\n\nmodule.exports = copyObject;\n","/*\nCopyright Joyent, Inc. and other Node contributors. All rights reserved.\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\nvar isArray = typeof Array.isArray === 'function'\n ? Array.isArray\n : function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]'\n }\n;\nfunction indexOf (xs, x) {\n if (xs.indexOf) return xs.indexOf(x);\n for (var i = 0; i < xs.length; i++) {\n if (x === xs[i]) return i;\n }\n return -1;\n}\n\nfunction EventEmitter() {}\nmodule.exports = EventEmitter;\n\nEventEmitter.prototype.emit = function(type) {\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events || !this._events.error ||\n (isArray(this._events.error) && !this._events.error.length))\n {\n if (arguments[1] instanceof Error) {\n throw arguments[1]; // Unhandled 'error' event\n } else {\n throw new Error(\"Uncaught, unspecified 'error' event.\");\n }\n return false;\n }\n }\n\n if (!this._events) return false;\n var handler = this._events[type];\n if (!handler) return false;\n\n if (typeof handler == 'function') {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n var args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n return true;\n\n } else if (isArray(handler)) {\n var args = Array.prototype.slice.call(arguments, 1);\n\n var listeners = handler.slice();\n for (var i = 0, l = listeners.length; i < l; i++) {\n listeners[i].apply(this, args);\n }\n return true;\n\n } else {\n return false;\n }\n};\n\n// EventEmitter is defined in src/node_events.cc\n// EventEmitter.prototype.emit() is also defined there.\nEventEmitter.prototype.addListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('addListener only takes instances of Function');\n }\n\n if (!this._events) this._events = {};\n\n // To avoid recursion in the case that type == \"newListeners\"! Before\n // adding it to the listeners, first emit \"newListeners\".\n this.emit('newListener', type, listener);\n\n if (!this._events[type]) {\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n } else if (isArray(this._events[type])) {\n // If we've already got an array, just append.\n this._events[type].push(listener);\n } else {\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n var self = this;\n self.on(type, function g() {\n self.removeListener(type, g);\n listener.apply(this, arguments);\n });\n\n return this;\n};\n\nEventEmitter.prototype.removeListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('removeListener only takes instances of Function');\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (!this._events || !this._events[type]) return this;\n\n var list = this._events[type];\n\n if (isArray(list)) {\n var i = indexOf(list, listener);\n if (i < 0) return this;\n list.splice(i, 1);\n if (list.length == 0)\n delete this._events[type];\n } else if (this._events[type] === listener) {\n delete this._events[type];\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n if (arguments.length === 0) {\n this._events = {};\n return this;\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (type && this._events && this._events[type]) this._events[type] = null;\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n if (!this._events) this._events = {};\n if (!this._events[type]) this._events[type] = [];\n if (!isArray(this._events[type])) {\n this._events[type] = [this._events[type]];\n }\n return this._events[type];\n};\n","'use strict';\n\nvar asap = require('asap');\n\nvar PENDING = -1,\n FULFILLED = 0,\n REJECTED = 1;\n\nvar Promise = function(task) {\n this._state = PENDING;\n this._value = null;\n this._defer = [];\n\n execute(this, task);\n};\n\nPromise.prototype.then = function(onFulfilled, onRejected) {\n var promise = new Promise();\n\n var deferred = {\n promise: promise,\n onFulfilled: onFulfilled,\n onRejected: onRejected\n };\n\n if (this._state === PENDING)\n this._defer.push(deferred);\n else\n propagate(this, deferred);\n\n return promise;\n};\n\nPromise.prototype['catch'] = function(onRejected) {\n return this.then(null, onRejected);\n};\n\nvar execute = function(promise, task) {\n if (typeof task !== 'function') return;\n\n var calls = 0;\n\n var resolvePromise = function(value) {\n if (calls++ === 0) resolve(promise, value);\n };\n\n var rejectPromise = function(reason) {\n if (calls++ === 0) reject(promise, reason);\n };\n\n try {\n task(resolvePromise, rejectPromise);\n } catch (error) {\n rejectPromise(error);\n }\n};\n\nvar propagate = function(promise, deferred) {\n var state = promise._state,\n value = promise._value,\n next = deferred.promise,\n handler = [deferred.onFulfilled, deferred.onRejected][state],\n pass = [resolve, reject][state];\n\n if (typeof handler !== 'function')\n return pass(next, value);\n\n asap(function() {\n try {\n resolve(next, handler(value));\n } catch (error) {\n reject(next, error);\n }\n });\n};\n\nvar resolve = function(promise, value) {\n if (promise === value)\n return reject(promise, new TypeError('Recursive promise chain detected'));\n\n var then;\n\n try {\n then = getThen(value);\n } catch (error) {\n return reject(promise, error);\n }\n\n if (!then) return fulfill(promise, value);\n\n execute(promise, function(resolvePromise, rejectPromise) {\n then.call(value, resolvePromise, rejectPromise);\n });\n};\n\nvar getThen = function(value) {\n var type = typeof value,\n then = (type === 'object' || type === 'function') && value && value.then;\n\n return (typeof then === 'function')\n ? then\n : null;\n};\n\nvar fulfill = function(promise, value) {\n settle(promise, FULFILLED, value);\n};\n\nvar reject = function(promise, reason) {\n settle(promise, REJECTED, reason);\n};\n\nvar settle = function(promise, state, value) {\n var defer = promise._defer, i = 0;\n\n promise._state = state;\n promise._value = value;\n promise._defer = null;\n\n if (defer.length === 0) return;\n while (i < defer.length) propagate(promise, defer[i++]);\n};\n\nPromise.resolve = function(value) {\n try {\n if (getThen(value)) return value;\n } catch (error) {\n return Promise.reject(error);\n }\n\n return new Promise(function(resolve, reject) { resolve(value) });\n};\n\nPromise.reject = function(reason) {\n return new Promise(function(resolve, reject) { reject(reason) });\n};\n\nPromise.all = function(promises) {\n return new Promise(function(resolve, reject) {\n var list = [], n = promises.length, i;\n\n if (n === 0) return resolve(list);\n\n var push = function(promise, i) {\n Promise.resolve(promise).then(function(value) {\n list[i] = value;\n if (--n === 0) resolve(list);\n }, reject);\n };\n\n for (i = 0; i < n; i++) push(promises[i], i);\n });\n};\n\nPromise.race = function(promises) {\n return new Promise(function(resolve, reject) {\n for (var i = 0, n = promises.length; i < n; i++)\n Promise.resolve(promises[i]).then(resolve, reject);\n });\n};\n\nPromise.deferred = function() {\n var tuple = {};\n\n tuple.promise = new Promise(function(resolve, reject) {\n tuple.resolve = resolve;\n tuple.reject = reject;\n });\n return tuple;\n};\n\nmodule.exports = Promise;\n","'use strict';\n\nvar Class = require('./class');\n\nmodule.exports = Class({\n initialize: function() {\n this._index = {};\n },\n\n add: function(item) {\n var key = (item.id !== undefined) ? item.id : item;\n if (this._index.hasOwnProperty(key)) return false;\n this._index[key] = item;\n return true;\n },\n\n forEach: function(block, context) {\n for (var key in this._index) {\n if (this._index.hasOwnProperty(key))\n block.call(context, this._index[key]);\n }\n },\n\n isEmpty: function() {\n for (var key in this._index) {\n if (this._index.hasOwnProperty(key)) return false;\n }\n return true;\n },\n\n member: function(item) {\n for (var key in this._index) {\n if (this._index[key] === item) return true;\n }\n return false;\n },\n\n remove: function(item) {\n var key = (item.id !== undefined) ? item.id : item;\n var removed = this._index[key];\n delete this._index[key];\n return removed;\n },\n\n toArray: function() {\n var array = [];\n this.forEach(function(item) { array.push(item) });\n return array;\n }\n});\n","'use strict';\n\n// http://assanka.net/content/tech/2009/09/02/json2-js-vs-prototype/\n\nmodule.exports = function(object) {\n return JSON.stringify(object, function(key, value) {\n return (this[key] instanceof Array) ? this[key] : value;\n });\n};\n","'use strict';\n\nmodule.exports = {\n isURI: function(uri) {\n return uri && uri.protocol && uri.host && uri.path;\n },\n\n isSameOrigin: function(uri) {\n return uri.protocol === location.protocol &&\n uri.hostname === location.hostname &&\n uri.port === location.port;\n },\n\n parse: function(url) {\n if (typeof url !== 'string') return url;\n var uri = {}, parts, query, pairs, i, n, data;\n\n var consume = function(name, pattern) {\n url = url.replace(pattern, function(match) {\n uri[name] = match;\n return '';\n });\n uri[name] = uri[name] || '';\n };\n\n consume('protocol', /^[a-z]+\\:/i);\n consume('host', /^\\/\\/[^\\/\\?#]+/);\n\n if (!/^\\//.test(url) && !uri.host)\n url = location.pathname.replace(/[^\\/]*$/, '') + url;\n\n consume('pathname', /^[^\\?#]*/);\n consume('search', /^\\?[^#]*/);\n consume('hash', /^#.*/);\n\n uri.protocol = uri.protocol || location.protocol;\n\n if (uri.host) {\n uri.host = uri.host.substr(2);\n\n if (/@/.test(uri.host)) {\n uri.auth = uri.host.split('@')[0];\n uri.host = uri.host.split('@')[1];\n }\n parts = uri.host.match(/^\\[([^\\]]+)\\]|^[^:]+/);\n uri.hostname = parts[1] || parts[0];\n uri.port = (uri.host.match(/:(\\d+)$/) || [])[1] || '';\n } else {\n uri.host = location.host;\n uri.hostname = location.hostname;\n uri.port = location.port;\n }\n\n uri.pathname = uri.pathname || '/';\n uri.path = uri.pathname + uri.search;\n\n query = uri.search.replace(/^\\?/, '');\n pairs = query ? query.split('&') : [];\n data = {};\n\n for (i = 0, n = pairs.length; i < n; i++) {\n parts = pairs[i].split('=');\n data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');\n }\n\n uri.query = data;\n\n uri.href = this.stringify(uri);\n return uri;\n },\n\n stringify: function(uri) {\n var auth = uri.auth ? uri.auth + '@' : '',\n string = uri.protocol + '//' + auth + uri.host;\n\n string += uri.pathname + this.queryString(uri.query) + (uri.hash || '');\n\n return string;\n },\n\n queryString: function(query) {\n var pairs = [];\n for (var key in query) {\n if (!query.hasOwnProperty(key)) continue;\n pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(query[key]));\n }\n if (pairs.length === 0) return '';\n return '?' + pairs.join('&');\n }\n};\n","'use strict';\n\nvar array = require('./array');\n\nmodule.exports = function(options, validKeys) {\n for (var key in options) {\n if (array.indexOf(validKeys, key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n","'use strict';\n\nvar WS = global.MozWebSocket || global.WebSocket;\n\nmodule.exports = {\n create: function(url, protocols, options) {\n if (typeof WS !== 'function') return null;\n return new WS(url);\n }\n};\n"],"sourceRoot":""}
data/lib/faye.rb CHANGED
@@ -14,30 +14,31 @@ require 'time'
14
14
  require 'uri'
15
15
 
16
16
  module Faye
17
- VERSION = '1.0.3'
17
+ VERSION = '1.4.0'
18
18
 
19
19
  ROOT = File.expand_path(File.dirname(__FILE__))
20
20
 
21
- autoload :Publisher, File.join(ROOT, 'faye', 'mixins', 'publisher')
22
21
  autoload :Deferrable, File.join(ROOT, 'faye', 'mixins', 'deferrable')
23
- autoload :Timeouts, File.join(ROOT, 'faye', 'mixins', 'timeouts')
24
22
  autoload :Logging, File.join(ROOT, 'faye', 'mixins', 'logging')
23
+ autoload :Publisher, File.join(ROOT, 'faye', 'mixins', 'publisher')
24
+ autoload :Timeouts, File.join(ROOT, 'faye', 'mixins', 'timeouts')
25
25
 
26
26
  autoload :Namespace, File.join(ROOT, 'faye', 'util', 'namespace')
27
27
 
28
28
  autoload :Engine, File.join(ROOT, 'faye', 'engines', 'proxy')
29
29
 
30
- autoload :Grammar, File.join(ROOT, 'faye', 'protocol', 'grammar')
31
- autoload :Extensible, File.join(ROOT, 'faye', 'protocol', 'extensible')
32
30
  autoload :Channel, File.join(ROOT, 'faye', 'protocol', 'channel')
33
- autoload :Envelope, File.join(ROOT, 'faye', 'protocol', 'envelope')
34
- autoload :Subscription, File.join(ROOT, 'faye', 'protocol', 'subscription')
35
- autoload :Publication, File.join(ROOT, 'faye', 'protocol', 'publication')
36
31
  autoload :Client, File.join(ROOT, 'faye', 'protocol', 'client')
32
+ autoload :Dispatcher, File.join(ROOT, 'faye', 'protocol', 'dispatcher')
33
+ autoload :Scheduler, File.join(ROOT, 'faye', 'protocol', 'scheduler')
34
+ autoload :Extensible, File.join(ROOT, 'faye', 'protocol', 'extensible')
35
+ autoload :Grammar, File.join(ROOT, 'faye', 'protocol', 'grammar')
36
+ autoload :Publication, File.join(ROOT, 'faye', 'protocol', 'publication')
37
37
  autoload :Server, File.join(ROOT, 'faye', 'protocol', 'server')
38
+ autoload :Subscription, File.join(ROOT, 'faye', 'protocol', 'subscription')
38
39
 
39
- autoload :Transport, File.join(ROOT, 'faye', 'transport', 'transport')
40
40
  autoload :Error, File.join(ROOT, 'faye', 'error')
41
+ autoload :Transport, File.join(ROOT, 'faye', 'transport', 'transport')
41
42
 
42
43
  autoload :RackAdapter, File.join(ROOT, 'faye', 'adapters', 'rack_adapter')
43
44
  autoload :StaticServer, File.join(ROOT, 'faye', 'adapters', 'static_server')
@@ -80,10 +81,6 @@ module Faye
80
81
  end
81
82
  end
82
83
 
83
- def self.parse_url(url)
84
- String === url ? URI.parse(url) : url
85
- end
86
-
87
84
  def self.to_json(value)
88
85
  case value
89
86
  when Hash, Array then MultiJson.dump(value)
@@ -125,4 +122,3 @@ module Faye
125
122
  resume.call
126
123
  end
127
124
  end
128
-
@@ -11,9 +11,9 @@ module Faye
11
11
  DEFAULT_ENDPOINT = '/bayeux'
12
12
  SCRIPT_PATH = 'faye-browser-min.js'
13
13
 
14
- TYPE_JSON = {'Content-Type' => 'application/json; charset=utf-8'}
15
- TYPE_SCRIPT = {'Content-Type' => 'text/javascript; charset=utf-8'}
16
- TYPE_TEXT = {'Content-Type' => 'text/plain; charset=utf-8'}
14
+ TYPE_JSON = { 'Content-Type' => 'application/json; charset=utf-8' }
15
+ TYPE_SCRIPT = { 'Content-Type' => 'text/javascript; charset=utf-8' }
16
+ TYPE_TEXT = { 'Content-Type' => 'text/plain; charset=utf-8' }
17
17
 
18
18
  VALID_JSONP_CALLBACK = /^[a-z_\$][a-z0-9_\$]*(\.[a-z_\$][a-z0-9_\$]*)*$/i
19
19
 
@@ -22,20 +22,30 @@ module Faye
22
22
  # down. Better suggestions welcome.
23
23
  HTTP_X_NO_CONTENT_LENGTH = 'HTTP_X_NO_CONTENT_LENGTH'
24
24
 
25
- def initialize(app = nil, options = nil)
25
+ def initialize(app = nil, options = nil, &block)
26
26
  @app = app if app.respond_to?(:call)
27
27
  @options = [app, options].grep(Hash).first || {}
28
28
 
29
+ ::WebSocket::Driver.validate_options(@options, [:engine, :mount, :ping, :timeout, :extensions, :websocket_extensions])
30
+
29
31
  @endpoint = @options[:mount] || DEFAULT_ENDPOINT
32
+ @extensions = []
30
33
  @endpoint_re = Regexp.new('^' + @endpoint.gsub(/\/$/, '') + '(/[^/]*)*(\\.[^\\.]+)?$')
31
34
  @server = Server.new(@options)
32
35
 
33
- @static = StaticServer.new(ROOT, /\.(?:js|map)$/)
36
+ @static = StaticServer.new(File.join(ROOT, '..', 'build', 'client'), /\.(?:js|map)$/)
34
37
  @static.map(File.basename(@endpoint) + '.js', SCRIPT_PATH)
35
38
  @static.map('client.js', SCRIPT_PATH)
36
39
 
37
- return unless extensions = @options[:extensions]
38
- [*extensions].each { |extension| add_extension(extension) }
40
+ if extensions = @options[:extensions]
41
+ [*extensions].each { |extension| add_extension(extension) }
42
+ end
43
+
44
+ if websocket_extensions = @options[:websocket_extensions]
45
+ [*websocket_extensions].each { |ext| add_websocket_extension(ext) }
46
+ end
47
+
48
+ block.call(self) if block
39
49
  end
40
50
 
41
51
  def listen(*args)
@@ -50,6 +60,10 @@ module Faye
50
60
  @server.remove_extension(extension)
51
61
  end
52
62
 
63
+ def add_websocket_extension(extension)
64
+ @extensions << extension
65
+ end
66
+
53
67
  def close
54
68
  @server.close
55
69
  end
@@ -65,14 +79,14 @@ module Faye
65
79
  unless request.path_info =~ @endpoint_re
66
80
  env['faye.client'] = get_client
67
81
  return @app ? @app.call(env) :
68
- [404, TYPE_TEXT, ["Sure you're not looking for #{@endpoint} ?"]]
82
+ [404, TYPE_TEXT, ["Sure you're not looking for #{ @endpoint } ?"]]
69
83
  end
70
84
 
71
85
  return @static.call(env) if @static =~ request.path_info
72
86
 
73
87
  # http://groups.google.com/group/faye-users/browse_thread/thread/4a01bb7d25d3636a
74
88
  if env['REQUEST_METHOD'] == 'OPTIONS' or env['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] == 'POST'
75
- return handle_options
89
+ return handle_options(request)
76
90
  end
77
91
 
78
92
  return handle_websocket(request) if Faye::WebSocket.websocket?(env)
@@ -89,9 +103,14 @@ module Faye
89
103
  return [400, TYPE_TEXT, ['Bad request']]
90
104
  end
91
105
 
92
- debug "Received message via HTTP #{request.request_method}: ?", json_msg
106
+ unless json_msg.force_encoding('UTF-8').valid_encoding?
107
+ error 'Received request with invalid encoding: ?', format_request(request)
108
+ return [400, TYPE_TEXT, ['Bad request']]
109
+ end
110
+
111
+ debug("Received message via HTTP #{ request.request_method }: ?", json_msg)
93
112
 
94
- message = MultiJson.load(json_msg)
113
+ message = parse_json(json_msg)
95
114
  jsonp = request.params['jsonp'] || JSONP_CALLBACK
96
115
  headers = request.get? ? TYPE_SCRIPT.dup : TYPE_JSON.dup
97
116
  origin = request.env['HTTP_ORIGIN']
@@ -102,10 +121,14 @@ module Faye
102
121
  return [400, TYPE_TEXT, ['Bad request']]
103
122
  end
104
123
 
105
- headers['Access-Control-Allow-Origin'] = origin if origin
106
124
  headers['Cache-Control'] = 'no-cache, no-store'
107
125
  headers['X-Content-Type-Options'] = 'nosniff'
108
126
 
127
+ if origin
128
+ headers['Access-Control-Allow-Credentials'] = 'true'
129
+ headers['Access-Control-Allow-Origin'] = origin
130
+ end
131
+
109
132
  request.env['rack.hijack'].call if request.env['rack.hijack']
110
133
  hijack = request.env['rack.hijack_io']
111
134
 
@@ -119,15 +142,14 @@ module Faye
119
142
  end
120
143
 
121
144
  headers['Content-Length'] = response.bytesize.to_s unless request.env[HTTP_X_NO_CONTENT_LENGTH]
122
- headers['Connection'] = 'close'
123
- debug 'HTTP response: ?', response
145
+ debug('HTTP response: ?', response)
124
146
  send_response([200, headers, [response]], hijack, callback)
125
147
  end
126
148
  end
127
149
 
128
150
  ASYNC_RESPONSE
129
151
  rescue => e
130
- error "#{e.message}\nBacktrace:\n#{e.backtrace * "\n"}"
152
+ error "#{ e.message }\nBacktrace:\n#{ e.backtrace * "\n" }"
131
153
  [400, TYPE_TEXT, ['Bad request']]
132
154
  end
133
155
 
@@ -154,9 +176,9 @@ module Faye
154
176
  def send_response(response, hijack, callback)
155
177
  return callback.call(response) if callback
156
178
 
157
- buffer = "HTTP/1.1 #{response[0]} OK\r\n"
179
+ buffer = "HTTP/1.1 #{ response[0] } OK\r\n"
158
180
  response[1].each do |name, value|
159
- buffer << "#{name}: #{value}\r\n"
181
+ buffer << "#{ name }: #{ value }\r\n"
160
182
  end
161
183
  buffer << "\r\n"
162
184
  response[2].each do |chunk|
@@ -169,25 +191,26 @@ module Faye
169
191
  end
170
192
 
171
193
  def handle_websocket(request)
172
- ws = Faye::WebSocket.new(request.env, nil, :ping => @options[:ping])
194
+ options = { :extensions => @extensions, :ping => @options[:ping] }
195
+ ws = Faye::WebSocket.new(request.env, [], options)
173
196
  client_id = nil
174
197
 
175
198
  ws.onmessage = lambda do |event|
176
199
  begin
177
- debug "Received message via WebSocket[#{ws.version}]: ?", event.data
200
+ debug("Received message via WebSocket[#{ ws.version }]: ?", event.data)
178
201
 
179
- message = MultiJson.load(event.data)
202
+ message = parse_json(event.data)
180
203
  cid = Faye.client_id_from_messages(message)
181
204
 
182
- @server.close_socket(client_id) if client_id and cid and cid != client_id
205
+ @server.close_socket(client_id, false) if client_id and cid and cid != client_id
183
206
  @server.open_socket(cid, ws, request)
184
- client_id = cid
207
+ client_id = cid if cid
185
208
 
186
209
  @server.process(message, request) do |replies|
187
210
  ws.send(Faye.to_json(replies)) if ws
188
211
  end
189
212
  rescue => e
190
- error "#{e.message}\nBacktrace:\n#{e.backtrace * "\n"}"
213
+ error "#{ e.message }\nBacktrace:\n#{ e.backtrace * "\n" }"
191
214
  end
192
215
  end
193
216
 
@@ -203,7 +226,7 @@ module Faye
203
226
  es = Faye::EventSource.new(request.env, :ping => @options[:ping])
204
227
  client_id = es.url.split('/').pop
205
228
 
206
- debug 'Opened EventSource connection for ?', client_id
229
+ debug('Opened EventSource connection for ?', client_id)
207
230
  @server.open_socket(client_id, es, request)
208
231
 
209
232
  es.onclose = lambda do |event|
@@ -214,28 +237,35 @@ module Faye
214
237
  es.rack_response
215
238
  end
216
239
 
217
- def handle_options
240
+ def handle_options(request)
241
+ origin = request.env['HTTP_ORIGIN'] || request.env['HTTP_REFERER']
242
+
218
243
  headers = {
219
- 'Access-Control-Allow-Credentials' => 'false',
220
- 'Access-Control-Allow-Headers' => 'Accept, Content-Type, Pragma, X-Requested-With',
221
- 'Access-Control-Allow-Methods' => 'POST, GET, PUT, DELETE, OPTIONS',
222
- 'Access-Control-Allow-Origin' => '*',
244
+ 'Access-Control-Allow-Credentials' => 'true',
245
+ 'Access-Control-Allow-Headers' => 'Accept, Authorization, Content-Type, Pragma, X-Requested-With',
246
+ 'Access-Control-Allow-Methods' => 'POST, GET',
247
+ 'Access-Control-Allow-Origin' => origin || '*',
223
248
  'Access-Control-Max-Age' => '86400'
224
249
  }
225
250
  [200, headers, []]
226
251
  end
227
252
 
253
+ def parse_json(json)
254
+ data = MultiJson.load(json)
255
+ return data if Array === data or Hash === data
256
+ raise ArgumentError, 'JSON messages must contain an object or array'
257
+ end
258
+
228
259
  def format_request(request)
229
260
  request.body.rewind
230
- string = "curl -X #{request.request_method.upcase}"
231
- string << " '#{request.url}'"
261
+ string = "curl -X #{ request.request_method.upcase }"
262
+ string << " '#{ request.url }'"
232
263
  if request.post?
233
- string << " -H 'Content-Type: #{request.env['CONTENT_TYPE']}'"
234
- string << " -d '#{request.body.read}'"
264
+ string << " -H 'Content-Type: #{ request.env['CONTENT_TYPE'] }'"
265
+ string << " -d '#{ request.body.read }'"
235
266
  end
236
267
  string
237
268
  end
238
269
 
239
270
  end
240
271
  end
241
-
@@ -15,7 +15,8 @@ module Faye
15
15
  end
16
16
 
17
17
  def deliver(message)
18
- return socket.send(message) if socket
18
+ message.delete('clientId')
19
+ return @socket.send(message) if @socket
19
20
  return unless @inbox.add?(message)
20
21
  begin_delivery_timeout
21
22
  end
@@ -31,28 +32,27 @@ module Faye
31
32
  begin_connection_timeout(timeout)
32
33
  end
33
34
 
34
- def flush!(force = false)
35
- @engine.close_connection(@id) if force or socket.nil?
36
-
35
+ def flush
37
36
  remove_timeout(:connection)
38
37
  remove_timeout(:delivery)
39
38
 
40
39
  set_deferred_status(:succeeded, @inbox.entries)
41
40
  @inbox = []
41
+
42
+ @engine.close_connection(@id) unless @socket
42
43
  end
43
44
 
44
45
  private
45
46
 
46
47
  def begin_delivery_timeout
47
48
  return if @inbox.empty?
48
- add_timeout(:delivery, MAX_DELAY) { flush! }
49
+ add_timeout(:delivery, MAX_DELAY) { flush }
49
50
  end
50
51
 
51
52
  def begin_connection_timeout(timeout)
52
- add_timeout(:connection, timeout) { flush! }
53
+ add_timeout(:connection, timeout) { flush }
53
54
  end
54
55
  end
55
56
 
56
57
  end
57
58
  end
58
-
@@ -28,7 +28,7 @@ module Faye
28
28
 
29
29
  def create_client(&callback)
30
30
  client_id = @namespace.generate
31
- @server.debug 'Created new client ?', client_id
31
+ @server.debug('Created new client ?', client_id)
32
32
  ping(client_id)
33
33
  @server.trigger(:handshake, client_id)
34
34
  callback.call(client_id)
@@ -44,7 +44,7 @@ module Faye
44
44
  remove_timeout(client_id)
45
45
  @namespace.release(client_id)
46
46
  @messages.delete(client_id)
47
- @server.debug 'Destroyed client ?', client_id
47
+ @server.debug('Destroyed client ?', client_id)
48
48
  @server.trigger(:disconnect, client_id)
49
49
  @server.trigger(:close, client_id)
50
50
  callback.call if callback
@@ -57,7 +57,7 @@ module Faye
57
57
  def ping(client_id)
58
58
  timeout = @server.timeout
59
59
  return unless Numeric === timeout
60
- @server.debug 'Ping ?, ?', client_id, timeout
60
+ @server.debug('Ping ?, ?', client_id, timeout)
61
61
  remove_timeout(client_id)
62
62
  add_timeout(client_id, 2 * timeout) { destroy_client(client_id) }
63
63
  end
@@ -69,7 +69,7 @@ module Faye
69
69
  @channels[channel] ||= Set.new
70
70
  @channels[channel].add(client_id)
71
71
 
72
- @server.debug 'Subscribed client ? to channel ?', client_id, channel
72
+ @server.debug('Subscribed client ? to channel ?', client_id, channel)
73
73
  @server.trigger(:subscribe, client_id, channel) if should_trigger
74
74
  callback.call(true) if callback
75
75
  end
@@ -85,13 +85,13 @@ module Faye
85
85
  @channels.delete(channel) if @channels[channel].empty?
86
86
  end
87
87
 
88
- @server.debug 'Unsubscribed client ? from channel ?', client_id, channel
88
+ @server.debug('Unsubscribed client ? from channel ?', client_id, channel)
89
89
  @server.trigger(:unsubscribe, client_id, channel) if should_trigger
90
90
  callback.call(true) if callback
91
91
  end
92
92
 
93
93
  def publish(message, channels)
94
- @server.debug 'Publishing message ?', message
94
+ @server.debug('Publishing message ?', message)
95
95
 
96
96
  clients = Set.new
97
97
 
@@ -101,7 +101,7 @@ module Faye
101
101
  end
102
102
 
103
103
  clients.each do |client_id|
104
- @server.debug 'Queueing for client ?: ?', client_id, message
104
+ @server.debug('Queueing for client ?: ?', client_id, message)
105
105
  @messages[client_id] ||= []
106
106
  @messages[client_id] << Faye.copy_object(message)
107
107
  empty_queue(client_id)
@@ -119,4 +119,3 @@ module Faye
119
119
 
120
120
  end
121
121
  end
122
-
@@ -21,7 +21,7 @@ module Faye
21
21
 
22
22
  def self.random(bitlength = ID_LENGTH)
23
23
  limit = 2 ** bitlength
24
- max_size = (limit - 1).to_s(36).size
24
+ max_size = (bitlength * Math.log(2) / Math.log(36)).ceil
25
25
  string = SecureRandom.random_number(limit).to_s(36)
26
26
  string = '0' + string while string.size < max_size
27
27
  string
@@ -48,14 +48,14 @@ module Faye
48
48
  @engine = engine_class.create(self, @options)
49
49
 
50
50
  bind :close do |client_id|
51
- EventMachine.next_tick { flush(client_id) }
51
+ EventMachine.next_tick { flush_connection(client_id) }
52
52
  end
53
53
 
54
- debug 'Created new engine: ?', @options
54
+ debug('Created new engine: ?', @options)
55
55
  end
56
56
 
57
57
  def connect(client_id, options = {}, &callback)
58
- debug 'Accepting connection from ?', client_id
58
+ debug('Accepting connection from ?', client_id)
59
59
  @engine.ping(client_id)
60
60
  conn = connection(client_id, true)
61
61
  conn.connect(options, &callback)
@@ -75,9 +75,8 @@ module Faye
75
75
  end
76
76
 
77
77
  def close_connection(client_id)
78
- debug 'Closing connection for ?', client_id
79
- conn = @connections[client_id]
80
- return unless conn
78
+ debug('Closing connection for ?', client_id)
79
+ return unless conn = @connections[client_id]
81
80
  conn.socket.close if conn.socket
82
81
  trigger('connection:close', client_id)
83
82
  @connections.delete(client_id)
@@ -90,8 +89,7 @@ module Faye
90
89
 
91
90
  def deliver(client_id, messages)
92
91
  return if !messages || messages.empty?
93
- conn = connection(client_id, false)
94
- return false unless conn
92
+ return false unless conn = connection(client_id, false)
95
93
  messages.each(&conn.method(:deliver))
96
94
  true
97
95
  end
@@ -100,15 +98,17 @@ module Faye
100
98
  Engine.random
101
99
  end
102
100
 
103
- def flush(client_id)
101
+ def flush_connection(client_id, close = true)
104
102
  return unless client_id
105
- debug 'Flushing connection for ?', client_id
106
- conn = connection(client_id, false)
107
- conn.flush!(true) if conn
103
+ debug('Flushing connection for ?', client_id)
104
+ return unless conn = connection(client_id, false)
105
+ conn.socket = nil unless close
106
+ conn.flush
107
+ close_connection(client_id)
108
108
  end
109
109
 
110
110
  def close
111
- @connections.keys.each { |client_id| flush(client_id) }
111
+ @connections.keys.each { |client_id| flush_connection(client_id) }
112
112
  @engine.disconnect
113
113
  end
114
114
 
@@ -124,4 +124,3 @@ module Faye
124
124
 
125
125
  end
126
126
  end
127
-