atome-opal-browser 0.3.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +33 -0
- data/Gemfile.lock +122 -0
- data/LICENSE +20 -0
- data/README.md +301 -0
- data/Rakefile +63 -0
- data/bin/rake +7 -0
- data/bin/setup +8 -0
- data/config.ru +81 -0
- data/docs/polyfills.md +24 -0
- data/examples/2048/Gemfile +13 -0
- data/examples/2048/Gemfile.lock +41 -0
- data/examples/2048/README.md +13 -0
- data/examples/2048/app/application.rb +169 -0
- data/examples/2048/config.ru +9 -0
- data/examples/canvas/Gemfile +9 -0
- data/examples/canvas/README.md +9 -0
- data/examples/canvas/app/application.rb +55 -0
- data/examples/canvas/config.ru +9 -0
- data/examples/component/Gemfile +9 -0
- data/examples/component/Gemfile.lock +45 -0
- data/examples/component/README.md +10 -0
- data/examples/component/app/application.rb +66 -0
- data/examples/component/config.ru +9 -0
- data/examples/integrations/README.md +24 -0
- data/examples/integrations/dynamic-rack-opal-sprockets-server/Gemfile +7 -0
- data/examples/integrations/dynamic-rack-opal-sprockets-server/README.md +16 -0
- data/examples/integrations/dynamic-rack-opal-sprockets-server/app/application.rb +6 -0
- data/examples/integrations/dynamic-rack-opal-sprockets-server/config.ru +9 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/.gitignore +1 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/Gemfile +8 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/README.md +22 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/Rakefile +4 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/app/application.rb +6 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/app.rb +32 -0
- data/examples/integrations/dynamic-roda-roda-sprockets/config.ru +3 -0
- data/examples/integrations/dynamic-roda-tilt/.gitignore +1 -0
- data/examples/integrations/dynamic-roda-tilt/Gemfile +9 -0
- data/examples/integrations/dynamic-roda-tilt/README.md +17 -0
- data/examples/integrations/dynamic-roda-tilt/Rakefile +6 -0
- data/examples/integrations/dynamic-roda-tilt/app/application.rb +6 -0
- data/examples/integrations/dynamic-roda-tilt/app.rb +50 -0
- data/examples/integrations/dynamic-roda-tilt/config.ru +3 -0
- data/examples/integrations/dynamic-sinatra-opal-sprockets-server/Gemfile +10 -0
- data/examples/integrations/dynamic-sinatra-opal-sprockets-server/README.md +16 -0
- data/examples/integrations/dynamic-sinatra-opal-sprockets-server/app/application.rb +6 -0
- data/examples/integrations/dynamic-sinatra-opal-sprockets-server/config.ru +29 -0
- data/examples/integrations/static-bash/.gitignore +2 -0
- data/examples/integrations/static-bash/Gemfile +3 -0
- data/examples/integrations/static-bash/README.md +8 -0
- data/examples/integrations/static-bash/app/application.rb +6 -0
- data/examples/integrations/static-bash/build.sh +4 -0
- data/examples/integrations/static-bash/index.html +10 -0
- data/examples/integrations/static-bash-opal-parser/.gitignore +3 -0
- data/examples/integrations/static-bash-opal-parser/Gemfile +3 -0
- data/examples/integrations/static-bash-opal-parser/README.md +10 -0
- data/examples/integrations/static-bash-opal-parser/build.sh +4 -0
- data/examples/integrations/static-bash-opal-parser/index.html +19 -0
- data/examples/integrations/static-rake/.gitignore +1 -0
- data/examples/integrations/static-rake/Gemfile +7 -0
- data/examples/integrations/static-rake/README.md +7 -0
- data/examples/integrations/static-rake/Rakefile +10 -0
- data/examples/integrations/static-rake/app/application.rb +6 -0
- data/examples/integrations/static-rake/index.html +9 -0
- data/examples/integrations/static-rake-guard/.gitignore +1 -0
- data/examples/integrations/static-rake-guard/Gemfile +9 -0
- data/examples/integrations/static-rake-guard/Gemfile.lock +69 -0
- data/examples/integrations/static-rake-guard/Guardfile +3 -0
- data/examples/integrations/static-rake-guard/README.md +10 -0
- data/examples/integrations/static-rake-guard/Rakefile +10 -0
- data/examples/integrations/static-rake-guard/app/application.rb +6 -0
- data/examples/integrations/static-rake-guard/index.html +9 -0
- data/examples/svg/.gitignore +1 -0
- data/examples/svg/Gemfile +4 -0
- data/examples/svg/README.md +7 -0
- data/examples/svg/Rakefile +10 -0
- data/examples/svg/app/application.rb +11 -0
- data/examples/svg/index.html +17 -0
- data/examples/svg/index.svg +6 -0
- data/index.html.erb +24 -0
- data/lib/opal/browser.rb +4 -0
- data/lib/opal-browser.rb +1 -0
- data/opal/browser/animation_frame.rb +111 -0
- data/opal/browser/audio/node.rb +121 -0
- data/opal/browser/audio/param_schedule.rb +43 -0
- data/opal/browser/audio.rb +66 -0
- data/opal/browser/blob.rb +94 -0
- data/opal/browser/canvas/data.rb +63 -0
- data/opal/browser/canvas/gradient.rb +27 -0
- data/opal/browser/canvas/style.rb +115 -0
- data/opal/browser/canvas/text.rb +45 -0
- data/opal/browser/canvas.rb +335 -0
- data/opal/browser/console.rb +105 -0
- data/opal/browser/cookies.rb +171 -0
- data/opal/browser/crypto.rb +79 -0
- data/opal/browser/css/declaration.rb +83 -0
- data/opal/browser/css/rule/style.rb +16 -0
- data/opal/browser/css/rule.rb +48 -0
- data/opal/browser/css/style_sheet.rb +83 -0
- data/opal/browser/css/unit.rb +188 -0
- data/opal/browser/css.rb +40 -0
- data/opal/browser/database/sql.rb +193 -0
- data/opal/browser/delay.rb +94 -0
- data/opal/browser/dom/attribute.rb +26 -0
- data/opal/browser/dom/builder.rb +107 -0
- data/opal/browser/dom/cdata.rb +9 -0
- data/opal/browser/dom/character_data.rb +73 -0
- data/opal/browser/dom/comment.rb +9 -0
- data/opal/browser/dom/document.rb +217 -0
- data/opal/browser/dom/document_fragment.rb +25 -0
- data/opal/browser/dom/document_or_shadow_root.rb +19 -0
- data/opal/browser/dom/element/attributes.rb +111 -0
- data/opal/browser/dom/element/button.rb +31 -0
- data/opal/browser/dom/element/custom.rb +177 -0
- data/opal/browser/dom/element/data.rb +82 -0
- data/opal/browser/dom/element/editable.rb +47 -0
- data/opal/browser/dom/element/form.rb +38 -0
- data/opal/browser/dom/element/iframe.rb +37 -0
- data/opal/browser/dom/element/image.rb +25 -0
- data/opal/browser/dom/element/input.rb +64 -0
- data/opal/browser/dom/element/media.rb +43 -0
- data/opal/browser/dom/element/offset.rb +89 -0
- data/opal/browser/dom/element/position.rb +46 -0
- data/opal/browser/dom/element/scroll.rb +168 -0
- data/opal/browser/dom/element/select.rb +42 -0
- data/opal/browser/dom/element/size.rb +46 -0
- data/opal/browser/dom/element/template.rb +11 -0
- data/opal/browser/dom/element/textarea.rb +26 -0
- data/opal/browser/dom/element.rb +618 -0
- data/opal/browser/dom/mutation_observer.rb +178 -0
- data/opal/browser/dom/node.rb +504 -0
- data/opal/browser/dom/node_set.rb +121 -0
- data/opal/browser/dom/shadow_root.rb +12 -0
- data/opal/browser/dom/text.rb +36 -0
- data/opal/browser/dom.rb +124 -0
- data/opal/browser/effects.rb +216 -0
- data/opal/browser/event/all.rb +26 -0
- data/opal/browser/event/animation.rb +40 -0
- data/opal/browser/event/audio_processing.rb +35 -0
- data/opal/browser/event/base.rb +461 -0
- data/opal/browser/event/before_unload.rb +17 -0
- data/opal/browser/event/clipboard.rb +37 -0
- data/opal/browser/event/close.rb +49 -0
- data/opal/browser/event/composition.rb +52 -0
- data/opal/browser/event/custom.rb +65 -0
- data/opal/browser/event/data_transfer.rb +95 -0
- data/opal/browser/event/device_light.rb +25 -0
- data/opal/browser/event/device_motion.rb +53 -0
- data/opal/browser/event/device_orientation.rb +50 -0
- data/opal/browser/event/device_proximity.rb +35 -0
- data/opal/browser/event/drag.rb +123 -0
- data/opal/browser/event/focus.rb +41 -0
- data/opal/browser/event/gamepad.rb +62 -0
- data/opal/browser/event/hash_change.rb +30 -0
- data/opal/browser/event/keyboard.rb +128 -0
- data/opal/browser/event/message.rb +72 -0
- data/opal/browser/event/mouse.rb +258 -0
- data/opal/browser/event/page_transition.rb +25 -0
- data/opal/browser/event/pop_state.rb +35 -0
- data/opal/browser/event/progress.rb +45 -0
- data/opal/browser/event/sensor.rb +17 -0
- data/opal/browser/event/storage.rb +45 -0
- data/opal/browser/event/touch.rb +62 -0
- data/opal/browser/event/ui.rb +38 -0
- data/opal/browser/event/wheel.rb +51 -0
- data/opal/browser/event.rb +162 -0
- data/opal/browser/event_source.rb +70 -0
- data/opal/browser/form_data.rb +225 -0
- data/opal/browser/history.rb +86 -0
- data/opal/browser/http/binary.rb +58 -0
- data/opal/browser/http/headers.rb +109 -0
- data/opal/browser/http/request.rb +359 -0
- data/opal/browser/http/response.rb +119 -0
- data/opal/browser/http.rb +167 -0
- data/opal/browser/immediate.rb +161 -0
- data/opal/browser/interval.rb +111 -0
- data/opal/browser/location.rb +93 -0
- data/opal/browser/navigator.rb +274 -0
- data/opal/browser/polyfill/visual_viewport.rb +216 -0
- data/opal/browser/screen.rb +66 -0
- data/opal/browser/setup/base.rb +6 -0
- data/opal/browser/setup/full.rb +13 -0
- data/opal/browser/setup/large.rb +17 -0
- data/opal/browser/setup/mini.rb +8 -0
- data/opal/browser/setup/traditional.rb +10 -0
- data/opal/browser/socket.rb +123 -0
- data/opal/browser/storage.rb +252 -0
- data/opal/browser/support.rb +299 -0
- data/opal/browser/utils.rb +154 -0
- data/opal/browser/version.rb +3 -0
- data/opal/browser/visual_viewport.rb +39 -0
- data/opal/browser/window/size.rb +73 -0
- data/opal/browser/window/view.rb +51 -0
- data/opal/browser/window.rb +133 -0
- data/opal/browser.rb +1 -0
- data/opal/opal-browser.rb +1 -0
- data/opal-browser.gemspec +27 -0
- data/spec/database/sql_spec.rb +139 -0
- data/spec/delay_spec.rb +41 -0
- data/spec/dom/attribute_spec.rb +49 -0
- data/spec/dom/builder_spec.rb +86 -0
- data/spec/dom/document_spec.rb +62 -0
- data/spec/dom/element/attributes_spec.rb +52 -0
- data/spec/dom/element/custom_spec.rb +106 -0
- data/spec/dom/element/subclass_spec.rb +144 -0
- data/spec/dom/element_spec.rb +223 -0
- data/spec/dom/mutation_observer_spec.rb +41 -0
- data/spec/dom/node_set_spec.rb +44 -0
- data/spec/dom/node_spec.rb +214 -0
- data/spec/dom_spec.rb +23 -0
- data/spec/event_source_spec.rb +45 -0
- data/spec/event_spec.rb +156 -0
- data/spec/history_spec.rb +61 -0
- data/spec/http_spec.rb +76 -0
- data/spec/immediate_spec.rb +15 -0
- data/spec/interval_spec.rb +59 -0
- data/spec/json2.js +486 -0
- data/spec/native_cached_wrapper_spec.rb +46 -0
- data/spec/runner.rb +107 -0
- data/spec/sizzle.js +5 -0
- data/spec/socket_spec.rb +47 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/spec_helper_promise.rb.erb +25 -0
- data/spec/storage_spec.rb +26 -0
- data/spec/wgxpath.install.js +49 -0
- data/spec/window_spec.rb +10 -0
- metadata +500 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9dbdd6e9d572cae1acb8b53fa2daaf4492bef554d84c2c0e989ad43d32bb34ba
|
|
4
|
+
data.tar.gz: b5bb70c2406c0143d4b1a5a2be3bba7151d707e20615965134a09b2a894b046c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8b75e9ed30ed18b07bad5356fb1df35dfcb63ee9ca16ccdb7011f740a01b3dec97e6893a1917c26fe48043385e3b3b680b2aa631073e9c814b1cca8e43fd4892
|
|
7
|
+
data.tar.gz: 84a211f8fc03ac41e5e9af2d9028b00b2ca8f6745f020983a1ac5d1114e63e3276f8ec53f792a1ba9e44affae18ab05599e29446a18042d61b901d8f719a7bc9
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## 0.3.3
|
|
2
|
+
* Compatibility fix for Opal 1.4
|
|
3
|
+
|
|
4
|
+
## 0.3.2
|
|
5
|
+
* Cookie: refactor the module
|
|
6
|
+
* Note in documentation it's available as `$document.cookies` and it's the preferred way to access it
|
|
7
|
+
* Always encode a cookie with JSON, unless a new parameter `raw:` is provided
|
|
8
|
+
|
|
9
|
+
## 0.3.1
|
|
10
|
+
* Element#inner_dom: Reduce flickering - first build tree, then insert it
|
|
11
|
+
* NodeSet#to_a to be aliased to #to_ary
|
data/Gemfile
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
gemspec
|
|
3
|
+
|
|
4
|
+
# specs
|
|
5
|
+
gem 'rake'
|
|
6
|
+
gem 'rack'
|
|
7
|
+
gem 'sinatra'
|
|
8
|
+
gem 'sinatra-websocket'
|
|
9
|
+
gem 'opal-rspec'
|
|
10
|
+
gem 'opal-sprockets'
|
|
11
|
+
# Force build of eventmachine... I wish we could find a way to not use
|
|
12
|
+
# this unmaintained library anymore.
|
|
13
|
+
gem 'eventmachine', github: 'eventmachine/eventmachine'
|
|
14
|
+
gem 'thin', github: 'macournoyer/thin' unless RUBY_PLATFORM =~ /mingw/
|
|
15
|
+
|
|
16
|
+
# runner
|
|
17
|
+
gem 'selenium-webdriver', require: false
|
|
18
|
+
gem 'rest-client', require: false
|
|
19
|
+
gem 'webdrivers', require: false
|
|
20
|
+
gem 'rexml', require: false
|
|
21
|
+
|
|
22
|
+
# browser
|
|
23
|
+
case ENV['OPAL_VERSION']
|
|
24
|
+
when nil
|
|
25
|
+
# noop
|
|
26
|
+
when ->(path) { File.exist? path }
|
|
27
|
+
gem 'opal', path: ENV['OPAL_VERSION']
|
|
28
|
+
when /\./
|
|
29
|
+
gem 'opal', "~> #{ENV['OPAL_VERSION']}.0a"
|
|
30
|
+
else
|
|
31
|
+
gem 'opal', github: 'opal/opal', ref: ENV['OPAL_VERSION']
|
|
32
|
+
end
|
|
33
|
+
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
GIT
|
|
2
|
+
remote: https://github.com/eventmachine/eventmachine.git
|
|
3
|
+
revision: df4ab0068e5e9f504096584093a74510d0dac6c8
|
|
4
|
+
specs:
|
|
5
|
+
eventmachine (1.3.0.dev.1)
|
|
6
|
+
|
|
7
|
+
GIT
|
|
8
|
+
remote: https://github.com/macournoyer/thin.git
|
|
9
|
+
revision: 10607a2663fc282d67f98a930f954dc407fd056d
|
|
10
|
+
specs:
|
|
11
|
+
thin (1.8.1)
|
|
12
|
+
daemons (~> 1.0, >= 1.0.9)
|
|
13
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
|
14
|
+
rack (>= 1, < 3)
|
|
15
|
+
|
|
16
|
+
PATH
|
|
17
|
+
remote: .
|
|
18
|
+
specs:
|
|
19
|
+
opal-browser (0.3.9.3)
|
|
20
|
+
opal (>= 1.0, < 2.0)
|
|
21
|
+
paggio (~> 0.3.0)
|
|
22
|
+
|
|
23
|
+
GEM
|
|
24
|
+
remote: https://rubygems.org/
|
|
25
|
+
specs:
|
|
26
|
+
addressable (2.8.1)
|
|
27
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
28
|
+
ast (2.4.2)
|
|
29
|
+
childprocess (4.1.0)
|
|
30
|
+
concurrent-ruby (1.1.10)
|
|
31
|
+
daemons (1.4.1)
|
|
32
|
+
domain_name (0.5.20190701)
|
|
33
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
34
|
+
em-websocket (0.3.8)
|
|
35
|
+
addressable (>= 2.1.1)
|
|
36
|
+
eventmachine (>= 0.12.9)
|
|
37
|
+
http-accept (1.7.0)
|
|
38
|
+
http-cookie (1.0.5)
|
|
39
|
+
domain_name (~> 0.5)
|
|
40
|
+
mime-types (3.4.1)
|
|
41
|
+
mime-types-data (~> 3.2015)
|
|
42
|
+
mime-types-data (3.2022.0105)
|
|
43
|
+
mustermann (3.0.0)
|
|
44
|
+
ruby2_keywords (~> 0.0.1)
|
|
45
|
+
netrc (0.11.0)
|
|
46
|
+
nokogiri (1.13.9-arm64-darwin)
|
|
47
|
+
racc (~> 1.4)
|
|
48
|
+
opal (1.5.1)
|
|
49
|
+
ast (>= 2.3.0)
|
|
50
|
+
parser (~> 3.0, >= 3.0.3.2)
|
|
51
|
+
opal-rspec (0.8.0)
|
|
52
|
+
opal (>= 1.0.0, < 2.0)
|
|
53
|
+
opal-sprockets (< 2.0)
|
|
54
|
+
rake (>= 12.0)
|
|
55
|
+
opal-sprockets (1.0.3)
|
|
56
|
+
opal (>= 1.0, < 2.0)
|
|
57
|
+
sprockets (~> 4.0)
|
|
58
|
+
tilt (>= 1.4)
|
|
59
|
+
paggio (0.3.0)
|
|
60
|
+
parser (3.1.2.1)
|
|
61
|
+
ast (~> 2.4.1)
|
|
62
|
+
public_suffix (5.0.0)
|
|
63
|
+
racc (1.6.0)
|
|
64
|
+
rack (2.2.4)
|
|
65
|
+
rack-protection (3.0.2)
|
|
66
|
+
rack
|
|
67
|
+
rake (13.0.6)
|
|
68
|
+
rest-client (2.1.0)
|
|
69
|
+
http-accept (>= 1.7.0, < 2.0)
|
|
70
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
71
|
+
mime-types (>= 1.16, < 4.0)
|
|
72
|
+
netrc (~> 0.8)
|
|
73
|
+
rexml (3.2.5)
|
|
74
|
+
ruby2_keywords (0.0.5)
|
|
75
|
+
rubyzip (2.3.2)
|
|
76
|
+
selenium-webdriver (4.5.0)
|
|
77
|
+
childprocess (>= 0.5, < 5.0)
|
|
78
|
+
rexml (~> 3.2, >= 3.2.5)
|
|
79
|
+
rubyzip (>= 1.2.2, < 3.0)
|
|
80
|
+
websocket (~> 1.0)
|
|
81
|
+
sinatra (3.0.2)
|
|
82
|
+
mustermann (~> 3.0)
|
|
83
|
+
rack (~> 2.2, >= 2.2.4)
|
|
84
|
+
rack-protection (= 3.0.2)
|
|
85
|
+
tilt (~> 2.0)
|
|
86
|
+
sinatra-websocket (0.3.1)
|
|
87
|
+
em-websocket (~> 0.3.6)
|
|
88
|
+
eventmachine
|
|
89
|
+
thin (>= 1.3.1, < 2.0.0)
|
|
90
|
+
sprockets (4.1.1)
|
|
91
|
+
concurrent-ruby (~> 1.0)
|
|
92
|
+
rack (> 1, < 3)
|
|
93
|
+
tilt (2.0.11)
|
|
94
|
+
unf (0.1.4)
|
|
95
|
+
unf_ext
|
|
96
|
+
unf_ext (0.0.8.2)
|
|
97
|
+
webdrivers (5.2.0)
|
|
98
|
+
nokogiri (~> 1.6)
|
|
99
|
+
rubyzip (>= 1.3.0)
|
|
100
|
+
selenium-webdriver (~> 4.0)
|
|
101
|
+
websocket (1.2.9)
|
|
102
|
+
|
|
103
|
+
PLATFORMS
|
|
104
|
+
arm64-darwin-22
|
|
105
|
+
|
|
106
|
+
DEPENDENCIES
|
|
107
|
+
eventmachine!
|
|
108
|
+
opal-browser!
|
|
109
|
+
opal-rspec
|
|
110
|
+
opal-sprockets
|
|
111
|
+
rack
|
|
112
|
+
rake
|
|
113
|
+
rest-client
|
|
114
|
+
rexml
|
|
115
|
+
selenium-webdriver
|
|
116
|
+
sinatra
|
|
117
|
+
sinatra-websocket
|
|
118
|
+
thin!
|
|
119
|
+
webdrivers
|
|
120
|
+
|
|
121
|
+
BUNDLED WITH
|
|
122
|
+
2.3.24
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (C) 2013-2018 by meh
|
|
2
|
+
Copyright (C) 2019-2021 hmdne and the Opal-Browser contributors
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
Opal-Browser - Client side web development in pure Ruby, using Opal
|
|
2
|
+
===================================================================
|
|
3
|
+
|
|
4
|
+
[](http://badge.fury.io/rb/opal-browser)
|
|
5
|
+
[](https://codeclimate.com/github/opal/opal-browser)
|
|
6
|
+
[](https://github.com/opal/opal-browser/actions?query=workflow%3Abuild)
|
|
7
|
+
[](https://slack.opalrb.com/)
|
|
8
|
+
[](https://stackoverflow.com/questions/ask?tags=opalrb,opal-browser)
|
|
9
|
+
[](https://rubydoc.info/gems/opal-browser)
|
|
10
|
+
|
|
11
|
+
This library aims to be a full-blown wrapper for all the browser API as defined by
|
|
12
|
+
HTML5.
|
|
13
|
+
|
|
14
|
+
It provides a very JQuery-like interface to DOM, but itself it doesn't use nor
|
|
15
|
+
require JQuery nor opal-jquery (which is an alternative library for interfacing
|
|
16
|
+
the web browser). The main difference though is that Opal-Browser goes far beyond
|
|
17
|
+
what JQuery does.
|
|
18
|
+
|
|
19
|
+
Usage
|
|
20
|
+
=====
|
|
21
|
+
|
|
22
|
+
_Gemfile_
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
source 'https://rubygems.org/'
|
|
26
|
+
|
|
27
|
+
gem 'opal-browser'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
_Server side (config.ru, Rakefile, Rails, Sinatra, Roda, etc. - not needed for static compilation)_
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
require 'opal-browser'
|
|
34
|
+
# Your server code here
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
_Browser side_
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
require 'opal'
|
|
41
|
+
require 'native'
|
|
42
|
+
require 'promise'
|
|
43
|
+
require 'browser/setup/full'
|
|
44
|
+
|
|
45
|
+
# Your Opal code here
|
|
46
|
+
$document.body << "Hello world!"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
_Static Compile Opal + Opal-Browser library_
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bundle exec opal -c -q opal-browser -p native -p promise -p browser/setup/full -e '#' -E > opal-browser.js
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
_Static Compile your application_
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bundle exec opal -Oc -s opal -s native -s promise -s browser/setup/full app/application.rb > application.js
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
_And load it in HTML!_
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<!DOCTYPE html>
|
|
65
|
+
<html>
|
|
66
|
+
<head>
|
|
67
|
+
<title>My Application</title>
|
|
68
|
+
</head>
|
|
69
|
+
<body>
|
|
70
|
+
<script src='opal-browser.js' onload='Opal.require("native"); Opal.require("promise"); Opal.require("browser/setup/full");'></script>
|
|
71
|
+
<script src='application.js'></script>
|
|
72
|
+
</body>
|
|
73
|
+
</html>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See the `examples/integrations/` directory for various ideas on how to quickly start
|
|
77
|
+
development using opal-browser.
|
|
78
|
+
|
|
79
|
+
Features
|
|
80
|
+
========
|
|
81
|
+
This is a list of many currently wrapped features and some details on them.
|
|
82
|
+
|
|
83
|
+
DOM
|
|
84
|
+
---
|
|
85
|
+
DOM support is complete as far as I know, it has a very Nokogiri feel to it
|
|
86
|
+
with obvious differences where relevant (for instance, event handling).
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
$document.ready do
|
|
90
|
+
alert "yo dawg, I'm all loaded up in here"
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
It also supports a markaby inspired builder DSL (using Paggio) which generates
|
|
95
|
+
DOM nodes directly instead of creating a string.
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
$document.ready do
|
|
99
|
+
DOM {
|
|
100
|
+
div.info {
|
|
101
|
+
span.red "I'm all cooked up."
|
|
102
|
+
}
|
|
103
|
+
}.append_to($document.body)
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Events
|
|
108
|
+
------
|
|
109
|
+
|
|
110
|
+
Add an event to a given element:
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
$document.at_css("button").on(:click) do |e|
|
|
114
|
+
e.prevent # Prevent the default action (eg. form submission)
|
|
115
|
+
# You can also use `e.stop` to stop propagating the event to other handlers.
|
|
116
|
+
alert "Button clicked!"
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or add it to a parent element and use a delegator, so that an event gets fired
|
|
121
|
+
when any button children of `$document` is clicked:
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
$document.on(:click, "button") do |e|
|
|
125
|
+
e.prevent
|
|
126
|
+
# e.on is a button that has been clicked
|
|
127
|
+
e.on.inner_text = "Clicked!"
|
|
128
|
+
end
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Run an event once with `#one` instead of `#on`, or disable an event with `#off`.
|
|
132
|
+
|
|
133
|
+
CSSOM
|
|
134
|
+
-----
|
|
135
|
+
CSSOM support (using Paggio) is still incomplete but the useful parts are
|
|
136
|
+
implemented, this includes a DSL for generating a CSS style and the same DSL
|
|
137
|
+
is also used to change style declarations (which can either belong to a
|
|
138
|
+
`DOM::Element` or a `CSS::Rule::Style`).
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
$document.body.style.apply {
|
|
142
|
+
background color: 'black'
|
|
143
|
+
color 'white'
|
|
144
|
+
font family: 'Verdana'
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
AJAX & SJAX
|
|
149
|
+
-----------
|
|
150
|
+
The `XMLHttpRequest` API has been wrapped completely, it also optionally
|
|
151
|
+
supports binary results as typed-arrays.
|
|
152
|
+
|
|
153
|
+
It easily allows for synchronous and asynchronous requests.
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
require 'browser/http'
|
|
157
|
+
|
|
158
|
+
Browser::HTTP.get "/something.json" do
|
|
159
|
+
on :success do |res|
|
|
160
|
+
alert res.json.inspect
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
WebSocket
|
|
166
|
+
---------
|
|
167
|
+
Websockets have been fully wrapped and they are easily configurable with
|
|
168
|
+
blocks.
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
require 'browser/socket'
|
|
172
|
+
|
|
173
|
+
Browser::Socket.new 'ws://echo.websocket.org' do
|
|
174
|
+
on :open do
|
|
175
|
+
every 1 do
|
|
176
|
+
puts "ping"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
on :message do |e|
|
|
181
|
+
log "Received #{e.data}"
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
EventSource
|
|
187
|
+
-----------
|
|
188
|
+
Event sources have been implemented and are easily configurable with blocks.
|
|
189
|
+
|
|
190
|
+
```ruby
|
|
191
|
+
require 'browser/event_source'
|
|
192
|
+
|
|
193
|
+
Browser::EventSource.new '/events' do |es|
|
|
194
|
+
es.on :message do |e|
|
|
195
|
+
alert e.data
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
es.on :custom do |e|
|
|
199
|
+
alert "custom #{e.data}"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
History
|
|
205
|
+
-------
|
|
206
|
+
The HTML5 History API has been fully wrapped.
|
|
207
|
+
|
|
208
|
+
```ruby
|
|
209
|
+
current = $window.history.current
|
|
210
|
+
$window.history.replace("?get=params")
|
|
211
|
+
$window.history.push("?get=params")
|
|
212
|
+
$window.history.back
|
|
213
|
+
|
|
214
|
+
$window.on :popstate do |e|
|
|
215
|
+
p "User clicked a back button! He is now on #{$window.history.current}"
|
|
216
|
+
end
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Storage
|
|
220
|
+
-------
|
|
221
|
+
The HTML5 Storage API has been wrapped and it exports a single Storage class
|
|
222
|
+
that uses the most appropriate and available API to store data locally.
|
|
223
|
+
|
|
224
|
+
```ruby
|
|
225
|
+
require 'browser/storage'
|
|
226
|
+
|
|
227
|
+
$storage = $window.storage
|
|
228
|
+
$storage[:hello] = "world"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Database SQL
|
|
232
|
+
------------
|
|
233
|
+
WebSQL has been fully wrapped (Chromium-only)
|
|
234
|
+
|
|
235
|
+
```ruby
|
|
236
|
+
require 'browser/database/sql'
|
|
237
|
+
|
|
238
|
+
db = Browser::Database::SQL.new 'test'
|
|
239
|
+
db.transaction {|t|
|
|
240
|
+
t.query('CREATE TABLE test(ID INTEGER PRIMARY KEY ASC, text TEXT)').then {
|
|
241
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 1, 'huehue')
|
|
242
|
+
}.then {
|
|
243
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 2, 'jajaja')
|
|
244
|
+
}.then {
|
|
245
|
+
t.query('SELECT * FROM test')
|
|
246
|
+
}.then {|r|
|
|
247
|
+
r.each {|row|
|
|
248
|
+
alert row.inspect
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Browser support
|
|
255
|
+
===============
|
|
256
|
+
|
|
257
|
+
* Edge (Current - 3) to Current
|
|
258
|
+
* Firefox (Current - 3) to Current
|
|
259
|
+
* Chrome (Current - 3) to Current
|
|
260
|
+
* Safari (Current - 3) to Current
|
|
261
|
+
* Opera (Current - 3) to Current
|
|
262
|
+
|
|
263
|
+
Any problem above browsers should be considered and reported as a bug.
|
|
264
|
+
|
|
265
|
+
(Current - 3) to Current denotes that we support the current major stable version
|
|
266
|
+
of the browser and 3 versions preceding it. For example, if the current version
|
|
267
|
+
of a browser is 24.x, we support all versions between 21.x to 24.x.
|
|
268
|
+
|
|
269
|
+
We will accept compatibility patches for even earlier browser versions. Opal-Browser
|
|
270
|
+
is written in such a way, that it integrates a robust compatibility check system,
|
|
271
|
+
similar to Modernizr, and the history of this library goes even as far as supporting
|
|
272
|
+
Internet Explorer 6.
|
|
273
|
+
|
|
274
|
+
See the [polyfills documentation](docs/polyfills.md) if you wish to polyfill some
|
|
275
|
+
behaviors not supported by the ancient web browsers (like `querySelectorAll`).
|
|
276
|
+
|
|
277
|
+
License
|
|
278
|
+
=======
|
|
279
|
+
|
|
280
|
+
(The MIT License)
|
|
281
|
+
|
|
282
|
+
Copyright (C) 2013-2018 by meh<br>
|
|
283
|
+
Copyright (C) 2019-2021 hmdne and the Opal-Browser contributors
|
|
284
|
+
|
|
285
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
286
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
287
|
+
in the Software without restriction, including without limitation the rights
|
|
288
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
289
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
290
|
+
furnished to do so, subject to the following conditions:
|
|
291
|
+
|
|
292
|
+
The above copyright notice and this permission notice shall be included in
|
|
293
|
+
all copies or substantial portions of the Software.
|
|
294
|
+
|
|
295
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
296
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
297
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
298
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
299
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
300
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
301
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler.require
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
|
|
5
|
+
require 'webdrivers'
|
|
6
|
+
load 'webdrivers/Rakefile'
|
|
7
|
+
|
|
8
|
+
require 'opal/rspec/rake_task'
|
|
9
|
+
Opal::RSpec::RakeTask.new(:broken_rspec) do |_, task|
|
|
10
|
+
task.default_path = 'spec'
|
|
11
|
+
task.pattern = 'spec/**/*_spec.{rb,opal}'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
task(:nil) {}
|
|
15
|
+
|
|
16
|
+
%w[chrome edge gecko safari].each do |i|
|
|
17
|
+
dependency = nil
|
|
18
|
+
if %w[chrome edge gecko].include? i
|
|
19
|
+
dependency = "webdrivers:#{i}driver:update"
|
|
20
|
+
end
|
|
21
|
+
desc "Run Selenium tests with #{i}"
|
|
22
|
+
task :"selenium_#{i}" => dependency do
|
|
23
|
+
server = Process.spawn("bundle", "exec", "rackup")
|
|
24
|
+
at_exit { Process.kill(9, server) rescue nil }
|
|
25
|
+
sleep 2
|
|
26
|
+
ENV['BROWSER'] = i
|
|
27
|
+
load 'spec/runner.rb'
|
|
28
|
+
ensure
|
|
29
|
+
Process.kill(9, server) rescue nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
task :default => :selenium_chrome
|
|
34
|
+
|
|
35
|
+
task :build_gh_pages do
|
|
36
|
+
require 'fileutils'
|
|
37
|
+
|
|
38
|
+
output_dir = __dir__+"/gh-pages/examples/"
|
|
39
|
+
FileUtils.mkdir_p output_dir
|
|
40
|
+
|
|
41
|
+
Dir['examples/*'].reject { |i| i =~ /integrations|svg/ }.each do |example_path|
|
|
42
|
+
example = File.basename(example_path)
|
|
43
|
+
|
|
44
|
+
output_example_dir = output_dir+"/"+example
|
|
45
|
+
FileUtils.mkdir_p output_example_dir
|
|
46
|
+
|
|
47
|
+
Dir.chdir(example_path) do
|
|
48
|
+
Bundler.with_unbundled_env do
|
|
49
|
+
`bundle install`
|
|
50
|
+
`bundle exec opal -qopal-browser -c app/application.rb > #{output_example_dir}/app.js`
|
|
51
|
+
end
|
|
52
|
+
File.write("#{output_example_dir}/index.html", <<~HTML)
|
|
53
|
+
<!DOCTYPE html>
|
|
54
|
+
<html>
|
|
55
|
+
<head></head>
|
|
56
|
+
<body>
|
|
57
|
+
<script src="app.js"></script>
|
|
58
|
+
</body>
|
|
59
|
+
</html>
|
|
60
|
+
HTML
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/bin/rake
ADDED
data/bin/setup
ADDED
data/config.ru
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler.require
|
|
3
|
+
|
|
4
|
+
apps = []
|
|
5
|
+
|
|
6
|
+
sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern = 'spec/**/*_spec.{rb,opal}',
|
|
7
|
+
spec_exclude_pattern = nil,
|
|
8
|
+
spec_files = nil,
|
|
9
|
+
default_path = 'spec')
|
|
10
|
+
|
|
11
|
+
apps << Opal::Sprockets::Server.new(sprockets: sprockets_env) { |s|
|
|
12
|
+
s.main = 'opal/rspec/sprockets_runner'
|
|
13
|
+
s.append_path 'spec'
|
|
14
|
+
s.index_path = 'index.html.erb'
|
|
15
|
+
s.debug = true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apps << Class.new(Sinatra::Base) {
|
|
19
|
+
get '/http' do
|
|
20
|
+
"lol"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
post '/http' do
|
|
24
|
+
if params['lol'] == 'wut'
|
|
25
|
+
"ok"
|
|
26
|
+
else
|
|
27
|
+
"fail"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
put '/http' do
|
|
32
|
+
if params['lol'] == 'wut'
|
|
33
|
+
"ok"
|
|
34
|
+
else
|
|
35
|
+
"fail"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
delete '/http' do
|
|
40
|
+
"lol"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
post '/http-file' do
|
|
44
|
+
if params['lol'] == 'wut' &&
|
|
45
|
+
params['file'][:filename] == 'yay.txt' &&
|
|
46
|
+
params['file'][:tempfile].read == 'content'
|
|
47
|
+
|
|
48
|
+
"ok"
|
|
49
|
+
else
|
|
50
|
+
"fail"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
get '/events' do
|
|
55
|
+
headers 'Content-Type' => 'text/event-stream'
|
|
56
|
+
|
|
57
|
+
stream do |out|
|
|
58
|
+
sleep 0.2
|
|
59
|
+
|
|
60
|
+
out << "data: lol\n" << "\n"
|
|
61
|
+
out << "event: custom\n" << "data: omg\n" << "\n"
|
|
62
|
+
out << "data: wut\n" << "\n"
|
|
63
|
+
|
|
64
|
+
sleep 10
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
get '/socket' do
|
|
69
|
+
request.websocket do |ws|
|
|
70
|
+
ws.onopen do
|
|
71
|
+
ws.send 'lol'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
ws.onmessage do |msg|
|
|
75
|
+
ws.send msg
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
run Rack::Cascade.new(apps)
|
data/docs/polyfills.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
CSS selectors
|
|
2
|
+
-------------
|
|
3
|
+
Older browsers do not support CSS selector in queries, this means you'll need
|
|
4
|
+
external polyfills for this.
|
|
5
|
+
|
|
6
|
+
The suggested polyfill is [Sizzle](http://sizzlejs.com/), require it **before**
|
|
7
|
+
opal-browser.
|
|
8
|
+
|
|
9
|
+
JSON parsing
|
|
10
|
+
------------
|
|
11
|
+
Older browsers don't support JSON parsing natively, this means you'll need
|
|
12
|
+
external polyfills for this.
|
|
13
|
+
|
|
14
|
+
The suggested polyfill is [json2](https://github.com/douglascrockford/JSON-js),
|
|
15
|
+
require it **before** opal-browser.
|
|
16
|
+
|
|
17
|
+
XPath support
|
|
18
|
+
-------------
|
|
19
|
+
Not all browsers support XPath queries, I'm looking at you Internet Explorer,
|
|
20
|
+
this means you'll need external polyfills for this.
|
|
21
|
+
|
|
22
|
+
The suggested polyfill is
|
|
23
|
+
[wgxpath](https://code.google.com/p/wicked-good-xpath/), require it **before**
|
|
24
|
+
opal-browser.
|