hyper-component 0.99.6 → 1.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -3
  3. data/Gemfile +4 -3
  4. data/Gemfile.lock +51 -36
  5. data/{misc/how-component-name-lookup-works.md → how-component-name-lookup-works.md} +1 -1
  6. data/hyper-component.gemspec +9 -8
  7. data/lib/hyper-component.rb +31 -43
  8. data/lib/hyperstack/component.rb +145 -0
  9. data/lib/hyperstack/component/auto-import.rb +44 -0
  10. data/lib/hyperstack/component/children.rb +40 -0
  11. data/lib/hyperstack/component/element.rb +129 -0
  12. data/lib/hyperstack/component/event.rb +78 -0
  13. data/lib/hyperstack/component/haml.rb +18 -0
  14. data/lib/hyperstack/component/isomorphic_helpers.rb +235 -0
  15. data/lib/hyperstack/component/jquery.rb +2 -0
  16. data/lib/hyperstack/component/native_library.rb +92 -0
  17. data/lib/hyperstack/component/react_api.rb +142 -0
  18. data/lib/hyperstack/component/server.rb +21 -0
  19. data/lib/hyperstack/component/version.rb +5 -0
  20. data/lib/hyperstack/ext/component/boolean.rb +14 -0
  21. data/lib/{react/ext/opal-jquery → hyperstack/ext/component}/element.rb +17 -12
  22. data/lib/{react/ext → hyperstack/ext/component}/hash.rb +0 -0
  23. data/lib/{react/to_key.rb → hyperstack/ext/component/number.rb} +0 -12
  24. data/lib/hyperstack/ext/component/object.rb +32 -0
  25. data/lib/{reactive-ruby → hyperstack/ext/component}/serializers.rb +0 -0
  26. data/lib/{react/ext → hyperstack/ext/component}/string.rb +0 -0
  27. data/lib/hyperstack/internal/component.rb +16 -0
  28. data/lib/hyperstack/internal/component/class_methods.rb +212 -0
  29. data/lib/hyperstack/internal/component/haml.rb +56 -0
  30. data/lib/hyperstack/internal/component/instance_methods.rb +92 -0
  31. data/lib/hyperstack/internal/component/props_wrapper.rb +125 -0
  32. data/lib/hyperstack/internal/component/rails.rb +11 -0
  33. data/lib/hyperstack/internal/component/rails/component_loader.rb +49 -0
  34. data/lib/hyperstack/internal/component/rails/component_mount.rb +52 -0
  35. data/lib/{reactive-ruby → hyperstack/internal/component}/rails/controller_helper.rb +0 -0
  36. data/lib/hyperstack/internal/component/rails/railtie.rb +24 -0
  37. data/lib/hyperstack/internal/component/rails/server_rendering/contextual_renderer.rb +52 -0
  38. data/lib/hyperstack/internal/component/rails/server_rendering/hyper_asset_container.rb +52 -0
  39. data/lib/hyperstack/internal/component/react_wrapper.rb +308 -0
  40. data/lib/hyperstack/internal/component/rendering_context.rb +165 -0
  41. data/lib/hyperstack/internal/component/should_component_update.rb +101 -0
  42. data/lib/hyperstack/internal/component/tags.rb +109 -0
  43. data/lib/hyperstack/internal/component/top_level_rails_component.rb +83 -0
  44. data/lib/hyperstack/internal/component/validator.rb +149 -0
  45. data/lib/react/react-source.rb +2 -2
  46. data/unmounting-objects.md +78 -0
  47. metadata +73 -85
  48. data/DOCS.md +0 -1515
  49. data/LICENSE +0 -19
  50. data/README.md +0 -49
  51. data/lib/hyper-component/jquery.rb +0 -2
  52. data/lib/rails-helpers/top_level_rails_component.rb +0 -79
  53. data/lib/react/api.rb +0 -272
  54. data/lib/react/callbacks.rb +0 -42
  55. data/lib/react/children.rb +0 -38
  56. data/lib/react/component.rb +0 -189
  57. data/lib/react/component/api.rb +0 -70
  58. data/lib/react/component/base.rb +0 -13
  59. data/lib/react/component/class_methods.rb +0 -175
  60. data/lib/react/component/dsl_instance_methods.rb +0 -23
  61. data/lib/react/component/params.rb +0 -6
  62. data/lib/react/component/props_wrapper.rb +0 -90
  63. data/lib/react/component/should_component_update.rb +0 -99
  64. data/lib/react/component/tags.rb +0 -116
  65. data/lib/react/config.rb +0 -5
  66. data/lib/react/element.rb +0 -167
  67. data/lib/react/event.rb +0 -76
  68. data/lib/react/native_library.rb +0 -87
  69. data/lib/react/object.rb +0 -15
  70. data/lib/react/ref_callback.rb +0 -31
  71. data/lib/react/rendering_context.rb +0 -149
  72. data/lib/react/server.rb +0 -19
  73. data/lib/react/state_wrapper.rb +0 -23
  74. data/lib/react/test.rb +0 -16
  75. data/lib/react/test/dsl.rb +0 -17
  76. data/lib/react/test/matchers/render_html_matcher.rb +0 -56
  77. data/lib/react/test/rspec.rb +0 -15
  78. data/lib/react/test/session.rb +0 -37
  79. data/lib/react/test/utils.rb +0 -71
  80. data/lib/react/top_level.rb +0 -110
  81. data/lib/react/top_level_render.rb +0 -30
  82. data/lib/react/validator.rb +0 -132
  83. data/lib/reactive-ruby/component_loader.rb +0 -43
  84. data/lib/reactive-ruby/isomorphic_helpers.rb +0 -233
  85. data/lib/reactive-ruby/rails.rb +0 -8
  86. data/lib/reactive-ruby/rails/component_mount.rb +0 -48
  87. data/lib/reactive-ruby/rails/railtie.rb +0 -20
  88. data/lib/reactive-ruby/server_rendering/contextual_renderer.rb +0 -46
  89. data/lib/reactive-ruby/server_rendering/hyper_asset_container.rb +0 -46
  90. data/lib/reactive-ruby/version.rb +0 -5
  91. data/lib/reactrb/auto-import.rb +0 -27
  92. data/misc/generators/reactive_ruby/test_app/templates/assets/javascripts/components.rb +0 -3
  93. data/misc/generators/reactive_ruby/test_app/templates/assets/javascripts/server_rendering.js +0 -5
  94. data/misc/generators/reactive_ruby/test_app/templates/assets/javascripts/test_application.rb +0 -2
  95. data/misc/generators/reactive_ruby/test_app/templates/boot.rb.erb +0 -6
  96. data/misc/generators/reactive_ruby/test_app/templates/script/rails +0 -5
  97. data/misc/generators/reactive_ruby/test_app/templates/test_application.rb.erb +0 -13
  98. data/misc/generators/reactive_ruby/test_app/templates/views/components/hello_world.rb +0 -11
  99. data/misc/generators/reactive_ruby/test_app/templates/views/components/todo.rb +0 -14
  100. data/misc/generators/reactive_ruby/test_app/templates/views/layouts/test_layout.html.erb +0 -0
  101. data/misc/generators/reactive_ruby/test_app/test_app_generator.rb +0 -121
  102. data/misc/hyperloop-logo-small-pink.png +0 -0
  103. data/misc/logo1.png +0 -0
  104. data/misc/logo2.png +0 -0
  105. data/misc/logo3.png +0 -0
  106. data/path_release_steps.md +0 -9
@@ -1,8 +0,0 @@
1
- require 'action_view'
2
- require 'react-rails'
3
- require 'reactive-ruby/server_rendering/hyper_asset_container'
4
- require 'reactive-ruby/server_rendering/contextual_renderer'
5
- require 'reactive-ruby/rails/component_mount'
6
- require 'reactive-ruby/rails/railtie'
7
- require 'reactive-ruby/rails/controller_helper'
8
- require 'reactive-ruby/component_loader'
@@ -1,48 +0,0 @@
1
- module ReactiveRuby
2
- module Rails
3
- class ComponentMount < React::Rails::ComponentMount
4
- attr_accessor :controller
5
-
6
- def setup(controller)
7
- self.controller = controller
8
- end
9
-
10
- def react_component(name, props = {}, options = {}, &block)
11
- if options[:prerender] || [:on, 'on', true].include?(Hyperloop.prerendering)
12
- options = context_initializer_options(options, name)
13
- end
14
- props = serialized_props(props, name, controller)
15
- result = super(top_level_name, props, options, &block).gsub("\n","")
16
- result = result.gsub(/(<script.*<\/script>)<\/div>$/,'</div>\1').html_safe
17
- result + footers
18
- end
19
-
20
- private
21
-
22
- def context_initializer_options(options, name)
23
- options[:prerender] = {options[:prerender] => true} unless options[:prerender].is_a? Hash
24
- existing_context_initializer = options[:prerender][:context_initializer]
25
-
26
- options[:prerender][:context_initializer] = lambda do |ctx|
27
- React::IsomorphicHelpers.load_context(ctx, controller, name)
28
- existing_context_initializer.call(ctx) if existing_context_initializer
29
- end
30
-
31
- options
32
- end
33
-
34
- def serialized_props(props, name, controller)
35
- { render_params: props, component_name: name,
36
- controller: controller.class.name.gsub(/Controller$/,"") }.react_serializer
37
- end
38
-
39
- def top_level_name
40
- 'React.TopLevelRailsComponent'
41
- end
42
-
43
- def footers
44
- React::IsomorphicHelpers.prerender_footers(controller)
45
- end
46
- end
47
- end
48
- end
@@ -1,20 +0,0 @@
1
- module ReactiveRuby
2
- module Rails
3
- class Railtie < ::Rails::Railtie
4
- config.before_configuration do |app|
5
- app.config.assets.enabled = true
6
- app.config.assets.paths << ::Rails.root.join('app', 'views').to_s
7
- app.config.react.server_renderer = ReactiveRuby::ServerRendering::ContextualRenderer
8
- app.config.react.view_helper_implementation = ReactiveRuby::Rails::ComponentMount
9
- ReactiveRuby::ServerRendering::ContextualRenderer.asset_container_class = ReactiveRuby::ServerRendering::HyperAssetContainer
10
- end
11
- config.after_initialize do
12
- class ::HyperloopController < ::ApplicationController
13
- def action_missing(name)
14
- render_component
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,46 +0,0 @@
1
- module ReactiveRuby
2
- module ServerRendering
3
- def self.context_instance_name
4
- '@context'
5
- end
6
-
7
- def self.context_instance_for(context)
8
- context.instance_variable_get(context_instance_name)
9
- end
10
-
11
- class ContextualRenderer < React::ServerRendering::BundleRenderer
12
- def initialize(options = {})
13
- super(options)
14
- ComponentLoader.new(v8_context).load
15
- end
16
-
17
- def before_render(*args)
18
- # the base class clears the log history... we don't want that as it is taken
19
- # care of in IsomorphicHelpers.load_context
20
- end
21
-
22
- def render(component_name, props, prerender_options)
23
- if prerender_options.is_a?(Hash)
24
- if !v8_runtime? && prerender_options[:context_initializer]
25
- raise React::ServerRendering::PrerenderError.new(component_name, props, "you must use 'mini_racer' with the prerender[:context] option") unless v8_runtime?
26
- else
27
- prerender_options[:context_initializer].call v8_context
28
- prerender_options = prerender_options[:static] ? :static : true
29
- end
30
- end
31
-
32
- super(component_name, props, prerender_options)
33
- end
34
-
35
- private
36
-
37
- def v8_runtime?
38
- ExecJS.runtime.name == 'mini_racer (V8)'
39
- end
40
-
41
- def v8_context
42
- @v8_context ||= ReactiveRuby::ServerRendering.context_instance_for(@context)
43
- end
44
- end
45
- end
46
- end
@@ -1,46 +0,0 @@
1
- require 'react/server_rendering/environment_container'
2
- require 'react/server_rendering/manifest_container'
3
- require 'react/server_rendering/webpacker_manifest_container'
4
-
5
- module ReactiveRuby
6
- module ServerRendering
7
- class HyperTestAssetContainer
8
- def find_asset(logical_path)
9
- ::Rails.cache.read(logical_path)
10
- end
11
- end
12
-
13
- class HyperAssetContainer
14
- def initialize
15
- @ass_containers = []
16
- if assets_precompiled?
17
- @ass_containers << React::ServerRendering::ManifestContainer.new if React::ServerRendering::ManifestContainer.compatible?
18
- else
19
- @ass_containers << React::ServerRendering::EnvironmentContainer.new if ::Rails.application.assets
20
- end
21
- if React::ServerRendering::WebpackerManifestContainer.compatible?
22
- @ass_containers << React::ServerRendering::WebpackerManifestContainer.new
23
- end
24
- @ass_containers << HyperTestAssetContainer.new if ::Rails.env.test?
25
- end
26
-
27
- def find_asset(logical_path)
28
- @ass_containers.each do |ass|
29
- begin
30
- asset = ass.find_asset(logical_path)
31
- return asset if asset && asset != ''
32
- rescue
33
- next # no asset found, try the next container
34
- end
35
- end
36
- raise "No asset found for #{logical_path}, tried: #{@ass_containers.map { |c| c.class.name }.join(', ')}"
37
- end
38
-
39
- private
40
-
41
- def assets_precompiled?
42
- !::Rails.application.config.assets.compile
43
- end
44
- end
45
- end
46
- end
@@ -1,5 +0,0 @@
1
- module Hyperloop
2
- class Component
3
- VERSION = '0.99.6'
4
- end
5
- end
@@ -1,27 +0,0 @@
1
- # rubocop:disable Style/FileName
2
- # require 'reactrb/auto-import' to automatically
3
- # import JS libraries and components when they are detected
4
- if RUBY_ENGINE == 'opal'
5
- # modifies const and method_missing so that they will attempt
6
- # to auto import native libraries and components using React::NativeLibrary
7
- class Object
8
- class << self
9
- alias _reactrb_original_const_missing const_missing
10
- alias _reactrb_original_method_missing method_missing
11
-
12
- def const_missing(const_name)
13
- # Opal uses const_missing to initially define things,
14
- # so we always call the original, and respond to the exception
15
- _reactrb_original_const_missing(const_name)
16
- rescue StandardError => e
17
- React::NativeLibrary.import_const_from_native(Object, const_name, true) || raise(e)
18
- end
19
-
20
- def method_missing(method, *args, &block)
21
- component_class = React::NativeLibrary.import_const_from_native(self, method, false)
22
- _reactrb_original_method_missing(method, *args, &block) unless component_class
23
- React::RenderingContext.render(component_class, *args, &block)
24
- end
25
- end
26
- end
27
- end
@@ -1,3 +0,0 @@
1
- require 'opal'
2
- require 'hyper-react'
3
- require_tree './components'
@@ -1,5 +0,0 @@
1
- //= require 'react-server'
2
- //= require 'react_ujs'
3
- //= require 'components'
4
-
5
- Opal.load('components')
@@ -1,2 +0,0 @@
1
- require 'components'
2
- require 'react_ujs'
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path("<%= gemfile_path %>", __FILE__)
3
-
4
- ENV['BUNDLE_GEMFILE'] = gemfile
5
- require 'bundler'
6
- Bundler.setup
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- APP_PATH = File.expand_path('../../config/application', __FILE__)
4
- require File.expand_path('../../config/boot', __FILE__)
5
- require 'rails/commands'
@@ -1,13 +0,0 @@
1
- <% if defined? application_definition %>
2
- require 'rails/all'
3
- require File.expand_path('../boot', __FILE__)
4
-
5
- # Require the gems listed in Gemfile, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(*Rails.groups(assets: %w(development test)))
8
-
9
- require 'opal-rails'
10
- require 'hyper-react'
11
-
12
- <%= application_definition %>
13
- <% end %>
@@ -1,11 +0,0 @@
1
- module Components
2
- class HelloWorld
3
- include React::Component
4
-
5
- def render
6
- div do
7
- "Hello, World!".span
8
- end
9
- end
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- module Components
2
- class Todo
3
- include React::Component
4
- export_component
5
-
6
- params do
7
- requires :todo
8
- end
9
-
10
- def render
11
- li { "#{params[:todo]}" }
12
- end
13
- end
14
- end
@@ -1,121 +0,0 @@
1
- # Although we are not using this it would be good to move back to this model in future.
2
- # For one thing it would be a good way to test the hyperloop/Hyperloop rails installer
3
- # so for now keep these files here as a template
4
-
5
- require 'rails/generators/rails/app/app_generator'
6
-
7
- module ReactiveRuby
8
- class TestAppGenerator < ::Rails::Generators::Base
9
- def self.source_paths
10
- paths = self.superclass.source_paths
11
- paths << File.expand_path('../templates', __FILE__)
12
- paths.flatten
13
- end
14
-
15
- def remove_existing_app
16
- remove_dir(test_app_path) if File.directory?(test_app_path)
17
- end
18
-
19
- def generate_test_app
20
- opts = options.dup
21
- opts[:database] = 'sqlite3' if opts[:database].blank?
22
- opts[:force] = true
23
- opts[:skip_bundle] = true
24
-
25
- puts "Generating Test Rails Application..."
26
- invoke ::Rails::Generators::AppGenerator,
27
- [ File.expand_path(test_app_path, destination_root) ], opts
28
- end
29
-
30
- def configure_test_app
31
- template 'boot.rb.erb', "#{test_app_path}/config/boot.rb", force: true
32
- template 'test_application.rb.erb', "#{test_app_path}/config/application.rb", force: true
33
- template 'assets/javascripts/test_application.rb',
34
- "#{test_app_path}/app/assets/javascripts/application.rb", force: true
35
- template 'assets/javascripts/server_rendering.js',
36
- "#{test_app_path}/app/assets/javascripts/server_rendering.js", force: true
37
- template 'assets/javascripts/components.rb',
38
- "#{test_app_path}/app/views/components.rb", force: true
39
- template 'views/components/hello_world.rb',
40
- "#{test_app_path}/app/views/components/hello_world.rb", force: true
41
- template 'views/components/todo.rb',
42
- "#{test_app_path}/app/views/components/todo.rb", force: true
43
- template 'views/layouts/test_layout.html.erb',
44
- "#{test_app_path}/app/views/layouts/test_layout.html.erb", force: true
45
- template 'views/layouts/test_layout.html.erb',
46
- "#{test_app_path}/app/views/layouts/explicit_layout.html.erb", force: true
47
- end
48
-
49
- def clean_superfluous_files
50
- inside test_app_path do
51
- remove_file '.gitignore'
52
- remove_file 'doc'
53
- remove_file 'Gemfile'
54
- remove_file 'lib/tasks'
55
- remove_file 'app/assets/images/rails.png'
56
- remove_file 'app/assets/javascripts/application.js'
57
- remove_file 'public/index.html'
58
- remove_file 'public/robots.txt'
59
- remove_file 'README.rdoc'
60
- remove_file 'test'
61
- remove_file 'vendor'
62
- remove_file 'spec'
63
- end
64
- end
65
-
66
- def configure_opal_rspec
67
- inject_into_file "#{test_app_path}/config/application.rb",
68
- after: /class Application < Rails::Application/, verbose: true do
69
- %Q[
70
- config.opal.method_missing = true
71
- config.opal.optimized_operators = true
72
- config.opal.arity_check = false
73
- config.opal.const_missing = true
74
- config.opal.dynamic_require_severity = :ignore
75
- config.opal.enable_specs = true
76
- config.opal.spec_location = 'spec-opal'
77
- config.hyperloop.auto_config = false
78
-
79
- config.react.server_renderer_options = {
80
- files: ["server_rendering.js"]
81
- }
82
- config.react.server_renderer_directories = ["/app/assets/javascripts"]
83
- ]
84
- end
85
- end
86
-
87
- protected
88
-
89
- def application_definition
90
- @application_definition ||= begin
91
- test_application_contents
92
- end
93
- end
94
- alias :store_application_definition! :application_definition
95
-
96
- private
97
-
98
- def test_app_path
99
- 'spec/test_app'
100
- end
101
-
102
- def test_application_path
103
- File.expand_path("#{test_app_path}/config/application.rb",
104
- destination_root)
105
- end
106
-
107
- def test_application_contents
108
- return unless File.exists?(test_application_path) && !options[:pretend]
109
- contents = File.read(test_application_path)
110
- contents[(contents.index("module #{module_name}"))..-1]
111
- end
112
-
113
- def module_name
114
- 'TestApp'
115
- end
116
-
117
- def gemfile_path
118
- '../../../../Gemfile'
119
- end
120
- end
121
- end
Binary file
Binary file
Binary file
@@ -1,9 +0,0 @@
1
-
2
- For example assuming you are releasing fix to 0.8.18
3
-
4
- 1. Checkout 0-8-stable
5
- 2. Update tests, fix the bug and commit the changes.
6
- 3. Build & Release to RubyGems (Remember the version in version.rb should already be 0.8.19)
7
- 4. Create a tag 'v0.8.19' pointing to that commit.
8
- 5. Bump the version in 0-8-stable to 0.8.20 so it will be ready for the next patch level release.
9
- 6. Commit the version bump, and do a `git push --tags` so the new tag goes up