proscenium 0.22.0.beta3-arm64-darwin → 0.22.0.beta4-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 +4 -4
- data/README.md +19 -0
- data/lib/proscenium/builder.rb +1 -0
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/middleware/chunks.rb +26 -0
- data/lib/proscenium/middleware/vendor.rb +28 -0
- data/lib/proscenium/middleware.rb +4 -11
- data/lib/proscenium/railtie.rb +4 -0
- data/lib/proscenium/version.rb +1 -1
- data/lib/proscenium.rb +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31c2b9b5e2e0f22192302caea2e404ea4bc6ac6044d6edd4b59751716b8ac84e
|
|
4
|
+
data.tar.gz: 92494e43b1470603e10046f2901f3abe3d7dc4aaaebe60d6194d5faf3695e627
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1643d7f4d7563a1d7aeceab68e597b71dc6b0ee2d922621849d52f6e35c88c9b610fca42c5f3af30352b2e45238a3a440f04c42f8603115b5b098ad8f2b1a502
|
|
7
|
+
data.tar.gz: 66306450d1de78849fada32948ad4036664b1114083039202090b7521a764030d61ec8f679625b183b79e45e8f28899485495b54308cf0f2631da91f64a893f7
|
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.
|
data/lib/proscenium/builder.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
|
33
|
+
type.attempt(request)
|
|
41
34
|
end
|
|
42
35
|
|
|
43
36
|
def find_type(request)
|
data/lib/proscenium/railtie.rb
CHANGED
|
@@ -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
|
data/lib/proscenium/version.rb
CHANGED
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,
|
|
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.
|
|
4
|
+
version: 0.22.0.beta4
|
|
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-
|
|
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
|