@firebase/database 0.13.9 → 0.13.10-canary.09dfc3aac
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/CHANGELOG.md +12 -0
- package/dist/index.esm2017.js +131 -218
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +135 -217
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +134 -216
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +133 -215
- package/dist/index.standalone.js.map +1 -1
- package/dist/internal.d.ts +0 -2
- package/dist/node-esm/index.node.esm.js +131 -218
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/core/view/QueryParams.d.ts +0 -2
- package/dist/node-esm/src/core/view/filter/LimitedFilter.d.ts +6 -0
- package/dist/node-esm/src/core/view/filter/RangedFilter.d.ts +2 -0
- package/dist/src/core/view/QueryParams.d.ts +0 -2
- package/dist/src/core/view/filter/LimitedFilter.d.ts +6 -0
- package/dist/src/core/view/filter/RangedFilter.d.ts +2 -0
- package/package.json +7 -7
package/dist/index.standalone.js
CHANGED
|
@@ -6173,153 +6173,6 @@ var ValueIndex = /** @class */ (function (_super) {
|
|
|
6173
6173
|
}(Index));
|
|
6174
6174
|
var VALUE_INDEX = new ValueIndex();
|
|
6175
6175
|
|
|
6176
|
-
/**
|
|
6177
|
-
* @license
|
|
6178
|
-
* Copyright 2017 Google LLC
|
|
6179
|
-
*
|
|
6180
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6181
|
-
* you may not use this file except in compliance with the License.
|
|
6182
|
-
* You may obtain a copy of the License at
|
|
6183
|
-
*
|
|
6184
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6185
|
-
*
|
|
6186
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
6187
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6188
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6189
|
-
* See the License for the specific language governing permissions and
|
|
6190
|
-
* limitations under the License.
|
|
6191
|
-
*/
|
|
6192
|
-
// Modeled after base64 web-safe chars, but ordered by ASCII.
|
|
6193
|
-
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
|
|
6194
|
-
var MIN_PUSH_CHAR = '-';
|
|
6195
|
-
var MAX_PUSH_CHAR = 'z';
|
|
6196
|
-
var MAX_KEY_LEN = 786;
|
|
6197
|
-
/**
|
|
6198
|
-
* Fancy ID generator that creates 20-character string identifiers with the
|
|
6199
|
-
* following properties:
|
|
6200
|
-
*
|
|
6201
|
-
* 1. They're based on timestamp so that they sort *after* any existing ids.
|
|
6202
|
-
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
|
|
6203
|
-
* collide with other clients' IDs.
|
|
6204
|
-
* 3. They sort *lexicographically* (so the timestamp is converted to characters
|
|
6205
|
-
* that will sort properly).
|
|
6206
|
-
* 4. They're monotonically increasing. Even if you generate more than one in
|
|
6207
|
-
* the same timestamp, the latter ones will sort after the former ones. We do
|
|
6208
|
-
* this by using the previous random bits but "incrementing" them by 1 (only
|
|
6209
|
-
* in the case of a timestamp collision).
|
|
6210
|
-
*/
|
|
6211
|
-
var nextPushId = (function () {
|
|
6212
|
-
// Timestamp of last push, used to prevent local collisions if you push twice
|
|
6213
|
-
// in one ms.
|
|
6214
|
-
var lastPushTime = 0;
|
|
6215
|
-
// We generate 72-bits of randomness which get turned into 12 characters and
|
|
6216
|
-
// appended to the timestamp to prevent collisions with other clients. We
|
|
6217
|
-
// store the last characters we generated because in the event of a collision,
|
|
6218
|
-
// we'll use those same characters except "incremented" by one.
|
|
6219
|
-
var lastRandChars = [];
|
|
6220
|
-
return function (now) {
|
|
6221
|
-
var duplicateTime = now === lastPushTime;
|
|
6222
|
-
lastPushTime = now;
|
|
6223
|
-
var i;
|
|
6224
|
-
var timeStampChars = new Array(8);
|
|
6225
|
-
for (i = 7; i >= 0; i--) {
|
|
6226
|
-
timeStampChars[i] = PUSH_CHARS.charAt(now % 64);
|
|
6227
|
-
// NOTE: Can't use << here because javascript will convert to int and lose
|
|
6228
|
-
// the upper bits.
|
|
6229
|
-
now = Math.floor(now / 64);
|
|
6230
|
-
}
|
|
6231
|
-
util.assert(now === 0, 'Cannot push at time == 0');
|
|
6232
|
-
var id = timeStampChars.join('');
|
|
6233
|
-
if (!duplicateTime) {
|
|
6234
|
-
for (i = 0; i < 12; i++) {
|
|
6235
|
-
lastRandChars[i] = Math.floor(Math.random() * 64);
|
|
6236
|
-
}
|
|
6237
|
-
}
|
|
6238
|
-
else {
|
|
6239
|
-
// If the timestamp hasn't changed since last push, use the same random
|
|
6240
|
-
// number, except incremented by 1.
|
|
6241
|
-
for (i = 11; i >= 0 && lastRandChars[i] === 63; i--) {
|
|
6242
|
-
lastRandChars[i] = 0;
|
|
6243
|
-
}
|
|
6244
|
-
lastRandChars[i]++;
|
|
6245
|
-
}
|
|
6246
|
-
for (i = 0; i < 12; i++) {
|
|
6247
|
-
id += PUSH_CHARS.charAt(lastRandChars[i]);
|
|
6248
|
-
}
|
|
6249
|
-
util.assert(id.length === 20, 'nextPushId: Length should be 20.');
|
|
6250
|
-
return id;
|
|
6251
|
-
};
|
|
6252
|
-
})();
|
|
6253
|
-
var successor = function (key) {
|
|
6254
|
-
if (key === '' + INTEGER_32_MAX) {
|
|
6255
|
-
// See https://firebase.google.com/docs/database/web/lists-of-data#data-order
|
|
6256
|
-
return MIN_PUSH_CHAR;
|
|
6257
|
-
}
|
|
6258
|
-
var keyAsInt = tryParseInt(key);
|
|
6259
|
-
if (keyAsInt != null) {
|
|
6260
|
-
return '' + (keyAsInt + 1);
|
|
6261
|
-
}
|
|
6262
|
-
var next = new Array(key.length);
|
|
6263
|
-
for (var i_1 = 0; i_1 < next.length; i_1++) {
|
|
6264
|
-
next[i_1] = key.charAt(i_1);
|
|
6265
|
-
}
|
|
6266
|
-
if (next.length < MAX_KEY_LEN) {
|
|
6267
|
-
next.push(MIN_PUSH_CHAR);
|
|
6268
|
-
return next.join('');
|
|
6269
|
-
}
|
|
6270
|
-
var i = next.length - 1;
|
|
6271
|
-
while (i >= 0 && next[i] === MAX_PUSH_CHAR) {
|
|
6272
|
-
i--;
|
|
6273
|
-
}
|
|
6274
|
-
// `successor` was called on the largest possible key, so return the
|
|
6275
|
-
// MAX_NAME, which sorts larger than all keys.
|
|
6276
|
-
if (i === -1) {
|
|
6277
|
-
return MAX_NAME;
|
|
6278
|
-
}
|
|
6279
|
-
var source = next[i];
|
|
6280
|
-
var sourcePlusOne = PUSH_CHARS.charAt(PUSH_CHARS.indexOf(source) + 1);
|
|
6281
|
-
next[i] = sourcePlusOne;
|
|
6282
|
-
return next.slice(0, i + 1).join('');
|
|
6283
|
-
};
|
|
6284
|
-
// `key` is assumed to be non-empty.
|
|
6285
|
-
var predecessor = function (key) {
|
|
6286
|
-
if (key === '' + INTEGER_32_MIN) {
|
|
6287
|
-
return MIN_NAME;
|
|
6288
|
-
}
|
|
6289
|
-
var keyAsInt = tryParseInt(key);
|
|
6290
|
-
if (keyAsInt != null) {
|
|
6291
|
-
return '' + (keyAsInt - 1);
|
|
6292
|
-
}
|
|
6293
|
-
var next = new Array(key.length);
|
|
6294
|
-
for (var i = 0; i < next.length; i++) {
|
|
6295
|
-
next[i] = key.charAt(i);
|
|
6296
|
-
}
|
|
6297
|
-
// If `key` ends in `MIN_PUSH_CHAR`, the largest key lexicographically
|
|
6298
|
-
// smaller than `key`, is `key[0:key.length - 1]`. The next key smaller
|
|
6299
|
-
// than that, `predecessor(predecessor(key))`, is
|
|
6300
|
-
//
|
|
6301
|
-
// `key[0:key.length - 2] + (key[key.length - 1] - 1) + \
|
|
6302
|
-
// { MAX_PUSH_CHAR repeated MAX_KEY_LEN - (key.length - 1) times }
|
|
6303
|
-
//
|
|
6304
|
-
// analogous to increment/decrement for base-10 integers.
|
|
6305
|
-
//
|
|
6306
|
-
// This works because lexigographic comparison works character-by-character,
|
|
6307
|
-
// using length as a tie-breaker if one key is a prefix of the other.
|
|
6308
|
-
if (next[next.length - 1] === MIN_PUSH_CHAR) {
|
|
6309
|
-
if (next.length === 1) {
|
|
6310
|
-
// See https://firebase.google.com/docs/database/web/lists-of-data#orderbykey
|
|
6311
|
-
return '' + INTEGER_32_MAX;
|
|
6312
|
-
}
|
|
6313
|
-
delete next[next.length - 1];
|
|
6314
|
-
return next.join('');
|
|
6315
|
-
}
|
|
6316
|
-
// Replace the last character with it's immediate predecessor, and
|
|
6317
|
-
// fill the suffix of the key with MAX_PUSH_CHAR. This is the
|
|
6318
|
-
// lexicographically largest possible key smaller than `key`.
|
|
6319
|
-
next[next.length - 1] = PUSH_CHARS.charAt(PUSH_CHARS.indexOf(next[next.length - 1]) - 1);
|
|
6320
|
-
return next.join('') + MAX_PUSH_CHAR.repeat(MAX_KEY_LEN - next.length);
|
|
6321
|
-
};
|
|
6322
|
-
|
|
6323
6176
|
/**
|
|
6324
6177
|
* @license
|
|
6325
6178
|
* Copyright 2017 Google LLC
|
|
@@ -6489,6 +6342,8 @@ var RangedFilter = /** @class */ (function () {
|
|
|
6489
6342
|
this.index_ = params.getIndex();
|
|
6490
6343
|
this.startPost_ = RangedFilter.getStartPost_(params);
|
|
6491
6344
|
this.endPost_ = RangedFilter.getEndPost_(params);
|
|
6345
|
+
this.startIsInclusive_ = !params.startAfterSet_;
|
|
6346
|
+
this.endIsInclusive_ = !params.endBeforeSet_;
|
|
6492
6347
|
}
|
|
6493
6348
|
RangedFilter.prototype.getStartPost = function () {
|
|
6494
6349
|
return this.startPost_;
|
|
@@ -6497,8 +6352,13 @@ var RangedFilter = /** @class */ (function () {
|
|
|
6497
6352
|
return this.endPost_;
|
|
6498
6353
|
};
|
|
6499
6354
|
RangedFilter.prototype.matches = function (node) {
|
|
6500
|
-
|
|
6501
|
-
this.index_.compare(
|
|
6355
|
+
var isWithinStart = this.startIsInclusive_
|
|
6356
|
+
? this.index_.compare(this.getStartPost(), node) <= 0
|
|
6357
|
+
: this.index_.compare(this.getStartPost(), node) < 0;
|
|
6358
|
+
var isWithinEnd = this.endIsInclusive_
|
|
6359
|
+
? this.index_.compare(node, this.getEndPost()) <= 0
|
|
6360
|
+
: this.index_.compare(node, this.getEndPost()) < 0;
|
|
6361
|
+
return isWithinStart && isWithinEnd;
|
|
6502
6362
|
};
|
|
6503
6363
|
RangedFilter.prototype.updateChild = function (snap, key, newChild, affectedPath, source, optChangeAccumulator) {
|
|
6504
6364
|
if (!this.matches(new NamedNode(key, newChild))) {
|
|
@@ -6577,10 +6437,27 @@ var RangedFilter = /** @class */ (function () {
|
|
|
6577
6437
|
*/
|
|
6578
6438
|
var LimitedFilter = /** @class */ (function () {
|
|
6579
6439
|
function LimitedFilter(params) {
|
|
6440
|
+
var _this = this;
|
|
6441
|
+
this.withinDirectionalStart = function (node) {
|
|
6442
|
+
return _this.reverse_ ? _this.withinEndPost(node) : _this.withinStartPost(node);
|
|
6443
|
+
};
|
|
6444
|
+
this.withinDirectionalEnd = function (node) {
|
|
6445
|
+
return _this.reverse_ ? _this.withinStartPost(node) : _this.withinEndPost(node);
|
|
6446
|
+
};
|
|
6447
|
+
this.withinStartPost = function (node) {
|
|
6448
|
+
var compareRes = _this.index_.compare(_this.rangedFilter_.getStartPost(), node);
|
|
6449
|
+
return _this.startIsInclusive_ ? compareRes <= 0 : compareRes < 0;
|
|
6450
|
+
};
|
|
6451
|
+
this.withinEndPost = function (node) {
|
|
6452
|
+
var compareRes = _this.index_.compare(node, _this.rangedFilter_.getEndPost());
|
|
6453
|
+
return _this.endIsInclusive_ ? compareRes <= 0 : compareRes < 0;
|
|
6454
|
+
};
|
|
6580
6455
|
this.rangedFilter_ = new RangedFilter(params);
|
|
6581
6456
|
this.index_ = params.getIndex();
|
|
6582
6457
|
this.limit_ = params.getLimit();
|
|
6583
6458
|
this.reverse_ = !params.isViewFromLeft();
|
|
6459
|
+
this.startIsInclusive_ = !params.startAfterSet_;
|
|
6460
|
+
this.endIsInclusive_ = !params.endBeforeSet_;
|
|
6584
6461
|
}
|
|
6585
6462
|
LimitedFilter.prototype.updateChild = function (snap, key, newChild, affectedPath, source, optChangeAccumulator) {
|
|
6586
6463
|
if (!this.rangedFilter_.matches(new NamedNode(key, newChild))) {
|
|
@@ -6621,23 +6498,18 @@ var LimitedFilter = /** @class */ (function () {
|
|
|
6621
6498
|
var count = 0;
|
|
6622
6499
|
while (iterator.hasNext() && count < this.limit_) {
|
|
6623
6500
|
var next = iterator.getNext();
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
this.index_.compare(this.rangedFilter_.getStartPost(), next) <= 0;
|
|
6501
|
+
if (!this.withinDirectionalStart(next)) {
|
|
6502
|
+
// if we have not reached the start, skip to the next element
|
|
6503
|
+
continue;
|
|
6628
6504
|
}
|
|
6629
|
-
else {
|
|
6630
|
-
|
|
6631
|
-
|
|
6505
|
+
else if (!this.withinDirectionalEnd(next)) {
|
|
6506
|
+
// if we have reached the end, stop adding elements
|
|
6507
|
+
break;
|
|
6632
6508
|
}
|
|
6633
|
-
|
|
6509
|
+
else {
|
|
6634
6510
|
filtered = filtered.updateImmediateChild(next.name, next.node);
|
|
6635
6511
|
count++;
|
|
6636
6512
|
}
|
|
6637
|
-
else {
|
|
6638
|
-
// if we have reached the end post, we cannot keep adding elemments
|
|
6639
|
-
break;
|
|
6640
|
-
}
|
|
6641
6513
|
}
|
|
6642
6514
|
}
|
|
6643
6515
|
else {
|
|
@@ -6645,32 +6517,19 @@ var LimitedFilter = /** @class */ (function () {
|
|
|
6645
6517
|
filtered = newSnap.withIndex(this.index_);
|
|
6646
6518
|
// Don't support priorities on queries
|
|
6647
6519
|
filtered = filtered.updatePriority(ChildrenNode.EMPTY_NODE);
|
|
6648
|
-
var startPost = void 0;
|
|
6649
|
-
var endPost = void 0;
|
|
6650
|
-
var cmp = void 0;
|
|
6651
6520
|
var iterator = void 0;
|
|
6652
6521
|
if (this.reverse_) {
|
|
6653
6522
|
iterator = filtered.getReverseIterator(this.index_);
|
|
6654
|
-
startPost = this.rangedFilter_.getEndPost();
|
|
6655
|
-
endPost = this.rangedFilter_.getStartPost();
|
|
6656
|
-
var indexCompare_1 = this.index_.getCompare();
|
|
6657
|
-
cmp = function (a, b) { return indexCompare_1(b, a); };
|
|
6658
6523
|
}
|
|
6659
6524
|
else {
|
|
6660
6525
|
iterator = filtered.getIterator(this.index_);
|
|
6661
|
-
startPost = this.rangedFilter_.getStartPost();
|
|
6662
|
-
endPost = this.rangedFilter_.getEndPost();
|
|
6663
|
-
cmp = this.index_.getCompare();
|
|
6664
6526
|
}
|
|
6665
6527
|
var count = 0;
|
|
6666
|
-
var foundStartPost = false;
|
|
6667
6528
|
while (iterator.hasNext()) {
|
|
6668
6529
|
var next = iterator.getNext();
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
}
|
|
6673
|
-
var inRange = foundStartPost && count < this.limit_ && cmp(next, endPost) <= 0;
|
|
6530
|
+
var inRange = count < this.limit_ &&
|
|
6531
|
+
this.withinDirectionalStart(next) &&
|
|
6532
|
+
this.withinDirectionalEnd(next);
|
|
6674
6533
|
if (inRange) {
|
|
6675
6534
|
count++;
|
|
6676
6535
|
}
|
|
@@ -6802,10 +6661,10 @@ var QueryParams = /** @class */ (function () {
|
|
|
6802
6661
|
this.limitSet_ = false;
|
|
6803
6662
|
this.startSet_ = false;
|
|
6804
6663
|
this.startNameSet_ = false;
|
|
6805
|
-
this.startAfterSet_ = false;
|
|
6664
|
+
this.startAfterSet_ = false; // can only be true if startSet_ is true
|
|
6806
6665
|
this.endSet_ = false;
|
|
6807
6666
|
this.endNameSet_ = false;
|
|
6808
|
-
this.endBeforeSet_ = false;
|
|
6667
|
+
this.endBeforeSet_ = false; // can only be true if endSet_ is true
|
|
6809
6668
|
this.limit_ = 0;
|
|
6810
6669
|
this.viewFrom_ = '';
|
|
6811
6670
|
this.indexStartValue_ = null;
|
|
@@ -6817,12 +6676,6 @@ var QueryParams = /** @class */ (function () {
|
|
|
6817
6676
|
QueryParams.prototype.hasStart = function () {
|
|
6818
6677
|
return this.startSet_;
|
|
6819
6678
|
};
|
|
6820
|
-
QueryParams.prototype.hasStartAfter = function () {
|
|
6821
|
-
return this.startAfterSet_;
|
|
6822
|
-
};
|
|
6823
|
-
QueryParams.prototype.hasEndBefore = function () {
|
|
6824
|
-
return this.endBeforeSet_;
|
|
6825
|
-
};
|
|
6826
6679
|
/**
|
|
6827
6680
|
* @returns True if it would return from left.
|
|
6828
6681
|
*/
|
|
@@ -6911,10 +6764,12 @@ var QueryParams = /** @class */ (function () {
|
|
|
6911
6764
|
copy.limitSet_ = this.limitSet_;
|
|
6912
6765
|
copy.limit_ = this.limit_;
|
|
6913
6766
|
copy.startSet_ = this.startSet_;
|
|
6767
|
+
copy.startAfterSet_ = this.startAfterSet_;
|
|
6914
6768
|
copy.indexStartValue_ = this.indexStartValue_;
|
|
6915
6769
|
copy.startNameSet_ = this.startNameSet_;
|
|
6916
6770
|
copy.indexStartName_ = this.indexStartName_;
|
|
6917
6771
|
copy.endSet_ = this.endSet_;
|
|
6772
|
+
copy.endBeforeSet_ = this.endBeforeSet_;
|
|
6918
6773
|
copy.indexEndValue_ = this.indexEndValue_;
|
|
6919
6774
|
copy.endNameSet_ = this.endNameSet_;
|
|
6920
6775
|
copy.indexEndName_ = this.indexEndName_;
|
|
@@ -6968,21 +6823,11 @@ function queryParamsStartAt(queryParams, indexValue, key) {
|
|
|
6968
6823
|
}
|
|
6969
6824
|
function queryParamsStartAfter(queryParams, indexValue, key) {
|
|
6970
6825
|
var params;
|
|
6971
|
-
if (queryParams.index_ === KEY_INDEX) {
|
|
6972
|
-
if (typeof indexValue === 'string') {
|
|
6973
|
-
indexValue = successor(indexValue);
|
|
6974
|
-
}
|
|
6826
|
+
if (queryParams.index_ === KEY_INDEX || !!key) {
|
|
6975
6827
|
params = queryParamsStartAt(queryParams, indexValue, key);
|
|
6976
6828
|
}
|
|
6977
6829
|
else {
|
|
6978
|
-
|
|
6979
|
-
if (key == null) {
|
|
6980
|
-
childKey = MAX_NAME;
|
|
6981
|
-
}
|
|
6982
|
-
else {
|
|
6983
|
-
childKey = successor(key);
|
|
6984
|
-
}
|
|
6985
|
-
params = queryParamsStartAt(queryParams, indexValue, childKey);
|
|
6830
|
+
params = queryParamsStartAt(queryParams, indexValue, MAX_NAME);
|
|
6986
6831
|
}
|
|
6987
6832
|
params.startAfterSet_ = true;
|
|
6988
6833
|
return params;
|
|
@@ -7005,22 +6850,12 @@ function queryParamsEndAt(queryParams, indexValue, key) {
|
|
|
7005
6850
|
return newParams;
|
|
7006
6851
|
}
|
|
7007
6852
|
function queryParamsEndBefore(queryParams, indexValue, key) {
|
|
7008
|
-
var childKey;
|
|
7009
6853
|
var params;
|
|
7010
|
-
if (queryParams.index_ === KEY_INDEX) {
|
|
7011
|
-
if (typeof indexValue === 'string') {
|
|
7012
|
-
indexValue = predecessor(indexValue);
|
|
7013
|
-
}
|
|
6854
|
+
if (queryParams.index_ === KEY_INDEX || !!key) {
|
|
7014
6855
|
params = queryParamsEndAt(queryParams, indexValue, key);
|
|
7015
6856
|
}
|
|
7016
6857
|
else {
|
|
7017
|
-
|
|
7018
|
-
childKey = MIN_NAME;
|
|
7019
|
-
}
|
|
7020
|
-
else {
|
|
7021
|
-
childKey = predecessor(key);
|
|
7022
|
-
}
|
|
7023
|
-
params = queryParamsEndAt(queryParams, indexValue, childKey);
|
|
6858
|
+
params = queryParamsEndAt(queryParams, indexValue, MIN_NAME);
|
|
7024
6859
|
}
|
|
7025
6860
|
params.endBeforeSet_ = true;
|
|
7026
6861
|
return params;
|
|
@@ -7056,17 +6891,21 @@ function queryParamsToRestQueryStringParameters(queryParams) {
|
|
|
7056
6891
|
}
|
|
7057
6892
|
qs["orderBy" /* ORDER_BY */] = util.stringify(orderBy);
|
|
7058
6893
|
if (queryParams.startSet_) {
|
|
7059
|
-
|
|
6894
|
+
var startParam = queryParams.startAfterSet_
|
|
6895
|
+
? "startAfter" /* START_AFTER */
|
|
6896
|
+
: "startAt" /* START_AT */;
|
|
6897
|
+
qs[startParam] = util.stringify(queryParams.indexStartValue_);
|
|
7060
6898
|
if (queryParams.startNameSet_) {
|
|
7061
|
-
qs[
|
|
7062
|
-
',' + util.stringify(queryParams.indexStartName_);
|
|
6899
|
+
qs[startParam] += ',' + util.stringify(queryParams.indexStartName_);
|
|
7063
6900
|
}
|
|
7064
6901
|
}
|
|
7065
6902
|
if (queryParams.endSet_) {
|
|
7066
|
-
|
|
6903
|
+
var endParam = queryParams.endBeforeSet_
|
|
6904
|
+
? "endBefore" /* END_BEFORE */
|
|
6905
|
+
: "endAt" /* END_AT */;
|
|
6906
|
+
qs[endParam] = util.stringify(queryParams.indexEndValue_);
|
|
7067
6907
|
if (queryParams.endNameSet_) {
|
|
7068
|
-
qs[
|
|
7069
|
-
',' + util.stringify(queryParams.indexEndName_);
|
|
6908
|
+
qs[endParam] += ',' + util.stringify(queryParams.indexEndName_);
|
|
7070
6909
|
}
|
|
7071
6910
|
}
|
|
7072
6911
|
if (queryParams.limitSet_) {
|
|
@@ -7088,12 +6927,16 @@ function queryParamsGetQueryObject(queryParams) {
|
|
|
7088
6927
|
obj["sn" /* INDEX_START_NAME */] =
|
|
7089
6928
|
queryParams.indexStartName_;
|
|
7090
6929
|
}
|
|
6930
|
+
obj["sin" /* INDEX_START_IS_INCLUSIVE */] =
|
|
6931
|
+
!queryParams.startAfterSet_;
|
|
7091
6932
|
}
|
|
7092
6933
|
if (queryParams.endSet_) {
|
|
7093
6934
|
obj["ep" /* INDEX_END_VALUE */] = queryParams.indexEndValue_;
|
|
7094
6935
|
if (queryParams.endNameSet_) {
|
|
7095
6936
|
obj["en" /* INDEX_END_NAME */] = queryParams.indexEndName_;
|
|
7096
6937
|
}
|
|
6938
|
+
obj["ein" /* INDEX_END_IS_INCLUSIVE */] =
|
|
6939
|
+
!queryParams.endBeforeSet_;
|
|
7097
6940
|
}
|
|
7098
6941
|
if (queryParams.limitSet_) {
|
|
7099
6942
|
obj["l" /* LIMIT */] = queryParams.limit_;
|
|
@@ -12367,6 +12210,81 @@ var parseDatabaseURL = function (dataURL) {
|
|
|
12367
12210
|
};
|
|
12368
12211
|
};
|
|
12369
12212
|
|
|
12213
|
+
/**
|
|
12214
|
+
* @license
|
|
12215
|
+
* Copyright 2017 Google LLC
|
|
12216
|
+
*
|
|
12217
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12218
|
+
* you may not use this file except in compliance with the License.
|
|
12219
|
+
* You may obtain a copy of the License at
|
|
12220
|
+
*
|
|
12221
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12222
|
+
*
|
|
12223
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12224
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12225
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12226
|
+
* See the License for the specific language governing permissions and
|
|
12227
|
+
* limitations under the License.
|
|
12228
|
+
*/
|
|
12229
|
+
// Modeled after base64 web-safe chars, but ordered by ASCII.
|
|
12230
|
+
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
|
|
12231
|
+
/**
|
|
12232
|
+
* Fancy ID generator that creates 20-character string identifiers with the
|
|
12233
|
+
* following properties:
|
|
12234
|
+
*
|
|
12235
|
+
* 1. They're based on timestamp so that they sort *after* any existing ids.
|
|
12236
|
+
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
|
|
12237
|
+
* collide with other clients' IDs.
|
|
12238
|
+
* 3. They sort *lexicographically* (so the timestamp is converted to characters
|
|
12239
|
+
* that will sort properly).
|
|
12240
|
+
* 4. They're monotonically increasing. Even if you generate more than one in
|
|
12241
|
+
* the same timestamp, the latter ones will sort after the former ones. We do
|
|
12242
|
+
* this by using the previous random bits but "incrementing" them by 1 (only
|
|
12243
|
+
* in the case of a timestamp collision).
|
|
12244
|
+
*/
|
|
12245
|
+
var nextPushId = (function () {
|
|
12246
|
+
// Timestamp of last push, used to prevent local collisions if you push twice
|
|
12247
|
+
// in one ms.
|
|
12248
|
+
var lastPushTime = 0;
|
|
12249
|
+
// We generate 72-bits of randomness which get turned into 12 characters and
|
|
12250
|
+
// appended to the timestamp to prevent collisions with other clients. We
|
|
12251
|
+
// store the last characters we generated because in the event of a collision,
|
|
12252
|
+
// we'll use those same characters except "incremented" by one.
|
|
12253
|
+
var lastRandChars = [];
|
|
12254
|
+
return function (now) {
|
|
12255
|
+
var duplicateTime = now === lastPushTime;
|
|
12256
|
+
lastPushTime = now;
|
|
12257
|
+
var i;
|
|
12258
|
+
var timeStampChars = new Array(8);
|
|
12259
|
+
for (i = 7; i >= 0; i--) {
|
|
12260
|
+
timeStampChars[i] = PUSH_CHARS.charAt(now % 64);
|
|
12261
|
+
// NOTE: Can't use << here because javascript will convert to int and lose
|
|
12262
|
+
// the upper bits.
|
|
12263
|
+
now = Math.floor(now / 64);
|
|
12264
|
+
}
|
|
12265
|
+
util.assert(now === 0, 'Cannot push at time == 0');
|
|
12266
|
+
var id = timeStampChars.join('');
|
|
12267
|
+
if (!duplicateTime) {
|
|
12268
|
+
for (i = 0; i < 12; i++) {
|
|
12269
|
+
lastRandChars[i] = Math.floor(Math.random() * 64);
|
|
12270
|
+
}
|
|
12271
|
+
}
|
|
12272
|
+
else {
|
|
12273
|
+
// If the timestamp hasn't changed since last push, use the same random
|
|
12274
|
+
// number, except incremented by 1.
|
|
12275
|
+
for (i = 11; i >= 0 && lastRandChars[i] === 63; i--) {
|
|
12276
|
+
lastRandChars[i] = 0;
|
|
12277
|
+
}
|
|
12278
|
+
lastRandChars[i]++;
|
|
12279
|
+
}
|
|
12280
|
+
for (i = 0; i < 12; i++) {
|
|
12281
|
+
id += PUSH_CHARS.charAt(lastRandChars[i]);
|
|
12282
|
+
}
|
|
12283
|
+
util.assert(id.length === 20, 'nextPushId: Length should be 20.');
|
|
12284
|
+
return id;
|
|
12285
|
+
};
|
|
12286
|
+
})();
|
|
12287
|
+
|
|
12370
12288
|
/**
|
|
12371
12289
|
* @license
|
|
12372
12290
|
* Copyright 2017 Google LLC
|