@firebase/database 0.13.1 → 0.13.2-canary.b60cf76e1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.esm2017.js +66 -13
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +66 -13
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +66 -13
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +65 -12
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +66 -13
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/core/SyncTree.d.ts +28 -1
- package/dist/node-esm/src/core/util/Path.d.ts +1 -1
- package/dist/node-esm/test/helpers/util.d.ts +6 -0
- package/dist/src/core/SyncTree.d.ts +28 -1
- package/dist/src/core/util/Path.d.ts +1 -1
- package/dist/test/helpers/util.d.ts +6 -0
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Unreleased
|
|
2
2
|
|
|
3
|
+
## 0.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`578dc5836`](https://github.com/firebase/firebase-js-sdk/commit/578dc58365c6c71d8ad01dd8b9dbe829e76de068) [#6273](https://github.com/firebase/firebase-js-sdk/pull/6273) - Fixed issue where `get()` saved results incorrectly for non-default queries.
|
|
8
|
+
|
|
9
|
+
* [`efe2000fc`](https://github.com/firebase/firebase-js-sdk/commit/efe2000fc499e2c85c4e5e0fef6741ff3bad2eb0) [#6363](https://github.com/firebase/firebase-js-sdk/pull/6363) - Extract uuid function into @firebase/util
|
|
10
|
+
|
|
11
|
+
* Updated dependencies [[`efe2000fc`](https://github.com/firebase/firebase-js-sdk/commit/efe2000fc499e2c85c4e5e0fef6741ff3bad2eb0)]:
|
|
12
|
+
- @firebase/util@1.6.2
|
|
13
|
+
- @firebase/component@0.5.16
|
|
14
|
+
|
|
3
15
|
## 0.13.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.esm2017.js
CHANGED
|
@@ -4,7 +4,7 @@ import { stringify, jsonEval, contains, assert, isNodeSdk, base64, stringToByteA
|
|
|
4
4
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
const name = "@firebase/database";
|
|
7
|
-
const version = "0.13.
|
|
7
|
+
const version = "0.13.2-canary.b60cf76e1";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -3010,7 +3010,7 @@ function pathEquals(path, other) {
|
|
|
3010
3010
|
return true;
|
|
3011
3011
|
}
|
|
3012
3012
|
/**
|
|
3013
|
-
* @returns True if this path is a parent (or the same as) other
|
|
3013
|
+
* @returns True if this path is a parent of (or the same as) other
|
|
3014
3014
|
*/
|
|
3015
3015
|
function pathContains(path, other) {
|
|
3016
3016
|
let i = path.pieceNum_;
|
|
@@ -3269,9 +3269,6 @@ class PersistentConnection extends ServerActions {
|
|
|
3269
3269
|
onComplete: (message) => {
|
|
3270
3270
|
const payload = message['d'];
|
|
3271
3271
|
if (message['s'] === 'ok') {
|
|
3272
|
-
this.onDataUpdate_(request['p'], payload,
|
|
3273
|
-
/*isMerge*/ false,
|
|
3274
|
-
/*tag*/ null);
|
|
3275
3272
|
deferred.resolve(payload);
|
|
3276
3273
|
}
|
|
3277
3274
|
else {
|
|
@@ -3311,7 +3308,7 @@ class PersistentConnection extends ServerActions {
|
|
|
3311
3308
|
this.listens.set(pathString, new Map());
|
|
3312
3309
|
}
|
|
3313
3310
|
assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3314
|
-
assert(!this.listens.get(pathString).has(queryId),
|
|
3311
|
+
assert(!this.listens.get(pathString).has(queryId), `listen() called twice for same path/queryId.`);
|
|
3315
3312
|
const listenSpec = {
|
|
3316
3313
|
onComplete,
|
|
3317
3314
|
hashFn: currentHashFn,
|
|
@@ -9861,6 +9858,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
9861
9858
|
}
|
|
9862
9859
|
return cancelEvents;
|
|
9863
9860
|
}
|
|
9861
|
+
/**
|
|
9862
|
+
* This function was added to support non-listener queries,
|
|
9863
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
9864
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
9865
|
+
* needed for listeners without installing an event registration.
|
|
9866
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
9867
|
+
* the query so that query results can be merged into the sync
|
|
9868
|
+
* tree using existing logic for tagged listener queries.
|
|
9869
|
+
*
|
|
9870
|
+
* @param syncTree - Synctree to add the query to.
|
|
9871
|
+
* @param query - Query to register
|
|
9872
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
9873
|
+
*/
|
|
9874
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
9875
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9876
|
+
const view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
9877
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
9878
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
9879
|
+
}
|
|
9880
|
+
if (!query._queryParams.loadsAllData()) {
|
|
9881
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
9882
|
+
}
|
|
9883
|
+
return null;
|
|
9884
|
+
}
|
|
9864
9885
|
/**
|
|
9865
9886
|
* Apply new server data for the specified tagged query.
|
|
9866
9887
|
*
|
|
@@ -9901,11 +9922,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
9901
9922
|
}
|
|
9902
9923
|
}
|
|
9903
9924
|
/**
|
|
9904
|
-
*
|
|
9905
|
-
*
|
|
9906
|
-
*
|
|
9925
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
9926
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
9927
|
+
* without actually listening on a query.
|
|
9907
9928
|
*/
|
|
9908
|
-
function
|
|
9929
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
9909
9930
|
const path = query._path;
|
|
9910
9931
|
let serverCache = null;
|
|
9911
9932
|
let foundAncestorDefaultView = false;
|
|
@@ -9954,6 +9975,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
9954
9975
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
9955
9976
|
}
|
|
9956
9977
|
const writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
9978
|
+
return {
|
|
9979
|
+
syncPoint,
|
|
9980
|
+
writesCache,
|
|
9981
|
+
serverCache,
|
|
9982
|
+
serverCacheComplete,
|
|
9983
|
+
foundAncestorDefaultView,
|
|
9984
|
+
viewAlreadyExists
|
|
9985
|
+
};
|
|
9986
|
+
}
|
|
9987
|
+
/**
|
|
9988
|
+
* Add an event callback for the specified query.
|
|
9989
|
+
*
|
|
9990
|
+
* @returns Events to raise.
|
|
9991
|
+
*/
|
|
9992
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
9993
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete, viewAlreadyExists, foundAncestorDefaultView } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9957
9994
|
let events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
9958
9995
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
9959
9996
|
const view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11184,9 +11221,25 @@ function repoGetValue(repo, query) {
|
|
|
11184
11221
|
}
|
|
11185
11222
|
return repo.server_.get(query).then(payload => {
|
|
11186
11223
|
const node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11224
|
+
// if this is a filtered query, then overwrite at path
|
|
11225
|
+
if (query._queryParams.loadsAllData()) {
|
|
11226
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11227
|
+
}
|
|
11228
|
+
else {
|
|
11229
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11230
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11231
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11232
|
+
// updates.
|
|
11233
|
+
const tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11234
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11235
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11236
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11237
|
+
}
|
|
11238
|
+
const cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11239
|
+
if (cancels.length > 0) {
|
|
11240
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11241
|
+
}
|
|
11242
|
+
return node;
|
|
11190
11243
|
}, err => {
|
|
11191
11244
|
repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
|
|
11192
11245
|
return Promise.reject(new Error(err));
|