isomorfeus-asset-manager 0.13.4 → 0.13.8
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: 21a755b3c964b1e4463ac86d3a107bfa96cf1e3711013f3d27ab360805e54a52
|
4
|
+
data.tar.gz: a61345d86fd03993f9eeb0f27528731285135a200208e3065c0e2cd2737bcb5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7847d671507e887ae60b0577b3b9bbe2811dc004ca5ada5392d04df064e9bb58f1d80fd6af79d5d20d6611788d27351e5b5e467d155039ad07b0e19e917aa4ef
|
7
|
+
data.tar.gz: 55e4afab66c907df3655198dd52271be34d8f2a43b77ebc3dc4881a48df64bb29980c05013057c71a5653105b431922dbbad063f3573413b280ac1534e5b3fa8
|
@@ -64,7 +64,7 @@ module Isomorfeus
|
|
64
64
|
@css_size = @css.size
|
65
65
|
unless @target == :node
|
66
66
|
@css_gz = Zlib::gzip(b, level: Zlib::BEST_COMPRESSION)
|
67
|
-
@css_gz_size = @
|
67
|
+
@css_gz_size = @css_gz.size
|
68
68
|
end
|
69
69
|
end
|
70
70
|
@css
|
@@ -93,7 +93,7 @@ module Isomorfeus
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def touch
|
96
|
-
@mtime = Time.now
|
96
|
+
@mtime = (Time.now.to_f * (10 ** 9)).to_i
|
97
97
|
end
|
98
98
|
|
99
99
|
def to_s
|
@@ -112,7 +112,7 @@ module Isomorfeus
|
|
112
112
|
hmr_ws.onmessage = function(event) {
|
113
113
|
let update = JSON.parse(event.data);
|
114
114
|
if (typeof update.error !== 'undefined') { console.error(update.error); return; }
|
115
|
-
let start_index = '
|
115
|
+
let start_index = 'Opal.modules[\\"'.length;
|
116
116
|
let end_index = update.javascript.indexOf('"', start_index);
|
117
117
|
let opal_module_name = update.javascript.substr(start_index, end_index - start_index);
|
118
118
|
console.log('Updating ', opal_module_name);
|
@@ -8,7 +8,7 @@ module Isomorfeus
|
|
8
8
|
attr_accessor :root
|
9
9
|
attr_accessor :app_root
|
10
10
|
attr_accessor :assets_path
|
11
|
-
attr_accessor :assets_websocket_path
|
11
|
+
attr_accessor :assets_websocket_path
|
12
12
|
attr_accessor :asset_manager_tmpdir
|
13
13
|
attr_accessor :asset_manager_hmr_channel
|
14
14
|
attr_accessor :asset_manager_hmr_dirs
|
@@ -19,24 +19,24 @@ module Isomorfeus
|
|
19
19
|
def add_web_js_import(*args)
|
20
20
|
Isomorfeus.assets['web.js'].add_js_import(*args)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def add_ssr_js_import(*args)
|
24
24
|
Isomorfeus.assets['ssr.js'].add_js_import(*args)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def add_common_js_import(*args)
|
28
28
|
Isomorfeus.assets['web.js'].add_js_import(*args)
|
29
29
|
Isomorfeus.assets['ssr.js'].add_js_import(*args)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def add_web_ruby_import(*args)
|
33
33
|
Isomorfeus.assets['web.js'].add_ruby_import(*args)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def add_ssr_ruby_import(*args)
|
37
37
|
Isomorfeus.assets['ssr.js'].add_ruby_import(*args)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def add_common_ruby_import(*args)
|
41
41
|
Isomorfeus.assets['web.js'].add_ruby_import(*args)
|
42
42
|
Isomorfeus.assets['ssr.js'].add_ruby_import(*args)
|
@@ -66,7 +66,7 @@ module Isomorfeus
|
|
66
66
|
|
67
67
|
self.hmr_listener = nil
|
68
68
|
self.asset_manager_hmr_channel = :isomorfeus_asset_manager_module_updates
|
69
|
-
self.asset_manager_hmr_dirs = %w[channels
|
69
|
+
self.asset_manager_hmr_dirs = %w[channels components data operations policies]
|
70
70
|
self.assets_websocket_path = '/_assets_websocket'
|
71
71
|
self.assets_path = '/assets'
|
72
72
|
self.assets = {
|
@@ -18,7 +18,7 @@ module Isomorfeus
|
|
18
18
|
@assets_path_size = @assets_path.size
|
19
19
|
end
|
20
20
|
rescue Exception => e
|
21
|
-
STDERR.puts "#{e.message}\n#{e.backtrace
|
21
|
+
STDERR.puts "#{e.message}\n#{e.backtrace&.join("\n")}\n"
|
22
22
|
end
|
23
23
|
|
24
24
|
def call(env)
|
@@ -41,7 +41,7 @@ module Isomorfeus
|
|
41
41
|
return [200, headers, asset.bundle_gz]
|
42
42
|
else
|
43
43
|
headers[Rack::CONTENT_LENGTH] = asset.bundle_size
|
44
|
-
return [200,
|
44
|
+
return [200, headers, asset.bundle]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -51,7 +51,7 @@ module Isomorfeus
|
|
51
51
|
asset_key = path_info[@assets_path_size..-5]
|
52
52
|
asset = Isomorfeus.assets[asset_key]
|
53
53
|
if asset && asset.target != :node
|
54
|
-
asset_manager.transition(asset_key, asset)
|
54
|
+
asset_manager.transition(asset_key, asset) unless asset.bundled?
|
55
55
|
headers = {}
|
56
56
|
headers['Last-Modified'] = asset.mtime
|
57
57
|
headers[Rack::CONTENT_TYPE] = 'application/json'
|
@@ -61,7 +61,7 @@ module Isomorfeus
|
|
61
61
|
return [200, headers, asset.bundle_map_gz]
|
62
62
|
else
|
63
63
|
headers[Rack::CONTENT_LENGTH] = asset.bundle_map_size
|
64
|
-
return [200,
|
64
|
+
return [200, headers, asset.bundle_map]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -80,7 +80,7 @@ module Isomorfeus
|
|
80
80
|
return [200, headers, asset.css_gz]
|
81
81
|
else
|
82
82
|
headers[Rack::CONTENT_LENGTH] = asset.css_size
|
83
|
-
return [200,
|
83
|
+
return [200, headers, asset.css]
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -89,7 +89,7 @@ module Isomorfeus
|
|
89
89
|
asset_key = path_info[@assets_path_size..-9] + '.js'
|
90
90
|
asset = Isomorfeus.assets[asset_key]
|
91
91
|
if asset && asset.target != :node
|
92
|
-
asset_manager.transition(asset_key, asset)
|
92
|
+
asset_manager.transition(asset_key, asset) unless asset.bundled?
|
93
93
|
headers = {}
|
94
94
|
headers['Last-Modified'] = asset.mtime
|
95
95
|
headers[Rack::CONTENT_TYPE] = 'application/json'
|
@@ -99,7 +99,7 @@ module Isomorfeus
|
|
99
99
|
return [200, headers, asset.css_map_gz]
|
100
100
|
else
|
101
101
|
headers[Rack::CONTENT_LENGTH] = asset.css_map_size
|
102
|
-
return [200,
|
102
|
+
return [200, headers, asset.css_map]
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -115,7 +115,7 @@ module Isomorfeus
|
|
115
115
|
@app.call(env)
|
116
116
|
end
|
117
117
|
rescue Exception => e
|
118
|
-
STDERR.puts "#{e.message}\n#{e.backtrace
|
118
|
+
STDERR.puts "#{e.message}\n#{e.backtrace&.join("\n")}\n"
|
119
119
|
@app.call(env)
|
120
120
|
end
|
121
121
|
|
@@ -1,5 +1,44 @@
|
|
1
1
|
module Isomorfeus
|
2
2
|
class AssetManager
|
3
|
+
@@app_common_imports = false
|
4
|
+
@@app_web_imports = false
|
5
|
+
@@app_ssr_imports = false
|
6
|
+
|
7
|
+
def self.add_app_imports
|
8
|
+
imports_path = File.expand_path(File.join(Isomorfeus.app_root, 'imports'))
|
9
|
+
if Dir.exist?(imports_path)
|
10
|
+
unless @@app_common_imports
|
11
|
+
common_imports_file = File.join(imports_path, 'common.js')
|
12
|
+
if File.exist?(common_imports_file)
|
13
|
+
Isomorfeus.add_common_js_import(common_imports_file)
|
14
|
+
@@app_common_imports = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
unless @@app_web_imports
|
18
|
+
web_imports_file = File.join(imports_path, 'web.js')
|
19
|
+
if File.exist?(web_imports_file)
|
20
|
+
Isomorfeus.add_web_js_import(web_imports_file)
|
21
|
+
@@app_web_imports = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
unless @@app_ssr_imports
|
25
|
+
ssr_imports_file = File.join(imports_path, 'ssr.js')
|
26
|
+
if File.exist?(ssr_imports_file)
|
27
|
+
Isomorfeus.add_ssr_js_import(ssr_imports_file)
|
28
|
+
@@app_ssr_imports
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.last_updated
|
35
|
+
@last_updated
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.last_updated=(l)
|
39
|
+
@last_updated = l
|
40
|
+
end
|
41
|
+
|
3
42
|
def initialize
|
4
43
|
Isomorfeus.set_node_paths
|
5
44
|
|
@@ -9,19 +48,10 @@ module Isomorfeus
|
|
9
48
|
FileUtils.mkdir_p(@imports_path)
|
10
49
|
FileUtils.mkdir_p(@output_path)
|
11
50
|
@server_path = File.join(Isomorfeus.app_root, 'server')
|
51
|
+
self.class.add_app_imports
|
12
52
|
|
13
53
|
@context = ExecJS.permissive_compile(init_js)
|
14
54
|
|
15
|
-
imports_path = File.expand_path(File.join(Isomorfeus.app_root, 'imports'))
|
16
|
-
if Dir.exist?(imports_path)
|
17
|
-
common_imports_file = File.join(imports_path, 'common.js')
|
18
|
-
Isomorfeus.add_common_js_import(common_imports_file) if File.exist?(common_imports_file)
|
19
|
-
web_imports_file = File.join(imports_path, 'web.js')
|
20
|
-
Isomorfeus.add_web_js_import(web_imports_file) if File.exist?(web_imports_file)
|
21
|
-
ssr_imports_file = File.join(imports_path, 'ssr.js')
|
22
|
-
Isomorfeus.add_ssr_js_import(ssr_imports_file) if File.exist?(ssr_imports_file)
|
23
|
-
end
|
24
|
-
|
25
55
|
init_hmr_listener if Isomorfeus.development? && !Isomorfeus.hmr_listener
|
26
56
|
end
|
27
57
|
|
@@ -29,6 +59,7 @@ module Isomorfeus
|
|
29
59
|
return if !Isomorfeus.development? && asset.bundled?
|
30
60
|
asset.mutex.synchronize do
|
31
61
|
return if !Isomorfeus.development? && asset.bundled?
|
62
|
+
return if Isomorfeus.development? && asset.bundled? && (self.class.last_updated.nil? || (asset.mtime > self.class.last_updated))
|
32
63
|
asset.touch
|
33
64
|
build_ruby_and_save(asset_key, asset)
|
34
65
|
save_imports(asset_key, asset)
|
@@ -131,8 +162,10 @@ module Isomorfeus
|
|
131
162
|
listen_dirs << listen_dir if Dir.exist?(listen_dir)
|
132
163
|
end
|
133
164
|
end
|
165
|
+
am_class = self.class
|
134
166
|
Isomorfeus.hmr_listener = Listen.to(*listen_dirs) do |modified, added, _|
|
135
167
|
(modified + added).each do |file|
|
168
|
+
am_class.last_updated = (Time.now.to_f * (10 ** 9)).to_i
|
136
169
|
next if file.start_with?(@server_path)
|
137
170
|
begin
|
138
171
|
update = compile_ruby(file)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-asset-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isomorfeus-iodine
|