@firebase/app 0.9.29 → 0.10.0-canary.42fcdfe4c
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 +43 -1
- package/dist/app/src/errors.d.ts +7 -1
- package/dist/app/src/firebaseApp.d.ts +4 -4
- package/dist/app/src/firebaseServerApp.d.ts +35 -0
- package/dist/app/src/firebaseServerApp.test.d.ts +17 -0
- package/dist/app/src/global_index.d.ts +145 -1
- package/dist/app/src/internal.d.ts +23 -1
- package/dist/app/src/public-types.d.ts +80 -0
- package/dist/app-public.d.ts +131 -0
- package/dist/app.d.ts +150 -0
- package/dist/esm/app/src/api.d.ts +43 -1
- package/dist/esm/app/src/errors.d.ts +7 -1
- package/dist/esm/app/src/firebaseApp.d.ts +4 -4
- package/dist/esm/app/src/firebaseServerApp.d.ts +35 -0
- package/dist/esm/app/src/firebaseServerApp.test.d.ts +17 -0
- package/dist/esm/app/src/internal.d.ts +23 -1
- package/dist/esm/app/src/public-types.d.ts +80 -0
- package/dist/esm/index.esm2017.js +183 -6
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/index.esm5.js +223 -13
- package/dist/esm/index.esm5.js.map +1 -1
- package/dist/index.cjs.js +224 -10
- package/dist/index.cjs.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -63,7 +63,7 @@ function isVersionServiceProvider(provider) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
var name$o = "@firebase/app";
|
|
66
|
-
var version$1 = "0.
|
|
66
|
+
var version$1 = "0.10.0-canary.42fcdfe4c";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -130,7 +130,7 @@ var name$2 = "@firebase/firestore";
|
|
|
130
130
|
var name$1 = "@firebase/firestore-compat";
|
|
131
131
|
|
|
132
132
|
var name = "firebase";
|
|
133
|
-
var version = "10.
|
|
133
|
+
var version = "10.10.0-canary.42fcdfe4c";
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* @license
|
|
@@ -204,6 +204,10 @@ var PLATFORM_LOG_STRING = (_a$1 = {},
|
|
|
204
204
|
* @internal
|
|
205
205
|
*/
|
|
206
206
|
var _apps = new Map();
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
var _serverApps = new Map();
|
|
207
211
|
/**
|
|
208
212
|
* Registered components.
|
|
209
213
|
*
|
|
@@ -239,7 +243,7 @@ function _addOrOverwriteComponent(app, component) {
|
|
|
239
243
|
* @internal
|
|
240
244
|
*/
|
|
241
245
|
function _registerComponent(component) {
|
|
242
|
-
var e_1, _a;
|
|
246
|
+
var e_1, _a, e_2, _b;
|
|
243
247
|
var componentName = component.name;
|
|
244
248
|
if (_components.has(componentName)) {
|
|
245
249
|
logger.debug("There were multiple attempts to register component ".concat(componentName, "."));
|
|
@@ -248,18 +252,31 @@ function _registerComponent(component) {
|
|
|
248
252
|
_components.set(componentName, component);
|
|
249
253
|
try {
|
|
250
254
|
// add the component to existing app instances
|
|
251
|
-
for (var
|
|
252
|
-
var app =
|
|
255
|
+
for (var _c = tslib.__values(_apps.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
256
|
+
var app = _d.value;
|
|
253
257
|
_addComponent(app, component);
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
260
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
257
261
|
finally {
|
|
258
262
|
try {
|
|
259
|
-
if (
|
|
263
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
260
264
|
}
|
|
261
265
|
finally { if (e_1) throw e_1.error; }
|
|
262
266
|
}
|
|
267
|
+
try {
|
|
268
|
+
for (var _e = tslib.__values(_serverApps.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
269
|
+
var serverApp = _f.value;
|
|
270
|
+
_addComponent(serverApp, component);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
274
|
+
finally {
|
|
275
|
+
try {
|
|
276
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
277
|
+
}
|
|
278
|
+
finally { if (e_2) throw e_2.error; }
|
|
279
|
+
}
|
|
263
280
|
return true;
|
|
264
281
|
}
|
|
265
282
|
/**
|
|
@@ -292,6 +309,28 @@ function _removeServiceInstance(app, name, instanceIdentifier) {
|
|
|
292
309
|
if (instanceIdentifier === void 0) { instanceIdentifier = DEFAULT_ENTRY_NAME; }
|
|
293
310
|
_getProvider(app, name).clearInstance(instanceIdentifier);
|
|
294
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
*
|
|
314
|
+
* @param obj - an object of type FirebaseApp or FirebaseOptions.
|
|
315
|
+
*
|
|
316
|
+
* @returns true if the provide object is of type FirebaseApp.
|
|
317
|
+
*
|
|
318
|
+
* @internal
|
|
319
|
+
*/
|
|
320
|
+
function _isFirebaseApp(obj) {
|
|
321
|
+
return obj.options !== undefined;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
*
|
|
325
|
+
* @param obj - an object of type FirebaseApp.
|
|
326
|
+
*
|
|
327
|
+
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
328
|
+
*
|
|
329
|
+
* @internal
|
|
330
|
+
*/
|
|
331
|
+
function _isFirebaseServerApp(obj) {
|
|
332
|
+
return obj.settings !== undefined;
|
|
333
|
+
}
|
|
295
334
|
/**
|
|
296
335
|
* Test only
|
|
297
336
|
*
|
|
@@ -321,9 +360,10 @@ var _a;
|
|
|
321
360
|
var ERRORS = (_a = {},
|
|
322
361
|
_a["no-app" /* AppError.NO_APP */] = "No Firebase App '{$appName}' has been created - " +
|
|
323
362
|
'call initializeApp() first',
|
|
324
|
-
_a["bad-app-name" /* AppError.BAD_APP_NAME */] = "Illegal App name: '{$appName}",
|
|
363
|
+
_a["bad-app-name" /* AppError.BAD_APP_NAME */] = "Illegal App name: '{$appName}'",
|
|
325
364
|
_a["duplicate-app" /* AppError.DUPLICATE_APP */] = "Firebase App named '{$appName}' already exists with different options or config",
|
|
326
365
|
_a["app-deleted" /* AppError.APP_DELETED */] = "Firebase App named '{$appName}' already deleted",
|
|
366
|
+
_a["server-app-deleted" /* AppError.SERVER_APP_DELETED */] = 'Firebase Server App has been deleted',
|
|
327
367
|
_a["no-options" /* AppError.NO_OPTIONS */] = 'Need to provide options, when not being deployed to hosting via source.',
|
|
328
368
|
_a["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */] = 'firebase.{$appName}() takes either no argument or a ' +
|
|
329
369
|
'Firebase App instance.',
|
|
@@ -332,6 +372,8 @@ var ERRORS = (_a = {},
|
|
|
332
372
|
_a["idb-get" /* AppError.IDB_GET */] = 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
333
373
|
_a["idb-set" /* AppError.IDB_WRITE */] = 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
|
|
334
374
|
_a["idb-delete" /* AppError.IDB_DELETE */] = 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
375
|
+
_a["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */] = 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
|
|
376
|
+
_a["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */] = 'FirebaseServerApp is not for use in browser environments.',
|
|
335
377
|
_a);
|
|
336
378
|
var ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
|
337
379
|
|
|
@@ -428,6 +470,108 @@ var FirebaseAppImpl = /** @class */ (function () {
|
|
|
428
470
|
return FirebaseAppImpl;
|
|
429
471
|
}());
|
|
430
472
|
|
|
473
|
+
/**
|
|
474
|
+
* @license
|
|
475
|
+
* Copyright 2023 Google LLC
|
|
476
|
+
*
|
|
477
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
478
|
+
* you may not use this file except in compliance with the License.
|
|
479
|
+
* You may obtain a copy of the License at
|
|
480
|
+
*
|
|
481
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
482
|
+
*
|
|
483
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
484
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
485
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
486
|
+
* See the License for the specific language governing permissions and
|
|
487
|
+
* limitations under the License.
|
|
488
|
+
*/
|
|
489
|
+
var FirebaseServerAppImpl = /** @class */ (function (_super) {
|
|
490
|
+
tslib.__extends(FirebaseServerAppImpl, _super);
|
|
491
|
+
function FirebaseServerAppImpl(options, serverConfig, name, container) {
|
|
492
|
+
var _this = this;
|
|
493
|
+
// Build configuration parameters for the FirebaseAppImpl base class.
|
|
494
|
+
var automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
|
|
495
|
+
? serverConfig.automaticDataCollectionEnabled
|
|
496
|
+
: false;
|
|
497
|
+
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
|
|
498
|
+
var config = {
|
|
499
|
+
name: name,
|
|
500
|
+
automaticDataCollectionEnabled: automaticDataCollectionEnabled
|
|
501
|
+
};
|
|
502
|
+
if (options.apiKey !== undefined) {
|
|
503
|
+
// Construct the parent FirebaseAppImp object.
|
|
504
|
+
_this = _super.call(this, options, config, container) || this;
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
var appImpl = options;
|
|
508
|
+
_this = _super.call(this, appImpl.options, config, container) || this;
|
|
509
|
+
}
|
|
510
|
+
// Now construct the data for the FirebaseServerAppImpl.
|
|
511
|
+
_this._serverConfig = tslib.__assign({ automaticDataCollectionEnabled: automaticDataCollectionEnabled }, serverConfig);
|
|
512
|
+
_this._finalizationRegistry = new FinalizationRegistry(function () {
|
|
513
|
+
_this.automaticCleanup();
|
|
514
|
+
});
|
|
515
|
+
_this._refCount = 0;
|
|
516
|
+
_this.incRefCount(_this._serverConfig.releaseOnDeref);
|
|
517
|
+
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegisry
|
|
518
|
+
// will never trigger.
|
|
519
|
+
_this._serverConfig.releaseOnDeref = undefined;
|
|
520
|
+
serverConfig.releaseOnDeref = undefined;
|
|
521
|
+
registerVersion(name$o, version$1, 'serverapp');
|
|
522
|
+
return _this;
|
|
523
|
+
}
|
|
524
|
+
Object.defineProperty(FirebaseServerAppImpl.prototype, "refCount", {
|
|
525
|
+
get: function () {
|
|
526
|
+
return this._refCount;
|
|
527
|
+
},
|
|
528
|
+
enumerable: false,
|
|
529
|
+
configurable: true
|
|
530
|
+
});
|
|
531
|
+
// Increment the reference count of this server app. If an object is provided, register it
|
|
532
|
+
// with the finalization registry.
|
|
533
|
+
FirebaseServerAppImpl.prototype.incRefCount = function (obj) {
|
|
534
|
+
if (this.isDeleted) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
this._refCount++;
|
|
538
|
+
if (obj !== undefined) {
|
|
539
|
+
this._finalizationRegistry.register(obj, this);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
// Decrement the reference count.
|
|
543
|
+
FirebaseServerAppImpl.prototype.decRefCount = function () {
|
|
544
|
+
if (this.isDeleted) {
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
return --this._refCount;
|
|
548
|
+
};
|
|
549
|
+
// Invoked by the FinalizationRegistry callback to note that this app should go through its
|
|
550
|
+
// reference counts and delete itself if no reference count remain. The coordinating logic that
|
|
551
|
+
// handles this is in deleteApp(...).
|
|
552
|
+
FirebaseServerAppImpl.prototype.automaticCleanup = function () {
|
|
553
|
+
void deleteApp(this);
|
|
554
|
+
};
|
|
555
|
+
Object.defineProperty(FirebaseServerAppImpl.prototype, "settings", {
|
|
556
|
+
get: function () {
|
|
557
|
+
this.checkDestroyed();
|
|
558
|
+
return this._serverConfig;
|
|
559
|
+
},
|
|
560
|
+
enumerable: false,
|
|
561
|
+
configurable: true
|
|
562
|
+
});
|
|
563
|
+
/**
|
|
564
|
+
* This function will throw an Error if the App has already been deleted -
|
|
565
|
+
* use before performing API actions on the App.
|
|
566
|
+
*/
|
|
567
|
+
FirebaseServerAppImpl.prototype.checkDestroyed = function () {
|
|
568
|
+
if (this.isDeleted) {
|
|
569
|
+
throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
return FirebaseServerAppImpl;
|
|
573
|
+
}(FirebaseAppImpl));
|
|
574
|
+
|
|
431
575
|
/**
|
|
432
576
|
* @license
|
|
433
577
|
* Copyright 2019 Google LLC
|
|
@@ -498,6 +642,61 @@ function initializeApp(_options, rawConfig) {
|
|
|
498
642
|
_apps.set(name, newApp);
|
|
499
643
|
return newApp;
|
|
500
644
|
}
|
|
645
|
+
function initializeServerApp(_options, _serverAppConfig) {
|
|
646
|
+
var e_2, _a;
|
|
647
|
+
if (util.isBrowser()) {
|
|
648
|
+
// FirebaseServerApp isn't designed to be run in browsers.
|
|
649
|
+
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
|
650
|
+
}
|
|
651
|
+
if (_serverAppConfig.automaticDataCollectionEnabled === undefined) {
|
|
652
|
+
_serverAppConfig.automaticDataCollectionEnabled = false;
|
|
653
|
+
}
|
|
654
|
+
var appOptions;
|
|
655
|
+
if (_isFirebaseApp(_options)) {
|
|
656
|
+
appOptions = _options.options;
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
appOptions = _options;
|
|
660
|
+
}
|
|
661
|
+
// Build an app name based on a hash of the configuration options.
|
|
662
|
+
var nameObj = tslib.__assign(tslib.__assign({}, _serverAppConfig), appOptions);
|
|
663
|
+
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
|
664
|
+
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
|
665
|
+
if (nameObj.releaseOnDeref !== undefined) {
|
|
666
|
+
delete nameObj.releaseOnDeref;
|
|
667
|
+
}
|
|
668
|
+
var hashCode = function (s) {
|
|
669
|
+
return tslib.__spreadArray([], tslib.__read(s), false).reduce(function (hash, c) { return (Math.imul(31, hash) + c.charCodeAt(0)) | 0; }, 0);
|
|
670
|
+
};
|
|
671
|
+
if (_serverAppConfig.releaseOnDeref !== undefined) {
|
|
672
|
+
if (typeof FinalizationRegistry === 'undefined') {
|
|
673
|
+
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
var nameString = '' + hashCode(JSON.stringify(nameObj));
|
|
677
|
+
var existingApp = _serverApps.get(nameString);
|
|
678
|
+
if (existingApp) {
|
|
679
|
+
existingApp.incRefCount(_serverAppConfig.releaseOnDeref);
|
|
680
|
+
return existingApp;
|
|
681
|
+
}
|
|
682
|
+
var container = new component.ComponentContainer(nameString);
|
|
683
|
+
try {
|
|
684
|
+
for (var _b = tslib.__values(_components.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
685
|
+
var component$1 = _c.value;
|
|
686
|
+
container.addComponent(component$1);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
690
|
+
finally {
|
|
691
|
+
try {
|
|
692
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
693
|
+
}
|
|
694
|
+
finally { if (e_2) throw e_2.error; }
|
|
695
|
+
}
|
|
696
|
+
var newApp = new FirebaseServerAppImpl(appOptions, _serverAppConfig, nameString, container);
|
|
697
|
+
_serverApps.set(nameString, newApp);
|
|
698
|
+
return newApp;
|
|
699
|
+
}
|
|
501
700
|
/**
|
|
502
701
|
* Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
|
503
702
|
*
|
|
@@ -564,13 +763,24 @@ function getApps() {
|
|
|
564
763
|
*/
|
|
565
764
|
function deleteApp(app) {
|
|
566
765
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
567
|
-
var name;
|
|
766
|
+
var cleanupProviders, name, firebaseServerApp;
|
|
568
767
|
return tslib.__generator(this, function (_a) {
|
|
569
768
|
switch (_a.label) {
|
|
570
769
|
case 0:
|
|
770
|
+
cleanupProviders = false;
|
|
571
771
|
name = app.name;
|
|
572
|
-
if (
|
|
573
|
-
|
|
772
|
+
if (_apps.has(name)) {
|
|
773
|
+
cleanupProviders = true;
|
|
774
|
+
_apps.delete(name);
|
|
775
|
+
}
|
|
776
|
+
else if (_serverApps.has(name)) {
|
|
777
|
+
firebaseServerApp = app;
|
|
778
|
+
if (firebaseServerApp.decRefCount() <= 0) {
|
|
779
|
+
_serverApps.delete(name);
|
|
780
|
+
cleanupProviders = true;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (!cleanupProviders) return [3 /*break*/, 2];
|
|
574
784
|
return [4 /*yield*/, Promise.all(app.container
|
|
575
785
|
.getProviders()
|
|
576
786
|
.map(function (provider) { return provider.delete(); }))];
|
|
@@ -1135,12 +1345,16 @@ exports._apps = _apps;
|
|
|
1135
1345
|
exports._clearComponents = _clearComponents;
|
|
1136
1346
|
exports._components = _components;
|
|
1137
1347
|
exports._getProvider = _getProvider;
|
|
1348
|
+
exports._isFirebaseApp = _isFirebaseApp;
|
|
1349
|
+
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
|
1138
1350
|
exports._registerComponent = _registerComponent;
|
|
1139
1351
|
exports._removeServiceInstance = _removeServiceInstance;
|
|
1352
|
+
exports._serverApps = _serverApps;
|
|
1140
1353
|
exports.deleteApp = deleteApp;
|
|
1141
1354
|
exports.getApp = getApp;
|
|
1142
1355
|
exports.getApps = getApps;
|
|
1143
1356
|
exports.initializeApp = initializeApp;
|
|
1357
|
+
exports.initializeServerApp = initializeServerApp;
|
|
1144
1358
|
exports.onLog = onLog;
|
|
1145
1359
|
exports.registerVersion = registerVersion;
|
|
1146
1360
|
exports.setLogLevel = setLogLevel;
|