Skip to content

Commit

Permalink
Merge pull request #53 from yhara/opal18
Browse files Browse the repository at this point in the history
Upgrade to Opal 1.8.2
  • Loading branch information
yhara authored Jun 26, 2024
2 parents ec29ee8 + de6c58e commit 71d5e9c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'

gem 'opal'
gem 'opal-sprockets'
gem 'c_lexer'
gem 'rake'
gem 'yard'
gem 'puma'
Expand Down
44 changes: 21 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,35 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.1)
c_lexer (2.6.4.1.1)
ast (~> 2.4.0)
parser (= 2.6.4.1)
concurrent-ruby (1.1.7)
nio4r (2.5.4)
opal (1.0.5)
ast (2.4.2)
concurrent-ruby (1.3.3)
nio4r (2.7.3)
opal (1.8.2)
ast (>= 2.3.0)
parser (~> 2.6)
opal-sprockets (0.4.9.1.0.3.7)
opal (~> 1.0.0)
sprockets (~> 3.7)
parser (~> 3.0, >= 3.0.3.2)
opal-sprockets (1.0.3)
opal (>= 1.0, < 2.0)
sprockets (~> 4.0)
tilt (>= 1.4)
parser (2.6.4.1)
ast (~> 2.4.0)
puma (5.1.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
puma (6.4.2)
nio4r (~> 2.0)
rack (2.2.3)
rake (13.0.3)
sprockets (3.7.2)
racc (1.8.0)
rack (2.2.9)
rake (13.2.1)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
rack (>= 2.2.4, < 4)
thor (0.20.3)
tilt (2.0.10)
yard (0.9.26)
tilt (2.3.0)
yard (0.9.36)

PLATFORMS
ruby
arm64-darwin-21

DEPENDENCIES
c_lexer
dxopal!
opal
opal-sprockets
Expand All @@ -47,4 +45,4 @@ DEPENDENCIES
yard

BUNDLED WITH
2.1.2
2.4.13
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ has similar API to [DXRuby](http://dxruby.osdn.jp/)

see https://yhara.github.io/dxopal/

## Development

- `rake build` to make build/dxopal.js
- `rake build_min` to make build/dxopal.min.js (You need `npm install -g terser`)
- `rake api` to build yardoc
- `bundle exec dxopal server` to preview website

## License

MIT (including images and sounds under examples/)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ desc "Build dxopal.js and dxopal.min.js"
task :build_min => "build/dxopal.min.js"

file "build/dxopal.min.js" => "build/dxopal.js" do |t|
sh "uglifyjs #{t.source} -o #{t.name}"
sh "terser #{t.source} -o #{t.name}"
end

file "build/dxopal.js" => Dir["lib/**/*.rb"] do |t|
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'opal/sprockets'
opal_server = Opal::Sprockets::Server.new{|s|
# Let javascript_include_tag to serve compiled version of lib/dxopal.rb
s.append_path 'lib'
s.main = 'dxopal.rb'
s.main = 'dxopal'
# Serve static files
s.public_root = __dir__
# Just serve static ./index.html
Expand Down
1 change: 1 addition & 0 deletions lib/dxopal.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# backtick_javascript: true
require 'opal'
require 'console'; def console; $console; end

Expand Down
9 changes: 6 additions & 3 deletions lib/dxopal/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def self.loop(&block)
already_running = !!@@block
@@block = block
return if already_running
`window`.JS.requestAnimationFrame{|time| _loop(time) }
self_ = self
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
end

# (DXOpal original) Pause & resume
Expand Down Expand Up @@ -61,7 +62,8 @@ def self._loop(timestamp)
if @@fps_ct >= frame_msec
@@fps_ct -= frame_msec
else
`window`.JS.requestAnimationFrame{|time| _loop(time) }
self_ = self
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
return
end

Expand Down Expand Up @@ -110,7 +112,8 @@ def self._loop(timestamp)
end
end

`window`.JS.requestAnimationFrame{|time| _loop(time) }
self_ = self
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
end

def self._init
Expand Down

0 comments on commit 71d5e9c

Please sign in to comment.