atome 0.5.4.1.7 → 0.5.5.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (358) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -1
  3. data/Gemfile +3 -1
  4. data/README.md +70 -1
  5. data/Rakefile +246 -75
  6. data/app_builder_helpers/Rakefile +276 -288
  7. data/documentation/basic.md +242 -0
  8. data/documentation/deep learning/architecture.txt +3763 -0
  9. data/documentation/deep learning/atome.png +0 -0
  10. data/documentation/deep learning/basic_infos.txt +227 -0
  11. data/documentation/deep learning/example_of_users_code.rb +1810 -0
  12. data/documentation/deep learning/misc.txt +24 -0
  13. data/documentation/deep learning/ruby_js_example.rb +272 -0
  14. data/documentation/deep learning/wasm_script_help.text +14 -0
  15. data/documentation/framework/enhance_atome.md +1 -1
  16. data/documentation/tutorials/tutorials.md +7 -0
  17. data/exe/atome +308 -208
  18. data/lib/atome/atome.rb +52 -156
  19. data/lib/atome/extensions/atome.rb +129 -47
  20. data/lib/atome/extensions/mathematics.rb +20 -0
  21. data/lib/atome/extensions/ping.rb +2 -3
  22. data/lib/atome/genesis/generators/atome.rb +57 -30
  23. data/lib/atome/genesis/generators/communication.rb +9 -0
  24. data/lib/atome/genesis/generators/effect.rb +0 -1
  25. data/lib/atome/genesis/generators/event.rb +279 -43
  26. data/lib/atome/genesis/generators/geometry.rb +1 -10
  27. data/lib/atome/genesis/generators/hierarchy.rb +103 -0
  28. data/lib/atome/genesis/generators/identity.rb +45 -84
  29. data/lib/atome/genesis/generators/material.rb +31 -34
  30. data/lib/atome/genesis/generators/property.rb +31 -0
  31. data/lib/atome/genesis/generators/security.rb +31 -0
  32. data/lib/atome/genesis/generators/spatial.rb +3 -5
  33. data/lib/atome/genesis/generators/time.rb +0 -1
  34. data/lib/atome/genesis/generators/utility.rb +181 -66
  35. data/lib/atome/genesis/genesis.rb +152 -55
  36. data/lib/atome/genesis/sparkle.rb +59 -75
  37. data/lib/atome/helpers/color_helper/color/rgb/colors.rb +1 -1
  38. data/lib/atome/helpers/color_helper/color/rgb.rb +1 -1
  39. data/lib/atome/helpers/color_helper/color.rb +226 -7
  40. data/lib/atome/helpers/essentials.rb +22 -26
  41. data/lib/atome/helpers/security.rb +71 -0
  42. data/lib/atome/helpers/utilities.rb +191 -178
  43. data/lib/atome/kernel/black_matter.rb +22 -0
  44. data/lib/atome/kernel/universe.rb +123 -24
  45. data/lib/atome/presets/atome.rb +39 -35
  46. data/lib/atome/version.rb +3 -2
  47. data/lib/atome.rb +12 -12
  48. data/lib/atome_relative.rb +36 -0
  49. data/lib/{atome/renderers → platform_specific}/opal/atome_opal_extensions.rb +4 -1
  50. data/lib/{atome/renderers → platform_specific}/opal/extensions/color.rb +12 -5
  51. data/lib/{atome/renderers → platform_specific}/opal/extensions/geolocation.rb +1 -0
  52. data/lib/platform_specific/opal/extensions/js.rb +21 -0
  53. data/lib/platform_specific/opal/extensions/object.rb +6 -0
  54. data/lib/platform_specific/opal/extensions/ping.rb +31 -0
  55. data/lib/{atome/renderers → platform_specific}/opal/extensions/sha.rb +4 -2
  56. data/lib/platform_specific/wasm/atome_wasm_extensions.rb +11 -0
  57. data/lib/renderers/headless/headless.rb +18 -0
  58. data/lib/renderers/headless/index.rb +6 -0
  59. data/lib/renderers/headless/index_relative.rb +6 -0
  60. data/lib/renderers/headless/utility.rb +6 -0
  61. data/{vendor/assets/src/medias/rubies/examples/top.rb → lib/renderers/html/atome.rb} +0 -1
  62. data/lib/renderers/html/atome_html.rb +22 -0
  63. data/lib/renderers/html/effect.rb +26 -0
  64. data/lib/renderers/html/event.rb +43 -0
  65. data/lib/renderers/html/geometry.rb +31 -0
  66. data/lib/renderers/html/hierarchy.rb +233 -0
  67. data/lib/renderers/html/html.rb +1112 -0
  68. data/lib/renderers/html/identity.rb +84 -0
  69. data/lib/renderers/html/index.rb +19 -0
  70. data/lib/renderers/html/index_relative.rb +20 -0
  71. data/lib/renderers/html/material.rb +53 -0
  72. data/lib/renderers/html/property.rb +24 -0
  73. data/lib/renderers/html/spatial.rb +46 -0
  74. data/lib/renderers/html/time.rb +1 -0
  75. data/lib/renderers/html/utility.rb +38 -0
  76. data/lib/renderers/renderer.rb +16 -0
  77. data/lib/renderers/server/index.rb +4 -0
  78. data/lib/renderers/server/index_relative.rb +4 -0
  79. data/lib/renderers/server/utility.rb +4 -0
  80. data/sig/atome.rbs +6 -0
  81. data/sig/object.rbs +4 -0
  82. data/sig/universe.rbs +3 -0
  83. data/vendor/assets/Rakefile +3 -3
  84. data/vendor/assets/application/examples/a_concat.rb +16 -0
  85. data/vendor/assets/application/examples/affect.rb +8 -0
  86. data/vendor/assets/application/examples/animation.rb +96 -0
  87. data/vendor/assets/application/examples/apply.rb +8 -0
  88. data/vendor/assets/application/examples/atome.rb +5 -0
  89. data/vendor/assets/application/examples/attach.rb +34 -0
  90. data/vendor/assets/application/examples/attached.rb +38 -0
  91. data/vendor/assets/application/examples/basic_understanding.rb +52 -0
  92. data/vendor/assets/application/examples/browse.rb +17 -0
  93. data/vendor/assets/application/examples/callback.rb +20 -0
  94. data/vendor/assets/application/examples/category.rb +12 -0
  95. data/vendor/assets/application/examples/clear.rb +96 -0
  96. data/vendor/assets/application/examples/clones.rb +177 -0
  97. data/vendor/assets/application/examples/code.rb +13 -0
  98. data/vendor/assets/application/examples/color.rb +54 -0
  99. data/vendor/assets/application/examples/convert.rb +163 -0
  100. data/vendor/assets/application/examples/copy.rb +25 -0
  101. data/vendor/assets/application/examples/copybck.rb +68 -0
  102. data/vendor/assets/application/examples/debug.rb +78 -0
  103. data/vendor/assets/application/examples/delete.rb +93 -0
  104. data/vendor/assets/application/examples/display.rb +279 -0
  105. data/vendor/assets/application/examples/display_bck.rb +164 -0
  106. data/vendor/assets/application/examples/drag.rb +45 -0
  107. data/vendor/assets/application/examples/drop.rb +35 -0
  108. data/vendor/assets/application/examples/duplicate.rb +64 -0
  109. data/vendor/assets/application/examples/edit.rb +21 -0
  110. data/vendor/assets/application/examples/encode.rb +6 -0
  111. data/vendor/assets/application/examples/file.rb +50 -0
  112. data/vendor/assets/application/examples/find.rb +157 -0
  113. data/vendor/assets/application/examples/generator_and_build.rb +15 -0
  114. data/vendor/assets/application/examples/getter.rb +16 -0
  115. data/vendor/assets/application/examples/grab.rb +14 -0
  116. data/vendor/assets/application/examples/gradient.rb +35 -0
  117. data/vendor/assets/application/examples/group.rb +44 -0
  118. data/vendor/assets/application/examples/hierarchy.rb +21 -0
  119. data/vendor/assets/application/examples/history.rb +31 -0
  120. data/vendor/assets/application/examples/hypertext.rb +113 -0
  121. data/vendor/assets/application/examples/image.rb +5 -0
  122. data/vendor/assets/application/examples/keyboard.rb +59 -0
  123. data/vendor/assets/application/examples/layout.rb +227 -0
  124. data/vendor/assets/application/examples/login.rb +10 -0
  125. data/vendor/assets/application/examples/markup.rb +4 -0
  126. data/vendor/assets/application/examples/match.rb +115 -0
  127. data/vendor/assets/application/examples/messaging.rb +16 -0
  128. data/vendor/assets/application/examples/monitor.rb +14 -0
  129. data/vendor/assets/application/examples/on_resize.rb +7 -0
  130. data/vendor/assets/{src/medias/rubies/examples/get_renderer_list.rb → application/examples/online.rb} +1 -1
  131. data/vendor/assets/application/examples/over.rb +29 -0
  132. data/vendor/assets/application/examples/paint.rb +23 -0
  133. data/vendor/assets/application/examples/particles.rb +4 -0
  134. data/vendor/assets/application/examples/percent_to_px.rb +4 -0
  135. data/vendor/assets/application/examples/play.rb +50 -0
  136. data/vendor/assets/application/examples/presets.rb +33 -0
  137. data/vendor/assets/application/examples/random.rb +42 -0
  138. data/vendor/assets/application/examples/raw_html.rb +48 -0
  139. data/vendor/assets/application/examples/read.rb +11 -0
  140. data/vendor/assets/application/examples/refresh.rb +62 -0
  141. data/vendor/assets/application/examples/remove.rb +47 -0
  142. data/vendor/assets/application/examples/repeat.rb +26 -0
  143. data/vendor/assets/application/examples/resize.rb +17 -0
  144. data/vendor/assets/application/examples/scroll.rb +11 -0
  145. data/vendor/assets/application/examples/security.rb +76 -0
  146. data/vendor/assets/application/examples/selected.rb +30 -0
  147. data/vendor/assets/application/examples/shadow.rb +46 -0
  148. data/vendor/assets/application/examples/shapes.rb +6 -0
  149. data/vendor/assets/{src/medias/rubies → application}/examples/smooth.rb +5 -1
  150. data/vendor/assets/application/examples/style.rb +4 -0
  151. data/vendor/assets/application/examples/sync.rb +39 -0
  152. data/vendor/assets/application/examples/tagged.rb +24 -0
  153. data/vendor/assets/application/examples/terminal.rb +4 -0
  154. data/vendor/assets/application/examples/text.rb +5 -0
  155. data/vendor/assets/application/examples/touch.rb +38 -0
  156. data/vendor/assets/application/examples/type_mutation.rb +18 -0
  157. data/vendor/assets/application/examples/universe.rb +8 -0
  158. data/vendor/assets/application/examples/vector.rb +24 -0
  159. data/vendor/assets/application/examples/video.rb +14 -0
  160. data/vendor/assets/application/examples/wait.rb +6 -0
  161. data/vendor/assets/application/examples/www.rb +10 -0
  162. data/vendor/assets/application/index.rb +1 -1
  163. data/vendor/assets/application/test.rb +29 -0
  164. data/vendor/assets/application/works/photos.rb +672 -0
  165. data/vendor/assets/application/works/photos2.rb +218 -0
  166. data/vendor/assets/application/works/photos3.rb +343 -0
  167. data/vendor/assets/application/works/photos4.rb +34 -0
  168. data/vendor/assets/application/works/photos6.rb +6 -0
  169. data/vendor/assets/application/works/trigga.rb +0 -0
  170. data/vendor/assets/application/works/vie.rb +74 -0
  171. data/vendor/assets/server/atome_server.rb +37 -41
  172. data/vendor/assets/server/atome_server_wasm.rb +112 -0
  173. data/vendor/assets/server/capture.rb +10 -0
  174. data/vendor/assets/server/config.ru +5 -4
  175. data/vendor/assets/src/css/style.css +29 -4
  176. data/vendor/assets/src/index.html +31 -38
  177. data/vendor/assets/src/index_opal.html +42 -0
  178. data/vendor/assets/src/index_server.html +43 -0
  179. data/vendor/assets/src/index_server_wasm.html +46 -0
  180. data/vendor/assets/src/js/atome/atome.js +170 -150
  181. data/vendor/assets/src/js/atome/atome_helpers/add_font.js +46 -0
  182. data/vendor/assets/src/js/atome/atome_helpers/atome_drag.js +3 -1
  183. data/vendor/assets/src/js/atome/atome_helpers/atome_events.js +12 -7
  184. data/vendor/assets/src/js/atome/atome_helpers/communication.js +126 -0
  185. data/vendor/assets/src/js/atome/atome_helpers/{atome_file.js → file.js} +1 -1
  186. data/vendor/assets/src/js/atome/specific/opal.js +3 -0
  187. data/vendor/assets/src/js/atome/specific/wasm.js +12 -0
  188. data/vendor/assets/src/js/third_parties/browser.script.iife.min.js +13 -0
  189. data/vendor/assets/src/js/third_parties/fabric.min.js +1 -1
  190. data/vendor/assets/src/js/third_parties/html-to-image.min.js +2 -0
  191. data/vendor/assets/src/js/third_parties/jsencrypt.min.js +2 -0
  192. data/vendor/assets/src/js/third_parties/papaparse.min.js +7 -0
  193. data/vendor/assets/src/medias/fonts/Roboto/LICENSE.txt +202 -0
  194. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Black.ttf +0 -0
  195. data/vendor/assets/src/medias/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  196. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Bold.ttf +0 -0
  197. data/vendor/assets/src/medias/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  198. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Italic.ttf +0 -0
  199. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Light.ttf +0 -0
  200. data/vendor/assets/src/medias/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  201. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Medium.ttf +0 -0
  202. data/vendor/assets/src/medias/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  203. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Regular.ttf +0 -0
  204. data/vendor/assets/src/medias/fonts/Roboto/Roboto-Thin.ttf +0 -0
  205. data/vendor/assets/src/medias/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  206. data/vendor/assets/src/medias/images/logos/Facebook.svg +1 -1
  207. data/vendor/assets/src/medias/images/logos/LinkedIn-full.svg +109 -0
  208. data/vendor/assets/src/medias/images/logos/LinkedIn.svg +11 -0
  209. data/vendor/assets/src/medias/images/logos/X.svg +5 -0
  210. data/vendor/assets/src-tauri/Cargo.toml +1 -1
  211. data/vendor/assets/src-tauri/src/main.rs +59 -5
  212. data/vendor/assets/src-tauri/tauri.conf.json +1 -1
  213. data/vendor/assets/src-wasm/wasm/wasi-vfs-osx_arm +0 -0
  214. data/vendor/assets/src-wasm/wasm/wasi-vfs-osx_x86 +0 -0
  215. data/vendor/assets/src-wasm/wasm/wasi-vfs-unix +0 -0
  216. data/vendor/assets/src-wasm/wasm/wasi-vfs.exe +0 -0
  217. metadata +188 -180
  218. data/lib/atome/extensions/mathematic.rb +0 -20
  219. data/lib/atome/extensions/matrix.rb +0 -346
  220. data/lib/atome/helpers/callbacks.rb +0 -133
  221. data/lib/atome/kernel/batch.rb +0 -26
  222. data/lib/atome/kernel/essentials.rb +0 -23
  223. data/lib/atome/renderers/browser/atome.rb +0 -158
  224. data/lib/atome/renderers/browser/browser.rb +0 -47
  225. data/lib/atome/renderers/browser/effect.rb +0 -23
  226. data/lib/atome/renderers/browser/event.rb +0 -96
  227. data/lib/atome/renderers/browser/geometry.rb +0 -27
  228. data/lib/atome/renderers/browser/helpers/animation_helper.rb +0 -69
  229. data/lib/atome/renderers/browser/helpers/browser_helper.rb +0 -101
  230. data/lib/atome/renderers/browser/helpers/color_helper.rb +0 -80
  231. data/lib/atome/renderers/browser/helpers/drag_helper.rb +0 -52
  232. data/lib/atome/renderers/browser/helpers/drop_helper.rb +0 -13
  233. data/lib/atome/renderers/browser/helpers/effect_helper.rb +0 -23
  234. data/lib/atome/renderers/browser/helpers/event_helper.rb +0 -76
  235. data/lib/atome/renderers/browser/helpers/image_helper.rb +0 -27
  236. data/lib/atome/renderers/browser/helpers/over_helper.rb +0 -13
  237. data/lib/atome/renderers/browser/helpers/shadow_helper.rb +0 -74
  238. data/lib/atome/renderers/browser/helpers/shape_helper.rb +0 -22
  239. data/lib/atome/renderers/browser/helpers/text_helper.rb +0 -38
  240. data/lib/atome/renderers/browser/helpers/video_helper.rb +0 -50
  241. data/lib/atome/renderers/browser/helpers/web_helper.rb +0 -26
  242. data/lib/atome/renderers/browser/identity.rb +0 -61
  243. data/lib/atome/renderers/browser/material.rb +0 -121
  244. data/lib/atome/renderers/browser/opal_add_on.rb +0 -31
  245. data/lib/atome/renderers/browser/opal_browser.rb +0 -6
  246. data/lib/atome/renderers/browser/spatial.rb +0 -59
  247. data/lib/atome/renderers/browser/time.rb +0 -3
  248. data/lib/atome/renderers/browser/utility.rb +0 -49
  249. data/lib/atome/renderers/headless/headless.rb +0 -10
  250. data/lib/atome/renderers/headless/utility.rb +0 -6
  251. data/lib/atome/renderers/html/atome.rb +0 -49
  252. data/lib/atome/renderers/html/effect.rb +0 -19
  253. data/lib/atome/renderers/html/event.rb +0 -9
  254. data/lib/atome/renderers/html/geometry.rb +0 -11
  255. data/lib/atome/renderers/html/html.rb +0 -42
  256. data/lib/atome/renderers/html/identity.rb +0 -14
  257. data/lib/atome/renderers/html/opal_browser.rb +0 -6
  258. data/lib/atome/renderers/html/spatial.rb +0 -28
  259. data/lib/atome/renderers/html/utility.rb +0 -17
  260. data/lib/atome/renderers/opal/extensions/atome.rb +0 -29
  261. data/lib/atome/renderers/opal/extensions/ping.rb +0 -18
  262. data/lib/atome/renderers/renderer.rb +0 -15
  263. data/lib/atome/renderers/server/server.rb +0 -10
  264. data/lib/atome/renderers/server/utility.rb +0 -6
  265. data/vendor/assets/aui.rb +0 -5
  266. data/vendor/assets/r&d/misc.rb +0 -219
  267. data/vendor/assets/r&d/ping.rb +0 -3
  268. data/vendor/assets/r&d/storage.rb +0 -9
  269. data/vendor/assets/r&d/view_example.rb +0 -21
  270. data/vendor/assets/src/js/atome/atome_helpers/atome_communication.js +0 -40
  271. data/vendor/assets/src/medias/javascripts/test.js +0 -1
  272. data/vendor/assets/src/medias/rubies/demos.rb +0 -63
  273. data/vendor/assets/src/medias/rubies/examples/add.rb +0 -24
  274. data/vendor/assets/src/medias/rubies/examples/animation.rb +0 -81
  275. data/vendor/assets/src/medias/rubies/examples/atome_new.rb +0 -27
  276. data/vendor/assets/src/medias/rubies/examples/attach.rb +0 -15
  277. data/vendor/assets/src/medias/rubies/examples/attached.rb +0 -15
  278. data/vendor/assets/src/medias/rubies/examples/auto_height.rb +0 -5
  279. data/vendor/assets/src/medias/rubies/examples/auto_width.rb +0 -4
  280. data/vendor/assets/src/medias/rubies/examples/batch.rb +0 -17
  281. data/vendor/assets/src/medias/rubies/examples/blur.rb +0 -4
  282. data/vendor/assets/src/medias/rubies/examples/bottom.rb +0 -3
  283. data/vendor/assets/src/medias/rubies/examples/box.rb +0 -20
  284. data/vendor/assets/src/medias/rubies/examples/center.rb +0 -21
  285. data/vendor/assets/src/medias/rubies/examples/circle.rb +0 -3
  286. data/vendor/assets/src/medias/rubies/examples/class.rb +0 -13
  287. data/vendor/assets/src/medias/rubies/examples/clear.rb +0 -10
  288. data/vendor/assets/src/medias/rubies/examples/clone.rb +0 -35
  289. data/vendor/assets/src/medias/rubies/examples/code.rb +0 -11
  290. data/vendor/assets/src/medias/rubies/examples/color.rb +0 -73
  291. data/vendor/assets/src/medias/rubies/examples/create_atome_in_atome.rb +0 -13
  292. data/vendor/assets/src/medias/rubies/examples/cursor.rb +0 -7
  293. data/vendor/assets/src/medias/rubies/examples/delete.rb +0 -42
  294. data/vendor/assets/src/medias/rubies/examples/depth.rb +0 -6
  295. data/vendor/assets/src/medias/rubies/examples/detached.rb +0 -13
  296. data/vendor/assets/src/medias/rubies/examples/drag.rb +0 -98
  297. data/vendor/assets/src/medias/rubies/examples/drop.rb +0 -26
  298. data/vendor/assets/src/medias/rubies/examples/edit.rb +0 -12
  299. data/vendor/assets/src/medias/rubies/examples/element.rb +0 -6
  300. data/vendor/assets/src/medias/rubies/examples/empty_atome.rb +0 -12
  301. data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +0 -15
  302. data/vendor/assets/src/medias/rubies/examples/grab.rb +0 -5
  303. data/vendor/assets/src/medias/rubies/examples/height.rb +0 -7
  304. data/vendor/assets/src/medias/rubies/examples/hide.rb +0 -7
  305. data/vendor/assets/src/medias/rubies/examples/id.rb +0 -14
  306. data/vendor/assets/src/medias/rubies/examples/image.rb +0 -8
  307. data/vendor/assets/src/medias/rubies/examples/left.rb +0 -7
  308. data/vendor/assets/src/medias/rubies/examples/link.rb +0 -22
  309. data/vendor/assets/src/medias/rubies/examples/markers.rb +0 -48
  310. data/vendor/assets/src/medias/rubies/examples/materials.rb +0 -15
  311. data/vendor/assets/src/medias/rubies/examples/matrix.rb +0 -102
  312. data/vendor/assets/src/medias/rubies/examples/matrix_changes.rb +0 -483
  313. data/vendor/assets/src/medias/rubies/examples/matrix_simple.rb +0 -32
  314. data/vendor/assets/src/medias/rubies/examples/monitoring.rb +0 -70
  315. data/vendor/assets/src/medias/rubies/examples/mute.rb +0 -22
  316. data/vendor/assets/src/medias/rubies/examples/on.rb +0 -26
  317. data/vendor/assets/src/medias/rubies/examples/opacity.rb +0 -5
  318. data/vendor/assets/src/medias/rubies/examples/over.rb +0 -21
  319. data/vendor/assets/src/medias/rubies/examples/pause.rb +0 -15
  320. data/vendor/assets/src/medias/rubies/examples/physical.rb +0 -19
  321. data/vendor/assets/src/medias/rubies/examples/play.rb +0 -15
  322. data/vendor/assets/src/medias/rubies/examples/read.rb +0 -11
  323. data/vendor/assets/src/medias/rubies/examples/refresh.rb +0 -8
  324. data/vendor/assets/src/medias/rubies/examples/remove.rb +0 -16
  325. data/vendor/assets/src/medias/rubies/examples/repeat.rb +0 -6
  326. data/vendor/assets/src/medias/rubies/examples/right.rb +0 -3
  327. data/vendor/assets/src/medias/rubies/examples/rotate.rb +0 -4
  328. data/vendor/assets/src/medias/rubies/examples/schedule.rb +0 -13
  329. data/vendor/assets/src/medias/rubies/examples/shadow.rb +0 -84
  330. data/vendor/assets/src/medias/rubies/examples/size.rb +0 -8
  331. data/vendor/assets/src/medias/rubies/examples/sort.rb +0 -18
  332. data/vendor/assets/src/medias/rubies/examples/style.rb +0 -4
  333. data/vendor/assets/src/medias/rubies/examples/tags.rb +0 -10
  334. data/vendor/assets/src/medias/rubies/examples/text.rb +0 -39
  335. data/vendor/assets/src/medias/rubies/examples/time.rb +0 -18
  336. data/vendor/assets/src/medias/rubies/examples/to_px.rb +0 -10
  337. data/vendor/assets/src/medias/rubies/examples/touch.rb +0 -56
  338. data/vendor/assets/src/medias/rubies/examples/vector.rb +0 -39
  339. data/vendor/assets/src/medias/rubies/examples/video.rb +0 -65
  340. data/vendor/assets/src/medias/rubies/examples/wait.rb +0 -8
  341. data/vendor/assets/src/medias/rubies/examples/web.rb +0 -13
  342. data/vendor/assets/src/medias/rubies/examples/width.rb +0 -6
  343. data/vendor/assets/src/medias/rubies/test.rb +0 -1
  344. data/vendor/assets/src/medias/rubies/text_read.rb +0 -1
  345. data/vendor/assets/src/medias/rubies/unstable/!run.rb +0 -16
  346. data/vendor/assets/src/medias/rubies/unstable/_2_solve.rb +0 -72
  347. data/vendor/assets/src/medias/rubies/unstable/_attach.rb +0 -12
  348. data/vendor/assets/src/medias/rubies/unstable/_audio.rb +0 -231
  349. data/vendor/assets/src/medias/rubies/unstable/_dataset.rb +0 -257
  350. data/vendor/assets/src/medias/rubies/unstable/_matrix.rb +0 -58
  351. data/vendor/assets/src/medias/rubies/unstable/_os.rb +0 -29
  352. data/vendor/assets/src/medias/rubies/unstable/_table2.rb +0 -108
  353. data/vendor/assets/src/medias/rubies/unstable/_vie.rb +0 -211
  354. data/vendor/assets/src/medias/rubies/users/code.rb +0 -6
  355. /data/lib/{atome/renderers → platform_specific}/opal/opal.rb +0 -0
  356. /data/lib/{atome/renderers → platform_specific}/opal/opal_parser.rb +0 -0
  357. /data/{vendor/assets/src/utilities/mode.rb → lib/renderers/html/communication.rb} +0 -0
  358. /data/{vendor/assets/src/medias/rubies/unstable/_test.rb → lib/renderers/html/security.rb} +0 -0
@@ -0,0 +1,1112 @@
1
+ # frozen_string_literal: true
2
+
3
+ # this class is aimed at html rendering
4
+
5
+ class HTML
6
+
7
+ def initialize(id_found, current_atome)
8
+ @element ||= JS.global[:document].getElementById(id_found.to_s)
9
+ @id = id_found
10
+ @original_atome = current_atome
11
+ end
12
+
13
+ def hypertext(params)
14
+ current_div = JS.global[:document].getElementById(@id.to_s)
15
+ current_div[:innerHTML] = params
16
+ end
17
+
18
+ def add_css_to_atomic_style(css)
19
+ style_element = JS.global[:document].getElementById('atomic_style')
20
+ text_node = JS.global[:document].createTextNode(css)
21
+ style_element.appendChild(text_node)
22
+ end
23
+
24
+ def convert_to_css(data)
25
+ conditions = data[:condition]
26
+ apply = data[:alterations]
27
+
28
+ # Convert the conditions
29
+ condition_strings = []
30
+
31
+ if conditions[:max]
32
+ condition_strings << "(max-width: #{conditions[:max][:width]}px)" if conditions[:max][:width]
33
+ condition_strings << "(max-height: #{conditions[:max][:height]}px)" if conditions[:max][:height]
34
+ end
35
+
36
+ if conditions[:min]
37
+ condition_strings << "(min-width: #{conditions[:min][:width]}px)" if conditions[:min][:width]
38
+ condition_strings << "(min-height: #{conditions[:min][:height]}px)" if conditions[:min][:height]
39
+ end
40
+
41
+ operator = conditions[:operator] == :and ? "and" : "or"
42
+
43
+ # Convert properties to apply
44
+ property_strings = []
45
+ apply.each do |key, values|
46
+ inner_properties = []
47
+ values.each do |property, value|
48
+ if property == :color
49
+ inner_properties << "background-color: #{value} !important;"
50
+ else
51
+ inner_properties << "#{property}: #{value}px !important;" if value.is_a?(Integer)
52
+ inner_properties << "#{property}: #{value} !important;" if value.is_a?(Symbol)
53
+ end
54
+ end
55
+ # Prefix each key with "#"
56
+ property_strings << "##{key} {\n#{inner_properties.join("\n")}\n}"
57
+ end
58
+
59
+ # let it build
60
+ css = "@media #{condition_strings.join(" #{operator} ")} {\n#{property_strings.join("\n")}\n}"
61
+ add_css_to_atomic_style(css)
62
+ css
63
+ end
64
+
65
+ def css_to_data(css)
66
+ data = {
67
+ :condition => {},
68
+ :apply => {}
69
+ }
70
+ # Extract conditions
71
+ media_conditions = css.match(/@media ([^\{]+)/)[1].split(',').map(&:strip)
72
+ media_conditions.each do |condition|
73
+ type = condition.match(/(max|min)-/)[1].to_sym
74
+ property = condition.match(/(width|height)/)[1].to_sym
75
+ value = condition.match(/(\d+)/)[1].to_i
76
+
77
+ data[:condition][type] ||= {}
78
+ data[:condition][type][property] = value
79
+ end
80
+
81
+ # Extract properties to be applied
82
+ css.scan(/(\w+) \{([^\}]+)\}/).each do |match|
83
+ key = match[0].to_sym
84
+ properties = match[1].split(';').map(&:strip).reject(&:empty?)
85
+
86
+ data[:apply][key] ||= {}
87
+ properties.each do |property|
88
+ prop, value = property.split(':').map(&:strip)
89
+ if prop == "background-color"
90
+ data[:apply][key][:color] = value.to_sym
91
+ elsif value[-2..] == "px"
92
+ data[:apply][key][prop.to_sym] = value.to_i
93
+ else
94
+ data[:apply][key][prop.to_sym] = value.to_sym
95
+ end
96
+ end
97
+ end
98
+
99
+ data
100
+ end
101
+
102
+ def extract_properties(properties_string)
103
+ properties_hash = {}
104
+ properties = properties_string.split(';').map(&:strip).reject(&:empty?)
105
+ properties.each do |property|
106
+ key, value = property.split(':').map(&:strip)
107
+ properties_hash[key] = value
108
+ end
109
+ properties_hash
110
+ end
111
+
112
+ def get_page_style
113
+ main_view = JS.global[:document].getElementById('view')
114
+ main_view_content = main_view[:innerHTML].to_s
115
+ style_tags = main_view_content.split(/<\/?style[^>]*>/i).select.with_index { |_, index| index.odd? }
116
+ style_tags = style_tags.join('')
117
+ style_tags = style_tags.split("\n")
118
+ hash_result = {}
119
+ inside_media = false
120
+ media_hash = {}
121
+
122
+ style_tags.each do |line|
123
+ line = line.strip
124
+ next if line.empty? || line.start_with?("/*")
125
+
126
+ if inside_media
127
+ if line == "}"
128
+ hash_result["@media"] << media_hash
129
+ inside_media = false
130
+ next
131
+ end
132
+
133
+ selector, properties = line.split('{').map(&:strip)
134
+ next unless properties&.end_with?("}")
135
+
136
+ properties = properties[0...-1].strip
137
+ media_hash[selector] = extract_properties(properties)
138
+ elsif line.start_with?("@media")
139
+ media_content = line.match(/@media\s*\(([^)]+)\)\s*{/)
140
+ next unless media_content
141
+
142
+ media_query = media_content[1]
143
+ hash_result["@media"] = [media_query]
144
+ inside_media = true
145
+ else
146
+ selector, properties = line.split('{').map(&:strip)
147
+ next unless properties&.end_with?("}")
148
+
149
+ properties = properties[0...-1].strip
150
+ hash_result[selector] = extract_properties(properties)
151
+ end
152
+ end
153
+ hash_result
154
+ end
155
+
156
+ def hyperedit(params)
157
+ html_object = JS.global[:document].getElementById(params.to_s)
158
+ particles_from_style = {}
159
+ # we get all the styles tag present in the page
160
+ get_page_style
161
+ if html_object[:className].to_s
162
+ classes_found = html_object[:className].to_s.split(' ')
163
+ classes_found.each do |class_found|
164
+ if get_page_style[".#{class_found}"]
165
+ particles_from_style = particles_from_style.merge(get_page_style[".#{class_found}"])
166
+ end
167
+ end
168
+ end
169
+
170
+ particles_found = {}
171
+ particles_found[:data] = html_object[:innerText].to_s.chomp
172
+ particles_found[:markup] = html_object[:tagName].to_s
173
+
174
+ style_found = html_object[:style][:cssText].to_s
175
+
176
+ style_found.split(';').each do |pair|
177
+ key, value = pair.split(':').map(&:strip)
178
+ particles_from_style[key.to_sym] = value if key && value
179
+ end
180
+ particles_found = particles_found.merge(particles_from_style)
181
+ current_atome = grab(@id)
182
+ current_atome.callback({ hyperedit: particles_found })
183
+ current_atome.call(:hyperedit)
184
+
185
+ end
186
+
187
+ def match(params)
188
+ css_converted = convert_to_css(params)
189
+ css_to_data(css_converted)
190
+ end
191
+
192
+ def connect(params, &bloc)
193
+ JS.eval("atomeJS.connect('ws://#{params}')")
194
+ end
195
+
196
+ def send_message(message)
197
+ JS.eval("atomeJS.ws_sender('#{message}')")
198
+ end
199
+
200
+ def close_websocket
201
+ @websocket.close
202
+ end
203
+
204
+ def attr(attribute, value)
205
+ @element.setAttribute(attribute.to_s, value.to_s)
206
+ self
207
+ end
208
+
209
+ def add_class(class_to_add)
210
+ @element[:classList].add(class_to_add.to_s)
211
+ self
212
+ end
213
+
214
+ def remove_class(class_to_remove)
215
+ @element[:classList].remove(class_to_remove.to_s)
216
+ self
217
+ end
218
+
219
+ def id(id)
220
+ attr('id', id)
221
+ self
222
+ end
223
+
224
+ def check_double(id)
225
+ # we remove any element if the id already exist
226
+ element_to_delete = JS.global[:document].getElementById(id.to_s)
227
+ delete(id) unless element_to_delete.inspect == 'null'
228
+ end
229
+
230
+ def shape(id)
231
+ # we remove any element if the id already exist
232
+ check_double(id)
233
+ markup_found = @original_atome.markup || :div
234
+ @element_type = markup_found.to_s
235
+ @element = JS.global[:document].createElement(@element_type)
236
+ JS.global[:document][:body].appendChild(@element)
237
+ add_class('atome')
238
+ id(id)
239
+ self
240
+ end
241
+
242
+ def text(id)
243
+ # we remove any element if the id already exist
244
+ check_double(id)
245
+ markup_found = @original_atome.markup || :pre
246
+ @element_type = markup_found.to_s
247
+ @element = JS.global[:document].createElement(@element_type)
248
+ JS.global[:document][:body].appendChild(@element)
249
+ add_class('atome')
250
+ id(id)
251
+ self
252
+ end
253
+
254
+ def image(id)
255
+ # we remove any element if the id already exist
256
+ check_double(id)
257
+ markup_found = @original_atome.markup || :img
258
+ @element_type = markup_found.to_s
259
+ @element = JS.global[:document].createElement(@element_type)
260
+ JS.global[:document][:body].appendChild(@element)
261
+ add_class('atome')
262
+ self.id(id)
263
+ self
264
+ end
265
+
266
+ def video(id)
267
+ # we remove any element if the id already exist
268
+ check_double(id)
269
+ markup_found = @original_atome.markup || :video
270
+ @element_type = markup_found.to_s
271
+ @element = JS.global[:document].createElement(@element_type)
272
+ JS.global[:document][:body].appendChild(@element)
273
+ add_class('atome')
274
+ self.id(id)
275
+ self
276
+ end
277
+
278
+ def www(id)
279
+ # we remove any element if the id already exist
280
+ check_double(id)
281
+ markup_found = @original_atome.markup || :iframe
282
+ @element_type = markup_found.to_s
283
+ @element = JS.global[:document].createElement(@element_type)
284
+ JS.global[:document][:body].appendChild(@element)
285
+ add_class('atome')
286
+ @element.setAttribute('src', 'https://www.youtube.com/embed/lLeQZ8Llkso?si=MMsGBEXELy9yBl9R')
287
+ # below we get image to feed width and height if needed
288
+ # image = JS.global[:Image].new
289
+ self.id(id)
290
+ self
291
+ end
292
+
293
+ def raw(id)
294
+ # we remove any element if the id already exist
295
+ check_double(id)
296
+ @element = JS.global[:document].createElement('div')
297
+ add_class('atome')
298
+ self.id(id)
299
+ JS.global[:document][:body].appendChild(@element)
300
+ self
301
+ end
302
+
303
+ def svg(id)
304
+ # we remove any element if the id already exist
305
+ check_double(id)
306
+ markup_found = @original_atome.markup || 'svg'
307
+ @element_type = markup_found.to_s
308
+ svg_ns = "http://www.w3.org/2000/svg"
309
+ @element = JS.global[:document].createElementNS(svg_ns, "svg")
310
+ JS.global[:document][:body].appendChild(@element)
311
+ @element.setAttribute('viewBox', '0 0 1024 1024')
312
+ @element.setAttribute('version', '1.1')
313
+ add_class('atome')
314
+ self.id(id)
315
+ self
316
+ end
317
+
318
+ def svg_data(data)
319
+ data.each do |type_passed, datas|
320
+ svg_ns = "http://www.w3.org/2000/svg"
321
+ new_path = JS.global[:document].createElementNS(svg_ns.to_s, type_passed.to_s)
322
+ JS.global[:document][:body].appendChild(new_path)
323
+ datas.each do |property, value|
324
+ new_path.setAttribute(property.to_s, value.to_s)
325
+ end
326
+ @element.appendChild(new_path)
327
+ end
328
+ end
329
+
330
+ def update_svg_data(data)
331
+ data.each do |type_passed, datas|
332
+ element_to_update = JS.global[:document].getElementById(type_passed.to_s)
333
+ datas.each do |property, value|
334
+ element_to_update.setAttribute(property.to_s, value.to_s)
335
+ end
336
+ end
337
+ end
338
+
339
+ def colorize_svg_data(data)
340
+ command = <<-JS
341
+ let svgElement = document.getElementById("#{@id}");
342
+ if (!svgElement) {
343
+ return [];
344
+ }
345
+ var children = svgElement.children;
346
+ var ids = [];
347
+ for (var i = 0; i < children.length; i++) {
348
+ var element = document.getElementById(children[i].id); // Récupérer l'élément par son ID
349
+ if (element) {
350
+ element.setAttribute('fill', '#{data}'); // Modifier l'attribut fill
351
+ element.setAttribute('stroke', '#{data}'); // Modifier l'attribut stroke
352
+ }
353
+ ids.push(children[i].id);
354
+ }
355
+ return ids
356
+ JS
357
+ JS.eval(command)
358
+ end
359
+
360
+ def raw_data(html_string)
361
+ @element[:innerHTML] = html_string
362
+ end
363
+
364
+ def video_path(video_path, type = 'video/mp4')
365
+ source = JS.global[:document].createElement('source')
366
+ source.setAttribute('src', video_path)
367
+ source.setAttribute('type', type)
368
+ @element.appendChild(source)
369
+ end
370
+
371
+ def sanitize_text(text)
372
+ text.to_s
373
+ .gsub('&', "\&")
374
+ .gsub('<', "\<")
375
+ .gsub('>', "\>")
376
+ .gsub('"', "\"")
377
+ .gsub("'", "\'")
378
+ end
379
+
380
+ def innerText(data)
381
+ sanitized_data = sanitize_text(data.to_s)
382
+ @element[:innerText] = sanitized_data
383
+ end
384
+
385
+ def textContent(data)
386
+ @element[:textContent] = data
387
+ end
388
+
389
+ def path(objet_path)
390
+ @element.setAttribute('src', objet_path)
391
+ # below we get image to feed width and height if needed
392
+ # image = JS.global[:Image].new
393
+ @element[:src] = objet_path
394
+ @element[:onload] = lambda do |_event|
395
+ @element[:width]
396
+ @element[:height]
397
+ end
398
+ end
399
+
400
+ def transform(property, value = nil)
401
+ transform_needed = "#{property}(#{value}deg)"
402
+ @element[:style][:transform] = transform_needed.to_s
403
+ end
404
+
405
+ def style(property, value = nil)
406
+ if value
407
+ @element[:style][property] = value.to_s
408
+ elsif value.nil?
409
+ @element[:style][property]
410
+ else
411
+ # If value is explicitly set to false, remove the property
412
+ command = "document.getElementById('#{@id}').style.removeProperty('#{property}')"
413
+ JS.eval(command)
414
+ end
415
+ end
416
+
417
+ def filter(property, value)
418
+ filter_needed = "#{property}(#{value})"
419
+ @element[:style][:filter] = filter_needed
420
+ end
421
+
422
+ def currentTime(time)
423
+ @element[:currentTime] = time
424
+ end
425
+
426
+ def animation_frame_callback(proc_pass, play_content)
427
+ JS.global[:window].requestAnimationFrame(-> (timestamp) {
428
+ current_time = @element[:currentTime]
429
+ fps = 30
430
+ current_frame = (current_time.to_f * fps).to_i
431
+ @original_atome.instance_exec({ frame: current_frame, time: current_time }, &proc_pass) if proc_pass.is_a? Proc
432
+ # we update play instance variable so if user ask for atome.play it will return current frame
433
+ play_content[:play] = current_frame
434
+ animation_frame_callback(proc_pass, play_content)
435
+ })
436
+ end
437
+
438
+ def action(_particle, action_found, option = nil)
439
+
440
+ # alert option
441
+ if action_found == :stop
442
+ currentTime(option)
443
+ @element.pause
444
+ elsif action_found == :pause
445
+ @element.pause
446
+ else
447
+ currentTime(option)
448
+ proc_found = @original_atome.instance_variable_get('@play_code')[action_found]
449
+ play_content = @original_atome.instance_variable_get('@play')
450
+ animation_frame_callback(proc_found, play_content)
451
+ @element.play
452
+ end
453
+ end
454
+
455
+ def append_to(parent_id_found)
456
+ parent_found = JS.global[:document].getElementById(parent_id_found.to_s)
457
+ parent_found.appendChild(@element)
458
+ self
459
+ end
460
+
461
+ # def visible(param)
462
+ # @element[:style][:display] = param.to_s
463
+ # end
464
+
465
+ def delete(id_to_delete)
466
+ element_to_delete = JS.global[:document].getElementById(id_to_delete.to_s)
467
+ element_to_delete.remove if element_to_delete
468
+ end
469
+
470
+ def append(child_id_found)
471
+ child_found = JS.global[:document].getElementById(child_id_found.to_s)
472
+ @element.appendChild(child_found)
473
+ self
474
+ end
475
+
476
+ # events handlers
477
+ def on(property, _option)
478
+ bloc = @original_atome.instance_variable_get('@on_code')[:view_resize]
479
+ property = property.to_s
480
+
481
+ if property.start_with?('media:')
482
+ # extract request from property
483
+ media_query = property.split(':', 2).last
484
+
485
+ mql = JS.global[:window].matchMedia(media_query)
486
+
487
+ event_handler = ->(event) do
488
+ bloc.call({ matches: event[:matches] }) if bloc.is_a? Proc
489
+ end
490
+
491
+ # add a listener to matchMedia object
492
+ mql.addListener(event_handler)
493
+
494
+ elsif property == 'resize'
495
+ event_handler = ->(event) do
496
+ width = JS.global[:window][:innerWidth]
497
+ height = JS.global[:window][:innerHeight]
498
+ bloc.call({ width: width, height: height }) if bloc.is_a? Proc
499
+ end
500
+ JS.global[:window].addEventListener('resize', event_handler)
501
+ else
502
+ event_handler = ->(event) do
503
+ bloc.call(event) if bloc.is_a? Proc
504
+ end
505
+ @element.addEventListener(property, event_handler)
506
+ end
507
+ end
508
+
509
+ def keyboard_press(_option)
510
+ @keyboard_press = @original_atome.instance_variable_get('@keyboard_code')[:press]
511
+
512
+ keypress_handler = ->(native_event) do
513
+
514
+ event = Native(native_event)
515
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
516
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
517
+ # group etc..
518
+ @keyboard_press.call(event) if @keyboard_press.is_a?(Proc)
519
+ end
520
+ @element.addEventListener('keypress', keypress_handler)
521
+ end
522
+
523
+ def keyboard_down(_option)
524
+ @keyboard_down = @original_atome.instance_variable_get('@keyboard_code')[:down]
525
+
526
+ keypress_handler = ->(event) do
527
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
528
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
529
+ # group etc..
530
+ @keyboard_down.call(event) if @keyboard_down.is_a?(Proc)
531
+ end
532
+ @element.addEventListener('keydown', keypress_handler)
533
+ end
534
+
535
+ def keyboard_up(_option)
536
+ @keyboard_up = @original_atome.instance_variable_get('@keyboard_code')[:up]
537
+
538
+ keypress_handler = ->(event) do
539
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
540
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
541
+ # group etc..
542
+ @keyboard_up.call(event) if @keyboard_up.is_a?(Proc)
543
+ end
544
+ @element.addEventListener('keyup', keypress_handler)
545
+ end
546
+
547
+ def keyboard_remove(option)
548
+ case option
549
+ when :down
550
+ @keyboard_down = ''
551
+ when :up
552
+ @keyboard_up = ''
553
+ when :down
554
+ @keyboard_press = ''
555
+ else
556
+ @keyboard_down = ''
557
+ @keyboard_up = ''
558
+ @keyboard_press = ''
559
+ end
560
+ end
561
+
562
+ def event(action, variance, option = nil)
563
+ send("#{action}_#{variance}", option)
564
+ end
565
+
566
+ def restrict_movement(restricted_x, restricted_y)
567
+ @original_atome.left(restricted_x)
568
+ @original_atome.top(restricted_y)
569
+ end
570
+
571
+ def drag_remove(option)
572
+ case option
573
+ when :start
574
+ @drag_start = ''
575
+ when :end, :stop
576
+ @drag_end = ''
577
+ when :locked
578
+ @drag_locked = ''
579
+ when :restrict
580
+ @drag_restrict = ''
581
+ else
582
+ # to remove all interact event ( touch, drag, scale, ... uncomment below)
583
+ @drag_start = ''
584
+ @drag_end = ''
585
+ @drag_locked = ''
586
+ @drag_restrict = ''
587
+ end
588
+
589
+ end
590
+
591
+ def drag_start(_option)
592
+ interact = JS.eval("return interact('##{@id}')")
593
+ @drag_start = @original_atome.instance_variable_get('@drag_code')[:start]
594
+ interact.on('dragstart') do |native_event|
595
+ event = Native(native_event)
596
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
597
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
598
+ # group etc..
599
+ @drag_start.call(event) if @drag_start.is_a?(Proc)
600
+ end
601
+ end
602
+
603
+ def drag_end(_option)
604
+ interact = JS.eval("return interact('##{@id}')")
605
+ @drag_end = @original_atome.instance_variable_get('@drag_code')[:end]
606
+ interact.on('dragend') do |native_event|
607
+ event = Native(native_event)
608
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
609
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
610
+ # group etc..
611
+ @drag_end.call(event) if @drag_end.is_a?(Proc)
612
+ end
613
+ end
614
+
615
+ def drag_move(_option)
616
+ interact = JS.eval("return interact('##{@id}')")
617
+ interact.draggable({
618
+ drag: true,
619
+ inertia: { resistance: 12,
620
+ minSpeed: 200,
621
+ endSpeed: 100 },
622
+ })
623
+
624
+ @drag_move = @original_atome.instance_variable_get('@drag_code')[:move]
625
+ interact.on('dragmove') do |native_event|
626
+ # the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
627
+ event = Native(native_event)
628
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
629
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
630
+ # group etc..
631
+ @drag_move.call(event) if @drag_move.is_a?(Proc)
632
+
633
+ dx = event[:dx]
634
+ dy = event[:dy]
635
+ x = (@original_atome.left || 0) + dx.to_f
636
+ y = (@original_atome.top || 0) + dy.to_f
637
+ @original_atome.left(x)
638
+ @original_atome.top(y)
639
+ end
640
+ end
641
+
642
+ def drag_restrict(option)
643
+ interact = JS.eval("return interact('##{@id}')")
644
+ interact.draggable({
645
+ drag: true,
646
+ inertia: { resistance: 12,
647
+ minSpeed: 200,
648
+ endSpeed: 100 },
649
+ })
650
+
651
+ @drag_move = @original_atome.instance_variable_get('@drag_code')[:restrict]
652
+ if option.instance_of? Hash
653
+ max_left = grab(:view).to_px(:width)
654
+ max_top = grab(:view).to_px(:height)
655
+ min_left = 0
656
+ min_top = 0
657
+
658
+ if option[:max]
659
+ max_left = option[:max][:left] || max_left
660
+ max_top = option[:max][:top] || max_top
661
+ else
662
+ max_left
663
+ max_top
664
+ end
665
+ if option[:min]
666
+ min_left = option[:min][:left] || min_left
667
+ min_top = option[:min][:top] || min_top
668
+ else
669
+ min_left
670
+ min_top
671
+ end
672
+ else
673
+ parent_found = grab(option)
674
+ min_left = parent_found.left
675
+ min_top = parent_found.top
676
+ parent_width = parent_found.width
677
+ parent_height = parent_found.height
678
+ original_width = @original_atome.width
679
+ original_height = @original_atome.height
680
+ max_left = min_left + parent_width - original_width
681
+ max_top = min_top + parent_height - original_height
682
+ end
683
+
684
+ interact.on('dragmove') do |native_event|
685
+ # the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
686
+ event = Native(native_event)
687
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
688
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
689
+ # group etc..
690
+ @drag_move.call(event) if @drag_move.is_a?(Proc)
691
+ dx = event[:dx]
692
+ dy = event[:dy]
693
+ x = (@original_atome.left || 0) + dx.to_f
694
+ y = (@original_atome.top || 0) + dy.to_f
695
+ restricted_x = [[x, min_left].max, max_left].min
696
+ restricted_y = [[y, min_top].max, max_top].min
697
+ restrict_movement(restricted_x, restricted_y)
698
+ end
699
+ end
700
+
701
+ def drag_locked(_option)
702
+ interact = JS.eval("return interact('##{@id}')")
703
+ interact.draggable({
704
+ drag: true,
705
+ inertia: { resistance: 12,
706
+ minSpeed: 200,
707
+ endSpeed: 100 }
708
+ })
709
+
710
+ @drag_lock = @original_atome.instance_variable_get('@drag_code')[:locked]
711
+ interact.on('dragmove') do |native_event|
712
+ # the use of Native is only for Opal (look at lib/platform_specific/atome_wasm_extensions.rb for more infos)
713
+ event = Native(native_event)
714
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
715
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
716
+ # group etc..
717
+ @drag_lock.call(event) if @drag_lock.is_a?(Proc)
718
+ end
719
+ end
720
+
721
+ def drop_action(native_event, bloc)
722
+ event = Native(native_event)
723
+ draggable_element = event[:relatedTarget][:id].to_s
724
+ dropzone_element = event[:target][:id].to_s
725
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
726
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
727
+ # group etc..
728
+ bloc.call({ source: draggable_element, destination: dropzone_element }) if bloc.is_a?(Proc)
729
+ end
730
+
731
+ def drop_activate(_option)
732
+ interact = JS.eval("return interact('##{@id}')")
733
+ @drop_activate = @original_atome.instance_variable_get('@drop_code')[:activate]
734
+
735
+ interact.dropzone({
736
+ accept: nil, # Accept any element
737
+ overlap: 0.75,
738
+ ondropactivate: lambda do |native_event|
739
+ drop_action(native_event, @drop_activate)
740
+ end
741
+ })
742
+ end
743
+
744
+ def drop_deactivate(_option)
745
+ interact = JS.eval("return interact('##{@id}')")
746
+ @drop_deactivate = @original_atome.instance_variable_get('@drop_code')[:deactivate]
747
+ interact.dropzone({
748
+ # accept: nil, # Accept any element
749
+ # overlap: 0.75,
750
+ # FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
751
+ ondropdeactivate: lambda do |native_event|
752
+ drop_action(native_event, @drop_deactivate)
753
+ end
754
+ })
755
+ end
756
+
757
+ def drop_dropped(_option)
758
+ @drop_dropped = @original_atome.instance_variable_get('@drop_code')[:dropped]
759
+ interact = JS.eval("return interact('##{@id}')")
760
+ interact.dropzone({
761
+ # accept: nil, # Accept any element
762
+ overlap: 0.75,
763
+ # FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
764
+ ondrop: lambda do |native_event|
765
+ drop_action(native_event, @drop_dropped)
766
+ end
767
+ })
768
+ end
769
+
770
+ def drop_enter(_option)
771
+ interact = JS.eval("return interact('##{@id}')")
772
+
773
+ @drop_enter = @original_atome.instance_variable_get('@drop_code')[:enter]
774
+
775
+ interact.dropzone({
776
+ # accept: nil,
777
+ overlap: 0.001,
778
+ # FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
779
+ ondragenter: lambda do |native_event|
780
+ drop_action(native_event, @drop_enter)
781
+ end
782
+ })
783
+ end
784
+
785
+ def drop_leave(_option)
786
+ interact = JS.eval("return interact('##{@id}')")
787
+ @drop_leave = @original_atome.instance_variable_get('@drop_code')[:leave]
788
+
789
+ interact.dropzone({
790
+ # accept: nil,
791
+ # overlap: 0.75,
792
+ # FIXME : remove because os an opal bug since 1.8 reactivate when opal will be debbuged
793
+ ondragleave: lambda do |native_event|
794
+ drop_action(native_event, @drop_leave)
795
+ end
796
+ })
797
+
798
+ end
799
+
800
+ def drop_remove(option)
801
+ case option
802
+ when :activate
803
+ @drop_activate = ''
804
+ when :deactivate
805
+ @drop_deactivate = ''
806
+ when :dropped
807
+ @drop_dropped = ''
808
+ when :enter
809
+ @drop_enter = ''
810
+ when :leave
811
+ @drop_leave = ''
812
+ else
813
+ # to remove all interact event ( touch, drag, scale, ... uncomment below)
814
+ # interact = JS.eval("return interact('##{@id}')")
815
+ # interact.unset
816
+ @drop_activate = ''
817
+ @drop_deactivate = ''
818
+ @drop_dropped = ''
819
+ @drop_enter = ''
820
+ @drop_leave = ''
821
+
822
+ end
823
+
824
+ end
825
+
826
+ def resize(params, options)
827
+ interact = JS.eval("return interact('##{@id}')")
828
+ if params == :remove
829
+ @resize = ''
830
+ interact.resizable(false)
831
+ else
832
+ min_width = options[:min][:width] || 10
833
+ min_height = options[:min][:height] || 10
834
+ max_width = options[:max][:width] || 3000
835
+ max_height = options[:max][:height] || 3000
836
+ @resize = @original_atome.instance_variable_get('@resize_code')[:resize]
837
+ interact.resizable({
838
+ edges: { left: true, right: true, top: true, bottom: true },
839
+ inertia: true,
840
+ modifiers: [],
841
+ listeners: {
842
+ move: lambda do |native_event|
843
+ if @resize.is_a?(Proc)
844
+ event = Native(native_event)
845
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
846
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
847
+ # group etc..
848
+ @resize.call(event) if @resize.is_a?(Proc)
849
+ x = (@element[:offsetLeft].to_i || 0)
850
+ y = (@element[:offsetTop].to_i || 0)
851
+ width = event[:rect][:width]
852
+ height = event[:rect][:height]
853
+ # Translate when resizing from any corner
854
+ x += event[:deltaRect][:left].to_f
855
+ y += event[:deltaRect][:top].to_f
856
+ @original_atome.width width.to_i if width.to_i.between?(min_width, max_width)
857
+ @original_atome.height height.to_i if height.to_i.between?(min_height, max_height)
858
+ @original_atome.left(x)
859
+ @original_atome.top (y)
860
+ end
861
+ end
862
+ },
863
+
864
+ })
865
+ end
866
+
867
+ end
868
+
869
+ def overflow(params, bloc)
870
+ style(:overflow, params)
871
+ @overflow = @original_atome.instance_variable_get('@overflow_code')[:overflow]
872
+ @element.addEventListener('scroll', lambda do |event|
873
+ scroll_top = @element[:scrollTop].to_i
874
+ scroll_left = @element[:scrollLeft].to_i
875
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
876
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
877
+ # group etc..
878
+ @overflow.call({ left: scroll_left, top: scroll_top }) if @overflow.is_a?(Proc)
879
+ end)
880
+ end
881
+
882
+ def over_over(_option)
883
+ interact = JS.eval("return interact('##{@id}')")
884
+ @over_over = @original_atome.over_code[:over]
885
+ interact.on('mouseover') do |native_event|
886
+ JS.global[:myRubyMouseOverCallback] = Proc.new { @original_atome.over_code[:over].call }
887
+ JS.eval("document.querySelector('##{@id}').addEventListener('mouseleave', myRubyMouseOverCallback);")
888
+ event = Native(native_event)
889
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
890
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
891
+ # group etc..
892
+ @over_over.call(event) if @over_over.is_a?(Proc)
893
+ end
894
+ end
895
+
896
+ def over_enter(_option)
897
+ @over_enter = @original_atome.instance_variable_get('@over_code')[:enter]
898
+ if @over_enter
899
+ @over_enter_callback = lambda do |event|
900
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
901
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
902
+ # group etc..
903
+ @over_enter.call(event) if @over_enter.is_a?(Proc)
904
+ end
905
+ @element.addEventListener('mouseenter', @over_enter_callback)
906
+ end
907
+ end
908
+
909
+ def over_leave(_option)
910
+ @over_leave = @original_atome.instance_variable_get('@over_code')[:leave]
911
+ if @over_leave
912
+ @over_leave_callback = lambda do |event|
913
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
914
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
915
+ # group etc..
916
+ @over_leave.call(event) if @over_leave.is_a?(Proc)
917
+ end
918
+ @element.addEventListener('mouseleave', @over_leave_callback)
919
+ end
920
+ end
921
+
922
+ def over_remove(option)
923
+ case option
924
+ when :enter
925
+ if @over_enter_callback
926
+ # Remove the event listener using the same lambda
927
+ @element.removeEventListener('mouseenter', @over_enter_callback)
928
+ @over_enter_callback = nil
929
+ @over_enter = nil
930
+ end
931
+ when :leave
932
+ @element.removeEventListener('mouseleave', @over_leave_callback)
933
+ @over_leave_callback = nil
934
+ @over_leave = nil
935
+ when :over
936
+ @over_over = ''
937
+ else
938
+ @element.removeEventListener('mouseenter', @over_enter_callback)
939
+ @over_enter_callback = nil
940
+ @over_enter = nil
941
+ @element.removeEventListener('mouseleave', @over_leave_callback)
942
+ @over_leave_callback = nil
943
+ @over_leave = nil
944
+ @over_over = ''
945
+ end
946
+ end
947
+
948
+ def touch_tap(_option)
949
+ interact = JS.eval("return interact('##{@id}')")
950
+ @touch_tap = @original_atome.instance_variable_get('@touch_code')[:tap]
951
+ interact.on('tap') do |native_event|
952
+ event = Native(native_event)
953
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
954
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
955
+ # group etc..
956
+ @touch_tap.call(event) if @touch_tap.is_a?(Proc)
957
+ end
958
+ end
959
+
960
+ def touch_double(_option)
961
+ interact = JS.eval("return interact('##{@id}')")
962
+ @touch_double = @original_atome.instance_variable_get('@touch_code')[:double]
963
+ interact.on('doubletap') do |native_event|
964
+ event = Native(native_event)
965
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
966
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
967
+ # group etc..
968
+ @touch_double.call(event) if @touch_double.is_a?(Proc)
969
+ end
970
+ end
971
+
972
+ def touch_long(_option)
973
+ @touch_long = @original_atome.instance_variable_get('@touch_code')[:long]
974
+ interact = JS.eval("return interact('##{@id}')")
975
+ interact.on('hold') do |native_event|
976
+ event = Native(native_event)
977
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
978
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
979
+ # group etc..
980
+ @touch_long.call(event) if @touch_long.is_a?(Proc)
981
+ end
982
+ end
983
+
984
+ def touch_down(_option)
985
+ @touch_down = @original_atome.instance_variable_get('@touch_code')[:down]
986
+ interact = JS.eval("return interact('##{@id}')")
987
+ interact.on('down') do |native_event|
988
+ event = Native(native_event)
989
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
990
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
991
+ # group etc..
992
+ @touch_down.call(event) if @touch_down.is_a?(Proc)
993
+ end
994
+ end
995
+
996
+ def touch_up(_option)
997
+ @touch_up = @original_atome.instance_variable_get('@touch_code')[:up]
998
+ interact = JS.eval("return interact('##{@id}')")
999
+ interact.on('up') do |native_event|
1000
+ event = Native(native_event)
1001
+ # we use .call instead of instance_eval because instance_eval bring the current object as context
1002
+ # and it's lead to a problem of context and force the use of grab(:view) when suing atome method such as shape ,
1003
+ # group etc..
1004
+ @touch_up.call(event) if @touch_up.is_a?(Proc)
1005
+ end
1006
+ end
1007
+
1008
+ def touch_remove(option)
1009
+ case option
1010
+ when :double
1011
+ @touch_double = ''
1012
+ when :down
1013
+ @touch_down = ''
1014
+ when :long
1015
+ @touch_long = ''
1016
+ when :tap
1017
+ @touch_tap = ''
1018
+ when :up
1019
+ @touch_up = ''
1020
+ else
1021
+ @touch_double = ''
1022
+ @touch_down = ''
1023
+ @touch_long = ''
1024
+ @touch_tap = ''
1025
+ @touch_up = ''
1026
+ # to remove all interact event ( touch, drag, scale, ... uncomment below)
1027
+ # interact = JS.eval("return interact('##{@id}')")
1028
+ # interact.unset
1029
+ end
1030
+
1031
+ end
1032
+
1033
+
1034
+ def internet
1035
+ JS.eval('return navigator.onLine')
1036
+ end
1037
+
1038
+ def terminal(id, cmd)
1039
+ if Atome.host == 'tauri'
1040
+ JS.eval("terminal('#{id}','#{cmd}')")
1041
+ else
1042
+ JS.eval("distant_terminal('#{id}','#{cmd}')")
1043
+ end
1044
+ end
1045
+
1046
+ def read(id, file)
1047
+ if Atome.host == 'tauri'
1048
+ JS.eval("readFile('#{id}','#{file}')")
1049
+ else
1050
+ puts " work in progress"
1051
+ end
1052
+ end
1053
+
1054
+ def browse(id, file)
1055
+ if Atome.host == 'tauri'
1056
+ JS.eval("browseFile('#{id}','#{file}')")
1057
+ else
1058
+ puts "work in progress"
1059
+ end
1060
+ end
1061
+
1062
+ def handle_input
1063
+ @original_atome.instance_variable_set("@data", @element[:innerText].to_s)
1064
+ end
1065
+
1066
+ # this method update the data content of the atome
1067
+ def update_data(params)
1068
+ # we update the @data of the atome
1069
+ @input_listener ||= lambda { |event| handle_input }
1070
+ if params
1071
+ @element.addEventListener('input', &@input_listener)
1072
+ else
1073
+ @element.removeEventListener('input', &@input_listener)
1074
+ end
1075
+ end
1076
+
1077
+ # animation below
1078
+ def animate(animation_properties)
1079
+ command = <<~JS
1080
+ var target_div = document.getElementById('#{@id}');
1081
+ window.currentAnimation = popmotion.animate({
1082
+ from: #{animation_properties[:from]},
1083
+ to: #{animation_properties[:to]},
1084
+ duration: #{animation_properties[:duration]},
1085
+ onUpdate: function(v) {
1086
+ rubyVMCallback("puts x= "+v)
1087
+ rubyVMCallback("grab('#{@id}').left("+v+")")
1088
+ },
1089
+ onComplete: function() {
1090
+ window.currentAnimation = null;
1091
+ rubyVMCallback("puts :complete")
1092
+ }
1093
+ });
1094
+ JS
1095
+ JS.eval(command)
1096
+ end
1097
+
1098
+ def play_animation(properties)
1099
+ alert 'change for standard method : action'
1100
+ required_keys = [:from, :to, :duration]
1101
+ if properties.is_a?(Hash) && (required_keys - properties.keys).empty?
1102
+ animate(properties)
1103
+ else
1104
+ raise ArgumentError, "Properties must be a hash with :from, :to, and :duration keys"
1105
+ end
1106
+ end
1107
+
1108
+ def stop_animation
1109
+ JS.eval("if (window.currentAnimation) window.currentAnimation.stop();")
1110
+ end
1111
+
1112
+ end