@firebase/storage 0.9.14 → 0.10.0-20221206221533

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.
@@ -121,13 +121,13 @@ function prependCode(code) {
121
121
  function unknown() {
122
122
  const message = 'An unknown error occurred, please check the error payload for ' +
123
123
  'server response.';
124
- return new StorageError("unknown" /* UNKNOWN */, message);
124
+ return new StorageError("unknown" /* StorageErrorCode.UNKNOWN */, message);
125
125
  }
126
126
  function objectNotFound(path) {
127
- return new StorageError("object-not-found" /* OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
127
+ return new StorageError("object-not-found" /* StorageErrorCode.OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
128
128
  }
129
129
  function quotaExceeded(bucket) {
130
- return new StorageError("quota-exceeded" /* QUOTA_EXCEEDED */, "Quota for bucket '" +
130
+ return new StorageError("quota-exceeded" /* StorageErrorCode.QUOTA_EXCEEDED */, "Quota for bucket '" +
131
131
  bucket +
132
132
  "' exceeded, please view quota on " +
133
133
  'https://firebase.google.com/pricing/.');
@@ -135,49 +135,49 @@ function quotaExceeded(bucket) {
135
135
  function unauthenticated() {
136
136
  const message = 'User is not authenticated, please authenticate using Firebase ' +
137
137
  'Authentication and try again.';
138
- return new StorageError("unauthenticated" /* UNAUTHENTICATED */, message);
138
+ return new StorageError("unauthenticated" /* StorageErrorCode.UNAUTHENTICATED */, message);
139
139
  }
140
140
  function unauthorizedApp() {
141
- return new StorageError("unauthorized-app" /* UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
141
+ return new StorageError("unauthorized-app" /* StorageErrorCode.UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
142
142
  }
143
143
  function unauthorized(path) {
144
- return new StorageError("unauthorized" /* UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
144
+ return new StorageError("unauthorized" /* StorageErrorCode.UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
145
145
  }
146
146
  function retryLimitExceeded() {
147
- return new StorageError("retry-limit-exceeded" /* RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
147
+ return new StorageError("retry-limit-exceeded" /* StorageErrorCode.RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
148
148
  }
149
149
  function canceled() {
150
- return new StorageError("canceled" /* CANCELED */, 'User canceled the upload/download.');
150
+ return new StorageError("canceled" /* StorageErrorCode.CANCELED */, 'User canceled the upload/download.');
151
151
  }
152
152
  function invalidUrl(url) {
153
- return new StorageError("invalid-url" /* INVALID_URL */, "Invalid URL '" + url + "'.");
153
+ return new StorageError("invalid-url" /* StorageErrorCode.INVALID_URL */, "Invalid URL '" + url + "'.");
154
154
  }
155
155
  function invalidDefaultBucket(bucket) {
156
- return new StorageError("invalid-default-bucket" /* INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
156
+ return new StorageError("invalid-default-bucket" /* StorageErrorCode.INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
157
157
  }
158
158
  function noDefaultBucket() {
159
- return new StorageError("no-default-bucket" /* NO_DEFAULT_BUCKET */, 'No default bucket ' +
159
+ return new StorageError("no-default-bucket" /* StorageErrorCode.NO_DEFAULT_BUCKET */, 'No default bucket ' +
160
160
  "found. Did you set the '" +
161
161
  CONFIG_STORAGE_BUCKET_KEY +
162
162
  "' property when initializing the app?");
163
163
  }
164
164
  function cannotSliceBlob() {
165
- return new StorageError("cannot-slice-blob" /* CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
165
+ return new StorageError("cannot-slice-blob" /* StorageErrorCode.CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
166
166
  }
167
167
  function serverFileWrongSize() {
168
- return new StorageError("server-file-wrong-size" /* SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
168
+ return new StorageError("server-file-wrong-size" /* StorageErrorCode.SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
169
169
  }
170
170
  function noDownloadURL() {
171
- return new StorageError("no-download-url" /* NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
171
+ return new StorageError("no-download-url" /* StorageErrorCode.NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
172
172
  }
173
173
  /**
174
174
  * @internal
175
175
  */
176
176
  function invalidArgument(message) {
177
- return new StorageError("invalid-argument" /* INVALID_ARGUMENT */, message);
177
+ return new StorageError("invalid-argument" /* StorageErrorCode.INVALID_ARGUMENT */, message);
178
178
  }
179
179
  function appDeleted() {
180
- return new StorageError("app-deleted" /* APP_DELETED */, 'The Firebase app was deleted.');
180
+ return new StorageError("app-deleted" /* StorageErrorCode.APP_DELETED */, 'The Firebase app was deleted.');
181
181
  }
182
182
  /**
183
183
  * @param name - The name of the operation that was invalid.
@@ -185,7 +185,7 @@ function appDeleted() {
185
185
  * @internal
186
186
  */
187
187
  function invalidRootOperation(name) {
188
- return new StorageError("invalid-root-operation" /* INVALID_ROOT_OPERATION */, "The operation '" +
188
+ return new StorageError("invalid-root-operation" /* StorageErrorCode.INVALID_ROOT_OPERATION */, "The operation '" +
189
189
  name +
190
190
  "' cannot be performed on a root reference, create a non-root " +
191
191
  "reference using child, such as .child('file.png').");
@@ -195,13 +195,13 @@ function invalidRootOperation(name) {
195
195
  * @param message - A message describing the format violation.
196
196
  */
197
197
  function invalidFormat(format, message) {
198
- return new StorageError("invalid-format" /* INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
198
+ return new StorageError("invalid-format" /* StorageErrorCode.INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
199
199
  }
200
200
  /**
201
201
  * @param message - A message describing the internal error.
202
202
  */
203
203
  function internalError(message) {
204
- throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
204
+ throw new StorageError("internal-error" /* StorageErrorCode.INTERNAL_ERROR */, 'Internal error: ' + message);
205
205
  }
206
206
 
207
207
  /**
@@ -862,7 +862,7 @@ function getBlob$1(...args) {
862
862
  return new Blob(args);
863
863
  }
864
864
  else {
865
- throw new StorageError("unsupported-environment" /* UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
865
+ throw new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
866
866
  }
867
867
  }
868
868
  }
@@ -2021,17 +2021,17 @@ const TaskState = {
2021
2021
  };
2022
2022
  function taskStateFromInternalTaskState(state) {
2023
2023
  switch (state) {
2024
- case "running" /* RUNNING */:
2025
- case "pausing" /* PAUSING */:
2026
- case "canceling" /* CANCELING */:
2024
+ case "running" /* InternalTaskState.RUNNING */:
2025
+ case "pausing" /* InternalTaskState.PAUSING */:
2026
+ case "canceling" /* InternalTaskState.CANCELING */:
2027
2027
  return TaskState.RUNNING;
2028
- case "paused" /* PAUSED */:
2028
+ case "paused" /* InternalTaskState.PAUSED */:
2029
2029
  return TaskState.PAUSED;
2030
- case "success" /* SUCCESS */:
2030
+ case "success" /* InternalTaskState.SUCCESS */:
2031
2031
  return TaskState.SUCCESS;
2032
- case "canceled" /* CANCELED */:
2032
+ case "canceled" /* InternalTaskState.CANCELED */:
2033
2033
  return TaskState.CANCELED;
2034
- case "error" /* ERROR */:
2034
+ case "error" /* InternalTaskState.ERROR */:
2035
2035
  return TaskState.ERROR;
2036
2036
  default:
2037
2037
  // TODO(andysoto): assert(false);
@@ -2133,7 +2133,6 @@ class FetchConnection {
2133
2133
  this.errorCode_ = ErrorCode.NO_ERROR;
2134
2134
  }
2135
2135
  async send(url, method, body, headers) {
2136
- var _a;
2137
2136
  if (this.sent_) {
2138
2137
  throw internalError('cannot .send() more than once');
2139
2138
  }
@@ -2150,7 +2149,7 @@ class FetchConnection {
2150
2149
  this.body_ = await response.arrayBuffer();
2151
2150
  }
2152
2151
  catch (e) {
2153
- this.errorText_ = (_a = e) === null || _a === void 0 ? void 0 : _a.message;
2152
+ this.errorText_ = e === null || e === void 0 ? void 0 : e.message;
2154
2153
  // emulate XHR which sets status to 0 when encountering a network error
2155
2154
  this.statusCode_ = 0;
2156
2155
  this.errorCode_ = ErrorCode.NETWORK_ERROR;
@@ -2217,7 +2216,6 @@ class FetchStreamConnection extends FetchConnection {
2217
2216
  this.stream_ = null;
2218
2217
  }
2219
2218
  async send(url, method, body, headers) {
2220
- var _a;
2221
2219
  if (this.sent_) {
2222
2220
  throw internalError('cannot .send() more than once');
2223
2221
  }
@@ -2234,7 +2232,7 @@ class FetchStreamConnection extends FetchConnection {
2234
2232
  this.stream_ = response.body;
2235
2233
  }
2236
2234
  catch (e) {
2237
- this.errorText_ = (_a = e) === null || _a === void 0 ? void 0 : _a.message;
2235
+ this.errorText_ = e === null || e === void 0 ? void 0 : e.message;
2238
2236
  // emulate XHR which sets status to 0 when encountering a network error
2239
2237
  this.statusCode_ = 0;
2240
2238
  this.errorCode_ = ErrorCode.NETWORK_ERROR;
@@ -2297,11 +2295,11 @@ class UploadTask {
2297
2295
  this._metadata = metadata;
2298
2296
  this._mappings = getMappings();
2299
2297
  this._resumable = this._shouldDoResumable(this._blob);
2300
- this._state = "running" /* RUNNING */;
2298
+ this._state = "running" /* InternalTaskState.RUNNING */;
2301
2299
  this._errorHandler = error => {
2302
2300
  this._request = undefined;
2303
2301
  this._chunkMultiplier = 1;
2304
- if (error._codeEquals("canceled" /* CANCELED */)) {
2302
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2305
2303
  this._needToFetchStatus = true;
2306
2304
  this.completeTransitions_();
2307
2305
  }
@@ -2319,17 +2317,17 @@ class UploadTask {
2319
2317
  }
2320
2318
  }
2321
2319
  this._error = error;
2322
- this._transition("error" /* ERROR */);
2320
+ this._transition("error" /* InternalTaskState.ERROR */);
2323
2321
  }
2324
2322
  };
2325
2323
  this._metadataErrorHandler = error => {
2326
2324
  this._request = undefined;
2327
- if (error._codeEquals("canceled" /* CANCELED */)) {
2325
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2328
2326
  this.completeTransitions_();
2329
2327
  }
2330
2328
  else {
2331
2329
  this._error = error;
2332
- this._transition("error" /* ERROR */);
2330
+ this._transition("error" /* InternalTaskState.ERROR */);
2333
2331
  }
2334
2332
  };
2335
2333
  this.sleepTime = 0;
@@ -2354,7 +2352,7 @@ class UploadTask {
2354
2352
  return blob.size() > 256 * 1024;
2355
2353
  }
2356
2354
  _start() {
2357
- if (this._state !== "running" /* RUNNING */) {
2355
+ if (this._state !== "running" /* InternalTaskState.RUNNING */) {
2358
2356
  // This can happen if someone pauses us in a resume callback, for example.
2359
2357
  return;
2360
2358
  }
@@ -2394,14 +2392,14 @@ class UploadTask {
2394
2392
  this._ref.storage._getAppCheckToken()
2395
2393
  ]).then(([authToken, appCheckToken]) => {
2396
2394
  switch (this._state) {
2397
- case "running" /* RUNNING */:
2395
+ case "running" /* InternalTaskState.RUNNING */:
2398
2396
  callback(authToken, appCheckToken);
2399
2397
  break;
2400
- case "canceling" /* CANCELING */:
2401
- this._transition("canceled" /* CANCELED */);
2398
+ case "canceling" /* InternalTaskState.CANCELING */:
2399
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2402
2400
  break;
2403
- case "pausing" /* PAUSING */:
2404
- this._transition("paused" /* PAUSED */);
2401
+ case "pausing" /* InternalTaskState.PAUSING */:
2402
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2405
2403
  break;
2406
2404
  }
2407
2405
  });
@@ -2451,7 +2449,7 @@ class UploadTask {
2451
2449
  }
2452
2450
  catch (e) {
2453
2451
  this._error = e;
2454
- this._transition("error" /* ERROR */);
2452
+ this._transition("error" /* InternalTaskState.ERROR */);
2455
2453
  return;
2456
2454
  }
2457
2455
  const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken,
@@ -2464,7 +2462,7 @@ class UploadTask {
2464
2462
  this._updateProgress(newStatus.current);
2465
2463
  if (newStatus.finalized) {
2466
2464
  this._metadata = newStatus.metadata;
2467
- this._transition("success" /* SUCCESS */);
2465
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2468
2466
  }
2469
2467
  else {
2470
2468
  this.completeTransitions_();
@@ -2487,7 +2485,7 @@ class UploadTask {
2487
2485
  metadataRequest.getPromise().then(metadata => {
2488
2486
  this._request = undefined;
2489
2487
  this._metadata = metadata;
2490
- this._transition("success" /* SUCCESS */);
2488
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2491
2489
  }, this._metadataErrorHandler);
2492
2490
  });
2493
2491
  }
@@ -2500,7 +2498,7 @@ class UploadTask {
2500
2498
  this._request = undefined;
2501
2499
  this._metadata = metadata;
2502
2500
  this._updateProgress(this._blob.size());
2503
- this._transition("success" /* SUCCESS */);
2501
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2504
2502
  }, this._errorHandler);
2505
2503
  });
2506
2504
  }
@@ -2519,8 +2517,8 @@ class UploadTask {
2519
2517
  return;
2520
2518
  }
2521
2519
  switch (state) {
2522
- case "canceling" /* CANCELING */:
2523
- case "pausing" /* PAUSING */:
2520
+ case "canceling" /* InternalTaskState.CANCELING */:
2521
+ case "pausing" /* InternalTaskState.PAUSING */:
2524
2522
  // TODO(andysoto):
2525
2523
  // assert(this.state_ === InternalTaskState.RUNNING ||
2526
2524
  // this.state_ === InternalTaskState.PAUSING);
@@ -2534,24 +2532,24 @@ class UploadTask {
2534
2532
  this.completeTransitions_();
2535
2533
  }
2536
2534
  break;
2537
- case "running" /* RUNNING */:
2535
+ case "running" /* InternalTaskState.RUNNING */:
2538
2536
  // TODO(andysoto):
2539
2537
  // assert(this.state_ === InternalTaskState.PAUSED ||
2540
2538
  // this.state_ === InternalTaskState.PAUSING);
2541
- const wasPaused = this._state === "paused" /* PAUSED */;
2539
+ const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */;
2542
2540
  this._state = state;
2543
2541
  if (wasPaused) {
2544
2542
  this._notifyObservers();
2545
2543
  this._start();
2546
2544
  }
2547
2545
  break;
2548
- case "paused" /* PAUSED */:
2546
+ case "paused" /* InternalTaskState.PAUSED */:
2549
2547
  // TODO(andysoto):
2550
2548
  // assert(this.state_ === InternalTaskState.PAUSING);
2551
2549
  this._state = state;
2552
2550
  this._notifyObservers();
2553
2551
  break;
2554
- case "canceled" /* CANCELED */:
2552
+ case "canceled" /* InternalTaskState.CANCELED */:
2555
2553
  // TODO(andysoto):
2556
2554
  // assert(this.state_ === InternalTaskState.PAUSED ||
2557
2555
  // this.state_ === InternalTaskState.CANCELING);
@@ -2559,7 +2557,7 @@ class UploadTask {
2559
2557
  this._state = state;
2560
2558
  this._notifyObservers();
2561
2559
  break;
2562
- case "error" /* ERROR */:
2560
+ case "error" /* InternalTaskState.ERROR */:
2563
2561
  // TODO(andysoto):
2564
2562
  // assert(this.state_ === InternalTaskState.RUNNING ||
2565
2563
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2567,7 +2565,7 @@ class UploadTask {
2567
2565
  this._state = state;
2568
2566
  this._notifyObservers();
2569
2567
  break;
2570
- case "success" /* SUCCESS */:
2568
+ case "success" /* InternalTaskState.SUCCESS */:
2571
2569
  // TODO(andysoto):
2572
2570
  // assert(this.state_ === InternalTaskState.RUNNING ||
2573
2571
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2579,13 +2577,13 @@ class UploadTask {
2579
2577
  }
2580
2578
  completeTransitions_() {
2581
2579
  switch (this._state) {
2582
- case "pausing" /* PAUSING */:
2583
- this._transition("paused" /* PAUSED */);
2580
+ case "pausing" /* InternalTaskState.PAUSING */:
2581
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2584
2582
  break;
2585
- case "canceling" /* CANCELING */:
2586
- this._transition("canceled" /* CANCELED */);
2583
+ case "canceling" /* InternalTaskState.CANCELING */:
2584
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2587
2585
  break;
2588
- case "running" /* RUNNING */:
2586
+ case "running" /* InternalTaskState.RUNNING */:
2589
2587
  this._start();
2590
2588
  break;
2591
2589
  }
@@ -2723,10 +2721,10 @@ class UploadTask {
2723
2721
  * @returns True if the operation took effect, false if ignored.
2724
2722
  */
2725
2723
  resume() {
2726
- const valid = this._state === "paused" /* PAUSED */ ||
2727
- this._state === "pausing" /* PAUSING */;
2724
+ const valid = this._state === "paused" /* InternalTaskState.PAUSED */ ||
2725
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2728
2726
  if (valid) {
2729
- this._transition("running" /* RUNNING */);
2727
+ this._transition("running" /* InternalTaskState.RUNNING */);
2730
2728
  }
2731
2729
  return valid;
2732
2730
  }
@@ -2735,9 +2733,9 @@ class UploadTask {
2735
2733
  * @returns True if the operation took effect, false if ignored.
2736
2734
  */
2737
2735
  pause() {
2738
- const valid = this._state === "running" /* RUNNING */;
2736
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */;
2739
2737
  if (valid) {
2740
- this._transition("pausing" /* PAUSING */);
2738
+ this._transition("pausing" /* InternalTaskState.PAUSING */);
2741
2739
  }
2742
2740
  return valid;
2743
2741
  }
@@ -2747,10 +2745,10 @@ class UploadTask {
2747
2745
  * @returns True if the operation took effect, false if ignored.
2748
2746
  */
2749
2747
  cancel() {
2750
- const valid = this._state === "running" /* RUNNING */ ||
2751
- this._state === "pausing" /* PAUSING */;
2748
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */ ||
2749
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2752
2750
  if (valid) {
2753
- this._transition("canceling" /* CANCELING */);
2751
+ this._transition("canceling" /* InternalTaskState.CANCELING */);
2754
2752
  }
2755
2753
  return valid;
2756
2754
  }
@@ -3347,7 +3345,7 @@ class FirebaseStorageImpl {
3347
3345
  }
3348
3346
 
3349
3347
  const name = "@firebase/storage";
3350
- const version = "0.9.14";
3348
+ const version = "0.10.0-20221206221533";
3351
3349
 
3352
3350
  /**
3353
3351
  * @license
@@ -3647,7 +3645,7 @@ function factory(container, { instanceIdentifier: url }) {
3647
3645
  return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
3648
3646
  }
3649
3647
  function registerStorage() {
3650
- _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
3648
+ _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
3651
3649
  registerVersion(name, version);
3652
3650
  }
3653
3651
  registerStorage();