UNPKG

5.49 kBJavaScriptView Raw
1import { ɵgetAllInstancesOf, ɵgetDefaultInstanceOf, VERSION, ɵAngularFireSchedulers, ɵzoneWrap } from '@angular/fire';
2import { timer, from } from 'rxjs';
3import { concatMap, distinct } from 'rxjs/operators';
4import * as i0 from '@angular/core';
5import { InjectionToken, Optional, NgModule, NgZone, Injector } from '@angular/core';
6import { FirebaseApp, FirebaseApps } from '@angular/fire/app';
7import { AuthInstances } from '@angular/fire/auth';
8import { registerVersion } from 'firebase/app';
9import { AppCheckInstances } from '@angular/fire/app-check';
10import { fromTask as fromTask$1, percentage as percentage$1 } from 'rxfire/storage';
11import { connectStorageEmulator as connectStorageEmulator$1, deleteObject as deleteObject$1, getBlob as getBlob$1, getBytes as getBytes$1, getDownloadURL as getDownloadURL$1, getMetadata as getMetadata$1, getStorage as getStorage$1, getStream as getStream$1, list as list$1, listAll as listAll$1, ref as ref$1, updateMetadata as updateMetadata$1, uploadBytes as uploadBytes$1, uploadBytesResumable as uploadBytesResumable$1, uploadString as uploadString$1 } from 'firebase/storage';
12export * from 'firebase/storage';
13
14class Storage {
15 constructor(auth) {
16 return auth;
17 }
18}
19const STORAGE_PROVIDER_NAME = 'storage';
20class StorageInstances {
21 constructor() {
22 return ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME);
23 }
24}
25const storageInstance$ = timer(0, 300).pipe(concatMap(() => from(ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME))), distinct());
26
27const PROVIDED_STORAGE_INSTANCES = new InjectionToken('angularfire2.storage-instances');
28function defaultStorageInstanceFactory(provided, defaultApp) {
29 const defaultStorage = ɵgetDefaultInstanceOf(STORAGE_PROVIDER_NAME, provided, defaultApp);
30 return defaultStorage && new Storage(defaultStorage);
31}
32function storageInstanceFactory(fn) {
33 return (zone, injector) => {
34 const storage = zone.runOutsideAngular(() => fn(injector));
35 return new Storage(storage);
36 };
37}
38const STORAGE_INSTANCES_PROVIDER = {
39 provide: StorageInstances,
40 deps: [
41 [new Optional(), PROVIDED_STORAGE_INSTANCES],
42 ]
43};
44const DEFAULT_STORAGE_INSTANCE_PROVIDER = {
45 provide: Storage,
46 useFactory: defaultStorageInstanceFactory,
47 deps: [
48 [new Optional(), PROVIDED_STORAGE_INSTANCES],
49 FirebaseApp,
50 ]
51};
52class StorageModule {
53 constructor() {
54 registerVersion('angularfire', VERSION.full, 'gcs');
55 }
56}
57StorageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
58StorageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule });
59StorageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule, providers: [
60 DEFAULT_STORAGE_INSTANCE_PROVIDER,
61 STORAGE_INSTANCES_PROVIDER,
62 ] });
63i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule, decorators: [{
64 type: NgModule,
65 args: [{
66 providers: [
67 DEFAULT_STORAGE_INSTANCE_PROVIDER,
68 STORAGE_INSTANCES_PROVIDER,
69 ]
70 }]
71 }], ctorParameters: function () { return []; } });
72function provideStorage(fn, ...deps) {
73 return {
74 ngModule: StorageModule,
75 providers: [{
76 provide: PROVIDED_STORAGE_INSTANCES,
77 useFactory: storageInstanceFactory(fn),
78 multi: true,
79 deps: [
80 NgZone,
81 Injector,
82 ɵAngularFireSchedulers,
83 FirebaseApps,
84 // Defensively load Auth first, if provided
85 [new Optional(), AuthInstances],
86 [new Optional(), AppCheckInstances],
87 ...deps,
88 ]
89 }]
90 };
91}
92
93// DO NOT MODIFY, this file is autogenerated by tools/build.ts
94const fromTask = ɵzoneWrap(fromTask$1, true);
95const percentage = ɵzoneWrap(percentage$1, true);
96
97// DO NOT MODIFY, this file is autogenerated by tools/build.ts
98const connectStorageEmulator = ɵzoneWrap(connectStorageEmulator$1, true);
99const deleteObject = ɵzoneWrap(deleteObject$1, true);
100const getBlob = ɵzoneWrap(getBlob$1, true);
101const getBytes = ɵzoneWrap(getBytes$1, true);
102const getDownloadURL = ɵzoneWrap(getDownloadURL$1, true);
103const getMetadata = ɵzoneWrap(getMetadata$1, true);
104const getStorage = ɵzoneWrap(getStorage$1, true);
105const getStream = ɵzoneWrap(getStream$1, true);
106const list = ɵzoneWrap(list$1, true);
107const listAll = ɵzoneWrap(listAll$1, true);
108const ref = ɵzoneWrap(ref$1, true);
109const updateMetadata = ɵzoneWrap(updateMetadata$1, true);
110const uploadBytes = ɵzoneWrap(uploadBytes$1, true);
111const uploadBytesResumable = ɵzoneWrap(uploadBytesResumable$1, true);
112const uploadString = ɵzoneWrap(uploadString$1, true);
113
114/**
115 * Generated bundle index. Do not edit.
116 */
117
118export { Storage, StorageInstances, StorageModule, connectStorageEmulator, deleteObject, fromTask, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, percentage, provideStorage, ref, storageInstance$, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
119//# sourceMappingURL=angular-fire-storage.js.map