proscenium 0.24.0-aarch64-linux → 0.24.1-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: 38c9b43db8324967d20bf6fbebce23c15c602dbe3fecf418bd9dd0157a3f2f6f
4
- data.tar.gz: dc986967bc03e66921e9bb90574b4ee59b0e58d6555289b00b53c197088612b6
3
+ metadata.gz: 9a3c2342c13ecc8f74633f806e135140427f37e9886433c2c9c12984823c3d44
4
+ data.tar.gz: d16c89353c53a1379941cc5f916d617012bd0d55da2b7cb956b05d22b40433b9
5
5
  SHA512:
6
- metadata.gz: 6151f48ac0e52f064ffbb093b0c048114ed8ad1a41ce48619ae02a33c447145b8e98a4a79a2e13afa09923327846efb953887b7a5cb4c840e9ac454f0bf2d8ba
7
- data.tar.gz: 7ab817143d0020be420aa8e6e91bec5089241f74031ef1cfca61a7543af9663b996709a1979236f56c9541c0dc240fc1a53e14d0f67a0094244e9fb3b90fa9e9
6
+ metadata.gz: 2ca84ecb37b878d95afec420a3168e3861bd88ef4e1b4baa5ddf3e270cf849dd2d9e317dad84a3ade7aaebeb84e28d34c4e5c221907dfab0ef8e6ed068c5329c
7
+ data.tar.gz: 8ba34b73a200991c2a23a3e33a755c8d6b205314a5e6111d4ee8925d265397e3ae6a8ada9cabed38b55250e8266ba3eb1f7a7a9214518be2bdb2e001f59f56bd
@@ -33,31 +33,22 @@ module Proscenium
33
33
  # class_names "mypackage/button@large"
34
34
  # class_names "@scoped/package/button@small"
35
35
  #
36
+ # When a block is given, it is yielded once per input name with
37
+ # `(transformed_name, side_load_path)`. `side_load_path` is the exact string passed to
38
+ # `Importer.import` for that name, or `nil` for names that did not trigger a side-load (plain
39
+ # class names with `require_prefix: true`). The return value is unchanged — callers that don't
40
+ # need the path can keep ignoring the block.
41
+ #
36
42
  # @param names [String,Symbol,Array<String,Symbol>]
37
43
  # @param require_prefix: [Boolean] whether or not to require the `@` prefix.
44
+ # @yieldparam transformed_name [String]
45
+ # @yieldparam side_load_path [String, nil]
38
46
  # @return [Array<String>] the transformed CSS module names.
39
47
  def class_names(*names, require_prefix: true)
40
48
  names.map do |name|
41
- original_name = name.dup
42
- name = name.to_s if name.is_a?(Symbol)
43
-
44
- if name.include?('/')
45
- if name.start_with?('@')
46
- # Scoped bare specifier (eg. "@scoped/package/lib/button@default").
47
- _, path, name = name.split('@')
48
- path = "@#{path}"
49
- else
50
- # Local path (eg. /some/path/to/button@default") or bare specifier (eg.
51
- # "mypackage/lib/button@default").
52
- path, name = name.split('@')
53
- end
54
-
55
- class_name! name, original_name, path: "#{path}#{FILE_EXT}"
56
- elsif name.start_with?('@')
57
- class_name! name[1..], original_name
58
- else
59
- require_prefix ? name : class_name!(name, original_name)
60
- end
49
+ transformed, path = transform_class_name(name, require_prefix: require_prefix)
50
+ yield(transformed, path) if block_given?
51
+ transformed
61
52
  end
62
53
  end
63
54
 
@@ -75,5 +66,38 @@ module Proscenium
75
66
  "#{transformed_name}_#{digest}"
76
67
  end
77
68
  end
69
+
70
+ private
71
+
72
+ # Returns `[transformed_name, side_load_path]` for a single class-name reference.
73
+ # `side_load_path` is the exact string that `class_name!` passed to `Importer.import`, or
74
+ # `nil` if the name did not trigger a side-load. Extracted so `#class_names` can yield paths
75
+ # to consumers (e.g. proscenium-phlex's `resolved_css_module_paths` replay registry) without
76
+ # re-parsing names.
77
+ def transform_class_name(name, require_prefix:)
78
+ original_name = name.dup
79
+ name = name.to_s if name.is_a?(Symbol)
80
+
81
+ if name.include?('/')
82
+ if name.start_with?('@')
83
+ # Scoped bare specifier (eg. "@scoped/package/lib/button@default").
84
+ _, path, name = name.split('@')
85
+ path = "@#{path}"
86
+ else
87
+ # Local path (eg. /some/path/to/button@default") or bare specifier (eg.
88
+ # "mypackage/lib/button@default").
89
+ path, name = name.split('@')
90
+ end
91
+
92
+ module_path = "#{path}#{FILE_EXT}"
93
+ [class_name!(name, original_name, path: module_path), module_path]
94
+ elsif name.start_with?('@')
95
+ [class_name!(name[1..], original_name), @source_path&.to_s]
96
+ elsif require_prefix
97
+ [name, nil]
98
+ else
99
+ [class_name!(name, original_name), @source_path&.to_s]
100
+ end
101
+ end
78
102
  end
79
103
  end
Binary file
@@ -30,9 +30,9 @@ module Proscenium
30
30
  digest = nil
31
31
 
32
32
  if filepath.end_with?('.module.css')
33
- if self.imported.key?(filepath)
34
- digest = self.imported[filepath][:digest]
35
- abs_path = self.imported[filepath][:abs_path]
33
+ if imported.key?(filepath)
34
+ digest = imported[filepath][:digest]
35
+ abs_path = imported[filepath][:abs_path]
36
36
  else
37
37
  manifest_path, non_manifest_path, abs_path = Resolver.resolve(filepath, as_array: true)
38
38
  digest = Utils.css_module_digest(abs_path)
@@ -41,14 +41,14 @@ module Proscenium
41
41
  if sideloaded
42
42
  ActiveSupport::Notifications.instrument 'sideload.proscenium', identifier: filepath,
43
43
  sideloaded: do
44
- self.imported[filepath] = { ** }
45
- self.imported[filepath][:digest] = digest
46
- self.imported[filepath][:abs_path] = abs_path
44
+ imported[filepath] = { ** }
45
+ imported[filepath][:digest] = digest
46
+ imported[filepath][:abs_path] = abs_path
47
47
  end
48
48
  else
49
- self.imported[filepath] = { ** }
50
- self.imported[filepath][:digest] = digest
51
- self.imported[filepath][:abs_path] = abs_path
49
+ imported[filepath] = { ** }
50
+ imported[filepath][:digest] = digest
51
+ imported[filepath][:abs_path] = abs_path
52
52
  end
53
53
  end
54
54
 
@@ -60,16 +60,16 @@ module Proscenium
60
60
 
61
61
  "#{digest}#{transformed_path}"
62
62
  else
63
- return if self.imported.key?(filepath)
63
+ return if imported.key?(filepath)
64
64
 
65
65
  Array(Resolver.resolve(filepath)).each do |fp|
66
66
  if sideloaded
67
67
  ActiveSupport::Notifications.instrument 'sideload.proscenium', identifier: fp,
68
68
  sideloaded: do
69
- self.imported[fp] = { ** }
69
+ imported[fp] = { ** }
70
70
  end
71
71
  else
72
- self.imported[fp] = { ** }
72
+ imported[fp] = { ** }
73
73
  end
74
74
  end
75
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.24.0'
4
+ VERSION = '0.24.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Joel Moss