@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.
@@ -1,11 +1,11 @@
1
1
  import { getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';
2
2
  import { Component } from '@firebase/component';
3
- import { __spreadArray, __read, __values, __extends, __awaiter, __generator, __assign } from 'tslib';
3
+ import { __spreadArray, __read, __values, __assign, __extends, __awaiter, __generator } from 'tslib';
4
4
  import { stringify, jsonEval, contains, assert, isNodeSdk, stringToByteArray, Sha1, base64, deepCopy, base64Encode, isMobileCordova, stringLength, Deferred, safeGet, isAdmin, isValidFormat, isEmpty, isReactNative, assertionError, map, querystring, errorPrefix, getModularInstance, getDefaultEmulatorHostnameAndPort, createMockUserToken } from '@firebase/util';
5
5
  import { Logger, LogLevel } from '@firebase/logger';
6
6
 
7
7
  var name = "@firebase/database";
8
- var version = "0.14.0";
8
+ var version = "0.14.1-canary.68369740a";
9
9
 
10
10
  /**
11
11
  * @license
@@ -963,16 +963,18 @@ var RepoInfo = /** @class */ (function () {
963
963
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
964
964
  * @param persistenceKey - Override the default session persistence storage key
965
965
  */
966
- function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams) {
966
+ function RepoInfo(host, secure, namespace, webSocketOnly, nodeAdmin, persistenceKey, includeNamespaceInQueryParams, isUsingEmulator) {
967
967
  if (nodeAdmin === void 0) { nodeAdmin = false; }
968
968
  if (persistenceKey === void 0) { persistenceKey = ''; }
969
969
  if (includeNamespaceInQueryParams === void 0) { includeNamespaceInQueryParams = false; }
970
+ if (isUsingEmulator === void 0) { isUsingEmulator = false; }
970
971
  this.secure = secure;
971
972
  this.namespace = namespace;
972
973
  this.webSocketOnly = webSocketOnly;
973
974
  this.nodeAdmin = nodeAdmin;
974
975
  this.persistenceKey = persistenceKey;
975
976
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
977
+ this.isUsingEmulator = isUsingEmulator;
976
978
  this._host = host.toLowerCase();
977
979
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
978
980
  this.internalHost =
@@ -1647,8 +1649,8 @@ var FirebaseIFrameScriptHolder = /** @class */ (function () {
1647
1649
  if (this.myIFrame) {
1648
1650
  //We have to actually remove all of the html inside this iframe before removing it from the
1649
1651
  //window, or IE will continue loading and executing the script tags we've already added, which
1650
- //can lead to some errors being thrown. Setting innerHTML seems to be the easiest way to do this.
1651
- this.myIFrame.doc.body.innerHTML = '';
1652
+ //can lead to some errors being thrown. Setting textContent seems to be the safest way to do this.
1653
+ this.myIFrame.doc.body.textContent = '';
1652
1654
  setTimeout(function () {
1653
1655
  if (_this.myIFrame !== null) {
1654
1656
  document.body.removeChild(_this.myIFrame);
@@ -2561,7 +2563,12 @@ var Connection = /** @class */ (function () {
2561
2563
  if (MESSAGE_DATA in controlData) {
2562
2564
  var payload = controlData[MESSAGE_DATA];
2563
2565
  if (cmd === SERVER_HELLO) {
2564
- this.onHandshake_(payload);
2566
+ var handshakePayload = __assign({}, payload);
2567
+ if (this.repoInfo_.isUsingEmulator) {
2568
+ // 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.
2569
+ handshakePayload.h = this.repoInfo_.host;
2570
+ }
2571
+ this.onHandshake_(handshakePayload);
2565
2572
  }
2566
2573
  else if (cmd === END_TRANSMISSION) {
2567
2574
  this.log_('recvd end transmission on primary');
@@ -13916,7 +13923,8 @@ var useRestClient = false;
13916
13923
  */
13917
13924
  function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13918
13925
  repo.repoInfo_ = new RepoInfo("".concat(host, ":").concat(port),
13919
- /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams);
13926
+ /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13927
+ /*isUsingEmulator=*/ true);
13920
13928
  if (tokenProvider) {
13921
13929
  repo.authTokenProvider_ = tokenProvider;
13922
13930
  }
@@ -14090,9 +14098,11 @@ function getDatabase(app, url) {
14090
14098
  var db = _getProvider(app, 'database').getImmediate({
14091
14099
  identifier: url
14092
14100
  });
14093
- var emulator = getDefaultEmulatorHostnameAndPort('database');
14094
- if (emulator) {
14095
- connectDatabaseEmulator.apply(void 0, __spreadArray([db], __read(emulator), false));
14101
+ if (!db._instanceStarted) {
14102
+ var emulator = getDefaultEmulatorHostnameAndPort('database');
14103
+ if (emulator) {
14104
+ connectDatabaseEmulator.apply(void 0, __spreadArray([db], __read(emulator), false));
14105
+ }
14096
14106
  }
14097
14107
  return db;
14098
14108
  }