@firebase/database 0.13.1 → 0.13.2-canary.d3336a9cd
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
|
@@ -1241,7 +1241,7 @@ WebSocketConnection.responsesRequiredToBeHealthy = 2;
|
|
|
1241
1241
|
WebSocketConnection.healthyTimeout = 30000;
|
|
1242
1242
|
|
|
1243
1243
|
const name = "@firebase/database";
|
|
1244
|
-
const version = "0.13.
|
|
1244
|
+
const version = "0.13.2-canary.d3336a9cd";
|
|
1245
1245
|
|
|
1246
1246
|
/**
|
|
1247
1247
|
* @license
|
|
@@ -3014,7 +3014,7 @@ function pathEquals(path, other) {
|
|
|
3014
3014
|
return true;
|
|
3015
3015
|
}
|
|
3016
3016
|
/**
|
|
3017
|
-
* @returns True if this path is a parent (or the same as) other
|
|
3017
|
+
* @returns True if this path is a parent of (or the same as) other
|
|
3018
3018
|
*/
|
|
3019
3019
|
function pathContains(path, other) {
|
|
3020
3020
|
let i = path.pieceNum_;
|
|
@@ -3273,9 +3273,6 @@ class PersistentConnection extends ServerActions {
|
|
|
3273
3273
|
onComplete: (message) => {
|
|
3274
3274
|
const payload = message['d'];
|
|
3275
3275
|
if (message['s'] === 'ok') {
|
|
3276
|
-
this.onDataUpdate_(request['p'], payload,
|
|
3277
|
-
/*isMerge*/ false,
|
|
3278
|
-
/*tag*/ null);
|
|
3279
3276
|
deferred.resolve(payload);
|
|
3280
3277
|
}
|
|
3281
3278
|
else {
|
|
@@ -3315,7 +3312,7 @@ class PersistentConnection extends ServerActions {
|
|
|
3315
3312
|
this.listens.set(pathString, new Map());
|
|
3316
3313
|
}
|
|
3317
3314
|
assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3318
|
-
assert(!this.listens.get(pathString).has(queryId),
|
|
3315
|
+
assert(!this.listens.get(pathString).has(queryId), `listen() called twice for same path/queryId.`);
|
|
3319
3316
|
const listenSpec = {
|
|
3320
3317
|
onComplete,
|
|
3321
3318
|
hashFn: currentHashFn,
|
|
@@ -9865,6 +9862,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
9865
9862
|
}
|
|
9866
9863
|
return cancelEvents;
|
|
9867
9864
|
}
|
|
9865
|
+
/**
|
|
9866
|
+
* This function was added to support non-listener queries,
|
|
9867
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
9868
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
9869
|
+
* needed for listeners without installing an event registration.
|
|
9870
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
9871
|
+
* the query so that query results can be merged into the sync
|
|
9872
|
+
* tree using existing logic for tagged listener queries.
|
|
9873
|
+
*
|
|
9874
|
+
* @param syncTree - Synctree to add the query to.
|
|
9875
|
+
* @param query - Query to register
|
|
9876
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
9877
|
+
*/
|
|
9878
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
9879
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9880
|
+
const view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
9881
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
9882
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
9883
|
+
}
|
|
9884
|
+
if (!query._queryParams.loadsAllData()) {
|
|
9885
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
9886
|
+
}
|
|
9887
|
+
return null;
|
|
9888
|
+
}
|
|
9868
9889
|
/**
|
|
9869
9890
|
* Apply new server data for the specified tagged query.
|
|
9870
9891
|
*
|
|
@@ -9905,11 +9926,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
9905
9926
|
}
|
|
9906
9927
|
}
|
|
9907
9928
|
/**
|
|
9908
|
-
*
|
|
9909
|
-
*
|
|
9910
|
-
*
|
|
9929
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
9930
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
9931
|
+
* without actually listening on a query.
|
|
9911
9932
|
*/
|
|
9912
|
-
function
|
|
9933
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
9913
9934
|
const path = query._path;
|
|
9914
9935
|
let serverCache = null;
|
|
9915
9936
|
let foundAncestorDefaultView = false;
|
|
@@ -9958,6 +9979,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
9958
9979
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
9959
9980
|
}
|
|
9960
9981
|
const writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
9982
|
+
return {
|
|
9983
|
+
syncPoint,
|
|
9984
|
+
writesCache,
|
|
9985
|
+
serverCache,
|
|
9986
|
+
serverCacheComplete,
|
|
9987
|
+
foundAncestorDefaultView,
|
|
9988
|
+
viewAlreadyExists
|
|
9989
|
+
};
|
|
9990
|
+
}
|
|
9991
|
+
/**
|
|
9992
|
+
* Add an event callback for the specified query.
|
|
9993
|
+
*
|
|
9994
|
+
* @returns Events to raise.
|
|
9995
|
+
*/
|
|
9996
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
9997
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete, viewAlreadyExists, foundAncestorDefaultView } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9961
9998
|
let events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
9962
9999
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
9963
10000
|
const view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11188,9 +11225,25 @@ function repoGetValue(repo, query) {
|
|
|
11188
11225
|
}
|
|
11189
11226
|
return repo.server_.get(query).then(payload => {
|
|
11190
11227
|
const node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11228
|
+
// if this is a filtered query, then overwrite at path
|
|
11229
|
+
if (query._queryParams.loadsAllData()) {
|
|
11230
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11231
|
+
}
|
|
11232
|
+
else {
|
|
11233
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11234
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11235
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11236
|
+
// updates.
|
|
11237
|
+
const tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11238
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11239
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11240
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11241
|
+
}
|
|
11242
|
+
const cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11243
|
+
if (cancels.length > 0) {
|
|
11244
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11245
|
+
}
|
|
11246
|
+
return node;
|
|
11194
11247
|
}, err => {
|
|
11195
11248
|
repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
|
|
11196
11249
|
return Promise.reject(new Error(err));
|