atome 0.5.5.6.5 → 0.5.5.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +112 -15
- data/exe/atome +119 -14
- data/lib/atome/genesis/generators/utility.rb +3 -0
- data/lib/atome/helpers/utilities.rb +14 -1
- data/lib/atome/version.rb +1 -1
- data/lib/platform_specific/opal/atome_opal_extensions.rb +1 -0
- data/lib/renderers/html/utility.rb +46 -0
- data/vendor/assets/application/examples/file.rb +11 -46
- data/vendor/assets/application/examples/security.rb +5 -5
- data/vendor/assets/src/js/atome/atome.js +155 -20
- metadata +2 -3
- data/app_builder_helpers/Rakefile +0 -278
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf1de59b3e8d3060f6c7714a7a4c11e16b42428aa6bc152c95248968c884e85e
|
4
|
+
data.tar.gz: 950f6e9967e30eb5be2d7437674b3471a3f8d1b513597e985de0fb8629378976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f30d53165d850093d1692d23bd315acb3c47d60ac77bd700a091cf601b562cd2030c46a4ac57234b73dc29bc1d7fcce61731ecb096fe713e5448323d14a5492
|
7
|
+
data.tar.gz: a1b9d403f01442c3670cdbac25c367474514392464bd7f5cfee6123f50d775e5cf183563067e993df4f1584137c1803f319685109625afb494781b407a7bb2ec
|
data/Rakefile
CHANGED
@@ -6,11 +6,39 @@ require 'bundler/gem_tasks'
|
|
6
6
|
load 'exe/atome'
|
7
7
|
|
8
8
|
task :cleanup do
|
9
|
-
|
9
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
10
|
+
# Code à exécuter sous Windows
|
11
|
+
`gem cleanup atome`
|
12
|
+
`echo yes | gem uninstall atome`
|
13
|
+
`cd pkg`
|
14
|
+
|
15
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
16
|
+
# Code à exécuter sous MacOS
|
17
|
+
`gem cleanup atome;yes | gem uninstall atome;cd pkg`
|
18
|
+
else
|
19
|
+
# Code à exécuter sous Unix/Linux
|
20
|
+
`gem cleanup atome;yes | gem uninstall atome;cd pkg`
|
21
|
+
end
|
22
|
+
|
23
|
+
|
10
24
|
end
|
11
25
|
task :reset_cache do
|
12
|
-
|
13
|
-
|
26
|
+
|
27
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
28
|
+
# Code à exécuter sous Windows
|
29
|
+
`rmdir /s /q .\\tmp`
|
30
|
+
`rmdir /s /q .\\pkg`
|
31
|
+
|
32
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
33
|
+
# Code à exécuter sous MacOS
|
34
|
+
`rm -r -f ./tmp`
|
35
|
+
`rm -r -f ./pkg`
|
36
|
+
else
|
37
|
+
# Code à exécuter sous Unix/Linux
|
38
|
+
`rm -r -f ./tmp`
|
39
|
+
`rm -r -f ./pkg`
|
40
|
+
end
|
41
|
+
|
14
42
|
end
|
15
43
|
|
16
44
|
def resolve_requires(file_path, root_path, processed_files = Set.new, depth = 0)
|
@@ -51,7 +79,18 @@ task :test_wasm do
|
|
51
79
|
host_mode = 'pure_wasm'
|
52
80
|
create_application(source, destination, project_name)
|
53
81
|
wasm_common(source, destination, project_name, wasi_file, host_mode, script_source)
|
54
|
-
|
82
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
83
|
+
# Code à exécuter sous Windows
|
84
|
+
`start "" ".\\tmp\\#{project_name}\\src\\index.html"`
|
85
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
86
|
+
# Code à exécuter sous MacOS
|
87
|
+
`open ./tmp/#{project_name}/src/index.html`
|
88
|
+
else
|
89
|
+
# Code à exécuter sous Unix/Linux
|
90
|
+
`open ./tmp/#{project_name}/src/index.html`
|
91
|
+
end
|
92
|
+
|
93
|
+
|
55
94
|
puts 'atome wasm is build and running!'
|
56
95
|
end
|
57
96
|
|
@@ -65,7 +104,18 @@ task :test_wasm_osx_x86 do
|
|
65
104
|
host_mode = 'pure_wasm'
|
66
105
|
create_application(source, destination, project_name)
|
67
106
|
wasm_common(source, destination, project_name, wasi_file, script_source, host_mode, script_source)
|
68
|
-
|
107
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
108
|
+
# Code à exécuter sous Windows
|
109
|
+
`start "" ".\\tmp\\#{project_name}\\src\\index.html"`
|
110
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
111
|
+
# Code à exécuter sous MacOS
|
112
|
+
`open ./tmp/#{project_name}/src/index.html`
|
113
|
+
else
|
114
|
+
# Code à exécuter sous Unix/Linux
|
115
|
+
`open ./tmp/#{project_name}/src/index.html`
|
116
|
+
end
|
117
|
+
|
118
|
+
|
69
119
|
puts 'atome wasm is build and running!'
|
70
120
|
end
|
71
121
|
task :test_wasm_windows do
|
@@ -78,7 +128,16 @@ task :test_wasm_windows do
|
|
78
128
|
host_mode = 'pure_wasm'
|
79
129
|
create_application(source, destination, project_name)
|
80
130
|
wasm_common(source, destination, project_name, wasi_file, host_mode, script_source)
|
81
|
-
|
131
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
132
|
+
# Code à exécuter sous Windows
|
133
|
+
`start "" ".\\tmp\\#{project_name}\\src\\index.html"`
|
134
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
135
|
+
# Code à exécuter sous MacOS
|
136
|
+
`open ./tmp/#{project_name}/src/index.html`
|
137
|
+
else
|
138
|
+
# Code à exécuter sous Unix/Linux
|
139
|
+
`open ./tmp/#{project_name}/src/index.html`
|
140
|
+
end
|
82
141
|
puts 'atome wasm is build and running!'
|
83
142
|
end
|
84
143
|
task :test_wasm_unix do
|
@@ -91,7 +150,16 @@ task :test_wasm_unix do
|
|
91
150
|
host_mode = 'pure_wasm'
|
92
151
|
create_application(source, destination, project_name)
|
93
152
|
wasm_common(source, destination, project_name, wasi_file, host_mode, script_source)
|
94
|
-
|
153
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
154
|
+
# Code à exécuter sous Windows
|
155
|
+
`start "" ".\\tmp\\#{project_name}\\src\\index.html"`
|
156
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
157
|
+
# Code à exécuter sous MacOS
|
158
|
+
`open ./tmp/#{project_name}/src/index.html`
|
159
|
+
else
|
160
|
+
# Code à exécuter sous Unix/Linux
|
161
|
+
`open ./tmp/#{project_name}/src/index.html`
|
162
|
+
end
|
95
163
|
puts 'atome wasm is build and running!'
|
96
164
|
end
|
97
165
|
|
@@ -116,7 +184,17 @@ task :test_opal do
|
|
116
184
|
# build application
|
117
185
|
build_opal_application(source, destination, project_name)
|
118
186
|
# open the app
|
119
|
-
|
187
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
188
|
+
# Code à exécuter sous Windows
|
189
|
+
`start "" "#{destination}\\#{project_name}\\src\\index_opal.html"`
|
190
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
191
|
+
# Code à exécuter sous MacOS
|
192
|
+
`open #{destination}/#{project_name}/src/index_opal.html`
|
193
|
+
else
|
194
|
+
# Code à exécuter sous Unix/Linux
|
195
|
+
`open #{destination}/#{project_name}/src/index_opal.html`
|
196
|
+
end
|
197
|
+
|
120
198
|
puts 'atome opal is build and running!'
|
121
199
|
end
|
122
200
|
task :server_wasm do
|
@@ -157,7 +235,18 @@ task :test_server do
|
|
157
235
|
threads = []
|
158
236
|
threads << Thread.new do
|
159
237
|
sleep 1
|
160
|
-
|
238
|
+
|
239
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
240
|
+
# Code à exécuter sous Windows
|
241
|
+
`start "" "http://localhost:9292"`
|
242
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
243
|
+
# Code à exécuter sous MacOS
|
244
|
+
`open http://localhost:9292`
|
245
|
+
else
|
246
|
+
# Code à exécuter sous Unix/Linux
|
247
|
+
`open http://localhost:9292`
|
248
|
+
end
|
249
|
+
|
161
250
|
end
|
162
251
|
build_for_server(destination, project_name, 9292, :production)
|
163
252
|
end
|
@@ -245,10 +334,6 @@ task :osx_server do
|
|
245
334
|
|
246
335
|
puts 'atome osx is running'
|
247
336
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
337
|
end
|
253
338
|
|
254
339
|
|
@@ -256,8 +341,20 @@ task :build_gem do
|
|
256
341
|
# building the gem
|
257
342
|
`rake build` # run build_app thru ARGV in exe atome
|
258
343
|
# installing the gem
|
259
|
-
|
260
|
-
|
344
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
345
|
+
# Code à exécuter sous Windows
|
346
|
+
`cd pkg && gem install atome --local`
|
347
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
348
|
+
# Code à exécuter sous MacOS
|
349
|
+
`cd pkg; gem install atome --local`
|
350
|
+
# open the app
|
351
|
+
else
|
352
|
+
# Code à exécuter sous Unix/Linux
|
353
|
+
`cd pkg; gem install atome --local`
|
354
|
+
# open the app
|
355
|
+
end
|
356
|
+
|
357
|
+
|
261
358
|
puts 'atome gem built and installed'
|
262
359
|
end
|
263
360
|
|
data/exe/atome
CHANGED
@@ -131,7 +131,20 @@ STR
|
|
131
131
|
File.open(opal_compiler, 'w') do |f|
|
132
132
|
f.puts opal_compiler_content
|
133
133
|
end
|
134
|
-
|
134
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
135
|
+
# Code à exécuter sous Windows
|
136
|
+
`cd #{destination}\\#{project_name}\\tmp\\application\\ && echo %cd% && ruby .opal_compiler.rb`
|
137
|
+
|
138
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
139
|
+
# Code à exécuter sous MacOS
|
140
|
+
`cd #{destination}/#{project_name}/tmp/application/;pwd;ruby .opal_compiler.rb`
|
141
|
+
|
142
|
+
else
|
143
|
+
# Code à exécuter sous Unix/Linux
|
144
|
+
`cd #{destination}/#{project_name}/tmp/application/;pwd;ruby .opal_compiler.rb`
|
145
|
+
|
146
|
+
end
|
147
|
+
|
135
148
|
end
|
136
149
|
|
137
150
|
def add_to_application_folder(script_source, destination, project_name)
|
@@ -243,14 +256,42 @@ def wasm_initialize (source, destination, project_name, wasi_source)
|
|
243
256
|
#### IMPORTANT TO REFRESH RUBY WASM TO THE LATEST VERSION, (when ruby_browser get far too large)
|
244
257
|
# and UNCOMMENT the line below : ('curl -LO ....')
|
245
258
|
unless File.exist?("#{wasm_temp_folder}/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz")
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
259
|
+
|
260
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
261
|
+
`cd /d %wasm_temp_folder% && curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz
|
262
|
+
`
|
263
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
264
|
+
# Code à exécuter sous MacOS
|
265
|
+
# `cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
266
|
+
`cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
267
|
+
# debug : https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-minimal-js-debug.tar.gz
|
268
|
+
# standard : `cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
269
|
+
|
270
|
+
else
|
271
|
+
# Code à exécuter sous Unix/Linux
|
272
|
+
`cd #{wasm_temp_folder};curl -LO https://github.com/ruby/ruby.wasm/releases/download/2023-11-17-a/ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
278
|
+
# Code à exécuter sous Windows
|
279
|
+
`cd /d %wasm_temp_folder% && 7z x ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
280
|
+
`move %wasm_temp_folder%\\3_2-wasm32-unknown-wasi-full-js\\usr\\local\\bin\\ruby %wasm_temp_folder%\\system_ruby_browser.wasm`
|
281
|
+
`del %application_location%\\src\\wasm\\ruby_browser.wasm`
|
282
|
+
|
283
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
284
|
+
# Code à exécuter sous MacOS
|
285
|
+
`cd #{wasm_temp_folder}; tar xfz ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
286
|
+
`mv #{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr/local/bin/ruby #{wasm_temp_folder}/system_ruby_browser.wasm`
|
287
|
+
`rm -f #{application_location}/src/wasm/ruby_browser.wasm`
|
288
|
+
else
|
289
|
+
# Code à exécuter sous Unix/Linux
|
290
|
+
`cd #{wasm_temp_folder}; tar xfz ruby-3_2-wasm32-unknown-wasi-full-js.tar.gz`
|
291
|
+
`mv #{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr/local/bin/ruby #{wasm_temp_folder}/system_ruby_browser.wasm`
|
292
|
+
`rm -f #{application_location}/src/wasm/ruby_browser.wasm`
|
250
293
|
end
|
251
|
-
|
252
|
-
`mv #{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr/local/bin/ruby #{wasm_temp_folder}/system_ruby_browser.wasm`
|
253
|
-
`rm -f #{application_location}/src/wasm/ruby_browser.wasm`
|
294
|
+
|
254
295
|
cmd = <<~STRDELIM
|
255
296
|
#{application_location}/src-wasm/wasm/#{wasi_source} pack #{wasm_temp_folder}/system_ruby_browser.wasm
|
256
297
|
--mapdir usr::#{wasm_temp_folder}/3_2-wasm32-unknown-wasi-full-js/usr
|
@@ -277,14 +318,34 @@ end
|
|
277
318
|
|
278
319
|
def build_for_osx(destination, mode = :dev)
|
279
320
|
# dev or build
|
321
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
322
|
+
# Code à exécuter sous Windows
|
323
|
+
`cd /d #{destination} && cargo tauri %mode%`
|
324
|
+
|
325
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
326
|
+
# Code à exécuter sous MacOS
|
327
|
+
`cd #{destination};cargo tauri #{mode}`
|
328
|
+
else
|
329
|
+
# Code à exécuter sous Unix/Linux
|
330
|
+
`cd #{destination};cargo tauri #{mode}`
|
331
|
+
end
|
280
332
|
|
281
|
-
`cd #{destination};cargo tauri #{mode}`
|
282
333
|
|
283
334
|
end
|
284
335
|
|
285
336
|
def build_for_server(destination, project_name, port, production)
|
286
337
|
prod = '--env production' if production
|
287
|
-
|
338
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
339
|
+
# Code à exécuter sous Windows
|
340
|
+
`cd /d #{destination}\\#{project_name}\\server && puma --port %port% %prod%`
|
341
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
342
|
+
# Code à exécuter sous MacOS
|
343
|
+
`cd #{destination}/#{project_name}/server;puma --port #{port} #{prod}`
|
344
|
+
else
|
345
|
+
# Code à exécuter sous Unix/Linux
|
346
|
+
`cd #{destination}/#{project_name}/server;puma --port #{port} #{prod}`
|
347
|
+
end
|
348
|
+
|
288
349
|
end
|
289
350
|
|
290
351
|
# def run_application(build_target, location, port = 9292, production = false)
|
@@ -295,7 +356,18 @@ end
|
|
295
356
|
# below we analyse the ARGV
|
296
357
|
location = '/'
|
297
358
|
project_name = ARGV[1]
|
298
|
-
|
359
|
+
|
360
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
361
|
+
# Code à exécuter sous Windows
|
362
|
+
destination = `cd`.chomp
|
363
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
364
|
+
# Code à exécuter sous MacOS
|
365
|
+
destination = `pwd`.chomp
|
366
|
+
else
|
367
|
+
# Code à exécuter sous Unix/Linux
|
368
|
+
destination = `pwd`.chomp
|
369
|
+
end
|
370
|
+
|
299
371
|
source = Pathname(__FILE__).parent.parent.to_s
|
300
372
|
|
301
373
|
wasi_file = 'wasi-vfs-osx_arm' # default to osx arm
|
@@ -349,7 +421,17 @@ if ARGV.include?('guard')
|
|
349
421
|
end
|
350
422
|
|
351
423
|
if ARGV.include?('run')
|
352
|
-
|
424
|
+
|
425
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
426
|
+
# Code à exécuter sous Windows
|
427
|
+
current_path = `cd`.chomp
|
428
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
429
|
+
# Code à exécuter sous MacOS
|
430
|
+
current_path = `pwd`.chomp
|
431
|
+
else
|
432
|
+
# Code à exécuter sous Unix/Linux
|
433
|
+
current_path = `pwd`.chomp
|
434
|
+
end
|
353
435
|
segments = current_path.split("/")
|
354
436
|
project_name = segments.last
|
355
437
|
destination = segments[0...-1].join("/")
|
@@ -366,7 +448,19 @@ if ARGV.include?('run')
|
|
366
448
|
threads = []
|
367
449
|
threads << Thread.new do
|
368
450
|
sleep 1
|
369
|
-
|
451
|
+
|
452
|
+
|
453
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
454
|
+
# Code à exécuter sous Windows
|
455
|
+
`start "" "#{destination}\\#{project_name}\\src\\index_opal.html`
|
456
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
457
|
+
# Code à exécuter sous MacOS
|
458
|
+
`open http://localhost:9292`
|
459
|
+
else
|
460
|
+
# Code à exécuter sous Unix/Linux
|
461
|
+
`open http://localhost:9292`
|
462
|
+
end
|
463
|
+
|
370
464
|
end
|
371
465
|
build_for_server(destination, project_name, 9292, :production)
|
372
466
|
when 'osx'
|
@@ -386,7 +480,18 @@ if ARGV.include?('run')
|
|
386
480
|
else
|
387
481
|
wasi_file = 'wasi-vfs-osx_arm'
|
388
482
|
wasm_common(source, destination, project_name, wasi_file, 'pure_wasm')
|
389
|
-
|
483
|
+
|
484
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
485
|
+
# Code à exécuter sous Windows
|
486
|
+
`start "" "%current_path%\\src\\index.html"`
|
487
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
488
|
+
# Code à exécuter sous MacOS
|
489
|
+
`open #{current_path}/src/index.html`
|
490
|
+
else
|
491
|
+
# Code à exécuter sous Unix/Linux
|
492
|
+
`open #{current_path}/src/index.html`
|
493
|
+
end
|
494
|
+
|
390
495
|
end
|
391
496
|
|
392
497
|
end
|
@@ -2,10 +2,19 @@
|
|
2
2
|
|
3
3
|
# toolbox method here
|
4
4
|
require 'json'
|
5
|
+
|
5
6
|
class Atome
|
6
7
|
class << self
|
8
|
+
|
9
|
+
def file_handler(parent, content, bloc)
|
10
|
+
grab(parent).instance_exec(content, &bloc)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
7
15
|
def controller_sender(message)
|
8
16
|
return if $host == :html
|
17
|
+
|
9
18
|
json_msg = message.to_json
|
10
19
|
js_json_msg = json_msg.inspect
|
11
20
|
js_command = "atomeJS.controller_sender(#{js_json_msg})"
|
@@ -44,6 +53,9 @@ class Atome
|
|
44
53
|
end
|
45
54
|
|
46
55
|
# local server messaging
|
56
|
+
def file_for_opal(parent, bloc)
|
57
|
+
JS.eval("fileForOpal('#{parent}', #{bloc})")
|
58
|
+
end
|
47
59
|
|
48
60
|
def response_listener(hashed_msg)
|
49
61
|
js_action = hashed_msg.JS[:action]
|
@@ -127,6 +139,7 @@ class Atome
|
|
127
139
|
def atome_post_process(element, params, new_atome, &user_proc)
|
128
140
|
|
129
141
|
return unless Atome.instance_variable_get("@post_#{element}").is_a?(Proc)
|
142
|
+
|
130
143
|
new_atome.instance_exec(params, user_proc, &Atome.instance_variable_get("@post_#{element}"))
|
131
144
|
|
132
145
|
end
|
@@ -280,6 +293,7 @@ class Atome
|
|
280
293
|
debug "#{user_id} not found"
|
281
294
|
end
|
282
295
|
end
|
296
|
+
|
283
297
|
def remove_layout
|
284
298
|
display(:default)
|
285
299
|
# we get the current parent (the previous layout)
|
@@ -297,5 +311,4 @@ class Atome
|
|
297
311
|
end
|
298
312
|
end
|
299
313
|
|
300
|
-
|
301
314
|
end
|
data/lib/atome/version.rb
CHANGED
@@ -36,3 +36,49 @@ new({renderer: :html, method: :match}) do |params, bloc|
|
|
36
36
|
html.match(params)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
42
|
+
|
43
|
+
if Atome::host == 'web-opal'
|
44
|
+
file_for_opal(@id, bloc) do |file_content|
|
45
|
+
bloc.call(file_content)
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
# Wasm version
|
50
|
+
def create_file_browser(_options = '', &bloc)
|
51
|
+
div_element = JS.global[:document].getElementById(@id.to_s)
|
52
|
+
input_element = JS.global[:document].createElement("input")
|
53
|
+
input_element[:type] = "file"
|
54
|
+
input_element[:style][:position] = "absolute"
|
55
|
+
input_element[:style][:display] = "none"
|
56
|
+
input_element[:style][:width] = "0px"
|
57
|
+
input_element[:style][:height] = "0px"
|
58
|
+
|
59
|
+
input_element.addEventListener("change") do |native_event|
|
60
|
+
event = Native(native_event)
|
61
|
+
file = event[:target][:files][0]
|
62
|
+
if file
|
63
|
+
puts "file requested: #{file[:name]}"
|
64
|
+
file_reader = JS.global[:FileReader].new
|
65
|
+
file_reader.addEventListener("load") do |load_event|
|
66
|
+
file_content = load_event[:target][:result]
|
67
|
+
Atome.file_handler(@id, file_content, bloc)
|
68
|
+
end
|
69
|
+
file_reader.readAsText(file)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
div_element.addEventListener("mousedown") do |event|
|
74
|
+
input_element.click
|
75
|
+
end
|
76
|
+
div_element.appendChild(input_element)
|
77
|
+
end
|
78
|
+
create_file_browser(:options) do |file_content|
|
79
|
+
# puts "wasm ===>#{file_content}"
|
80
|
+
bloc.call(file_content)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -1,50 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
# id: :s3,
|
7
|
-
# left: 3, top: 3, blur: 9,
|
8
|
-
# invert: true,
|
9
|
-
# red: 0, green: 0, blue: 0, alpha: 0.7
|
10
|
-
# })
|
11
|
-
def create_file_browser
|
12
|
-
div_element = JS.global[:document].createElement("div")
|
13
|
-
|
14
|
-
# Définir les propriétés CSS de l'élément div
|
15
|
-
div_element[:style][:width] = "33px" # Taille: largeur de 100 pixels
|
16
|
-
div_element[:style][:height] = "33px" # Taille: hauteur de 100 pixels
|
17
|
-
div_element[:style][:backgroundColor] = "rgba(255,0,0,0.3)" # Couleur de fond rouge
|
18
|
-
div_element[:style][:position] = "absolute" # Positionnement absolu
|
19
|
-
div_element[:style][:top] = "0px" # Position par rapport au haut de l'écran
|
20
|
-
div_element[:style][:left] = "0px" # Position par rapport à la gauche de l'écran
|
21
|
-
|
22
|
-
# Définir un ID pour l'élément div
|
23
|
-
div_element[:id] = "monDiv"
|
24
|
-
|
25
|
-
input_element = JS.global[:document].createElement("input")
|
26
|
-
input_element[:type] = "file"
|
27
|
-
input_element[:style][:position] = "absolute"
|
28
|
-
input_element[:style][:display] = "none"
|
29
|
-
input_element[:style][:width] = "0px"
|
30
|
-
input_element[:style][:height] = "0px"
|
31
|
-
input_element.addEventListener("change") do |native_event|
|
32
|
-
event = Native(native_event)
|
33
|
-
file = event[:target][:files][0]
|
34
|
-
if file
|
35
|
-
puts "file requested: #{file[:name]}"
|
36
|
-
# support.controller({ action: :loadProject, params: { path: file[:name]} })
|
37
|
-
end
|
38
|
-
end
|
39
|
-
div_element.addEventListener("mousedown") do |event|
|
40
|
-
# Déclenchez manuellement un clic sur l'input
|
41
|
-
input_element.click
|
42
|
-
end
|
43
|
-
view_div = JS.global[:document].querySelector("#view")
|
44
|
-
|
45
|
-
view_div.appendChild(input_element)
|
46
|
-
view_div.appendChild(div_element)
|
47
|
-
|
3
|
+
b = box({ drag: true })
|
4
|
+
b.import(true) do |content|
|
5
|
+
puts "add code here, content: #{content}"
|
48
6
|
end
|
49
7
|
|
50
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
c=circle({left: 220})
|
5
|
-
t=text({left: 550,data: :hello,password: { read: {atome: :my_secret} }})
|
5
|
+
t=text({left: 550,data: :hello,password: { read: { atome: :my_secret} }})
|
6
6
|
b = box({ id: :the_box, left: 66,smooth: 1.789,
|
7
7
|
password: {
|
8
8
|
read: {
|
@@ -18,16 +18,16 @@ b = box({ id: :the_box, left: 66,smooth: 1.789,
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
b.authorise({ read: {atome: :the_pass,smooth: :read_pass }, write: {smooth: :write_pass}, destroy: true} )
|
21
|
+
b.authorise({ read: { atome: :the_pass, smooth: :read_pass }, write: { smooth: :write_pass}, destroy: true} )
|
22
22
|
puts b.smooth
|
23
23
|
# next will be rejected because destroy: true
|
24
24
|
puts b.smooth
|
25
25
|
#
|
26
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :no_read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
26
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :no_read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
27
27
|
puts 'will send the wrong password'
|
28
28
|
puts b.smooth
|
29
29
|
|
30
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
30
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
31
31
|
puts "'with send the right password it'll works"
|
32
32
|
puts b.smooth
|
33
33
|
# authorise has two params the first is the password to authorise the second is used to destroy the password or keep for
|
@@ -41,7 +41,7 @@ wait 1 do
|
|
41
41
|
b.authorise({write: {smooth: :write_pass}, destroy: false} )
|
42
42
|
b.smooth(66)
|
43
43
|
wait 1 do
|
44
|
-
b.authorise({write: {smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
44
|
+
b.authorise({write: { smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
45
45
|
b.smooth(6)
|
46
46
|
end
|
47
47
|
end
|
@@ -63,8 +63,6 @@ async function changeCurrentDirectory(atome_id, newPath) {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
|
66
|
-
|
67
|
-
|
68
66
|
// Terminal
|
69
67
|
|
70
68
|
async function terminal(atome_id, cmd) {
|
@@ -152,29 +150,166 @@ function createSvgElement(tagName, attributes) {
|
|
152
150
|
return elem;
|
153
151
|
}
|
154
152
|
|
153
|
+
//
|
154
|
+
// function sanitizeString(str) {
|
155
|
+
// return str.replace(/'/g, "\\'");
|
156
|
+
// }
|
157
|
+
// function fileread(){
|
158
|
+
// var inputElement = document.createElement("input");
|
159
|
+
// inputElement.type = "file";
|
160
|
+
//
|
161
|
+
// inputElement.addEventListener("change", function(event) {
|
162
|
+
// var file = event.target.files[0];
|
163
|
+
// var reader = new FileReader();
|
164
|
+
//
|
165
|
+
// reader.onload = function(event) {
|
166
|
+
// var content = event.target.result;
|
167
|
+
// var sanitizedContent = sanitizeString(content);
|
168
|
+
// rubyVMCallback("input_callback('"+sanitizedContent+"')");
|
169
|
+
// };
|
170
|
+
//
|
171
|
+
// reader.readAsText(file);
|
172
|
+
// });
|
173
|
+
//
|
174
|
+
// // Ajout de l'élément input à la div
|
175
|
+
// var viewDiv = document.querySelector("#support");
|
176
|
+
// viewDiv.appendChild(inputElement);
|
177
|
+
// }
|
155
178
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
179
|
+
|
180
|
+
function fileForOpal(parent, bloc) {
|
181
|
+
let input = document.createElement('input');
|
182
|
+
input.type = 'file';
|
183
|
+
input.style.position = "absolute";
|
184
|
+
input.style.display = "none";
|
185
|
+
input.style.width = "0px";
|
186
|
+
input.style.height = "0px";
|
187
|
+
input.addEventListener('change', function (event) {
|
188
|
+
let file = event.target.files[0];
|
189
|
+
let reader = new FileReader();
|
190
|
+
|
191
|
+
reader.onloadstart = function () {
|
192
|
+
console.log("Load start");
|
193
|
+
};
|
194
|
+
|
195
|
+
reader.onprogress = function (e) {
|
196
|
+
console.log("Loading: " + (e.loaded / e.total * 100) + '%');
|
197
|
+
};
|
198
|
+
|
199
|
+
reader.onload = function (e) {
|
200
|
+
var content = e.target.result;
|
201
|
+
Opal.Atome.$file_handler(parent, content, bloc)
|
202
|
+
};
|
203
|
+
|
204
|
+
reader.onloadend = function () {
|
205
|
+
console.log("Load end");
|
206
|
+
};
|
207
|
+
|
208
|
+
reader.onerror = function () {
|
209
|
+
console.error("Error reading file");
|
171
210
|
};
|
172
211
|
|
173
212
|
reader.readAsText(file);
|
174
213
|
});
|
214
|
+
let div_element = document.getElementById(parent);
|
215
|
+
div_element.appendChild(input);
|
216
|
+
div_element.addEventListener('mousedown', function (event) {
|
217
|
+
input.click()
|
218
|
+
})
|
175
219
|
|
176
|
-
// Ajout de l'élément input à la div
|
177
|
-
var viewDiv = document.querySelector("#support");
|
178
|
-
viewDiv.appendChild(inputElement);
|
179
220
|
}
|
180
221
|
|
222
|
+
function importer(){
|
223
|
+
|
224
|
+
// Gestionnaire pour le drag and drop de fichiers
|
225
|
+
document.body.addEventListener('dragover', function(e) {
|
226
|
+
e.preventDefault(); // Nécessaire pour autoriser le drop
|
227
|
+
// Modifier le style si nécessaire
|
228
|
+
});
|
229
|
+
|
230
|
+
document.body.addEventListener('drop', function(e) {
|
231
|
+
e.preventDefault();
|
232
|
+
let files = e.dataTransfer.files; // Obtention de la liste des fichiers déposés
|
233
|
+
|
234
|
+
if (files.length) {
|
235
|
+
// Parcourir chaque fichier
|
236
|
+
for (let i = 0; i < files.length; i++) {
|
237
|
+
let file = files[i];
|
238
|
+
let reader = new FileReader();
|
239
|
+
|
240
|
+
// Lire le fichier en tant que texte
|
241
|
+
reader.readAsText(file);
|
242
|
+
|
243
|
+
// Événement déclenché une fois la lecture terminée
|
244
|
+
reader.onload = function() {
|
245
|
+
console.log('Contenu du fichier #' + (i + 1));
|
246
|
+
console.log('Nom: ' + file.name);
|
247
|
+
console.log('Type: ' + file.type);
|
248
|
+
console.log('Taille: ' + file.size + ' octets');
|
249
|
+
console.log('Contenu: \n' + reader.result); // Affichage du contenu du fichier
|
250
|
+
};
|
251
|
+
|
252
|
+
// Gestion des erreurs de lecture
|
253
|
+
reader.onerror = function() {
|
254
|
+
console.error('Erreur de lecture du fichier: ' + file.name);
|
255
|
+
};
|
256
|
+
}
|
257
|
+
}
|
258
|
+
// if (e.dataTransfer.files.length) {
|
259
|
+
// alert (e.dataTransfer.files);
|
260
|
+
// // Traiter les fichiers déposés
|
261
|
+
// }
|
262
|
+
});
|
263
|
+
|
264
|
+
// Gestionnaire pour les éléments div
|
265
|
+
var divs = document.querySelectorAll('.draggable-div');
|
266
|
+
divs.forEach(function(div) {
|
267
|
+
div.addEventListener('dragstart', function(e) {
|
268
|
+
e.dataTransfer.setData('text/plain', 'some-data');
|
269
|
+
e.stopPropagation(); // Empêcher la propagation au body
|
270
|
+
});
|
271
|
+
});
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
importer()
|
276
|
+
|
277
|
+
|
278
|
+
function exception_import (){
|
279
|
+
// Sélectionner la div spéciale par son ID
|
280
|
+
var specialDiv = document.getElementById('exept');
|
281
|
+
|
282
|
+
// Gestionnaire d'événements pour la 'special-div' pour le drag over
|
283
|
+
specialDiv.addEventListener('dragover', function(e) {
|
284
|
+
|
285
|
+
specialDiv.style.backgroundColor= 'red';
|
286
|
+
e.preventDefault(); // Prévenir le comportement par défaut
|
287
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
288
|
+
});
|
289
|
+
specialDiv.addEventListener('dragleave', function(e) {
|
290
|
+
specialDiv.style.backgroundColor = 'yellow'; // Réinitialiser la couleur de fond lors du drag out
|
291
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
292
|
+
});
|
293
|
+
// Gestionnaire d'événements pour la 'special-div' pour le drop
|
294
|
+
specialDiv.addEventListener('drop', function(e) {
|
295
|
+
e.preventDefault(); // Prévenir le comportement par défaut
|
296
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
297
|
+
|
298
|
+
// Traitement spécifique pour les fichiers déposés sur la 'special-div'
|
299
|
+
console.log('Fichier déposé dans la zone spéciale');
|
300
|
+
});
|
301
|
+
|
302
|
+
// Gestionnaire d'événements pour le body pour le drop
|
303
|
+
// document.body.addEventListener('drop', function(e) {
|
304
|
+
// e.preventDefault(); // Prévenir le comportement par défaut
|
305
|
+
//
|
306
|
+
// // Traitement pour les fichiers déposés en dehors de la 'special-div'
|
307
|
+
// console.log('Fichier déposé hors de la zone spéciale');
|
308
|
+
// });
|
309
|
+
|
310
|
+
|
311
|
+
}
|
312
|
+
setTimeout(function () {
|
313
|
+
exception_import();
|
314
|
+
console.log('ready');
|
315
|
+
}, 3000);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.5.6.
|
4
|
+
version: 0.5.5.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Eric Godard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arduino_firmata
|
@@ -346,7 +346,6 @@ files:
|
|
346
346
|
- LICENSE.txt
|
347
347
|
- README.md
|
348
348
|
- Rakefile
|
349
|
-
- app_builder_helpers/Rakefile
|
350
349
|
- documentation/atome.md
|
351
350
|
- documentation/basic.md
|
352
351
|
- documentation/database.JPG
|
@@ -1,278 +0,0 @@
|
|
1
|
-
# # frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# # FIXME: check when creating gem version the new gem is not always fully updated we have to type gem uninstall first
|
4
|
-
#
|
5
|
-
# require 'opal'
|
6
|
-
# require 'parser'
|
7
|
-
# require 'uglifier'
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# Opal.append_path 'app'
|
11
|
-
#
|
12
|
-
# # def build_opal_content
|
13
|
-
# # Opal::Builder.build('../lib/platform_specific/opal/opal.rb').to_s
|
14
|
-
# # end
|
15
|
-
# #
|
16
|
-
# # def build_opal(user_project_path)
|
17
|
-
# #
|
18
|
-
# # opal_directory = "#{user_project_path}/src/js/opal"
|
19
|
-
# # opal_js = "#{opal_directory}/opal.js"
|
20
|
-
# # Dir.mkdir(opal_directory) unless File.directory?(opal_directory)
|
21
|
-
# #
|
22
|
-
# # File.new opal_js, 'w'
|
23
|
-
# # opal_content = build_opal_content
|
24
|
-
# # File.open(opal_js, 'w') do |f|
|
25
|
-
# # f.puts opal_content
|
26
|
-
# # end
|
27
|
-
# # end
|
28
|
-
#
|
29
|
-
# # def build_aui_for_opal(user_project_path)
|
30
|
-
# # # now we add an uniq aui to the app
|
31
|
-
# # aui_js = "#{user_project_path}/src/js/aui.js"
|
32
|
-
# # File.new aui_js, 'w'
|
33
|
-
# # builder = Opal::Builder.new
|
34
|
-
# # aui_content = builder.build("#{user_project_path}/src/utilities/aui.rb").to_s
|
35
|
-
# # File.open(aui_js, 'w') do |f|
|
36
|
-
# # f.puts aui_content
|
37
|
-
# # end
|
38
|
-
# # end
|
39
|
-
#
|
40
|
-
# # def build_host_mode_for_opal(user_project_path)
|
41
|
-
# # host_mode_js = "#{user_project_path}/src/js/host_mode.js"
|
42
|
-
# # File.new host_mode_js, 'w'
|
43
|
-
# # builder = Opal::Builder.new
|
44
|
-
# # host_mode_content = builder.build("#{user_project_path}/src/utilities/host_mode.rb").to_s
|
45
|
-
# # File.open(host_mode_js, 'w') do |f|
|
46
|
-
# # f.puts host_mode_content
|
47
|
-
# # end
|
48
|
-
# # end
|
49
|
-
#
|
50
|
-
# # def copy_assets_files(user_project_path, gem_location)
|
51
|
-
# # server_location = "#{gem_location}/../vendor/assets/server/"
|
52
|
-
# # FileUtils.copy_entry server_location, "#{user_project_path}/server", preserve: nil
|
53
|
-
# # css_location ="#{gem_location}/../vendor/assets/src/css/"
|
54
|
-
# # FileUtils.copy_entry css_location, "#{user_project_path}/src/css", preserve: nil
|
55
|
-
# # js_location ="#{gem_location}/../vendor/assets/src/js/"
|
56
|
-
# # FileUtils.copy_entry js_location, "#{user_project_path}/src/js", preserve: nil
|
57
|
-
# # index_location ="#{gem_location}/../vendor/assets/src/index.html"
|
58
|
-
# # FileUtils.copy_entry index_location, "#{user_project_path}/src/index.html", preserve: nil
|
59
|
-
# # end
|
60
|
-
#
|
61
|
-
# # def build_atome_kernel(user_project_path, gem_location)
|
62
|
-
# # # now lets build the atome kernel
|
63
|
-
# # atome_directory = "#{user_project_path}/src/js/atome"
|
64
|
-
# # Dir.mkdir(atome_directory) unless File.directory?(atome_directory)
|
65
|
-
# # kernel_js = "#{atome_directory}/kernel.js"
|
66
|
-
# # File.new kernel_js, 'w'
|
67
|
-
# # builder = Opal::Builder.new
|
68
|
-
# # builder.append_paths("#{gem_location}/../lib/")
|
69
|
-
# # kernel_content = builder.build("#{gem_location}/../lib/atome.rb").to_s
|
70
|
-
# # File.open(kernel_js, 'w') do |f|
|
71
|
-
# # f.puts kernel_content
|
72
|
-
# # end
|
73
|
-
# # end
|
74
|
-
#
|
75
|
-
# def build_opal_extensions(user_project_path, gem_location)
|
76
|
-
# opal_directory = "#{user_project_path}/src/js/opal"
|
77
|
-
# extensions_js = "#{opal_directory}/atome_opal_extensions.js"
|
78
|
-
# File.new extensions_js, 'w'
|
79
|
-
# builder = Opal::Builder.new
|
80
|
-
# builder.append_paths("#{gem_location}/../lib/platform_specific/opal/")
|
81
|
-
# extensions_content = builder.build("#{gem_location}/../lib/platform_specific/opal/atome_opal_extensions.rb").to_s
|
82
|
-
# File.open(extensions_js, 'w') do |f|
|
83
|
-
# f.puts extensions_content
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
#
|
87
|
-
# # def build_opal_parser(user_project_path)
|
88
|
-
# # parser_js = "#{user_project_path}/src/js/opal/opal_parser.js"
|
89
|
-
# # File.new parser_js, 'w'
|
90
|
-
# # parser_content = Opal::Builder.build('../lib/platform_specific/opal/opal_parser.rb').to_s
|
91
|
-
# # File.open(parser_js, 'w') do |f|
|
92
|
-
# # f.puts parser_content
|
93
|
-
# # end
|
94
|
-
# # end
|
95
|
-
#
|
96
|
-
# def modify_and_copy_file(source_path, destination_path,source_code)
|
97
|
-
# file_content = File.read(source_path)
|
98
|
-
# modified_content = file_content.gsub(' ', ' ').gsub(' ', ' ').gsub(' ', ' ').gsub(' ', ' ').gsub("require './", "require 'tmp/opal/").gsub('require "./', 'require "tmp/opal/')
|
99
|
-
# File.write(destination_path, modified_content)
|
100
|
-
#
|
101
|
-
# end
|
102
|
-
# def process_directory(source_dir, destination_dir, source_code)
|
103
|
-
# Dir.entries(source_dir).each do |entry|
|
104
|
-
# next if entry == '.' || entry == '..'
|
105
|
-
#
|
106
|
-
# source_path = File.join(source_dir, entry)
|
107
|
-
# destination_path = File.join(destination_dir, entry)
|
108
|
-
#
|
109
|
-
# if File.directory?(source_path)
|
110
|
-
# Dir.mkdir(destination_path) unless Dir.exist?(destination_path)
|
111
|
-
# process_directory(source_path, destination_path,source_code)
|
112
|
-
# elsif File.file?(source_path)
|
113
|
-
# modify_and_copy_file(source_path, destination_path,source_code)
|
114
|
-
# end
|
115
|
-
# end
|
116
|
-
# end
|
117
|
-
# def build_user_code(user_project_path, source_code)
|
118
|
-
# application_js = "#{user_project_path}/src/js/application.js"
|
119
|
-
# builder = Opal::Builder.new
|
120
|
-
# builder.append_paths("#{user_project_path}/")
|
121
|
-
# source_directory = "#{source_code}/application"
|
122
|
-
# destination_directory = "#{source_code}/tmp/opal"
|
123
|
-
# process_directory(source_directory, destination_directory, source_code)
|
124
|
-
# application_content = builder.build("#{source_code}/tmp/opal/index.rb").to_s
|
125
|
-
# File.open(application_js, 'w') do |f|
|
126
|
-
# f.puts application_content
|
127
|
-
# end
|
128
|
-
# end
|
129
|
-
#
|
130
|
-
# def build_system_infos(user_project_path, source_code)
|
131
|
-
# system_infos_js = "#{user_project_path}/src/js/infos.js"
|
132
|
-
# builder = Opal::Builder.new
|
133
|
-
# builder.append_paths("#{user_project_path}/")
|
134
|
-
# # system_infos = builder.build("#{source_code}/src/utilities/mode.rb").to_s
|
135
|
-
# File.open(system_infos_js, 'w') do |f|
|
136
|
-
# f.puts system_infos
|
137
|
-
# end
|
138
|
-
# end
|
139
|
-
#
|
140
|
-
# def minimize_aui(user_project_path)
|
141
|
-
# aui_js = "#{user_project_path}/src/js/aui.js"
|
142
|
-
# aui_content = File.open(aui_js).read
|
143
|
-
# aui_content = Uglifier.new.compile(aui_content)
|
144
|
-
# File.open(aui_js, 'w') do |f|
|
145
|
-
# f.puts aui_content
|
146
|
-
# end
|
147
|
-
# end
|
148
|
-
#
|
149
|
-
# def minimize_opal(user_project_path)
|
150
|
-
# opal_js = "#{user_project_path}/src/js/opal/opal.js"
|
151
|
-
# opal_content = File.open(opal_js).read
|
152
|
-
# opal_content = Uglifier.new.compile(opal_content)
|
153
|
-
# File.open(opal_js, 'w') do |f|
|
154
|
-
# f.puts opal_content
|
155
|
-
# end
|
156
|
-
# end
|
157
|
-
#
|
158
|
-
# def minimize_parser(user_project_path)
|
159
|
-
# parser_js = "#{user_project_path}/src/js/opal/opal_parser.js"
|
160
|
-
# parser_content = File.open(parser_js).read
|
161
|
-
# parser_content = Uglifier.new.compile(parser_content)
|
162
|
-
# File.open(parser_js, 'w') do |f|
|
163
|
-
# f.puts parser_content
|
164
|
-
# end
|
165
|
-
# end
|
166
|
-
#
|
167
|
-
# def minimize_kernel(user_project_path)
|
168
|
-
# kernel_js = "#{user_project_path}/src/js/atome/kernel.js"
|
169
|
-
# kernel_content = File.open(kernel_js).read
|
170
|
-
# kernel_content = Uglifier.new.compile(kernel_content)
|
171
|
-
# File.open(kernel_js, 'w') do |f|
|
172
|
-
# f.puts kernel_content
|
173
|
-
# end
|
174
|
-
# end
|
175
|
-
#
|
176
|
-
# def minimize_atome(user_project_path)
|
177
|
-
# atome_js = "#{user_project_path}/src/js/atome/atome.js"
|
178
|
-
# atome_content = File.open(atome_js).read
|
179
|
-
# atome_content = Uglifier.new.compile(atome_content)
|
180
|
-
# File.open(atome_js, 'w') do |f|
|
181
|
-
# f.puts atome_content
|
182
|
-
# end
|
183
|
-
# end
|
184
|
-
#
|
185
|
-
# def minimize_opal_extensions(user_project_path)
|
186
|
-
# atome_opal_extensions_js = "#{user_project_path}/src/js/opal/atome_opal_extensions.js"
|
187
|
-
# atome_opal_extensions_content = File.open(atome_opal_extensions_js).read
|
188
|
-
# atome_opal_extensions_content = Uglifier.new.compile(atome_opal_extensions_content)
|
189
|
-
# File.open(atome_opal_extensions_js, 'w') do |f|
|
190
|
-
# f.puts atome_opal_extensions_content
|
191
|
-
# end
|
192
|
-
# end
|
193
|
-
#
|
194
|
-
# def minimize_libraries(user_project_path)
|
195
|
-
# # minimizing aui
|
196
|
-
# minimize_aui(user_project_path)
|
197
|
-
# # minimizing opal
|
198
|
-
# minimize_opal(user_project_path)
|
199
|
-
# # # minimizing opal_browser
|
200
|
-
# # minimize_browser(user_project_path)
|
201
|
-
# # minimizing opal_parser
|
202
|
-
# minimize_parser(user_project_path)
|
203
|
-
# # minimizing atome_lib
|
204
|
-
# minimize_kernel(user_project_path)
|
205
|
-
# # minimizing atome
|
206
|
-
# minimize_atome(user_project_path)
|
207
|
-
# # minimizing atome_lib
|
208
|
-
# minimize_opal_extensions(user_project_path)
|
209
|
-
# # minimizing application
|
210
|
-
# minimize_application(user_project_path)
|
211
|
-
# # minimize(user_project_path) if production == 'production'
|
212
|
-
# end
|
213
|
-
#
|
214
|
-
# def minimize_application(user_project_path)
|
215
|
-
# # minimizing user codes
|
216
|
-
# application_js = "#{user_project_path}/src/js/application.js"
|
217
|
-
# application_content = File.open(application_js).read
|
218
|
-
# application_content = Uglifier.new.compile(application_content)
|
219
|
-
# File.open(application_js, 'w') do |f|
|
220
|
-
# f.puts application_content
|
221
|
-
# end
|
222
|
-
# end
|
223
|
-
#
|
224
|
-
# task :build_user_code, :user_project_path, :production do |_t, args|
|
225
|
-
# user_project_path = args[:user_project_path]
|
226
|
-
# source_code = "#{user_project_path}"
|
227
|
-
# build_system_infos(user_project_path, source_code)
|
228
|
-
# build_user_code(user_project_path, source_code)
|
229
|
-
# end
|
230
|
-
#
|
231
|
-
# task :system_builder, :user_project_path, :production do |_t, args|
|
232
|
-
# user_project_path = args[:user_project_path]
|
233
|
-
# production = args[:production]
|
234
|
-
# source_code = '../vendor/assets'
|
235
|
-
# build_common_libraries(user_project_path, production)
|
236
|
-
# build_system_infos(user_project_path, source_code)
|
237
|
-
# build_user_code(user_project_path, source_code)
|
238
|
-
#
|
239
|
-
# # TODO: catch and message to user when when there's no force and folder already exist
|
240
|
-
# end
|
241
|
-
#
|
242
|
-
# task :system_updater, :user_project_path, :production do |_t, args|
|
243
|
-
# user_project_path = args[:user_project_path]
|
244
|
-
# production = args[:production]
|
245
|
-
# gem_location = File.join(File.dirname(__FILE__))
|
246
|
-
# build_libraries(user_project_path, gem_location)
|
247
|
-
# build_common_libraries(user_project_path, production)
|
248
|
-
# end
|
249
|
-
#
|
250
|
-
# task :minimizer, :user_project_path do |_t, args|
|
251
|
-
# user_project_path = args[:user_project_path]
|
252
|
-
# minimize(user_project_path)
|
253
|
-
# end
|
254
|
-
#
|
255
|
-
# task default: :run
|
256
|
-
#
|
257
|
-
# def build_libraries(user_project_path, gem_location)
|
258
|
-
# build_aui_for_opal(user_project_path)
|
259
|
-
# build_host_mode_for_opal(user_project_path)
|
260
|
-
# build_atome_kernel(user_project_path, gem_location)
|
261
|
-
# build_opal(user_project_path)
|
262
|
-
# build_opal_parser(user_project_path)
|
263
|
-
# build_opal_extensions(user_project_path, gem_location)
|
264
|
-
# end
|
265
|
-
#
|
266
|
-
# def minimize(user_project_path)
|
267
|
-
# minimize_libraries(user_project_path)
|
268
|
-
# # minimize_user_code(user_project_path)
|
269
|
-
# end
|
270
|
-
#
|
271
|
-
# def build_common_libraries(user_project_path, production)
|
272
|
-
# gem_location = File.join(File.dirname(__FILE__))
|
273
|
-
# copy_assets_files(user_project_path, gem_location)
|
274
|
-
# build_libraries(user_project_path, gem_location)
|
275
|
-
# minimize(user_project_path) if production == 'production'
|
276
|
-
# end
|
277
|
-
#
|
278
|
-
# # TODO: integrate pure JS (ruby2js) compilation
|