@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
package/dist/index.standalone.js
CHANGED
|
@@ -1037,7 +1037,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1037
1037
|
if (util.isNodeSdk()) {
|
|
1038
1038
|
var device = this.nodeAdmin ? 'AdminNode' : 'Node';
|
|
1039
1039
|
// UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
|
|
1040
|
-
|
|
1040
|
+
options = {
|
|
1041
1041
|
headers: {
|
|
1042
1042
|
'User-Agent': "Firebase/" + PROTOCOL_VERSION + "/" + SDK_VERSION + "/" + process.platform + "/" + device,
|
|
1043
1043
|
'X-Firebase-GMPID': this.applicationId || ''
|
|
@@ -1049,10 +1049,10 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1049
1049
|
// Note that this header is just used to bypass appcheck, and the token should still be sent
|
|
1050
1050
|
// through the websocket connection once it is established.
|
|
1051
1051
|
if (this.authToken) {
|
|
1052
|
-
|
|
1052
|
+
options.headers['Authorization'] = "Bearer " + this.authToken;
|
|
1053
1053
|
}
|
|
1054
1054
|
if (this.appCheckToken) {
|
|
1055
|
-
|
|
1055
|
+
options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
|
|
1056
1056
|
}
|
|
1057
1057
|
// Plumb appropriate http_proxy environment variable into faye-websocket if it exists.
|
|
1058
1058
|
var env = process['env'];
|
|
@@ -1060,7 +1060,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1060
1060
|
? env['HTTPS_PROXY'] || env['https_proxy']
|
|
1061
1061
|
: env['HTTP_PROXY'] || env['http_proxy'];
|
|
1062
1062
|
if (proxy) {
|
|
1063
|
-
|
|
1063
|
+
options['proxy'] = { origin: proxy };
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
1066
|
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
@@ -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_;
|
|
@@ -3303,7 +3303,6 @@ var VisibilityMonitor = /** @class */ (function (_super) {
|
|
|
3303
3303
|
*/
|
|
3304
3304
|
var RECONNECT_MIN_DELAY = 1000;
|
|
3305
3305
|
var RECONNECT_MAX_DELAY_DEFAULT = 60 * 5 * 1000; // 5 minutes in milliseconds (Case: 1858)
|
|
3306
|
-
var GET_CONNECT_TIMEOUT = 3 * 1000;
|
|
3307
3306
|
var RECONNECT_MAX_DELAY_FOR_ADMINS = 30 * 1000; // 30 seconds for admin clients (likely to be a backend server)
|
|
3308
3307
|
var RECONNECT_DELAY_MULTIPLIER = 1.3;
|
|
3309
3308
|
var RECONNECT_DELAY_RESET_TIMEOUT = 30000; // Reset delay back to MIN_DELAY after being connected for 30sec.
|
|
@@ -3382,7 +3381,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3382
3381
|
}
|
|
3383
3382
|
};
|
|
3384
3383
|
PersistentConnection.prototype.get = function (query) {
|
|
3385
|
-
var _this = this;
|
|
3386
3384
|
this.initConnection_();
|
|
3387
3385
|
var deferred = new util.Deferred();
|
|
3388
3386
|
var request = {
|
|
@@ -3395,9 +3393,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3395
3393
|
onComplete: function (message) {
|
|
3396
3394
|
var payload = message['d'];
|
|
3397
3395
|
if (message['s'] === 'ok') {
|
|
3398
|
-
_this.onDataUpdate_(request['p'], payload,
|
|
3399
|
-
/*isMerge*/ false,
|
|
3400
|
-
/*tag*/ null);
|
|
3401
3396
|
deferred.resolve(payload);
|
|
3402
3397
|
}
|
|
3403
3398
|
else {
|
|
@@ -3408,21 +3403,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3408
3403
|
this.outstandingGets_.push(outstandingGet);
|
|
3409
3404
|
this.outstandingGetCount_++;
|
|
3410
3405
|
var index = this.outstandingGets_.length - 1;
|
|
3411
|
-
if (!this.connected_) {
|
|
3412
|
-
setTimeout(function () {
|
|
3413
|
-
var get = _this.outstandingGets_[index];
|
|
3414
|
-
if (get === undefined || outstandingGet !== get) {
|
|
3415
|
-
return;
|
|
3416
|
-
}
|
|
3417
|
-
delete _this.outstandingGets_[index];
|
|
3418
|
-
_this.outstandingGetCount_--;
|
|
3419
|
-
if (_this.outstandingGetCount_ === 0) {
|
|
3420
|
-
_this.outstandingGets_ = [];
|
|
3421
|
-
}
|
|
3422
|
-
_this.log_('get ' + index + ' timed out on connection');
|
|
3423
|
-
deferred.reject(new Error('Client is offline.'));
|
|
3424
|
-
}, GET_CONNECT_TIMEOUT);
|
|
3425
|
-
}
|
|
3426
3406
|
if (this.connected_) {
|
|
3427
3407
|
this.sendGet_(index);
|
|
3428
3408
|
}
|
|
@@ -3437,7 +3417,7 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3437
3417
|
this.listens.set(pathString, new Map());
|
|
3438
3418
|
}
|
|
3439
3419
|
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),
|
|
3420
|
+
util.assert(!this.listens.get(pathString).has(queryId), "listen() called twice for same path/queryId.");
|
|
3441
3421
|
var listenSpec = {
|
|
3442
3422
|
onComplete: onComplete,
|
|
3443
3423
|
hashFn: currentHashFn,
|
|
@@ -10182,6 +10162,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
10182
10162
|
}
|
|
10183
10163
|
return cancelEvents;
|
|
10184
10164
|
}
|
|
10165
|
+
/**
|
|
10166
|
+
* This function was added to support non-listener queries,
|
|
10167
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
10168
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
10169
|
+
* needed for listeners without installing an event registration.
|
|
10170
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
10171
|
+
* the query so that query results can be merged into the sync
|
|
10172
|
+
* tree using existing logic for tagged listener queries.
|
|
10173
|
+
*
|
|
10174
|
+
* @param syncTree - Synctree to add the query to.
|
|
10175
|
+
* @param query - Query to register
|
|
10176
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
10177
|
+
*/
|
|
10178
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
10179
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete;
|
|
10180
|
+
var view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
10181
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
10182
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
10183
|
+
}
|
|
10184
|
+
if (!query._queryParams.loadsAllData()) {
|
|
10185
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
10186
|
+
}
|
|
10187
|
+
return null;
|
|
10188
|
+
}
|
|
10185
10189
|
/**
|
|
10186
10190
|
* Apply new server data for the specified tagged query.
|
|
10187
10191
|
*
|
|
@@ -10222,11 +10226,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
10222
10226
|
}
|
|
10223
10227
|
}
|
|
10224
10228
|
/**
|
|
10225
|
-
*
|
|
10226
|
-
*
|
|
10227
|
-
*
|
|
10229
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
10230
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
10231
|
+
* without actually listening on a query.
|
|
10228
10232
|
*/
|
|
10229
|
-
function
|
|
10233
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
10230
10234
|
var path = query._path;
|
|
10231
10235
|
var serverCache = null;
|
|
10232
10236
|
var foundAncestorDefaultView = false;
|
|
@@ -10275,6 +10279,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
10275
10279
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
10276
10280
|
}
|
|
10277
10281
|
var writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
10282
|
+
return {
|
|
10283
|
+
syncPoint: syncPoint,
|
|
10284
|
+
writesCache: writesCache,
|
|
10285
|
+
serverCache: serverCache,
|
|
10286
|
+
serverCacheComplete: serverCacheComplete,
|
|
10287
|
+
foundAncestorDefaultView: foundAncestorDefaultView,
|
|
10288
|
+
viewAlreadyExists: viewAlreadyExists
|
|
10289
|
+
};
|
|
10290
|
+
}
|
|
10291
|
+
/**
|
|
10292
|
+
* Add an event callback for the specified query.
|
|
10293
|
+
*
|
|
10294
|
+
* @returns Events to raise.
|
|
10295
|
+
*/
|
|
10296
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
10297
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete, viewAlreadyExists = _a.viewAlreadyExists, foundAncestorDefaultView = _a.foundAncestorDefaultView;
|
|
10278
10298
|
var events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
10279
10299
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
10280
10300
|
var view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11517,9 +11537,25 @@ function repoGetValue(repo, query) {
|
|
|
11517
11537
|
}
|
|
11518
11538
|
return repo.server_.get(query).then(function (payload) {
|
|
11519
11539
|
var node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11540
|
+
// if this is a filtered query, then overwrite at path
|
|
11541
|
+
if (query._queryParams.loadsAllData()) {
|
|
11542
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11543
|
+
}
|
|
11544
|
+
else {
|
|
11545
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11546
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11547
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11548
|
+
// updates.
|
|
11549
|
+
var tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11550
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11551
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11552
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11553
|
+
}
|
|
11554
|
+
var cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11555
|
+
if (cancels.length > 0) {
|
|
11556
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11557
|
+
}
|
|
11558
|
+
return node;
|
|
11523
11559
|
}, function (err) {
|
|
11524
11560
|
repoLog(repo, 'get for query ' + util.stringify(query) + ' failed: ' + err);
|
|
11525
11561
|
return Promise.reject(new Error(err));
|