web-repl 0.7 → 0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4e0434060703c3bc75cf67d85d2897d4990da1a
4
- data.tar.gz: 0378db709e99f75dc4a9e83cf6c017b6159103ac
3
+ metadata.gz: b413d1b03b128e8c82e22c8a615e0acd88a73584
4
+ data.tar.gz: 4fe6b7f94734f7822c12d844ed858c2ec76f4674
5
5
  SHA512:
6
- metadata.gz: 814a12b0fb7b606f3d84e4879f570a9f0e9e38c141ef0e58d4bb57120db97e8019181f564d4bba74e7f4e2d27c5d12707b646b97f846dc31703200c10ce1bbc2
7
- data.tar.gz: 8fcdf3dd69be65c74111f2acaba1400808a50a1d42fde538125259e12de002c5bbb41b7bbe41516f4dfef6bcf2c67a20e790af1f3800a5d16f0ac5e4348bfa33
6
+ metadata.gz: be73a5e019b08492b1ab6dc889ce39ca3c986e29870933f5e44bde8526f439d819cc9783ce7a3bf9131fb4b03f7ff69116dd447777610c61d4da9a4c001e3919
7
+ data.tar.gz: 61c6f0ed93b19d61c54d6f59e8ffc0b17fa1ed49b40ec5d657b750d769899adb6e37bc0bc4364e74c0e17a8222a8bf9d9d89b06ad5fef16790fb2ed1c2c8dd6e
@@ -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.prepareJSON(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
@@ -120,7 +120,7 @@ ReplConnection.prototype.prepareJSON = function(message) {
120
120
  ReplConnection.prototype.handleJsonError = function(message, error) {
121
121
  message.value = null;
122
122
  message.error = error.message;
123
- return this.prepareJSONResponse(message);
123
+ return this.prepareJSON(message);
124
124
  }
125
125
 
126
126
  // Initialize the Websocket event handling actions
data/lib/web-repl.rb CHANGED
@@ -13,7 +13,7 @@ require "web-repl/repl"
13
13
  # A Javascript REPL that runs in Ruby. Evaluation is done by a web browser instance.
14
14
  module WebRepl
15
15
 
16
- VERSION = "0.7"
16
+ VERSION = "0.8"
17
17
 
18
18
  # Shortcut to REPL.start
19
19
  def self.start(*a)
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.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo
@@ -110,6 +110,7 @@ files:
110
110
  - js/replConnection-0.4.min.js
111
111
  - js/replConnection-0.5.min.js
112
112
  - js/replConnection-0.6.min.js
113
+ - js/replConnection-0.8.min.js
113
114
  - js/replConnection.js
114
115
  - lib/web-repl.rb
115
116
  - lib/web-repl/messenger.rb