@firebase/database 1.0.12 → 1.0.13-20250226000544

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,10 +1,10 @@
1
1
  import { _isFirebaseServerApp, _getProvider, getApp, SDK_VERSION as SDK_VERSION$1, _registerComponent, registerVersion } from '@firebase/app';
2
2
  import { Component, ComponentContainer, Provider } from '@firebase/component';
3
- 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';
3
+ 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, deepEqual, createMockUserToken } from '@firebase/util';
4
4
  import { Logger, LogLevel } from '@firebase/logger';
5
5
 
6
6
  const name = "@firebase/database";
7
- const version = "1.0.12";
7
+ const version = "1.0.13-20250226000544";
8
8
 
9
9
  /**
10
10
  * @license
@@ -938,7 +938,7 @@ class RepoInfo {
938
938
  * @param nodeAdmin - Whether this instance uses Admin SDK credentials
939
939
  * @param persistenceKey - Override the default session persistence storage key
940
940
  */
941
- constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false, isUsingEmulator = false) {
941
+ constructor(host, secure, namespace, webSocketOnly, nodeAdmin = false, persistenceKey = '', includeNamespaceInQueryParams = false, isUsingEmulator = false, emulatorOptions = null) {
942
942
  this.secure = secure;
943
943
  this.namespace = namespace;
944
944
  this.webSocketOnly = webSocketOnly;
@@ -946,6 +946,7 @@ class RepoInfo {
946
946
  this.persistenceKey = persistenceKey;
947
947
  this.includeNamespaceInQueryParams = includeNamespaceInQueryParams;
948
948
  this.isUsingEmulator = isUsingEmulator;
949
+ this.emulatorOptions = emulatorOptions;
949
950
  this._host = host.toLowerCase();
950
951
  this._domain = this._host.substr(this._host.indexOf('.') + 1);
951
952
  this.internalHost =
@@ -13486,10 +13487,10 @@ let useRestClient = false;
13486
13487
  /**
13487
13488
  * Update an existing `Repo` in place to point to a new host/port.
13488
13489
  */
13489
- function repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider) {
13490
- repo.repoInfo_ = new RepoInfo(`${host}:${port}`,
13490
+ function repoManagerApplyEmulatorSettings(repo, hostAndPort, emulatorOptions, tokenProvider) {
13491
+ repo.repoInfo_ = new RepoInfo(hostAndPort,
13491
13492
  /* secure= */ false, repo.repoInfo_.namespace, repo.repoInfo_.webSocketOnly, repo.repoInfo_.nodeAdmin, repo.repoInfo_.persistenceKey, repo.repoInfo_.includeNamespaceInQueryParams,
13492
- /*isUsingEmulator=*/ true);
13493
+ /*isUsingEmulator=*/ true, emulatorOptions);
13493
13494
  if (tokenProvider) {
13494
13495
  repo.authTokenProvider_ = tokenProvider;
13495
13496
  }
@@ -13674,10 +13675,17 @@ function getDatabase(app = getApp(), url) {
13674
13675
  function connectDatabaseEmulator(db, host, port, options = {}) {
13675
13676
  db = getModularInstance(db);
13676
13677
  db._checkNotDeleted('useEmulator');
13678
+ const hostAndPort = `${host}:${port}`;
13679
+ const repo = db._repoInternal;
13677
13680
  if (db._instanceStarted) {
13678
- fatal('Cannot call useEmulator() after instance has already been initialized.');
13681
+ // If the instance has already been started, then silenty fail if this function is called again
13682
+ // with the same parameters. If the parameters differ then assert.
13683
+ if (hostAndPort === db._repoInternal.repoInfo_.host &&
13684
+ deepEqual(options, repo.repoInfo_.emulatorOptions)) {
13685
+ return;
13686
+ }
13687
+ fatal('connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.');
13679
13688
  }
13680
- const repo = db._repoInternal;
13681
13689
  let tokenProvider = undefined;
13682
13690
  if (repo.repoInfo_.nodeAdmin) {
13683
13691
  if (options.mockUserToken) {
@@ -13692,7 +13700,7 @@ function connectDatabaseEmulator(db, host, port, options = {}) {
13692
13700
  tokenProvider = new EmulatorTokenProvider(token);
13693
13701
  }
13694
13702
  // Modify the repo to apply emulator settings
13695
- repoManagerApplyEmulatorSettings(repo, host, port, tokenProvider);
13703
+ repoManagerApplyEmulatorSettings(repo, hostAndPort, options, tokenProvider);
13696
13704
  }
13697
13705
  /**
13698
13706
  * Disconnects from the server (all Database operations will be completed