Skip to content

Commit d974b64

Browse files
committed
pulled from master
2 parents 6b1f381 + e733228 commit d974b64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2458
-1747
lines changed

config/webpack.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -18,6 +18,12 @@
1818
const path = require('path');
1919
const webpack = require('webpack');
2020

21+
/**
22+
* A regular expression used to replace Firestore's platform specific modules,
23+
* which are located under 'packages/firestore/src/platform/'.
24+
*/
25+
const FIRESTORE_PLATFORM_RE = /^(.*)\/platform\/([^.\/]*)(\.ts)?$/;
26+
2127
module.exports = {
2228
mode: 'development',
2329
devtool: 'source-map',
@@ -77,6 +83,15 @@ module.exports = {
7783
extensions: ['.js', '.ts']
7884
},
7985
plugins: [
86+
new webpack.NormalModuleReplacementPlugin(
87+
FIRESTORE_PLATFORM_RE,
88+
resource => {
89+
resource.request = resource.request.replace(
90+
FIRESTORE_PLATFORM_RE,
91+
'$1/platform/browser/$2.ts'
92+
);
93+
}
94+
),
8095
new webpack.EnvironmentPlugin([
8196
'RTDB_EMULATOR_PORT',
8297
'RTDB_EMULATOR_NAMESPACE'

packages/firebase/src/index.rn.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import '../database';
2323
// TODO(b/158625454): Storage doesn't actually work by default in RN (it uses
2424
// `atob`). We should provide a RN build that works out of the box.
2525
import '../storage';
26-
import '../firestore';
2726

2827
firebase.registerVersion(name, version, 'rn');
2928

packages/firestore/index.console.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import './src/platform_browser/browser_init';
18+
// TODO(mrschmidt): Once imported into Google3, fix
19+
// third_party/javascript/firebase/src/packages/firestore/tools/console.build.js
1920

2021
export { Firestore, FirestoreDatabase } from './src/api/database';
2122
export {
@@ -25,7 +26,7 @@ export {
2526
PublicQuerySnapshot as QuerySnapshot,
2627
PublicFieldValue as FieldValue,
2728
PublicBlob as Blob
28-
} from './src/platform/config';
29+
} from './src/config';
2930
export { GeoPoint } from './src/api/geo_point';
3031
export { FirstPartyCredentialsSettings } from './src/api/credentials';
3132
export { FieldPath } from './src/api/field_path';

packages/firestore/index.memory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import { FirebaseNamespace } from '@firebase/app-types';
2020

2121
import { Firestore } from './src/api/database';
2222
import { MemoryComponentProvider } from './src/core/component_provider';
23-
import { configureForFirebase } from './src/platform/config';
23+
import { configureForFirebase } from './src/config';
2424

2525
import './register-module';
26-
import './src/platform_browser/browser_init';
2726

2827
import { name, version } from './package.json';
2928

packages/firestore/index.node.memory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import { FirebaseNamespace } from '@firebase/app-types';
2020

2121
import { Firestore } from './src/api/database';
2222
import { MemoryComponentProvider } from './src/core/component_provider';
23-
import { configureForFirebase } from './src/platform/config';
23+
import { configureForFirebase } from './src/config';
2424
import './register-module';
25-
import './src/platform_node/node_init';
2625

2726
import { name, version } from './package.json';
2827

packages/firestore/index.node.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ import { FirebaseNamespace } from '@firebase/app-types';
1919

2020
import { Firestore } from './src/api/database';
2121
import { IndexedDbComponentProvider } from './src/core/component_provider';
22-
import { configureForFirebase } from './src/platform/config';
22+
import { configureForFirebase } from './src/config';
2323

2424
import './register-module';
25-
import './src/platform_node/node_init';
2625

2726
import { name, version } from './package.json';
2827

packages/firestore/index.rn.memory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import { FirebaseNamespace } from '@firebase/app-types';
2020

2121
import { Firestore } from './src/api/database';
2222
import { MemoryComponentProvider } from './src/core/component_provider';
23-
import { configureForFirebase } from './src/platform/config';
23+
import { configureForFirebase } from './src/config';
2424

2525
import './register-module';
26-
import './src/platform_rn/rn_init';
2726

2827
import { name, version } from './package.json';
2928

packages/firestore/index.rn.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import { FirebaseNamespace } from '@firebase/app-types';
1919

2020
import { Firestore } from './src/api/database';
2121
import { IndexedDbComponentProvider } from './src/core/component_provider';
22-
import { configureForFirebase } from './src/platform/config';
22+
import { configureForFirebase } from './src/config';
2323

2424
import './register-module';
25-
import './src/platform_rn/rn_init';
26-
2725
import { name, version } from './package.json';
2826

2927
/**

packages/firestore/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ import { FirebaseNamespace } from '@firebase/app-types';
2020

2121
import { Firestore } from './src/api/database';
2222
import { IndexedDbComponentProvider } from './src/core/component_provider';
23-
import { configureForFirebase } from './src/platform/config';
23+
import { configureForFirebase } from './src/config';
2424
import { name, version } from './package.json';
2525

2626
import './register-module';
27-
import './src/platform_browser/browser_init';
2827

2928
/**
3029
* Registers the main Firestore build with the components framework.

packages/firestore/lite/index.node.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import { Firestore } from './src/api/database';
2020
import { version } from '../package.json';
2121
import { Component, ComponentType } from '@firebase/component';
2222

23-
import '../src/platform_node/node_init';
24-
2523
export {
2624
Firestore as FirebaseFirestore,
2725
initializeFirestore,

packages/firestore/lite/src/api/database.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import {
3333
newDatastore,
3434
terminateDatastore
3535
} from '../../../src/remote/datastore';
36-
import { PlatformSupport } from '../../../src/platform/platform';
36+
import { newConnection } from '../../../src/platform/connection';
37+
import { newSerializer } from '../../../src/platform/serializer';
3738
import { cast } from './util';
3839
import { Settings } from '../../';
3940

@@ -90,14 +91,10 @@ export class Firestore implements firestore.FirebaseFirestore {
9091
_getDatastore(): Promise<Datastore> {
9192
if (!this._datastorePromise) {
9293
const databaseInfo = this._makeDatabaseInfo(this._getSettings());
93-
this._datastorePromise = PlatformSupport.getPlatform()
94-
.loadConnection(databaseInfo)
95-
.then(connection => {
96-
const serializer = PlatformSupport.getPlatform().newSerializer(
97-
databaseInfo.databaseId
98-
);
99-
return newDatastore(connection, this._credentials, serializer);
100-
});
94+
this._datastorePromise = newConnection(databaseInfo).then(connection => {
95+
const serializer = newSerializer(databaseInfo.databaseId);
96+
return newDatastore(connection, this._credentials, serializer);
97+
});
10198
}
10299

103100
return this._datastorePromise;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import {
4646
} from '../../../src/remote/datastore';
4747
import { hardAssert } from '../../../src/util/assert';
4848
import { DeleteMutation, Precondition } from '../../../src/model/mutation';
49-
import { PlatformSupport } from '../../../src/platform/platform';
5049
import {
5150
applyFirestoreDataConverter,
5251
BaseQuery
@@ -60,6 +59,7 @@ import {
6059
validateExactNumberOfArgs,
6160
validatePositiveNumber
6261
} from '../../../src/util/input_validation';
62+
import { newSerializer } from '../../../src/platform/serializer';
6363
import { FieldPath as ExternalFieldPath } from '../../../src/api/field_path';
6464
import { Code, FirestoreError } from '../../../src/util/error';
6565

@@ -592,9 +592,7 @@ export function queryEqual<T>(
592592

593593
export function newUserDataReader(firestore: Firestore): UserDataReader {
594594
const settings = firestore._getSettings();
595-
const serializer = PlatformSupport.getPlatform().newSerializer(
596-
firestore._databaseId
597-
);
595+
const serializer = newSerializer(firestore._databaseId);
598596
return new UserDataReader(
599597
firestore._databaseId,
600598
!!settings.ignoreUndefinedProperties,

0 commit comments

Comments
 (0)