proscenium 0.19.0.beta7-aarch64-linux → 0.19.0.beta9-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4e392b165407d990bc826b5e109faa8087749163527d430f7a5d6b914fe23ea
4
- data.tar.gz: 0d176be8e4427e83fc415792081aa1ecbb8bbf3eb0def8972d465c02df5262f1
3
+ metadata.gz: c28443bd291a5fe78a46a1c1210f17f8cdfb87561589fd2b396abb5dbb32afd2
4
+ data.tar.gz: 30341a580ecf30d1c310394af9f7e63e5b01e1b3bc2644dfd3a0d140516fefda
5
5
  SHA512:
6
- metadata.gz: d6d8171cd2c1ef7f12abd1008485dc33e952c519dec0f7c563603ab6506b8ab5bd30fcf28821b9ec024ee1a33bdac6c26feb65ffcf7bc707515cf1c5210f029a
7
- data.tar.gz: 9fe0b9a97261d749ed0fa5830e55743595cf0e56fb2599d000dc970abfa30fdfbff1c2bceaa12cb449489882856431d1c718882b129e789d2bb72a5dc1e5db5f
6
+ metadata.gz: 11a2d8682f9de2e3ec48383e185001937ebf1c704874aa4f24ee59a1e2659a18ed671507e26a61e6cb182104cc21ec9d3a37931a933217cca6aaf80df32ae420
7
+ data.tar.gz: 9bd6ee3bbf5a6e4517e804d61c11d4430ab6a8031572eed99ab8e5be8638f9d8b5a82c3a26f1f93b78c1b4cf5976fabe3301edb9c9652454623450a56a6d0829
@@ -85,7 +85,7 @@ module Proscenium
85
85
  end
86
86
 
87
87
  def build_to_string(path)
88
- ActiveSupport::Notifications.instrument('build_to_string.proscenium', identifier: path) do
88
+ ActiveSupport::Notifications.instrument('build.proscenium', identifier: path) do
89
89
  result = Request.build_to_string(path, @request_config)
90
90
 
91
91
  raise BuildError, result[:response] unless result[:success]
@@ -27,9 +27,9 @@ module Proscenium
27
27
  def css_module_string(name)
28
28
  if (path = Pathname.new(context.path).sub_ext('.module.css')).exist?
29
29
  tname = Transformer.new(path).class_name!(name, name.dup).first
30
- "Proscenium::CssModule::Name.new(:@#{name}, '#{tname}')"
30
+ "Proscenium::CssModule::Name.new(:@#{name}, '#{tname}', #{path})"
31
31
  else
32
- "Proscenium::CssModule::Name.new(:@#{name}, css_module(:#{name}))"
32
+ "Proscenium::CssModule::Name.new(:@#{name}, css_module(:#{name}), nil)"
33
33
  end
34
34
  end
35
35
  end
@@ -16,9 +16,12 @@ module Proscenium::CssModule
16
16
  end
17
17
 
18
18
  class Name
19
- def initialize(name, transform)
19
+ attr_reader :path
20
+
21
+ def initialize(name, transform, path = nil)
20
22
  @name = name
21
23
  @transform = transform
24
+ @path = path
22
25
  end
23
26
 
24
27
  def to_s
Binary file
@@ -24,17 +24,23 @@ module Proscenium
24
24
  # @param filepath [String] Absolute URL path (relative to Rails root) of the file to import.
25
25
  # Should be the actual asset file, eg. app.css, some/component.js.
26
26
  # @return [String|nil] the digest of the imported file path if a css module (*.module.css).
27
- def import(filepath = nil, **)
27
+ def import(filepath = nil, sideloaded: false, **)
28
28
  self.imported ||= {}
29
29
 
30
30
  filepath = "/node_modules/#{filepath}" if filepath.start_with?('@rubygems/')
31
31
  css_module = filepath.end_with?('.module.css')
32
32
 
33
33
  unless self.imported.key?(filepath)
34
- # ActiveSupport::Notifications.instrument('sideload.proscenium', identifier: value)
35
-
36
- self.imported[filepath] = { ** }
37
- self.imported[filepath][:digest] = Utils.digest(filepath) if css_module
34
+ if sideloaded
35
+ ActiveSupport::Notifications.instrument 'sideload.proscenium', identifier: filepath,
36
+ sideloaded: do
37
+ self.imported[filepath] = { ** }
38
+ self.imported[filepath][:digest] = Utils.digest(filepath) if css_module
39
+ end
40
+ else
41
+ self.imported[filepath] = { ** }
42
+ self.imported[filepath][:digest] = Utils.digest(filepath) if css_module
43
+ end
38
44
  end
39
45
 
40
46
  css_module ? self.imported[filepath][:digest] : nil
@@ -72,12 +78,17 @@ module Proscenium
72
78
  end
73
79
 
74
80
  def sideload_css(filepath, **)
75
- _sideload(filepath, CSS_EXTENSIONS, **)
81
+ _sideload(filepath, ['.css'], **)
82
+ end
83
+
84
+ def sideload_css_module(filepath, **)
85
+ _sideload(filepath, ['.module.css'], **)
76
86
  end
77
87
 
78
88
  # @param filepath [Pathname] Absolute file system path of the Ruby file to sideload.
79
89
  # @param extensions [Array<String>] Supported file extensions to sideload.
80
90
  # @param options [Hash] Options to pass to `import`.
91
+ # @return [Array<String>] The imported file paths.
81
92
  # @raise [ArgumentError] if `filepath` is not an absolute file system path.
82
93
  private def _sideload(filepath, extensions, **options) # rubocop:disable Style/AccessModifierDeclarations
83
94
  return unless Proscenium.config.side_load
@@ -86,13 +97,18 @@ module Proscenium
86
97
  raise ArgumentError, "`filepath` (#{filepath}) must be a `Pathname`, and an absolute path"
87
98
  end
88
99
 
100
+ # Ensures extensions with more than one dot are handled correctly.
89
101
  filepath = filepath.sub_ext('')
90
102
 
103
+ sideloaded = []
104
+
91
105
  extensions.find do |x|
92
106
  if (fp = filepath.sub_ext(x)).exist?
93
- import(Resolver.resolve(fp.to_s), sideloaded: true, **options)
107
+ sideloaded << import(Resolver.resolve(fp.to_s), sideloaded: filepath, **options)
94
108
  end
95
109
  end
110
+
111
+ sideloaded
96
112
  end
97
113
 
98
114
  def each_stylesheet(delete: false)
@@ -5,17 +5,32 @@ require 'active_support/log_subscriber'
5
5
  module Proscenium
6
6
  class LogSubscriber < ActiveSupport::LogSubscriber
7
7
  def sideload(event)
8
+ path = event.payload[:identifier]
9
+ sideloaded = event.payload[:sideloaded]
10
+ sideloaded = sideloaded.relative_path_from(Rails.root) if sideloaded.is_a?(Pathname)
11
+
12
+ info do
13
+ msg = " #{color('[Proscenium]', nil, bold: true)} Sideloading #{path}"
14
+ sideloaded.is_a?(Pathname) ? msg << " from #{sideloaded}" : msg
15
+ end
16
+ end
17
+
18
+ def build(event)
19
+ path = event.payload[:identifier]
20
+ path = CGI.unescape(path) if path.start_with?(/https?%3A%2F%2F/)
21
+
8
22
  info do
9
- " [Proscenium] Side loaded #{event.payload[:identifier]}"
23
+ message = "#{color('[Proscenium]', nil, bold: true)} Building /#{path}"
24
+ message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
10
25
  end
11
26
  end
12
27
 
13
- def build_to_string(event)
28
+ def resolve(event)
14
29
  path = event.payload[:identifier]
15
30
  path = CGI.unescape(path) if path.start_with?(/https?%3A%2F%2F/)
16
31
 
17
32
  info do
18
- message = " #{color('[Proscenium]', nil, bold: true)} Building (to string) #{path}"
33
+ message = " #{color('[Proscenium]', nil, bold: true)} Resolving #{path}"
19
34
  message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
20
35
  end
21
36
  end
@@ -23,8 +23,9 @@ module Proscenium
23
23
  end
24
24
 
25
25
  def after_template
26
+ self.class.resolved_css_module_paths ||= Concurrent::Set.new
26
27
  self.class.resolved_css_module_paths.each do |path|
27
- Proscenium::Importer.import path
28
+ Proscenium::Importer.import path, sideloaded: true
28
29
  end
29
30
 
30
31
  super
@@ -67,6 +68,8 @@ module Proscenium
67
68
  if attributes.key?(:class) && (attributes[:class] = tokens(attributes[:class])).include?('@')
68
69
  names = attributes[:class].is_a?(Array) ? attributes[:class] : attributes[:class].split
69
70
 
71
+ self.class.resolved_css_module_paths ||= Concurrent::Set.new
72
+
70
73
  attributes[:class] = cssm.class_names(*names).map do |name, path|
71
74
  self.class.resolved_css_module_paths << path if path
72
75
  name
@@ -48,8 +48,6 @@ module Proscenium
48
48
 
49
49
  initializer 'proscenium.middleware' do |app|
50
50
  app.middleware.insert_after ActionDispatch::Static, Proscenium::Middleware
51
- # app.middleware.insert_after ActionDispatch::Static, Rack::ETag, 'no-cache'
52
- # app.middleware.insert_after ActionDispatch::Static, Rack::ConditionalGet
53
51
  end
54
52
 
55
53
  initializer 'proscenium.sideloading' do
@@ -77,14 +75,3 @@ module Proscenium
77
75
  end
78
76
  end
79
77
  end
80
-
81
- if Rails.gem_version < Gem::Version.new('7.1.0')
82
- class ActionDispatch::DebugView
83
- def initialize(assigns)
84
- tpl_path = Proscenium::Railtie.root.join('lib', 'proscenium', 'templates').to_s
85
- paths = [RESCUES_TEMPLATE_PATH, tpl_path]
86
- lookup_context = ActionView::LookupContext.new(paths)
87
- super(lookup_context, assigns, nil)
88
- end
89
- end
90
- end
@@ -46,7 +46,6 @@ module Proscenium
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
 
@@ -86,13 +86,14 @@ module Proscenium
86
86
  end
87
87
 
88
88
  class << self
89
- # 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.
90
91
  #
91
92
  # Set the `abstract_class` class variable to true in any class, and it will not be side
92
93
  # loaded.
93
94
  #
94
- # If the class responds to `.sideload`, it will be called instead of the regular side loading.
95
- # 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.
96
97
  def sideload_inheritance_chain(obj, options)
97
98
  return unless Proscenium.config.side_load
98
99
 
@@ -116,18 +117,28 @@ module Proscenium
116
117
 
117
118
  klass = obj.class
118
119
  while klass.respond_to?(:source_path) && klass.source_path && !klass.abstract_class
119
- if klass.respond_to?(:sideload)
120
- klass.sideload options
121
- elsif options[:css] == false
120
+ if options[:css] == false
122
121
  Importer.sideload klass.source_path, **options
123
122
  else
124
123
  Importer.sideload_js klass.source_path, **options
125
124
  css_imports << klass.source_path
126
125
  end
127
126
 
127
+ klass.sideload options if klass.respond_to?(:sideload)
128
+
128
129
  klass = klass.superclass
129
130
  end
130
131
 
132
+ # All regular CSS files (*.css) are ancestrally sideloaded. However, the first CSS module
133
+ # in the ancestry is also sideloaded in addition to the regular CSS files. This is because
134
+ # the CSS module digest will be different for each file, so we only sideload the first CSS
135
+ # module.
136
+ css_imports.each do |it|
137
+ break if Importer.sideload_css_module(it, **options).present?
138
+ end
139
+
140
+ # Sideload regular CSS files in reverse order.
141
+ #
131
142
  # The reason why we sideload CSS after JS is because the order of CSS is important.
132
143
  # Basically, the layout should be loaded before the view so that CSS cascading works in the
133
144
  # right direction.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'literal'
4
-
5
3
  module Proscenium::UI
6
4
  class Breadcrumbs::Component < Component
7
5
  extend Literal::Properties
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'literal'
4
-
5
3
  module Proscenium::UI
6
4
  # Helpers to aid in building forms and associated inputs with built-in styling, and inspired by
7
5
  # Rails form helpers and SimpleForm.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.19.0.beta7'
4
+ VERSION = '0.19.0.beta9'
5
5
  end
data/lib/proscenium.rb CHANGED
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'zeitwerk'
4
-
5
- # loader = Zeitwerk::Loader.for_gem
6
- # loader.inflector.inflect 'ui' => 'UI'
7
- # loader.ignore "#{__dir__}/proscenium/ext"
8
- # loader.ignore "#{__dir__}/proscenium/libs"
9
- # loader.setup
3
+ require 'active_support'
4
+ require 'active_record/type' # needed by Literal, even though we're not using ActiveRecord
5
+ require 'literal'
10
6
 
11
7
  module Proscenium
12
8
  extend ActiveSupport::Autoload
metadata CHANGED
@@ -1,77 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0.beta7
4
+ version: 0.19.0.beta9
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Joel Moss
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-31 00:00:00.000000000 Z
10
+ date: 2025-04-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: activesupport
13
+ name: countries
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: 7.1.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '9.0'
23
19
  type: :runtime
24
20
  prerelease: false
25
21
  version_requirements: !ruby/object:Gem::Requirement
26
22
  requirements:
27
- - - ">="
23
+ - - "~>"
28
24
  - !ruby/object:Gem::Version
29
25
  version: 7.1.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '9.0'
33
26
  - !ruby/object:Gem::Dependency
34
- name: countries
27
+ name: ffi
35
28
  requirement: !ruby/object:Gem::Requirement
36
29
  requirements:
37
30
  - - "~>"
38
31
  - !ruby/object:Gem::Version
39
- version: 7.1.0
32
+ version: 1.17.0
40
33
  type: :runtime
41
34
  prerelease: false
42
35
  version_requirements: !ruby/object:Gem::Requirement
43
36
  requirements:
44
37
  - - "~>"
45
38
  - !ruby/object:Gem::Version
46
- version: 7.1.0
39
+ version: 1.17.0
47
40
  - !ruby/object:Gem::Dependency
48
- name: ffi
41
+ name: literal
49
42
  requirement: !ruby/object:Gem::Requirement
50
43
  requirements:
51
44
  - - "~>"
52
45
  - !ruby/object:Gem::Version
53
- version: 1.17.0
46
+ version: '1.0'
54
47
  type: :runtime
55
48
  prerelease: false
56
49
  version_requirements: !ruby/object:Gem::Requirement
57
50
  requirements:
58
51
  - - "~>"
59
52
  - !ruby/object:Gem::Version
60
- version: 1.17.0
53
+ version: '1.0'
61
54
  - !ruby/object:Gem::Dependency
62
- name: literal
55
+ name: phlex-rails
63
56
  requirement: !ruby/object:Gem::Requirement
64
57
  requirements:
65
58
  - - "~>"
66
59
  - !ruby/object:Gem::Version
67
- version: '1.0'
60
+ version: '1.2'
68
61
  type: :runtime
69
62
  prerelease: false
70
63
  version_requirements: !ruby/object:Gem::Requirement
71
64
  requirements:
72
65
  - - "~>"
73
66
  - !ruby/object:Gem::Version
74
- version: '1.0'
67
+ version: '1.2'
75
68
  - !ruby/object:Gem::Dependency
76
69
  name: phonelib
77
70
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +80,7 @@ dependencies:
87
80
  - !ruby/object:Gem::Version
88
81
  version: 0.10.3
89
82
  - !ruby/object:Gem::Dependency
90
- name: railties
83
+ name: rails
91
84
  requirement: !ruby/object:Gem::Requirement
92
85
  requirements:
93
86
  - - ">="
@@ -112,15 +105,14 @@ dependencies:
112
105
  requirements:
113
106
  - - "~>"
114
107
  - !ruby/object:Gem::Version
115
- version: 1.0.1
108
+ version: 1.1.1
116
109
  type: :runtime
117
110
  prerelease: false
118
111
  version_requirements: !ruby/object:Gem::Requirement
119
112
  requirements:
120
113
  - - "~>"
121
114
  - !ruby/object:Gem::Version
122
- version: 1.0.1
123
- description:
115
+ version: 1.1.1
124
116
  email:
125
117
  - joel@developwithstyle.com
126
118
  executables: []
@@ -245,7 +237,6 @@ metadata:
245
237
  source_code_uri: https://github.com/joelmoss/proscenium
246
238
  changelog_uri: https://github.com/joelmoss/proscenium/releases
247
239
  rubygems_mfa_required: 'true'
248
- post_install_message:
249
240
  rdoc_options: []
250
241
  require_paths:
251
242
  - lib
@@ -260,8 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
251
  - !ruby/object:Gem::Version
261
252
  version: '0'
262
253
  requirements: []
263
- rubygems_version: 3.5.23
264
- signing_key:
254
+ rubygems_version: 3.6.5
265
255
  specification_version: 4
266
256
  summary: The engine powering your Rails frontend
267
257
  test_files: []