proscenium 0.23.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: e9fca5d3c15df8bca393f34a3797bc4c28b9e6a56dbb16deeec3e779b7a7cd6a
4
- data.tar.gz: 401c4d4b642ac38e2dea04d2be60942960074941cfd50d91a231876e598e1930
3
+ metadata.gz: 9a3c2342c13ecc8f74633f806e135140427f37e9886433c2c9c12984823c3d44
4
+ data.tar.gz: d16c89353c53a1379941cc5f916d617012bd0d55da2b7cb956b05d22b40433b9
5
5
  SHA512:
6
- metadata.gz: 999e249ee74c1e36825bacd392396840b286e045ace096b2e8661cad3c33ed33b3937ab38c636ad414f2ff583f9d77c165df0729b774cda0a63462dd72095ac5
7
- data.tar.gz: cb0e5986bb38ac53bde5e2813fad938f06906d9c6a911513f4332ed971c0c9750612343a22e33249a7ac083f9f7ac4e0ddf8e1e0291abe77a3f0f89ff0e4e68a
6
+ metadata.gz: 2ca84ecb37b878d95afec420a3168e3861bd88ef4e1b4baa5ddf3e270cf849dd2d9e317dad84a3ade7aaebeb84e28d34c4e5c221907dfab0ef8e6ed068c5329c
7
+ data.tar.gz: 8ba34b73a200991c2a23a3e33a755c8d6b205314a5e6111d4ee8925d265397e3ae6a8ada9cabed38b55250e8266ba3eb1f7a7a9214518be2bdb2e001f59f56bd
data/README.md CHANGED
@@ -36,6 +36,7 @@
36
36
  - [JavaScript](#javascript)
37
37
  - [Tree Shaking](#tree-shaking)
38
38
  - [Code Splitting](#code-splitting)
39
+ - [`__filename` and `__dirname`](#__filename-and-__dirname)
39
40
  - [JavaScript Caveats](#javascript-caveats)
40
41
  - [CSS](#css)
41
42
  - [Importing CSS from JavaScript](#importing-css-from-javascript)
@@ -57,11 +58,9 @@
57
58
 
58
59
  Getting started obviously depends on whether you are adding Proscenium to an existing Rails app, or creating a new one. So choose the appropriate guide below:
59
60
 
60
- - [Getting Started with a new Rails app](https://github.com/joelmoss/proscenium/blob/master/docs/guides/new_rails_app.md)
61
+ - [Getting Started with a new Rails app](docs/guides/new_rails_app.md)
61
62
  - Getting Started with an existing Rails app
62
63
  - [Migrate from Sprockets](docs/guides/migrate_from_sprockets.md)
63
- - Migrate from Propshaft _[Coming soon]_
64
- - Migrate from Webpacker _[Coming soon]_
65
64
  - [Render a React component with Proscenium](docs/guides/basic_react.md)
66
65
 
67
66
  ## Installation
@@ -158,7 +157,7 @@ Let's continue with our problem example above, where we have the following asset
158
157
  - `/app/assets/users.js`
159
158
  - `/app/assets/user.js`
160
159
 
161
- Your application layout is at `/app/views/layouts/application.hml.erb`, and the view that needs the users assets is at `/app/views/users/index.html.erb`, so move your assets JS and CSS alongside them:
160
+ Your application layout is at `/app/views/layouts/application.html.erb`, and the view that needs the users assets is at `/app/views/users/index.html.erb`, so move your assets JS and CSS alongside them:
162
161
 
163
162
  - `/app/views/layouts/application.css`
164
163
  - `/app/views/layouts/application.js`
@@ -297,8 +296,6 @@ You can import SVG from JS(X), which will bundle the SVG source code. Additional
297
296
 
298
297
  ## Environment Variables
299
298
 
300
- > Available in `>=0.10.0`
301
-
302
299
  You can define and access any environment variable from your JavaScript and Typescript under the `proscenium.env` namespace.
303
300
 
304
301
  For performance and security reasons you must declare the environment variable names that you wish to expose in your `config/application.rb` file.
@@ -442,6 +439,26 @@ Code splitting is enabled by default. You can disable it by setting the `code_sp
442
439
  config.proscenium.code_splitting = false
443
440
  ```
444
441
 
442
+ ### `__filename` and `__dirname`
443
+
444
+ Proscenium provides Node.js-style `__filename` and `__dirname` constants in your JavaScript and TypeScript files. These are replaced at build time with the root-relative path of the current file and its directory respectively.
445
+
446
+ ```js
447
+ // /app/views/users/index.js
448
+ console.log(__filename); // "/app/views/users/index.js"
449
+ console.log(__dirname); // "/app/views/users"
450
+ ```
451
+
452
+ Files inside Ruby gems resolve to their `@rubygems/` scoped path:
453
+
454
+ ```js
455
+ // Inside the "mygem" gem
456
+ console.log(__filename); // "@rubygems/mygem/lib/mygem/component.js"
457
+ console.log(__dirname); // "@rubygems/mygem/lib/mygem"
458
+ ```
459
+
460
+ Note that `__filename` and `__dirname` are not injected into files within `node_modules`.
461
+
445
462
  ### JavaScript Caveats
446
463
 
447
464
  There are a few important caveats as far as JavaScript is concerned. These are [detailed on the esbuild site](https://esbuild.github.io/content-types/#javascript-caveats).
@@ -458,7 +475,9 @@ Proscenium will also automatically insert vendor prefixes so that your CSS will
458
475
 
459
476
  ### Importing CSS from JavaScript
460
477
 
461
- You can also import CSS from JavaScript. When you do this, Proscenium will automatically append each stylesheet to the document's head as a `<link>` element.
478
+ You can also import CSS from JavaScript. When you do this, Proscenium will automatically append each stylesheet to the document's head as a `<style>` element.
479
+
480
+ If your page includes a `<meta name="csp-nonce" content="...">` tag, the injected `<style>` elements will automatically pick up the nonce value for Content Security Policy compliance.
462
481
 
463
482
  ```jsx
464
483
  import "./button.css";
@@ -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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- NotIncludedError = Class.new(Error)
4
+ NotIncludedError = Class.new(Error) # rubocop:disable Style/EmptyClassDefinition
5
5
 
6
6
  module EnsureLoaded
7
7
  def self.included(child)
Binary file
@@ -101,25 +101,8 @@ extern "C" {
101
101
  #endif
102
102
 
103
103
  extern void reset_config(void);
104
-
105
- // Build the given `path` using the `config`.
106
- //
107
- // - path - The path to build relative to `root`.
108
- // - config
109
- //
110
104
  extern struct Result build_to_string(char* filePath, char* configJson);
111
-
112
- // Resolve the given `path` relative to the `root`.
113
- //
114
- // - path - The path to build relative to `root`.
115
- // - config
116
- //
117
105
  extern struct ResolveResult resolve(char* filePath, char* configJson);
118
-
119
- // Compile assets using the given `config`.
120
- //
121
- // - config
122
- //
123
106
  extern struct CompileResult compile(char* configJson);
124
107
 
125
108
  #ifdef __cplusplus
@@ -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.23.0'
4
+ VERSION = '0.24.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.1
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Joel Moss
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-02-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ffi
@@ -44,7 +43,6 @@ dependencies:
44
43
  - - "<"
45
44
  - !ruby/object:Gem::Version
46
45
  version: '9.0'
47
- description:
48
46
  email:
49
47
  - joel@developwithstyle.com
50
48
  executables: []
@@ -94,7 +92,6 @@ metadata:
94
92
  source_code_uri: https://github.com/joelmoss/proscenium
95
93
  changelog_uri: https://github.com/joelmoss/proscenium/releases
96
94
  rubygems_mfa_required: 'true'
97
- post_install_message:
98
95
  rdoc_options: []
99
96
  require_paths:
100
97
  - lib
@@ -109,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
106
  - !ruby/object:Gem::Version
110
107
  version: '0'
111
108
  requirements: []
112
- rubygems_version: 3.5.22
113
- signing_key:
109
+ rubygems_version: 4.0.6
114
110
  specification_version: 4
115
111
  summary: The engine powering your Rails frontend
116
112
  test_files: []