08-27-周三_17-09-29
This commit is contained in:
2
node_modules/shoe/.npmignore
generated
vendored
Normal file
2
node_modules/shoe/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
example/*/node_modules
|
||||
example/*/static/bundle.js
|
18
node_modules/shoe/LICENSE
generated
vendored
Normal file
18
node_modules/shoe/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
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.
|
63
node_modules/shoe/browser.js
generated
vendored
Normal file
63
node_modules/shoe/browser.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
var Stream = require('stream');
|
||||
var sockjs = require('sockjs-client');
|
||||
var resolve = require('url').resolve;
|
||||
var parse = require('url').parse;
|
||||
|
||||
module.exports = function (u, cb) {
|
||||
var uri = parse(u).protocol ? u : resolve(window.location.href, u);
|
||||
|
||||
var stream = new Stream;
|
||||
stream.readable = true;
|
||||
stream.writable = true;
|
||||
|
||||
var ready = false;
|
||||
var buffer = [];
|
||||
|
||||
var sock = sockjs(uri);
|
||||
stream.sock = sock;
|
||||
|
||||
stream.write = function (msg) {
|
||||
if (!ready || buffer.length) buffer.push(msg)
|
||||
else sock.send(msg)
|
||||
};
|
||||
|
||||
stream.end = function (msg) {
|
||||
if (msg !== undefined) stream.write(msg);
|
||||
if (!ready) {
|
||||
stream._ended = true;
|
||||
return;
|
||||
}
|
||||
stream.writable = false;
|
||||
sock.close();
|
||||
};
|
||||
|
||||
stream.destroy = function () {
|
||||
stream._ended = true;
|
||||
stream.writable = stream.readable = false;
|
||||
buffer.length = 0
|
||||
sock.close();
|
||||
};
|
||||
|
||||
sock.onopen = function () {
|
||||
if (typeof cb === 'function') cb();
|
||||
ready = true;
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
sock.send(buffer[i]);
|
||||
}
|
||||
buffer = [];
|
||||
stream.emit('connect');
|
||||
if (stream._ended) stream.end();
|
||||
};
|
||||
|
||||
sock.onmessage = function (e) {
|
||||
stream.emit('data', e.data);
|
||||
};
|
||||
|
||||
sock.onclose = function () {
|
||||
stream.emit('end');
|
||||
stream.writable = false;
|
||||
stream.readable = false;
|
||||
};
|
||||
|
||||
return stream;
|
||||
};
|
2
node_modules/shoe/example/dnode/Makefile
generated
vendored
Normal file
2
node_modules/shoe/example/dnode/Makefile
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
node_modules/.bin/browserify client.js -o static/bundle.js
|
13
node_modules/shoe/example/dnode/client.js
generated
vendored
Normal file
13
node_modules/shoe/example/dnode/client.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var shoe = require('../../');
|
||||
var dnode = require('dnode');
|
||||
|
||||
var result = document.getElementById('result');
|
||||
var stream = shoe('/dnode');
|
||||
|
||||
var d = dnode();
|
||||
d.on('remote', function (remote) {
|
||||
remote.transform('beep', function (s) {
|
||||
result.textContent = 'beep => ' + s;
|
||||
});
|
||||
});
|
||||
d.pipe(stream).pipe(d);
|
10
node_modules/shoe/example/dnode/package.json
generated
vendored
Normal file
10
node_modules/shoe/example/dnode/package.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name" : "shoe-dnode-example",
|
||||
"version" : "0.0.0",
|
||||
"dependencies" : {
|
||||
"browserify" : "~1.13.0",
|
||||
"ecstatic" : "~0.1.6",
|
||||
"dnode" : "~1.0.1"
|
||||
},
|
||||
"private" : true
|
||||
}
|
19
node_modules/shoe/example/dnode/server.js
generated
vendored
Normal file
19
node_modules/shoe/example/dnode/server.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var shoe = require('../../');
|
||||
var dnode = require('dnode');
|
||||
|
||||
var http = require('http');
|
||||
var ecstatic = require('ecstatic')(__dirname + '/static');
|
||||
|
||||
var server = http.createServer(ecstatic);
|
||||
server.listen(9999);
|
||||
|
||||
var sock = shoe(function (stream) {
|
||||
var d = dnode({
|
||||
transform : function (s, cb) {
|
||||
var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase();
|
||||
cb(res);
|
||||
}
|
||||
});
|
||||
d.pipe(stream).pipe(d);
|
||||
});
|
||||
sock.install(server, '/dnode');
|
6
node_modules/shoe/example/dnode/static/index.html
generated
vendored
Normal file
6
node_modules/shoe/example/dnode/static/index.html
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<div id="result"></div>
|
||||
<script src="/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
5
node_modules/shoe/example/invert/Makefile
generated
vendored
Normal file
5
node_modules/shoe/example/invert/Makefile
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
all:
|
||||
node_modules/.bin/browserify \
|
||||
client.js \
|
||||
-o static/bundle.js \
|
||||
--debug
|
10
node_modules/shoe/example/invert/client.js
generated
vendored
Normal file
10
node_modules/shoe/example/invert/client.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var shoe = require('../../');
|
||||
var through = require('through');
|
||||
|
||||
var result = document.getElementById('result');
|
||||
|
||||
var stream = shoe('/invert');
|
||||
stream.pipe(through(function (msg) {
|
||||
result.appendChild(document.createTextNode(msg));
|
||||
this.queue(String(Number(msg)^1));
|
||||
})).pipe(stream);
|
10
node_modules/shoe/example/invert/package.json
generated
vendored
Normal file
10
node_modules/shoe/example/invert/package.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name" : "shoe-invert-example",
|
||||
"version" : "0.0.0",
|
||||
"dependencies" : {
|
||||
"browserify" : "~2.25.1",
|
||||
"ecstatic" : "~0.4.5",
|
||||
"through" : "~2.3.4"
|
||||
},
|
||||
"private" : true
|
||||
}
|
19
node_modules/shoe/example/invert/server.js
generated
vendored
Normal file
19
node_modules/shoe/example/invert/server.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var http = require('http');
|
||||
var ecstatic = require('ecstatic')(__dirname + '/static');
|
||||
var shoe = require('../../');
|
||||
|
||||
var server = http.createServer(ecstatic);
|
||||
server.listen(9999);
|
||||
|
||||
var sock = shoe(function (stream) {
|
||||
var iv = setInterval(function () {
|
||||
stream.write(Math.floor(Math.random() * 2));
|
||||
}, 250);
|
||||
|
||||
stream.on('end', function () {
|
||||
clearInterval(iv);
|
||||
});
|
||||
|
||||
stream.pipe(process.stdout, { end : false });
|
||||
});
|
||||
sock.install(server, '/invert');
|
2
node_modules/shoe/example/invert/static/index.html
generated
vendored
Normal file
2
node_modules/shoe/example/invert/static/index.html
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
<div id="result"></div>
|
||||
<script src="/bundle.js"></script>
|
59
node_modules/shoe/index.js
generated
vendored
Normal file
59
node_modules/shoe/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
var sockjs = require('sockjs');
|
||||
|
||||
exports = module.exports = function (opts, cb) {
|
||||
if (typeof opts === 'function') {
|
||||
cb = opts;
|
||||
opts = {};
|
||||
}
|
||||
var server = sockjs.createServer();
|
||||
var handler = function (stream) {
|
||||
var _didTimeout = stream._session.didTimeout
|
||||
var _didClose = stream._session.didClose
|
||||
|
||||
stream._session.didTimeout = function () {
|
||||
cleanup()
|
||||
_didTimeout.apply(this, arguments)
|
||||
}
|
||||
stream._session.didClose = function () {
|
||||
cleanup()
|
||||
_didClose.apply(this, arguments)
|
||||
}
|
||||
|
||||
cb(stream)
|
||||
|
||||
function cleanup() {
|
||||
stream.emit("close")
|
||||
if (stream.destroy) {
|
||||
stream.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof cb === 'function') {
|
||||
server.on('connection', handler);
|
||||
}
|
||||
server.install = function (httpServer, hopts) {
|
||||
if (hopts && hopts.listen && !httpServer.listen) {
|
||||
httpServer = arguments[1];
|
||||
hopts = arguments[0];
|
||||
}
|
||||
if (typeof hopts === 'string') {
|
||||
hopts = { prefix : hopts };
|
||||
}
|
||||
if (!hopts) hopts = {};
|
||||
if (hopts.log === undefined) {
|
||||
// spamming stdout by default is VERY infuriating,
|
||||
// emit an event instead
|
||||
hopts.log = function (severity, line) {
|
||||
server.emit('log', severity, line);
|
||||
};
|
||||
}
|
||||
server.installHandlers(httpServer, hopts);
|
||||
return server;
|
||||
};
|
||||
|
||||
return server;
|
||||
};
|
||||
|
||||
for (var key in sockjs) {
|
||||
exports[key] = sockjs[key];
|
||||
}
|
3
node_modules/shoe/node_modules/sockjs-client/.npmignore
generated
vendored
Normal file
3
node_modules/shoe/node_modules/sockjs-client/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.testling_env.sh
|
||||
bin/.testling_env.sh
|
||||
tests
|
11
node_modules/shoe/node_modules/sockjs-client/COPYING
generated
vendored
Normal file
11
node_modules/shoe/node_modules/sockjs-client/COPYING
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Parts of the code are derived from various open source projects.
|
||||
|
||||
For code derived from Socket.IO by Guillermo Rauch see
|
||||
https://github.com/LearnBoost/socket.io/tree/0.6.17#readme.
|
||||
|
||||
Snippets derived from JSON-js by Douglas Crockford are public domain.
|
||||
|
||||
Snippets derived from jQuery-JSONP by Julian Aubourg, generic MIT
|
||||
license.
|
||||
|
||||
All other code is released on MIT license, see LICENSE-MIT-SockJS.
|
128
node_modules/shoe/node_modules/sockjs-client/Changelog
generated
vendored
Normal file
128
node_modules/shoe/node_modules/sockjs-client/Changelog
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
0.3.1
|
||||
=====
|
||||
|
||||
* #61 - Meteor guys found that we unintentionally catch "onopen" errors.
|
||||
* #63 - Meteorjs guys found that xhr-streaming on Safari sometimes
|
||||
left busy cursor running.
|
||||
* Increased allowed time for websocket transport (from 1 rtt to 2),
|
||||
this should make ws transport more reliable over SSL, at the cost
|
||||
of slightly longer connection time for users with blocked ws.
|
||||
* #57 - previous fix didn't really work, sockjs-client still left
|
||||
a mess in browsers history when using iframe transports. This
|
||||
is fixed now.
|
||||
* #60 - Opera 12 (next) claims to do AJAX2 / CORS, but can't
|
||||
do xhr-streaming.
|
||||
* #58 - onunload test sometimes failed on Safari on windows
|
||||
* Updated readme WRT websocket protocols
|
||||
* Updated readme WRT deployments on heroku
|
||||
* Add minimalistic license block to every source file.
|
||||
|
||||
|
||||
0.3.0
|
||||
=====
|
||||
|
||||
* Temporarily disabled iframe tests - they are failing unpredictably.
|
||||
* #57 - pointing an iframe to "about:blank" during cleanup caused
|
||||
Opera to messup history.
|
||||
* #55 - Improved iframe abstraction (reduced a possible mem leak)
|
||||
* Refactored AJAX abstractions, for better CORS handing - again.
|
||||
* Add additional parent origin security check to an iframe.
|
||||
* Urls with hashes or query strings can't be passed to SockJS.
|
||||
* #18 - Mention workaround for Firefox ESC key issue
|
||||
* #53 - AMD compliance
|
||||
* sockjs/sockjs-protocol#28 - always use square brackets for
|
||||
websocket frames
|
||||
* #51 - initial support for IE10 - try XHR before XDR
|
||||
* #28 - handle onunload / onbeforeunload in a more robust fashion
|
||||
* #49 - support SockJS-client being used from files served from
|
||||
file:// urls.
|
||||
|
||||
|
||||
0.2.1
|
||||
=====
|
||||
|
||||
* "smoke-latency.html" test was unnecesairly sending too much data.
|
||||
* Bumped core dependencies (coffee-script and uglify-js)
|
||||
* Minor updates to the README, few cosmetic changes in the code.
|
||||
|
||||
|
||||
0.2.0
|
||||
=====
|
||||
|
||||
* The API had changed - use `protocols_whitelist` option instead of
|
||||
passing an array of protocols as a second argument to SockJS constructor.
|
||||
* Dropped 'chunking-test' functionality and replace it with 'info'.
|
||||
* Rewritten protocol-choosing alogirthm, see "utils.detectProtocols" method.
|
||||
* Use dynamic protocol timeouts based on RTT, not hardcoded 5 seconds
|
||||
* #34 - Don't ever reuse `session_id`, especially when trying
|
||||
fallback protocols.
|
||||
* The test server got moved from SockJS-client to SockJS-node.
|
||||
* Don't test unicode surrogates - it can't work in some environments.
|
||||
* XHR/XDR helpers were rewritten, ajax transports were simplified.
|
||||
* Added a domain check in the iframe to improve security.
|
||||
* SockJS will now trigger 1002 error if there is a problem during handshake
|
||||
instead of 2000 error.
|
||||
* Smoke-throughput test is renamed to smoke-latency.
|
||||
|
||||
0.1.2
|
||||
=====
|
||||
|
||||
* #29 - Allow all unicode characters to be send over SockJS.
|
||||
* #15 - SockJS should now work fine even if the connection is started
|
||||
in HEAD, before BODY is loaded.
|
||||
* #28 - In rare circumstances WebSocket connection can be left intact
|
||||
after the page is unloaded in FireFox.
|
||||
* Updated scripts to work with Node 0.6.
|
||||
* Initial work to do better QUnit testing.
|
||||
* Updated the minifying script (always escape unicode chars, remove
|
||||
trailing comment).
|
||||
* Use string instead of array of chars (utils.js:random_number_string).
|
||||
|
||||
|
||||
0.1.1
|
||||
=====
|
||||
|
||||
* #21 Get JsonP transport working on IE9 (Vladimir Dronnikov).
|
||||
* #26 Emit heartbeat event.
|
||||
* #27 Include license inline.
|
||||
|
||||
|
||||
0.1.0
|
||||
=====
|
||||
|
||||
* SockJS-client can only send UTF-8 encodable strings. Previously we
|
||||
took advantage of rich data structures and automatically
|
||||
json-encoded them, but this got removed. Now, all data passed to
|
||||
`send` will be converted to string. This is also how native
|
||||
* `status` property on `EventClose` is renamed to `code`
|
||||
as per Websocket API
|
||||
WebSockets behave.
|
||||
* The test server was updated to new `sockjs-node` API
|
||||
* Fixed problem with Jsonp-polling transport on IE9
|
||||
* Repository was moved - updated links.
|
||||
|
||||
|
||||
0.0.4
|
||||
=====
|
||||
|
||||
* All transports were refactored, some transports were introduced:
|
||||
htmlfile and separate xhr-streaming.
|
||||
* Added logic to detect support for http chunking, and thus a
|
||||
possibility to rule out streaming transports before running them.
|
||||
* Added 'cookie' option, useful for cookie-based load balancing
|
||||
(currently, it make a difference only for IE).
|
||||
* Added hack to prevent EventSource from crashing Safari and Chrome.
|
||||
* Loads and loads of other small and medium changes.
|
||||
|
||||
|
||||
0.0.2
|
||||
=====
|
||||
|
||||
* Initial support for JSESSIONID based load balancing. Currently
|
||||
doesn't play nicely with IE XDomainRequest transport.
|
||||
|
||||
|
||||
0.0.1
|
||||
=====
|
||||
|
||||
* Initial release.
|
19
node_modules/shoe/node_modules/sockjs-client/LICENSE-MIT-SockJS
generated
vendored
Normal file
19
node_modules/shoe/node_modules/sockjs-client/LICENSE-MIT-SockJS
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2011-2012 VMware, Inc.
|
||||
|
||||
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.
|
107
node_modules/shoe/node_modules/sockjs-client/Makefile
generated
vendored
Normal file
107
node_modules/shoe/node_modules/sockjs-client/Makefile
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
.PHONY: all build tests test serve clean
|
||||
|
||||
COFFEE:=./node_modules/.bin/coffee
|
||||
|
||||
all: sockjs.js
|
||||
|
||||
build: sockjs.js sockjs.min.js
|
||||
|
||||
sockjs.js: lib/*js version
|
||||
@$(COFFEE) -v > /dev/null
|
||||
$(COFFEE) bin/render.coffee --set-version $(VER) lib/all.js > $@
|
||||
|
||||
sockjs.min.js: lib/*js version
|
||||
@$(COFFEE) -v > /dev/null
|
||||
$(COFFEE) bin/render.coffee --set-version $(VER) --minify lib/all.js > $@
|
||||
|
||||
sockjs.pretty.js: lib/*js version
|
||||
@$(COFFEE) -v > /dev/null
|
||||
$(COFFEE) bin/render.coffee --set-version $(VER) --minify --pretty lib/all.js > $@
|
||||
|
||||
tests/html/lib/sockjs.js: sockjs.js
|
||||
cp $< $@
|
||||
|
||||
tests/html/lib/%.js: tests/html/src/%.coffee
|
||||
@$(COFFEE) -v > /dev/null
|
||||
$(COFFEE) -o tests/html/lib/ -c --bare $<
|
||||
|
||||
build_tests: tests/html/lib/sockjs.js tests/html/lib/tests.js \
|
||||
tests/html/lib/unittests.js tests/html/lib/domtests.js \
|
||||
tests/html/lib/endtoendtests.js
|
||||
|
||||
test: tests
|
||||
tests: build_tests
|
||||
node tests/server.js
|
||||
|
||||
|
||||
serve:
|
||||
@if [ -e .pidfile.pid ]; then \
|
||||
kill `cat .pidfile.pid`; \
|
||||
rm .pidfile.pid; \
|
||||
fi
|
||||
|
||||
@while [ 1 ]; do \
|
||||
make build_tests; \
|
||||
echo " [*] Running http server"; \
|
||||
make test & \
|
||||
SRVPID=$$!; \
|
||||
echo $$SRVPID > .pidfile.pid; \
|
||||
echo " [*] Server pid: $$SRVPID"; \
|
||||
inotifywait -r -q -e modify . ../sockjs-node; \
|
||||
kill `cat .pidfile.pid`; \
|
||||
rm -f .pidfile.pid; \
|
||||
sleep 0.1; \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -f sockjs*.js tests/html/lib/*.js
|
||||
|
||||
# To release:
|
||||
# 0) 'make prepare-release'
|
||||
# 1) commit everything you need
|
||||
# 2) amend 'version' file (don't commit)
|
||||
# 3) run 'make tag', and git push/git push --tag as suggested
|
||||
# 4) run 'make upload', and suggested commands
|
||||
|
||||
RVER:=$(shell cat version)
|
||||
VER:=$(shell ./VERSION-GEN)
|
||||
# The first two dots: 1.2.3 -> 1.2
|
||||
MAJVER:=$(shell echo $(VER)|sed 's|^\([^.]\+[.][^.]\+\).*$$|\1|' )
|
||||
|
||||
.PHONY: prepare-release tag upload
|
||||
prepare-release:
|
||||
make clean
|
||||
[ -e ../sockjs-client-gh-pages ] || \
|
||||
git clone `git remote -v|tr "[:space:]" "\t"|cut -f 2` \
|
||||
--branch gh-pages ../sockjs-client-gh-pages
|
||||
(cd ../sockjs-client-gh-pages; git pull;)
|
||||
|
||||
#-git tag -d v$(RVER)
|
||||
tag:
|
||||
git commit $(TAG_OPTS) version Changelog -m "Release $(RVER)" --allow-empty
|
||||
git tag -s v$(RVER) -m "Release $(RVER)"
|
||||
@echo ' [*] Now run'
|
||||
@echo 'git push; git push --tag'
|
||||
|
||||
ARTIFACTS=\
|
||||
sockjs-$(VER).js \
|
||||
sockjs-$(VER).min.js \
|
||||
sockjs-$(MAJVER).js \
|
||||
sockjs-$(MAJVER).min.js
|
||||
|
||||
upload: build
|
||||
echo "VER=$(VER) MAJVER=$(MAJVER)"
|
||||
cp sockjs.js ../sockjs-client-gh-pages/sockjs-$(VER).js
|
||||
cp sockjs.min.js ../sockjs-client-gh-pages/sockjs-$(VER).min.js
|
||||
cp sockjs.js ../sockjs-client-gh-pages/sockjs-$(MAJVER).js
|
||||
cp sockjs.min.js ../sockjs-client-gh-pages/sockjs-$(MAJVER).min.js
|
||||
(cd ../sockjs-client-gh-pages; \
|
||||
git add $(ARTIFACTS); \
|
||||
git commit -m "Release $(VER)"; \
|
||||
node generate_index.js > index.html; \
|
||||
git add index.html; \
|
||||
git commit --amend -m "Release $(VER)";)
|
||||
@echo ' [*] Now run: '
|
||||
@echo '(cd ../sockjs-client-gh-pages; git push; )'
|
||||
@echo '(cd ../sockjs-client-gh-pages; \
|
||||
s3cmd put --acl-public index.html $(ARTIFACTS) s3://sockjs; );'
|
379
node_modules/shoe/node_modules/sockjs-client/README.md
generated
vendored
Normal file
379
node_modules/shoe/node_modules/sockjs-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,379 @@
|
||||
SockJS family:
|
||||
|
||||
* [SockJS-client](https://github.com/sockjs/sockjs-client) JavaScript client library
|
||||
* [SockJS-node](https://github.com/sockjs/sockjs-node) Node.js server
|
||||
* [SockJS-erlang](https://github.com/sockjs/sockjs-erlang) Erlang server
|
||||
* [SockJS-lua](https://github.com/luvit/sockjs-luvit) Lua/Luvit server
|
||||
* [SockJS-tornado](https://github.com/MrJoes/sockjs-tornado) Python/Tornado server
|
||||
* [vert.x](https://github.com/purplefox/vert.x) Java/vert.x server
|
||||
|
||||
Work in progress:
|
||||
|
||||
* [SockJS-ruby](https://github.com/sockjs/sockjs-ruby)
|
||||
* [SockJS-netty](https://github.com/cgbystrom/sockjs-netty)
|
||||
* [SockJS-gevent](https://github.com/sdiehl/sockjs-gevent)
|
||||
* [pyramid-SockJS](https://github.com/fafhrd91/pyramid_sockjs)
|
||||
* [wildcloud-websockets](https://github.com/wildcloud/wildcloud-websockets)
|
||||
* [SockJS-cyclone](https://github.com/flaviogrossi/sockjs-cyclone)
|
||||
* [SockJS-twisted](https://github.com/Fugiman/sockjs-twisted/)
|
||||
|
||||
|
||||
SockJS-client
|
||||
=============
|
||||
|
||||
SockJS is a browser JavaScript library that provides a WebSocket-like
|
||||
object. SockJS gives you a coherent, cross-browser, Javascript API
|
||||
which creates a low latency, full duplex, cross-domain communication
|
||||
channel between the browser and the web server.
|
||||
|
||||
Under the hood SockJS tries to use native WebSockets first. If that
|
||||
fails it can use a variety of browser-specific transport protocols and
|
||||
presents them through WebSocket-like abstractions.
|
||||
|
||||
SockJS is intended to work for all modern browsers and in environments
|
||||
which don't support WebSocket protcol, for example behind restrictive
|
||||
corporate proxies.
|
||||
|
||||
SockJS-client does require a server counterpart:
|
||||
|
||||
* [SockJS-node](https://github.com/sockjs/sockjs-node) is a SockJS
|
||||
server for Node.js.
|
||||
|
||||
|
||||
Philosophy:
|
||||
|
||||
* The API should follow
|
||||
[HTML5 Websockets API](http://dev.w3.org/html5/websockets/) as
|
||||
closely as possible.
|
||||
* All the transports must support cross domain connections out of the
|
||||
box. It's possible and recommended to host SockJS server on
|
||||
different server than your main web site.
|
||||
* There is a support for at least one streaming protocol for every
|
||||
major browser.
|
||||
* Streaming transports should work cross-domain and
|
||||
should support cookies (for cookie-based sticky sessions).
|
||||
* Polling transports are be used as a fallback for old browsers and
|
||||
hosts behind restrictive proxies.
|
||||
* Connection establishment should be fast and lightweight.
|
||||
* No Flash inside (no need to open port 843 - which doesn't work
|
||||
through proxies, no need to host 'crossdomain.xml', no need
|
||||
[to wait for 3 seconds](https://github.com/gimite/web-socket-js/issues/49)
|
||||
in order to detect problems)
|
||||
|
||||
|
||||
Subscribe to
|
||||
[SockJS mailing list](https://groups.google.com/forum/#!forum/sockjs) for
|
||||
discussions and support.
|
||||
|
||||
|
||||
Live QUnit tests and smoke tests
|
||||
--------------------------------
|
||||
|
||||
SockJS comes with some QUnit tests and a few smoke tests (using
|
||||
[SockJS-node](https://github.com/sockjs/sockjs-client) on the server
|
||||
side). At the moment they are deployed in few places:
|
||||
|
||||
* http://sockjs.popcnt.org/ and https://sockjs.popcnt.org/ (hosted in Europe)
|
||||
* http://sockjs.cloudfoundry.com/ (CloudFoundry, websockets disabled, loadbalanced)
|
||||
* https://sockjs.cloudfoundry.com/ (CloudFoundry SSL, websockets disabled, loadbalanced)
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
SockJS mimics [WebSockets API](http://dev.w3.org/html5/websockets/)
|
||||
but instead of `WebSocket` there is a `SockJS` Javascript object.
|
||||
|
||||
First, you need to load SockJS JavaScript library, for example you can
|
||||
put that in your http head:
|
||||
|
||||
<script src="http://cdn.sockjs.org/sockjs-0.3.min.js">
|
||||
</script>
|
||||
|
||||
After the script is loaded you can establish a connection with the
|
||||
SockJS server. Here's a simple example:
|
||||
|
||||
```javascript
|
||||
<script>
|
||||
var sock = new SockJS('http://mydomain.com/my_prefix');
|
||||
sock.onopen = function() {
|
||||
console.log('open');
|
||||
};
|
||||
sock.onmessage = function(e) {
|
||||
console.log('message', e.data);
|
||||
};
|
||||
sock.onclose = function() {
|
||||
console.log('close');
|
||||
};
|
||||
</script>
|
||||
```
|
||||
|
||||
SockJS-client API
|
||||
-----------------
|
||||
|
||||
### SockJS class
|
||||
|
||||
Similar to 'WebSocket' class 'SockJS' constructor takes one, or more arguments:
|
||||
|
||||
```javascript
|
||||
var sockjs = new SockJS(url, _reserved, options);
|
||||
```
|
||||
|
||||
Where `options` is a hash which can contain:
|
||||
|
||||
* **debug (boolean)**
|
||||
|
||||
Print some debugging messages using 'console.log'.
|
||||
|
||||
* **devel (boolean)**
|
||||
|
||||
Development mode. Currently setting it disables caching of the
|
||||
'iframe.html'.
|
||||
|
||||
* **protocols_whitelist (list of strings)**
|
||||
|
||||
Sometimes it is useful to disable some fallback protocols. This
|
||||
option allows you to supply a list protocols that may be used by
|
||||
SockJS. By default all available protocols will be used, which is
|
||||
equivalent to supplying: "['websocket', 'xdr-streaming', 'xhr-streaming',
|
||||
'iframe-eventsource', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling',
|
||||
'iframe-xhr-polling', 'jsonp-polling']"
|
||||
|
||||
|
||||
Although the 'SockJS' object tries to emulate the 'WebSocket'
|
||||
behaviour, it's impossible to support all features. One of the
|
||||
important SockJS limitations is the fact that you're not allowed to
|
||||
open more than one SockJS connection to a single domain at a time.
|
||||
This limitation is caused by a in-browser limit of outgoing
|
||||
connections - usually [browsers don't allow opening more than two
|
||||
outgoing connections to a single domain](http://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser). Single SockJS session
|
||||
requires those two connections - one for downloading data, other for
|
||||
sending messages. Opening second SockJS session at the same time
|
||||
would most probably block and can result in both sessions timing out.
|
||||
|
||||
Opening more than one SockJS connection at a time is generally a
|
||||
bad practice. If you absolutely must do it, you can use
|
||||
mutliple subdomains, using different subdomain for every
|
||||
SockJS connection.
|
||||
|
||||
Supported transports, by browser (html served from http:// or https://)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
_Browser_ | _Websockets_ | _Streaming_ | _Polling_
|
||||
----------------|------------------|-------------|-----------
|
||||
IE 6, 7 | no | no | jsonp-polling
|
||||
IE 8, 9 (cookies=no) | no | xdr-streaming † | xdr-polling †
|
||||
IE 8, 9 (cookies=yes)| no | iframe-htmlfile | iframe-xhr-polling
|
||||
IE 10 | rfc6455 | xhr-streaming | xhr-polling
|
||||
Chrome 6-13 | hixie-76 | xhr-streaming | xhr-polling
|
||||
Chrome 14+ | hybi-10 / rfc6455| xhr-streaming | xhr-polling
|
||||
Firefox <10 | no ‡ | xhr-streaming | xhr-polling
|
||||
Firefox 10+ | hybi-10 / rfc6455| xhr-streaming | xhr-polling
|
||||
Safari 5 | hixie-76 | xhr-streaming | xhr-polling
|
||||
Opera 10.70+ | no ‡ | iframe-eventsource | iframe-xhr-polling
|
||||
Konqueror | no | no | jsonp-polling
|
||||
|
||||
|
||||
* **†**: IE 8+ supports [XDomainRequest][^9], which is
|
||||
esentially a modified AJAX/XHR that can do requests across
|
||||
domains. But unfortunately it doesn't send any cookies, which
|
||||
makes it inaproppriate for deployments when the load balancer uses
|
||||
JSESSIONID cookie to do sticky sessions.
|
||||
|
||||
* **‡**: Firefox 4.0 and Opera 11.00 and shipped with disabled
|
||||
Websockets "hixie-76". They can still be enabled by manually
|
||||
changing a browser setting.
|
||||
|
||||
Supported transports, by browser (html served from file://)
|
||||
-----------------------------------------------------------
|
||||
|
||||
Sometimes you may want to serve your html from "file://" address - for
|
||||
development or if you're using PhoneGap or similar technologies. But
|
||||
due to the Cross Origin Policy files served from "file://" have no
|
||||
Origin, and that means some of SockJS transports won't work. For this
|
||||
reason the SockJS protocol table is different than usually, major
|
||||
differences are:
|
||||
|
||||
_Browser_ | _Websockets_ | _Streaming_ | _Polling_
|
||||
----------------|---------------|--------------------|-----------
|
||||
IE 8, 9 | same as above | iframe-htmlfile | iframe-xhr-polling
|
||||
Other | same as above | iframe-eventsource | iframe-xhr-polling
|
||||
|
||||
Supported transports, by name
|
||||
-----------------------------
|
||||
|
||||
_Transport_ | _References_
|
||||
---------------------|---------------
|
||||
websocket (rfc6455) | [rfc 6455][^10]
|
||||
websocket (hixie-76) | [draft-hixie-thewebsocketprotocol-76][^1]
|
||||
websocket (hybi-10) | [draft-ietf-hybi-thewebsocketprotocol-10][^2]
|
||||
xhr-streaming | Transport using [Cross domain XHR][^5] [streaming][^7] capability (readyState=3).
|
||||
xdr-streaming | Transport using [XDomainRequest][^9] [streaming][^7] capability (readyState=3).
|
||||
iframe-eventsource | [EventSource][^4] used from an [iframe via postMessage][^3].
|
||||
iframe-htmlfile | [HtmlFile][^8] used from an [iframe via postMessage][^3].
|
||||
xhr-polling | Long-polling using [cross domain XHR][^5].
|
||||
xdr-polling | Long-polling using [XDomainRequest][^9].
|
||||
iframe-xhr-polling | Long-polling using normal AJAX from an [iframe via postMessage][^3].
|
||||
jsonp-polling | Slow and old fashioned [JSONP polling][^6]. This transport will show "busy indicator" (aka: "spinning wheel") when sending data.
|
||||
|
||||
|
||||
[^1]: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
|
||||
[^2]: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
|
||||
[^3]: https://developer.mozilla.org/en/DOM/window.postMessage
|
||||
[^4]: http://dev.w3.org/html5/eventsource/
|
||||
[^5]: https://secure.wikimedia.org/wikipedia/en/wiki/XMLHttpRequest#Cross-domain_requests
|
||||
[^6]: https://secure.wikimedia.org/wikipedia/en/wiki/JSONP
|
||||
[^7]: http://www.debugtheweb.com/test/teststreaming.aspx
|
||||
[^8]: http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/
|
||||
[^9]: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
|
||||
[^10]: http://www.rfc-editor.org/rfc/rfc6455.txt
|
||||
|
||||
|
||||
Connecting to SockJS without the client
|
||||
---------------------------------------
|
||||
|
||||
Although the main point of SockJS it to enable browser-to-server
|
||||
connectivity, it is possible to connect to SockJS from an external
|
||||
application. Any SockJS server complying with 0.3 protocol does
|
||||
support a raw WebSocket url. The raw WebSocket url for the test server
|
||||
looks like:
|
||||
|
||||
* ws://localhost:8081/echo/websocket
|
||||
|
||||
You can connect any WebSocket RFC 6455 compliant WebSocket client to
|
||||
this url. This can be a command line client, external application,
|
||||
third party code or even a browser (though I don't know why you would
|
||||
want to do so).
|
||||
|
||||
|
||||
Deployment
|
||||
----------
|
||||
|
||||
In order to utilize best performance you should use the SockJS-client
|
||||
releases hosted on SockJS CDN. You should use a version of sockjs-client
|
||||
that supports the protocol used by your server. For example:
|
||||
|
||||
<script src="http://cdn.sockjs.org/sockjs-0.3.min.js">
|
||||
</script>
|
||||
|
||||
A list of files hosted on a CDN is available here: http://sockjs.github.com/sockjs-client/ .
|
||||
|
||||
You can also use or CDN via https (using Cloud Front domain name):
|
||||
|
||||
<script src="https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.js">
|
||||
</script>
|
||||
|
||||
For server-side deployment tricks, especially about load balancing and
|
||||
session stickiness, take a look at the
|
||||
[SockJS-node readme](https://github.com/sockjs/sockjs-node#readme).
|
||||
|
||||
|
||||
Development and testing
|
||||
-----------------------
|
||||
|
||||
SockJS-client needs [Node.js](http://nodejs.org/) for running a test
|
||||
server and JavaScript minification. If you want to work on
|
||||
SockJS-client source code, check out the git repo and follow this
|
||||
steps:
|
||||
|
||||
cd sockjs-client
|
||||
npm install --dev
|
||||
|
||||
To generate JavaScript run:
|
||||
|
||||
make sockjs.js
|
||||
|
||||
To generate minified JavaScript run:
|
||||
|
||||
make sockjs.min.js
|
||||
|
||||
(To generate both run `make build`.)
|
||||
|
||||
|
||||
### Testing
|
||||
|
||||
Once you compiled SockJS-client you may want to check if your changes
|
||||
pass all the tests. To run the tests you need a server that can answer
|
||||
various SockJS requests. A common way is to use `SockJS-node` test
|
||||
server for that. To run it (by default it will be listening on port 8081):
|
||||
|
||||
cd sockjs-node
|
||||
npm install --dev
|
||||
make build
|
||||
make test_server
|
||||
|
||||
At this point you're ready to run a SockJS-client server that will
|
||||
server your freshly compiled JavaScript and various static http and
|
||||
javscript files (by default it will run on port 8080).
|
||||
|
||||
cd sockjs-client
|
||||
make test
|
||||
|
||||
At that point you should have two web servers running: sockjs-node on
|
||||
8081 and sockjs-client on 8080. When you open the browser on
|
||||
[http://localhost:8080/](http://localhost:8080/) you should be able
|
||||
run the QUnit tests against your sockjs-node server.
|
||||
|
||||
If you look at your browser console you will see warnings like that:
|
||||
|
||||
Incompatibile SockJS! Main site uses: "a", the iframe: "b".
|
||||
|
||||
This is due to a fact that SockJS-node test server is using compiled
|
||||
javascript from CDN, rather than your freshly compiled version. To fix
|
||||
that you must amend `sockjs_url` that is used by SockJS-node test
|
||||
server. Edit the [`config.js`](https://github.com/sockjs/sockjs-node/blob/master/examples/test_server/config.js) file:
|
||||
|
||||
vim sockjs-node/examples/test_server/config.js
|
||||
|
||||
And replace `sockjs_url` setting which by default points to CDN:
|
||||
|
||||
sockjs_url: 'http://cdn.sockjs.org/sockjs-0.3.min.js',
|
||||
|
||||
to a freshly compiled sockjs, for example:
|
||||
|
||||
sockjs_url: 'http://localhost:8080/lib/sockjs.js',
|
||||
|
||||
|
||||
Also, if you want to run tests agains SockJS server not running on
|
||||
`localhost:8081` you may want to edit the
|
||||
[`tests/config.js`](https://github.com/sockjs/sockjs-client/blob/master/tests/config.js)
|
||||
file.
|
||||
|
||||
Additionally, if you're doing more serious development consider using
|
||||
`make serve`, which will automatically reload the server when you
|
||||
modify the source code.
|
||||
|
||||
|
||||
Browser Quirks
|
||||
--------------
|
||||
|
||||
There are various browser quirks which we don't intend to address:
|
||||
|
||||
* Pressing ESC in Firefox closes SockJS connection. For a workaround
|
||||
and discussion see [#18](https://github.com/sockjs/sockjs-client/issues/18).
|
||||
* Jsonp-polling transport will show a "spinning wheel" (aka. "busy indicator")
|
||||
when sending data.
|
||||
* You can't open more than one SockJS connection to one domain at the
|
||||
same time due to [the browsers limit of consurrent connections](http://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser)
|
||||
(this limit is not counting native websockets connections).
|
||||
* Although SockJS is trying to escape any strange Unicode characters
|
||||
(even invalid ones - [like surrogates \xD800-\xDBFF](http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates) or [\xFFFE and \xFFFF](https://en.wikipedia.org/wiki/Unicode#Character_General_Category))
|
||||
it's advisable to use only valid characters. Using invalid
|
||||
characters is a bit slower, and may not work with SockJS servers
|
||||
that have a proper Unicode support.
|
||||
* Having a global function called `onmessage` or such is probably a
|
||||
bad idea, as it could be called by the built-in `postMessage` API.
|
||||
* From SockJS point of view there is nothing special about
|
||||
SSL/HTTPS. Connecting between unencrypted and encrypted sites
|
||||
should work just fine.
|
||||
* Although SockJS does best to support both prefix and cookie based
|
||||
sticky sessions, the latter may not work well cross-domain with
|
||||
browsers that don't accept third-party cookies by default (Safari).
|
||||
In order to get around this make sure you're connecting to sockjs
|
||||
from the same parent domain as the main site. For example
|
||||
'sockjs.a.com' is able to set cookies if you're connecting from
|
||||
'www.a.com' or 'a.com'.
|
||||
* Trying to connect from secure "https://" to insecure "http://" is
|
||||
not good idea. The other way around should be fine.
|
||||
* Long polling is known to cause problems on Heroku, but
|
||||
[workaround for SockJS is available](https://github.com/sockjs/sockjs-node/issues/57#issuecomment-5242187).
|
17
node_modules/shoe/node_modules/sockjs-client/VERSION-GEN
generated
vendored
Normal file
17
node_modules/shoe/node_modules/sockjs-client/VERSION-GEN
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
LF='
|
||||
'
|
||||
|
||||
VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null)
|
||||
case "$VN" in
|
||||
*$LF*) (exit 1) ;;
|
||||
v[0-9]*)
|
||||
git update-index -q --refresh
|
||||
test -z "$(git diff-index --name-only HEAD --)" ||
|
||||
VN="$VN-dirty" ;;
|
||||
esac
|
||||
VN=$(echo "$VN" | sed -e 's/-/./g');
|
||||
VN=$(expr "$VN" : v*'\(.*\)')
|
||||
|
||||
echo "$VN"
|
111
node_modules/shoe/node_modules/sockjs-client/bin/render.coffee
generated
vendored
Normal file
111
node_modules/shoe/node_modules/sockjs-client/bin/render.coffee
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env coffee
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Copyright (c) 2011-2012 VMware, Inc.
|
||||
#
|
||||
# For the license see COPYING.
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
fs = require('fs')
|
||||
uglify = require('uglify-js')
|
||||
optparse = require('optparse')
|
||||
|
||||
array_flatten = (arr, acc) ->
|
||||
if typeof acc is 'undefined'
|
||||
acc = []
|
||||
if typeof arr is 'string'
|
||||
acc.push(arr)
|
||||
return acc
|
||||
|
||||
if arr.constructor isnt Array
|
||||
throw "Value is not an Array nor a String!"
|
||||
|
||||
for v in arr
|
||||
if typeof v is 'string'
|
||||
acc.push(v)
|
||||
else if v.constructor is Array
|
||||
array_flatten(v, acc)
|
||||
else
|
||||
throw "Value is not an Array nor a String!"
|
||||
return acc
|
||||
|
||||
stringify_unicode = (str) ->
|
||||
str = str.replace /[\u0100-\uffff]/g, (ch) ->
|
||||
return "\\u" + ('0000' + ch.charCodeAt(0).toString(16)).substr(-4)
|
||||
str = str.replace /[\x00-\x08\x0b-\x1f\x7f-\xff]/g, (ch) ->
|
||||
return "\\x" + ('00' + ch.charCodeAt(0).toString(16)).substr(-2)
|
||||
return str
|
||||
|
||||
|
||||
minify = (data, minify_options)->
|
||||
ast = uglify.parser.parse(data)
|
||||
ast = uglify.uglify.ast_mangle(ast, minify_options)
|
||||
ast = uglify.uglify.ast_squeeze(ast)
|
||||
uglify.uglify.gen_code(ast, minify_options)
|
||||
|
||||
render = (filename, depth, options) ->
|
||||
tags =
|
||||
include: (args) ->
|
||||
if (args.length > 1 and args[1].indexOf('c') isnt -1 and
|
||||
options.minify is false)
|
||||
options.comment = true
|
||||
render(args[0], depth + ' ', options)
|
||||
version: ->
|
||||
options.version
|
||||
include_and_minify: (args) ->
|
||||
if (args.length > 1 and args[1].indexOf('c') isnt -1 and
|
||||
options.minify is false)
|
||||
options.comment = true
|
||||
d = render(args[0], depth + ' ', options)
|
||||
if options.minify
|
||||
return minify(array_flatten(d).join(''), options)
|
||||
return d
|
||||
|
||||
console.warn(depth + " [.] Rendering", filename)
|
||||
|
||||
# no trailing whitespace
|
||||
data = fs.readFileSync(filename, encoding='utf8').replace(/\s+$/, '')
|
||||
|
||||
content = []
|
||||
if options.comment
|
||||
content.push('\n// ' + depth + '[*] Including ' + filename + '\n')
|
||||
|
||||
elements = data.split(/<!--\s*([^>]+)\s*-->/g)
|
||||
for i in [0...elements.length]
|
||||
e = elements[i];
|
||||
if i % 2 is 0
|
||||
content.push(e)
|
||||
else
|
||||
p = e.split(' ')
|
||||
content.push( tags[p[0]](p.slice(1)) )
|
||||
|
||||
if options.comment
|
||||
content.push('\n// ' + depth + '[*] End of ' + filename + '\n')
|
||||
return content
|
||||
|
||||
|
||||
main = ->
|
||||
switches = [
|
||||
['-p', '--pretty', 'Prettify javascript']
|
||||
['-m', '--minify', 'Minify javascript']
|
||||
['-s', '--set-version [VERSION]', 'Set the value of version tag']
|
||||
]
|
||||
options = {minify: false, toplevel: true, version: 'unknown'}
|
||||
parser = new optparse.OptionParser(switches)
|
||||
parser.on 'pretty', ->
|
||||
options.beautify = true
|
||||
parser.on 'minify', ->
|
||||
options.minify = true
|
||||
parser.on 'set-version', (_, version) ->
|
||||
options.version = version
|
||||
filenames = parser.parse((process.ARGV || process.argv).slice(2))
|
||||
|
||||
content = for filename in filenames
|
||||
render(filename, '', options)
|
||||
content.push('\n')
|
||||
process.stdout.write(
|
||||
stringify_unicode(array_flatten(content).join('')),
|
||||
'utf8')
|
||||
|
||||
main()
|
135
node_modules/shoe/node_modules/sockjs-client/bin/run_testling.sh
generated
vendored
Normal file
135
node_modules/shoe/node_modules/sockjs-client/bin/run_testling.sh
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
# Include a script with credentails:
|
||||
. .testling_env.sh
|
||||
# This script should set few Testling variables and should look more
|
||||
# or less like that:
|
||||
#
|
||||
# TESTLING_CRED=my@email.com:password
|
||||
# TUNNEL_PORT=12345
|
||||
# TUNNEL_USER=my_email_com
|
||||
#
|
||||
# First, you need to create browserling.com account. Set TESTLING_CRED
|
||||
# to email:password. Additionally, you must create a testling tunnel
|
||||
# using commands like that:
|
||||
#
|
||||
# curl -u $TESTLING_CRED "testling.com/tunnel" -sST ~/.ssh/id_rsa.pub
|
||||
# curl -u $TESTLING_CRED "testling.com/tunnel/open"
|
||||
#
|
||||
# After that set TUNNEL_PORT and TUNNEL_USER accordingly.
|
||||
#
|
||||
#
|
||||
|
||||
browsers=(
|
||||
# iexplore/6.0
|
||||
# iexplore/7.0
|
||||
# iexplore/8.0
|
||||
# iexplore/9.0
|
||||
# chrome/4.0
|
||||
# chrome/5.0
|
||||
# chrome/6.0
|
||||
# chrome/7.0
|
||||
# chrome/8.0
|
||||
# chrome/9.0
|
||||
# chrome/10.0
|
||||
# chrome/11.0
|
||||
# chrome/12.0
|
||||
# chrome/13.0
|
||||
# chrome/14.0
|
||||
# chrome/15.0
|
||||
chrome/canary
|
||||
# firefox/3.0
|
||||
# firefox/3.5
|
||||
# firefox/3.6
|
||||
# firefox/4.0
|
||||
# firefox/5.0
|
||||
# firefox/6.0
|
||||
# firefox/7.0
|
||||
# firefox/8.0
|
||||
# firefox/nightly
|
||||
# opera/10.0
|
||||
# opera/10.5
|
||||
# opera/11.0
|
||||
# opera/11.5
|
||||
# opera/next
|
||||
# safari/5.0.5
|
||||
# safari/5.1
|
||||
)
|
||||
|
||||
BROWSERS=`echo ${browsers[@]}|tr ' ' ','`
|
||||
|
||||
|
||||
if [ "$TESTLING_CRED" = "" ] || \
|
||||
[ "$TUNNEL_PORT" = "" ] || \
|
||||
[ "$TUNNEL_USER" = "" ]; then
|
||||
echo "Error: Please set following env variables: "\
|
||||
"TESTLING_CRED TUNNEL_PORT TUNNEL_USER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
PIDFILE=.sshpidfile.pid
|
||||
|
||||
if [ -e $PIDFILE ]; then
|
||||
kill `cat $PIDFILE`
|
||||
rm $PIDFILE
|
||||
fi
|
||||
|
||||
|
||||
|
||||
cat > testling.js << EOF
|
||||
var test = require('testling');
|
||||
test('Testling Test Runner', function (t) {
|
||||
t.createWindow('http://tunnel.browserling.com:$TUNNEL_PORT/unittests.html',
|
||||
function(win, jq) {
|
||||
jq(function() {
|
||||
if(typeof win.QUnit === 'undefined') {
|
||||
t.log("No QUnit object in the window!");
|
||||
t.end();
|
||||
} else {
|
||||
var q = win.QUnit;
|
||||
var module_name = '[unknown]';
|
||||
q.begin = function() {
|
||||
t.log(' [*] Start');
|
||||
};
|
||||
q.moduleStart = function(o) {
|
||||
module_name = o.name;
|
||||
};
|
||||
q.log = function(o) {
|
||||
var x = module_name + ': ' + o.message;
|
||||
t.ok(o.result, x);
|
||||
if(!o.result) {
|
||||
t.log(" [-] Failed: " + x);
|
||||
}
|
||||
};
|
||||
q.done = function(o) {
|
||||
t.log(' [*] Done ' + o.failed + ' ' + o.passed +
|
||||
' ' + o.total + ' ' + o.runtime);
|
||||
t.end();
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
// Dead man's switch
|
||||
setTimeout(function(){
|
||||
t.log("Emergency timeout ocurred");
|
||||
t.end();
|
||||
}, 5000);
|
||||
});
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
ssh -o "VerifyHostKeyDNS no" \
|
||||
-NR $TUNNEL_PORT:localhost:8080 $TUNNEL_USER@tunnel.browserling.com &
|
||||
SSHPID=$!
|
||||
echo $SSHPID > $PIDFILE
|
||||
|
||||
echo "[*] Running against: ${browsers[@]}"
|
||||
curl -u $TESTLING_CRED -sSNT testling.js \
|
||||
"testling.com/?browsers=$BROWSERS&noinstrument=test.js"
|
||||
|
||||
kill $SSHPID
|
||||
wait $SSHPID
|
||||
rm $PIDFILE
|
||||
|
||||
curl -sSNu $TESTLING_CRED "testling.com/browsers"|tail -n 1
|
9
node_modules/shoe/node_modules/sockjs-client/lib/all.js
generated
vendored
Normal file
9
node_modules/shoe/node_modules/sockjs-client/lib/all.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/* SockJS client, version <!-- version -->, http://sockjs.org, MIT License
|
||||
|
||||
<!-- include LICENSE-MIT-SockJS -->
|
||||
*/
|
||||
|
||||
// JSON2 by Douglas Crockford (minified).
|
||||
<!-- include lib/json2.min.js -->
|
||||
|
||||
<!-- include_and_minify lib/index.js c -->
|
205
node_modules/shoe/node_modules/sockjs-client/lib/dom.js
generated
vendored
Normal file
205
node_modules/shoe/node_modules/sockjs-client/lib/dom.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// May be used by htmlfile jsonp and transports.
|
||||
var MPrefix = '_sockjs_global';
|
||||
utils.createHook = function() {
|
||||
var window_id = 'a' + utils.random_string(8);
|
||||
if (!(MPrefix in _window)) {
|
||||
var map = {};
|
||||
_window[MPrefix] = function(window_id) {
|
||||
if (!(window_id in map)) {
|
||||
map[window_id] = {
|
||||
id: window_id,
|
||||
del: function() {delete map[window_id];}
|
||||
};
|
||||
}
|
||||
return map[window_id];
|
||||
}
|
||||
}
|
||||
return _window[MPrefix](window_id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
utils.attachMessage = function(listener) {
|
||||
utils.attachEvent('message', listener);
|
||||
};
|
||||
utils.attachEvent = function(event, listener) {
|
||||
if (typeof _window.addEventListener !== 'undefined') {
|
||||
_window.addEventListener(event, listener, false);
|
||||
} else {
|
||||
// IE quirks.
|
||||
// According to: http://stevesouders.com/misc/test-postmessage.php
|
||||
// the message gets delivered only to 'document', not 'window'.
|
||||
_document.attachEvent("on" + event, listener);
|
||||
// I get 'window' for ie8.
|
||||
_window.attachEvent("on" + event, listener);
|
||||
}
|
||||
};
|
||||
|
||||
utils.detachMessage = function(listener) {
|
||||
utils.detachEvent('message', listener);
|
||||
};
|
||||
utils.detachEvent = function(event, listener) {
|
||||
if (typeof _window.addEventListener !== 'undefined') {
|
||||
_window.removeEventListener(event, listener, false);
|
||||
} else {
|
||||
_document.detachEvent("on" + event, listener);
|
||||
_window.detachEvent("on" + event, listener);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var on_unload = {};
|
||||
// Things registered after beforeunload are to be called immediately.
|
||||
var after_unload = false;
|
||||
|
||||
var trigger_unload_callbacks = function() {
|
||||
for(var ref in on_unload) {
|
||||
on_unload[ref]();
|
||||
delete on_unload[ref];
|
||||
};
|
||||
};
|
||||
|
||||
var unload_triggered = function() {
|
||||
if(after_unload) return;
|
||||
after_unload = true;
|
||||
trigger_unload_callbacks();
|
||||
};
|
||||
|
||||
// Onbeforeunload alone is not reliable. We could use only 'unload'
|
||||
// but it's not working in opera within an iframe. Let's use both.
|
||||
utils.attachEvent('beforeunload', unload_triggered);
|
||||
utils.attachEvent('unload', unload_triggered);
|
||||
|
||||
utils.unload_add = function(listener) {
|
||||
var ref = utils.random_string(8);
|
||||
on_unload[ref] = listener;
|
||||
if (after_unload) {
|
||||
utils.delay(trigger_unload_callbacks);
|
||||
}
|
||||
return ref;
|
||||
};
|
||||
utils.unload_del = function(ref) {
|
||||
if (ref in on_unload)
|
||||
delete on_unload[ref];
|
||||
};
|
||||
|
||||
|
||||
utils.createIframe = function (iframe_url, error_callback) {
|
||||
var iframe = _document.createElement('iframe');
|
||||
var tref, unload_ref;
|
||||
var unattach = function() {
|
||||
clearTimeout(tref);
|
||||
// Explorer had problems with that.
|
||||
try {iframe.onload = null;} catch (x) {}
|
||||
iframe.onerror = null;
|
||||
};
|
||||
var cleanup = function() {
|
||||
if (iframe) {
|
||||
unattach();
|
||||
// This timeout makes chrome fire onbeforeunload event
|
||||
// within iframe. Without the timeout it goes straight to
|
||||
// onunload.
|
||||
setTimeout(function() {
|
||||
if(iframe) {
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
}
|
||||
iframe = null;
|
||||
}, 0);
|
||||
utils.unload_del(unload_ref);
|
||||
}
|
||||
};
|
||||
var onerror = function(r) {
|
||||
if (iframe) {
|
||||
cleanup();
|
||||
error_callback(r);
|
||||
}
|
||||
};
|
||||
var post = function(msg, origin) {
|
||||
try {
|
||||
// When the iframe is not loaded, IE raises an exception
|
||||
// on 'contentWindow'.
|
||||
if (iframe && iframe.contentWindow) {
|
||||
iframe.contentWindow.postMessage(msg, origin);
|
||||
}
|
||||
} catch (x) {};
|
||||
};
|
||||
|
||||
iframe.src = iframe_url;
|
||||
iframe.style.display = 'none';
|
||||
iframe.style.position = 'absolute';
|
||||
iframe.onerror = function(){onerror('onerror');};
|
||||
iframe.onload = function() {
|
||||
// `onload` is triggered before scripts on the iframe are
|
||||
// executed. Give it few seconds to actually load stuff.
|
||||
clearTimeout(tref);
|
||||
tref = setTimeout(function(){onerror('onload timeout');}, 2000);
|
||||
};
|
||||
_document.body.appendChild(iframe);
|
||||
tref = setTimeout(function(){onerror('timeout');}, 15000);
|
||||
unload_ref = utils.unload_add(cleanup);
|
||||
return {
|
||||
post: post,
|
||||
cleanup: cleanup,
|
||||
loaded: unattach
|
||||
};
|
||||
};
|
||||
|
||||
utils.createHtmlfile = function (iframe_url, error_callback) {
|
||||
var doc = new ActiveXObject('htmlfile');
|
||||
var tref, unload_ref;
|
||||
var iframe;
|
||||
var unattach = function() {
|
||||
clearTimeout(tref);
|
||||
};
|
||||
var cleanup = function() {
|
||||
if (doc) {
|
||||
unattach();
|
||||
utils.unload_del(unload_ref);
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
iframe = doc = null;
|
||||
CollectGarbage();
|
||||
}
|
||||
};
|
||||
var onerror = function(r) {
|
||||
if (doc) {
|
||||
cleanup();
|
||||
error_callback(r);
|
||||
}
|
||||
};
|
||||
var post = function(msg, origin) {
|
||||
try {
|
||||
// When the iframe is not loaded, IE raises an exception
|
||||
// on 'contentWindow'.
|
||||
if (iframe && iframe.contentWindow) {
|
||||
iframe.contentWindow.postMessage(msg, origin);
|
||||
}
|
||||
} catch (x) {};
|
||||
};
|
||||
|
||||
doc.open();
|
||||
doc.write('<html><s' + 'cript>' +
|
||||
'document.domain="' + document.domain + '";' +
|
||||
'</s' + 'cript></html>');
|
||||
doc.close();
|
||||
doc.parentWindow[WPrefix] = _window[WPrefix];
|
||||
var c = doc.createElement('div');
|
||||
doc.body.appendChild(c);
|
||||
iframe = doc.createElement('iframe');
|
||||
c.appendChild(iframe);
|
||||
iframe.src = iframe_url;
|
||||
tref = setTimeout(function(){onerror('timeout');}, 15000);
|
||||
unload_ref = utils.unload_add(cleanup);
|
||||
return {
|
||||
post: post,
|
||||
cleanup: cleanup,
|
||||
loaded: unattach
|
||||
};
|
||||
};
|
191
node_modules/shoe/node_modules/sockjs-client/lib/dom2.js
generated
vendored
Normal file
191
node_modules/shoe/node_modules/sockjs-client/lib/dom2.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var AbstractXHRObject = function(){};
|
||||
AbstractXHRObject.prototype = new EventEmitter(['chunk', 'finish']);
|
||||
|
||||
AbstractXHRObject.prototype._start = function(method, url, payload, opts) {
|
||||
var that = this;
|
||||
|
||||
try {
|
||||
that.xhr = new XMLHttpRequest();
|
||||
} catch(x) {};
|
||||
|
||||
if (!that.xhr) {
|
||||
try {
|
||||
that.xhr = new _window.ActiveXObject('Microsoft.XMLHTTP');
|
||||
} catch(x) {};
|
||||
}
|
||||
if (_window.ActiveXObject || _window.XDomainRequest) {
|
||||
// IE8 caches even POSTs
|
||||
url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);
|
||||
}
|
||||
|
||||
// Explorer tends to keep connection open, even after the
|
||||
// tab gets closed: http://bugs.jquery.com/ticket/5280
|
||||
that.unload_ref = utils.unload_add(function(){that._cleanup(true);});
|
||||
try {
|
||||
that.xhr.open(method, url, true);
|
||||
} catch(e) {
|
||||
// IE raises an exception on wrong port.
|
||||
that.emit('finish', 0, '');
|
||||
that._cleanup();
|
||||
return;
|
||||
};
|
||||
|
||||
if (!opts || !opts.no_credentials) {
|
||||
// Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :
|
||||
// "This never affects same-site requests."
|
||||
that.xhr.withCredentials = 'true';
|
||||
}
|
||||
if (opts && opts.headers) {
|
||||
for(var key in opts.headers) {
|
||||
that.xhr.setRequestHeader(key, opts.headers[key]);
|
||||
}
|
||||
}
|
||||
|
||||
that.xhr.onreadystatechange = function() {
|
||||
if (that.xhr) {
|
||||
var x = that.xhr;
|
||||
switch (x.readyState) {
|
||||
case 3:
|
||||
// IE doesn't like peeking into responseText or status
|
||||
// on Microsoft.XMLHTTP and readystate=3
|
||||
try {
|
||||
var status = x.status;
|
||||
var text = x.responseText;
|
||||
} catch (x) {};
|
||||
// IE does return readystate == 3 for 404 answers.
|
||||
if (text && text.length > 0) {
|
||||
that.emit('chunk', status, text);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
that.emit('finish', x.status, x.responseText);
|
||||
that._cleanup(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
that.xhr.send(payload);
|
||||
};
|
||||
|
||||
AbstractXHRObject.prototype._cleanup = function(abort) {
|
||||
var that = this;
|
||||
if (!that.xhr) return;
|
||||
utils.unload_del(that.unload_ref);
|
||||
|
||||
// IE needs this field to be a function
|
||||
that.xhr.onreadystatechange = function(){};
|
||||
|
||||
if (abort) {
|
||||
try {
|
||||
that.xhr.abort();
|
||||
} catch(x) {};
|
||||
}
|
||||
that.unload_ref = that.xhr = null;
|
||||
};
|
||||
|
||||
AbstractXHRObject.prototype.close = function() {
|
||||
var that = this;
|
||||
that.nuke();
|
||||
that._cleanup(true);
|
||||
};
|
||||
|
||||
var XHRCorsObject = utils.XHRCorsObject = function() {
|
||||
var that = this, args = arguments;
|
||||
utils.delay(function(){that._start.apply(that, args);});
|
||||
};
|
||||
XHRCorsObject.prototype = new AbstractXHRObject();
|
||||
|
||||
var XHRLocalObject = utils.XHRLocalObject = function(method, url, payload) {
|
||||
var that = this;
|
||||
utils.delay(function(){
|
||||
that._start(method, url, payload, {
|
||||
no_credentials: true
|
||||
});
|
||||
});
|
||||
};
|
||||
XHRLocalObject.prototype = new AbstractXHRObject();
|
||||
|
||||
|
||||
|
||||
// References:
|
||||
// http://ajaxian.com/archives/100-line-ajax-wrapper
|
||||
// http://msdn.microsoft.com/en-us/library/cc288060(v=VS.85).aspx
|
||||
var XDRObject = utils.XDRObject = function(method, url, payload) {
|
||||
var that = this;
|
||||
utils.delay(function(){that._start(method, url, payload);});
|
||||
};
|
||||
XDRObject.prototype = new EventEmitter(['chunk', 'finish']);
|
||||
XDRObject.prototype._start = function(method, url, payload) {
|
||||
var that = this;
|
||||
var xdr = new XDomainRequest();
|
||||
// IE caches even POSTs
|
||||
url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);
|
||||
|
||||
var onerror = xdr.ontimeout = xdr.onerror = function() {
|
||||
that.emit('finish', 0, '');
|
||||
that._cleanup(false);
|
||||
};
|
||||
xdr.onprogress = function() {
|
||||
that.emit('chunk', 200, xdr.responseText);
|
||||
};
|
||||
xdr.onload = function() {
|
||||
that.emit('finish', 200, xdr.responseText);
|
||||
that._cleanup(false);
|
||||
};
|
||||
that.xdr = xdr;
|
||||
that.unload_ref = utils.unload_add(function(){that._cleanup(true);});
|
||||
try {
|
||||
// Fails with AccessDenied if port number is bogus
|
||||
that.xdr.open(method, url);
|
||||
that.xdr.send(payload);
|
||||
} catch(x) {
|
||||
onerror();
|
||||
}
|
||||
};
|
||||
|
||||
XDRObject.prototype._cleanup = function(abort) {
|
||||
var that = this;
|
||||
if (!that.xdr) return;
|
||||
utils.unload_del(that.unload_ref);
|
||||
|
||||
that.xdr.ontimeout = that.xdr.onerror = that.xdr.onprogress =
|
||||
that.xdr.onload = null;
|
||||
if (abort) {
|
||||
try {
|
||||
that.xdr.abort();
|
||||
} catch(x) {};
|
||||
}
|
||||
that.unload_ref = that.xdr = null;
|
||||
};
|
||||
|
||||
XDRObject.prototype.close = function() {
|
||||
var that = this;
|
||||
that.nuke();
|
||||
that._cleanup(true);
|
||||
};
|
||||
|
||||
// 1. Is natively via XHR
|
||||
// 2. Is natively via XDR
|
||||
// 3. Nope, but postMessage is there so it should work via the Iframe.
|
||||
// 4. Nope, sorry.
|
||||
utils.isXHRCorsCapable = function() {
|
||||
if (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) {
|
||||
return 1;
|
||||
}
|
||||
// XDomainRequest doesn't work if page is served from file://
|
||||
if (_window.XDomainRequest && _document.domain) {
|
||||
return 2;
|
||||
}
|
||||
if (IframeTransport.enabled()) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
};
|
31
node_modules/shoe/node_modules/sockjs-client/lib/eventemitter.js
generated
vendored
Normal file
31
node_modules/shoe/node_modules/sockjs-client/lib/eventemitter.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var EventEmitter = function(events) {
|
||||
this.events = events || [];
|
||||
};
|
||||
EventEmitter.prototype.emit = function(type) {
|
||||
var that = this;
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (!that.nuked && that['on'+type]) {
|
||||
that['on'+type].apply(that, args);
|
||||
}
|
||||
if (utils.arrIndexOf(that.events, type) === -1) {
|
||||
utils.log('Event ' + JSON.stringify(type) +
|
||||
' not listed ' + JSON.stringify(that.events) +
|
||||
' in ' + that);
|
||||
}
|
||||
};
|
||||
|
||||
EventEmitter.prototype.nuke = function(type) {
|
||||
var that = this;
|
||||
that.nuked = true;
|
||||
for(var i=0; i<that.events.length; i++) {
|
||||
delete that[that.events[i]];
|
||||
}
|
||||
};
|
41
node_modules/shoe/node_modules/sockjs-client/lib/index.js
generated
vendored
Normal file
41
node_modules/shoe/node_modules/sockjs-client/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Public object
|
||||
var SockJS = (function(){
|
||||
var _document = document;
|
||||
var _window = window;
|
||||
var utils = {};
|
||||
|
||||
<!-- include lib/reventtarget.js -->
|
||||
<!-- include lib/simpleevent.js -->
|
||||
<!-- include lib/eventemitter.js -->
|
||||
<!-- include lib/utils.js -->
|
||||
<!-- include lib/dom.js -->
|
||||
<!-- include lib/dom2.js -->
|
||||
<!-- include lib/sockjs.js -->
|
||||
<!-- include lib/trans-websocket.js -->
|
||||
<!-- include lib/trans-sender.js -->
|
||||
<!-- include lib/trans-jsonp-receiver.js -->
|
||||
<!-- include lib/trans-jsonp-polling.js -->
|
||||
<!-- include lib/trans-xhr.js -->
|
||||
<!-- include lib/trans-iframe.js -->
|
||||
<!-- include lib/trans-iframe-within.js -->
|
||||
<!-- include lib/info.js -->
|
||||
<!-- include lib/trans-iframe-eventsource.js -->
|
||||
<!-- include lib/trans-iframe-xhr-polling.js -->
|
||||
<!-- include lib/trans-iframe-htmlfile.js -->
|
||||
<!-- include lib/trans-polling.js -->
|
||||
<!-- include lib/trans-receiver-eventsource.js -->
|
||||
<!-- include lib/trans-receiver-htmlfile.js -->
|
||||
<!-- include lib/trans-receiver-xhr.js -->
|
||||
<!-- include lib/test-hooks.js -->
|
||||
return SockJS;
|
||||
})();
|
||||
if ('_sockjs_onload' in window) setTimeout(_sockjs_onload, 1);
|
||||
|
||||
// AMD compliance
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('sockjs', [], function(){return SockJS;});
|
||||
}
|
||||
|
||||
if (typeof module === 'object' && module && module.exports) {
|
||||
module.exports = SockJS;
|
||||
}
|
114
node_modules/shoe/node_modules/sockjs-client/lib/info.js
generated
vendored
Normal file
114
node_modules/shoe/node_modules/sockjs-client/lib/info.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var InfoReceiver = function(base_url, AjaxObject) {
|
||||
var that = this;
|
||||
utils.delay(function(){that.doXhr(base_url, AjaxObject);});
|
||||
};
|
||||
|
||||
InfoReceiver.prototype = new EventEmitter(['finish']);
|
||||
|
||||
InfoReceiver.prototype.doXhr = function(base_url, AjaxObject) {
|
||||
var that = this;
|
||||
var t0 = (new Date()).getTime();
|
||||
var xo = new AjaxObject('GET', base_url + '/info');
|
||||
|
||||
var tref = utils.delay(8000,
|
||||
function(){xo.ontimeout();});
|
||||
|
||||
xo.onfinish = function(status, text) {
|
||||
clearTimeout(tref);
|
||||
tref = null;
|
||||
if (status === 200) {
|
||||
var rtt = (new Date()).getTime() - t0;
|
||||
var info = JSON.parse(text);
|
||||
if (typeof info !== 'object') info = {};
|
||||
that.emit('finish', info, rtt);
|
||||
} else {
|
||||
that.emit('finish');
|
||||
}
|
||||
};
|
||||
xo.ontimeout = function() {
|
||||
xo.close();
|
||||
that.emit('finish');
|
||||
};
|
||||
};
|
||||
|
||||
var InfoReceiverIframe = function(base_url) {
|
||||
var that = this;
|
||||
var go = function() {
|
||||
var ifr = new IframeTransport();
|
||||
ifr.protocol = 'w-iframe-info-receiver';
|
||||
var fun = function(r) {
|
||||
if (typeof r === 'string' && r.substr(0,1) === 'm') {
|
||||
var d = JSON.parse(r.substr(1));
|
||||
var info = d[0], rtt = d[1];
|
||||
that.emit('finish', info, rtt);
|
||||
} else {
|
||||
that.emit('finish');
|
||||
}
|
||||
ifr.doCleanup();
|
||||
ifr = null;
|
||||
};
|
||||
var mock_ri = {
|
||||
_options: {},
|
||||
_didClose: fun,
|
||||
_didMessage: fun
|
||||
};
|
||||
ifr.i_constructor(mock_ri, base_url, base_url);
|
||||
}
|
||||
if(!_document.body) {
|
||||
utils.attachEvent('load', go);
|
||||
} else {
|
||||
go();
|
||||
}
|
||||
};
|
||||
InfoReceiverIframe.prototype = new EventEmitter(['finish']);
|
||||
|
||||
|
||||
var InfoReceiverFake = function() {
|
||||
// It may not be possible to do cross domain AJAX to get the info
|
||||
// data, for example for IE7. But we want to run JSONP, so let's
|
||||
// fake the response, with rtt=2s (rto=6s).
|
||||
var that = this;
|
||||
utils.delay(function() {
|
||||
that.emit('finish', {}, 2000);
|
||||
});
|
||||
};
|
||||
InfoReceiverFake.prototype = new EventEmitter(['finish']);
|
||||
|
||||
var createInfoReceiver = function(base_url) {
|
||||
if (utils.isSameOriginUrl(base_url)) {
|
||||
// If, for some reason, we have SockJS locally - there's no
|
||||
// need to start up the complex machinery. Just use ajax.
|
||||
return new InfoReceiver(base_url, utils.XHRLocalObject);
|
||||
}
|
||||
switch (utils.isXHRCorsCapable()) {
|
||||
case 1:
|
||||
return new InfoReceiver(base_url, utils.XHRCorsObject);
|
||||
case 2:
|
||||
return new InfoReceiver(base_url, utils.XDRObject);
|
||||
case 3:
|
||||
// Opera
|
||||
return new InfoReceiverIframe(base_url);
|
||||
default:
|
||||
// IE 7
|
||||
return new InfoReceiverFake();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
var WInfoReceiverIframe = FacadeJS['w-iframe-info-receiver'] = function(ri, _trans_url, base_url) {
|
||||
var ir = new InfoReceiver(base_url, utils.XHRLocalObject);
|
||||
ir.onfinish = function(info, rtt) {
|
||||
ri._didMessage('m'+JSON.stringify([info, rtt]));
|
||||
ri._didClose();
|
||||
}
|
||||
};
|
||||
WInfoReceiverIframe.prototype.doCleanup = function() {};
|
||||
|
1
node_modules/shoe/node_modules/sockjs-client/lib/json2.min.js
generated
vendored
Normal file
1
node_modules/shoe/node_modules/sockjs-client/lib/json2.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")})}()
|
55
node_modules/shoe/node_modules/sockjs-client/lib/reventtarget.js
generated
vendored
Normal file
55
node_modules/shoe/node_modules/sockjs-client/lib/reventtarget.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/* Simplified implementation of DOM2 EventTarget.
|
||||
* http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget
|
||||
*/
|
||||
var REventTarget = function() {};
|
||||
REventTarget.prototype.addEventListener = function (eventType, listener) {
|
||||
if(!this._listeners) {
|
||||
this._listeners = {};
|
||||
}
|
||||
if(!(eventType in this._listeners)) {
|
||||
this._listeners[eventType] = [];
|
||||
}
|
||||
var arr = this._listeners[eventType];
|
||||
if(utils.arrIndexOf(arr, listener) === -1) {
|
||||
arr.push(listener);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
REventTarget.prototype.removeEventListener = function (eventType, listener) {
|
||||
if(!(this._listeners && (eventType in this._listeners))) {
|
||||
return;
|
||||
}
|
||||
var arr = this._listeners[eventType];
|
||||
var idx = utils.arrIndexOf(arr, listener);
|
||||
if (idx !== -1) {
|
||||
if(arr.length > 1) {
|
||||
this._listeners[eventType] = arr.slice(0, idx).concat( arr.slice(idx+1) );
|
||||
} else {
|
||||
delete this._listeners[eventType];
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
REventTarget.prototype.dispatchEvent = function (event) {
|
||||
var t = event.type;
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
if (this['on'+t]) {
|
||||
this['on'+t].apply(this, args);
|
||||
}
|
||||
if (this._listeners && t in this._listeners) {
|
||||
for(var i=0; i < this._listeners[t].length; i++) {
|
||||
this._listeners[t][i].apply(this, args);
|
||||
}
|
||||
}
|
||||
};
|
28
node_modules/shoe/node_modules/sockjs-client/lib/simpleevent.js
generated
vendored
Normal file
28
node_modules/shoe/node_modules/sockjs-client/lib/simpleevent.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var SimpleEvent = function(type, obj) {
|
||||
this.type = type;
|
||||
if (typeof obj !== 'undefined') {
|
||||
for(var k in obj) {
|
||||
if (!obj.hasOwnProperty(k)) continue;
|
||||
this[k] = obj[k];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SimpleEvent.prototype.toString = function() {
|
||||
var r = [];
|
||||
for(var k in this) {
|
||||
if (!this.hasOwnProperty(k)) continue;
|
||||
var v = this[k];
|
||||
if (typeof v === 'function') v = '[function]';
|
||||
r.push(k + '=' + v);
|
||||
}
|
||||
return 'SimpleEvent(' + r.join(', ') + ')';
|
||||
};
|
261
node_modules/shoe/node_modules/sockjs-client/lib/sockjs.js
generated
vendored
Normal file
261
node_modules/shoe/node_modules/sockjs-client/lib/sockjs.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var SockJS = function(url, dep_protocols_whitelist, options) {
|
||||
if (this === window) {
|
||||
// makes `new` optional
|
||||
return new SockJS(url, dep_protocols_whitelist, options);
|
||||
}
|
||||
|
||||
var that = this, protocols_whitelist;
|
||||
that._options = {devel: false, debug: false, protocols_whitelist: [],
|
||||
info: undefined, rtt: undefined};
|
||||
if (options) {
|
||||
utils.objectExtend(that._options, options);
|
||||
}
|
||||
that._base_url = utils.amendUrl(url);
|
||||
that._server = that._options.server || utils.random_number_string(1000);
|
||||
if (that._options.protocols_whitelist &&
|
||||
that._options.protocols_whitelist.length) {
|
||||
protocols_whitelist = that._options.protocols_whitelist;
|
||||
} else {
|
||||
// Deprecated API
|
||||
if (typeof dep_protocols_whitelist === 'string' &&
|
||||
dep_protocols_whitelist.length > 0) {
|
||||
protocols_whitelist = [dep_protocols_whitelist];
|
||||
} else if (utils.isArray(dep_protocols_whitelist)) {
|
||||
protocols_whitelist = dep_protocols_whitelist
|
||||
} else {
|
||||
protocols_whitelist = null;
|
||||
}
|
||||
if (protocols_whitelist) {
|
||||
that._debug('Deprecated API: Use "protocols_whitelist" option ' +
|
||||
'instead of supplying protocol list as a second ' +
|
||||
'parameter to SockJS constructor.');
|
||||
}
|
||||
}
|
||||
that._protocols = [];
|
||||
that.protocol = null;
|
||||
that.readyState = SockJS.CONNECTING;
|
||||
that._ir = createInfoReceiver(that._base_url);
|
||||
that._ir.onfinish = function(info, rtt) {
|
||||
that._ir = null;
|
||||
if (info) {
|
||||
if (that._options.info) {
|
||||
// Override if user supplies the option
|
||||
info = utils.objectExtend(info, that._options.info);
|
||||
}
|
||||
if (that._options.rtt) {
|
||||
rtt = that._options.rtt;
|
||||
}
|
||||
that._applyInfo(info, rtt, protocols_whitelist);
|
||||
that._didClose();
|
||||
} else {
|
||||
that._didClose(1002, 'Can\'t connect to server', true);
|
||||
}
|
||||
};
|
||||
};
|
||||
// Inheritance
|
||||
SockJS.prototype = new REventTarget();
|
||||
|
||||
SockJS.version = "<!-- version -->";
|
||||
|
||||
SockJS.CONNECTING = 0;
|
||||
SockJS.OPEN = 1;
|
||||
SockJS.CLOSING = 2;
|
||||
SockJS.CLOSED = 3;
|
||||
|
||||
SockJS.prototype._debug = function() {
|
||||
if (this._options.debug)
|
||||
utils.log.apply(utils, arguments);
|
||||
};
|
||||
|
||||
SockJS.prototype._dispatchOpen = function() {
|
||||
var that = this;
|
||||
if (that.readyState === SockJS.CONNECTING) {
|
||||
if (that._transport_tref) {
|
||||
clearTimeout(that._transport_tref);
|
||||
that._transport_tref = null;
|
||||
}
|
||||
that.readyState = SockJS.OPEN;
|
||||
that.dispatchEvent(new SimpleEvent("open"));
|
||||
} else {
|
||||
// The server might have been restarted, and lost track of our
|
||||
// connection.
|
||||
that._didClose(1006, "Server lost session");
|
||||
}
|
||||
};
|
||||
|
||||
SockJS.prototype._dispatchMessage = function(data) {
|
||||
var that = this;
|
||||
if (that.readyState !== SockJS.OPEN)
|
||||
return;
|
||||
that.dispatchEvent(new SimpleEvent("message", {data: data}));
|
||||
};
|
||||
|
||||
SockJS.prototype._dispatchHeartbeat = function(data) {
|
||||
var that = this;
|
||||
if (that.readyState !== SockJS.OPEN)
|
||||
return;
|
||||
that.dispatchEvent(new SimpleEvent('heartbeat', {}));
|
||||
};
|
||||
|
||||
SockJS.prototype._didClose = function(code, reason, force) {
|
||||
var that = this;
|
||||
if (that.readyState !== SockJS.CONNECTING &&
|
||||
that.readyState !== SockJS.OPEN &&
|
||||
that.readyState !== SockJS.CLOSING)
|
||||
throw new Error('INVALID_STATE_ERR');
|
||||
if (that._ir) {
|
||||
that._ir.nuke();
|
||||
that._ir = null;
|
||||
}
|
||||
|
||||
if (that._transport) {
|
||||
that._transport.doCleanup();
|
||||
that._transport = null;
|
||||
}
|
||||
|
||||
var close_event = new SimpleEvent("close", {
|
||||
code: code,
|
||||
reason: reason,
|
||||
wasClean: utils.userSetCode(code)});
|
||||
|
||||
if (!utils.userSetCode(code) &&
|
||||
that.readyState === SockJS.CONNECTING && !force) {
|
||||
if (that._try_next_protocol(close_event)) {
|
||||
return;
|
||||
}
|
||||
close_event = new SimpleEvent("close", {code: 2000,
|
||||
reason: "All transports failed",
|
||||
wasClean: false,
|
||||
last_event: close_event});
|
||||
}
|
||||
that.readyState = SockJS.CLOSED;
|
||||
|
||||
utils.delay(function() {
|
||||
that.dispatchEvent(close_event);
|
||||
});
|
||||
};
|
||||
|
||||
SockJS.prototype._didMessage = function(data) {
|
||||
var that = this;
|
||||
var type = data.slice(0, 1);
|
||||
switch(type) {
|
||||
case 'o':
|
||||
that._dispatchOpen();
|
||||
break;
|
||||
case 'a':
|
||||
var payload = JSON.parse(data.slice(1) || '[]');
|
||||
for(var i=0; i < payload.length; i++){
|
||||
that._dispatchMessage(payload[i]);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
var payload = JSON.parse(data.slice(1) || 'null');
|
||||
that._dispatchMessage(payload);
|
||||
break;
|
||||
case 'c':
|
||||
var payload = JSON.parse(data.slice(1) || '[]');
|
||||
that._didClose(payload[0], payload[1]);
|
||||
break;
|
||||
case 'h':
|
||||
that._dispatchHeartbeat();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
SockJS.prototype._try_next_protocol = function(close_event) {
|
||||
var that = this;
|
||||
if (that.protocol) {
|
||||
that._debug('Closed transport:', that.protocol, ''+close_event);
|
||||
that.protocol = null;
|
||||
}
|
||||
if (that._transport_tref) {
|
||||
clearTimeout(that._transport_tref);
|
||||
that._transport_tref = null;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
var protocol = that.protocol = that._protocols.shift();
|
||||
if (!protocol) {
|
||||
return false;
|
||||
}
|
||||
// Some protocols require access to `body`, what if were in
|
||||
// the `head`?
|
||||
if (SockJS[protocol] &&
|
||||
SockJS[protocol].need_body === true &&
|
||||
(!_document.body ||
|
||||
(typeof _document.readyState !== 'undefined'
|
||||
&& _document.readyState !== 'complete'))) {
|
||||
that._protocols.unshift(protocol);
|
||||
that.protocol = 'waiting-for-load';
|
||||
utils.attachEvent('load', function(){
|
||||
that._try_next_protocol();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SockJS[protocol] ||
|
||||
!SockJS[protocol].enabled(that._options)) {
|
||||
that._debug('Skipping transport:', protocol);
|
||||
} else {
|
||||
var roundTrips = SockJS[protocol].roundTrips || 1;
|
||||
var to = ((that._options.rto || 0) * roundTrips) || 5000;
|
||||
that._transport_tref = utils.delay(to, function() {
|
||||
if (that.readyState === SockJS.CONNECTING) {
|
||||
// I can't understand how it is possible to run
|
||||
// this timer, when the state is CLOSED, but
|
||||
// apparently in IE everythin is possible.
|
||||
that._didClose(2007, "Transport timeouted");
|
||||
}
|
||||
});
|
||||
|
||||
var connid = utils.random_string(8);
|
||||
var trans_url = that._base_url + '/' + that._server + '/' + connid;
|
||||
that._debug('Opening transport:', protocol, ' url:'+trans_url,
|
||||
' RTO:'+that._options.rto);
|
||||
that._transport = new SockJS[protocol](that, trans_url,
|
||||
that._base_url);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SockJS.prototype.close = function(code, reason) {
|
||||
var that = this;
|
||||
if (code && !utils.userSetCode(code))
|
||||
throw new Error("INVALID_ACCESS_ERR");
|
||||
if(that.readyState !== SockJS.CONNECTING &&
|
||||
that.readyState !== SockJS.OPEN) {
|
||||
return false;
|
||||
}
|
||||
that.readyState = SockJS.CLOSING;
|
||||
that._didClose(code || 1000, reason || "Normal closure");
|
||||
return true;
|
||||
};
|
||||
|
||||
SockJS.prototype.send = function(data) {
|
||||
var that = this;
|
||||
if (that.readyState === SockJS.CONNECTING)
|
||||
throw new Error('INVALID_STATE_ERR');
|
||||
if (that.readyState === SockJS.OPEN) {
|
||||
that._transport.doSend(utils.quote('' + data));
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
SockJS.prototype._applyInfo = function(info, rtt, protocols_whitelist) {
|
||||
var that = this;
|
||||
that._options.info = info;
|
||||
that._options.rtt = rtt;
|
||||
that._options.rto = utils.countRTO(rtt);
|
||||
that._options.info.null_origin = !_document.domain;
|
||||
var probed = utils.probeProtocols();
|
||||
that._protocols = utils.detectProtocols(probed, protocols_whitelist, info);
|
||||
};
|
16
node_modules/shoe/node_modules/sockjs-client/lib/test-hooks.js
generated
vendored
Normal file
16
node_modules/shoe/node_modules/sockjs-client/lib/test-hooks.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// For testing
|
||||
SockJS.getUtils = function(){
|
||||
return utils;
|
||||
};
|
||||
|
||||
SockJS.getIframeTransport = function(){
|
||||
return IframeTransport;
|
||||
};
|
29
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-eventsource.js
generated
vendored
Normal file
29
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-eventsource.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var EventSourceIframeTransport = SockJS['iframe-eventsource'] = function () {
|
||||
var that = this;
|
||||
that.protocol = 'w-iframe-eventsource';
|
||||
that.i_constructor.apply(that, arguments);
|
||||
};
|
||||
|
||||
EventSourceIframeTransport.prototype = new IframeTransport();
|
||||
|
||||
EventSourceIframeTransport.enabled = function () {
|
||||
return ('EventSource' in _window) && IframeTransport.enabled();
|
||||
};
|
||||
|
||||
EventSourceIframeTransport.need_body = true;
|
||||
EventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource
|
||||
|
||||
|
||||
// w-iframe-eventsource
|
||||
var EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/eventsource', EventSourceReceiver, utils.XHRLocalObject);
|
||||
}
|
||||
EventSourceTransport.prototype = new AjaxBasedTransport();
|
35
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-htmlfile.js
generated
vendored
Normal file
35
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-htmlfile.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// This transport generally works in any browser, but will cause a
|
||||
// spinning cursor to appear in any browser other than IE.
|
||||
// We may test this transport in all browsers - why not, but in
|
||||
// production it should be only run in IE.
|
||||
|
||||
var HtmlFileIframeTransport = SockJS['iframe-htmlfile'] = function () {
|
||||
var that = this;
|
||||
that.protocol = 'w-iframe-htmlfile';
|
||||
that.i_constructor.apply(that, arguments);
|
||||
};
|
||||
|
||||
// Inheritance.
|
||||
HtmlFileIframeTransport.prototype = new IframeTransport();
|
||||
|
||||
HtmlFileIframeTransport.enabled = function() {
|
||||
return IframeTransport.enabled();
|
||||
};
|
||||
|
||||
HtmlFileIframeTransport.need_body = true;
|
||||
HtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile
|
||||
|
||||
|
||||
// w-iframe-htmlfile
|
||||
var HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, utils.XHRLocalObject);
|
||||
};
|
||||
HtmlFileTransport.prototype = new AjaxBasedTransport();
|
94
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-within.js
generated
vendored
Normal file
94
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-within.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var curr_window_id;
|
||||
|
||||
var postMessage = function (type, data) {
|
||||
if(parent !== _window) {
|
||||
parent.postMessage(curr_window_id + type + (data || ''), '*');
|
||||
} else {
|
||||
utils.log("Can't postMessage, no parent window.", type, data);
|
||||
}
|
||||
};
|
||||
|
||||
var FacadeJS = function() {};
|
||||
FacadeJS.prototype._didClose = function (code, reason) {
|
||||
postMessage('t', utils.closeFrame(code, reason));
|
||||
};
|
||||
FacadeJS.prototype._didMessage = function (frame) {
|
||||
postMessage('t', frame);
|
||||
};
|
||||
FacadeJS.prototype._doSend = function (data) {
|
||||
this._transport.doSend(data);
|
||||
};
|
||||
FacadeJS.prototype._doCleanup = function () {
|
||||
this._transport.doCleanup();
|
||||
};
|
||||
|
||||
utils.parent_origin = undefined;
|
||||
|
||||
SockJS.bootstrap_iframe = function() {
|
||||
var facade;
|
||||
curr_window_id = _document.location.hash.slice(1);
|
||||
var onMessage = function(e) {
|
||||
if(e.source !== parent) return;
|
||||
if(typeof utils.parent_origin === 'undefined')
|
||||
utils.parent_origin = e.origin;
|
||||
if (e.origin !== utils.parent_origin) return;
|
||||
|
||||
var window_id = e.data.slice(0, 8);
|
||||
var type = e.data.slice(8, 9);
|
||||
var data = e.data.slice(9);
|
||||
if (window_id !== curr_window_id) return;
|
||||
switch(type) {
|
||||
case 's':
|
||||
var p = JSON.parse(data);
|
||||
var version = p[0];
|
||||
var protocol = p[1];
|
||||
var trans_url = p[2];
|
||||
var base_url = p[3];
|
||||
if (version !== SockJS.version) {
|
||||
utils.log("Incompatibile SockJS! Main site uses:" +
|
||||
" \"" + version + "\", the iframe:" +
|
||||
" \"" + SockJS.version + "\".");
|
||||
}
|
||||
if (!utils.flatUrl(trans_url) || !utils.flatUrl(base_url)) {
|
||||
utils.log("Only basic urls are supported in SockJS");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!utils.isSameOriginUrl(trans_url) ||
|
||||
!utils.isSameOriginUrl(base_url)) {
|
||||
utils.log("Can't connect to different domain from within an " +
|
||||
"iframe. (" + JSON.stringify([_window.location.href, trans_url, base_url]) +
|
||||
")");
|
||||
return;
|
||||
}
|
||||
facade = new FacadeJS();
|
||||
facade._transport = new FacadeJS[protocol](facade, trans_url, base_url);
|
||||
break;
|
||||
case 'm':
|
||||
facade._doSend(data);
|
||||
break;
|
||||
case 'c':
|
||||
if (facade)
|
||||
facade._doCleanup();
|
||||
facade = null;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// alert('test ticker');
|
||||
// facade = new FacadeJS();
|
||||
// facade._transport = new FacadeJS['w-iframe-xhr-polling'](facade, 'http://host.com:9999/ticker/12/basd');
|
||||
|
||||
utils.attachMessage(onMessage);
|
||||
|
||||
// Start
|
||||
postMessage('s');
|
||||
};
|
30
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-xhr-polling.js
generated
vendored
Normal file
30
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-xhr-polling.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var XhrPollingIframeTransport = SockJS['iframe-xhr-polling'] = function () {
|
||||
var that = this;
|
||||
that.protocol = 'w-iframe-xhr-polling';
|
||||
that.i_constructor.apply(that, arguments);
|
||||
};
|
||||
|
||||
XhrPollingIframeTransport.prototype = new IframeTransport();
|
||||
|
||||
XhrPollingIframeTransport.enabled = function () {
|
||||
return _window.XMLHttpRequest && IframeTransport.enabled();
|
||||
};
|
||||
|
||||
XhrPollingIframeTransport.need_body = true;
|
||||
XhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr
|
||||
|
||||
|
||||
// w-iframe-xhr-polling
|
||||
var XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRLocalObject);
|
||||
};
|
||||
|
||||
XhrPollingITransport.prototype = new AjaxBasedTransport();
|
93
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe.js
generated
vendored
Normal file
93
node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// Few cool transports do work only for same-origin. In order to make
|
||||
// them working cross-domain we shall use iframe, served form the
|
||||
// remote domain. New browsers, have capabilities to communicate with
|
||||
// cross domain iframe, using postMessage(). In IE it was implemented
|
||||
// from IE 8+, but of course, IE got some details wrong:
|
||||
// http://msdn.microsoft.com/en-us/library/cc197015(v=VS.85).aspx
|
||||
// http://stevesouders.com/misc/test-postmessage.php
|
||||
|
||||
var IframeTransport = function() {};
|
||||
|
||||
IframeTransport.prototype.i_constructor = function(ri, trans_url, base_url) {
|
||||
var that = this;
|
||||
that.ri = ri;
|
||||
that.origin = utils.getOrigin(base_url);
|
||||
that.base_url = base_url;
|
||||
that.trans_url = trans_url;
|
||||
|
||||
var iframe_url = base_url + '/iframe.html';
|
||||
if (that.ri._options.devel) {
|
||||
iframe_url += '?t=' + (+new Date);
|
||||
}
|
||||
that.window_id = utils.random_string(8);
|
||||
iframe_url += '#' + that.window_id;
|
||||
|
||||
that.iframeObj = utils.createIframe(iframe_url, function(r) {
|
||||
that.ri._didClose(1006, "Unable to load an iframe (" + r + ")");
|
||||
});
|
||||
|
||||
that.onmessage_cb = utils.bind(that.onmessage, that);
|
||||
utils.attachMessage(that.onmessage_cb);
|
||||
};
|
||||
|
||||
IframeTransport.prototype.doCleanup = function() {
|
||||
var that = this;
|
||||
if (that.iframeObj) {
|
||||
utils.detachMessage(that.onmessage_cb);
|
||||
try {
|
||||
// When the iframe is not loaded, IE raises an exception
|
||||
// on 'contentWindow'.
|
||||
if (that.iframeObj.iframe.contentWindow) {
|
||||
that.postMessage('c');
|
||||
}
|
||||
} catch (x) {}
|
||||
that.iframeObj.cleanup();
|
||||
that.iframeObj = null;
|
||||
that.onmessage_cb = that.iframeObj = null;
|
||||
}
|
||||
};
|
||||
|
||||
IframeTransport.prototype.onmessage = function(e) {
|
||||
var that = this;
|
||||
if (e.origin !== that.origin) return;
|
||||
var window_id = e.data.slice(0, 8);
|
||||
var type = e.data.slice(8, 9);
|
||||
var data = e.data.slice(9);
|
||||
|
||||
if (window_id !== that.window_id) return;
|
||||
|
||||
switch(type) {
|
||||
case 's':
|
||||
that.iframeObj.loaded();
|
||||
that.postMessage('s', JSON.stringify([SockJS.version, that.protocol, that.trans_url, that.base_url]));
|
||||
break;
|
||||
case 't':
|
||||
that.ri._didMessage(data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
IframeTransport.prototype.postMessage = function(type, data) {
|
||||
var that = this;
|
||||
that.iframeObj.post(that.window_id + type + (data || ''), that.origin);
|
||||
};
|
||||
|
||||
IframeTransport.prototype.doSend = function (message) {
|
||||
this.postMessage('m', message);
|
||||
};
|
||||
|
||||
IframeTransport.enabled = function() {
|
||||
// postMessage misbehaves in konqueror 4.6.5 - the messages are delivered with
|
||||
// huge delay, or not at all.
|
||||
var konqueror = navigator && navigator.userAgent && navigator.userAgent.indexOf('Konqueror') !== -1;
|
||||
return ((typeof _window.postMessage === 'function' ||
|
||||
typeof _window.postMessage === 'object') && (!konqueror));
|
||||
};
|
85
node_modules/shoe/node_modules/sockjs-client/lib/trans-jsonp-polling.js
generated
vendored
Normal file
85
node_modules/shoe/node_modules/sockjs-client/lib/trans-jsonp-polling.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// The simplest and most robust transport, using the well-know cross
|
||||
// domain hack - JSONP. This transport is quite inefficient - one
|
||||
// mssage could use up to one http request. But at least it works almost
|
||||
// everywhere.
|
||||
// Known limitations:
|
||||
// o you will get a spinning cursor
|
||||
// o for Konqueror a dumb timer is needed to detect errors
|
||||
|
||||
|
||||
var JsonPTransport = SockJS['jsonp-polling'] = function(ri, trans_url) {
|
||||
utils.polluteGlobalNamespace();
|
||||
var that = this;
|
||||
that.ri = ri;
|
||||
that.trans_url = trans_url;
|
||||
that.send_constructor(jsonPGenericSender);
|
||||
that._schedule_recv();
|
||||
};
|
||||
|
||||
// Inheritnace
|
||||
JsonPTransport.prototype = new BufferedSender();
|
||||
|
||||
JsonPTransport.prototype._schedule_recv = function() {
|
||||
var that = this;
|
||||
var callback = function(data) {
|
||||
that._recv_stop = null;
|
||||
if (data) {
|
||||
// no data - heartbeat;
|
||||
if (!that._is_closing) {
|
||||
that.ri._didMessage(data);
|
||||
}
|
||||
}
|
||||
// The message can be a close message, and change is_closing state.
|
||||
if (!that._is_closing) {
|
||||
that._schedule_recv();
|
||||
}
|
||||
};
|
||||
that._recv_stop = jsonPReceiverWrapper(that.trans_url + '/jsonp',
|
||||
jsonPGenericReceiver, callback);
|
||||
};
|
||||
|
||||
JsonPTransport.enabled = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
JsonPTransport.need_body = true;
|
||||
|
||||
|
||||
JsonPTransport.prototype.doCleanup = function() {
|
||||
var that = this;
|
||||
that._is_closing = true;
|
||||
if (that._recv_stop) {
|
||||
that._recv_stop();
|
||||
}
|
||||
that.ri = that._recv_stop = null;
|
||||
that.send_destructor();
|
||||
};
|
||||
|
||||
|
||||
// Abstract away code that handles global namespace pollution.
|
||||
var jsonPReceiverWrapper = function(url, constructReceiver, user_callback) {
|
||||
var id = 'a' + utils.random_string(6);
|
||||
var url_id = url + '?c=' + escape(WPrefix + '.' + id);
|
||||
// Callback will be called exactly once.
|
||||
var callback = function(frame) {
|
||||
delete _window[WPrefix][id];
|
||||
user_callback(frame);
|
||||
};
|
||||
|
||||
var close_script = constructReceiver(url_id, callback);
|
||||
_window[WPrefix][id] = close_script;
|
||||
var stop = function() {
|
||||
if (_window[WPrefix][id]) {
|
||||
_window[WPrefix][id](utils.closeFrame(1000, "JSONP user aborted read"));
|
||||
}
|
||||
};
|
||||
return stop;
|
||||
};
|
114
node_modules/shoe/node_modules/sockjs-client/lib/trans-jsonp-receiver.js
generated
vendored
Normal file
114
node_modules/shoe/node_modules/sockjs-client/lib/trans-jsonp-receiver.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
// Parts derived from Socket.io:
|
||||
// https://github.com/LearnBoost/socket.io/blob/0.6.17/lib/socket.io/transports/jsonp-polling.js
|
||||
// and jQuery-JSONP:
|
||||
// https://code.google.com/p/jquery-jsonp/source/browse/trunk/core/jquery.jsonp.js
|
||||
var jsonPGenericReceiver = function(url, callback) {
|
||||
var tref;
|
||||
var script = _document.createElement('script');
|
||||
var script2; // Opera synchronous load trick.
|
||||
var close_script = function(frame) {
|
||||
if (script2) {
|
||||
script2.parentNode.removeChild(script2);
|
||||
script2 = null;
|
||||
}
|
||||
if (script) {
|
||||
clearTimeout(tref);
|
||||
script.parentNode.removeChild(script);
|
||||
script.onreadystatechange = script.onerror =
|
||||
script.onload = script.onclick = null;
|
||||
script = null;
|
||||
callback(frame);
|
||||
callback = null;
|
||||
}
|
||||
};
|
||||
|
||||
// IE9 fires 'error' event after orsc or before, in random order.
|
||||
var loaded_okay = false;
|
||||
var error_timer = null;
|
||||
|
||||
script.id = 'a' + utils.random_string(8);
|
||||
script.src = url;
|
||||
script.type = 'text/javascript';
|
||||
script.charset = 'UTF-8';
|
||||
script.onerror = function(e) {
|
||||
if (!error_timer) {
|
||||
// Delay firing close_script.
|
||||
error_timer = setTimeout(function() {
|
||||
if (!loaded_okay) {
|
||||
close_script(utils.closeFrame(
|
||||
1006,
|
||||
"JSONP script loaded abnormally (onerror)"));
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
script.onload = function(e) {
|
||||
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (onload)"));
|
||||
};
|
||||
|
||||
script.onreadystatechange = function(e) {
|
||||
if (/loaded|closed/.test(script.readyState)) {
|
||||
if (script && script.htmlFor && script.onclick) {
|
||||
loaded_okay = true;
|
||||
try {
|
||||
// In IE, actually execute the script.
|
||||
script.onclick();
|
||||
} catch (x) {}
|
||||
}
|
||||
if (script) {
|
||||
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (onreadystatechange)"));
|
||||
}
|
||||
}
|
||||
};
|
||||
// IE: event/htmlFor/onclick trick.
|
||||
// One can't rely on proper order for onreadystatechange. In order to
|
||||
// make sure, set a 'htmlFor' and 'event' properties, so that
|
||||
// script code will be installed as 'onclick' handler for the
|
||||
// script object. Later, onreadystatechange, manually execute this
|
||||
// code. FF and Chrome doesn't work with 'event' and 'htmlFor'
|
||||
// set. For reference see:
|
||||
// http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html
|
||||
// Also, read on that about script ordering:
|
||||
// http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
|
||||
if (typeof script.async === 'undefined' && _document.attachEvent) {
|
||||
// According to mozilla docs, in recent browsers script.async defaults
|
||||
// to 'true', so we may use it to detect a good browser:
|
||||
// https://developer.mozilla.org/en/HTML/Element/script
|
||||
if (!/opera/i.test(navigator.userAgent)) {
|
||||
// Naively assume we're in IE
|
||||
try {
|
||||
script.htmlFor = script.id;
|
||||
script.event = "onclick";
|
||||
} catch (x) {}
|
||||
script.async = true;
|
||||
} else {
|
||||
// Opera, second sync script hack
|
||||
script2 = _document.createElement('script');
|
||||
script2.text = "try{var a = document.getElementById('"+script.id+"'); if(a)a.onerror();}catch(x){};";
|
||||
script.async = script2.async = false;
|
||||
}
|
||||
}
|
||||
if (typeof script.async !== 'undefined') {
|
||||
script.async = true;
|
||||
}
|
||||
|
||||
// Fallback mostly for Konqueror - stupid timer, 35 seconds shall be plenty.
|
||||
tref = setTimeout(function() {
|
||||
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (timeout)"));
|
||||
}, 35000);
|
||||
|
||||
var head = _document.getElementsByTagName('head')[0];
|
||||
head.insertBefore(script, head.firstChild);
|
||||
if (script2) {
|
||||
head.insertBefore(script2, head.firstChild);
|
||||
}
|
||||
return close_script;
|
||||
};
|
44
node_modules/shoe/node_modules/sockjs-client/lib/trans-polling.js
generated
vendored
Normal file
44
node_modules/shoe/node_modules/sockjs-client/lib/trans-polling.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var Polling = function(ri, Receiver, recv_url, AjaxObject) {
|
||||
var that = this;
|
||||
that.ri = ri;
|
||||
that.Receiver = Receiver;
|
||||
that.recv_url = recv_url;
|
||||
that.AjaxObject = AjaxObject;
|
||||
that._scheduleRecv();
|
||||
};
|
||||
|
||||
Polling.prototype._scheduleRecv = function() {
|
||||
var that = this;
|
||||
var poll = that.poll = new that.Receiver(that.recv_url, that.AjaxObject);
|
||||
var msg_counter = 0;
|
||||
poll.onmessage = function(e) {
|
||||
msg_counter += 1;
|
||||
that.ri._didMessage(e.data);
|
||||
};
|
||||
poll.onclose = function(e) {
|
||||
that.poll = poll = poll.onmessage = poll.onclose = null;
|
||||
if (!that.poll_is_closing) {
|
||||
if (e.reason === 'permanent') {
|
||||
that.ri._didClose(1006, 'Polling error (' + e.reason + ')');
|
||||
} else {
|
||||
that._scheduleRecv();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Polling.prototype.abort = function() {
|
||||
var that = this;
|
||||
that.poll_is_closing = true;
|
||||
if (that.poll) {
|
||||
that.poll.abort();
|
||||
}
|
||||
};
|
41
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-eventsource.js
generated
vendored
Normal file
41
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-eventsource.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var EventSourceReceiver = function(url) {
|
||||
var that = this;
|
||||
var es = new EventSource(url);
|
||||
es.onmessage = function(e) {
|
||||
that.dispatchEvent(new SimpleEvent('message',
|
||||
{'data': unescape(e.data)}));
|
||||
};
|
||||
that.es_close = es.onerror = function(e, abort_reason) {
|
||||
// ES on reconnection has readyState = 0 or 1.
|
||||
// on network error it's CLOSED = 2
|
||||
var reason = abort_reason ? 'user' :
|
||||
(es.readyState !== 2 ? 'network' : 'permanent');
|
||||
that.es_close = es.onmessage = es.onerror = null;
|
||||
// EventSource reconnects automatically.
|
||||
es.close();
|
||||
es = null;
|
||||
// Safari and chrome < 15 crash if we close window before
|
||||
// waiting for ES cleanup. See:
|
||||
// https://code.google.com/p/chromium/issues/detail?id=89155
|
||||
utils.delay(200, function() {
|
||||
that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
EventSourceReceiver.prototype = new REventTarget();
|
||||
|
||||
EventSourceReceiver.prototype.abort = function() {
|
||||
var that = this;
|
||||
if (that.es_close) {
|
||||
that.es_close({}, true);
|
||||
}
|
||||
};
|
65
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-htmlfile.js
generated
vendored
Normal file
65
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-htmlfile.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var _is_ie_htmlfile_capable;
|
||||
var isIeHtmlfileCapable = function() {
|
||||
if (_is_ie_htmlfile_capable === undefined) {
|
||||
if ('ActiveXObject' in _window) {
|
||||
try {
|
||||
_is_ie_htmlfile_capable = !!new ActiveXObject('htmlfile');
|
||||
} catch (x) {}
|
||||
} else {
|
||||
_is_ie_htmlfile_capable = false;
|
||||
}
|
||||
}
|
||||
return _is_ie_htmlfile_capable;
|
||||
};
|
||||
|
||||
|
||||
var HtmlfileReceiver = function(url) {
|
||||
var that = this;
|
||||
utils.polluteGlobalNamespace();
|
||||
|
||||
that.id = 'a' + utils.random_string(6, 26);
|
||||
url += ((url.indexOf('?') === -1) ? '?' : '&') +
|
||||
'c=' + escape(WPrefix + '.' + that.id);
|
||||
|
||||
var constructor = isIeHtmlfileCapable() ?
|
||||
utils.createHtmlfile : utils.createIframe;
|
||||
|
||||
var iframeObj;
|
||||
_window[WPrefix][that.id] = {
|
||||
start: function () {
|
||||
iframeObj.loaded();
|
||||
},
|
||||
message: function (data) {
|
||||
that.dispatchEvent(new SimpleEvent('message', {'data': data}));
|
||||
},
|
||||
stop: function () {
|
||||
that.iframe_close({}, 'network');
|
||||
}
|
||||
};
|
||||
that.iframe_close = function(e, abort_reason) {
|
||||
iframeObj.cleanup();
|
||||
that.iframe_close = iframeObj = null;
|
||||
delete _window[WPrefix][that.id];
|
||||
that.dispatchEvent(new SimpleEvent('close', {reason: abort_reason}));
|
||||
};
|
||||
iframeObj = constructor(url, function(e) {
|
||||
that.iframe_close({}, 'permanent');
|
||||
});
|
||||
};
|
||||
|
||||
HtmlfileReceiver.prototype = new REventTarget();
|
||||
|
||||
HtmlfileReceiver.prototype.abort = function() {
|
||||
var that = this;
|
||||
if (that.iframe_close) {
|
||||
that.iframe_close({}, 'user');
|
||||
}
|
||||
};
|
42
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-xhr.js
generated
vendored
Normal file
42
node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-xhr.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var XhrReceiver = function(url, AjaxObject) {
|
||||
var that = this;
|
||||
var buf_pos = 0;
|
||||
|
||||
that.xo = new AjaxObject('POST', url, null);
|
||||
that.xo.onchunk = function(status, text) {
|
||||
if (status !== 200) return;
|
||||
while (1) {
|
||||
var buf = text.slice(buf_pos);
|
||||
var p = buf.indexOf('\n');
|
||||
if (p === -1) break;
|
||||
buf_pos += p+1;
|
||||
var msg = buf.slice(0, p);
|
||||
that.dispatchEvent(new SimpleEvent('message', {data: msg}));
|
||||
}
|
||||
};
|
||||
that.xo.onfinish = function(status, text) {
|
||||
that.xo.onchunk(status, text);
|
||||
that.xo = null;
|
||||
var reason = status === 200 ? 'network' : 'permanent';
|
||||
that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
|
||||
}
|
||||
};
|
||||
|
||||
XhrReceiver.prototype = new REventTarget();
|
||||
|
||||
XhrReceiver.prototype.abort = function() {
|
||||
var that = this;
|
||||
if (that.xo) {
|
||||
that.xo.close();
|
||||
that.dispatchEvent(new SimpleEvent('close', {reason: 'user'}));
|
||||
that.xo = null;
|
||||
}
|
||||
};
|
135
node_modules/shoe/node_modules/sockjs-client/lib/trans-sender.js
generated
vendored
Normal file
135
node_modules/shoe/node_modules/sockjs-client/lib/trans-sender.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var BufferedSender = function() {};
|
||||
BufferedSender.prototype.send_constructor = function(sender) {
|
||||
var that = this;
|
||||
that.send_buffer = [];
|
||||
that.sender = sender;
|
||||
};
|
||||
BufferedSender.prototype.doSend = function(message) {
|
||||
var that = this;
|
||||
that.send_buffer.push(message);
|
||||
if (!that.send_stop) {
|
||||
that.send_schedule();
|
||||
}
|
||||
};
|
||||
|
||||
// For polling transports in a situation when in the message callback,
|
||||
// new message is being send. If the sending connection was started
|
||||
// before receiving one, it is possible to saturate the network and
|
||||
// timeout due to the lack of receiving socket. To avoid that we delay
|
||||
// sending messages by some small time, in order to let receiving
|
||||
// connection be started beforehand. This is only a halfmeasure and
|
||||
// does not fix the big problem, but it does make the tests go more
|
||||
// stable on slow networks.
|
||||
BufferedSender.prototype.send_schedule_wait = function() {
|
||||
var that = this;
|
||||
var tref;
|
||||
that.send_stop = function() {
|
||||
that.send_stop = null;
|
||||
clearTimeout(tref);
|
||||
};
|
||||
tref = utils.delay(25, function() {
|
||||
that.send_stop = null;
|
||||
that.send_schedule();
|
||||
});
|
||||
};
|
||||
|
||||
BufferedSender.prototype.send_schedule = function() {
|
||||
var that = this;
|
||||
if (that.send_buffer.length > 0) {
|
||||
var payload = '[' + that.send_buffer.join(',') + ']';
|
||||
that.send_stop = that.sender(that.trans_url,
|
||||
payload,
|
||||
function() {
|
||||
that.send_stop = null;
|
||||
that.send_schedule_wait();
|
||||
});
|
||||
that.send_buffer = [];
|
||||
}
|
||||
};
|
||||
|
||||
BufferedSender.prototype.send_destructor = function() {
|
||||
var that = this;
|
||||
if (that._send_stop) {
|
||||
that._send_stop();
|
||||
}
|
||||
that._send_stop = null;
|
||||
};
|
||||
|
||||
var jsonPGenericSender = function(url, payload, callback) {
|
||||
var that = this;
|
||||
|
||||
if (!('_send_form' in that)) {
|
||||
var form = that._send_form = _document.createElement('form');
|
||||
var area = that._send_area = _document.createElement('textarea');
|
||||
area.name = 'd';
|
||||
form.style.display = 'none';
|
||||
form.style.position = 'absolute';
|
||||
form.method = 'POST';
|
||||
form.enctype = 'application/x-www-form-urlencoded';
|
||||
form.acceptCharset = "UTF-8";
|
||||
form.appendChild(area);
|
||||
_document.body.appendChild(form);
|
||||
}
|
||||
var form = that._send_form;
|
||||
var area = that._send_area;
|
||||
var id = 'a' + utils.random_string(8);
|
||||
form.target = id;
|
||||
form.action = url + '/jsonp_send?i=' + id;
|
||||
|
||||
var iframe;
|
||||
try {
|
||||
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
|
||||
iframe = _document.createElement('<iframe name="'+ id +'">');
|
||||
} catch(x) {
|
||||
iframe = _document.createElement('iframe');
|
||||
iframe.name = id;
|
||||
}
|
||||
iframe.id = id;
|
||||
form.appendChild(iframe);
|
||||
iframe.style.display = 'none';
|
||||
|
||||
try {
|
||||
area.value = payload;
|
||||
} catch(e) {
|
||||
utils.log('Your browser is seriously broken. Go home! ' + e.message);
|
||||
}
|
||||
form.submit();
|
||||
|
||||
var completed = function(e) {
|
||||
if (!iframe.onerror) return;
|
||||
iframe.onreadystatechange = iframe.onerror = iframe.onload = null;
|
||||
// Opera mini doesn't like if we GC iframe
|
||||
// immediately, thus this timeout.
|
||||
utils.delay(500, function() {
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
iframe = null;
|
||||
});
|
||||
area.value = '';
|
||||
callback();
|
||||
};
|
||||
iframe.onerror = iframe.onload = completed;
|
||||
iframe.onreadystatechange = function(e) {
|
||||
if (iframe.readyState == 'complete') completed();
|
||||
};
|
||||
return completed;
|
||||
};
|
||||
|
||||
var createAjaxSender = function(AjaxObject) {
|
||||
return function(url, payload, callback) {
|
||||
var xo = new AjaxObject('POST', url + '/xhr_send', payload);
|
||||
xo.onfinish = function(status, text) {
|
||||
callback(status);
|
||||
};
|
||||
return function(abort_reason) {
|
||||
callback(0, abort_reason);
|
||||
};
|
||||
};
|
||||
};
|
60
node_modules/shoe/node_modules/sockjs-client/lib/trans-websocket.js
generated
vendored
Normal file
60
node_modules/shoe/node_modules/sockjs-client/lib/trans-websocket.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var WebSocketTransport = SockJS.websocket = function(ri, trans_url) {
|
||||
var that = this;
|
||||
var url = trans_url + '/websocket';
|
||||
if (url.slice(0, 5) === 'https') {
|
||||
url = 'wss' + url.slice(5);
|
||||
} else {
|
||||
url = 'ws' + url.slice(4);
|
||||
}
|
||||
that.ri = ri;
|
||||
that.url = url;
|
||||
var Constructor = _window.WebSocket || _window.MozWebSocket;
|
||||
|
||||
that.ws = new Constructor(that.url);
|
||||
that.ws.onmessage = function(e) {
|
||||
that.ri._didMessage(e.data);
|
||||
};
|
||||
// Firefox has an interesting bug. If a websocket connection is
|
||||
// created after onbeforeunload, it stays alive even when user
|
||||
// navigates away from the page. In such situation let's lie -
|
||||
// let's not open the ws connection at all. See:
|
||||
// https://github.com/sockjs/sockjs-client/issues/28
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=696085
|
||||
that.unload_ref = utils.unload_add(function(){that.ws.close()});
|
||||
that.ws.onclose = function() {
|
||||
that.ri._didMessage(utils.closeFrame(1006, "WebSocket connection broken"));
|
||||
};
|
||||
};
|
||||
|
||||
WebSocketTransport.prototype.doSend = function(data) {
|
||||
this.ws.send('[' + data + ']');
|
||||
};
|
||||
|
||||
WebSocketTransport.prototype.doCleanup = function() {
|
||||
var that = this;
|
||||
var ws = that.ws;
|
||||
if (ws) {
|
||||
ws.onmessage = ws.onclose = null;
|
||||
ws.close();
|
||||
utils.unload_del(that.unload_ref);
|
||||
that.unload_ref = that.ri = that.ws = null;
|
||||
}
|
||||
};
|
||||
|
||||
WebSocketTransport.enabled = function() {
|
||||
return !!(_window.WebSocket || _window.MozWebSocket);
|
||||
};
|
||||
|
||||
// In theory, ws should require 1 round trip. But in chrome, this is
|
||||
// not very stable over SSL. Most likely a ws connection requires a
|
||||
// separate SSL connection, in which case 2 round trips are an
|
||||
// absolute minumum.
|
||||
WebSocketTransport.roundTrips = 2;
|
89
node_modules/shoe/node_modules/sockjs-client/lib/trans-xhr.js
generated
vendored
Normal file
89
node_modules/shoe/node_modules/sockjs-client/lib/trans-xhr.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var AjaxBasedTransport = function() {};
|
||||
AjaxBasedTransport.prototype = new BufferedSender();
|
||||
|
||||
AjaxBasedTransport.prototype.run = function(ri, trans_url,
|
||||
url_suffix, Receiver, AjaxObject) {
|
||||
var that = this;
|
||||
that.ri = ri;
|
||||
that.trans_url = trans_url;
|
||||
that.send_constructor(createAjaxSender(AjaxObject));
|
||||
that.poll = new Polling(ri, Receiver,
|
||||
trans_url + url_suffix, AjaxObject);
|
||||
};
|
||||
|
||||
AjaxBasedTransport.prototype.doCleanup = function() {
|
||||
var that = this;
|
||||
if (that.poll) {
|
||||
that.poll.abort();
|
||||
that.poll = null;
|
||||
}
|
||||
};
|
||||
|
||||
// xhr-streaming
|
||||
var XhrStreamingTransport = SockJS['xhr-streaming'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject);
|
||||
};
|
||||
|
||||
XhrStreamingTransport.prototype = new AjaxBasedTransport();
|
||||
|
||||
XhrStreamingTransport.enabled = function() {
|
||||
// Support for CORS Ajax aka Ajax2? Opera 12 claims CORS but
|
||||
// doesn't do streaming.
|
||||
return (_window.XMLHttpRequest &&
|
||||
'withCredentials' in new XMLHttpRequest() &&
|
||||
(!/opera/i.test(navigator.userAgent)));
|
||||
};
|
||||
XhrStreamingTransport.roundTrips = 2; // preflight, ajax
|
||||
|
||||
// Safari gets confused when a streaming ajax request is started
|
||||
// before onload. This causes the load indicator to spin indefinetely.
|
||||
XhrStreamingTransport.need_body = true;
|
||||
|
||||
|
||||
// According to:
|
||||
// http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests
|
||||
// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
|
||||
|
||||
|
||||
// xdr-streaming
|
||||
var XdrStreamingTransport = SockJS['xdr-streaming'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XDRObject);
|
||||
};
|
||||
|
||||
XdrStreamingTransport.prototype = new AjaxBasedTransport();
|
||||
|
||||
XdrStreamingTransport.enabled = function() {
|
||||
return !!_window.XDomainRequest;
|
||||
};
|
||||
XdrStreamingTransport.roundTrips = 2; // preflight, ajax
|
||||
|
||||
|
||||
|
||||
// xhr-polling
|
||||
var XhrPollingTransport = SockJS['xhr-polling'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRCorsObject);
|
||||
};
|
||||
|
||||
XhrPollingTransport.prototype = new AjaxBasedTransport();
|
||||
|
||||
XhrPollingTransport.enabled = XhrStreamingTransport.enabled;
|
||||
XhrPollingTransport.roundTrips = 2; // preflight, ajax
|
||||
|
||||
|
||||
// xdr-polling
|
||||
var XdrPollingTransport = SockJS['xdr-polling'] = function(ri, trans_url) {
|
||||
this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XDRObject);
|
||||
};
|
||||
|
||||
XdrPollingTransport.prototype = new AjaxBasedTransport();
|
||||
|
||||
XdrPollingTransport.enabled = XdrStreamingTransport.enabled;
|
||||
XdrPollingTransport.roundTrips = 2; // preflight, ajax
|
325
node_modules/shoe/node_modules/sockjs-client/lib/utils.js
generated
vendored
Normal file
325
node_modules/shoe/node_modules/sockjs-client/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Copyright (c) 2011-2012 VMware, Inc.
|
||||
*
|
||||
* For the license see COPYING.
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
var random_string_chars = 'abcdefghijklmnopqrstuvwxyz0123456789_';
|
||||
utils.random_string = function(length, max) {
|
||||
max = max || random_string_chars.length;
|
||||
var i, ret = [];
|
||||
for(i=0; i < length; i++) {
|
||||
ret.push( random_string_chars.substr(Math.floor(Math.random() * max),1) );
|
||||
}
|
||||
return ret.join('');
|
||||
};
|
||||
utils.random_number = function(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
};
|
||||
utils.random_number_string = function(max) {
|
||||
var t = (''+(max - 1)).length;
|
||||
var p = Array(t+1).join('0');
|
||||
return (p + utils.random_number(max)).slice(-t);
|
||||
};
|
||||
|
||||
// Assuming that url looks like: http://asdasd:111/asd
|
||||
utils.getOrigin = function(url) {
|
||||
url += '/';
|
||||
var parts = url.split('/').slice(0, 3);
|
||||
return parts.join('/');
|
||||
};
|
||||
|
||||
utils.isSameOriginUrl = function(url_a, url_b) {
|
||||
// location.origin would do, but it's not always available.
|
||||
if (!url_b) url_b = _window.location.href;
|
||||
|
||||
return (url_a.split('/').slice(0,3).join('/')
|
||||
===
|
||||
url_b.split('/').slice(0,3).join('/'));
|
||||
};
|
||||
|
||||
utils.getParentDomain = function(url) {
|
||||
// ipv4 ip address
|
||||
if (/^[0-9.]*$/.test(url)) return url;
|
||||
// ipv6 ip address
|
||||
if (/^\[/.test(url)) return url;
|
||||
// no dots
|
||||
if (!(/[.]/.test(url))) return url;
|
||||
|
||||
var parts = url.split('.').slice(1);
|
||||
return parts.join('.');
|
||||
};
|
||||
|
||||
utils.objectExtend = function(dst, src) {
|
||||
for(var k in src) {
|
||||
if (src.hasOwnProperty(k)) {
|
||||
dst[k] = src[k];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
};
|
||||
|
||||
var WPrefix = '_jp';
|
||||
|
||||
utils.polluteGlobalNamespace = function() {
|
||||
if (!(WPrefix in _window)) {
|
||||
_window[WPrefix] = {};
|
||||
}
|
||||
};
|
||||
|
||||
utils.closeFrame = function (code, reason) {
|
||||
return 'c'+JSON.stringify([code, reason]);
|
||||
};
|
||||
|
||||
utils.userSetCode = function (code) {
|
||||
return code === 1000 || (code >= 3000 && code <= 4999);
|
||||
};
|
||||
|
||||
// See: http://www.erg.abdn.ac.uk/~gerrit/dccp/notes/ccid2/rto_estimator/
|
||||
// and RFC 2988.
|
||||
utils.countRTO = function (rtt) {
|
||||
var rto;
|
||||
if (rtt > 100) {
|
||||
rto = 3 * rtt; // rto > 300msec
|
||||
} else {
|
||||
rto = rtt + 200; // 200msec < rto <= 300msec
|
||||
}
|
||||
return rto;
|
||||
}
|
||||
|
||||
utils.log = function() {
|
||||
if (_window.console && console.log && console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
utils.bind = function(fun, that) {
|
||||
if (fun.bind) {
|
||||
return fun.bind(that);
|
||||
} else {
|
||||
return function() {
|
||||
return fun.apply(that, arguments);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
utils.flatUrl = function(url) {
|
||||
return url.indexOf('?') === -1 && url.indexOf('#') === -1;
|
||||
};
|
||||
|
||||
utils.amendUrl = function(url) {
|
||||
var dl = _document.location;
|
||||
if (!url) {
|
||||
throw new Error('Wrong url for SockJS');
|
||||
}
|
||||
if (!utils.flatUrl(url)) {
|
||||
throw new Error('Only basic urls are supported in SockJS');
|
||||
}
|
||||
|
||||
// '//abc' --> 'http://abc'
|
||||
if (url.indexOf('//') === 0) {
|
||||
url = dl.protocol + url;
|
||||
}
|
||||
// '/abc' --> 'http://localhost:80/abc'
|
||||
if (url.indexOf('/') === 0) {
|
||||
url = dl.protocol + '//' + dl.host + url;
|
||||
}
|
||||
// strip trailing slashes
|
||||
url = url.replace(/[/]+$/,'');
|
||||
return url;
|
||||
};
|
||||
|
||||
// IE doesn't support [].indexOf.
|
||||
utils.arrIndexOf = function(arr, obj){
|
||||
for(var i=0; i < arr.length; i++){
|
||||
if(arr[i] === obj){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
utils.arrSkip = function(arr, obj) {
|
||||
var idx = utils.arrIndexOf(arr, obj);
|
||||
if (idx === -1) {
|
||||
return arr.slice();
|
||||
} else {
|
||||
var dst = arr.slice(0, idx);
|
||||
return dst.concat(arr.slice(idx+1));
|
||||
}
|
||||
};
|
||||
|
||||
// Via: https://gist.github.com/1133122/2121c601c5549155483f50be3da5305e83b8c5df
|
||||
utils.isArray = Array.isArray || function(value) {
|
||||
return {}.toString.call(value).indexOf('Array') >= 0
|
||||
};
|
||||
|
||||
utils.delay = function(t, fun) {
|
||||
if(typeof t === 'function') {
|
||||
fun = t;
|
||||
t = 0;
|
||||
}
|
||||
return setTimeout(fun, t);
|
||||
};
|
||||
|
||||
|
||||
// Chars worth escaping, as defined by Douglas Crockford:
|
||||
// https://github.com/douglascrockford/JSON-js/blob/47a9882cddeb1e8529e07af9736218075372b8ac/json2.js#L196
|
||||
var json_escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
json_lookup = {
|
||||
"\u0000":"\\u0000","\u0001":"\\u0001","\u0002":"\\u0002","\u0003":"\\u0003",
|
||||
"\u0004":"\\u0004","\u0005":"\\u0005","\u0006":"\\u0006","\u0007":"\\u0007",
|
||||
"\b":"\\b","\t":"\\t","\n":"\\n","\u000b":"\\u000b","\f":"\\f","\r":"\\r",
|
||||
"\u000e":"\\u000e","\u000f":"\\u000f","\u0010":"\\u0010","\u0011":"\\u0011",
|
||||
"\u0012":"\\u0012","\u0013":"\\u0013","\u0014":"\\u0014","\u0015":"\\u0015",
|
||||
"\u0016":"\\u0016","\u0017":"\\u0017","\u0018":"\\u0018","\u0019":"\\u0019",
|
||||
"\u001a":"\\u001a","\u001b":"\\u001b","\u001c":"\\u001c","\u001d":"\\u001d",
|
||||
"\u001e":"\\u001e","\u001f":"\\u001f","\"":"\\\"","\\":"\\\\",
|
||||
"\u007f":"\\u007f","\u0080":"\\u0080","\u0081":"\\u0081","\u0082":"\\u0082",
|
||||
"\u0083":"\\u0083","\u0084":"\\u0084","\u0085":"\\u0085","\u0086":"\\u0086",
|
||||
"\u0087":"\\u0087","\u0088":"\\u0088","\u0089":"\\u0089","\u008a":"\\u008a",
|
||||
"\u008b":"\\u008b","\u008c":"\\u008c","\u008d":"\\u008d","\u008e":"\\u008e",
|
||||
"\u008f":"\\u008f","\u0090":"\\u0090","\u0091":"\\u0091","\u0092":"\\u0092",
|
||||
"\u0093":"\\u0093","\u0094":"\\u0094","\u0095":"\\u0095","\u0096":"\\u0096",
|
||||
"\u0097":"\\u0097","\u0098":"\\u0098","\u0099":"\\u0099","\u009a":"\\u009a",
|
||||
"\u009b":"\\u009b","\u009c":"\\u009c","\u009d":"\\u009d","\u009e":"\\u009e",
|
||||
"\u009f":"\\u009f","\u00ad":"\\u00ad","\u0600":"\\u0600","\u0601":"\\u0601",
|
||||
"\u0602":"\\u0602","\u0603":"\\u0603","\u0604":"\\u0604","\u070f":"\\u070f",
|
||||
"\u17b4":"\\u17b4","\u17b5":"\\u17b5","\u200c":"\\u200c","\u200d":"\\u200d",
|
||||
"\u200e":"\\u200e","\u200f":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029",
|
||||
"\u202a":"\\u202a","\u202b":"\\u202b","\u202c":"\\u202c","\u202d":"\\u202d",
|
||||
"\u202e":"\\u202e","\u202f":"\\u202f","\u2060":"\\u2060","\u2061":"\\u2061",
|
||||
"\u2062":"\\u2062","\u2063":"\\u2063","\u2064":"\\u2064","\u2065":"\\u2065",
|
||||
"\u2066":"\\u2066","\u2067":"\\u2067","\u2068":"\\u2068","\u2069":"\\u2069",
|
||||
"\u206a":"\\u206a","\u206b":"\\u206b","\u206c":"\\u206c","\u206d":"\\u206d",
|
||||
"\u206e":"\\u206e","\u206f":"\\u206f","\ufeff":"\\ufeff","\ufff0":"\\ufff0",
|
||||
"\ufff1":"\\ufff1","\ufff2":"\\ufff2","\ufff3":"\\ufff3","\ufff4":"\\ufff4",
|
||||
"\ufff5":"\\ufff5","\ufff6":"\\ufff6","\ufff7":"\\ufff7","\ufff8":"\\ufff8",
|
||||
"\ufff9":"\\ufff9","\ufffa":"\\ufffa","\ufffb":"\\ufffb","\ufffc":"\\ufffc",
|
||||
"\ufffd":"\\ufffd","\ufffe":"\\ufffe","\uffff":"\\uffff"};
|
||||
|
||||
// Some extra characters that Chrome gets wrong, and substitutes with
|
||||
// something else on the wire.
|
||||
var extra_escapable = /[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,
|
||||
extra_lookup;
|
||||
|
||||
// JSON Quote string. Use native implementation when possible.
|
||||
var JSONQuote = (JSON && JSON.stringify) || function(string) {
|
||||
json_escapable.lastIndex = 0;
|
||||
if (json_escapable.test(string)) {
|
||||
string = string.replace(json_escapable, function(a) {
|
||||
return json_lookup[a];
|
||||
});
|
||||
}
|
||||
return '"' + string + '"';
|
||||
};
|
||||
|
||||
// This may be quite slow, so let's delay until user actually uses bad
|
||||
// characters.
|
||||
var unroll_lookup = function(escapable) {
|
||||
var i;
|
||||
var unrolled = {}
|
||||
var c = []
|
||||
for(i=0; i<65536; i++) {
|
||||
c.push( String.fromCharCode(i) );
|
||||
}
|
||||
escapable.lastIndex = 0;
|
||||
c.join('').replace(escapable, function (a) {
|
||||
unrolled[ a ] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
return '';
|
||||
});
|
||||
escapable.lastIndex = 0;
|
||||
return unrolled;
|
||||
};
|
||||
|
||||
// Quote string, also taking care of unicode characters that browsers
|
||||
// often break. Especially, take care of unicode surrogates:
|
||||
// http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates
|
||||
utils.quote = function(string) {
|
||||
var quoted = JSONQuote(string);
|
||||
|
||||
// In most cases this should be very fast and good enough.
|
||||
extra_escapable.lastIndex = 0;
|
||||
if(!extra_escapable.test(quoted)) {
|
||||
return quoted;
|
||||
}
|
||||
|
||||
if(!extra_lookup) extra_lookup = unroll_lookup(extra_escapable);
|
||||
|
||||
return quoted.replace(extra_escapable, function(a) {
|
||||
return extra_lookup[a];
|
||||
});
|
||||
}
|
||||
|
||||
var _all_protocols = ['websocket',
|
||||
'xdr-streaming',
|
||||
'xhr-streaming',
|
||||
'iframe-eventsource',
|
||||
'iframe-htmlfile',
|
||||
'xdr-polling',
|
||||
'xhr-polling',
|
||||
'iframe-xhr-polling',
|
||||
'jsonp-polling'];
|
||||
|
||||
utils.probeProtocols = function() {
|
||||
var probed = {};
|
||||
for(var i=0; i<_all_protocols.length; i++) {
|
||||
var protocol = _all_protocols[i];
|
||||
// User can have a typo in protocol name.
|
||||
probed[protocol] = SockJS[protocol] &&
|
||||
SockJS[protocol].enabled();
|
||||
}
|
||||
return probed;
|
||||
};
|
||||
|
||||
utils.detectProtocols = function(probed, protocols_whitelist, info) {
|
||||
var pe = {},
|
||||
protocols = [];
|
||||
if (!protocols_whitelist) protocols_whitelist = _all_protocols;
|
||||
for(var i=0; i<protocols_whitelist.length; i++) {
|
||||
var protocol = protocols_whitelist[i];
|
||||
pe[protocol] = probed[protocol];
|
||||
}
|
||||
var maybe_push = function(protos) {
|
||||
var proto = protos.shift();
|
||||
if (pe[proto]) {
|
||||
protocols.push(proto);
|
||||
} else {
|
||||
if (protos.length > 0) {
|
||||
maybe_push(protos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Websocket
|
||||
if (info.websocket !== false) {
|
||||
maybe_push(['websocket']);
|
||||
}
|
||||
|
||||
// 2. Streaming
|
||||
if (pe['xhr-streaming'] && !info.null_origin) {
|
||||
protocols.push('xhr-streaming');
|
||||
} else {
|
||||
if (pe['xdr-streaming'] && !info.cookie_needed && !info.null_origin) {
|
||||
protocols.push('xdr-streaming');
|
||||
} else {
|
||||
maybe_push(['iframe-eventsource',
|
||||
'iframe-htmlfile']);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Polling
|
||||
if (pe['xhr-polling'] && !info.null_origin) {
|
||||
protocols.push('xhr-polling');
|
||||
} else {
|
||||
if (pe['xdr-polling'] && !info.cookie_needed && !info.null_origin) {
|
||||
protocols.push('xdr-polling');
|
||||
} else {
|
||||
maybe_push(['iframe-xhr-polling',
|
||||
'jsonp-polling']);
|
||||
}
|
||||
}
|
||||
return protocols;
|
||||
}
|
38
node_modules/shoe/node_modules/sockjs-client/package.json
generated
vendored
Normal file
38
node_modules/shoe/node_modules/sockjs-client/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2323
node_modules/shoe/node_modules/sockjs-client/sockjs.js
generated
vendored
Normal file
2323
node_modules/shoe/node_modules/sockjs-client/sockjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/shoe/node_modules/sockjs-client/version
generated
vendored
Normal file
1
node_modules/shoe/node_modules/sockjs-client/version
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0.3.1
|
122
node_modules/shoe/package.json
generated
vendored
Normal file
122
node_modules/shoe/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
242
node_modules/shoe/readme.markdown
generated
vendored
Normal file
242
node_modules/shoe/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
shoe
|
||||
====
|
||||
|
||||
Streaming sockjs for node and the browser.
|
||||
|
||||
This is a more streaming,
|
||||
[more unixy](http://www.faqs.org/docs/artu/ch01s06.html)
|
||||
take on [sockjs](https://github.com/sockjs/sockjs-node).
|
||||
|
||||
* works with [browserify](https://github.com/substack/node-browserify)
|
||||
([modularity](http://www.faqs.org/docs/artu/ch01s06.html#id2877537))
|
||||
* stream all the things
|
||||
([composition](http://www.faqs.org/docs/artu/ch01s06.html#id2877684))
|
||||
* emits a `'log'` event instead of spamming stdout
|
||||
([silence](http://www.faqs.org/docs/artu/ch01s06.html#id2878450))
|
||||
|
||||

|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
stream all the things
|
||||
---------------------
|
||||
|
||||
Browser code that takes in a stream of 0s and 1s from the server and inverts
|
||||
them:
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
var through = require('through');
|
||||
|
||||
var result = document.getElementById('result');
|
||||
|
||||
var stream = shoe('/invert');
|
||||
stream.pipe(through(function (msg) {
|
||||
result.appendChild(document.createTextNode(msg));
|
||||
this.queue(String(Number(msg)^1));
|
||||
})).pipe(stream);
|
||||
```
|
||||
|
||||
Server code that hosts some static files and emits 0s and 1s:
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
var http = require('http');
|
||||
|
||||
var ecstatic = require('ecstatic')(__dirname + '/static');
|
||||
|
||||
var server = http.createServer(ecstatic);
|
||||
server.listen(9999);
|
||||
|
||||
var sock = shoe(function (stream) {
|
||||
var iv = setInterval(function () {
|
||||
stream.write(Math.floor(Math.random() * 2));
|
||||
}, 250);
|
||||
|
||||
stream.on('end', function () {
|
||||
clearInterval(iv);
|
||||
});
|
||||
|
||||
stream.pipe(process.stdout, { end : false });
|
||||
});
|
||||
sock.install(server, '/invert');
|
||||
```
|
||||
|
||||
The server emits 0s and 1s to the browser, the browser inverts them and sends
|
||||
them back, and the server dumps the binary digits to stdout.
|
||||
|
||||
By default, there's no logspam on stdout to clutter the output, which is a
|
||||
frustrating trend in realtimey websocket libraries that violates the
|
||||
[rule of silence](http://www.faqs.org/docs/artu/ch01s06.html#id2878450).
|
||||
|
||||
Just wait for a client to connect and you'll see:
|
||||
|
||||
```
|
||||
$ node server.js
|
||||
001011010101101000101110010000100
|
||||
```
|
||||
|
||||
with dnode
|
||||
----------
|
||||
|
||||
Since dnode has a simple streaming api it's very simple to plug into shoe.
|
||||
|
||||
Just hack up some browser code:
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
var dnode = require('dnode');
|
||||
|
||||
var result = document.getElementById('result');
|
||||
var stream = shoe('/dnode');
|
||||
|
||||
var d = dnode();
|
||||
d.on('remote', function (remote) {
|
||||
remote.transform('beep', function (s) {
|
||||
result.textContent = 'beep => ' + s;
|
||||
});
|
||||
});
|
||||
d.pipe(stream).pipe(d);
|
||||
```
|
||||
and hack up a server piping shoe streams into dnode:
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
var dnode = require('dnode');
|
||||
|
||||
var http = require('http');
|
||||
var ecstatic = require('ecstatic')(__dirname + '/static');
|
||||
|
||||
var server = http.createServer(ecstatic);
|
||||
server.listen(9999);
|
||||
|
||||
var sock = shoe(function (stream) {
|
||||
var d = dnode({
|
||||
transform : function (s, cb) {
|
||||
var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase();
|
||||
cb(res);
|
||||
}
|
||||
});
|
||||
d.pipe(stream).pipe(d);
|
||||
});
|
||||
sock.install(server, '/dnode');
|
||||
```
|
||||
|
||||
Then open up `localhost:9999` in your browser and you should see:
|
||||
|
||||
```
|
||||
beep => BOOP
|
||||
```
|
||||
|
||||
with express or connect
|
||||
-----------------------
|
||||
|
||||
you must pass the return value of `app.listen(port)`
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
var sock = shoe(function (stream) { ... });
|
||||
|
||||
// *** must pass expcess/connect apps like this:
|
||||
sock.install(app.listen(9999), '/dnode');
|
||||
```
|
||||
|
||||
with reconnect
|
||||
--------------
|
||||
|
||||
you can use [reconnect](https://github.com/dominictarr/reconnect) just in case your sock ends or gets disconnected.
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe');
|
||||
var reconnect = require('reconnect');
|
||||
var es = require('event-stream');
|
||||
var result = document.getElementById('result');
|
||||
|
||||
var r = reconnect(function (stream) {
|
||||
|
||||
var s = es.mapSync(function (msg) {
|
||||
result.appendChild(document.createTextNode(msg));
|
||||
return String(Number(msg)^1);
|
||||
});
|
||||
s.pipe(stream).pipe(s);
|
||||
|
||||
}).connect('/invert')
|
||||
|
||||
```
|
||||
|
||||
browser methods
|
||||
===============
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe')
|
||||
```
|
||||
|
||||
var stream = shoe(uri, cb)
|
||||
--------------------------
|
||||
|
||||
Return a readable/writable stream from the sockjs path `uri`.
|
||||
`uri` may be a full uri or just a path.
|
||||
|
||||
`shoe` will emit a `'connect'` event when the connection is actually open,
|
||||
(just like in [net](http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener)).
|
||||
writes performed before the `'connect'` event will be buffered. passing in `cb` to
|
||||
shoe is a shortcut for `shoe(uri).on('connect', cb)`
|
||||
|
||||
server methods
|
||||
==============
|
||||
|
||||
``` js
|
||||
var shoe = require('shoe')
|
||||
```
|
||||
|
||||
All the methods from the sockjs exports objects are attached onto the `shoe`
|
||||
function, but the `shoe()` function itself is special.
|
||||
|
||||
var sock = shoe(opts, cb)
|
||||
-------------------------
|
||||
|
||||
Create a server with `sockjs.createServer(opts)` except this function also adds
|
||||
the `.install()` function below.
|
||||
|
||||
If `cb` is specified, it fires `cb(stream)` on `'connection'` events.
|
||||
|
||||
sock.install(server, opts)
|
||||
--------------------------
|
||||
|
||||
Call `sock.installHandler()` with the default option of spamming stdout with log
|
||||
messages switched off in place of just emitting `'log'` messages
|
||||
on the `sock` object instead. This is a much less spammy default that gets out
|
||||
of your way.
|
||||
|
||||
If `opts` is a string, use it as the `opts.prefix`.
|
||||
|
||||
server events
|
||||
=============
|
||||
|
||||
All the messages that sockjs normally emits will be available on the `sock`
|
||||
object plus the events below:
|
||||
|
||||
sock.on('log', function (severity, msg) { ... })
|
||||
------------------------------------------------
|
||||
|
||||
Using the default logger with `sock.install()` will cause these `'log'` messages
|
||||
to be emitted instead of spamming stdout.
|
||||
|
||||
install
|
||||
=======
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install shoe
|
||||
```
|
||||
|
||||
license
|
||||
=======
|
||||
|
||||
MIT
|
19
node_modules/shoe/test/browser.js
generated
vendored
Normal file
19
node_modules/shoe/test/browser.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var shoe = require('../');
|
||||
var test = require('tape');
|
||||
var through = require('through');
|
||||
|
||||
test('round-trip', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var stream = shoe('/sock');
|
||||
var data = '';
|
||||
|
||||
stream.pipe(through(function (buf) {
|
||||
data += buf;
|
||||
if (data === 'BEEP BOOP') {
|
||||
t.ok(true, 'got upper-cased data back');
|
||||
}
|
||||
}));
|
||||
|
||||
stream.write('beep boop');
|
||||
});
|
16
node_modules/shoe/test/server.js
generated
vendored
Normal file
16
node_modules/shoe/test/server.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var http = require('http');
|
||||
var shoe = require('../');
|
||||
var through = require('through');
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
res.statusCode = 404;
|
||||
res.end('not found\n');
|
||||
});
|
||||
server.listen(process.env.PORT);
|
||||
|
||||
var sock = shoe(function (stream) {
|
||||
stream.pipe(through(function (buf) {
|
||||
this.queue(buf.toString('utf8').toUpperCase());
|
||||
})).pipe(stream);
|
||||
});
|
||||
sock.install(server, '/sock');
|
Reference in New Issue
Block a user