proscenium 0.17.0-aarch64-linux → 0.19.0-aarch64-linux

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -175
  3. data/lib/proscenium/builder.rb +36 -100
  4. data/lib/proscenium/bundled_gems.rb +37 -0
  5. data/lib/proscenium/css_module/path.rb +2 -1
  6. data/lib/proscenium/css_module/transformer.rb +1 -1
  7. data/lib/proscenium/css_module.rb +16 -9
  8. data/lib/proscenium/ensure_loaded.rb +14 -10
  9. data/lib/proscenium/ext/proscenium +0 -0
  10. data/lib/proscenium/ext/proscenium.h +9 -36
  11. data/lib/proscenium/helper.rb +5 -25
  12. data/lib/proscenium/importer.rb +39 -21
  13. data/lib/proscenium/log_subscriber.rb +11 -10
  14. data/lib/proscenium/middleware/base.rb +11 -6
  15. data/lib/proscenium/middleware/esbuild.rb +8 -9
  16. data/lib/proscenium/middleware/ruby_gems.rb +23 -0
  17. data/lib/proscenium/middleware.rb +26 -24
  18. data/lib/proscenium/monkey.rb +5 -14
  19. data/lib/proscenium/railtie.rb +11 -53
  20. data/lib/proscenium/{libs/react-manager → react-manager}/index.jsx +3 -22
  21. data/lib/proscenium/react_componentable.rb +2 -3
  22. data/lib/proscenium/resolver.rb +14 -23
  23. data/lib/proscenium/side_load.rb +60 -63
  24. data/lib/proscenium/utils.rb +33 -0
  25. data/lib/proscenium/version.rb +1 -1
  26. data/lib/proscenium.rb +2 -12
  27. metadata +11 -127
  28. data/lib/proscenium/core_ext/object/css_module_ivars.rb +0 -19
  29. data/lib/proscenium/css_module/rewriter.rb +0 -44
  30. data/lib/proscenium/libs/custom_element.js +0 -54
  31. data/lib/proscenium/libs/stimulus-loading.js +0 -65
  32. data/lib/proscenium/libs/test.js +0 -1
  33. data/lib/proscenium/libs/ujs/class.js +0 -15
  34. data/lib/proscenium/libs/ujs/data_confirm.js +0 -23
  35. data/lib/proscenium/libs/ujs/data_disable_with.js +0 -68
  36. data/lib/proscenium/libs/ujs/index.js +0 -9
  37. data/lib/proscenium/middleware/engines.rb +0 -45
  38. data/lib/proscenium/middleware/runtime.rb +0 -18
  39. data/lib/proscenium/phlex/asset_inclusions.rb +0 -17
  40. data/lib/proscenium/phlex/css_modules.rb +0 -79
  41. data/lib/proscenium/phlex/react_component.rb +0 -32
  42. data/lib/proscenium/phlex.rb +0 -42
  43. data/lib/proscenium/ui/breadcrumbs/component.module.css +0 -14
  44. data/lib/proscenium/ui/breadcrumbs/component.rb +0 -79
  45. data/lib/proscenium/ui/breadcrumbs/computed_element.rb +0 -69
  46. data/lib/proscenium/ui/breadcrumbs/control.rb +0 -95
  47. data/lib/proscenium/ui/breadcrumbs/mixins.css +0 -83
  48. data/lib/proscenium/ui/breadcrumbs.rb +0 -72
  49. data/lib/proscenium/ui/component.rb +0 -11
  50. data/lib/proscenium/ui/test.js +0 -1
  51. data/lib/proscenium/ui.rb +0 -14
  52. data/lib/proscenium/view_component/css_modules.rb +0 -11
  53. data/lib/proscenium/view_component/react_component.rb +0 -22
  54. data/lib/proscenium/view_component/sideload.rb +0 -4
  55. data/lib/proscenium/view_component.rb +0 -38
  56. /data/lib/proscenium/{libs/react-manager → react-manager}/react.js +0 -0
@@ -11,7 +11,7 @@ module Proscenium
11
11
  # The HTML tag to use as the wrapping element for the component. You can reassign this in your
12
12
  # component class to use a different tag:
13
13
  #
14
- # class MyComponent < Proscenium::ViewComponent::ReactComponent
14
+ # class MyComponent < Proscenium::ReactComponent
15
15
  # self.root_tag = :span
16
16
  # end
17
17
  #
@@ -40,13 +40,12 @@ module Proscenium
40
40
  class_attribute :loader
41
41
 
42
42
  # @return [String] the URL path to the component manager.
43
- class_attribute :manager, default: '/@proscenium/react-manager/index.jsx'
43
+ class_attribute :manager, default: '/proscenium/react-manager/index.jsx'
44
44
  end
45
45
 
46
46
  class_methods do
47
47
  def sideload(options)
48
48
  Importer.import manager, **options, js: { type: 'module' }
49
- Importer.sideload source_path, lazy: true, **options
50
49
  end
51
50
  end
52
51
 
@@ -4,36 +4,27 @@ require 'active_support/current_attributes'
4
4
 
5
5
  module Proscenium
6
6
  class Resolver < ActiveSupport::CurrentAttributes
7
- # TODO: cache this across requests in production.
8
- attribute :resolved
7
+ attribute :resolved unless Rails.env.production?
8
+ mattr_accessor :resolved if Rails.env.production?
9
9
 
10
- # Resolve the given `path` to a URL path.
10
+ # Resolve the given `path` to a fully qualified URL path.
11
11
  #
12
- # @param path [String] Can be URL path, file system path, or bare specifier (ie. NPM package).
12
+ # @param path [String] URL path, file system path, or bare specifier (ie. NPM package).
13
13
  # @return [String] URL path.
14
- #
15
- # rubocop:disable Metrics/*
16
14
  def self.resolve(path)
17
15
  self.resolved ||= {}
18
16
 
19
- self.resolved[path] ||= begin
20
- if path.start_with?('./', '../')
21
- raise ArgumentError, 'path must be an absolute file system or URL path'
22
- end
23
-
24
- if path.start_with?('@proscenium/')
25
- "/#{path}"
26
- elsif path.start_with?(Proscenium.ui_path.to_s)
27
- path.delete_prefix Proscenium.root.join('lib').to_s
28
- elsif (engine = Proscenium.config.engines.find { |e| path.start_with? "#{e.root}/" })
29
- path.sub(/^#{engine.root}/, "/#{engine.engine_name}")
30
- elsif path.start_with?("#{Rails.root}/")
31
- path.delete_prefix Rails.root.to_s
32
- else
33
- Builder.resolve path
34
- end
17
+ if path.start_with?('./', '../')
18
+ raise ArgumentError, '`path` must be an absolute file system or URL path'
35
19
  end
20
+
21
+ self.resolved[path] ||= if (gem = BundledGems.paths.find { |_, v| path.start_with? "#{v}/" })
22
+ path.sub(/^#{gem.last}/, "/node_modules/@rubygems/#{gem.first}")
23
+ elsif path.start_with?("#{Rails.root}/")
24
+ path.delete_prefix Rails.root.to_s
25
+ else
26
+ Builder.resolve path
27
+ end
36
28
  end
37
- # rubocop:enable Metrics/*
38
29
  end
39
30
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Proscenium
4
4
  class SideLoad
5
+ JS_COMMENT = '<!-- [PROSCENIUM_JAVASCRIPTS] -->'
6
+ CSS_COMMENT = '<!-- [PROSCENIUM_STYLESHEETS] -->'
7
+
5
8
  module Controller
6
9
  def self.included(child)
7
10
  child.class_eval do
@@ -23,91 +26,74 @@ module Proscenium
23
26
  def capture_and_replace_proscenium_stylesheets
24
27
  return if response_body.nil?
25
28
  return if response_body.first.blank? || !Proscenium::Importer.css_imported?
26
- return unless response_body.first.include? '<!-- [PROSCENIUM_STYLESHEETS] -->'
27
29
 
28
- imports = Proscenium::Importer.imported.dup
29
- paths_to_build = []
30
- Proscenium::Importer.each_stylesheet(delete: true) do |x, _|
31
- paths_to_build << x.delete_prefix('/')
32
- end
30
+ included_comment = response_body.first.include?(CSS_COMMENT)
31
+ fragments = if (fragment_header = request.headers['X-Fragment'])
32
+ fragment_header.split
33
+ end
33
34
 
34
- result = Proscenium::Builder.build_to_path(paths_to_build.join(';'),
35
- base_url: helpers.request.base_url)
35
+ return if !fragments && !included_comment
36
36
 
37
37
  out = []
38
- result.split(';').each do |x|
39
- inpath, outpath = x.split('::')
40
- inpath.prepend '/'
41
- outpath.delete_prefix! 'public'
42
-
43
- next unless imports.key?(inpath)
44
-
45
- import = imports[inpath]
46
- opts = import[:css].is_a?(Hash) ? import[:css] : {}
38
+ Proscenium::Importer.each_stylesheet(delete: true) do |path, opts|
39
+ opts = opts[:css].is_a?(Hash) ? opts[:css] : {}
40
+ opts[:preload_links_header] = false if fragments
47
41
  opts[:data] ||= {}
48
- opts[:data][:original_href] = inpath
49
- out << helpers.stylesheet_link_tag(outpath, extname: false, **opts)
42
+
43
+ if Proscenium.config.cache_query_string.present?
44
+ path += "?#{Proscenium.config.cache_query_string}"
45
+ end
46
+ out << helpers.stylesheet_link_tag(path, extname: false, **opts)
50
47
  end
51
48
 
52
- response_body.first.gsub! '<!-- [PROSCENIUM_STYLESHEETS] -->', out.join.html_safe
49
+ if fragments
50
+ response_body.first.prepend out.join.html_safe
51
+ elsif included_comment
52
+ response_body.first.gsub! CSS_COMMENT, out.join.html_safe
53
+ end
53
54
  end
54
55
 
55
56
  def capture_and_replace_proscenium_javascripts
56
57
  return if response_body.nil?
57
58
  return if response_body.first.blank? || !Proscenium::Importer.js_imported?
58
59
 
59
- imports = Proscenium::Importer.imported.dup
60
- paths_to_build = []
61
- Proscenium::Importer.each_javascript(delete: true) do |x, _|
62
- paths_to_build << x.delete_prefix('/')
63
- end
60
+ included_comment = response_body.first.include?(JS_COMMENT)
61
+ fragments = if (fragment_header = request.headers['X-Fragment'])
62
+ fragment_header.split
63
+ end
64
64
 
65
- result = Proscenium::Builder.build_to_path(paths_to_build.join(';'),
66
- base_url: helpers.request.base_url)
67
-
68
- if response_body.first.include? '<!-- [PROSCENIUM_JAVASCRIPTS] -->'
69
- out = []
70
- scripts = {}
71
- result.split(';').each do |x|
72
- inpath, outpath = x.split('::')
73
- inpath.prepend '/'
74
- outpath.delete_prefix! 'public'
75
-
76
- next unless imports.key?(inpath)
77
-
78
- if (import = imports[inpath]).delete(:lazy)
79
- scripts[inpath] = import.merge(outpath:)
80
- else
81
- opts = import[:js].is_a?(Hash) ? import[:js] : {}
82
- out << helpers.javascript_include_tag(outpath, extname: false, **opts)
83
- end
84
- end
65
+ return if !fragments && !included_comment
85
66
 
86
- response_body.first.gsub! '<!-- [PROSCENIUM_JAVASCRIPTS] -->', out.join.html_safe
87
- end
67
+ out = []
68
+ Proscenium::Importer.each_javascript(delete: true) do |path, opts|
69
+ next if opts.delete(:lazy)
88
70
 
89
- return unless response_body.first.include? '<!-- [PROSCENIUM_LAZY_SCRIPTS] -->'
71
+ opts = opts[:js].is_a?(Hash) ? opts[:js] : {}
72
+ opts[:preload_links_header] = false if fragments
90
73
 
91
- lazy_script = ''
92
- if scripts.present?
93
- lazy_script = helpers.content_tag 'script', type: 'application/json',
94
- id: 'prosceniumLazyScripts' do
95
- scripts.to_json.html_safe
74
+ if Proscenium.config.cache_query_string.present?
75
+ path += "?#{Proscenium.config.cache_query_string}"
96
76
  end
77
+ out << helpers.javascript_include_tag(path, extname: false, **opts)
97
78
  end
98
79
 
99
- response_body.first.gsub! '<!-- [PROSCENIUM_LAZY_SCRIPTS] -->', lazy_script
80
+ if fragments
81
+ response_body.first.prepend out.join.html_safe
82
+ elsif included_comment
83
+ response_body.first.gsub! JS_COMMENT, out.join.html_safe
84
+ end
100
85
  end
101
86
  end
102
87
 
103
88
  class << self
104
- # Side loads the class, and its super classes that respond to `.source_path`.
89
+ # Side loads assets for the class, and its super classes that respond to `.source_path`, which
90
+ # should return a Pathname of the class source file.
105
91
  #
106
92
  # Set the `abstract_class` class variable to true in any class, and it will not be side
107
93
  # loaded.
108
94
  #
109
- # If the class responds to `.sideload`, it will be called instead of the regular side loading.
110
- # You can use this to customise what is side loaded.
95
+ # If the class responds to `.sideload`, it will be called after the regular side loading. You
96
+ # can use this to customise what is side loaded.
111
97
  def sideload_inheritance_chain(obj, options)
112
98
  return unless Proscenium.config.side_load
113
99
 
@@ -130,23 +116,34 @@ module Proscenium
130
116
  css_imports = []
131
117
 
132
118
  klass = obj.class
133
- while klass.respond_to?(:source_path) && klass.source_path && !klass.abstract_class
134
- if klass.respond_to?(:sideload)
135
- klass.sideload options
136
- elsif options[:css] == false
119
+ while klass.respond_to?(:source_path) && klass.source_path &&
120
+ (klass.respond_to?(:abstract_class) ? !klass.abstract_class : true)
121
+ if options[:css] == false
137
122
  Importer.sideload klass.source_path, **options
138
123
  else
139
124
  Importer.sideload_js klass.source_path, **options
140
125
  css_imports << klass.source_path
141
126
  end
142
127
 
128
+ klass.sideload options if klass.respond_to?(:sideload)
129
+
143
130
  klass = klass.superclass
144
131
  end
145
132
 
133
+ # All regular CSS files (*.css) are ancestrally sideloaded. However, the first CSS module
134
+ # in the ancestry is also sideloaded in addition to the regular CSS files. This is because
135
+ # the CSS module digest will be different for each file, so we only sideload the first CSS
136
+ # module.
137
+ css_imports.each do |it| # rubocop:disable Style/ItAssignment
138
+ break if Importer.sideload_css_module(it, **options).present?
139
+ end
140
+
141
+ # Sideload regular CSS files in reverse order.
142
+ #
146
143
  # The reason why we sideload CSS after JS is because the order of CSS is important.
147
- # Basically, the layout should be loaded before the view so that CSS cascading works i9n the
144
+ # Basically, the layout should be loaded before the view so that CSS cascading works in the
148
145
  # right direction.
149
- css_imports.reverse_each do |it|
146
+ css_imports.reverse_each do |it| # rubocop:disable Style/ItAssignment
150
147
  Importer.sideload_css it, **options
151
148
  end
152
149
  end
@@ -9,5 +9,38 @@ module Proscenium
9
9
  def digest(value)
10
10
  Digest::SHA1.hexdigest(value.to_s)[..7]
11
11
  end
12
+
13
+ # Merges the given array of attribute `name`'s into the `kw_arguments`. A bang attribute is one
14
+ # that ends with an exclamation mark or - in Ruby parlance - a "bang", and has a boolean value.
15
+ # Modifies the given `kw_attributes`, and only attribute names in `allowed` will be merged.
16
+ #
17
+ # @param names [Array(Symbol)] of argument names
18
+ # @param kw_attributes [Hash] attributes to be merged with
19
+ # @param allowed [Array(Symbol)] attribute names allowed to be merged as bang attributes
20
+ #
21
+ # Example:
22
+ #
23
+ # def tab(name, *args, href:, **attributes)
24
+ # Hue::Utils.merge_bang_attributes!(args, attributes, [:current])
25
+ # end
26
+ #
27
+ # Allowing you to use either of the following API's:
28
+ #
29
+ # tab 'Tab 1', required: true
30
+ # tab 'Tab 1', :required!
31
+ #
32
+ def merge_bang_attributes!(names, kw_attributes, allowed)
33
+ allowed.each do |name|
34
+ sym_name = name.to_sym
35
+ bang_name = :"#{sym_name}!"
36
+
37
+ next unless names.include?(bang_name)
38
+
39
+ names.delete(bang_name)
40
+
41
+ # Keyword arguments should override the bang.
42
+ kw_attributes[sym_name] = true unless kw_attributes.key?(sym_name)
43
+ end
44
+ end
12
45
  end
13
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.17.0'
4
+ VERSION = '0.19.0'
5
5
  end
data/lib/proscenium.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/dependencies/autoload'
3
+ require 'active_support'
4
4
 
5
5
  module Proscenium
6
6
  extend ActiveSupport::Autoload
@@ -28,13 +28,11 @@ module Proscenium
28
28
  autoload :SideLoad
29
29
  autoload :CssModule
30
30
  autoload :ReactComponentable
31
- autoload :ViewComponent
32
- autoload :Phlex
33
31
  autoload :Helper
34
32
  autoload :Builder
35
33
  autoload :Importer
36
34
  autoload :Resolver
37
- autoload :UI
35
+ autoload :BundledGems
38
36
 
39
37
  class Deprecator
40
38
  def deprecation_warning(name, message, _caller_backtrace = nil)
@@ -60,14 +58,6 @@ module Proscenium
60
58
  @config ||= Railtie.config.proscenium
61
59
  end
62
60
 
63
- def cache
64
- @cache ||= config.cache || ActiveSupport::Cache::NullStore.new
65
- end
66
-
67
- def ui_path
68
- Railtie.root.join('lib', 'proscenium', 'ui')
69
- end
70
-
71
61
  def root
72
62
  Railtie.root
73
63
  end
metadata CHANGED
@@ -1,63 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-29 00:00:00.000000000 Z
11
+ date: 2025-09-08 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
62
14
  name: ffi
63
15
  requirement: !ruby/object:Gem::Requirement
@@ -73,35 +25,7 @@ dependencies:
73
25
  - !ruby/object:Gem::Version
74
26
  version: 1.17.0
75
27
  - !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
28
+ name: rails
105
29
  requirement: !ruby/object:Gem::Requirement
106
30
  requirements:
107
31
  - - ">="
@@ -109,7 +33,7 @@ dependencies:
109
33
  version: 7.1.0
110
34
  - - "<"
111
35
  - !ruby/object:Gem::Version
112
- version: '8.0'
36
+ version: '9.0'
113
37
  type: :runtime
114
38
  prerelease: false
115
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -119,21 +43,7 @@ dependencies:
119
43
  version: 7.1.0
120
44
  - - "<"
121
45
  - !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
46
+ version: '9.0'
137
47
  description:
138
48
  email:
139
49
  - joel@developwithstyle.com
@@ -146,57 +56,31 @@ files:
146
56
  - README.md
147
57
  - lib/proscenium.rb
148
58
  - lib/proscenium/builder.rb
149
- - lib/proscenium/core_ext/object/css_module_ivars.rb
59
+ - lib/proscenium/bundled_gems.rb
150
60
  - lib/proscenium/css_module.rb
151
61
  - lib/proscenium/css_module/path.rb
152
- - lib/proscenium/css_module/rewriter.rb
153
62
  - lib/proscenium/css_module/transformer.rb
154
63
  - lib/proscenium/ensure_loaded.rb
155
64
  - lib/proscenium/ext/proscenium
156
65
  - lib/proscenium/ext/proscenium.h
157
66
  - lib/proscenium/helper.rb
158
67
  - 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
68
  - lib/proscenium/log_subscriber.rb
169
69
  - lib/proscenium/middleware.rb
170
70
  - lib/proscenium/middleware/base.rb
171
- - lib/proscenium/middleware/engines.rb
172
71
  - lib/proscenium/middleware/esbuild.rb
173
- - lib/proscenium/middleware/runtime.rb
72
+ - lib/proscenium/middleware/ruby_gems.rb
174
73
  - lib/proscenium/monkey.rb
175
- - lib/proscenium/phlex.rb
176
- - lib/proscenium/phlex/asset_inclusions.rb
177
- - lib/proscenium/phlex/css_modules.rb
178
- - lib/proscenium/phlex/react_component.rb
179
74
  - lib/proscenium/railtie.rb
75
+ - lib/proscenium/react-manager/index.jsx
76
+ - lib/proscenium/react-manager/react.js
180
77
  - lib/proscenium/react_componentable.rb
181
78
  - lib/proscenium/resolver.rb
182
79
  - lib/proscenium/side_load.rb
183
80
  - lib/proscenium/source_path.rb
184
81
  - lib/proscenium/templates/rescues/build_error.html.erb
185
- - lib/proscenium/ui.rb
186
- - lib/proscenium/ui/breadcrumbs.rb
187
- - lib/proscenium/ui/breadcrumbs/component.module.css
188
- - lib/proscenium/ui/breadcrumbs/component.rb
189
- - lib/proscenium/ui/breadcrumbs/computed_element.rb
190
- - lib/proscenium/ui/breadcrumbs/control.rb
191
- - lib/proscenium/ui/breadcrumbs/mixins.css
192
- - lib/proscenium/ui/component.rb
193
- - lib/proscenium/ui/test.js
194
82
  - lib/proscenium/utils.rb
195
83
  - lib/proscenium/version.rb
196
- - lib/proscenium/view_component.rb
197
- - lib/proscenium/view_component/css_modules.rb
198
- - lib/proscenium/view_component/react_component.rb
199
- - lib/proscenium/view_component/sideload.rb
200
84
  homepage: https://github.com/joelmoss/proscenium
201
85
  licenses:
202
86
  - MIT
@@ -213,14 +97,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
97
  requirements:
214
98
  - - ">="
215
99
  - !ruby/object:Gem::Version
216
- version: 3.2.0
100
+ version: 3.3.0
217
101
  required_rubygems_version: !ruby/object:Gem::Requirement
218
102
  requirements:
219
103
  - - ">="
220
104
  - !ruby/object:Gem::Version
221
105
  version: '0'
222
106
  requirements: []
223
- rubygems_version: 3.5.21
107
+ rubygems_version: 3.5.22
224
108
  signing_key:
225
109
  specification_version: 4
226
110
  summary: The engine powering your Rails frontend
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Object
4
- def instance_variable_get(name)
5
- name.is_a?(::Proscenium::CssModule::Name) ? super(name.to_sym) : super
6
- end
7
-
8
- def instance_variable_set(name, obj)
9
- name.is_a?(::Proscenium::CssModule::Name) ? super(name.to_sym, obj) : super
10
- end
11
-
12
- def instance_variable_defined?(name)
13
- name.is_a?(::Proscenium::CssModule::Name) ? super(name.to_sym) : super
14
- end
15
-
16
- def remove_instance_variable(name)
17
- name.is_a?(::Proscenium::CssModule::Name) ? super(name.to_sym) : super
18
- end
19
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ruby-next/language'
4
- require 'proscenium/core_ext/object/css_module_ivars'
5
-
6
- module Proscenium
7
- module CssModule
8
- class Rewriter < RubyNext::Language::Rewriters::Text
9
- NAME = 'proscenium-css-module'
10
-
11
- def rewrite(source)
12
- source = source.gsub(/%i\[((@[\w@ ]+)|([\w@ ]+ @[\w@ ]+))\]/) do |_|
13
- arr = ::Regexp.last_match(1).split.map do |x|
14
- x.start_with?('@') ? css_module_string(x[1..]) : ":#{x}"
15
- end
16
- "[#{arr.join(',')}]"
17
- end
18
-
19
- source.gsub(/:@([\w]+)/) do |_|
20
- context.track!(self)
21
- css_module_string(::Regexp.last_match(1))
22
- end
23
- end
24
-
25
- private
26
-
27
- def css_module_string(name)
28
- if (path = Pathname.new(context.path).sub_ext('.module.css')).exist?
29
- tname = Transformer.new(path).class_name!(name, name.dup).first
30
- "Proscenium::CssModule::Name.new(:@#{name}, '#{tname}')"
31
- else
32
- "Proscenium::CssModule::Name.new(:@#{name}, css_module(:#{name}))"
33
- end
34
- end
35
- end
36
- end
37
- end
38
-
39
- RubyNext::Language.send :include_patterns=, []
40
- RubyNext::Language.include_patterns << "#{Rails.root.join('app', 'components')}/*.rb"
41
- RubyNext::Language.include_patterns << "#{Rails.root.join('app', 'views')}/*.rb"
42
- RubyNext::Language.rewriters = [Proscenium::CssModule::Rewriter]
43
-
44
- require 'ruby-next/language/runtime'
@@ -1,54 +0,0 @@
1
- /**
2
- * Base class for custom elements, providing support for event delegation, and idempotent
3
- * customElement registration.
4
- *
5
- * The `handleEvent` method is called any time an event defined in `delegatedEvents` is triggered.
6
- * It's a central handler to handle events for this custom element.
7
- *
8
- * @example
9
- * class MyComponent extends CustomElement {
10
- * static componentName = 'my-component'
11
- * static delegatedEvents = ['click']
12
- *
13
- * handleEvent(event) {
14
- * console.log('Hello, world!')
15
- * }
16
- * }
17
- * MyComponent.register()
18
- */
19
- export default class CustomElement extends HTMLElement {
20
- /**
21
- * Register the component as a custom element, inferring the component name from the kebab-cased
22
- * class name. You can override the component name by setting a static `componentName` property.
23
- *
24
- * This method is idempotent.
25
- */
26
- static register() {
27
- if (this.componentName === undefined) {
28
- this.componentName = this.name
29
- .replaceAll(/(.)([A-Z])/g, "$1-$2")
30
- .toLowerCase();
31
- }
32
-
33
- if (!customElements.get(this.componentName)) {
34
- customElements.define(this.componentName, this);
35
- }
36
- }
37
-
38
- /**
39
- * A list of event types to be delegated for the lifetime of the custom element.
40
- *
41
- * @type {Array}
42
- */
43
- static delegatedEvents = [];
44
-
45
- constructor() {
46
- super();
47
-
48
- if (typeof this.handleEvent !== "undefined") {
49
- this.constructor.delegatedEvents?.forEach((event) => {
50
- this.addEventListener(event, this);
51
- });
52
- }
53
- }
54
- }