Skip to content

Commit 3e4c610

Browse files
Fix build
1 parent 6b34bc9 commit 3e4c610

File tree

6 files changed

+82
-47
lines changed

6 files changed

+82
-47
lines changed

packages/firestore/exp/src/api/reference.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ export function onSnapshot<T>(
387387
asyncUnsubscribe = getFirestoreClient(firestore).then(firestoreClient =>
388388
firestoreClient.listen(
389389
newQueryForPath(ref._key.path),
390-
observer,
391-
internalOptions
390+
internalOptions,
391+
observer
392392
)
393393
);
394394
} else {
@@ -410,7 +410,7 @@ export function onSnapshot<T>(
410410
validateHasExplicitOrderByForLimitToLast(query._query);
411411

412412
asyncUnsubscribe = getFirestoreClient(firestore).then(firestoreClient =>
413-
firestoreClient.listen(query._query, observer, internalOptions)
413+
firestoreClient.listen(query._query, internalOptions, observer)
414414
);
415415
}
416416

packages/firestore/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"description": "The Cloud Firestore component of the Firebase JS SDK.",
88
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
99
"scripts": {
10-
"build": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js",
10+
"build": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js && yarn build:lite && yarn build:exp",
1111
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
1212
"build:release": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js",
1313
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",

packages/firestore/rollup.config.es2017.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ const browserBuilds = [
8383
},
8484
plugins: browserBuildPlugins,
8585
external: util.resolveBrowserExterns
86+
},
87+
// Memory-only build
88+
{
89+
input: 'index.memory.ts',
90+
output: {
91+
file: path.resolve('./memory', memoryPkg.esm2017),
92+
format: 'es',
93+
sourcemap: true
94+
},
95+
plugins: browserBuildPlugins,
96+
external: util.resolveBrowserExterns
8697
}
8798
];
8899

@@ -147,7 +158,20 @@ const nodeBuilds = [
147158
output: [{ file: pkg['main-esm2017'], format: 'es', sourcemap: true }],
148159
plugins: nodeBuildPlugins,
149160
external: util.resolveNodeExterns
161+
},
162+
// Memory-only build
163+
{
164+
input: 'index.node.memory.ts',
165+
output: [
166+
{
167+
file: path.resolve('./memory', memoryPkg['main-esm2017']),
168+
format: 'es',
169+
sourcemap: true
170+
}
171+
],
172+
plugins: nodeBuildPlugins,
173+
external: util.resolveNodeExterns
150174
}
151175
];
152176

153-
export default [...browserBuilds, ...nodeBuilds];
177+
export default [...browserBuilds, ...reactNativeBuilds, ...nodeBuilds];

packages/firestore/rollup.config.es5.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,31 @@ const browserBuilds = [
6868
plugins: browserPlugins,
6969
external: util.resolveBrowserExterns
7070
},
71+
{
72+
input: path.resolve('./memory', memoryPkg.esm2017),
73+
output: {
74+
file: path.resolve('./memory', memoryPkg.module),
75+
format: 'es',
76+
sourcemap: true
77+
},
78+
plugins: browserPlugins,
79+
external: util.resolveBrowserExterns
80+
},
7181
{
7282
input: pkg.esm2017,
7383
output: { file: pkg.browser, format: 'cjs', sourcemap: true },
7484
plugins: browserPlugins,
7585
external: util.resolveBrowserExterns
86+
},
87+
{
88+
input: path.resolve('./memory', memoryPkg.esm2017),
89+
output: {
90+
file: path.resolve('./memory', memoryPkg.browser),
91+
format: 'cjs',
92+
sourcemap: true
93+
},
94+
plugins: browserPlugins,
95+
external: util.resolveBrowserExterns
7696
}
7797
];
7898

@@ -82,6 +102,18 @@ const nodeBuilds = [
82102
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
83103
plugins: nodePlugins,
84104
external: util.resolveNodeExterns
105+
},
106+
{
107+
input: path.resolve('./memory', memoryPkg['main-esm2017']),
108+
output: [
109+
{
110+
file: path.resolve('./memory', memoryPkg.main),
111+
format: 'cjs',
112+
sourcemap: true
113+
}
114+
],
115+
plugins: nodePlugins,
116+
external: util.resolveNodeExterns
85117
}
86118
];
87119

packages/firestore/src/api/database.ts

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import { _FirebaseApp, FirebaseService } from '@firebase/app-types/private';
2424
import { DatabaseId, DatabaseInfo } from '../core/database_info';
2525
import { ListenOptions } from '../core/event_manager';
2626
import {
27-
OnlineComponentProvider,
2827
MemoryOfflineComponentProvider,
29-
OfflineComponentProvider
28+
OfflineComponentProvider,
29+
OnlineComponentProvider
3030
} from '../core/component_provider';
3131
import { FirestoreClient, PersistenceSettings } from '../core/firestore_client';
3232
import {
@@ -60,7 +60,6 @@ import { FieldPath, ResourcePath } from '../model/path';
6060
import { isServerTimestamp } from '../model/server_timestamps';
6161
import { refValue } from '../model/values';
6262
import { debugAssert, fail } from '../util/assert';
63-
import { AsyncObserver } from '../util/async_observer';
6463
import { AsyncQueue } from '../util/async_queue';
6564
import { Code, FirestoreError } from '../util/error';
6665
import {
@@ -485,16 +484,15 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
485484
this.ensureClientConfigured();
486485

487486
if (isPartialObserver(arg)) {
488-
return addSnapshotsInSyncListener(
489-
this._firestoreClient!,
487+
return this._firestoreClient!.addSnapshotsInSyncListener(
490488
arg as PartialObserver<void>
491489
);
492490
} else {
493491
validateArgType('Firestore.onSnapshotsInSync', 'function', 1, arg);
494492
const observer: PartialObserver<void> = {
495493
next: arg as () => void
496494
};
497-
return addSnapshotsInSyncListener(this._firestoreClient!, observer);
495+
return this._firestoreClient!.addSnapshotsInSyncListener(observer);
498496
}
499497
}
500498

@@ -686,14 +684,6 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
686684
}
687685
}
688686

689-
/** Registers the listener for onSnapshotsInSync() */
690-
export function addSnapshotsInSyncListener(
691-
firestoreClient: FirestoreClient,
692-
observer: PartialObserver<void>
693-
): Unsubscribe {
694-
return firestoreClient.addSnapshotsInSyncListener(observer);
695-
}
696-
697687
/**
698688
* A reference to a transaction.
699689
*/
@@ -1168,7 +1158,7 @@ export class DocumentReference<T = firestore.DocumentData>
11681158
1,
11691159
4
11701160
);
1171-
let options: firestore.SnapshotListenOptions = {
1161+
let options: ListenOptions = {
11721162
includeMetadataChanges: false
11731163
};
11741164
let currArg = 0;
@@ -1233,9 +1223,8 @@ export class DocumentReference<T = firestore.DocumentData>
12331223
complete: args[currArg + 2] as CompleteFn
12341224
};
12351225

1236-
return addDocSnapshotListener(
1237-
this._firestoreClient,
1238-
this._key,
1226+
return this._firestoreClient.listen(
1227+
newQueryForPath(this._key.path),
12391228
internalOptions,
12401229
observer
12411230
);
@@ -1297,16 +1286,6 @@ export class DocumentReference<T = firestore.DocumentData>
12971286
}
12981287
}
12991288

1300-
/** Registers an internal snapshot listener for `ref`. */
1301-
export function addDocSnapshotListener(
1302-
firestoreClient: FirestoreClient,
1303-
key: DocumentKey,
1304-
options: ListenOptions,
1305-
observer: PartialObserver<ViewSnapshot>
1306-
): Unsubscribe {
1307-
return firestoreClient.listen(newQueryForPath(key.path), observer, options);
1308-
}
1309-
13101289
/**
13111290
* Retrieves a latency-compensated document from the backend via a
13121291
* SnapshotListener.
@@ -1319,6 +1298,10 @@ export function getDocViaSnapshotListener(
13191298
const result = new Deferred<ViewSnapshot>();
13201299
const unlisten = firestoreClient.listen(
13211300
newQueryForPath(key.path),
1301+
{
1302+
includeMetadataChanges: true,
1303+
waitForSyncWhenOnline: true
1304+
},
13221305
{
13231306
next: (snap: ViewSnapshot) => {
13241307
// Remove query first before passing event to user to avoid
@@ -1360,10 +1343,6 @@ export function getDocViaSnapshotListener(
13601343
}
13611344
},
13621345
error: e => result.reject(e)
1363-
},
1364-
{
1365-
includeMetadataChanges: true,
1366-
waitForSyncWhenOnline: true
13671346
}
13681347
);
13691348
return result.promise;
@@ -2119,7 +2098,7 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
21192098

21202099
onSnapshot(...args: unknown[]): Unsubscribe {
21212100
validateBetweenNumberOfArgs('Query.onSnapshot', arguments, 1, 4);
2122-
let options: firestore.SnapshotListenOptions = {};
2101+
let options: ListenOptions = {};
21232102
let currArg = 0;
21242103
if (
21252104
typeof args[currArg] === 'object' &&
@@ -2180,7 +2159,7 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
21802159

21812160
validateHasExplicitOrderByForLimitToLast(this._query);
21822161
const firestoreClient = this.firestore.ensureClientConfigured();
2183-
return firestoreClient.listen(this._query, observer, options);
2162+
return firestoreClient.listen(this._query, options, observer);
21842163
}
21852164

21862165
get(options?: firestore.GetOptions): Promise<firestore.QuerySnapshot<T>> {
@@ -2211,6 +2190,10 @@ export function getDocsViaSnapshotListener(
22112190
const result = new Deferred<ViewSnapshot>();
22122191
const unlisten = firestore.listen(
22132192
query,
2193+
{
2194+
includeMetadataChanges: true,
2195+
waitForSyncWhenOnline: true
2196+
},
22142197
{
22152198
next: snapshot => {
22162199
// Remove query first before passing event to user to avoid
@@ -2232,10 +2215,6 @@ export function getDocsViaSnapshotListener(
22322215
}
22332216
},
22342217
error: e => result.reject(e)
2235-
},
2236-
{
2237-
includeMetadataChanges: true,
2238-
waitForSyncWhenOnline: true
22392218
}
22402219
);
22412220
return result.promise;

packages/firestore/src/core/firestore_client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
} from './event_manager';
3636
import { SyncEngine } from './sync_engine';
3737
import { View } from './view';
38-
3938
import { SharedClientState } from '../local/shared_client_state';
4039
import { AutoId } from '../util/misc';
4140
import { DatabaseId, DatabaseInfo } from './database_info';
@@ -48,6 +47,7 @@ import {
4847
OfflineComponentProvider
4948
} from './component_provider';
5049
import { AsyncObserver } from '../util/async_observer';
50+
import { PartialObserver } from '../api/observer';
5151

5252
const LOG_TAG = 'FirestoreClient';
5353
const MAX_CONCURRENT_LIMBO_RESOLUTIONS = 100;
@@ -392,8 +392,8 @@ export class FirestoreClient {
392392

393393
listen(
394394
query: Query,
395-
observer: Partial<Observer<ViewSnapshot>>,
396-
options: ListenOptions
395+
options: ListenOptions,
396+
observer: PartialObserver<ViewSnapshot>
397397
): () => void {
398398
this.verifyNotTerminated();
399399
const wrappedObserver = new AsyncObserver(observer);
@@ -480,7 +480,7 @@ export class FirestoreClient {
480480
return this.databaseInfo.databaseId;
481481
}
482482

483-
addSnapshotsInSyncListener(observer: Partial<Observer<void>>): () => void {
483+
addSnapshotsInSyncListener(observer: PartialObserver<void>): () => void {
484484
this.verifyNotTerminated();
485485
const wrappedObserver = new AsyncObserver(observer);
486486
this.asyncQueue.enqueueAndForget(async () =>

0 commit comments

Comments
 (0)