Skip to content

Commit 8dbf020

Browse files
committed
Has placeholder implementation.
Added bundles rolling.
1 parent 0880c8d commit 8dbf020

File tree

8 files changed

+143
-22
lines changed

8 files changed

+143
-22
lines changed

packages/firebase/index.d.ts

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

18+
import { DocumentData, LoadBundleTask, Query } from '@firebase/firestore-types';
19+
1820
/**
1921
* <code>firebase</code> is a global namespace from which all Firebase
2022
* services are accessed.
@@ -8279,22 +8281,18 @@ declare namespace firebase.firestore {
82798281
*/
82808282
terminate(): Promise<void>;
82818283

8284+
loadBundle(
8285+
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
8286+
): LoadBundleTask;
8287+
8288+
namedQuery(name: string): Promise<Query<DocumentData> | null>;
8289+
82828290
/**
82838291
* @hidden
82848292
*/
82858293
INTERNAL: { delete: () => Promise<void> };
82868294
}
82878295

8288-
export function loadBundle(
8289-
db: Firestore,
8290-
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
8291-
): LoadBundleTask;
8292-
8293-
export function namedQuery(
8294-
db: Firestore,
8295-
name: string
8296-
): Promise<Query<DocumentData> | null>;
8297-
82988296
export interface LoadBundleTask {
82998297
onProgress(
83008298
next?: (progress: LoadBundleTaskProgress) => any,

packages/firestore-types/index.d.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,14 @@ export class FirebaseFirestore {
9696

9797
terminate(): Promise<void>;
9898

99-
INTERNAL: { delete: () => Promise<void> };
100-
}
99+
loadBundle(
100+
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
101+
): LoadBundleTask;
101102

102-
export function loadBundle(
103-
db: FirebaseFirestore,
104-
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
105-
): LoadBundleTask;
103+
namedQuery(name: string): Promise<Query<DocumentData> | null>;
106104

107-
export function namedQuery(
108-
db: FirebaseFirestore,
109-
name: string
110-
): Promise<Query<DocumentData> | null>;
105+
INTERNAL: { delete: () => Promise<void> };
106+
}
111107

112108
export interface LoadBundleTask {
113109
onProgress(

packages/firestore/index.bundle.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import * as firestore from '@firebase/firestore-types';
19+
import { loadBundle, namedQuery } from './src/api/database';
20+
21+
/**
22+
* Registers the memory-only Firestore build with the components framework.
23+
*/
24+
export function registerBundle(
25+
instance: typeof firestore.FirebaseFirestore
26+
): void {
27+
instance.prototype.loadBundle = function (
28+
data: ArrayBuffer | ReadableStream<Uint8Array> | string
29+
) {
30+
return loadBundle(this as any, data);
31+
};
32+
instance.prototype.namedQuery = function (queryName: string) {
33+
return namedQuery(this as any, queryName);
34+
};
35+
}
36+
37+
registerBundle(firestore.FirebaseFirestore);

packages/firestore/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:console": "node tools/console.build.js",
1616
"build:exp": "rollup -c rollup.config.exp.js",
1717
"build:lite": "rollup -c rollup.config.lite.js",
18+
"build:bundle": "rollup -c rollup.config.bundle.js",
1819
"build:exp:release": "yarn build:exp && yarn build:lite",
1920
"predev": "yarn prebuild",
2021
"dev": "rollup -c -w",
@@ -57,6 +58,8 @@
5758
"browser": "dist/index.esm.js",
5859
"module": "dist/index.esm.js",
5960
"esm2017": "dist/index.esm2017.js",
61+
"bundle": "dist/index.bundle.js",
62+
"bundleModule": "dist/index.bundle.module.js",
6063
"license": "Apache-2.0",
6164
"files": [
6265
"dist",

packages/firestore/register-bundle.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '@firebase/firestore-types';
19+
import { LoadBundleTask } from './exp-types';
20+
21+
declare module '@firebase/firestore-types' {
22+
interface FirebaseFirestore {
23+
loadBundle(
24+
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string
25+
): LoadBundleTask;
26+
}
27+
}

packages/firestore/register-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ declare module '@firebase/app-types' {
3636
Transaction: typeof types.Transaction;
3737
WriteBatch: typeof types.WriteBatch;
3838
setLogLevel: typeof types.setLogLevel;
39-
loadBundle: typeof types.loadBundle;
40-
namedQuery: typeof types.namedQuery;
4139
};
4240
}
4341
interface FirebaseApp {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import pkg from './package.json';
19+
20+
const util = require('./rollup.shared');
21+
22+
export default [
23+
{
24+
input: 'index.bundle.ts',
25+
output: {
26+
file: pkg.bundle,
27+
format: 'es',
28+
sourcemap: true
29+
},
30+
plugins: util.es2017Plugins('browser', /* mangled= */ true),
31+
external: util.resolveBrowserExterns,
32+
treeshake: {
33+
moduleSideEffects: false
34+
}
35+
},
36+
{
37+
input: pkg.bundle,
38+
output: { file: pkg.bundleModule, format: 'es', sourcemap: true },
39+
plugins: util.es2017ToEs5Plugins(/* mangled= */ true),
40+
external: util.resolveBrowserExterns,
41+
treeshake: {
42+
moduleSideEffects: false
43+
}
44+
}
45+
];

packages/firestore/src/api/database.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ import {
130130
CollectionReference as PublicCollectionReference,
131131
DocumentChange as PublicDocumentChange,
132132
DocumentChangeType as PublicDocumentChangeType,
133+
DocumentData,
133134
DocumentData as PublicDocumentData,
134135
DocumentReference as PublicDocumentReference,
135136
DocumentSnapshot as PublicDocumentSnapshot,
@@ -409,6 +410,22 @@ export class Firestore
409410
)
410411
);
411412
}
413+
414+
loadBundle(
415+
bundleData: ArrayBuffer | ReadableStream<ArrayBuffer> | string
416+
): LoadBundleTask {
417+
throw new FirestoreError(
418+
Code.FAILED_PRECONDITION,
419+
'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"'
420+
);
421+
}
422+
423+
namedQuery(name: string): Promise<PublicQuery<DocumentData> | null> {
424+
throw new FirestoreError(
425+
Code.FAILED_PRECONDITION,
426+
'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"'
427+
);
428+
}
412429
}
413430

414431
export function ensureFirestoreConfigured(

0 commit comments

Comments
 (0)