@firebase/database 0.14.0 → 0.14.1-canary.68369740a

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.
@@ -756,16 +756,18 @@ var RepoInfo = /** @class */ (function () {
756
756
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
757
757
  * @param persistenceKey - Override the default session persistence storage key
758
758
  */
759
- function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams) {
759
+ function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams, isUsingEmulator) {
760
760
  if (nodeAdmin === void 0) { nodeAdmin = false; }
761
761
  if (persistenceKey === void 0) { persistenceKey = ''; }
762
762
  if (includeNamespaceInQueryParams === void 0) { includeNamespaceInQueryParams = false; }
763
+ if (isUsingEmulator === void 0) { isUsingEmulator = false; }
763
764
  this.secure = secure;
764
765
  this.namespace = namespace;
765
766
  this.webSocketOnly = webSocketOnly;
766
767
  this.nodeAdmin = nodeAdmin;
767
768
  this.persistenceKey = persistenceKey;
768
769
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
770
+ this.isUsingEmulator = isUsingEmulator;
769
771
  this._host = host.toLowerCase();
770
772
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
771
773
  this.internalHost =
@@ -1298,7 +1300,7 @@ var WebSocketConnection = /** @class */ (function () {
1298
1300
  }());
1299
1301
 
1300
1302
  var name = "@firebase/database";
1301
- var version = "0.14.0";
1303
+ var version = "0.14.1-canary.68369740a";
1302
1304
 
1303
1305
  /**
1304
1306
  * @license
@@ -2010,8 +2012,8 @@ var FirebaseIFrameScriptHolder = /** @class */ (function () {
2010
2012
  if (this.myIFrame) {
2011
2013
  //We have to actually remove all of the html inside this iframe before removing it from the
2012
2014
  //window, or IE will continue loading and executing the script tags we've already added, which
2013
- //can lead to some errors being thrown. Setting innerHTML seems to be the easiest way to do this.
2014
- this.myIFrame.doc.body.innerHTML = '';
2015
+ //can lead to some errors being thrown. Setting textContent seems to be the safest way to do this.
2016
+ this.myIFrame.doc.body.textContent = '';
2015
2017
  setTimeout(function () {
2016
2018
  if (_this.myIFrame !== null) {
2017
2019
  document.body.removeChild(_this.myIFrame);
@@ -2573,7 +2575,12 @@ var Connection = /** @class */ (function () {
2573
2575
  if (MESSAGE_DATA in controlData) {
2574
2576
  var payload = controlData[MESSAGE_DATA];
2575
2577
  if (cmd === SERVER_HELLO) {
2576
- this.onHandshake_(payload);
2578
+ var handshakePayload = tslib.__assign({}, payload);
2579
+ if (this.repoInfo_.isUsingEmulator) {
2580
+ // Upon connecting, the emulator will pass the hostname that it's aware of, but we prefer the user's set hostname via `connectDatabaseEmulator` over what the emulator passes.
2581
+ handshakePayload.h = this.repoInfo_.host;
2582
+ }
2583
+ this.onHandshake_(handshakePayload);
2577
2584
  }
2578
2585
  else if (cmd === END_TRANSMISSION) {
2579
2586
  this.log_('recvd end transmission on primary');
@@ -13928,7 +13935,8 @@ var useRestClient = false;
13928
13935
  */
13929
13936
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13930
13937
  repo.repoInfo_ = new RepoInfo("".concat(host, ":").concat(port),
13931
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13938
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13939
+ /*isUsingEmulator=*/ true);
13932
13940
  if (tokenProvider) {
13933
13941
  repo.authTokenProvider_ = tokenProvider;
13934
13942
  }
@@ -14102,9 +14110,11 @@ function getDatabase(app$1, url) {
14102
14110
  var db = app._getProvider(app$1, 'database').getImmediate({
14103
14111
  identifier: url
14104
14112
  });
14105
- var emulator = util.getDefaultEmulatorHostnameAndPort('database');
14106
- if (emulator) {
14107
- connectDatabaseEmulator.apply(void 0, tslib.__spreadArray([db], tslib.__read(emulator), false));
14113
+ if (!db._instanceStarted) {
14114
+ var emulator = util.getDefaultEmulatorHostnameAndPort('database');
14115
+ if (emulator) {
14116
+ connectDatabaseEmulator.apply(void 0, tslib.__spreadArray([db], tslib.__read(emulator), false));
14117
+ }
14108
14118
  }
14109
14119
  return db;
14110
14120
  }