-
Notifications
You must be signed in to change notification settings - Fork 893
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
Add bundles to d.ts and rearrange bundles source code for building it as a separate module #4120
Conversation
… as a separate module.
|
Size Analysis ReportAffected ProductsNo changes between base commit (ddb7993) and head commit (82214fe). Test Logs
|
packages/firestore/src/api/bundle.ts
Outdated
implements ApiLoadBundleTask, PromiseLike<ApiLoadBundleTaskProgress> { | ||
private _progressObserver: PartialObserver<ApiLoadBundleTaskProgress> = {}; | ||
private _taskCompletionResolver = new Deferred<ApiLoadBundleTaskProgress>(); | ||
implements LoadBundleTask, PromiseLike<LoadBundleTaskProgress> { |
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.
Is LoadBundleTask implements LoadBundleTask
intended?
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.
Meant to be the interface from d.ts, fixed.
): LoadBundleTask { | ||
const resultTask = new LoadBundleTask(); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
firestoreClientLoadBundle( |
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.
You should drop the Promise from firestoreClientLoadBundle
. It doesn't seem to be needed.
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.
Done.
@@ -265,3 +257,113 @@ export class BundleLoader { | |||
return new BundleLoadResult({ ...this.progress }, changedDocuments); | |||
} | |||
} | |||
|
|||
export async function firestoreClientLoadBundle( |
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.
As mentioned about, this doesn't need to be async
.
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.
Done.
): Promise<void> { | ||
const reader = createBundleReader( | ||
data, | ||
newSerializer((await client.getConfiguration()).databaseInfo.databaseId) |
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.
Can you pass in the databaseId
or get it from FirestoreClient?
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.
Done.
}); | ||
} | ||
|
||
export function firestoreClientGetNamedQuery( |
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.
These two methods should live in firestore_client
along with all their counterparts. In Android and iOS, they will be part of the FIrestoreClient class.
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.
Done.
I leave the refactor for local_store and sync_engine alone, because they actually look good.
} from '../model/collections'; | ||
import { debugCast } from '../util/assert'; | ||
|
||
import * as bundleProto from '../protos/firestore_bundle_proto'; |
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.
No namespace imports please.
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.
Done.
@@ -28,9 +28,11 @@ import { FieldValue } from '../../../src/compat/field_value'; | |||
import { FieldPath } from '../../../src/api/field_path'; | |||
import { Timestamp } from '../../../src/api/timestamp'; | |||
import { Blob } from '../../../src/api/blob'; | |||
null; |
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.
Please remove
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.
Done.
import { GeoPoint } from '../../../src/api/geo_point'; | ||
import { FirebaseApp } from '@firebase/app-types'; | ||
import { Firestore } from '../../../src/api/database'; | ||
import '../../../index.bundle'; |
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.
Should we add a comment here?
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.
Done.
packages/firestore/index.bundle.ts
Outdated
return namedQuery(this as any, queryName); | ||
}; | ||
|
||
//TODO: add loadBundle and namedQuery to the firestore namespace |
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.
Please assign TODO to yourself or to a bug
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.
This was added by Fei, I actually don't know what he meant by this. Added my name anyways.
* @param bundleReader Bundle to load into the SDK. | ||
* @param task LoadBundleTask used to update the loading progress to public API. | ||
*/ | ||
export function syncEngineLoadBundle( |
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.
This should live in SyncEngine as it uses the private SyncEngine types (SyncEngineImpl should not be used outside of sync_engine.ts)
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.
Done.
@@ -209,7 +200,7 @@ export interface SyncEngine { | |||
* This is useful to implement optional features (like bundles) in free | |||
* functions, such that they are tree-shakeable. | |||
*/ | |||
class SyncEngineImpl implements SyncEngine { | |||
export class SyncEngineImpl implements SyncEngine { |
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.
Please don't export this class, as it leaks all the public members that are only public for consumers in this file.
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.
Done.
@@ -183,7 +174,7 @@ export interface LocalStore { | |||
* This is useful to implement optional features (like bundles) in free | |||
* functions, such that they are tree-shakeable. | |||
*/ | |||
class LocalStoreImpl implements LocalStore { | |||
export class LocalStoreImpl implements LocalStore { |
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.
Same comments regarding the changes here as in SyncEngine. In general, since we don't seem to need the source re-arrangement anymore (with the prebuilt), we should move the bundle code back to where it was before.
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.
Done.
* LocalDocuments are re-calculated if there are remaining mutations in the | ||
* queue. | ||
*/ | ||
export async function applyBundleDocuments( |
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.
Would prefer to have this back in local_store.ts
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.
Done.
Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
packages/firestore/index.bundle.ts
Outdated
import { loadBundle, namedQuery } from './src/api/bundle'; | ||
|
||
/** | ||
* Registers the memory-only Firestore build with the components framework. |
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.
Comment needs updating.
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.
Done.
packages/firestore/index.bundle.ts
Outdated
return namedQuery(this, queryName); | ||
}; | ||
|
||
//TODO(wuandy): add loadBundle and namedQuery to the firestore namespace |
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.
If we both don't know what this refers to, then we might as well remove it.
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.
Done.
readonly id: string; | ||
readonly version: number; |
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.
Ideally, this would be commented as well as it will be used to generate the firestore-exp docs (once you merge master)
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.
Done.
readonly name: string; | ||
readonly query: Query; |
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.
Same applies here - we should add JSDoc.
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.
Done.
Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
* Add bundles to d.ts and rearrange bundles source code for building it as a separate module (#4120) * Add bundles to d.ts and rearrange bundles source code for building it as a separate module. * Roll bundle with prebuilt (#4128) Build firestore sdks with prebuilt to support bundle as a prototype patched feature. * Add JSDoc for bundles (#4155) Add JSDoc for bundles. * Create changeset * Update old-lobsters-pull.md * A few fixes for Firestore bundle sdk builds (#4177) * Actually creates firebase/firestore/bundle package.json * Fix standard node/browser builds for bundles * Make it release from remote branch. * Add bundle to firebase complete build and fix missing proto for memory build. * Make rollup.config.js more organized. * Revert "Make it release from remote branch." This reverts commit 2c91fd1. * 2017 -> 2020 * Update comment. * Address comments * Update .changeset/old-lobsters-pull.md Co-authored-by: Sebastian Schmidt <mrschmidt@google.com> * Update .changeset/old-lobsters-pull.md Co-authored-by: Sebastian Schmidt <mrschmidt@google.com> * Add toc. * Remove webpack change. Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
No description provided.