isomorfeus-preact 23.9.0.rc2 → 23.9.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b75453247bc0c884571e884c674717562fe5e27fadf2f1f27f5f62965e37580
4
- data.tar.gz: 6eaddb4ca8921da6d124b1eb983663fd8de05b3d25ad31c9975b35d77468cc6d
3
+ metadata.gz: e407fc877fc823bc4293e77aa42bdfec02301d3c94ab46ab03f64cb1b322ec48
4
+ data.tar.gz: ac9a74ed17b3bc6506d2108868b812c72f425b5b5a38331667402172e226e787
5
5
  SHA512:
6
- metadata.gz: 37662cbea0b4b59cd9ec04c632cb2ea2bf9e96fa2ffab3f6a40f9d7632be83b72d60189b8da2c60ba70af41c4f7de435a7410a40c66887699ab1ad9d6419c57d
7
- data.tar.gz: 4300537585ebb569255dddc9a34ea47ddc19d682ae0e1f995cf30f9b7cebe7a063512f9689a634bd9a9a113d80083bb684a0262db5c4d05d1aa18e008e1f90dd
6
+ metadata.gz: f1a783d3d655b8296ec24c9d402320c7484877b2392cbf5fc095b7b4a3a2e1b240f807febafd2df6c4a7ecf6797420cf44a0622a8759ed471db227967eb1441c
7
+ data.tar.gz: 6ec873ec434adb9d2c68c4ff3fd892397b758dde1066fa1fc4c3050c9124763d6c1efd64cba77aa9a2c2bc3032fb6ae7ca87de50edcfd7fa8586d706bae0a3b2
@@ -0,0 +1,7 @@
1
+ # backtick_javascript: true
2
+
3
+ module Browser
4
+ class ArrayBuffer < `ArrayBuffer`
5
+ include Delegate
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # backtick_javascript: true
2
+
3
+ module Browser
4
+ class Blob < `Blob`
5
+ include Delegate
6
+ end
7
+ end
@@ -1,43 +1,28 @@
1
1
  # backtick_javascript: true
2
2
 
3
3
  module Browser
4
- module DelegateNative
5
- # Provides a default initializer. This should be overridden in all but the
6
- # simplest cases.
7
- def initialize native
8
- @native = native
9
- end
10
-
4
+ module Delegate
11
5
  def [](property)
12
6
  method_missing(property)
13
7
  end
14
8
 
15
- # Fall back to native properties. If the message sent to this element is not
16
- # recognized, it checks to see if it is a property of the native element. It
17
- # also checks for variations of the message name, such as:
18
- #
19
- # :supported? => [:supported, :isSupported]
20
- #
21
- # If a property with the specified message name is found and it is a
22
- # function, that function is invoked with `args`. Otherwise, the property
23
- # is returned as is.
24
9
  def method_missing message, *args, &block
25
10
  if message.end_with? '='
26
11
  message = message.chop
27
12
  property_name = property_for_message(message)
28
13
  arg = args[0]
29
14
  arg = arg.to_n if `arg && typeof arg.$to_n === 'function'`
30
- return `#@native[#{property_name}] = arg`
15
+ return `self[#{property_name}] = arg`
31
16
  else
32
17
  property_name = property_for_message(message)
33
18
  %x{
34
- let value = #@native[#{property_name}];
19
+ let value = self[#{property_name}];
35
20
  let type = typeof(value);
36
21
  if (type === 'undefined') { return #{super}; }
37
22
  try {
38
23
  if (type === 'function') {
39
24
  #{args.map! { |arg| `arg && typeof arg.$to_n === 'function'` ? arg.to_n : arg }}
40
- value = value.apply(#@native, args);
25
+ value = value.apply(self, args);
41
26
  }
42
27
  if (value instanceof HTMLCollection || value instanceof NodeList) {
43
28
  let a = [];
@@ -49,10 +34,6 @@ module Browser
49
34
  value = #{Browser::Element.new(`value`)};
50
35
  } else if (value instanceof Event) {
51
36
  value = #{Browser::Event.new(`value`)};
52
- } else if (value instanceof FileList) {
53
- value = #{Browser::FileList.new(`value`)};
54
- } else if (value instanceof File) {
55
- value = #{Browser::File.new(`value`)};
56
37
  } else if (value instanceof FileReader) {
57
38
  value = #{Browser::FileReader.new(`value`)}
58
39
  } else if (value === null || type === 'undefined' || (type === 'number' && isNaN(value))) {
@@ -67,28 +48,24 @@ module Browser
67
48
  def respond_to_missing? message, include_all
68
49
  message = message.chop if message.end_with? '='
69
50
  property_name = property_for_message(message)
70
- return true if `#{property_name} in #@native`
51
+ return true if `#{property_name} in self`
71
52
  false
72
53
  end
73
54
 
74
55
  def property_for_message(message)
75
56
  %x{
76
57
  let camel_cased_message;
77
- if (typeof(#@native[message]) !== 'undefined') { camel_cased_message = message; }
58
+ if (typeof(self[message]) !== 'undefined') { camel_cased_message = message; }
78
59
  else { camel_cased_message = #{message.camelize(:lower)} }
79
60
 
80
61
  if (camel_cased_message.endsWith('?')) {
81
62
  camel_cased_message = camel_cased_message.substring(0, camel_cased_message.length - 2);
82
- if (typeof(#@native[camel_cased_message]) === 'undefined') {
63
+ if (typeof(self[camel_cased_message]) === 'undefined') {
83
64
  camel_cased_message = 'is' + camel_cased_message[0].toUpperCase() + camel_cased_message.substring(0, camel_cased_message.length - 1);
84
65
  }
85
66
  }
86
67
  return camel_cased_message
87
68
  }
88
69
  end
89
-
90
- def to_n
91
- @native
92
- end
93
70
  end
94
71
  end
@@ -49,10 +49,6 @@ module Browser
49
49
  value = #{Browser::Element.new(`value`)};
50
50
  } else if (value instanceof Event) {
51
51
  value = #{Browser::Event.new(`value`)};
52
- } else if (value instanceof FileList) {
53
- value = #{Browser::FileList.new(`value`)};
54
- } else if (value instanceof File) {
55
- value = #{Browser::File.new(`value`)};
56
52
  } else if (value instanceof FileReader) {
57
53
  value = #{Browser::FileReader.new(`value`)}
58
54
  } else if (value === null || type === 'undefined' || (type === 'number' && isNaN(value))) {
@@ -0,0 +1,8 @@
1
+ # backtick_javascript: true
2
+
3
+ module Browser
4
+ # An individual item in a FileList
5
+ class File < `File`
6
+ include Delegate
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ # backtick_javascript: true
2
+
3
+ module Browser
4
+ class FileList < `FileList`
5
+ include Delegate
6
+ include Enumerable
7
+
8
+ def [](idx)
9
+ `self.item(idx)`
10
+ end
11
+
12
+ # @return [Integer] the number of files in this list
13
+ def size
14
+ `self.length`
15
+ end
16
+
17
+ # Call the given block for each file in the list
18
+ #
19
+ # @yieldparam file [Browser::FileList::File]
20
+ def each &block
21
+ %x{
22
+ let l = #@native.length, i;
23
+ for(i = 0; i < l; i++) {
24
+ #{block.call(File.new(`#@native.item(i)`))}
25
+ }
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ # backtick_javascript: true
2
+
3
+ module Browser
4
+ class ReadableStream < `ReadableStream`
5
+ include Delegate
6
+ end
7
+ end
@@ -109,15 +109,7 @@ module Browser
109
109
  #
110
110
  # @return [Browser::File] the file selected by the user
111
111
  def file
112
- files.first
113
- end
114
-
115
- # Get the currently selected files for this input. This is only useful for
116
- # file inputs with the `multiple` property set.
117
- #
118
- # @return [Browser::FileList] the currently selected files for this input
119
- def files
120
- FileList.new(`#@native.files`)
112
+ `#@native.files.item(0)`
121
113
  end
122
114
 
123
115
  # Determine whether this is the same element
@@ -1,18 +1,20 @@
1
+ # backtick_javascript: true
2
+
1
3
  module Browser
2
- # The object that reads the file from disk.
3
4
  class FileReader
5
+ include DelegateNative
4
6
  include EventTarget
5
7
 
6
- def initialize
7
- @native = `new FileReader()`
8
- end
8
+ EMPTY = 0
9
+ LOADING = 1
10
+ DONE = 2
9
11
 
10
- def result
11
- `#@native.result`
12
+ def initialize(native=nil)
13
+ @native = native || `new FileReader()`
12
14
  end
13
15
 
14
- def read_as_binary_string file
15
- `#@native.readAsBinaryString(#{file.to_n})`
16
+ def read_as_data_url file
17
+ `#@native.readAsDataURL(file)`
16
18
  end
17
19
  end
18
20
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Preact
3
- VERSION = '23.9.0.rc2'
3
+ VERSION = '23.9.0.rc3'
4
4
  end
5
5
  end
@@ -16,7 +16,9 @@ require 'isomorfeus-i18n'
16
16
  require 'isomorfeus/preact/config'
17
17
 
18
18
  if RUBY_ENGINE == 'opal'
19
+ require 'browser/delegate'
19
20
  require 'browser/delegate_native'
21
+ require 'browser/file'
20
22
  require_tree 'browser_auto', autoload: true
21
23
  end
22
24
 
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: 23.9.0.rc2
4
+ version: 23.9.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-10 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -78,28 +78,28 @@ dependencies:
78
78
  requirements:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
- version: 23.9.0.rc2
81
+ version: 23.9.0.rc3
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 23.9.0.rc2
88
+ version: 23.9.0.rc3
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: isomorfeus-redux
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 23.9.0.rc2
95
+ version: 23.9.0.rc3
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 23.9.0.rc2
102
+ version: 23.9.0.rc3
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: benchmark-ips
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.9.2
123
+ version: 0.9.3
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.9.2
130
+ version: 0.9.3
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rake
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -185,18 +185,21 @@ files:
185
185
  - ext/isomorfeus_preact_ext/preact.c
186
186
  - ext/isomorfeus_preact_ext/vnode.c
187
187
  - ext/isomorfeus_preact_ext/vnode.h
188
+ - lib/browser/array_buffer.rb
189
+ - lib/browser/blob.rb
190
+ - lib/browser/delegate.rb
188
191
  - lib/browser/delegate_native.rb
192
+ - lib/browser/file.rb
193
+ - lib/browser/file_list.rb
189
194
  - lib/browser/history.rb
190
195
  - lib/browser/location.rb
191
- - lib/browser_auto/browser/delegate_native.rb
196
+ - lib/browser/readable_stream.rb
192
197
  - lib/browser_auto/browser/document.rb
193
198
  - lib/browser_auto/browser/element.rb
194
199
  - lib/browser_auto/browser/element/canvas.rb
195
200
  - lib/browser_auto/browser/element/media.rb
196
201
  - lib/browser_auto/browser/event.rb
197
202
  - lib/browser_auto/browser/event_target.rb
198
- - lib/browser_auto/browser/file.rb
199
- - lib/browser_auto/browser/file_list.rb
200
203
  - lib/browser_auto/browser/file_reader.rb
201
204
  - lib/browser_auto/browser/window.rb
202
205
  - lib/data_uri.rb
@@ -1,62 +0,0 @@
1
- module Browser
2
- # An individual item in a FileList
3
- class File
4
- attr_reader :data
5
-
6
- # @param native [JS] the native File object to wrap
7
- def initialize native
8
- @native = native
9
- @data = nil
10
- end
11
-
12
- # @return [String] the filename
13
- def name
14
- `#@native.name`
15
- end
16
-
17
- # @return [Integer] the size of this file on disk
18
- def size
19
- `#@native.size`
20
- end
21
-
22
- # @return [String] the MIME type of the file, detected by the browser
23
- def type
24
- `#@native.type`
25
- end
26
-
27
- # @return [Time] the timestamp of the file
28
- def last_modified
29
- `#@native.lastModifiedDate`
30
- end
31
-
32
- # Read the file from disk into memory
33
- #
34
- # @return [Promise] a promise that resolves when finished loading and
35
- # rejects if an error occurs while loading.
36
- def read
37
- promise = Promise.new
38
- reader = FileReader.new
39
- reader.on :load do
40
- result = reader.result
41
-
42
- @data = result
43
- promise.resolve result
44
- end
45
-
46
- reader.on :error do
47
- promise.reject reader.result
48
- end
49
-
50
- reader.read_as_binary_string self
51
-
52
- promise
53
- end
54
-
55
- # Convert to the native object
56
- #
57
- # @return [JS.HTMLElement] the underlying native element
58
- def to_n
59
- @native
60
- end
61
- end
62
- end
@@ -1,47 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- module Browser
4
- class FileList
5
- include Enumerable
6
-
7
- # @param native [JS] the native FileList object to wrap
8
- def initialize native
9
- @native = `#{native} || []`
10
- @files = length.times.each_with_object([]) { |index, array|
11
- array[index] = ::Browser::File.new(`#@native[index]`)
12
- }
13
- end
14
-
15
- # @param index [Integer] the index of the file in the list
16
- # @return [Browser::FileList::File] the file at the specified index
17
- def [] index
18
- @files[index]
19
- end
20
-
21
- # @return [Integer] the number of files in this list
22
- def length
23
- `#@native.length`
24
- end
25
- alias size length
26
-
27
- # Call the given block for each file in the list
28
- #
29
- # @yieldparam file [Browser::FileList::File]
30
- def each &block
31
- @files.each do |file|
32
- block.call file
33
- end
34
- end
35
-
36
- # Convert this FileList into an array
37
- def to_a
38
- @files.dup # Don't return a value that can mutate our internal state
39
- end
40
- alias to_ary to_a
41
-
42
- # @return [String] a string representation of this FileList
43
- def to_s
44
- @files.to_s
45
- end
46
- end
47
- end