-
Notifications
You must be signed in to change notification settings - Fork 930
Add Node build for Firebase Storage #5468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00cfe38
Add Node build for Firebase Storage
schmidt-sebastian b83cd47
Update All Tests.run.xml
schmidt-sebastian ba88035
Feedback
schmidt-sebastian bbd4803
Merge branch 'master' into mrschmidt/nodebuild
schmidt-sebastian f5ea975
Update API reports
schmidt-sebastian 3013b33
Suppress lint
schmidt-sebastian 1fa7ce9
Update API reports
schmidt-sebastian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TODO(mrschmidt): Add getBlob() | ||
|
||
export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TODO(mrschmidt): Add getStream() | ||
|
||
export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Cloud Storage for Firebase | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
/** | ||
* @license | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { | ||
_registerComponent, | ||
registerVersion, | ||
SDK_VERSION | ||
} from '@firebase/app'; | ||
|
||
import { FirebaseStorageImpl } from './service'; | ||
import { | ||
Component, | ||
ComponentType, | ||
ComponentContainer, | ||
InstanceFactoryOptions | ||
} from '@firebase/component'; | ||
|
||
import { name, version } from '../package.json'; | ||
|
||
import { FirebaseStorage } from './public-types'; | ||
import { STORAGE_TYPE } from './constants'; | ||
import { ConnectionPool } from './implementation/connectionPool'; | ||
|
||
export * from './api'; | ||
export * from './api.node'; | ||
|
||
function factory( | ||
container: ComponentContainer, | ||
{ instanceIdentifier: url }: InstanceFactoryOptions | ||
): FirebaseStorage { | ||
const app = container.getProvider('app').getImmediate(); | ||
const authProvider = container.getProvider('auth-internal'); | ||
const appCheckProvider = container.getProvider('app-check-internal'); | ||
|
||
return new FirebaseStorageImpl( | ||
app, | ||
authProvider, | ||
appCheckProvider, | ||
new ConnectionPool(), | ||
url, | ||
SDK_VERSION | ||
); | ||
} | ||
|
||
function registerStorage(): void { | ||
_registerComponent( | ||
new Component( | ||
STORAGE_TYPE, | ||
factory, | ||
ComponentType.PUBLIC | ||
).setMultipleInstances(true) | ||
); | ||
|
||
registerVersion(name, version); | ||
} | ||
|
||
registerStorage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of having different API for browser and node.
It makes it harder for developers to write isomorphic code for use cases like SSR. It also makes documentation harder, as we need to document the differences. We will also need to provide 2 typing files.
What does
getStream
do? Is it possible to make it part ofgetBlob
with a flag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can combine getBlob and getStream. The Blob API is not available in Node, and Streams are not available for Browsers.
I have two suggestions:
I updated the PR to throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I agree with throwing and keeping the same API for browser and node. We have taken the same approach in Auth to keep their node and browser API consistent.