proscenium 0.22.0.beta3-x86_64-darwin → 0.22.0.beta4-x86_64-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: b3bfb2a67a11f5dd86e0ecad9e15158b8cd3a387b99427bfd0c538b5eee6ff54
4
- data.tar.gz: 622ac9d0c8ba1c1ff8ea38e0f1505202464f926496572f5b25f71c1654dd2089
3
+ metadata.gz: 2f3ef4d46e1d6c291e9bd34781f0ec367e698f7b84adc45f56ff395ee0a7a48d
4
+ data.tar.gz: 35ed55e564ba803efefe58bef4c3dcd050ea105bd399fda7ae73fba4ce056edf
5
5
  SHA512:
6
- metadata.gz: fb039f697724d744c9a00d809bc945f8aa3434acc13d76944353774553370850560edc600f982c9f9e1c13cc886f74a31b60762a10d42889b2b2c9ee5e901f93
7
- data.tar.gz: c702281a718e00387c51d1bb7086415ca8f932d75b07aa1182f5ab1df167b8d42928ac849072254cf5dc6fbc4020ec94846b288f1c6fd7a2a67413aac2b6a5d5
6
+ metadata.gz: 64facb09186047f861d5ca70e763b438b6a27885089b90808a542d92bb2632e47065184f16eb495280798d1014cb1dbd4035233322fa37ff3101c363f017299a
7
+ data.tar.gz: 8a2a1309dcfb65865d721a03fead818966faffa5e8f09556d003b5706dd6200335b2fdaf885d27a8ee50f92d54b865bbc895e5a94507f200985498344ac8a6d6
data/README.md CHANGED
@@ -48,6 +48,7 @@
48
48
  - [JSON](#json)
49
49
  - [rjs is back!](#rjs-is-back)
50
50
  - [Resolution](#resolution)
51
+ - [Aliases](#aliases)
51
52
  - [Pre-compilation](#precompilation)
52
53
  - [Thanks](#thanks)
53
54
  - [Development](#development)
@@ -653,6 +654,24 @@ You can continue to access any file in the `/public` directory as you normally w
653
654
 
654
655
  If requesting a file that exists in a root directory and the public directory, the file in the public directory will be served. For example, if you have a file at `/lib/foo.js` and `/public/lib/foo.js`, and you request `/lib/foo.js`, the file in the public directory (`/public/lib/foo.js`) will be served.
655
656
 
657
+ ## Aliases
658
+
659
+ You can define import aliases via the `config.proscenium.aliases` config option. This allows you to create shorter or more meaningful import paths.
660
+
661
+ ```ruby
662
+ config.proscenium.aliases = {
663
+ "utils": "/lib/utils.js",
664
+ "components": "/app/components"
665
+ }
666
+ ```
667
+
668
+ You can then import using the alias:
669
+
670
+ ```js
671
+ import utils from "utils";
672
+ import Header from "components/header";
673
+ ```
674
+
656
675
  ## Pre-compilation
657
676
 
658
677
  Proscenium is designed to bundle and minify your frontend code in real time, on demand, with no build step or pre-compilation needed. However, if you want to pre-compile your assets for production deployment, you can do so using the `assets:precompile` Rake task.
@@ -95,6 +95,7 @@ module Proscenium
95
95
  RubyGems: Proscenium::BundledGems.paths,
96
96
  Bundle: Proscenium.config.bundle,
97
97
  Aliases: Proscenium.config.aliases,
98
+ External: Proscenium.config.external,
98
99
  Precompile: Proscenium.config.precompile,
99
100
  Debug: Proscenium.config.debug
100
101
  }.to_json)
Binary file
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium
4
+ class Middleware
5
+ class Chunks
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ request = ActionDispatch::Request.new(env)
12
+
13
+ return @app.call(env) unless request.path.match?(CHUNKS_PATH)
14
+
15
+ ActionDispatch::FileHandler.new(
16
+ Proscenium.config.output_path.to_s,
17
+ headers: {
18
+ 'X-Proscenium-Middleware' => 'chunks',
19
+ 'Cache-Control' => "public, max-age=#{100.years}, immutable",
20
+ 'ETag' => request.path.match(/-\$([a-z0-9]+)\$/i)[1]
21
+ }
22
+ ).attempt(request.env) || @app.call(env)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium
4
+ class Middleware
5
+ class Vendor
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ request = ActionDispatch::Request.new(env)
12
+ pathname = Pathname.new(request.path)
13
+
14
+ return @app.call(env) unless pathname.fnmatch?(VENDOR_PATH_GLOB, File::FNM_EXTGLOB)
15
+
16
+ request.path_info = request.path.delete_prefix('/vendor')
17
+
18
+ ActionDispatch::FileHandler.new(
19
+ Rails.root.join('vendor').to_s,
20
+ headers: {
21
+ 'X-Proscenium-Middleware' => 'vendor',
22
+ 'Cache-Control' => "public, max-age=#{100.years}, immutable"
23
+ }
24
+ ).attempt(request.env) || @app.call(env)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -9,6 +9,8 @@ module Proscenium
9
9
  autoload :Base
10
10
  autoload :Esbuild
11
11
  autoload :RubyGems
12
+ autoload :Vendor
13
+ autoload :Chunks
12
14
  autoload :SilenceRequest
13
15
 
14
16
  def initialize(app)
@@ -20,16 +22,7 @@ module Proscenium
20
22
 
21
23
  return @app.call(env) if !request.get? && !request.head?
22
24
 
23
- if request.path.match?(CHUNKS_PATH)
24
- ::ActionDispatch::FileHandler.new(
25
- Proscenium.config.output_path.to_s,
26
- headers: {
27
- 'etag' => request.path.match(/-\$([a-z0-9]+)\$/i)[1]
28
- }
29
- ).attempt(env) || @app.call(env)
30
- else
31
- attempt(request) || @app.call(env)
32
- end
25
+ attempt(request) || @app.call(env)
33
26
  end
34
27
 
35
28
  private
@@ -37,7 +30,7 @@ module Proscenium
37
30
  def attempt(request)
38
31
  return unless (type = find_type(request))
39
32
 
40
- type.attempt request
33
+ type.attempt(request)
41
34
  end
42
35
 
43
36
  def find_type(request)
@@ -16,6 +16,7 @@ module Proscenium
16
16
  config.proscenium.code_splitting = true
17
17
  config.proscenium.ensure_loaded = :raise
18
18
  config.proscenium.aliases = {}
19
+ config.proscenium.external = Set['*.rjs', '*.gif', '*.jpg', '*.png', '*.woff2', '*.woff']
19
20
  config.proscenium.precompile = Set.new
20
21
  config.proscenium.output_dir = '/assets'
21
22
 
@@ -55,6 +56,9 @@ module Proscenium
55
56
  app.middleware.insert_before Rails::Rack::Logger, Proscenium::Middleware::SilenceRequest
56
57
  end
57
58
 
59
+ app.middleware.insert_after Rack::Sendfile, Proscenium::Middleware::Vendor
60
+ app.middleware.insert_after Rack::Sendfile, Proscenium::Middleware::Chunks
61
+
58
62
  # Ensure the middleware is inserted as early as possible.
59
63
  if app.config.consider_all_requests_local
60
64
  app.middleware.insert_before ActionDispatch::ActionableExceptions, Proscenium::Middleware
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.22.0.beta3'
4
+ VERSION = '0.22.0.beta4'
5
5
  end
data/lib/proscenium.rb CHANGED
@@ -14,7 +14,8 @@ module Proscenium
14
14
 
15
15
  FILE_EXTENSIONS = ['js', 'mjs', 'ts', 'jsx', 'tsx', 'css', 'js.map', 'mjs.map', 'jsx.map',
16
16
  'ts.map', 'tsx.map', 'css.map'].freeze
17
- ALLOWED_DIRECTORIES = 'app,lib,config,vendor,node_modules'
17
+ ALLOWED_DIRECTORIES = 'app,lib,config,node_modules'
18
+ VENDOR_PATH_GLOB = '/vendor/**.{js,css}'
18
19
  APP_PATH_GLOB = "/{#{ALLOWED_DIRECTORIES}}/**.{#{FILE_EXTENSIONS.join(',')}}".freeze
19
20
  GEMS_PATH_GLOB = "/node_modules/@rubygems/**.{#{FILE_EXTENSIONS.join(',')}}".freeze
20
21
  CHUNKS_PATH = %r{^/_asset_chunks/}
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.22.0.beta3
4
+ version: 0.22.0.beta4
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -69,9 +69,11 @@ files:
69
69
  - lib/proscenium/manifest.rb
70
70
  - lib/proscenium/middleware.rb
71
71
  - lib/proscenium/middleware/base.rb
72
+ - lib/proscenium/middleware/chunks.rb
72
73
  - lib/proscenium/middleware/esbuild.rb
73
74
  - lib/proscenium/middleware/ruby_gems.rb
74
75
  - lib/proscenium/middleware/silence_request.rb
76
+ - lib/proscenium/middleware/vendor.rb
75
77
  - lib/proscenium/monkey.rb
76
78
  - lib/proscenium/railtie.rb
77
79
  - lib/proscenium/railties/assets.rake