clearwater-hot_loader 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/clearwater/hot_loader/version.rb +1 -1
- data/opal/clearwater/hot_loader.rb +18 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 88069316bdc48d8c2d56ae1af915ff36127831e25c3b884e5ec59bebd730428f
|
4
|
+
data.tar.gz: 96ebbfda995dcf51cfb523eaeefa3d861c087367522db6a46619bc7bc85be8fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aa35a5fa937a07754305a46097f3aa9e24771cc369477beece437cd7156dc774a565658624d72fee52b89ac2ebf5bbbcb54bd23c2ea8da1c68ad1dee9fd92a6
|
7
|
+
data.tar.gz: 8df849b68d530b6bf8bfb43943a7901890b42c51717ffbcfa62c35a1a2ab9ff8370b4fe6c883b5437ad5b667cc5150ff6df66be9baced83c5d5546c533b386d4
|
@@ -6,11 +6,15 @@ module Clearwater
|
|
6
6
|
class HotLoader
|
7
7
|
attr_reader :port, :path
|
8
8
|
|
9
|
-
def self.connect port=
|
10
|
-
|
9
|
+
def self.connect port=nil, deprecated_path=nil, path: '/clearwater_hot_loader'
|
10
|
+
if deprecated_path
|
11
|
+
warn "[Clearwater::HotLoader] Passing the path as a positional argument is deprecated. Please pass the path as a keyword argument."
|
12
|
+
end
|
13
|
+
|
14
|
+
new(port, path: deprecated_path || path).connect
|
11
15
|
end
|
12
16
|
|
13
|
-
def initialize port, path
|
17
|
+
def initialize port=nil, path: '/clearwater_hot_loader'
|
14
18
|
@port = port
|
15
19
|
@path = path
|
16
20
|
Bowser.window.animation_frame do
|
@@ -25,7 +29,10 @@ module Clearwater
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def connect
|
28
|
-
|
32
|
+
match, scheme, host, port, = *Bowser.window.location.href.match(%r{(https?)://([^:/]+)(?:\:(\d+))?/?([^\?]*)})
|
33
|
+
port = @port if @port
|
34
|
+
socket_url = "ws#{'s' if scheme == 'https'}://#{host}#{":#{port}" if port}#{path}"
|
35
|
+
@socket = Bowser::WebSocket.new(socket_url)
|
29
36
|
|
30
37
|
@socket.on :open do
|
31
38
|
@app.render
|
@@ -34,11 +41,17 @@ module Clearwater
|
|
34
41
|
@socket.on :message do |msg|
|
35
42
|
begin
|
36
43
|
%x{ eval(msg.native.data) }
|
44
|
+
|
45
|
+
# We need to perform the renders synchronously so we can rescue
|
46
|
+
# exceptions, but the app registry doesn't give us a way to do that,
|
47
|
+
# so we reach in and do this manually. Don't try this at home.
|
48
|
+
Clearwater::Application::AppRegistry
|
49
|
+
.instance_exec { @apps }
|
50
|
+
.each { |app| app.perform_render }
|
37
51
|
rescue => e
|
38
52
|
error_message = "[Clearwater::HotLoader] Error #{e.class}: #{e.message}"
|
39
53
|
`console.error(error_message)`
|
40
54
|
end
|
41
|
-
Clearwater::Application.render
|
42
55
|
end
|
43
56
|
|
44
57
|
@socket.on :close do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clearwater-hot_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Gaskins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clearwater
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.7.2
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Reload your Clearwater app without refreshing the browser
|