proscenium 0.22.3-x86_64-darwin → 0.22.5-x86_64-darwin
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 +4 -4
- data/lib/proscenium/builder.rb +9 -3
- data/lib/proscenium/css_module/transformer.rb +6 -15
- data/lib/proscenium/css_module.rb +4 -4
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/ext/proscenium.h +6 -1
- data/lib/proscenium/helper.rb +1 -2
- data/lib/proscenium/importer.rb +28 -28
- data/lib/proscenium/manifest.rb +4 -1
- data/lib/proscenium/react_componentable.rb +2 -2
- data/lib/proscenium/resolver.rb +8 -6
- data/lib/proscenium/utils.rb +5 -2
- data/lib/proscenium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73d2dee4f8b525fda2265632513a61da45f97f9303d4af693d4f813d73954fc7
|
|
4
|
+
data.tar.gz: 27151e2eab7e775695208709f0bf9aa2b89b91acccc9962a3f35cb23defdb7ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6693bf2f317b41310d678f53594b58296aecf6f15f899eab766a1ef8c4ce8e61d9301c2aec056ed3601cbc427732780d802a41c9e48a767278c03d792aaf16c
|
|
7
|
+
data.tar.gz: 22a6d877a52e0527c8651ee7a184326d244a057e5279ebaf3ed758e9754aadf4377b3066a1dea8b5a651eb64a48edd713435e0f3bb8d3ff90d25cba856b74639
|
data/lib/proscenium/builder.rb
CHANGED
|
@@ -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
|
-
],
|
|
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[:
|
|
124
|
+
raise ResolveError.new(path, result[:url_path]) unless result[:success]
|
|
119
125
|
|
|
120
|
-
result[:
|
|
126
|
+
[result[:url_path], result[:abs_path]]
|
|
121
127
|
end
|
|
122
128
|
end
|
|
123
129
|
|
|
@@ -66,23 +66,14 @@ module Proscenium
|
|
|
66
66
|
raise Proscenium::CssModule::TransformError.new(original_name, 'CSS module path not given')
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
digest = Importer.import(manifest_path || non_manifest_path, digest: lambda {
|
|
71
|
-
Utils.digest non_manifest_path
|
|
72
|
-
})
|
|
69
|
+
digest = Importer.import(path.to_s)
|
|
73
70
|
|
|
74
|
-
transformed_path = ''
|
|
75
|
-
if Rails.env.development?
|
|
76
|
-
transformed_path = "__#{non_manifest_path[1..].gsub(%r{[@/.+]}, '-')}"
|
|
77
|
-
end
|
|
78
71
|
transformed_name = name.to_s
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[transformed_name, non_manifest_path]
|
|
72
|
+
if transformed_name.start_with?('_')
|
|
73
|
+
"_#{transformed_name[1..]}_#{digest}"
|
|
74
|
+
else
|
|
75
|
+
"#{transformed_name}_#{digest}"
|
|
76
|
+
end
|
|
86
77
|
end
|
|
87
78
|
end
|
|
88
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).
|
|
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).
|
|
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).
|
|
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).
|
|
56
|
+
transformer.class_names(*names).join(' ') unless names.empty?
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
private
|
|
Binary file
|
|
@@ -28,6 +28,11 @@ struct Result {
|
|
|
28
28
|
char* response;
|
|
29
29
|
char* contentHash;
|
|
30
30
|
};
|
|
31
|
+
struct ResolveResult {
|
|
32
|
+
int success;
|
|
33
|
+
char* urlPath;
|
|
34
|
+
char* absPath;
|
|
35
|
+
};
|
|
31
36
|
struct CompileResult {
|
|
32
37
|
int success;
|
|
33
38
|
char* messages;
|
|
@@ -109,7 +114,7 @@ extern struct Result build_to_string(char* filePath, char* configJson);
|
|
|
109
114
|
// - path - The path to build relative to `root`.
|
|
110
115
|
// - config
|
|
111
116
|
//
|
|
112
|
-
extern struct
|
|
117
|
+
extern struct ResolveResult resolve(char* filePath, char* configJson);
|
|
113
118
|
|
|
114
119
|
// Compile assets using the given `config`.
|
|
115
120
|
//
|
data/lib/proscenium/helper.rb
CHANGED
|
@@ -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
|
data/lib/proscenium/importer.rb
CHANGED
|
@@ -27,31 +27,45 @@ module Proscenium
|
|
|
27
27
|
def import(filepath = nil, sideloaded: false, **)
|
|
28
28
|
self.imported ||= {}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
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]
|
|
39
|
-
|
|
40
|
-
if self.imported[filepath][:digest].is_a?(Proc)
|
|
41
|
-
self.imported[filepath][:digest] = self.imported[filepath][:digest].call
|
|
42
|
-
end
|
|
43
|
+
self.imported[filepath][:digest] = digest
|
|
43
44
|
end
|
|
44
45
|
else
|
|
45
46
|
self.imported[filepath] = { ** }
|
|
46
|
-
self.imported[filepath][:digest]
|
|
47
|
+
self.imported[filepath][:digest] = digest
|
|
48
|
+
end
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
transformed_path = ''
|
|
51
|
+
if !Rails.env.production?
|
|
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] = { ** }
|
|
50
66
|
end
|
|
51
67
|
end
|
|
52
68
|
end
|
|
53
|
-
|
|
54
|
-
css_module ? self.imported[filepath][:digest] : nil
|
|
55
69
|
end
|
|
56
70
|
|
|
57
71
|
# Sideloads JS and CSS assets for the given Ruby filepath.
|
|
@@ -96,7 +110,6 @@ module Proscenium
|
|
|
96
110
|
# @param filepath [Pathname] Absolute file system path of the Ruby file to sideload.
|
|
97
111
|
# @param extensions [Array<String>] Supported file extensions to sideload.
|
|
98
112
|
# @param options [Hash] Options to pass to `import`.
|
|
99
|
-
# @return [Array<String>] The imported file paths.
|
|
100
113
|
# @raise [ArgumentError] if `filepath` is not an absolute file system path.
|
|
101
114
|
private def _sideload(filepath, extensions, **options) # rubocop:disable Style/AccessModifierDeclarations
|
|
102
115
|
return unless Proscenium.config.side_load
|
|
@@ -108,24 +121,11 @@ module Proscenium
|
|
|
108
121
|
# Ensures extensions with more than one dot are handled correctly.
|
|
109
122
|
filepath = filepath.sub_ext('').sub_ext('')
|
|
110
123
|
|
|
111
|
-
sideloaded = []
|
|
112
|
-
|
|
113
124
|
extensions.find do |x|
|
|
114
125
|
next unless (fp = filepath.sub_ext(x)).exist?
|
|
115
126
|
|
|
116
|
-
sideloaded
|
|
117
|
-
manifest_path, non_manifest_path = Resolver.resolve(fp.to_s,
|
|
118
|
-
as_array: true)
|
|
119
|
-
import(manifest_path || non_manifest_path,
|
|
120
|
-
sideloaded: filepath,
|
|
121
|
-
digest: -> { Utils.digest non_manifest_path },
|
|
122
|
-
**options)
|
|
123
|
-
else
|
|
124
|
-
import(Resolver.resolve(fp.to_s), sideloaded: filepath, **options)
|
|
125
|
-
end
|
|
127
|
+
import(fp.to_s, sideloaded: filepath, **options)
|
|
126
128
|
end
|
|
127
|
-
|
|
128
|
-
sideloaded
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
def each_stylesheet(delete: false)
|
data/lib/proscenium/manifest.rb
CHANGED
|
@@ -45,7 +45,7 @@ module Proscenium
|
|
|
45
45
|
|
|
46
46
|
class_methods do
|
|
47
47
|
def sideload(options)
|
|
48
|
-
Importer.import
|
|
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
|
|
61
|
+
@virtual_path ||= Resolver.resolve(self.class.source_path.sub_ext('.jsx').to_s)[0]
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def props
|
data/lib/proscenium/resolver.rb
CHANGED
|
@@ -9,10 +9,12 @@ 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
|
-
# @param as_array [Boolean] whether or not to return
|
|
14
|
-
#
|
|
15
|
-
# @return [String]
|
|
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>]
|
|
16
18
|
def self.resolve(path, as_array: false)
|
|
17
19
|
self.resolved ||= {}
|
|
18
20
|
|
|
@@ -22,12 +24,12 @@ module Proscenium
|
|
|
22
24
|
|
|
23
25
|
self.resolved[path] ||= if (gem = BundledGems.paths.find { |_, v| path.start_with? "#{v}/" })
|
|
24
26
|
vpath = path.sub(/^#{gem.last}/, "@rubygems/#{gem.first}")
|
|
25
|
-
[Proscenium::Manifest[vpath], "/node_modules/#{vpath}"]
|
|
27
|
+
[Proscenium::Manifest[vpath], "/node_modules/#{vpath}", path]
|
|
26
28
|
elsif path.start_with?("#{Rails.root}/")
|
|
27
29
|
vpath = path.delete_prefix(Rails.root.to_s)
|
|
28
|
-
[Proscenium::Manifest[vpath], vpath]
|
|
30
|
+
[Proscenium::Manifest[vpath], vpath, path]
|
|
29
31
|
else
|
|
30
|
-
[Proscenium::Manifest[path], Builder.resolve(path)]
|
|
32
|
+
[Proscenium::Manifest[path], *Builder.resolve(path)]
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
as_array ? self.resolved[path] : self.resolved[path][0] || self.resolved[path][1]
|
data/lib/proscenium/utils.rb
CHANGED
|
@@ -4,9 +4,12 @@ module Proscenium
|
|
|
4
4
|
module Utils
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
|
-
#
|
|
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
|
|
12
|
+
def css_module_digest(value)
|
|
10
13
|
Digest::SHA1.hexdigest(value.to_s)[..7]
|
|
11
14
|
end
|
|
12
15
|
|
data/lib/proscenium/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.22.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: 2025-
|
|
11
|
+
date: 2025-12-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|