@firebase/firestore 1.14.0-canary.daf63c2c → 1.14.0

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.
@@ -14670,11 +14670,22 @@ var IndexedDbPersistence = /** @class */ (function () {
14670
14670
  }
14671
14671
  };
14672
14672
  IndexedDbPersistence.createIndexedDbPersistence = function (options) {
14673
- if (!IndexedDbPersistence.isAvailable()) {
14674
- throw new FirestoreError(Code.UNIMPLEMENTED, UNSUPPORTED_PLATFORM_ERROR_MSG);
14675
- }
14676
- var persistence = new IndexedDbPersistence(options.allowTabSynchronization, options.persistenceKey, options.clientId, options.platform, options.lruParams, options.queue, options.serializer, options.sequenceNumberSyncer);
14677
- return persistence;
14673
+ return tslib.__awaiter(this, void 0, void 0, function () {
14674
+ var persistence;
14675
+ return tslib.__generator(this, function (_c) {
14676
+ switch (_c.label) {
14677
+ case 0:
14678
+ if (!IndexedDbPersistence.isAvailable()) {
14679
+ throw new FirestoreError(Code.UNIMPLEMENTED, UNSUPPORTED_PLATFORM_ERROR_MSG);
14680
+ }
14681
+ persistence = new IndexedDbPersistence(options.allowTabSynchronization, options.persistenceKey, options.clientId, options.platform, options.lruParams, options.queue, options.serializer, options.sequenceNumberSyncer);
14682
+ return [4 /*yield*/, persistence.start()];
14683
+ case 1:
14684
+ _c.sent();
14685
+ return [2 /*return*/, persistence];
14686
+ }
14687
+ });
14688
+ });
14678
14689
  };
14679
14690
  /**
14680
14691
  * Attempt to start IndexedDb persistence.
@@ -16031,9 +16042,6 @@ var MemoryPersistence = /** @class */ (function () {
16031
16042
  this.indexManager = new MemoryIndexManager();
16032
16043
  this.remoteDocumentCache = new MemoryRemoteDocumentCache(this.indexManager, sizer);
16033
16044
  }
16034
- MemoryPersistence.prototype.start = function () {
16035
- return Promise.resolve();
16036
- };
16037
16045
  MemoryPersistence.prototype.shutdown = function () {
16038
16046
  // No durable state to ensure is closed on shutdown.
16039
16047
  this._started = false;
@@ -16221,44 +16229,61 @@ var MemoryEagerDelegate = /** @class */ (function () {
16221
16229
  * See the License for the specific language governing permissions and
16222
16230
  * limitations under the License.
16223
16231
  */
16224
- var MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = 'You are using the memory-only build of Firestore. Persistence support is ' +
16225
- 'only available via the @firebase/firestore bundle or the ' +
16226
- 'firebase-firestore.js build.';
16227
16232
  /**
16228
- * Provides all components needed for Firestore with in-memory persistence.
16229
- * Uses EagerGC garbage collection.
16233
+ * Provides all components needed for Firestore with IndexedDB persistence.
16230
16234
  */
16231
- var MemoryComponentProvider = /** @class */ (function () {
16232
- function MemoryComponentProvider() {
16235
+ var IndexedDbComponentProvider = /** @class */ (function () {
16236
+ function IndexedDbComponentProvider() {
16233
16237
  }
16234
- MemoryComponentProvider.prototype.initialize = function (cfg) {
16238
+ IndexedDbComponentProvider.prototype.initialize = function (asyncQueue, databaseInfo, platform, datastore, clientId, initialUser, maxConcurrentLimboResolutions, persistenceSettings) {
16235
16239
  return tslib.__awaiter(this, void 0, void 0, function () {
16240
+ var persistenceKey, serializer, _c, garbageCollector;
16236
16241
  var _this = this;
16237
- return tslib.__generator(this, function (_c) {
16238
- switch (_c.label) {
16242
+ return tslib.__generator(this, function (_d) {
16243
+ switch (_d.label) {
16239
16244
  case 0:
16240
- this.sharedClientState = this.createSharedClientState(cfg);
16241
- this.persistence = this.createPersistence(cfg);
16242
- return [4 /*yield*/, this.persistence.start()];
16243
- case 1:
16244
- _c.sent();
16245
- this.gcScheduler = this.createGarbageCollectionScheduler(cfg);
16246
- this.localStore = this.createLocalStore(cfg);
16247
- this.remoteStore = this.createRemoteStore(cfg);
16248
- this.syncEngine = this.createSyncEngine(cfg);
16249
- this.eventManager = this.createEventManager(cfg);
16245
+ debugAssert(persistenceSettings.durable, 'IndexedDbComponentProvider can only provide durable persistence');
16246
+ debugAssert(!this.sharedClientState, 'initialize() already called');
16247
+ persistenceKey = IndexedDbPersistence.buildStoragePrefix(databaseInfo);
16248
+ serializer = platform.newSerializer(databaseInfo.databaseId);
16249
+ if (!WebStorageSharedClientState.isAvailable(platform)) {
16250
+ throw new FirestoreError(Code.UNIMPLEMENTED, 'IndexedDB persistence is only available on platforms that support LocalStorage.');
16251
+ }
16252
+ this.sharedClientState = persistenceSettings.synchronizeTabs
16253
+ ? new WebStorageSharedClientState(asyncQueue, platform, persistenceKey, clientId, initialUser)
16254
+ : new MemorySharedClientState();
16250
16255
  this.sharedClientState.onlineStateHandler = function (onlineState) { return _this.syncEngine.applyOnlineStateChange(onlineState, 1 /* SharedClientState */); };
16256
+ _c = this;
16257
+ return [4 /*yield*/, IndexedDbPersistence.createIndexedDbPersistence({
16258
+ allowTabSynchronization: persistenceSettings.synchronizeTabs,
16259
+ persistenceKey: persistenceKey,
16260
+ clientId: clientId,
16261
+ platform: platform,
16262
+ queue: asyncQueue,
16263
+ serializer: serializer,
16264
+ lruParams: LruParams.withCacheSize(persistenceSettings.cacheSizeBytes),
16265
+ sequenceNumberSyncer: this.sharedClientState
16266
+ })];
16267
+ case 1:
16268
+ _c.persistence = _d.sent();
16269
+ garbageCollector = this.persistence.referenceDelegate
16270
+ .garbageCollector;
16271
+ this.gcScheduler = new LruScheduler(garbageCollector, asyncQueue);
16272
+ this.localStore = new LocalStore(this.persistence, new IndexFreeQueryEngine(), initialUser);
16273
+ this.remoteStore = new RemoteStore(this.localStore, datastore, asyncQueue, function (onlineState) { return _this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */); }, platform.newConnectivityMonitor());
16274
+ this.syncEngine = new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, initialUser, maxConcurrentLimboResolutions);
16275
+ this.eventManager = new EventManager(this.syncEngine);
16251
16276
  this.remoteStore.syncEngine = this.syncEngine;
16252
16277
  this.sharedClientState.syncEngine = this.syncEngine;
16253
16278
  return [4 /*yield*/, this.sharedClientState.start()];
16254
16279
  case 2:
16255
- _c.sent();
16280
+ _d.sent();
16256
16281
  return [4 /*yield*/, this.remoteStore.start()];
16257
16282
  case 3:
16258
- _c.sent();
16283
+ _d.sent();
16259
16284
  return [4 /*yield*/, this.localStore.start()];
16260
16285
  case 4:
16261
- _c.sent();
16286
+ _d.sent();
16262
16287
  // NOTE: This will immediately call the listener, so we make sure to
16263
16288
  // set it after localStore / remoteStore are started.
16264
16289
  return [4 /*yield*/, this.persistence.setPrimaryStateListener(function (isPrimary) { return tslib.__awaiter(_this, void 0, void 0, function () {
@@ -16267,13 +16292,11 @@ var MemoryComponentProvider = /** @class */ (function () {
16267
16292
  case 0: return [4 /*yield*/, this.syncEngine.applyPrimaryState(isPrimary)];
16268
16293
  case 1:
16269
16294
  _c.sent();
16270
- if (this.gcScheduler) {
16271
- if (isPrimary && !this.gcScheduler.started) {
16272
- this.gcScheduler.start(this.localStore);
16273
- }
16274
- else if (!isPrimary) {
16275
- this.gcScheduler.stop();
16276
- }
16295
+ if (isPrimary && !this.gcScheduler.started) {
16296
+ this.gcScheduler.start(this.localStore);
16297
+ }
16298
+ else if (!isPrimary) {
16299
+ this.gcScheduler.stop();
16277
16300
  }
16278
16301
  return [2 /*return*/];
16279
16302
  }
@@ -16282,86 +16305,65 @@ var MemoryComponentProvider = /** @class */ (function () {
16282
16305
  case 5:
16283
16306
  // NOTE: This will immediately call the listener, so we make sure to
16284
16307
  // set it after localStore / remoteStore are started.
16285
- _c.sent();
16308
+ _d.sent();
16286
16309
  return [2 /*return*/];
16287
16310
  }
16288
16311
  });
16289
16312
  });
16290
16313
  };
16291
- MemoryComponentProvider.prototype.createEventManager = function (cfg) {
16292
- return new EventManager(this.syncEngine);
16293
- };
16294
- MemoryComponentProvider.prototype.createGarbageCollectionScheduler = function (cfg) {
16295
- return null;
16296
- };
16297
- MemoryComponentProvider.prototype.createLocalStore = function (cfg) {
16298
- return new LocalStore(this.persistence, new IndexFreeQueryEngine(), cfg.initialUser);
16299
- };
16300
- MemoryComponentProvider.prototype.createPersistence = function (cfg) {
16301
- debugAssert(!cfg.persistenceSettings.durable, 'Can only start memory persistence');
16302
- return new MemoryPersistence(cfg.clientId, MemoryEagerDelegate.factory);
16303
- };
16304
- MemoryComponentProvider.prototype.createRemoteStore = function (cfg) {
16305
- var _this = this;
16306
- return new RemoteStore(this.localStore, cfg.datastore, cfg.asyncQueue, function (onlineState) { return _this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */); }, cfg.platform.newConnectivityMonitor());
16307
- };
16308
- MemoryComponentProvider.prototype.createSharedClientState = function (cfg) {
16309
- return new MemorySharedClientState();
16310
- };
16311
- MemoryComponentProvider.prototype.createSyncEngine = function (cfg) {
16312
- return new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, cfg.initialUser, cfg.maxConcurrentLimboResolutions);
16313
- };
16314
- MemoryComponentProvider.prototype.clearPersistence = function (databaseInfo) {
16315
- throw new FirestoreError(Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE);
16314
+ IndexedDbComponentProvider.prototype.clearPersistence = function (databaseInfo) {
16315
+ var persistenceKey = IndexedDbPersistence.buildStoragePrefix(databaseInfo);
16316
+ return IndexedDbPersistence.clearPersistence(persistenceKey);
16316
16317
  };
16317
- return MemoryComponentProvider;
16318
+ return IndexedDbComponentProvider;
16318
16319
  }());
16320
+ var MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = 'You are using the memory-only build of Firestore. Persistence support is ' +
16321
+ 'only available via the @firebase/firestore bundle or the ' +
16322
+ 'firebase-firestore.js build.';
16319
16323
  /**
16320
- * Provides all components needed for Firestore with IndexedDB persistence.
16324
+ * Provides all components needed for Firestore with in-memory persistence.
16321
16325
  */
16322
- var IndexedDbComponentProvider = /** @class */ (function (_super) {
16323
- tslib.__extends(IndexedDbComponentProvider, _super);
16324
- function IndexedDbComponentProvider() {
16325
- return _super !== null && _super.apply(this, arguments) || this;
16326
+ var MemoryComponentProvider = /** @class */ (function () {
16327
+ function MemoryComponentProvider(referenceDelegateFactory) {
16328
+ if (referenceDelegateFactory === void 0) { referenceDelegateFactory = MemoryEagerDelegate.factory; }
16329
+ this.referenceDelegateFactory = referenceDelegateFactory;
16326
16330
  }
16327
- IndexedDbComponentProvider.prototype.createGarbageCollectionScheduler = function (cfg) {
16328
- debugAssert(this.persistence instanceof IndexedDbPersistence, 'IndexedDbComponentProvider should provide IndexedDBPersistence');
16329
- var garbageCollector = this.persistence.referenceDelegate
16330
- .garbageCollector;
16331
- return new LruScheduler(garbageCollector, cfg.asyncQueue);
16332
- };
16333
- IndexedDbComponentProvider.prototype.createPersistence = function (cfg) {
16334
- debugAssert(cfg.persistenceSettings.durable, 'Can only start durable persistence');
16335
- var persistenceKey = IndexedDbPersistence.buildStoragePrefix(cfg.databaseInfo);
16336
- var serializer = cfg.platform.newSerializer(cfg.databaseInfo.databaseId);
16337
- return IndexedDbPersistence.createIndexedDbPersistence({
16338
- allowTabSynchronization: cfg.persistenceSettings.synchronizeTabs,
16339
- persistenceKey: persistenceKey,
16340
- clientId: cfg.clientId,
16341
- platform: cfg.platform,
16342
- queue: cfg.asyncQueue,
16343
- serializer: serializer,
16344
- lruParams: LruParams.withCacheSize(cfg.persistenceSettings.cacheSizeBytes),
16345
- sequenceNumberSyncer: this.sharedClientState
16346
- });
16347
- };
16348
- IndexedDbComponentProvider.prototype.createSharedClientState = function (cfg) {
16349
- debugAssert(cfg.persistenceSettings.durable, 'Can only start durable persistence');
16350
- if (cfg.persistenceSettings.synchronizeTabs) {
16351
- if (!WebStorageSharedClientState.isAvailable(cfg.platform)) {
16352
- throw new FirestoreError(Code.UNIMPLEMENTED, 'IndexedDB persistence is only available on platforms that support LocalStorage.');
16353
- }
16354
- var persistenceKey = IndexedDbPersistence.buildStoragePrefix(cfg.databaseInfo);
16355
- return new WebStorageSharedClientState(cfg.asyncQueue, cfg.platform, persistenceKey, cfg.clientId, cfg.initialUser);
16356
- }
16357
- return new MemorySharedClientState();
16331
+ MemoryComponentProvider.prototype.initialize = function (asyncQueue, databaseInfo, platform, datastore, clientId, initialUser, maxConcurrentLimboResolutions, persistenceSettings) {
16332
+ return tslib.__awaiter(this, void 0, void 0, function () {
16333
+ var _this = this;
16334
+ return tslib.__generator(this, function (_c) {
16335
+ switch (_c.label) {
16336
+ case 0:
16337
+ if (persistenceSettings.durable) {
16338
+ throw new FirestoreError(Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE);
16339
+ }
16340
+ this.persistence = new MemoryPersistence(clientId, this.referenceDelegateFactory);
16341
+ this.gcScheduler = null;
16342
+ this.sharedClientState = new MemorySharedClientState();
16343
+ this.localStore = new LocalStore(this.persistence, new IndexFreeQueryEngine(), initialUser);
16344
+ this.remoteStore = new RemoteStore(this.localStore, datastore, asyncQueue, function (onlineState) { return _this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */); }, platform.newConnectivityMonitor());
16345
+ this.syncEngine = new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, initialUser, maxConcurrentLimboResolutions);
16346
+ this.eventManager = new EventManager(this.syncEngine);
16347
+ this.remoteStore.syncEngine = this.syncEngine;
16348
+ return [4 /*yield*/, this.remoteStore.start()];
16349
+ case 1:
16350
+ _c.sent();
16351
+ return [4 /*yield*/, this.remoteStore.applyPrimaryState(true)];
16352
+ case 2:
16353
+ _c.sent();
16354
+ return [4 /*yield*/, this.syncEngine.applyPrimaryState(true)];
16355
+ case 3:
16356
+ _c.sent();
16357
+ return [2 /*return*/];
16358
+ }
16359
+ });
16360
+ });
16358
16361
  };
16359
- IndexedDbComponentProvider.prototype.clearPersistence = function (databaseInfo) {
16360
- var persistenceKey = IndexedDbPersistence.buildStoragePrefix(databaseInfo);
16361
- return IndexedDbPersistence.clearPersistence(persistenceKey);
16362
+ MemoryComponentProvider.prototype.clearPersistence = function () {
16363
+ throw new FirestoreError(Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE);
16362
16364
  };
16363
- return IndexedDbComponentProvider;
16364
- }(MemoryComponentProvider));
16365
+ return MemoryComponentProvider;
16366
+ }());
16365
16367
  /**
16366
16368
  * @license
16367
16369
  * Copyright 2017 Google LLC
@@ -17118,16 +17120,7 @@ var FirestoreClient = /** @class */ (function () {
17118
17120
  connection = _c.sent();
17119
17121
  serializer = this.platform.newSerializer(this.databaseInfo.databaseId);
17120
17122
  datastore = new Datastore(this.asyncQueue, connection, this.credentials, serializer);
17121
- return [4 /*yield*/, componentProvider.initialize({
17122
- asyncQueue: this.asyncQueue,
17123
- databaseInfo: this.databaseInfo,
17124
- platform: this.platform,
17125
- datastore: datastore,
17126
- clientId: this.clientId,
17127
- initialUser: user,
17128
- maxConcurrentLimboResolutions: MAX_CONCURRENT_LIMBO_RESOLUTIONS,
17129
- persistenceSettings: persistenceSettings
17130
- })];
17123
+ return [4 /*yield*/, componentProvider.initialize(this.asyncQueue, this.databaseInfo, this.platform, datastore, this.clientId, user, MAX_CONCURRENT_LIMBO_RESOLUTIONS, persistenceSettings)];
17131
17124
  case 2:
17132
17125
  _c.sent();
17133
17126
  this.persistence = componentProvider.persistence;
@@ -22587,7 +22580,7 @@ var NodePlatform = /** @class */ (function () {
22587
22580
  */
22588
22581
  PlatformSupport.setPlatform(new NodePlatform());
22589
22582
  var name = "@firebase/firestore";
22590
- var version = "1.14.0-canary.daf63c2c";
22583
+ var version = "1.14.0";
22591
22584
  /**
22592
22585
  * @license
22593
22586
  * Copyright 2017 Google LLC