@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/dist/index.standalone.js
CHANGED
|
@@ -3129,7 +3129,7 @@ function pathEquals(path, other) {
|
|
|
3129
3129
|
return true;
|
|
3130
3130
|
}
|
|
3131
3131
|
/**
|
|
3132
|
-
* @returns True if this path is a parent (or the same as) other
|
|
3132
|
+
* @returns True if this path is a parent of (or the same as) other
|
|
3133
3133
|
*/
|
|
3134
3134
|
function pathContains(path, other) {
|
|
3135
3135
|
var i = path.pieceNum_;
|
|
@@ -3395,9 +3395,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3395
3395
|
onComplete: function (message) {
|
|
3396
3396
|
var payload = message['d'];
|
|
3397
3397
|
if (message['s'] === 'ok') {
|
|
3398
|
-
_this.onDataUpdate_(request['p'], payload,
|
|
3399
|
-
/*isMerge*/ false,
|
|
3400
|
-
/*tag*/ null);
|
|
3401
3398
|
deferred.resolve(payload);
|
|
3402
3399
|
}
|
|
3403
3400
|
else {
|
|
@@ -3437,7 +3434,7 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3437
3434
|
this.listens.set(pathString, new Map());
|
|
3438
3435
|
}
|
|
3439
3436
|
util.assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3440
|
-
util.assert(!this.listens.get(pathString).has(queryId),
|
|
3437
|
+
util.assert(!this.listens.get(pathString).has(queryId), "listen() called twice for same path/queryId.");
|
|
3441
3438
|
var listenSpec = {
|
|
3442
3439
|
onComplete: onComplete,
|
|
3443
3440
|
hashFn: currentHashFn,
|
|
@@ -10182,6 +10179,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
10182
10179
|
}
|
|
10183
10180
|
return cancelEvents;
|
|
10184
10181
|
}
|
|
10182
|
+
/**
|
|
10183
|
+
* This function was added to support non-listener queries,
|
|
10184
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
10185
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
10186
|
+
* needed for listeners without installing an event registration.
|
|
10187
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
10188
|
+
* the query so that query results can be merged into the sync
|
|
10189
|
+
* tree using existing logic for tagged listener queries.
|
|
10190
|
+
*
|
|
10191
|
+
* @param syncTree - Synctree to add the query to.
|
|
10192
|
+
* @param query - Query to register
|
|
10193
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
10194
|
+
*/
|
|
10195
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
10196
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete;
|
|
10197
|
+
var view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
10198
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
10199
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
10200
|
+
}
|
|
10201
|
+
if (!query._queryParams.loadsAllData()) {
|
|
10202
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
10203
|
+
}
|
|
10204
|
+
return null;
|
|
10205
|
+
}
|
|
10185
10206
|
/**
|
|
10186
10207
|
* Apply new server data for the specified tagged query.
|
|
10187
10208
|
*
|
|
@@ -10222,11 +10243,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
10222
10243
|
}
|
|
10223
10244
|
}
|
|
10224
10245
|
/**
|
|
10225
|
-
*
|
|
10226
|
-
*
|
|
10227
|
-
*
|
|
10246
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
10247
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
10248
|
+
* without actually listening on a query.
|
|
10228
10249
|
*/
|
|
10229
|
-
function
|
|
10250
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
10230
10251
|
var path = query._path;
|
|
10231
10252
|
var serverCache = null;
|
|
10232
10253
|
var foundAncestorDefaultView = false;
|
|
@@ -10275,6 +10296,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
10275
10296
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
10276
10297
|
}
|
|
10277
10298
|
var writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
10299
|
+
return {
|
|
10300
|
+
syncPoint: syncPoint,
|
|
10301
|
+
writesCache: writesCache,
|
|
10302
|
+
serverCache: serverCache,
|
|
10303
|
+
serverCacheComplete: serverCacheComplete,
|
|
10304
|
+
foundAncestorDefaultView: foundAncestorDefaultView,
|
|
10305
|
+
viewAlreadyExists: viewAlreadyExists
|
|
10306
|
+
};
|
|
10307
|
+
}
|
|
10308
|
+
/**
|
|
10309
|
+
* Add an event callback for the specified query.
|
|
10310
|
+
*
|
|
10311
|
+
* @returns Events to raise.
|
|
10312
|
+
*/
|
|
10313
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
10314
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete, viewAlreadyExists = _a.viewAlreadyExists, foundAncestorDefaultView = _a.foundAncestorDefaultView;
|
|
10278
10315
|
var events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
10279
10316
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
10280
10317
|
var view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11517,9 +11554,25 @@ function repoGetValue(repo, query) {
|
|
|
11517
11554
|
}
|
|
11518
11555
|
return repo.server_.get(query).then(function (payload) {
|
|
11519
11556
|
var node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11557
|
+
// if this is a filtered query, then overwrite at path
|
|
11558
|
+
if (query._queryParams.loadsAllData()) {
|
|
11559
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11560
|
+
}
|
|
11561
|
+
else {
|
|
11562
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11563
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11564
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11565
|
+
// updates.
|
|
11566
|
+
var tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11567
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11568
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11569
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11570
|
+
}
|
|
11571
|
+
var cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11572
|
+
if (cancels.length > 0) {
|
|
11573
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11574
|
+
}
|
|
11575
|
+
return node;
|
|
11523
11576
|
}, function (err) {
|
|
11524
11577
|
repoLog(repo, 'get for query ' + util.stringify(query) + ' failed: ' + err);
|
|
11525
11578
|
return Promise.reject(new Error(err));
|