@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.
@@ -129,13 +129,13 @@ function prependCode(code) {
129
129
  function unknown() {
130
130
  const message = 'An unknown error occurred, please check the error payload for ' +
131
131
  'server response.';
132
- return new StorageError("unknown" /* UNKNOWN */, message);
132
+ return new StorageError("unknown" /* StorageErrorCode.UNKNOWN */, message);
133
133
  }
134
134
  function objectNotFound(path) {
135
- return new StorageError("object-not-found" /* OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
135
+ return new StorageError("object-not-found" /* StorageErrorCode.OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
136
136
  }
137
137
  function quotaExceeded(bucket) {
138
- return new StorageError("quota-exceeded" /* QUOTA_EXCEEDED */, "Quota for bucket '" +
138
+ return new StorageError("quota-exceeded" /* StorageErrorCode.QUOTA_EXCEEDED */, "Quota for bucket '" +
139
139
  bucket +
140
140
  "' exceeded, please view quota on " +
141
141
  'https://firebase.google.com/pricing/.');
@@ -143,49 +143,49 @@ function quotaExceeded(bucket) {
143
143
  function unauthenticated() {
144
144
  const message = 'User is not authenticated, please authenticate using Firebase ' +
145
145
  'Authentication and try again.';
146
- return new StorageError("unauthenticated" /* UNAUTHENTICATED */, message);
146
+ return new StorageError("unauthenticated" /* StorageErrorCode.UNAUTHENTICATED */, message);
147
147
  }
148
148
  function unauthorizedApp() {
149
- return new StorageError("unauthorized-app" /* UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
149
+ return new StorageError("unauthorized-app" /* StorageErrorCode.UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
150
150
  }
151
151
  function unauthorized(path) {
152
- return new StorageError("unauthorized" /* UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
152
+ return new StorageError("unauthorized" /* StorageErrorCode.UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
153
153
  }
154
154
  function retryLimitExceeded() {
155
- return new StorageError("retry-limit-exceeded" /* RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
155
+ return new StorageError("retry-limit-exceeded" /* StorageErrorCode.RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
156
156
  }
157
157
  function canceled() {
158
- return new StorageError("canceled" /* CANCELED */, 'User canceled the upload/download.');
158
+ return new StorageError("canceled" /* StorageErrorCode.CANCELED */, 'User canceled the upload/download.');
159
159
  }
160
160
  function invalidUrl(url) {
161
- return new StorageError("invalid-url" /* INVALID_URL */, "Invalid URL '" + url + "'.");
161
+ return new StorageError("invalid-url" /* StorageErrorCode.INVALID_URL */, "Invalid URL '" + url + "'.");
162
162
  }
163
163
  function invalidDefaultBucket(bucket) {
164
- return new StorageError("invalid-default-bucket" /* INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
164
+ return new StorageError("invalid-default-bucket" /* StorageErrorCode.INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
165
165
  }
166
166
  function noDefaultBucket() {
167
- return new StorageError("no-default-bucket" /* NO_DEFAULT_BUCKET */, 'No default bucket ' +
167
+ return new StorageError("no-default-bucket" /* StorageErrorCode.NO_DEFAULT_BUCKET */, 'No default bucket ' +
168
168
  "found. Did you set the '" +
169
169
  CONFIG_STORAGE_BUCKET_KEY +
170
170
  "' property when initializing the app?");
171
171
  }
172
172
  function cannotSliceBlob() {
173
- return new StorageError("cannot-slice-blob" /* CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
173
+ return new StorageError("cannot-slice-blob" /* StorageErrorCode.CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
174
174
  }
175
175
  function serverFileWrongSize() {
176
- return new StorageError("server-file-wrong-size" /* SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
176
+ return new StorageError("server-file-wrong-size" /* StorageErrorCode.SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
177
177
  }
178
178
  function noDownloadURL() {
179
- return new StorageError("no-download-url" /* NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
179
+ return new StorageError("no-download-url" /* StorageErrorCode.NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
180
180
  }
181
181
  /**
182
182
  * @internal
183
183
  */
184
184
  function invalidArgument(message) {
185
- return new StorageError("invalid-argument" /* INVALID_ARGUMENT */, message);
185
+ return new StorageError("invalid-argument" /* StorageErrorCode.INVALID_ARGUMENT */, message);
186
186
  }
187
187
  function appDeleted() {
188
- return new StorageError("app-deleted" /* APP_DELETED */, 'The Firebase app was deleted.');
188
+ return new StorageError("app-deleted" /* StorageErrorCode.APP_DELETED */, 'The Firebase app was deleted.');
189
189
  }
190
190
  /**
191
191
  * @param name - The name of the operation that was invalid.
@@ -193,7 +193,7 @@ function appDeleted() {
193
193
  * @internal
194
194
  */
195
195
  function invalidRootOperation(name) {
196
- return new StorageError("invalid-root-operation" /* INVALID_ROOT_OPERATION */, "The operation '" +
196
+ return new StorageError("invalid-root-operation" /* StorageErrorCode.INVALID_ROOT_OPERATION */, "The operation '" +
197
197
  name +
198
198
  "' cannot be performed on a root reference, create a non-root " +
199
199
  "reference using child, such as .child('file.png').");
@@ -203,13 +203,13 @@ function invalidRootOperation(name) {
203
203
  * @param message - A message describing the format violation.
204
204
  */
205
205
  function invalidFormat(format, message) {
206
- return new StorageError("invalid-format" /* INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
206
+ return new StorageError("invalid-format" /* StorageErrorCode.INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
207
207
  }
208
208
  /**
209
209
  * @param message - A message describing the internal error.
210
210
  */
211
211
  function internalError(message) {
212
- throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
212
+ throw new StorageError("internal-error" /* StorageErrorCode.INTERNAL_ERROR */, 'Internal error: ' + message);
213
213
  }
214
214
 
215
215
  /**
@@ -870,7 +870,7 @@ function getBlob$1(...args) {
870
870
  return new Blob(args);
871
871
  }
872
872
  else {
873
- throw new StorageError("unsupported-environment" /* UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
873
+ throw new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
874
874
  }
875
875
  }
876
876
  }
@@ -2029,17 +2029,17 @@ const TaskState = {
2029
2029
  };
2030
2030
  function taskStateFromInternalTaskState(state) {
2031
2031
  switch (state) {
2032
- case "running" /* RUNNING */:
2033
- case "pausing" /* PAUSING */:
2034
- case "canceling" /* CANCELING */:
2032
+ case "running" /* InternalTaskState.RUNNING */:
2033
+ case "pausing" /* InternalTaskState.PAUSING */:
2034
+ case "canceling" /* InternalTaskState.CANCELING */:
2035
2035
  return TaskState.RUNNING;
2036
- case "paused" /* PAUSED */:
2036
+ case "paused" /* InternalTaskState.PAUSED */:
2037
2037
  return TaskState.PAUSED;
2038
- case "success" /* SUCCESS */:
2038
+ case "success" /* InternalTaskState.SUCCESS */:
2039
2039
  return TaskState.SUCCESS;
2040
- case "canceled" /* CANCELED */:
2040
+ case "canceled" /* InternalTaskState.CANCELED */:
2041
2041
  return TaskState.CANCELED;
2042
- case "error" /* ERROR */:
2042
+ case "error" /* InternalTaskState.ERROR */:
2043
2043
  return TaskState.ERROR;
2044
2044
  default:
2045
2045
  // TODO(andysoto): assert(false);
@@ -2141,7 +2141,6 @@ class FetchConnection {
2141
2141
  this.errorCode_ = ErrorCode.NO_ERROR;
2142
2142
  }
2143
2143
  async send(url, method, body, headers) {
2144
- var _a;
2145
2144
  if (this.sent_) {
2146
2145
  throw internalError('cannot .send() more than once');
2147
2146
  }
@@ -2158,7 +2157,7 @@ class FetchConnection {
2158
2157
  this.body_ = await response.arrayBuffer();
2159
2158
  }
2160
2159
  catch (e) {
2161
- this.errorText_ = (_a = e) === null || _a === void 0 ? void 0 : _a.message;
2160
+ this.errorText_ = e === null || e === void 0 ? void 0 : e.message;
2162
2161
  // emulate XHR which sets status to 0 when encountering a network error
2163
2162
  this.statusCode_ = 0;
2164
2163
  this.errorCode_ = ErrorCode.NETWORK_ERROR;
@@ -2225,7 +2224,6 @@ class FetchStreamConnection extends FetchConnection {
2225
2224
  this.stream_ = null;
2226
2225
  }
2227
2226
  async send(url, method, body, headers) {
2228
- var _a;
2229
2227
  if (this.sent_) {
2230
2228
  throw internalError('cannot .send() more than once');
2231
2229
  }
@@ -2242,7 +2240,7 @@ class FetchStreamConnection extends FetchConnection {
2242
2240
  this.stream_ = response.body;
2243
2241
  }
2244
2242
  catch (e) {
2245
- this.errorText_ = (_a = e) === null || _a === void 0 ? void 0 : _a.message;
2243
+ this.errorText_ = e === null || e === void 0 ? void 0 : e.message;
2246
2244
  // emulate XHR which sets status to 0 when encountering a network error
2247
2245
  this.statusCode_ = 0;
2248
2246
  this.errorCode_ = ErrorCode.NETWORK_ERROR;
@@ -2305,11 +2303,11 @@ class UploadTask {
2305
2303
  this._metadata = metadata;
2306
2304
  this._mappings = getMappings();
2307
2305
  this._resumable = this._shouldDoResumable(this._blob);
2308
- this._state = "running" /* RUNNING */;
2306
+ this._state = "running" /* InternalTaskState.RUNNING */;
2309
2307
  this._errorHandler = error => {
2310
2308
  this._request = undefined;
2311
2309
  this._chunkMultiplier = 1;
2312
- if (error._codeEquals("canceled" /* CANCELED */)) {
2310
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2313
2311
  this._needToFetchStatus = true;
2314
2312
  this.completeTransitions_();
2315
2313
  }
@@ -2327,17 +2325,17 @@ class UploadTask {
2327
2325
  }
2328
2326
  }
2329
2327
  this._error = error;
2330
- this._transition("error" /* ERROR */);
2328
+ this._transition("error" /* InternalTaskState.ERROR */);
2331
2329
  }
2332
2330
  };
2333
2331
  this._metadataErrorHandler = error => {
2334
2332
  this._request = undefined;
2335
- if (error._codeEquals("canceled" /* CANCELED */)) {
2333
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2336
2334
  this.completeTransitions_();
2337
2335
  }
2338
2336
  else {
2339
2337
  this._error = error;
2340
- this._transition("error" /* ERROR */);
2338
+ this._transition("error" /* InternalTaskState.ERROR */);
2341
2339
  }
2342
2340
  };
2343
2341
  this.sleepTime = 0;
@@ -2362,7 +2360,7 @@ class UploadTask {
2362
2360
  return blob.size() > 256 * 1024;
2363
2361
  }
2364
2362
  _start() {
2365
- if (this._state !== "running" /* RUNNING */) {
2363
+ if (this._state !== "running" /* InternalTaskState.RUNNING */) {
2366
2364
  // This can happen if someone pauses us in a resume callback, for example.
2367
2365
  return;
2368
2366
  }
@@ -2402,14 +2400,14 @@ class UploadTask {
2402
2400
  this._ref.storage._getAppCheckToken()
2403
2401
  ]).then(([authToken, appCheckToken]) => {
2404
2402
  switch (this._state) {
2405
- case "running" /* RUNNING */:
2403
+ case "running" /* InternalTaskState.RUNNING */:
2406
2404
  callback(authToken, appCheckToken);
2407
2405
  break;
2408
- case "canceling" /* CANCELING */:
2409
- this._transition("canceled" /* CANCELED */);
2406
+ case "canceling" /* InternalTaskState.CANCELING */:
2407
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2410
2408
  break;
2411
- case "pausing" /* PAUSING */:
2412
- this._transition("paused" /* PAUSED */);
2409
+ case "pausing" /* InternalTaskState.PAUSING */:
2410
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2413
2411
  break;
2414
2412
  }
2415
2413
  });
@@ -2459,7 +2457,7 @@ class UploadTask {
2459
2457
  }
2460
2458
  catch (e) {
2461
2459
  this._error = e;
2462
- this._transition("error" /* ERROR */);
2460
+ this._transition("error" /* InternalTaskState.ERROR */);
2463
2461
  return;
2464
2462
  }
2465
2463
  const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken,
@@ -2472,7 +2470,7 @@ class UploadTask {
2472
2470
  this._updateProgress(newStatus.current);
2473
2471
  if (newStatus.finalized) {
2474
2472
  this._metadata = newStatus.metadata;
2475
- this._transition("success" /* SUCCESS */);
2473
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2476
2474
  }
2477
2475
  else {
2478
2476
  this.completeTransitions_();
@@ -2495,7 +2493,7 @@ class UploadTask {
2495
2493
  metadataRequest.getPromise().then(metadata => {
2496
2494
  this._request = undefined;
2497
2495
  this._metadata = metadata;
2498
- this._transition("success" /* SUCCESS */);
2496
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2499
2497
  }, this._metadataErrorHandler);
2500
2498
  });
2501
2499
  }
@@ -2508,7 +2506,7 @@ class UploadTask {
2508
2506
  this._request = undefined;
2509
2507
  this._metadata = metadata;
2510
2508
  this._updateProgress(this._blob.size());
2511
- this._transition("success" /* SUCCESS */);
2509
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2512
2510
  }, this._errorHandler);
2513
2511
  });
2514
2512
  }
@@ -2527,8 +2525,8 @@ class UploadTask {
2527
2525
  return;
2528
2526
  }
2529
2527
  switch (state) {
2530
- case "canceling" /* CANCELING */:
2531
- case "pausing" /* PAUSING */:
2528
+ case "canceling" /* InternalTaskState.CANCELING */:
2529
+ case "pausing" /* InternalTaskState.PAUSING */:
2532
2530
  // TODO(andysoto):
2533
2531
  // assert(this.state_ === InternalTaskState.RUNNING ||
2534
2532
  // this.state_ === InternalTaskState.PAUSING);
@@ -2542,24 +2540,24 @@ class UploadTask {
2542
2540
  this.completeTransitions_();
2543
2541
  }
2544
2542
  break;
2545
- case "running" /* RUNNING */:
2543
+ case "running" /* InternalTaskState.RUNNING */:
2546
2544
  // TODO(andysoto):
2547
2545
  // assert(this.state_ === InternalTaskState.PAUSED ||
2548
2546
  // this.state_ === InternalTaskState.PAUSING);
2549
- const wasPaused = this._state === "paused" /* PAUSED */;
2547
+ const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */;
2550
2548
  this._state = state;
2551
2549
  if (wasPaused) {
2552
2550
  this._notifyObservers();
2553
2551
  this._start();
2554
2552
  }
2555
2553
  break;
2556
- case "paused" /* PAUSED */:
2554
+ case "paused" /* InternalTaskState.PAUSED */:
2557
2555
  // TODO(andysoto):
2558
2556
  // assert(this.state_ === InternalTaskState.PAUSING);
2559
2557
  this._state = state;
2560
2558
  this._notifyObservers();
2561
2559
  break;
2562
- case "canceled" /* CANCELED */:
2560
+ case "canceled" /* InternalTaskState.CANCELED */:
2563
2561
  // TODO(andysoto):
2564
2562
  // assert(this.state_ === InternalTaskState.PAUSED ||
2565
2563
  // this.state_ === InternalTaskState.CANCELING);
@@ -2567,7 +2565,7 @@ class UploadTask {
2567
2565
  this._state = state;
2568
2566
  this._notifyObservers();
2569
2567
  break;
2570
- case "error" /* ERROR */:
2568
+ case "error" /* InternalTaskState.ERROR */:
2571
2569
  // TODO(andysoto):
2572
2570
  // assert(this.state_ === InternalTaskState.RUNNING ||
2573
2571
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2575,7 +2573,7 @@ class UploadTask {
2575
2573
  this._state = state;
2576
2574
  this._notifyObservers();
2577
2575
  break;
2578
- case "success" /* SUCCESS */:
2576
+ case "success" /* InternalTaskState.SUCCESS */:
2579
2577
  // TODO(andysoto):
2580
2578
  // assert(this.state_ === InternalTaskState.RUNNING ||
2581
2579
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2587,13 +2585,13 @@ class UploadTask {
2587
2585
  }
2588
2586
  completeTransitions_() {
2589
2587
  switch (this._state) {
2590
- case "pausing" /* PAUSING */:
2591
- this._transition("paused" /* PAUSED */);
2588
+ case "pausing" /* InternalTaskState.PAUSING */:
2589
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2592
2590
  break;
2593
- case "canceling" /* CANCELING */:
2594
- this._transition("canceled" /* CANCELED */);
2591
+ case "canceling" /* InternalTaskState.CANCELING */:
2592
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2595
2593
  break;
2596
- case "running" /* RUNNING */:
2594
+ case "running" /* InternalTaskState.RUNNING */:
2597
2595
  this._start();
2598
2596
  break;
2599
2597
  }
@@ -2731,10 +2729,10 @@ class UploadTask {
2731
2729
  * @returns True if the operation took effect, false if ignored.
2732
2730
  */
2733
2731
  resume() {
2734
- const valid = this._state === "paused" /* PAUSED */ ||
2735
- this._state === "pausing" /* PAUSING */;
2732
+ const valid = this._state === "paused" /* InternalTaskState.PAUSED */ ||
2733
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2736
2734
  if (valid) {
2737
- this._transition("running" /* RUNNING */);
2735
+ this._transition("running" /* InternalTaskState.RUNNING */);
2738
2736
  }
2739
2737
  return valid;
2740
2738
  }
@@ -2743,9 +2741,9 @@ class UploadTask {
2743
2741
  * @returns True if the operation took effect, false if ignored.
2744
2742
  */
2745
2743
  pause() {
2746
- const valid = this._state === "running" /* RUNNING */;
2744
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */;
2747
2745
  if (valid) {
2748
- this._transition("pausing" /* PAUSING */);
2746
+ this._transition("pausing" /* InternalTaskState.PAUSING */);
2749
2747
  }
2750
2748
  return valid;
2751
2749
  }
@@ -2755,10 +2753,10 @@ class UploadTask {
2755
2753
  * @returns True if the operation took effect, false if ignored.
2756
2754
  */
2757
2755
  cancel() {
2758
- const valid = this._state === "running" /* RUNNING */ ||
2759
- this._state === "pausing" /* PAUSING */;
2756
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */ ||
2757
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2760
2758
  if (valid) {
2761
- this._transition("canceling" /* CANCELING */);
2759
+ this._transition("canceling" /* InternalTaskState.CANCELING */);
2762
2760
  }
2763
2761
  return valid;
2764
2762
  }
@@ -3355,7 +3353,7 @@ class FirebaseStorageImpl {
3355
3353
  }
3356
3354
 
3357
3355
  const name = "@firebase/storage";
3358
- const version = "0.9.14";
3356
+ const version = "0.10.0-20221206221533";
3359
3357
 
3360
3358
  /**
3361
3359
  * @license
@@ -3655,7 +3653,7 @@ function factory(container, { instanceIdentifier: url }) {
3655
3653
  return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION);
3656
3654
  }
3657
3655
  function registerStorage() {
3658
- app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
3656
+ app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
3659
3657
  app.registerVersion(name, version);
3660
3658
  }
3661
3659
  registerStorage();