@firebase/app 0.13.1 → 0.13.2-canary.25b60fdaa
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/app/src/api.d.ts +30 -2
- package/dist/app/src/global_index.d.ts +42 -5
- package/dist/app/src/internal.d.ts +12 -3
- package/dist/app-public.d.ts +33 -2
- package/dist/app.d.ts +43 -4
- package/dist/esm/app/src/api.d.ts +30 -2
- package/dist/esm/app/src/internal.d.ts +12 -3
- package/dist/esm/{index.esm2017.js → index.esm.js} +72 -38
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/index.cjs.js +71 -36
- package/dist/index.cjs.js.map +1 -1
- package/package.json +10 -8
- package/dist/esm/index.esm2017.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -57,11 +57,11 @@ class PlatformLoggerServiceImpl {
|
|
|
57
57
|
*/
|
|
58
58
|
function isVersionServiceProvider(provider) {
|
|
59
59
|
const component = provider.getComponent();
|
|
60
|
-
return
|
|
60
|
+
return component?.type === "VERSION" /* ComponentType.VERSION */;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const name$q = "@firebase/app";
|
|
64
|
-
const version$1 = "0.13.
|
|
64
|
+
const version$1 = "0.13.2-canary.25b60fdaa";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -132,7 +132,7 @@ const name$2 = "@firebase/ai";
|
|
|
132
132
|
const name$1 = "@firebase/firestore-compat";
|
|
133
133
|
|
|
134
134
|
const name = "firebase";
|
|
135
|
-
const version = "11.
|
|
135
|
+
const version = "11.10.0-canary.25b60fdaa";
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* @license
|
|
@@ -292,7 +292,7 @@ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NA
|
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
294
|
*
|
|
295
|
-
* @param obj - an object of type FirebaseApp or
|
|
295
|
+
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
296
296
|
*
|
|
297
297
|
* @returns true if the provide object is of type FirebaseApp.
|
|
298
298
|
*
|
|
@@ -301,6 +301,23 @@ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NA
|
|
|
301
301
|
function _isFirebaseApp(obj) {
|
|
302
302
|
return obj.options !== undefined;
|
|
303
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
*
|
|
306
|
+
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
307
|
+
*
|
|
308
|
+
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
309
|
+
*
|
|
310
|
+
* @internal
|
|
311
|
+
*/
|
|
312
|
+
function _isFirebaseServerAppSettings(obj) {
|
|
313
|
+
if (_isFirebaseApp(obj)) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
return ('authIdToken' in obj ||
|
|
317
|
+
'appCheckToken' in obj ||
|
|
318
|
+
'releaseOnDeref' in obj ||
|
|
319
|
+
'automaticDataCollectionEnabled' in obj);
|
|
320
|
+
}
|
|
304
321
|
/**
|
|
305
322
|
*
|
|
306
323
|
* @param obj - an object of type FirebaseApp.
|
|
@@ -379,8 +396,8 @@ const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
|
|
379
396
|
class FirebaseAppImpl {
|
|
380
397
|
constructor(options, config, container) {
|
|
381
398
|
this._isDeleted = false;
|
|
382
|
-
this._options =
|
|
383
|
-
this._config =
|
|
399
|
+
this._options = { ...options };
|
|
400
|
+
this._config = { ...config };
|
|
384
401
|
this._name = config.name;
|
|
385
402
|
this._automaticDataCollectionEnabled =
|
|
386
403
|
config.automaticDataCollectionEnabled;
|
|
@@ -484,7 +501,10 @@ class FirebaseServerAppImpl extends FirebaseAppImpl {
|
|
|
484
501
|
super(appImpl.options, config, container);
|
|
485
502
|
}
|
|
486
503
|
// Now construct the data for the FirebaseServerAppImpl.
|
|
487
|
-
this._serverConfig =
|
|
504
|
+
this._serverConfig = {
|
|
505
|
+
automaticDataCollectionEnabled,
|
|
506
|
+
...serverConfig
|
|
507
|
+
};
|
|
488
508
|
// Ensure that the current time is within the `authIdtoken` window of validity.
|
|
489
509
|
if (this._serverConfig.authIdToken) {
|
|
490
510
|
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
|
|
@@ -580,7 +600,11 @@ function initializeApp(_options, rawConfig = {}) {
|
|
|
580
600
|
const name = rawConfig;
|
|
581
601
|
rawConfig = { name };
|
|
582
602
|
}
|
|
583
|
-
const config =
|
|
603
|
+
const config = {
|
|
604
|
+
name: DEFAULT_ENTRY_NAME,
|
|
605
|
+
automaticDataCollectionEnabled: true,
|
|
606
|
+
...rawConfig
|
|
607
|
+
};
|
|
584
608
|
const name = config.name;
|
|
585
609
|
if (typeof name !== 'string' || !name) {
|
|
586
610
|
throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
|
|
@@ -610,23 +634,36 @@ function initializeApp(_options, rawConfig = {}) {
|
|
|
610
634
|
_apps.set(name, newApp);
|
|
611
635
|
return newApp;
|
|
612
636
|
}
|
|
613
|
-
function initializeServerApp(_options, _serverAppConfig) {
|
|
637
|
+
function initializeServerApp(_options, _serverAppConfig = {}) {
|
|
614
638
|
if (util.isBrowser() && !util.isWebWorker()) {
|
|
615
639
|
// FirebaseServerApp isn't designed to be run in browsers.
|
|
616
640
|
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
|
617
641
|
}
|
|
618
|
-
|
|
619
|
-
|
|
642
|
+
let firebaseOptions;
|
|
643
|
+
let serverAppSettings = _serverAppConfig || {};
|
|
644
|
+
if (_options) {
|
|
645
|
+
if (_isFirebaseApp(_options)) {
|
|
646
|
+
firebaseOptions = _options.options;
|
|
647
|
+
}
|
|
648
|
+
else if (_isFirebaseServerAppSettings(_options)) {
|
|
649
|
+
serverAppSettings = _options;
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
firebaseOptions = _options;
|
|
653
|
+
}
|
|
620
654
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
appOptions = _options.options;
|
|
655
|
+
if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
|
|
656
|
+
serverAppSettings.automaticDataCollectionEnabled = true;
|
|
624
657
|
}
|
|
625
|
-
|
|
626
|
-
|
|
658
|
+
firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
|
|
659
|
+
if (!firebaseOptions) {
|
|
660
|
+
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
627
661
|
}
|
|
628
662
|
// Build an app name based on a hash of the configuration options.
|
|
629
|
-
const nameObj =
|
|
663
|
+
const nameObj = {
|
|
664
|
+
...serverAppSettings,
|
|
665
|
+
...firebaseOptions
|
|
666
|
+
};
|
|
630
667
|
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
|
631
668
|
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
|
632
669
|
if (nameObj.releaseOnDeref !== undefined) {
|
|
@@ -635,7 +672,7 @@ function initializeServerApp(_options, _serverAppConfig) {
|
|
|
635
672
|
const hashCode = (s) => {
|
|
636
673
|
return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
|
|
637
674
|
};
|
|
638
|
-
if (
|
|
675
|
+
if (serverAppSettings.releaseOnDeref !== undefined) {
|
|
639
676
|
if (typeof FinalizationRegistry === 'undefined') {
|
|
640
677
|
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
|
641
678
|
}
|
|
@@ -643,14 +680,14 @@ function initializeServerApp(_options, _serverAppConfig) {
|
|
|
643
680
|
const nameString = '' + hashCode(JSON.stringify(nameObj));
|
|
644
681
|
const existingApp = _serverApps.get(nameString);
|
|
645
682
|
if (existingApp) {
|
|
646
|
-
existingApp.incRefCount(
|
|
683
|
+
existingApp.incRefCount(serverAppSettings.releaseOnDeref);
|
|
647
684
|
return existingApp;
|
|
648
685
|
}
|
|
649
686
|
const container = new component.ComponentContainer(nameString);
|
|
650
687
|
for (const component of _components.values()) {
|
|
651
688
|
container.addComponent(component);
|
|
652
689
|
}
|
|
653
|
-
const newApp = new FirebaseServerAppImpl(
|
|
690
|
+
const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
|
|
654
691
|
_serverApps.set(nameString, newApp);
|
|
655
692
|
return newApp;
|
|
656
693
|
}
|
|
@@ -747,10 +784,9 @@ async function deleteApp(app) {
|
|
|
747
784
|
* @public
|
|
748
785
|
*/
|
|
749
786
|
function registerVersion(libraryKeyOrName, version, variant) {
|
|
750
|
-
var _a;
|
|
751
787
|
// TODO: We can use this check to whitelist strings when/if we set up
|
|
752
788
|
// a good whitelist system.
|
|
753
|
-
let library =
|
|
789
|
+
let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
|
|
754
790
|
if (variant) {
|
|
755
791
|
library += `-${variant}`;
|
|
756
792
|
}
|
|
@@ -866,7 +902,7 @@ async function readHeartbeatsFromIndexedDB(app) {
|
|
|
866
902
|
}
|
|
867
903
|
else {
|
|
868
904
|
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
|
|
869
|
-
originalErrorMessage: e
|
|
905
|
+
originalErrorMessage: e?.message
|
|
870
906
|
});
|
|
871
907
|
logger.warn(idbGetError.message);
|
|
872
908
|
}
|
|
@@ -886,7 +922,7 @@ async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
|
|
|
886
922
|
}
|
|
887
923
|
else {
|
|
888
924
|
const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
|
|
889
|
-
originalErrorMessage: e
|
|
925
|
+
originalErrorMessage: e?.message
|
|
890
926
|
});
|
|
891
927
|
logger.warn(idbGetError.message);
|
|
892
928
|
}
|
|
@@ -942,7 +978,6 @@ class HeartbeatServiceImpl {
|
|
|
942
978
|
* already logged, subsequent calls to this function in the same day will be ignored.
|
|
943
979
|
*/
|
|
944
980
|
async triggerHeartbeat() {
|
|
945
|
-
var _a, _b;
|
|
946
981
|
try {
|
|
947
982
|
const platformLogger = this.container
|
|
948
983
|
.getProvider('platform-logger')
|
|
@@ -951,10 +986,10 @@ class HeartbeatServiceImpl {
|
|
|
951
986
|
// service, not the browser user agent.
|
|
952
987
|
const agent = platformLogger.getPlatformInfoString();
|
|
953
988
|
const date = getUTCDateString();
|
|
954
|
-
if (
|
|
989
|
+
if (this._heartbeatsCache?.heartbeats == null) {
|
|
955
990
|
this._heartbeatsCache = await this._heartbeatsCachePromise;
|
|
956
991
|
// If we failed to construct a heartbeats cache, then return immediately.
|
|
957
|
-
if (
|
|
992
|
+
if (this._heartbeatsCache?.heartbeats == null) {
|
|
958
993
|
return;
|
|
959
994
|
}
|
|
960
995
|
}
|
|
@@ -988,13 +1023,12 @@ class HeartbeatServiceImpl {
|
|
|
988
1023
|
* returns an empty string.
|
|
989
1024
|
*/
|
|
990
1025
|
async getHeartbeatsHeader() {
|
|
991
|
-
var _a;
|
|
992
1026
|
try {
|
|
993
1027
|
if (this._heartbeatsCache === null) {
|
|
994
1028
|
await this._heartbeatsCachePromise;
|
|
995
1029
|
}
|
|
996
1030
|
// If it's still null or the array is empty, there is no data to send.
|
|
997
|
-
if (
|
|
1031
|
+
if (this._heartbeatsCache?.heartbeats == null ||
|
|
998
1032
|
this._heartbeatsCache.heartbeats.length === 0) {
|
|
999
1033
|
return '';
|
|
1000
1034
|
}
|
|
@@ -1095,7 +1129,7 @@ class HeartbeatStorageImpl {
|
|
|
1095
1129
|
}
|
|
1096
1130
|
else {
|
|
1097
1131
|
const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
|
|
1098
|
-
if (idbHeartbeatObject
|
|
1132
|
+
if (idbHeartbeatObject?.heartbeats) {
|
|
1099
1133
|
return idbHeartbeatObject;
|
|
1100
1134
|
}
|
|
1101
1135
|
else {
|
|
@@ -1105,7 +1139,6 @@ class HeartbeatStorageImpl {
|
|
|
1105
1139
|
}
|
|
1106
1140
|
// overwrite the storage with the provided heartbeats
|
|
1107
1141
|
async overwrite(heartbeatsObject) {
|
|
1108
|
-
var _a;
|
|
1109
1142
|
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
1110
1143
|
if (!canUseIndexedDB) {
|
|
1111
1144
|
return;
|
|
@@ -1113,14 +1146,14 @@ class HeartbeatStorageImpl {
|
|
|
1113
1146
|
else {
|
|
1114
1147
|
const existingHeartbeatsObject = await this.read();
|
|
1115
1148
|
return writeHeartbeatsToIndexedDB(this.app, {
|
|
1116
|
-
lastSentHeartbeatDate:
|
|
1149
|
+
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
1150
|
+
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
1117
1151
|
heartbeats: heartbeatsObject.heartbeats
|
|
1118
1152
|
});
|
|
1119
1153
|
}
|
|
1120
1154
|
}
|
|
1121
1155
|
// add heartbeats
|
|
1122
1156
|
async add(heartbeatsObject) {
|
|
1123
|
-
var _a;
|
|
1124
1157
|
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
1125
1158
|
if (!canUseIndexedDB) {
|
|
1126
1159
|
return;
|
|
@@ -1128,7 +1161,8 @@ class HeartbeatStorageImpl {
|
|
|
1128
1161
|
else {
|
|
1129
1162
|
const existingHeartbeatsObject = await this.read();
|
|
1130
1163
|
return writeHeartbeatsToIndexedDB(this.app, {
|
|
1131
|
-
lastSentHeartbeatDate:
|
|
1164
|
+
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
1165
|
+
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
1132
1166
|
heartbeats: [
|
|
1133
1167
|
...existingHeartbeatsObject.heartbeats,
|
|
1134
1168
|
...heartbeatsObject.heartbeats
|
|
@@ -1188,8 +1222,8 @@ function registerCoreComponents(variant) {
|
|
|
1188
1222
|
_registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
1189
1223
|
// Register `app` package.
|
|
1190
1224
|
registerVersion(name$q, version$1, variant);
|
|
1191
|
-
// BUILD_TARGET will be replaced by values like
|
|
1192
|
-
registerVersion(name$q, version$1, '
|
|
1225
|
+
// BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
|
|
1226
|
+
registerVersion(name$q, version$1, 'cjs2020');
|
|
1193
1227
|
// Register platform SDK identifier (no version).
|
|
1194
1228
|
registerVersion('fire-js', '');
|
|
1195
1229
|
}
|
|
@@ -1216,6 +1250,7 @@ exports._components = _components;
|
|
|
1216
1250
|
exports._getProvider = _getProvider;
|
|
1217
1251
|
exports._isFirebaseApp = _isFirebaseApp;
|
|
1218
1252
|
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
|
1253
|
+
exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
|
|
1219
1254
|
exports._registerComponent = _registerComponent;
|
|
1220
1255
|
exports._removeServiceInstance = _removeServiceInstance;
|
|
1221
1256
|
exports._serverApps = _serverApps;
|