1 line
44 KiB
Text
1 line
44 KiB
Text
|
{"version":3,"file":"angular-fire-compat-storage.umd.js","sources":["../../../src/compat/storage/observable/fromTask.ts","../../../src/compat/storage/task.ts","../../../src/compat/storage/ref.ts","../../../node_modules/tslib/tslib.es6.js","../../../src/compat/storage/storage.ts","../../../src/compat/storage/pipes/storageUrl.pipe.ts","../../../src/compat/storage/storage.module.ts","../../../src/compat/storage/angular-fire-compat-storage.ts"],"sourcesContent":["import { Observable } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { UploadTask, UploadTaskSnapshot } from '../interfaces';\n\n// need to import, else the types become import('firebase/compat/app').default.storage.UploadTask\n// and it no longer works w/Firebase v7\nimport firebase from 'firebase/compat/app';\n\n// Things aren't working great, I'm having to put in a lot of work-arounds for what\n// appear to be Firebase JS SDK bugs https://github.com/firebase/firebase-js-sdk/issues/4158\nexport function fromTask(task: UploadTask) {\n return new Observable<UploadTaskSnapshot>(subscriber => {\n const progress = (snap: UploadTaskSnapshot) => subscriber.next(snap);\n const error = e => subscriber.error(e);\n const complete = () => subscriber.complete();\n // emit the current snapshot, so they don't have to wait for state_changes\n // to fire next... this is stale if the task is no longer running :(\n progress(task.snapshot);\n const unsub = task.on('state_changed', progress);\n // it turns out that neither task snapshot nor 'state_changed' fire the last\n // snapshot before completion, the one with status 'success\" and 100% progress\n // so let's use the promise form of the task for that\n task.then(snapshot => {\n progress(snapshot);\n complete();\n }, e => {\n // TODO investigate, again this is stale, we never fire a canceled or error it seems\n progress(task.snapshot);\n error(e);\n });\n // on's type if Function, rather than () => void, need to wrap\n return function unsubscribe() {\n unsub();\n };\n }).pipe(\n // deal with sync emissions from first emitting `task.snapshot`, this makes sure\n // that if the task is already finished we don't emit the old running state\n debounceTime(0)\n );\n}\n","import { UploadTask, UploadTaskSnapshot } from './interfaces';\nimport { fromTask } from './observable/fromTask';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface AngularFireUploadTask {\n task: UploadTask;\n snapshotChanges(): Observable<UploadTaskSnapshot | undefined>;\n percentageChanges(): Observable<number | undefined>;\n pause(): boolean;\n cancel(): boolean;\n resume(): boolean;\n then(\n onFulfilled?: ((a: UploadTaskSnapshot) => any) | null,\n onRejected?: ((a: Error) => any) | null\n ): Promise<any>;\n catch(onRejected: (a: Error) => any): Promise<any>;\n}\n\n/**\n * Create an AngularFireUploadTask from a regular UploadTask from the Storage SDK.\n * This method creates an observable of the upload and returns on object that provides\n * multiple methods for controlling and monitoring the file upload.\n */\nexport function createUploadTask(task: UploadTask): AngularFireUploadTask {\n const inner$ = fromTask(task);\n return {\n task,\n then: task.then.bind(task),\n catch: task.catch.bind(task),\n pause: task.pause.bind(task),\n cancel: task.cancel.bind(task),\n resume: task.resume.bind(task),\n snapshotChanges: () => inner$,\n percentageChanges: () => inner$.pipe(\n map(s => s.bytesTransferred / s.totalBytes * 100)\n )\n };\n}\n","import { ListOptions, ListResult, Reference, SettableMetadata, StringFormat, UploadMetadata } from './interfaces';\nimport { AngularFireUploadTask, createUploadTask } from './task';\nimport { from, Observable, of } from 'rxjs';\nimport { observeOutsideAngular, keepUnstableUntilFirst } from '@angular/fire';\nimport { switchMap } from 'rxjs/operators';\n\nexport interface AngularFireStorageReference {\n getDownloadURL(): Observable<an
|