proscenium 0.2.1-x86_64-darwin → 0.3.0-x86_64-darwin

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ff3e6f9ef3c0899228d17e682c38689bc9d82fad512b0c5036c2cfda42fe315
4
- data.tar.gz: fbab1b6e960ef567c011accf9ebdd338fe65bebebc1547b44f2cc1604211708f
3
+ metadata.gz: 41451bb7fb99e0c3a26cc8e9e76e9db9da134f027c6178b504eb6241066e4617
4
+ data.tar.gz: 7ed47753820edebfc0f38a95030af31d02ce5b8290cbf5e48febe289a5db71f5
5
5
  SHA512:
6
- metadata.gz: 92619349a36b89440908b4b1e43e5c5dc522c3613675966739eb0bd42d39a7c09c123572b3cb5dd09d03e2a7823c2ecf9fbf1d50530b7d130a8508d2e7c34934
7
- data.tar.gz: a3fbda539dc68995d3bea2652db8c71b78a8ba025b6db7c20a9b58aa9a5397fd711a6c18b3123664023b923d538bdada3cd66af61e53c4aa8215ad4390b3eeea
6
+ metadata.gz: cc0b1bda992c1b2e0e740d7089e0c229bccf65c34b8254a8603cf040337d4ce1353856397c9fef2487fbed7daee5b08d459bed835d20fdc7f469dc9d026e7209
7
+ data.tar.gz: 14024fd83e150ddcd6352a607c7f8696de46595d4db00a5a27928cc2cd4c0a2ce16804fb2ea0e06ada793c3fa42ff7771def88becd9777d2d8a00df76a44f6c3
data/bin/esbuild CHANGED
Binary file
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Proscenium::Phlex::Component < Proscenium::Phlex
4
+ private
5
+
6
+ def virtual_path
7
+ "/#{self.class.name.underscore}"
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Renders a div for use with component-manager.
5
+ #
6
+ class Proscenium::Phlex::ReactComponent < Proscenium::Phlex::Component
7
+ attr_accessor :props, :lazy
8
+
9
+ # @param props: [Hash]
10
+ # @param lazy: [Boolean] Lazy load the component using IntersectionObserver. Default: true.
11
+ def initialize(props: {}, lazy: true) # rubocop:disable Lint/MissingSuper
12
+ @props = props
13
+ @lazy = lazy
14
+ end
15
+
16
+ # @yield the given block to a `div` within the top level component div. If not given,
17
+ # `<div>loading...</div>` will be rendered. Use this to display a loading UI while the component
18
+ # is loading and rendered.
19
+ def template(&block)
20
+ div class: ['componentManagedByProscenium', '@component'],
21
+ data: { component: { path: virtual_path, props: props, lazy: lazy }.to_json } do
22
+ block ? div(&block) : div { 'loading...' }
23
+ end
24
+ end
25
+ end
@@ -1,7 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'phlex'
4
+
3
5
  module Proscenium
4
6
  class Phlex < ::Phlex::View
7
+ extend ActiveSupport::Autoload
8
+
9
+ autoload :Component
10
+ autoload :ReactComponent
11
+
12
+ module Helpers
13
+ def side_load_javascripts(...)
14
+ if (output = @_view_context.side_load_javascripts(...))
15
+ @_target << output
16
+ end
17
+ end
18
+
19
+ %i[side_load_stylesheets proscenium_dev].each do |name|
20
+ define_method name do
21
+ if (output = @_view_context.send(name))
22
+ @_target << output
23
+ end
24
+ end
25
+ end
26
+ end
27
+
5
28
  module Sideload
6
29
  def template(...)
7
30
  Proscenium::SideLoad.append self.class.path if Rails.application.config.proscenium.side_load
@@ -18,6 +41,7 @@ module Proscenium
18
41
  child.path = path.delete_prefix(::Rails.root.to_s).delete_suffix('.rb')[1..]
19
42
 
20
43
  child.prepend Sideload
44
+ child.include Helpers
21
45
 
22
46
  super
23
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ReactComponent < ApplicationComponent
3
+ class Proscenium::ViewComponent::ReactComponent < Proscenium::ViewComponent
4
4
  attr_accessor :props, :lazy
5
5
 
6
6
  # @param props: [Hash]
@@ -15,7 +15,7 @@ class ReactComponent < ApplicationComponent
15
15
  def call
16
16
  tag.div class: ['componentManagedByProscenium', css_module(:component)],
17
17
  data: { component: { path: virtual_path, props: props, lazy: lazy } } do
18
- tag.div content
18
+ tag.div content || 'loading...'
19
19
  end
20
20
  end
21
21
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Proscenium::ViewComponent
3
+ require 'view_component'
4
+
5
+ class Proscenium::ViewComponent < ViewComponent::Base
4
6
  extend ActiveSupport::Autoload
5
7
 
6
8
  autoload :TagBuilder
9
+ autoload :ReactComponent
7
10
 
8
11
  def render_in(...)
9
- cssm.compile_class_names(super)
12
+ cssm.compile_class_names(super(...))
10
13
  end
11
14
 
12
15
  def before_render
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2022-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '3.13'
95
+ - !ruby/object:Gem::Dependency
96
+ name: phlex
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.4.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.4.0
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: railties
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -140,8 +154,6 @@ files:
140
154
  - README.md
141
155
  - app/channels/proscenium/connection.rb
142
156
  - app/channels/proscenium/reload_channel.rb
143
- - app/components/application_component.rb
144
- - app/components/react_component.rb
145
157
  - bin/esbuild
146
158
  - bin/lightningcss
147
159
  - config/routes.rb
@@ -171,6 +183,8 @@ files:
171
183
  - lib/proscenium/middleware/runtime.rb
172
184
  - lib/proscenium/middleware/static.rb
173
185
  - lib/proscenium/phlex.rb
186
+ - lib/proscenium/phlex/component.rb
187
+ - lib/proscenium/phlex/react_component.rb
174
188
  - lib/proscenium/precompile.rb
175
189
  - lib/proscenium/railtie.rb
176
190
  - lib/proscenium/runtime/auto_reload.js
@@ -180,6 +194,7 @@ files:
180
194
  - lib/proscenium/utils.js
181
195
  - lib/proscenium/version.rb
182
196
  - lib/proscenium/view_component.rb
197
+ - lib/proscenium/view_component/react_component.rb
183
198
  - lib/proscenium/view_component/tag_builder.rb
184
199
  - lib/tasks/assets.rake
185
200
  homepage: https://github.com/joelmoss/proscenium
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'view_component'
4
-
5
- class ApplicationComponent < ViewComponent::Base
6
- include Proscenium::ViewComponent
7
- end