proscenium 0.2.1-x86_64-linux → 0.4.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3865fbb2c2e0c606febd498305b5c547f4ed96ff271012f0a0a0069f7178bed0
4
- data.tar.gz: 4961bfa53fb5f2e495e7b5d60903fc9898cf61f9c6ac4b7fe1d33fd6e7c028d6
3
+ metadata.gz: 58f737e5fa0b80684f7a5ddedf5cc9289dc7be0f434b19a0e896a3edd841bf08
4
+ data.tar.gz: 31953469f20839292f307548bb9e74deb77330cc36c14fd525a1abbaf49f25ad
5
5
  SHA512:
6
- metadata.gz: c270f788bc4f61af038d19ce5250f70bbd3684061cfb2d865a5522c148ca78e713c47506c1813a73e72e11cd37f9c30d471bb04f617bbda14b7d26ded41b1b40
7
- data.tar.gz: 894ff8cc3f247356d8cf1983fda1dba591d33fb309aaedc765d30445a2d9eba97608f656c9e4c5fb72c12c81da088e7dd15d2f55685128bdd1cda9966156b80c
6
+ metadata.gz: f1ae53eb9ebfa8b03f16b35b2b202097e4fa5630ccbc1f2224265b67b5a3c1b452105f2fc5c2220e7644fefb23283f0d616f67a77c617a2adf36a74ba0bd546c
7
+ data.tar.gz: 6bfa5721620e454ab12f0c4f41ad431f2b8d71dc7b3573ca462e1c7c7cc91e7694f3eb758299065da79859fa028d2948f927f8501d635407de79e348432584ab
data/bin/esbuild CHANGED
Binary file
@@ -1,10 +1,13 @@
1
1
  import setup from './setup_plugin.js'
2
2
 
3
+ // Export environment variables as named exports only. You can also import from `env:ENV_VAR_NAME`,
4
+ // which will return the value of the environment variable as the default export. This allows you to
5
+ // safely import a variable regardless of its existence.
3
6
  export default setup('env', () => {
4
7
  return [
5
8
  {
6
9
  type: 'onResolve',
7
- filter: /^env$/,
10
+ filter: /^env(:.+)?$/,
8
11
  callback({ path }) {
9
12
  return { path, namespace: 'env' }
10
13
  }
@@ -14,9 +17,27 @@ export default setup('env', () => {
14
17
  type: 'onLoad',
15
18
  filter: /.*/,
16
19
  namespace: 'env',
17
- callback() {
20
+ callback({ path }) {
21
+ if (path.includes(':')) {
22
+ return {
23
+ loader: 'js',
24
+ contents: `export default ${Deno.env.get(path.split(':')[1])}`
25
+ }
26
+ }
27
+
18
28
  const env = Deno.env.toObject()
19
- return { loader: 'json', contents: JSON.stringify(env) }
29
+ const contents = []
30
+
31
+ for (const key in env) {
32
+ if (Object.hasOwnProperty.call(env, key)) {
33
+ contents.push(`export const ${key} = '${env[key]}'`)
34
+ }
35
+ }
36
+
37
+ return {
38
+ loader: 'js',
39
+ contents: contents.join(';')
40
+ }
20
41
  }
21
42
  }
22
43
  ]
@@ -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.4.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.4.0
5
5
  platform: x86_64-linux
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-29 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