proscenium 0.19.0-x86_64-linux → 0.20.1-x86_64-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: e686c9d55f815ad70fc17be7ad98bde1bfaf57dd426464a75fda4b3f08fd3d9d
4
- data.tar.gz: 362e72b47cdcb0743cff1ab94e3cc413f2b85e605225fbc2706342760958133a
3
+ metadata.gz: 22c982d0c998870ee599aba5e42ad84599420a6cdbcd16b98bf94d0786a9c6f2
4
+ data.tar.gz: 0bf66ecd15e6709d462f188a5599c1edba653227171b9373809b423177c57b3c
5
5
  SHA512:
6
- metadata.gz: 17a945e83e1e18faff56b408ef10245dec73b7baea589f41fc5125d7febb89f88463c09b2a868889ee8275879961b2e04cf3b9ef6c6632f1612504aa7d4aa2ae
7
- data.tar.gz: 889ed2b063887281c9aa1e51c28f5c7aad1bc8f400bf5090e7121b0fc6718c9e4584b9c5d5320a99a8029c4cccd1255fffaefa761f648920d879ea45463c390d
6
+ metadata.gz: fe52870dfa416cc26b7c1183e0f85c4c20e5d0bd83ba214fcf1bd4311dfcb3a10ce902ea027226d6a50af6d51daf3dd1c8965d3ac7ab9b1a7bfa01014719dc45
7
+ data.tar.gz: 79708350eafc8597f0bea7951214164bce24e967d2f07efa82d40988e8d1406cc64876f05d0d85036a5c260d92fc29b634c168d5edf8e593b52b3f211d38df84
data/README.md CHANGED
@@ -415,13 +415,17 @@ if (typeof proscenium.env?.UNKNOWN !== "undefined") {
415
415
 
416
416
  ## i18n
417
417
 
418
- 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.
419
419
 
420
420
  ```js
421
421
  import translations from "proscenium/i18n";
422
422
  // translations.en.*
423
423
  ```
424
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
+
425
429
  ## Javascript
426
430
 
427
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.
Binary file
@@ -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
@@ -24,6 +24,8 @@ module Proscenium
24
24
  end
25
25
 
26
26
  def sideload_template_assets(tpl, controller, options)
27
+ return unless (tpl_path = Pathname.new(tpl.identifier)).file?
28
+
27
29
  options = {} if options.nil?
28
30
  options = { js: options, css: options } unless options.is_a?(Hash)
29
31
 
@@ -40,7 +42,7 @@ module Proscenium
40
42
  options[k] = controller.instance_eval(&options[k]) if options[k].is_a?(Proc)
41
43
  end
42
44
 
43
- Importer.sideload Rails.root.join("app/views/#{tpl.virtual_path}"), **options
45
+ Importer.sideload tpl_path, **options
44
46
  end
45
47
  end
46
48
 
@@ -52,8 +54,9 @@ module Proscenium
52
54
 
53
55
  return result if !view.controller || !Proscenium.config.side_load
54
56
 
55
- if template.respond_to?(:virtual_path) &&
56
- template.respond_to?(:type) && template.type == :html
57
+ if template.respond_to?(:identifier) &&
58
+ template.respond_to?(:type) && template.type == :html &&
59
+ view.controller.respond_to?(:sideload_assets_options)
57
60
  options = view.controller.sideload_assets_options
58
61
  sideload_template_assets layout, options if layout
59
62
  sideload_template_assets template, options
@@ -63,6 +66,8 @@ module Proscenium
63
66
  end
64
67
 
65
68
  def sideload_template_assets(tpl, options)
69
+ return unless (tpl_path = Pathname.new(tpl.identifier)).file?
70
+
66
71
  options = {} if options.nil?
67
72
  options = { js: options, css: options } unless options.is_a?(Hash)
68
73
 
@@ -79,7 +84,7 @@ module Proscenium
79
84
  options[k] = controller.instance_eval(&options[k]) if options[k].is_a?(Proc)
80
85
  end
81
86
 
82
- Importer.sideload Rails.root.join("app/views/#{tpl.virtual_path}"), **options
87
+ Importer.sideload tpl_path, **options
83
88
  end
84
89
  end
85
90
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.19.0'
4
+ VERSION = '0.20.1'
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
4
+ version: 0.20.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-08 00:00:00.000000000 Z
11
+ date: 2025-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi