Skip to content
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

Merged
merged 9 commits into from
Dec 3, 2020

Conversation

wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Nov 25, 2020

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Nov 25, 2020

⚠️ No Changeset found

Latest commit: 3f83901

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@wu-hui wu-hui changed the base branch from master to wuandy/ReleaseBundles November 25, 2020 11:52
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 25, 2020

Size Analysis Report

Affected Products

No changes between base commit (ddb7993) and head commit (82214fe).

Test Logs

implements ApiLoadBundleTask, PromiseLike<ApiLoadBundleTaskProgress> {
private _progressObserver: PartialObserver<ApiLoadBundleTaskProgress> = {};
private _taskCompletionResolver = new Deferred<ApiLoadBundleTaskProgress>();
implements LoadBundleTask, PromiseLike<LoadBundleTaskProgress> {
Copy link
Contributor

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?

Copy link
Contributor Author

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

});
}

export function firestoreClientGetNamedQuery(
Copy link
Contributor

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.

Copy link
Contributor Author

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No namespace imports please.

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

Copy link
Contributor Author

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';
Copy link
Contributor

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?

Copy link
Contributor Author

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 Show resolved Hide resolved
return namedQuery(this as any, queryName);
};

//TODO: add loadBundle and namedQuery to the firestore namespace
Copy link
Contributor

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

Copy link
Contributor Author

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(
Copy link
Contributor

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)

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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(
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@schmidt-sebastian schmidt-sebastian removed their assignment Nov 30, 2020
@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui Dec 1, 2020
import { loadBundle, namedQuery } from './src/api/bundle';

/**
* Registers the memory-only Firestore build with the components framework.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs updating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return namedQuery(this, queryName);
};

//TODO(wuandy): add loadBundle and namedQuery to the firestore namespace
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

packages/firestore/src/core/bundle_types.ts Outdated Show resolved Hide resolved
Comment on lines 28 to 29
readonly id: string;
readonly version: number;
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 41 to 42
readonly name: string;
readonly query: Query;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

wu-hui and others added 2 commits December 3, 2020 09:16
@wu-hui wu-hui merged commit cc8dd9c into wuandy/ReleaseBundles Dec 3, 2020
wu-hui added a commit that referenced this pull request Dec 8, 2020
* 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>
@firebase firebase locked and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants