@rails/activestorage 6.0.0 → 7.0.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.
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@rails/activestorage",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "Attach cloud and local files in Rails applications",
5
+ "module": "app/assets/javascripts/activestorage.esm.js",
5
6
  "main": "app/assets/javascripts/activestorage.js",
6
7
  "files": [
7
8
  "app/assets/javascripts/*.js",
8
9
  "src/*.js"
9
10
  ],
10
- "homepage": "http://rubyonrails.org/",
11
+ "homepage": "https://rubyonrails.org/",
11
12
  "repository": {
12
13
  "type": "git",
13
14
  "url": "git+https://github.com/rails/rails.git"
@@ -18,19 +19,15 @@
18
19
  "author": "Javan Makhmali <javan@javan.us>",
19
20
  "license": "MIT",
20
21
  "dependencies": {
21
- "spark-md5": "^3.0.0"
22
+ "spark-md5": "^3.0.1"
22
23
  },
23
24
  "devDependencies": {
24
- "babel-core": "^6.25.0",
25
- "babel-plugin-external-helpers": "^6.22.0",
26
- "babel-preset-env": "^1.6.0",
25
+ "@rollup/plugin-node-resolve": "^11.0.1",
26
+ "@rollup/plugin-commonjs": "^19.0.1",
27
27
  "eslint": "^4.3.0",
28
- "eslint-plugin-import": "^2.7.0",
29
- "rollup": "^0.58.2",
30
- "rollup-plugin-babel": "^3.0.4",
31
- "rollup-plugin-commonjs": "^9.1.0",
32
- "rollup-plugin-node-resolve": "^3.3.0",
33
- "rollup-plugin-uglify": "^3.0.0"
28
+ "eslint-plugin-import": "^2.23.4",
29
+ "rollup": "^2.35.1",
30
+ "rollup-plugin-terser": "^7.0.2"
34
31
  },
35
32
  "scripts": {
36
33
  "prebuild": "yarn lint",
@@ -1,16 +1,19 @@
1
1
  import { getMetaValue } from "./helpers"
2
2
 
3
3
  export class BlobRecord {
4
- constructor(file, checksum, url) {
4
+ constructor(file, checksum, url, directUploadToken, attachmentName) {
5
5
  this.file = file
6
6
 
7
7
  this.attributes = {
8
8
  filename: file.name,
9
- content_type: file.type,
9
+ content_type: file.type || "application/octet-stream",
10
10
  byte_size: file.size,
11
- checksum: checksum
11
+ checksum: checksum,
12
12
  }
13
13
 
14
+ this.directUploadToken = directUploadToken
15
+ this.attachmentName = attachmentName
16
+
14
17
  this.xhr = new XMLHttpRequest
15
18
  this.xhr.open("POST", url, true)
16
19
  this.xhr.responseType = "json"
@@ -43,7 +46,11 @@ export class BlobRecord {
43
46
 
44
47
  create(callback) {
45
48
  this.callback = callback
46
- this.xhr.send(JSON.stringify({ blob: this.attributes }))
49
+ this.xhr.send(JSON.stringify({
50
+ blob: this.attributes,
51
+ direct_upload_token: this.directUploadToken,
52
+ attachment_name: this.attachmentName
53
+ }))
47
54
  }
48
55
 
49
56
  requestDidLoad(event) {
@@ -5,10 +5,12 @@ import { BlobUpload } from "./blob_upload"
5
5
  let id = 0
6
6
 
7
7
  export class DirectUpload {
8
- constructor(file, url, delegate) {
8
+ constructor(file, url, serviceName, attachmentName, delegate) {
9
9
  this.id = ++id
10
10
  this.file = file
11
11
  this.url = url
12
+ this.serviceName = serviceName
13
+ this.attachmentName = attachmentName
12
14
  this.delegate = delegate
13
15
  }
14
16
 
@@ -19,7 +21,7 @@ export class DirectUpload {
19
21
  return
20
22
  }
21
23
 
22
- const blob = new BlobRecord(this.file, checksum, this.url)
24
+ const blob = new BlobRecord(this.file, checksum, this.url, this.serviceName, this.attachmentName)
23
25
  notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr)
24
26
 
25
27
  blob.create(error => {
@@ -5,7 +5,7 @@ export class DirectUploadController {
5
5
  constructor(input, file) {
6
6
  this.input = input
7
7
  this.file = file
8
- this.directUpload = new DirectUpload(this.file, this.url, this)
8
+ this.directUpload = new DirectUpload(this.file, this.url, this.directUploadToken, this.attachmentName, this)
9
9
  this.dispatch("initialize")
10
10
  }
11
11
 
@@ -41,6 +41,14 @@ export class DirectUploadController {
41
41
  return this.input.getAttribute("data-direct-upload-url")
42
42
  }
43
43
 
44
+ get directUploadToken() {
45
+ return this.input.getAttribute("data-direct-upload-token")
46
+ }
47
+
48
+ get attachmentName() {
49
+ return this.input.getAttribute("data-direct-upload-attachment-name")
50
+ }
51
+
44
52
  dispatch(name, detail = {}) {
45
53
  detail.file = this.file
46
54
  detail.id = this.directUpload.id
package/src/ujs.js CHANGED
@@ -9,7 +9,7 @@ export function start() {
9
9
  if (!started) {
10
10
  started = true
11
11
  document.addEventListener("click", didClick, true)
12
- document.addEventListener("submit", didSubmitForm)
12
+ document.addEventListener("submit", didSubmitForm, true)
13
13
  document.addEventListener("ajax:before", didSubmitRemoteElement)
14
14
  }
15
15
  }
package/CHANGELOG.md DELETED
@@ -1,198 +0,0 @@
1
- ## Rails 6.0.0 (August 16, 2019) ##
2
-
3
- * No changes.
4
-
5
-
6
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
12
-
13
- * Don't raise when analyzing an image whose type is unsupported by ImageMagick.
14
-
15
- Fixes #36065.
16
-
17
- *Guilherme Mansur*
18
-
19
- * Permit generating variants of BMP images.
20
-
21
- *Younes Serraj*
22
-
23
-
24
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
25
-
26
- * No changes.
27
-
28
-
29
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
30
-
31
- * No changes.
32
-
33
-
34
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
35
-
36
- * [Rename npm package](https://github.com/rails/rails/pull/34905) from
37
- [`activestorage`](https://www.npmjs.com/package/activestorage) to
38
- [`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
39
-
40
- *Javan Makhmali*
41
-
42
- * Replace `config.active_storage.queue` with two options that indicate which
43
- queues analysis and purge jobs should use, respectively:
44
-
45
- * `config.active_storage.queues.analysis`
46
- * `config.active_storage.queues.purge`
47
-
48
- `config.active_storage.queue` is preferred over the new options when it's
49
- set, but it is deprecated and will be removed in Rails 6.1.
50
-
51
- *George Claghorn*
52
-
53
- * Permit generating variants of TIFF images.
54
-
55
- *Luciano Sousa*
56
-
57
- * Use base36 (all lowercase) for all new Blob keys to prevent
58
- collisions and undefined behavior with case-insensitive filesystems and
59
- database indices.
60
-
61
- *Julik Tarkhanov*
62
-
63
- * It doesn’t include an `X-CSRF-Token` header if a meta tag is not found on
64
- the page. It previously included one with a value of `undefined`.
65
-
66
- *Cameron Bothner*
67
-
68
- * Fix `ArgumentError` when uploading to amazon s3
69
-
70
- *Hiroki Sanpei*
71
-
72
- * Add progressive JPG to default list of variable content types
73
-
74
- *Maurice Kühlborn*
75
-
76
- * Add `ActiveStorage.routes_prefix` for configuring generated routes.
77
-
78
- *Chris Bisnett*
79
-
80
- * `ActiveStorage::Service::AzureStorageService` only handles specifically
81
- relevant types of `Azure::Core::Http::HTTPError`. It previously obscured
82
- other types of `HTTPError`, which is the azure-storage gem’s catch-all
83
- exception class.
84
-
85
- *Cameron Bothner*
86
-
87
- * `ActiveStorage::DiskController#show` generates a 404 Not Found response when
88
- the requested file is missing from the disk service. It previously raised
89
- `Errno::ENOENT`.
90
-
91
- *Cameron Bothner*
92
-
93
- * `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise
94
- `ActiveStorage::FileNotFoundError` when the corresponding file is missing
95
- from the storage service. Services translate service-specific missing object
96
- exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and
97
- `Errno::ENOENT` for the disk service) into
98
- `ActiveStorage::FileNotFoundError`.
99
-
100
- *Cameron Bothner*
101
-
102
- * Added the `ActiveStorage::SetCurrent` concern for custom Active Storage
103
- controllers that can't inherit from `ActiveStorage::BaseController`.
104
-
105
- *George Claghorn*
106
-
107
- * Active Storage error classes like `ActiveStorage::IntegrityError` and
108
- `ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
109
- instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
110
- handle all Active Storage errors.
111
-
112
- *Andrei Makarov*, *George Claghorn*
113
-
114
- * Uploaded files assigned to a record are persisted to storage when the record
115
- is saved instead of immediately.
116
-
117
- In Rails 5.2, the following causes an uploaded file in `params[:avatar]` to
118
- be stored:
119
-
120
- ```ruby
121
- @user.avatar = params[:avatar]
122
- ```
123
-
124
- In Rails 6, the uploaded file is stored when `@user` is successfully saved.
125
-
126
- *George Claghorn*
127
-
128
- * Add the ability to reflect on defined attachments using the existing
129
- ActiveRecord reflection mechanism.
130
-
131
- *Kevin Deisz*
132
-
133
- * Variant arguments of `false` or `nil` will no longer be passed to the
134
- processor. For example, the following will not have the monochrome
135
- variation applied:
136
-
137
- ```ruby
138
- avatar.variant(monochrome: false)
139
- ```
140
-
141
- *Jacob Smith*
142
-
143
- * Generated attachment getter and setter methods are created
144
- within the model's `GeneratedAssociationMethods` module to
145
- allow overriding and composition using `super`.
146
-
147
- *Josh Susser*, *Jamon Douglas*
148
-
149
- * Add `ActiveStorage::Blob#open`, which downloads a blob to a tempfile on disk
150
- and yields the tempfile. Deprecate `ActiveStorage::Downloading`.
151
-
152
- *David Robertson*, *George Claghorn*
153
-
154
- * Pass in `identify: false` as an argument when providing a `content_type` for
155
- `ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
156
- type inference. For example:
157
-
158
- ```ruby
159
- @message.image.attach(
160
- io: File.open('/path/to/file'),
161
- filename: 'file.pdf',
162
- content_type: 'application/pdf',
163
- identify: false
164
- )
165
- ```
166
-
167
- *Ryan Davidson*
168
-
169
- * The Google Cloud Storage service properly supports streaming downloads.
170
- It now requires version 1.11 or newer of the google-cloud-storage gem.
171
-
172
- *George Claghorn*
173
-
174
- * Use the [ImageProcessing](https://github.com/janko-m/image_processing) gem
175
- for Active Storage variants, and deprecate the MiniMagick backend.
176
-
177
- This means that variants are now automatically oriented if the original
178
- image was rotated. Also, in addition to the existing ImageMagick
179
- operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
180
- other ImageProcessing macros. These are now recommended over raw `:resize`,
181
- as they also sharpen the thumbnail after resizing.
182
-
183
- The ImageProcessing gem also comes with a backend implemented on
184
- [libvips](http://jcupitt.github.io/libvips/), an alternative to
185
- ImageMagick which has significantly better performance than
186
- ImageMagick in most cases, both in terms of speed and memory usage. In
187
- Active Storage it's now possible to switch to the libvips backend by
188
- changing `Rails.application.config.active_storage.variant_processor` to
189
- `:vips`.
190
-
191
- *Janko Marohnić*
192
-
193
- * Rails 6 requires Ruby 2.5.0 or newer.
194
-
195
- *Jeremy Daer*, *Kasper Timm Hansen*
196
-
197
-
198
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activestorage/CHANGELOG.md) for previous changes.