proscenium 0.16.0

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 (59) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +84 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +908 -0
  5. data/lib/proscenium/builder.rb +189 -0
  6. data/lib/proscenium/core_ext/object/css_module_ivars.rb +19 -0
  7. data/lib/proscenium/css_module/path.rb +31 -0
  8. data/lib/proscenium/css_module/rewriter.rb +44 -0
  9. data/lib/proscenium/css_module/transformer.rb +84 -0
  10. data/lib/proscenium/css_module.rb +57 -0
  11. data/lib/proscenium/ensure_loaded.rb +27 -0
  12. data/lib/proscenium/ext/proscenium +0 -0
  13. data/lib/proscenium/ext/proscenium.h +131 -0
  14. data/lib/proscenium/helper.rb +70 -0
  15. data/lib/proscenium/importer.rb +134 -0
  16. data/lib/proscenium/libs/custom_element.js +54 -0
  17. data/lib/proscenium/libs/react-manager/index.jsx +121 -0
  18. data/lib/proscenium/libs/react-manager/react.js +2 -0
  19. data/lib/proscenium/libs/stimulus-loading.js +65 -0
  20. data/lib/proscenium/libs/test.js +1 -0
  21. data/lib/proscenium/libs/ujs/class.js +15 -0
  22. data/lib/proscenium/libs/ujs/data_confirm.js +23 -0
  23. data/lib/proscenium/libs/ujs/data_disable_with.js +68 -0
  24. data/lib/proscenium/libs/ujs/index.js +9 -0
  25. data/lib/proscenium/log_subscriber.rb +37 -0
  26. data/lib/proscenium/middleware/base.rb +103 -0
  27. data/lib/proscenium/middleware/engines.rb +45 -0
  28. data/lib/proscenium/middleware/esbuild.rb +30 -0
  29. data/lib/proscenium/middleware/runtime.rb +18 -0
  30. data/lib/proscenium/middleware/url.rb +16 -0
  31. data/lib/proscenium/middleware.rb +76 -0
  32. data/lib/proscenium/monkey.rb +95 -0
  33. data/lib/proscenium/phlex/asset_inclusions.rb +17 -0
  34. data/lib/proscenium/phlex/css_modules.rb +79 -0
  35. data/lib/proscenium/phlex/react_component.rb +32 -0
  36. data/lib/proscenium/phlex.rb +42 -0
  37. data/lib/proscenium/railtie.rb +106 -0
  38. data/lib/proscenium/react_componentable.rb +95 -0
  39. data/lib/proscenium/resolver.rb +39 -0
  40. data/lib/proscenium/side_load.rb +155 -0
  41. data/lib/proscenium/source_path.rb +15 -0
  42. data/lib/proscenium/templates/rescues/build_error.html.erb +30 -0
  43. data/lib/proscenium/ui/breadcrumbs/component.module.css +14 -0
  44. data/lib/proscenium/ui/breadcrumbs/component.rb +79 -0
  45. data/lib/proscenium/ui/breadcrumbs/computed_element.rb +69 -0
  46. data/lib/proscenium/ui/breadcrumbs/control.rb +95 -0
  47. data/lib/proscenium/ui/breadcrumbs/mixins.css +83 -0
  48. data/lib/proscenium/ui/breadcrumbs.rb +72 -0
  49. data/lib/proscenium/ui/component.rb +11 -0
  50. data/lib/proscenium/ui/test.js +1 -0
  51. data/lib/proscenium/ui.rb +14 -0
  52. data/lib/proscenium/utils.rb +13 -0
  53. data/lib/proscenium/version.rb +5 -0
  54. data/lib/proscenium/view_component/css_modules.rb +11 -0
  55. data/lib/proscenium/view_component/react_component.rb +22 -0
  56. data/lib/proscenium/view_component/sideload.rb +4 -0
  57. data/lib/proscenium/view_component.rb +38 -0
  58. data/lib/proscenium.rb +70 -0
  59. metadata +228 -0
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium
4
+ # Renders a <div> for use with React components, with data attributes specifying the component
5
+ # path and props.
6
+ #
7
+ # If a content block is given, that content will be rendered inside the component, allowing for a
8
+ # "loading" UI. If no block is given, then a "loading..." text will be rendered. It is intended
9
+ # that the component is mounted to this div, and the loading UI will then be replaced with the
10
+ # component's rendered output.
11
+ class ViewComponent::ReactComponent < ViewComponent
12
+ self.abstract_class = true
13
+
14
+ include ReactComponentable
15
+
16
+ def call
17
+ tag.send root_tag, data: data_attributes do
18
+ tag.div content || 'loading...'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium::ViewComponent::Sideload
4
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'view_component'
4
+
5
+ class Proscenium::ViewComponent < ViewComponent::Base
6
+ extend ActiveSupport::Autoload
7
+
8
+ autoload :Sideload
9
+ autoload :ReactComponent
10
+ autoload :CssModules
11
+
12
+ include Proscenium::SourcePath
13
+ include CssModules
14
+
15
+ module Sideload
16
+ def before_render
17
+ Proscenium::SideLoad.sideload_inheritance_chain self, controller.sideload_assets_options
18
+
19
+ super
20
+ end
21
+ end
22
+
23
+ class_attribute :sideload_assets_options
24
+
25
+ class << self
26
+ attr_accessor :abstract_class
27
+
28
+ def inherited(child)
29
+ child.prepend Sideload
30
+
31
+ super
32
+ end
33
+
34
+ def sideload_assets(value)
35
+ self.sideload_assets_options = value
36
+ end
37
+ end
38
+ end
data/lib/proscenium.rb ADDED
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/dependencies/autoload'
4
+
5
+ module Proscenium
6
+ extend ActiveSupport::Autoload
7
+
8
+ FILE_EXTENSIONS = ['js', 'mjs', 'ts', 'jsx', 'tsx', 'css', 'js.map', 'mjs.map', 'jsx.map',
9
+ 'ts.map', 'tsx.map', 'css.map'].freeze
10
+
11
+ ALLOWED_DIRECTORIES = 'app,lib,config,vendor,node_modules'
12
+
13
+ # Environment variables that should always be passed to the builder.
14
+ DEFAULT_ENV_VARS = Set['RAILS_ENV', 'NODE_ENV'].freeze
15
+
16
+ autoload :SourcePath
17
+ autoload :Utils
18
+ autoload :Monkey
19
+ autoload :Middleware
20
+ autoload :EnsureLoaded
21
+ autoload :SideLoad
22
+ autoload :CssModule
23
+ autoload :ReactComponentable
24
+ autoload :ViewComponent
25
+ autoload :Phlex
26
+ autoload :Helper
27
+ autoload :Builder
28
+ autoload :Importer
29
+ autoload :Resolver
30
+ autoload :UI
31
+
32
+ class Deprecator
33
+ def deprecation_warning(name, message, _caller_backtrace = nil)
34
+ msg = "`#{name}` is deprecated and will be removed in a near future release of Proscenium"
35
+ msg << " (#{message})" if message
36
+ Kernel.warn msg
37
+ end
38
+ end
39
+
40
+ class PathResolutionFailed < StandardError
41
+ def initialize(path)
42
+ @path = path
43
+ super
44
+ end
45
+
46
+ def message
47
+ "Path #{@path.inspect} cannot be resolved"
48
+ end
49
+ end
50
+
51
+ class << self
52
+ def config
53
+ @config ||= Railtie.config.proscenium
54
+ end
55
+
56
+ def cache
57
+ @cache ||= config.cache || ActiveSupport::Cache::NullStore.new
58
+ end
59
+
60
+ def ui_path
61
+ Railtie.root.join('lib', 'proscenium', 'ui')
62
+ end
63
+
64
+ def root
65
+ Railtie.root
66
+ end
67
+ end
68
+ end
69
+
70
+ require 'proscenium/railtie'
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proscenium
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.16.0
5
+ platform: ruby
6
+ authors:
7
+ - Joel Moss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.1.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 7.1.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: dry-initializer
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.1'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: dry-types
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.7'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: ffi
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 1.17.0
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 1.17.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: oj
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.13'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.13'
89
+ - !ruby/object:Gem::Dependency
90
+ name: phlex-rails
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 1.2.1
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 1.2.1
103
+ - !ruby/object:Gem::Dependency
104
+ name: railties
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 7.1.0
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '8.0'
113
+ type: :runtime
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 7.1.0
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '8.0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: ruby-next
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 1.0.1
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 1.0.1
137
+ description:
138
+ email:
139
+ - joel@developwithstyle.com
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - CODE_OF_CONDUCT.md
145
+ - LICENSE.txt
146
+ - README.md
147
+ - lib/proscenium.rb
148
+ - lib/proscenium/builder.rb
149
+ - lib/proscenium/core_ext/object/css_module_ivars.rb
150
+ - lib/proscenium/css_module.rb
151
+ - lib/proscenium/css_module/path.rb
152
+ - lib/proscenium/css_module/rewriter.rb
153
+ - lib/proscenium/css_module/transformer.rb
154
+ - lib/proscenium/ensure_loaded.rb
155
+ - lib/proscenium/ext/proscenium
156
+ - lib/proscenium/ext/proscenium.h
157
+ - lib/proscenium/helper.rb
158
+ - lib/proscenium/importer.rb
159
+ - lib/proscenium/libs/custom_element.js
160
+ - lib/proscenium/libs/react-manager/index.jsx
161
+ - lib/proscenium/libs/react-manager/react.js
162
+ - lib/proscenium/libs/stimulus-loading.js
163
+ - lib/proscenium/libs/test.js
164
+ - lib/proscenium/libs/ujs/class.js
165
+ - lib/proscenium/libs/ujs/data_confirm.js
166
+ - lib/proscenium/libs/ujs/data_disable_with.js
167
+ - lib/proscenium/libs/ujs/index.js
168
+ - lib/proscenium/log_subscriber.rb
169
+ - lib/proscenium/middleware.rb
170
+ - lib/proscenium/middleware/base.rb
171
+ - lib/proscenium/middleware/engines.rb
172
+ - lib/proscenium/middleware/esbuild.rb
173
+ - lib/proscenium/middleware/runtime.rb
174
+ - lib/proscenium/middleware/url.rb
175
+ - lib/proscenium/monkey.rb
176
+ - lib/proscenium/phlex.rb
177
+ - lib/proscenium/phlex/asset_inclusions.rb
178
+ - lib/proscenium/phlex/css_modules.rb
179
+ - lib/proscenium/phlex/react_component.rb
180
+ - lib/proscenium/railtie.rb
181
+ - lib/proscenium/react_componentable.rb
182
+ - lib/proscenium/resolver.rb
183
+ - lib/proscenium/side_load.rb
184
+ - lib/proscenium/source_path.rb
185
+ - lib/proscenium/templates/rescues/build_error.html.erb
186
+ - lib/proscenium/ui.rb
187
+ - lib/proscenium/ui/breadcrumbs.rb
188
+ - lib/proscenium/ui/breadcrumbs/component.module.css
189
+ - lib/proscenium/ui/breadcrumbs/component.rb
190
+ - lib/proscenium/ui/breadcrumbs/computed_element.rb
191
+ - lib/proscenium/ui/breadcrumbs/control.rb
192
+ - lib/proscenium/ui/breadcrumbs/mixins.css
193
+ - lib/proscenium/ui/component.rb
194
+ - lib/proscenium/ui/test.js
195
+ - lib/proscenium/utils.rb
196
+ - lib/proscenium/version.rb
197
+ - lib/proscenium/view_component.rb
198
+ - lib/proscenium/view_component/css_modules.rb
199
+ - lib/proscenium/view_component/react_component.rb
200
+ - lib/proscenium/view_component/sideload.rb
201
+ homepage: https://github.com/joelmoss/proscenium
202
+ licenses:
203
+ - MIT
204
+ metadata:
205
+ homepage_uri: https://github.com/joelmoss/proscenium
206
+ source_code_uri: https://github.com/joelmoss/proscenium
207
+ changelog_uri: https://github.com/joelmoss/proscenium/releases
208
+ rubygems_mfa_required: 'true'
209
+ post_install_message:
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: 3.2.0
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubygems_version: 3.5.21
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: The engine powering your Rails frontend
228
+ test_files: []