-
Notifications
You must be signed in to change notification settings - Fork 946
Build and release Firestore compat #4616
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 all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e65e5ef
build firestore compat
Feiyang1 1e40f70
save
Feiyang1 a5e924c
various compat builds
Feiyang1 4d23279
update externs
Feiyang1 9bf23f7
create firestore-compat folder
Feiyang1 4fa5108
publish firestore-compat
Feiyang1 fccfd29
fix auth-compat build
Feiyang1 5cc44d8
abortOnError false
Feiyang1 f8d94d2
use the correct plugin
Feiyang1 e06c3ff
Fix order
Feiyang1 5e82bbd
fix script
Feiyang1 62b1f2d
fix typo
Feiyang1 43b84d9
correct dist folder path
Feiyang1 c394304
replace all
Feiyang1 7af64e8
copy d.ts files
Feiyang1 5c190ec
use regex
Feiyang1 6a3c721
fix lint errors
Feiyang1 b8dd58b
address comments
Feiyang1 a1cec3d
remove bundle and memory builds
Feiyang1 75ccd16
update release build
Feiyang1 6a93bce
remove bundle build
Feiyang1 54401da
remove dangling code
Feiyang1 eb657ed
fix lint
Feiyang1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @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. | ||
*/ | ||
|
||
import { | ||
loadBundle as expLoadBundle, | ||
namedQuery as expNamedQuery, | ||
LoadBundleTask | ||
} from '../exp/index'; | ||
import { Firestore, Query } from '../src/api/database'; | ||
|
||
export function loadBundle( | ||
this: Firestore, | ||
data: ArrayBuffer | ReadableStream<Uint8Array> | string | ||
): LoadBundleTask { | ||
return expLoadBundle(this._delegate, data); | ||
} | ||
|
||
export function namedQuery( | ||
this: Firestore, | ||
queryName: string | ||
): Promise<Query | null> { | ||
return expNamedQuery(this._delegate, queryName).then(expQuery => { | ||
if (!expQuery) { | ||
return null; | ||
} | ||
return new Query( | ||
this, | ||
// We can pass `expQuery` here directly since named queries don't have a UserDataConverter. | ||
// Otherwise, we would have to create a new ExpQuery and pass the old UserDataConverter. | ||
expQuery | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* Prototype patches bundle loading to Firestore. | ||
*/ | ||
export function registerBundle(instance: typeof Firestore): void { | ||
instance.prototype.loadBundle = loadBundle; | ||
instance.prototype.namedQuery = namedQuery; | ||
} |
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,92 @@ | ||
/** | ||
* @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 { FirebaseApp } from '@firebase/app-compat'; | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
import { _FirebaseNamespace } from '@firebase/app-types/private'; | ||
import { Component, ComponentType } from '@firebase/component'; | ||
|
||
import { | ||
FirebaseFirestore, | ||
CACHE_SIZE_UNLIMITED, | ||
FieldPath, | ||
GeoPoint, | ||
Timestamp, | ||
FieldValue | ||
} from '../exp/index'; // import from the exp public API | ||
import { Blob } from '../src/api/blob'; | ||
import { | ||
Firestore, | ||
Transaction, | ||
CollectionReference, | ||
DocumentReference, | ||
DocumentSnapshot, | ||
Query, | ||
QueryDocumentSnapshot, | ||
QuerySnapshot, | ||
WriteBatch, | ||
setLogLevel | ||
} from '../src/api/database'; | ||
|
||
const firestoreNamespace = { | ||
Firestore, | ||
GeoPoint, | ||
Timestamp, | ||
Blob, | ||
Transaction, | ||
WriteBatch, | ||
DocumentReference, | ||
DocumentSnapshot, | ||
Query, | ||
QueryDocumentSnapshot, | ||
QuerySnapshot, | ||
CollectionReference, | ||
FieldPath, | ||
FieldValue, | ||
setLogLevel, | ||
CACHE_SIZE_UNLIMITED | ||
}; | ||
|
||
/** | ||
* Configures Firestore as part of the Firebase SDK by calling registerComponent. | ||
* | ||
* @param firebase - The FirebaseNamespace to register Firestore with | ||
* @param firestoreFactory - A factory function that returns a new Firestore | ||
* instance. | ||
*/ | ||
export function configureForFirebase( | ||
firebase: FirebaseNamespace, | ||
firestoreFactory: ( | ||
app: FirebaseApp, | ||
firestoreExp: FirebaseFirestore | ||
) => Firestore | ||
): void { | ||
(firebase as _FirebaseNamespace).INTERNAL.registerComponent( | ||
new Component( | ||
'firestore', | ||
container => { | ||
const app = container.getProvider('app-compat').getImmediate()!; | ||
const firestoreExp = container | ||
.getProvider('firestore-exp') | ||
.getImmediate()!; | ||
return firestoreFactory(app, firestoreExp); | ||
}, | ||
ComponentType.PUBLIC | ||
).setServiceProps({ ...firestoreNamespace }) | ||
); | ||
} |
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,44 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 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 firebase from '@firebase/app-compat'; | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
|
||
import { name, version } from '../package.json'; | ||
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database'; | ||
|
||
import { registerBundle } from './bundle'; | ||
import { configureForFirebase } from './config'; | ||
|
||
import '../register-module'; | ||
|
||
/** | ||
* Registers the main Firestore Node build with the components framework. | ||
* Persistence can be enabled via `firebase.firestore().enablePersistence()`. | ||
*/ | ||
export function registerFirestore(instance: FirebaseNamespace): void { | ||
configureForFirebase( | ||
instance, | ||
(app, firestoreExp) => | ||
new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()) | ||
); | ||
instance.registerVersion(name, version, 'node'); | ||
} | ||
|
||
registerFirestore((firebase as unknown) as FirebaseNamespace); | ||
registerBundle(Firestore); |
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,44 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 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 firebase from '@firebase/app-compat'; | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
|
||
import { name, version } from '../package.json'; | ||
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database'; | ||
|
||
import { registerBundle } from './bundle'; | ||
import { configureForFirebase } from './config'; | ||
|
||
import '../register-module'; | ||
|
||
/** | ||
* Registers the main Firestore ReactNative build with the components framework. | ||
* Persistence can be enabled via `firebase.firestore().enablePersistence()`. | ||
*/ | ||
export function registerFirestore(instance: FirebaseNamespace): void { | ||
configureForFirebase( | ||
instance, | ||
(app, firestoreExp) => | ||
new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()) | ||
); | ||
instance.registerVersion(name, version, 'rn'); | ||
} | ||
|
||
registerFirestore((firebase as unknown) as FirebaseNamespace); | ||
registerBundle(Firestore); |
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,44 @@ | ||
/** | ||
* @license | ||
* Copyright 2020 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 firebase from '@firebase/app-compat'; | ||
import { FirebaseNamespace } from '@firebase/app-types'; | ||
|
||
import { name, version } from '../package.json'; | ||
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database'; | ||
|
||
import { registerBundle } from './bundle'; | ||
import { configureForFirebase } from './config'; | ||
|
||
import '../register-module'; | ||
|
||
/** | ||
* Registers the main Firestore build with the components framework. | ||
* Persistence can be enabled via `firebase.firestore().enablePersistence()`. | ||
*/ | ||
export function registerFirestore(instance: FirebaseNamespace): void { | ||
configureForFirebase( | ||
instance, | ||
(app, firestoreExp) => | ||
new Firestore(app, firestoreExp, new IndexedDbPersistenceProvider()) | ||
); | ||
instance.registerVersion(name, version); | ||
} | ||
|
||
registerFirestore((firebase as unknown) as FirebaseNamespace); | ||
registerBundle(Firestore); |
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,15 @@ | ||
{ | ||
"name": "@firebase/firestore-compat", | ||
"version": "0.0.900", | ||
"description": "The Cloud Firestore component of the Firebase JS SDK.", | ||
"author": "Firebase <[email protected]> (https://firebase.google.com/)", | ||
"main": "../dist/compat/node-cjs/index.js", | ||
"main-esm2017": "../dist/compat/node-esm2017/index.js", | ||
"react-native": "../dist/compat/rn/index.js", | ||
"browser": "../dist/compat/esm5/index.js", | ||
"module": "../dist/compat/esm5/index.js", | ||
"esm2017": "../dist/compat/esm2017/index.js", | ||
"license": "Apache-2.0", | ||
"typings": "../dist/compat/esm5/packages/firestore/compat/index.d.ts" | ||
} | ||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.