proscenium 0.21.4 → 0.21.5
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/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/log_subscriber.rb +1 -1
- data/lib/proscenium/middleware/silence_request.rb +31 -0
- data/lib/proscenium/middleware.rb +4 -16
- data/lib/proscenium/railtie.rb +8 -1
- data/lib/proscenium/templates/rescues/build_error.html.erb +2 -2
- data/lib/proscenium/version.rb +1 -1
- data/lib/proscenium.rb +5 -3
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ab3a5c048aca3611e56e9cc428a697983195187a077f79c749dea5b9c199856
|
|
4
|
+
data.tar.gz: 1752c0330bbc6a27ef881ee83b60fc99c83254bdbc27abf4f5e16efca28d012e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e052da702cd1966d11605641cb374c6c87b7d411adfe933714b07d7985bd92de1ec2e5cec4a70ed13e513fb503adf869fe0456db6c2b6335ffbbc8590bd2341
|
|
7
|
+
data.tar.gz: 5badf14b8bce9c45ce2325fcc8012bbdd7ec679b5ca64ad1201f19b3613549ffd0031d5ced96c946cc34ded6154efd07e4476359c2ffcdf10cf566d208f2d50e
|
|
Binary file
|
|
@@ -20,7 +20,7 @@ module Proscenium
|
|
|
20
20
|
path = CGI.unescape(path) if path.start_with?(/https?%3A%2F%2F/)
|
|
21
21
|
|
|
22
22
|
info do
|
|
23
|
-
message = "#{color('[Proscenium]', nil, bold: true)} Building /#{path}"
|
|
23
|
+
message = " #{color('[Proscenium]', nil, bold: true)} Building /#{path}"
|
|
24
24
|
message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'active_support/logger_silence'
|
|
4
|
+
|
|
5
|
+
module Proscenium
|
|
6
|
+
class Middleware::SilenceRequest
|
|
7
|
+
def initialize(app)
|
|
8
|
+
@app = app
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(env)
|
|
12
|
+
request = ActionDispatch::Request.new(env)
|
|
13
|
+
|
|
14
|
+
if (request.get? || request.head?) && proscenium_request?(request)
|
|
15
|
+
Rails.logger.silence { @app.call(env) }
|
|
16
|
+
else
|
|
17
|
+
@app.call(env)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def proscenium_request?(request)
|
|
24
|
+
return true if request.path.match?(CHUNKS_PATH)
|
|
25
|
+
|
|
26
|
+
pathname = Pathname.new(request.path)
|
|
27
|
+
pathname.fnmatch?(GEMS_PATH_GLOB, File::FNM_EXTGLOB) ||
|
|
28
|
+
pathname.fnmatch?(APP_PATH_GLOB, File::FNM_EXTGLOB)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -4,12 +4,12 @@ module Proscenium
|
|
|
4
4
|
class Middleware
|
|
5
5
|
extend ActiveSupport::Autoload
|
|
6
6
|
|
|
7
|
-
# Error when the build command fails.
|
|
8
7
|
class BuildError < StandardError; end
|
|
9
8
|
|
|
10
9
|
autoload :Base
|
|
11
10
|
autoload :Esbuild
|
|
12
11
|
autoload :RubyGems
|
|
12
|
+
autoload :SilenceRequest
|
|
13
13
|
|
|
14
14
|
def initialize(app)
|
|
15
15
|
@app = app
|
|
@@ -22,7 +22,7 @@ module Proscenium
|
|
|
22
22
|
|
|
23
23
|
# If this is a request for an asset chunk, we want to serve it with a very long
|
|
24
24
|
# cache lifetime, since these are content-hashed and will never change.
|
|
25
|
-
if request.path.match?(
|
|
25
|
+
if request.path.match?(CHUNKS_PATH)
|
|
26
26
|
::ActionDispatch::FileHandler.new(
|
|
27
27
|
Rails.public_path.join('assets').to_s,
|
|
28
28
|
headers: {
|
|
@@ -46,23 +46,11 @@ module Proscenium
|
|
|
46
46
|
def find_type(request)
|
|
47
47
|
pathname = Pathname.new(request.path)
|
|
48
48
|
|
|
49
|
-
if pathname.fnmatch?(
|
|
49
|
+
if pathname.fnmatch?(GEMS_PATH_GLOB, File::FNM_EXTGLOB)
|
|
50
50
|
RubyGems
|
|
51
|
-
elsif pathname.fnmatch?(
|
|
51
|
+
elsif pathname.fnmatch?(APP_PATH_GLOB, File::FNM_EXTGLOB)
|
|
52
52
|
Esbuild
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
|
-
|
|
56
|
-
def app_path_glob
|
|
57
|
-
"/{#{Proscenium::ALLOWED_DIRECTORIES}}/**.{#{file_extensions}}"
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def gems_path_glob
|
|
61
|
-
"/node_modules/@rubygems/**.{#{file_extensions}}"
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def file_extensions
|
|
65
|
-
@file_extensions ||= FILE_EXTENSIONS.join(',')
|
|
66
|
-
end
|
|
67
55
|
end
|
|
68
56
|
end
|
data/lib/proscenium/railtie.rb
CHANGED
|
@@ -46,7 +46,10 @@ module Proscenium
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
initializer 'proscenium.middleware' do |app|
|
|
49
|
-
|
|
49
|
+
unless config.proscenium.logging
|
|
50
|
+
app.middleware.insert_before Rails::Rack::Logger, Proscenium::Middleware::SilenceRequest
|
|
51
|
+
end
|
|
52
|
+
app.middleware.insert_before ActionDispatch::ActionableExceptions, Proscenium::Middleware
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
initializer 'proscenium.sideloading' do
|
|
@@ -62,5 +65,9 @@ module Proscenium
|
|
|
62
65
|
ActionView::PartialRenderer.prepend Monkey::PartialRenderer
|
|
63
66
|
end
|
|
64
67
|
end
|
|
68
|
+
|
|
69
|
+
rake_tasks do
|
|
70
|
+
load 'proscenium/railties/compile.rake'
|
|
71
|
+
end
|
|
65
72
|
end
|
|
66
73
|
end
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
<%= @exception.error['location']['line'].to_s.rjust 5 %> │ <%= @exception.error['location']['line_text'] %>
|
|
21
21
|
│ <%= (@exception.error['location']['length'] > 1 ? "~" * @exception.error['location']['length'] : "^").rjust(@exception.error['location']['column'] + @exception.error['location']['length']) %>
|
|
22
|
-
<%- if @exception.error['location']['suggestion'].present?
|
|
23
|
-
<% else %> <%- end
|
|
22
|
+
<%- if @exception.error['location']['suggestion'].present? %> + │ <%= @exception.error['location']['suggestion'].rjust(@exception.error['location']['column'] + 1) %>
|
|
23
|
+
<% else %> <%- end %>
|
|
24
24
|
</pre>
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
data/lib/proscenium/version.rb
CHANGED
data/lib/proscenium.rb
CHANGED
|
@@ -5,9 +5,6 @@ require 'active_support'
|
|
|
5
5
|
module Proscenium
|
|
6
6
|
extend ActiveSupport::Autoload
|
|
7
7
|
|
|
8
|
-
FILE_EXTENSIONS = ['js', 'mjs', 'ts', 'jsx', 'tsx', 'css', 'js.map', 'mjs.map', 'jsx.map',
|
|
9
|
-
'ts.map', 'tsx.map', 'css.map'].freeze
|
|
10
|
-
|
|
11
8
|
# Default paths for Rails assets. Used by the `compute_asset_path` helper to maintain Rails
|
|
12
9
|
# default conventions of where JS and CSS files are located.
|
|
13
10
|
DEFAULT_RAILS_ASSET_PATHS = {
|
|
@@ -15,7 +12,12 @@ module Proscenium
|
|
|
15
12
|
javascript: 'app/javascript/'
|
|
16
13
|
}.freeze
|
|
17
14
|
|
|
15
|
+
FILE_EXTENSIONS = ['js', 'mjs', 'ts', 'jsx', 'tsx', 'css', 'js.map', 'mjs.map', 'jsx.map',
|
|
16
|
+
'ts.map', 'tsx.map', 'css.map'].freeze
|
|
18
17
|
ALLOWED_DIRECTORIES = 'app,lib,config,vendor,node_modules'
|
|
18
|
+
APP_PATH_GLOB = "/{#{ALLOWED_DIRECTORIES}}/**.{#{FILE_EXTENSIONS.join(',')}}".freeze
|
|
19
|
+
GEMS_PATH_GLOB = "/node_modules/@rubygems/**.{#{FILE_EXTENSIONS.join(',')}}".freeze
|
|
20
|
+
CHUNKS_PATH = %r{^/_asset_chunks/}
|
|
19
21
|
|
|
20
22
|
# Environment variables that should always be passed to the builder.
|
|
21
23
|
DEFAULT_ENV_VARS = Set['RAILS_ENV', 'NODE_ENV'].freeze
|
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.21.
|
|
4
|
+
version: 0.21.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Moss
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -70,6 +70,7 @@ files:
|
|
|
70
70
|
- lib/proscenium/middleware/base.rb
|
|
71
71
|
- lib/proscenium/middleware/esbuild.rb
|
|
72
72
|
- lib/proscenium/middleware/ruby_gems.rb
|
|
73
|
+
- lib/proscenium/middleware/silence_request.rb
|
|
73
74
|
- lib/proscenium/monkey.rb
|
|
74
75
|
- lib/proscenium/railtie.rb
|
|
75
76
|
- lib/proscenium/react-manager/index.jsx
|