Skip to content

Commit 074e69e

Browse files
committed
moved callbacks instance_methods tags and top_level_component
1 parent ba19081 commit 074e69e

File tree

11 files changed

+35
-37
lines changed

11 files changed

+35
-37
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require 'react/component'
1515
#require 'react/component/dsl_instance_methods'
1616
require 'react/component/should_component_update'
17-
require 'react/component/tags'
17+
require 'hyperstack/internal/component/tags'
1818
require 'react/component/base'
1919
require 'react/event'
2020
require 'react/rendering_context'
@@ -25,7 +25,7 @@
2525
require 'reactive-ruby/isomorphic_helpers'
2626
require 'react/top_level'
2727
#require 'react/top_level_render'
28-
require 'rails-helpers/top_level_rails_component'
28+
require 'hyperstack/internal/component/top_level_rails_component'
2929
require 'reactive-ruby/version'
3030
else
3131
require 'opal'

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require 'hyperstack-config'
22

33
module Hyperstack
4-
module Component
5-
module Internal
4+
module Internal
5+
module Component
66
module Callbacks
77
def self.included(base)
88
base.extend(ClassMethods)
@@ -22,7 +22,7 @@ module ClassMethods
2222
def define_callback(callback_name, &after_define_hook)
2323
wrapper_name = "_#{callback_name}_callbacks"
2424
define_singleton_method(wrapper_name) do
25-
Hyperstack::Context.set_var(self, "@#{wrapper_name}", force: true) { [] }
25+
Context.set_var(self, "@#{wrapper_name}", force: true) { [] }
2626
end
2727
define_singleton_method(callback_name) do |*args, &block|
2828
send(wrapper_name).concat(args)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require "react/children"
22

33
module Hyperstack
4-
module Component
5-
module Internal
4+
module Internal
5+
module Component
66
module InstanceMethods
77
def children
8-
Children.new(`#{@native}.props.children`)
8+
Hyperstack::Component::Children.new(`#{@native}.props.children`)
99
end
1010

1111
def params

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Hyperstack
2-
module Component
3-
module Internal # contains the name of all HTML tags, and the mechanism to register a component
2+
module Internal
3+
module Component # contains the name of all HTML tags, and the mechanism to register a component
44
# class as a new tag
55
module Tags
66
HTML_TAGS = %w(a abbr address area article aside audio b base bdi bdo big blockquote body br
@@ -26,7 +26,7 @@ module Tags
2626
HTML_TAGS.each do |tag|
2727

2828
define_method(tag.upcase) do |*params, &children|
29-
RenderingContext.render(tag, *params, &children)
29+
Hyperstack::Component::Internal::RenderingContext.render(tag, *params, &children)
3030
end
3131

3232
const_set tag.upcase, tag
@@ -35,7 +35,7 @@ module Tags
3535
if tag == 'p'
3636
define_method(tag) do |*params, &children|
3737
if children || params.count == 0 || (params.count == 1 && params.first.is_a?(Hash))
38-
RenderingContext.render(tag, *params, &children)
38+
Hyperstack::Component::Internal::RenderingContext.render(tag, *params, &children)
3939
else
4040
Kernel.p(*params)
4141
end
@@ -50,7 +50,7 @@ module Tags
5050
def self.html_tag_class_for(tag)
5151
downcased_tag = tag.downcase
5252
if tag =~ /[A-Z]+/ && HTML_TAGS.include?(downcased_tag)
53-
Object.const_set tag, ReactWrapper.create_element(downcased_tag)
53+
Object.const_set tag, Hyperstack::Component::Internal::ReactWrapper.create_element(downcased_tag)
5454
end
5555
end
5656

@@ -59,7 +59,7 @@ def self.html_tag_class_for(tag)
5959

6060
def method_missing(name, *params, &children)
6161
component = find_component(name)
62-
return RenderingContext.render(component, *params, &children) if component
62+
return Hyperstack::Component::Internal::RenderingContext.render(component, *params, &children) if component
6363
super
6464
end
6565

@@ -71,11 +71,11 @@ def included(component)
7171
name, parent = find_name_and_parent(component)
7272
tag_names_module = Module.new do
7373
define_method name do |*params, &children|
74-
RenderingContext.render(component, *params, &children)
74+
Hyperstack::Component::Internal::RenderingContext.render(component, *params, &children)
7575
end
7676
# handle deprecated _as_node style
7777
define_method "#{name}_as_node" do |*params, &children|
78-
RenderingContext.build_only(component, *params, &children)
78+
Hyperstack::Component::Internal::RenderingContext.build_only(component, *params, &children)
7979
end
8080
end
8181
parent.extend(tag_names_module)
@@ -103,8 +103,6 @@ def find_component(name)
103103

104104
def lookup_const(name)
105105
return nil unless name =~ /^[A-Z]/
106-
#html_tag = React::Component::Tags.html_tag_class(name)
107-
#return html_tag if html_tag
108106
scopes = self.class.name.to_s.split('::').inject([Module]) do |nesting, next_const|
109107
nesting + [nesting.last.const_get(next_const)]
110108
end.reverse

ruby/hyper-component/lib/rails-helpers/top_level_rails_component.rb renamed to ruby/hyper-component/lib/hyperstack/internal/component/top_level_rails_component.rb

File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def self.create_element(type, *args, &block)
167167
params << ncc
168168
elsif type.is_a?(Class)
169169
params << create_native_react_class(type)
170-
elsif block_given? || Tags::HTML_TAGS.include?(type)
170+
elsif block_given? || Hyperstack::Internal::Component::Tags::HTML_TAGS.include?(type)
171171
params << type
172172
elsif type.is_a?(String)
173173
return Element.new(type)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'react/ext/string'
22
require 'react/ext/hash'
33
require 'active_support/core_ext/class/attribute'
4-
require 'react/callbacks'
4+
require 'hyperstack/internal/component/callbacks'
55
require 'react/rendering_context'
66
require 'react/state_wrapper'
7-
require 'react/component/api'
7+
require 'hyperstack/internal/component/instance_methods'
88
require 'react/component/class_methods'
99
require 'react/component/props_wrapper'
1010
module Hyperstack
@@ -30,9 +30,9 @@ def self.force_update!
3030
def self.included(base)
3131
#base.include(Hyperstack::State::Observable)
3232
base.include(Hyperstack::State::Observer)
33-
base.include(Internal::InstanceMethods)
34-
base.include(Internal::Callbacks)
35-
base.include(Internal::Tags)
33+
base.include(Hyperstack::Internal::Component::InstanceMethods)
34+
base.include(Hyperstack::Internal::Component::Callbacks)
35+
base.include(Hyperstack::Internal::Component::Tags)
3636
#base.include(React::Component::DslInstanceMethods)
3737
base.include(Internal::ShouldComponentUpdate)
3838
base.class_eval do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def const_missing(const_name)
99
# so we always call the original, and respond to the exception
1010
_reactrb_tag_original_const_missing(const_name)
1111
rescue StandardError => e
12-
Hyperstack::Component::Internal::Tags.html_tag_class_for(const_name) || raise(e)
12+
Hyperstack::Internal::Component::Tags.html_tag_class_for(const_name) || raise(e)
1313
end
1414
end
1515
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "native"
22
require 'active_support/core_ext/object/try'
3-
require 'react/component/tags'
3+
require 'hyperstack/internal/component/tags'
44
require 'react/component/base'
55

66
module Hyperstack
@@ -28,7 +28,7 @@ module ReactAPI
2828
viewBox x1 x2 x xlinkActuate xlinkArcrole xlinkHref xlinkRole
2929
xlinkShow xlinkTitle xlinkType xmlBase xmlLang xmlSpace y1 y2 y)
3030
HASH_ATTRIBUTES = %w(data aria)
31-
HTML_TAGS = Internal::Tags::HTML_TAGS
31+
HTML_TAGS = Hyperstack::Internal::Component::Tags::HTML_TAGS
3232

3333
def self.html_tag?(name)
3434
tags = HTML_TAGS

ruby/hyper-component/spec/react/builtin_tags_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
describe 'redefining builtin tags', js: true do
44
it "built in tags can be redefined" do
55
mount 'Foo' do
6-
Hyperstack::Component::Internal::Tags.remove_method :DIV
7-
Hyperstack::Component::Internal::Tags.send(:remove_const, :DIV)
6+
Hyperstack::Internal::Component::Tags.remove_method :DIV
7+
Hyperstack::Internal::Component::Tags.send(:remove_const, :DIV)
88

9-
class Hyperstack::Component::Internal::Tags::DIV #< HyperComponent
9+
class Hyperstack::Internal::Component::Tags::DIV #< HyperComponent
1010
include Hyperstack::Component
1111
others :opts
1212
render do

0 commit comments

Comments
 (0)