sprockets 4.0.0 → 4.0.1
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/CHANGELOG.md +5 -1
- data/README.md +44 -11
- data/lib/sprockets/asset.rb +9 -2
- data/lib/sprockets/base.rb +2 -2
- data/lib/sprockets/exporters/base.rb +0 -1
- data/lib/sprockets/loader.rb +4 -2
- data/lib/sprockets/source_map_utils.rb +2 -2
- data/lib/sprockets/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bbf26f3dfff9a86ca4b4407072f1786fafed4040a2f3f25c875842dc834bdcf
|
4
|
+
data.tar.gz: 5a6dd07a6568dca18b5d1eca850a1e3a78030c20a6530781d8a16ac31c25649c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa3fb386fe8ded820388ff86e1b505736dadcf5e072fedc124c8635955af70df9db7386ce66f4e2d4f412c652e88df9c8dc93a451ac31b2982f0457393911202
|
7
|
+
data.tar.gz: 3dde983e601b16c7b4bc71343543c69b7b8787b70daaaad711bc45ec47b4dd53507d67f6b6a9c1f8de1a7069bfbc12f72c96a0eaa088f976187fe9d4ca8f78f8
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md
|
4
4
|
|
5
|
-
##
|
5
|
+
## 4.0.1
|
6
|
+
|
7
|
+
- Fix for Ruby 2.7 keyword arguments warning in `base.rb`. [#660](https://github.com/rails/sprockets/pull/660)
|
8
|
+
- Fix for when `x_sprockets_linecount` is missing from a source map.
|
9
|
+
- Fix subresource integrity to match the digest of the asset.
|
6
10
|
|
7
11
|
## 4.0.0
|
8
12
|
|
data/README.md
CHANGED
@@ -115,9 +115,9 @@ Here is a list of the available directives:
|
|
115
115
|
- [`require_self`](#require_self) - Change order of where current contents are concatenated to current
|
116
116
|
- [`require_directory`](#require_directory) - Add contents of each file in a folder to current
|
117
117
|
- [`require_tree`](#require_tree) - Add contents of all files in all directories in a path to current
|
118
|
-
- [`link`](#link) - Make target file compile and be
|
119
|
-
- [`link_directory`](#link_directory) - Make target directory compile and be
|
120
|
-
- [`link_tree`](#link_tree) - Make target tree compile and be
|
118
|
+
- [`link`](#link) - Make target file compile and be publicly available without adding contents to current
|
119
|
+
- [`link_directory`](#link_directory) - Make target directory compile and be publicly available without adding contents to current
|
120
|
+
- [`link_tree`](#link_tree) - Make target tree compile and be publicly available without adding contents to current
|
121
121
|
- [`depend_on`](#depend_on) - Recompile current file if target has changed
|
122
122
|
- [`stub`](#stub) - Ignore target file
|
123
123
|
|
@@ -363,37 +363,70 @@ directory specified by *path*.
|
|
363
363
|
### link
|
364
364
|
|
365
365
|
`link` *path* declares a dependency on the target *path* and adds it to a list
|
366
|
-
of subdependencies to
|
366
|
+
of subdependencies to be compiled when the asset is written out to
|
367
367
|
disk.
|
368
368
|
|
369
369
|
Example:
|
370
370
|
|
371
|
-
If you've got a `manifest.js` file and you want to
|
372
|
-
generated and made available to the public you can link it
|
371
|
+
If you've got a `manifest.js` file and you want to specify that a `admin.js` source file should be
|
372
|
+
generated and made available to the public you can link it by including this in the `manifest.js` file:
|
373
373
|
|
374
374
|
```
|
375
375
|
//= link admin.js
|
376
376
|
```
|
377
377
|
|
378
|
+
The argument to `link` is a _logical path_, that is it will be resolved according to the
|
379
|
+
configured asset load paths. See [Accesing Assets](#accessing-assets) above. A path relative to
|
380
|
+
the current file won't work, it must be a logical path.
|
381
|
+
|
382
|
+
**Caution**: the "link" directive should always have an explicit extension on the end.
|
383
|
+
|
378
384
|
### link_directory
|
379
385
|
|
380
|
-
`link_directory` *path* links all the files inside the directory specified by the *path
|
386
|
+
`link_directory` *path* links all the files inside the directory specified by the *path*. By "link", we mean they are specified as compilation targets to be written out to disk, and made available to be served to user-agents.
|
387
|
+
|
388
|
+
Files in subdirectories will not be linked (Compare to [link_tree](#link_tree)).
|
389
|
+
|
390
|
+
The *path* argument to `link_directory` is _not_ a logical path (it does not use the asset load paths), but is a path relative to the file the `link_directory` directive is found in, and can use `..` to . For instance, you might want:
|
391
|
+
|
392
|
+
```js
|
393
|
+
//= link_directory ../stylesheets
|
394
|
+
```
|
395
|
+
|
396
|
+
`link_directory` can take an optional second argument with an extension or content-type, with the
|
397
|
+
two arguments separated by a space:
|
398
|
+
|
399
|
+
```js
|
400
|
+
//= link_directory ../stylesheets text/css
|
401
|
+
//= link_directory ../more_stylesheets .css
|
402
|
+
```
|
403
|
+
|
404
|
+
This will limit the matching files to link to only files recognized as that type. An extension is
|
405
|
+
just a shortcut for the type referenced, it does not need to match the source file exactly, but
|
406
|
+
instead identifies the content-type the source file must be recognized as.
|
381
407
|
|
382
408
|
### link_tree
|
383
409
|
|
384
|
-
`link_tree` *path* works like
|
410
|
+
`link_tree` *path* works like [link_directory](#link_directory), but operates
|
385
411
|
recursively to link all files in all subdirectories of the
|
386
412
|
directory specified by *path*.
|
387
413
|
|
388
414
|
Example:
|
389
415
|
|
390
|
-
|
416
|
+
```js
|
417
|
+
//= link_tree ./path/to/folder
|
418
|
+
```
|
419
|
+
|
420
|
+
Like `link_directory`, the argument is path relative to the current file, it is *not* a 'logical path' tresolved against load paths.
|
421
|
+
|
422
|
+
|
423
|
+
As with `link_directory`, you can also specify a second argument -- separated by a space -- so any extra files not matching the content-type specified will be ignored:
|
391
424
|
|
392
425
|
```js
|
393
|
-
//= link_tree ./path/to/folder
|
426
|
+
//= link_tree ./path/to/folder text/javascript
|
427
|
+
//= link_tree ./path/to/other_folder .js
|
394
428
|
```
|
395
429
|
|
396
|
-
> Note: There is an intentional space between the path and the extension
|
397
430
|
|
398
431
|
### depend_on
|
399
432
|
|
data/lib/sprockets/asset.rb
CHANGED
@@ -123,13 +123,20 @@ module Sprockets
|
|
123
123
|
metadata[:digest]
|
124
124
|
end
|
125
125
|
|
126
|
+
# Private: Return the version of the environment where the asset was generated.
|
127
|
+
def environment_version
|
128
|
+
metadata[:environment_version]
|
129
|
+
end
|
130
|
+
|
126
131
|
# Public: Returns String hexdigest of source.
|
127
132
|
def hexdigest
|
128
133
|
DigestUtils.pack_hexdigest(digest)
|
129
134
|
end
|
130
135
|
|
131
136
|
# Pubic: ETag String of Asset.
|
132
|
-
|
137
|
+
def etag
|
138
|
+
DigestUtils.pack_hexdigest(environment_version + digest)
|
139
|
+
end
|
133
140
|
|
134
141
|
# Public: Returns String base64 digest of source.
|
135
142
|
def base64digest
|
@@ -138,7 +145,7 @@ module Sprockets
|
|
138
145
|
|
139
146
|
# Public: A "named information" URL for subresource integrity.
|
140
147
|
def integrity
|
141
|
-
DigestUtils.integrity_uri(
|
148
|
+
DigestUtils.integrity_uri(digest)
|
142
149
|
end
|
143
150
|
|
144
151
|
# Public: Add enumerator to allow `Asset` instances to be used as Rack
|
data/lib/sprockets/base.rb
CHANGED
data/lib/sprockets/loader.rb
CHANGED
@@ -195,14 +195,16 @@ module Sprockets
|
|
195
195
|
source = result.delete(:data)
|
196
196
|
metadata = result
|
197
197
|
metadata[:charset] = source.encoding.name.downcase unless metadata.key?(:charset)
|
198
|
-
metadata[:digest] = digest(
|
198
|
+
metadata[:digest] = digest(source)
|
199
199
|
metadata[:length] = source.bytesize
|
200
|
+
metadata[:environment_version] = version
|
200
201
|
else
|
201
202
|
dependencies << build_file_digest_uri(unloaded.filename)
|
202
203
|
metadata = {
|
203
204
|
digest: file_digest(unloaded.filename),
|
204
205
|
length: self.stat(unloaded.filename).size,
|
205
|
-
dependencies: dependencies
|
206
|
+
dependencies: dependencies,
|
207
|
+
environment_version: version,
|
206
208
|
}
|
207
209
|
end
|
208
210
|
|
@@ -78,7 +78,7 @@ module Sprockets
|
|
78
78
|
offset = 0
|
79
79
|
if a["sections"].count != 0 && !a["sections"].last["map"]["mappings"].empty?
|
80
80
|
last_line_count = a["sections"].last["map"].delete("x_sprockets_linecount")
|
81
|
-
offset += last_line_count
|
81
|
+
offset += last_line_count || 1
|
82
82
|
|
83
83
|
last_offset = a["sections"].last["offset"]["line"]
|
84
84
|
offset += last_offset
|
@@ -436,7 +436,7 @@ module Sprockets
|
|
436
436
|
digit = BASE64_VALUES[str[i]]
|
437
437
|
raise ArgumentError unless digit
|
438
438
|
continuation = (digit & VLQ_CONTINUATION_BIT) != 0
|
439
|
-
digit &=
|
439
|
+
digit &= VLQ_BASE_MASK
|
440
440
|
value += digit << shift
|
441
441
|
if continuation
|
442
442
|
shift += VLQ_BASE_SHIFT
|
data/lib/sprockets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -437,7 +437,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
437
437
|
- !ruby/object:Gem::Version
|
438
438
|
version: '0'
|
439
439
|
requirements: []
|
440
|
-
rubygems_version: 3.
|
440
|
+
rubygems_version: 3.1.2
|
441
441
|
signing_key:
|
442
442
|
specification_version: 4
|
443
443
|
summary: Rack-based asset packaging system
|