1 | import { ɵgetAllInstancesOf, ɵgetDefaultInstanceOf, VERSION, ɵAngularFireSchedulers, ɵzoneWrap } from '@angular/fire';
|
2 | import { timer, from } from 'rxjs';
|
3 | import { concatMap, distinct } from 'rxjs/operators';
|
4 | import * as i0 from '@angular/core';
|
5 | import { InjectionToken, Optional, NgModule, NgZone, Injector } from '@angular/core';
|
6 | import { FirebaseApp, FirebaseApps } from '@angular/fire/app';
|
7 | import { AuthInstances } from '@angular/fire/auth';
|
8 | import { registerVersion } from 'firebase/app';
|
9 | import { AppCheckInstances } from '@angular/fire/app-check';
|
10 | import { fromTask as fromTask$1, percentage as percentage$1 } from 'rxfire/storage';
|
11 | import { 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';
|
12 | export * from 'firebase/storage';
|
13 |
|
14 | class Storage {
|
15 | constructor(auth) {
|
16 | return auth;
|
17 | }
|
18 | }
|
19 | const STORAGE_PROVIDER_NAME = 'storage';
|
20 | class StorageInstances {
|
21 | constructor() {
|
22 | return ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME);
|
23 | }
|
24 | }
|
25 | const storageInstance$ = timer(0, 300).pipe(concatMap(() => from(ɵgetAllInstancesOf(STORAGE_PROVIDER_NAME))), distinct());
|
26 |
|
27 | const PROVIDED_STORAGE_INSTANCES = new InjectionToken('angularfire2.storage-instances');
|
28 | function defaultStorageInstanceFactory(provided, defaultApp) {
|
29 | const defaultStorage = ɵgetDefaultInstanceOf(STORAGE_PROVIDER_NAME, provided, defaultApp);
|
30 | return defaultStorage && new Storage(defaultStorage);
|
31 | }
|
32 | function storageInstanceFactory(fn) {
|
33 | return (zone, injector) => {
|
34 | const storage = zone.runOutsideAngular(() => fn(injector));
|
35 | return new Storage(storage);
|
36 | };
|
37 | }
|
38 | const STORAGE_INSTANCES_PROVIDER = {
|
39 | provide: StorageInstances,
|
40 | deps: [
|
41 | [new Optional(), PROVIDED_STORAGE_INSTANCES],
|
42 | ]
|
43 | };
|
44 | const DEFAULT_STORAGE_INSTANCE_PROVIDER = {
|
45 | provide: Storage,
|
46 | useFactory: defaultStorageInstanceFactory,
|
47 | deps: [
|
48 | [new Optional(), PROVIDED_STORAGE_INSTANCES],
|
49 | FirebaseApp,
|
50 | ]
|
51 | };
|
52 | class StorageModule {
|
53 | constructor() {
|
54 | registerVersion('angularfire', VERSION.full, 'gcs');
|
55 | }
|
56 | }
|
57 | StorageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
58 | StorageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: StorageModule });
|
59 | StorageModule.ɵ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 | ] });
|
63 | i0.ɵɵ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 []; } });
|
72 | function 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 |
|
85 | [new Optional(), AuthInstances],
|
86 | [new Optional(), AppCheckInstances],
|
87 | ...deps,
|
88 | ]
|
89 | }]
|
90 | };
|
91 | }
|
92 |
|
93 |
|
94 | const fromTask = ɵzoneWrap(fromTask$1, true);
|
95 | const percentage = ɵzoneWrap(percentage$1, true);
|
96 |
|
97 |
|
98 | const connectStorageEmulator = ɵzoneWrap(connectStorageEmulator$1, true);
|
99 | const deleteObject = ɵzoneWrap(deleteObject$1, true);
|
100 | const getBlob = ɵzoneWrap(getBlob$1, true);
|
101 | const getBytes = ɵzoneWrap(getBytes$1, true);
|
102 | const getDownloadURL = ɵzoneWrap(getDownloadURL$1, true);
|
103 | const getMetadata = ɵzoneWrap(getMetadata$1, true);
|
104 | const getStorage = ɵzoneWrap(getStorage$1, true);
|
105 | const getStream = ɵzoneWrap(getStream$1, true);
|
106 | const list = ɵzoneWrap(list$1, true);
|
107 | const listAll = ɵzoneWrap(listAll$1, true);
|
108 | const ref = ɵzoneWrap(ref$1, true);
|
109 | const updateMetadata = ɵzoneWrap(updateMetadata$1, true);
|
110 | const uploadBytes = ɵzoneWrap(uploadBytes$1, true);
|
111 | const uploadBytesResumable = ɵzoneWrap(uploadBytesResumable$1, true);
|
112 | const uploadString = ɵzoneWrap(uploadString$1, true);
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | export { Storage, StorageInstances, StorageModule, connectStorageEmulator, deleteObject, fromTask, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, percentage, provideStorage, ref, storageInstance$, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
|
119 |
|