opal-browser 0.1.0.beta1 → 0.3.1
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 +5 -5
- data/.github/workflows/build.yml +95 -0
- data/.gitignore +3 -0
- data/.yardopts +1 -1
- data/Gemfile +22 -3
- data/LICENSE +20 -0
- data/README.md +200 -20
- data/Rakefile +29 -1
- data/config.ru +20 -2
- data/docs/polyfills.md +24 -0
- data/examples/2048/Gemfile +6 -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 +6 -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 +6 -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 +6 -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 +7 -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 +8 -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 +7 -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 +4 -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 +6 -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 +1 -0
- data/opal/browser/animation_frame.rb +92 -10
- 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 +2 -12
- data/opal/browser/canvas/gradient.rb +1 -11
- data/opal/browser/canvas/style.rb +3 -11
- data/opal/browser/canvas/text.rb +1 -11
- data/opal/browser/canvas.rb +86 -28
- data/opal/browser/console.rb +6 -38
- data/opal/browser/cookies.rb +90 -27
- data/opal/browser/crypto.rb +79 -0
- data/opal/browser/css/declaration.rb +1 -6
- data/opal/browser/css/rule.rb +1 -1
- data/opal/browser/css/style_sheet.rb +2 -2
- data/opal/browser/css.rb +23 -7
- data/opal/browser/database/sql.rb +193 -0
- data/opal/browser/delay.rb +94 -0
- data/opal/browser/dom/attribute.rb +16 -9
- data/opal/browser/dom/builder.rb +35 -25
- data/opal/browser/dom/character_data.rb +43 -7
- data/opal/browser/dom/document.rb +171 -37
- data/opal/browser/dom/document_fragment.rb +18 -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 +48 -1
- data/opal/browser/dom/element/media.rb +17 -0
- data/opal/browser/dom/element/offset.rb +32 -10
- data/opal/browser/dom/element/position.rb +11 -2
- data/opal/browser/dom/element/scroll.rb +139 -20
- 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 +496 -168
- data/opal/browser/dom/mutation_observer.rb +69 -9
- data/opal/browser/dom/node.rb +270 -83
- data/opal/browser/dom/node_set.rb +74 -41
- data/opal/browser/dom/shadow_root.rb +12 -0
- data/opal/browser/dom/text.rb +18 -3
- data/opal/browser/dom.rb +40 -18
- data/opal/browser/effects.rb +180 -3
- data/opal/browser/event/all.rb +26 -0
- data/opal/browser/event/animation.rb +40 -0
- data/opal/browser/{dom/event → event}/audio_processing.rb +10 -6
- 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/{dom/event → event}/device_motion.rb +21 -6
- data/opal/browser/event/device_orientation.rb +50 -0
- data/opal/browser/{dom/event → event}/device_proximity.rb +10 -6
- 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/{dom/event → event}/hash_change.rb +10 -6
- data/opal/browser/event/keyboard.rb +128 -0
- data/opal/browser/event/message.rb +72 -0
- data/opal/browser/{dom/event → event}/mouse.rb +37 -32
- 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/{dom/event → event}/storage.rb +10 -6
- data/opal/browser/{dom/event → event}/touch.rb +14 -21
- data/opal/browser/event/ui.rb +38 -0
- data/opal/browser/{dom/event → event}/wheel.rb +6 -4
- data/opal/browser/event.rb +163 -0
- data/opal/browser/event_source.rb +7 -4
- data/opal/browser/form_data.rb +225 -0
- data/opal/browser/history.rb +53 -21
- data/opal/browser/http/binary.rb +1 -0
- data/opal/browser/http/headers.rb +21 -2
- data/opal/browser/http/request.rb +83 -55
- data/opal/browser/http/response.rb +5 -1
- data/opal/browser/http.rb +47 -9
- data/opal/browser/immediate.rb +128 -10
- data/opal/browser/interval.rb +41 -23
- data/opal/browser/location.rb +20 -4
- data/opal/browser/navigator.rb +136 -13
- data/opal/browser/polyfill/visual_viewport.rb +216 -0
- data/opal/browser/screen.rb +34 -8
- 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 +16 -8
- data/opal/browser/storage.rb +155 -52
- data/opal/browser/support.rb +299 -0
- data/opal/browser/utils.rb +116 -18
- data/opal/browser/version.rb +1 -1
- data/opal/browser/visual_viewport.rb +39 -0
- data/opal/browser/window/size.rb +47 -9
- data/opal/browser/window/view.rb +37 -4
- data/opal/browser/window.rb +46 -26
- data/opal/browser.rb +1 -10
- data/opal/opal-browser.rb +1 -0
- data/opal-browser.gemspec +10 -12
- 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 +36 -19
- data/spec/dom/document_spec.rb +28 -6
- 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 +184 -7
- data/spec/dom/mutation_observer_spec.rb +13 -9
- data/spec/dom/node_set_spec.rb +44 -0
- data/spec/dom/node_spec.rb +87 -27
- data/spec/dom_spec.rb +19 -9
- data/spec/event_source_spec.rb +18 -15
- data/spec/{dom/event_spec.rb → event_spec.rb} +55 -26
- data/spec/history_spec.rb +32 -19
- data/spec/http_spec.rb +25 -36
- data/spec/immediate_spec.rb +10 -7
- data/spec/interval_spec.rb +59 -0
- data/spec/native_cached_wrapper_spec.rb +46 -0
- data/spec/runner.rb +107 -0
- data/spec/socket_spec.rb +18 -14
- data/spec/spec_helper.rb +2 -4
- data/spec/spec_helper_promise.rb.erb +25 -0
- data/spec/storage_spec.rb +7 -7
- data/spec/wgxpath.install.js +49 -0
- data/spec/window_spec.rb +2 -2
- metadata +181 -93
- data/opal/browser/compatibility/animation_frame.rb +0 -93
- data/opal/browser/compatibility/dom/document/window.rb +0 -15
- data/opal/browser/compatibility/dom/element/css.rb +0 -15
- data/opal/browser/compatibility/dom/element/matches.rb +0 -31
- data/opal/browser/compatibility/dom/element/offset.rb +0 -20
- data/opal/browser/compatibility/dom/element/scroll.rb +0 -25
- data/opal/browser/compatibility/dom/element/style.rb +0 -15
- data/opal/browser/compatibility/dom/mutation_observer.rb +0 -47
- data/opal/browser/compatibility/http/request.rb +0 -15
- data/opal/browser/compatibility/immediate.rb +0 -107
- data/opal/browser/compatibility/window/scroll.rb +0 -27
- data/opal/browser/compatibility/window/size.rb +0 -13
- data/opal/browser/compatibility/window/view.rb +0 -13
- data/opal/browser/compatibility.rb +0 -59
- data/opal/browser/dom/compatibility.rb +0 -8
- data/opal/browser/dom/event/animation.rb +0 -26
- data/opal/browser/dom/event/base.rb +0 -207
- data/opal/browser/dom/event/before_unload.rb +0 -13
- data/opal/browser/dom/event/clipboard.rb +0 -26
- data/opal/browser/dom/event/close.rb +0 -35
- data/opal/browser/dom/event/composition.rb +0 -38
- data/opal/browser/dom/event/custom.rb +0 -30
- data/opal/browser/dom/event/device_light.rb +0 -21
- data/opal/browser/dom/event/device_orientation.rb +0 -36
- data/opal/browser/dom/event/drag.rb +0 -113
- data/opal/browser/dom/event/focus.rb +0 -23
- data/opal/browser/dom/event/gamepad.rb +0 -47
- data/opal/browser/dom/event/keyboard.rb +0 -93
- data/opal/browser/dom/event/message.rb +0 -50
- data/opal/browser/dom/event/page_transition.rb +0 -21
- data/opal/browser/dom/event/pop_state.rb +0 -21
- data/opal/browser/dom/event/progress.rb +0 -31
- data/opal/browser/dom/event/sensor.rb +0 -13
- data/opal/browser/dom/event/ui.rb +0 -22
- data/opal/browser/dom/event.rb +0 -240
- data/opal/browser/http/compatibility.rb +0 -1
- data/opal/browser/http/parameters.rb +0 -8
- data/opal/browser/timeout.rb +0 -60
- data/opal/browser/window/compatibility.rb +0 -3
- data/opal/browser/window/scroll.rb +0 -49
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0a728e0d53d58c89018baa0d46dbc4731da85966b7fb5b7b312f4bb24d9dc23f
|
|
4
|
+
data.tar.gz: 7219cd2463a99d60f4f39b19045ab3ebf22b254a62f82c4684bd3023ad7548e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a04d4225b59e9e3d244bfa748d931bc3954946c9de3e6f4623115494e00e54a8a5c3e90bf7fe679b71d1ebc74b7318c18f422014775059ca457bcd1cf872f250
|
|
7
|
+
data.tar.gz: 194e860d12c4e737593bc1888cff156fccfc94d13b20faf8ec26b12ed9a1d26d43ad960b21fb88a6605a5b8c20b8b2d4c239dec4a52013b87d1ab7ec9649c372
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
- "*-stable"
|
|
8
|
+
- "*/ci-check"
|
|
9
|
+
pull_request: {}
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
rake:
|
|
13
|
+
name: ${{ matrix.combo.name }}
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
combo:
|
|
18
|
+
- name: Chromium/Linux/Opal-master
|
|
19
|
+
browser: chrome
|
|
20
|
+
os: ubuntu-latest
|
|
21
|
+
opal: master
|
|
22
|
+
- name: Chromium/Linux/Opal-1.3/PromiseV2
|
|
23
|
+
browser: chrome
|
|
24
|
+
os: ubuntu-latest
|
|
25
|
+
opal: 1.3
|
|
26
|
+
promise: v2
|
|
27
|
+
- name: Chromium/Linux/Opal-1.3
|
|
28
|
+
browser: chrome
|
|
29
|
+
os: ubuntu-latest
|
|
30
|
+
opal: 1.3
|
|
31
|
+
- name: Chromium/Linux/Opal-1.2
|
|
32
|
+
browser: chrome
|
|
33
|
+
os: ubuntu-latest
|
|
34
|
+
opal: 1.2
|
|
35
|
+
- name: Chromium/Linux/Opal-1.0
|
|
36
|
+
browser: chrome
|
|
37
|
+
os: ubuntu-latest
|
|
38
|
+
opal: '1.0'
|
|
39
|
+
- name: Chromium/Linux/Ruby-2.7
|
|
40
|
+
browser: chrome
|
|
41
|
+
os: ubuntu-latest
|
|
42
|
+
ruby: 2.7
|
|
43
|
+
- name: Chromium/Linux/Ruby-2.6
|
|
44
|
+
browser: chrome
|
|
45
|
+
os: ubuntu-latest
|
|
46
|
+
ruby: 2.6
|
|
47
|
+
- name: Firefox/Linux
|
|
48
|
+
browser: gecko
|
|
49
|
+
os: ubuntu-latest
|
|
50
|
+
- name: Chromium/Windows
|
|
51
|
+
browser: chrome
|
|
52
|
+
os: windows-latest
|
|
53
|
+
- name: Firefox/Windows
|
|
54
|
+
browser: gecko
|
|
55
|
+
os: windows-latest
|
|
56
|
+
- name: Edge/Windows
|
|
57
|
+
browser: edge
|
|
58
|
+
os: windows-latest
|
|
59
|
+
- name: Chromium/macOS
|
|
60
|
+
browser: chrome
|
|
61
|
+
os: macos-latest
|
|
62
|
+
- name: Firefox/macOS
|
|
63
|
+
browser: gecko
|
|
64
|
+
os: macos-latest
|
|
65
|
+
- name: Safari/macOS
|
|
66
|
+
browser: safari
|
|
67
|
+
os: macos-latest
|
|
68
|
+
|
|
69
|
+
runs-on: ${{ matrix.combo.os }}
|
|
70
|
+
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v2
|
|
73
|
+
- name: set environment variables
|
|
74
|
+
run: |
|
|
75
|
+
echo "OPAL_VERSION=${{ matrix.combo.opal || '1.3' }}" >> $GITHUB_ENV
|
|
76
|
+
echo "OPAL_BROWSER_PROMISE=${{ matrix.combo.promise || 'v1' }}" >> $GITHUB_ENV
|
|
77
|
+
- uses: ruby/setup-ruby@v1
|
|
78
|
+
with:
|
|
79
|
+
ruby-version: ${{ matrix.combo.ruby || '3.0' }}
|
|
80
|
+
- run: bundle lock
|
|
81
|
+
- uses: actions/cache@v2
|
|
82
|
+
with:
|
|
83
|
+
path: ./vendor/bundle
|
|
84
|
+
key: ${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-${{ github.ref }}-${{ hashFiles('**/Gemfile.lock') }}
|
|
85
|
+
restore-keys: |
|
|
86
|
+
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-${{ github.ref }}
|
|
87
|
+
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-master
|
|
88
|
+
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-
|
|
89
|
+
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-
|
|
90
|
+
- name: bundle install
|
|
91
|
+
run: |
|
|
92
|
+
bundle config path $PWD/vendor/bundle
|
|
93
|
+
bundle install --jobs 4 --retry 3
|
|
94
|
+
bundle clean
|
|
95
|
+
- run: bundle exec rake selenium_${{ matrix.combo.browser }}
|
data/.gitignore
CHANGED
data/.yardopts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
--no-private opal/**/*.rb
|
|
1
|
+
--no-private opal/**/*.rb --markup markdown
|
data/Gemfile
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
|
+
# specs
|
|
4
5
|
gem 'rake'
|
|
5
6
|
gem 'rack'
|
|
6
7
|
gem 'sinatra'
|
|
7
8
|
gem 'sinatra-websocket'
|
|
9
|
+
# For opal-rspec, a release is needed
|
|
10
|
+
gem 'opal-rspec', github: 'hmdne/opal-rspec', branch: 'opal-1.3', submodules: true # '>= 0.8.0.alpha1'
|
|
11
|
+
gem 'opal-sprockets'
|
|
12
|
+
# Force build of eventmachine on Windows
|
|
13
|
+
gem 'eventmachine', github: 'eventmachine/eventmachine' if RUBY_PLATFORM =~ /mingw/
|
|
14
|
+
|
|
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
|
+
when /\./
|
|
26
|
+
gem 'opal', "~> #{ENV['OPAL_VERSION']}.0a"
|
|
27
|
+
else
|
|
28
|
+
gem 'opal', github: 'opal/opal', ref: ENV['OPAL_VERSION']
|
|
29
|
+
end
|
|
8
30
|
|
|
9
|
-
gem 'opal', github: 'opal/opal'
|
|
10
|
-
gem 'opal-rspec', '0.3.0.beta2'
|
|
11
|
-
gem 'paggio', github: 'meh/paggio'
|
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
CHANGED
|
@@ -1,11 +1,81 @@
|
|
|
1
|
-
Browser
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
|
|
8
|
+
This library aims to be a full-blown wrapper for all the browser API as defined by
|
|
4
9
|
HTML5.
|
|
5
10
|
|
|
11
|
+
It provides a very JQuery-like interface to DOM, but itself it doesn't use nor
|
|
12
|
+
require JQuery nor opal-jquery (which is an alternative library for interfacing
|
|
13
|
+
the web browser). The main difference though is that Opal-Browser goes far beyond
|
|
14
|
+
what JQuery does.
|
|
15
|
+
|
|
16
|
+
Usage
|
|
17
|
+
=====
|
|
18
|
+
|
|
19
|
+
_Gemfile_
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
source 'https://rubygems.org/'
|
|
23
|
+
|
|
24
|
+
gem 'opal-browser'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
_Server side (config.ru, Rakefile, Rails, Sinatra, Roda, etc. - not needed for static compilation)_
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require 'opal-browser'
|
|
31
|
+
# Your server code here
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
_Browser side_
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require 'opal'
|
|
38
|
+
require 'native'
|
|
39
|
+
require 'promise'
|
|
40
|
+
require 'browser/setup/full'
|
|
41
|
+
|
|
42
|
+
# Your Opal code here
|
|
43
|
+
$document.body << "Hello world!"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
_Static Compile Opal + Opal-Browser library_
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bundle exec opal -c -q opal-browser -p native -p promise -p browser/setup/full -e '#' -E > opal-browser.js
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
_Static Compile your application_
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
bundle exec opal -Oc -s opal -s native -s promise -s browser/setup/full app/application.rb > application.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
_And load it in HTML!_
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<!DOCTYPE html>
|
|
62
|
+
<html>
|
|
63
|
+
<head>
|
|
64
|
+
<title>My Application</title>
|
|
65
|
+
</head>
|
|
66
|
+
<body>
|
|
67
|
+
<script src='opal-browser.js' onload='Opal.require("native"); Opal.require("promise"); Opal.require("browser/setup/full");'></script>
|
|
68
|
+
<script src='application.js'></script>
|
|
69
|
+
</body>
|
|
70
|
+
</html>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See the examples/integrations/ directory for various ideas on how to quickly start
|
|
74
|
+
development using opal-browser.
|
|
75
|
+
|
|
6
76
|
Features
|
|
7
77
|
========
|
|
8
|
-
This is a list of
|
|
78
|
+
This is a list of many currently wrapped features and some details on them.
|
|
9
79
|
|
|
10
80
|
DOM
|
|
11
81
|
---
|
|
@@ -13,16 +83,16 @@ DOM support is complete as far as I know, it has a very Nokogiri feel to it
|
|
|
13
83
|
with obvious differences where relevant (for instance, event handling).
|
|
14
84
|
|
|
15
85
|
```ruby
|
|
16
|
-
$document.
|
|
86
|
+
$document.ready do
|
|
17
87
|
alert "yo dawg, I'm all loaded up in here"
|
|
18
88
|
end
|
|
19
89
|
```
|
|
20
90
|
|
|
21
|
-
It also supports a markaby inspired builder DSL which generates
|
|
22
|
-
directly instead of creating a string.
|
|
91
|
+
It also supports a markaby inspired builder DSL (using Paggio) which generates
|
|
92
|
+
DOM nodes directly instead of creating a string.
|
|
23
93
|
|
|
24
94
|
```ruby
|
|
25
|
-
$document.
|
|
95
|
+
$document.ready do
|
|
26
96
|
DOM {
|
|
27
97
|
div.info {
|
|
28
98
|
span.red "I'm all cooked up."
|
|
@@ -31,12 +101,37 @@ $document.on :load do
|
|
|
31
101
|
end
|
|
32
102
|
```
|
|
33
103
|
|
|
104
|
+
Events
|
|
105
|
+
------
|
|
106
|
+
|
|
107
|
+
Add an event to a given element:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
$document.at_css("button").on(:click) do |e|
|
|
111
|
+
e.prevent # Prevent the default action (eg. form submission)
|
|
112
|
+
alert "Button clicked!"
|
|
113
|
+
end
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Or add it to a parent element and use a delegator, so that an event gets fired
|
|
117
|
+
when any button children of `$document` is clicked:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
$document.on(:click, "button") do |e|
|
|
121
|
+
e.prevent
|
|
122
|
+
# e.on is a button that has been clicked
|
|
123
|
+
e.on.inner_text = "Clicked!"
|
|
124
|
+
end
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Run an event once with `#one` instead of `#on`, or disable an event with `#off`.
|
|
128
|
+
|
|
34
129
|
CSSOM
|
|
35
130
|
-----
|
|
36
|
-
CSSOM support is still incomplete but the useful parts are
|
|
37
|
-
includes a DSL for generating a CSS style and the same DSL
|
|
38
|
-
change style declarations (which can either belong to a
|
|
39
|
-
`CSS::Rule::Style`).
|
|
131
|
+
CSSOM support (using Paggio) is still incomplete but the useful parts are
|
|
132
|
+
implemented, this includes a DSL for generating a CSS style and the same DSL
|
|
133
|
+
is also used to change style declarations (which can either belong to a
|
|
134
|
+
`DOM::Element` or a `CSS::Rule::Style`).
|
|
40
135
|
|
|
41
136
|
```ruby
|
|
42
137
|
$document.body.style.apply {
|
|
@@ -54,6 +149,8 @@ supports binary results as typed-arrays.
|
|
|
54
149
|
It easily allows for synchronous and asynchronous requests.
|
|
55
150
|
|
|
56
151
|
```ruby
|
|
152
|
+
require 'browser/http'
|
|
153
|
+
|
|
57
154
|
Browser::HTTP.get "/something.json" do
|
|
58
155
|
on :success do |res|
|
|
59
156
|
alert res.json.inspect
|
|
@@ -67,6 +164,8 @@ Websockets have been fully wrapped and they are easily configurable with
|
|
|
67
164
|
blocks.
|
|
68
165
|
|
|
69
166
|
```ruby
|
|
167
|
+
require 'browser/socket'
|
|
168
|
+
|
|
70
169
|
Browser::Socket.new 'ws://echo.websocket.org' do
|
|
71
170
|
on :open do
|
|
72
171
|
every 1 do
|
|
@@ -84,6 +183,20 @@ EventSource
|
|
|
84
183
|
-----------
|
|
85
184
|
Event sources have been implemented and are easily configurable with blocks.
|
|
86
185
|
|
|
186
|
+
```ruby
|
|
187
|
+
require 'browser/event_source'
|
|
188
|
+
|
|
189
|
+
Browser::EventSource.new '/events' do |es|
|
|
190
|
+
es.on :message do |e|
|
|
191
|
+
alert e.data
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
es.on :custom do |e|
|
|
195
|
+
alert "custom #{e.data}"
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
```
|
|
199
|
+
|
|
87
200
|
History
|
|
88
201
|
-------
|
|
89
202
|
The HTML5 History API has been fully wrapped.
|
|
@@ -93,14 +206,81 @@ Storage
|
|
|
93
206
|
The HTML5 Storage API has been wrapped and it exports a single Storage class
|
|
94
207
|
that uses the most appropriate and available API to store data locally.
|
|
95
208
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
209
|
+
```ruby
|
|
210
|
+
require 'browser/storage'
|
|
211
|
+
|
|
212
|
+
$storage = $window.storage
|
|
213
|
+
$storage[:hello] = "world"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Database SQL
|
|
217
|
+
------------
|
|
218
|
+
WebSQL has been fully wrapped (Chromium-only)
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
require 'browser/database/sql'
|
|
222
|
+
|
|
223
|
+
db = Browser::Database::SQL.new 'test'
|
|
224
|
+
db.transaction {|t|
|
|
225
|
+
t.query('CREATE TABLE test(ID INTEGER PRIMARY KEY ASC, text TEXT)').then {
|
|
226
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 1, 'huehue')
|
|
227
|
+
}.then {
|
|
228
|
+
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 2, 'jajaja')
|
|
229
|
+
}.then {
|
|
230
|
+
t.query('SELECT * FROM test')
|
|
231
|
+
}.then {|r|
|
|
232
|
+
r.each {|row|
|
|
233
|
+
alert row.inspect
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Browser support
|
|
240
|
+
===============
|
|
241
|
+
|
|
242
|
+
* Edge (Current - 3) to Current
|
|
243
|
+
* Firefox (Current - 3) to Current
|
|
244
|
+
* Chrome (Current - 3) to Current
|
|
245
|
+
* Safari (Current - 3) to Current
|
|
246
|
+
* Opera (Current - 3) to Current
|
|
247
|
+
|
|
248
|
+
Any problem above browsers should be considered and reported as a bug.
|
|
249
|
+
|
|
250
|
+
(Current - 3) to Current denotes that we support the current major stable version
|
|
251
|
+
of the browser and 3 versions preceding it. For example, if the current version
|
|
252
|
+
of a browser is 24.x, we support all versions between 21.x to 24.x.
|
|
253
|
+
|
|
254
|
+
We will accept compatibility patches for even earlier browser versions. Opal-Browser
|
|
255
|
+
is written in such a way, that it integrates a robust compatibility check system,
|
|
256
|
+
similar to Modernizr, and the history of this library goes even as far as supporting
|
|
257
|
+
Internet Explorer 6.
|
|
258
|
+
|
|
259
|
+
See the [polyfills documentation](docs/polyfills.md) if you wish to polyfill some
|
|
260
|
+
behaviors not supported by the ancient web browsers (like `querySelectorAll`).
|
|
261
|
+
|
|
262
|
+
License
|
|
263
|
+
=======
|
|
264
|
+
|
|
265
|
+
(The MIT License)
|
|
266
|
+
|
|
267
|
+
Copyright (C) 2013-2018 by meh<br>
|
|
268
|
+
Copyright (C) 2019-2021 hmdne and the Opal-Browser contributors
|
|
100
269
|
|
|
101
|
-
|
|
102
|
-
|
|
270
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
271
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
272
|
+
in the Software without restriction, including without limitation the rights
|
|
273
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
274
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
275
|
+
furnished to do so, subject to the following conditions:
|
|
103
276
|
|
|
104
|
-
|
|
277
|
+
The above copyright notice and this permission notice shall be included in
|
|
278
|
+
all copies or substantial portions of the Software.
|
|
105
279
|
|
|
106
|
-
|
|
280
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
281
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
282
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
283
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
284
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
285
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
286
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
Bundler.require
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
|
|
5
|
+
require 'webdrivers'
|
|
6
|
+
load 'webdrivers/Rakefile'
|
|
3
7
|
|
|
4
8
|
require 'opal/rspec/rake_task'
|
|
5
|
-
Opal::RSpec::RakeTask.new(:
|
|
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
|
data/config.ru
CHANGED
|
@@ -2,10 +2,17 @@ require 'bundler'
|
|
|
2
2
|
Bundler.require
|
|
3
3
|
|
|
4
4
|
apps = []
|
|
5
|
-
|
|
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|
|
|
6
12
|
s.main = 'opal/rspec/sprockets_runner'
|
|
7
13
|
s.append_path 'spec'
|
|
8
|
-
s.
|
|
14
|
+
s.index_path = 'index.html.erb'
|
|
15
|
+
s.debug = true
|
|
9
16
|
}
|
|
10
17
|
|
|
11
18
|
apps << Class.new(Sinatra::Base) {
|
|
@@ -33,6 +40,17 @@ apps << Class.new(Sinatra::Base) {
|
|
|
33
40
|
"lol"
|
|
34
41
|
end
|
|
35
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
|
+
|
|
36
54
|
get '/events' do
|
|
37
55
|
headers 'Content-Type' => 'text/event-stream'
|
|
38
56
|
|
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.
|