@firebase/storage 0.9.14 → 0.10.0-canary.06dc1364d

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.
@@ -119,13 +119,13 @@ function prependCode(code) {
119
119
  function unknown() {
120
120
  const message = 'An unknown error occurred, please check the error payload for ' +
121
121
  'server response.';
122
- return new StorageError("unknown" /* UNKNOWN */, message);
122
+ return new StorageError("unknown" /* StorageErrorCode.UNKNOWN */, message);
123
123
  }
124
124
  function objectNotFound(path) {
125
- return new StorageError("object-not-found" /* OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
125
+ return new StorageError("object-not-found" /* StorageErrorCode.OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
126
126
  }
127
127
  function quotaExceeded(bucket) {
128
- return new StorageError("quota-exceeded" /* QUOTA_EXCEEDED */, "Quota for bucket '" +
128
+ return new StorageError("quota-exceeded" /* StorageErrorCode.QUOTA_EXCEEDED */, "Quota for bucket '" +
129
129
  bucket +
130
130
  "' exceeded, please view quota on " +
131
131
  'https://firebase.google.com/pricing/.');
@@ -133,52 +133,52 @@ function quotaExceeded(bucket) {
133
133
  function unauthenticated() {
134
134
  const message = 'User is not authenticated, please authenticate using Firebase ' +
135
135
  'Authentication and try again.';
136
- return new StorageError("unauthenticated" /* UNAUTHENTICATED */, message);
136
+ return new StorageError("unauthenticated" /* StorageErrorCode.UNAUTHENTICATED */, message);
137
137
  }
138
138
  function unauthorizedApp() {
139
- return new StorageError("unauthorized-app" /* UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
139
+ return new StorageError("unauthorized-app" /* StorageErrorCode.UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
140
140
  }
141
141
  function unauthorized(path) {
142
- return new StorageError("unauthorized" /* UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
142
+ return new StorageError("unauthorized" /* StorageErrorCode.UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
143
143
  }
144
144
  function retryLimitExceeded() {
145
- return new StorageError("retry-limit-exceeded" /* RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
145
+ return new StorageError("retry-limit-exceeded" /* StorageErrorCode.RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
146
146
  }
147
147
  function canceled() {
148
- return new StorageError("canceled" /* CANCELED */, 'User canceled the upload/download.');
148
+ return new StorageError("canceled" /* StorageErrorCode.CANCELED */, 'User canceled the upload/download.');
149
149
  }
150
150
  function invalidUrl(url) {
151
- return new StorageError("invalid-url" /* INVALID_URL */, "Invalid URL '" + url + "'.");
151
+ return new StorageError("invalid-url" /* StorageErrorCode.INVALID_URL */, "Invalid URL '" + url + "'.");
152
152
  }
153
153
  function invalidDefaultBucket(bucket) {
154
- return new StorageError("invalid-default-bucket" /* INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
154
+ return new StorageError("invalid-default-bucket" /* StorageErrorCode.INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
155
155
  }
156
156
  function noDefaultBucket() {
157
- return new StorageError("no-default-bucket" /* NO_DEFAULT_BUCKET */, 'No default bucket ' +
157
+ return new StorageError("no-default-bucket" /* StorageErrorCode.NO_DEFAULT_BUCKET */, 'No default bucket ' +
158
158
  "found. Did you set the '" +
159
159
  CONFIG_STORAGE_BUCKET_KEY +
160
160
  "' property when initializing the app?");
161
161
  }
162
162
  function cannotSliceBlob() {
163
- return new StorageError("cannot-slice-blob" /* CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
163
+ return new StorageError("cannot-slice-blob" /* StorageErrorCode.CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
164
164
  }
165
165
  function serverFileWrongSize() {
166
- return new StorageError("server-file-wrong-size" /* SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
166
+ return new StorageError("server-file-wrong-size" /* StorageErrorCode.SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
167
167
  }
168
168
  function noDownloadURL() {
169
- return new StorageError("no-download-url" /* NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
169
+ return new StorageError("no-download-url" /* StorageErrorCode.NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
170
170
  }
171
171
  function missingPolyFill(polyFill) {
172
- return new StorageError("unsupported-environment" /* UNSUPPORTED_ENVIRONMENT */, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
172
+ return new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
173
173
  }
174
174
  /**
175
175
  * @internal
176
176
  */
177
177
  function invalidArgument(message) {
178
- return new StorageError("invalid-argument" /* INVALID_ARGUMENT */, message);
178
+ return new StorageError("invalid-argument" /* StorageErrorCode.INVALID_ARGUMENT */, message);
179
179
  }
180
180
  function appDeleted() {
181
- return new StorageError("app-deleted" /* APP_DELETED */, 'The Firebase app was deleted.');
181
+ return new StorageError("app-deleted" /* StorageErrorCode.APP_DELETED */, 'The Firebase app was deleted.');
182
182
  }
183
183
  /**
184
184
  * @param name - The name of the operation that was invalid.
@@ -186,7 +186,7 @@ function appDeleted() {
186
186
  * @internal
187
187
  */
188
188
  function invalidRootOperation(name) {
189
- return new StorageError("invalid-root-operation" /* INVALID_ROOT_OPERATION */, "The operation '" +
189
+ return new StorageError("invalid-root-operation" /* StorageErrorCode.INVALID_ROOT_OPERATION */, "The operation '" +
190
190
  name +
191
191
  "' cannot be performed on a root reference, create a non-root " +
192
192
  "reference using child, such as .child('file.png').");
@@ -196,13 +196,13 @@ function invalidRootOperation(name) {
196
196
  * @param message - A message describing the format violation.
197
197
  */
198
198
  function invalidFormat(format, message) {
199
- return new StorageError("invalid-format" /* INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
199
+ return new StorageError("invalid-format" /* StorageErrorCode.INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
200
200
  }
201
201
  /**
202
202
  * @param message - A message describing the internal error.
203
203
  */
204
204
  function internalError(message) {
205
- throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
205
+ throw new StorageError("internal-error" /* StorageErrorCode.INTERNAL_ERROR */, 'Internal error: ' + message);
206
206
  }
207
207
 
208
208
  /**
@@ -863,7 +863,7 @@ function getBlob$1(...args) {
863
863
  return new Blob(args);
864
864
  }
865
865
  else {
866
- throw new StorageError("unsupported-environment" /* UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
866
+ throw new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
867
867
  }
868
868
  }
869
869
  }
@@ -2020,17 +2020,17 @@ const TaskState = {
2020
2020
  };
2021
2021
  function taskStateFromInternalTaskState(state) {
2022
2022
  switch (state) {
2023
- case "running" /* RUNNING */:
2024
- case "pausing" /* PAUSING */:
2025
- case "canceling" /* CANCELING */:
2023
+ case "running" /* InternalTaskState.RUNNING */:
2024
+ case "pausing" /* InternalTaskState.PAUSING */:
2025
+ case "canceling" /* InternalTaskState.CANCELING */:
2026
2026
  return TaskState.RUNNING;
2027
- case "paused" /* PAUSED */:
2027
+ case "paused" /* InternalTaskState.PAUSED */:
2028
2028
  return TaskState.PAUSED;
2029
- case "success" /* SUCCESS */:
2029
+ case "success" /* InternalTaskState.SUCCESS */:
2030
2030
  return TaskState.SUCCESS;
2031
- case "canceled" /* CANCELED */:
2031
+ case "canceled" /* InternalTaskState.CANCELED */:
2032
2032
  return TaskState.CANCELED;
2033
- case "error" /* ERROR */:
2033
+ case "error" /* InternalTaskState.ERROR */:
2034
2034
  return TaskState.ERROR;
2035
2035
  default:
2036
2036
  // TODO(andysoto): assert(false);
@@ -2281,11 +2281,11 @@ class UploadTask {
2281
2281
  this._metadata = metadata;
2282
2282
  this._mappings = getMappings();
2283
2283
  this._resumable = this._shouldDoResumable(this._blob);
2284
- this._state = "running" /* RUNNING */;
2284
+ this._state = "running" /* InternalTaskState.RUNNING */;
2285
2285
  this._errorHandler = error => {
2286
2286
  this._request = undefined;
2287
2287
  this._chunkMultiplier = 1;
2288
- if (error._codeEquals("canceled" /* CANCELED */)) {
2288
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2289
2289
  this._needToFetchStatus = true;
2290
2290
  this.completeTransitions_();
2291
2291
  }
@@ -2303,17 +2303,17 @@ class UploadTask {
2303
2303
  }
2304
2304
  }
2305
2305
  this._error = error;
2306
- this._transition("error" /* ERROR */);
2306
+ this._transition("error" /* InternalTaskState.ERROR */);
2307
2307
  }
2308
2308
  };
2309
2309
  this._metadataErrorHandler = error => {
2310
2310
  this._request = undefined;
2311
- if (error._codeEquals("canceled" /* CANCELED */)) {
2311
+ if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2312
2312
  this.completeTransitions_();
2313
2313
  }
2314
2314
  else {
2315
2315
  this._error = error;
2316
- this._transition("error" /* ERROR */);
2316
+ this._transition("error" /* InternalTaskState.ERROR */);
2317
2317
  }
2318
2318
  };
2319
2319
  this.sleepTime = 0;
@@ -2338,7 +2338,7 @@ class UploadTask {
2338
2338
  return blob.size() > 256 * 1024;
2339
2339
  }
2340
2340
  _start() {
2341
- if (this._state !== "running" /* RUNNING */) {
2341
+ if (this._state !== "running" /* InternalTaskState.RUNNING */) {
2342
2342
  // This can happen if someone pauses us in a resume callback, for example.
2343
2343
  return;
2344
2344
  }
@@ -2378,14 +2378,14 @@ class UploadTask {
2378
2378
  this._ref.storage._getAppCheckToken()
2379
2379
  ]).then(([authToken, appCheckToken]) => {
2380
2380
  switch (this._state) {
2381
- case "running" /* RUNNING */:
2381
+ case "running" /* InternalTaskState.RUNNING */:
2382
2382
  callback(authToken, appCheckToken);
2383
2383
  break;
2384
- case "canceling" /* CANCELING */:
2385
- this._transition("canceled" /* CANCELED */);
2384
+ case "canceling" /* InternalTaskState.CANCELING */:
2385
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2386
2386
  break;
2387
- case "pausing" /* PAUSING */:
2388
- this._transition("paused" /* PAUSED */);
2387
+ case "pausing" /* InternalTaskState.PAUSING */:
2388
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2389
2389
  break;
2390
2390
  }
2391
2391
  });
@@ -2435,7 +2435,7 @@ class UploadTask {
2435
2435
  }
2436
2436
  catch (e) {
2437
2437
  this._error = e;
2438
- this._transition("error" /* ERROR */);
2438
+ this._transition("error" /* InternalTaskState.ERROR */);
2439
2439
  return;
2440
2440
  }
2441
2441
  const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken,
@@ -2448,7 +2448,7 @@ class UploadTask {
2448
2448
  this._updateProgress(newStatus.current);
2449
2449
  if (newStatus.finalized) {
2450
2450
  this._metadata = newStatus.metadata;
2451
- this._transition("success" /* SUCCESS */);
2451
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2452
2452
  }
2453
2453
  else {
2454
2454
  this.completeTransitions_();
@@ -2471,7 +2471,7 @@ class UploadTask {
2471
2471
  metadataRequest.getPromise().then(metadata => {
2472
2472
  this._request = undefined;
2473
2473
  this._metadata = metadata;
2474
- this._transition("success" /* SUCCESS */);
2474
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2475
2475
  }, this._metadataErrorHandler);
2476
2476
  });
2477
2477
  }
@@ -2484,7 +2484,7 @@ class UploadTask {
2484
2484
  this._request = undefined;
2485
2485
  this._metadata = metadata;
2486
2486
  this._updateProgress(this._blob.size());
2487
- this._transition("success" /* SUCCESS */);
2487
+ this._transition("success" /* InternalTaskState.SUCCESS */);
2488
2488
  }, this._errorHandler);
2489
2489
  });
2490
2490
  }
@@ -2503,8 +2503,8 @@ class UploadTask {
2503
2503
  return;
2504
2504
  }
2505
2505
  switch (state) {
2506
- case "canceling" /* CANCELING */:
2507
- case "pausing" /* PAUSING */:
2506
+ case "canceling" /* InternalTaskState.CANCELING */:
2507
+ case "pausing" /* InternalTaskState.PAUSING */:
2508
2508
  // TODO(andysoto):
2509
2509
  // assert(this.state_ === InternalTaskState.RUNNING ||
2510
2510
  // this.state_ === InternalTaskState.PAUSING);
@@ -2518,24 +2518,24 @@ class UploadTask {
2518
2518
  this.completeTransitions_();
2519
2519
  }
2520
2520
  break;
2521
- case "running" /* RUNNING */:
2521
+ case "running" /* InternalTaskState.RUNNING */:
2522
2522
  // TODO(andysoto):
2523
2523
  // assert(this.state_ === InternalTaskState.PAUSED ||
2524
2524
  // this.state_ === InternalTaskState.PAUSING);
2525
- const wasPaused = this._state === "paused" /* PAUSED */;
2525
+ const wasPaused = this._state === "paused" /* InternalTaskState.PAUSED */;
2526
2526
  this._state = state;
2527
2527
  if (wasPaused) {
2528
2528
  this._notifyObservers();
2529
2529
  this._start();
2530
2530
  }
2531
2531
  break;
2532
- case "paused" /* PAUSED */:
2532
+ case "paused" /* InternalTaskState.PAUSED */:
2533
2533
  // TODO(andysoto):
2534
2534
  // assert(this.state_ === InternalTaskState.PAUSING);
2535
2535
  this._state = state;
2536
2536
  this._notifyObservers();
2537
2537
  break;
2538
- case "canceled" /* CANCELED */:
2538
+ case "canceled" /* InternalTaskState.CANCELED */:
2539
2539
  // TODO(andysoto):
2540
2540
  // assert(this.state_ === InternalTaskState.PAUSED ||
2541
2541
  // this.state_ === InternalTaskState.CANCELING);
@@ -2543,7 +2543,7 @@ class UploadTask {
2543
2543
  this._state = state;
2544
2544
  this._notifyObservers();
2545
2545
  break;
2546
- case "error" /* ERROR */:
2546
+ case "error" /* InternalTaskState.ERROR */:
2547
2547
  // TODO(andysoto):
2548
2548
  // assert(this.state_ === InternalTaskState.RUNNING ||
2549
2549
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2551,7 +2551,7 @@ class UploadTask {
2551
2551
  this._state = state;
2552
2552
  this._notifyObservers();
2553
2553
  break;
2554
- case "success" /* SUCCESS */:
2554
+ case "success" /* InternalTaskState.SUCCESS */:
2555
2555
  // TODO(andysoto):
2556
2556
  // assert(this.state_ === InternalTaskState.RUNNING ||
2557
2557
  // this.state_ === InternalTaskState.PAUSING ||
@@ -2563,13 +2563,13 @@ class UploadTask {
2563
2563
  }
2564
2564
  completeTransitions_() {
2565
2565
  switch (this._state) {
2566
- case "pausing" /* PAUSING */:
2567
- this._transition("paused" /* PAUSED */);
2566
+ case "pausing" /* InternalTaskState.PAUSING */:
2567
+ this._transition("paused" /* InternalTaskState.PAUSED */);
2568
2568
  break;
2569
- case "canceling" /* CANCELING */:
2570
- this._transition("canceled" /* CANCELED */);
2569
+ case "canceling" /* InternalTaskState.CANCELING */:
2570
+ this._transition("canceled" /* InternalTaskState.CANCELED */);
2571
2571
  break;
2572
- case "running" /* RUNNING */:
2572
+ case "running" /* InternalTaskState.RUNNING */:
2573
2573
  this._start();
2574
2574
  break;
2575
2575
  }
@@ -2707,10 +2707,10 @@ class UploadTask {
2707
2707
  * @returns True if the operation took effect, false if ignored.
2708
2708
  */
2709
2709
  resume() {
2710
- const valid = this._state === "paused" /* PAUSED */ ||
2711
- this._state === "pausing" /* PAUSING */;
2710
+ const valid = this._state === "paused" /* InternalTaskState.PAUSED */ ||
2711
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2712
2712
  if (valid) {
2713
- this._transition("running" /* RUNNING */);
2713
+ this._transition("running" /* InternalTaskState.RUNNING */);
2714
2714
  }
2715
2715
  return valid;
2716
2716
  }
@@ -2719,9 +2719,9 @@ class UploadTask {
2719
2719
  * @returns True if the operation took effect, false if ignored.
2720
2720
  */
2721
2721
  pause() {
2722
- const valid = this._state === "running" /* RUNNING */;
2722
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */;
2723
2723
  if (valid) {
2724
- this._transition("pausing" /* PAUSING */);
2724
+ this._transition("pausing" /* InternalTaskState.PAUSING */);
2725
2725
  }
2726
2726
  return valid;
2727
2727
  }
@@ -2731,10 +2731,10 @@ class UploadTask {
2731
2731
  * @returns True if the operation took effect, false if ignored.
2732
2732
  */
2733
2733
  cancel() {
2734
- const valid = this._state === "running" /* RUNNING */ ||
2735
- this._state === "pausing" /* PAUSING */;
2734
+ const valid = this._state === "running" /* InternalTaskState.RUNNING */ ||
2735
+ this._state === "pausing" /* InternalTaskState.PAUSING */;
2736
2736
  if (valid) {
2737
- this._transition("canceling" /* CANCELING */);
2737
+ this._transition("canceling" /* InternalTaskState.CANCELING */);
2738
2738
  }
2739
2739
  return valid;
2740
2740
  }
@@ -3314,7 +3314,7 @@ class FirebaseStorageImpl {
3314
3314
  }
3315
3315
 
3316
3316
  const name = "@firebase/storage";
3317
- const version = "0.9.14";
3317
+ const version = "0.10.0-canary.06dc1364d";
3318
3318
 
3319
3319
  /**
3320
3320
  * @license
@@ -3613,7 +3613,7 @@ function factory(container, { instanceIdentifier: url }) {
3613
3613
  return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
3614
3614
  }
3615
3615
  function registerStorage() {
3616
- _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
3616
+ _registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
3617
3617
  //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
3618
3618
  registerVersion(name, version, '');
3619
3619
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation