[Pkg-javascript-commits] [sockjs-client] 182/350: Remove old sockjs.js

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit f6727b1741bd8250cd05a8b713951f9220729a9c
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Sun Oct 19 22:34:33 2014 -0400

    Remove old sockjs.js
---
 gulpfile.js   |   4 +-
 lib/sockjs.js | 354 ----------------------------------------------------------
 2 files changed, 2 insertions(+), 356 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 85333ca..0055658 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -21,7 +21,7 @@ gulp.task('test', function () {
 });
 
 gulp.task('eslint', function () {
-  gulp.src(['lib/**/*.js', '!lib/sockjs.js'])
+  gulp.src(['lib/**/*.js'])
     .pipe(eslint())
     .pipe(eslint.format());
 });
@@ -45,7 +45,7 @@ gulp.task('testbundle', function() {
 });
 
 gulp.task('browserify', function () {
-  return browserify('./lib/entry.js', { 
+  return browserify('./lib/entry.js', {
       standalone: 'SockJS'
     , debug: true
     })
diff --git a/lib/sockjs.js b/lib/sockjs.js
deleted file mode 100644
index 2075bd6..0000000
--- a/lib/sockjs.js
+++ /dev/null
@@ -1,354 +0,0 @@
-'use strict';
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Copyright (c) 2011-2012 VMware, Inc.
- *
- * For the license see COPYING.
- * ***** END LICENSE BLOCK *****
- */
-
-var utils = require('./utils');
-var REventTarget = require('./reventtarget');
-var SimpleEvent = require('./simpleevent');
-var InfoReceiver = require('./info-receiver');
-var InfoReceiverIframe = require('./info-receiver-iframe');
-var InfoReceiverFake = require('./info-receiver-fake');
-var FacadeJS = require('./facade');
-var JSON3 = require('json3');
-var XHRLocalObject = require('./xhr-local');
-var XHRCorsObject = require('./xhr-cors');
-var XDRObject = require('./xdr');
-var XDRPolling = require('./trans-xdr-polling');
-var IframeTransport = require('./transport/lib/iframe');
-
-var protocols = require('./protocols');
-
-function SockJS(url, _reserved, options) {
-    if (!(this instanceof SockJS)) {
-        // makes `new` optional
-        return new SockJS(url, _reserved, options);
-    }
-
-    var that = this;
-    that._base_url = utils.amendUrl(url);
-
-    options = options || {};
-    that._server = 'server' in options ? options.server : utils.random_number_string(1000);
-    that._devel = 'devel' in options ? options.devel : false;
-    that._debug = 'debug' in options ? options.debug : false;
-
-    // only allow whitelist if it is valid
-    if (options.protocols_whitelist && options.protocols_whitelist.length) {
-        that._protocols_whitelist = utils.isArray(options.protocols_whitelist)
-            ? options.protocols_whitelist
-            : [options.protocols_whitelist]
-            ;
-    } else {
-        that._protocols_whitelist = [];
-    }
-
-    that._protocols = [];
-    that.protocol = null;
-    that.readyState = SockJS.CONNECTING;
-    that._ir = createInfoReceiver(that._base_url);
-    that._ir.on('finish', function(info, rtt) {
-        that._ir = null;
-        if (info) {
-            that._applyInfo(info, rtt, that._protocols_whitelist);
-            that._didClose();
-        } else {
-            that._didClose(1002, "Can't connect to server", true);
-        }
-    });
-}
-
-// Inheritance
-SockJS.prototype = new REventTarget();
-
-SockJS.version = '1.0.0-alpha1';
-
-SockJS.prototype.CONNECTING = SockJS.CONNECTING = 0;
-SockJS.prototype.OPEN = SockJS.OPEN = 1;
-SockJS.prototype.CLOSING = SockJS.CLOSING = 2;
-SockJS.prototype.CLOSED = SockJS.CLOSED = 3;
-
-SockJS.prototype._log = function() {
-    if (this._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.protocol = that._transport.transportName;
-        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.removeAllListeners();
-        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;
-
-    setTimeout(function() {
-                   that.dispatchEvent(close_event);
-                }, 0);
-};
-
-SockJS.prototype._didMessage = function(data) {
-    var that = this;
-    var type = data.slice(0, 1);
-    var payload;
-    switch(type) {
-    case 'o':
-        that._dispatchOpen();
-        break;
-    case 'a':
-        payload = JSON3.parse(data.slice(1) || '[]');
-        for(var i=0; i < payload.length; i++){
-            that._dispatchMessage(payload[i]);
-        }
-        break;
-    case 'm':
-        payload = JSON3.parse(data.slice(1) || 'null');
-        that._dispatchMessage(payload);
-        break;
-    case 'c':
-        payload = JSON3.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._log('Closed transport:', that.protocol, ''+close_event);
-        that.protocol = null;
-    }
-    if (that._transport_tref) {
-        clearTimeout(that._transport_tref);
-        that._transport_tref = null;
-    }
-
-    function timeoutFunction() {
-        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 timed out");
-        }
-    }
-
-    function tryNextProtocol() {
-        that._try_next_protocol();
-    }
-
-    while (true) {
-        var Protocol = that._protocols.shift();
-        if (!Protocol) {
-            return false;
-        }
-        // Some protocols require access to `body`, what if we are in the `head`?
-        if (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', tryNextProtocol);
-            return true;
-        }
-        
-        var roundTrips = Protocol.roundTrips || 1;
-        var to = ((that._rto || 0) * roundTrips) || 5000;
-        that._transport_tref = setTimeout(timeoutFunction, to);
-
-        var connid = utils.random_string(8);
-        var trans_url = that._base_url + '/' + that._server + '/' + connid;
-        that._log('Opening transport:', Protocol.transportName, ' url:'+trans_url,
-                    ' RTO:'+that._rto);
-        that._transport = new 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._rtt = rtt;
-    that._rto = utils.countRTO(rtt);
-
-    info.null_origin = !document.domain;
-    // Servers can override base_url, eg to provide a randomized domain name and
-    // avoid browser per-domain connection limits.
-    if (info.base_url) that._base_url = utils.amendUrl(info.base_url);
-    that._protocols = protocols(that._base_url, protocols_whitelist, info);
-};
-
-utils.parent_origin = undefined;
-
-SockJS.bootstrap_iframe = function() {
-    var facade;
-    utils.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 !== utils.curr_window_id) return;
-        switch(type) {
-        case 's':
-            var p = JSON3.parse(data);
-            var version = p[0];
-            var protocol = p[1];
-            var trans_url = p[2];
-            var base_url = p[3];
-            // change this to semver logic
-            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.isOriginEqual(trans_url) ||
-                !utils.isOriginEqual(base_url)) {
-                utils.log("Can't connect to different domain from within an " +
-                          "iframe. (" + JSON3.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;
-        }
-    };
-
-    utils.attachMessage(onMessage);
-
-    // Start
-    utils.postMessage('s');
-};
-
-module.exports = SockJS;
-
-FacadeJS['w-iframe-info-receiver'] = require('./trans-receiver-iframe');
-FacadeJS['w-iframe-eventsource'] = require('./trans-eventsource');
-FacadeJS['w-iframe-htmlfile'] = require('./trans-htmlfile');
-FacadeJS['w-iframe-xhr-polling'] = require('./xhr-polling-iframe');
-
-// This is seriously wack. It is needed for almost all iframe transports
-if ('_sockjs_onload' in window) setTimeout(window._sockjs_onload, 1);
-
-function createInfoReceiver(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, XHRCorsObject);
-    }
-    if (utils.isXHRCorsCapable() === 1) {
-        // XHRLocalObject -> no_credentials=true
-        return new InfoReceiver(base_url, XHRLocalObject);
-    }
-    if (XDRPolling.enabled(base_url)) {
-        return new InfoReceiver(base_url, XDRObject);
-    }
-    if (IframeTransport.enabled()) {
-        return new InfoReceiverIframe(base_url);
-    }
-
-    // IE 7, and IE 8/9 if requesting across schemes (e.g. http -> https)
-    return new InfoReceiverFake();
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list