proscenium 0.23.0 → 0.24.0
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/README.md +26 -7
- data/lib/proscenium/ensure_loaded.rb +1 -1
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/ext/proscenium.h +0 -17
- data/lib/proscenium/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16db506d3fd893f4571ad6ffd54383a168263907c859941e2d9915dc0115cb1a
|
|
4
|
+
data.tar.gz: 997471670509f50518233b195fae64fb4ddff122a36091750a11bac2ae72ac5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26005960b8699c1127f63e54ec293fa5da1a1f39b92e34893126a9d6f1e1a3730c563fc44ade829c51c238706602e44ea6aab7444d056528ab30fccad5ad0cf2
|
|
7
|
+
data.tar.gz: afea4b975a576b6ac2a43e7a92930d293a2dac73cd9d1fd99908a48e3debaa5a15733c4e7027f6ce232e46f2bfd16df6dfdfbcf240ba7f5c99136dc3f64a6fd2
|
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](
|
|
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.
|
|
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 `<
|
|
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";
|
|
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
|
data/lib/proscenium/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Moss
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
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:
|
|
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: []
|