@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.
- package/dist/dist/index.esm2017.d.ts +2 -2
- package/dist/dist/index.memory.esm2017.d.ts +2 -2
- package/dist/index.cjs.js +872 -874
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +933 -935
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm2017.js +746 -780
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.memory.cjs.js +604 -651
- package/dist/index.memory.cjs.js.map +1 -1
- package/dist/index.memory.esm.js +882 -929
- package/dist/index.memory.esm.js.map +1 -1
- package/dist/index.memory.esm2017.js +387 -422
- package/dist/index.memory.esm2017.js.map +1 -1
- package/dist/index.memory.node.cjs.js +21 -81
- package/dist/index.memory.node.cjs.js.map +1 -1
- package/dist/index.memory.node.esm2017.js +19 -64
- package/dist/index.memory.node.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +110 -117
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm2017.js +66 -96
- package/dist/index.node.esm2017.js.map +1 -1
- package/dist/lib/src/core/component_provider.d.ts +19 -35
- package/dist/lib/src/local/indexeddb_persistence.d.ts +2 -2
- package/dist/lib/src/local/memory_persistence.d.ts +0 -1
- package/dist/lib/src/local/persistence.d.ts +0 -2
- package/dist/src/core/component_provider.d.ts +19 -35
- package/dist/src/local/indexeddb_persistence.d.ts +2 -2
- package/dist/src/local/memory_persistence.d.ts +0 -1
- package/dist/src/local/persistence.d.ts +0 -2
- package/package.json +12 -12
|
@@ -13683,11 +13683,12 @@ class IndexedDbPersistence {
|
|
|
13683
13683
|
throw fail('IndexedDbPersistence must use instances of IndexedDbTransaction');
|
|
13684
13684
|
}
|
|
13685
13685
|
}
|
|
13686
|
-
static createIndexedDbPersistence(options) {
|
|
13686
|
+
static async createIndexedDbPersistence(options) {
|
|
13687
13687
|
if (!IndexedDbPersistence.isAvailable()) {
|
|
13688
13688
|
throw new FirestoreError(Code.UNIMPLEMENTED, UNSUPPORTED_PLATFORM_ERROR_MSG);
|
|
13689
13689
|
}
|
|
13690
13690
|
const persistence = new IndexedDbPersistence(options.allowTabSynchronization, options.persistenceKey, options.clientId, options.platform, options.lruParams, options.queue, options.serializer, options.sequenceNumberSyncer);
|
|
13691
|
+
await persistence.start();
|
|
13691
13692
|
return persistence;
|
|
13692
13693
|
}
|
|
13693
13694
|
/**
|
|
@@ -14958,9 +14959,6 @@ class MemoryPersistence {
|
|
|
14958
14959
|
this.indexManager = new MemoryIndexManager();
|
|
14959
14960
|
this.remoteDocumentCache = new MemoryRemoteDocumentCache(this.indexManager, sizer);
|
|
14960
14961
|
}
|
|
14961
|
-
start() {
|
|
14962
|
-
return Promise.resolve();
|
|
14963
|
-
}
|
|
14964
14962
|
shutdown() {
|
|
14965
14963
|
// No durable state to ensure is closed on shutdown.
|
|
14966
14964
|
this._started = false;
|
|
@@ -15127,24 +15125,39 @@ class MemoryEagerDelegate {
|
|
|
15127
15125
|
* See the License for the specific language governing permissions and
|
|
15128
15126
|
* limitations under the License.
|
|
15129
15127
|
*/
|
|
15130
|
-
const MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = 'You are using the memory-only build of Firestore. Persistence support is ' +
|
|
15131
|
-
'only available via the @firebase/firestore bundle or the ' +
|
|
15132
|
-
'firebase-firestore.js build.';
|
|
15133
15128
|
/**
|
|
15134
|
-
* Provides all components needed for Firestore with
|
|
15135
|
-
* Uses EagerGC garbage collection.
|
|
15129
|
+
* Provides all components needed for Firestore with IndexedDB persistence.
|
|
15136
15130
|
*/
|
|
15137
|
-
class
|
|
15138
|
-
async initialize(
|
|
15139
|
-
|
|
15140
|
-
this.
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
this.
|
|
15131
|
+
class IndexedDbComponentProvider {
|
|
15132
|
+
async initialize(asyncQueue, databaseInfo, platform, datastore, clientId, initialUser, maxConcurrentLimboResolutions, persistenceSettings) {
|
|
15133
|
+
debugAssert(persistenceSettings.durable, 'IndexedDbComponentProvider can only provide durable persistence');
|
|
15134
|
+
debugAssert(!this.sharedClientState, 'initialize() already called');
|
|
15135
|
+
const persistenceKey = IndexedDbPersistence.buildStoragePrefix(databaseInfo);
|
|
15136
|
+
const serializer = platform.newSerializer(databaseInfo.databaseId);
|
|
15137
|
+
if (!WebStorageSharedClientState.isAvailable(platform)) {
|
|
15138
|
+
throw new FirestoreError(Code.UNIMPLEMENTED, 'IndexedDB persistence is only available on platforms that support LocalStorage.');
|
|
15139
|
+
}
|
|
15140
|
+
this.sharedClientState = persistenceSettings.synchronizeTabs
|
|
15141
|
+
? new WebStorageSharedClientState(asyncQueue, platform, persistenceKey, clientId, initialUser)
|
|
15142
|
+
: new MemorySharedClientState();
|
|
15147
15143
|
this.sharedClientState.onlineStateHandler = onlineState => this.syncEngine.applyOnlineStateChange(onlineState, 1 /* SharedClientState */);
|
|
15144
|
+
this.persistence = await IndexedDbPersistence.createIndexedDbPersistence({
|
|
15145
|
+
allowTabSynchronization: persistenceSettings.synchronizeTabs,
|
|
15146
|
+
persistenceKey,
|
|
15147
|
+
clientId,
|
|
15148
|
+
platform,
|
|
15149
|
+
queue: asyncQueue,
|
|
15150
|
+
serializer,
|
|
15151
|
+
lruParams: LruParams.withCacheSize(persistenceSettings.cacheSizeBytes),
|
|
15152
|
+
sequenceNumberSyncer: this.sharedClientState
|
|
15153
|
+
});
|
|
15154
|
+
const garbageCollector = this.persistence.referenceDelegate
|
|
15155
|
+
.garbageCollector;
|
|
15156
|
+
this.gcScheduler = new LruScheduler(garbageCollector, asyncQueue);
|
|
15157
|
+
this.localStore = new LocalStore(this.persistence, new IndexFreeQueryEngine(), initialUser);
|
|
15158
|
+
this.remoteStore = new RemoteStore(this.localStore, datastore, asyncQueue, onlineState => this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */), platform.newConnectivityMonitor());
|
|
15159
|
+
this.syncEngine = new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, initialUser, maxConcurrentLimboResolutions);
|
|
15160
|
+
this.eventManager = new EventManager(this.syncEngine);
|
|
15148
15161
|
this.remoteStore.syncEngine = this.syncEngine;
|
|
15149
15162
|
this.sharedClientState.syncEngine = this.syncEngine;
|
|
15150
15163
|
await this.sharedClientState.start();
|
|
@@ -15154,81 +15167,47 @@ class MemoryComponentProvider {
|
|
|
15154
15167
|
// set it after localStore / remoteStore are started.
|
|
15155
15168
|
await this.persistence.setPrimaryStateListener(async (isPrimary) => {
|
|
15156
15169
|
await this.syncEngine.applyPrimaryState(isPrimary);
|
|
15157
|
-
if (this.gcScheduler) {
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
this.gcScheduler.stop();
|
|
15163
|
-
}
|
|
15170
|
+
if (isPrimary && !this.gcScheduler.started) {
|
|
15171
|
+
this.gcScheduler.start(this.localStore);
|
|
15172
|
+
}
|
|
15173
|
+
else if (!isPrimary) {
|
|
15174
|
+
this.gcScheduler.stop();
|
|
15164
15175
|
}
|
|
15165
15176
|
});
|
|
15166
15177
|
}
|
|
15167
|
-
createEventManager(cfg) {
|
|
15168
|
-
return new EventManager(this.syncEngine);
|
|
15169
|
-
}
|
|
15170
|
-
createGarbageCollectionScheduler(cfg) {
|
|
15171
|
-
return null;
|
|
15172
|
-
}
|
|
15173
|
-
createLocalStore(cfg) {
|
|
15174
|
-
return new LocalStore(this.persistence, new IndexFreeQueryEngine(), cfg.initialUser);
|
|
15175
|
-
}
|
|
15176
|
-
createPersistence(cfg) {
|
|
15177
|
-
debugAssert(!cfg.persistenceSettings.durable, 'Can only start memory persistence');
|
|
15178
|
-
return new MemoryPersistence(cfg.clientId, MemoryEagerDelegate.factory);
|
|
15179
|
-
}
|
|
15180
|
-
createRemoteStore(cfg) {
|
|
15181
|
-
return new RemoteStore(this.localStore, cfg.datastore, cfg.asyncQueue, onlineState => this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */), cfg.platform.newConnectivityMonitor());
|
|
15182
|
-
}
|
|
15183
|
-
createSharedClientState(cfg) {
|
|
15184
|
-
return new MemorySharedClientState();
|
|
15185
|
-
}
|
|
15186
|
-
createSyncEngine(cfg) {
|
|
15187
|
-
return new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, cfg.initialUser, cfg.maxConcurrentLimboResolutions);
|
|
15188
|
-
}
|
|
15189
15178
|
clearPersistence(databaseInfo) {
|
|
15190
|
-
|
|
15179
|
+
const persistenceKey = IndexedDbPersistence.buildStoragePrefix(databaseInfo);
|
|
15180
|
+
return IndexedDbPersistence.clearPersistence(persistenceKey);
|
|
15191
15181
|
}
|
|
15192
15182
|
}
|
|
15183
|
+
const MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE = 'You are using the memory-only build of Firestore. Persistence support is ' +
|
|
15184
|
+
'only available via the @firebase/firestore bundle or the ' +
|
|
15185
|
+
'firebase-firestore.js build.';
|
|
15193
15186
|
/**
|
|
15194
|
-
* Provides all components needed for Firestore with
|
|
15187
|
+
* Provides all components needed for Firestore with in-memory persistence.
|
|
15195
15188
|
*/
|
|
15196
|
-
class
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
sequenceNumberSyncer: this.sharedClientState
|
|
15216
|
-
});
|
|
15217
|
-
}
|
|
15218
|
-
createSharedClientState(cfg) {
|
|
15219
|
-
debugAssert(cfg.persistenceSettings.durable, 'Can only start durable persistence');
|
|
15220
|
-
if (cfg.persistenceSettings.synchronizeTabs) {
|
|
15221
|
-
if (!WebStorageSharedClientState.isAvailable(cfg.platform)) {
|
|
15222
|
-
throw new FirestoreError(Code.UNIMPLEMENTED, 'IndexedDB persistence is only available on platforms that support LocalStorage.');
|
|
15223
|
-
}
|
|
15224
|
-
const persistenceKey = IndexedDbPersistence.buildStoragePrefix(cfg.databaseInfo);
|
|
15225
|
-
return new WebStorageSharedClientState(cfg.asyncQueue, cfg.platform, persistenceKey, cfg.clientId, cfg.initialUser);
|
|
15226
|
-
}
|
|
15227
|
-
return new MemorySharedClientState();
|
|
15189
|
+
class MemoryComponentProvider {
|
|
15190
|
+
constructor(referenceDelegateFactory = MemoryEagerDelegate.factory) {
|
|
15191
|
+
this.referenceDelegateFactory = referenceDelegateFactory;
|
|
15192
|
+
}
|
|
15193
|
+
async initialize(asyncQueue, databaseInfo, platform, datastore, clientId, initialUser, maxConcurrentLimboResolutions, persistenceSettings) {
|
|
15194
|
+
if (persistenceSettings.durable) {
|
|
15195
|
+
throw new FirestoreError(Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE);
|
|
15196
|
+
}
|
|
15197
|
+
this.persistence = new MemoryPersistence(clientId, this.referenceDelegateFactory);
|
|
15198
|
+
this.gcScheduler = null;
|
|
15199
|
+
this.sharedClientState = new MemorySharedClientState();
|
|
15200
|
+
this.localStore = new LocalStore(this.persistence, new IndexFreeQueryEngine(), initialUser);
|
|
15201
|
+
this.remoteStore = new RemoteStore(this.localStore, datastore, asyncQueue, onlineState => this.syncEngine.applyOnlineStateChange(onlineState, 0 /* RemoteStore */), platform.newConnectivityMonitor());
|
|
15202
|
+
this.syncEngine = new SyncEngine(this.localStore, this.remoteStore, this.sharedClientState, initialUser, maxConcurrentLimboResolutions);
|
|
15203
|
+
this.eventManager = new EventManager(this.syncEngine);
|
|
15204
|
+
this.remoteStore.syncEngine = this.syncEngine;
|
|
15205
|
+
await this.remoteStore.start();
|
|
15206
|
+
await this.remoteStore.applyPrimaryState(true);
|
|
15207
|
+
await this.syncEngine.applyPrimaryState(true);
|
|
15228
15208
|
}
|
|
15229
|
-
clearPersistence(
|
|
15230
|
-
|
|
15231
|
-
return IndexedDbPersistence.clearPersistence(persistenceKey);
|
|
15209
|
+
clearPersistence() {
|
|
15210
|
+
throw new FirestoreError(Code.FAILED_PRECONDITION, MEMORY_ONLY_PERSISTENCE_ERROR_MESSAGE);
|
|
15232
15211
|
}
|
|
15233
15212
|
}
|
|
15234
15213
|
|
|
@@ -15932,16 +15911,7 @@ class FirestoreClient {
|
|
|
15932
15911
|
const connection = await this.platform.loadConnection(this.databaseInfo);
|
|
15933
15912
|
const serializer = this.platform.newSerializer(this.databaseInfo.databaseId);
|
|
15934
15913
|
const datastore = new Datastore(this.asyncQueue, connection, this.credentials, serializer);
|
|
15935
|
-
await componentProvider.initialize(
|
|
15936
|
-
asyncQueue: this.asyncQueue,
|
|
15937
|
-
databaseInfo: this.databaseInfo,
|
|
15938
|
-
platform: this.platform,
|
|
15939
|
-
datastore,
|
|
15940
|
-
clientId: this.clientId,
|
|
15941
|
-
initialUser: user,
|
|
15942
|
-
maxConcurrentLimboResolutions: MAX_CONCURRENT_LIMBO_RESOLUTIONS,
|
|
15943
|
-
persistenceSettings
|
|
15944
|
-
});
|
|
15914
|
+
await componentProvider.initialize(this.asyncQueue, this.databaseInfo, this.platform, datastore, this.clientId, user, MAX_CONCURRENT_LIMBO_RESOLUTIONS, persistenceSettings);
|
|
15945
15915
|
this.persistence = componentProvider.persistence;
|
|
15946
15916
|
this.sharedClientState = componentProvider.sharedClientState;
|
|
15947
15917
|
this.localStore = componentProvider.localStore;
|
|
@@ -21089,7 +21059,7 @@ class NodePlatform {
|
|
|
21089
21059
|
PlatformSupport.setPlatform(new NodePlatform());
|
|
21090
21060
|
|
|
21091
21061
|
var name = "@firebase/firestore";
|
|
21092
|
-
var version = "1.14.0
|
|
21062
|
+
var version = "1.14.0";
|
|
21093
21063
|
|
|
21094
21064
|
/**
|
|
21095
21065
|
* @license
|