web-repl 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/js/replConnection-0.6.min.js +1 -0
- data/js/replConnection.js +1 -1
- data/lib/web-repl.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9cb6f9d73523c501441de89215c76c8e7343161
|
4
|
+
data.tar.gz: bdb3396923e7fca4fc2a267162c9d5f1ff81cd53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a4b0890411729f1c1fbaec5ad54b0e78c81b6fdf98e54a342c6244d059db54f7386694adadde2d0767d771eb8123995afb2a0c6a007880a1be7a6d7846d357
|
7
|
+
data.tar.gz: 8abdfd2e5050b6c79671a77e24fb827343104b6b679f34c20986878aa0772153df88a6e24b0fb861fc930f66bf7bef4c36c01f6118ecdd1c699b970a6d9e71fc
|
@@ -0,0 +1 @@
|
|
1
|
+
function ReplConnection(e,t,n){n=typeof n==="undefined"?{}:n;this.debug=!!n.debug;this.reconnect=!!n.reconnect;this.retryTime=n.retryTime||1e3;this.evalFunction=n.evalFunction;this.host=e;this.port=t;this.active=false;this.socket;this.supported="WebSocket"in window;if(this.supported){console.log("REPL: socket ok")}else{console.log("REPL: socket not supported")}}ReplConnection.prototype.eval=function(statement){options=typeof options==="undefined"?{}:options;var response={};try{if(typeof this.evalFunction==="function"){response.value=this.evalFunction(statement)}else{response.value=eval(statement)}}catch(err){response.error=err.message}return response};ReplConnection.prototype.initSocket=function(e){if(this.socket!==undefined&&this.socket!==null){this.socket.close()}var t="ws://"+this.host+":"+this.port+"/echo";this.socket=new WebSocket(t);e()};ReplConnection.prototype.handleSocketOpen=function(){this.active=true;console.log("REPL: socket ready")};ReplConnection.prototype.tryConnection=function(){console.log("REPL: waiting for connection");if(this.reconnect){var e=this;window.setTimeout(function(){e.start()},this.retryTime)}};ReplConnection.prototype.handleSocketClose=function(e){if(!this.active){this.tryConnection()}else{console.log("REPL: socket closed");this.active=false;if(this.reconnect){this.tryConnection()}}};ReplConnection.prototype.convertTimestamp=function(e){var t=e.timestamp;e.timestamp=new Date(t);return e.timestamp};ReplConnection.prototype.handleMessageReceived=function(e){if(this.debug){console.log("REPL: message received");console.log(e)}var t=JSON.parse(e.data);this.convertTimestamp(t);var n=this.eval(t.statement);return this.send(n)};ReplConnection.prototype.send=function(e){var t=this.prepareJSON(e);if(this.debug){console.log("REPL: sending");console.log(t)}return this.socket.send(t)};ReplConnection.prototype.prepareJSON=function(e){var t;try{e.timestamp=(new Date).getTime();t=JSON.stringify(e)}catch(n){t=this.handleJsonError(e,n)}return t};ReplConnection.prototype.handleJsonError=function(e,t){e.value=null;e.error=t.message;return this.prepareJSONResponse(e)};ReplConnection.prototype.initEventHandling=function(){var e=this;this.socket.onopen=function(){e.handleSocketOpen()};this.socket.onclose=function(t){e.handleSocketClose(t)};this.socket.onmessage=function(t){e.handleMessageReceived(t)}};ReplConnection.prototype.start=function(e){if(this.supported){var t=this;this.initSocket(function(){t.initEventHandling();if(e!==undefined){e(t)}})}}
|
data/js/replConnection.js
CHANGED
@@ -119,7 +119,7 @@ ReplConnection.prototype.prepareJSON = function(message) {
|
|
119
119
|
// Handle an error when converting the message to JSON
|
120
120
|
ReplConnection.prototype.handleJsonError = function(message, error) {
|
121
121
|
message.value = null;
|
122
|
-
message.error =
|
122
|
+
message.error = error.message;
|
123
123
|
return this.prepareJSONResponse(message);
|
124
124
|
}
|
125
125
|
|
data/lib/web-repl.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-repl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- js/replConnection-0.3.min.js
|
96
96
|
- js/replConnection-0.4.min.js
|
97
97
|
- js/replConnection-0.5.min.js
|
98
|
+
- js/replConnection-0.6.min.js
|
98
99
|
- js/replConnection.js
|
99
100
|
- lib/web-repl.rb
|
100
101
|
- lib/web-repl/messager.rb
|