@firebase/database-compat 2.0.2-canary.d8aabaf9e → 2.0.2-canary.dafae52af
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/index.esm2017.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.standalone.js +27 -11
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.js +1 -1
- package/package.json +7 -7
package/dist/index.esm2017.js
CHANGED
@@ -5,7 +5,7 @@ import { errorPrefix, validateArgCount, validateCallback, validateContextObject,
|
|
5
5
|
import { Logger } from '@firebase/logger';
|
6
6
|
|
7
7
|
const name = "@firebase/database-compat";
|
8
|
-
const version = "2.0.2-canary.
|
8
|
+
const version = "2.0.2-canary.dafae52af";
|
9
9
|
|
10
10
|
/**
|
11
11
|
* @license
|
package/dist/index.js
CHANGED
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
11
11
|
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
12
12
|
|
13
13
|
const name = "@firebase/database-compat";
|
14
|
-
const version = "2.0.2-canary.
|
14
|
+
const version = "2.0.2-canary.dafae52af";
|
15
15
|
|
16
16
|
/**
|
17
17
|
* @license
|
package/dist/index.standalone.js
CHANGED
@@ -3710,7 +3710,7 @@ function isVersionServiceProvider(provider) {
|
|
3710
3710
|
}
|
3711
3711
|
|
3712
3712
|
const name$q = "@firebase/app";
|
3713
|
-
const version$1 = "0.10.18-canary.
|
3713
|
+
const version$1 = "0.10.18-canary.dafae52af";
|
3714
3714
|
|
3715
3715
|
/**
|
3716
3716
|
* @license
|
@@ -3781,7 +3781,7 @@ const name$2 = "@firebase/vertexai";
|
|
3781
3781
|
const name$1 = "@firebase/firestore-compat";
|
3782
3782
|
|
3783
3783
|
const name = "firebase";
|
3784
|
-
const version = "11.2.0-canary.
|
3784
|
+
const version = "11.2.0-canary.dafae52af";
|
3785
3785
|
|
3786
3786
|
/**
|
3787
3787
|
* @license
|
@@ -4562,8 +4562,7 @@ function computeKey(app) {
|
|
4562
4562
|
* limitations under the License.
|
4563
4563
|
*/
|
4564
4564
|
const MAX_HEADER_BYTES = 1024;
|
4565
|
-
|
4566
|
-
const STORED_HEARTBEAT_RETENTION_MAX_MILLIS = 30 * 24 * 60 * 60 * 1000;
|
4565
|
+
const MAX_NUM_STORED_HEARTBEATS = 30;
|
4567
4566
|
class HeartbeatServiceImpl {
|
4568
4567
|
constructor(container) {
|
4569
4568
|
this.container = container;
|
@@ -4617,14 +4616,13 @@ class HeartbeatServiceImpl {
|
|
4617
4616
|
else {
|
4618
4617
|
// There is no entry for this date. Create one.
|
4619
4618
|
this._heartbeatsCache.heartbeats.push({ date, agent });
|
4619
|
+
// If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
|
4620
|
+
// Since this is executed each time a heartbeat is pushed, the limit can only be exceeded by one, so only one needs to be removed.
|
4621
|
+
if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
|
4622
|
+
const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
|
4623
|
+
this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
|
4624
|
+
}
|
4620
4625
|
}
|
4621
|
-
// Remove entries older than 30 days.
|
4622
|
-
this._heartbeatsCache.heartbeats =
|
4623
|
-
this._heartbeatsCache.heartbeats.filter(singleDateHeartbeat => {
|
4624
|
-
const hbTimestamp = new Date(singleDateHeartbeat.date).valueOf();
|
4625
|
-
const now = Date.now();
|
4626
|
-
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS;
|
4627
|
-
});
|
4628
4626
|
return this._storage.overwrite(this._heartbeatsCache);
|
4629
4627
|
}
|
4630
4628
|
catch (e) {
|
@@ -4799,6 +4797,24 @@ function countBytes(heartbeatsCache) {
|
|
4799
4797
|
// heartbeatsCache wrapper properties
|
4800
4798
|
JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
|
4801
4799
|
}
|
4800
|
+
/**
|
4801
|
+
* Returns the index of the heartbeat with the earliest date.
|
4802
|
+
* If the heartbeats array is empty, -1 is returned.
|
4803
|
+
*/
|
4804
|
+
function getEarliestHeartbeatIdx(heartbeats) {
|
4805
|
+
if (heartbeats.length === 0) {
|
4806
|
+
return -1;
|
4807
|
+
}
|
4808
|
+
let earliestHeartbeatIdx = 0;
|
4809
|
+
let earliestHeartbeatDate = heartbeats[0].date;
|
4810
|
+
for (let i = 1; i < heartbeats.length; i++) {
|
4811
|
+
if (heartbeats[i].date < earliestHeartbeatDate) {
|
4812
|
+
earliestHeartbeatDate = heartbeats[i].date;
|
4813
|
+
earliestHeartbeatIdx = i;
|
4814
|
+
}
|
4815
|
+
}
|
4816
|
+
return earliestHeartbeatIdx;
|
4817
|
+
}
|
4802
4818
|
|
4803
4819
|
/**
|
4804
4820
|
* @license
|