clearwater-hot_loader 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09405aae0dd6f8b113f7a03cebc18b60a46f776450444c0575edb41e5e14f12d'
|
4
|
+
data.tar.gz: 4e1e0a0a7e981a1fc6795e2613ac4c819083d1b09a0ade53f4b8c011d7ce4fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b7b9f5bbdd4d958c83249617ccd5946933ba147a981d13a54259de44d61434c378c996ed4a0eaa52d9d76b3eee993375431475b08f56e2f8967ecb808a82b42
|
7
|
+
data.tar.gz: 7018ba87929270f6c6bd24edfd74f9e53528961f66613238bf3b60106b4e31b46f933943dbe33842da2f8968e1606a12d18cc4c6723dd149f5b1163be22488fe
|
@@ -34,14 +34,17 @@ module Clearwater
|
|
34
34
|
code = File.read(filename)
|
35
35
|
|
36
36
|
if filename.end_with? '.rb'
|
37
|
-
Opal.compile(code)
|
37
|
+
{ js: Opal.compile(code) }
|
38
38
|
elsif filename.end_with? '.js'
|
39
|
-
code
|
39
|
+
{ js: code }
|
40
|
+
elsif filename.end_with? '.scss'
|
41
|
+
{ css: { filename: filename, body: Sass.compile(code.gsub(/^\s*@import.*$/, '')) } }
|
40
42
|
else
|
41
|
-
|
43
|
+
{}
|
42
44
|
end
|
43
45
|
rescue => e
|
44
|
-
|
46
|
+
warn "[Clearwater::HotLoader] #{e}"
|
47
|
+
{}
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -3,6 +3,7 @@ require 'clearwater/hot_loader/server'
|
|
3
3
|
require 'clearwater/hot_loader/file_listener'
|
4
4
|
require 'clearwater/hot_loader/configuration'
|
5
5
|
require 'set'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
module Clearwater
|
8
9
|
module HotLoader
|
@@ -33,11 +34,12 @@ module Clearwater
|
|
33
34
|
code = server.compile_file(filename)
|
34
35
|
rescue SyntaxError => e
|
35
36
|
puts "ONOES! #{e.class} - #{e.message}"
|
37
|
+
code = {}
|
36
38
|
end
|
37
39
|
|
38
40
|
puts "[Clearwater::HotLoader] Hot-loading #{filename}..."
|
39
41
|
sockets.each do |ws|
|
40
|
-
ws.send code
|
42
|
+
ws.send code.to_json
|
41
43
|
end
|
42
44
|
end
|
43
45
|
}
|
@@ -40,18 +40,29 @@ module Clearwater
|
|
40
40
|
end
|
41
41
|
|
42
42
|
@socket.on :message do |msg|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
data = msg.data
|
44
|
+
if data.key? :js
|
45
|
+
begin
|
46
|
+
%x{ eval(#{data[:js]}) }
|
47
|
+
|
48
|
+
# We need to perform the renders synchronously so we can rescue
|
49
|
+
# exceptions, but the app registry doesn't give us a way to do that,
|
50
|
+
# so we reach in and do this manually. Don't try this at home.
|
51
|
+
Clearwater::Application::AppRegistry
|
52
|
+
.instance_exec { @apps }
|
53
|
+
.each { |app| app.perform_render }
|
54
|
+
rescue => e
|
55
|
+
error_message = "[Clearwater::HotLoader] Error #{e.class}: #{e.message}"
|
56
|
+
`console.error(error_message)`
|
57
|
+
end
|
58
|
+
elsif data.key? :css
|
59
|
+
id = "clearwater-hot-loader-style-#{data[:css][:filename].gsub(/\W/, '-')}"
|
60
|
+
style = Bowser.document["##{id}"] || Bowser.document.create_element(:style)
|
61
|
+
new_element = style.id.empty?
|
62
|
+
style.id = id
|
63
|
+
style.text_content = data[:css][:body]
|
64
|
+
|
65
|
+
Bowser.document.head.append style if new_element
|
55
66
|
end
|
56
67
|
end
|
57
68
|
|
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.4.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: 2018-
|
11
|
+
date: 2018-06-25 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.7.
|
139
|
+
rubygems_version: 2.7.6
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Reload your Clearwater app without refreshing the browser
|