isomorfeus-react 16.9.24 → 16.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. metadata +3 -85
  3. data/README.md +0 -64
  4. data/lib/browser/delegate_native.rb +0 -70
  5. data/lib/browser/element.rb +0 -176
  6. data/lib/browser/element/canvas.rb +0 -17
  7. data/lib/browser/element/media.rb +0 -78
  8. data/lib/browser/event.rb +0 -92
  9. data/lib/browser/event_target.rb +0 -39
  10. data/lib/browser/file_list.rb +0 -125
  11. data/lib/browser/iterable.rb +0 -15
  12. data/lib/isomorfeus-react-material-ui.rb +0 -10
  13. data/lib/isomorfeus-react.rb +0 -145
  14. data/lib/isomorfeus/config.rb +0 -130
  15. data/lib/isomorfeus/props/validate_hash_proxy.rb +0 -178
  16. data/lib/isomorfeus/props/validator.rb +0 -131
  17. data/lib/isomorfeus/react_view_helper.rb +0 -130
  18. data/lib/isomorfeus/top_level.rb +0 -86
  19. data/lib/isomorfeus/top_level_ssr.rb +0 -28
  20. data/lib/lucid_app/api.rb +0 -30
  21. data/lib/lucid_app/base.rb +0 -7
  22. data/lib/lucid_app/context.rb +0 -7
  23. data/lib/lucid_app/mixin.rb +0 -20
  24. data/lib/lucid_app/native_component_constructor.rb +0 -105
  25. data/lib/lucid_component/app_store_defaults.rb +0 -36
  26. data/lib/lucid_component/app_store_proxy.rb +0 -38
  27. data/lib/lucid_component/base.rb +0 -7
  28. data/lib/lucid_component/class_store_proxy.rb +0 -41
  29. data/lib/lucid_component/component_class_store_defaults.rb +0 -38
  30. data/lib/lucid_component/component_instance_store_defaults.rb +0 -35
  31. data/lib/lucid_component/event_handler.rb +0 -17
  32. data/lib/lucid_component/initializer.rb +0 -12
  33. data/lib/lucid_component/instance_store_proxy.rb +0 -45
  34. data/lib/lucid_component/mixin.rb +0 -18
  35. data/lib/lucid_component/native_component_constructor.rb +0 -116
  36. data/lib/lucid_component/reducers.rb +0 -48
  37. data/lib/lucid_component/store_api.rb +0 -38
  38. data/lib/lucid_component/styles_support.rb +0 -37
  39. data/lib/lucid_material/app/base.rb +0 -9
  40. data/lib/lucid_material/app/mixin.rb +0 -22
  41. data/lib/lucid_material/app/native_component_constructor.rb +0 -107
  42. data/lib/lucid_material/component/base.rb +0 -9
  43. data/lib/lucid_material/component/mixin.rb +0 -20
  44. data/lib/lucid_material/component/native_component_constructor.rb +0 -118
  45. data/lib/lucid_prop_declaration/mixin.rb +0 -91
  46. data/lib/react.rb +0 -195
  47. data/lib/react/active_support_support.rb +0 -13
  48. data/lib/react/children.rb +0 -35
  49. data/lib/react/component/api.rb +0 -80
  50. data/lib/react/component/base.rb +0 -9
  51. data/lib/react/component/callbacks.rb +0 -106
  52. data/lib/react/component/elements.rb +0 -60
  53. data/lib/react/component/event_handler.rb +0 -19
  54. data/lib/react/component/features.rb +0 -47
  55. data/lib/react/component/history.rb +0 -36
  56. data/lib/react/component/initializer.rb +0 -11
  57. data/lib/react/component/location.rb +0 -15
  58. data/lib/react/component/match.rb +0 -31
  59. data/lib/react/component/mixin.rb +0 -19
  60. data/lib/react/component/native_component_constructor.rb +0 -93
  61. data/lib/react/component/props.rb +0 -59
  62. data/lib/react/component/resolution.rb +0 -70
  63. data/lib/react/component/should_component_update.rb +0 -14
  64. data/lib/react/component/state.rb +0 -52
  65. data/lib/react/component/styles.rb +0 -27
  66. data/lib/react/component/unsafe_api.rb +0 -33
  67. data/lib/react/context_wrapper.rb +0 -46
  68. data/lib/react/function_component/api.rb +0 -63
  69. data/lib/react/function_component/base.rb +0 -9
  70. data/lib/react/function_component/creator.rb +0 -32
  71. data/lib/react/function_component/event_handler.rb +0 -13
  72. data/lib/react/function_component/mixin.rb +0 -14
  73. data/lib/react/function_component/resolution.rb +0 -62
  74. data/lib/react/memo_component/base.rb +0 -9
  75. data/lib/react/memo_component/creator.rb +0 -32
  76. data/lib/react/memo_component/mixin.rb +0 -14
  77. data/lib/react/native_constant_wrapper.rb +0 -26
  78. data/lib/react/pure_component/base.rb +0 -9
  79. data/lib/react/pure_component/mixin.rb +0 -18
  80. data/lib/react/ref.rb +0 -13
  81. data/lib/react/synthetic_event.rb +0 -53
  82. data/lib/react/version.rb +0 -3
  83. data/lib/react_dom.rb +0 -47
  84. data/lib/react_dom_server.rb +0 -19
@@ -1,78 +0,0 @@
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,92 +0,0 @@
1
- module Browser
2
- # Wrapper for JS events
3
- class Event
4
- # @param [JS] the native event to wrap
5
- def initialize native
6
- @native = native
7
- end
8
-
9
- # Prevent the runtime from executing this event's default behavior. For
10
- # example, prevent navigation after clicking a link.
11
- #
12
- # @return [Browser::Event] self
13
- def prevent
14
- `#@native.preventDefault()`
15
- self
16
- end
17
-
18
- # Prevent the runtime from bubbling this event up the hierarchy. This is
19
- # typically used to keep an event local to the element on which it was
20
- # triggered, such as keeping a click event on a button from unintentionally
21
- # triggering a handler on a parent element.
22
- #
23
- # @return self
24
- def stop_propagation
25
- `#@native.stopPropagation()`
26
- self
27
- end
28
-
29
- # @return [Boolean] true if `prevent` has been called on this event, false
30
- # otherwise
31
- def prevented?
32
- `#@native.defaultPrevented`
33
- end
34
-
35
- # @return [Boolean] true if the Meta/Command/Windows key was pressed when
36
- # this event fired, false otherwise
37
- def meta?
38
- `#@native.metaKey`
39
- end
40
-
41
- # @return [Boolean] true if the Shift key was pressed when this event fired,
42
- # false otherwise
43
- def shift?
44
- `#@native.shiftKey`
45
- end
46
-
47
- # @return [Boolean] true if the Ctrl key was pressed when this event fired,
48
- # false otherwise
49
- def ctrl?
50
- `#@native.ctrlKey`
51
- end
52
-
53
- # @return [Boolean] true if the Alt key was pressed when this event fired,
54
- # false otherwise
55
- def alt?
56
- `#@native.altKey`
57
- end
58
-
59
- # The target for this event
60
- #
61
- # @return [Browser::Element] the element on which this event was triggered
62
- # @todo Handle non-DOM events here
63
- def target
64
- Element.new(`#@native.target`)
65
- end
66
-
67
- # @return [Numeric] the key code associated with this event. Only useful for
68
- # keyboard-based events.
69
- def code
70
- `#@native.keyCode`
71
- end
72
-
73
- # Return properties on the event not covered by Ruby methods.
74
- def method_missing name, *args
75
- property = name.gsub(/_[a-z]/) { |match| match[-1, 1].upcase }
76
- value = `#@native[property]`
77
-
78
- if `!!value && #{Proc === value}`
79
- value.call(*args)
80
- elsif `value == null`
81
- nil
82
- else
83
- value
84
- end
85
- end
86
-
87
- # @return [JS] the native event wrapped by this object.
88
- def to_n
89
- @native
90
- end
91
- end
92
- end
@@ -1,39 +0,0 @@
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,125 +0,0 @@
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,15 +0,0 @@
1
- module Browser
2
- class Iterable
3
- include Enumerable
4
-
5
- def initialize js_iterable
6
- @js_iterable = js_iterable
7
- end
8
-
9
- def each
10
- `#@js_iterable.length`.times do |i|
11
- yield `#@js_iterable[i]`
12
- end
13
- end
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- require 'isomorfeus-react'
2
-
3
- # LucidMaterial::Component
4
- require 'lucid_material/component/native_component_constructor'
5
- require 'lucid_material/component/mixin'
6
- require 'lucid_material/component/base'
7
- # LucidMaterial::App
8
- require 'lucid_material/app/native_component_constructor'
9
- require 'lucid_material/app/mixin'
10
- require 'lucid_material/app/base'
@@ -1,145 +0,0 @@
1
- if RUBY_ENGINE == 'opal'
2
- require 'opal'
3
- require 'opal-autoloader'
4
- require 'native'
5
- require 'promise'
6
- require 'active_support/core_ext/string'
7
- require 'react/active_support_support'
8
- require 'isomorfeus-redux'
9
-
10
- if Isomorfeus.on_browser?
11
- require 'browser/event'
12
- require 'browser/event_target'
13
- require 'browser/delegate_native'
14
- require 'browser/element'
15
- end
16
-
17
- require 'isomorfeus/config'
18
-
19
- # allow mounting of components
20
- if Isomorfeus.on_browser?
21
- require 'isomorfeus/top_level'
22
- else
23
- require 'isomorfeus/top_level_ssr'
24
- end
25
-
26
- # react
27
- require 'react/version'
28
- require 'react'
29
- require 'react/synthetic_event'
30
- require 'react/ref'
31
- require 'react/children'
32
- if Isomorfeus.on_browser?
33
- require 'react_dom'
34
- else
35
- require 'react_dom_server'
36
- end
37
-
38
- # props
39
- require 'isomorfeus/props/validate_hash_proxy'
40
- require 'isomorfeus/props/validator'
41
- require 'lucid_prop_declaration/mixin'
42
- require 'react/component/props'
43
-
44
- # HTML Elements support
45
- require 'react/component/elements'
46
-
47
- # React Features
48
- require 'react/component/features'
49
- require 'react/context_wrapper'
50
- require 'react/native_constant_wrapper'
51
-
52
- # Function Component
53
- require 'react/function_component/resolution'
54
- require 'react/function_component/api'
55
- require 'react/function_component/event_handler'
56
- require 'react/function_component/creator'
57
- require 'react/function_component/mixin'
58
- require 'react/function_component/base'
59
- require 'react/memo_component/creator'
60
- require 'react/memo_component/mixin'
61
- require 'react/memo_component/base'
62
-
63
- # React::Component
64
- require 'react/component/api'
65
- require 'react/component/callbacks'
66
- # require 'react/component/unsafe_api'
67
- require 'react/component/initializer'
68
- require 'react/component/native_component_constructor'
69
- require 'react/component/state'
70
- require 'react/component/match'
71
- require 'react/component/location'
72
- require 'react/component/history'
73
- require 'react/component/resolution'
74
- require 'react/component/should_component_update'
75
- require 'react/component/event_handler'
76
- require 'react/component/styles'
77
- require 'react/component/mixin'
78
- require 'react/component/base'
79
-
80
- # React::PureComponent
81
- require 'react/pure_component/mixin'
82
- require 'react/pure_component/base'
83
-
84
- # init component reducers
85
- require 'lucid_component/reducers'
86
- LucidComponent::Reducers.add_component_reducers_to_store
87
-
88
- # init LucidApplicationContext (Store Provider and Consumer)
89
- require 'lucid_app/context'
90
- LucidApp::Context.create_application_context
91
-
92
- # LucidComponent
93
- require 'lucid_component/styles_support'
94
- require 'lucid_component/store_api'
95
- require 'lucid_component/app_store_defaults'
96
- require 'lucid_component/component_class_store_defaults'
97
- require 'lucid_component/component_instance_store_defaults'
98
- require 'lucid_component/app_store_proxy'
99
- require 'lucid_component/class_store_proxy'
100
- require 'lucid_component/instance_store_proxy'
101
- require 'lucid_component/initializer'
102
- require 'lucid_component/native_component_constructor'
103
- require 'lucid_component/event_handler'
104
- require 'lucid_component/mixin'
105
- require 'lucid_component/base'
106
-
107
- # LucidApp
108
- require 'lucid_app/api'
109
- require 'lucid_app/native_component_constructor'
110
- require 'lucid_app/mixin'
111
- require 'lucid_app/base'
112
-
113
- Opal::Autoloader.add_load_path('components')
114
- else
115
- require 'oj'
116
- require 'opal'
117
- require 'opal-activesupport'
118
- require 'opal-autoloader'
119
- require 'isomorfeus-redux'
120
- require 'isomorfeus-speednode'
121
- require 'react/version'
122
- require 'isomorfeus/config'
123
-
124
- # props
125
- require 'isomorfeus/props/validate_hash_proxy'
126
- require 'isomorfeus/props/validator'
127
- require 'lucid_prop_declaration/mixin'
128
-
129
- Isomorfeus.env = ENV['RACK_ENV']
130
-
131
- if Isomorfeus.production?
132
- Isomorfeus.server_side_rendering = true
133
- else
134
- Isomorfeus.server_side_rendering = false
135
- end
136
-
137
- require 'isomorfeus/execution_environment'
138
- require 'isomorfeus/react_view_helper'
139
-
140
- Opal.append_path(__dir__.untaint)
141
-
142
- if Dir.exist?('isomorfeus')
143
- Opal.append_path(File.expand_path('isomorfeus')) unless Opal.paths.include?(File.expand_path('isomorfeus'))
144
- end
145
- end