opal-browser 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +28 -17
  3. data/.github/workflows/pages.yml +21 -0
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +7 -0
  6. data/Gemfile +15 -5
  7. data/Rakefile +32 -9
  8. data/bin/rake +7 -0
  9. data/bin/setup +8 -0
  10. data/config.ru +19 -12
  11. data/opal/browser/dom/element/attributes.rb +2 -0
  12. data/opal/browser/dom/element/button.rb +2 -0
  13. data/opal/browser/dom/element/custom.rb +2 -1
  14. data/opal/browser/dom/element/data.rb +2 -0
  15. data/opal/browser/dom/element/editable.rb +2 -0
  16. data/opal/browser/dom/element/form.rb +25 -1
  17. data/opal/browser/dom/element/iframe.rb +2 -0
  18. data/opal/browser/dom/element/image.rb +6 -15
  19. data/opal/browser/dom/element/input.rb +7 -19
  20. data/opal/browser/dom/element/media.rb +4 -3
  21. data/opal/browser/dom/element/offset.rb +2 -0
  22. data/opal/browser/dom/element/scroll.rb +2 -0
  23. data/opal/browser/dom/element/select.rb +4 -7
  24. data/opal/browser/dom/element/size.rb +6 -12
  25. data/opal/browser/dom/element/template.rb +2 -0
  26. data/opal/browser/dom/element/textarea.rb +3 -3
  27. data/opal/browser/dom/element.rb +4 -0
  28. data/opal/browser/event/animation.rb +5 -7
  29. data/opal/browser/event/audio_processing.rb +5 -11
  30. data/opal/browser/event/base.rb +4 -6
  31. data/opal/browser/event/before_unload.rb +2 -0
  32. data/opal/browser/event/clipboard.rb +4 -7
  33. data/opal/browser/event/close.rb +4 -7
  34. data/opal/browser/event/composition.rb +4 -7
  35. data/opal/browser/event/custom.rb +5 -3
  36. data/opal/browser/event/data_transfer.rb +3 -1
  37. data/opal/browser/event/device_light.rb +3 -3
  38. data/opal/browser/event/device_motion.rb +6 -15
  39. data/opal/browser/event/device_orientation.rb +6 -15
  40. data/opal/browser/event/device_proximity.rb +5 -11
  41. data/opal/browser/event/drag.rb +6 -14
  42. data/opal/browser/event/focus.rb +4 -7
  43. data/opal/browser/event/gamepad.rb +3 -1
  44. data/opal/browser/event/hash_change.rb +4 -7
  45. data/opal/browser/event/keyboard.rb +2 -0
  46. data/opal/browser/event/message.rb +5 -11
  47. data/opal/browser/event/mouse.rb +20 -65
  48. data/opal/browser/event/page_transition.rb +3 -3
  49. data/opal/browser/event/pop_state.rb +3 -1
  50. data/opal/browser/event/progress.rb +5 -11
  51. data/opal/browser/event/sensor.rb +2 -0
  52. data/opal/browser/event/storage.rb +7 -19
  53. data/opal/browser/event/touch.rb +2 -0
  54. data/opal/browser/event/ui.rb +4 -7
  55. data/opal/browser/event/wheel.rb +5 -11
  56. data/opal/browser/support.rb +21 -33
  57. data/opal/browser/version.rb +1 -1
  58. data/opal-browser.gemspec +23 -18
  59. data/spec/browser_runner.rb.erb +14 -0
  60. data/spec/browser_runner_compat.rb +29 -0
  61. data/{index.html.erb → spec/browser_runner_index.html.erb} +1 -5
  62. data/spec/database/sql_spec.rb +1 -1
  63. data/spec/event_spec.rb +43 -0
  64. data/spec/immediate_spec.rb +1 -1
  65. data/spec/runner.rb +3 -3
  66. data/spec/spec_helper_promise.rb.erb +13 -5
  67. metadata +206 -34
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class BeforeUnload < Event
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Clipboard < Event
@@ -8,13 +10,8 @@ class Clipboard < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def data=(value)
12
- `#@native.data = #{value}`
13
- end
14
-
15
- def type=(value)
16
- `#@native.dataType = #{value}`
17
- end
13
+ alias_native :data=
14
+ alias_native :type=, :dataType=
18
15
  end
19
16
 
20
17
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Close < Event
@@ -8,13 +10,8 @@ class Close < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def code=(value)
12
- `#@native.code = #{value}`
13
- end
14
-
15
- def reason=(value)
16
- `#@native.reason = #{value}`
17
- end
13
+ alias_native :code=
14
+ alias_native :reason=
18
15
 
19
16
  def clean!(value)
20
17
  `#@native.wasClean = true`
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Composition < UI
@@ -8,13 +10,8 @@ class Composition < UI
8
10
  end
9
11
 
10
12
  class Definition < UI::Definition
11
- def data=(value)
12
- `#@native.data = #{value}`
13
- end
14
-
15
- def locale=(value)
16
- `#@native.locale = #{value}`
17
- end
13
+ alias_native :data=
14
+ alias_native :locale=
18
15
  end
19
16
 
20
17
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  require 'ostruct'
2
4
 
3
5
  module Browser; class Event
@@ -11,6 +13,8 @@ class Custom < Event
11
13
  def method_missing(name, value)
12
14
  if name.end_with? ?=
13
15
  `#@native[#{name[0 .. -2]}] = value`
16
+ else
17
+ super
14
18
  end
15
19
  end
16
20
  end
@@ -51,12 +55,10 @@ class Custom < Event
51
55
 
52
56
  def initialize(event, callback = nil)
53
57
  super(event, callback)
54
-
55
- @detail = Hash.new(`#{event}.detail`)
56
58
  end
57
59
 
58
60
  def method_missing(id, *)
59
- return @detail[id] if @detail.has_key?(id)
61
+ `if (#@native.detail != null && Object.hasOwn(#@native.detail, id)) return #@native.detail[id]`
60
62
 
61
63
  super
62
64
  end
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  require 'browser/blob'
2
4
 
3
5
  module Browser; class Event
@@ -92,4 +94,4 @@ class DataTransfer
92
94
  end
93
95
  end
94
96
 
95
- end; end
97
+ end; end
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class DeviceLight < Event
@@ -8,9 +10,7 @@ class DeviceLight < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def value=(value)
12
- `#@native.value = #{value}`
13
- end
13
+ alias_native :value
14
14
  end
15
15
 
16
16
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class DeviceMotion < Event
@@ -10,21 +12,10 @@ class DeviceMotion < Event
10
12
  Acceleration = Struct.new(:x, :y, :z)
11
13
 
12
14
  class Definition < Definition
13
- def acceleration=(value)
14
- `#@native.acceleration = #{value.to_n}`
15
- end
16
-
17
- def acceleration_with_gravity=(value)
18
- `#@native.accelerationIncludingGravity = #{value.to_n}`
19
- end
20
-
21
- def rotation=(value)
22
- `#@native.rotationRate = #{value}`
23
- end
24
-
25
- def interval=(value)
26
- `#@native.interval = #{value}`
27
- end
15
+ alias_native :acceleration=
16
+ alias_native :acceleration_with_gravity=, :accelerationIncludingGravity=
17
+ alias_native :rotation=, :rotationRate=
18
+ alias_native :interval=
28
19
  end
29
20
 
30
21
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class DeviceOrientation < Event
@@ -8,21 +10,10 @@ class DeviceOrientation < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def absolute=(value)
12
- `#@native.absolute = #{value}`
13
- end
14
-
15
- def alpha=(value)
16
- `#@native.alpha = #{value}`
17
- end
18
-
19
- def beta=(value)
20
- `#@native.beta = #{value}`
21
- end
22
-
23
- def gamma=(value)
24
- `#@native.gamma = #{value}`
25
- end
13
+ alias_native :absolute=
14
+ alias_native :alpha=
15
+ alias_native :beta=
16
+ alias_native :gamma=
26
17
  end
27
18
 
28
19
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class DeviceProximity < Event
@@ -8,17 +10,9 @@ class DeviceProximity < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def value=(value)
12
- `#@native.value = #{value}`
13
- end
14
-
15
- def min=(value)
16
- `#@native.min = #{value}`
17
- end
18
-
19
- def max=(value)
20
- `#@native.max = #{value}`
21
- end
13
+ alias_native :value=
14
+ alias_native :min=
15
+ alias_native :max=
22
16
  end
23
17
 
24
18
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Drag < Event
@@ -12,25 +14,15 @@ class Drag < Event
12
14
  class Client
13
15
  include Native::Wrapper
14
16
 
15
- def x=(value)
16
- `#@native.clientX = #{value}`
17
- end
18
-
19
- def y=(value)
20
- `#@native.clientY = #{value}`
21
- end
17
+ alias_native :x=, :clientX
18
+ alias_native :y=, :clientY
22
19
  end
23
20
 
24
21
  class Screen
25
22
  include Native::Wrapper
26
23
 
27
- def x=(value)
28
- `#@native.screenX = #{value}`
29
- end
30
-
31
- def y=(value)
32
- `#@native.screenY = #{value}`
33
- end
24
+ alias_native :x=, :screenX
25
+ alias_native :y=, :screenY
34
26
  end
35
27
 
36
28
  def alt!
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Focus < UI
@@ -8,13 +10,8 @@ class Focus < UI
8
10
  end
9
11
 
10
12
  class Definition < UI::Definition
11
- def view=(value)
12
- `#@native.view = #{Native.convert(value)}`
13
- end
14
-
15
- def related=(elem)
16
- `#@native.relatedTarget = #{Native.convert(elem)}`
17
- end
13
+ alias_native :view=
14
+ alias_native :related=, :relatedTarget
18
15
  end
19
16
 
20
17
  if Browser.supports? 'Event.constructor'
@@ -1,6 +1,8 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
- class Gamepad < Event
5
+ class Gamepad < Event
4
6
  handles 'gamepadconnected', 'gamepaddisconnected'
5
7
 
6
8
  def self.supported?
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class HashChange < Event
@@ -8,13 +10,8 @@ class HashChange < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def old=(value)
12
- `#@native.oldURL = #{value}`
13
- end
14
-
15
- def new=(value)
16
- `#@native.newURL = #{value}`
17
- end
13
+ alias_native :old=, :oldURL=
14
+ alias_native :new=, :newURL=
18
15
  end
19
16
 
20
17
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Keyboard < UI
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  require 'buffer'
2
4
 
3
5
  module Browser; class Event
@@ -10,17 +12,9 @@ class Message < Event
10
12
  end
11
13
 
12
14
  class Definition < Definition
13
- def data=(value)
14
- `#@native.data = value`
15
- end
16
-
17
- def origin=(value)
18
- `#@native.origin = value`
19
- end
20
-
21
- def source=(value)
22
- `#@native.source = #{Native.convert(value)}`
23
- end
15
+ alias_native :data=
16
+ alias_native :origin=
17
+ alias_native :source=
24
18
  end
25
19
 
26
20
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Mouse < UI
@@ -13,82 +15,51 @@ class Mouse < UI
13
15
  class Client
14
16
  include Native::Wrapper
15
17
 
16
- def x=(value)
17
- `#@native.clientX = #{value}`
18
- end
19
-
20
- def y=(value)
21
- `#@native.clientY = #{value}`
22
- end
18
+ alias_native :x=, :clientX=
19
+ alias_native :y=, :clientY=
23
20
  end
24
21
 
25
22
  class Layer
26
23
  include Native::Wrapper
27
24
 
28
- def x=(value)
29
- `#@native.layerX = #{value}`
30
- end
31
-
32
- def y=(value)
33
- `#@native.layerY = #{value}`
34
- end
25
+ alias_native :x=, :layerX=
26
+ alias_native :y=, :layerY=
35
27
  end
36
28
 
37
29
  class Offset
38
30
  include Native::Wrapper
39
31
 
40
- def x=(value)
41
- `#@native.offsetX = #{value}`
42
- end
43
-
44
- def y=(value)
45
- `#@native.offsetY= #{value}`
46
- end
32
+ alias_native :x=, :offsetX=
33
+ alias_native :y=, :offsetY=
47
34
  end
48
35
 
49
36
  class Page
50
37
  include Native::Wrapper
51
38
 
52
- def x=(value)
53
- `#@native.pageX = #{value}`
54
- end
55
-
56
- def y=(value)
57
- `#@native.pageY = #{value}`
58
- end
39
+ alias_native :x=, :pageX=
40
+ alias_native :y=, :pageY=
59
41
  end
60
42
 
61
43
  class Screen
62
44
  include Native::Wrapper
63
45
 
64
- def x=(value)
65
- `#@native.screenX = #{value}`
66
- end
67
-
68
- def y=(value)
69
- `#@native.screenY = #{value}`
70
- end
46
+ alias_native :x=, :screenX=
47
+ alias_native :y=, :screenY=
71
48
  end
72
49
 
73
50
  class Ancestor
74
51
  include Native::Wrapper
75
52
 
76
- def x=(value)
77
- `#@native.x = #{value}`
78
- end
79
-
80
- def y=(value)
81
- `#@native.y = #{value}`
82
- end
83
- end
84
-
85
- def x=(value)
86
- `#@native.screenX = #{value}`
53
+ alias_native :x=
54
+ alias_native :y=
87
55
  end
88
56
 
89
- def y=(value)
90
- `#@native.screenY = #{value}`
91
- end
57
+ alias_native :x=, :screenX=
58
+ alias_native :y=, :screenY=
59
+ alias_native :button=
60
+ alias_native :related=, :relatedTarget=
61
+ alias_native :from=, :fromElement=
62
+ alias_native :to=, :toElement=
92
63
 
93
64
  def alt!
94
65
  `#@native.altKey = true`
@@ -102,10 +73,6 @@ class Mouse < UI
102
73
  `#@native.metaKey = true`
103
74
  end
104
75
 
105
- def button=(value)
106
- `#@native.button = #{value}`
107
- end
108
-
109
76
  def client
110
77
  Client.new(@native)
111
78
  end
@@ -129,18 +96,6 @@ class Mouse < UI
129
96
  def ancestor
130
97
  Ancestor.new(@native)
131
98
  end
132
-
133
- def related=(elem)
134
- `#@native.relatedTarget = #{Native.try_convert(elem)}`
135
- end
136
-
137
- def from=(elem)
138
- `#@native.fromElement = #{Native.try_convert(elem)}`
139
- end
140
-
141
- def to=(elem)
142
- `#@native.toElement = #{Native.try_convert(elem)}`
143
- end
144
99
  end
145
100
 
146
101
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class PageTransition < Event
@@ -8,9 +10,7 @@ class PageTransition < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def persisted=(value)
12
- `#@native.persisted = #{value}`
13
- end
13
+ alias_native :persisted=
14
14
  end
15
15
 
16
16
  if Browser.supports? 'Event.PageTransition'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class PopState < Event
@@ -9,7 +11,7 @@ class PopState < Event
9
11
 
10
12
  class Definition < Definition
11
13
  def state=(value)
12
- `#@native.state = #{value}`
14
+ alias_native :state=
13
15
  end
14
16
  end
15
17
 
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Progress < Event
@@ -8,17 +10,9 @@ class Progress < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def computable=(value)
12
- `#@native.computableLength = #{value}`
13
- end
14
-
15
- def loaded=(value)
16
- `#@native.loaded = #{value}`
17
- end
18
-
19
- def total=(value)
20
- `#@native.total = #{value}`
21
- end
13
+ alias_native :computable=, :computableLength=
14
+ alias_native :loaded=
15
+ alias_native :total=
22
16
  end
23
17
 
24
18
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Sensor < Event
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Storage < Event
@@ -8,25 +10,11 @@ class Storage < Event
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def key=(value)
12
- `#@native.key = #{value}`
13
- end
14
-
15
- def new=(value)
16
- `#@native.newValue = #{value}`
17
- end
18
-
19
- def old=(value)
20
- `#@native.oldValue = #{value}`
21
- end
22
-
23
- def area=(value)
24
- `#@native.storageArea = #{value}`
25
- end
26
-
27
- def url=(value)
28
- `#@native.url = #{value}`
29
- end
13
+ alias_native :key=
14
+ alias_native :new=, :newValue=
15
+ alias_native :old=, :oldValue=
16
+ alias_native :area=, :storageArea=
17
+ alias_native :url=
30
18
  end
31
19
 
32
20
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Touch < Event
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class UI < Event
@@ -6,13 +8,8 @@ class UI < Event
6
8
  end
7
9
 
8
10
  class Definition < Definition
9
- def detail=(value)
10
- `#@native.detail = #{value}`
11
- end
12
-
13
- def view=(value)
14
- `#@native.view = #{value}`
15
- end
11
+ alias_native :detail=
12
+ alias_native :view=
16
13
  end
17
14
 
18
15
  if Browser.supports? 'Event.constructor'
@@ -1,3 +1,5 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser; class Event
2
4
 
3
5
  class Wheel < UI
@@ -8,17 +10,9 @@ class Wheel < UI
8
10
  end
9
11
 
10
12
  class Definition < Definition
11
- def x=(value)
12
- `#@native.deltaX = #{value}`
13
- end
14
-
15
- def y=(value)
16
- `#@native.deltaY = #{value}`
17
- end
18
-
19
- def z=(value)
20
- `#@native.deltaZ = #{value}`
21
- end
13
+ alias_native :x=, :deltaX=
14
+ alias_native :y=, :deltaY=
15
+ alias_native :z=, :deltaZ=
22
16
 
23
17
  def mode=(value)
24
18
  value = case value