@firebase/database 0.12.8 → 0.13.0-20220505222723

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.
@@ -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, isNodeSdk, deepCopy, base64Encode, isMobileCordova, stringLength, Deferred, safeGet, isAdmin, isValidFormat, isEmpty, isReactNative, assertionError, map, querystring, errorPrefix, getModularInstance, createMockUserToken } from '@firebase/util';
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';
@@ -1246,7 +1246,7 @@ WebSocketConnection.responsesRequiredToBeHealthy = 2;
1246
1246
  WebSocketConnection.healthyTimeout = 30000;
1247
1247
 
1248
1248
  const name = "@firebase/database";
1249
- const version = "0.12.8";
1249
+ const version = "0.13.0-20220505222723";
1250
1250
 
1251
1251
  /**
1252
1252
  * @license
@@ -2141,6 +2141,13 @@ class TransportManager {
2141
2141
  static get ALL_TRANSPORTS() {
2142
2142
  return [BrowserPollConnection, WebSocketConnection];
2143
2143
  }
2144
+ /**
2145
+ * Returns whether transport has been selected to ensure WebSocketConnection or BrowserPollConnection are not called after
2146
+ * TransportManager has already set up transports_
2147
+ */
2148
+ static get IS_TRANSPORT_INITIALIZED() {
2149
+ return this.globalTransportInitialized_;
2150
+ }
2144
2151
  initTransports_(repoInfo) {
2145
2152
  const isWebSocketsAvailable = WebSocketConnection && WebSocketConnection['isAvailable']();
2146
2153
  let isSkipPollConnection = isWebSocketsAvailable && !WebSocketConnection.previouslyFailed();
@@ -2160,6 +2167,7 @@ class TransportManager {
2160
2167
  transports.push(transport);
2161
2168
  }
2162
2169
  }
2170
+ TransportManager.globalTransportInitialized_ = true;
2163
2171
  }
2164
2172
  }
2165
2173
  /**
@@ -2184,7 +2192,9 @@ class TransportManager {
2184
2192
  return null;
2185
2193
  }
2186
2194
  }
2187
- }
2195
+ }
2196
+ // Keeps track of whether the TransportManager has already chosen a transport to use
2197
+ TransportManager.globalTransportInitialized_ = false;
2188
2198
 
2189
2199
  /**
2190
2200
  * @license
@@ -13644,6 +13654,26 @@ class Database {
13644
13654
  }
13645
13655
  }
13646
13656
  }
13657
+ function checkTransportInit() {
13658
+ if (TransportManager.IS_TRANSPORT_INITIALIZED) {
13659
+ warn('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
13660
+ }
13661
+ }
13662
+ /**
13663
+ * Force the use of websockets instead of longPolling.
13664
+ */
13665
+ function forceWebSockets() {
13666
+ checkTransportInit();
13667
+ BrowserPollConnection.forceDisallow();
13668
+ }
13669
+ /**
13670
+ * Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
13671
+ */
13672
+ function forceLongPolling() {
13673
+ checkTransportInit();
13674
+ WebSocketConnection.forceDisallow();
13675
+ BrowserPollConnection.forceAllow();
13676
+ }
13647
13677
  /**
13648
13678
  * Returns the instance of the Realtime Database SDK that is associated
13649
13679
  * with the provided {@link @firebase/app#FirebaseApp}. Initializes a new instance with
@@ -13980,5 +14010,5 @@ const forceRestClient = function (forceRestClient) {
13980
14010
  setWebSocketImpl(Websocket.Client);
13981
14011
  registerDatabase('node');
13982
14012
 
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 };
14013
+ 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
14014
  //# sourceMappingURL=index.node.esm.js.map