proscenium 0.22.2-aarch64-linux → 0.22.4-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: 80674235b91e1592c6090faa96087a6955c626112dfd9934bb81dad1c87bff8c
4
- data.tar.gz: c3504f8e728b439447ee52dd352af2607e4f74dee745572b5a2a8865765a0223
3
+ metadata.gz: c56281b2a06af5036e1a47f14d583b3ab30085f466afabfdb28b68879eae1789
4
+ data.tar.gz: cbf1d8e23db3501921cd70a6b7ec1b346b5291c6072d0860e78022ec68ab8110
5
5
  SHA512:
6
- metadata.gz: 67242a4b8fd5bf4e942f36547c18dbd5283e76640f61ac3b92fe2f07f500a9cc9ef5a0385728f0fd42087d94a3466af2efd0e7f0363b2c0d475fc04bb02683a7
7
- data.tar.gz: ac26fdb8b6ecb1af969c3df439d0703b3bdb8b23ebd8af6618f8b3b641b1d007ea614ac615e12018cc54eb656c220a432a9ea26342a560925847a07ef496df38
6
+ metadata.gz: 84c1b186bf77bb85e2ad76eb2f75d62f5b7f067f6e319d278a16cbadbdd2d98483cc8b9cef6eceb5221900f5d07a244af9bd3491e6cf4c6ab03331667095834a
7
+ data.tar.gz: 2a16b7424101e2ffc1556b945e41e976e910e7f851ff64c34a0c5d56cc207b77a7eff994bd5b192700b8e4964ba9e759db09d7a52a85e7d52ad7fd30ac3006d8
@@ -12,6 +12,12 @@ module Proscenium
12
12
  :content_hash, :string
13
13
  end
14
14
 
15
+ class ResolveResult < FFI::Struct
16
+ layout :success, :bool,
17
+ :url_path, :string,
18
+ :abs_path, :string
19
+ end
20
+
15
21
  class CompileResult < FFI::Struct
16
22
  layout :success, :bool,
17
23
  :messages, :string
@@ -32,7 +38,7 @@ module Proscenium
32
38
  attach_function :resolve, [
33
39
  :string, # path or entry point
34
40
  :pointer # Config as JSON.
35
- ], Result.by_value
41
+ ], ResolveResult.by_value
36
42
 
37
43
  attach_function :compile, [
38
44
  :pointer # Config as JSON.
@@ -115,9 +121,9 @@ module Proscenium
115
121
  ActiveSupport::Notifications.instrument('resolve.proscenium', identifier: path) do
116
122
  result = Request.resolve(path, @request_config)
117
123
 
118
- raise ResolveError.new(path, result[:response]) unless result[:success]
124
+ raise ResolveError.new(path, result[:url_path]) unless result[:success]
119
125
 
120
- result[:response]
126
+ [result[:url_path], result[:abs_path]]
121
127
  end
122
128
  end
123
129
 
@@ -66,19 +66,14 @@ module Proscenium
66
66
  raise Proscenium::CssModule::TransformError.new(original_name, 'CSS module path not given')
67
67
  end
68
68
 
69
- resolved_path = Resolver.resolve(path.to_s)
70
- digest = Importer.import(resolved_path)
69
+ digest = Importer.import(path.to_s)
71
70
 
72
- transformed_path = ''
73
- transformed_path = "__#{resolved_path[1..].gsub(%r{[@/.+]}, '-')}" if Rails.env.development?
74
71
  transformed_name = name.to_s
75
- transformed_name = if transformed_name.start_with?('_')
76
- "_#{transformed_name[1..]}-#{digest}#{transformed_path}"
77
- else
78
- "#{transformed_name}-#{digest}#{transformed_path}"
79
- end
80
-
81
- [transformed_name, resolved_path]
72
+ if transformed_name.start_with?('_')
73
+ "_#{transformed_name[1..]}_#{digest}"
74
+ else
75
+ "#{transformed_name}_#{digest}"
76
+ end
82
77
  end
83
78
  end
84
79
  end
@@ -21,7 +21,7 @@ module Proscenium::CssModule
21
21
  path ||= respond_to?(:css_module_path) ? css_module_path : path
22
22
 
23
23
  cssm = Transformer.new(path)
24
- cssm.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
24
+ cssm.class_names(*names, require_prefix: false).join(' ')
25
25
  end
26
26
 
27
27
  def class_names(*names, path: nil)
@@ -29,7 +29,7 @@ module Proscenium::CssModule
29
29
  names = names.flatten.compact
30
30
 
31
31
  cssm = Transformer.new(path)
32
- cssm.class_names(*names).map { |name, _| name }.join(' ') unless names.empty?
32
+ cssm.class_names(*names).join(' ') unless names.empty?
33
33
  end
34
34
  end
35
35
 
@@ -44,7 +44,7 @@ module Proscenium::CssModule
44
44
  # @return [String] the transformed CSS module names concatenated as a string.
45
45
  def css_module(*names, path: nil)
46
46
  transformer = path.nil? ? cssm : Transformer.new(path)
47
- transformer.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
47
+ transformer.class_names(*names, require_prefix: false).join(' ')
48
48
  end
49
49
 
50
50
  # @param name [String,Symbol,Array<String,Symbol>]
@@ -53,7 +53,7 @@ module Proscenium::CssModule
53
53
  def class_names(*names, path: nil)
54
54
  names = names.flatten.compact
55
55
  transformer = path.nil? ? cssm : Transformer.new(path)
56
- transformer.class_names(*names).map { |name, _| name }.join(' ') unless names.empty?
56
+ transformer.class_names(*names).join(' ') unless names.empty?
57
57
  end
58
58
 
59
59
  private
Binary file
@@ -12,6 +12,8 @@
12
12
 
13
13
  #ifndef GO_CGO_GOSTRING_TYPEDEF
14
14
  typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15
+ extern size_t _GoStringLen(_GoString_ s);
16
+ extern const char *_GoStringPtr(_GoString_ s);
15
17
  #endif
16
18
 
17
19
  #endif
@@ -26,6 +28,11 @@ struct Result {
26
28
  char* response;
27
29
  char* contentHash;
28
30
  };
31
+ struct ResolveResult {
32
+ int success;
33
+ char* urlPath;
34
+ char* absPath;
35
+ };
29
36
  struct CompileResult {
30
37
  int success;
31
38
  char* messages;
@@ -57,10 +64,16 @@ typedef size_t GoUintptr;
57
64
  typedef float GoFloat32;
58
65
  typedef double GoFloat64;
59
66
  #ifdef _MSC_VER
67
+ #if !defined(__cplusplus) || _MSVC_LANG <= 201402L
60
68
  #include <complex.h>
61
69
  typedef _Fcomplex GoComplex64;
62
70
  typedef _Dcomplex GoComplex128;
63
71
  #else
72
+ #include <complex>
73
+ typedef std::complex<float> GoComplex64;
74
+ typedef std::complex<double> GoComplex128;
75
+ #endif
76
+ #else
64
77
  typedef float _Complex GoComplex64;
65
78
  typedef double _Complex GoComplex128;
66
79
  #endif
@@ -87,7 +100,7 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
87
100
  extern "C" {
88
101
  #endif
89
102
 
90
- extern void reset_config();
103
+ extern void reset_config(void);
91
104
 
92
105
  // Build the given `path` using the `config`.
93
106
  //
@@ -101,7 +114,7 @@ extern struct Result build_to_string(char* filePath, char* configJson);
101
114
  // - path - The path to build relative to `root`.
102
115
  // - config
103
116
  //
104
- extern struct Result resolve(char* filePath, char* configJson);
117
+ extern struct ResolveResult resolve(char* filePath, char* configJson);
105
118
 
106
119
  // Compile assets using the given `config`.
107
120
  //
@@ -27,8 +27,7 @@ module Proscenium
27
27
  # @return [String] the transformed CSS module names concatenated as a string.
28
28
  def css_module(*names, path: nil)
29
29
  path ||= Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
30
- CssModule::Transformer.new(path).class_names(*names, require_prefix: false)
31
- .map { |name, _| name }.join(' ')
30
+ CssModule::Transformer.new(path).class_names(*names, require_prefix: false).join(' ')
32
31
  end
33
32
 
34
33
  def include_assets
@@ -27,23 +27,45 @@ module Proscenium
27
27
  def import(filepath = nil, sideloaded: false, **)
28
28
  self.imported ||= {}
29
29
 
30
- filepath = "/node_modules/#{filepath}" if filepath.start_with?('@rubygems/')
31
- css_module = filepath.end_with?('.module.css')
30
+ return if self.imported.key?(filepath)
31
+
32
+ digest = nil
33
+
34
+ if filepath.end_with?('.module.css')
35
+ manifest_path, non_manifest_path, abs_path = Resolver.resolve(filepath, as_array: true)
36
+ digest = Utils.css_module_digest(abs_path)
37
+ filepath = Array(manifest_path || non_manifest_path)[0]
32
38
 
33
- unless self.imported.key?(filepath)
34
39
  if sideloaded
35
40
  ActiveSupport::Notifications.instrument 'sideload.proscenium', identifier: filepath,
36
41
  sideloaded: do
37
42
  self.imported[filepath] = { ** }
38
- self.imported[filepath][:digest] = Utils.digest(filepath) if css_module
43
+ self.imported[filepath][:digest] = digest
39
44
  end
40
45
  else
41
46
  self.imported[filepath] = { ** }
42
- self.imported[filepath][:digest] = Utils.digest(filepath) if css_module
47
+ self.imported[filepath][:digest] = digest
43
48
  end
44
- end
45
49
 
46
- css_module ? self.imported[filepath][:digest] : nil
50
+ transformed_path = ''
51
+ if Rails.env.development?
52
+ rel_path = Pathname.new(abs_path).relative_path_from(Rails.root).sub_ext('')
53
+ transformed_path = "_#{rel_path.to_s.gsub(%r{[@/.+]}, '-')}"
54
+ end
55
+
56
+ "#{digest}#{transformed_path}"
57
+ else
58
+ Array(Resolver.resolve(filepath)).each do |fp|
59
+ if sideloaded
60
+ ActiveSupport::Notifications.instrument 'sideload.proscenium', identifier: fp,
61
+ sideloaded: do
62
+ self.imported[fp] = { ** }
63
+ end
64
+ else
65
+ self.imported[fp] = { ** }
66
+ end
67
+ end
68
+ end
47
69
  end
48
70
 
49
71
  # Sideloads JS and CSS assets for the given Ruby filepath.
@@ -88,7 +110,6 @@ module Proscenium
88
110
  # @param filepath [Pathname] Absolute file system path of the Ruby file to sideload.
89
111
  # @param extensions [Array<String>] Supported file extensions to sideload.
90
112
  # @param options [Hash] Options to pass to `import`.
91
- # @return [Array<String>] The imported file paths.
92
113
  # @raise [ArgumentError] if `filepath` is not an absolute file system path.
93
114
  private def _sideload(filepath, extensions, **options) # rubocop:disable Style/AccessModifierDeclarations
94
115
  return unless Proscenium.config.side_load
@@ -100,15 +121,11 @@ module Proscenium
100
121
  # Ensures extensions with more than one dot are handled correctly.
101
122
  filepath = filepath.sub_ext('').sub_ext('')
102
123
 
103
- sideloaded = []
104
-
105
124
  extensions.find do |x|
106
- if (fp = filepath.sub_ext(x)).exist?
107
- sideloaded << import(Resolver.resolve(fp.to_s), sideloaded: filepath, **options)
108
- end
109
- end
125
+ next unless (fp = filepath.sub_ext(x)).exist?
110
126
 
111
- sideloaded
127
+ import(fp.to_s, sideloaded: filepath, **options)
128
+ end
112
129
  end
113
130
 
114
131
  def each_stylesheet(delete: false)
@@ -31,7 +31,10 @@ module Proscenium
31
31
  ep.delete_prefix(Rails.root.to_s)
32
32
  end
33
33
 
34
- manifest[ep] = "/#{outpath}"
34
+ manifest[ep] = [
35
+ "/#{outpath}",
36
+ details['cssBundle']&.delete_prefix(public_path)
37
+ ].compact
35
38
  end
36
39
  end
37
40
 
@@ -45,7 +45,7 @@ module Proscenium
45
45
 
46
46
  class_methods do
47
47
  def sideload(options)
48
- Importer.import Resolver.resolve(manager.to_s), **options, js: { type: 'module' }
48
+ Importer.import manager.to_s, sideloaded: true, **options, js: { type: 'module' }
49
49
  end
50
50
  end
51
51
 
@@ -58,7 +58,7 @@ module Proscenium
58
58
 
59
59
  # The absolute URL path to the javascript component.
60
60
  def virtual_path
61
- @virtual_path ||= Resolver.resolve self.class.source_path.sub_ext('.jsx').to_s
61
+ @virtual_path ||= Resolver.resolve(self.class.source_path.sub_ext('.jsx').to_s)[0]
62
62
  end
63
63
 
64
64
  def props
@@ -9,9 +9,13 @@ module Proscenium
9
9
 
10
10
  # Resolve the given `path` to a fully qualified URL path.
11
11
  #
12
+ # TODO: cache this across requests in production.
13
+ #
12
14
  # @param path [String] URL path, file system path, or bare specifier (ie. NPM package).
13
- # @return [String] URL path.
14
- def self.resolve(path)
15
+ # @param as_array [Boolean] whether or not to return the manifest path, non-manifest path, and
16
+ # absolute file system path as an array. Only returns the resolved path if false (default).
17
+ # @return [String, Array<String>]
18
+ def self.resolve(path, as_array: false)
15
19
  self.resolved ||= {}
16
20
 
17
21
  if path.start_with?('./', '../')
@@ -20,13 +24,15 @@ module Proscenium
20
24
 
21
25
  self.resolved[path] ||= if (gem = BundledGems.paths.find { |_, v| path.start_with? "#{v}/" })
22
26
  vpath = path.sub(/^#{gem.last}/, "@rubygems/#{gem.first}")
23
- Proscenium::Manifest[vpath] || "/node_modules/#{vpath}"
27
+ [Proscenium::Manifest[vpath], "/node_modules/#{vpath}", path]
24
28
  elsif path.start_with?("#{Rails.root}/")
25
29
  vpath = path.delete_prefix(Rails.root.to_s)
26
- Proscenium::Manifest[vpath] || vpath
30
+ [Proscenium::Manifest[vpath], vpath, path]
27
31
  else
28
- Proscenium::Manifest[path] || Builder.resolve(path)
32
+ [Proscenium::Manifest[path], *Builder.resolve(path)]
29
33
  end
34
+
35
+ as_array ? self.resolved[path] : self.resolved[path][0] || self.resolved[path][1]
30
36
  end
31
37
  end
32
38
  end
@@ -4,9 +4,12 @@ module Proscenium
4
4
  module Utils
5
5
  module_function
6
6
 
7
- # @param value [#to_s] The value to create the digest from. This will usually be a `Pathname`.
7
+ # Returns a short digest for the given `value`, intended for CSS module class name suffixes.
8
+ #
9
+ # @param value [#to_s] The value to create the digest from. This will usually be the absolute
10
+ # file system file path.
8
11
  # @return [String] digest of the given value.
9
- def digest(value)
12
+ def css_module_digest(value)
10
13
  Digest::SHA1.hexdigest(value.to_s)[..7]
11
14
  end
12
15
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.22.2'
4
+ VERSION = '0.22.4'
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.22.2
4
+ version: 0.22.4
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-11-10 00:00:00.000000000 Z
11
+ date: 2025-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi