@firebase/database-compat 2.0.11-canary.f11b55294 → 2.0.11-canary.f18b25f73

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.
@@ -3713,11 +3713,11 @@ class PlatformLoggerServiceImpl {
3713
3713
  */
3714
3714
  function isVersionServiceProvider(provider) {
3715
3715
  const component = provider.getComponent();
3716
- return (component === null || component === void 0 ? void 0 : component.type) === "VERSION" /* ComponentType.VERSION */;
3716
+ return component?.type === "VERSION" /* ComponentType.VERSION */;
3717
3717
  }
3718
3718
 
3719
3719
  const name$q = "@firebase/app";
3720
- const version$1 = "0.13.2-canary.f11b55294";
3720
+ const version$1 = "0.13.2-canary.f18b25f73";
3721
3721
 
3722
3722
  /**
3723
3723
  * @license
@@ -3788,7 +3788,7 @@ const name$2 = "@firebase/ai";
3788
3788
  const name$1 = "@firebase/firestore-compat";
3789
3789
 
3790
3790
  const name = "firebase";
3791
- const version = "11.10.0-canary.f11b55294";
3791
+ const version = "11.10.0-canary.f18b25f73";
3792
3792
 
3793
3793
  /**
3794
3794
  * @license
@@ -3948,7 +3948,7 @@ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NA
3948
3948
  }
3949
3949
  /**
3950
3950
  *
3951
- * @param obj - an object of type FirebaseApp or FirebaseOptions.
3951
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
3952
3952
  *
3953
3953
  * @returns true if the provide object is of type FirebaseApp.
3954
3954
  *
@@ -3957,6 +3957,23 @@ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NA
3957
3957
  function _isFirebaseApp(obj) {
3958
3958
  return obj.options !== undefined;
3959
3959
  }
3960
+ /**
3961
+ *
3962
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
3963
+ *
3964
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
3965
+ *
3966
+ * @internal
3967
+ */
3968
+ function _isFirebaseServerAppSettings(obj) {
3969
+ if (_isFirebaseApp(obj)) {
3970
+ return false;
3971
+ }
3972
+ return ('authIdToken' in obj ||
3973
+ 'appCheckToken' in obj ||
3974
+ 'releaseOnDeref' in obj ||
3975
+ 'automaticDataCollectionEnabled' in obj);
3976
+ }
3960
3977
  /**
3961
3978
  *
3962
3979
  * @param obj - an object of type FirebaseApp.
@@ -4035,8 +4052,8 @@ const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
4035
4052
  class FirebaseAppImpl {
4036
4053
  constructor(options, config, container) {
4037
4054
  this._isDeleted = false;
4038
- this._options = Object.assign({}, options);
4039
- this._config = Object.assign({}, config);
4055
+ this._options = { ...options };
4056
+ this._config = { ...config };
4040
4057
  this._name = config.name;
4041
4058
  this._automaticDataCollectionEnabled =
4042
4059
  config.automaticDataCollectionEnabled;
@@ -4140,7 +4157,10 @@ class FirebaseServerAppImpl extends FirebaseAppImpl {
4140
4157
  super(appImpl.options, config, container);
4141
4158
  }
4142
4159
  // Now construct the data for the FirebaseServerAppImpl.
4143
- this._serverConfig = Object.assign({ automaticDataCollectionEnabled }, serverConfig);
4160
+ this._serverConfig = {
4161
+ automaticDataCollectionEnabled,
4162
+ ...serverConfig
4163
+ };
4144
4164
  // Ensure that the current time is within the `authIdtoken` window of validity.
4145
4165
  if (this._serverConfig.authIdToken) {
4146
4166
  validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
@@ -4236,7 +4256,11 @@ function initializeApp(_options, rawConfig = {}) {
4236
4256
  const name = rawConfig;
4237
4257
  rawConfig = { name };
4238
4258
  }
4239
- const config = Object.assign({ name: DEFAULT_ENTRY_NAME, automaticDataCollectionEnabled: true }, rawConfig);
4259
+ const config = {
4260
+ name: DEFAULT_ENTRY_NAME,
4261
+ automaticDataCollectionEnabled: true,
4262
+ ...rawConfig
4263
+ };
4240
4264
  const name = config.name;
4241
4265
  if (typeof name !== 'string' || !name) {
4242
4266
  throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
@@ -4266,23 +4290,36 @@ function initializeApp(_options, rawConfig = {}) {
4266
4290
  _apps.set(name, newApp);
4267
4291
  return newApp;
4268
4292
  }
4269
- function initializeServerApp(_options, _serverAppConfig) {
4293
+ function initializeServerApp(_options, _serverAppConfig = {}) {
4270
4294
  if (util.isBrowser() && !util.isWebWorker()) {
4271
4295
  // FirebaseServerApp isn't designed to be run in browsers.
4272
4296
  throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
4273
4297
  }
4274
- if (_serverAppConfig.automaticDataCollectionEnabled === undefined) {
4275
- _serverAppConfig.automaticDataCollectionEnabled = true;
4298
+ let firebaseOptions;
4299
+ let serverAppSettings = _serverAppConfig || {};
4300
+ if (_options) {
4301
+ if (_isFirebaseApp(_options)) {
4302
+ firebaseOptions = _options.options;
4303
+ }
4304
+ else if (_isFirebaseServerAppSettings(_options)) {
4305
+ serverAppSettings = _options;
4306
+ }
4307
+ else {
4308
+ firebaseOptions = _options;
4309
+ }
4276
4310
  }
4277
- let appOptions;
4278
- if (_isFirebaseApp(_options)) {
4279
- appOptions = _options.options;
4311
+ if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
4312
+ serverAppSettings.automaticDataCollectionEnabled = true;
4280
4313
  }
4281
- else {
4282
- appOptions = _options;
4314
+ firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
4315
+ if (!firebaseOptions) {
4316
+ throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
4283
4317
  }
4284
4318
  // Build an app name based on a hash of the configuration options.
4285
- const nameObj = Object.assign(Object.assign({}, _serverAppConfig), appOptions);
4319
+ const nameObj = {
4320
+ ...serverAppSettings,
4321
+ ...firebaseOptions
4322
+ };
4286
4323
  // However, Do not mangle the name based on releaseOnDeref, since it will vary between the
4287
4324
  // construction of FirebaseServerApp instances. For example, if the object is the request headers.
4288
4325
  if (nameObj.releaseOnDeref !== undefined) {
@@ -4291,7 +4328,7 @@ function initializeServerApp(_options, _serverAppConfig) {
4291
4328
  const hashCode = (s) => {
4292
4329
  return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
4293
4330
  };
4294
- if (_serverAppConfig.releaseOnDeref !== undefined) {
4331
+ if (serverAppSettings.releaseOnDeref !== undefined) {
4295
4332
  if (typeof FinalizationRegistry === 'undefined') {
4296
4333
  throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
4297
4334
  }
@@ -4299,14 +4336,14 @@ function initializeServerApp(_options, _serverAppConfig) {
4299
4336
  const nameString = '' + hashCode(JSON.stringify(nameObj));
4300
4337
  const existingApp = _serverApps.get(nameString);
4301
4338
  if (existingApp) {
4302
- existingApp.incRefCount(_serverAppConfig.releaseOnDeref);
4339
+ existingApp.incRefCount(serverAppSettings.releaseOnDeref);
4303
4340
  return existingApp;
4304
4341
  }
4305
4342
  const container = new component.ComponentContainer(nameString);
4306
4343
  for (const component of _components.values()) {
4307
4344
  container.addComponent(component);
4308
4345
  }
4309
- const newApp = new FirebaseServerAppImpl(appOptions, _serverAppConfig, nameString, container);
4346
+ const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
4310
4347
  _serverApps.set(nameString, newApp);
4311
4348
  return newApp;
4312
4349
  }
@@ -4403,10 +4440,9 @@ async function deleteApp(app) {
4403
4440
  * @public
4404
4441
  */
4405
4442
  function registerVersion(libraryKeyOrName, version, variant) {
4406
- var _a;
4407
4443
  // TODO: We can use this check to whitelist strings when/if we set up
4408
4444
  // a good whitelist system.
4409
- let library = (_a = PLATFORM_LOG_STRING[libraryKeyOrName]) !== null && _a !== void 0 ? _a : libraryKeyOrName;
4445
+ let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
4410
4446
  if (variant) {
4411
4447
  library += `-${variant}`;
4412
4448
  }
@@ -4522,7 +4558,7 @@ async function readHeartbeatsFromIndexedDB(app) {
4522
4558
  }
4523
4559
  else {
4524
4560
  const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
4525
- originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
4561
+ originalErrorMessage: e?.message
4526
4562
  });
4527
4563
  logger.warn(idbGetError.message);
4528
4564
  }
@@ -4542,7 +4578,7 @@ async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
4542
4578
  }
4543
4579
  else {
4544
4580
  const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
4545
- originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
4581
+ originalErrorMessage: e?.message
4546
4582
  });
4547
4583
  logger.warn(idbGetError.message);
4548
4584
  }
@@ -4598,7 +4634,6 @@ class HeartbeatServiceImpl {
4598
4634
  * already logged, subsequent calls to this function in the same day will be ignored.
4599
4635
  */
4600
4636
  async triggerHeartbeat() {
4601
- var _a, _b;
4602
4637
  try {
4603
4638
  const platformLogger = this.container
4604
4639
  .getProvider('platform-logger')
@@ -4607,10 +4642,10 @@ class HeartbeatServiceImpl {
4607
4642
  // service, not the browser user agent.
4608
4643
  const agent = platformLogger.getPlatformInfoString();
4609
4644
  const date = getUTCDateString();
4610
- if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) {
4645
+ if (this._heartbeatsCache?.heartbeats == null) {
4611
4646
  this._heartbeatsCache = await this._heartbeatsCachePromise;
4612
4647
  // If we failed to construct a heartbeats cache, then return immediately.
4613
- if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) {
4648
+ if (this._heartbeatsCache?.heartbeats == null) {
4614
4649
  return;
4615
4650
  }
4616
4651
  }
@@ -4644,13 +4679,12 @@ class HeartbeatServiceImpl {
4644
4679
  * returns an empty string.
4645
4680
  */
4646
4681
  async getHeartbeatsHeader() {
4647
- var _a;
4648
4682
  try {
4649
4683
  if (this._heartbeatsCache === null) {
4650
4684
  await this._heartbeatsCachePromise;
4651
4685
  }
4652
4686
  // If it's still null or the array is empty, there is no data to send.
4653
- if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null ||
4687
+ if (this._heartbeatsCache?.heartbeats == null ||
4654
4688
  this._heartbeatsCache.heartbeats.length === 0) {
4655
4689
  return '';
4656
4690
  }
@@ -4751,7 +4785,7 @@ class HeartbeatStorageImpl {
4751
4785
  }
4752
4786
  else {
4753
4787
  const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
4754
- if (idbHeartbeatObject === null || idbHeartbeatObject === void 0 ? void 0 : idbHeartbeatObject.heartbeats) {
4788
+ if (idbHeartbeatObject?.heartbeats) {
4755
4789
  return idbHeartbeatObject;
4756
4790
  }
4757
4791
  else {
@@ -4761,7 +4795,6 @@ class HeartbeatStorageImpl {
4761
4795
  }
4762
4796
  // overwrite the storage with the provided heartbeats
4763
4797
  async overwrite(heartbeatsObject) {
4764
- var _a;
4765
4798
  const canUseIndexedDB = await this._canUseIndexedDBPromise;
4766
4799
  if (!canUseIndexedDB) {
4767
4800
  return;
@@ -4769,14 +4802,14 @@ class HeartbeatStorageImpl {
4769
4802
  else {
4770
4803
  const existingHeartbeatsObject = await this.read();
4771
4804
  return writeHeartbeatsToIndexedDB(this.app, {
4772
- lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
4805
+ lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
4806
+ existingHeartbeatsObject.lastSentHeartbeatDate,
4773
4807
  heartbeats: heartbeatsObject.heartbeats
4774
4808
  });
4775
4809
  }
4776
4810
  }
4777
4811
  // add heartbeats
4778
4812
  async add(heartbeatsObject) {
4779
- var _a;
4780
4813
  const canUseIndexedDB = await this._canUseIndexedDBPromise;
4781
4814
  if (!canUseIndexedDB) {
4782
4815
  return;
@@ -4784,7 +4817,8 @@ class HeartbeatStorageImpl {
4784
4817
  else {
4785
4818
  const existingHeartbeatsObject = await this.read();
4786
4819
  return writeHeartbeatsToIndexedDB(this.app, {
4787
- lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
4820
+ lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
4821
+ existingHeartbeatsObject.lastSentHeartbeatDate,
4788
4822
  heartbeats: [
4789
4823
  ...existingHeartbeatsObject.heartbeats,
4790
4824
  ...heartbeatsObject.heartbeats
@@ -4844,8 +4878,8 @@ function registerCoreComponents(variant) {
4844
4878
  _registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
4845
4879
  // Register `app` package.
4846
4880
  registerVersion(name$q, version$1, variant);
4847
- // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
4848
- registerVersion(name$q, version$1, 'cjs2017');
4881
+ // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
4882
+ registerVersion(name$q, version$1, 'cjs2020');
4849
4883
  // Register platform SDK identifier (no version).
4850
4884
  registerVersion('fire-js', '');
4851
4885
  }
@@ -4872,6 +4906,7 @@ exports._components = _components;
4872
4906
  exports._getProvider = _getProvider;
4873
4907
  exports._isFirebaseApp = _isFirebaseApp;
4874
4908
  exports._isFirebaseServerApp = _isFirebaseServerApp;
4909
+ exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
4875
4910
  exports._registerComponent = _registerComponent;
4876
4911
  exports._removeServiceInstance = _removeServiceInstance;
4877
4912
  exports._serverApps = _serverApps;
@@ -6171,9 +6206,9 @@ class AppCheckTokenProvider {
6171
6206
  if (app._isFirebaseServerApp(app$1) && app$1.settings.appCheckToken) {
6172
6207
  this.serverAppAppCheckToken = app$1.settings.appCheckToken;
6173
6208
  }
6174
- this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
6209
+ this.appCheck = appCheckProvider?.getImmediate({ optional: true });
6175
6210
  if (!this.appCheck) {
6176
- appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck));
6211
+ appCheckProvider?.get().then(appCheck => (this.appCheck = appCheck));
6177
6212
  }
6178
6213
  }
6179
6214
  getToken(forceRefresh) {
@@ -6202,8 +6237,9 @@ class AppCheckTokenProvider {
6202
6237
  return this.appCheck.getToken(forceRefresh);
6203
6238
  }
6204
6239
  addTokenChangeListener(listener) {
6205
- var _a;
6206
- (_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener));
6240
+ this.appCheckProvider
6241
+ ?.get()
6242
+ .then(appCheck => appCheck.addTokenListener(listener));
6207
6243
  }
6208
6244
  notifyForInvalidToken() {
6209
6245
  warn$1(`Provided AppCheck credentials for the app named "${this.appName}" ` +
@@ -7371,7 +7407,9 @@ class Connection {
7371
7407
  if (MESSAGE_DATA in controlData) {
7372
7408
  const payload = controlData[MESSAGE_DATA];
7373
7409
  if (cmd === SERVER_HELLO) {
7374
- const handshakePayload = Object.assign({}, payload);
7410
+ const handshakePayload = {
7411
+ ...payload
7412
+ };
7375
7413
  if (this.repoInfo_.isUsingEmulator) {
7376
7414
  // 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.
7377
7415
  handshakePayload.h = this.repoInfo_.host;
@@ -10187,9 +10225,9 @@ class IndexMap {
10187
10225
  newIndex = fallbackObject;
10188
10226
  }
10189
10227
  const indexName = indexDefinition.toString();
10190
- const newIndexSet = Object.assign({}, this.indexSet_);
10228
+ const newIndexSet = { ...this.indexSet_ };
10191
10229
  newIndexSet[indexName] = indexDefinition;
10192
- const newIndexes = Object.assign({}, this.indexes_);
10230
+ const newIndexes = { ...this.indexes_ };
10193
10231
  newIndexes[indexName] = newIndex;
10194
10232
  return new IndexMap(newIndexes, newIndexSet);
10195
10233
  }
@@ -11993,7 +12031,7 @@ class StatsListener {
11993
12031
  }
11994
12032
  get() {
11995
12033
  const newStats = this.collection_.get();
11996
- const delta = Object.assign({}, newStats);
12034
+ const delta = { ...newStats };
11997
12035
  if (this.last_) {
11998
12036
  each(this.last_, (stat, value) => {
11999
12037
  delta[stat] = delta[stat] - value;
@@ -18744,13 +18782,12 @@ class TransactionResult$1 {
18744
18782
  function runTransaction(ref,
18745
18783
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18746
18784
  transactionUpdate, options) {
18747
- var _a;
18748
18785
  ref = util.getModularInstance(ref);
18749
18786
  validateWritablePath('Reference.transaction', ref._path);
18750
18787
  if (ref.key === '.length' || ref.key === '.keys') {
18751
18788
  throw ('Reference.transaction failed: ' + ref.key + ' is a read-only object.');
18752
18789
  }
18753
- const applyLocally = (_a = options === null || options === void 0 ? void 0 : options.applyLocally) !== null && _a !== void 0 ? _a : true;
18790
+ const applyLocally = options?.applyLocally ?? true;
18754
18791
  const deferred = new util.Deferred();
18755
18792
  const promiseComplete = (error, committed, node) => {
18756
18793
  let dataSnapshot = null;
@@ -19234,7 +19271,6 @@ class Query {
19234
19271
  this._delegate = _delegate;
19235
19272
  }
19236
19273
  on(eventType, callback, cancelCallbackOrContext, context) {
19237
- var _a;
19238
19274
  require$$2$3.validateArgCount('Query.on', 2, 4, arguments.length);
19239
19275
  require$$2$3.validateCallback('Query.on', 'callback', callback, false);
19240
19276
  const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
@@ -19243,7 +19279,7 @@ class Query {
19243
19279
  };
19244
19280
  valueCallback.userCallback = callback;
19245
19281
  valueCallback.context = ret.context;
19246
- const cancelCallback = (_a = ret.cancel) === null || _a === void 0 ? void 0 : _a.bind(ret.context);
19282
+ const cancelCallback = ret.cancel?.bind(ret.context);
19247
19283
  switch (eventType) {
19248
19284
  case 'value':
19249
19285
  onValue_1(this._delegate, valueCallback, cancelCallback);