Skip to content

Commit 0ee79ea

Browse files
committed
moved component config event native_library object server state_wrapper to_key top_level and validator
1 parent 6e9723d commit 0ee79ea

File tree

20 files changed

+60
-75
lines changed

20 files changed

+60
-75
lines changed

ruby/hyper-component/lib/hyper-component.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
require 'hyperstack-config'
1+
require 'hyperstack/internal/component'
2+
23
Hyperstack.import 'hyper-state'
34
Hyperstack.js_import 'react/react-source-browser', client_only: true, defines: %w[ReactDOM React]
45
Hyperstack.js_import 'react/react-source-server', server_only: true, defines: 'React'
56
Hyperstack.import 'browser/delay', client_only: true
67
Hyperstack.js_import 'react_ujs', defines: 'ReactRailsUJS'
78
Hyperstack.import 'hyper-component' # TODO: confirm this does not break anything. Added while converting hyperloop->hyperstack
9+
810
if RUBY_ENGINE == 'opal'
911
require 'native'
1012
require 'hyperstack/state/observer'
11-
require 'react/validator'
13+
require 'hyperstack/internal/component/validator'
1214
require 'react/element'
1315
require 'hyperstack/internal/component/react_wrapper'
14-
require 'react/component'
15-
#require 'react/component/dsl_instance_methods'
16+
require 'hyperstack/component'
1617
require 'hyperstack/internal/component/should_component_update'
1718
require 'hyperstack/internal/component/tags'
18-
require 'react/event'
19+
require 'hyperstack/component/event'
1920
require 'react/rendering_context'
20-
#require 'react/state'
21-
require 'react/object'
22-
require 'react/to_key'
21+
require 'hyperstack/ext/component/object'
22+
require 'hyperstack/ext/component/number'
23+
require 'hyperstack/ext/component/boolean'
2324
require 'reactive-ruby/isomorphic_helpers'
24-
require 'react/top_level'
25-
#require 'react/top_level_render'
25+
require 'hyperstack/component/react_api'
2626
require 'hyperstack/internal/component/top_level_rails_component'
2727
require 'reactive-ruby/version'
2828
else

ruby/hyper-component/lib/react/component.rb renamed to ruby/hyper-component/lib/hyperstack/component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
require 'active_support/core_ext/class/attribute'
44
require 'hyperstack/internal/component/callbacks'
55
require 'react/rendering_context'
6-
require 'react/state_wrapper'
76
require 'hyperstack/internal/component'
87
require 'hyperstack/internal/component/instance_methods'
98
require 'hyperstack/internal/component/class_methods'
109
require 'hyperstack/internal/component/props_wrapper'
1110
module Hyperstack
11+
1212
module Component
1313

1414
def self.included(base)
File renamed without changes.

ruby/hyper-component/lib/react/native_library.rb renamed to ruby/hyper-component/lib/hyperstack/component/native_library.rb

File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# to_key method returns a suitable unique id that can be used as
2+
# a react `key`. Other classes may override to_key as needed
3+
# for example hyper_mesh returns the object id of the internal
4+
# backing record.
5+
#
6+
# to_key is automatically called on objects passed as keys for
7+
# example Foo(key: my_object) results in Foo(key: my_object.to_key)
8+
9+
# for Boolean to_key can be true or false
10+
class Boolean
11+
def to_key
12+
self
13+
end
14+
end

ruby/hyper-component/lib/react/to_key.rb renamed to ruby/hyper-component/lib/hyperstack/ext/component/number.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,10 @@
55
#
66
# to_key is automatically called on objects passed as keys for
77
# example Foo(key: my_object) results in Foo(key: my_object.to_key)
8-
class Object
9-
def to_key
10-
object_id
11-
end
12-
end
138

149
# for Number to_key can just be the number itself
1510
class Number
1611
def to_key
1712
self
1813
end
1914
end
20-
21-
# for Boolean to_key can be true or false
22-
class Boolean
23-
def to_key
24-
self
25-
end
26-
end

ruby/hyper-component/lib/react/object.rb renamed to ruby/hyper-component/lib/hyperstack/ext/component/object.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ def const_missing(const_name)
1212
Hyperstack::Internal::Component::Tags.html_tag_class_for(const_name) || raise(e)
1313
end
1414
end
15+
# to_key method returns a suitable unique id that can be used as
16+
# a react `key`. Other classes may override to_key as needed
17+
# for example hyper_mesh returns the object id of the internal
18+
# backing record.
19+
#
20+
# to_key is automatically called on objects passed as keys for
21+
# example Foo(key: my_object) results in Foo(key: my_object.to_key)
22+
def to_key
23+
object_id
24+
end
1525
end

ruby/hyper-component/lib/hyperstack/internal/component.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
require 'hyperstack-config'
2+
13
module Hyperstack
4+
5+
define_setting :prerendering, :off if RUBY_ENGINE != 'opal'
6+
27
module Internal
38
module Component
49
class << self

0 commit comments

Comments
 (0)