swim-client-js
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -1,1 +0,1 @@ | ||
{"version":"0.4.4"} | ||
{"version":"0.4.5"} |
{ | ||
"name": "swim-client-js", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "Swim Client JavaScript Implementation", | ||
@@ -29,4 +29,4 @@ "homepage": "https://github.com/swimit/swim-client-js", | ||
"dependencies": { | ||
"recon-js": "^0.3.8", | ||
"swim-proto-js": "^0.4.1", | ||
"recon-js": "^0.3.9", | ||
"swim-proto-js": "^0.4.2", | ||
"websocket": "^1.0.22" | ||
@@ -55,2 +55,5 @@ }, | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/swimit/swim-client-js/issues" | ||
}, | ||
"repository": { | ||
@@ -60,5 +63,2 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/swimit/swim-client-js/issues" | ||
}, | ||
"scripts": { | ||
@@ -65,0 +65,0 @@ "test": "gulp", |
@@ -59,4 +59,4 @@ # Swim Client Javascript Implementation | ||
Returns a new [DownlinkBuilder](#downlinkbuilder) for constructing a link to | ||
a lane of a remote node. | ||
Returns a new [DownlinkBuilder](#downlinkbuilder), which is used to establish | ||
a new link to a lane of some remote node. | ||
@@ -128,3 +128,3 @@ #### client.link([hostUri, ]nodeUri, laneUri[, options]) | ||
Sends a command to a lane of a remote node. If provided,`hostUri` specifies | ||
Sends a command to a lane of a remote node. If provided, `hostUri` specifies | ||
the network endpoint to connect to, otherwise `nodeUri` must include a network | ||
@@ -160,5 +160,5 @@ authority component. `body` can be any JSON-compatible object; `body` is | ||
directly to the client object. If `delegate` is reassigned, then callbacks | ||
will instead by invoked on the assigned `delegate` object instead. | ||
will instead by invoked on the assigned `delegate` object. | ||
#### client.onConnect = function (info) {} | ||
#### client.onConnect = function (info) | ||
@@ -170,3 +170,3 @@ The `onConnect` callback gets invoked when a network connection managed by the | ||
#### client.onDisconnect = function (info) {} | ||
#### client.onDisconnect = function (info) | ||
@@ -178,3 +178,3 @@ The `onConnect` callback gets invoked when a network connection managed by the | ||
#### client.onError = function (info) {} | ||
#### client.onError = function (info) | ||
@@ -186,3 +186,3 @@ The `onError` callback gets invoked when a network connection managed by the | ||
#### client.onAuthorize = function (info) {} | ||
#### client.onAuthorize = function (info) | ||
@@ -195,3 +195,3 @@ The `onAuthorize` callback gets invoked when a network connection managed by | ||
#### client.onDeauthorize = function (info) {} | ||
#### client.onDeauthorize = function (info) | ||
@@ -239,5 +239,5 @@ The `onDeauthorize` callback gets invoked when a network connection managed by | ||
directly to the scope object. If `delegate` is reassigned, then callbacks | ||
will instead by invoked on the assigned `delegate` object instead. | ||
will instead by invoked on the assigned `delegate` object. | ||
#### scope.onConnect = function (info) {} | ||
#### scope.onConnect = function (info) | ||
@@ -249,3 +249,3 @@ The `onConnect` callback gets invoked when a network connection to the scope's | ||
#### scope.onDisconnect = function (info) {} | ||
#### scope.onDisconnect = function (info) | ||
@@ -257,3 +257,3 @@ The `onConnect` callback gets invoked when a network connection to the scope's | ||
#### scope.onError = function (info) {} | ||
#### scope.onError = function (info) | ||
@@ -265,3 +265,3 @@ The `onError` callback gets invoked when a network connection to the scope's | ||
#### scope.onAuthorize = function (info) {} | ||
#### scope.onAuthorize = function (info) | ||
@@ -274,3 +274,3 @@ The `onAuthorize` callback gets invoked when a network connection to the scope's | ||
#### scope.onDeauthorize = function (info) {} | ||
#### scope.onDeauthorize = function (info) | ||
@@ -462,20 +462,20 @@ The `onDeauthorize` callback gets invoked when a network connection to the | ||
Returns the URI containing the network authority of the downlink. | ||
Returns the URI of the host to which `downlink` connects. | ||
#### downlink.nodeUri | ||
Returns the URI of the remote node to which this link is connected. Returns | ||
an absolute URI resolved against the `hostUri`. | ||
Returns the URI of the remote node to which `downlink` connects. Returns an | ||
absolute URI resolved against the `hostUri`. | ||
#### downlink.laneUri | ||
Returns the URI of the lane to which this link is connected. | ||
Returns the URI of the lane to which `downlink` connects. | ||
#### downlink.options | ||
Returns the `options` object provided when the link was created. | ||
Returns the `options` object provided when `downlink` was created. | ||
#### downlink.prio | ||
Returns the floating point priority level of the link. | ||
Returns the floating point priority level of the `downlink`. | ||
@@ -509,2 +509,6 @@ #### downlink.keepAlive[ = keepAlive] | ||
#### downlink.command(body) | ||
Sends a command to the remote lane to which this downlink is connected. | ||
#### downlink.close() | ||
@@ -520,5 +524,5 @@ | ||
directly to the downlink object. If `delegate` is reassigned, then callbacks | ||
will instead by invoked on the assigned `delegate` object instead. | ||
will instead by invoked on the assigned `delegate` object. | ||
#### downlink.onEvent = function (message) {} | ||
#### downlink.onEvent = function (message) | ||
@@ -531,3 +535,3 @@ The `onEvent` callback gets invoked every time the downlink receives an event. | ||
#### downlink.onLink = function (request) {} | ||
#### downlink.onLink = function (request) | ||
@@ -542,3 +546,3 @@ The `onLink` callback gets invoked when the downlink is about to send a `@link` | ||
#### downlink.onLinked = function (response) {} | ||
#### downlink.onLinked = function (response) | ||
@@ -553,3 +557,3 @@ The `onLinked` callback gets invoked when the downlink receives a `@linked` | ||
#### downlink.onSync = function (request) {} | ||
#### downlink.onSync = function (request) | ||
@@ -564,3 +568,3 @@ The `onSync` callback gets invoked when the downlink is about to send a `@sync` | ||
#### downlink.onSynced = function (response) {} | ||
#### downlink.onSynced = function (response) | ||
@@ -575,3 +579,3 @@ The `onSynced` callback gets invoked when the downlink receives a `@synced` | ||
#### downlink.onUnlink = function (request) {} | ||
#### downlink.onUnlink = function (request) | ||
@@ -587,3 +591,3 @@ The `onUnlink` callback gets invoked when the downlink is about to send an | ||
#### downlink.onUnlinked = function (response) {} | ||
#### downlink.onUnlinked = function (response) | ||
@@ -600,3 +604,3 @@ The `onUnlinked` callback gets invoked when the downlink receives an `@unlinked` | ||
#### downlink.onConnect = function () {} | ||
#### downlink.onConnect = function () | ||
@@ -606,3 +610,3 @@ The `onConnect` callback gets invoked when the network connection that carries | ||
#### downlink.onDisconnect = function () {} | ||
#### downlink.onDisconnect = function () | ||
@@ -612,3 +616,3 @@ The `onDisconnect` callback gets invoked when the network connection that | ||
#### downlink.onError = function () {} | ||
#### downlink.onError = function () | ||
@@ -621,3 +625,3 @@ The `onError` callback gets invoked when the network connection that carries | ||
#### downlink.onClose = function () {} | ||
#### downlink.onClose = function () | ||
@@ -679,7 +683,7 @@ The `onClose` callback gets invoked when the downlink has been disconnected and | ||
#### listDownlink.splice(start, deleteCount[, value1, ..., valueN]) | ||
#### listDownlink.splice(startIndex, deleteCount[, value1, ..., valueN]) | ||
Removes `deleteCount` elements from the downlinked list state, starting index | ||
`start`, and inserts zero or more new values at index `start`. Pushes all | ||
changes to the remote lane. | ||
Removes `deleteCount` elements from the downlinked list state, starting at | ||
index `start`, and inserts zero or more new values at `startIndex`. Pushes | ||
all changes to the remote lane. | ||
@@ -696,5 +700,5 @@ #### listDownlink.clear() | ||
`callback` is invoked with two arguments: | ||
`callback` is invoked with three arguments: | ||
- the current list value | ||
- index of the current list value | ||
- the index of the current list value | ||
- the `listDownlink` being traversed | ||
@@ -701,0 +705,0 @@ |
'use strict'; | ||
var config = require('./config.json'); | ||
var recon = require('recon-js'); | ||
var recon = global.recon || require('recon-js'); | ||
var proto = require('swim-proto-js'); | ||
@@ -1123,2 +1123,5 @@ var WebSocket = global.WebSocket || require('websocket').w3cwebsocket; | ||
}); | ||
Downlink.prototype.command = function (body) { | ||
this.channel.command(this.nodeUri, this.laneUri, body); | ||
}; | ||
Downlink.prototype.close = function () { | ||
@@ -1257,2 +1260,3 @@ this.channel.unregisterDownlink(this); | ||
ListDownlink.prototype.set = function (index, value) { | ||
value = recon(value !== undefined ? value : this.get(index)); | ||
this.state[index] = value; | ||
@@ -1268,3 +1272,3 @@ var nodeUri = this.channel.unresolve(this.nodeUri); | ||
for (var i = 0, n = arguments.length; i < n; i += 1) { | ||
var value = arguments[i]; | ||
var value = recon(arguments[i]); | ||
this.state.push(value); | ||
@@ -1292,3 +1296,3 @@ var message = new proto.CommandMessage(nodeUri, this.laneUri, value); | ||
for (var i = arguments.length - 1; i >= 0; i -= 1) { | ||
var value = arguments[i]; | ||
var value = recon(arguments[i]); | ||
this.state.unshift(value); | ||
@@ -1344,3 +1348,3 @@ var body = recon.concat(recon({'@insert': recon({index: 0})}), value); | ||
var index = start + i - 2; | ||
value = arguments[i]; | ||
value = recon(arguments[i]); | ||
this.state.splice(index, 0, value); | ||
@@ -1479,2 +1483,3 @@ body = recon.concat(recon({'@insert': recon({index: index})}), value); | ||
MapDownlink.prototype.set = function (key, value) { | ||
value = recon(value !== undefined ? value : this.get(key)); | ||
if (typeof key === 'string') { | ||
@@ -1481,0 +1486,0 @@ this.table[key] = value; |
@@ -1,3 +0,3 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.swim||(t.swim={})).client=e()}}(function(){return function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,n){t.exports={version:"0.4.4"}},{}],2:[function(e,t,n){},{}],3:[function(e,t,n){t.exports={version:"0.4.1"}},{}],4:[function(e,t,n){"use strict";function o(e){switch(U.tag(e)){case"@event":return p.decode(e);case"@command":return u.decode(e);case"@link":return d.decode(e);case"@linked":return f.decode(e);case"@sync":return y.decode(e);case"@synced":return v.decode(e);case"@unlink":return b.decode(e);case"@unlinked":return g.decode(e);case"@auth":return m.decode(e);case"@authed":return k.decode(e);case"@deauth":return O.decode(e);case"@deauthed":return j.decode(e)}}function i(e){return e.encode()}function r(e){return o(U.parse(e))}function s(e){return U.stringify(i(e))}function a(){}function h(){a.call(this)}function c(){a.call(this)}function l(){a.call(this)}function p(e,t,n){l.call(this),this.node=e,this.lane=t,this.body=n}function u(e,t,n){l.call(this),this.node=e,this.lane=t,this.body=n}function d(e,t,n,o){h.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function f(e,t,n,o){c.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function y(e,t,n,o){h.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function v(e,t,n){c.call(this),this.node=e,this.lane=t,this.body=n}function b(e,t,n){h.call(this),this.node=e,this.lane=t,this.body=n}function g(e,t,n){c.call(this),this.node=e,this.lane=t,this.body=n}function m(e){h.call(this),this.body=e}function k(e){c.call(this),this.body=e}function O(e){h.call(this),this.body=e}function j(e){c.call(this),this.body=e}var w=e("./config.json"),U=e("recon-js");Object.defineProperty(a.prototype,"isRequest",{value:!1}),Object.defineProperty(a.prototype,"isResponse",{value:!1}),Object.defineProperty(a.prototype,"isMessage",{value:!1}),Object.defineProperty(a.prototype,"isEventMessage",{value:!1}),Object.defineProperty(a.prototype,"isCommandMessage",{value:!1}),Object.defineProperty(a.prototype,"isLinkRequest",{value:!1}),Object.defineProperty(a.prototype,"isLinkedResponse",{value:!1}),Object.defineProperty(a.prototype,"isSyncRequest",{value:!1}),Object.defineProperty(a.prototype,"isSyncedResponse",{value:!1}),Object.defineProperty(a.prototype,"isUnlinkRequest",{value:!1}),Object.defineProperty(a.prototype,"isUnlinkedResponse",{value:!1}),Object.defineProperty(a.prototype,"isAuthRequest",{value:!1}),Object.defineProperty(a.prototype,"isAuthedResponse",{value:!1}),Object.defineProperty(a.prototype,"isDeauthRequest",{value:!1}),Object.defineProperty(a.prototype,"isDeauthedResponse",{value:!1}),h.prototype=Object.create(a.prototype),h.prototype.constructor=h,Object.defineProperty(h.prototype,"isRequest",{value:!0}),c.prototype=Object.create(a.prototype),c.prototype.constructor=c,Object.defineProperty(c.prototype,"isResponse",{value:!0}),l.prototype=Object.create(a.prototype),l.prototype.constructor=l,Object.defineProperty(l.prototype,"isMessage",{value:!0}),p.prototype=Object.create(l.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"isEventMessage",{value:!0}),p.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new p(e,t,this.body)},p.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@event":e},this.body)},p.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new p(t,n,o):void 0},u.prototype=Object.create(l.prototype),u.prototype.constructor=u,Object.defineProperty(u.prototype,"isCommandMessage",{value:!0}),u.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new u(e,t,this.body)},u.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@command":e},this.body)},u.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new u(t,n,o):void 0},d.prototype=Object.create(h.prototype),d.prototype.constructor=d,Object.defineProperty(d.prototype,"isLinkRequest",{value:!0}),d.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new d(e,t,this.prio,this.body)},d.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@link":e},this.body)},d.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new d(t,n,o,i):void 0},f.prototype=Object.create(c.prototype),f.prototype.constructor=f,Object.defineProperty(f.prototype,"isLinkedResponse",{value:!0}),f.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new f(e,t,this.prio,this.body)},f.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@linked":e},this.body)},f.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new f(t,n,o,i):void 0},y.prototype=Object.create(h.prototype),y.prototype.constructor=y,Object.defineProperty(y.prototype,"isSyncRequest",{value:!0}),y.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new y(e,t,this.prio,this.body)},y.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@sync":e},this.body)},y.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new y(t,n,o,i):void 0},v.prototype=Object.create(c.prototype),v.prototype.constructor=v,Object.defineProperty(v.prototype,"isSyncedResponse",{value:!0}),v.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new v(e,t,this.body)},v.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@synced":e},this.body)},v.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new v(t,n,o):void 0},b.prototype=Object.create(h.prototype),b.prototype.constructor=b,Object.defineProperty(b.prototype,"isUnlinkRequest",{value:!0}),b.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new b(e,t,this.body)},b.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@unlink":e},this.body)},b.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new b(t,n,o):void 0},g.prototype=Object.create(c.prototype),g.prototype.constructor=g,Object.defineProperty(g.prototype,"isUnlinkedResponse",{value:!0}),g.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new g(e,t,this.body)},g.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@unlinked":e},this.body)},g.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new g(t,n,o):void 0},m.prototype=Object.create(h.prototype),m.prototype.constructor=m,Object.defineProperty(m.prototype,"isAuthRequest",{value:!0}),m.prototype.encode=function(){return U.concat({"@auth":null},this.body)},m.decode=function(e){var t=U.tail(e);return new m(t)},k.prototype=Object.create(c.prototype),k.prototype.constructor=k,Object.defineProperty(k.prototype,"isAuthedResponse",{value:!0}),k.prototype.encode=function(){return U.concat({"@authed":null},this.body)},k.decode=function(e){var t=U.tail(e);return new k(t)},O.prototype=Object.create(h.prototype),O.prototype.constructor=O,Object.defineProperty(O.prototype,"isDeauthRequest",{value:!0}),O.prototype.encode=function(){return U.concat({"@deauth":null},this.body)},O.decode=function(e){var t=U.tail(e);return new O(t)},j.prototype=Object.create(c.prototype),j.prototype.constructor=j,Object.defineProperty(j.prototype,"isDeauthedResponse",{value:!0}),j.prototype.encode=function(){return U.concat({"@deauthed":null},this.body)},j.decode=function(e){var t=U.tail(e);return new j(t)},n.decode=o,n.encode=i,n.parse=r,n.stringify=s,n.Envelope=a,n.RequestEnvelope=h,n.ResponseEnvelope=c,n.MessageEnvelope=l,n.EventMessage=p,n.CommandMessage=u,n.SyncRequest=y,n.SyncedResponse=v,n.LinkRequest=d,n.LinkedResponse=f,n.UnlinkRequest=b,n.UnlinkedResponse=g,n.AuthRequest=m,n.AuthedResponse=k,n.DeauthRequest=O,n.DeauthedResponse=j,n.config=w},{"./config.json":3,"recon-js":"recon-js"}],"swim-client-js":[function(e,t,n){(function(n){"use strict";function o(e){e=e||{},Object.defineProperty(this,"options",{value:e,enumerable:!0}),Object.defineProperty(this,"channels",{value:{},configurable:!0}),Object.defineProperty(this,"delegate",{value:this,enumerable:!0,writable:!0})}function i(e){Object.defineProperty(this,"channel",{value:e}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0}),Object.defineProperty(this,"delegate",{value:this,enumerable:!0,writable:!0}),e.registerDelegate(this)}function r(e,t){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function s(e,t,n){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function a(e,t,n,o){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"laneUri",{value:o,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function h(e,t,n){n=n||{},Object.defineProperty(this,"client",{value:e,configurable:!0}),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"options",{value:n,enumerable:!0}),Object.defineProperty(this,"credentials",{value:n.credentials,writable:!0}),Object.defineProperty(this,"isAuthorized",{value:!1,enumerable:!0,writable:!0}),Object.defineProperty(this,"session",{value:null,enumerable:!0,writable:!0}),Object.defineProperty(this,"uriCache",{value:new y(t),configurable:!0}),Object.defineProperty(this,"delegates",{value:[],configurable:!0}),Object.defineProperty(this,"downlinks",{value:{},configurable:!0}),Object.defineProperty(this,"sendBuffer",{value:[],configurable:!0}),Object.defineProperty(this,"reconnectTimer",{value:null,writable:!0}),Object.defineProperty(this,"reconnectTimeout",{value:0,writable:!0}),Object.defineProperty(this,"idleTimer",{value:null,writable:!0}),Object.defineProperty(this,"socket",{value:null,writable:!0})}function c(e,t){Object.defineProperty(this,"channel",{value:e,configurable:!0}),Object.defineProperty(this,"scope",{value:t,configurable:!0}),Object.defineProperty(this,"proxy",{value:{},configurable:!0}),this.options={}}function l(e,t,n,o,i){i=i||{},Object.defineProperty(this,"channel",{value:e}),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"laneUri",{value:o,enumerable:!0}),Object.defineProperty(this,"options",{value:i,enumerable:!0}),Object.defineProperty(this,"delegate",{value:i.delegate||this,enumerable:!0,writable:!0})}function p(e,t,n,o,i){l.call(this,e,t,n,o,i)}function u(e,t,n,o,i){l.call(this,e,t,n,o,i)}function d(e,t,n,o,i){u.call(this,e,t,n,o,i),Object.defineProperty(this,"state",{value:[],configurable:!0})}function f(e,t,n,o,i){u.call(this,e,t,n,o,i),Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0}),this.primaryKey=f.primaryKeyOption(this.options),this.sortBy=f.sortByOption(this.options)}function y(e,t){t=t||32,Object.defineProperty(this,"baseUri",{value:e,enumerable:!0}),Object.defineProperty(this,"base",{value:b.uri.parse(e)}),Object.defineProperty(this,"size",{value:t,enumerable:!0}),Object.defineProperty(this,"resolveCache",{value:new Array(t)}),Object.defineProperty(this,"unresolveCache",{value:new Array(t)})}var v=e("./config.json"),b=e("recon-js"),g=e("swim-proto-js"),m=n.WebSocket||e("websocket").w3cwebsocket;Object.defineProperty(o.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.onConnect(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.onDisconnect(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.onError(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelAuthorize",{value:function(e){"function"==typeof this.delegate.onAuthorize&&this.onAuthorize(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelDeauthorize",{value:function(e){"function"==typeof this.delegate.onDeauthorize&&this.onDeauthorize(e)},configurable:!0}),Object.defineProperty(o.prototype,"callChannelWithLinkArgs",{value:function(e,t){var n,i,r,s;2===t.length?(s={},r=t[1],i=t[0],n=o.extractHostUri(i)):3===t.length?"object"==typeof t[2]?(s=t[2],r=t[1],i=t[0],n=o.extractHostUri(i)):(n=t[0],i=o.resolveNodeUri(n,t[1]),r=t[2],s={}):(n=t[0],i=o.resolveNodeUri(n,t[1]),r=t[2],s=t[3]);var a=this.getOrCreateChannel(n);return a[e](i,r,s)},configurable:!0}),o.prototype.getOrCreateChannel=function(e){var t=this.channels[e];return void 0===t&&(t=new h(this,e,this.options),this.channels[e]=t),t},o.prototype.authorize=function(e,t){var n=this.getOrCreateChannel(e);n.authorize(t)},o.prototype.downlink=function(){return new c(null,this)},o.prototype.link=function(){return this.callChannelWithLinkArgs("link",arguments)},o.prototype.sync=function(){return this.callChannelWithLinkArgs("sync",arguments)},o.prototype.syncList=function(){return this.callChannelWithLinkArgs("syncList",arguments)},o.prototype.syncMap=function(){return this.callChannelWithLinkArgs("syncMap",arguments)},o.prototype.command=function(){var e,t,n,i;3===arguments.length?(i=arguments[2],n=arguments[1],t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]),n=arguments[2],i=arguments[3]);var r=this.getOrCreateChannel(e);r.command(t,n,i)},o.prototype.host=function(e){var t=this.getOrCreateChannel(e);return new r(t,e)},o.prototype.node=function(){var e,t;1===arguments.length?(t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]));var n=this.getOrCreateChannel(e);return new s(n,e,t)},o.prototype.lane=function(){var e,t,n;2===arguments.length?(n=arguments[1],t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]),n=arguments[2]);var i=this.getOrCreateChannel(e);return new a(i,e,t,n)},o.prototype.close=function(){var e=this.channels;Object.defineProperty(this,"channels",{value:{},configurable:!0});for(var t in e){var n=e[t];n.close()}},o.extractHostUri=function(e){var t=b.uri.parse(e),n=t.scheme;return"swim"===n?n="ws":"swims"===n&&(n="wss"),b.uri.stringify({scheme:n,authority:t.authority})},o.resolveNodeUri=function(e,t){return b.uri.stringify(b.uri.resolve(e,t))},Object.defineProperty(i.prototype,"isConnected",{get:function(){return this.channel.isConnected},enumerable:!0}),Object.defineProperty(i.prototype,"isAuthorized",{get:function(){return this.channel.isAuthorized},enumerable:!0}),Object.defineProperty(i.prototype,"session",{get:function(){return this.channel.session},enumerable:!0}),Object.defineProperty(i.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.onConnect(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.onDisconnect(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.onError(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelAuthorize",{value:function(e){"function"==typeof this.delegate.onAuthorize&&this.onAuthorize(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelDeauthorize",{value:function(e){"function"==typeof this.delegate.onDeauthorize&&this.onDeauthorize(e)},configurable:!0}),i.prototype.registerDownlink=function(e){var t=this;Object.defineProperty(e,"onChannelClose",{value:function(){t.unregisterDownlink(e),e.__proto__.onChannelClose.call(e)},configurable:!0}),this.downlinks.push(e)},i.prototype.unregisterDownlink=function(e){for(var t=0,n=this.downlinks.length;n>t;t+=1)if(e===this.downlinks[t])return void this.downlinks.splice(t,1)},i.prototype.close=function(){this.channel.unregisterDelegate(this);var e=this.downlinks;Object.defineProperty(this,"downlinks",{value:[],configurable:!0});for(var t=0,n=e.length;n>t;t+=1){var o=e[t];o.close()}},r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.authorize=function(e){this.channel.authorize(e)},r.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri)},r.prototype.link=function(e,t,n){var i=this.channel.link(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.sync=function(e,t,n){var i=this.channel.sync(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.syncList=function(e,t,n){var i=this.channel.syncList(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.syncMap=function(e,t,n){var i=this.channel.syncMap(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.command=function(e,t,n){this.channel.command(o.resolveNodeUri(this.hostUri,e),t,n)},r.prototype.node=function(e){return new s(this.channel,this.hostUri,o.resolveNodeUri(this.hostUri,e))},r.prototype.lane=function(e,t){return new a(this.channel,this.hostUri,o.resolveNodeUri(this.hostUri,e),t)},s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri).node(this.nodeUri)},s.prototype.link=function(e,t){var n=this.channel.link(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.sync=function(e,t){var n=this.channel.sync(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.syncList=function(e,t){var n=this.channel.syncList(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.syncMap=function(e,t){var n=this.channel.syncMap(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.command=function(e,t){this.channel.command(this.nodeUri,e,t)},s.prototype.lane=function(e){return new a(this.channel,this.hostUri,this.nodeUri,e)},a.prototype=Object.create(i.prototype),a.prototype.constructor=a,a.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri).node(this.nodeUri).lane(this.laneUri)},a.prototype.link=function(e){var t=this.channel.link(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.sync=function(e){var t=this.channel.sync(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.syncList=function(e){var t=this.channel.syncList(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.syncMap=function(e){var t=this.channel.syncMap(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.command=function(e){this.channel.command(this.nodeUri,this.laneUri,e)},Object.defineProperty(h.prototype,"protocols",{get:function(){return this.options.protocols}}),Object.defineProperty(h.prototype,"maxReconnectTimeout",{get:function(){return this.options.maxReconnectTimeout||3e4}}),Object.defineProperty(h.prototype,"idleTimeout",{get:function(){return this.options.idleTimeout||1e3}}),Object.defineProperty(h.prototype,"sendBufferSize",{get:function(){return this.options.sendBufferSize||1024}}),Object.defineProperty(h.prototype,"isConnected",{get:function(){return this.socket&&this.socket.readyState===this.socket.OPEN},enumerable:!0}),h.prototype.resolve=function(e){return this.uriCache.resolve(e)},h.prototype.unresolve=function(e){return this.uriCache.unresolve(e)},h.prototype.authorize=function(e){if(!b.equal(e,this.credentials))if(this.credentials=e,this.isConnected){var t=new g.AuthRequest(e);this.push(t)}else this.open()},h.prototype.link=function(e,t,n){var o=new p(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.sync=function(e,t,n){var o=new u(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.syncList=function(e,t,n){var o=new d(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.syncMap=function(e,t,n){var o=new f(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.command=function(e,t,n){var o=new g.CommandMessage(this.unresolve(e),t,n);this.push(o)},h.prototype.registerDelegate=function(e){this.delegates.push(e)},h.prototype.unregisterDelegate=function(e){for(var t=0,n=this.delegates.length;n>t;t+=1)this.delegates[t]===e&&this.delegates.splice(t,1)},h.prototype.registerDownlink=function(e){this.clearIdle();var t=e.nodeUri,n=e.laneUri,o=this.downlinks[t]||{},i=o[n]||[];i.push(e),o[n]=i,this.downlinks[t]=o,this.isConnected?e.onChannelConnect({hostUri:this.hostUri}):this.open()},h.prototype.unregisterDownlink=function(e){var t=e.nodeUri,n=e.laneUri,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=0,s=i.length;s>r;r+=1)if(i[r]===e){if(i.splice(r,1),0===i.length&&(delete o[n],0===Object.keys(o).length&&(delete this.downlinks[t],this.watchIdle()),this.isConnected)){var a=new g.UnlinkRequest(this.unresolve(t),n);e.onUnlinkRequest(a),this.push(a)}e.onChannelClose()}}},h.prototype.onEnvelope=function(e){e.isEventMessage?this.onEventMessage(e):e.isCommandMessage?this.onCommandMessage(e):e.isLinkRequest?this.onLinkRequest(e):e.isLinkedResponse?this.onLinkedResponse(e):e.isSyncRequest?this.onSyncRequest(e):e.isSyncedResponse?this.onSyncedResponse(e):e.isUnlinkRequest?this.onUnlinkRequest(e):e.isUnlinkedResponse?this.onUnlinkedResponse(e):e.isAuthRequest?this.onAuthRequest(e):e.isAuthedResponse?this.onAuthedResponse(e):e.isDeauthRequest?this.onDeauthRequest(e):e.isDeauthedResponse&&this.onDeauthedResponse(e)},h.prototype.onEventMessage=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onEventMessage(r)}}},h.prototype.onCommandMessage=function(e){},h.prototype.onLinkRequest=function(e){},h.prototype.onLinkedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onLinkedResponse(r)}}},h.prototype.onSyncRequest=function(e){},h.prototype.onSyncedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onSyncedResponse(r)}}},h.prototype.onUnlinkRequest=function(e){},h.prototype.onUnlinkedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i){delete o[n],0===Object.keys(o).length&&delete this.downlinks[t];for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onUnlinkedResponse(r),h.onChannelClose()}}}},h.prototype.onAuthRequest=function(e){},h.prototype.onAuthedResponse=function(e){this.isAuthorized=!0,this.session=e.body;var t={hostUri:this.hostUri,session:this.session};this.client.onChannelAuthorize(t);for(var n=0,o=this.delegates.length;o>n;n+=1){var i=this.delegates[n];i.onChannelAuthorize(t)}},h.prototype.onDeauthRequest=function(e){},h.prototype.onDeauthedResponse=function(e){this.isAuthorized=!1,this.session=null;var t={hostUri:this.hostUri,session:e.body};this.client.onChannelDeauthorize(t);for(var n=0,o=this.delegates.length;o>n;n+=1){var i=this.delegates[n];i.onChannelDeauthorize(t)}},h.prototype.onConnect=function(){var e={hostUri:this.hostUri};this.client.onChannelConnect(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelConnect(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s];for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelConnect(e)}}}},h.prototype.onDisconnect=function(){var e={hostUri:this.hostUri};this.client.onChannelDisconnect(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelDisconnect(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s].slice();for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelDisconnect(e)}}}},h.prototype.onError=function(){var e={hostUri:this.hostUri};this.client.onChannelError(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelError(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s];for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelError(e)}}}},h.prototype.open=function(){this.clearReconnect(),this.socket||(this.socket=this.protocols?new m(this.hostUri,this.protocols):new m(this.hostUri),this.socket.onopen=this.onWebSocketOpen.bind(this),this.socket.onmessage=this.onWebSocketMessage.bind(this),this.socket.onerror=this.onWebSocketError.bind(this),this.socket.onclose=this.onWebSocketClose.bind(this))},h.prototype.close=function(){this.clearReconnect(),this.clearIdle(),this.socket&&(this.socket.close(),this.socket=null);var e=this.downlinks;Object.defineProperty(this,"downlinks",{value:{},configurable:!0});for(var t in e){var n=e[t];for(var o in n)for(var i=n[o],r=0,s=i.length;s>r;r+=1){var a=i[r];a.onChannelClose()}}},h.prototype.reconnect=function(){if(!this.reconnectTimer){if(this.reconnectTimeout){var e=this.maxReconnectTimeout||3e4;this.reconnectTimeout=Math.min(1.8*this.reconnectTimeout,e)}else{var t=1e3*Math.random();this.reconnectTimeout=500+t}this.reconnectTimer=setTimeout(this.open.bind(this),this.reconnectTimeout)}},h.prototype.clearReconnect=function(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.reconnectTimeout=0)},h.prototype.clearIdle=function(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)},h.prototype.watchIdle=function(){this.isConnected&&0===this.sendBuffer.length&&0===Object.keys(this.downlinks).length&&(this.idleTimer=setTimeout(this.checkIdle.bind(this),this.idleTimeout))},h.prototype.checkIdle=function(){0===this.sendBuffer.length&&0===Object.keys(this.downlinks).length&&this.close()},h.prototype.push=function(e){if(this.isConnected){this.clearIdle();var t=g.stringify(e);this.socket.send(t),this.watchIdle()}else e.isCommandMessage&&(this.sendBuffer.length<this.sendBufferSize&&this.sendBuffer.push(e),this.open())},h.prototype.onWebSocketOpen=function(){if(this.credentials){var e=new g.AuthRequest(this.credentials);this.push(e)}this.onConnect();for(var t;t=this.sendBuffer.shift();)this.push(t);this.watchIdle()},h.prototype.onWebSocketMessage=function(e){var t=e.data;if("string"==typeof t){var n=g.parse(t);n&&this.onEnvelope(n)}},h.prototype.onWebSocketError=function(){this.onError(),this.clearIdle(),this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.close(),this.socket=null)},h.prototype.onWebSocketClose=function(){this.isAuthorized=!1,this.session=null,this.socket=null,this.onDisconnect(),this.clearIdle(),(this.sendBuffer.length>0||Object.keys(this.downlinks).length>0)&&this.reconnect()},c.prototype.host=function(e){return this.hostUri=e,this},c.prototype.node=function(e){return this.nodeUri=e,this},c.prototype.lane=function(e){return this.laneUri=e,this},c.prototype.prio=function(e){return this.options.prio=e,this},c.prototype.keepAlive=function(){return this.options.keepAlive=!0,this},c.prototype.delegate=function(e){return this.options.delegate=e,this},c.prototype.onEvent=function(e){return this.proxy.onEvent=e,this},c.prototype.onCommand=function(e){return this.proxy.onCommand=e,this},c.prototype.onLink=function(e){return this.proxy.onLink=e,this},c.prototype.onLinked=function(e){return this.proxy.onLinked=e,this},c.prototype.onSync=function(e){return this.proxy.onSync=e,this},c.prototype.onSynced=function(e){return this.proxy.onSynced=e,this},c.prototype.onUnlink=function(e){return this.proxy.onUnlink=e,this},c.prototype.onUnlinked=function(e){return this.proxy.onUnlinked=e,this},c.prototype.onConnect=function(e){return this.proxy.onConnect=e,this},c.prototype.onDisconnect=function(e){return this.proxy.onDisconnect=e,this},c.prototype.onError=function(e){return this.proxy.onError=e,this},c.prototype.onClose=function(e){return this.proxy.onClose=e,this},c.prototype.primaryKey=function(e){return this.options.primaryKey=e,this},c.prototype.sortBy=function(e){return this.options.sortBy=e,this},Object.defineProperty(c.prototype,"normalize",{value:function(){this.hostUri?this.nodeUri=o.resolveNodeUri(this.hostUri,this.nodeUri):this.hostUri=o.extractHostUri(this.nodeUri),this.channel||(Object.defineProperty(this,"channel",{value:this.scope.getOrCreateChannel(this.hostUri),configurable:!0}),Object.defineProperty(this,"scope",{value:null,configurable:!0}))},configurable:!0}),Object.defineProperty(c.prototype,"registerDownlink",{value:function(e){for(var t in this.proxy)e[t]=this.proxy[t];this.channel.registerDownlink(e),this.scope&&this.scope.registerDownlink(e)},configure:!0}),c.prototype.link=function(){this.normalize();var e=new p(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.sync=function(){this.normalize();var e=new u(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.syncList=function(){this.normalize();var e=new d(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.syncMap=function(){this.normalize();var e=new f(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},Object.defineProperty(l.prototype,"prio",{get:function(){return this.options.prio||0}}),Object.defineProperty(l.prototype,"keepAlive",{get:function(){return this.options.keepAlive||!1},set:function(e){this.options.keepAlive=e}}),Object.defineProperty(l.prototype,"isConnected",{get:function(){return this.channel.isConnected},enumerable:!0}),Object.defineProperty(l.prototype,"isAuthorized",{get:function(){return this.channel.isAuthorized},enumerable:!0}),Object.defineProperty(l.prototype,"session",{ | ||
get:function(){return this.channel.session},enumerable:!0}),Object.defineProperty(l.prototype,"onEventMessage",{value:function(e){"function"==typeof this.delegate.onEvent&&this.delegate.onEvent(e)},configurable:!0}),Object.defineProperty(l.prototype,"onCommandMessage",{value:function(e){"function"==typeof this.delegate.onCommand&&this.delegate.onCommand(e)},configurable:!0}),Object.defineProperty(l.prototype,"onLinkRequest",{value:function(e){"function"==typeof this.delegate.onLink&&this.delegate.onLink(e)},configurable:!0}),Object.defineProperty(l.prototype,"onLinkedResponse",{value:function(e){"function"==typeof this.delegate.onLinked&&this.delegate.onLinked(e)},configurable:!0}),Object.defineProperty(l.prototype,"onSyncRequest",{value:function(e){"function"==typeof this.delegate.onSync&&this.delegate.onSync(e)},configurable:!0}),Object.defineProperty(l.prototype,"onSyncedResponse",{value:function(e){"function"==typeof this.delegate.onSynced&&this.delegate.onSynced(e)},configurable:!0}),Object.defineProperty(l.prototype,"onUnlinkRequest",{value:function(e){"function"==typeof this.delegate.onUnlink&&this.delegate.onUnlink(e)},configurable:!0}),Object.defineProperty(l.prototype,"onUnlinkedResponse",{value:function(e){"function"==typeof this.delegate.onUnlinked&&this.delegate.onUnlinked(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.delegate.onConnect(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.delegate.onDisconnect(e),this.keepAlive||this.close()},configurable:!0}),Object.defineProperty(l.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.delegate.onError(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelClose",{value:function(){"function"==typeof this.delegate.onClose&&this.delegate.onClose()},configurable:!0}),l.prototype.close=function(){this.channel.unregisterDownlink(this)},p.prototype=Object.create(l.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"onChannelConnect",{value:function(e){l.prototype.onChannelConnect.call(this,e);var t=this.channel.unresolve(this.nodeUri),n=new g.LinkRequest(t,this.laneUri,this.prio);this.onLinkRequest(n),this.channel.push(n)},configurable:!0}),u.prototype=Object.create(l.prototype),u.prototype.constructor=u,Object.defineProperty(u.prototype,"onChannelConnect",{value:function(e){l.prototype.onChannelConnect.call(this,e);var t=this.channel.unresolve(this.nodeUri),n=new g.SyncRequest(t,this.laneUri,this.prio);this.onSyncRequest(n),this.channel.push(n)},configurable:!0}),d.prototype=Object.create(u.prototype),d.prototype.constructor=d,Object.defineProperty(d.prototype,"onEventMessage",{value:function(e){var t,n,o,i=b.tag(e.body);if("@update"===i)t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteUpdate(n,o);else if("@insert"===i)t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteInsert(n,o);else if("@move"===i){t=b.head(e.body);var r=b.get(t,"from"),s=b.get(t,"to");o=b.tail(e.body),this.remoteMove(r,s,o)}else"@remove"===i||"@delete"===i?(t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteRemove(n,o)):"@clear"===i&&1===b.size(e.body)?this.remoteClear():this.remoteAppend(e.body);u.prototype.onEventMessage.call(this,e)},configurable:!0}),Object.defineProperty(d.prototype,"remoteAppend",{value:function(e){this.state.push(e)},configurable:!0}),Object.defineProperty(d.prototype,"remoteUpdate",{value:function(e,t){this.state[e]=t},configurable:!0}),Object.defineProperty(d.prototype,"remoteInsert",{value:function(e,t){b.equal(this.state[e],t)||this.state.splice(e,0,t)},configurable:!0}),Object.defineProperty(d.prototype,"remoteMove",{value:function(e,t,n){b.equal(this.state[t],n)||(this.state.splice(e,1),this.state.splice(t,0,n))},configurable:!0}),Object.defineProperty(d.prototype,"remoteRemove",{value:function(e,t){b.equal(this.state[e],t)&&this.state.splice(e,1)},configurable:!0}),Object.defineProperty(d.prototype,"remoteClear",{value:function(e,t){Object.defineProperty(this,"state",{value:[],configurable:!0})},configurable:!0}),Object.defineProperty(d.prototype,"length",{get:function(){return this.state.length},configurable:!0,enumerable:!0}),d.prototype.get=function(e){return this.state[e]},d.prototype.set=function(e,t){this.state[e]=t;var n=this.channel.unresolve(this.nodeUri),o=b.concat(b({"@update":b({index:e})}),t),i=new g.CommandMessage(n,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)},d.prototype.push=function(){for(var e=this.channel.unresolve(this.nodeUri),t=0,n=arguments.length;n>t;t+=1){var o=arguments[t];this.state.push(o);var i=new g.CommandMessage(e,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return this.state.length},d.prototype.pop=function(){var e=this.state.pop(),t=this.state.length;if(void 0!==e){var n=this.channel.unresolve(this.nodeUri),o=b.concat(b({"@remove":b({index:t})}),e),i=new g.CommandMessage(n,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return e},d.prototype.unshift=function(){for(var e=this.channel.unresolve(this.nodeUri),t=arguments.length-1;t>=0;t-=1){var n=arguments[t];this.state.unshift(n);var o=b.concat(b({"@insert":b({index:0})}),n),i=new g.CommandMessage(e,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return this.state.length},d.prototype.shift=function(){var e=this.state.shift();if(void 0!==e){var t=this.channel.unresolve(this.nodeUri),n=b.concat(b({"@remove":b({index:0})}),e),o=new g.CommandMessage(t,this.laneUri,n);this.onCommandMessage(o),this.channel.push(o)}return e},d.prototype.move=function(e,t){var n=this.state.splice(e,1);if(1===n.length){var o=n[0];this.state.splice(t,0,o);var i=this.channel.unresolve(this.nodeUri),r=b.concat(b({"@move":b({from:e,to:t})}),o),s=new g.CommandMessage(i,this.laneUri,r);this.onCommandMessage(s),this.channel.push(s)}},d.prototype.splice=function(){var e,t,n,o,i,r=arguments[0],s=arguments[1],a=this.channel.unresolve(this.nodeUri),h=[];for(e=r;r+s>e;e+=1)n=this.state[e],void 0!==n&&(h.push(n),this.state.splice(r,1),o=b.concat(b({"@remove":b({index:r})}),n),i=new g.CommandMessage(a,this.laneUri,o),this.onCommandMessage(i),this.channel.push(i));for(e=2,t=arguments.length;t>e;e+=1){var c=r+e-2;n=arguments[e],this.state.splice(c,0,n),o=b.concat(b({"@insert":b({index:c})}),n),i=new g.CommandMessage(a,this.laneUri,o),this.onCommandMessage(i),this.channel.push(i)}return h},d.prototype.clear=function(){Object.defineProperty(this,"state",{value:[],configurable:!0});var e=this.channel.unresolve(this.nodeUri),t=new g.CommandMessage(e,this.laneUri,[{"@clear":null}]);return this.onCommandMessage(t),this.channel.push(t),this},d.prototype.forEach=function(e,t){for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n];e.call(t,i,n,this)}},f.prototype=Object.create(u.prototype),f.prototype.constructor=f,Object.defineProperty(f.prototype,"onEventMessage",{value:function(e){var t,n=b.tag(e.body);if("@remove"===n||"@delete"===n){var o=b.tail(e.body);t=this.primaryKey(o),void 0!==t&&this.remoteDelete(t)}else"@clear"===n&&1===b.size(e.body)?this.remoteClear():(t=this.primaryKey(e.body),void 0!==t&&this.remoteSet(t,e.body));u.prototype.onEventMessage.call(this,e)},configurable:!0}),Object.defineProperty(f.prototype,"remoteSet",{value:function(e,t){"string"==typeof e&&(this.table[e]=t);for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n],r=this.primaryKey(i);if(b.equal(e,r)){this.state[n]=t;break}}n===o&&this.state.push(t),this.sort()},configurable:!0}),Object.defineProperty(f.prototype,"remoteDelete",{value:function(e){"string"==typeof e&&delete this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return void this.state.splice(t,1)}},configurable:!0}),Object.defineProperty(f.prototype,"remoteClear",{value:function(e){Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0})},configurable:!0}),Object.defineProperty(f.prototype,"size",{get:function(){return this.state.length},configurable:!0,enumerable:!0}),f.prototype.has=function(e){if("string"==typeof e)return void 0!==this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return!0}return!1},f.prototype.get=function(e){if("string"==typeof e)return this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return o}},f.prototype.set=function(e,t){"string"==typeof e&&(this.table[e]=t);for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n],r=this.primaryKey(i);if(b.equal(e,r)){this.state[n]=t;break}}n===o&&this.state.push(t),this.sort();var s=this.channel.unresolve(this.nodeUri),a=new g.CommandMessage(s,this.laneUri,t);return this.onCommandMessage(a),this.channel.push(a),this},f.prototype["delete"]=function(e){"string"==typeof e&&delete this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i)){this.state.splice(t,1);var r=this.channel.unresolve(this.nodeUri),s=b.concat(b({"@remove":null}),o),a=new g.CommandMessage(r,this.laneUri,s);return this.onCommandMessage(a),this.channel.push(a),!0}}return!1},f.prototype.clear=function(){Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0});var e=this.channel.unresolve(this.nodeUri),t=new g.CommandMessage(e,this.laneUri,[{"@clear":null}]);return this.onCommandMessage(t),this.channel.push(t),this},f.prototype.sort=function(){this.sortBy&&this.state.sort(this.sortBy)},f.prototype.keys=function(){for(var e=[],t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);void 0!==i&&e.push(i)}return e},f.prototype.values=function(){return this.state},f.prototype.forEach=function(e,t){for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n];e.call(t,i,this)}},f.primaryKeyOption=function(e){if("function"==typeof e.primaryKey)return e.primaryKey;if("string"==typeof e.primaryKey){var t=e.primaryKey.split(".");return function(e){for(var n=0,o=t.length;o>n;n+=1){var i=t[n];e=b.get(e,i)}return e}}return f.identityKey},f.identityKey=function(e){return e},f.sortByOption=function(e){if("function"==typeof e.sortBy)return e.sortBy;if("string"==typeof e.sortBy){var t=e.sortBy.split(".");return function(e,n){for(var o=0,i=t.length;i>o;o+=1){var r=t[o];return e=b.get(e,r),n=b.get(n,r),b.compare(e,n)}}}},y.prototype.resolve=function(e){var t=Math.abs(y.hash(e)%this.size),n=this.resolveCache[t];if(n&&n.unresolved===e)return n.resolved;var o=b.uri.stringify(b.uri.resolve(this.base,e));return this.resolveCache[t]={unresolved:e,resolved:o},o},y.prototype.unresolve=function(e){var t=Math.abs(y.hash(e)%this.size),n=this.unresolveCache[t];if(n&&n.resolved===e)return n.unresolved;var o=b.uri.stringify(b.uri.unresolve(this.base,e));return this.unresolveCache[t]={unresolved:o,resolved:e},o},y.rotl=function(e,t){return e<<t|e>>>32-t},y.mix=function(e,t){return t*=3432918353,t=y.rotl(t,15),t*=461845907,e^=t,e=y.rotl(e,13),e=5*e+3864292196},y.mash=function(e){return e^=e>>>16,e*=2246822507,e^=e>>>13,e*=3266489909,e^=e>>>16},y.hash=function(e){for(var t=0,n=0,o=e.length;o>n;n+=1)t=y.mix(t,e.charAt(n));return t=y.mash(t)};var k=new o;k.client=function(e){return new o(e)},k.config=v,t.exports=k}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./config.json":1,"recon-js":"recon-js","swim-proto-js":4,websocket:2}]},{},[])("swim-client-js")}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.swim=e()}}(function(){return function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,o)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,n){t.exports={version:"0.4.5"}},{}],2:[function(e,t,n){},{}],3:[function(e,t,n){t.exports={version:"0.4.2"}},{}],4:[function(e,t,n){(function(t){"use strict";function o(e){switch(U.tag(e)){case"@event":return p.decode(e);case"@command":return u.decode(e);case"@link":return d.decode(e);case"@linked":return f.decode(e);case"@sync":return y.decode(e);case"@synced":return v.decode(e);case"@unlink":return b.decode(e);case"@unlinked":return g.decode(e);case"@auth":return m.decode(e);case"@authed":return k.decode(e);case"@deauth":return O.decode(e);case"@deauthed":return j.decode(e)}}function i(e){return e.encode()}function r(e){return o(U.parse(e))}function s(e){return U.stringify(i(e))}function a(){}function h(){a.call(this)}function c(){a.call(this)}function l(){a.call(this)}function p(e,t,n){l.call(this),this.node=e,this.lane=t,this.body=n}function u(e,t,n){l.call(this),this.node=e,this.lane=t,this.body=n}function d(e,t,n,o){h.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function f(e,t,n,o){c.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function y(e,t,n,o){h.call(this),this.node=e,this.lane=t,this.prio=n||0,this.body=o}function v(e,t,n){c.call(this),this.node=e,this.lane=t,this.body=n}function b(e,t,n){h.call(this),this.node=e,this.lane=t,this.body=n}function g(e,t,n){c.call(this),this.node=e,this.lane=t,this.body=n}function m(e){h.call(this),this.body=e}function k(e){c.call(this),this.body=e}function O(e){h.call(this),this.body=e}function j(e){c.call(this),this.body=e}var w=e("./config.json"),U=t.recon||e("recon-js");Object.defineProperty(a.prototype,"isRequest",{value:!1}),Object.defineProperty(a.prototype,"isResponse",{value:!1}),Object.defineProperty(a.prototype,"isMessage",{value:!1}),Object.defineProperty(a.prototype,"isEventMessage",{value:!1}),Object.defineProperty(a.prototype,"isCommandMessage",{value:!1}),Object.defineProperty(a.prototype,"isLinkRequest",{value:!1}),Object.defineProperty(a.prototype,"isLinkedResponse",{value:!1}),Object.defineProperty(a.prototype,"isSyncRequest",{value:!1}),Object.defineProperty(a.prototype,"isSyncedResponse",{value:!1}),Object.defineProperty(a.prototype,"isUnlinkRequest",{value:!1}),Object.defineProperty(a.prototype,"isUnlinkedResponse",{value:!1}),Object.defineProperty(a.prototype,"isAuthRequest",{value:!1}),Object.defineProperty(a.prototype,"isAuthedResponse",{value:!1}),Object.defineProperty(a.prototype,"isDeauthRequest",{value:!1}),Object.defineProperty(a.prototype,"isDeauthedResponse",{value:!1}),h.prototype=Object.create(a.prototype),h.prototype.constructor=h,Object.defineProperty(h.prototype,"isRequest",{value:!0}),c.prototype=Object.create(a.prototype),c.prototype.constructor=c,Object.defineProperty(c.prototype,"isResponse",{value:!0}),l.prototype=Object.create(a.prototype),l.prototype.constructor=l,Object.defineProperty(l.prototype,"isMessage",{value:!0}),p.prototype=Object.create(l.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"isEventMessage",{value:!0}),p.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new p(e,t,this.body)},p.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@event":e},this.body)},p.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new p(t,n,o):void 0},u.prototype=Object.create(l.prototype),u.prototype.constructor=u,Object.defineProperty(u.prototype,"isCommandMessage",{value:!0}),u.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new u(e,t,this.body)},u.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@command":e},this.body)},u.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new u(t,n,o):void 0},d.prototype=Object.create(h.prototype),d.prototype.constructor=d,Object.defineProperty(d.prototype,"isLinkRequest",{value:!0}),d.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new d(e,t,this.prio,this.body)},d.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@link":e},this.body)},d.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new d(t,n,o,i):void 0},f.prototype=Object.create(c.prototype),f.prototype.constructor=f,Object.defineProperty(f.prototype,"isLinkedResponse",{value:!0}),f.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new f(e,t,this.prio,this.body)},f.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@linked":e},this.body)},f.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new f(t,n,o,i):void 0},y.prototype=Object.create(h.prototype),y.prototype.constructor=y,Object.defineProperty(y.prototype,"isSyncRequest",{value:!0}),y.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new y(e,t,this.prio,this.body)},y.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return this.prio&&e.push({prio:this.prio}),U.concat({"@sync":e},this.body)},y.decode=function(e){for(var t,n,o,i=U.tail(e),r=U.head(e),s=r&&r.length||0,a=0;s>a;a+=1){var h=r[a];void 0!==h.node?t=h.node:void 0!==h.lane?n=h.lane:void 0!==h.prio?o=h.prio:0===a?t=h:1===a&&(n=h)}return void 0!==t&&void 0!==n?new y(t,n,o,i):void 0},v.prototype=Object.create(c.prototype),v.prototype.constructor=v,Object.defineProperty(v.prototype,"isSyncedResponse",{value:!0}),v.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new v(e,t,this.body)},v.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@synced":e},this.body)},v.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new v(t,n,o):void 0},b.prototype=Object.create(h.prototype),b.prototype.constructor=b,Object.defineProperty(b.prototype,"isUnlinkRequest",{value:!0}),b.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new b(e,t,this.body)},b.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@unlink":e},this.body)},b.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new b(t,n,o):void 0},g.prototype=Object.create(c.prototype),g.prototype.constructor=g,Object.defineProperty(g.prototype,"isUnlinkedResponse",{value:!0}),g.prototype.withAddress=function(e,t){return void 0===e&&(e=this.node),void 0===t&&(t=this.lane),new g(e,t,this.body)},g.prototype.encode=function(){var e=[{node:this.node},{lane:this.lane}];return U.concat({"@unlinked":e},this.body)},g.decode=function(e){for(var t,n,o=U.tail(e),i=U.head(e),r=i&&i.length||0,s=0;r>s;s+=1){var a=i[s];void 0!==a.node?t=a.node:void 0!==a.lane?n=a.lane:0===s?t=a:1===s&&(n=a)}return void 0!==t&&void 0!==n?new g(t,n,o):void 0},m.prototype=Object.create(h.prototype),m.prototype.constructor=m,Object.defineProperty(m.prototype,"isAuthRequest",{value:!0}),m.prototype.encode=function(){return U.concat({"@auth":null},this.body)},m.decode=function(e){var t=U.tail(e);return new m(t)},k.prototype=Object.create(c.prototype),k.prototype.constructor=k,Object.defineProperty(k.prototype,"isAuthedResponse",{value:!0}),k.prototype.encode=function(){return U.concat({"@authed":null},this.body)},k.decode=function(e){var t=U.tail(e);return new k(t)},O.prototype=Object.create(h.prototype),O.prototype.constructor=O,Object.defineProperty(O.prototype,"isDeauthRequest",{value:!0}),O.prototype.encode=function(){return U.concat({"@deauth":null},this.body)},O.decode=function(e){var t=U.tail(e);return new O(t)},j.prototype=Object.create(c.prototype),j.prototype.constructor=j,Object.defineProperty(j.prototype,"isDeauthedResponse",{value:!0}),j.prototype.encode=function(){return U.concat({"@deauthed":null},this.body)},j.decode=function(e){var t=U.tail(e);return new j(t)},n.decode=o,n.encode=i,n.parse=r,n.stringify=s,n.Envelope=a,n.RequestEnvelope=h,n.ResponseEnvelope=c,n.MessageEnvelope=l,n.EventMessage=p,n.CommandMessage=u,n.SyncRequest=y,n.SyncedResponse=v,n.LinkRequest=d,n.LinkedResponse=f,n.UnlinkRequest=b,n.UnlinkedResponse=g,n.AuthRequest=m,n.AuthedResponse=k,n.DeauthRequest=O,n.DeauthedResponse=j,n.config=w}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./config.json":3,"recon-js":"recon-js"}],"swim-client-js":[function(e,t,n){(function(n){"use strict";function o(e){e=e||{},Object.defineProperty(this,"options",{value:e,enumerable:!0}),Object.defineProperty(this,"channels",{value:{},configurable:!0}),Object.defineProperty(this,"delegate",{value:this,enumerable:!0,writable:!0})}function i(e){Object.defineProperty(this,"channel",{value:e}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0}),Object.defineProperty(this,"delegate",{value:this,enumerable:!0,writable:!0}),e.registerDelegate(this)}function r(e,t){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function s(e,t,n){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function a(e,t,n,o){i.call(this,e),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"laneUri",{value:o,enumerable:!0}),Object.defineProperty(this,"downlinks",{value:[],configurable:!0})}function h(e,t,n){n=n||{},Object.defineProperty(this,"client",{value:e,configurable:!0}),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"options",{value:n,enumerable:!0}),Object.defineProperty(this,"credentials",{value:n.credentials,writable:!0}),Object.defineProperty(this,"isAuthorized",{value:!1,enumerable:!0,writable:!0}),Object.defineProperty(this,"session",{value:null,enumerable:!0,writable:!0}),Object.defineProperty(this,"uriCache",{value:new y(t),configurable:!0}),Object.defineProperty(this,"delegates",{value:[],configurable:!0}),Object.defineProperty(this,"downlinks",{value:{},configurable:!0}),Object.defineProperty(this,"sendBuffer",{value:[],configurable:!0}),Object.defineProperty(this,"reconnectTimer",{value:null,writable:!0}),Object.defineProperty(this,"reconnectTimeout",{value:0,writable:!0}),Object.defineProperty(this,"idleTimer",{value:null,writable:!0}),Object.defineProperty(this,"socket",{value:null,writable:!0})}function c(e,t){Object.defineProperty(this,"channel",{value:e,configurable:!0}),Object.defineProperty(this,"scope",{value:t,configurable:!0}),Object.defineProperty(this,"proxy",{value:{},configurable:!0}),this.options={}}function l(e,t,n,o,i){i=i||{},Object.defineProperty(this,"channel",{value:e}),Object.defineProperty(this,"hostUri",{value:t,enumerable:!0}),Object.defineProperty(this,"nodeUri",{value:n,enumerable:!0}),Object.defineProperty(this,"laneUri",{value:o,enumerable:!0}),Object.defineProperty(this,"options",{value:i,enumerable:!0}),Object.defineProperty(this,"delegate",{value:i.delegate||this,enumerable:!0,writable:!0})}function p(e,t,n,o,i){l.call(this,e,t,n,o,i)}function u(e,t,n,o,i){l.call(this,e,t,n,o,i)}function d(e,t,n,o,i){u.call(this,e,t,n,o,i),Object.defineProperty(this,"state",{value:[],configurable:!0})}function f(e,t,n,o,i){u.call(this,e,t,n,o,i),Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0}),this.primaryKey=f.primaryKeyOption(this.options),this.sortBy=f.sortByOption(this.options)}function y(e,t){t=t||32,Object.defineProperty(this,"baseUri",{value:e,enumerable:!0}),Object.defineProperty(this,"base",{value:b.uri.parse(e)}),Object.defineProperty(this,"size",{value:t,enumerable:!0}),Object.defineProperty(this,"resolveCache",{value:new Array(t)}),Object.defineProperty(this,"unresolveCache",{value:new Array(t)})}var v=e("./config.json"),b=n.recon||e("recon-js"),g=e("swim-proto-js"),m=n.WebSocket||e("websocket").w3cwebsocket;Object.defineProperty(o.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.onConnect(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.onDisconnect(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.onError(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelAuthorize",{value:function(e){"function"==typeof this.delegate.onAuthorize&&this.onAuthorize(e)},configurable:!0}),Object.defineProperty(o.prototype,"onChannelDeauthorize",{value:function(e){"function"==typeof this.delegate.onDeauthorize&&this.onDeauthorize(e)},configurable:!0}),Object.defineProperty(o.prototype,"callChannelWithLinkArgs",{value:function(e,t){var n,i,r,s;2===t.length?(s={},r=t[1],i=t[0],n=o.extractHostUri(i)):3===t.length?"object"==typeof t[2]?(s=t[2],r=t[1],i=t[0],n=o.extractHostUri(i)):(n=t[0],i=o.resolveNodeUri(n,t[1]),r=t[2],s={}):(n=t[0],i=o.resolveNodeUri(n,t[1]),r=t[2],s=t[3]);var a=this.getOrCreateChannel(n);return a[e](i,r,s)},configurable:!0}),o.prototype.getOrCreateChannel=function(e){var t=this.channels[e];return void 0===t&&(t=new h(this,e,this.options),this.channels[e]=t),t},o.prototype.authorize=function(e,t){var n=this.getOrCreateChannel(e);n.authorize(t)},o.prototype.downlink=function(){return new c(null,this)},o.prototype.link=function(){return this.callChannelWithLinkArgs("link",arguments)},o.prototype.sync=function(){return this.callChannelWithLinkArgs("sync",arguments)},o.prototype.syncList=function(){return this.callChannelWithLinkArgs("syncList",arguments)},o.prototype.syncMap=function(){return this.callChannelWithLinkArgs("syncMap",arguments)},o.prototype.command=function(){var e,t,n,i;3===arguments.length?(i=arguments[2],n=arguments[1],t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]),n=arguments[2],i=arguments[3]);var r=this.getOrCreateChannel(e);r.command(t,n,i)},o.prototype.host=function(e){var t=this.getOrCreateChannel(e);return new r(t,e)},o.prototype.node=function(){var e,t;1===arguments.length?(t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]));var n=this.getOrCreateChannel(e);return new s(n,e,t)},o.prototype.lane=function(){var e,t,n;2===arguments.length?(n=arguments[1],t=arguments[0],e=o.extractHostUri(t)):(e=arguments[0],t=o.resolveNodeUri(e,arguments[1]),n=arguments[2]);var i=this.getOrCreateChannel(e);return new a(i,e,t,n)},o.prototype.close=function(){var e=this.channels;Object.defineProperty(this,"channels",{value:{},configurable:!0});for(var t in e){var n=e[t];n.close()}},o.extractHostUri=function(e){var t=b.uri.parse(e),n=t.scheme;return"swim"===n?n="ws":"swims"===n&&(n="wss"),b.uri.stringify({scheme:n,authority:t.authority})},o.resolveNodeUri=function(e,t){return b.uri.stringify(b.uri.resolve(e,t))},Object.defineProperty(i.prototype,"isConnected",{get:function(){return this.channel.isConnected},enumerable:!0}),Object.defineProperty(i.prototype,"isAuthorized",{get:function(){return this.channel.isAuthorized},enumerable:!0}),Object.defineProperty(i.prototype,"session",{get:function(){return this.channel.session},enumerable:!0}),Object.defineProperty(i.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.onConnect(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.onDisconnect(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.onError(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelAuthorize",{value:function(e){"function"==typeof this.delegate.onAuthorize&&this.onAuthorize(e)},configurable:!0}),Object.defineProperty(i.prototype,"onChannelDeauthorize",{value:function(e){"function"==typeof this.delegate.onDeauthorize&&this.onDeauthorize(e)},configurable:!0}),i.prototype.registerDownlink=function(e){var t=this;Object.defineProperty(e,"onChannelClose",{value:function(){t.unregisterDownlink(e),e.__proto__.onChannelClose.call(e)},configurable:!0}),this.downlinks.push(e)},i.prototype.unregisterDownlink=function(e){for(var t=0,n=this.downlinks.length;n>t;t+=1)if(e===this.downlinks[t])return void this.downlinks.splice(t,1)},i.prototype.close=function(){this.channel.unregisterDelegate(this);var e=this.downlinks;Object.defineProperty(this,"downlinks",{value:[],configurable:!0});for(var t=0,n=e.length;n>t;t+=1){var o=e[t];o.close()}},r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.authorize=function(e){this.channel.authorize(e)},r.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri)},r.prototype.link=function(e,t,n){var i=this.channel.link(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.sync=function(e,t,n){var i=this.channel.sync(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.syncList=function(e,t,n){var i=this.channel.syncList(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.syncMap=function(e,t,n){var i=this.channel.syncMap(o.resolveNodeUri(this.hostUri,e),t,n);return this.registerDownlink(i),i},r.prototype.command=function(e,t,n){this.channel.command(o.resolveNodeUri(this.hostUri,e),t,n)},r.prototype.node=function(e){return new s(this.channel,this.hostUri,o.resolveNodeUri(this.hostUri,e))},r.prototype.lane=function(e,t){return new a(this.channel,this.hostUri,o.resolveNodeUri(this.hostUri,e),t)},s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri).node(this.nodeUri)},s.prototype.link=function(e,t){var n=this.channel.link(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.sync=function(e,t){var n=this.channel.sync(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.syncList=function(e,t){var n=this.channel.syncList(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.syncMap=function(e,t){var n=this.channel.syncMap(this.nodeUri,e,t);return this.registerDownlink(n),n},s.prototype.command=function(e,t){this.channel.command(this.nodeUri,e,t)},s.prototype.lane=function(e){return new a(this.channel,this.hostUri,this.nodeUri,e)},a.prototype=Object.create(i.prototype),a.prototype.constructor=a,a.prototype.downlink=function(){return new c(this.channel,this).host(this.hostUri).node(this.nodeUri).lane(this.laneUri)},a.prototype.link=function(e){var t=this.channel.link(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.sync=function(e){var t=this.channel.sync(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.syncList=function(e){var t=this.channel.syncList(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.syncMap=function(e){var t=this.channel.syncMap(this.nodeUri,this.laneUri,e);return this.registerDownlink(t),t},a.prototype.command=function(e){this.channel.command(this.nodeUri,this.laneUri,e)},Object.defineProperty(h.prototype,"protocols",{get:function(){return this.options.protocols}}),Object.defineProperty(h.prototype,"maxReconnectTimeout",{get:function(){return this.options.maxReconnectTimeout||3e4}}),Object.defineProperty(h.prototype,"idleTimeout",{get:function(){return this.options.idleTimeout||1e3}}),Object.defineProperty(h.prototype,"sendBufferSize",{get:function(){return this.options.sendBufferSize||1024}}),Object.defineProperty(h.prototype,"isConnected",{get:function(){return this.socket&&this.socket.readyState===this.socket.OPEN},enumerable:!0}),h.prototype.resolve=function(e){return this.uriCache.resolve(e)},h.prototype.unresolve=function(e){return this.uriCache.unresolve(e)},h.prototype.authorize=function(e){if(!b.equal(e,this.credentials))if(this.credentials=e,this.isConnected){var t=new g.AuthRequest(e);this.push(t)}else this.open()},h.prototype.link=function(e,t,n){var o=new p(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.sync=function(e,t,n){var o=new u(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.syncList=function(e,t,n){var o=new d(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.syncMap=function(e,t,n){var o=new f(this,this.hostUri,e,t,n);return this.registerDownlink(o),o},h.prototype.command=function(e,t,n){var o=new g.CommandMessage(this.unresolve(e),t,n);this.push(o)},h.prototype.registerDelegate=function(e){this.delegates.push(e)},h.prototype.unregisterDelegate=function(e){for(var t=0,n=this.delegates.length;n>t;t+=1)this.delegates[t]===e&&this.delegates.splice(t,1)},h.prototype.registerDownlink=function(e){this.clearIdle();var t=e.nodeUri,n=e.laneUri,o=this.downlinks[t]||{},i=o[n]||[];i.push(e),o[n]=i,this.downlinks[t]=o,this.isConnected?e.onChannelConnect({hostUri:this.hostUri}):this.open()},h.prototype.unregisterDownlink=function(e){var t=e.nodeUri,n=e.laneUri,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=0,s=i.length;s>r;r+=1)if(i[r]===e){if(i.splice(r,1),0===i.length&&(delete o[n],0===Object.keys(o).length&&(delete this.downlinks[t],this.watchIdle()),this.isConnected)){var a=new g.UnlinkRequest(this.unresolve(t),n);e.onUnlinkRequest(a),this.push(a)}e.onChannelClose()}}},h.prototype.onEnvelope=function(e){e.isEventMessage?this.onEventMessage(e):e.isCommandMessage?this.onCommandMessage(e):e.isLinkRequest?this.onLinkRequest(e):e.isLinkedResponse?this.onLinkedResponse(e):e.isSyncRequest?this.onSyncRequest(e):e.isSyncedResponse?this.onSyncedResponse(e):e.isUnlinkRequest?this.onUnlinkRequest(e):e.isUnlinkedResponse?this.onUnlinkedResponse(e):e.isAuthRequest?this.onAuthRequest(e):e.isAuthedResponse?this.onAuthedResponse(e):e.isDeauthRequest?this.onDeauthRequest(e):e.isDeauthedResponse&&this.onDeauthedResponse(e)},h.prototype.onEventMessage=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onEventMessage(r)}}},h.prototype.onCommandMessage=function(e){},h.prototype.onLinkRequest=function(e){},h.prototype.onLinkedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onLinkedResponse(r)}}},h.prototype.onSyncRequest=function(e){},h.prototype.onSyncedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i)for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onSyncedResponse(r)}}},h.prototype.onUnlinkRequest=function(e){},h.prototype.onUnlinkedResponse=function(e){var t=this.resolve(e.node),n=e.lane,o=this.downlinks[t];if(o){var i=o[n];if(i){delete o[n],0===Object.keys(o).length&&delete this.downlinks[t];for(var r=e.withAddress(t),s=0,a=i.length;a>s;s+=1){var h=i[s];h.onUnlinkedResponse(r),h.onChannelClose()}}}},h.prototype.onAuthRequest=function(e){},h.prototype.onAuthedResponse=function(e){this.isAuthorized=!0,this.session=e.body;var t={hostUri:this.hostUri,session:this.session};this.client.onChannelAuthorize(t);for(var n=0,o=this.delegates.length;o>n;n+=1){var i=this.delegates[n];i.onChannelAuthorize(t)}},h.prototype.onDeauthRequest=function(e){},h.prototype.onDeauthedResponse=function(e){this.isAuthorized=!1,this.session=null;var t={hostUri:this.hostUri,session:e.body};this.client.onChannelDeauthorize(t);for(var n=0,o=this.delegates.length;o>n;n+=1){var i=this.delegates[n];i.onChannelDeauthorize(t)}},h.prototype.onConnect=function(){var e={hostUri:this.hostUri};this.client.onChannelConnect(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelConnect(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s];for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelConnect(e)}}}},h.prototype.onDisconnect=function(){var e={hostUri:this.hostUri};this.client.onChannelDisconnect(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelDisconnect(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s].slice();for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelDisconnect(e)}}}},h.prototype.onError=function(){var e={hostUri:this.hostUri};this.client.onChannelError(e);for(var t=0,n=this.delegates.length;n>t;t+=1){var o=this.delegates[t];o.onChannelError(e)}for(var i in this.downlinks){var r=this.downlinks[i];for(var s in r){var a=r[s];for(t=0,n=a.length;n>t;t+=1){var h=a[t];h.onChannelError(e)}}}},h.prototype.open=function(){this.clearReconnect(),this.socket||(this.socket=this.protocols?new m(this.hostUri,this.protocols):new m(this.hostUri),this.socket.onopen=this.onWebSocketOpen.bind(this),this.socket.onmessage=this.onWebSocketMessage.bind(this),this.socket.onerror=this.onWebSocketError.bind(this),this.socket.onclose=this.onWebSocketClose.bind(this))},h.prototype.close=function(){this.clearReconnect(),this.clearIdle(),this.socket&&(this.socket.close(),this.socket=null);var e=this.downlinks;Object.defineProperty(this,"downlinks",{value:{},configurable:!0});for(var t in e){var n=e[t];for(var o in n)for(var i=n[o],r=0,s=i.length;s>r;r+=1){var a=i[r];a.onChannelClose()}}},h.prototype.reconnect=function(){if(!this.reconnectTimer){if(this.reconnectTimeout){var e=this.maxReconnectTimeout||3e4;this.reconnectTimeout=Math.min(1.8*this.reconnectTimeout,e)}else{var t=1e3*Math.random();this.reconnectTimeout=500+t}this.reconnectTimer=setTimeout(this.open.bind(this),this.reconnectTimeout)}},h.prototype.clearReconnect=function(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.reconnectTimeout=0)},h.prototype.clearIdle=function(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)},h.prototype.watchIdle=function(){this.isConnected&&0===this.sendBuffer.length&&0===Object.keys(this.downlinks).length&&(this.idleTimer=setTimeout(this.checkIdle.bind(this),this.idleTimeout))},h.prototype.checkIdle=function(){0===this.sendBuffer.length&&0===Object.keys(this.downlinks).length&&this.close()},h.prototype.push=function(e){if(this.isConnected){this.clearIdle();var t=g.stringify(e);this.socket.send(t),this.watchIdle()}else e.isCommandMessage&&(this.sendBuffer.length<this.sendBufferSize&&this.sendBuffer.push(e),this.open())},h.prototype.onWebSocketOpen=function(){if(this.credentials){var e=new g.AuthRequest(this.credentials);this.push(e)}this.onConnect();for(var t;t=this.sendBuffer.shift();)this.push(t);this.watchIdle()},h.prototype.onWebSocketMessage=function(e){var t=e.data;if("string"==typeof t){var n=g.parse(t);n&&this.onEnvelope(n)}},h.prototype.onWebSocketError=function(){this.onError(),this.clearIdle(),this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.close(),this.socket=null)},h.prototype.onWebSocketClose=function(){this.isAuthorized=!1,this.session=null,this.socket=null,this.onDisconnect(),this.clearIdle(),(this.sendBuffer.length>0||Object.keys(this.downlinks).length>0)&&this.reconnect()},c.prototype.host=function(e){return this.hostUri=e,this},c.prototype.node=function(e){return this.nodeUri=e,this},c.prototype.lane=function(e){return this.laneUri=e,this},c.prototype.prio=function(e){return this.options.prio=e,this},c.prototype.keepAlive=function(){return this.options.keepAlive=!0,this},c.prototype.delegate=function(e){return this.options.delegate=e,this},c.prototype.onEvent=function(e){return this.proxy.onEvent=e,this},c.prototype.onCommand=function(e){return this.proxy.onCommand=e,this},c.prototype.onLink=function(e){return this.proxy.onLink=e,this},c.prototype.onLinked=function(e){return this.proxy.onLinked=e,this},c.prototype.onSync=function(e){return this.proxy.onSync=e,this},c.prototype.onSynced=function(e){return this.proxy.onSynced=e,this},c.prototype.onUnlink=function(e){return this.proxy.onUnlink=e,this},c.prototype.onUnlinked=function(e){return this.proxy.onUnlinked=e,this},c.prototype.onConnect=function(e){return this.proxy.onConnect=e,this},c.prototype.onDisconnect=function(e){return this.proxy.onDisconnect=e,this},c.prototype.onError=function(e){return this.proxy.onError=e,this},c.prototype.onClose=function(e){return this.proxy.onClose=e,this},c.prototype.primaryKey=function(e){return this.options.primaryKey=e,this},c.prototype.sortBy=function(e){return this.options.sortBy=e,this},Object.defineProperty(c.prototype,"normalize",{value:function(){this.hostUri?this.nodeUri=o.resolveNodeUri(this.hostUri,this.nodeUri):this.hostUri=o.extractHostUri(this.nodeUri),this.channel||(Object.defineProperty(this,"channel",{value:this.scope.getOrCreateChannel(this.hostUri),configurable:!0}),Object.defineProperty(this,"scope",{value:null,configurable:!0}))},configurable:!0}),Object.defineProperty(c.prototype,"registerDownlink",{value:function(e){for(var t in this.proxy)e[t]=this.proxy[t];this.channel.registerDownlink(e),this.scope&&this.scope.registerDownlink(e)},configure:!0}),c.prototype.link=function(){this.normalize();var e=new p(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.sync=function(){this.normalize();var e=new u(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.syncList=function(){this.normalize();var e=new d(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},c.prototype.syncMap=function(){this.normalize();var e=new f(this.channel,this.hostUri,this.nodeUri,this.laneUri,this.options);return this.registerDownlink(e),e},Object.defineProperty(l.prototype,"prio",{get:function(){return this.options.prio||0}}),Object.defineProperty(l.prototype,"keepAlive",{get:function(){return this.options.keepAlive||!1},set:function(e){this.options.keepAlive=e}}),Object.defineProperty(l.prototype,"isConnected",{get:function(){return this.channel.isConnected},enumerable:!0}),Object.defineProperty(l.prototype,"isAuthorized",{ | ||
get:function(){return this.channel.isAuthorized},enumerable:!0}),Object.defineProperty(l.prototype,"session",{get:function(){return this.channel.session},enumerable:!0}),Object.defineProperty(l.prototype,"onEventMessage",{value:function(e){"function"==typeof this.delegate.onEvent&&this.delegate.onEvent(e)},configurable:!0}),Object.defineProperty(l.prototype,"onCommandMessage",{value:function(e){"function"==typeof this.delegate.onCommand&&this.delegate.onCommand(e)},configurable:!0}),Object.defineProperty(l.prototype,"onLinkRequest",{value:function(e){"function"==typeof this.delegate.onLink&&this.delegate.onLink(e)},configurable:!0}),Object.defineProperty(l.prototype,"onLinkedResponse",{value:function(e){"function"==typeof this.delegate.onLinked&&this.delegate.onLinked(e)},configurable:!0}),Object.defineProperty(l.prototype,"onSyncRequest",{value:function(e){"function"==typeof this.delegate.onSync&&this.delegate.onSync(e)},configurable:!0}),Object.defineProperty(l.prototype,"onSyncedResponse",{value:function(e){"function"==typeof this.delegate.onSynced&&this.delegate.onSynced(e)},configurable:!0}),Object.defineProperty(l.prototype,"onUnlinkRequest",{value:function(e){"function"==typeof this.delegate.onUnlink&&this.delegate.onUnlink(e)},configurable:!0}),Object.defineProperty(l.prototype,"onUnlinkedResponse",{value:function(e){"function"==typeof this.delegate.onUnlinked&&this.delegate.onUnlinked(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelConnect",{value:function(e){"function"==typeof this.delegate.onConnect&&this.delegate.onConnect(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelDisconnect",{value:function(e){"function"==typeof this.delegate.onDisconnect&&this.delegate.onDisconnect(e),this.keepAlive||this.close()},configurable:!0}),Object.defineProperty(l.prototype,"onChannelError",{value:function(e){"function"==typeof this.delegate.onError&&this.delegate.onError(e)},configurable:!0}),Object.defineProperty(l.prototype,"onChannelClose",{value:function(){"function"==typeof this.delegate.onClose&&this.delegate.onClose()},configurable:!0}),l.prototype.command=function(e){this.channel.command(this.nodeUri,this.laneUri,e)},l.prototype.close=function(){this.channel.unregisterDownlink(this)},p.prototype=Object.create(l.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"onChannelConnect",{value:function(e){l.prototype.onChannelConnect.call(this,e);var t=this.channel.unresolve(this.nodeUri),n=new g.LinkRequest(t,this.laneUri,this.prio);this.onLinkRequest(n),this.channel.push(n)},configurable:!0}),u.prototype=Object.create(l.prototype),u.prototype.constructor=u,Object.defineProperty(u.prototype,"onChannelConnect",{value:function(e){l.prototype.onChannelConnect.call(this,e);var t=this.channel.unresolve(this.nodeUri),n=new g.SyncRequest(t,this.laneUri,this.prio);this.onSyncRequest(n),this.channel.push(n)},configurable:!0}),d.prototype=Object.create(u.prototype),d.prototype.constructor=d,Object.defineProperty(d.prototype,"onEventMessage",{value:function(e){var t,n,o,i=b.tag(e.body);if("@update"===i)t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteUpdate(n,o);else if("@insert"===i)t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteInsert(n,o);else if("@move"===i){t=b.head(e.body);var r=b.get(t,"from"),s=b.get(t,"to");o=b.tail(e.body),this.remoteMove(r,s,o)}else"@remove"===i||"@delete"===i?(t=b.head(e.body),n=b.get(t,"index"),o=b.tail(e.body),this.remoteRemove(n,o)):"@clear"===i&&1===b.size(e.body)?this.remoteClear():this.remoteAppend(e.body);u.prototype.onEventMessage.call(this,e)},configurable:!0}),Object.defineProperty(d.prototype,"remoteAppend",{value:function(e){this.state.push(e)},configurable:!0}),Object.defineProperty(d.prototype,"remoteUpdate",{value:function(e,t){this.state[e]=t},configurable:!0}),Object.defineProperty(d.prototype,"remoteInsert",{value:function(e,t){b.equal(this.state[e],t)||this.state.splice(e,0,t)},configurable:!0}),Object.defineProperty(d.prototype,"remoteMove",{value:function(e,t,n){b.equal(this.state[t],n)||(this.state.splice(e,1),this.state.splice(t,0,n))},configurable:!0}),Object.defineProperty(d.prototype,"remoteRemove",{value:function(e,t){b.equal(this.state[e],t)&&this.state.splice(e,1)},configurable:!0}),Object.defineProperty(d.prototype,"remoteClear",{value:function(e,t){Object.defineProperty(this,"state",{value:[],configurable:!0})},configurable:!0}),Object.defineProperty(d.prototype,"length",{get:function(){return this.state.length},configurable:!0,enumerable:!0}),d.prototype.get=function(e){return this.state[e]},d.prototype.set=function(e,t){t=b(void 0!==t?t:this.get(e)),this.state[e]=t;var n=this.channel.unresolve(this.nodeUri),o=b.concat(b({"@update":b({index:e})}),t),i=new g.CommandMessage(n,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)},d.prototype.push=function(){for(var e=this.channel.unresolve(this.nodeUri),t=0,n=arguments.length;n>t;t+=1){var o=b(arguments[t]);this.state.push(o);var i=new g.CommandMessage(e,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return this.state.length},d.prototype.pop=function(){var e=this.state.pop(),t=this.state.length;if(void 0!==e){var n=this.channel.unresolve(this.nodeUri),o=b.concat(b({"@remove":b({index:t})}),e),i=new g.CommandMessage(n,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return e},d.prototype.unshift=function(){for(var e=this.channel.unresolve(this.nodeUri),t=arguments.length-1;t>=0;t-=1){var n=b(arguments[t]);this.state.unshift(n);var o=b.concat(b({"@insert":b({index:0})}),n),i=new g.CommandMessage(e,this.laneUri,o);this.onCommandMessage(i),this.channel.push(i)}return this.state.length},d.prototype.shift=function(){var e=this.state.shift();if(void 0!==e){var t=this.channel.unresolve(this.nodeUri),n=b.concat(b({"@remove":b({index:0})}),e),o=new g.CommandMessage(t,this.laneUri,n);this.onCommandMessage(o),this.channel.push(o)}return e},d.prototype.move=function(e,t){var n=this.state.splice(e,1);if(1===n.length){var o=n[0];this.state.splice(t,0,o);var i=this.channel.unresolve(this.nodeUri),r=b.concat(b({"@move":b({from:e,to:t})}),o),s=new g.CommandMessage(i,this.laneUri,r);this.onCommandMessage(s),this.channel.push(s)}},d.prototype.splice=function(){var e,t,n,o,i,r=arguments[0],s=arguments[1],a=this.channel.unresolve(this.nodeUri),h=[];for(e=r;r+s>e;e+=1)n=this.state[e],void 0!==n&&(h.push(n),this.state.splice(r,1),o=b.concat(b({"@remove":b({index:r})}),n),i=new g.CommandMessage(a,this.laneUri,o),this.onCommandMessage(i),this.channel.push(i));for(e=2,t=arguments.length;t>e;e+=1){var c=r+e-2;n=b(arguments[e]),this.state.splice(c,0,n),o=b.concat(b({"@insert":b({index:c})}),n),i=new g.CommandMessage(a,this.laneUri,o),this.onCommandMessage(i),this.channel.push(i)}return h},d.prototype.clear=function(){Object.defineProperty(this,"state",{value:[],configurable:!0});var e=this.channel.unresolve(this.nodeUri),t=new g.CommandMessage(e,this.laneUri,[{"@clear":null}]);return this.onCommandMessage(t),this.channel.push(t),this},d.prototype.forEach=function(e,t){for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n];e.call(t,i,n,this)}},f.prototype=Object.create(u.prototype),f.prototype.constructor=f,Object.defineProperty(f.prototype,"onEventMessage",{value:function(e){var t,n=b.tag(e.body);if("@remove"===n||"@delete"===n){var o=b.tail(e.body);t=this.primaryKey(o),void 0!==t&&this.remoteDelete(t)}else"@clear"===n&&1===b.size(e.body)?this.remoteClear():(t=this.primaryKey(e.body),void 0!==t&&this.remoteSet(t,e.body));u.prototype.onEventMessage.call(this,e)},configurable:!0}),Object.defineProperty(f.prototype,"remoteSet",{value:function(e,t){"string"==typeof e&&(this.table[e]=t);for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n],r=this.primaryKey(i);if(b.equal(e,r)){this.state[n]=t;break}}n===o&&this.state.push(t),this.sort()},configurable:!0}),Object.defineProperty(f.prototype,"remoteDelete",{value:function(e){"string"==typeof e&&delete this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return void this.state.splice(t,1)}},configurable:!0}),Object.defineProperty(f.prototype,"remoteClear",{value:function(e){Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0})},configurable:!0}),Object.defineProperty(f.prototype,"size",{get:function(){return this.state.length},configurable:!0,enumerable:!0}),f.prototype.has=function(e){if("string"==typeof e)return void 0!==this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return!0}return!1},f.prototype.get=function(e){if("string"==typeof e)return this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i))return o}},f.prototype.set=function(e,t){t=b(void 0!==t?t:this.get(e)),"string"==typeof e&&(this.table[e]=t);for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n],r=this.primaryKey(i);if(b.equal(e,r)){this.state[n]=t;break}}n===o&&this.state.push(t),this.sort();var s=this.channel.unresolve(this.nodeUri),a=new g.CommandMessage(s,this.laneUri,t);return this.onCommandMessage(a),this.channel.push(a),this},f.prototype["delete"]=function(e){"string"==typeof e&&delete this.table[e];for(var t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);if(b.equal(e,i)){this.state.splice(t,1);var r=this.channel.unresolve(this.nodeUri),s=b.concat(b({"@remove":null}),o),a=new g.CommandMessage(r,this.laneUri,s);return this.onCommandMessage(a),this.channel.push(a),!0}}return!1},f.prototype.clear=function(){Object.defineProperty(this,"state",{value:[],configurable:!0}),Object.defineProperty(this,"table",{value:{},configurable:!0});var e=this.channel.unresolve(this.nodeUri),t=new g.CommandMessage(e,this.laneUri,[{"@clear":null}]);return this.onCommandMessage(t),this.channel.push(t),this},f.prototype.sort=function(){this.sortBy&&this.state.sort(this.sortBy)},f.prototype.keys=function(){for(var e=[],t=0,n=this.state.length;n>t;t+=1){var o=this.state[t],i=this.primaryKey(o);void 0!==i&&e.push(i)}return e},f.prototype.values=function(){return this.state},f.prototype.forEach=function(e,t){for(var n=0,o=this.state.length;o>n;n+=1){var i=this.state[n];e.call(t,i,this)}},f.primaryKeyOption=function(e){if("function"==typeof e.primaryKey)return e.primaryKey;if("string"==typeof e.primaryKey){var t=e.primaryKey.split(".");return function(e){for(var n=0,o=t.length;o>n;n+=1){var i=t[n];e=b.get(e,i)}return e}}return f.identityKey},f.identityKey=function(e){return e},f.sortByOption=function(e){if("function"==typeof e.sortBy)return e.sortBy;if("string"==typeof e.sortBy){var t=e.sortBy.split(".");return function(e,n){for(var o=0,i=t.length;i>o;o+=1){var r=t[o];return e=b.get(e,r),n=b.get(n,r),b.compare(e,n)}}}},y.prototype.resolve=function(e){var t=Math.abs(y.hash(e)%this.size),n=this.resolveCache[t];if(n&&n.unresolved===e)return n.resolved;var o=b.uri.stringify(b.uri.resolve(this.base,e));return this.resolveCache[t]={unresolved:e,resolved:o},o},y.prototype.unresolve=function(e){var t=Math.abs(y.hash(e)%this.size),n=this.unresolveCache[t];if(n&&n.resolved===e)return n.unresolved;var o=b.uri.stringify(b.uri.unresolve(this.base,e));return this.unresolveCache[t]={unresolved:o,resolved:e},o},y.rotl=function(e,t){return e<<t|e>>>32-t},y.mix=function(e,t){return t*=3432918353,t=y.rotl(t,15),t*=461845907,e^=t,e=y.rotl(e,13),e=5*e+3864292196},y.mash=function(e){return e^=e>>>16,e*=2246822507,e^=e>>>13,e*=3266489909,e^=e>>>16},y.hash=function(e){for(var t=0,n=0,o=e.length;o>n;n+=1)t=y.mix(t,e.charAt(n));return t=y.mash(t)};var k=new o;k.client=function(e){return new o(e)},k.config=v,t.exports=k}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./config.json":1,"recon-js":"recon-js","swim-proto-js":4,websocket:2}]},{},[])("swim-client-js")}); | ||
//# sourceMappingURL=swim-client.min.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
329535
1804
855
Updatedrecon-js@^0.3.9
Updatedswim-proto-js@^0.4.2