@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.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.13550089f";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
@@ -1923,7 +1923,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1923
1923
|
if (isNodeSdk()) {
|
|
1924
1924
|
var device = this.nodeAdmin ? 'AdminNode' : 'Node';
|
|
1925
1925
|
// UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
|
|
1926
|
-
|
|
1926
|
+
options = {
|
|
1927
1927
|
headers: {
|
|
1928
1928
|
'User-Agent': "Firebase/" + PROTOCOL_VERSION + "/" + SDK_VERSION + "/" + process.platform + "/" + device,
|
|
1929
1929
|
'X-Firebase-GMPID': this.applicationId || ''
|
|
@@ -1935,10 +1935,10 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1935
1935
|
// Note that this header is just used to bypass appcheck, and the token should still be sent
|
|
1936
1936
|
// through the websocket connection once it is established.
|
|
1937
1937
|
if (this.authToken) {
|
|
1938
|
-
|
|
1938
|
+
options.headers['Authorization'] = "Bearer " + this.authToken;
|
|
1939
1939
|
}
|
|
1940
1940
|
if (this.appCheckToken) {
|
|
1941
|
-
|
|
1941
|
+
options.headers['X-Firebase-AppCheck'] = this.appCheckToken;
|
|
1942
1942
|
}
|
|
1943
1943
|
// Plumb appropriate http_proxy environment variable into faye-websocket if it exists.
|
|
1944
1944
|
var env = process['env'];
|
|
@@ -1946,7 +1946,7 @@ var WebSocketConnection = /** @class */ (function () {
|
|
|
1946
1946
|
? env['HTTPS_PROXY'] || env['https_proxy']
|
|
1947
1947
|
: env['HTTP_PROXY'] || env['http_proxy'];
|
|
1948
1948
|
if (proxy) {
|
|
1949
|
-
|
|
1949
|
+
options['proxy'] = { origin: proxy };
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
1952
|
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
@@ -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_;
|
|
@@ -3296,7 +3296,6 @@ var VisibilityMonitor = /** @class */ (function (_super) {
|
|
|
3296
3296
|
*/
|
|
3297
3297
|
var RECONNECT_MIN_DELAY = 1000;
|
|
3298
3298
|
var RECONNECT_MAX_DELAY_DEFAULT = 60 * 5 * 1000; // 5 minutes in milliseconds (Case: 1858)
|
|
3299
|
-
var GET_CONNECT_TIMEOUT = 3 * 1000;
|
|
3300
3299
|
var RECONNECT_MAX_DELAY_FOR_ADMINS = 30 * 1000; // 30 seconds for admin clients (likely to be a backend server)
|
|
3301
3300
|
var RECONNECT_DELAY_MULTIPLIER = 1.3;
|
|
3302
3301
|
var RECONNECT_DELAY_RESET_TIMEOUT = 30000; // Reset delay back to MIN_DELAY after being connected for 30sec.
|
|
@@ -3375,7 +3374,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3375
3374
|
}
|
|
3376
3375
|
};
|
|
3377
3376
|
PersistentConnection.prototype.get = function (query) {
|
|
3378
|
-
var _this = this;
|
|
3379
3377
|
this.initConnection_();
|
|
3380
3378
|
var deferred = new Deferred();
|
|
3381
3379
|
var request = {
|
|
@@ -3388,9 +3386,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3388
3386
|
onComplete: function (message) {
|
|
3389
3387
|
var payload = message['d'];
|
|
3390
3388
|
if (message['s'] === 'ok') {
|
|
3391
|
-
_this.onDataUpdate_(request['p'], payload,
|
|
3392
|
-
/*isMerge*/ false,
|
|
3393
|
-
/*tag*/ null);
|
|
3394
3389
|
deferred.resolve(payload);
|
|
3395
3390
|
}
|
|
3396
3391
|
else {
|
|
@@ -3401,21 +3396,6 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3401
3396
|
this.outstandingGets_.push(outstandingGet);
|
|
3402
3397
|
this.outstandingGetCount_++;
|
|
3403
3398
|
var index = this.outstandingGets_.length - 1;
|
|
3404
|
-
if (!this.connected_) {
|
|
3405
|
-
setTimeout(function () {
|
|
3406
|
-
var get = _this.outstandingGets_[index];
|
|
3407
|
-
if (get === undefined || outstandingGet !== get) {
|
|
3408
|
-
return;
|
|
3409
|
-
}
|
|
3410
|
-
delete _this.outstandingGets_[index];
|
|
3411
|
-
_this.outstandingGetCount_--;
|
|
3412
|
-
if (_this.outstandingGetCount_ === 0) {
|
|
3413
|
-
_this.outstandingGets_ = [];
|
|
3414
|
-
}
|
|
3415
|
-
_this.log_('get ' + index + ' timed out on connection');
|
|
3416
|
-
deferred.reject(new Error('Client is offline.'));
|
|
3417
|
-
}, GET_CONNECT_TIMEOUT);
|
|
3418
|
-
}
|
|
3419
3399
|
if (this.connected_) {
|
|
3420
3400
|
this.sendGet_(index);
|
|
3421
3401
|
}
|
|
@@ -3430,7 +3410,7 @@ var PersistentConnection = /** @class */ (function (_super) {
|
|
|
3430
3410
|
this.listens.set(pathString, new Map());
|
|
3431
3411
|
}
|
|
3432
3412
|
assert(query._queryParams.isDefault() || !query._queryParams.loadsAllData(), 'listen() called for non-default but complete query');
|
|
3433
|
-
assert(!this.listens.get(pathString).has(queryId),
|
|
3413
|
+
assert(!this.listens.get(pathString).has(queryId), "listen() called twice for same path/queryId.");
|
|
3434
3414
|
var listenSpec = {
|
|
3435
3415
|
onComplete: onComplete,
|
|
3436
3416
|
hashFn: currentHashFn,
|
|
@@ -10175,6 +10155,30 @@ function syncTreeRemoveEventRegistration(syncTree, query, eventRegistration, can
|
|
|
10175
10155
|
}
|
|
10176
10156
|
return cancelEvents;
|
|
10177
10157
|
}
|
|
10158
|
+
/**
|
|
10159
|
+
* This function was added to support non-listener queries,
|
|
10160
|
+
* specifically for use in repoGetValue. It sets up all the same
|
|
10161
|
+
* local cache data-structures (SyncPoint + View) that are
|
|
10162
|
+
* needed for listeners without installing an event registration.
|
|
10163
|
+
* If `query` is not `loadsAllData`, it will also provision a tag for
|
|
10164
|
+
* the query so that query results can be merged into the sync
|
|
10165
|
+
* tree using existing logic for tagged listener queries.
|
|
10166
|
+
*
|
|
10167
|
+
* @param syncTree - Synctree to add the query to.
|
|
10168
|
+
* @param query - Query to register
|
|
10169
|
+
* @returns tag as a string if query is not a default query, null if query is not.
|
|
10170
|
+
*/
|
|
10171
|
+
function syncTreeRegisterQuery(syncTree, query) {
|
|
10172
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete;
|
|
10173
|
+
var view = syncPointGetView(syncPoint, query, writesCache, serverCache, serverCacheComplete);
|
|
10174
|
+
if (!syncPoint.views.has(query._queryIdentifier)) {
|
|
10175
|
+
syncPoint.views.set(query._queryIdentifier, view);
|
|
10176
|
+
}
|
|
10177
|
+
if (!query._queryParams.loadsAllData()) {
|
|
10178
|
+
return syncTreeTagForQuery_(syncTree, query);
|
|
10179
|
+
}
|
|
10180
|
+
return null;
|
|
10181
|
+
}
|
|
10178
10182
|
/**
|
|
10179
10183
|
* Apply new server data for the specified tagged query.
|
|
10180
10184
|
*
|
|
@@ -10215,11 +10219,11 @@ function syncTreeApplyTaggedQueryMerge(syncTree, path, changedChildren, tag) {
|
|
|
10215
10219
|
}
|
|
10216
10220
|
}
|
|
10217
10221
|
/**
|
|
10218
|
-
*
|
|
10219
|
-
*
|
|
10220
|
-
*
|
|
10222
|
+
* Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
|
|
10223
|
+
* Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
|
|
10224
|
+
* without actually listening on a query.
|
|
10221
10225
|
*/
|
|
10222
|
-
function
|
|
10226
|
+
function syncTreeRegisterSyncPoint(query, syncTree) {
|
|
10223
10227
|
var path = query._path;
|
|
10224
10228
|
var serverCache = null;
|
|
10225
10229
|
var foundAncestorDefaultView = false;
|
|
@@ -10268,6 +10272,22 @@ function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
|
10268
10272
|
syncTree.tagToQueryMap.set(tag, queryKey);
|
|
10269
10273
|
}
|
|
10270
10274
|
var writesCache = writeTreeChildWrites(syncTree.pendingWriteTree_, path);
|
|
10275
|
+
return {
|
|
10276
|
+
syncPoint: syncPoint,
|
|
10277
|
+
writesCache: writesCache,
|
|
10278
|
+
serverCache: serverCache,
|
|
10279
|
+
serverCacheComplete: serverCacheComplete,
|
|
10280
|
+
foundAncestorDefaultView: foundAncestorDefaultView,
|
|
10281
|
+
viewAlreadyExists: viewAlreadyExists
|
|
10282
|
+
};
|
|
10283
|
+
}
|
|
10284
|
+
/**
|
|
10285
|
+
* Add an event callback for the specified query.
|
|
10286
|
+
*
|
|
10287
|
+
* @returns Events to raise.
|
|
10288
|
+
*/
|
|
10289
|
+
function syncTreeAddEventRegistration(syncTree, query, eventRegistration) {
|
|
10290
|
+
var _a = syncTreeRegisterSyncPoint(query, syncTree), syncPoint = _a.syncPoint, serverCache = _a.serverCache, writesCache = _a.writesCache, serverCacheComplete = _a.serverCacheComplete, viewAlreadyExists = _a.viewAlreadyExists, foundAncestorDefaultView = _a.foundAncestorDefaultView;
|
|
10271
10291
|
var events = syncPointAddEventRegistration(syncPoint, query, eventRegistration, writesCache, serverCache, serverCacheComplete);
|
|
10272
10292
|
if (!viewAlreadyExists && !foundAncestorDefaultView) {
|
|
10273
10293
|
var view = syncPointViewForQuery(syncPoint, query);
|
|
@@ -11510,9 +11530,25 @@ function repoGetValue(repo, query) {
|
|
|
11510
11530
|
}
|
|
11511
11531
|
return repo.server_.get(query).then(function (payload) {
|
|
11512
11532
|
var node = nodeFromJSON(payload).withIndex(query._queryParams.getIndex());
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11533
|
+
// if this is a filtered query, then overwrite at path
|
|
11534
|
+
if (query._queryParams.loadsAllData()) {
|
|
11535
|
+
syncTreeApplyServerOverwrite(repo.serverSyncTree_, query._path, node);
|
|
11536
|
+
}
|
|
11537
|
+
else {
|
|
11538
|
+
// Simulate `syncTreeAddEventRegistration` without events/listener setup.
|
|
11539
|
+
// We do this (along with the syncTreeRemoveEventRegistration` below) so that
|
|
11540
|
+
// `repoGetValue` results have the same cache effects as initial listener(s)
|
|
11541
|
+
// updates.
|
|
11542
|
+
var tag = syncTreeRegisterQuery(repo.serverSyncTree_, query);
|
|
11543
|
+
syncTreeApplyTaggedQueryOverwrite(repo.serverSyncTree_, query._path, node, tag);
|
|
11544
|
+
// Call `syncTreeRemoveEventRegistration` with a null event registration, since there is none.
|
|
11545
|
+
// Note: The below code essentially unregisters the query and cleans up any views/syncpoints temporarily created above.
|
|
11546
|
+
}
|
|
11547
|
+
var cancels = syncTreeRemoveEventRegistration(repo.serverSyncTree_, query, null);
|
|
11548
|
+
if (cancels.length > 0) {
|
|
11549
|
+
repoLog(repo, 'unexpected cancel events in repoGetValue');
|
|
11550
|
+
}
|
|
11551
|
+
return node;
|
|
11516
11552
|
}, function (err) {
|
|
11517
11553
|
repoLog(repo, 'get for query ' + stringify(query) + ' failed: ' + err);
|
|
11518
11554
|
return Promise.reject(new Error(err));
|