|
| 1 | +/** |
| 2 | + * Cloud Storage for Firebase |
| 3 | + * |
| 4 | + * @packageDocumentation |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * @license |
| 9 | + * Copyright 2021 Google LLC |
| 10 | + * |
| 11 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 12 | + * you may not use this file except in compliance with the License. |
| 13 | + * You may obtain a copy of the License at |
| 14 | + * |
| 15 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | + * |
| 17 | + * Unless required by applicable law or agreed to in writing, software |
| 18 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 19 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | + * See the License for the specific language governing permissions and |
| 21 | + * limitations under the License. |
| 22 | + */ |
| 23 | + |
| 24 | +// eslint-disable-next-line import/no-extraneous-dependencies |
| 25 | +import { |
| 26 | + _registerComponent, |
| 27 | + registerVersion, |
| 28 | + SDK_VERSION |
| 29 | +} from '@firebase/app'; |
| 30 | + |
| 31 | +import { FirebaseStorageImpl } from './service'; |
| 32 | +import { |
| 33 | + Component, |
| 34 | + ComponentType, |
| 35 | + ComponentContainer, |
| 36 | + InstanceFactoryOptions |
| 37 | +} from '@firebase/component'; |
| 38 | + |
| 39 | +import { name, version } from '../package.json'; |
| 40 | + |
| 41 | +import { FirebaseStorage } from './public-types'; |
| 42 | +import { STORAGE_TYPE } from './constants'; |
| 43 | +import { ConnectionPool } from './implementation/connectionPool'; |
| 44 | + |
| 45 | +export * from './api'; |
| 46 | +export * from './api.node'; |
| 47 | + |
| 48 | +function factory( |
| 49 | + container: ComponentContainer, |
| 50 | + { instanceIdentifier: url }: InstanceFactoryOptions |
| 51 | +): FirebaseStorage { |
| 52 | + const app = container.getProvider('app').getImmediate(); |
| 53 | + const authProvider = container.getProvider('auth-internal'); |
| 54 | + const appCheckProvider = container.getProvider('app-check-internal'); |
| 55 | + |
| 56 | + return new FirebaseStorageImpl( |
| 57 | + app, |
| 58 | + authProvider, |
| 59 | + appCheckProvider, |
| 60 | + new ConnectionPool(), |
| 61 | + url, |
| 62 | + SDK_VERSION |
| 63 | + ); |
| 64 | +} |
| 65 | + |
| 66 | +function registerStorage(): void { |
| 67 | + _registerComponent( |
| 68 | + new Component( |
| 69 | + STORAGE_TYPE, |
| 70 | + factory, |
| 71 | + ComponentType.PUBLIC |
| 72 | + ).setMultipleInstances(true) |
| 73 | + ); |
| 74 | + |
| 75 | + registerVersion(name, version); |
| 76 | +} |
| 77 | + |
| 78 | +registerStorage(); |
0 commit comments