@firebase/storage-compat 0.3.13 → 0.3.14-canary.ffbf5a60a

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