proscenium 0.22.2 → 0.22.4
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 -11
- data/lib/proscenium/css_module.rb +4 -4
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/ext/proscenium.h +15 -2
- data/lib/proscenium/helper.rb +1 -2
- data/lib/proscenium/importer.rb +32 -15
- data/lib/proscenium/manifest.rb +4 -1
- data/lib/proscenium/react_componentable.rb +2 -2
- data/lib/proscenium/resolver.rb +11 -5
- 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: 6fda75c598a47171a1252aa60697a1395322cf1848ac597dc966d0834254c842
|
|
4
|
+
data.tar.gz: fe8d96e72704c1cbb026e15ef952f00e14d41d675ff905527b3a73c06728bc84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29ceba0dda58ba6593bce53d2fb768e56b6bee04a67856b51fc58cc2bb9c4ace1ef91d876ce7ae2ca61ee7066278f7bcca4c09247395f4f5d89f1605d1a914ab
|
|
7
|
+
data.tar.gz: 71a830db8253363979d772a160acacd7bb7e0ac32d1061f9de99baf0bb44ebf0f5814ce589717a8fccc7033eb98e478e6ae657c440772096a10b8723fa87111d
|
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,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
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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).
|
|
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
|
|
@@ -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
|
|
117
|
+
extern struct ResolveResult resolve(char* filePath, char* configJson);
|
|
105
118
|
|
|
106
119
|
// Compile assets using the given `config`.
|
|
107
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,23 +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] =
|
|
43
|
+
self.imported[filepath][:digest] = digest
|
|
39
44
|
end
|
|
40
45
|
else
|
|
41
46
|
self.imported[filepath] = { ** }
|
|
42
|
-
self.imported[filepath][:digest] =
|
|
47
|
+
self.imported[filepath][:digest] = digest
|
|
43
48
|
end
|
|
44
|
-
end
|
|
45
49
|
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
+
import(fp.to_s, sideloaded: filepath, **options)
|
|
128
|
+
end
|
|
112
129
|
end
|
|
113
130
|
|
|
114
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,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
|
-
# @
|
|
14
|
-
|
|
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]
|
|
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]
|
|
30
|
+
[Proscenium::Manifest[vpath], vpath, path]
|
|
27
31
|
else
|
|
28
|
-
Proscenium::Manifest[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
|
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.4
|
|
5
5
|
platform: ruby
|
|
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
|