nodejs with express server, leapmotion for movement control, and threejs for 3d render

This commit is contained in:
idoctnef
2016-05-30 18:14:08 +02:00
parent e2aeac1bae
commit 52b63ee33a
893 changed files with 127726 additions and 0 deletions

2
node_modules/engine.io-client/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
support/
test

45
node_modules/engine.io-client/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,45 @@
language: node_js
node_js:
- "0.10"
notifications:
irc: "irc.freenode.org#socket.io"
env:
global:
- secure: v76/Y3hGIGsANoFAW0US3X8cuDFY7g8stMFrwGUxiQnm4HN3j83w+FfoZay0mESKhNIpqk4nCJQwMCd1gJnLL7ybjGOt5LeEuQVlLDXkRVrXSViy2XwAW+mLj7H/++/LTHWo/Ma6pOa1YC2o4SbSsiK1NdhdAK5ZGluonPBIG18=
- secure: P2zFTMeI9duoPBXhAZZLddqeJS+dUI27Q02tTdr+AjvUkr8f7Zga57SZxP6Jbn8bxUPI3ZQzAm1KMsyUo4IAegXLJ4j9VCF6ab65NkE1k8UH99kXXS30Ha27NS1aQafCbaOTxxQfqQHmnjt2HJtvk04nqCEDhoZCdDUZNVSGCOc=
matrix:
include:
- node_js: '0.10'
env: BROWSER_NAME=chrome BROWSER_VERSION=latest
- node_js: '0.10'
env: BROWSER_NAME=safari BROWSER_VERSION=latest
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=6
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=7
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=8
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=9
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=10 BROWSER_PLATFORM="Windows 2012"
- node_js: '0.10'
env: BROWSER_NAME=ie BROWSER_VERSION=latest BROWSER_PLATFORM="Windows 2012"
- node_js: '0.10'
env: BROWSER_NAME=iphone BROWSER_VERSION=4.3
- node_js: '0.10'
env: BROWSER_NAME=iphone BROWSER_VERSION=5.1
- node_js: '0.10'
env: BROWSER_NAME=iphone BROWSER_VERSION=6.1
- node_js: '0.10'
env: BROWSER_NAME=iphone BROWSER_VERSION=7.1
- node_js: '0.10'
env: BROWSER_NAME=android BROWSER_VERSION=4.0
- node_js: '0.10'
env: BROWSER_NAME=android BROWSER_VERSION=4.1
- node_js: '0.10'
env: BROWSER_NAME=android BROWSER_VERSION=4.2
- node_js: '0.10'
env: BROWSER_NAME=android BROWSER_VERSION=4.3
- node_js: '0.10'
env: BROWSER_NAME=android BROWSER_VERSION=4.4

20
node_modules/engine.io-client/.zuul.yml generated vendored Normal file
View File

@@ -0,0 +1,20 @@
ui: mocha-bdd
server: ./test/support/server.js
browsers:
- name: chrome
version: 29..latest
# Firefox disabled for now because it can cause infinite wait loops when
# running any tests
# - name: firefox
# version: latest
- name: safari
version: latest
- name: ie
version: 10
platform: Windows 2012
- name: ie
version: [6..9, latest]
- name: iphone
version: oldest..latest
- name: android
version: oldest..latest

447
node_modules/engine.io-client/History.md generated vendored Normal file
View File

@@ -0,0 +1,447 @@
1.4.2 / 2014-10-27
==================
* remove invalid value for strict mode
* IE10 should prefer using XHR2 over XDR because it's safer
* fixed transport close deferring logic [nkzawa]
* wait for buffer to be drained before closing [nkzawa]
1.4.1 / 2014-10-03
==================
* Fixed "jsonp polling iframe removal error"
* Move ws upgrade needing connection tests to a block checking browser support.
* check `readyState` in `sendPacket` and close on `upgradeError` too
* defer close while upgrading a transport
1.4.0 / 2014-09-03
==================
* add matrix support for travis runs.
* add `enablesXDR` option to turn on `XDomainRequest`
* package: bump `browserify`
* package: bump `engine.io-parser`
* style and close socket after assert
* add support for `jsonp` option to turn it off
1.3.1 / 2014-06-19
==================
* transport: catch utf8 decode errors
1.3.0 / 2014-06-13
==================
* smaller inherits utility
* fix a test for ws
* upgrade emitter dep to not rely on tarball
1.2.2 / 2014-05-30
==================
* package: bump `engine.io-parser` for binary utf8 fix
1.2.1 / 2014-05-22
==================
* build
1.2.0 / 2014-05-18
==================
* removed flashsocket, moving to userland
* new build
1.1.1 / 2014-05-14
==================
* jsonp-polling: fixed newline double escaping
* package: bump parser
* remove legacy Socket#onopen call
* added tests for multibyte strings
1.1.0 / 2014-04-27
==================
* bump zuul version
* renamed removeAllListeners to cleanup
* use inherits package instead of inherit
* removed all references to util.js
* fix if statement in FlashWS.ready method
* polling-jsonp: prevent spurious errors from being emitted when the window is unloaded
* polling-xhr: fix a comment and remove unneeded `document` reference
* enforce cache busting for all user agents
* JSONP and test fixes for fails in IE
* package: bump `engine.io-parser`
* polling-xhr: abort the request when the window is unloaded
1.0.5 / 2014-03-18
==================
* package: bump `engine.io-parser` for android binary fix
1.0.4 / 2014-03-14
==================
* no base64 encoding for no reason when using websockets
1.0.3 / 2014-03-12
==================
* fix browserify
1.0.2 / 2014-03-12
==================
* bump `engine.io-parser`
* made `parseJSON` and `parseURI` from `util` their own modules [gkoren]
* clean up tests
* clean up browserify
1.0.1 / 2014-03-06
==================
* package: bump `engine.io-parser`
1.0.0 / 2014-03-06
==================
* run browserify without shims
* emit socket upgrade event after upgrade done
* better feature detection for XHR2
* added `rememberUpgrade` option
* binary support
0.9.0 / 2014-02-09
==================
* Fix simple `host:port` URLs and IPV6 [bmalehorn]
* Fix XHR cleanup method [poohlty]
* Match semantics of `close` event with `WebSocket`. If an error occurs
and `open` hadn't fired before, we still emit `close` as per
WebSocket spec [mokesmokes].
* Removed SPEC (now in `engine.io-protocol` repository)
* Remove `Socket#open` docs (private API) [mokesmokes]
0.8.2 / 2014-01-18
==================
* polling-xhr: avoid catching user-thrown errors
* util: remove unused `hasCORS`
* polling: remove deferring for faster startup (fixes #174)
* engine now works perfectly on workers
0.8.1 / 2014-01-17
==================
* package: bump debug to fix `localStorage` issue (fixes #213)
* remove duplicate xmlhttprequest code
* add iphone automated testing
* bump zuul to 1.3.0 to improve tests performance
* use invalid ip address for incorrect connection test
* Fix GH-224, remove sockets array
0.8.0 / 2014-01-05
==================
* socket: emit upgrade errors as `upgradeError` instead of `error`
0.7.14 / 2014-01-01
===================
* test: increase timeouts for network tests
* test: whitelist globals
* test: improve socket closing test
* polling: improve url timestamp for ie11 and allow force disabling
* polling-xhr: handle errors for xhr creation (fixes `access denied` issues)
* polling-xhr: style
* socket: more instrumentation for transport creation
* socket: allow explicit `false` for `timestampRequests`
* socket: accept `null` as first argument
* Makefile: cleanup
* .travis: deprecate 0.6
0.7.13 / 2013-12-20
===================
* use `jsonp` in favor of `XDomainRequest` to preserve `Cookie`
headers in all situations [3rd-eden] (fixes #217)
* run zuul tests after node tests [defunctzombie]
* add zuul support for easier browser testing [defunctzombie]
0.7.12 / 2013-11-11
===================
* engine.io: updated build to fix WebSocket constructor issue
* package: move browserify into devDeps
0.7.11 / 2013-11-06
===================
* AMD support
* Makefile: build now smaller thanks to browserify
* add browserify support
0.7.10 / 2013-10-28
===================
* fixed issue which prevented IE9 and under to pass Cookies to server during handshake
* package: update "ws" to v0.4.31
* fixed - there is no host property only hostname
* fixed - flash socket creation
* fixed - emit errors thrown by xhr.send()
0.7.9 / 2013-08-30
==================
* websocket: pass `undefined` as the WebSocket "protocols"
0.7.8 / 2013-08-30
==================
* package: update "ws"
0.7.7 / 2013-08-30
==================
* package: bump ws to 0.4.30
* websocket: no more env sniffing, just require `ws` [TooTallNate]
* websocket: remove the "bufferedAmount" checking logic [TooTallNate]
0.7.6 / 2013-08-30
==================
* package: revert ws to avoid upgrade fail now
0.7.5 / 2013-08-30
==================
* package: bump ws to 0.4.30
0.7.4 / 2013-08-25
==================
* package: rolling back to `ws` `0.4.25` due to disconnection bug
0.7.3 / 2013-08-23
==================
* noop bump
0.7.2 / 2013-08-23
==================
* transports: fix WebSocket transport in the web browser (again)
0.7.1 / 2013-08-23
==================
* transports: fix WebSocket transport in the web browser
* package: upgrade "ws" to v0.4.29
0.7.0 / 2013-08-23
==================
* socket: add `agent` option
* package: point "xmlhttprequest" to our LearnBoost fork for agent support
* package: specify a newer version of "ws" that includes `agent` support
* util: use "component/has-cors"
* transport: fix whitespace
* util: use "component/global"
* package: Add repository field to readme
* socket: Don't lose packets writen during upgrade after a re-open
* socket: use a consistent "debug" name for socket.js
* package: Update emitter dep to 1.0.1 for old IE support
0.6.3 / 2013-06-21
==================
* fix check readyState in polling transport (Naoyuki Kanezawa)
* use http url in npm dependencies for emitter (Eric Schoffstall)
0.6.2 / 2013-06-15
==================
* transports: improve polling orderly close (fixes #164)
* socket: ignore further transport communication upon `onClose`
* socket: added missing `socket#onerror` support
* socket: don't call `socket#onclose` if previous state was not `open`
* transports: fix iOS5 crash issue
* Makefile: extra precaution when building to avoid 0.6.0 build problem
0.6.1 / 2013-06-06
==================
* engine.io: fixed build
0.6.0 / 2013-05-31
==================
* does not emit close on incorrect socket connection
* use indexof component for ie8 and below
* improved x-domain handling
* introduce public `ping` api
* added drain event
* fix `flush` and `flushComplete` events
* fixed `drain` bug splicing with upgrading
* add support for callbacks with socket.send()
0.5.0 / 2013-03-16
==================
* socket: implement qs support for `string`
* added query.EIO to take protocol version from parser
* use istanbul for code coverage
* integrated engine.io-protocol 0.3.0
* updated ws
* fixed JSONPPolling iframe removal error
* changed error message to match xhr error message on jsonp transport script tag
* Added onerror handler for script tag in jsonp transport
* remove uid qs
* Added missing colon in payload. Thanks @lsm
0.4.3 / 2013-02-08
==================
* package: removed unusued `parser.js`
0.4.2 / 2013-02-08
==================
* polling-jsonp: fix ie6 JSONP on SSL
* close also if socket.readyState is on "opening"
* parser.js: removed the file package.json: added the engine.io-parser dependency everything else: switched to engine.io-parser
* fix "TypeError: Object #<Object> has no method 'global'"
* client now ignores unsupported upgrades
0.4.1 / 2013-01-18
==================
* do not shadow global XMLHttpRequest
* socket: added `data` event (as synonym to `message`)
* socket: remove `resource` and fix `path`
* socket: fixed access to `opts`
* test: fixed transports tests
* socket: constructor can accept uri/opts simultaneously
* SPEC: simplified: removed resource from SPEC
* socket: proper `host`/`hostname` support
* socket: ensure `onclose` idempotency
* socket: added `onerror` instrumentation
* socket: fix style
* use window to detect platform and fix global reference
* *: fix references to `global` (fixes #79)
0.4.0 / 2012-12-09
==================
* *: now based on `component(1)`
* *: module now exports `Socket`
* socket: export constructors, utils and `protocol`
* *: implemented `emitter` component
* *: removed browserbuild and preprocessor instructions
0.3.10 / 2012-12-03
===================
* socket: fix closing the socket in an `open` listener [mmastrac]
* socket: perform ping interval/timer cleanup [mmastrac]
* fix SPEC (packages -> packets) [jxck]
* socket: handle probe's transport errors [indutny]
0.3.9 / 2012-10-23
==================
* socket: fix `hostname` instead of `host`
* socket: avoid duplicate `port` defaults
0.3.8 / 2012-10-23
==================
* socket: introduce introspection hooks
* socket: introduced `host` and `port` `location` defaults
* flashsocket: obfuscate activex (fixes #31)
* README: documented reconnect (closes #45)
* socket: unset `id` upon close
* socket: clear transport listeners upon force close
0.3.7 / 2012-10-21
==================
* fix `version` [quackingduck]
* ping timeout gets reset upon any packet received [indutny]
* timeout fixes [cadorn, indutny]
* transport: fix xdomain detection in absence of location.port (GH-38)
* socket: fix passing `false` as secure getting overridden
* socket: default `secure` to `true` for SSL-served pages
* socket: fix default port for SSL when `secure` is not supplied
0.3.6 / 2012-10-16
==================
* socket: reset timeout on any incoming data [indutny]
0.3.5 / 2012-10-14
==================
* new build
0.3.4 / 2012-10-14
==================
* package: fix `component` exports
0.3.3 / 2012-10-10
==================
* socket: fix `secure` default value discovery [quackingduck]
0.3.2 / 2012-10-08
==================
* Bump
0.3.1 / 2012-10-08
==================
* socket: added `write` alias for `send`
* package: added `component`
0.3.0 / 2012-09-04
==================
* IE's XDomainRequest cannot do requests that go from HTTPS to HTTP or HTTP to HTTPS [mixu]
* Switch to client-initiated ping, and set interval in handshake [cadorn]
0.2.2 / 2012-08-26
==================
* polling-jsonp: allow unneeded global leak (fixes #41)
* polling-jsonp: allow for multiple eio's in the same page
0.2.1 / 2012-08-13
==================
* Bump
0.2.0 / 2012-08-06
==================
* polling: introduced `poll` and `pollComplete` (formerly `poll`) events
0.1.2 / 2012-08-02
==================
* Bump
0.1.1 / 2012-08-01
==================
* Added options for request timestamping
* Made timestamp query param customizable
* Added automatic timestamping for Android
0.1.0 / 2012-07-03
==================
* Initial release.

37
node_modules/engine.io-client/Makefile generated vendored Normal file
View File

@@ -0,0 +1,37 @@
REPORTER = dot
build: engine.io.js
engine.io.js: lib/*.js lib/transports/*.js package.json
@./support/browserify.sh > engine.io.js
test:
@if [ "x$(BROWSER_NAME)" = "x" ]; then make test-node; else make test-zuul; fi
test-node:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) \
test/index.js
test-zuul:
@if [ "x$(BROWSER_PLATFORM)" = "x" ]; then \
./node_modules/zuul/bin/zuul \
--browser-name $(BROWSER_NAME) \
--browser-version $(BROWSER_VERSION) \
test/index.js; \
else \
./node_modules/zuul/bin/zuul \
--browser-name $(BROWSER_NAME) \
--browser-version $(BROWSER_VERSION) \
--browser-platform "$(BROWSER_PLATFORM)" \
test/index.js; \
fi
test-cov:
@./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \
--require ./test/common \
--reporter $(REPORTER) \
$(TESTS)
.PHONY: test build

243
node_modules/engine.io-client/README.md generated vendored Normal file
View File

@@ -0,0 +1,243 @@
# Engine.IO client
[![Build Status](https://secure.travis-ci.org/Automattic/engine.io-client.png)](http://travis-ci.org/Automattic/engine.io-client)
[![NPM version](https://badge.fury.io/js/engine.io-client.png)](http://badge.fury.io/js/engine.io-client)
This is the client for [Engine.IO](http://github.com/automattic/engine.io),
the implementation of transport-based cross-browser/cross-device
bi-directional communication layer for [Socket.IO](http://github.com/automattic/socket.io).
## How to use
### Standalone
You can find an `engine.io.js` file in this repository, which is a
standalone build you can use as follows:
```html
<script src="/path/to/engine.io.js"></script>
<script>
// eio = Socket
var socket = eio('ws://localhost');
socket.on('open', function(){
socket.on('message', function(data){});
socket.on('close', function(){});
});
</script>
```
### With browserify
Engine.IO is a commonjs module, which means you can include it by using
`require` on the browser and package using [browserify](http://browserify.org/):
1. install the client package
```bash
$ npm install engine.io-client
```
1. write your app code
```js
var socket = require('engine.io-client')('ws://localhost');
socket.on('open', function(){
socket.on('message', function(data){});
socket.on('close', function(){});
});
```
1. build your app bundle
```bash
$ browserify app.js > bundle.js
```
1. include on your page
```html
<script src="/path/to/bundle.js"></script>
```
### Sending and receiving binary
```html
<script src="/path/to/engine.io.js"></script>
<script>
var socket = new eio.Socket('ws://localhost/');
socket.binaryType = 'blob';
socket.on('open', function () {
socket.send(new Int8Array(5));
socket.on('message', function(blob){});
socket.on('close', function(){ });
});
</script>
```
### Node.JS
Add `engine.io-client` to your `package.json` and then:
```js
var socket = require('engine.io-client')('ws://localhost');
socket.on('open', function(){
socket.on('message', function(data){});
socket.on('close', function(){});
});
```
## Features
- Lightweight
- Runs on browser and node.js seamlessly
- Transports are independent of `Engine`
- Easy to debug
- Easy to unit test
- Runs inside HTML5 WebWorker
- Can send and receive binary data
- Receives as ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer
in Node
- When XHR2 or WebSockets are used, binary is emitted directly. Otherwise
binary is encoded into base64 strings, and decoded when binary types are
supported.
- With browsers that don't support ArrayBuffer, an object { base64: true,
data: dataAsBase64String } is emitted on the `message` event.
## API
### Socket
The client class. Mixes in [Emitter](http://github.com/component/emitter).
Exposed as `eio` in the browser standalone build.
#### Properties
- `protocol` _(Number)_: protocol revision number
- `binaryType` _(String)_ : can be set to 'arraybuffer' or 'blob' in browsers,
and `buffer` or `arraybuffer` in Node. Blob is only used in browser if it's
supported.
#### Events
- `open`
- Fired upon successful connection.
- `message`
- Fired when data is received from the server.
- **Arguments**
- `String` | `ArrayBuffer`: utf-8 encoded data or ArrayBuffer containing
binary data
- `close`
- Fired upon disconnection. In compliance with the WebSocket API spec, this event may be
fired even if the `open` event does not occur (i.e. due to connection error or `close()`).
- `error`
- Fired when an error occurs.
- `flush`
- Fired upon completing a buffer flush
- `drain`
- Fired after `drain` event of transport if writeBuffer is empty
- `upgradeError`
- Fired if an error occurs with a transport we're trying to upgrade to.
- `upgrade`
- Fired upon upgrade success, after the new transport is set
#### Methods
- **constructor**
- Initializes the client
- **Parameters**
- `String` uri
- `Object`: optional, options object
- **Options**
- `agent` (`http.Agent`): `http.Agent` to use, defaults to `false` (NodeJS only)
- `upgrade` (`Boolean`): defaults to true, whether the client should try
to upgrade the transport from long-polling to something better.
- `forceJSONP` (`Boolean`): forces JSONP for polling transport.
- `jsonp` (`Boolean`): determines whether to use JSONP when
necessary for polling. If disabled (by settings to false) an error will
be emitted (saying "No transports available") if no other transports
are available. If another transport is available for opening a
connection (e.g. WebSocket) that transport
will be used instead.
- `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary.
- `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie.
- `timestampRequests` (`Boolean`): whether to add the timestamp with
each transport request. Note: this is ignored if the browser is
IE or Android, in which case requests are always stamped (`false`)
- `timestampParam` (`String`): timestamp parameter (`t`)
- `policyPort` (`Number`): port the policy server listens on (`843`)
- `path` (`String`): path to connect to, default is `/engine.io`
- `transports` (`Array`): a list of transports to try (in order).
Defaults to `['polling', 'websocket']`. `Engine`
always attempts to connect directly with the first one, provided the
feature detection test for it passes.
- `rememberUpgrade` (`Boolean`): defaults to false.
If true and if the previous websocket connection to the server succeeded,
the connection attempt will bypass the normal upgrade process and will initially
try websocket. A connection attempt following a transport error will use the
normal upgrade process. It is recommended you turn this on only when using
SSL/TLS connections, or if you know that your network does not block websockets.
- `send`
- Sends a message to the server
- **Parameters**
- `String` | `ArrayBuffer` | `ArrayBufferView` | `Blob`: data to send
- `Function`: optional, callback upon `drain`
- `close`
- Disconnects the client.
### Transport
The transport class. Private. _Inherits from EventEmitter_.
#### Events
- `poll`: emitted by polling transports upon starting a new request
- `pollComplete`: emitted by polling transports upon completing a request
- `drain`: emitted by polling transports upon a buffer drain
## Tests
`engine.io-client` is used to test
[engine](http://github.com/automattic/engine.io). Running the `engine.io`
test suite ensures the client works and vice-versa.
Browser tests are run using [zuul](https://github.com/defunctzombie/zuul). You can
run the tests locally using the following command.
```
./node_modules/.bin/zuul --local 8080 -- test/index.js
```
Additionally, `engine.io-client` has a standalone test suite you can run
with `make test` which will run node.js and browser tests. You must have zuul setup with
a saucelabs account.
## Support
The support channels for `engine.io-client` are the same as `socket.io`:
- irc.freenode.net **#socket.io**
- [Google Groups](http://groups.google.com/group/socket_io)
- [Website](http://socket.io)
## Development
To contribute patches, run tests or benchmarks, make sure to clone the
repository:
```bash
git clone git://github.com/automattic/engine.io-client.git
```
Then:
```bash
cd engine.io-client
npm install
```
See the `Tests` section above for how to run tests before submitting any patches.
## License
MIT - Copyright (c) 2014 Automattic, Inc.

3551
node_modules/engine.io-client/engine.io.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

2
node_modules/engine.io-client/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
module.exports = require('./lib/');

10
node_modules/engine.io-client/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
module.exports = require('./socket');
/**
* Exports parser
*
* @api public
*
*/
module.exports.parser = require('engine.io-parser');

683
node_modules/engine.io-client/lib/socket.js generated vendored Normal file
View File

@@ -0,0 +1,683 @@
/**
* Module dependencies.
*/
var transports = require('./transports');
var Emitter = require('component-emitter');
var debug = require('debug')('engine.io-client:socket');
var index = require('indexof');
var parser = require('engine.io-parser');
var parseuri = require('parseuri');
var parsejson = require('parsejson');
var parseqs = require('parseqs');
/**
* Module exports.
*/
module.exports = Socket;
/**
* Noop function.
*
* @api private
*/
function noop(){}
/**
* Socket constructor.
*
* @param {String|Object} uri or options
* @param {Object} options
* @api public
*/
function Socket(uri, opts){
if (!(this instanceof Socket)) return new Socket(uri, opts);
opts = opts || {};
if (uri && 'object' == typeof uri) {
opts = uri;
uri = null;
}
if (uri) {
uri = parseuri(uri);
opts.host = uri.host;
opts.secure = uri.protocol == 'https' || uri.protocol == 'wss';
opts.port = uri.port;
if (uri.query) opts.query = uri.query;
}
this.secure = null != opts.secure ? opts.secure :
(global.location && 'https:' == location.protocol);
if (opts.host) {
var pieces = opts.host.split(':');
opts.hostname = pieces.shift();
if (pieces.length) opts.port = pieces.pop();
}
this.agent = opts.agent || false;
this.hostname = opts.hostname ||
(global.location ? location.hostname : 'localhost');
this.port = opts.port || (global.location && location.port ?
location.port :
(this.secure ? 443 : 80));
this.query = opts.query || {};
if ('string' == typeof this.query) this.query = parseqs.decode(this.query);
this.upgrade = false !== opts.upgrade;
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
this.forceJSONP = !!opts.forceJSONP;
this.jsonp = false !== opts.jsonp;
this.forceBase64 = !!opts.forceBase64;
this.enablesXDR = !!opts.enablesXDR;
this.timestampParam = opts.timestampParam || 't';
this.timestampRequests = opts.timestampRequests;
this.transports = opts.transports || ['polling', 'websocket'];
this.readyState = '';
this.writeBuffer = [];
this.callbackBuffer = [];
this.policyPort = opts.policyPort || 843;
this.rememberUpgrade = opts.rememberUpgrade || false;
this.open();
this.binaryType = null;
this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
}
Socket.priorWebsocketSuccess = false;
/**
* Mix in `Emitter`.
*/
Emitter(Socket.prototype);
/**
* Protocol version.
*
* @api public
*/
Socket.protocol = parser.protocol; // this is an int
/**
* Expose deps for legacy compatibility
* and standalone browser access.
*/
Socket.Socket = Socket;
Socket.Transport = require('./transport');
Socket.transports = require('./transports');
Socket.parser = require('engine.io-parser');
/**
* Creates transport of the given type.
*
* @param {String} transport name
* @return {Transport}
* @api private
*/
Socket.prototype.createTransport = function (name) {
debug('creating transport "%s"', name);
var query = clone(this.query);
// append engine.io protocol identifier
query.EIO = parser.protocol;
// transport name
query.transport = name;
// session id if we already have one
if (this.id) query.sid = this.id;
var transport = new transports[name]({
agent: this.agent,
hostname: this.hostname,
port: this.port,
secure: this.secure,
path: this.path,
query: query,
forceJSONP: this.forceJSONP,
jsonp: this.jsonp,
forceBase64: this.forceBase64,
enablesXDR: this.enablesXDR,
timestampRequests: this.timestampRequests,
timestampParam: this.timestampParam,
policyPort: this.policyPort,
socket: this
});
return transport;
};
function clone (obj) {
var o = {};
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
o[i] = obj[i];
}
}
return o;
}
/**
* Initializes transport to use and starts probe.
*
* @api private
*/
Socket.prototype.open = function () {
var transport;
if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
transport = 'websocket';
} else if (0 == this.transports.length) {
// Emit error on next tick so it can be listened to
var self = this;
setTimeout(function() {
self.emit('error', 'No transports available');
}, 0);
return;
} else {
transport = this.transports[0];
}
this.readyState = 'opening';
// Retry with the next transport if the transport is disabled (jsonp: false)
var transport;
try {
transport = this.createTransport(transport);
} catch (e) {
this.transports.shift();
this.open();
return;
}
transport.open();
this.setTransport(transport);
};
/**
* Sets the current transport. Disables the existing one (if any).
*
* @api private
*/
Socket.prototype.setTransport = function(transport){
debug('setting transport %s', transport.name);
var self = this;
if (this.transport) {
debug('clearing existing transport %s', this.transport.name);
this.transport.removeAllListeners();
}
// set up transport
this.transport = transport;
// set up transport listeners
transport
.on('drain', function(){
self.onDrain();
})
.on('packet', function(packet){
self.onPacket(packet);
})
.on('error', function(e){
self.onError(e);
})
.on('close', function(){
self.onClose('transport close');
});
};
/**
* Probes a transport.
*
* @param {String} transport name
* @api private
*/
Socket.prototype.probe = function (name) {
debug('probing transport "%s"', name);
var transport = this.createTransport(name, { probe: 1 })
, failed = false
, self = this;
Socket.priorWebsocketSuccess = false;
function onTransportOpen(){
if (self.onlyBinaryUpgrades) {
var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
failed = failed || upgradeLosesBinary;
}
if (failed) return;
debug('probe transport "%s" opened', name);
transport.send([{ type: 'ping', data: 'probe' }]);
transport.once('packet', function (msg) {
if (failed) return;
if ('pong' == msg.type && 'probe' == msg.data) {
debug('probe transport "%s" pong', name);
self.upgrading = true;
self.emit('upgrading', transport);
if (!transport) return;
Socket.priorWebsocketSuccess = 'websocket' == transport.name;
debug('pausing current transport "%s"', self.transport.name);
self.transport.pause(function () {
if (failed) return;
if ('closed' == self.readyState) return;
debug('changing transport and sending upgrade packet');
cleanup();
self.setTransport(transport);
transport.send([{ type: 'upgrade' }]);
self.emit('upgrade', transport);
transport = null;
self.upgrading = false;
self.flush();
});
} else {
debug('probe transport "%s" failed', name);
var err = new Error('probe error');
err.transport = transport.name;
self.emit('upgradeError', err);
}
});
}
function freezeTransport() {
if (failed) return;
// Any callback called by transport should be ignored since now
failed = true;
cleanup();
transport.close();
transport = null;
}
//Handle any error that happens while probing
function onerror(err) {
var error = new Error('probe error: ' + err);
error.transport = transport.name;
freezeTransport();
debug('probe transport "%s" failed because of error: %s', name, err);
self.emit('upgradeError', error);
}
function onTransportClose(){
onerror("transport closed");
}
//When the socket is closed while we're probing
function onclose(){
onerror("socket closed");
}
//When the socket is upgraded while we're probing
function onupgrade(to){
if (transport && to.name != transport.name) {
debug('"%s" works - aborting "%s"', to.name, transport.name);
freezeTransport();
}
}
//Remove all listeners on the transport and on self
function cleanup(){
transport.removeListener('open', onTransportOpen);
transport.removeListener('error', onerror);
transport.removeListener('close', onTransportClose);
self.removeListener('close', onclose);
self.removeListener('upgrading', onupgrade);
}
transport.once('open', onTransportOpen);
transport.once('error', onerror);
transport.once('close', onTransportClose);
this.once('close', onclose);
this.once('upgrading', onupgrade);
transport.open();
};
/**
* Called when connection is deemed open.
*
* @api public
*/
Socket.prototype.onOpen = function () {
debug('socket open');
this.readyState = 'open';
Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
this.emit('open');
this.flush();
// we check for `readyState` in case an `open`
// listener already closed the socket
if ('open' == this.readyState && this.upgrade && this.transport.pause) {
debug('starting upgrade probes');
for (var i = 0, l = this.upgrades.length; i < l; i++) {
this.probe(this.upgrades[i]);
}
}
};
/**
* Handles a packet.
*
* @api private
*/
Socket.prototype.onPacket = function (packet) {
if ('opening' == this.readyState || 'open' == this.readyState) {
debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
this.emit('packet', packet);
// Socket is live - any packet counts
this.emit('heartbeat');
switch (packet.type) {
case 'open':
this.onHandshake(parsejson(packet.data));
break;
case 'pong':
this.setPing();
break;
case 'error':
var err = new Error('server error');
err.code = packet.data;
this.emit('error', err);
break;
case 'message':
this.emit('data', packet.data);
this.emit('message', packet.data);
break;
}
} else {
debug('packet received with socket readyState "%s"', this.readyState);
}
};
/**
* Called upon handshake completion.
*
* @param {Object} handshake obj
* @api private
*/
Socket.prototype.onHandshake = function (data) {
this.emit('handshake', data);
this.id = data.sid;
this.transport.query.sid = data.sid;
this.upgrades = this.filterUpgrades(data.upgrades);
this.pingInterval = data.pingInterval;
this.pingTimeout = data.pingTimeout;
this.onOpen();
// In case open handler closes socket
if ('closed' == this.readyState) return;
this.setPing();
// Prolong liveness of socket on heartbeat
this.removeListener('heartbeat', this.onHeartbeat);
this.on('heartbeat', this.onHeartbeat);
};
/**
* Resets ping timeout.
*
* @api private
*/
Socket.prototype.onHeartbeat = function (timeout) {
clearTimeout(this.pingTimeoutTimer);
var self = this;
self.pingTimeoutTimer = setTimeout(function () {
if ('closed' == self.readyState) return;
self.onClose('ping timeout');
}, timeout || (self.pingInterval + self.pingTimeout));
};
/**
* Pings server every `this.pingInterval` and expects response
* within `this.pingTimeout` or closes connection.
*
* @api private
*/
Socket.prototype.setPing = function () {
var self = this;
clearTimeout(self.pingIntervalTimer);
self.pingIntervalTimer = setTimeout(function () {
debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
self.ping();
self.onHeartbeat(self.pingTimeout);
}, self.pingInterval);
};
/**
* Sends a ping packet.
*
* @api public
*/
Socket.prototype.ping = function () {
this.sendPacket('ping');
};
/**
* Called on `drain` event
*
* @api private
*/
Socket.prototype.onDrain = function() {
for (var i = 0; i < this.prevBufferLen; i++) {
if (this.callbackBuffer[i]) {
this.callbackBuffer[i]();
}
}
this.writeBuffer.splice(0, this.prevBufferLen);
this.callbackBuffer.splice(0, this.prevBufferLen);
// setting prevBufferLen = 0 is very important
// for example, when upgrading, upgrade packet is sent over,
// and a nonzero prevBufferLen could cause problems on `drain`
this.prevBufferLen = 0;
if (this.writeBuffer.length == 0) {
this.emit('drain');
} else {
this.flush();
}
};
/**
* Flush write buffers.
*
* @api private
*/
Socket.prototype.flush = function () {
if ('closed' != this.readyState && this.transport.writable &&
!this.upgrading && this.writeBuffer.length) {
debug('flushing %d packets in socket', this.writeBuffer.length);
this.transport.send(this.writeBuffer);
// keep track of current length of writeBuffer
// splice writeBuffer and callbackBuffer on `drain`
this.prevBufferLen = this.writeBuffer.length;
this.emit('flush');
}
};
/**
* Sends a message.
*
* @param {String} message.
* @param {Function} callback function.
* @return {Socket} for chaining.
* @api public
*/
Socket.prototype.write =
Socket.prototype.send = function (msg, fn) {
this.sendPacket('message', msg, fn);
return this;
};
/**
* Sends a packet.
*
* @param {String} packet type.
* @param {String} data.
* @param {Function} callback function.
* @api private
*/
Socket.prototype.sendPacket = function (type, data, fn) {
if ('closing' == this.readyState || 'closed' == this.readyState) {
return;
}
var packet = { type: type, data: data };
this.emit('packetCreate', packet);
this.writeBuffer.push(packet);
this.callbackBuffer.push(fn);
this.flush();
};
/**
* Closes the connection.
*
* @api private
*/
Socket.prototype.close = function () {
if ('opening' == this.readyState || 'open' == this.readyState) {
this.readyState = 'closing';
var self = this;
function close() {
self.onClose('forced close');
debug('socket closing - telling transport to close');
self.transport.close();
}
function cleanupAndClose() {
self.removeListener('upgrade', cleanupAndClose);
self.removeListener('upgradeError', cleanupAndClose);
close();
}
function waitForUpgrade() {
// wait for upgrade to finish since we can't send packets while pausing a transport
self.once('upgrade', cleanupAndClose);
self.once('upgradeError', cleanupAndClose);
}
if (this.writeBuffer.length) {
this.once('drain', function() {
if (this.upgrading) {
waitForUpgrade();
} else {
close();
}
});
} else if (this.upgrading) {
waitForUpgrade();
} else {
close();
}
}
return this;
};
/**
* Called upon transport error
*
* @api private
*/
Socket.prototype.onError = function (err) {
debug('socket error %j', err);
Socket.priorWebsocketSuccess = false;
this.emit('error', err);
this.onClose('transport error', err);
};
/**
* Called upon transport close.
*
* @api private
*/
Socket.prototype.onClose = function (reason, desc) {
if ('opening' == this.readyState || 'open' == this.readyState || 'closing' == this.readyState) {
debug('socket close with reason: "%s"', reason);
var self = this;
// clear timers
clearTimeout(this.pingIntervalTimer);
clearTimeout(this.pingTimeoutTimer);
// clean buffers in next tick, so developers can still
// grab the buffers on `close` event
setTimeout(function() {
self.writeBuffer = [];
self.callbackBuffer = [];
self.prevBufferLen = 0;
}, 0);
// stop event from firing again for transport
this.transport.removeAllListeners('close');
// ensure transport won't stay open
this.transport.close();
// ignore further transport communication
this.transport.removeAllListeners();
// set ready state
this.readyState = 'closed';
// clear session id
this.id = null;
// emit close event
this.emit('close', reason, desc);
}
};
/**
* Filters upgrades, returning only those matching client transports.
*
* @param {Array} server upgrades
* @api private
*
*/
Socket.prototype.filterUpgrades = function (upgrades) {
var filteredUpgrades = [];
for (var i = 0, j = upgrades.length; i<j; i++) {
if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
}
return filteredUpgrades;
};

150
node_modules/engine.io-client/lib/transport.js generated vendored Normal file
View File

@@ -0,0 +1,150 @@
/**
* Module dependencies.
*/
var parser = require('engine.io-parser');
var Emitter = require('component-emitter');
/**
* Module exports.
*/
module.exports = Transport;
/**
* Transport abstract constructor.
*
* @param {Object} options.
* @api private
*/
function Transport (opts) {
this.path = opts.path;
this.hostname = opts.hostname;
this.port = opts.port;
this.secure = opts.secure;
this.query = opts.query;
this.timestampParam = opts.timestampParam;
this.timestampRequests = opts.timestampRequests;
this.readyState = '';
this.agent = opts.agent || false;
this.socket = opts.socket;
this.enablesXDR = opts.enablesXDR;
}
/**
* Mix in `Emitter`.
*/
Emitter(Transport.prototype);
/**
* A counter used to prevent collisions in the timestamps used
* for cache busting.
*/
Transport.timestamps = 0;
/**
* Emits an error.
*
* @param {String} str
* @return {Transport} for chaining
* @api public
*/
Transport.prototype.onError = function (msg, desc) {
var err = new Error(msg);
err.type = 'TransportError';
err.description = desc;
this.emit('error', err);
return this;
};
/**
* Opens the transport.
*
* @api public
*/
Transport.prototype.open = function () {
if ('closed' == this.readyState || '' == this.readyState) {
this.readyState = 'opening';
this.doOpen();
}
return this;
};
/**
* Closes the transport.
*
* @api private
*/
Transport.prototype.close = function () {
if ('opening' == this.readyState || 'open' == this.readyState) {
this.doClose();
this.onClose();
}
return this;
};
/**
* Sends multiple packets.
*
* @param {Array} packets
* @api private
*/
Transport.prototype.send = function(packets){
if ('open' == this.readyState) {
this.write(packets);
} else {
throw new Error('Transport not open');
}
};
/**
* Called upon open
*
* @api private
*/
Transport.prototype.onOpen = function () {
this.readyState = 'open';
this.writable = true;
this.emit('open');
};
/**
* Called with data.
*
* @param {String} data
* @api private
*/
Transport.prototype.onData = function(data){
var packet = parser.decodePacket(data, this.socket.binaryType);
this.onPacket(packet);
};
/**
* Called with a decoded packet.
*/
Transport.prototype.onPacket = function (packet) {
this.emit('packet', packet);
};
/**
* Called upon close.
*
* @api private
*/
Transport.prototype.onClose = function () {
this.readyState = 'closed';
this.emit('close');
};

53
node_modules/engine.io-client/lib/transports/index.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
/**
* Module dependencies
*/
var XMLHttpRequest = require('xmlhttprequest');
var XHR = require('./polling-xhr');
var JSONP = require('./polling-jsonp');
var websocket = require('./websocket');
/**
* Export transports.
*/
exports.polling = polling;
exports.websocket = websocket;
/**
* Polling transport polymorphic constructor.
* Decides on xhr vs jsonp based on feature detection.
*
* @api private
*/
function polling(opts){
var xhr;
var xd = false;
var xs = false;
var jsonp = false !== opts.jsonp;
if (global.location) {
var isSSL = 'https:' == location.protocol;
var port = location.port;
// some user agents have empty `location.port`
if (!port) {
port = isSSL ? 443 : 80;
}
xd = opts.hostname != location.hostname || port != opts.port;
xs = opts.secure != isSSL;
}
opts.xdomain = xd;
opts.xscheme = xs;
xhr = new XMLHttpRequest(opts);
if ('open' in xhr && !opts.forceJSONP) {
return new XHR(opts);
} else {
if (!jsonp) throw new Error('JSONP disabled');
return new JSONP(opts);
}
}

View File

@@ -0,0 +1,233 @@
/**
* Module requirements.
*/
var Polling = require('./polling');
var inherit = require('component-inherit');
/**
* Module exports.
*/
module.exports = JSONPPolling;
/**
* Cached regular expressions.
*/
var rNewline = /\n/g;
var rEscapedNewline = /\\n/g;
/**
* Global JSONP callbacks.
*/
var callbacks;
/**
* Callbacks count.
*/
var index = 0;
/**
* Noop.
*/
function empty () { }
/**
* JSONP Polling constructor.
*
* @param {Object} opts.
* @api public
*/
function JSONPPolling (opts) {
Polling.call(this, opts);
this.query = this.query || {};
// define global callbacks array if not present
// we do this here (lazily) to avoid unneeded global pollution
if (!callbacks) {
// we need to consider multiple engines in the same page
if (!global.___eio) global.___eio = [];
callbacks = global.___eio;
}
// callback identifier
this.index = callbacks.length;
// add callback to jsonp global
var self = this;
callbacks.push(function (msg) {
self.onData(msg);
});
// append to query string
this.query.j = this.index;
// prevent spurious errors from being emitted when the window is unloaded
if (global.document && global.addEventListener) {
global.addEventListener('beforeunload', function () {
if (self.script) self.script.onerror = empty;
});
}
}
/**
* Inherits from Polling.
*/
inherit(JSONPPolling, Polling);
/*
* JSONP only supports binary as base64 encoded strings
*/
JSONPPolling.prototype.supportsBinary = false;
/**
* Closes the socket.
*
* @api private
*/
JSONPPolling.prototype.doClose = function () {
if (this.script) {
this.script.parentNode.removeChild(this.script);
this.script = null;
}
if (this.form) {
this.form.parentNode.removeChild(this.form);
this.form = null;
this.iframe = null;
}
Polling.prototype.doClose.call(this);
};
/**
* Starts a poll cycle.
*
* @api private
*/
JSONPPolling.prototype.doPoll = function () {
var self = this;
var script = document.createElement('script');
if (this.script) {
this.script.parentNode.removeChild(this.script);
this.script = null;
}
script.async = true;
script.src = this.uri();
script.onerror = function(e){
self.onError('jsonp poll error',e);
};
var insertAt = document.getElementsByTagName('script')[0];
insertAt.parentNode.insertBefore(script, insertAt);
this.script = script;
var isUAgecko = 'undefined' != typeof navigator && /gecko/i.test(navigator.userAgent);
if (isUAgecko) {
setTimeout(function () {
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
document.body.removeChild(iframe);
}, 100);
}
};
/**
* Writes with a hidden iframe.
*
* @param {String} data to send
* @param {Function} called upon flush.
* @api private
*/
JSONPPolling.prototype.doWrite = function (data, fn) {
var self = this;
if (!this.form) {
var form = document.createElement('form');
var area = document.createElement('textarea');
var id = this.iframeId = 'eio_iframe_' + this.index;
var iframe;
form.className = 'socketio';
form.style.position = 'absolute';
form.style.top = '-1000px';
form.style.left = '-1000px';
form.target = id;
form.method = 'POST';
form.setAttribute('accept-charset', 'utf-8');
area.name = 'd';
form.appendChild(area);
document.body.appendChild(form);
this.form = form;
this.area = area;
}
this.form.action = this.uri();
function complete () {
initIframe();
fn();
}
function initIframe () {
if (self.iframe) {
try {
self.form.removeChild(self.iframe);
} catch (e) {
self.onError('jsonp polling iframe removal error', e);
}
}
try {
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
var html = '<iframe src="javascript:0" name="'+ self.iframeId +'">';
iframe = document.createElement(html);
} catch (e) {
iframe = document.createElement('iframe');
iframe.name = self.iframeId;
iframe.src = 'javascript:0';
}
iframe.id = self.iframeId;
self.form.appendChild(iframe);
self.iframe = iframe;
}
initIframe();
// escape \n to prevent it from being converted into \r\n by some UAs
// double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
data = data.replace(rEscapedNewline, '\\\n');
this.area.value = data.replace(rNewline, '\\n');
try {
this.form.submit();
} catch(e) {}
if (this.iframe.attachEvent) {
this.iframe.onreadystatechange = function(){
if (self.iframe.readyState == 'complete') {
complete();
}
};
} else {
this.iframe.onload = complete;
}
};

View File

@@ -0,0 +1,351 @@
/**
* Module requirements.
*/
var XMLHttpRequest = require('xmlhttprequest');
var Polling = require('./polling');
var Emitter = require('component-emitter');
var inherit = require('component-inherit');
var debug = require('debug')('engine.io-client:polling-xhr');
/**
* Module exports.
*/
module.exports = XHR;
module.exports.Request = Request;
/**
* Empty function
*/
function empty(){}
/**
* XHR Polling constructor.
*
* @param {Object} opts
* @api public
*/
function XHR(opts){
Polling.call(this, opts);
if (global.location) {
var isSSL = 'https:' == location.protocol;
var port = location.port;
// some user agents have empty `location.port`
if (!port) {
port = isSSL ? 443 : 80;
}
this.xd = opts.hostname != global.location.hostname ||
port != opts.port;
this.xs = opts.secure != isSSL;
}
}
/**
* Inherits from Polling.
*/
inherit(XHR, Polling);
/**
* XHR supports binary
*/
XHR.prototype.supportsBinary = true;
/**
* Creates a request.
*
* @param {String} method
* @api private
*/
XHR.prototype.request = function(opts){
opts = opts || {};
opts.uri = this.uri();
opts.xd = this.xd;
opts.xs = this.xs;
opts.agent = this.agent || false;
opts.supportsBinary = this.supportsBinary;
opts.enablesXDR = this.enablesXDR;
return new Request(opts);
};
/**
* Sends data.
*
* @param {String} data to send.
* @param {Function} called upon flush.
* @api private
*/
XHR.prototype.doWrite = function(data, fn){
var isBinary = typeof data !== 'string' && data !== undefined;
var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
var self = this;
req.on('success', fn);
req.on('error', function(err){
self.onError('xhr post error', err);
});
this.sendXhr = req;
};
/**
* Starts a poll cycle.
*
* @api private
*/
XHR.prototype.doPoll = function(){
debug('xhr poll');
var req = this.request();
var self = this;
req.on('data', function(data){
self.onData(data);
});
req.on('error', function(err){
self.onError('xhr poll error', err);
});
this.pollXhr = req;
};
/**
* Request constructor
*
* @param {Object} options
* @api public
*/
function Request(opts){
this.method = opts.method || 'GET';
this.uri = opts.uri;
this.xd = !!opts.xd;
this.xs = !!opts.xs;
this.async = false !== opts.async;
this.data = undefined != opts.data ? opts.data : null;
this.agent = opts.agent;
this.isBinary = opts.isBinary;
this.supportsBinary = opts.supportsBinary;
this.enablesXDR = opts.enablesXDR;
this.create();
}
/**
* Mix in `Emitter`.
*/
Emitter(Request.prototype);
/**
* Creates the XHR object and sends the request.
*
* @api private
*/
Request.prototype.create = function(){
var xhr = this.xhr = new XMLHttpRequest({ agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR });
var self = this;
try {
debug('xhr open %s: %s', this.method, this.uri);
xhr.open(this.method, this.uri, this.async);
if (this.supportsBinary) {
// This has to be done after open because Firefox is stupid
// http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension
xhr.responseType = 'arraybuffer';
}
if ('POST' == this.method) {
try {
if (this.isBinary) {
xhr.setRequestHeader('Content-type', 'application/octet-stream');
} else {
xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
}
} catch (e) {}
}
// ie6 check
if ('withCredentials' in xhr) {
xhr.withCredentials = true;
}
if (this.hasXDR()) {
xhr.onload = function(){
self.onLoad();
};
xhr.onerror = function(){
self.onError(xhr.responseText);
};
} else {
xhr.onreadystatechange = function(){
if (4 != xhr.readyState) return;
if (200 == xhr.status || 1223 == xhr.status) {
self.onLoad();
} else {
// make sure the `error` event handler that's user-set
// does not throw in the same tick and gets caught here
setTimeout(function(){
self.onError(xhr.status);
}, 0);
}
};
}
debug('xhr data %s', this.data);
xhr.send(this.data);
} catch (e) {
// Need to defer since .create() is called directly fhrom the constructor
// and thus the 'error' event can only be only bound *after* this exception
// occurs. Therefore, also, we cannot throw here at all.
setTimeout(function() {
self.onError(e);
}, 0);
return;
}
if (global.document) {
this.index = Request.requestsCount++;
Request.requests[this.index] = this;
}
};
/**
* Called upon successful response.
*
* @api private
*/
Request.prototype.onSuccess = function(){
this.emit('success');
this.cleanup();
};
/**
* Called if we have data.
*
* @api private
*/
Request.prototype.onData = function(data){
this.emit('data', data);
this.onSuccess();
};
/**
* Called upon error.
*
* @api private
*/
Request.prototype.onError = function(err){
this.emit('error', err);
this.cleanup();
};
/**
* Cleans up house.
*
* @api private
*/
Request.prototype.cleanup = function(){
if ('undefined' == typeof this.xhr || null === this.xhr) {
return;
}
// xmlhttprequest
if (this.hasXDR()) {
this.xhr.onload = this.xhr.onerror = empty;
} else {
this.xhr.onreadystatechange = empty;
}
try {
this.xhr.abort();
} catch(e) {}
if (global.document) {
delete Request.requests[this.index];
}
this.xhr = null;
};
/**
* Called upon load.
*
* @api private
*/
Request.prototype.onLoad = function(){
var data;
try {
var contentType;
try {
contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
} catch (e) {}
if (contentType === 'application/octet-stream') {
data = this.xhr.response;
} else {
if (!this.supportsBinary) {
data = this.xhr.responseText;
} else {
data = 'ok';
}
}
} catch (e) {
this.onError(e);
}
if (null != data) {
this.onData(data);
}
};
/**
* Check if it has XDomainRequest.
*
* @api private
*/
Request.prototype.hasXDR = function(){
return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;
};
/**
* Aborts the request.
*
* @api public
*/
Request.prototype.abort = function(){
this.cleanup();
};
/**
* Aborts pending requests when unloading the window. This is needed to prevent
* memory leaks (e.g. when using IE) and to ensure that no spurious error is
* emitted.
*/
if (global.document) {
Request.requestsCount = 0;
Request.requests = {};
if (global.attachEvent) {
global.attachEvent('onunload', unloadHandler);
} else if (global.addEventListener) {
global.addEventListener('beforeunload', unloadHandler);
}
}
function unloadHandler() {
for (var i in Request.requests) {
if (Request.requests.hasOwnProperty(i)) {
Request.requests[i].abort();
}
}
}

245
node_modules/engine.io-client/lib/transports/polling.js generated vendored Normal file
View File

@@ -0,0 +1,245 @@
/**
* Module dependencies.
*/
var Transport = require('../transport');
var parseqs = require('parseqs');
var parser = require('engine.io-parser');
var inherit = require('component-inherit');
var debug = require('debug')('engine.io-client:polling');
/**
* Module exports.
*/
module.exports = Polling;
/**
* Is XHR2 supported?
*/
var hasXHR2 = (function() {
var XMLHttpRequest = require('xmlhttprequest');
var xhr = new XMLHttpRequest({ xdomain: false });
return null != xhr.responseType;
})();
/**
* Polling interface.
*
* @param {Object} opts
* @api private
*/
function Polling(opts){
var forceBase64 = (opts && opts.forceBase64);
if (!hasXHR2 || forceBase64) {
this.supportsBinary = false;
}
Transport.call(this, opts);
}
/**
* Inherits from Transport.
*/
inherit(Polling, Transport);
/**
* Transport name.
*/
Polling.prototype.name = 'polling';
/**
* Opens the socket (triggers polling). We write a PING message to determine
* when the transport is open.
*
* @api private
*/
Polling.prototype.doOpen = function(){
this.poll();
};
/**
* Pauses polling.
*
* @param {Function} callback upon buffers are flushed and transport is paused
* @api private
*/
Polling.prototype.pause = function(onPause){
var pending = 0;
var self = this;
this.readyState = 'pausing';
function pause(){
debug('paused');
self.readyState = 'paused';
onPause();
}
if (this.polling || !this.writable) {
var total = 0;
if (this.polling) {
debug('we are currently polling - waiting to pause');
total++;
this.once('pollComplete', function(){
debug('pre-pause polling complete');
--total || pause();
});
}
if (!this.writable) {
debug('we are currently writing - waiting to pause');
total++;
this.once('drain', function(){
debug('pre-pause writing complete');
--total || pause();
});
}
} else {
pause();
}
};
/**
* Starts polling cycle.
*
* @api public
*/
Polling.prototype.poll = function(){
debug('polling');
this.polling = true;
this.doPoll();
this.emit('poll');
};
/**
* Overloads onData to detect payloads.
*
* @api private
*/
Polling.prototype.onData = function(data){
var self = this;
debug('polling got data %s', data);
var callback = function(packet, index, total) {
// if its the first message we consider the transport open
if ('opening' == self.readyState) {
self.onOpen();
}
// if its a close packet, we close the ongoing requests
if ('close' == packet.type) {
self.onClose();
return false;
}
// otherwise bypass onData and handle the message
self.onPacket(packet);
};
// decode payload
parser.decodePayload(data, this.socket.binaryType, callback);
// if an event did not trigger closing
if ('closed' != this.readyState) {
// if we got data we're not polling
this.polling = false;
this.emit('pollComplete');
if ('open' == this.readyState) {
this.poll();
} else {
debug('ignoring poll - transport state "%s"', this.readyState);
}
}
};
/**
* For polling, send a close packet.
*
* @api private
*/
Polling.prototype.doClose = function(){
var self = this;
function close(){
debug('writing close packet');
self.write([{ type: 'close' }]);
}
if ('open' == this.readyState) {
debug('transport open - closing');
close();
} else {
// in case we're trying to close while
// handshaking is in progress (GH-164)
debug('transport not open - deferring close');
this.once('open', close);
}
};
/**
* Writes a packets payload.
*
* @param {Array} data packets
* @param {Function} drain callback
* @api private
*/
Polling.prototype.write = function(packets){
var self = this;
this.writable = false;
var callbackfn = function() {
self.writable = true;
self.emit('drain');
};
var self = this;
parser.encodePayload(packets, this.supportsBinary, function(data) {
self.doWrite(data, callbackfn);
});
};
/**
* Generates uri for connection.
*
* @api private
*/
Polling.prototype.uri = function(){
var query = this.query || {};
var schema = this.secure ? 'https' : 'http';
var port = '';
// cache busting is forced
if (false !== this.timestampRequests) {
query[this.timestampParam] = +new Date + '-' + Transport.timestamps++;
}
if (!this.supportsBinary && !query.sid) {
query.b64 = 1;
}
query = parseqs.encode(query);
// avoid port if default for schema
if (this.port && (('https' == schema && this.port != 443) ||
('http' == schema && this.port != 80))) {
port = ':' + this.port;
}
// prepend ? to query
if (query.length) {
query = '?' + query;
}
return schema + '://' + this.hostname + port + this.path + query;
};

View File

@@ -0,0 +1,229 @@
/**
* Module dependencies.
*/
var Transport = require('../transport');
var parser = require('engine.io-parser');
var parseqs = require('parseqs');
var inherit = require('component-inherit');
var debug = require('debug')('engine.io-client:websocket');
/**
* `ws` exposes a WebSocket-compatible interface in
* Node, or the `WebSocket` or `MozWebSocket` globals
* in the browser.
*/
var WebSocket = require('ws');
/**
* Module exports.
*/
module.exports = WS;
/**
* WebSocket transport constructor.
*
* @api {Object} connection options
* @api public
*/
function WS(opts){
var forceBase64 = (opts && opts.forceBase64);
if (forceBase64) {
this.supportsBinary = false;
}
Transport.call(this, opts);
}
/**
* Inherits from Transport.
*/
inherit(WS, Transport);
/**
* Transport name.
*
* @api public
*/
WS.prototype.name = 'websocket';
/*
* WebSockets support binary
*/
WS.prototype.supportsBinary = true;
/**
* Opens socket.
*
* @api private
*/
WS.prototype.doOpen = function(){
if (!this.check()) {
// let probe timeout
return;
}
var self = this;
var uri = this.uri();
var protocols = void(0);
var opts = { agent: this.agent };
this.ws = new WebSocket(uri, protocols, opts);
if (this.ws.binaryType === undefined) {
this.supportsBinary = false;
}
this.ws.binaryType = 'arraybuffer';
this.addEventListeners();
};
/**
* Adds event listeners to the socket
*
* @api private
*/
WS.prototype.addEventListeners = function(){
var self = this;
this.ws.onopen = function(){
self.onOpen();
};
this.ws.onclose = function(){
self.onClose();
};
this.ws.onmessage = function(ev){
self.onData(ev.data);
};
this.ws.onerror = function(e){
self.onError('websocket error', e);
};
};
/**
* Override `onData` to use a timer on iOS.
* See: https://gist.github.com/mloughran/2052006
*
* @api private
*/
if ('undefined' != typeof navigator
&& /iPad|iPhone|iPod/i.test(navigator.userAgent)) {
WS.prototype.onData = function(data){
var self = this;
setTimeout(function(){
Transport.prototype.onData.call(self, data);
}, 0);
};
}
/**
* Writes data to socket.
*
* @param {Array} array of packets.
* @api private
*/
WS.prototype.write = function(packets){
var self = this;
this.writable = false;
// encodePacket efficient as it uses WS framing
// no need for encodePayload
for (var i = 0, l = packets.length; i < l; i++) {
parser.encodePacket(packets[i], this.supportsBinary, function(data) {
//Sometimes the websocket has already been closed but the browser didn't
//have a chance of informing us about it yet, in that case send will
//throw an error
try {
self.ws.send(data);
} catch (e){
debug('websocket closed before onclose event');
}
});
}
function ondrain() {
self.writable = true;
self.emit('drain');
}
// fake drain
// defer to next tick to allow Socket to clear writeBuffer
setTimeout(ondrain, 0);
};
/**
* Called upon close
*
* @api private
*/
WS.prototype.onClose = function(){
Transport.prototype.onClose.call(this);
};
/**
* Closes socket.
*
* @api private
*/
WS.prototype.doClose = function(){
if (typeof this.ws !== 'undefined') {
this.ws.close();
}
};
/**
* Generates uri for connection.
*
* @api private
*/
WS.prototype.uri = function(){
var query = this.query || {};
var schema = this.secure ? 'wss' : 'ws';
var port = '';
// avoid port if default for schema
if (this.port && (('wss' == schema && this.port != 443)
|| ('ws' == schema && this.port != 80))) {
port = ':' + this.port;
}
// append timestamp to URI
if (this.timestampRequests) {
query[this.timestampParam] = +new Date;
}
// communicate binary support capabilities
if (!this.supportsBinary) {
query.b64 = 1;
}
query = parseqs.encode(query);
// prepend ? to query
if (query.length) {
query = '?' + query;
}
return schema + '://' + this.hostname + port + this.path + query;
};
/**
* Feature detection for WebSocket.
*
* @return {Boolean} whether this transport is available.
* @api public
*/
WS.prototype.check = function(){
return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
};

36
node_modules/engine.io-client/lib/xmlhttprequest.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
// browser shim for xmlhttprequest module
var hasCORS = require('has-cors');
module.exports = function(opts) {
var xdomain = opts.xdomain;
// scheme must be same when usign XDomainRequest
// http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
var xscheme = opts.xscheme;
// XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
// https://github.com/Automattic/engine.io-client/pull/217
var enablesXDR = opts.enablesXDR;
// XMLHttpRequest can be disabled on IE
try {
if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {
return new XMLHttpRequest();
}
} catch (e) { }
// Use XDomainRequest for IE8 if enablesXDR is true
// because loading bar keeps flashing when using jsonp-polling
// https://github.com/yujiosaka/socke.io-ie8-loading-example
try {
if ('undefined' != typeof XDomainRequest && !xscheme && enablesXDR) {
return new XDomainRequest();
}
} catch (e) { }
if (!xdomain) {
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) { }
}
}

View File

@@ -0,0 +1,115 @@
# debug
tiny node.js debugging utility modelled after node core's debugging technique.
## Installation
```
$ npm install debug
```
## Usage
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
Example _app.js_:
```js
var debug = require('debug')('http')
, http = require('http')
, name = 'My App';
// fake app
debug('booting %s', name);
http.createServer(function(req, res){
debug(req.method + ' ' + req.url);
res.end('hello\n');
}).listen(3000, function(){
debug('listening');
});
// fake worker of some kind
require('./worker');
```
Example _worker.js_:
```js
var debug = require('debug')('worker');
setInterval(function(){
debug('doing some work');
}, 1000);
```
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)
![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)
## Millisecond diff
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
When stderr is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
_(NOTE: Debug now uses stderr instead of stdout, so the correct shell command for this example is actually `DEBUG=* node example/worker 2> out &`)_
![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)
## Conventions
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
## Wildcards
The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=* -connect:*` would include all debuggers except those starting with "connect:".
## Browser support
Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
```js
a = debug('worker:a');
b = debug('worker:b');
setInterval(function(){
a('doing some work');
}, 1000);
setInterval(function(){
a('doing some work');
}, 1200);
```
## License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,137 @@
/**
* Expose `debug()` as the module.
*/
module.exports = debug;
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
if (!debug.enabled(name)) return function(){};
return function(fmt){
fmt = coerce(fmt);
var curr = new Date;
var ms = curr - (debug[name] || curr);
debug[name] = curr;
fmt = name
+ ' '
+ fmt
+ ' +' + debug.humanize(ms);
// This hackery is required for IE8
// where `console.log` doesn't have 'apply'
window.console
&& console.log
&& Function.prototype.apply.call(console.log, console, arguments);
}
}
/**
* The currently active debug mode names.
*/
debug.names = [];
debug.skips = [];
/**
* Enables a debug mode by name. This can include modes
* separated by a colon and wildcards.
*
* @param {String} name
* @api public
*/
debug.enable = function(name) {
try {
localStorage.debug = name;
} catch(e){}
var split = (name || '').split(/[\s,]+/)
, len = split.length;
for (var i = 0; i < len; i++) {
name = split[i].replace('*', '.*?');
if (name[0] === '-') {
debug.skips.push(new RegExp('^' + name.substr(1) + '$'));
}
else {
debug.names.push(new RegExp('^' + name + '$'));
}
}
};
/**
* Disable debug output.
*
* @api public
*/
debug.disable = function(){
debug.enable('');
};
/**
* Humanize the given `ms`.
*
* @param {Number} m
* @return {String}
* @api private
*/
debug.humanize = function(ms) {
var sec = 1000
, min = 60 * 1000
, hour = 60 * min;
if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
if (ms >= min) return (ms / min).toFixed(1) + 'm';
if (ms >= sec) return (ms / sec | 0) + 's';
return ms + 'ms';
};
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
debug.enabled = function(name) {
for (var i = 0, len = debug.skips.length; i < len; i++) {
if (debug.skips[i].test(name)) {
return false;
}
}
for (var i = 0, len = debug.names.length; i < len; i++) {
if (debug.names[i].test(name)) {
return true;
}
}
return false;
};
/**
* Coerce `val`.
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
// persist
try {
if (window.localStorage) debug.enable(localStorage.debug);
} catch(e){}

View File

@@ -0,0 +1,5 @@
if ('undefined' == typeof window) {
module.exports = require('./lib/debug');
} else {
module.exports = require('./debug');
}

View File

@@ -0,0 +1,147 @@
/**
* Module dependencies.
*/
var tty = require('tty');
/**
* Expose `debug()` as the module.
*/
module.exports = debug;
/**
* Enabled debuggers.
*/
var names = []
, skips = [];
(process.env.DEBUG || '')
.split(/[\s,]+/)
.forEach(function(name){
name = name.replace('*', '.*?');
if (name[0] === '-') {
skips.push(new RegExp('^' + name.substr(1) + '$'));
} else {
names.push(new RegExp('^' + name + '$'));
}
});
/**
* Colors.
*/
var colors = [6, 2, 3, 4, 5, 1];
/**
* Previous debug() call.
*/
var prev = {};
/**
* Previously assigned color.
*/
var prevColor = 0;
/**
* Is stdout a TTY? Colored output is disabled when `true`.
*/
var isatty = tty.isatty(2);
/**
* Select a color.
*
* @return {Number}
* @api private
*/
function color() {
return colors[prevColor++ % colors.length];
}
/**
* Humanize the given `ms`.
*
* @param {Number} m
* @return {String}
* @api private
*/
function humanize(ms) {
var sec = 1000
, min = 60 * 1000
, hour = 60 * min;
if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
if (ms >= min) return (ms / min).toFixed(1) + 'm';
if (ms >= sec) return (ms / sec | 0) + 's';
return ms + 'ms';
}
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
function disabled(){}
disabled.enabled = false;
var match = skips.some(function(re){
return re.test(name);
});
if (match) return disabled;
match = names.some(function(re){
return re.test(name);
});
if (!match) return disabled;
var c = color();
function colored(fmt) {
fmt = coerce(fmt);
var curr = new Date;
var ms = curr - (prev[name] || curr);
prev[name] = curr;
fmt = ' \u001b[9' + c + 'm' + name + ' '
+ '\u001b[3' + c + 'm\u001b[90m'
+ fmt + '\u001b[3' + c + 'm'
+ ' +' + humanize(ms) + '\u001b[0m';
console.error.apply(this, arguments);
}
function plain(fmt) {
fmt = coerce(fmt);
fmt = new Date().toUTCString()
+ ' ' + name + ' ' + fmt;
console.error.apply(this, arguments);
}
colored.enabled = plain.enabled = true;
return isatty || process.env.DEBUG_COLORS
? colored
: plain;
}
/**
* Coerce `val`.
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}

View File

@@ -0,0 +1,88 @@
{
"_args": [
[
"debug@0.7.4",
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\engine.io-client"
]
],
"_from": "debug@0.7.4",
"_id": "debug@0.7.4",
"_inCache": true,
"_installable": true,
"_location": "/engine.io-client/debug",
"_npmUser": {
"email": "tj@vision-media.ca",
"name": "tjholowaychuk"
},
"_npmVersion": "1.3.13",
"_phantomChildren": {},
"_requested": {
"name": "debug",
"raw": "debug@0.7.4",
"rawSpec": "0.7.4",
"scope": null,
"spec": "0.7.4",
"type": "version"
},
"_requiredBy": [
"/engine.io-client"
],
"_resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz",
"_shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
"_shrinkwrap": null,
"_spec": "debug@0.7.4",
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\engine.io-client",
"author": {
"email": "tj@vision-media.ca",
"name": "TJ Holowaychuk"
},
"browser": "./debug.js",
"bugs": {
"url": "https://github.com/visionmedia/debug/issues"
},
"component": {
"scripts": {
"debug/debug.js": "debug.js",
"debug/index.js": "index.js"
}
},
"dependencies": {},
"description": "small debugging utility",
"devDependencies": {
"mocha": "*"
},
"directories": {},
"dist": {
"shasum": "06e1ea8082c2cb14e39806e22e2f6f757f92af39",
"tarball": "http://registry.npmjs.org/debug/-/debug-0.7.4.tgz"
},
"engines": {
"node": "*"
},
"files": [
"lib/debug.js",
"debug.js",
"index.js"
],
"homepage": "https://github.com/visionmedia/debug",
"keywords": [
"debug",
"log",
"debugger"
],
"main": "lib/debug.js",
"maintainers": [
{
"email": "tj@vision-media.ca",
"name": "tjholowaychuk"
}
],
"name": "debug",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/debug.git"
},
"version": "0.7.4"
}

View File

@@ -0,0 +1,5 @@
n.n.n / 2014-02-09
==================
* parseuri first commit

View File

@@ -0,0 +1,3 @@
test:
@./node_modules/.bin/mocha test.js

View File

@@ -0,0 +1,39 @@
/**
* Parses an URI
*
* @author Steven Levithan <stevenlevithan.com> (MIT license)
* @api private
*/
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
var parts = [
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
];
module.exports = function parseuri(str) {
var src = str,
b = str.indexOf('['),
e = str.indexOf(']');
if (b != -1 && e != -1) {
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
}
var m = re.exec(str || ''),
uri = {},
i = 14;
while (i--) {
uri[parts[i]] = m[i] || '';
}
if (b != -1 && e != -1) {
uri.source = src;
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
uri.ipv6uri = true;
}
return uri;
};

View File

@@ -0,0 +1,70 @@
{
"_args": [
[
"parseuri@0.0.4",
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\engine.io-client"
]
],
"_from": "parseuri@0.0.4",
"_id": "parseuri@0.0.4",
"_inCache": true,
"_installable": true,
"_location": "/engine.io-client/parseuri",
"_npmUser": {
"email": "koren@mit.edu",
"name": "gal"
},
"_npmVersion": "1.3.15",
"_phantomChildren": {},
"_requested": {
"name": "parseuri",
"raw": "parseuri@0.0.4",
"rawSpec": "0.0.4",
"scope": null,
"spec": "0.0.4",
"type": "version"
},
"_requiredBy": [
"/engine.io-client"
],
"_resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.4.tgz",
"_shasum": "806582a39887e1ea18dd5e2fe0e01902268e9350",
"_shrinkwrap": null,
"_spec": "parseuri@0.0.4",
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\engine.io-client",
"author": "",
"bugs": {
"url": "https://github.com/get/parseuri/issues"
},
"dependencies": {
"better-assert": "~1.0.0"
},
"description": "Method that parses a URI and returns an array of its components",
"devDependencies": {
"mocha": "1.17.1"
},
"directories": {},
"dist": {
"shasum": "806582a39887e1ea18dd5e2fe0e01902268e9350",
"tarball": "http://registry.npmjs.org/parseuri/-/parseuri-0.0.4.tgz"
},
"homepage": "https://github.com/get/parseuri",
"license": "MIT",
"maintainers": [
{
"email": "koren@mit.edu",
"name": "gal"
}
],
"name": "parseuri",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/get/parseuri.git"
},
"scripts": {
"test": "make test"
},
"version": "0.0.4"
}

View File

@@ -0,0 +1,51 @@
var assert = require('better-assert');
var expect = require('expect.js');
var parseuri = require('./index.js');
describe('my suite', function(){
it('should parse an uri', function () {
var http = parseuri('http://google.com')
, https = parseuri('https://www.google.com:80')
, query = parseuri('google.com:8080/foo/bar?foo=bar')
, localhost = parseuri('localhost:8080')
, ipv6 = parseuri('2001:0db8:85a3:0042:1000:8a2e:0370:7334')
, ipv6short = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334')
, ipv6port = parseuri('2001:db8:85a3:42:1000:8a2e:370:7334:80')
, ipv6abbrev = parseuri('2001::7334:a:80')
, ipv6http = parseuri('http://[2001::7334:a]:80')
, ipv6query = parseuri('http://[2001::7334:a]:80/foo/bar?foo=bar')
expect(http.protocol).to.be('http');
expect(http.port).to.be('');
expect(http.host).to.be('google.com');
expect(https.protocol).to.be('https');
expect(https.port).to.be('80');
expect(https.host).to.be('www.google.com');
expect(query.port).to.be('8080');
expect(query.query).to.be('foo=bar');
expect(query.path).to.be('/foo/bar');
expect(query.relative).to.be('/foo/bar?foo=bar');
expect(localhost.protocol).to.be('');
expect(localhost.host).to.be('localhost');
expect(localhost.port).to.be('8080');
expect(ipv6.protocol).to.be('');
expect(ipv6.host).to.be('2001:0db8:85a3:0042:1000:8a2e:0370:7334');
expect(ipv6.port).to.be('');
expect(ipv6short.protocol).to.be('');
expect(ipv6short.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6short.port).to.be('');
expect(ipv6port.protocol).to.be('');
expect(ipv6port.host).to.be('2001:db8:85a3:42:1000:8a2e:370:7334');
expect(ipv6port.port).to.be('80');
expect(ipv6abbrev.protocol).to.be('');
expect(ipv6abbrev.host).to.be('2001::7334:a:80');
expect(ipv6abbrev.port).to.be('');
expect(ipv6http.protocol).to.be('http');
expect(ipv6http.port).to.be('80');
expect(ipv6http.host).to.be('2001::7334:a');
expect(ipv6query.protocol).to.be('http');
expect(ipv6query.port).to.be('80');
expect(ipv6query.host).to.be('2001::7334:a');
expect(ipv6query.relative).to.be('/foo/bar?foo=bar');
});
});

109
node_modules/engine.io-client/package.json generated vendored Normal file
View File

@@ -0,0 +1,109 @@
{
"_args": [
[
"engine.io-client@1.4.2",
"C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io-client"
]
],
"_from": "engine.io-client@1.4.2",
"_id": "engine.io-client@1.4.2",
"_inCache": true,
"_installable": true,
"_location": "/engine.io-client",
"_npmUser": {
"email": "rauchg@gmail.com",
"name": "rauchg"
},
"_npmVersion": "1.4.21",
"_phantomChildren": {
"better-assert": "1.0.2"
},
"_requested": {
"name": "engine.io-client",
"raw": "engine.io-client@1.4.2",
"rawSpec": "1.4.2",
"scope": null,
"spec": "1.4.2",
"type": "version"
},
"_requiredBy": [
"/socket.io-client"
],
"_resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-1.4.2.tgz",
"_shasum": "c7ac000e6df05b1ca358f060c7999df9114ccf1e",
"_shrinkwrap": null,
"_spec": "engine.io-client@1.4.2",
"_where": "C:\\Users\\esanvin\\Desktop\\multi\\NodeServer\\node_modules\\socket.io-client",
"browser": {
"xmlhttprequest": "./lib/xmlhttprequest.js"
},
"bugs": {
"url": "https://github.com/Automattic/engine.io-client/issues"
},
"contributors": [
{
"email": "rauchg@gmail.com",
"name": "Guillermo Rauch"
},
{
"email": "dronnikov@gmail.com",
"name": "Vladimir Dronnikov"
},
{
"name": "Christoph Dorn",
"url": "https://github.com/cadorn"
},
{
"email": "mokesmokes@gmail.com",
"name": "Mark Mokryn"
}
],
"dependencies": {
"component-emitter": "1.1.2",
"component-inherit": "0.0.3",
"debug": "0.7.4",
"engine.io-parser": "1.1.0",
"has-cors": "1.0.3",
"indexof": "0.0.1",
"parsejson": "0.0.1",
"parseqs": "0.0.2",
"parseuri": "0.0.4",
"ws": "0.4.31",
"xmlhttprequest": "https://github.com/LearnBoost/node-XMLHttpRequest/archive/0f36d0b5ebc03d85f860d42a64ae9791e1daa433.tar.gz"
},
"description": "Client for the realtime Engine",
"devDependencies": {
"blob": "0.0.2",
"browserify": "4.2.1",
"engine.io": "1.4.2",
"expect.js": "0.2.0",
"express": "3.4.8",
"istanbul": "0.2.3",
"mocha": "1.16.2",
"zuul": "1.10.2"
},
"directories": {},
"dist": {
"shasum": "c7ac000e6df05b1ca358f060c7999df9114ccf1e",
"tarball": "http://registry.npmjs.org/engine.io-client/-/engine.io-client-1.4.2.tgz"
},
"gitHead": "8bd41ad7b44c66d6ec400c398bcaad1e29eb0f9a",
"homepage": "http://socket.io",
"maintainers": [
{
"email": "rauchg@gmail.com",
"name": "rauchg"
}
],
"name": "engine.io-client",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/Automattic/engine.io-client.git"
},
"scripts": {
"test": "make test"
},
"version": "1.4.2"
}