@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
package/dist/index.esm5.js
CHANGED
|
@@ -5,7 +5,7 @@ import { __spreadArray, __read, __values, __extends, __awaiter, __generator, __a
|
|
|
5
5
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
6
6
|
|
|
7
7
|
var name = "@firebase/database";
|
|
8
|
-
var version = "0.13.
|
|
8
|
+
var version = "0.13.2-canary.d3336a9cd";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
@@ -3122,7 +3122,7 @@ function pathEquals(path, other) {
|
|
|
3122
3122
|
return true;
|
|
3123
3123
|
}
|
|
3124
3124
|
/**
|
|
3125
|
-
* @returns True if this path is a parent (or the same as) other
|
|
3125
|
+
* @returns True if this path is a parent of (or the same as) other
|
|
3126
3126
|
*/
|
|
3127
3127
|
function pathContains(path, other) {
|
|
3128
3128
|
var i = path.pieceNum_;
|
|
@@ -3388,9 +3388,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3388
3388
|
onComplete: function (message) {
|
|
3389
3389
|
var payload = message['d'];
|
|
3390
3390
|
if (message['s'] === 'ok') {
|
|
3391
|
-
_this.onDataUpdate_(request['p'], payload,
|
|
3392
|
-
/*isMerge*/ false,
|
|
3393
|
-
/*tag*/ null);
|
|
3394
3391
|
deferred.resolve(payload);
|
|
3395
3392
|
}
|
|
3396
3393
|
else {
|
|
@@ -3430,7 +3427,7 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3430
3427
|
this.listens.set(pathString, new Map());
|
|
3431
3428
|
}
|
|
3432
3429
|
assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3433
|
-
assert(!this.listens.get(pathString).has(queryId),
|
|
3430
|
+
assert(!this.listens.get(pathString).has(queryId), "listen() called twice for same path/queryId.");
|
|
3434
3431
|
var listenSpec = {
|
|
3435
3432
|
onComplete: onComplete,
|
|
3436
3433
|
hashFn: currentHashFn,
|
|
@@ -10175,6 +10172,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
10175
10172
|
}
|
|
10176
10173
|
return cancelEvents;
|
|
10177
10174
|
}
|
|
10175
|
+
/**
|
|
10176
|
+
* This function was added to support non-listener queries,
|
|
10177
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
10178
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
10179
|
+
* needed for listeners without installing an event registration.
|
|
10180
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
10181
|
+
* the query so that query results can be merged into the sync
|
|
10182
|
+
* tree using existing logic for tagged listener queries.
|
|
10183
|
+
*
|
|
10184
|
+
* @param syncTree - Synctree to add the query to.
|
|
10185
|
+
* @param query - Query to register
|
|
10186
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
10187
|
+
*/
|
|
10188
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
10189
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete;
|
|
10190
|
+
var view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
10191
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
10192
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
10193
|
+
}
|
|
10194
|
+
if (!query._queryParams.loadsAllData()) {
|
|
10195
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
10196
|
+
}
|
|
10197
|
+
return null;
|
|
10198
|
+
}
|
|
10178
10199
|
/**
|
|
10179
10200
|
* Apply new server data for the specified tagged query.
|
|
10180
10201
|
*
|
|
@@ -10215,11 +10236,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
10215
10236
|
}
|
|
10216
10237
|
}
|
|
10217
10238
|
/**
|
|
10218
|
-
*
|
|
10219
|
-
*
|
|
10220
|
-
*
|
|
10239
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
10240
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
10241
|
+
* without actually listening on a query.
|
|
10221
10242
|
*/
|
|
10222
|
-
function
|
|
10243
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
10223
10244
|
var path = query._path;
|
|
10224
10245
|
var serverCache = null;
|
|
10225
10246
|
var foundAncestorDefaultView = false;
|
|
@@ -10268,6 +10289,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
10268
10289
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
10269
10290
|
}
|
|
10270
10291
|
var writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
10292
|
+
return {
|
|
10293
|
+
syncPoint: syncPoint,
|
|
10294
|
+
writesCache: writesCache,
|
|
10295
|
+
serverCache: serverCache,
|
|
10296
|
+
serverCacheComplete: serverCacheComplete,
|
|
10297
|
+
foundAncestorDefaultView: foundAncestorDefaultView,
|
|
10298
|
+
viewAlreadyExists: viewAlreadyExists
|
|
10299
|
+
};
|
|
10300
|
+
}
|
|
10301
|
+
/**
|
|
10302
|
+
* Add an event callback for the specified query.
|
|
10303
|
+
*
|
|
10304
|
+
* @returns Events to raise.
|
|
10305
|
+
*/
|
|
10306
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
10307
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete, viewAlreadyExists = _a.viewAlreadyExists, foundAncestorDefaultView = _a.foundAncestorDefaultView;
|
|
10271
10308
|
var events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
10272
10309
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
10273
10310
|
var view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11510,9 +11547,25 @@ function repoGetValue(repo, query) {
|
|
|
11510
11547
|
}
|
|
11511
11548
|
return repo.server_.get(query).then(function (payload) {
|
|
11512
11549
|
var node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11550
|
+
// if this is a filtered query, then overwrite at path
|
|
11551
|
+
if (query._queryParams.loadsAllData()) {
|
|
11552
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11553
|
+
}
|
|
11554
|
+
else {
|
|
11555
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11556
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11557
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11558
|
+
// updates.
|
|
11559
|
+
var tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11560
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11561
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11562
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11563
|
+
}
|
|
11564
|
+
var cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11565
|
+
if (cancels.length > 0) {
|
|
11566
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11567
|
+
}
|
|
11568
|
+
return node;
|
|
11516
11569
|
}, function (err) {
|
|
11517
11570
|
repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
|
|
11518
11571
|
return Promise.reject(new Error(err));
|