@firebase/database 0.12.8 → 0.13.0-canary.61f7112e0
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 +14 -0
- package/dist/index.esm2017.js +41 -16
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +48 -19
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +48 -17
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +47 -16
- package/dist/index.standalone.js.map +1 -1
- package/dist/internal.d.ts +10 -0
- package/dist/node-esm/index.node.esm.js +41 -16
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/Database.d.ts +8 -0
- package/dist/node-esm/src/api.standalone.d.ts +1 -1
- package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +2 -2
- package/dist/node-esm/src/realtime/TransportManager.d.ts +6 -0
- package/dist/node-esm/test/transport.test.d.ts +17 -0
- package/dist/node-esm/test/websocketconnection.test.d.ts +17 -0
- package/dist/private.d.ts +10 -0
- package/dist/public.d.ts +8 -0
- package/dist/src/api/Database.d.ts +8 -0
- package/dist/src/api.standalone.d.ts +1 -1
- package/dist/src/realtime/BrowserPollConnection.d.ts +2 -2
- package/dist/src/realtime/TransportManager.d.ts +6 -0
- package/dist/test/transport.test.d.ts +17 -0
- package/dist/test/websocketconnection.test.d.ts +17 -0
- package/package.json +7 -7
package/dist/internal.d.ts
CHANGED
|
@@ -552,6 +552,16 @@ declare interface EventRegistration {
|
|
|
552
552
|
*/
|
|
553
553
|
export declare type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
|
|
554
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
557
|
+
*/
|
|
558
|
+
export declare function forceLongPolling(): void;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Force the use of websockets instead of longPolling.
|
|
562
|
+
*/
|
|
563
|
+
export declare function forceWebSockets(): void;
|
|
564
|
+
|
|
555
565
|
/**
|
|
556
566
|
* Gets the most up-to-date result for this query.
|
|
557
567
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Websocket from 'faye-websocket';
|
|
2
|
-
import { stringify, jsonEval, contains, assert, base64, stringToByteArray, Sha1,
|
|
2
|
+
import { stringify, jsonEval, contains, assert, isNodeSdk, base64, stringToByteArray, Sha1, deepCopy, base64Encode, isMobileCordova, stringLength, Deferred, safeGet, isAdmin, isValidFormat, isEmpty, isReactNative, assertionError, map, querystring, errorPrefix, getModularInstance, createMockUserToken } from '@firebase/util';
|
|
3
3
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
4
|
import { getApp, _getProvider, SDK_VERSION as SDK_VERSION$1, _registerComponent, registerVersion } from '@firebase/app';
|
|
5
5
|
import { Component } from '@firebase/component';
|
|
@@ -944,7 +944,7 @@ class WebSocketConnection {
|
|
|
944
944
|
this.bytesReceived = 0;
|
|
945
945
|
this.log_ = logWrapper(this.connId);
|
|
946
946
|
this.stats_ = statsManagerGetCollection(repoInfo);
|
|
947
|
-
this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken);
|
|
947
|
+
this.connURL = WebSocketConnection.connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId);
|
|
948
948
|
this.nodeAdmin = repoInfo.nodeAdmin;
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
@@ -954,7 +954,7 @@ class WebSocketConnection {
|
|
|
954
954
|
* @param lastSessionId - Optional lastSessionId if there was a previous connection
|
|
955
955
|
* @returns connection url
|
|
956
956
|
*/
|
|
957
|
-
static connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken) {
|
|
957
|
+
static connectionURL_(repoInfo, transportSessionId, lastSessionId, appCheckToken, applicationId) {
|
|
958
958
|
const urlParams = {};
|
|
959
959
|
urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
|
|
960
960
|
if (!isNodeSdk() &&
|
|
@@ -972,6 +972,9 @@ class WebSocketConnection {
|
|
|
972
972
|
if (appCheckToken) {
|
|
973
973
|
urlParams[APP_CHECK_TOKEN_PARAM] = appCheckToken;
|
|
974
974
|
}
|
|
975
|
+
if (applicationId) {
|
|
976
|
+
urlParams[APPLICATION_ID_PARAM] = applicationId;
|
|
977
|
+
}
|
|
975
978
|
return repoInfoConnectionURL(repoInfo, WEBSOCKET, urlParams);
|
|
976
979
|
}
|
|
977
980
|
/**
|
|
@@ -986,6 +989,7 @@ class WebSocketConnection {
|
|
|
986
989
|
// Assume failure until proven otherwise.
|
|
987
990
|
PersistentStorage.set('previous_websocket_failure', true);
|
|
988
991
|
try {
|
|
992
|
+
let options;
|
|
989
993
|
if (isNodeSdk()) {
|
|
990
994
|
const device = this.nodeAdmin ? 'AdminNode' : 'Node';
|
|
991
995
|
// UA Format: Firebase/<wire_protocol>/<sdk_version>/<platform>/<device>
|
|
@@ -1014,17 +1018,8 @@ class WebSocketConnection {
|
|
|
1014
1018
|
if (proxy) {
|
|
1015
1019
|
options['proxy'] = { origin: proxy };
|
|
1016
1020
|
}
|
|
1017
|
-
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
const options = {
|
|
1021
|
-
headers: {
|
|
1022
|
-
'X-Firebase-GMPID': this.applicationId || '',
|
|
1023
|
-
'X-Firebase-AppCheck': this.appCheckToken || ''
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1027
1021
|
}
|
|
1022
|
+
this.mySock = new WebSocketImpl(this.connURL, [], options);
|
|
1028
1023
|
}
|
|
1029
1024
|
catch (e) {
|
|
1030
1025
|
this.log_('Error instantiating WebSocket.');
|
|
@@ -1246,7 +1241,7 @@ WebSocketConnection.responsesRequiredToBeHealthy = 2;
|
|
|
1246
1241
|
WebSocketConnection.healthyTimeout = 30000;
|
|
1247
1242
|
|
|
1248
1243
|
const name = "@firebase/database";
|
|
1249
|
-
const version = "0.
|
|
1244
|
+
const version = "0.13.0-canary.61f7112e0";
|
|
1250
1245
|
|
|
1251
1246
|
/**
|
|
1252
1247
|
* @license
|
|
@@ -2141,6 +2136,13 @@ class TransportManager {
|
|
|
2141
2136
|
static get ALL_TRANSPORTS() {
|
|
2142
2137
|
return [BrowserPollConnection, WebSocketConnection];
|
|
2143
2138
|
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Returns whether transport has been selected to ensure WebSocketConnection or BrowserPollConnection are not called after
|
|
2141
|
+
* TransportManager has already set up transports_
|
|
2142
|
+
*/
|
|
2143
|
+
static get IS_TRANSPORT_INITIALIZED() {
|
|
2144
|
+
return this.globalTransportInitialized_;
|
|
2145
|
+
}
|
|
2144
2146
|
initTransports_(repoInfo) {
|
|
2145
2147
|
const isWebSocketsAvailable = WebSocketConnection && WebSocketConnection['isAvailable']();
|
|
2146
2148
|
let isSkipPollConnection = isWebSocketsAvailable && !WebSocketConnection.previouslyFailed();
|
|
@@ -2160,6 +2162,7 @@ class TransportManager {
|
|
|
2160
2162
|
transports.push(transport);
|
|
2161
2163
|
}
|
|
2162
2164
|
}
|
|
2165
|
+
TransportManager.globalTransportInitialized_ = true;
|
|
2163
2166
|
}
|
|
2164
2167
|
}
|
|
2165
2168
|
/**
|
|
@@ -2184,7 +2187,9 @@ class TransportManager {
|
|
|
2184
2187
|
return null;
|
|
2185
2188
|
}
|
|
2186
2189
|
}
|
|
2187
|
-
}
|
|
2190
|
+
}
|
|
2191
|
+
// Keeps track of whether the TransportManager has already chosen a transport to use
|
|
2192
|
+
TransportManager.globalTransportInitialized_ = false;
|
|
2188
2193
|
|
|
2189
2194
|
/**
|
|
2190
2195
|
* @license
|
|
@@ -13644,6 +13649,26 @@ class Database {
|
|
|
13644
13649
|
}
|
|
13645
13650
|
}
|
|
13646
13651
|
}
|
|
13652
|
+
function checkTransportInit() {
|
|
13653
|
+
if (TransportManager.IS_TRANSPORT_INITIALIZED) {
|
|
13654
|
+
warn('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
|
|
13655
|
+
}
|
|
13656
|
+
}
|
|
13657
|
+
/**
|
|
13658
|
+
* Force the use of websockets instead of longPolling.
|
|
13659
|
+
*/
|
|
13660
|
+
function forceWebSockets() {
|
|
13661
|
+
checkTransportInit();
|
|
13662
|
+
BrowserPollConnection.forceDisallow();
|
|
13663
|
+
}
|
|
13664
|
+
/**
|
|
13665
|
+
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
13666
|
+
*/
|
|
13667
|
+
function forceLongPolling() {
|
|
13668
|
+
checkTransportInit();
|
|
13669
|
+
WebSocketConnection.forceDisallow();
|
|
13670
|
+
BrowserPollConnection.forceAllow();
|
|
13671
|
+
}
|
|
13647
13672
|
/**
|
|
13648
13673
|
* Returns the instance of the Realtime Database SDK that is associated
|
|
13649
13674
|
* with the provided {@link @firebase/app#FirebaseApp}. Initializes a new instance with
|
|
@@ -13980,5 +14005,5 @@ const forceRestClient = function (forceRestClient) {
|
|
|
13980
14005
|
setWebSocketImpl(Websocket.Client);
|
|
13981
14006
|
registerDatabase('node');
|
|
13982
14007
|
|
|
13983
|
-
export { DataSnapshot, Database, OnDisconnect, QueryConstraint, TransactionResult, QueryImpl as _QueryImpl, QueryParams as _QueryParams, ReferenceImpl as _ReferenceImpl, forceRestClient as _TEST_ACCESS_forceRestClient, hijackHash as _TEST_ACCESS_hijackHash, repoManagerDatabaseFromApp as _repoManagerDatabaseFromApp, setSDKVersion as _setSDKVersion, validatePathString as _validatePathString, validateWritablePath as _validateWritablePath, child, connectDatabaseEmulator, enableLogging, endAt, endBefore, equalTo, get, getDatabase, goOffline, goOnline, increment, limitToFirst, limitToLast, off, onChildAdded, onChildChanged, onChildMoved, onChildRemoved, onDisconnect, onValue, orderByChild, orderByKey, orderByPriority, orderByValue, push, query, ref, refFromURL, remove, runTransaction, serverTimestamp, set, setPriority, setWithPriority, startAfter, startAt, update };
|
|
14008
|
+
export { DataSnapshot, Database, OnDisconnect, QueryConstraint, TransactionResult, QueryImpl as _QueryImpl, QueryParams as _QueryParams, ReferenceImpl as _ReferenceImpl, forceRestClient as _TEST_ACCESS_forceRestClient, hijackHash as _TEST_ACCESS_hijackHash, repoManagerDatabaseFromApp as _repoManagerDatabaseFromApp, setSDKVersion as _setSDKVersion, validatePathString as _validatePathString, validateWritablePath as _validateWritablePath, child, connectDatabaseEmulator, enableLogging, endAt, endBefore, equalTo, forceLongPolling, forceWebSockets, get, getDatabase, goOffline, goOnline, increment, limitToFirst, limitToLast, off, onChildAdded, onChildChanged, onChildMoved, onChildRemoved, onDisconnect, onValue, orderByChild, orderByKey, orderByPriority, orderByValue, push, query, ref, refFromURL, remove, runTransaction, serverTimestamp, set, setPriority, setWithPriority, startAfter, startAt, update };
|
|
13984
14009
|
//# sourceMappingURL=index.node.esm.js.map
|