proscenium 0.19.0.beta20-aarch64-linux → 0.20.0-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: 7b8800c8cdac40a504951a4f4c6991d695d84cc417c9e70a0fd7881c35c40b1e
4
- data.tar.gz: ab7f98fd1e9babd944cae54ff4e025d24c2bb1ac1705a5b6ba3fec4cff1d1796
3
+ metadata.gz: f732bbb4ca60aaa281b4de37e84dec4eeffd7978a5fa9f87a7948202887ba157
4
+ data.tar.gz: c5cc0839a611c3599a12b46646fe05f8f0a5c46594449f375b6d54258a3b0da9
5
5
  SHA512:
6
- metadata.gz: 066161a3dddcb31dc76144124a6c96a5e169dae975aab3e7a100d9b5f067e1bff5b8dee35a9dd9df35369cb5fdb5e3ba2ed6ba96afbb8b39e3f82b4fd062878f
7
- data.tar.gz: dca021c7c4849048db4cbd942ab18c072cce5a14a0bf0cf93daa9dd724620c874bfa25170410b742ff6aeec5a8b4f5f717f4b34431bfff68adce155a35e01b78
6
+ metadata.gz: e1c94f9ee0ad1e5c5bfb782d904a6c502ba0985149fdc7024cf92802298f4bc85fd562d23ab491c450eb527ee0af952e893a0dc975c9ae6823a70702c284055b
7
+ data.tar.gz: a92e3e734d397cb1161d609231cc04dddf3ce6a294ad64b1fcc5301155b4750f9ed7dc197e5858193491fe98fe9da99b966f235deaa1c74bf01b0206002e91fa
data/README.md CHANGED
@@ -6,17 +6,17 @@
6
6
  >
7
7
  > - _the part of a theatre stage in front of the curtain._
8
8
 
9
- **_Proscenium_** treats your frontend and client-side code as first class citizens of your Rails app, and assumes a "fast by default" internet. It bundles and minifies JavaScript (+ JSX), TypeScript (+TSX) and CSS in real time, on demand, and with zero configuration.
9
+ **_Proscenium_** treats your frontend and client-side code as first class citizens of your Rails app, and assumes a "fast by default" internet. It bundles and minifies JavaScript (+JSX), TypeScript (+TSX) and CSS in real time, on demand, and with zero configuration.
10
10
 
11
11
  **The highlights:**
12
12
 
13
13
  - Fast, real-time bundling, tree-shaking, code-splitting and minification of Javascript (.js,.jsx), Typescript (.ts,.tsx) and CSS (.css).
14
14
  - NO JavaScript runtime needed (eg. Node) - just the browser!
15
15
  - NO build step or pre-compilation.
16
- - NO additional process or server - Just run `rails s`!
16
+ - NO additional process or server - Just run `rails server`!
17
17
  - Transforms newer JavaScript and CSS syntax to older syntax for older browsers.
18
18
  - Deep integration with Rails.
19
- - Automatically side-load your layouts, views, and partials.
19
+ - Automatically side-load JS and CSS for your layouts, views, and partials.
20
20
  - Import from NPM, URL's, and locally.
21
21
  - Server-side import map support.
22
22
  - CSS Modules & mixins.
@@ -75,15 +75,15 @@ gem 'proscenium'
75
75
 
76
76
  Please note that Proscenium is designed solely for use with Rails.
77
77
 
78
- Now if you start your Rails app, you can open any front end code (JS, CSS, etc.). For example, a file at `app/assets/stylesheets/application.css` can be accessed at `https://localhost:3000/app/assets/stylesheets/application.css`, which will be bundled, transformed, and minified [in production] in real time.
78
+ Now if you start your Rails app, you can open any front end code (JS, CSS, etc.). For example, a file at `app/assets/stylesheets/application.css` can be accessed at `https://localhost:3000/app/assets/stylesheets/application.css`, which will be transformed, bundled, and minified [in production] in real time.
79
79
 
80
80
  ## Client-Side Code Anywhere
81
81
 
82
- Proscenium believes that your frontend code is just as important as your backend code, and is not an afterthought - they should be first class citizens of your Rails app. So instead of having to throw all your JS and CSS into a "app/assets" directory, and then requiring a separate process to compile or bundle, just put them wherever you want within your app, and just run Rails!
82
+ Proscenium believes that your frontend code is just as important as your backend code, and is not an afterthought - they should be first class citizens of your Rails app. So instead of having to throw all your JS and CSS into a "app/assets" directory, and then requiring a separate process to compile or bundle, you can simply put them wherever you want within your app, and just run Rails!
83
83
 
84
84
  For example, if you have some JS that is required by your `app/views/users/index.html.erb` view, just create a JS file alongside it at `app/views/users/index.js`. Or if you have some CSS that is used by your entire application, put it in `app/views/layouts/application.css` and load it alongside your layout. Maybe you have a few JS utility functions, so put them in `lib/utils.js`.
85
85
 
86
- Simply put your JS(X) and CSS anywhere you want, and they will be served by your Rails app from the location where you placed them.
86
+ Simply put your JS(X) and CSS anywhere you want, and they will be served by your Rails app from the same location where you placed them.
87
87
 
88
88
  Using the examples above...
89
89
 
@@ -95,15 +95,15 @@ Using the examples above...
95
95
 
96
96
  ## Side Loading
97
97
 
98
- Proscenium is best experienced when your assets are automtically side loaded.
98
+ Proscenium is best experienced when your assets are automatically side loaded.
99
99
 
100
100
  ### The Problem
101
101
 
102
- With Rails you would typically declaratively load your JavaScript and CSS assets using the `javascript_include_tag` and `stylesheet_link_tag` helpers.
102
+ With Rails you would typically load your JavaScript and CSS assets declaratively using the `javascript_include_tag` and `stylesheet_link_tag` helpers.
103
103
 
104
- For example, you may have top-level "application" CSS located in a file at `/app/assets/stylesheets/application.css`. Likewise, you may have some global JavaScript located in a file at `/app/javascript/application.js`.
104
+ For example, you may have top-level "application" styles located in a file at `/app/assets/stylesheets/application.css`. Likewise, you may have some global JavaScript located in a file at `/app/javascript/application.js`.
105
105
 
106
- You would manually and declaratively include those two files in your application layout, something like this:
106
+ You would manually and declaratively include those two files in each of your layouts, something like this:
107
107
 
108
108
  ```erb
109
109
  <%# /app/views/layouts/application.html.erb %>
@@ -141,7 +141,9 @@ The main problem is that you have to keep track of all these assets, and make su
141
141
 
142
142
  When side loading your JavaScript, Typescript and CSS with Proscenium, they are automatically included alongside your views, partials, layouts, and components, and only when needed.
143
143
 
144
- Side loading works by looking for a JS/TS/CSS file with the same name as your view, partial, layout or component. For example, if you have a view at `app/views/users/index.html.erb`, then Proscenium will look for a JS/TS/CSS file at `app/views/users/index.js`, `app/views/users/index.ts` or `app/views/users/index.css`. If it finds one, it will include it in the HTML for that view.
144
+ Side loading works by looking for a JS/TS/CSS file with the same name as your view, partial, layout or component. For example, if you have a view at `app/views/users/index.html.erb`, then Proscenium will look for a JS and CSS file at `app/views/users/index.js` (or TypeScript with a .ts extension) and `app/views/users/index.css`. If it finds one, it will automatically include it in the HTML for that view. And only for that view.
145
+
146
+ This allows you to keep your assets organized alongside the views, partials, and components that use them, without having to manually track and include them. It also means only the assets that are needed are included.
145
147
 
146
148
  JSX is also supported for JavaScript and Typescript. Simply use the `.jsx` or `.tsx` extension instead of `.js` or `.ts`.
147
149
 
@@ -272,6 +274,14 @@ Then just import as normal:
272
274
  import React from "react";
273
275
  ```
274
276
 
277
+ Or if you don't want any bundling at all, simply turn it off application-wide:
278
+
279
+ ```ruby
280
+ config.proscenium.bundle = false
281
+ ```
282
+
283
+ This will mean every asset and import will be loaded independently.
284
+
275
285
  ## Import Maps
276
286
 
277
287
  > **[WIP]**
@@ -405,13 +415,17 @@ if (typeof proscenium.env?.UNKNOWN !== "undefined") {
405
415
 
406
416
  ## i18n
407
417
 
408
- Basic support is provided for importing your Rails locale files from `config/locales/*.yml`, exporting them as JSON.
418
+ Support is provided for importing your Rails locale files from `config/locales/*.yml`, exporting them as JSON.
409
419
 
410
420
  ```js
411
421
  import translations from "proscenium/i18n";
412
422
  // translations.en.*
413
423
  ```
414
424
 
425
+ If you have multiple locale files, they will be merged together. into one json object.
426
+
427
+ Note that because it is assumed that you will be consuming these translations in the browser, all keys are converted to camelCase, as per the JavaScript conventions.
428
+
415
429
  ## Javascript
416
430
 
417
431
  By default, Proscenium's output will take advantage of all modern JS features from the ES2022 spec and earlier. For example, `a !== void 0 && a !== null ? a : b` will become `a ?? b` when minifying (enabled by default in production), which makes use of syntax from the ES2020 version of JavaScript. Any syntax feature that is not supported by ES2020 will be transformed into older JavaScript syntax that is more widely supported.
@@ -441,8 +455,6 @@ one();
441
455
 
442
456
  ### Code Splitting
443
457
 
444
- > Available in `>=0.10.0`.
445
-
446
458
  [Side loaded](#side-loading) assets are automatically code split. This means that if you have a file that is imported and used imported several times, and by different files, it will be split off into a separate file.
447
459
 
448
460
  As an example:
@@ -682,8 +694,6 @@ console.log(version);
682
694
 
683
695
  ## Cache Busting
684
696
 
685
- > _COMING SOON_
686
-
687
697
  By default, all assets are not cached by the browser. But if in production, you populate the `REVISION` env variable, all CSS and JS URL's will be appended with its value as a query string, and the `Cache-Control` response header will be set to `public` and a max-age of 30 days.
688
698
 
689
699
  For example, if you set `REVISION=v1`, URL's will be appended with `?v1`: `/my/imported/file.js?v1`.
@@ -16,6 +16,7 @@ module Proscenium
16
16
 
17
17
  module Request
18
18
  extend FFI::Library
19
+
19
20
  ffi_lib Pathname.new(__dir__).join('ext/proscenium').to_s
20
21
 
21
22
  enum :environment, [:development, 1, :test, :production]
@@ -70,7 +70,7 @@ module Proscenium
70
70
  digest = Importer.import(resolved_path)
71
71
 
72
72
  transformed_path = ''
73
- transformed_path = "__#{resolved_path[1..].gsub(%r{[@/\.+]}, '-')}" if Rails.env.development?
73
+ transformed_path = "__#{resolved_path[1..].gsub(%r{[@/.+]}, '-')}" if Rails.env.development?
74
74
  transformed_name = name.to_s
75
75
  transformed_name = if transformed_name.start_with?('_')
76
76
  "_#{transformed_name[1..]}-#{digest}#{transformed_path}"
Binary file
@@ -40,18 +40,6 @@ module Proscenium
40
40
  .map { |name, _| name }.join(' ')
41
41
  end
42
42
 
43
- # @param name [String,Symbol,Array<String,Symbol>]
44
- # @param path [Pathname] the path to the CSS file to use for the transformation.
45
- # @return [String] the transformed CSS module names concatenated as a string.
46
- def class_names(*names, path: nil)
47
- names = names.flatten.compact
48
-
49
- return if names.empty?
50
-
51
- path ||= Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
52
- CssModule::Transformer.new(path).class_names(*names).map { |name, _| name }.join(' ')
53
- end
54
-
55
43
  def include_assets
56
44
  include_stylesheets + include_javascripts
57
45
  end
@@ -98,7 +98,7 @@ module Proscenium
98
98
  end
99
99
 
100
100
  # Ensures extensions with more than one dot are handled correctly.
101
- filepath = filepath.sub_ext('')
101
+ filepath = filepath.sub_ext('').sub_ext('')
102
102
 
103
103
  sideloaded = []
104
104
 
@@ -13,10 +13,6 @@ module Proscenium
13
13
 
14
14
  def initialize(app)
15
15
  @app = app
16
-
17
- chunks_path = Rails.public_path.join('assets').to_s
18
- headers = Rails.application.config.public_file_server.headers || {}
19
- @chunk_handler = ::ActionDispatch::FileHandler.new(chunks_path, headers:)
20
16
  end
21
17
 
22
18
  def call(env)
@@ -24,23 +20,19 @@ module Proscenium
24
20
 
25
21
  return @app.call(env) if !request.get? && !request.head?
26
22
 
23
+ # If this is a request for an asset chunk, we want to serve it with a very long
24
+ # cache lifetime, since these are content-hashed and will never change.
27
25
  if request.path.match?(%r{^/_asset_chunks/})
28
- response = Rack::Response[*@chunk_handler.attempt(request.env)]
29
- response.etag = request.path.match(/-\$([a-z0-9]+)\$/i)[1]
30
-
31
- if Proscenium.config.cache_query_string && Proscenium.config.cache_max_age
32
- response.cache! Proscenium.config.cache_max_age
33
- end
34
-
35
- if request.fresh?(response)
36
- response.status = 304
37
- response.body = []
38
- end
39
-
40
- return response.finish
26
+ ::ActionDispatch::FileHandler.new(
27
+ Rails.public_path.join('assets').to_s,
28
+ headers: {
29
+ 'Cache-Control' => "public, max-age=#{100.years}, immutable",
30
+ 'etag' => request.path.match(/-\$([a-z0-9]+)\$/i)[1]
31
+ }
32
+ ).attempt(env) || @app.call(env)
33
+ else
34
+ attempt(request) || @app.call(env)
41
35
  end
42
-
43
- attempt(request) || @app.call(env)
44
36
  end
45
37
 
46
38
  private
@@ -9,11 +9,11 @@ module Proscenium
9
9
  result = super
10
10
  return result if !view.controller || !Proscenium.config.side_load
11
11
 
12
- to_sideload = if template.respond_to?(:virtual_path) &&
12
+ to_sideload = if template.respond_to?(:identifier) &&
13
13
  template.respond_to?(:type) && template.type == :html
14
14
  template
15
15
  end
16
- if to_sideload
16
+ if to_sideload && view.controller.respond_to?(:sideload_assets_options)
17
17
  options = view.controller.sideload_assets_options
18
18
  layout = find_layout(layout_name, locals.keys, [formats.first])
19
19
  sideload_template_assets layout, view.controller, options if layout
@@ -40,7 +40,7 @@ module Proscenium
40
40
  options[k] = controller.instance_eval(&options[k]) if options[k].is_a?(Proc)
41
41
  end
42
42
 
43
- Importer.sideload Rails.root.join("app/views/#{tpl.virtual_path}"), **options
43
+ Importer.sideload Pathname.new(tpl.identifier), **options
44
44
  end
45
45
  end
46
46
 
@@ -52,8 +52,9 @@ module Proscenium
52
52
 
53
53
  return result if !view.controller || !Proscenium.config.side_load
54
54
 
55
- if template.respond_to?(:virtual_path) &&
56
- template.respond_to?(:type) && template.type == :html
55
+ if template.respond_to?(:identifier) &&
56
+ template.respond_to?(:type) && template.type == :html &&
57
+ view.controller.respond_to?(:sideload_assets_options)
57
58
  options = view.controller.sideload_assets_options
58
59
  sideload_template_assets layout, options if layout
59
60
  sideload_template_assets template, options
@@ -79,7 +80,7 @@ module Proscenium
79
80
  options[k] = controller.instance_eval(&options[k]) if options[k].is_a?(Proc)
80
81
  end
81
82
 
82
- Importer.sideload Rails.root.join("app/views/#{tpl.virtual_path}"), **options
83
+ Importer.sideload Pathname.new(tpl.identifier), **options
83
84
  end
84
85
  end
85
86
  end
@@ -134,7 +134,7 @@ module Proscenium
134
134
  # in the ancestry is also sideloaded in addition to the regular CSS files. This is because
135
135
  # the CSS module digest will be different for each file, so we only sideload the first CSS
136
136
  # module.
137
- css_imports.each do |it|
137
+ css_imports.each do |it| # rubocop:disable Style/ItAssignment
138
138
  break if Importer.sideload_css_module(it, **options).present?
139
139
  end
140
140
 
@@ -143,7 +143,7 @@ module Proscenium
143
143
  # The reason why we sideload CSS after JS is because the order of CSS is important.
144
144
  # Basically, the layout should be loaded before the view so that CSS cascading works in the
145
145
  # right direction.
146
- css_imports.reverse_each do |it|
146
+ css_imports.reverse_each do |it| # rubocop:disable Style/ItAssignment
147
147
  Importer.sideload_css it, **options
148
148
  end
149
149
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.19.0.beta20'
4
+ VERSION = '0.20.0'
5
5
  end
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.beta20
4
+ version: 0.20.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-22 00:00:00.000000000 Z
11
+ date: 2025-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi