@firebase/firestore 4.7.14 → 4.7.15
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/firestore/src/index/index_entry.d.ts +22 -5
- package/dist/firestore/src/local/indexeddb_schema.d.ts +7 -5
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +12 -3
- package/dist/index.cjs.js +1888 -1837
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +1889 -1838
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +115 -52
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +116 -53
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1932 -1881
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/index/index_entry.d.ts +22 -5
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +7 -5
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +12 -3
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/package.json +8 -6
package/dist/index.node.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import { _getProvider, getApp, _removeServiceInstance, _registerComponent, regis
|
|
|
2
2
|
import { Component } from '@firebase/component';
|
|
3
3
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
4
|
import { inspect, TextEncoder, TextDecoder } from 'util';
|
|
5
|
-
import { FirebaseError, isCloudWorkstation, deepEqual, pingServer, updateEmulatorBanner, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort, getGlobal, isIndexedDBAvailable, getUA, isSafari } from '@firebase/util';
|
|
5
|
+
import { FirebaseError, isCloudWorkstation, deepEqual, pingServer, updateEmulatorBanner, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort, getGlobal, isIndexedDBAvailable, getUA, isSafari, isSafariOrWebkit } from '@firebase/util';
|
|
6
6
|
import { randomBytes as randomBytes$1 } from 'crypto';
|
|
7
7
|
import { Integer, Md5 } from '@firebase/webchannel-wrapper/bloom-blob';
|
|
8
8
|
import * as grpc from '@grpc/grpc-js';
|
|
9
9
|
import * as protoLoader from '@grpc/proto-loader';
|
|
10
10
|
|
|
11
11
|
const name = "@firebase/firestore";
|
|
12
|
-
const version$1 = "4.7.
|
|
12
|
+
const version$1 = "4.7.15";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
@@ -62,7 +62,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
62
62
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
63
63
|
User.MOCK_USER = new User('mock-user');
|
|
64
64
|
|
|
65
|
-
const version = "11.
|
|
65
|
+
const version = "11.8.0";
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* @license
|
|
@@ -3320,9 +3320,13 @@ const V15_STORES = [
|
|
|
3320
3320
|
];
|
|
3321
3321
|
const V16_STORES = V15_STORES;
|
|
3322
3322
|
const V17_STORES = [...V15_STORES, DbGlobalsStore];
|
|
3323
|
+
const V18_STORES = V17_STORES;
|
|
3323
3324
|
/** Returns the object stores for the provided schema. */
|
|
3324
3325
|
function getObjectStores(schemaVersion) {
|
|
3325
|
-
if (schemaVersion ===
|
|
3326
|
+
if (schemaVersion === 18) {
|
|
3327
|
+
return V18_STORES;
|
|
3328
|
+
}
|
|
3329
|
+
else if (schemaVersion === 17) {
|
|
3326
3330
|
return V17_STORES;
|
|
3327
3331
|
}
|
|
3328
3332
|
else if (schemaVersion === 16) {
|
|
@@ -11183,46 +11187,69 @@ class IndexByteEncoder {
|
|
|
11183
11187
|
*/
|
|
11184
11188
|
/** Represents an index entry saved by the SDK in persisted storage. */
|
|
11185
11189
|
class IndexEntry {
|
|
11186
|
-
constructor(
|
|
11187
|
-
this.
|
|
11188
|
-
this.
|
|
11189
|
-
this.
|
|
11190
|
-
this.
|
|
11190
|
+
constructor(_indexId, _documentKey, _arrayValue, _directionalValue) {
|
|
11191
|
+
this._indexId = _indexId;
|
|
11192
|
+
this._documentKey = _documentKey;
|
|
11193
|
+
this._arrayValue = _arrayValue;
|
|
11194
|
+
this._directionalValue = _directionalValue;
|
|
11191
11195
|
}
|
|
11192
11196
|
/**
|
|
11193
11197
|
* Returns an IndexEntry entry that sorts immediately after the current
|
|
11194
11198
|
* directional value.
|
|
11195
11199
|
*/
|
|
11196
11200
|
successor() {
|
|
11197
|
-
const currentLength = this.
|
|
11198
|
-
const newLength = currentLength === 0 || this.
|
|
11201
|
+
const currentLength = this._directionalValue.length;
|
|
11202
|
+
const newLength = currentLength === 0 || this._directionalValue[currentLength - 1] === 255
|
|
11199
11203
|
? currentLength + 1
|
|
11200
11204
|
: currentLength;
|
|
11201
11205
|
const successor = new Uint8Array(newLength);
|
|
11202
|
-
successor.set(this.
|
|
11206
|
+
successor.set(this._directionalValue, 0);
|
|
11203
11207
|
if (newLength !== currentLength) {
|
|
11204
|
-
successor.set([0], this.
|
|
11208
|
+
successor.set([0], this._directionalValue.length);
|
|
11205
11209
|
}
|
|
11206
11210
|
else {
|
|
11207
11211
|
++successor[successor.length - 1];
|
|
11208
11212
|
}
|
|
11209
|
-
return new IndexEntry(this.
|
|
11213
|
+
return new IndexEntry(this._indexId, this._documentKey, this._arrayValue, successor);
|
|
11214
|
+
}
|
|
11215
|
+
// Create a representation of the Index Entry as a DbIndexEntry
|
|
11216
|
+
dbIndexEntry(uid, orderedDocumentKey, documentKey) {
|
|
11217
|
+
return {
|
|
11218
|
+
indexId: this._indexId,
|
|
11219
|
+
uid,
|
|
11220
|
+
arrayValue: encodeKeySafeBytes(this._arrayValue),
|
|
11221
|
+
directionalValue: encodeKeySafeBytes(this._directionalValue),
|
|
11222
|
+
orderedDocumentKey: encodeKeySafeBytes(orderedDocumentKey),
|
|
11223
|
+
documentKey: documentKey.path.toArray()
|
|
11224
|
+
};
|
|
11225
|
+
}
|
|
11226
|
+
// Create a representation of the Index Entry as a DbIndexEntryKey
|
|
11227
|
+
dbIndexEntryKey(uid, orderedDocumentKey, documentKey) {
|
|
11228
|
+
const entry = this.dbIndexEntry(uid, orderedDocumentKey, documentKey);
|
|
11229
|
+
return [
|
|
11230
|
+
entry.indexId,
|
|
11231
|
+
entry.uid,
|
|
11232
|
+
entry.arrayValue,
|
|
11233
|
+
entry.directionalValue,
|
|
11234
|
+
entry.orderedDocumentKey,
|
|
11235
|
+
entry.documentKey
|
|
11236
|
+
];
|
|
11210
11237
|
}
|
|
11211
11238
|
}
|
|
11212
11239
|
function indexEntryComparator(left, right) {
|
|
11213
|
-
let cmp = left.
|
|
11240
|
+
let cmp = left._indexId - right._indexId;
|
|
11214
11241
|
if (cmp !== 0) {
|
|
11215
11242
|
return cmp;
|
|
11216
11243
|
}
|
|
11217
|
-
cmp = compareByteArrays(left.
|
|
11244
|
+
cmp = compareByteArrays(left._arrayValue, right._arrayValue);
|
|
11218
11245
|
if (cmp !== 0) {
|
|
11219
11246
|
return cmp;
|
|
11220
11247
|
}
|
|
11221
|
-
cmp = compareByteArrays(left.
|
|
11248
|
+
cmp = compareByteArrays(left._directionalValue, right._directionalValue);
|
|
11222
11249
|
if (cmp !== 0) {
|
|
11223
11250
|
return cmp;
|
|
11224
11251
|
}
|
|
11225
|
-
return DocumentKey.comparator(left.
|
|
11252
|
+
return DocumentKey.comparator(left._documentKey, right._documentKey);
|
|
11226
11253
|
}
|
|
11227
11254
|
function compareByteArrays(left, right) {
|
|
11228
11255
|
for (let i = 0; i < left.length && i < right.length; ++i) {
|
|
@@ -11233,6 +11260,53 @@ function compareByteArrays(left, right) {
|
|
|
11233
11260
|
}
|
|
11234
11261
|
return left.length - right.length;
|
|
11235
11262
|
}
|
|
11263
|
+
/**
|
|
11264
|
+
* Workaround for WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=292721
|
|
11265
|
+
* Create a key safe representation of Uint8Array values.
|
|
11266
|
+
* If the browser is detected as Safari or WebKit, then
|
|
11267
|
+
* the input array will be converted to "sortable byte string".
|
|
11268
|
+
* Otherwise, the input array will be returned in its original type.
|
|
11269
|
+
*/
|
|
11270
|
+
function encodeKeySafeBytes(array) {
|
|
11271
|
+
if (isSafariOrWebkit()) {
|
|
11272
|
+
return encodeUint8ArrayToSortableString(array);
|
|
11273
|
+
}
|
|
11274
|
+
return array;
|
|
11275
|
+
}
|
|
11276
|
+
/**
|
|
11277
|
+
* Reverts the key safe representation of Uint8Array (created by
|
|
11278
|
+
* encodeKeySafeBytes) to a normal Uint8Array.
|
|
11279
|
+
*/
|
|
11280
|
+
function decodeKeySafeBytes(input) {
|
|
11281
|
+
if (typeof input !== 'string') {
|
|
11282
|
+
return input;
|
|
11283
|
+
}
|
|
11284
|
+
return decodeSortableStringToUint8Array(input);
|
|
11285
|
+
}
|
|
11286
|
+
/**
|
|
11287
|
+
* Encodes a Uint8Array into a "sortable byte string".
|
|
11288
|
+
* A "sortable byte string" sorts in the same order as the Uint8Array.
|
|
11289
|
+
* This works because JS string comparison sorts strings based on code points.
|
|
11290
|
+
*/
|
|
11291
|
+
function encodeUint8ArrayToSortableString(array) {
|
|
11292
|
+
let byteString = '';
|
|
11293
|
+
for (let i = 0; i < array.length; i++) {
|
|
11294
|
+
byteString += String.fromCharCode(array[i]);
|
|
11295
|
+
}
|
|
11296
|
+
return byteString;
|
|
11297
|
+
}
|
|
11298
|
+
/**
|
|
11299
|
+
* Decodes a "sortable byte string" back into a Uint8Array.
|
|
11300
|
+
* A "sortable byte string" is assumed to be created where each character's
|
|
11301
|
+
* Unicode code point directly corresponds to a single byte value (0-255).
|
|
11302
|
+
*/
|
|
11303
|
+
function decodeSortableStringToUint8Array(byteString) {
|
|
11304
|
+
const uint8array = new Uint8Array(byteString.length);
|
|
11305
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
11306
|
+
uint8array[i] = byteString.charCodeAt(i);
|
|
11307
|
+
}
|
|
11308
|
+
return uint8array;
|
|
11309
|
+
}
|
|
11236
11310
|
|
|
11237
11311
|
/**
|
|
11238
11312
|
* @license
|
|
@@ -12255,25 +12329,11 @@ class IndexedDbIndexManager {
|
|
|
12255
12329
|
}
|
|
12256
12330
|
addIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
12257
12331
|
const indexEntries = indexEntriesStore(transaction);
|
|
12258
|
-
return indexEntries.put(
|
|
12259
|
-
indexId: indexEntry.indexId,
|
|
12260
|
-
uid: this.uid,
|
|
12261
|
-
arrayValue: indexEntry.arrayValue,
|
|
12262
|
-
directionalValue: indexEntry.directionalValue,
|
|
12263
|
-
orderedDocumentKey: this.encodeDirectionalKey(fieldIndex, document.key),
|
|
12264
|
-
documentKey: document.key.path.toArray()
|
|
12265
|
-
});
|
|
12332
|
+
return indexEntries.put(indexEntry.dbIndexEntry(this.uid, this.encodeDirectionalKey(fieldIndex, document.key), document.key));
|
|
12266
12333
|
}
|
|
12267
12334
|
deleteIndexEntry(transaction, document, fieldIndex, indexEntry) {
|
|
12268
12335
|
const indexEntries = indexEntriesStore(transaction);
|
|
12269
|
-
return indexEntries.delete(
|
|
12270
|
-
indexEntry.indexId,
|
|
12271
|
-
this.uid,
|
|
12272
|
-
indexEntry.arrayValue,
|
|
12273
|
-
indexEntry.directionalValue,
|
|
12274
|
-
this.encodeDirectionalKey(fieldIndex, document.key),
|
|
12275
|
-
document.key.path.toArray()
|
|
12276
|
-
]);
|
|
12336
|
+
return indexEntries.delete(indexEntry.dbIndexEntryKey(this.uid, this.encodeDirectionalKey(fieldIndex, document.key), document.key));
|
|
12277
12337
|
}
|
|
12278
12338
|
getExistingIndexEntries(transaction, documentKey, fieldIndex) {
|
|
12279
12339
|
const indexEntries = indexEntriesStore(transaction);
|
|
@@ -12284,10 +12344,10 @@ class IndexedDbIndexManager {
|
|
|
12284
12344
|
range: IDBKeyRange.only([
|
|
12285
12345
|
fieldIndex.indexId,
|
|
12286
12346
|
this.uid,
|
|
12287
|
-
this.encodeDirectionalKey(fieldIndex, documentKey)
|
|
12347
|
+
encodeKeySafeBytes(this.encodeDirectionalKey(fieldIndex, documentKey))
|
|
12288
12348
|
])
|
|
12289
12349
|
}, (_, entry) => {
|
|
12290
|
-
results = results.add(new IndexEntry(fieldIndex.indexId, documentKey, entry.arrayValue, entry.directionalValue));
|
|
12350
|
+
results = results.add(new IndexEntry(fieldIndex.indexId, documentKey, decodeKeySafeBytes(entry.arrayValue), decodeKeySafeBytes(entry.directionalValue)));
|
|
12291
12351
|
})
|
|
12292
12352
|
.next(() => results);
|
|
12293
12353
|
}
|
|
@@ -12382,22 +12442,8 @@ class IndexedDbIndexManager {
|
|
|
12382
12442
|
if (this.isRangeMatchable(bounds[i], bounds[i + 1])) {
|
|
12383
12443
|
return [];
|
|
12384
12444
|
}
|
|
12385
|
-
const lowerBound = [
|
|
12386
|
-
|
|
12387
|
-
this.uid,
|
|
12388
|
-
bounds[i].arrayValue,
|
|
12389
|
-
bounds[i].directionalValue,
|
|
12390
|
-
EMPTY_VALUE,
|
|
12391
|
-
[]
|
|
12392
|
-
];
|
|
12393
|
-
const upperBound = [
|
|
12394
|
-
bounds[i + 1].indexId,
|
|
12395
|
-
this.uid,
|
|
12396
|
-
bounds[i + 1].arrayValue,
|
|
12397
|
-
bounds[i + 1].directionalValue,
|
|
12398
|
-
EMPTY_VALUE,
|
|
12399
|
-
[]
|
|
12400
|
-
];
|
|
12445
|
+
const lowerBound = bounds[i].dbIndexEntryKey(this.uid, EMPTY_VALUE, DocumentKey.empty());
|
|
12446
|
+
const upperBound = bounds[i + 1].dbIndexEntryKey(this.uid, EMPTY_VALUE, DocumentKey.empty());
|
|
12401
12447
|
ranges.push(IDBKeyRange.bound(lowerBound, upperBound));
|
|
12402
12448
|
}
|
|
12403
12449
|
return ranges;
|
|
@@ -14231,8 +14277,10 @@ function dbKeyComparator(l, r) {
|
|
|
14231
14277
|
* 14. Add overlays.
|
|
14232
14278
|
* 15. Add indexing support.
|
|
14233
14279
|
* 16. Parse timestamp strings before creating index entries.
|
|
14280
|
+
* 17. TODO(tomandersen)
|
|
14281
|
+
* 18. Encode key safe representations of IndexEntry in DbIndexEntryStore.
|
|
14234
14282
|
*/
|
|
14235
|
-
const SCHEMA_VERSION =
|
|
14283
|
+
const SCHEMA_VERSION = 18;
|
|
14236
14284
|
|
|
14237
14285
|
/**
|
|
14238
14286
|
* @license
|
|
@@ -15888,6 +15936,21 @@ class SchemaConverter {
|
|
|
15888
15936
|
createGlobalsStore(db);
|
|
15889
15937
|
});
|
|
15890
15938
|
}
|
|
15939
|
+
if (fromVersion < 18 && toVersion >= 18) {
|
|
15940
|
+
// Clear the IndexEntryStores on WebKit and Safari to remove possibly
|
|
15941
|
+
// corrupted index entries
|
|
15942
|
+
if (isSafariOrWebkit()) {
|
|
15943
|
+
p = p
|
|
15944
|
+
.next(() => {
|
|
15945
|
+
const indexStateStore = txn.objectStore(DbIndexStateStore);
|
|
15946
|
+
indexStateStore.clear();
|
|
15947
|
+
})
|
|
15948
|
+
.next(() => {
|
|
15949
|
+
const indexEntryStore = txn.objectStore(DbIndexEntryStore);
|
|
15950
|
+
indexEntryStore.clear();
|
|
15951
|
+
});
|
|
15952
|
+
}
|
|
15953
|
+
}
|
|
15891
15954
|
return p;
|
|
15892
15955
|
}
|
|
15893
15956
|
addDocumentGlobal(txn) {
|