@firebase/database-compat 2.1.4-eap-crashlytics.659b578fb → 2.1.5-20260728185501
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.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.standalone.js +98 -1682
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.js +1 -1
- package/package.json +19 -7
package/dist/index.standalone.js
CHANGED
|
@@ -10,24 +10,10 @@ var require$$1$1 = require('crypto');
|
|
|
10
10
|
var require$$2$1 = require('url');
|
|
11
11
|
var require$$1$2 = require('net');
|
|
12
12
|
var require$$2$2 = require('tls');
|
|
13
|
-
var require$$
|
|
14
|
-
var require$$
|
|
15
|
-
var require$$
|
|
16
|
-
|
|
17
|
-
function getAugmentedNamespace(n) {
|
|
18
|
-
if (n.__esModule) return n;
|
|
19
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
20
|
-
Object.keys(n).forEach(function (k) {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
22
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return n[k];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
return a;
|
|
30
|
-
}
|
|
13
|
+
var require$$1$3 = require('@firebase/util');
|
|
14
|
+
var require$$2$3 = require('@firebase/logger');
|
|
15
|
+
var require$$3 = require('@firebase/app');
|
|
16
|
+
var require$$4 = require('@firebase/component');
|
|
31
17
|
|
|
32
18
|
var index_standalone = {};
|
|
33
19
|
|
|
@@ -2230,7 +2216,7 @@ var Buffer$4 = safeBuffer.exports.Buffer,
|
|
|
2230
2216
|
|
|
2231
2217
|
var PORTS = { 'ws:': 80, 'wss:': 443 };
|
|
2232
2218
|
|
|
2233
|
-
var Proxy$
|
|
2219
|
+
var Proxy$1 = function(client, origin, options) {
|
|
2234
2220
|
this._client = client;
|
|
2235
2221
|
this._http = new HttpParser$2('response');
|
|
2236
2222
|
this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
|
|
@@ -2249,7 +2235,7 @@ var Proxy$2 = function(client, origin, options) {
|
|
|
2249
2235
|
var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
|
|
2250
2236
|
if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
|
|
2251
2237
|
};
|
|
2252
|
-
util$9.inherits(Proxy$
|
|
2238
|
+
util$9.inherits(Proxy$1, Stream$2);
|
|
2253
2239
|
|
|
2254
2240
|
var instance$6 = {
|
|
2255
2241
|
setHeader: function(name, value) {
|
|
@@ -2314,9 +2300,9 @@ var instance$6 = {
|
|
|
2314
2300
|
};
|
|
2315
2301
|
|
|
2316
2302
|
for (var key$6 in instance$6)
|
|
2317
|
-
Proxy$
|
|
2303
|
+
Proxy$1.prototype[key$6] = instance$6[key$6];
|
|
2318
2304
|
|
|
2319
|
-
var proxy = Proxy$
|
|
2305
|
+
var proxy = Proxy$1;
|
|
2320
2306
|
|
|
2321
2307
|
var Buffer$3 = safeBuffer.exports.Buffer,
|
|
2322
2308
|
crypto$1 = require$$1$1,
|
|
@@ -2325,7 +2311,7 @@ var Buffer$3 = safeBuffer.exports.Buffer,
|
|
|
2325
2311
|
HttpParser$1 = http_parser,
|
|
2326
2312
|
Base$4 = base,
|
|
2327
2313
|
Hybi$1 = hybi,
|
|
2328
|
-
Proxy
|
|
2314
|
+
Proxy = proxy;
|
|
2329
2315
|
|
|
2330
2316
|
var Client$2 = function(_url, options) {
|
|
2331
2317
|
this.version = 'hybi-' + Hybi$1.VERSION;
|
|
@@ -2366,7 +2352,7 @@ var instance$5 = {
|
|
|
2366
2352
|
VALID_PROTOCOLS: ['ws:', 'wss:'],
|
|
2367
2353
|
|
|
2368
2354
|
proxy: function(origin, options) {
|
|
2369
|
-
return new Proxy
|
|
2355
|
+
return new Proxy(this, origin, options);
|
|
2370
2356
|
},
|
|
2371
2357
|
|
|
2372
2358
|
start: function() {
|
|
@@ -3359,1583 +3345,13 @@ WebSocket$1.EventSource = eventsource;
|
|
|
3359
3345
|
|
|
3360
3346
|
var websocket = WebSocket$1;
|
|
3361
3347
|
|
|
3362
|
-
var index_cjs = {};
|
|
3363
|
-
|
|
3364
|
-
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
|
3365
|
-
|
|
3366
|
-
let idbProxyableTypes;
|
|
3367
|
-
let cursorAdvanceMethods;
|
|
3368
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3369
|
-
function getIdbProxyableTypes() {
|
|
3370
|
-
return (idbProxyableTypes ||
|
|
3371
|
-
(idbProxyableTypes = [
|
|
3372
|
-
IDBDatabase,
|
|
3373
|
-
IDBObjectStore,
|
|
3374
|
-
IDBIndex,
|
|
3375
|
-
IDBCursor,
|
|
3376
|
-
IDBTransaction,
|
|
3377
|
-
]));
|
|
3378
|
-
}
|
|
3379
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3380
|
-
function getCursorAdvanceMethods() {
|
|
3381
|
-
return (cursorAdvanceMethods ||
|
|
3382
|
-
(cursorAdvanceMethods = [
|
|
3383
|
-
IDBCursor.prototype.advance,
|
|
3384
|
-
IDBCursor.prototype.continue,
|
|
3385
|
-
IDBCursor.prototype.continuePrimaryKey,
|
|
3386
|
-
]));
|
|
3387
|
-
}
|
|
3388
|
-
const cursorRequestMap = new WeakMap();
|
|
3389
|
-
const transactionDoneMap = new WeakMap();
|
|
3390
|
-
const transactionStoreNamesMap = new WeakMap();
|
|
3391
|
-
const transformCache = new WeakMap();
|
|
3392
|
-
const reverseTransformCache = new WeakMap();
|
|
3393
|
-
function promisifyRequest(request) {
|
|
3394
|
-
const promise = new Promise((resolve, reject) => {
|
|
3395
|
-
const unlisten = () => {
|
|
3396
|
-
request.removeEventListener('success', success);
|
|
3397
|
-
request.removeEventListener('error', error);
|
|
3398
|
-
};
|
|
3399
|
-
const success = () => {
|
|
3400
|
-
resolve(wrap(request.result));
|
|
3401
|
-
unlisten();
|
|
3402
|
-
};
|
|
3403
|
-
const error = () => {
|
|
3404
|
-
reject(request.error);
|
|
3405
|
-
unlisten();
|
|
3406
|
-
};
|
|
3407
|
-
request.addEventListener('success', success);
|
|
3408
|
-
request.addEventListener('error', error);
|
|
3409
|
-
});
|
|
3410
|
-
promise
|
|
3411
|
-
.then((value) => {
|
|
3412
|
-
// Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
|
|
3413
|
-
// (see wrapFunction).
|
|
3414
|
-
if (value instanceof IDBCursor) {
|
|
3415
|
-
cursorRequestMap.set(value, request);
|
|
3416
|
-
}
|
|
3417
|
-
// Catching to avoid "Uncaught Promise exceptions"
|
|
3418
|
-
})
|
|
3419
|
-
.catch(() => { });
|
|
3420
|
-
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
|
3421
|
-
// is because we create many promises from a single IDBRequest.
|
|
3422
|
-
reverseTransformCache.set(promise, request);
|
|
3423
|
-
return promise;
|
|
3424
|
-
}
|
|
3425
|
-
function cacheDonePromiseForTransaction(tx) {
|
|
3426
|
-
// Early bail if we've already created a done promise for this transaction.
|
|
3427
|
-
if (transactionDoneMap.has(tx))
|
|
3428
|
-
return;
|
|
3429
|
-
const done = new Promise((resolve, reject) => {
|
|
3430
|
-
const unlisten = () => {
|
|
3431
|
-
tx.removeEventListener('complete', complete);
|
|
3432
|
-
tx.removeEventListener('error', error);
|
|
3433
|
-
tx.removeEventListener('abort', error);
|
|
3434
|
-
};
|
|
3435
|
-
const complete = () => {
|
|
3436
|
-
resolve();
|
|
3437
|
-
unlisten();
|
|
3438
|
-
};
|
|
3439
|
-
const error = () => {
|
|
3440
|
-
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
3441
|
-
unlisten();
|
|
3442
|
-
};
|
|
3443
|
-
tx.addEventListener('complete', complete);
|
|
3444
|
-
tx.addEventListener('error', error);
|
|
3445
|
-
tx.addEventListener('abort', error);
|
|
3446
|
-
});
|
|
3447
|
-
// Cache it for later retrieval.
|
|
3448
|
-
transactionDoneMap.set(tx, done);
|
|
3449
|
-
}
|
|
3450
|
-
let idbProxyTraps = {
|
|
3451
|
-
get(target, prop, receiver) {
|
|
3452
|
-
if (target instanceof IDBTransaction) {
|
|
3453
|
-
// Special handling for transaction.done.
|
|
3454
|
-
if (prop === 'done')
|
|
3455
|
-
return transactionDoneMap.get(target);
|
|
3456
|
-
// Polyfill for objectStoreNames because of Edge.
|
|
3457
|
-
if (prop === 'objectStoreNames') {
|
|
3458
|
-
return target.objectStoreNames || transactionStoreNamesMap.get(target);
|
|
3459
|
-
}
|
|
3460
|
-
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
3461
|
-
if (prop === 'store') {
|
|
3462
|
-
return receiver.objectStoreNames[1]
|
|
3463
|
-
? undefined
|
|
3464
|
-
: receiver.objectStore(receiver.objectStoreNames[0]);
|
|
3465
|
-
}
|
|
3466
|
-
}
|
|
3467
|
-
// Else transform whatever we get back.
|
|
3468
|
-
return wrap(target[prop]);
|
|
3469
|
-
},
|
|
3470
|
-
set(target, prop, value) {
|
|
3471
|
-
target[prop] = value;
|
|
3472
|
-
return true;
|
|
3473
|
-
},
|
|
3474
|
-
has(target, prop) {
|
|
3475
|
-
if (target instanceof IDBTransaction &&
|
|
3476
|
-
(prop === 'done' || prop === 'store')) {
|
|
3477
|
-
return true;
|
|
3478
|
-
}
|
|
3479
|
-
return prop in target;
|
|
3480
|
-
},
|
|
3481
|
-
};
|
|
3482
|
-
function replaceTraps(callback) {
|
|
3483
|
-
idbProxyTraps = callback(idbProxyTraps);
|
|
3484
|
-
}
|
|
3485
|
-
function wrapFunction(func) {
|
|
3486
|
-
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
3487
|
-
// only create one new func per func.
|
|
3488
|
-
// Edge doesn't support objectStoreNames (booo), so we polyfill it here.
|
|
3489
|
-
if (func === IDBDatabase.prototype.transaction &&
|
|
3490
|
-
!('objectStoreNames' in IDBTransaction.prototype)) {
|
|
3491
|
-
return function (storeNames, ...args) {
|
|
3492
|
-
const tx = func.call(unwrap(this), storeNames, ...args);
|
|
3493
|
-
transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
|
|
3494
|
-
return wrap(tx);
|
|
3495
|
-
};
|
|
3496
|
-
}
|
|
3497
|
-
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
3498
|
-
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
3499
|
-
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
3500
|
-
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
3501
|
-
// undefined if the end of the cursor has been reached.
|
|
3502
|
-
if (getCursorAdvanceMethods().includes(func)) {
|
|
3503
|
-
return function (...args) {
|
|
3504
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3505
|
-
// the original object.
|
|
3506
|
-
func.apply(unwrap(this), args);
|
|
3507
|
-
return wrap(cursorRequestMap.get(this));
|
|
3508
|
-
};
|
|
3509
|
-
}
|
|
3510
|
-
return function (...args) {
|
|
3511
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3512
|
-
// the original object.
|
|
3513
|
-
return wrap(func.apply(unwrap(this), args));
|
|
3514
|
-
};
|
|
3515
|
-
}
|
|
3516
|
-
function transformCachableValue(value) {
|
|
3517
|
-
if (typeof value === 'function')
|
|
3518
|
-
return wrapFunction(value);
|
|
3519
|
-
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
3520
|
-
// which is later returned for transaction.done (see idbObjectHandler).
|
|
3521
|
-
if (value instanceof IDBTransaction)
|
|
3522
|
-
cacheDonePromiseForTransaction(value);
|
|
3523
|
-
if (instanceOfAny(value, getIdbProxyableTypes()))
|
|
3524
|
-
return new Proxy(value, idbProxyTraps);
|
|
3525
|
-
// Return the same value back if we're not going to transform it.
|
|
3526
|
-
return value;
|
|
3527
|
-
}
|
|
3528
|
-
function wrap(value) {
|
|
3529
|
-
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
3530
|
-
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
3531
|
-
if (value instanceof IDBRequest)
|
|
3532
|
-
return promisifyRequest(value);
|
|
3533
|
-
// If we've already transformed this value before, reuse the transformed value.
|
|
3534
|
-
// This is faster, but it also provides object equality.
|
|
3535
|
-
if (transformCache.has(value))
|
|
3536
|
-
return transformCache.get(value);
|
|
3537
|
-
const newValue = transformCachableValue(value);
|
|
3538
|
-
// Not all types are transformed.
|
|
3539
|
-
// These may be primitive types, so they can't be WeakMap keys.
|
|
3540
|
-
if (newValue !== value) {
|
|
3541
|
-
transformCache.set(value, newValue);
|
|
3542
|
-
reverseTransformCache.set(newValue, value);
|
|
3543
|
-
}
|
|
3544
|
-
return newValue;
|
|
3545
|
-
}
|
|
3546
|
-
const unwrap = (value) => reverseTransformCache.get(value);
|
|
3547
|
-
|
|
3548
|
-
/**
|
|
3549
|
-
* Open a database.
|
|
3550
|
-
*
|
|
3551
|
-
* @param name Name of the database.
|
|
3552
|
-
* @param version Schema version.
|
|
3553
|
-
* @param callbacks Additional callbacks.
|
|
3554
|
-
*/
|
|
3555
|
-
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
|
|
3556
|
-
const request = indexedDB.open(name, version);
|
|
3557
|
-
const openPromise = wrap(request);
|
|
3558
|
-
if (upgrade) {
|
|
3559
|
-
request.addEventListener('upgradeneeded', (event) => {
|
|
3560
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
3561
|
-
});
|
|
3562
|
-
}
|
|
3563
|
-
if (blocked) {
|
|
3564
|
-
request.addEventListener('blocked', (event) => blocked(
|
|
3565
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3566
|
-
event.oldVersion, event.newVersion, event));
|
|
3567
|
-
}
|
|
3568
|
-
openPromise
|
|
3569
|
-
.then((db) => {
|
|
3570
|
-
if (terminated)
|
|
3571
|
-
db.addEventListener('close', () => terminated());
|
|
3572
|
-
if (blocking) {
|
|
3573
|
-
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
|
|
3574
|
-
}
|
|
3575
|
-
})
|
|
3576
|
-
.catch(() => { });
|
|
3577
|
-
return openPromise;
|
|
3578
|
-
}
|
|
3579
|
-
/**
|
|
3580
|
-
* Delete a database.
|
|
3581
|
-
*
|
|
3582
|
-
* @param name Name of the database.
|
|
3583
|
-
*/
|
|
3584
|
-
function deleteDB(name, { blocked } = {}) {
|
|
3585
|
-
const request = indexedDB.deleteDatabase(name);
|
|
3586
|
-
if (blocked) {
|
|
3587
|
-
request.addEventListener('blocked', (event) => blocked(
|
|
3588
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3589
|
-
event.oldVersion, event));
|
|
3590
|
-
}
|
|
3591
|
-
return wrap(request).then(() => undefined);
|
|
3592
|
-
}
|
|
3593
|
-
|
|
3594
|
-
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
3595
|
-
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
3596
|
-
const cachedMethods = new Map();
|
|
3597
|
-
function getMethod(target, prop) {
|
|
3598
|
-
if (!(target instanceof IDBDatabase &&
|
|
3599
|
-
!(prop in target) &&
|
|
3600
|
-
typeof prop === 'string')) {
|
|
3601
|
-
return;
|
|
3602
|
-
}
|
|
3603
|
-
if (cachedMethods.get(prop))
|
|
3604
|
-
return cachedMethods.get(prop);
|
|
3605
|
-
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
3606
|
-
const useIndex = prop !== targetFuncName;
|
|
3607
|
-
const isWrite = writeMethods.includes(targetFuncName);
|
|
3608
|
-
if (
|
|
3609
|
-
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
3610
|
-
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
|
|
3611
|
-
!(isWrite || readMethods.includes(targetFuncName))) {
|
|
3612
|
-
return;
|
|
3613
|
-
}
|
|
3614
|
-
const method = async function (storeName, ...args) {
|
|
3615
|
-
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
3616
|
-
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
3617
|
-
let target = tx.store;
|
|
3618
|
-
if (useIndex)
|
|
3619
|
-
target = target.index(args.shift());
|
|
3620
|
-
// Must reject if op rejects.
|
|
3621
|
-
// If it's a write operation, must reject if tx.done rejects.
|
|
3622
|
-
// Must reject with op rejection first.
|
|
3623
|
-
// Must resolve with op value.
|
|
3624
|
-
// Must handle both promises (no unhandled rejections)
|
|
3625
|
-
return (await Promise.all([
|
|
3626
|
-
target[targetFuncName](...args),
|
|
3627
|
-
isWrite && tx.done,
|
|
3628
|
-
]))[0];
|
|
3629
|
-
};
|
|
3630
|
-
cachedMethods.set(prop, method);
|
|
3631
|
-
return method;
|
|
3632
|
-
}
|
|
3633
|
-
replaceTraps((oldTraps) => ({
|
|
3634
|
-
...oldTraps,
|
|
3635
|
-
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
3636
|
-
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
|
|
3637
|
-
}));
|
|
3638
|
-
|
|
3639
|
-
var build = /*#__PURE__*/Object.freeze({
|
|
3640
|
-
__proto__: null,
|
|
3641
|
-
deleteDB: deleteDB,
|
|
3642
|
-
openDB: openDB,
|
|
3643
|
-
unwrap: unwrap,
|
|
3644
|
-
wrap: wrap
|
|
3645
|
-
});
|
|
3646
|
-
|
|
3647
|
-
var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
|
|
3648
|
-
|
|
3649
|
-
(function (exports) {
|
|
3650
|
-
|
|
3651
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3652
|
-
|
|
3653
|
-
var component = require$$0$2;
|
|
3654
|
-
var logger$1 = require$$1$3;
|
|
3655
|
-
var util = require$$2$3;
|
|
3656
|
-
var idb = require$$3;
|
|
3657
|
-
|
|
3658
|
-
/**
|
|
3659
|
-
* @license
|
|
3660
|
-
* Copyright 2019 Google LLC
|
|
3661
|
-
*
|
|
3662
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3663
|
-
* you may not use this file except in compliance with the License.
|
|
3664
|
-
* You may obtain a copy of the License at
|
|
3665
|
-
*
|
|
3666
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3667
|
-
*
|
|
3668
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3669
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3670
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3671
|
-
* See the License for the specific language governing permissions and
|
|
3672
|
-
* limitations under the License.
|
|
3673
|
-
*/
|
|
3674
|
-
class PlatformLoggerServiceImpl {
|
|
3675
|
-
constructor(container) {
|
|
3676
|
-
this.container = container;
|
|
3677
|
-
}
|
|
3678
|
-
// In initial implementation, this will be called by installations on
|
|
3679
|
-
// auth token refresh, and installations will send this string.
|
|
3680
|
-
getPlatformInfoString() {
|
|
3681
|
-
const providers = this.container.getProviders();
|
|
3682
|
-
// Loop through providers and get library/version pairs from any that are
|
|
3683
|
-
// version components.
|
|
3684
|
-
return providers
|
|
3685
|
-
.map(provider => {
|
|
3686
|
-
if (isVersionServiceProvider(provider)) {
|
|
3687
|
-
const service = provider.getImmediate();
|
|
3688
|
-
return `${service.library}/${service.version}`;
|
|
3689
|
-
}
|
|
3690
|
-
else {
|
|
3691
|
-
return null;
|
|
3692
|
-
}
|
|
3693
|
-
})
|
|
3694
|
-
.filter(logString => logString)
|
|
3695
|
-
.join(' ');
|
|
3696
|
-
}
|
|
3697
|
-
}
|
|
3698
|
-
/**
|
|
3699
|
-
*
|
|
3700
|
-
* @param provider check if this provider provides a VersionService
|
|
3701
|
-
*
|
|
3702
|
-
* NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
|
|
3703
|
-
* provides VersionService. The provider is not necessarily a 'app-version'
|
|
3704
|
-
* provider.
|
|
3705
|
-
*/
|
|
3706
|
-
function isVersionServiceProvider(provider) {
|
|
3707
|
-
const component = provider.getComponent();
|
|
3708
|
-
return component?.type === "VERSION" /* ComponentType.VERSION */;
|
|
3709
|
-
}
|
|
3710
|
-
|
|
3711
|
-
const name$q = "@firebase/app";
|
|
3712
|
-
const version$1 = "0.15.1-eap-crashlytics.659b578fb";
|
|
3713
|
-
|
|
3714
|
-
/**
|
|
3715
|
-
* @license
|
|
3716
|
-
* Copyright 2019 Google LLC
|
|
3717
|
-
*
|
|
3718
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3719
|
-
* you may not use this file except in compliance with the License.
|
|
3720
|
-
* You may obtain a copy of the License at
|
|
3721
|
-
*
|
|
3722
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3723
|
-
*
|
|
3724
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3725
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3726
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3727
|
-
* See the License for the specific language governing permissions and
|
|
3728
|
-
* limitations under the License.
|
|
3729
|
-
*/
|
|
3730
|
-
const logger = new logger$1.Logger('@firebase/app');
|
|
3731
|
-
|
|
3732
|
-
const name$p = "@firebase/app-compat";
|
|
3733
|
-
|
|
3734
|
-
const name$o = "@firebase/analytics-compat";
|
|
3735
|
-
|
|
3736
|
-
const name$n = "@firebase/analytics";
|
|
3737
|
-
|
|
3738
|
-
const name$m = "@firebase/app-check-compat";
|
|
3739
|
-
|
|
3740
|
-
const name$l = "@firebase/app-check";
|
|
3741
|
-
|
|
3742
|
-
const name$k = "@firebase/auth";
|
|
3743
|
-
|
|
3744
|
-
const name$j = "@firebase/auth-compat";
|
|
3745
|
-
|
|
3746
|
-
const name$i = "@firebase/database";
|
|
3747
|
-
|
|
3748
|
-
const name$h = "@firebase/data-connect";
|
|
3749
|
-
|
|
3750
|
-
const name$g = "@firebase/database-compat";
|
|
3751
|
-
|
|
3752
|
-
const name$f = "@firebase/functions";
|
|
3753
|
-
|
|
3754
|
-
const name$e = "@firebase/functions-compat";
|
|
3755
|
-
|
|
3756
|
-
const name$d = "@firebase/installations";
|
|
3757
|
-
|
|
3758
|
-
const name$c = "@firebase/installations-compat";
|
|
3759
|
-
|
|
3760
|
-
const name$b = "@firebase/messaging";
|
|
3761
|
-
|
|
3762
|
-
const name$a = "@firebase/messaging-compat";
|
|
3763
|
-
|
|
3764
|
-
const name$9 = "@firebase/performance";
|
|
3765
|
-
|
|
3766
|
-
const name$8 = "@firebase/performance-compat";
|
|
3767
|
-
|
|
3768
|
-
const name$7 = "@firebase/remote-config";
|
|
3769
|
-
|
|
3770
|
-
const name$6 = "@firebase/remote-config-compat";
|
|
3771
|
-
|
|
3772
|
-
const name$5 = "@firebase/storage";
|
|
3773
|
-
|
|
3774
|
-
const name$4 = "@firebase/storage-compat";
|
|
3775
|
-
|
|
3776
|
-
const name$3 = "@firebase/firestore";
|
|
3777
|
-
|
|
3778
|
-
const name$2 = "@firebase/ai";
|
|
3779
|
-
|
|
3780
|
-
const name$1 = "@firebase/firestore-compat";
|
|
3781
|
-
|
|
3782
|
-
const name = "firebase";
|
|
3783
|
-
const version = "12.16.0-eap-crashlytics.659b578fb";
|
|
3784
|
-
|
|
3785
|
-
/**
|
|
3786
|
-
* @license
|
|
3787
|
-
* Copyright 2019 Google LLC
|
|
3788
|
-
*
|
|
3789
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3790
|
-
* you may not use this file except in compliance with the License.
|
|
3791
|
-
* You may obtain a copy of the License at
|
|
3792
|
-
*
|
|
3793
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3794
|
-
*
|
|
3795
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3796
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3797
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3798
|
-
* See the License for the specific language governing permissions and
|
|
3799
|
-
* limitations under the License.
|
|
3800
|
-
*/
|
|
3801
|
-
/**
|
|
3802
|
-
* The default app name
|
|
3803
|
-
*
|
|
3804
|
-
* @internal
|
|
3805
|
-
*/
|
|
3806
|
-
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
|
3807
|
-
const PLATFORM_LOG_STRING = {
|
|
3808
|
-
[name$q]: 'fire-core',
|
|
3809
|
-
[name$p]: 'fire-core-compat',
|
|
3810
|
-
[name$n]: 'fire-analytics',
|
|
3811
|
-
[name$o]: 'fire-analytics-compat',
|
|
3812
|
-
[name$l]: 'fire-app-check',
|
|
3813
|
-
[name$m]: 'fire-app-check-compat',
|
|
3814
|
-
[name$k]: 'fire-auth',
|
|
3815
|
-
[name$j]: 'fire-auth-compat',
|
|
3816
|
-
[name$i]: 'fire-rtdb',
|
|
3817
|
-
[name$h]: 'fire-data-connect',
|
|
3818
|
-
[name$g]: 'fire-rtdb-compat',
|
|
3819
|
-
[name$f]: 'fire-fn',
|
|
3820
|
-
[name$e]: 'fire-fn-compat',
|
|
3821
|
-
[name$d]: 'fire-iid',
|
|
3822
|
-
[name$c]: 'fire-iid-compat',
|
|
3823
|
-
[name$b]: 'fire-fcm',
|
|
3824
|
-
[name$a]: 'fire-fcm-compat',
|
|
3825
|
-
[name$9]: 'fire-perf',
|
|
3826
|
-
[name$8]: 'fire-perf-compat',
|
|
3827
|
-
[name$7]: 'fire-rc',
|
|
3828
|
-
[name$6]: 'fire-rc-compat',
|
|
3829
|
-
[name$5]: 'fire-gcs',
|
|
3830
|
-
[name$4]: 'fire-gcs-compat',
|
|
3831
|
-
[name$3]: 'fire-fst',
|
|
3832
|
-
[name$1]: 'fire-fst-compat',
|
|
3833
|
-
[name$2]: 'fire-vertex',
|
|
3834
|
-
'fire-js': 'fire-js', // Platform identifier for JS SDK.
|
|
3835
|
-
[name]: 'fire-js-all'
|
|
3836
|
-
};
|
|
3837
|
-
|
|
3838
|
-
/**
|
|
3839
|
-
* @license
|
|
3840
|
-
* Copyright 2019 Google LLC
|
|
3841
|
-
*
|
|
3842
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3843
|
-
* you may not use this file except in compliance with the License.
|
|
3844
|
-
* You may obtain a copy of the License at
|
|
3845
|
-
*
|
|
3846
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3847
|
-
*
|
|
3848
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3849
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3850
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3851
|
-
* See the License for the specific language governing permissions and
|
|
3852
|
-
* limitations under the License.
|
|
3853
|
-
*/
|
|
3854
|
-
/**
|
|
3855
|
-
* @internal
|
|
3856
|
-
*/
|
|
3857
|
-
const _apps = new Map();
|
|
3858
|
-
/**
|
|
3859
|
-
* @internal
|
|
3860
|
-
*/
|
|
3861
|
-
const _serverApps = new Map();
|
|
3862
|
-
/**
|
|
3863
|
-
* Registered components.
|
|
3864
|
-
*
|
|
3865
|
-
* @internal
|
|
3866
|
-
*/
|
|
3867
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3868
|
-
const _components = new Map();
|
|
3869
|
-
/**
|
|
3870
|
-
* @param component - the component being added to this app's container
|
|
3871
|
-
*
|
|
3872
|
-
* @internal
|
|
3873
|
-
*/
|
|
3874
|
-
function _addComponent(app, component) {
|
|
3875
|
-
try {
|
|
3876
|
-
app.container.addComponent(component);
|
|
3877
|
-
}
|
|
3878
|
-
catch (e) {
|
|
3879
|
-
logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
/**
|
|
3883
|
-
*
|
|
3884
|
-
* @internal
|
|
3885
|
-
*/
|
|
3886
|
-
function _addOrOverwriteComponent(app, component) {
|
|
3887
|
-
app.container.addOrOverwriteComponent(component);
|
|
3888
|
-
}
|
|
3889
|
-
/**
|
|
3890
|
-
*
|
|
3891
|
-
* @param component - the component to register
|
|
3892
|
-
* @returns whether or not the component is registered successfully
|
|
3893
|
-
*
|
|
3894
|
-
* @internal
|
|
3895
|
-
*/
|
|
3896
|
-
function _registerComponent(component) {
|
|
3897
|
-
const componentName = component.name;
|
|
3898
|
-
if (_components.has(componentName)) {
|
|
3899
|
-
logger.debug(`There were multiple attempts to register component ${componentName}.`);
|
|
3900
|
-
return false;
|
|
3901
|
-
}
|
|
3902
|
-
_components.set(componentName, component);
|
|
3903
|
-
// add the component to existing app instances
|
|
3904
|
-
for (const app of _apps.values()) {
|
|
3905
|
-
_addComponent(app, component);
|
|
3906
|
-
}
|
|
3907
|
-
for (const serverApp of _serverApps.values()) {
|
|
3908
|
-
_addComponent(serverApp, component);
|
|
3909
|
-
}
|
|
3910
|
-
return true;
|
|
3911
|
-
}
|
|
3912
|
-
/**
|
|
3913
|
-
*
|
|
3914
|
-
* @param app - FirebaseApp instance
|
|
3915
|
-
* @param name - service name
|
|
3916
|
-
*
|
|
3917
|
-
* @returns the provider for the service with the matching name
|
|
3918
|
-
*
|
|
3919
|
-
* @internal
|
|
3920
|
-
*/
|
|
3921
|
-
function _getProvider(app, name) {
|
|
3922
|
-
const heartbeatController = app.container
|
|
3923
|
-
.getProvider('heartbeat')
|
|
3924
|
-
.getImmediate({ optional: true });
|
|
3925
|
-
if (heartbeatController) {
|
|
3926
|
-
void heartbeatController.triggerHeartbeat();
|
|
3927
|
-
}
|
|
3928
|
-
return app.container.getProvider(name);
|
|
3929
|
-
}
|
|
3930
|
-
/**
|
|
3931
|
-
*
|
|
3932
|
-
* @param app - FirebaseApp instance
|
|
3933
|
-
* @param name - service name
|
|
3934
|
-
* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
|
|
3935
|
-
*
|
|
3936
|
-
* @internal
|
|
3937
|
-
*/
|
|
3938
|
-
function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
|
|
3939
|
-
_getProvider(app, name).clearInstance(instanceIdentifier);
|
|
3940
|
-
}
|
|
3941
|
-
/**
|
|
3942
|
-
*
|
|
3943
|
-
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3944
|
-
*
|
|
3945
|
-
* @returns true if the provide object is of type FirebaseApp.
|
|
3946
|
-
*
|
|
3947
|
-
* @internal
|
|
3948
|
-
*/
|
|
3949
|
-
function _isFirebaseApp(obj) {
|
|
3950
|
-
return obj.options !== undefined;
|
|
3951
|
-
}
|
|
3952
|
-
/**
|
|
3953
|
-
*
|
|
3954
|
-
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3955
|
-
*
|
|
3956
|
-
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3957
|
-
*
|
|
3958
|
-
* @internal
|
|
3959
|
-
*/
|
|
3960
|
-
function _isFirebaseServerAppSettings(obj) {
|
|
3961
|
-
if (_isFirebaseApp(obj)) {
|
|
3962
|
-
return false;
|
|
3963
|
-
}
|
|
3964
|
-
return ('authIdToken' in obj ||
|
|
3965
|
-
'appCheckToken' in obj ||
|
|
3966
|
-
'releaseOnDeref' in obj ||
|
|
3967
|
-
'automaticDataCollectionEnabled' in obj);
|
|
3968
|
-
}
|
|
3969
|
-
/**
|
|
3970
|
-
*
|
|
3971
|
-
* @param obj - an object of type FirebaseApp.
|
|
3972
|
-
*
|
|
3973
|
-
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3974
|
-
*
|
|
3975
|
-
* @internal
|
|
3976
|
-
*/
|
|
3977
|
-
function _isFirebaseServerApp(obj) {
|
|
3978
|
-
if (obj === null || obj === undefined) {
|
|
3979
|
-
return false;
|
|
3980
|
-
}
|
|
3981
|
-
return obj.settings !== undefined;
|
|
3982
|
-
}
|
|
3983
|
-
/**
|
|
3984
|
-
* Test only
|
|
3985
|
-
*
|
|
3986
|
-
* @internal
|
|
3987
|
-
*/
|
|
3988
|
-
function _clearComponents() {
|
|
3989
|
-
_components.clear();
|
|
3990
|
-
}
|
|
3991
|
-
|
|
3992
|
-
/**
|
|
3993
|
-
* @license
|
|
3994
|
-
* Copyright 2019 Google LLC
|
|
3995
|
-
*
|
|
3996
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3997
|
-
* you may not use this file except in compliance with the License.
|
|
3998
|
-
* You may obtain a copy of the License at
|
|
3999
|
-
*
|
|
4000
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4001
|
-
*
|
|
4002
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4003
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4004
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4005
|
-
* See the License for the specific language governing permissions and
|
|
4006
|
-
* limitations under the License.
|
|
4007
|
-
*/
|
|
4008
|
-
const ERRORS = {
|
|
4009
|
-
["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
|
|
4010
|
-
'call initializeApp() first',
|
|
4011
|
-
["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
|
|
4012
|
-
["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different options or config",
|
|
4013
|
-
["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
|
|
4014
|
-
["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
|
|
4015
|
-
["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
|
|
4016
|
-
["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
|
|
4017
|
-
'Firebase App instance.',
|
|
4018
|
-
["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
|
|
4019
|
-
["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4020
|
-
["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4021
|
-
["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4022
|
-
["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4023
|
-
["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
|
|
4024
|
-
["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
|
|
4025
|
-
};
|
|
4026
|
-
const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
|
4027
|
-
|
|
4028
|
-
/**
|
|
4029
|
-
* @license
|
|
4030
|
-
* Copyright 2019 Google LLC
|
|
4031
|
-
*
|
|
4032
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4033
|
-
* you may not use this file except in compliance with the License.
|
|
4034
|
-
* You may obtain a copy of the License at
|
|
4035
|
-
*
|
|
4036
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4037
|
-
*
|
|
4038
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4039
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4040
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4041
|
-
* See the License for the specific language governing permissions and
|
|
4042
|
-
* limitations under the License.
|
|
4043
|
-
*/
|
|
4044
|
-
class FirebaseAppImpl {
|
|
4045
|
-
constructor(options, config, container) {
|
|
4046
|
-
this._isDeleted = false;
|
|
4047
|
-
this._options = { ...options };
|
|
4048
|
-
this._config = { ...config };
|
|
4049
|
-
this._name = config.name;
|
|
4050
|
-
this._automaticDataCollectionEnabled =
|
|
4051
|
-
config.automaticDataCollectionEnabled;
|
|
4052
|
-
this._container = container;
|
|
4053
|
-
this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
4054
|
-
}
|
|
4055
|
-
get automaticDataCollectionEnabled() {
|
|
4056
|
-
this.checkDestroyed();
|
|
4057
|
-
return this._automaticDataCollectionEnabled;
|
|
4058
|
-
}
|
|
4059
|
-
set automaticDataCollectionEnabled(val) {
|
|
4060
|
-
this.checkDestroyed();
|
|
4061
|
-
this._automaticDataCollectionEnabled = val;
|
|
4062
|
-
}
|
|
4063
|
-
get name() {
|
|
4064
|
-
this.checkDestroyed();
|
|
4065
|
-
return this._name;
|
|
4066
|
-
}
|
|
4067
|
-
get options() {
|
|
4068
|
-
this.checkDestroyed();
|
|
4069
|
-
return this._options;
|
|
4070
|
-
}
|
|
4071
|
-
get config() {
|
|
4072
|
-
this.checkDestroyed();
|
|
4073
|
-
return this._config;
|
|
4074
|
-
}
|
|
4075
|
-
get container() {
|
|
4076
|
-
return this._container;
|
|
4077
|
-
}
|
|
4078
|
-
get isDeleted() {
|
|
4079
|
-
return this._isDeleted;
|
|
4080
|
-
}
|
|
4081
|
-
set isDeleted(val) {
|
|
4082
|
-
this._isDeleted = val;
|
|
4083
|
-
}
|
|
4084
|
-
/**
|
|
4085
|
-
* This function will throw an Error if the App has already been deleted -
|
|
4086
|
-
* use before performing API actions on the App.
|
|
4087
|
-
*/
|
|
4088
|
-
checkDestroyed() {
|
|
4089
|
-
if (this.isDeleted) {
|
|
4090
|
-
throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
|
|
4091
|
-
}
|
|
4092
|
-
}
|
|
4093
|
-
}
|
|
4094
|
-
|
|
4095
|
-
/**
|
|
4096
|
-
* @license
|
|
4097
|
-
* Copyright 2023 Google LLC
|
|
4098
|
-
*
|
|
4099
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4100
|
-
* you may not use this file except in compliance with the License.
|
|
4101
|
-
* You may obtain a copy of the License at
|
|
4102
|
-
*
|
|
4103
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4104
|
-
*
|
|
4105
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4106
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4107
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4108
|
-
* See the License for the specific language governing permissions and
|
|
4109
|
-
* limitations under the License.
|
|
4110
|
-
*/
|
|
4111
|
-
// Parse the token and check to see if the `exp` claim is in the future.
|
|
4112
|
-
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
|
|
4113
|
-
// the past.
|
|
4114
|
-
function validateTokenTTL(base64Token, tokenName) {
|
|
4115
|
-
const secondPart = util.base64Decode(base64Token.split('.')[1]);
|
|
4116
|
-
if (secondPart === null) {
|
|
4117
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
|
|
4118
|
-
return;
|
|
4119
|
-
}
|
|
4120
|
-
const expClaim = JSON.parse(secondPart).exp;
|
|
4121
|
-
if (expClaim === undefined) {
|
|
4122
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
|
|
4123
|
-
return;
|
|
4124
|
-
}
|
|
4125
|
-
const exp = JSON.parse(secondPart).exp * 1000;
|
|
4126
|
-
const now = new Date().getTime();
|
|
4127
|
-
const diff = exp - now;
|
|
4128
|
-
if (diff <= 0) {
|
|
4129
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
|
|
4130
|
-
}
|
|
4131
|
-
}
|
|
4132
|
-
class FirebaseServerAppImpl extends FirebaseAppImpl {
|
|
4133
|
-
constructor(options, serverConfig, name, container) {
|
|
4134
|
-
// Build configuration parameters for the FirebaseAppImpl base class.
|
|
4135
|
-
const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
|
|
4136
|
-
? serverConfig.automaticDataCollectionEnabled
|
|
4137
|
-
: true;
|
|
4138
|
-
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
|
|
4139
|
-
const config = {
|
|
4140
|
-
name,
|
|
4141
|
-
automaticDataCollectionEnabled
|
|
4142
|
-
};
|
|
4143
|
-
if (options.apiKey !== undefined) {
|
|
4144
|
-
// Construct the parent FirebaseAppImp object.
|
|
4145
|
-
super(options, config, container);
|
|
4146
|
-
}
|
|
4147
|
-
else {
|
|
4148
|
-
const appImpl = options;
|
|
4149
|
-
super(appImpl.options, config, container);
|
|
4150
|
-
}
|
|
4151
|
-
// Now construct the data for the FirebaseServerAppImpl.
|
|
4152
|
-
this._serverConfig = {
|
|
4153
|
-
automaticDataCollectionEnabled,
|
|
4154
|
-
...serverConfig
|
|
4155
|
-
};
|
|
4156
|
-
// Ensure that the current time is within the `authIdtoken` window of validity.
|
|
4157
|
-
if (this._serverConfig.authIdToken) {
|
|
4158
|
-
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
|
|
4159
|
-
}
|
|
4160
|
-
// Ensure that the current time is within the `appCheckToken` window of validity.
|
|
4161
|
-
if (this._serverConfig.appCheckToken) {
|
|
4162
|
-
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
|
|
4163
|
-
}
|
|
4164
|
-
this._finalizationRegistry = null;
|
|
4165
|
-
if (typeof FinalizationRegistry !== 'undefined') {
|
|
4166
|
-
this._finalizationRegistry = new FinalizationRegistry(() => {
|
|
4167
|
-
this.automaticCleanup();
|
|
4168
|
-
});
|
|
4169
|
-
}
|
|
4170
|
-
this._refCount = 0;
|
|
4171
|
-
this.incRefCount(this._serverConfig.releaseOnDeref);
|
|
4172
|
-
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
|
|
4173
|
-
// will never trigger.
|
|
4174
|
-
this._serverConfig.releaseOnDeref = undefined;
|
|
4175
|
-
serverConfig.releaseOnDeref = undefined;
|
|
4176
|
-
registerVersion(name$q, version$1, 'serverapp');
|
|
4177
|
-
}
|
|
4178
|
-
toJSON() {
|
|
4179
|
-
return undefined;
|
|
4180
|
-
}
|
|
4181
|
-
get refCount() {
|
|
4182
|
-
return this._refCount;
|
|
4183
|
-
}
|
|
4184
|
-
// Increment the reference count of this server app. If an object is provided, register it
|
|
4185
|
-
// with the finalization registry.
|
|
4186
|
-
incRefCount(obj) {
|
|
4187
|
-
if (this.isDeleted) {
|
|
4188
|
-
return;
|
|
4189
|
-
}
|
|
4190
|
-
this._refCount++;
|
|
4191
|
-
if (obj !== undefined && this._finalizationRegistry !== null) {
|
|
4192
|
-
this._finalizationRegistry.register(obj, this);
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
// Decrement the reference count.
|
|
4196
|
-
decRefCount() {
|
|
4197
|
-
if (this.isDeleted) {
|
|
4198
|
-
return 0;
|
|
4199
|
-
}
|
|
4200
|
-
return --this._refCount;
|
|
4201
|
-
}
|
|
4202
|
-
// Invoked by the FinalizationRegistry callback to note that this app should go through its
|
|
4203
|
-
// reference counts and delete itself if no reference count remain. The coordinating logic that
|
|
4204
|
-
// handles this is in deleteApp(...).
|
|
4205
|
-
automaticCleanup() {
|
|
4206
|
-
void deleteApp(this);
|
|
4207
|
-
}
|
|
4208
|
-
get settings() {
|
|
4209
|
-
this.checkDestroyed();
|
|
4210
|
-
return this._serverConfig;
|
|
4211
|
-
}
|
|
4212
|
-
/**
|
|
4213
|
-
* This function will throw an Error if the App has already been deleted -
|
|
4214
|
-
* use before performing API actions on the App.
|
|
4215
|
-
*/
|
|
4216
|
-
checkDestroyed() {
|
|
4217
|
-
if (this.isDeleted) {
|
|
4218
|
-
throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
|
|
4219
|
-
}
|
|
4220
|
-
}
|
|
4221
|
-
}
|
|
4222
|
-
|
|
4223
|
-
/**
|
|
4224
|
-
* @license
|
|
4225
|
-
* Copyright 2019 Google LLC
|
|
4226
|
-
*
|
|
4227
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4228
|
-
* you may not use this file except in compliance with the License.
|
|
4229
|
-
* You may obtain a copy of the License at
|
|
4230
|
-
*
|
|
4231
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4232
|
-
*
|
|
4233
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4234
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4235
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4236
|
-
* See the License for the specific language governing permissions and
|
|
4237
|
-
* limitations under the License.
|
|
4238
|
-
*/
|
|
4239
|
-
/**
|
|
4240
|
-
* The current SDK version.
|
|
4241
|
-
*
|
|
4242
|
-
* @public
|
|
4243
|
-
*/
|
|
4244
|
-
const SDK_VERSION = version;
|
|
4245
|
-
function initializeApp(_options, rawConfig = {}) {
|
|
4246
|
-
let options = _options;
|
|
4247
|
-
if (typeof rawConfig !== 'object') {
|
|
4248
|
-
const name = rawConfig;
|
|
4249
|
-
rawConfig = { name };
|
|
4250
|
-
}
|
|
4251
|
-
const config = {
|
|
4252
|
-
name: DEFAULT_ENTRY_NAME,
|
|
4253
|
-
automaticDataCollectionEnabled: true,
|
|
4254
|
-
...rawConfig
|
|
4255
|
-
};
|
|
4256
|
-
const name = config.name;
|
|
4257
|
-
if (typeof name !== 'string' || !name) {
|
|
4258
|
-
throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
|
|
4259
|
-
appName: String(name)
|
|
4260
|
-
});
|
|
4261
|
-
}
|
|
4262
|
-
options || (options = util.getDefaultAppConfig());
|
|
4263
|
-
if (!options) {
|
|
4264
|
-
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4265
|
-
}
|
|
4266
|
-
const existingApp = _apps.get(name);
|
|
4267
|
-
if (existingApp) {
|
|
4268
|
-
// return the existing app if options and config deep equal the ones in the existing app.
|
|
4269
|
-
if (util.deepEqual(options, existingApp.options) &&
|
|
4270
|
-
util.deepEqual(config, existingApp.config)) {
|
|
4271
|
-
return existingApp;
|
|
4272
|
-
}
|
|
4273
|
-
else {
|
|
4274
|
-
throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, { appName: name });
|
|
4275
|
-
}
|
|
4276
|
-
}
|
|
4277
|
-
const container = new component.ComponentContainer(name);
|
|
4278
|
-
for (const component of _components.values()) {
|
|
4279
|
-
container.addComponent(component);
|
|
4280
|
-
}
|
|
4281
|
-
const newApp = new FirebaseAppImpl(options, config, container);
|
|
4282
|
-
_apps.set(name, newApp);
|
|
4283
|
-
return newApp;
|
|
4284
|
-
}
|
|
4285
|
-
function initializeServerApp(_options, _serverAppConfig = {}) {
|
|
4286
|
-
if (util.isBrowser() && !util.isWebWorker()) {
|
|
4287
|
-
// FirebaseServerApp isn't designed to be run in browsers.
|
|
4288
|
-
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
|
4289
|
-
}
|
|
4290
|
-
let firebaseOptions;
|
|
4291
|
-
let serverAppSettings = _serverAppConfig || {};
|
|
4292
|
-
if (_options) {
|
|
4293
|
-
if (_isFirebaseApp(_options)) {
|
|
4294
|
-
firebaseOptions = _options.options;
|
|
4295
|
-
}
|
|
4296
|
-
else if (_isFirebaseServerAppSettings(_options)) {
|
|
4297
|
-
serverAppSettings = _options;
|
|
4298
|
-
}
|
|
4299
|
-
else {
|
|
4300
|
-
firebaseOptions = _options;
|
|
4301
|
-
}
|
|
4302
|
-
}
|
|
4303
|
-
if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
|
|
4304
|
-
serverAppSettings.automaticDataCollectionEnabled = true;
|
|
4305
|
-
}
|
|
4306
|
-
firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
|
|
4307
|
-
if (!firebaseOptions) {
|
|
4308
|
-
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4309
|
-
}
|
|
4310
|
-
// Build an app name based on a hash of the configuration options.
|
|
4311
|
-
const nameObj = {
|
|
4312
|
-
...serverAppSettings,
|
|
4313
|
-
...firebaseOptions
|
|
4314
|
-
};
|
|
4315
|
-
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
|
4316
|
-
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
|
4317
|
-
if (nameObj.releaseOnDeref !== undefined) {
|
|
4318
|
-
delete nameObj.releaseOnDeref;
|
|
4319
|
-
}
|
|
4320
|
-
const hashCode = (s) => {
|
|
4321
|
-
return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
|
|
4322
|
-
};
|
|
4323
|
-
if (serverAppSettings.releaseOnDeref !== undefined) {
|
|
4324
|
-
if (typeof FinalizationRegistry === 'undefined') {
|
|
4325
|
-
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
|
4326
|
-
}
|
|
4327
|
-
}
|
|
4328
|
-
const nameString = '' + hashCode(JSON.stringify(nameObj));
|
|
4329
|
-
const existingApp = _serverApps.get(nameString);
|
|
4330
|
-
if (existingApp) {
|
|
4331
|
-
existingApp.incRefCount(serverAppSettings.releaseOnDeref);
|
|
4332
|
-
return existingApp;
|
|
4333
|
-
}
|
|
4334
|
-
const container = new component.ComponentContainer(nameString);
|
|
4335
|
-
for (const component of _components.values()) {
|
|
4336
|
-
container.addComponent(component);
|
|
4337
|
-
}
|
|
4338
|
-
const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
|
|
4339
|
-
_serverApps.set(nameString, newApp);
|
|
4340
|
-
return newApp;
|
|
4341
|
-
}
|
|
4342
|
-
/**
|
|
4343
|
-
* Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
|
4344
|
-
*
|
|
4345
|
-
* When called with no arguments, the default app is returned. When an app name
|
|
4346
|
-
* is provided, the app corresponding to that name is returned.
|
|
4347
|
-
*
|
|
4348
|
-
* An exception is thrown if the app being retrieved has not yet been
|
|
4349
|
-
* initialized.
|
|
4350
|
-
*
|
|
4351
|
-
* @example
|
|
4352
|
-
* ```javascript
|
|
4353
|
-
* // Return the default app
|
|
4354
|
-
* const app = getApp();
|
|
4355
|
-
* ```
|
|
4356
|
-
*
|
|
4357
|
-
* @example
|
|
4358
|
-
* ```javascript
|
|
4359
|
-
* // Return a named app
|
|
4360
|
-
* const otherApp = getApp("otherApp");
|
|
4361
|
-
* ```
|
|
4362
|
-
*
|
|
4363
|
-
* @param name - Optional name of the app to return. If no name is
|
|
4364
|
-
* provided, the default is `"[DEFAULT]"`.
|
|
4365
|
-
*
|
|
4366
|
-
* @returns The app corresponding to the provided app name.
|
|
4367
|
-
* If no app name is provided, the default app is returned.
|
|
4368
|
-
*
|
|
4369
|
-
* @public
|
|
4370
|
-
*/
|
|
4371
|
-
function getApp(name = DEFAULT_ENTRY_NAME) {
|
|
4372
|
-
const app = _apps.get(name);
|
|
4373
|
-
if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
|
|
4374
|
-
return initializeApp();
|
|
4375
|
-
}
|
|
4376
|
-
if (!app) {
|
|
4377
|
-
throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
|
|
4378
|
-
}
|
|
4379
|
-
return app;
|
|
4380
|
-
}
|
|
4381
|
-
/**
|
|
4382
|
-
* A (read-only) array of all initialized apps.
|
|
4383
|
-
* @public
|
|
4384
|
-
*/
|
|
4385
|
-
function getApps() {
|
|
4386
|
-
return Array.from(_apps.values());
|
|
4387
|
-
}
|
|
4388
|
-
/**
|
|
4389
|
-
* Renders this app unusable and frees the resources of all associated
|
|
4390
|
-
* services.
|
|
4391
|
-
*
|
|
4392
|
-
* @example
|
|
4393
|
-
* ```javascript
|
|
4394
|
-
* deleteApp(app)
|
|
4395
|
-
* .then(function() {
|
|
4396
|
-
* console.log("App deleted successfully");
|
|
4397
|
-
* })
|
|
4398
|
-
* .catch(function(error) {
|
|
4399
|
-
* console.log("Error deleting app:", error);
|
|
4400
|
-
* });
|
|
4401
|
-
* ```
|
|
4402
|
-
*
|
|
4403
|
-
* @public
|
|
4404
|
-
*/
|
|
4405
|
-
async function deleteApp(app) {
|
|
4406
|
-
let cleanupProviders = false;
|
|
4407
|
-
const name = app.name;
|
|
4408
|
-
if (_apps.has(name)) {
|
|
4409
|
-
cleanupProviders = true;
|
|
4410
|
-
_apps.delete(name);
|
|
4411
|
-
}
|
|
4412
|
-
else if (_serverApps.has(name)) {
|
|
4413
|
-
const firebaseServerApp = app;
|
|
4414
|
-
if (firebaseServerApp.decRefCount() <= 0) {
|
|
4415
|
-
_serverApps.delete(name);
|
|
4416
|
-
cleanupProviders = true;
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
if (cleanupProviders) {
|
|
4420
|
-
await Promise.all(app.container
|
|
4421
|
-
.getProviders()
|
|
4422
|
-
.map(provider => provider.delete()));
|
|
4423
|
-
app.isDeleted = true;
|
|
4424
|
-
}
|
|
4425
|
-
}
|
|
4426
|
-
/**
|
|
4427
|
-
* Registers a library's name and version for platform logging purposes.
|
|
4428
|
-
* @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
|
|
4429
|
-
* @param version - Current version of that library.
|
|
4430
|
-
* @param variant - Bundle variant, e.g., node, rn, etc.
|
|
4431
|
-
*
|
|
4432
|
-
* @public
|
|
4433
|
-
*/
|
|
4434
|
-
function registerVersion(libraryKeyOrName, version, variant) {
|
|
4435
|
-
// TODO: We can use this check to whitelist strings when/if we set up
|
|
4436
|
-
// a good whitelist system.
|
|
4437
|
-
let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
|
|
4438
|
-
if (variant) {
|
|
4439
|
-
library += `-${variant}`;
|
|
4440
|
-
}
|
|
4441
|
-
const libraryMismatch = library.match(/\s|\//);
|
|
4442
|
-
const versionMismatch = version.match(/\s|\//);
|
|
4443
|
-
if (libraryMismatch || versionMismatch) {
|
|
4444
|
-
const warning = [
|
|
4445
|
-
`Unable to register library "${library}" with version "${version}":`
|
|
4446
|
-
];
|
|
4447
|
-
if (libraryMismatch) {
|
|
4448
|
-
warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
|
|
4449
|
-
}
|
|
4450
|
-
if (libraryMismatch && versionMismatch) {
|
|
4451
|
-
warning.push('and');
|
|
4452
|
-
}
|
|
4453
|
-
if (versionMismatch) {
|
|
4454
|
-
warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
|
|
4455
|
-
}
|
|
4456
|
-
logger.warn(warning.join(' '));
|
|
4457
|
-
return;
|
|
4458
|
-
}
|
|
4459
|
-
_registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
|
|
4460
|
-
}
|
|
4461
|
-
/**
|
|
4462
|
-
* Sets log handler for all Firebase SDKs.
|
|
4463
|
-
* @param logCallback - An optional custom log handler that executes user code whenever
|
|
4464
|
-
* the Firebase SDK makes a logging call.
|
|
4465
|
-
*
|
|
4466
|
-
* @public
|
|
4467
|
-
*/
|
|
4468
|
-
function onLog(logCallback, options) {
|
|
4469
|
-
if (logCallback !== null && typeof logCallback !== 'function') {
|
|
4470
|
-
throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
|
|
4471
|
-
}
|
|
4472
|
-
logger$1.setUserLogHandler(logCallback, options);
|
|
4473
|
-
}
|
|
4474
|
-
/**
|
|
4475
|
-
* Sets log level for all Firebase SDKs.
|
|
4476
|
-
*
|
|
4477
|
-
* All of the log types above the current log level are captured (i.e. if
|
|
4478
|
-
* you set the log level to `info`, errors are logged, but `debug` and
|
|
4479
|
-
* `verbose` logs are not).
|
|
4480
|
-
*
|
|
4481
|
-
* @public
|
|
4482
|
-
*/
|
|
4483
|
-
function setLogLevel(logLevel) {
|
|
4484
|
-
logger$1.setLogLevel(logLevel);
|
|
4485
|
-
}
|
|
4486
|
-
|
|
4487
|
-
/**
|
|
4488
|
-
* @license
|
|
4489
|
-
* Copyright 2021 Google LLC
|
|
4490
|
-
*
|
|
4491
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4492
|
-
* you may not use this file except in compliance with the License.
|
|
4493
|
-
* You may obtain a copy of the License at
|
|
4494
|
-
*
|
|
4495
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4496
|
-
*
|
|
4497
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4498
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4499
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4500
|
-
* See the License for the specific language governing permissions and
|
|
4501
|
-
* limitations under the License.
|
|
4502
|
-
*/
|
|
4503
|
-
const DB_NAME = 'firebase-heartbeat-database';
|
|
4504
|
-
const DB_VERSION = 1;
|
|
4505
|
-
const STORE_NAME = 'firebase-heartbeat-store';
|
|
4506
|
-
let dbPromise = null;
|
|
4507
|
-
function getDbPromise() {
|
|
4508
|
-
if (!dbPromise) {
|
|
4509
|
-
dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
|
|
4510
|
-
upgrade: (db, oldVersion) => {
|
|
4511
|
-
// We don't use 'break' in this switch statement, the fall-through
|
|
4512
|
-
// behavior is what we want, because if there are multiple versions between
|
|
4513
|
-
// the old version and the current version, we want ALL the migrations
|
|
4514
|
-
// that correspond to those versions to run, not only the last one.
|
|
4515
|
-
// eslint-disable-next-line default-case
|
|
4516
|
-
switch (oldVersion) {
|
|
4517
|
-
case 0:
|
|
4518
|
-
try {
|
|
4519
|
-
db.createObjectStore(STORE_NAME);
|
|
4520
|
-
}
|
|
4521
|
-
catch (e) {
|
|
4522
|
-
// Safari/iOS browsers throw occasional exceptions on
|
|
4523
|
-
// db.createObjectStore() that may be a bug. Avoid blocking
|
|
4524
|
-
// the rest of the app functionality.
|
|
4525
|
-
console.warn(e);
|
|
4526
|
-
}
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
|
-
}).catch(e => {
|
|
4530
|
-
throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
|
|
4531
|
-
originalErrorMessage: e.message
|
|
4532
|
-
});
|
|
4533
|
-
});
|
|
4534
|
-
}
|
|
4535
|
-
return dbPromise;
|
|
4536
|
-
}
|
|
4537
|
-
async function readHeartbeatsFromIndexedDB(app) {
|
|
4538
|
-
try {
|
|
4539
|
-
const db = await getDbPromise();
|
|
4540
|
-
const tx = db.transaction(STORE_NAME);
|
|
4541
|
-
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
|
|
4542
|
-
// We already have the value but tx.done can throw,
|
|
4543
|
-
// so we need to await it here to catch errors
|
|
4544
|
-
await tx.done;
|
|
4545
|
-
return result;
|
|
4546
|
-
}
|
|
4547
|
-
catch (e) {
|
|
4548
|
-
if (e instanceof util.FirebaseError) {
|
|
4549
|
-
logger.warn(e.message);
|
|
4550
|
-
}
|
|
4551
|
-
else {
|
|
4552
|
-
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
|
|
4553
|
-
originalErrorMessage: e?.message
|
|
4554
|
-
});
|
|
4555
|
-
logger.warn(idbGetError.message);
|
|
4556
|
-
}
|
|
4557
|
-
}
|
|
4558
|
-
}
|
|
4559
|
-
async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
|
|
4560
|
-
try {
|
|
4561
|
-
const db = await getDbPromise();
|
|
4562
|
-
const tx = db.transaction(STORE_NAME, 'readwrite');
|
|
4563
|
-
const objectStore = tx.objectStore(STORE_NAME);
|
|
4564
|
-
await objectStore.put(heartbeatObject, computeKey(app));
|
|
4565
|
-
await tx.done;
|
|
4566
|
-
}
|
|
4567
|
-
catch (e) {
|
|
4568
|
-
if (e instanceof util.FirebaseError) {
|
|
4569
|
-
logger.warn(e.message);
|
|
4570
|
-
}
|
|
4571
|
-
else {
|
|
4572
|
-
const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
|
|
4573
|
-
originalErrorMessage: e?.message
|
|
4574
|
-
});
|
|
4575
|
-
logger.warn(idbGetError.message);
|
|
4576
|
-
}
|
|
4577
|
-
}
|
|
4578
|
-
}
|
|
4579
|
-
function computeKey(app) {
|
|
4580
|
-
return `${app.name}!${app.options.appId}`;
|
|
4581
|
-
}
|
|
4582
|
-
|
|
4583
|
-
/**
|
|
4584
|
-
* @license
|
|
4585
|
-
* Copyright 2021 Google LLC
|
|
4586
|
-
*
|
|
4587
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4588
|
-
* you may not use this file except in compliance with the License.
|
|
4589
|
-
* You may obtain a copy of the License at
|
|
4590
|
-
*
|
|
4591
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4592
|
-
*
|
|
4593
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4594
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4595
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4596
|
-
* See the License for the specific language governing permissions and
|
|
4597
|
-
* limitations under the License.
|
|
4598
|
-
*/
|
|
4599
|
-
const MAX_HEADER_BYTES = 1024;
|
|
4600
|
-
const MAX_NUM_STORED_HEARTBEATS = 30;
|
|
4601
|
-
class HeartbeatServiceImpl {
|
|
4602
|
-
constructor(container) {
|
|
4603
|
-
this.container = container;
|
|
4604
|
-
/**
|
|
4605
|
-
* In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
|
|
4606
|
-
* the header string.
|
|
4607
|
-
* Stores one record per date. This will be consolidated into the standard
|
|
4608
|
-
* format of one record per user agent string before being sent as a header.
|
|
4609
|
-
* Populated from indexedDB when the controller is instantiated and should
|
|
4610
|
-
* be kept in sync with indexedDB.
|
|
4611
|
-
* Leave public for easier testing.
|
|
4612
|
-
*/
|
|
4613
|
-
this._heartbeatsCache = null;
|
|
4614
|
-
const app = this.container.getProvider('app').getImmediate();
|
|
4615
|
-
this._storage = new HeartbeatStorageImpl(app);
|
|
4616
|
-
this._heartbeatsCachePromise = this._storage.read().then(result => {
|
|
4617
|
-
this._heartbeatsCache = result;
|
|
4618
|
-
return result;
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
|
-
/**
|
|
4622
|
-
* Called to report a heartbeat. The function will generate
|
|
4623
|
-
* a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
|
|
4624
|
-
* to IndexedDB.
|
|
4625
|
-
* Note that we only store one heartbeat per day. So if a heartbeat for today is
|
|
4626
|
-
* already logged, subsequent calls to this function in the same day will be ignored.
|
|
4627
|
-
*/
|
|
4628
|
-
async triggerHeartbeat() {
|
|
4629
|
-
try {
|
|
4630
|
-
const platformLogger = this.container
|
|
4631
|
-
.getProvider('platform-logger')
|
|
4632
|
-
.getImmediate();
|
|
4633
|
-
// This is the "Firebase user agent" string from the platform logger
|
|
4634
|
-
// service, not the browser user agent.
|
|
4635
|
-
const agent = platformLogger.getPlatformInfoString();
|
|
4636
|
-
const date = getUTCDateString();
|
|
4637
|
-
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4638
|
-
this._heartbeatsCache = await this._heartbeatsCachePromise;
|
|
4639
|
-
// If we failed to construct a heartbeats cache, then return immediately.
|
|
4640
|
-
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4641
|
-
return;
|
|
4642
|
-
}
|
|
4643
|
-
}
|
|
4644
|
-
// Do not store a heartbeat if one is already stored for this day
|
|
4645
|
-
// or if a header has already been sent today.
|
|
4646
|
-
if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
|
|
4647
|
-
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
|
|
4648
|
-
return;
|
|
4649
|
-
}
|
|
4650
|
-
else {
|
|
4651
|
-
// There is no entry for this date. Create one.
|
|
4652
|
-
this._heartbeatsCache.heartbeats.push({ date, agent });
|
|
4653
|
-
// If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
|
|
4654
|
-
// 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.
|
|
4655
|
-
if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
|
|
4656
|
-
const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
|
|
4657
|
-
this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
|
|
4658
|
-
}
|
|
4659
|
-
}
|
|
4660
|
-
return this._storage.overwrite(this._heartbeatsCache);
|
|
4661
|
-
}
|
|
4662
|
-
catch (e) {
|
|
4663
|
-
logger.warn(e);
|
|
4664
|
-
}
|
|
4665
|
-
}
|
|
4666
|
-
/**
|
|
4667
|
-
* Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
|
|
4668
|
-
* It also clears all heartbeats from memory as well as in IndexedDB.
|
|
4669
|
-
*
|
|
4670
|
-
* NOTE: Consuming product SDKs should not send the header if this method
|
|
4671
|
-
* returns an empty string.
|
|
4672
|
-
*/
|
|
4673
|
-
async getHeartbeatsHeader() {
|
|
4674
|
-
try {
|
|
4675
|
-
if (this._heartbeatsCache === null) {
|
|
4676
|
-
await this._heartbeatsCachePromise;
|
|
4677
|
-
}
|
|
4678
|
-
// If it's still null or the array is empty, there is no data to send.
|
|
4679
|
-
if (this._heartbeatsCache?.heartbeats == null ||
|
|
4680
|
-
this._heartbeatsCache.heartbeats.length === 0) {
|
|
4681
|
-
return '';
|
|
4682
|
-
}
|
|
4683
|
-
const date = getUTCDateString();
|
|
4684
|
-
// Extract as many heartbeats from the cache as will fit under the size limit.
|
|
4685
|
-
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
|
|
4686
|
-
const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
|
|
4687
|
-
// Store last sent date to prevent another being logged/sent for the same day.
|
|
4688
|
-
this._heartbeatsCache.lastSentHeartbeatDate = date;
|
|
4689
|
-
if (unsentEntries.length > 0) {
|
|
4690
|
-
// Store any unsent entries if they exist.
|
|
4691
|
-
this._heartbeatsCache.heartbeats = unsentEntries;
|
|
4692
|
-
// This seems more likely than emptying the array (below) to lead to some odd state
|
|
4693
|
-
// since the cache isn't empty and this will be called again on the next request,
|
|
4694
|
-
// and is probably safest if we await it.
|
|
4695
|
-
await this._storage.overwrite(this._heartbeatsCache);
|
|
4696
|
-
}
|
|
4697
|
-
else {
|
|
4698
|
-
this._heartbeatsCache.heartbeats = [];
|
|
4699
|
-
// Do not wait for this, to reduce latency.
|
|
4700
|
-
void this._storage.overwrite(this._heartbeatsCache);
|
|
4701
|
-
}
|
|
4702
|
-
return headerString;
|
|
4703
|
-
}
|
|
4704
|
-
catch (e) {
|
|
4705
|
-
logger.warn(e);
|
|
4706
|
-
return '';
|
|
4707
|
-
}
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
|
-
function getUTCDateString() {
|
|
4711
|
-
const today = new Date();
|
|
4712
|
-
// Returns date format 'YYYY-MM-DD'
|
|
4713
|
-
return today.toISOString().substring(0, 10);
|
|
4714
|
-
}
|
|
4715
|
-
function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
|
|
4716
|
-
// Heartbeats grouped by user agent in the standard format to be sent in
|
|
4717
|
-
// the header.
|
|
4718
|
-
const heartbeatsToSend = [];
|
|
4719
|
-
// Single date format heartbeats that are not sent.
|
|
4720
|
-
let unsentEntries = heartbeatsCache.slice();
|
|
4721
|
-
for (const singleDateHeartbeat of heartbeatsCache) {
|
|
4722
|
-
// Look for an existing entry with the same user agent.
|
|
4723
|
-
const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
|
|
4724
|
-
if (!heartbeatEntry) {
|
|
4725
|
-
// If no entry for this user agent exists, create one.
|
|
4726
|
-
heartbeatsToSend.push({
|
|
4727
|
-
agent: singleDateHeartbeat.agent,
|
|
4728
|
-
dates: [singleDateHeartbeat.date]
|
|
4729
|
-
});
|
|
4730
|
-
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4731
|
-
// If the header would exceed max size, remove the added heartbeat
|
|
4732
|
-
// entry and stop adding to the header.
|
|
4733
|
-
heartbeatsToSend.pop();
|
|
4734
|
-
break;
|
|
4735
|
-
}
|
|
4736
|
-
}
|
|
4737
|
-
else {
|
|
4738
|
-
heartbeatEntry.dates.push(singleDateHeartbeat.date);
|
|
4739
|
-
// If the header would exceed max size, remove the added date
|
|
4740
|
-
// and stop adding to the header.
|
|
4741
|
-
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4742
|
-
heartbeatEntry.dates.pop();
|
|
4743
|
-
break;
|
|
4744
|
-
}
|
|
4745
|
-
}
|
|
4746
|
-
// Pop unsent entry from queue. (Skipped if adding the entry exceeded
|
|
4747
|
-
// quota and the loop breaks early.)
|
|
4748
|
-
unsentEntries = unsentEntries.slice(1);
|
|
4749
|
-
}
|
|
4750
|
-
return {
|
|
4751
|
-
heartbeatsToSend,
|
|
4752
|
-
unsentEntries
|
|
4753
|
-
};
|
|
4754
|
-
}
|
|
4755
|
-
class HeartbeatStorageImpl {
|
|
4756
|
-
constructor(app) {
|
|
4757
|
-
this.app = app;
|
|
4758
|
-
this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
|
|
4759
|
-
}
|
|
4760
|
-
async runIndexedDBEnvironmentCheck() {
|
|
4761
|
-
if (!util.isIndexedDBAvailable()) {
|
|
4762
|
-
return false;
|
|
4763
|
-
}
|
|
4764
|
-
else {
|
|
4765
|
-
return util.validateIndexedDBOpenable()
|
|
4766
|
-
.then(() => true)
|
|
4767
|
-
.catch(() => false);
|
|
4768
|
-
}
|
|
4769
|
-
}
|
|
4770
|
-
/**
|
|
4771
|
-
* Read all heartbeats.
|
|
4772
|
-
*/
|
|
4773
|
-
async read() {
|
|
4774
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4775
|
-
if (!canUseIndexedDB) {
|
|
4776
|
-
return { heartbeats: [] };
|
|
4777
|
-
}
|
|
4778
|
-
else {
|
|
4779
|
-
const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
|
|
4780
|
-
if (idbHeartbeatObject?.heartbeats) {
|
|
4781
|
-
return idbHeartbeatObject;
|
|
4782
|
-
}
|
|
4783
|
-
else {
|
|
4784
|
-
return { heartbeats: [] };
|
|
4785
|
-
}
|
|
4786
|
-
}
|
|
4787
|
-
}
|
|
4788
|
-
// overwrite the storage with the provided heartbeats
|
|
4789
|
-
async overwrite(heartbeatsObject) {
|
|
4790
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4791
|
-
if (!canUseIndexedDB) {
|
|
4792
|
-
return;
|
|
4793
|
-
}
|
|
4794
|
-
else {
|
|
4795
|
-
const existingHeartbeatsObject = await this.read();
|
|
4796
|
-
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4797
|
-
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4798
|
-
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4799
|
-
heartbeats: heartbeatsObject.heartbeats
|
|
4800
|
-
});
|
|
4801
|
-
}
|
|
4802
|
-
}
|
|
4803
|
-
// add heartbeats
|
|
4804
|
-
async add(heartbeatsObject) {
|
|
4805
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4806
|
-
if (!canUseIndexedDB) {
|
|
4807
|
-
return;
|
|
4808
|
-
}
|
|
4809
|
-
else {
|
|
4810
|
-
const existingHeartbeatsObject = await this.read();
|
|
4811
|
-
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4812
|
-
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4813
|
-
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4814
|
-
heartbeats: [
|
|
4815
|
-
...existingHeartbeatsObject.heartbeats,
|
|
4816
|
-
...heartbeatsObject.heartbeats
|
|
4817
|
-
]
|
|
4818
|
-
});
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
}
|
|
4822
|
-
/**
|
|
4823
|
-
* Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
|
|
4824
|
-
* in a platform logging header JSON object, stringified, and converted
|
|
4825
|
-
* to base 64.
|
|
4826
|
-
*/
|
|
4827
|
-
function countBytes(heartbeatsCache) {
|
|
4828
|
-
// base64 has a restricted set of characters, all of which should be 1 byte.
|
|
4829
|
-
return util.base64urlEncodeWithoutPadding(
|
|
4830
|
-
// heartbeatsCache wrapper properties
|
|
4831
|
-
JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
|
|
4832
|
-
}
|
|
4833
|
-
/**
|
|
4834
|
-
* Returns the index of the heartbeat with the earliest date.
|
|
4835
|
-
* If the heartbeats array is empty, -1 is returned.
|
|
4836
|
-
*/
|
|
4837
|
-
function getEarliestHeartbeatIdx(heartbeats) {
|
|
4838
|
-
if (heartbeats.length === 0) {
|
|
4839
|
-
return -1;
|
|
4840
|
-
}
|
|
4841
|
-
let earliestHeartbeatIdx = 0;
|
|
4842
|
-
let earliestHeartbeatDate = heartbeats[0].date;
|
|
4843
|
-
for (let i = 1; i < heartbeats.length; i++) {
|
|
4844
|
-
if (heartbeats[i].date < earliestHeartbeatDate) {
|
|
4845
|
-
earliestHeartbeatDate = heartbeats[i].date;
|
|
4846
|
-
earliestHeartbeatIdx = i;
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
return earliestHeartbeatIdx;
|
|
4850
|
-
}
|
|
4851
|
-
|
|
4852
|
-
/**
|
|
4853
|
-
* @license
|
|
4854
|
-
* Copyright 2019 Google LLC
|
|
4855
|
-
*
|
|
4856
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4857
|
-
* you may not use this file except in compliance with the License.
|
|
4858
|
-
* You may obtain a copy of the License at
|
|
4859
|
-
*
|
|
4860
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4861
|
-
*
|
|
4862
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4863
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4864
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4865
|
-
* See the License for the specific language governing permissions and
|
|
4866
|
-
* limitations under the License.
|
|
4867
|
-
*/
|
|
4868
|
-
function registerCoreComponents(variant) {
|
|
4869
|
-
_registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4870
|
-
_registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4871
|
-
// Register `app` package.
|
|
4872
|
-
registerVersion(name$q, version$1, variant);
|
|
4873
|
-
// BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
|
|
4874
|
-
registerVersion(name$q, version$1, 'cjs2020');
|
|
4875
|
-
// Register platform SDK identifier (no version).
|
|
4876
|
-
registerVersion('fire-js', '');
|
|
4877
|
-
}
|
|
4878
|
-
|
|
4879
|
-
/**
|
|
4880
|
-
* Firebase App
|
|
4881
|
-
*
|
|
4882
|
-
* @remarks This package coordinates the communication between the different Firebase components
|
|
4883
|
-
* @packageDocumentation
|
|
4884
|
-
*/
|
|
4885
|
-
/**
|
|
4886
|
-
* @license
|
|
4887
|
-
* Copyright 2019 Google LLC
|
|
4888
|
-
*
|
|
4889
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4890
|
-
* you may not use this file except in compliance with the License.
|
|
4891
|
-
* You may obtain a copy of the License at
|
|
4892
|
-
*
|
|
4893
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4894
|
-
*
|
|
4895
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4896
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4897
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4898
|
-
* See the License for the specific language governing permissions and
|
|
4899
|
-
* limitations under the License.
|
|
4900
|
-
*/
|
|
4901
|
-
registerCoreComponents('node');
|
|
4902
|
-
|
|
4903
|
-
Object.defineProperty(exports, "FirebaseError", {
|
|
4904
|
-
enumerable: true,
|
|
4905
|
-
get: function () { return util.FirebaseError; }
|
|
4906
|
-
});
|
|
4907
|
-
exports.SDK_VERSION = SDK_VERSION;
|
|
4908
|
-
exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
|
|
4909
|
-
exports._addComponent = _addComponent;
|
|
4910
|
-
exports._addOrOverwriteComponent = _addOrOverwriteComponent;
|
|
4911
|
-
exports._apps = _apps;
|
|
4912
|
-
exports._clearComponents = _clearComponents;
|
|
4913
|
-
exports._components = _components;
|
|
4914
|
-
exports._getProvider = _getProvider;
|
|
4915
|
-
exports._isFirebaseApp = _isFirebaseApp;
|
|
4916
|
-
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
|
4917
|
-
exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
|
|
4918
|
-
exports._registerComponent = _registerComponent;
|
|
4919
|
-
exports._removeServiceInstance = _removeServiceInstance;
|
|
4920
|
-
exports._serverApps = _serverApps;
|
|
4921
|
-
exports.deleteApp = deleteApp;
|
|
4922
|
-
exports.getApp = getApp;
|
|
4923
|
-
exports.getApps = getApps;
|
|
4924
|
-
exports.initializeApp = initializeApp;
|
|
4925
|
-
exports.initializeServerApp = initializeServerApp;
|
|
4926
|
-
exports.onLog = onLog;
|
|
4927
|
-
exports.registerVersion = registerVersion;
|
|
4928
|
-
exports.setLogLevel = setLogLevel;
|
|
4929
|
-
|
|
4930
|
-
}(index_cjs));
|
|
4931
|
-
|
|
4932
3348
|
Object.defineProperty(index_standalone, '__esModule', { value: true });
|
|
4933
3349
|
|
|
4934
3350
|
var Websocket = websocket;
|
|
4935
|
-
var util = require$$
|
|
4936
|
-
var logger$1 = require$$
|
|
4937
|
-
var app =
|
|
4938
|
-
var component = require$$
|
|
3351
|
+
var util = require$$1$3;
|
|
3352
|
+
var logger$1 = require$$2$3;
|
|
3353
|
+
var app = require$$3;
|
|
3354
|
+
var component = require$$4;
|
|
4939
3355
|
|
|
4940
3356
|
/**
|
|
4941
3357
|
* @license
|
|
@@ -18978,7 +17394,7 @@ var update_1 = index_standalone.update = update;
|
|
|
18978
17394
|
* See the License for the specific language governing permissions and
|
|
18979
17395
|
* limitations under the License.
|
|
18980
17396
|
*/
|
|
18981
|
-
const logClient = new require$$
|
|
17397
|
+
const logClient = new require$$2$3.Logger('@firebase/database-compat');
|
|
18982
17398
|
const warn = function (msg) {
|
|
18983
17399
|
const message = 'FIREBASE WARNING: ' + msg;
|
|
18984
17400
|
logClient.warn(message);
|
|
@@ -19005,7 +17421,7 @@ const validateBoolean = function (fnName, argumentName, bool, optional) {
|
|
|
19005
17421
|
return;
|
|
19006
17422
|
}
|
|
19007
17423
|
if (typeof bool !== 'boolean') {
|
|
19008
|
-
throw new Error(require$$
|
|
17424
|
+
throw new Error(require$$1$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
|
19009
17425
|
}
|
|
19010
17426
|
};
|
|
19011
17427
|
const validateEventType = function (fnName, eventType, optional) {
|
|
@@ -19020,7 +17436,7 @@ const validateEventType = function (fnName, eventType, optional) {
|
|
|
19020
17436
|
case 'child_moved':
|
|
19021
17437
|
break;
|
|
19022
17438
|
default:
|
|
19023
|
-
throw new Error(require$$
|
|
17439
|
+
throw new Error(require$$1$3.errorPrefix(fnName, 'eventType') +
|
|
19024
17440
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19025
17441
|
'"child_changed", or "child_moved".');
|
|
19026
17442
|
}
|
|
@@ -19047,8 +17463,8 @@ class OnDisconnect {
|
|
|
19047
17463
|
this._delegate = _delegate;
|
|
19048
17464
|
}
|
|
19049
17465
|
cancel(onComplete) {
|
|
19050
|
-
require$$
|
|
19051
|
-
require$$
|
|
17466
|
+
require$$1$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
|
17467
|
+
require$$1$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
|
19052
17468
|
const result = this._delegate.cancel();
|
|
19053
17469
|
if (onComplete) {
|
|
19054
17470
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19056,8 +17472,8 @@ class OnDisconnect {
|
|
|
19056
17472
|
return result;
|
|
19057
17473
|
}
|
|
19058
17474
|
remove(onComplete) {
|
|
19059
|
-
require$$
|
|
19060
|
-
require$$
|
|
17475
|
+
require$$1$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
|
17476
|
+
require$$1$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
|
19061
17477
|
const result = this._delegate.remove();
|
|
19062
17478
|
if (onComplete) {
|
|
19063
17479
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19065,8 +17481,8 @@ class OnDisconnect {
|
|
|
19065
17481
|
return result;
|
|
19066
17482
|
}
|
|
19067
17483
|
set(value, onComplete) {
|
|
19068
|
-
require$$
|
|
19069
|
-
require$$
|
|
17484
|
+
require$$1$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
|
17485
|
+
require$$1$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
|
19070
17486
|
const result = this._delegate.set(value);
|
|
19071
17487
|
if (onComplete) {
|
|
19072
17488
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19074,8 +17490,8 @@ class OnDisconnect {
|
|
|
19074
17490
|
return result;
|
|
19075
17491
|
}
|
|
19076
17492
|
setWithPriority(value, priority, onComplete) {
|
|
19077
|
-
require$$
|
|
19078
|
-
require$$
|
|
17493
|
+
require$$1$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
|
17494
|
+
require$$1$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
|
19079
17495
|
const result = this._delegate.setWithPriority(value, priority);
|
|
19080
17496
|
if (onComplete) {
|
|
19081
17497
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19083,7 +17499,7 @@ class OnDisconnect {
|
|
|
19083
17499
|
return result;
|
|
19084
17500
|
}
|
|
19085
17501
|
update(objectToMerge, onComplete) {
|
|
19086
|
-
require$$
|
|
17502
|
+
require$$1$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
|
19087
17503
|
if (Array.isArray(objectToMerge)) {
|
|
19088
17504
|
const newObjectToMerge = {};
|
|
19089
17505
|
for (let i = 0; i < objectToMerge.length; ++i) {
|
|
@@ -19093,7 +17509,7 @@ class OnDisconnect {
|
|
|
19093
17509
|
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
|
19094
17510
|
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
|
19095
17511
|
}
|
|
19096
|
-
require$$
|
|
17512
|
+
require$$1$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
|
19097
17513
|
const result = this._delegate.update(objectToMerge);
|
|
19098
17514
|
if (onComplete) {
|
|
19099
17515
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19129,7 +17545,7 @@ class TransactionResult {
|
|
|
19129
17545
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19130
17546
|
// for end-users
|
|
19131
17547
|
toJSON() {
|
|
19132
|
-
require$$
|
|
17548
|
+
require$$1$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
|
19133
17549
|
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
|
19134
17550
|
}
|
|
19135
17551
|
}
|
|
@@ -19166,7 +17582,7 @@ class DataSnapshot {
|
|
|
19166
17582
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
19167
17583
|
*/
|
|
19168
17584
|
val() {
|
|
19169
|
-
require$$
|
|
17585
|
+
require$$1$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
|
19170
17586
|
return this._delegate.val();
|
|
19171
17587
|
}
|
|
19172
17588
|
/**
|
|
@@ -19175,14 +17591,14 @@ class DataSnapshot {
|
|
|
19175
17591
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
19176
17592
|
*/
|
|
19177
17593
|
exportVal() {
|
|
19178
|
-
require$$
|
|
17594
|
+
require$$1$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
|
19179
17595
|
return this._delegate.exportVal();
|
|
19180
17596
|
}
|
|
19181
17597
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19182
17598
|
// for end-users
|
|
19183
17599
|
toJSON() {
|
|
19184
17600
|
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
|
19185
|
-
require$$
|
|
17601
|
+
require$$1$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
|
19186
17602
|
return this._delegate.toJSON();
|
|
19187
17603
|
}
|
|
19188
17604
|
/**
|
|
@@ -19191,7 +17607,7 @@ class DataSnapshot {
|
|
|
19191
17607
|
* @returns Whether the snapshot contains a non-null value, or is empty.
|
|
19192
17608
|
*/
|
|
19193
17609
|
exists() {
|
|
19194
|
-
require$$
|
|
17610
|
+
require$$1$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
|
19195
17611
|
return this._delegate.exists();
|
|
19196
17612
|
}
|
|
19197
17613
|
/**
|
|
@@ -19201,7 +17617,7 @@ class DataSnapshot {
|
|
|
19201
17617
|
* @returns DataSnapshot for child node.
|
|
19202
17618
|
*/
|
|
19203
17619
|
child(path) {
|
|
19204
|
-
require$$
|
|
17620
|
+
require$$1$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
|
19205
17621
|
// Ensure the childPath is a string (can be a number)
|
|
19206
17622
|
path = String(path);
|
|
19207
17623
|
_validatePathString('DataSnapshot.child', 'path', path, false);
|
|
@@ -19214,7 +17630,7 @@ class DataSnapshot {
|
|
|
19214
17630
|
* @returns Whether the child exists.
|
|
19215
17631
|
*/
|
|
19216
17632
|
hasChild(path) {
|
|
19217
|
-
require$$
|
|
17633
|
+
require$$1$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
|
19218
17634
|
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
|
19219
17635
|
return this._delegate.hasChild(path);
|
|
19220
17636
|
}
|
|
@@ -19224,7 +17640,7 @@ class DataSnapshot {
|
|
|
19224
17640
|
* @returns The priority.
|
|
19225
17641
|
*/
|
|
19226
17642
|
getPriority() {
|
|
19227
|
-
require$$
|
|
17643
|
+
require$$1$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
|
19228
17644
|
return this._delegate.priority;
|
|
19229
17645
|
}
|
|
19230
17646
|
/**
|
|
@@ -19236,8 +17652,8 @@ class DataSnapshot {
|
|
|
19236
17652
|
* one of the child nodes.
|
|
19237
17653
|
*/
|
|
19238
17654
|
forEach(action) {
|
|
19239
|
-
require$$
|
|
19240
|
-
require$$
|
|
17655
|
+
require$$1$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
|
17656
|
+
require$$1$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
|
|
19241
17657
|
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
|
19242
17658
|
}
|
|
19243
17659
|
/**
|
|
@@ -19245,7 +17661,7 @@ class DataSnapshot {
|
|
|
19245
17661
|
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
|
19246
17662
|
*/
|
|
19247
17663
|
hasChildren() {
|
|
19248
|
-
require$$
|
|
17664
|
+
require$$1$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
|
19249
17665
|
return this._delegate.hasChildren();
|
|
19250
17666
|
}
|
|
19251
17667
|
get key() {
|
|
@@ -19256,7 +17672,7 @@ class DataSnapshot {
|
|
|
19256
17672
|
* @returns The number of children that this DataSnapshot contains.
|
|
19257
17673
|
*/
|
|
19258
17674
|
numChildren() {
|
|
19259
|
-
require$$
|
|
17675
|
+
require$$1$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
|
19260
17676
|
return this._delegate.size;
|
|
19261
17677
|
}
|
|
19262
17678
|
/**
|
|
@@ -19264,7 +17680,7 @@ class DataSnapshot {
|
|
|
19264
17680
|
* from.
|
|
19265
17681
|
*/
|
|
19266
17682
|
getRef() {
|
|
19267
|
-
require$$
|
|
17683
|
+
require$$1$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
|
19268
17684
|
return new Reference(this._database, this._delegate.ref);
|
|
19269
17685
|
}
|
|
19270
17686
|
get ref() {
|
|
@@ -19283,8 +17699,8 @@ class Query {
|
|
|
19283
17699
|
this._delegate = _delegate;
|
|
19284
17700
|
}
|
|
19285
17701
|
on(eventType, callback, cancelCallbackOrContext, context) {
|
|
19286
|
-
require$$
|
|
19287
|
-
require$$
|
|
17702
|
+
require$$1$3.validateArgCount('Query.on', 2, 4, arguments.length);
|
|
17703
|
+
require$$1$3.validateCallback('Query.on', 'callback', callback, false);
|
|
19288
17704
|
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
|
19289
17705
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
19290
17706
|
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
|
@@ -19309,16 +17725,16 @@ class Query {
|
|
|
19309
17725
|
onChildMoved_1(this._delegate, valueCallback, cancelCallback);
|
|
19310
17726
|
return callback;
|
|
19311
17727
|
default:
|
|
19312
|
-
throw new Error(require$$
|
|
17728
|
+
throw new Error(require$$1$3.errorPrefix('Query.on', 'eventType') +
|
|
19313
17729
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19314
17730
|
'"child_changed", or "child_moved".');
|
|
19315
17731
|
}
|
|
19316
17732
|
}
|
|
19317
17733
|
off(eventType, callback, context) {
|
|
19318
|
-
require$$
|
|
17734
|
+
require$$1$3.validateArgCount('Query.off', 0, 3, arguments.length);
|
|
19319
17735
|
validateEventType('Query.off', eventType);
|
|
19320
|
-
require$$
|
|
19321
|
-
require$$
|
|
17736
|
+
require$$1$3.validateCallback('Query.off', 'callback', callback, true);
|
|
17737
|
+
require$$1$3.validateContextObject('Query.off', 'context', context, true);
|
|
19322
17738
|
if (callback) {
|
|
19323
17739
|
const valueCallback = () => { };
|
|
19324
17740
|
valueCallback.userCallback = callback;
|
|
@@ -19341,10 +17757,10 @@ class Query {
|
|
|
19341
17757
|
* Attaches a listener, waits for the first event, and then removes the listener
|
|
19342
17758
|
*/
|
|
19343
17759
|
once(eventType, callback, failureCallbackOrContext, context) {
|
|
19344
|
-
require$$
|
|
19345
|
-
require$$
|
|
17760
|
+
require$$1$3.validateArgCount('Query.once', 1, 4, arguments.length);
|
|
17761
|
+
require$$1$3.validateCallback('Query.once', 'callback', callback, true);
|
|
19346
17762
|
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
|
19347
|
-
const deferred = new require$$
|
|
17763
|
+
const deferred = new require$$1$3.Deferred();
|
|
19348
17764
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
19349
17765
|
const result = new DataSnapshot(this.database, expSnapshot);
|
|
19350
17766
|
if (callback) {
|
|
@@ -19387,7 +17803,7 @@ class Query {
|
|
|
19387
17803
|
});
|
|
19388
17804
|
break;
|
|
19389
17805
|
default:
|
|
19390
|
-
throw new Error(require$$
|
|
17806
|
+
throw new Error(require$$1$3.errorPrefix('Query.once', 'eventType') +
|
|
19391
17807
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19392
17808
|
'"child_changed", or "child_moved".');
|
|
19393
17809
|
}
|
|
@@ -19397,58 +17813,58 @@ class Query {
|
|
|
19397
17813
|
* Set a limit and anchor it to the start of the window.
|
|
19398
17814
|
*/
|
|
19399
17815
|
limitToFirst(limit) {
|
|
19400
|
-
require$$
|
|
17816
|
+
require$$1$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
|
19401
17817
|
return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
|
|
19402
17818
|
}
|
|
19403
17819
|
/**
|
|
19404
17820
|
* Set a limit and anchor it to the end of the window.
|
|
19405
17821
|
*/
|
|
19406
17822
|
limitToLast(limit) {
|
|
19407
|
-
require$$
|
|
17823
|
+
require$$1$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
|
19408
17824
|
return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
|
|
19409
17825
|
}
|
|
19410
17826
|
/**
|
|
19411
17827
|
* Given a child path, return a new query ordered by the specified grandchild path.
|
|
19412
17828
|
*/
|
|
19413
17829
|
orderByChild(path) {
|
|
19414
|
-
require$$
|
|
17830
|
+
require$$1$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
|
19415
17831
|
return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
|
|
19416
17832
|
}
|
|
19417
17833
|
/**
|
|
19418
17834
|
* Return a new query ordered by the KeyIndex
|
|
19419
17835
|
*/
|
|
19420
17836
|
orderByKey() {
|
|
19421
|
-
require$$
|
|
17837
|
+
require$$1$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
|
19422
17838
|
return new Query(this.database, query_1(this._delegate, orderByKey_1()));
|
|
19423
17839
|
}
|
|
19424
17840
|
/**
|
|
19425
17841
|
* Return a new query ordered by the PriorityIndex
|
|
19426
17842
|
*/
|
|
19427
17843
|
orderByPriority() {
|
|
19428
|
-
require$$
|
|
17844
|
+
require$$1$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
|
19429
17845
|
return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
|
|
19430
17846
|
}
|
|
19431
17847
|
/**
|
|
19432
17848
|
* Return a new query ordered by the ValueIndex
|
|
19433
17849
|
*/
|
|
19434
17850
|
orderByValue() {
|
|
19435
|
-
require$$
|
|
17851
|
+
require$$1$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
|
19436
17852
|
return new Query(this.database, query_1(this._delegate, orderByValue_1()));
|
|
19437
17853
|
}
|
|
19438
17854
|
startAt(value = null, name) {
|
|
19439
|
-
require$$
|
|
17855
|
+
require$$1$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
|
|
19440
17856
|
return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
|
|
19441
17857
|
}
|
|
19442
17858
|
startAfter(value = null, name) {
|
|
19443
|
-
require$$
|
|
17859
|
+
require$$1$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
|
19444
17860
|
return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
|
|
19445
17861
|
}
|
|
19446
17862
|
endAt(value = null, name) {
|
|
19447
|
-
require$$
|
|
17863
|
+
require$$1$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
|
|
19448
17864
|
return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
|
|
19449
17865
|
}
|
|
19450
17866
|
endBefore(value = null, name) {
|
|
19451
|
-
require$$
|
|
17867
|
+
require$$1$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
|
19452
17868
|
return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
|
|
19453
17869
|
}
|
|
19454
17870
|
/**
|
|
@@ -19456,28 +17872,28 @@ class Query {
|
|
|
19456
17872
|
* the specified name.
|
|
19457
17873
|
*/
|
|
19458
17874
|
equalTo(value, name) {
|
|
19459
|
-
require$$
|
|
17875
|
+
require$$1$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
|
19460
17876
|
return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
|
|
19461
17877
|
}
|
|
19462
17878
|
/**
|
|
19463
17879
|
* @returns URL for this location.
|
|
19464
17880
|
*/
|
|
19465
17881
|
toString() {
|
|
19466
|
-
require$$
|
|
17882
|
+
require$$1$3.validateArgCount('Query.toString', 0, 0, arguments.length);
|
|
19467
17883
|
return this._delegate.toString();
|
|
19468
17884
|
}
|
|
19469
17885
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19470
17886
|
// for end-users.
|
|
19471
17887
|
toJSON() {
|
|
19472
17888
|
// An optional spacer argument is unnecessary for a string.
|
|
19473
|
-
require$$
|
|
17889
|
+
require$$1$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
|
19474
17890
|
return this._delegate.toJSON();
|
|
19475
17891
|
}
|
|
19476
17892
|
/**
|
|
19477
17893
|
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
|
19478
17894
|
*/
|
|
19479
17895
|
isEqual(other) {
|
|
19480
|
-
require$$
|
|
17896
|
+
require$$1$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
|
19481
17897
|
if (!(other instanceof Query)) {
|
|
19482
17898
|
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
|
19483
17899
|
throw new Error(error);
|
|
@@ -19493,9 +17909,9 @@ class Query {
|
|
|
19493
17909
|
const ret = { cancel: undefined, context: undefined };
|
|
19494
17910
|
if (cancelOrContext && context) {
|
|
19495
17911
|
ret.cancel = cancelOrContext;
|
|
19496
|
-
require$$
|
|
17912
|
+
require$$1$3.validateCallback(fnName, 'cancel', ret.cancel, true);
|
|
19497
17913
|
ret.context = context;
|
|
19498
|
-
require$$
|
|
17914
|
+
require$$1$3.validateContextObject(fnName, 'context', ret.context, true);
|
|
19499
17915
|
}
|
|
19500
17916
|
else if (cancelOrContext) {
|
|
19501
17917
|
// we have either a cancel callback or a context.
|
|
@@ -19507,7 +17923,7 @@ class Query {
|
|
|
19507
17923
|
ret.cancel = cancelOrContext;
|
|
19508
17924
|
}
|
|
19509
17925
|
else {
|
|
19510
|
-
throw new Error(require$$
|
|
17926
|
+
throw new Error(require$$1$3.errorPrefix(fnName, 'cancelOrContext') +
|
|
19511
17927
|
' must either be a cancel callback or a context object.');
|
|
19512
17928
|
}
|
|
19513
17929
|
}
|
|
@@ -19532,11 +17948,11 @@ class Reference extends Query {
|
|
|
19532
17948
|
}
|
|
19533
17949
|
/** @returns {?string} */
|
|
19534
17950
|
getKey() {
|
|
19535
|
-
require$$
|
|
17951
|
+
require$$1$3.validateArgCount('Reference.key', 0, 0, arguments.length);
|
|
19536
17952
|
return this._delegate.key;
|
|
19537
17953
|
}
|
|
19538
17954
|
child(pathString) {
|
|
19539
|
-
require$$
|
|
17955
|
+
require$$1$3.validateArgCount('Reference.child', 1, 1, arguments.length);
|
|
19540
17956
|
if (typeof pathString === 'number') {
|
|
19541
17957
|
pathString = String(pathString);
|
|
19542
17958
|
}
|
|
@@ -19544,18 +17960,18 @@ class Reference extends Query {
|
|
|
19544
17960
|
}
|
|
19545
17961
|
/** @returns {?Reference} */
|
|
19546
17962
|
getParent() {
|
|
19547
|
-
require$$
|
|
17963
|
+
require$$1$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
|
|
19548
17964
|
const parent = this._delegate.parent;
|
|
19549
17965
|
return parent ? new Reference(this.database, parent) : null;
|
|
19550
17966
|
}
|
|
19551
17967
|
/** @returns {!Reference} */
|
|
19552
17968
|
getRoot() {
|
|
19553
|
-
require$$
|
|
17969
|
+
require$$1$3.validateArgCount('Reference.root', 0, 0, arguments.length);
|
|
19554
17970
|
return new Reference(this.database, this._delegate.root);
|
|
19555
17971
|
}
|
|
19556
17972
|
set(newVal, onComplete) {
|
|
19557
|
-
require$$
|
|
19558
|
-
require$$
|
|
17973
|
+
require$$1$3.validateArgCount('Reference.set', 1, 2, arguments.length);
|
|
17974
|
+
require$$1$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
|
|
19559
17975
|
const result = set_1(this._delegate, newVal);
|
|
19560
17976
|
if (onComplete) {
|
|
19561
17977
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19563,7 +17979,7 @@ class Reference extends Query {
|
|
|
19563
17979
|
return result;
|
|
19564
17980
|
}
|
|
19565
17981
|
update(values, onComplete) {
|
|
19566
|
-
require$$
|
|
17982
|
+
require$$1$3.validateArgCount('Reference.update', 1, 2, arguments.length);
|
|
19567
17983
|
if (Array.isArray(values)) {
|
|
19568
17984
|
const newObjectToMerge = {};
|
|
19569
17985
|
for (let i = 0; i < values.length; ++i) {
|
|
@@ -19576,7 +17992,7 @@ class Reference extends Query {
|
|
|
19576
17992
|
'only update some of the children.');
|
|
19577
17993
|
}
|
|
19578
17994
|
_validateWritablePath('Reference.update', this._delegate._path);
|
|
19579
|
-
require$$
|
|
17995
|
+
require$$1$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
|
|
19580
17996
|
const result = update_1(this._delegate, values);
|
|
19581
17997
|
if (onComplete) {
|
|
19582
17998
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19584,8 +18000,8 @@ class Reference extends Query {
|
|
|
19584
18000
|
return result;
|
|
19585
18001
|
}
|
|
19586
18002
|
setWithPriority(newVal, newPriority, onComplete) {
|
|
19587
|
-
require$$
|
|
19588
|
-
require$$
|
|
18003
|
+
require$$1$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
|
18004
|
+
require$$1$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
|
19589
18005
|
const result = setWithPriority_1(this._delegate, newVal, newPriority);
|
|
19590
18006
|
if (onComplete) {
|
|
19591
18007
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19593,8 +18009,8 @@ class Reference extends Query {
|
|
|
19593
18009
|
return result;
|
|
19594
18010
|
}
|
|
19595
18011
|
remove(onComplete) {
|
|
19596
|
-
require$$
|
|
19597
|
-
require$$
|
|
18012
|
+
require$$1$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
|
|
18013
|
+
require$$1$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
|
19598
18014
|
const result = remove_1(this._delegate);
|
|
19599
18015
|
if (onComplete) {
|
|
19600
18016
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19602,9 +18018,9 @@ class Reference extends Query {
|
|
|
19602
18018
|
return result;
|
|
19603
18019
|
}
|
|
19604
18020
|
transaction(transactionUpdate, onComplete, applyLocally) {
|
|
19605
|
-
require$$
|
|
19606
|
-
require$$
|
|
19607
|
-
require$$
|
|
18021
|
+
require$$1$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
|
|
18022
|
+
require$$1$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
|
|
18023
|
+
require$$1$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
|
|
19608
18024
|
validateBoolean('Reference.transaction', 'applyLocally', applyLocally);
|
|
19609
18025
|
const result = runTransaction_1(this._delegate, transactionUpdate, {
|
|
19610
18026
|
applyLocally
|
|
@@ -19615,8 +18031,8 @@ class Reference extends Query {
|
|
|
19615
18031
|
return result;
|
|
19616
18032
|
}
|
|
19617
18033
|
setPriority(priority, onComplete) {
|
|
19618
|
-
require$$
|
|
19619
|
-
require$$
|
|
18034
|
+
require$$1$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
|
18035
|
+
require$$1$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
|
19620
18036
|
const result = setPriority_1(this._delegate, priority);
|
|
19621
18037
|
if (onComplete) {
|
|
19622
18038
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19624,8 +18040,8 @@ class Reference extends Query {
|
|
|
19624
18040
|
return result;
|
|
19625
18041
|
}
|
|
19626
18042
|
push(value, onComplete) {
|
|
19627
|
-
require$$
|
|
19628
|
-
require$$
|
|
18043
|
+
require$$1$3.validateArgCount('Reference.push', 0, 2, arguments.length);
|
|
18044
|
+
require$$1$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
|
|
19629
18045
|
const expPromise = push_1(this._delegate, value);
|
|
19630
18046
|
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
|
19631
18047
|
if (onComplete) {
|
|
@@ -19697,7 +18113,7 @@ class Database {
|
|
|
19697
18113
|
connectDatabaseEmulator_1(this._delegate, host, port, options);
|
|
19698
18114
|
}
|
|
19699
18115
|
ref(path) {
|
|
19700
|
-
require$$
|
|
18116
|
+
require$$1$3.validateArgCount('database.ref', 0, 1, arguments.length);
|
|
19701
18117
|
if (path instanceof Reference) {
|
|
19702
18118
|
const childRef = refFromURL_1(this._delegate, path.toString());
|
|
19703
18119
|
return new Reference(this, childRef);
|
|
@@ -19715,17 +18131,17 @@ class Database {
|
|
|
19715
18131
|
*/
|
|
19716
18132
|
refFromURL(url) {
|
|
19717
18133
|
const apiName = 'database.refFromURL';
|
|
19718
|
-
require$$
|
|
18134
|
+
require$$1$3.validateArgCount(apiName, 1, 1, arguments.length);
|
|
19719
18135
|
const childRef = refFromURL_1(this._delegate, url);
|
|
19720
18136
|
return new Reference(this, childRef);
|
|
19721
18137
|
}
|
|
19722
18138
|
// Make individual repo go offline.
|
|
19723
18139
|
goOffline() {
|
|
19724
|
-
require$$
|
|
18140
|
+
require$$1$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
|
|
19725
18141
|
return goOffline_1(this._delegate);
|
|
19726
18142
|
}
|
|
19727
18143
|
goOnline() {
|
|
19728
|
-
require$$
|
|
18144
|
+
require$$1$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
|
|
19729
18145
|
return goOnline_1(this._delegate);
|
|
19730
18146
|
}
|
|
19731
18147
|
}
|
|
@@ -19745,17 +18161,17 @@ Database.ServerValue = {
|
|
|
19745
18161
|
*/
|
|
19746
18162
|
function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
|
19747
18163
|
_setSDKVersion(version);
|
|
19748
|
-
const container = new require$$
|
|
18164
|
+
const container = new require$$4.ComponentContainer('database-standalone');
|
|
19749
18165
|
/**
|
|
19750
18166
|
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
|
19751
18167
|
* any actual function.
|
|
19752
18168
|
*/
|
|
19753
|
-
const authProvider = new require$$
|
|
19754
|
-
authProvider.setComponent(new require$$
|
|
18169
|
+
const authProvider = new require$$4.Provider('auth-internal', container);
|
|
18170
|
+
authProvider.setComponent(new require$$4.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
19755
18171
|
let appCheckProvider = undefined;
|
|
19756
18172
|
if (customAppCheckImpl) {
|
|
19757
|
-
appCheckProvider = new require$$
|
|
19758
|
-
appCheckProvider.setComponent(new require$$
|
|
18173
|
+
appCheckProvider = new require$$4.Provider('app-check-internal', container);
|
|
18174
|
+
appCheckProvider.setComponent(new require$$4.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
19759
18175
|
}
|
|
19760
18176
|
return {
|
|
19761
18177
|
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
|
@@ -19764,8 +18180,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
|
|
|
19764
18180
|
}
|
|
19765
18181
|
|
|
19766
18182
|
var INTERNAL = /*#__PURE__*/Object.freeze({
|
|
19767
|
-
|
|
19768
|
-
|
|
18183
|
+
__proto__: null,
|
|
18184
|
+
initStandalone: initStandalone$1
|
|
19769
18185
|
});
|
|
19770
18186
|
|
|
19771
18187
|
/**
|
|
@@ -19795,7 +18211,7 @@ const ServerValue = Database.ServerValue;
|
|
|
19795
18211
|
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
|
19796
18212
|
*/
|
|
19797
18213
|
function initStandalone(app, url, version, nodeAdmin = true) {
|
|
19798
|
-
require$$
|
|
18214
|
+
require$$1$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
|
|
19799
18215
|
return initStandalone$1({
|
|
19800
18216
|
app,
|
|
19801
18217
|
url,
|