proscenium 0.11.0.pre.1-x86_64-darwin → 0.11.0.pre.5-x86_64-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: 3ba51d67d2c6c2befac8704baeeb65b18d14991af344900edd9e187096f7108c
4
- data.tar.gz: 7303432ccf8f03d18cfd76bf98a7e6ba81be067e2855f8cb92b0f150064ec9c5
3
+ metadata.gz: 8c36b57a4023d8440bb695653665d16177455a928f6db1f83a0fb67d9bd239db
4
+ data.tar.gz: 1d58d6551714bd4739f595ccf7d8cd52feaf2425315ee6a54bee20d9fbe906f9
5
5
  SHA512:
6
- metadata.gz: 03c303f97cd7c7cb45e8261b11bd6e011277e52f427f59866c148a36a7d6bb72aef8b30a11bf6eea39fc3356454444d62bb814922bffedf0041e2d7ac3f77bdd
7
- data.tar.gz: ede216dd5c30f4950b704f0f0b4eb6760bd336747794c8130d816654aed4cba73d9e9671f5d1173343c9ffcf424dcba75b808f085725a62206451ad70251df9d
6
+ metadata.gz: 682bd22dc1972e1813b40c174185c887999cc7865408e5eca5cf8bbf84974f41c29534bf967a78eb4562df67e06b70fe511e7d808e49f4069aaddb98063ffef6
7
+ data.tar.gz: 41160899de48bd2e85d550daaa7354cce3d8eebd894deead7c02290fb3a121dcdf1a42ec39554e84d529d81584524e4f6908984de5cc05ca153302a21a1eba1a
@@ -25,7 +25,8 @@ module Proscenium
25
25
  :string, # ENV variables as a JSON string
26
26
 
27
27
  # Config
28
- :string, # root
28
+ :string, # Rails application root
29
+ :string, # Proscenium gem root
29
30
  :environment, # Rails environment as a Symbol
30
31
  :bool, # code splitting enabled?
31
32
  :bool # debugging enabled?
@@ -36,8 +37,10 @@ module Proscenium
36
37
  :string, # path to import map, relative to root
37
38
 
38
39
  # Config
39
- :string, # root
40
- :environment # Rails environment as a Symbol
40
+ :string, # Rails application root
41
+ :string, # Proscenium gem root
42
+ :environment, # Rails environment as a Symbol
43
+ :bool # debugging enabled?
41
44
  ], Result.by_value
42
45
  end
43
46
 
@@ -72,10 +75,11 @@ module Proscenium
72
75
  @base_url = base_url
73
76
  end
74
77
 
75
- def build(path)
78
+ def build(path) # rubocop:disable Metrics/AbcSize
76
79
  ActiveSupport::Notifications.instrument('build.proscenium', identifier: path) do
77
80
  result = Request.build(path, @base_url, import_map, env_vars.to_json,
78
81
  @root.to_s,
82
+ Pathname.new(__dir__).join('..', '..').to_s,
79
83
  Rails.env.to_sym,
80
84
  Proscenium.config.code_splitting,
81
85
  Proscenium.config.debug)
@@ -88,7 +92,10 @@ module Proscenium
88
92
 
89
93
  def resolve(path)
90
94
  ActiveSupport::Notifications.instrument('resolve.proscenium', identifier: path) do
91
- result = Request.resolve(path, import_map, @root.to_s, Rails.env.to_sym)
95
+ result = Request.resolve(path, import_map, @root.to_s,
96
+ Pathname.new(__dir__).join('..', '..').to_s,
97
+ Rails.env.to_sym,
98
+ Proscenium.config.debug)
92
99
  raise ResolveError.new(path, result[:response]) unless result[:success]
93
100
 
94
101
  result[:response]
Binary file
@@ -97,7 +97,7 @@ extern "C" {
97
97
  // - codeSpitting?
98
98
  // - debug?
99
99
  //
100
- extern struct Result build(char* filepath, char* baseUrl, char* importMap, char* envVars, char* root, unsigned int env, GoUint8 codeSplitting, GoUint8 debug);
100
+ extern struct Result build(char* filepath, char* baseUrl, char* importMap, char* envVars, char* appRoot, char* gemPath, unsigned int env, GoUint8 codeSplitting, GoUint8 debug);
101
101
 
102
102
  // Resolve the given `path` relative to the `root`.
103
103
  //
@@ -107,8 +107,9 @@ extern struct Result build(char* filepath, char* baseUrl, char* importMap, char*
107
107
  // Config
108
108
  // - root - The working directory.
109
109
  // - env - The environment (1 = development, 2 = test, 3 = production)
110
+ // - debug?
110
111
  //
111
- extern struct Result resolve(char* path, char* importMap, char* root, unsigned int env);
112
+ extern struct Result resolve(char* path, char* importMap, char* appRoot, char* gemPath, unsigned int env, GoUint8 debug);
112
113
 
113
114
  #ifdef __cplusplus
114
115
  }
@@ -0,0 +1 @@
1
+ console.log("/@proscenium/test.js");
@@ -34,12 +34,12 @@ module Proscenium
34
34
  private
35
35
 
36
36
  def real_path
37
- @request.path
37
+ @real_path ||= @request.path
38
38
  end
39
39
 
40
40
  # @return [String] the path to the file without the leading slash which will be built.
41
41
  def path_to_build
42
- @request.path[1..]
42
+ @path_to_build ||= @request.path[1..]
43
43
  end
44
44
 
45
45
  def sourcemap?
@@ -53,22 +53,22 @@ module Proscenium
53
53
  def file_readable?
54
54
  return false unless (path = clean_path(sourcemap? ? real_path[0...-4] : real_path))
55
55
 
56
- file_stat = File.stat(Pathname(root).join(path.delete_prefix('/').b).to_s)
56
+ file_stat = File.stat(root_for_readable.join(path.delete_prefix('/').b).to_s)
57
57
  rescue SystemCallError
58
58
  false
59
59
  else
60
60
  file_stat.file? && file_stat.readable?
61
61
  end
62
62
 
63
+ def root_for_readable
64
+ Rails.root
65
+ end
66
+
63
67
  def clean_path(file)
64
68
  path = Rack::Utils.unescape_path file.chomp('/').delete_prefix('/')
65
69
  Rack::Utils.clean_path_info path if Rack::Utils.valid_path? path
66
70
  end
67
71
 
68
- def root
69
- @root ||= Rails.root.to_s
70
- end
71
-
72
72
  def content_type
73
73
  case ::File.extname(path_to_build)
74
74
  when '.js', '.mjs', '.ts', '.tsx', '.jsx' then 'application/javascript'
@@ -20,7 +20,7 @@ module Proscenium
20
20
  end
21
21
 
22
22
  def attempt
23
- render_response Proscenium::Builder.build(path_to_build, root: root,
23
+ render_response Proscenium::Builder.build(path_to_build, root: Rails.root.to_s,
24
24
  base_url: @request.base_url)
25
25
  rescue Proscenium::Builder::CompileError => e
26
26
  raise self.class::CompileError, { file: @request.fullpath, detail: e.message }, caller
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium
4
+ class Middleware
5
+ class Runtime < Esbuild
6
+ private
7
+
8
+ def real_path
9
+ @real_path ||= Pathname.new(@request.path.sub(%r{^/@proscenium},
10
+ '/lib/proscenium/libs')).to_s
11
+ end
12
+
13
+ def root_for_readable
14
+ Proscenium::Railtie.root
15
+ end
16
+ end
17
+ end
18
+ end
@@ -9,6 +9,7 @@ module Proscenium
9
9
 
10
10
  autoload :Base
11
11
  autoload :Esbuild
12
+ autoload :Runtime
12
13
  autoload :Url
13
14
 
14
15
  def initialize(app)
@@ -40,6 +41,7 @@ module Proscenium
40
41
 
41
42
  def find_type(request)
42
43
  return Url if request.path.match?(%r{^/https?%3A%2F%2F})
44
+ return Runtime if request.path.match?(%r{^/@proscenium/})
43
45
 
44
46
  Esbuild if Pathname.new(request.path).fnmatch?(path_glob, File::FNM_EXTGLOB)
45
47
  end
@@ -11,7 +11,7 @@ module Proscenium
11
11
  #
12
12
  # @param path [String] Can be URL path, file system path, or bare specifier (ie. NPM package).
13
13
  # @return [String] URL path.
14
- def self.resolve(path) # rubocop:disable Metrics/AbcSize
14
+ def self.resolve(path) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
15
15
  self.resolved ||= {}
16
16
 
17
17
  self.resolved[path] ||= begin
@@ -19,7 +19,11 @@ module Proscenium
19
19
  raise ArgumentError, 'path must be an absolute file system or URL path'
20
20
  end
21
21
 
22
- if (gem = Proscenium.config.side_load_gems.find { |_, x| path.start_with? "#{x[:root]}/" })
22
+ if path.start_with?('@proscenium/')
23
+ "/#{path}"
24
+ elsif (gem = Proscenium.config.side_load_gems.find do |_, x|
25
+ path.start_with? "#{x[:root]}/"
26
+ end)
23
27
  unless (package_name = gem[1][:package_name] || gem[0])
24
28
  # TODO: manually resolve the path without esbuild
25
29
  raise PathResolutionFailed, path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.11.0.pre.1'
4
+ VERSION = '0.11.0.pre.5'
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.11.0.pre.1
4
+ version: 0.11.0.pre.5
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -101,10 +101,12 @@ files:
101
101
  - lib/proscenium/libs/react-manager/index.jsx
102
102
  - lib/proscenium/libs/react-manager/react.js
103
103
  - lib/proscenium/libs/stimulus-loading.js
104
+ - lib/proscenium/libs/test.js
104
105
  - lib/proscenium/log_subscriber.rb
105
106
  - lib/proscenium/middleware.rb
106
107
  - lib/proscenium/middleware/base.rb
107
108
  - lib/proscenium/middleware/esbuild.rb
109
+ - lib/proscenium/middleware/runtime.rb
108
110
  - lib/proscenium/middleware/url.rb
109
111
  - lib/proscenium/monkey.rb
110
112
  - lib/proscenium/phlex.rb
@@ -145,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
147
  - !ruby/object:Gem::Version
146
148
  version: 1.3.1
147
149
  requirements: []
148
- rubygems_version: 3.4.17
150
+ rubygems_version: 3.4.19
149
151
  signing_key:
150
152
  specification_version: 4
151
153
  summary: The engine powering your Rails frontend