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

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