UNPKG

22.3 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/fire'), require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/fire/app'), require('@angular/fire/auth'), require('firebase/app'), require('@angular/fire/app-check'), require('rxfire/storage'), require('firebase/storage')) :
3 typeof define === 'function' && define.amd ? define('@angular/fire/storage', ['exports', '@angular/fire', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/fire/app', '@angular/fire/auth', 'firebase/app', '@angular/fire/app-check', 'rxfire/storage', 'firebase/storage'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.angular = global.angular || {}, global.angular.fire = global.angular.fire || {}, global.angular.fire.storage = {}), global.angular.fire, global.rxjs, global.rxjs.operators, global.ng.core, global.angular.fire.app, global.angular.fire.auth, global.app$1, global.angular.fire['app-check'], global['rxfire-storage'], global['firebase-storage']));
5}(this, (function (exports, fire, rxjs, operators, i0, app, auth, app$1, appCheck, storage$1, storage) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
29 var Storage = /** @class */ (function () {
30 function Storage(auth) {
31 return auth;
32 }
33 return Storage;
34 }());
35 var STORAGE_PROVIDER_NAME = 'storage';
36 var StorageInstances = /** @class */ (function () {
37 function StorageInstances() {
38 return fire.ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME);
39 }
40 return StorageInstances;
41 }());
42 var storageInstance$ = rxjs.timer(0, 300).pipe(operators.concatMap(function () { return rxjs.from(fire.ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME)); }), operators.distinct());
43
44 /*! *****************************************************************************
45 Copyright (c) Microsoft Corporation.
46
47 Permission to use, copy, modify, and/or distribute this software for any
48 purpose with or without fee is hereby granted.
49
50 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
51 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
52 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
53 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
54 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56 PERFORMANCE OF THIS SOFTWARE.
57 ***************************************************************************** */
58 /* global Reflect, Promise */
59 var extendStatics = function (d, b) {
60 extendStatics = Object.setPrototypeOf ||
61 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62 function (d, b) { for (var p in b)
63 if (Object.prototype.hasOwnProperty.call(b, p))
64 d[p] = b[p]; };
65 return extendStatics(d, b);
66 };
67 function __extends(d, b) {
68 if (typeof b !== "function" && b !== null)
69 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
70 extendStatics(d, b);
71 function __() { this.constructor = d; }
72 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
73 }
74 var __assign = function () {
75 __assign = Object.assign || function __assign(t) {
76 for (var s, i = 1, n = arguments.length; i < n; i++) {
77 s = arguments[i];
78 for (var p in s)
79 if (Object.prototype.hasOwnProperty.call(s, p))
80 t[p] = s[p];
81 }
82 return t;
83 };
84 return __assign.apply(this, arguments);
85 };
86 function __rest(s, e) {
87 var t = {};
88 for (var p in s)
89 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
90 t[p] = s[p];
91 if (s != null && typeof Object.getOwnPropertySymbols === "function")
92 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
93 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
94 t[p[i]] = s[p[i]];
95 }
96 return t;
97 }
98 function __decorate(decorators, target, key, desc) {
99 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
100 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
101 r = Reflect.decorate(decorators, target, key, desc);
102 else
103 for (var i = decorators.length - 1; i >= 0; i--)
104 if (d = decorators[i])
105 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
106 return c > 3 && r && Object.defineProperty(target, key, r), r;
107 }
108 function __param(paramIndex, decorator) {
109 return function (target, key) { decorator(target, key, paramIndex); };
110 }
111 function __metadata(metadataKey, metadataValue) {
112 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
113 return Reflect.metadata(metadataKey, metadataValue);
114 }
115 function __awaiter(thisArg, _arguments, P, generator) {
116 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
117 return new (P || (P = Promise))(function (resolve, reject) {
118 function fulfilled(value) { try {
119 step(generator.next(value));
120 }
121 catch (e) {
122 reject(e);
123 } }
124 function rejected(value) { try {
125 step(generator["throw"](value));
126 }
127 catch (e) {
128 reject(e);
129 } }
130 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
131 step((generator = generator.apply(thisArg, _arguments || [])).next());
132 });
133 }
134 function __generator(thisArg, body) {
135 var _ = { label: 0, sent: function () { if (t[0] & 1)
136 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
137 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
138 function verb(n) { return function (v) { return step([n, v]); }; }
139 function step(op) {
140 if (f)
141 throw new TypeError("Generator is already executing.");
142 while (_)
143 try {
144 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
145 return t;
146 if (y = 0, t)
147 op = [op[0] & 2, t.value];
148 switch (op[0]) {
149 case 0:
150 case 1:
151 t = op;
152 break;
153 case 4:
154 _.label++;
155 return { value: op[1], done: false };
156 case 5:
157 _.label++;
158 y = op[1];
159 op = [0];
160 continue;
161 case 7:
162 op = _.ops.pop();
163 _.trys.pop();
164 continue;
165 default:
166 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
167 _ = 0;
168 continue;
169 }
170 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
171 _.label = op[1];
172 break;
173 }
174 if (op[0] === 6 && _.label < t[1]) {
175 _.label = t[1];
176 t = op;
177 break;
178 }
179 if (t && _.label < t[2]) {
180 _.label = t[2];
181 _.ops.push(op);
182 break;
183 }
184 if (t[2])
185 _.ops.pop();
186 _.trys.pop();
187 continue;
188 }
189 op = body.call(thisArg, _);
190 }
191 catch (e) {
192 op = [6, e];
193 y = 0;
194 }
195 finally {
196 f = t = 0;
197 }
198 if (op[0] & 5)
199 throw op[1];
200 return { value: op[0] ? op[1] : void 0, done: true };
201 }
202 }
203 var __createBinding = Object.create ? (function (o, m, k, k2) {
204 if (k2 === undefined)
205 k2 = k;
206 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
207 }) : (function (o, m, k, k2) {
208 if (k2 === undefined)
209 k2 = k;
210 o[k2] = m[k];
211 });
212 function __exportStar(m, o) {
213 for (var p in m)
214 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
215 __createBinding(o, m, p);
216 }
217 function __values(o) {
218 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
219 if (m)
220 return m.call(o);
221 if (o && typeof o.length === "number")
222 return {
223 next: function () {
224 if (o && i >= o.length)
225 o = void 0;
226 return { value: o && o[i++], done: !o };
227 }
228 };
229 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
230 }
231 function __read(o, n) {
232 var m = typeof Symbol === "function" && o[Symbol.iterator];
233 if (!m)
234 return o;
235 var i = m.call(o), r, ar = [], e;
236 try {
237 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
238 ar.push(r.value);
239 }
240 catch (error) {
241 e = { error: error };
242 }
243 finally {
244 try {
245 if (r && !r.done && (m = i["return"]))
246 m.call(i);
247 }
248 finally {
249 if (e)
250 throw e.error;
251 }
252 }
253 return ar;
254 }
255 /** @deprecated */
256 function __spread() {
257 for (var ar = [], i = 0; i < arguments.length; i++)
258 ar = ar.concat(__read(arguments[i]));
259 return ar;
260 }
261 /** @deprecated */
262 function __spreadArrays() {
263 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
264 s += arguments[i].length;
265 for (var r = Array(s), k = 0, i = 0; i < il; i++)
266 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
267 r[k] = a[j];
268 return r;
269 }
270 function __spreadArray(to, from) {
271 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
272 to[j] = from[i];
273 return to;
274 }
275 function __await(v) {
276 return this instanceof __await ? (this.v = v, this) : new __await(v);
277 }
278 function __asyncGenerator(thisArg, _arguments, generator) {
279 if (!Symbol.asyncIterator)
280 throw new TypeError("Symbol.asyncIterator is not defined.");
281 var g = generator.apply(thisArg, _arguments || []), i, q = [];
282 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
283 function verb(n) { if (g[n])
284 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
285 function resume(n, v) { try {
286 step(g[n](v));
287 }
288 catch (e) {
289 settle(q[0][3], e);
290 } }
291 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
292 function fulfill(value) { resume("next", value); }
293 function reject(value) { resume("throw", value); }
294 function settle(f, v) { if (f(v), q.shift(), q.length)
295 resume(q[0][0], q[0][1]); }
296 }
297 function __asyncDelegator(o) {
298 var i, p;
299 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
300 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
301 }
302 function __asyncValues(o) {
303 if (!Symbol.asyncIterator)
304 throw new TypeError("Symbol.asyncIterator is not defined.");
305 var m = o[Symbol.asyncIterator], i;
306 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
307 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
308 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
309 }
310 function __makeTemplateObject(cooked, raw) {
311 if (Object.defineProperty) {
312 Object.defineProperty(cooked, "raw", { value: raw });
313 }
314 else {
315 cooked.raw = raw;
316 }
317 return cooked;
318 }
319 ;
320 var __setModuleDefault = Object.create ? (function (o, v) {
321 Object.defineProperty(o, "default", { enumerable: true, value: v });
322 }) : function (o, v) {
323 o["default"] = v;
324 };
325 function __importStar(mod) {
326 if (mod && mod.__esModule)
327 return mod;
328 var result = {};
329 if (mod != null)
330 for (var k in mod)
331 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
332 __createBinding(result, mod, k);
333 __setModuleDefault(result, mod);
334 return result;
335 }
336 function __importDefault(mod) {
337 return (mod && mod.__esModule) ? mod : { default: mod };
338 }
339 function __classPrivateFieldGet(receiver, state, kind, f) {
340 if (kind === "a" && !f)
341 throw new TypeError("Private accessor was defined without a getter");
342 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343 throw new TypeError("Cannot read private member from an object whose class did not declare it");
344 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
345 }
346 function __classPrivateFieldSet(receiver, state, value, kind, f) {
347 if (kind === "m")
348 throw new TypeError("Private method is not writable");
349 if (kind === "a" && !f)
350 throw new TypeError("Private accessor was defined without a setter");
351 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
352 throw new TypeError("Cannot write private member to an object whose class did not declare it");
353 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
354 }
355
356 var PROVIDED_STORAGE_INSTANCES = new i0.InjectionToken('angularfire2.storage-instances');
357 function defaultStorageInstanceFactory(provided, defaultApp) {
358 var defaultStorage = fire.ɵgetDefaultInstanceOf(STORAGE_PROVIDER_NAME, provided, defaultApp);
359 return defaultStorage && new Storage(defaultStorage);
360 }
361 function storageInstanceFactory(fn) {
362 return function (zone, injector) {
363 var storage = zone.runOutsideAngular(function () { return fn(injector); });
364 return new Storage(storage);
365 };
366 }
367 var STORAGE_INSTANCES_PROVIDER = {
368 provide: StorageInstances,
369 deps: [
370 [new i0.Optional(), PROVIDED_STORAGE_INSTANCES],
371 ]
372 };
373 var DEFAULT_STORAGE_INSTANCE_PROVIDER = {
374 provide: Storage,
375 useFactory: defaultStorageInstanceFactory,
376 deps: [
377 [new i0.Optional(), PROVIDED_STORAGE_INSTANCES],
378 app.FirebaseApp,
379 ]
380 };
381 var StorageModule = /** @class */ (function () {
382 function StorageModule() {
383 app$1.registerVersion('angularfire', fire.VERSION.full, 'gcs');
384 }
385 return StorageModule;
386 }());
387 StorageModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: StorageModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
388 StorageModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: StorageModule });
389 StorageModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: StorageModule, providers: [
390 DEFAULT_STORAGE_INSTANCE_PROVIDER,
391 STORAGE_INSTANCES_PROVIDER,
392 ] });
393 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: StorageModule, decorators: [{
394 type: i0.NgModule,
395 args: [{
396 providers: [
397 DEFAULT_STORAGE_INSTANCE_PROVIDER,
398 STORAGE_INSTANCES_PROVIDER,
399 ]
400 }]
401 }], ctorParameters: function () { return []; } });
402 function provideStorage(fn) {
403 var deps = [];
404 for (var _i = 1; _i < arguments.length; _i++) {
405 deps[_i - 1] = arguments[_i];
406 }
407 return {
408 ngModule: StorageModule,
409 providers: [{
410 provide: PROVIDED_STORAGE_INSTANCES,
411 useFactory: storageInstanceFactory(fn),
412 multi: true,
413 deps: __spreadArray([
414 i0.NgZone,
415 i0.Injector,
416 fire.ɵAngularFireSchedulers,
417 app.FirebaseApps,
418 // Defensively load Auth first, if provided
419 [new i0.Optional(), auth.AuthInstances],
420 [new i0.Optional(), appCheck.AppCheckInstances]
421 ], __read(deps))
422 }]
423 };
424 }
425
426 // DO NOT MODIFY, this file is autogenerated by tools/build.ts
427 var fromTask = fire.ɵzoneWrap(storage$1.fromTask, true);
428 var percentage = fire.ɵzoneWrap(storage$1.percentage, true);
429
430 // DO NOT MODIFY, this file is autogenerated by tools/build.ts
431 var connectStorageEmulator = fire.ɵzoneWrap(storage.connectStorageEmulator, true);
432 var deleteObject = fire.ɵzoneWrap(storage.deleteObject, true);
433 var getBlob = fire.ɵzoneWrap(storage.getBlob, true);
434 var getBytes = fire.ɵzoneWrap(storage.getBytes, true);
435 var getDownloadURL = fire.ɵzoneWrap(storage.getDownloadURL, true);
436 var getMetadata = fire.ɵzoneWrap(storage.getMetadata, true);
437 var getStorage = fire.ɵzoneWrap(storage.getStorage, true);
438 var getStream = fire.ɵzoneWrap(storage.getStream, true);
439 var list = fire.ɵzoneWrap(storage.list, true);
440 var listAll = fire.ɵzoneWrap(storage.listAll, true);
441 var ref = fire.ɵzoneWrap(storage.ref, true);
442 var updateMetadata = fire.ɵzoneWrap(storage.updateMetadata, true);
443 var uploadBytes = fire.ɵzoneWrap(storage.uploadBytes, true);
444 var uploadBytesResumable = fire.ɵzoneWrap(storage.uploadBytesResumable, true);
445 var uploadString = fire.ɵzoneWrap(storage.uploadString, true);
446
447 /**
448 * Generated bundle index. Do not edit.
449 */
450
451 exports.Storage = Storage;
452 exports.StorageInstances = StorageInstances;
453 exports.StorageModule = StorageModule;
454 exports.connectStorageEmulator = connectStorageEmulator;
455 exports.deleteObject = deleteObject;
456 exports.fromTask = fromTask;
457 exports.getBlob = getBlob;
458 exports.getBytes = getBytes;
459 exports.getDownloadURL = getDownloadURL;
460 exports.getMetadata = getMetadata;
461 exports.getStorage = getStorage;
462 exports.getStream = getStream;
463 exports.list = list;
464 exports.listAll = listAll;
465 exports.percentage = percentage;
466 exports.provideStorage = provideStorage;
467 exports.ref = ref;
468 exports.storageInstance$ = storageInstance$;
469 exports.updateMetadata = updateMetadata;
470 exports.uploadBytes = uploadBytes;
471 exports.uploadBytesResumable = uploadBytesResumable;
472 exports.uploadString = uploadString;
473 Object.keys(storage).forEach(function (k) {
474 if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
475 enumerable: true,
476 get: function () {
477 return storage[k];
478 }
479 });
480 });
481
482 Object.defineProperty(exports, '__esModule', { value: true });
483
484})));
485//# sourceMappingURL=angular-fire-storage.umd.js.map