proscenium 0.19.0.beta19-arm64-darwin → 0.19.0.beta20-arm64-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: 923c460b315a425b3790d23fb45379166970775f8599bfc06a8fb95a71eba028
4
- data.tar.gz: 7aedc324e2a04c52026081b862ac925797fda0a302522d9690b17057d8bc1f66
3
+ metadata.gz: 1b0226fc1e03aed740a6f8a57451cd5d5244df61f39fa72b7c69239dc952bbed
4
+ data.tar.gz: 3dceeb133efd79563ac73579430eb113e5b2f19e38e836f3b2fc88c91ef6ac89
5
5
  SHA512:
6
- metadata.gz: be39d4906bce0552c3ee25d952b9bd375371c52076a06f0bbdc61772fac32039972cb3a676cb3714d5a4a4f31bb8d0469b6e931e979310f8905d205f2a7fb320
7
- data.tar.gz: 2b5f622a4365c7dd028f21935cbd237e192cbe7b8dc547841f75ba06acc838df91ea921a06eeab788f0eacddab8c188d9d2ab4b5f3bd22857161f32da35c861c
6
+ metadata.gz: 315359ede2e0bccf01e3b56dd76f0d24ab8e6f8f53b0b241cbca0332d69df2fe0b5cc20caa66c0d6f809c2d16f84fb1b568ea802bd294d6aa24da453baf4f0e3
7
+ data.tar.gz: 9209ad4652e88239e3190bcb4c76220dcfb598aa5158a349c386a4b37af6c8542bbc2702012b769f92768d4c9fbe99840e5b57ddc29492858516ff6a43245f2b
data/README.md CHANGED
@@ -48,7 +48,6 @@
48
48
  - [Typescript Caveats](#typescript-caveats)
49
49
  - [JSX](#jsx)
50
50
  - [JSON](#json)
51
- - [Phlex Support](#phlex-support)
52
51
  - [Cache Busting](#cache-busting)
53
52
  - [rjs is back!](#rjs-is-back)
54
53
  - [Resolution](#resolution)
@@ -681,93 +680,6 @@ import { version } from "./package.json";
681
680
  console.log(version);
682
681
  ```
683
682
 
684
- ## Phlex Support
685
-
686
- [Phlex](https://www.phlex.fun/) is a framework for building fast, reusable, testable views in pure Ruby. Proscenium works perfectly with Phlex, with support for side-loading, CSS modules, and more. Simply write your Phlex classes and inherit from `Proscenium::Phlex`.
687
-
688
- ```ruby
689
- class MyView < Proscenium::Phlex
690
- def view_template
691
- h1 { 'Hello World' }
692
- end
693
- end
694
- ```
695
-
696
- In your layouts, include `Proscenium::Phlex::AssetInclusions`, and call the `include_assets` helper.
697
-
698
- ```ruby
699
- class ApplicationLayout < Proscenium::Phlex
700
- include Proscenium::Phlex::AssetInclusions # <--
701
-
702
- def view_template(&)
703
- doctype
704
- html do
705
- head do
706
- title { 'My Awesome App' }
707
- include_assets # <--
708
- end
709
- body(&)
710
- end
711
- end
712
- end
713
- ```
714
-
715
- You can specifically include CCS and JS assets using the `include_stylesheets` and `include_javascripts` helpers, allowing you to control where they are included in the HTML.
716
-
717
- ### Side-loading
718
-
719
- Any Phlex class that inherits `Proscenium::Phlex` will automatically be [side-loaded](#side-loading).
720
-
721
- ### CSS Modules
722
-
723
- [CSS Modules](#css-modules) are fully supported in Phlex classes, with access to the [`css_module` helper](#in-your-views) if you need it. However, there is a better and more seemless way to reference CSS module classes in your Phlex classes.
724
-
725
- Within your Phlex classes, any class names that begin with `@` will be treated as a CSS module class.
726
-
727
- ```ruby
728
- # /app/views/users/show_view.rb
729
- class Users::ShowView < Proscenium::Phlex
730
- def view_template
731
- h1 class: :@user_name do
732
- @user.name
733
- end
734
- end
735
- end
736
- ```
737
-
738
- ```css
739
- /* /app/views/users/show_view.module.css */
740
- .userName {
741
- color: red;
742
- font-size: 50px;
743
- }
744
- ```
745
-
746
- In the above `Users::ShowView` Phlex class, the `@user_name` class will be resolved to the `userName` class in the `users/show_view.module.css` file.
747
-
748
- The view above will be rendered something like this:
749
-
750
- ```html
751
- <h1 class="user_name-ABCD1234"></h1>
752
- ```
753
-
754
- You can of course continue to reference regular class names in your view, and they will be passed through as is. This will allow you to mix and match CSS modules and regular CSS classes in your views.
755
-
756
- ```ruby
757
- # /app/views/users/show_view.rb
758
- class Users::ShowView < Proscenium::Phlex
759
- def view_template
760
- h1 class: :[@user_name, :title] do
761
- @user.name
762
- end
763
- end
764
- end
765
- ```
766
-
767
- ```html
768
- <h1 class="user_name-ABCD1234 title">Joel Moss</h1>
769
- ```
770
-
771
683
  ## Cache Busting
772
684
 
773
685
  > _COMING SOON_
@@ -18,7 +18,8 @@ module Proscenium
18
18
  unless @css_module_path
19
19
  klass = superclass
20
20
 
21
- while klass.respond_to?(:css_module_path) && !klass.abstract_class
21
+ while klass.respond_to?(:css_module_path) &&
22
+ (klass.respond_to?(:abstract_class) ? !klass.abstract_class : true)
22
23
  break if (@css_module_path = klass.css_module_path)
23
24
 
24
25
  klass = klass.superclass
Binary file
@@ -36,5 +36,3 @@ module Proscenium
36
36
  end
37
37
  end
38
38
  end
39
-
40
- Proscenium::LogSubscriber.attach_to :proscenium
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails'
4
- require 'proscenium/log_subscriber'
5
4
 
6
5
  ENV['RAILS_ENV'] = Rails.env
7
6
 
@@ -11,6 +10,7 @@ module Proscenium
11
10
 
12
11
  config.proscenium = ActiveSupport::OrderedOptions.new
13
12
  config.proscenium.debug = false
13
+ config.proscenium.logging = true
14
14
  config.proscenium.bundle = true
15
15
  config.proscenium.side_load = true
16
16
  config.proscenium.code_splitting = true
@@ -28,6 +28,11 @@ module Proscenium
28
28
  }
29
29
 
30
30
  config.after_initialize do |_app|
31
+ if config.proscenium.logging
32
+ require 'proscenium/log_subscriber'
33
+ Proscenium::LogSubscriber.attach_to :proscenium
34
+ end
35
+
31
36
  ActiveSupport.on_load(:action_view) do
32
37
  include Proscenium::Helper
33
38
  end
@@ -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::Phlex::ReactComponent
14
+ # class MyComponent < Proscenium::ReactComponent
15
15
  # self.root_tag = :span
16
16
  # end
17
17
  #
@@ -116,7 +116,8 @@ module Proscenium
116
116
  css_imports = []
117
117
 
118
118
  klass = obj.class
119
- while klass.respond_to?(:source_path) && klass.source_path && !klass.abstract_class
119
+ while klass.respond_to?(:source_path) && klass.source_path &&
120
+ (klass.respond_to?(:abstract_class) ? !klass.abstract_class : true)
120
121
  if options[:css] == false
121
122
  Importer.sideload klass.source_path, **options
122
123
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.19.0.beta19'
4
+ VERSION = '0.19.0.beta20'
5
5
  end
data/lib/proscenium.rb CHANGED
@@ -28,7 +28,6 @@ module Proscenium
28
28
  autoload :SideLoad
29
29
  autoload :CssModule
30
30
  autoload :ReactComponentable
31
- autoload :Phlex
32
31
  autoload :Helper
33
32
  autoload :Builder
34
33
  autoload :Importer
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.19.0.beta19
4
+ version: 0.19.0.beta20
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-01 00:00:00.000000000 Z
11
+ date: 2025-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.17.0
27
- - !ruby/object:Gem::Dependency
28
- name: phlex-rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.2'
41
- - !ruby/object:Gem::Dependency
42
- name: prism
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: rails
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,20 +44,6 @@ dependencies:
72
44
  - - "<"
73
45
  - !ruby/object:Gem::Version
74
46
  version: '9.0'
75
- - !ruby/object:Gem::Dependency
76
- name: require-hooks
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.2'
82
- type: :runtime
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.2'
89
47
  description:
90
48
  email:
91
49
  - joel@developwithstyle.com
@@ -101,7 +59,6 @@ files:
101
59
  - lib/proscenium/bundled_gems.rb
102
60
  - lib/proscenium/css_module.rb
103
61
  - lib/proscenium/css_module/path.rb
104
- - lib/proscenium/css_module/rewriter.rb
105
62
  - lib/proscenium/css_module/transformer.rb
106
63
  - lib/proscenium/ensure_loaded.rb
107
64
  - lib/proscenium/ext/proscenium
@@ -114,10 +71,6 @@ files:
114
71
  - lib/proscenium/middleware/esbuild.rb
115
72
  - lib/proscenium/middleware/ruby_gems.rb
116
73
  - lib/proscenium/monkey.rb
117
- - lib/proscenium/phlex.rb
118
- - lib/proscenium/phlex/asset_inclusions.rb
119
- - lib/proscenium/phlex/css_modules.rb
120
- - lib/proscenium/phlex/react_component.rb
121
74
  - lib/proscenium/railtie.rb
122
75
  - lib/proscenium/react-manager/index.jsx
123
76
  - lib/proscenium/react-manager/react.js
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'prism'
4
- require 'require-hooks/setup'
5
-
6
- module Proscenium
7
- module CssModule
8
- class Rewriter
9
- def self.init(include: [], exclude: [])
10
- RequireHooks.source_transform(
11
- patterns: include,
12
- exclude_patterns: exclude
13
- ) do |path, source|
14
- source ||= File.read(path)
15
- Processor.call(source)
16
- end
17
- end
18
-
19
- class Processor < Prism::Visitor
20
- def self.call(source)
21
- visitor = new
22
- visitor.visit(Prism.parse(source).value)
23
-
24
- buffer = source.dup
25
- annotations = visitor.annotations
26
- annotations.sort_by!(&:first)
27
-
28
- annotations.reverse_each do |offset, action|
29
- case action
30
- when :start
31
- buffer.insert(offset, 'class_names(*')
32
- when :end
33
- buffer.insert(offset, ')')
34
- else
35
- raise 'Invalid annotation'
36
- end
37
- end
38
-
39
- buffer
40
- end
41
-
42
- def initialize
43
- @annotations = []
44
- end
45
-
46
- PREFIX = '@'
47
-
48
- attr_reader :annotations
49
-
50
- def visit_assoc_node(node)
51
- # Skip if the key is not a symbol or string
52
- return if %i[symbol_node string_node].exclude?(node.key.type)
53
-
54
- return if node.key.type == :symbol_node && node.key.value != 'class'
55
- return if node.key.type == :string_node && node.key.content != 'class'
56
-
57
- value = node.value
58
- type = value.type
59
-
60
- if (type == :symbol_node && value.value.start_with?(PREFIX)) ||
61
- (type == :array_node && value.elements.any? { |it| it.value.start_with?(PREFIX) })
62
- build_annotation value
63
- end
64
- end
65
-
66
- def build_annotation(value)
67
- location = value.location
68
-
69
- @annotations <<
70
- [location.start_character_offset, :start] <<
71
- [location.end_character_offset, :end]
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Proscenium::Phlex::AssetInclusions
4
- def include_stylesheets
5
- comment { '[PROSCENIUM_STYLESHEETS]' }
6
- end
7
-
8
- def include_javascripts
9
- comment { '[PROSCENIUM_JAVASCRIPTS]' }
10
- end
11
-
12
- def include_assets
13
- include_stylesheets
14
- include_javascripts
15
- end
16
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Proscenium
4
- module Phlex::CssModules
5
- def self.included(base)
6
- base.extend CssModule::Path
7
- base.extend ClassMethods
8
- end
9
-
10
- module ClassMethods
11
- # Set of CSS module paths that have been resolved after being transformed from 'class' HTML
12
- # attributes. See #process_attributes. This is here because Phlex caches attributes. Which
13
- # means while the CSS class names will be transformed, any resolved paths will be lost in
14
- # subsequent requests.
15
- attr_accessor :resolved_css_module_paths
16
- end
17
-
18
- def before_template
19
- self.class.resolved_css_module_paths ||= Concurrent::Set.new
20
- super
21
- end
22
-
23
- def after_template
24
- self.class.resolved_css_module_paths ||= Concurrent::Set.new
25
- self.class.resolved_css_module_paths.each do |path|
26
- Proscenium::Importer.import path, sideloaded: true
27
- end
28
-
29
- super
30
- end
31
-
32
- # Resolve and side load any CSS modules in the "class" attributes, where a CSS module is a class
33
- # name beginning with a `@`. The class name is resolved to a CSS module name based on the file
34
- # system path of the Phlex class, and any CSS file is side loaded.
35
- #
36
- # For example, the following will side load the CSS module file at
37
- # app/components/user/component.module.css, and add the CSS Module name `user_name` to the
38
- # <div>.
39
- #
40
- # # app/components/user/component.rb
41
- # class User::Component < Proscenium::Phlex
42
- # def view_template
43
- # div class: :@user_name do
44
- # 'Joel Moss'
45
- # end
46
- # end
47
- # end
48
- #
49
- # Additionally, any class name containing a `/` is resolved as a CSS module path. Allowing you
50
- # to use the same syntax as a CSS module, but without the need to manually import the CSS file.
51
- #
52
- # For example, the following will side load the CSS module file at /lib/users.module.css, and
53
- # add the CSS Module name `name` to the <div>.
54
- #
55
- # class User::Component < Proscenium::Phlex
56
- # def view_template
57
- # div class: '/lib/users@name' do
58
- # 'Joel Moss'
59
- # end
60
- # end
61
- # end
62
- #
63
- # @raise [Proscenium::CssModule::Resolver::NotFound] If a CSS module file is not found for the
64
- # Phlex class file path.
65
- def process_attributes(**attributes)
66
- if attributes.key?(:class) && (attributes[:class] = tokens(attributes[:class])).include?('@')
67
- names = attributes[:class].is_a?(Array) ? attributes[:class] : attributes[:class].split
68
-
69
- self.class.resolved_css_module_paths ||= Concurrent::Set.new
70
-
71
- attributes[:class] = cssm.class_names(*names).map do |name, path|
72
- self.class.resolved_css_module_paths << path if path
73
- name
74
- end
75
- end
76
-
77
- attributes
78
- end
79
- end
80
- end
@@ -1,32 +0,0 @@
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 block is given, it will be yielded within the div, allowing for a custom "loading" UI. If
8
- # no block is given, then a "loading..." text will be rendered. It is intended that the component
9
- # is mounted to this div, and the loading UI will then be replaced with the component's rendered
10
- # output.
11
- #
12
- # You can pass props to the component in the `:props` keyword argument.
13
- class Phlex::ReactComponent < Phlex
14
- self.abstract_class = true
15
-
16
- include ReactComponentable
17
-
18
- # Override this to provide your own loading UI.
19
- #
20
- # @example
21
- # def view_template(**attributes, &block)
22
- # super do
23
- # 'Look at me! I am loading now...'
24
- # end
25
- # end
26
- #
27
- # @yield the given block to a `div` within the top level component div.
28
- def view_template(**attributes, &)
29
- send(root_tag, **{ data: data_attributes }.deep_merge(attributes), &)
30
- end
31
- end
32
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'phlex-rails'
4
-
5
- module Proscenium
6
- class Phlex < ::Phlex::HTML
7
- extend ActiveSupport::Autoload
8
-
9
- autoload :CssModules
10
- autoload :ReactComponent
11
- autoload :AssetInclusions
12
-
13
- include Proscenium::SourcePath
14
- include Proscenium::CssModule
15
- include CssModules
16
- include AssetInclusions
17
-
18
- module Sideload
19
- def before_template
20
- Proscenium::SideLoad.sideload_inheritance_chain self,
21
- helpers.controller.sideload_assets_options
22
-
23
- super
24
- end
25
- end
26
-
27
- class_attribute :sideload_assets_options
28
-
29
- class << self
30
- attr_accessor :abstract_class
31
-
32
- def inherited(child)
33
- child.prepend Sideload
34
-
35
- super
36
- end
37
-
38
- def sideload_assets(value)
39
- self.sideload_assets_options = value
40
- end
41
- end
42
- end
43
- end