isomorfeus-preact 22.9.0.rc3 → 22.9.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/browser/document.rb +1 -8
- data/lib/browser/element/canvas.rb +17 -17
- data/lib/browser/element/media.rb +78 -78
- data/lib/browser/element.rb +0 -1
- data/lib/browser/event_target.rb +39 -39
- data/lib/browser/file_list.rb +125 -125
- data/lib/browser/location.rb +1 -1
- data/lib/browser/window.rb +0 -7
- data/lib/isomorfeus/preact/version.rb +1 -1
- metadata +6 -7
- data/lib/browser/iterable.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bba88069414d8ed45e76c087c9f6bb20006fdea62ac0b4769a7a0838d32a037
|
4
|
+
data.tar.gz: 9336d12827cea1fad40fdb178cfe8323758bb4fee4d88c767d7f2249a1e52e13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d05800ff4b025c00ea0db26a8e0d463eadcf5811fa95b088b0485f18b311c97c6bdc8483d8af8163404c8326de2a24083b11d9b89cf4692c9d35bb103f4133c3
|
7
|
+
data.tar.gz: f58cc4c176ead2e90b7ab0cdfc3af7080a55266b07fb128c796187ccb06b7000aa5be2fdb64d428fe3357d264ff987204616aaf8f368abe91319bc4efd0b7c1d
|
data/lib/browser/document.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module Browser
|
2
|
-
class Element
|
3
|
-
element :canvas do
|
4
|
-
def context(type='2d')
|
5
|
-
Context.new(`#@native.getContext(#{type})`)
|
6
|
-
end
|
7
|
-
|
8
|
-
class Context
|
9
|
-
include DelegateNative
|
10
|
-
|
11
|
-
def initialize native
|
12
|
-
@native = native
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
module Browser
|
2
|
+
class Element
|
3
|
+
element :canvas do
|
4
|
+
def context(type='2d')
|
5
|
+
Context.new(`#@native.getContext(#{type})`)
|
6
|
+
end
|
7
|
+
|
8
|
+
class Context
|
9
|
+
include DelegateNative
|
10
|
+
|
11
|
+
def initialize native
|
12
|
+
@native = native
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,78 +1,78 @@
|
|
1
|
-
module Browser
|
2
|
-
class Element
|
3
|
-
element :video, :audio do
|
4
|
-
def buffered
|
5
|
-
TimeRanges.new(`#@native.buffered`)
|
6
|
-
end
|
7
|
-
|
8
|
-
def played
|
9
|
-
TimeRanges.new(`#@native.played`)
|
10
|
-
end
|
11
|
-
|
12
|
-
def seekable
|
13
|
-
TimeRanges.new(`#@native.seekable`)
|
14
|
-
end
|
15
|
-
|
16
|
-
def network_state
|
17
|
-
case `#@native.networkState`
|
18
|
-
when `HTMLMediaElement.NETWORK_EMPTY` then :no_data
|
19
|
-
when `HTMLMediaElement.NETWORK_IDLE` then :idle
|
20
|
-
when `HTMLMediaElement.NETWORK_LOADING` then :loading
|
21
|
-
when `HTMLMediaElement.NETWORK_NO_SOURCE` then :no_source
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
element :video do
|
27
|
-
def fullscreen
|
28
|
-
fullscreen = %w(
|
29
|
-
requestFullScreen
|
30
|
-
requestFullscreen
|
31
|
-
webkitRequestFullScreen
|
32
|
-
webkitRequestFullscreen
|
33
|
-
mozRequestFullScreen
|
34
|
-
msRequestFullscreen
|
35
|
-
).find { |prop| `!!#@native[prop]` }
|
36
|
-
|
37
|
-
if fullscreen
|
38
|
-
`#@native[fullscreen]()`
|
39
|
-
else
|
40
|
-
warn "[#{self.class}] Cannot determine the method to full-screen a video"
|
41
|
-
super
|
42
|
-
end
|
43
|
-
end
|
44
|
-
alias request_fullscreen fullscreen
|
45
|
-
end
|
46
|
-
|
47
|
-
class TimeRanges
|
48
|
-
include Enumerable
|
49
|
-
|
50
|
-
def initialize native
|
51
|
-
@native = native
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_n
|
55
|
-
@native
|
56
|
-
end
|
57
|
-
|
58
|
-
def each
|
59
|
-
`#@native.length`.times do |i|
|
60
|
-
yield TimeRange.new(`#@native.start(i)`, `#@native.end(i)`)
|
61
|
-
end
|
62
|
-
|
63
|
-
self
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class TimeRange
|
68
|
-
attr_reader :start, :end
|
69
|
-
|
70
|
-
def initialize start, _end
|
71
|
-
@start = start
|
72
|
-
@end = _end
|
73
|
-
end
|
74
|
-
|
75
|
-
alias begin start
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
1
|
+
module Browser
|
2
|
+
class Element
|
3
|
+
element :video, :audio do
|
4
|
+
def buffered
|
5
|
+
TimeRanges.new(`#@native.buffered`)
|
6
|
+
end
|
7
|
+
|
8
|
+
def played
|
9
|
+
TimeRanges.new(`#@native.played`)
|
10
|
+
end
|
11
|
+
|
12
|
+
def seekable
|
13
|
+
TimeRanges.new(`#@native.seekable`)
|
14
|
+
end
|
15
|
+
|
16
|
+
def network_state
|
17
|
+
case `#@native.networkState`
|
18
|
+
when `HTMLMediaElement.NETWORK_EMPTY` then :no_data
|
19
|
+
when `HTMLMediaElement.NETWORK_IDLE` then :idle
|
20
|
+
when `HTMLMediaElement.NETWORK_LOADING` then :loading
|
21
|
+
when `HTMLMediaElement.NETWORK_NO_SOURCE` then :no_source
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
element :video do
|
27
|
+
def fullscreen
|
28
|
+
fullscreen = %w(
|
29
|
+
requestFullScreen
|
30
|
+
requestFullscreen
|
31
|
+
webkitRequestFullScreen
|
32
|
+
webkitRequestFullscreen
|
33
|
+
mozRequestFullScreen
|
34
|
+
msRequestFullscreen
|
35
|
+
).find { |prop| `!!#@native[prop]` }
|
36
|
+
|
37
|
+
if fullscreen
|
38
|
+
`#@native[fullscreen]()`
|
39
|
+
else
|
40
|
+
warn "[#{self.class}] Cannot determine the method to full-screen a video"
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
alias request_fullscreen fullscreen
|
45
|
+
end
|
46
|
+
|
47
|
+
class TimeRanges
|
48
|
+
include Enumerable
|
49
|
+
|
50
|
+
def initialize native
|
51
|
+
@native = native
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_n
|
55
|
+
@native
|
56
|
+
end
|
57
|
+
|
58
|
+
def each
|
59
|
+
`#@native.length`.times do |i|
|
60
|
+
yield TimeRange.new(`#@native.start(i)`, `#@native.end(i)`)
|
61
|
+
end
|
62
|
+
|
63
|
+
self
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class TimeRange
|
68
|
+
attr_reader :start, :end
|
69
|
+
|
70
|
+
def initialize start, _end
|
71
|
+
@start = start
|
72
|
+
@end = _end
|
73
|
+
end
|
74
|
+
|
75
|
+
alias begin start
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/browser/element.rb
CHANGED
data/lib/browser/event_target.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
module Browser
|
2
|
-
module EventTarget
|
3
|
-
# Add the block as a handler for the specified event name. Will use either
|
4
|
-
# `addEventListener` or `addListener` if they exist.
|
5
|
-
#
|
6
|
-
# @param event_name [String] the name of the event
|
7
|
-
# @return [Proc] the block to pass to `off` to remove this handler
|
8
|
-
# @yieldparam event [Browser::Event] the event object
|
9
|
-
def on event_name, &block
|
10
|
-
wrapper = proc { |event| block.call Event.new(event) }
|
11
|
-
|
12
|
-
if `#@native.addEventListener !== undefined`
|
13
|
-
`#@native.addEventListener(event_name, wrapper)`
|
14
|
-
elsif `#@native.addListener !== undefined`
|
15
|
-
`#@native.addListener(event_name, wrapper)`
|
16
|
-
else
|
17
|
-
warn "[Browser] Not entirely sure how to add an event listener to #{self}"
|
18
|
-
end
|
19
|
-
|
20
|
-
wrapper
|
21
|
-
end
|
22
|
-
|
23
|
-
# Remove an event handler
|
24
|
-
#
|
25
|
-
# @param event_name [String] the name of the event
|
26
|
-
# @block the handler to remove, as returned from `on`
|
27
|
-
def off event_name, &block
|
28
|
-
if `#@native.removeEventListener !== undefined`
|
29
|
-
`#@native.removeEventListener(event_name, block)`
|
30
|
-
elsif `#@native.removeListener !== undefined`
|
31
|
-
`#@native.removeListener(event_name, block)`
|
32
|
-
else
|
33
|
-
warn "[Browser] Not entirely sure how to remove an event listener from #{self}"
|
34
|
-
end
|
35
|
-
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
module Browser
|
2
|
+
module EventTarget
|
3
|
+
# Add the block as a handler for the specified event name. Will use either
|
4
|
+
# `addEventListener` or `addListener` if they exist.
|
5
|
+
#
|
6
|
+
# @param event_name [String] the name of the event
|
7
|
+
# @return [Proc] the block to pass to `off` to remove this handler
|
8
|
+
# @yieldparam event [Browser::Event] the event object
|
9
|
+
def on event_name, &block
|
10
|
+
wrapper = proc { |event| block.call Event.new(event) }
|
11
|
+
|
12
|
+
if `#@native.addEventListener !== undefined`
|
13
|
+
`#@native.addEventListener(event_name, wrapper)`
|
14
|
+
elsif `#@native.addListener !== undefined`
|
15
|
+
`#@native.addListener(event_name, wrapper)`
|
16
|
+
else
|
17
|
+
warn "[Browser] Not entirely sure how to add an event listener to #{self}"
|
18
|
+
end
|
19
|
+
|
20
|
+
wrapper
|
21
|
+
end
|
22
|
+
|
23
|
+
# Remove an event handler
|
24
|
+
#
|
25
|
+
# @param event_name [String] the name of the event
|
26
|
+
# @block the handler to remove, as returned from `on`
|
27
|
+
def off event_name, &block
|
28
|
+
if `#@native.removeEventListener !== undefined`
|
29
|
+
`#@native.removeEventListener(event_name, block)`
|
30
|
+
elsif `#@native.removeListener !== undefined`
|
31
|
+
`#@native.removeListener(event_name, block)`
|
32
|
+
else
|
33
|
+
warn "[Browser] Not entirely sure how to remove an event listener from #{self}"
|
34
|
+
end
|
35
|
+
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/browser/file_list.rb
CHANGED
@@ -1,125 +1,125 @@
|
|
1
|
-
module Browser
|
2
|
-
class FileList
|
3
|
-
include Enumerable
|
4
|
-
|
5
|
-
# @param native [JS] the native FileList object to wrap
|
6
|
-
def initialize native
|
7
|
-
@native = `#{native} || []`
|
8
|
-
@files = length.times.each_with_object([]) { |index, array|
|
9
|
-
array[index] = File.new(`#@native[index]`)
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
# @param index [Integer] the index of the file in the list
|
14
|
-
# @return [Browser::FileList::File] the file at the specified index
|
15
|
-
def [] index
|
16
|
-
@files[index]
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [Integer] the number of files in this list
|
20
|
-
def length
|
21
|
-
`#@native.length`
|
22
|
-
end
|
23
|
-
alias size length
|
24
|
-
|
25
|
-
# Call the given block for each file in the list
|
26
|
-
#
|
27
|
-
# @yieldparam file [Browser::FileList::File]
|
28
|
-
def each &block
|
29
|
-
@files.each do |file|
|
30
|
-
block.call file
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Convert this FileList into an array
|
35
|
-
def to_a
|
36
|
-
@files.dup # Don't return a value that can mutate our internal state
|
37
|
-
end
|
38
|
-
alias to_ary to_a
|
39
|
-
|
40
|
-
# @return [String] a string representation of this FileList
|
41
|
-
def to_s
|
42
|
-
@files.to_s
|
43
|
-
end
|
44
|
-
|
45
|
-
# An individual item in a FileList
|
46
|
-
class File
|
47
|
-
attr_reader :data
|
48
|
-
|
49
|
-
# @param native [JS] the native File object to wrap
|
50
|
-
def initialize native
|
51
|
-
@native = native
|
52
|
-
@data = nil
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [String] the filename
|
56
|
-
def name
|
57
|
-
`#@native.name`
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [Integer] the size of this file on disk
|
61
|
-
def size
|
62
|
-
`#@native.size`
|
63
|
-
end
|
64
|
-
|
65
|
-
# @return [String] the MIME type of the file, detected by the browser
|
66
|
-
def type
|
67
|
-
`#@native.type`
|
68
|
-
end
|
69
|
-
|
70
|
-
# @return [Time] the timestamp of the file
|
71
|
-
def last_modified
|
72
|
-
`#@native.lastModifiedDate`
|
73
|
-
end
|
74
|
-
|
75
|
-
# Read the file from disk into memory
|
76
|
-
#
|
77
|
-
# @return [Promise] a promise that resolves when finished loading and
|
78
|
-
# rejects if an error occurs while loading.
|
79
|
-
def read
|
80
|
-
promise = Promise.new
|
81
|
-
reader = FileReader.new
|
82
|
-
reader.on :load do
|
83
|
-
result = reader.result
|
84
|
-
|
85
|
-
@data = result
|
86
|
-
promise.resolve result
|
87
|
-
end
|
88
|
-
|
89
|
-
reader.on :error do
|
90
|
-
promise.reject reader.result
|
91
|
-
end
|
92
|
-
|
93
|
-
reader.read_as_binary_string self
|
94
|
-
|
95
|
-
promise
|
96
|
-
end
|
97
|
-
|
98
|
-
# Convert to the native object
|
99
|
-
#
|
100
|
-
# @return [JS.HTMLElement] the underlying native element
|
101
|
-
def to_n
|
102
|
-
@native
|
103
|
-
end
|
104
|
-
|
105
|
-
# The object that reads the file from disk.
|
106
|
-
#
|
107
|
-
# @api private
|
108
|
-
class FileReader
|
109
|
-
include EventTarget
|
110
|
-
|
111
|
-
def initialize
|
112
|
-
@native = `new FileReader()`
|
113
|
-
end
|
114
|
-
|
115
|
-
def result
|
116
|
-
`#@native.result`
|
117
|
-
end
|
118
|
-
|
119
|
-
def read_as_binary_string file
|
120
|
-
`#@native.readAsBinaryString(#{file.to_n})`
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
1
|
+
module Browser
|
2
|
+
class FileList
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
# @param native [JS] the native FileList object to wrap
|
6
|
+
def initialize native
|
7
|
+
@native = `#{native} || []`
|
8
|
+
@files = length.times.each_with_object([]) { |index, array|
|
9
|
+
array[index] = File.new(`#@native[index]`)
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param index [Integer] the index of the file in the list
|
14
|
+
# @return [Browser::FileList::File] the file at the specified index
|
15
|
+
def [] index
|
16
|
+
@files[index]
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Integer] the number of files in this list
|
20
|
+
def length
|
21
|
+
`#@native.length`
|
22
|
+
end
|
23
|
+
alias size length
|
24
|
+
|
25
|
+
# Call the given block for each file in the list
|
26
|
+
#
|
27
|
+
# @yieldparam file [Browser::FileList::File]
|
28
|
+
def each &block
|
29
|
+
@files.each do |file|
|
30
|
+
block.call file
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Convert this FileList into an array
|
35
|
+
def to_a
|
36
|
+
@files.dup # Don't return a value that can mutate our internal state
|
37
|
+
end
|
38
|
+
alias to_ary to_a
|
39
|
+
|
40
|
+
# @return [String] a string representation of this FileList
|
41
|
+
def to_s
|
42
|
+
@files.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
# An individual item in a FileList
|
46
|
+
class File
|
47
|
+
attr_reader :data
|
48
|
+
|
49
|
+
# @param native [JS] the native File object to wrap
|
50
|
+
def initialize native
|
51
|
+
@native = native
|
52
|
+
@data = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String] the filename
|
56
|
+
def name
|
57
|
+
`#@native.name`
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Integer] the size of this file on disk
|
61
|
+
def size
|
62
|
+
`#@native.size`
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String] the MIME type of the file, detected by the browser
|
66
|
+
def type
|
67
|
+
`#@native.type`
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [Time] the timestamp of the file
|
71
|
+
def last_modified
|
72
|
+
`#@native.lastModifiedDate`
|
73
|
+
end
|
74
|
+
|
75
|
+
# Read the file from disk into memory
|
76
|
+
#
|
77
|
+
# @return [Promise] a promise that resolves when finished loading and
|
78
|
+
# rejects if an error occurs while loading.
|
79
|
+
def read
|
80
|
+
promise = Promise.new
|
81
|
+
reader = FileReader.new
|
82
|
+
reader.on :load do
|
83
|
+
result = reader.result
|
84
|
+
|
85
|
+
@data = result
|
86
|
+
promise.resolve result
|
87
|
+
end
|
88
|
+
|
89
|
+
reader.on :error do
|
90
|
+
promise.reject reader.result
|
91
|
+
end
|
92
|
+
|
93
|
+
reader.read_as_binary_string self
|
94
|
+
|
95
|
+
promise
|
96
|
+
end
|
97
|
+
|
98
|
+
# Convert to the native object
|
99
|
+
#
|
100
|
+
# @return [JS.HTMLElement] the underlying native element
|
101
|
+
def to_n
|
102
|
+
@native
|
103
|
+
end
|
104
|
+
|
105
|
+
# The object that reads the file from disk.
|
106
|
+
#
|
107
|
+
# @api private
|
108
|
+
class FileReader
|
109
|
+
include EventTarget
|
110
|
+
|
111
|
+
def initialize
|
112
|
+
@native = `new FileReader()`
|
113
|
+
end
|
114
|
+
|
115
|
+
def result
|
116
|
+
`#@native.result`
|
117
|
+
end
|
118
|
+
|
119
|
+
def read_as_binary_string file
|
120
|
+
`#@native.readAsBinaryString(#{file.to_n})`
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/browser/location.rb
CHANGED
data/lib/browser/window.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-preact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 22.9.0.
|
4
|
+
version: 22.9.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 22.9.0.
|
61
|
+
version: 22.9.0.rc4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 22.9.0.
|
68
|
+
version: 22.9.0.rc4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: isomorfeus-redux
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 22.9.0.
|
75
|
+
version: 22.9.0.rc4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 22.9.0.
|
82
|
+
version: 22.9.0.rc4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: isomorfeus-puppetmaster
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,6 @@ files:
|
|
140
140
|
- lib/browser/event_target.rb
|
141
141
|
- lib/browser/file_list.rb
|
142
142
|
- lib/browser/history.rb
|
143
|
-
- lib/browser/iterable.rb
|
144
143
|
- lib/browser/location.rb
|
145
144
|
- lib/browser/window.rb
|
146
145
|
- lib/data_uri.rb
|
data/lib/browser/iterable.rb
DELETED