@firebase/storage-compat 0.3.13 → 0.3.14

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/dist/index.cjs.js CHANGED
@@ -10,396 +10,396 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
12
12
 
13
- /**
14
- * @license
15
- * Copyright 2020 Google LLC
16
- *
17
- * Licensed under the Apache License, Version 2.0 (the "License");
18
- * you may not use this file except in compliance with the License.
19
- * You may obtain a copy of the License at
20
- *
21
- * http://www.apache.org/licenses/LICENSE-2.0
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the License is distributed on an "AS IS" BASIS,
25
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- * See the License for the specific language governing permissions and
27
- * limitations under the License.
28
- */
29
- class UploadTaskSnapshotCompat {
30
- constructor(_delegate, task, ref) {
31
- this._delegate = _delegate;
32
- this.task = task;
33
- this.ref = ref;
34
- }
35
- get bytesTransferred() {
36
- return this._delegate.bytesTransferred;
37
- }
38
- get metadata() {
39
- return this._delegate.metadata;
40
- }
41
- get state() {
42
- return this._delegate.state;
43
- }
44
- get totalBytes() {
45
- return this._delegate.totalBytes;
46
- }
13
+ /**
14
+ * @license
15
+ * Copyright 2020 Google LLC
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ */
29
+ class UploadTaskSnapshotCompat {
30
+ constructor(_delegate, task, ref) {
31
+ this._delegate = _delegate;
32
+ this.task = task;
33
+ this.ref = ref;
34
+ }
35
+ get bytesTransferred() {
36
+ return this._delegate.bytesTransferred;
37
+ }
38
+ get metadata() {
39
+ return this._delegate.metadata;
40
+ }
41
+ get state() {
42
+ return this._delegate.state;
43
+ }
44
+ get totalBytes() {
45
+ return this._delegate.totalBytes;
46
+ }
47
47
  }
48
48
 
49
- /**
50
- * @license
51
- * Copyright 2020 Google LLC
52
- *
53
- * Licensed under the Apache License, Version 2.0 (the "License");
54
- * you may not use this file except in compliance with the License.
55
- * You may obtain a copy of the License at
56
- *
57
- * http://www.apache.org/licenses/LICENSE-2.0
58
- *
59
- * Unless required by applicable law or agreed to in writing, software
60
- * distributed under the License is distributed on an "AS IS" BASIS,
61
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62
- * See the License for the specific language governing permissions and
63
- * limitations under the License.
64
- */
65
- class UploadTaskCompat {
66
- constructor(_delegate, _ref) {
67
- this._delegate = _delegate;
68
- this._ref = _ref;
69
- this.cancel = this._delegate.cancel.bind(this._delegate);
70
- this.catch = this._delegate.catch.bind(this._delegate);
71
- this.pause = this._delegate.pause.bind(this._delegate);
72
- this.resume = this._delegate.resume.bind(this._delegate);
73
- }
74
- get snapshot() {
75
- return new UploadTaskSnapshotCompat(this._delegate.snapshot, this, this._ref);
76
- }
77
- then(onFulfilled, onRejected) {
78
- return this._delegate.then(snapshot => {
79
- if (onFulfilled) {
80
- return onFulfilled(new UploadTaskSnapshotCompat(snapshot, this, this._ref));
81
- }
82
- }, onRejected);
83
- }
84
- on(type, nextOrObserver, error, completed) {
85
- let wrappedNextOrObserver = undefined;
86
- if (!!nextOrObserver) {
87
- if (typeof nextOrObserver === 'function') {
88
- wrappedNextOrObserver = (taskSnapshot) => nextOrObserver(new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref));
89
- }
90
- else {
91
- wrappedNextOrObserver = {
92
- next: !!nextOrObserver.next
93
- ? (taskSnapshot) => nextOrObserver.next(new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref))
94
- : undefined,
95
- complete: nextOrObserver.complete || undefined,
96
- error: nextOrObserver.error || undefined
97
- };
98
- }
99
- }
100
- return this._delegate.on(type, wrappedNextOrObserver, error || undefined, completed || undefined);
101
- }
49
+ /**
50
+ * @license
51
+ * Copyright 2020 Google LLC
52
+ *
53
+ * Licensed under the Apache License, Version 2.0 (the "License");
54
+ * you may not use this file except in compliance with the License.
55
+ * You may obtain a copy of the License at
56
+ *
57
+ * http://www.apache.org/licenses/LICENSE-2.0
58
+ *
59
+ * Unless required by applicable law or agreed to in writing, software
60
+ * distributed under the License is distributed on an "AS IS" BASIS,
61
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62
+ * See the License for the specific language governing permissions and
63
+ * limitations under the License.
64
+ */
65
+ class UploadTaskCompat {
66
+ constructor(_delegate, _ref) {
67
+ this._delegate = _delegate;
68
+ this._ref = _ref;
69
+ this.cancel = this._delegate.cancel.bind(this._delegate);
70
+ this.catch = this._delegate.catch.bind(this._delegate);
71
+ this.pause = this._delegate.pause.bind(this._delegate);
72
+ this.resume = this._delegate.resume.bind(this._delegate);
73
+ }
74
+ get snapshot() {
75
+ return new UploadTaskSnapshotCompat(this._delegate.snapshot, this, this._ref);
76
+ }
77
+ then(onFulfilled, onRejected) {
78
+ return this._delegate.then(snapshot => {
79
+ if (onFulfilled) {
80
+ return onFulfilled(new UploadTaskSnapshotCompat(snapshot, this, this._ref));
81
+ }
82
+ }, onRejected);
83
+ }
84
+ on(type, nextOrObserver, error, completed) {
85
+ let wrappedNextOrObserver = undefined;
86
+ if (!!nextOrObserver) {
87
+ if (typeof nextOrObserver === 'function') {
88
+ wrappedNextOrObserver = (taskSnapshot) => nextOrObserver(new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref));
89
+ }
90
+ else {
91
+ wrappedNextOrObserver = {
92
+ next: !!nextOrObserver.next
93
+ ? (taskSnapshot) => nextOrObserver.next(new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref))
94
+ : undefined,
95
+ complete: nextOrObserver.complete || undefined,
96
+ error: nextOrObserver.error || undefined
97
+ };
98
+ }
99
+ }
100
+ return this._delegate.on(type, wrappedNextOrObserver, error || undefined, completed || undefined);
101
+ }
102
102
  }
103
103
 
104
- class ListResultCompat {
105
- constructor(_delegate, _service) {
106
- this._delegate = _delegate;
107
- this._service = _service;
108
- }
109
- get prefixes() {
110
- return this._delegate.prefixes.map(ref => new ReferenceCompat(ref, this._service));
111
- }
112
- get items() {
113
- return this._delegate.items.map(ref => new ReferenceCompat(ref, this._service));
114
- }
115
- get nextPageToken() {
116
- return this._delegate.nextPageToken || null;
117
- }
104
+ class ListResultCompat {
105
+ constructor(_delegate, _service) {
106
+ this._delegate = _delegate;
107
+ this._service = _service;
108
+ }
109
+ get prefixes() {
110
+ return this._delegate.prefixes.map(ref => new ReferenceCompat(ref, this._service));
111
+ }
112
+ get items() {
113
+ return this._delegate.items.map(ref => new ReferenceCompat(ref, this._service));
114
+ }
115
+ get nextPageToken() {
116
+ return this._delegate.nextPageToken || null;
117
+ }
118
118
  }
119
119
 
120
- /**
121
- * @license
122
- * Copyright 2020 Google LLC
123
- *
124
- * Licensed under the Apache License, Version 2.0 (the "License");
125
- * you may not use this file except in compliance with the License.
126
- * You may obtain a copy of the License at
127
- *
128
- * http://www.apache.org/licenses/LICENSE-2.0
129
- *
130
- * Unless required by applicable law or agreed to in writing, software
131
- * distributed under the License is distributed on an "AS IS" BASIS,
132
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133
- * See the License for the specific language governing permissions and
134
- * limitations under the License.
135
- */
136
- class ReferenceCompat {
137
- constructor(_delegate, storage) {
138
- this._delegate = _delegate;
139
- this.storage = storage;
140
- }
141
- get name() {
142
- return this._delegate.name;
143
- }
144
- get bucket() {
145
- return this._delegate.bucket;
146
- }
147
- get fullPath() {
148
- return this._delegate.fullPath;
149
- }
150
- toString() {
151
- return this._delegate.toString();
152
- }
153
- /**
154
- * @returns A reference to the object obtained by
155
- * appending childPath, removing any duplicate, beginning, or trailing
156
- * slashes.
157
- */
158
- child(childPath) {
159
- const reference = storage._getChild(this._delegate, childPath);
160
- return new ReferenceCompat(reference, this.storage);
161
- }
162
- get root() {
163
- return new ReferenceCompat(this._delegate.root, this.storage);
164
- }
165
- /**
166
- * @returns A reference to the parent of the
167
- * current object, or null if the current object is the root.
168
- */
169
- get parent() {
170
- const reference = this._delegate.parent;
171
- if (reference == null) {
172
- return null;
173
- }
174
- return new ReferenceCompat(reference, this.storage);
175
- }
176
- /**
177
- * Uploads a blob to this object's location.
178
- * @param data - The blob to upload.
179
- * @returns An UploadTask that lets you control and
180
- * observe the upload.
181
- */
182
- put(data, metadata) {
183
- this._throwIfRoot('put');
184
- return new UploadTaskCompat(storage.uploadBytesResumable(this._delegate, data, metadata), this);
185
- }
186
- /**
187
- * Uploads a string to this object's location.
188
- * @param value - The string to upload.
189
- * @param format - The format of the string to upload.
190
- * @returns An UploadTask that lets you control and
191
- * observe the upload.
192
- */
193
- putString(value, format = storage.StringFormat.RAW, metadata) {
194
- this._throwIfRoot('putString');
195
- const data = storage._dataFromString(format, value);
196
- const metadataClone = Object.assign({}, metadata);
197
- if (metadataClone['contentType'] == null && data.contentType != null) {
198
- metadataClone['contentType'] = data.contentType;
199
- }
200
- return new UploadTaskCompat(new storage._UploadTask(this._delegate, new storage._FbsBlob(data.data, true), metadataClone), this);
201
- }
202
- /**
203
- * List all items (files) and prefixes (folders) under this storage reference.
204
- *
205
- * This is a helper method for calling list() repeatedly until there are
206
- * no more results. The default pagination size is 1000.
207
- *
208
- * Note: The results may not be consistent if objects are changed while this
209
- * operation is running.
210
- *
211
- * Warning: listAll may potentially consume too many resources if there are
212
- * too many results.
213
- *
214
- * @returns A Promise that resolves with all the items and prefixes under
215
- * the current storage reference. `prefixes` contains references to
216
- * sub-directories and `items` contains references to objects in this
217
- * folder. `nextPageToken` is never returned.
218
- */
219
- listAll() {
220
- return storage.listAll(this._delegate).then(r => new ListResultCompat(r, this.storage));
221
- }
222
- /**
223
- * List items (files) and prefixes (folders) under this storage reference.
224
- *
225
- * List API is only available for Firebase Rules Version 2.
226
- *
227
- * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
228
- * delimited folder structure. Refer to GCS's List API if you want to learn more.
229
- *
230
- * To adhere to Firebase Rules's Semantics, Firebase Storage does not
231
- * support objects whose paths end with "/" or contain two consecutive
232
- * "/"s. Firebase Storage List API will filter these unsupported objects.
233
- * list() may fail if there are too many unsupported objects in the bucket.
234
- *
235
- * @param options - See ListOptions for details.
236
- * @returns A Promise that resolves with the items and prefixes.
237
- * `prefixes` contains references to sub-folders and `items`
238
- * contains references to objects in this folder. `nextPageToken`
239
- * can be used to get the rest of the results.
240
- */
241
- list(options) {
242
- return storage.list(this._delegate, options || undefined).then(r => new ListResultCompat(r, this.storage));
243
- }
244
- /**
245
- * A `Promise` that resolves with the metadata for this object. If this
246
- * object doesn't exist or metadata cannot be retrieved, the promise is
247
- * rejected.
248
- */
249
- getMetadata() {
250
- return storage.getMetadata(this._delegate);
251
- }
252
- /**
253
- * Updates the metadata for this object.
254
- * @param metadata - The new metadata for the object.
255
- * Only values that have been explicitly set will be changed. Explicitly
256
- * setting a value to null will remove the metadata.
257
- * @returns A `Promise` that resolves
258
- * with the new metadata for this object.
259
- * @see firebaseStorage.Reference.prototype.getMetadata
260
- */
261
- updateMetadata(metadata) {
262
- return storage.updateMetadata(this._delegate, metadata);
263
- }
264
- /**
265
- * @returns A `Promise` that resolves with the download
266
- * URL for this object.
267
- */
268
- getDownloadURL() {
269
- return storage.getDownloadURL(this._delegate);
270
- }
271
- /**
272
- * Deletes the object at this location.
273
- * @returns A `Promise` that resolves if the deletion succeeds.
274
- */
275
- delete() {
276
- this._throwIfRoot('delete');
277
- return storage.deleteObject(this._delegate);
278
- }
279
- _throwIfRoot(name) {
280
- if (this._delegate._location.path === '') {
281
- throw storage._invalidRootOperation(name);
282
- }
283
- }
120
+ /**
121
+ * @license
122
+ * Copyright 2020 Google LLC
123
+ *
124
+ * Licensed under the Apache License, Version 2.0 (the "License");
125
+ * you may not use this file except in compliance with the License.
126
+ * You may obtain a copy of the License at
127
+ *
128
+ * http://www.apache.org/licenses/LICENSE-2.0
129
+ *
130
+ * Unless required by applicable law or agreed to in writing, software
131
+ * distributed under the License is distributed on an "AS IS" BASIS,
132
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133
+ * See the License for the specific language governing permissions and
134
+ * limitations under the License.
135
+ */
136
+ class ReferenceCompat {
137
+ constructor(_delegate, storage) {
138
+ this._delegate = _delegate;
139
+ this.storage = storage;
140
+ }
141
+ get name() {
142
+ return this._delegate.name;
143
+ }
144
+ get bucket() {
145
+ return this._delegate.bucket;
146
+ }
147
+ get fullPath() {
148
+ return this._delegate.fullPath;
149
+ }
150
+ toString() {
151
+ return this._delegate.toString();
152
+ }
153
+ /**
154
+ * @returns A reference to the object obtained by
155
+ * appending childPath, removing any duplicate, beginning, or trailing
156
+ * slashes.
157
+ */
158
+ child(childPath) {
159
+ const reference = storage._getChild(this._delegate, childPath);
160
+ return new ReferenceCompat(reference, this.storage);
161
+ }
162
+ get root() {
163
+ return new ReferenceCompat(this._delegate.root, this.storage);
164
+ }
165
+ /**
166
+ * @returns A reference to the parent of the
167
+ * current object, or null if the current object is the root.
168
+ */
169
+ get parent() {
170
+ const reference = this._delegate.parent;
171
+ if (reference == null) {
172
+ return null;
173
+ }
174
+ return new ReferenceCompat(reference, this.storage);
175
+ }
176
+ /**
177
+ * Uploads a blob to this object's location.
178
+ * @param data - The blob to upload.
179
+ * @returns An UploadTask that lets you control and
180
+ * observe the upload.
181
+ */
182
+ put(data, metadata) {
183
+ this._throwIfRoot('put');
184
+ return new UploadTaskCompat(storage.uploadBytesResumable(this._delegate, data, metadata), this);
185
+ }
186
+ /**
187
+ * Uploads a string to this object's location.
188
+ * @param value - The string to upload.
189
+ * @param format - The format of the string to upload.
190
+ * @returns An UploadTask that lets you control and
191
+ * observe the upload.
192
+ */
193
+ putString(value, format = storage.StringFormat.RAW, metadata) {
194
+ this._throwIfRoot('putString');
195
+ const data = storage._dataFromString(format, value);
196
+ const metadataClone = Object.assign({}, metadata);
197
+ if (metadataClone['contentType'] == null && data.contentType != null) {
198
+ metadataClone['contentType'] = data.contentType;
199
+ }
200
+ return new UploadTaskCompat(new storage._UploadTask(this._delegate, new storage._FbsBlob(data.data, true), metadataClone), this);
201
+ }
202
+ /**
203
+ * List all items (files) and prefixes (folders) under this storage reference.
204
+ *
205
+ * This is a helper method for calling list() repeatedly until there are
206
+ * no more results. The default pagination size is 1000.
207
+ *
208
+ * Note: The results may not be consistent if objects are changed while this
209
+ * operation is running.
210
+ *
211
+ * Warning: listAll may potentially consume too many resources if there are
212
+ * too many results.
213
+ *
214
+ * @returns A Promise that resolves with all the items and prefixes under
215
+ * the current storage reference. `prefixes` contains references to
216
+ * sub-directories and `items` contains references to objects in this
217
+ * folder. `nextPageToken` is never returned.
218
+ */
219
+ listAll() {
220
+ return storage.listAll(this._delegate).then(r => new ListResultCompat(r, this.storage));
221
+ }
222
+ /**
223
+ * List items (files) and prefixes (folders) under this storage reference.
224
+ *
225
+ * List API is only available for Firebase Rules Version 2.
226
+ *
227
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
228
+ * delimited folder structure. Refer to GCS's List API if you want to learn more.
229
+ *
230
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not
231
+ * support objects whose paths end with "/" or contain two consecutive
232
+ * "/"s. Firebase Storage List API will filter these unsupported objects.
233
+ * list() may fail if there are too many unsupported objects in the bucket.
234
+ *
235
+ * @param options - See ListOptions for details.
236
+ * @returns A Promise that resolves with the items and prefixes.
237
+ * `prefixes` contains references to sub-folders and `items`
238
+ * contains references to objects in this folder. `nextPageToken`
239
+ * can be used to get the rest of the results.
240
+ */
241
+ list(options) {
242
+ return storage.list(this._delegate, options || undefined).then(r => new ListResultCompat(r, this.storage));
243
+ }
244
+ /**
245
+ * A `Promise` that resolves with the metadata for this object. If this
246
+ * object doesn't exist or metadata cannot be retrieved, the promise is
247
+ * rejected.
248
+ */
249
+ getMetadata() {
250
+ return storage.getMetadata(this._delegate);
251
+ }
252
+ /**
253
+ * Updates the metadata for this object.
254
+ * @param metadata - The new metadata for the object.
255
+ * Only values that have been explicitly set will be changed. Explicitly
256
+ * setting a value to null will remove the metadata.
257
+ * @returns A `Promise` that resolves
258
+ * with the new metadata for this object.
259
+ * @see firebaseStorage.Reference.prototype.getMetadata
260
+ */
261
+ updateMetadata(metadata) {
262
+ return storage.updateMetadata(this._delegate, metadata);
263
+ }
264
+ /**
265
+ * @returns A `Promise` that resolves with the download
266
+ * URL for this object.
267
+ */
268
+ getDownloadURL() {
269
+ return storage.getDownloadURL(this._delegate);
270
+ }
271
+ /**
272
+ * Deletes the object at this location.
273
+ * @returns A `Promise` that resolves if the deletion succeeds.
274
+ */
275
+ delete() {
276
+ this._throwIfRoot('delete');
277
+ return storage.deleteObject(this._delegate);
278
+ }
279
+ _throwIfRoot(name) {
280
+ if (this._delegate._location.path === '') {
281
+ throw storage._invalidRootOperation(name);
282
+ }
283
+ }
284
284
  }
285
285
 
286
- /**
287
- * @license
288
- * Copyright 2020 Google LLC
289
- *
290
- * Licensed under the Apache License, Version 2.0 (the "License");
291
- * you may not use this file except in compliance with the License.
292
- * You may obtain a copy of the License at
293
- *
294
- * http://www.apache.org/licenses/LICENSE-2.0
295
- *
296
- * Unless required by applicable law or agreed to in writing, software
297
- * distributed under the License is distributed on an "AS IS" BASIS,
298
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
- * See the License for the specific language governing permissions and
300
- * limitations under the License.
301
- */
302
- /**
303
- * A service that provides firebaseStorage.Reference instances.
304
- * @param opt_url gs:// url to a custom Storage Bucket
305
- */
306
- class StorageServiceCompat {
307
- constructor(app, _delegate) {
308
- this.app = app;
309
- this._delegate = _delegate;
310
- }
311
- get maxOperationRetryTime() {
312
- return this._delegate.maxOperationRetryTime;
313
- }
314
- get maxUploadRetryTime() {
315
- return this._delegate.maxUploadRetryTime;
316
- }
317
- /**
318
- * Returns a firebaseStorage.Reference for the given path in the default
319
- * bucket.
320
- */
321
- ref(path) {
322
- if (isUrl(path)) {
323
- throw storage._invalidArgument('ref() expected a child path but got a URL, use refFromURL instead.');
324
- }
325
- return new ReferenceCompat(storage.ref(this._delegate, path), this);
326
- }
327
- /**
328
- * Returns a firebaseStorage.Reference object for the given absolute URL,
329
- * which must be a gs:// or http[s]:// URL.
330
- */
331
- refFromURL(url) {
332
- if (!isUrl(url)) {
333
- throw storage._invalidArgument('refFromURL() expected a full URL but got a child path, use ref() instead.');
334
- }
335
- try {
336
- storage._Location.makeFromUrl(url, this._delegate.host);
337
- }
338
- catch (e) {
339
- throw storage._invalidArgument('refFromUrl() expected a valid full URL but got an invalid one.');
340
- }
341
- return new ReferenceCompat(storage.ref(this._delegate, url), this);
342
- }
343
- setMaxUploadRetryTime(time) {
344
- this._delegate.maxUploadRetryTime = time;
345
- }
346
- setMaxOperationRetryTime(time) {
347
- this._delegate.maxOperationRetryTime = time;
348
- }
349
- useEmulator(host, port, options = {}) {
350
- storage.connectStorageEmulator(this._delegate, host, port, options);
351
- }
352
- }
353
- function isUrl(path) {
354
- return /^[A-Za-z]+:\/\//.test(path);
286
+ /**
287
+ * @license
288
+ * Copyright 2020 Google LLC
289
+ *
290
+ * Licensed under the Apache License, Version 2.0 (the "License");
291
+ * you may not use this file except in compliance with the License.
292
+ * You may obtain a copy of the License at
293
+ *
294
+ * http://www.apache.org/licenses/LICENSE-2.0
295
+ *
296
+ * Unless required by applicable law or agreed to in writing, software
297
+ * distributed under the License is distributed on an "AS IS" BASIS,
298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299
+ * See the License for the specific language governing permissions and
300
+ * limitations under the License.
301
+ */
302
+ /**
303
+ * A service that provides firebaseStorage.Reference instances.
304
+ * @param opt_url gs:// url to a custom Storage Bucket
305
+ */
306
+ class StorageServiceCompat {
307
+ constructor(app, _delegate) {
308
+ this.app = app;
309
+ this._delegate = _delegate;
310
+ }
311
+ get maxOperationRetryTime() {
312
+ return this._delegate.maxOperationRetryTime;
313
+ }
314
+ get maxUploadRetryTime() {
315
+ return this._delegate.maxUploadRetryTime;
316
+ }
317
+ /**
318
+ * Returns a firebaseStorage.Reference for the given path in the default
319
+ * bucket.
320
+ */
321
+ ref(path) {
322
+ if (isUrl(path)) {
323
+ throw storage._invalidArgument('ref() expected a child path but got a URL, use refFromURL instead.');
324
+ }
325
+ return new ReferenceCompat(storage.ref(this._delegate, path), this);
326
+ }
327
+ /**
328
+ * Returns a firebaseStorage.Reference object for the given absolute URL,
329
+ * which must be a gs:// or http[s]:// URL.
330
+ */
331
+ refFromURL(url) {
332
+ if (!isUrl(url)) {
333
+ throw storage._invalidArgument('refFromURL() expected a full URL but got a child path, use ref() instead.');
334
+ }
335
+ try {
336
+ storage._Location.makeFromUrl(url, this._delegate.host);
337
+ }
338
+ catch (e) {
339
+ throw storage._invalidArgument('refFromUrl() expected a valid full URL but got an invalid one.');
340
+ }
341
+ return new ReferenceCompat(storage.ref(this._delegate, url), this);
342
+ }
343
+ setMaxUploadRetryTime(time) {
344
+ this._delegate.maxUploadRetryTime = time;
345
+ }
346
+ setMaxOperationRetryTime(time) {
347
+ this._delegate.maxOperationRetryTime = time;
348
+ }
349
+ useEmulator(host, port, options = {}) {
350
+ storage.connectStorageEmulator(this._delegate, host, port, options);
351
+ }
352
+ }
353
+ function isUrl(path) {
354
+ return /^[A-Za-z]+:\/\//.test(path);
355
355
  }
356
356
 
357
357
  const name = "@firebase/storage-compat";
358
- const version = "0.3.13";
358
+ const version = "0.3.14";
359
359
 
360
- /**
361
- * @license
362
- * Copyright 2020 Google LLC
363
- *
364
- * Licensed under the Apache License, Version 2.0 (the "License");
365
- * you may not use this file except in compliance with the License.
366
- * You may obtain a copy of the License at
367
- *
368
- * http://www.apache.org/licenses/LICENSE-2.0
369
- *
370
- * Unless required by applicable law or agreed to in writing, software
371
- * distributed under the License is distributed on an "AS IS" BASIS,
372
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
373
- * See the License for the specific language governing permissions and
374
- * limitations under the License.
375
- */
376
- /**
377
- * Type constant for Firebase Storage.
378
- */
379
- const STORAGE_TYPE = 'storage-compat';
380
- function factory(container, { instanceIdentifier: url }) {
381
- // Dependencies
382
- const app = container.getProvider('app-compat').getImmediate();
383
- const storageExp = container
384
- .getProvider('storage')
385
- .getImmediate({ identifier: url });
386
- const storageServiceCompat = new StorageServiceCompat(app, storageExp);
387
- return storageServiceCompat;
388
- }
389
- function registerStorage(instance) {
390
- const namespaceExports = {
391
- // no-inline
392
- TaskState: storage._TaskState,
393
- TaskEvent: storage._TaskEvent,
394
- StringFormat: storage.StringFormat,
395
- Storage: StorageServiceCompat,
396
- Reference: ReferenceCompat
397
- };
398
- instance.INTERNAL.registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */)
399
- .setServiceProps(namespaceExports)
400
- .setMultipleInstances(true));
401
- instance.registerVersion(name, version);
402
- }
360
+ /**
361
+ * @license
362
+ * Copyright 2020 Google LLC
363
+ *
364
+ * Licensed under the Apache License, Version 2.0 (the "License");
365
+ * you may not use this file except in compliance with the License.
366
+ * You may obtain a copy of the License at
367
+ *
368
+ * http://www.apache.org/licenses/LICENSE-2.0
369
+ *
370
+ * Unless required by applicable law or agreed to in writing, software
371
+ * distributed under the License is distributed on an "AS IS" BASIS,
372
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
373
+ * See the License for the specific language governing permissions and
374
+ * limitations under the License.
375
+ */
376
+ /**
377
+ * Type constant for Firebase Storage.
378
+ */
379
+ const STORAGE_TYPE = 'storage-compat';
380
+ function factory(container, { instanceIdentifier: url }) {
381
+ // Dependencies
382
+ const app = container.getProvider('app-compat').getImmediate();
383
+ const storageExp = container
384
+ .getProvider('storage')
385
+ .getImmediate({ identifier: url });
386
+ const storageServiceCompat = new StorageServiceCompat(app, storageExp);
387
+ return storageServiceCompat;
388
+ }
389
+ function registerStorage(instance) {
390
+ const namespaceExports = {
391
+ // no-inline
392
+ TaskState: storage._TaskState,
393
+ TaskEvent: storage._TaskEvent,
394
+ StringFormat: storage.StringFormat,
395
+ Storage: StorageServiceCompat,
396
+ Reference: ReferenceCompat
397
+ };
398
+ instance.INTERNAL.registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */)
399
+ .setServiceProps(namespaceExports)
400
+ .setMultipleInstances(true));
401
+ instance.registerVersion(name, version);
402
+ }
403
403
  registerStorage(firebase__default["default"]);
404
404
 
405
405
  exports.registerStorage = registerStorage;