proscenium 0.11.0.pre.6-arm64-darwin → 0.11.0.pre.7-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e16c640f7e3f07a1a29698ba0da0788bc05b7da96f77b2dcb052c79cae0c2f6
4
- data.tar.gz: cb366a06cd0bed0d24eb846a882a320aca309b3cddf3829678e42b1e80d78f9a
3
+ metadata.gz: 6d2a8d1e6399504416c64f479d6a8f64a0709ea3de1709f4ac0f810a17f01bfe
4
+ data.tar.gz: f9b8d09284eedcb5d641e7953f8d0cddb1dae44f861bb1a5c613ad036d956cc4
5
5
  SHA512:
6
- metadata.gz: 5fe0935ec4a1231e8bc85d2b5598b32f0276bd9bfe15fe027bc0481996eb1e43f3bff6915186f5b1af866562b037add10c671a871e0f3bc22e7bb389645473a6
7
- data.tar.gz: dc36da2d9821fcd0590baa0c75e1ea2c0c24cf0c687581ab8f4e954e840f970310de303ce8edd0e2aa9848c0eb26ac9b61fbc73993bee2967cb1c1d48dfdac66
6
+ metadata.gz: 740af4c4b5b17492e44048ed5d9de7286b8a44f991c226ebb8d6b2b1245561747ba87a29ba6283366893a45457c26ad54a140e7ca462949720fc49226e728ca5
7
+ data.tar.gz: dce0e163a53a6cafe296cfcceeca3586cb81680de8eb80b0bd1608524759cc7ae5e1a4f5520ab672605ff6f563b223fe7f2ef2be21335bf06917f4c3fa3fa773
data/README.md CHANGED
@@ -757,19 +757,18 @@ Rails.application.config.proscenium.cache_max_age = 12.months.to_i
757
757
 
758
758
  Proscenium brings back RJS! Any path ending in .rjs will be served from your Rails app. This allows you to import server rendered javascript.
759
759
 
760
- ## Serving from Ruby Gem
761
-
762
- *docs needed*
763
760
 
764
761
  ## Included Paths
765
762
 
766
- By default, Proscenium will serve files ending with any of these extension: `js,mjs,ts,css,jsx,tsx`, and only from `app/assets`, `config`, `app/views`, `lib` and `node_modules` directories.
763
+ Proscenium will serve files ending with any of these extension: `js,mjs,ts,css,jsx,tsx` from the following directories, and their sub-directories: `/app`, `/lib`, `/config`, `/node_modules`, `/vendor`.
767
764
 
768
- However, you can customise these paths with the `include_path` config option...
765
+ So a file at `/app/views/users/index.js` will be served from `https://yourapp.com/app/views/users/index.js`.
769
766
 
770
- ```ruby
771
- Rails.application.config.proscenium.include_paths << 'app/components'
772
- ```
767
+ You can continue to access any file in the `/public` directory as you normally would, but any file ending with a supported extension (`js,mjs,ts,css,jsx,tsx`) will be processed by Proscenium. For example, `/public/some/file.js` will be served from `https://yourapp.com/some/file.js`.
768
+
769
+ ## Serving from Ruby Gems and Rails Engines
770
+
771
+ Proscenium can serve assets from Ruby Gems and Rails Engines.
773
772
 
774
773
  ## Thanks
775
774
 
Binary file
@@ -35,7 +35,14 @@ module Proscenium
35
35
  alias side_load_stylesheets include_stylesheets
36
36
  deprecate side_load_stylesheets: 'Use `include_stylesheets` instead', deprecator: Deprecator.new
37
37
 
38
- def include_javascripts(**options) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
38
+ # Includes all javascripts that have been imported and side loaded.
39
+ #
40
+ # @param extract_lazy_scripts [Boolean] if true, any lazy scripts will be extracted using
41
+ # `content_for` to `:proscenium_lazy_scripts` for later use. Be sure to include this in your
42
+ # page with the `declare_lazy_scripts` helper, or simply
43
+ # `content_for :proscenium_lazy_scripts`.
44
+ # @return [String] the HTML tags for the javascripts.
45
+ def include_javascripts(extract_lazy_scripts: false, **options) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
39
46
  out = []
40
47
 
41
48
  if Rails.application.config.proscenium.code_splitting && Importer.multiple_js_imported?
@@ -66,9 +73,15 @@ module Proscenium
66
73
  end
67
74
  end
68
75
 
69
- out << javascript_tag("window.prosceniumLazyScripts = #{scripts.to_json}")
76
+ if extract_lazy_scripts
77
+ content_for :proscenium_lazy_scripts do
78
+ javascript_tag "window.prosceniumLazyScripts = #{scripts.to_json}"
79
+ end
80
+ else
81
+ out << javascript_tag("window.prosceniumLazyScripts = #{scripts.to_json}")
82
+ end
70
83
  else
71
- Importer.each_javascript(delete: true) do |path, _path_options|
84
+ Importer.each_javascript(delete: true) do |path, _|
72
85
  out << javascript_include_tag(path, extname: false, **options)
73
86
  end
74
87
  end
@@ -77,5 +90,9 @@ module Proscenium
77
90
  end
78
91
  alias side_load_javascripts include_javascripts
79
92
  deprecate side_load_javascripts: 'Use `include_javascripts` instead', deprecator: Deprecator.new
93
+
94
+ def declare_lazy_scripts
95
+ content_for :proscenium_lazy_scripts
96
+ end
80
97
  end
81
98
  end
@@ -43,12 +43,11 @@ module Proscenium
43
43
  return Url if request.path.match?(%r{^/https?%3A%2F%2F})
44
44
  return Runtime if request.path.match?(%r{^/@proscenium/})
45
45
 
46
- Esbuild if Pathname.new(request.path).fnmatch?(path_glob, File::FNM_EXTGLOB)
46
+ Esbuild if Pathname.new(request.path).fnmatch?(app_path_glob, File::FNM_EXTGLOB)
47
47
  end
48
48
 
49
- def path_glob
50
- paths = Rails.application.config.proscenium.include_paths.join(',')
51
- "/{#{paths}}/**.{#{FILE_EXTENSIONS.join(',')}}"
49
+ def app_path_glob
50
+ "/{#{Proscenium::ALLOWED_DIRECTORIES.join(',')}}/**.{#{FILE_EXTENSIONS.join(',')}}"
52
51
  end
53
52
 
54
53
  # TODO: handle precompiled assets
@@ -20,6 +20,7 @@ module Proscenium
20
20
  define_output_helper :include_stylesheets
21
21
  define_output_helper :side_load_javascripts # deprecated
22
22
  define_output_helper :include_javascripts
23
+ define_output_helper :declare_lazy_scripts
23
24
 
24
25
  module Sideload
25
26
  def before_template
@@ -19,7 +19,6 @@ module Proscenium
19
19
  config.proscenium.debug = false
20
20
  config.proscenium.side_load = true
21
21
  config.proscenium.code_splitting = true
22
- config.proscenium.include_paths = Set.new(APPLICATION_INCLUDE_PATHS)
23
22
 
24
23
  # TODO: implement!
25
24
  config.proscenium.cache_query_string = Rails.env.production? && ENV.fetch('REVISION', nil)
@@ -48,11 +47,6 @@ module Proscenium
48
47
  # }
49
48
  config.proscenium.side_load_gems = {}
50
49
 
51
- initializer 'proscenium.configuration' do |app|
52
- options = app.config.proscenium
53
- options.include_paths = Set.new(APPLICATION_INCLUDE_PATHS) if options.include_paths.blank?
54
- end
55
-
56
50
  initializer 'proscenium.middleware' do |app|
57
51
  app.middleware.insert_after ActionDispatch::Static, Middleware
58
52
  app.middleware.insert_after ActionDispatch::Static, Rack::ETag, 'no-cache'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.11.0.pre.6'
4
+ VERSION = '0.11.0.pre.7'
5
5
  end
data/lib/proscenium.rb CHANGED
@@ -8,8 +8,7 @@ module Proscenium
8
8
  FILE_EXTENSIONS = ['js', 'mjs', 'ts', 'jsx', 'tsx', 'css', 'js.map', 'mjs.map', 'jsx.map',
9
9
  'ts.map', 'tsx.map', 'css.map'].freeze
10
10
 
11
- APPLICATION_INCLUDE_PATHS = ['config', 'app/assets', 'app/views', 'app/components', 'lib',
12
- 'node_modules'].freeze
11
+ ALLOWED_DIRECTORIES = %w[app lib config vendor node_modules].freeze
13
12
 
14
13
  # Environment variables that should always be passed to the builder.
15
14
  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.11.0.pre.6
4
+ version: 0.11.0.pre.7
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: 2023-09-14 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport