@firebase/database 0.13.1 → 0.13.2-canary.13550089f
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 +67 -30
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +70 -34
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +70 -34
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +69 -33
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +67 -30
- 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 +6 -6
|
@@ -993,7 +993,7 @@ class WebSocketConnection {
|
|
|
993
993
|
if (isNodeSdk()) {
|
|
994
994
|
const device = this.nodeAdmin ? 'AdminNode' : 'Node';
|
|
995
995
|
// UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
|
|
996
|
-
|
|
996
|
+
options = {
|
|
997
997
|
headers: {
|
|
998
998
|
'User-Agent': `Firebase/${PROTOCOL_VERSION}/${SDK_VERSION}/${process.platform}/${device}`,
|
|
999
999
|
'X-Firebase-GMPID': this.applicationId || ''
|
|
@@ -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.13550089f";
|
|
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_;
|
|
@@ -3184,7 +3184,6 @@ class VisibilityMonitor extends EventEmitter {
|
|
|
3184
3184
|
*/
|
|
3185
3185
|
const RECONNECT_MIN_DELAY = 1000;
|
|
3186
3186
|
const RECONNECT_MAX_DELAY_DEFAULT = 60 * 5 * 1000; // 5 minutes in milliseconds (Case: 1858)
|
|
3187
|
-
const GET_CONNECT_TIMEOUT = 3 * 1000;
|
|
3188
3187
|
const RECONNECT_MAX_DELAY_FOR_ADMINS = 30 * 1000; // 30 seconds for admin clients (likely to be a backend server)
|
|
3189
3188
|
const RECONNECT_DELAY_MULTIPLIER = 1.3;
|
|
3190
3189
|
const RECONNECT_DELAY_RESET_TIMEOUT = 30000; // Reset delay back to MIN_DELAY after being connected for 30sec.
|
|
@@ -3273,9 +3272,6 @@ class PersistentConnection extends ServerActions {
|
|
|
3273
3272
|
onComplete: (message) => {
|
|
3274
3273
|
const payload = message['d'];
|
|
3275
3274
|
if (message['s'] === 'ok') {
|
|
3276
|
-
this.onDataUpdate_(request['p'], payload,
|
|
3277
|
-
/*isMerge*/ false,
|
|
3278
|
-
/*tag*/ null);
|
|
3279
3275
|
deferred.resolve(payload);
|
|
3280
3276
|
}
|
|
3281
3277
|
else {
|
|
@@ -3286,21 +3282,6 @@ class PersistentConnection extends ServerActions {
|
|
|
3286
3282
|
this.outstandingGets_.push(outstandingGet);
|
|
3287
3283
|
this.outstandingGetCount_++;
|
|
3288
3284
|
const index = this.outstandingGets_.length - 1;
|
|
3289
|
-
if (!this.connected_) {
|
|
3290
|
-
setTimeout(() => {
|
|
3291
|
-
const get = this.outstandingGets_[index];
|
|
3292
|
-
if (get === undefined || outstandingGet !== get) {
|
|
3293
|
-
return;
|
|
3294
|
-
}
|
|
3295
|
-
delete this.outstandingGets_[index];
|
|
3296
|
-
this.outstandingGetCount_--;
|
|
3297
|
-
if (this.outstandingGetCount_ === 0) {
|
|
3298
|
-
this.outstandingGets_ = [];
|
|
3299
|
-
}
|
|
3300
|
-
this.log_('get ' + index + ' timed out on connection');
|
|
3301
|
-
deferred.reject(new Error('Client is offline.'));
|
|
3302
|
-
}, GET_CONNECT_TIMEOUT);
|
|
3303
|
-
}
|
|
3304
3285
|
if (this.connected_) {
|
|
3305
3286
|
this.sendGet_(index);
|
|
3306
3287
|
}
|
|
@@ -3315,7 +3296,7 @@ class PersistentConnection extends ServerActions {
|
|
|
3315
3296
|
this.listens.set(pathString, new Map());
|
|
3316
3297
|
}
|
|
3317
3298
|
assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3318
|
-
assert(!this.listens.get(pathString).has(queryId),
|
|
3299
|
+
assert(!this.listens.get(pathString).has(queryId), `listen() called twice for same path/queryId.`);
|
|
3319
3300
|
const listenSpec = {
|
|
3320
3301
|
onComplete,
|
|
3321
3302
|
hashFn: currentHashFn,
|
|
@@ -9865,6 +9846,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
9865
9846
|
}
|
|
9866
9847
|
return cancelEvents;
|
|
9867
9848
|
}
|
|
9849
|
+
/**
|
|
9850
|
+
* This function was added to support non-listener queries,
|
|
9851
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
9852
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
9853
|
+
* needed for listeners without installing an event registration.
|
|
9854
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
9855
|
+
* the query so that query results can be merged into the sync
|
|
9856
|
+
* tree using existing logic for tagged listener queries.
|
|
9857
|
+
*
|
|
9858
|
+
* @param syncTree - Synctree to add the query to.
|
|
9859
|
+
* @param query - Query to register
|
|
9860
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
9861
|
+
*/
|
|
9862
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
9863
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9864
|
+
const view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
9865
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
9866
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
9867
|
+
}
|
|
9868
|
+
if (!query._queryParams.loadsAllData()) {
|
|
9869
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
9870
|
+
}
|
|
9871
|
+
return null;
|
|
9872
|
+
}
|
|
9868
9873
|
/**
|
|
9869
9874
|
* Apply new server data for the specified tagged query.
|
|
9870
9875
|
*
|
|
@@ -9905,11 +9910,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
9905
9910
|
}
|
|
9906
9911
|
}
|
|
9907
9912
|
/**
|
|
9908
|
-
*
|
|
9909
|
-
*
|
|
9910
|
-
*
|
|
9913
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
9914
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
9915
|
+
* without actually listening on a query.
|
|
9911
9916
|
*/
|
|
9912
|
-
function
|
|
9917
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
9913
9918
|
const path = query._path;
|
|
9914
9919
|
let serverCache = null;
|
|
9915
9920
|
let foundAncestorDefaultView = false;
|
|
@@ -9958,6 +9963,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
9958
9963
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
9959
9964
|
}
|
|
9960
9965
|
const writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
9966
|
+
return {
|
|
9967
|
+
syncPoint,
|
|
9968
|
+
writesCache,
|
|
9969
|
+
serverCache,
|
|
9970
|
+
serverCacheComplete,
|
|
9971
|
+
foundAncestorDefaultView,
|
|
9972
|
+
viewAlreadyExists
|
|
9973
|
+
};
|
|
9974
|
+
}
|
|
9975
|
+
/**
|
|
9976
|
+
* Add an event callback for the specified query.
|
|
9977
|
+
*
|
|
9978
|
+
* @returns Events to raise.
|
|
9979
|
+
*/
|
|
9980
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
9981
|
+
const { syncPoint, serverCache, writesCache, serverCacheComplete, viewAlreadyExists, foundAncestorDefaultView } = syncTreeRegisterSyncPoint(query, syncTree);
|
|
9961
9982
|
let events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
9962
9983
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
9963
9984
|
const view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11188,9 +11209,25 @@ function repoGetValue(repo, query) {
|
|
|
11188
11209
|
}
|
|
11189
11210
|
return repo.server_.get(query).then(payload => {
|
|
11190
11211
|
const node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11212
|
+
// if this is a filtered query, then overwrite at path
|
|
11213
|
+
if (query._queryParams.loadsAllData()) {
|
|
11214
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11215
|
+
}
|
|
11216
|
+
else {
|
|
11217
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11218
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11219
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11220
|
+
// updates.
|
|
11221
|
+
const tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11222
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11223
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11224
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11225
|
+
}
|
|
11226
|
+
const cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11227
|
+
if (cancels.length > 0) {
|
|
11228
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11229
|
+
}
|
|
11230
|
+
return node;
|
|
11194
11231
|
}, err => {
|
|
11195
11232
|
repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
|
|
11196
11233
|
return Promise.reject(new Error(err));
|