@firebase/database-compat 2.1.4 → 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 +8 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/index.standalone.js +278 -1848
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.js +8 -6
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +22 -10
package/dist/index.standalone.js
CHANGED
|
@@ -10,38 +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 _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
20
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
21
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
22
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
23
|
-
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
24
|
-
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
25
|
-
var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
26
|
-
var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
|
|
27
|
-
var require$$2__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$2$3);
|
|
28
|
-
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
29
|
-
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
30
|
-
|
|
31
|
-
function getAugmentedNamespace(n) {
|
|
32
|
-
if (n.__esModule) return n;
|
|
33
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
34
|
-
Object.keys(n).forEach(function (k) {
|
|
35
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
36
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return n[k];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
return a;
|
|
44
|
-
}
|
|
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');
|
|
45
17
|
|
|
46
18
|
var index_standalone = {};
|
|
47
19
|
|
|
@@ -51,7 +23,7 @@ var safeBuffer = {exports: {}};
|
|
|
51
23
|
|
|
52
24
|
(function (module, exports) {
|
|
53
25
|
/* eslint-disable node/no-deprecated-api */
|
|
54
|
-
var buffer = require$$
|
|
26
|
+
var buffer = require$$0;
|
|
55
27
|
var Buffer = buffer.Buffer;
|
|
56
28
|
|
|
57
29
|
// alternative to using Object.keys for old browsers
|
|
@@ -161,8 +133,8 @@ driver having these two methods.
|
|
|
161
133
|
**/
|
|
162
134
|
|
|
163
135
|
|
|
164
|
-
var Stream$3 = require$$
|
|
165
|
-
util$c = require$$
|
|
136
|
+
var Stream$3 = require$$0$1.Stream,
|
|
137
|
+
util$c = require$$2;
|
|
166
138
|
|
|
167
139
|
|
|
168
140
|
var IO = function(driver) {
|
|
@@ -366,8 +338,8 @@ StreamReader.prototype.eachByte = function(callback, context) {
|
|
|
366
338
|
var stream_reader = StreamReader;
|
|
367
339
|
|
|
368
340
|
var Buffer$8 = safeBuffer.exports.Buffer,
|
|
369
|
-
Emitter = require$$
|
|
370
|
-
util$b = require$$
|
|
341
|
+
Emitter = require$$1.EventEmitter,
|
|
342
|
+
util$b = require$$2,
|
|
371
343
|
streams = streams$1,
|
|
372
344
|
Headers$2 = headers,
|
|
373
345
|
Reader = stream_reader;
|
|
@@ -1748,8 +1720,8 @@ for (var key$8 in instance$8)
|
|
|
1748
1720
|
var message = Message$1;
|
|
1749
1721
|
|
|
1750
1722
|
var Buffer$5 = safeBuffer.exports.Buffer,
|
|
1751
|
-
crypto$2 = require$$
|
|
1752
|
-
util$a = require$$
|
|
1723
|
+
crypto$2 = require$$1$1,
|
|
1724
|
+
util$a = require$$2,
|
|
1753
1725
|
Extensions = websocket_extensions,
|
|
1754
1726
|
Base$6 = base,
|
|
1755
1727
|
Frame = frame,
|
|
@@ -2199,7 +2171,12 @@ var instance$7 = {
|
|
|
2199
2171
|
if (error) return this._fail('extension_error', error.message);
|
|
2200
2172
|
|
|
2201
2173
|
var payload = message.data;
|
|
2202
|
-
|
|
2174
|
+
|
|
2175
|
+
if (payload.length > this._maxLength)
|
|
2176
|
+
return this._fail('too_large', 'WebSocket frame length too large');
|
|
2177
|
+
|
|
2178
|
+
if (message.opcode === this.OPCODES.text)
|
|
2179
|
+
payload = this._encode(payload);
|
|
2203
2180
|
|
|
2204
2181
|
if (payload === null)
|
|
2205
2182
|
return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');
|
|
@@ -2230,16 +2207,16 @@ for (var key$7 in instance$7)
|
|
|
2230
2207
|
var hybi = Hybi$2;
|
|
2231
2208
|
|
|
2232
2209
|
var Buffer$4 = safeBuffer.exports.Buffer,
|
|
2233
|
-
Stream$2 = require$$
|
|
2234
|
-
url$2 = require$$
|
|
2235
|
-
util$9 = require$$
|
|
2210
|
+
Stream$2 = require$$0$1.Stream,
|
|
2211
|
+
url$2 = require$$2$1,
|
|
2212
|
+
util$9 = require$$2,
|
|
2236
2213
|
Base$5 = base,
|
|
2237
2214
|
Headers$1 = headers,
|
|
2238
2215
|
HttpParser$2 = http_parser;
|
|
2239
2216
|
|
|
2240
2217
|
var PORTS = { 'ws:': 80, 'wss:': 443 };
|
|
2241
2218
|
|
|
2242
|
-
var Proxy$
|
|
2219
|
+
var Proxy$1 = function(client, origin, options) {
|
|
2243
2220
|
this._client = client;
|
|
2244
2221
|
this._http = new HttpParser$2('response');
|
|
2245
2222
|
this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
|
|
@@ -2258,7 +2235,7 @@ var Proxy$2 = function(client, origin, options) {
|
|
|
2258
2235
|
var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
|
|
2259
2236
|
if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
|
|
2260
2237
|
};
|
|
2261
|
-
util$9.inherits(Proxy$
|
|
2238
|
+
util$9.inherits(Proxy$1, Stream$2);
|
|
2262
2239
|
|
|
2263
2240
|
var instance$6 = {
|
|
2264
2241
|
setHeader: function(name, value) {
|
|
@@ -2323,18 +2300,18 @@ var instance$6 = {
|
|
|
2323
2300
|
};
|
|
2324
2301
|
|
|
2325
2302
|
for (var key$6 in instance$6)
|
|
2326
|
-
Proxy$
|
|
2303
|
+
Proxy$1.prototype[key$6] = instance$6[key$6];
|
|
2327
2304
|
|
|
2328
|
-
var proxy = Proxy$
|
|
2305
|
+
var proxy = Proxy$1;
|
|
2329
2306
|
|
|
2330
2307
|
var Buffer$3 = safeBuffer.exports.Buffer,
|
|
2331
|
-
crypto$1 = require$$
|
|
2332
|
-
url$1 = require$$
|
|
2333
|
-
util$8 = require$$
|
|
2308
|
+
crypto$1 = require$$1$1,
|
|
2309
|
+
url$1 = require$$2$1,
|
|
2310
|
+
util$8 = require$$2,
|
|
2334
2311
|
HttpParser$1 = http_parser,
|
|
2335
2312
|
Base$4 = base,
|
|
2336
2313
|
Hybi$1 = hybi,
|
|
2337
|
-
Proxy
|
|
2314
|
+
Proxy = proxy;
|
|
2338
2315
|
|
|
2339
2316
|
var Client$2 = function(_url, options) {
|
|
2340
2317
|
this.version = 'hybi-' + Hybi$1.VERSION;
|
|
@@ -2375,7 +2352,7 @@ var instance$5 = {
|
|
|
2375
2352
|
VALID_PROTOCOLS: ['ws:', 'wss:'],
|
|
2376
2353
|
|
|
2377
2354
|
proxy: function(origin, options) {
|
|
2378
|
-
return new Proxy
|
|
2355
|
+
return new Proxy(this, origin, options);
|
|
2379
2356
|
},
|
|
2380
2357
|
|
|
2381
2358
|
start: function() {
|
|
@@ -2470,7 +2447,7 @@ var client$1 = Client$2;
|
|
|
2470
2447
|
|
|
2471
2448
|
var Buffer$2 = safeBuffer.exports.Buffer,
|
|
2472
2449
|
Base$3 = base,
|
|
2473
|
-
util$7 = require$$
|
|
2450
|
+
util$7 = require$$2;
|
|
2474
2451
|
|
|
2475
2452
|
var Draft75$2 = function(request, url, options) {
|
|
2476
2453
|
Base$3.apply(this, arguments);
|
|
@@ -2512,6 +2489,7 @@ var instance$4 = {
|
|
|
2512
2489
|
|
|
2513
2490
|
case 1:
|
|
2514
2491
|
this._length = (octet & 0x7F) + 128 * this._length;
|
|
2492
|
+
if (this._length > this._maxLength) return this.close();
|
|
2515
2493
|
|
|
2516
2494
|
if (this._closing && this._length === 0) {
|
|
2517
2495
|
return this.close();
|
|
@@ -2593,8 +2571,8 @@ var draft75 = Draft75$2;
|
|
|
2593
2571
|
var Buffer$1 = safeBuffer.exports.Buffer,
|
|
2594
2572
|
Base$2 = base,
|
|
2595
2573
|
Draft75$1 = draft75,
|
|
2596
|
-
crypto = require$$
|
|
2597
|
-
util$6 = require$$
|
|
2574
|
+
crypto = require$$1$1,
|
|
2575
|
+
util$6 = require$$2;
|
|
2598
2576
|
|
|
2599
2577
|
|
|
2600
2578
|
var numberFromKey = function(key) {
|
|
@@ -2706,7 +2684,7 @@ for (var key$3 in instance$3)
|
|
|
2706
2684
|
|
|
2707
2685
|
var draft76 = Draft76$1;
|
|
2708
2686
|
|
|
2709
|
-
var util$5 = require$$
|
|
2687
|
+
var util$5 = require$$2,
|
|
2710
2688
|
HttpParser = http_parser,
|
|
2711
2689
|
Base$1 = base,
|
|
2712
2690
|
Draft75 = draft75,
|
|
@@ -2909,8 +2887,8 @@ var EventTarget$2 = {
|
|
|
2909
2887
|
|
|
2910
2888
|
var event_target = EventTarget$2;
|
|
2911
2889
|
|
|
2912
|
-
var Stream$1 = require$$
|
|
2913
|
-
util$4 = require$$
|
|
2890
|
+
var Stream$1 = require$$0$1.Stream,
|
|
2891
|
+
util$4 = require$$2,
|
|
2914
2892
|
driver$3 = driver$4,
|
|
2915
2893
|
EventTarget$1 = event_target,
|
|
2916
2894
|
Event$1 = event;
|
|
@@ -3107,10 +3085,10 @@ for (var key$1 in EventTarget$1) API$3.prototype[key$1] = EventTarget$1[key$1];
|
|
|
3107
3085
|
|
|
3108
3086
|
var api = API$3;
|
|
3109
3087
|
|
|
3110
|
-
var util$3 = require$$
|
|
3111
|
-
net = require$$
|
|
3112
|
-
tls = require$$
|
|
3113
|
-
url = require$$
|
|
3088
|
+
var util$3 = require$$2,
|
|
3089
|
+
net = require$$1$2,
|
|
3090
|
+
tls = require$$2$2,
|
|
3091
|
+
url = require$$2$1,
|
|
3114
3092
|
driver$2 = driver$4,
|
|
3115
3093
|
API$2 = api;
|
|
3116
3094
|
|
|
@@ -3195,8 +3173,8 @@ Client.prototype._configureProxy = function(proxy, originTLS) {
|
|
|
3195
3173
|
|
|
3196
3174
|
var client = Client;
|
|
3197
3175
|
|
|
3198
|
-
var Stream = require$$
|
|
3199
|
-
util$2 = require$$
|
|
3176
|
+
var Stream = require$$0$1.Stream,
|
|
3177
|
+
util$2 = require$$2,
|
|
3200
3178
|
driver$1 = driver$4,
|
|
3201
3179
|
Headers = headers,
|
|
3202
3180
|
API$1 = api,
|
|
@@ -3260,1678 +3238,120 @@ var instance = {
|
|
|
3260
3238
|
DEFAULT_PING: 10,
|
|
3261
3239
|
DEFAULT_RETRY: 5,
|
|
3262
3240
|
|
|
3263
|
-
_write: function(chunk) {
|
|
3264
|
-
if (!this.writable) return false;
|
|
3265
|
-
try {
|
|
3266
|
-
return this._stream.write(chunk, 'utf8');
|
|
3267
|
-
} catch (e) {
|
|
3268
|
-
return false;
|
|
3269
|
-
}
|
|
3270
|
-
},
|
|
3271
|
-
|
|
3272
|
-
_open: function() {
|
|
3273
|
-
if (this.readyState !== API$1.CONNECTING) return;
|
|
3274
|
-
|
|
3275
|
-
this.readyState = API$1.OPEN;
|
|
3276
|
-
|
|
3277
|
-
var event = new Event('open');
|
|
3278
|
-
event.initEvent('open', false, false);
|
|
3279
|
-
this.dispatchEvent(event);
|
|
3280
|
-
},
|
|
3281
|
-
|
|
3282
|
-
write: function(message) {
|
|
3283
|
-
return this.send(message);
|
|
3284
|
-
},
|
|
3285
|
-
|
|
3286
|
-
end: function(message) {
|
|
3287
|
-
if (message !== undefined) this.write(message);
|
|
3288
|
-
this.close();
|
|
3289
|
-
},
|
|
3290
|
-
|
|
3291
|
-
send: function(message, options) {
|
|
3292
|
-
if (this.readyState > API$1.OPEN) return false;
|
|
3293
|
-
|
|
3294
|
-
message = String(message).replace(/(\r\n|\r|\n)/g, '$1data: ');
|
|
3295
|
-
options = options || {};
|
|
3296
|
-
|
|
3297
|
-
var frame = '';
|
|
3298
|
-
if (options.event) frame += 'event: ' + options.event + '\r\n';
|
|
3299
|
-
if (options.id) frame += 'id: ' + options.id + '\r\n';
|
|
3300
|
-
frame += 'data: ' + message + '\r\n\r\n';
|
|
3301
|
-
|
|
3302
|
-
return this._write(frame);
|
|
3303
|
-
},
|
|
3304
|
-
|
|
3305
|
-
ping: function() {
|
|
3306
|
-
return this._write(':\r\n\r\n');
|
|
3307
|
-
},
|
|
3308
|
-
|
|
3309
|
-
close: function() {
|
|
3310
|
-
if (this.readyState > API$1.OPEN) return false;
|
|
3311
|
-
|
|
3312
|
-
this.readyState = API$1.CLOSED;
|
|
3313
|
-
this.writable = false;
|
|
3314
|
-
if (this._pingTimer) clearInterval(this._pingTimer);
|
|
3315
|
-
if (this._stream) this._stream.end();
|
|
3316
|
-
|
|
3317
|
-
var event = new Event('close');
|
|
3318
|
-
event.initEvent('close', false, false);
|
|
3319
|
-
this.dispatchEvent(event);
|
|
3320
|
-
|
|
3321
|
-
return true;
|
|
3322
|
-
}
|
|
3323
|
-
};
|
|
3324
|
-
|
|
3325
|
-
for (var method in instance) EventSource.prototype[method] = instance[method];
|
|
3326
|
-
for (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];
|
|
3327
|
-
|
|
3328
|
-
var eventsource = EventSource;
|
|
3329
|
-
|
|
3330
|
-
var util$1 = require$$2__default["default"],
|
|
3331
|
-
driver = driver$4,
|
|
3332
|
-
API = api;
|
|
3333
|
-
|
|
3334
|
-
var WebSocket$1 = function(request, socket, body, protocols, options) {
|
|
3335
|
-
options = options || {};
|
|
3336
|
-
|
|
3337
|
-
this._stream = socket;
|
|
3338
|
-
this._driver = driver.http(request, { maxLength: options.maxLength, protocols: protocols });
|
|
3339
|
-
|
|
3340
|
-
var self = this;
|
|
3341
|
-
if (!this._stream || !this._stream.writable) return;
|
|
3342
|
-
if (!this._stream.readable) return this._stream.end();
|
|
3343
|
-
|
|
3344
|
-
var catchup = function() { self._stream.removeListener('data', catchup); };
|
|
3345
|
-
this._stream.on('data', catchup);
|
|
3346
|
-
|
|
3347
|
-
API.call(this, options);
|
|
3348
|
-
|
|
3349
|
-
process.nextTick(function() {
|
|
3350
|
-
self._driver.start();
|
|
3351
|
-
self._driver.io.write(body);
|
|
3352
|
-
});
|
|
3353
|
-
};
|
|
3354
|
-
util$1.inherits(WebSocket$1, API);
|
|
3355
|
-
|
|
3356
|
-
WebSocket$1.isWebSocket = function(request) {
|
|
3357
|
-
return driver.isWebSocket(request);
|
|
3358
|
-
};
|
|
3359
|
-
|
|
3360
|
-
WebSocket$1.validateOptions = function(options, validKeys) {
|
|
3361
|
-
driver.validateOptions(options, validKeys);
|
|
3362
|
-
};
|
|
3363
|
-
|
|
3364
|
-
WebSocket$1.WebSocket = WebSocket$1;
|
|
3365
|
-
WebSocket$1.Client = client;
|
|
3366
|
-
WebSocket$1.EventSource = eventsource;
|
|
3367
|
-
|
|
3368
|
-
var websocket = WebSocket$1;
|
|
3369
|
-
|
|
3370
|
-
var index_cjs = {};
|
|
3371
|
-
|
|
3372
|
-
const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
|
|
3373
|
-
|
|
3374
|
-
let idbProxyableTypes;
|
|
3375
|
-
let cursorAdvanceMethods;
|
|
3376
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3377
|
-
function getIdbProxyableTypes() {
|
|
3378
|
-
return (idbProxyableTypes ||
|
|
3379
|
-
(idbProxyableTypes = [
|
|
3380
|
-
IDBDatabase,
|
|
3381
|
-
IDBObjectStore,
|
|
3382
|
-
IDBIndex,
|
|
3383
|
-
IDBCursor,
|
|
3384
|
-
IDBTransaction,
|
|
3385
|
-
]));
|
|
3386
|
-
}
|
|
3387
|
-
// This is a function to prevent it throwing up in node environments.
|
|
3388
|
-
function getCursorAdvanceMethods() {
|
|
3389
|
-
return (cursorAdvanceMethods ||
|
|
3390
|
-
(cursorAdvanceMethods = [
|
|
3391
|
-
IDBCursor.prototype.advance,
|
|
3392
|
-
IDBCursor.prototype.continue,
|
|
3393
|
-
IDBCursor.prototype.continuePrimaryKey,
|
|
3394
|
-
]));
|
|
3395
|
-
}
|
|
3396
|
-
const cursorRequestMap = new WeakMap();
|
|
3397
|
-
const transactionDoneMap = new WeakMap();
|
|
3398
|
-
const transactionStoreNamesMap = new WeakMap();
|
|
3399
|
-
const transformCache = new WeakMap();
|
|
3400
|
-
const reverseTransformCache = new WeakMap();
|
|
3401
|
-
function promisifyRequest(request) {
|
|
3402
|
-
const promise = new Promise((resolve, reject) => {
|
|
3403
|
-
const unlisten = () => {
|
|
3404
|
-
request.removeEventListener('success', success);
|
|
3405
|
-
request.removeEventListener('error', error);
|
|
3406
|
-
};
|
|
3407
|
-
const success = () => {
|
|
3408
|
-
resolve(wrap(request.result));
|
|
3409
|
-
unlisten();
|
|
3410
|
-
};
|
|
3411
|
-
const error = () => {
|
|
3412
|
-
reject(request.error);
|
|
3413
|
-
unlisten();
|
|
3414
|
-
};
|
|
3415
|
-
request.addEventListener('success', success);
|
|
3416
|
-
request.addEventListener('error', error);
|
|
3417
|
-
});
|
|
3418
|
-
promise
|
|
3419
|
-
.then((value) => {
|
|
3420
|
-
// Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
|
|
3421
|
-
// (see wrapFunction).
|
|
3422
|
-
if (value instanceof IDBCursor) {
|
|
3423
|
-
cursorRequestMap.set(value, request);
|
|
3424
|
-
}
|
|
3425
|
-
// Catching to avoid "Uncaught Promise exceptions"
|
|
3426
|
-
})
|
|
3427
|
-
.catch(() => { });
|
|
3428
|
-
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
|
3429
|
-
// is because we create many promises from a single IDBRequest.
|
|
3430
|
-
reverseTransformCache.set(promise, request);
|
|
3431
|
-
return promise;
|
|
3432
|
-
}
|
|
3433
|
-
function cacheDonePromiseForTransaction(tx) {
|
|
3434
|
-
// Early bail if we've already created a done promise for this transaction.
|
|
3435
|
-
if (transactionDoneMap.has(tx))
|
|
3436
|
-
return;
|
|
3437
|
-
const done = new Promise((resolve, reject) => {
|
|
3438
|
-
const unlisten = () => {
|
|
3439
|
-
tx.removeEventListener('complete', complete);
|
|
3440
|
-
tx.removeEventListener('error', error);
|
|
3441
|
-
tx.removeEventListener('abort', error);
|
|
3442
|
-
};
|
|
3443
|
-
const complete = () => {
|
|
3444
|
-
resolve();
|
|
3445
|
-
unlisten();
|
|
3446
|
-
};
|
|
3447
|
-
const error = () => {
|
|
3448
|
-
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
3449
|
-
unlisten();
|
|
3450
|
-
};
|
|
3451
|
-
tx.addEventListener('complete', complete);
|
|
3452
|
-
tx.addEventListener('error', error);
|
|
3453
|
-
tx.addEventListener('abort', error);
|
|
3454
|
-
});
|
|
3455
|
-
// Cache it for later retrieval.
|
|
3456
|
-
transactionDoneMap.set(tx, done);
|
|
3457
|
-
}
|
|
3458
|
-
let idbProxyTraps = {
|
|
3459
|
-
get(target, prop, receiver) {
|
|
3460
|
-
if (target instanceof IDBTransaction) {
|
|
3461
|
-
// Special handling for transaction.done.
|
|
3462
|
-
if (prop === 'done')
|
|
3463
|
-
return transactionDoneMap.get(target);
|
|
3464
|
-
// Polyfill for objectStoreNames because of Edge.
|
|
3465
|
-
if (prop === 'objectStoreNames') {
|
|
3466
|
-
return target.objectStoreNames || transactionStoreNamesMap.get(target);
|
|
3467
|
-
}
|
|
3468
|
-
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
3469
|
-
if (prop === 'store') {
|
|
3470
|
-
return receiver.objectStoreNames[1]
|
|
3471
|
-
? undefined
|
|
3472
|
-
: receiver.objectStore(receiver.objectStoreNames[0]);
|
|
3473
|
-
}
|
|
3474
|
-
}
|
|
3475
|
-
// Else transform whatever we get back.
|
|
3476
|
-
return wrap(target[prop]);
|
|
3477
|
-
},
|
|
3478
|
-
set(target, prop, value) {
|
|
3479
|
-
target[prop] = value;
|
|
3480
|
-
return true;
|
|
3481
|
-
},
|
|
3482
|
-
has(target, prop) {
|
|
3483
|
-
if (target instanceof IDBTransaction &&
|
|
3484
|
-
(prop === 'done' || prop === 'store')) {
|
|
3485
|
-
return true;
|
|
3486
|
-
}
|
|
3487
|
-
return prop in target;
|
|
3488
|
-
},
|
|
3489
|
-
};
|
|
3490
|
-
function replaceTraps(callback) {
|
|
3491
|
-
idbProxyTraps = callback(idbProxyTraps);
|
|
3492
|
-
}
|
|
3493
|
-
function wrapFunction(func) {
|
|
3494
|
-
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
3495
|
-
// only create one new func per func.
|
|
3496
|
-
// Edge doesn't support objectStoreNames (booo), so we polyfill it here.
|
|
3497
|
-
if (func === IDBDatabase.prototype.transaction &&
|
|
3498
|
-
!('objectStoreNames' in IDBTransaction.prototype)) {
|
|
3499
|
-
return function (storeNames, ...args) {
|
|
3500
|
-
const tx = func.call(unwrap(this), storeNames, ...args);
|
|
3501
|
-
transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
|
|
3502
|
-
return wrap(tx);
|
|
3503
|
-
};
|
|
3504
|
-
}
|
|
3505
|
-
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
3506
|
-
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
3507
|
-
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
3508
|
-
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
3509
|
-
// undefined if the end of the cursor has been reached.
|
|
3510
|
-
if (getCursorAdvanceMethods().includes(func)) {
|
|
3511
|
-
return function (...args) {
|
|
3512
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3513
|
-
// the original object.
|
|
3514
|
-
func.apply(unwrap(this), args);
|
|
3515
|
-
return wrap(cursorRequestMap.get(this));
|
|
3516
|
-
};
|
|
3517
|
-
}
|
|
3518
|
-
return function (...args) {
|
|
3519
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3520
|
-
// the original object.
|
|
3521
|
-
return wrap(func.apply(unwrap(this), args));
|
|
3522
|
-
};
|
|
3523
|
-
}
|
|
3524
|
-
function transformCachableValue(value) {
|
|
3525
|
-
if (typeof value === 'function')
|
|
3526
|
-
return wrapFunction(value);
|
|
3527
|
-
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
3528
|
-
// which is later returned for transaction.done (see idbObjectHandler).
|
|
3529
|
-
if (value instanceof IDBTransaction)
|
|
3530
|
-
cacheDonePromiseForTransaction(value);
|
|
3531
|
-
if (instanceOfAny(value, getIdbProxyableTypes()))
|
|
3532
|
-
return new Proxy(value, idbProxyTraps);
|
|
3533
|
-
// Return the same value back if we're not going to transform it.
|
|
3534
|
-
return value;
|
|
3535
|
-
}
|
|
3536
|
-
function wrap(value) {
|
|
3537
|
-
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
3538
|
-
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
3539
|
-
if (value instanceof IDBRequest)
|
|
3540
|
-
return promisifyRequest(value);
|
|
3541
|
-
// If we've already transformed this value before, reuse the transformed value.
|
|
3542
|
-
// This is faster, but it also provides object equality.
|
|
3543
|
-
if (transformCache.has(value))
|
|
3544
|
-
return transformCache.get(value);
|
|
3545
|
-
const newValue = transformCachableValue(value);
|
|
3546
|
-
// Not all types are transformed.
|
|
3547
|
-
// These may be primitive types, so they can't be WeakMap keys.
|
|
3548
|
-
if (newValue !== value) {
|
|
3549
|
-
transformCache.set(value, newValue);
|
|
3550
|
-
reverseTransformCache.set(newValue, value);
|
|
3551
|
-
}
|
|
3552
|
-
return newValue;
|
|
3553
|
-
}
|
|
3554
|
-
const unwrap = (value) => reverseTransformCache.get(value);
|
|
3555
|
-
|
|
3556
|
-
/**
|
|
3557
|
-
* Open a database.
|
|
3558
|
-
*
|
|
3559
|
-
* @param name Name of the database.
|
|
3560
|
-
* @param version Schema version.
|
|
3561
|
-
* @param callbacks Additional callbacks.
|
|
3562
|
-
*/
|
|
3563
|
-
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
|
|
3564
|
-
const request = indexedDB.open(name, version);
|
|
3565
|
-
const openPromise = wrap(request);
|
|
3566
|
-
if (upgrade) {
|
|
3567
|
-
request.addEventListener('upgradeneeded', (event) => {
|
|
3568
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
3569
|
-
});
|
|
3570
|
-
}
|
|
3571
|
-
if (blocked) {
|
|
3572
|
-
request.addEventListener('blocked', (event) => blocked(
|
|
3573
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3574
|
-
event.oldVersion, event.newVersion, event));
|
|
3575
|
-
}
|
|
3576
|
-
openPromise
|
|
3577
|
-
.then((db) => {
|
|
3578
|
-
if (terminated)
|
|
3579
|
-
db.addEventListener('close', () => terminated());
|
|
3580
|
-
if (blocking) {
|
|
3581
|
-
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
|
|
3582
|
-
}
|
|
3583
|
-
})
|
|
3584
|
-
.catch(() => { });
|
|
3585
|
-
return openPromise;
|
|
3586
|
-
}
|
|
3587
|
-
/**
|
|
3588
|
-
* Delete a database.
|
|
3589
|
-
*
|
|
3590
|
-
* @param name Name of the database.
|
|
3591
|
-
*/
|
|
3592
|
-
function deleteDB(name, { blocked } = {}) {
|
|
3593
|
-
const request = indexedDB.deleteDatabase(name);
|
|
3594
|
-
if (blocked) {
|
|
3595
|
-
request.addEventListener('blocked', (event) => blocked(
|
|
3596
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3597
|
-
event.oldVersion, event));
|
|
3598
|
-
}
|
|
3599
|
-
return wrap(request).then(() => undefined);
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
3603
|
-
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
3604
|
-
const cachedMethods = new Map();
|
|
3605
|
-
function getMethod(target, prop) {
|
|
3606
|
-
if (!(target instanceof IDBDatabase &&
|
|
3607
|
-
!(prop in target) &&
|
|
3608
|
-
typeof prop === 'string')) {
|
|
3609
|
-
return;
|
|
3610
|
-
}
|
|
3611
|
-
if (cachedMethods.get(prop))
|
|
3612
|
-
return cachedMethods.get(prop);
|
|
3613
|
-
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
3614
|
-
const useIndex = prop !== targetFuncName;
|
|
3615
|
-
const isWrite = writeMethods.includes(targetFuncName);
|
|
3616
|
-
if (
|
|
3617
|
-
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
3618
|
-
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
|
|
3619
|
-
!(isWrite || readMethods.includes(targetFuncName))) {
|
|
3620
|
-
return;
|
|
3621
|
-
}
|
|
3622
|
-
const method = async function (storeName, ...args) {
|
|
3623
|
-
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
3624
|
-
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
3625
|
-
let target = tx.store;
|
|
3626
|
-
if (useIndex)
|
|
3627
|
-
target = target.index(args.shift());
|
|
3628
|
-
// Must reject if op rejects.
|
|
3629
|
-
// If it's a write operation, must reject if tx.done rejects.
|
|
3630
|
-
// Must reject with op rejection first.
|
|
3631
|
-
// Must resolve with op value.
|
|
3632
|
-
// Must handle both promises (no unhandled rejections)
|
|
3633
|
-
return (await Promise.all([
|
|
3634
|
-
target[targetFuncName](...args),
|
|
3635
|
-
isWrite && tx.done,
|
|
3636
|
-
]))[0];
|
|
3637
|
-
};
|
|
3638
|
-
cachedMethods.set(prop, method);
|
|
3639
|
-
return method;
|
|
3640
|
-
}
|
|
3641
|
-
replaceTraps((oldTraps) => ({
|
|
3642
|
-
...oldTraps,
|
|
3643
|
-
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
3644
|
-
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
|
|
3645
|
-
}));
|
|
3646
|
-
|
|
3647
|
-
var build = /*#__PURE__*/Object.freeze({
|
|
3648
|
-
__proto__: null,
|
|
3649
|
-
deleteDB: deleteDB,
|
|
3650
|
-
openDB: openDB,
|
|
3651
|
-
unwrap: unwrap,
|
|
3652
|
-
wrap: wrap
|
|
3653
|
-
});
|
|
3654
|
-
|
|
3655
|
-
var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
|
|
3656
|
-
|
|
3657
|
-
(function (exports) {
|
|
3658
|
-
|
|
3659
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3660
|
-
|
|
3661
|
-
var component = require$$0__default$2["default"];
|
|
3662
|
-
var logger$1 = require$$1__default$3["default"];
|
|
3663
|
-
var util = require$$2__default$3["default"];
|
|
3664
|
-
var idb = require$$3;
|
|
3665
|
-
|
|
3666
|
-
/**
|
|
3667
|
-
* @license
|
|
3668
|
-
* Copyright 2019 Google LLC
|
|
3669
|
-
*
|
|
3670
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3671
|
-
* you may not use this file except in compliance with the License.
|
|
3672
|
-
* You may obtain a copy of the License at
|
|
3673
|
-
*
|
|
3674
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3675
|
-
*
|
|
3676
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3677
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3678
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3679
|
-
* See the License for the specific language governing permissions and
|
|
3680
|
-
* limitations under the License.
|
|
3681
|
-
*/
|
|
3682
|
-
class PlatformLoggerServiceImpl {
|
|
3683
|
-
constructor(container) {
|
|
3684
|
-
this.container = container;
|
|
3685
|
-
}
|
|
3686
|
-
// In initial implementation, this will be called by installations on
|
|
3687
|
-
// auth token refresh, and installations will send this string.
|
|
3688
|
-
getPlatformInfoString() {
|
|
3689
|
-
const providers = this.container.getProviders();
|
|
3690
|
-
// Loop through providers and get library/version pairs from any that are
|
|
3691
|
-
// version components.
|
|
3692
|
-
return providers
|
|
3693
|
-
.map(provider => {
|
|
3694
|
-
if (isVersionServiceProvider(provider)) {
|
|
3695
|
-
const service = provider.getImmediate();
|
|
3696
|
-
return `${service.library}/${service.version}`;
|
|
3697
|
-
}
|
|
3698
|
-
else {
|
|
3699
|
-
return null;
|
|
3700
|
-
}
|
|
3701
|
-
})
|
|
3702
|
-
.filter(logString => logString)
|
|
3703
|
-
.join(' ');
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
|
-
/**
|
|
3707
|
-
*
|
|
3708
|
-
* @param provider check if this provider provides a VersionService
|
|
3709
|
-
*
|
|
3710
|
-
* NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
|
|
3711
|
-
* provides VersionService. The provider is not necessarily a 'app-version'
|
|
3712
|
-
* provider.
|
|
3713
|
-
*/
|
|
3714
|
-
function isVersionServiceProvider(provider) {
|
|
3715
|
-
const component = provider.getComponent();
|
|
3716
|
-
return component?.type === "VERSION" /* ComponentType.VERSION */;
|
|
3717
|
-
}
|
|
3718
|
-
|
|
3719
|
-
const name$q = "@firebase/app";
|
|
3720
|
-
const version$1 = "0.14.12";
|
|
3721
|
-
|
|
3722
|
-
/**
|
|
3723
|
-
* @license
|
|
3724
|
-
* Copyright 2019 Google LLC
|
|
3725
|
-
*
|
|
3726
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3727
|
-
* you may not use this file except in compliance with the License.
|
|
3728
|
-
* You may obtain a copy of the License at
|
|
3729
|
-
*
|
|
3730
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3731
|
-
*
|
|
3732
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3733
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3734
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3735
|
-
* See the License for the specific language governing permissions and
|
|
3736
|
-
* limitations under the License.
|
|
3737
|
-
*/
|
|
3738
|
-
const logger = new logger$1.Logger('@firebase/app');
|
|
3739
|
-
|
|
3740
|
-
const name$p = "@firebase/app-compat";
|
|
3741
|
-
|
|
3742
|
-
const name$o = "@firebase/analytics-compat";
|
|
3743
|
-
|
|
3744
|
-
const name$n = "@firebase/analytics";
|
|
3745
|
-
|
|
3746
|
-
const name$m = "@firebase/app-check-compat";
|
|
3747
|
-
|
|
3748
|
-
const name$l = "@firebase/app-check";
|
|
3749
|
-
|
|
3750
|
-
const name$k = "@firebase/auth";
|
|
3751
|
-
|
|
3752
|
-
const name$j = "@firebase/auth-compat";
|
|
3753
|
-
|
|
3754
|
-
const name$i = "@firebase/database";
|
|
3755
|
-
|
|
3756
|
-
const name$h = "@firebase/data-connect";
|
|
3757
|
-
|
|
3758
|
-
const name$g = "@firebase/database-compat";
|
|
3759
|
-
|
|
3760
|
-
const name$f = "@firebase/functions";
|
|
3761
|
-
|
|
3762
|
-
const name$e = "@firebase/functions-compat";
|
|
3763
|
-
|
|
3764
|
-
const name$d = "@firebase/installations";
|
|
3765
|
-
|
|
3766
|
-
const name$c = "@firebase/installations-compat";
|
|
3767
|
-
|
|
3768
|
-
const name$b = "@firebase/messaging";
|
|
3769
|
-
|
|
3770
|
-
const name$a = "@firebase/messaging-compat";
|
|
3771
|
-
|
|
3772
|
-
const name$9 = "@firebase/performance";
|
|
3773
|
-
|
|
3774
|
-
const name$8 = "@firebase/performance-compat";
|
|
3775
|
-
|
|
3776
|
-
const name$7 = "@firebase/remote-config";
|
|
3777
|
-
|
|
3778
|
-
const name$6 = "@firebase/remote-config-compat";
|
|
3779
|
-
|
|
3780
|
-
const name$5 = "@firebase/storage";
|
|
3781
|
-
|
|
3782
|
-
const name$4 = "@firebase/storage-compat";
|
|
3783
|
-
|
|
3784
|
-
const name$3 = "@firebase/firestore";
|
|
3785
|
-
|
|
3786
|
-
const name$2 = "@firebase/ai";
|
|
3787
|
-
|
|
3788
|
-
const name$1 = "@firebase/firestore-compat";
|
|
3789
|
-
|
|
3790
|
-
const name = "firebase";
|
|
3791
|
-
const version = "12.13.0";
|
|
3792
|
-
|
|
3793
|
-
/**
|
|
3794
|
-
* @license
|
|
3795
|
-
* Copyright 2019 Google LLC
|
|
3796
|
-
*
|
|
3797
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3798
|
-
* you may not use this file except in compliance with the License.
|
|
3799
|
-
* You may obtain a copy of the License at
|
|
3800
|
-
*
|
|
3801
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3802
|
-
*
|
|
3803
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3804
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3805
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3806
|
-
* See the License for the specific language governing permissions and
|
|
3807
|
-
* limitations under the License.
|
|
3808
|
-
*/
|
|
3809
|
-
/**
|
|
3810
|
-
* The default app name
|
|
3811
|
-
*
|
|
3812
|
-
* @internal
|
|
3813
|
-
*/
|
|
3814
|
-
const DEFAULT_ENTRY_NAME = '[DEFAULT]';
|
|
3815
|
-
const PLATFORM_LOG_STRING = {
|
|
3816
|
-
[name$q]: 'fire-core',
|
|
3817
|
-
[name$p]: 'fire-core-compat',
|
|
3818
|
-
[name$n]: 'fire-analytics',
|
|
3819
|
-
[name$o]: 'fire-analytics-compat',
|
|
3820
|
-
[name$l]: 'fire-app-check',
|
|
3821
|
-
[name$m]: 'fire-app-check-compat',
|
|
3822
|
-
[name$k]: 'fire-auth',
|
|
3823
|
-
[name$j]: 'fire-auth-compat',
|
|
3824
|
-
[name$i]: 'fire-rtdb',
|
|
3825
|
-
[name$h]: 'fire-data-connect',
|
|
3826
|
-
[name$g]: 'fire-rtdb-compat',
|
|
3827
|
-
[name$f]: 'fire-fn',
|
|
3828
|
-
[name$e]: 'fire-fn-compat',
|
|
3829
|
-
[name$d]: 'fire-iid',
|
|
3830
|
-
[name$c]: 'fire-iid-compat',
|
|
3831
|
-
[name$b]: 'fire-fcm',
|
|
3832
|
-
[name$a]: 'fire-fcm-compat',
|
|
3833
|
-
[name$9]: 'fire-perf',
|
|
3834
|
-
[name$8]: 'fire-perf-compat',
|
|
3835
|
-
[name$7]: 'fire-rc',
|
|
3836
|
-
[name$6]: 'fire-rc-compat',
|
|
3837
|
-
[name$5]: 'fire-gcs',
|
|
3838
|
-
[name$4]: 'fire-gcs-compat',
|
|
3839
|
-
[name$3]: 'fire-fst',
|
|
3840
|
-
[name$1]: 'fire-fst-compat',
|
|
3841
|
-
[name$2]: 'fire-vertex',
|
|
3842
|
-
'fire-js': 'fire-js', // Platform identifier for JS SDK.
|
|
3843
|
-
[name]: 'fire-js-all'
|
|
3844
|
-
};
|
|
3845
|
-
|
|
3846
|
-
/**
|
|
3847
|
-
* @license
|
|
3848
|
-
* Copyright 2019 Google LLC
|
|
3849
|
-
*
|
|
3850
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3851
|
-
* you may not use this file except in compliance with the License.
|
|
3852
|
-
* You may obtain a copy of the License at
|
|
3853
|
-
*
|
|
3854
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3855
|
-
*
|
|
3856
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3857
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3858
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3859
|
-
* See the License for the specific language governing permissions and
|
|
3860
|
-
* limitations under the License.
|
|
3861
|
-
*/
|
|
3862
|
-
/**
|
|
3863
|
-
* @internal
|
|
3864
|
-
*/
|
|
3865
|
-
const _apps = new Map();
|
|
3866
|
-
/**
|
|
3867
|
-
* @internal
|
|
3868
|
-
*/
|
|
3869
|
-
const _serverApps = new Map();
|
|
3870
|
-
/**
|
|
3871
|
-
* Registered components.
|
|
3872
|
-
*
|
|
3873
|
-
* @internal
|
|
3874
|
-
*/
|
|
3875
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3876
|
-
const _components = new Map();
|
|
3877
|
-
/**
|
|
3878
|
-
* @param component - the component being added to this app's container
|
|
3879
|
-
*
|
|
3880
|
-
* @internal
|
|
3881
|
-
*/
|
|
3882
|
-
function _addComponent(app, component) {
|
|
3883
|
-
try {
|
|
3884
|
-
app.container.addComponent(component);
|
|
3885
|
-
}
|
|
3886
|
-
catch (e) {
|
|
3887
|
-
logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
|
|
3888
|
-
}
|
|
3889
|
-
}
|
|
3890
|
-
/**
|
|
3891
|
-
*
|
|
3892
|
-
* @internal
|
|
3893
|
-
*/
|
|
3894
|
-
function _addOrOverwriteComponent(app, component) {
|
|
3895
|
-
app.container.addOrOverwriteComponent(component);
|
|
3896
|
-
}
|
|
3897
|
-
/**
|
|
3898
|
-
*
|
|
3899
|
-
* @param component - the component to register
|
|
3900
|
-
* @returns whether or not the component is registered successfully
|
|
3901
|
-
*
|
|
3902
|
-
* @internal
|
|
3903
|
-
*/
|
|
3904
|
-
function _registerComponent(component) {
|
|
3905
|
-
const componentName = component.name;
|
|
3906
|
-
if (_components.has(componentName)) {
|
|
3907
|
-
logger.debug(`There were multiple attempts to register component ${componentName}.`);
|
|
3908
|
-
return false;
|
|
3909
|
-
}
|
|
3910
|
-
_components.set(componentName, component);
|
|
3911
|
-
// add the component to existing app instances
|
|
3912
|
-
for (const app of _apps.values()) {
|
|
3913
|
-
_addComponent(app, component);
|
|
3914
|
-
}
|
|
3915
|
-
for (const serverApp of _serverApps.values()) {
|
|
3916
|
-
_addComponent(serverApp, component);
|
|
3917
|
-
}
|
|
3918
|
-
return true;
|
|
3919
|
-
}
|
|
3920
|
-
/**
|
|
3921
|
-
*
|
|
3922
|
-
* @param app - FirebaseApp instance
|
|
3923
|
-
* @param name - service name
|
|
3924
|
-
*
|
|
3925
|
-
* @returns the provider for the service with the matching name
|
|
3926
|
-
*
|
|
3927
|
-
* @internal
|
|
3928
|
-
*/
|
|
3929
|
-
function _getProvider(app, name) {
|
|
3930
|
-
const heartbeatController = app.container
|
|
3931
|
-
.getProvider('heartbeat')
|
|
3932
|
-
.getImmediate({ optional: true });
|
|
3933
|
-
if (heartbeatController) {
|
|
3934
|
-
void heartbeatController.triggerHeartbeat();
|
|
3935
|
-
}
|
|
3936
|
-
return app.container.getProvider(name);
|
|
3937
|
-
}
|
|
3938
|
-
/**
|
|
3939
|
-
*
|
|
3940
|
-
* @param app - FirebaseApp instance
|
|
3941
|
-
* @param name - service name
|
|
3942
|
-
* @param instanceIdentifier - service instance identifier in case the service supports multiple instances
|
|
3943
|
-
*
|
|
3944
|
-
* @internal
|
|
3945
|
-
*/
|
|
3946
|
-
function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
|
|
3947
|
-
_getProvider(app, name).clearInstance(instanceIdentifier);
|
|
3948
|
-
}
|
|
3949
|
-
/**
|
|
3950
|
-
*
|
|
3951
|
-
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3952
|
-
*
|
|
3953
|
-
* @returns true if the provide object is of type FirebaseApp.
|
|
3954
|
-
*
|
|
3955
|
-
* @internal
|
|
3956
|
-
*/
|
|
3957
|
-
function _isFirebaseApp(obj) {
|
|
3958
|
-
return obj.options !== undefined;
|
|
3959
|
-
}
|
|
3960
|
-
/**
|
|
3961
|
-
*
|
|
3962
|
-
* @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
|
|
3963
|
-
*
|
|
3964
|
-
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3965
|
-
*
|
|
3966
|
-
* @internal
|
|
3967
|
-
*/
|
|
3968
|
-
function _isFirebaseServerAppSettings(obj) {
|
|
3969
|
-
if (_isFirebaseApp(obj)) {
|
|
3970
|
-
return false;
|
|
3971
|
-
}
|
|
3972
|
-
return ('authIdToken' in obj ||
|
|
3973
|
-
'appCheckToken' in obj ||
|
|
3974
|
-
'releaseOnDeref' in obj ||
|
|
3975
|
-
'automaticDataCollectionEnabled' in obj);
|
|
3976
|
-
}
|
|
3977
|
-
/**
|
|
3978
|
-
*
|
|
3979
|
-
* @param obj - an object of type FirebaseApp.
|
|
3980
|
-
*
|
|
3981
|
-
* @returns true if the provided object is of type FirebaseServerAppImpl.
|
|
3982
|
-
*
|
|
3983
|
-
* @internal
|
|
3984
|
-
*/
|
|
3985
|
-
function _isFirebaseServerApp(obj) {
|
|
3986
|
-
if (obj === null || obj === undefined) {
|
|
3987
|
-
return false;
|
|
3988
|
-
}
|
|
3989
|
-
return obj.settings !== undefined;
|
|
3990
|
-
}
|
|
3991
|
-
/**
|
|
3992
|
-
* Test only
|
|
3993
|
-
*
|
|
3994
|
-
* @internal
|
|
3995
|
-
*/
|
|
3996
|
-
function _clearComponents() {
|
|
3997
|
-
_components.clear();
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
/**
|
|
4001
|
-
* @license
|
|
4002
|
-
* Copyright 2019 Google LLC
|
|
4003
|
-
*
|
|
4004
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4005
|
-
* you may not use this file except in compliance with the License.
|
|
4006
|
-
* You may obtain a copy of the License at
|
|
4007
|
-
*
|
|
4008
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4009
|
-
*
|
|
4010
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4011
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4012
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4013
|
-
* See the License for the specific language governing permissions and
|
|
4014
|
-
* limitations under the License.
|
|
4015
|
-
*/
|
|
4016
|
-
const ERRORS = {
|
|
4017
|
-
["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
|
|
4018
|
-
'call initializeApp() first',
|
|
4019
|
-
["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
|
|
4020
|
-
["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different options or config",
|
|
4021
|
-
["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
|
|
4022
|
-
["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
|
|
4023
|
-
["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
|
|
4024
|
-
["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
|
|
4025
|
-
'Firebase App instance.',
|
|
4026
|
-
["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
|
|
4027
|
-
["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4028
|
-
["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4029
|
-
["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4030
|
-
["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
|
|
4031
|
-
["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
|
|
4032
|
-
["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
|
|
4033
|
-
};
|
|
4034
|
-
const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
|
|
4035
|
-
|
|
4036
|
-
/**
|
|
4037
|
-
* @license
|
|
4038
|
-
* Copyright 2019 Google LLC
|
|
4039
|
-
*
|
|
4040
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4041
|
-
* you may not use this file except in compliance with the License.
|
|
4042
|
-
* You may obtain a copy of the License at
|
|
4043
|
-
*
|
|
4044
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4045
|
-
*
|
|
4046
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4047
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4048
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4049
|
-
* See the License for the specific language governing permissions and
|
|
4050
|
-
* limitations under the License.
|
|
4051
|
-
*/
|
|
4052
|
-
class FirebaseAppImpl {
|
|
4053
|
-
constructor(options, config, container) {
|
|
4054
|
-
this._isDeleted = false;
|
|
4055
|
-
this._options = { ...options };
|
|
4056
|
-
this._config = { ...config };
|
|
4057
|
-
this._name = config.name;
|
|
4058
|
-
this._automaticDataCollectionEnabled =
|
|
4059
|
-
config.automaticDataCollectionEnabled;
|
|
4060
|
-
this._container = container;
|
|
4061
|
-
this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
4062
|
-
}
|
|
4063
|
-
get automaticDataCollectionEnabled() {
|
|
4064
|
-
this.checkDestroyed();
|
|
4065
|
-
return this._automaticDataCollectionEnabled;
|
|
4066
|
-
}
|
|
4067
|
-
set automaticDataCollectionEnabled(val) {
|
|
4068
|
-
this.checkDestroyed();
|
|
4069
|
-
this._automaticDataCollectionEnabled = val;
|
|
4070
|
-
}
|
|
4071
|
-
get name() {
|
|
4072
|
-
this.checkDestroyed();
|
|
4073
|
-
return this._name;
|
|
4074
|
-
}
|
|
4075
|
-
get options() {
|
|
4076
|
-
this.checkDestroyed();
|
|
4077
|
-
return this._options;
|
|
4078
|
-
}
|
|
4079
|
-
get config() {
|
|
4080
|
-
this.checkDestroyed();
|
|
4081
|
-
return this._config;
|
|
4082
|
-
}
|
|
4083
|
-
get container() {
|
|
4084
|
-
return this._container;
|
|
4085
|
-
}
|
|
4086
|
-
get isDeleted() {
|
|
4087
|
-
return this._isDeleted;
|
|
4088
|
-
}
|
|
4089
|
-
set isDeleted(val) {
|
|
4090
|
-
this._isDeleted = val;
|
|
4091
|
-
}
|
|
4092
|
-
/**
|
|
4093
|
-
* This function will throw an Error if the App has already been deleted -
|
|
4094
|
-
* use before performing API actions on the App.
|
|
4095
|
-
*/
|
|
4096
|
-
checkDestroyed() {
|
|
4097
|
-
if (this.isDeleted) {
|
|
4098
|
-
throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
|
|
4099
|
-
}
|
|
4100
|
-
}
|
|
4101
|
-
}
|
|
4102
|
-
|
|
4103
|
-
/**
|
|
4104
|
-
* @license
|
|
4105
|
-
* Copyright 2023 Google LLC
|
|
4106
|
-
*
|
|
4107
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4108
|
-
* you may not use this file except in compliance with the License.
|
|
4109
|
-
* You may obtain a copy of the License at
|
|
4110
|
-
*
|
|
4111
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4112
|
-
*
|
|
4113
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4114
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4115
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4116
|
-
* See the License for the specific language governing permissions and
|
|
4117
|
-
* limitations under the License.
|
|
4118
|
-
*/
|
|
4119
|
-
// Parse the token and check to see if the `exp` claim is in the future.
|
|
4120
|
-
// Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
|
|
4121
|
-
// the past.
|
|
4122
|
-
function validateTokenTTL(base64Token, tokenName) {
|
|
4123
|
-
const secondPart = util.base64Decode(base64Token.split('.')[1]);
|
|
4124
|
-
if (secondPart === null) {
|
|
4125
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
|
|
4126
|
-
return;
|
|
4127
|
-
}
|
|
4128
|
-
const expClaim = JSON.parse(secondPart).exp;
|
|
4129
|
-
if (expClaim === undefined) {
|
|
4130
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
|
|
4131
|
-
return;
|
|
4132
|
-
}
|
|
4133
|
-
const exp = JSON.parse(secondPart).exp * 1000;
|
|
4134
|
-
const now = new Date().getTime();
|
|
4135
|
-
const diff = exp - now;
|
|
4136
|
-
if (diff <= 0) {
|
|
4137
|
-
console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
|
|
4138
|
-
}
|
|
4139
|
-
}
|
|
4140
|
-
class FirebaseServerAppImpl extends FirebaseAppImpl {
|
|
4141
|
-
constructor(options, serverConfig, name, container) {
|
|
4142
|
-
// Build configuration parameters for the FirebaseAppImpl base class.
|
|
4143
|
-
const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
|
|
4144
|
-
? serverConfig.automaticDataCollectionEnabled
|
|
4145
|
-
: true;
|
|
4146
|
-
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
|
|
4147
|
-
const config = {
|
|
4148
|
-
name,
|
|
4149
|
-
automaticDataCollectionEnabled
|
|
4150
|
-
};
|
|
4151
|
-
if (options.apiKey !== undefined) {
|
|
4152
|
-
// Construct the parent FirebaseAppImp object.
|
|
4153
|
-
super(options, config, container);
|
|
4154
|
-
}
|
|
4155
|
-
else {
|
|
4156
|
-
const appImpl = options;
|
|
4157
|
-
super(appImpl.options, config, container);
|
|
4158
|
-
}
|
|
4159
|
-
// Now construct the data for the FirebaseServerAppImpl.
|
|
4160
|
-
this._serverConfig = {
|
|
4161
|
-
automaticDataCollectionEnabled,
|
|
4162
|
-
...serverConfig
|
|
4163
|
-
};
|
|
4164
|
-
// Ensure that the current time is within the `authIdtoken` window of validity.
|
|
4165
|
-
if (this._serverConfig.authIdToken) {
|
|
4166
|
-
validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
|
|
4167
|
-
}
|
|
4168
|
-
// Ensure that the current time is within the `appCheckToken` window of validity.
|
|
4169
|
-
if (this._serverConfig.appCheckToken) {
|
|
4170
|
-
validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
|
|
4171
|
-
}
|
|
4172
|
-
this._finalizationRegistry = null;
|
|
4173
|
-
if (typeof FinalizationRegistry !== 'undefined') {
|
|
4174
|
-
this._finalizationRegistry = new FinalizationRegistry(() => {
|
|
4175
|
-
this.automaticCleanup();
|
|
4176
|
-
});
|
|
4177
|
-
}
|
|
4178
|
-
this._refCount = 0;
|
|
4179
|
-
this.incRefCount(this._serverConfig.releaseOnDeref);
|
|
4180
|
-
// Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
|
|
4181
|
-
// will never trigger.
|
|
4182
|
-
this._serverConfig.releaseOnDeref = undefined;
|
|
4183
|
-
serverConfig.releaseOnDeref = undefined;
|
|
4184
|
-
registerVersion(name$q, version$1, 'serverapp');
|
|
4185
|
-
}
|
|
4186
|
-
toJSON() {
|
|
4187
|
-
return undefined;
|
|
4188
|
-
}
|
|
4189
|
-
get refCount() {
|
|
4190
|
-
return this._refCount;
|
|
4191
|
-
}
|
|
4192
|
-
// Increment the reference count of this server app. If an object is provided, register it
|
|
4193
|
-
// with the finalization registry.
|
|
4194
|
-
incRefCount(obj) {
|
|
4195
|
-
if (this.isDeleted) {
|
|
4196
|
-
return;
|
|
4197
|
-
}
|
|
4198
|
-
this._refCount++;
|
|
4199
|
-
if (obj !== undefined && this._finalizationRegistry !== null) {
|
|
4200
|
-
this._finalizationRegistry.register(obj, this);
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
// Decrement the reference count.
|
|
4204
|
-
decRefCount() {
|
|
4205
|
-
if (this.isDeleted) {
|
|
4206
|
-
return 0;
|
|
4207
|
-
}
|
|
4208
|
-
return --this._refCount;
|
|
4209
|
-
}
|
|
4210
|
-
// Invoked by the FinalizationRegistry callback to note that this app should go through its
|
|
4211
|
-
// reference counts and delete itself if no reference count remain. The coordinating logic that
|
|
4212
|
-
// handles this is in deleteApp(...).
|
|
4213
|
-
automaticCleanup() {
|
|
4214
|
-
void deleteApp(this);
|
|
4215
|
-
}
|
|
4216
|
-
get settings() {
|
|
4217
|
-
this.checkDestroyed();
|
|
4218
|
-
return this._serverConfig;
|
|
4219
|
-
}
|
|
4220
|
-
/**
|
|
4221
|
-
* This function will throw an Error if the App has already been deleted -
|
|
4222
|
-
* use before performing API actions on the App.
|
|
4223
|
-
*/
|
|
4224
|
-
checkDestroyed() {
|
|
4225
|
-
if (this.isDeleted) {
|
|
4226
|
-
throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
}
|
|
4230
|
-
|
|
4231
|
-
/**
|
|
4232
|
-
* @license
|
|
4233
|
-
* Copyright 2019 Google LLC
|
|
4234
|
-
*
|
|
4235
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4236
|
-
* you may not use this file except in compliance with the License.
|
|
4237
|
-
* You may obtain a copy of the License at
|
|
4238
|
-
*
|
|
4239
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4240
|
-
*
|
|
4241
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4242
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4243
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4244
|
-
* See the License for the specific language governing permissions and
|
|
4245
|
-
* limitations under the License.
|
|
4246
|
-
*/
|
|
4247
|
-
/**
|
|
4248
|
-
* The current SDK version.
|
|
4249
|
-
*
|
|
4250
|
-
* @public
|
|
4251
|
-
*/
|
|
4252
|
-
const SDK_VERSION = version;
|
|
4253
|
-
function initializeApp(_options, rawConfig = {}) {
|
|
4254
|
-
let options = _options;
|
|
4255
|
-
if (typeof rawConfig !== 'object') {
|
|
4256
|
-
const name = rawConfig;
|
|
4257
|
-
rawConfig = { name };
|
|
4258
|
-
}
|
|
4259
|
-
const config = {
|
|
4260
|
-
name: DEFAULT_ENTRY_NAME,
|
|
4261
|
-
automaticDataCollectionEnabled: true,
|
|
4262
|
-
...rawConfig
|
|
4263
|
-
};
|
|
4264
|
-
const name = config.name;
|
|
4265
|
-
if (typeof name !== 'string' || !name) {
|
|
4266
|
-
throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
|
|
4267
|
-
appName: String(name)
|
|
4268
|
-
});
|
|
4269
|
-
}
|
|
4270
|
-
options || (options = util.getDefaultAppConfig());
|
|
4271
|
-
if (!options) {
|
|
4272
|
-
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4273
|
-
}
|
|
4274
|
-
const existingApp = _apps.get(name);
|
|
4275
|
-
if (existingApp) {
|
|
4276
|
-
// return the existing app if options and config deep equal the ones in the existing app.
|
|
4277
|
-
if (util.deepEqual(options, existingApp.options) &&
|
|
4278
|
-
util.deepEqual(config, existingApp.config)) {
|
|
4279
|
-
return existingApp;
|
|
4280
|
-
}
|
|
4281
|
-
else {
|
|
4282
|
-
throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, { appName: name });
|
|
4283
|
-
}
|
|
4284
|
-
}
|
|
4285
|
-
const container = new component.ComponentContainer(name);
|
|
4286
|
-
for (const component of _components.values()) {
|
|
4287
|
-
container.addComponent(component);
|
|
4288
|
-
}
|
|
4289
|
-
const newApp = new FirebaseAppImpl(options, config, container);
|
|
4290
|
-
_apps.set(name, newApp);
|
|
4291
|
-
return newApp;
|
|
4292
|
-
}
|
|
4293
|
-
function initializeServerApp(_options, _serverAppConfig = {}) {
|
|
4294
|
-
if (util.isBrowser() && !util.isWebWorker()) {
|
|
4295
|
-
// FirebaseServerApp isn't designed to be run in browsers.
|
|
4296
|
-
throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
|
|
4297
|
-
}
|
|
4298
|
-
let firebaseOptions;
|
|
4299
|
-
let serverAppSettings = _serverAppConfig || {};
|
|
4300
|
-
if (_options) {
|
|
4301
|
-
if (_isFirebaseApp(_options)) {
|
|
4302
|
-
firebaseOptions = _options.options;
|
|
4303
|
-
}
|
|
4304
|
-
else if (_isFirebaseServerAppSettings(_options)) {
|
|
4305
|
-
serverAppSettings = _options;
|
|
4306
|
-
}
|
|
4307
|
-
else {
|
|
4308
|
-
firebaseOptions = _options;
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
|
|
4312
|
-
serverAppSettings.automaticDataCollectionEnabled = true;
|
|
4313
|
-
}
|
|
4314
|
-
firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
|
|
4315
|
-
if (!firebaseOptions) {
|
|
4316
|
-
throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
|
|
4317
|
-
}
|
|
4318
|
-
// Build an app name based on a hash of the configuration options.
|
|
4319
|
-
const nameObj = {
|
|
4320
|
-
...serverAppSettings,
|
|
4321
|
-
...firebaseOptions
|
|
4322
|
-
};
|
|
4323
|
-
// However, Do not mangle the name based on releaseOnDeref, since it will vary between the
|
|
4324
|
-
// construction of FirebaseServerApp instances. For example, if the object is the request headers.
|
|
4325
|
-
if (nameObj.releaseOnDeref !== undefined) {
|
|
4326
|
-
delete nameObj.releaseOnDeref;
|
|
4327
|
-
}
|
|
4328
|
-
const hashCode = (s) => {
|
|
4329
|
-
return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
|
|
4330
|
-
};
|
|
4331
|
-
if (serverAppSettings.releaseOnDeref !== undefined) {
|
|
4332
|
-
if (typeof FinalizationRegistry === 'undefined') {
|
|
4333
|
-
throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
const nameString = '' + hashCode(JSON.stringify(nameObj));
|
|
4337
|
-
const existingApp = _serverApps.get(nameString);
|
|
4338
|
-
if (existingApp) {
|
|
4339
|
-
existingApp.incRefCount(serverAppSettings.releaseOnDeref);
|
|
4340
|
-
return existingApp;
|
|
4341
|
-
}
|
|
4342
|
-
const container = new component.ComponentContainer(nameString);
|
|
4343
|
-
for (const component of _components.values()) {
|
|
4344
|
-
container.addComponent(component);
|
|
4345
|
-
}
|
|
4346
|
-
const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
|
|
4347
|
-
_serverApps.set(nameString, newApp);
|
|
4348
|
-
return newApp;
|
|
4349
|
-
}
|
|
4350
|
-
/**
|
|
4351
|
-
* Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
|
4352
|
-
*
|
|
4353
|
-
* When called with no arguments, the default app is returned. When an app name
|
|
4354
|
-
* is provided, the app corresponding to that name is returned.
|
|
4355
|
-
*
|
|
4356
|
-
* An exception is thrown if the app being retrieved has not yet been
|
|
4357
|
-
* initialized.
|
|
4358
|
-
*
|
|
4359
|
-
* @example
|
|
4360
|
-
* ```javascript
|
|
4361
|
-
* // Return the default app
|
|
4362
|
-
* const app = getApp();
|
|
4363
|
-
* ```
|
|
4364
|
-
*
|
|
4365
|
-
* @example
|
|
4366
|
-
* ```javascript
|
|
4367
|
-
* // Return a named app
|
|
4368
|
-
* const otherApp = getApp("otherApp");
|
|
4369
|
-
* ```
|
|
4370
|
-
*
|
|
4371
|
-
* @param name - Optional name of the app to return. If no name is
|
|
4372
|
-
* provided, the default is `"[DEFAULT]"`.
|
|
4373
|
-
*
|
|
4374
|
-
* @returns The app corresponding to the provided app name.
|
|
4375
|
-
* If no app name is provided, the default app is returned.
|
|
4376
|
-
*
|
|
4377
|
-
* @public
|
|
4378
|
-
*/
|
|
4379
|
-
function getApp(name = DEFAULT_ENTRY_NAME) {
|
|
4380
|
-
const app = _apps.get(name);
|
|
4381
|
-
if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
|
|
4382
|
-
return initializeApp();
|
|
4383
|
-
}
|
|
4384
|
-
if (!app) {
|
|
4385
|
-
throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
|
|
4386
|
-
}
|
|
4387
|
-
return app;
|
|
4388
|
-
}
|
|
4389
|
-
/**
|
|
4390
|
-
* A (read-only) array of all initialized apps.
|
|
4391
|
-
* @public
|
|
4392
|
-
*/
|
|
4393
|
-
function getApps() {
|
|
4394
|
-
return Array.from(_apps.values());
|
|
4395
|
-
}
|
|
4396
|
-
/**
|
|
4397
|
-
* Renders this app unusable and frees the resources of all associated
|
|
4398
|
-
* services.
|
|
4399
|
-
*
|
|
4400
|
-
* @example
|
|
4401
|
-
* ```javascript
|
|
4402
|
-
* deleteApp(app)
|
|
4403
|
-
* .then(function() {
|
|
4404
|
-
* console.log("App deleted successfully");
|
|
4405
|
-
* })
|
|
4406
|
-
* .catch(function(error) {
|
|
4407
|
-
* console.log("Error deleting app:", error);
|
|
4408
|
-
* });
|
|
4409
|
-
* ```
|
|
4410
|
-
*
|
|
4411
|
-
* @public
|
|
4412
|
-
*/
|
|
4413
|
-
async function deleteApp(app) {
|
|
4414
|
-
let cleanupProviders = false;
|
|
4415
|
-
const name = app.name;
|
|
4416
|
-
if (_apps.has(name)) {
|
|
4417
|
-
cleanupProviders = true;
|
|
4418
|
-
_apps.delete(name);
|
|
4419
|
-
}
|
|
4420
|
-
else if (_serverApps.has(name)) {
|
|
4421
|
-
const firebaseServerApp = app;
|
|
4422
|
-
if (firebaseServerApp.decRefCount() <= 0) {
|
|
4423
|
-
_serverApps.delete(name);
|
|
4424
|
-
cleanupProviders = true;
|
|
4425
|
-
}
|
|
4426
|
-
}
|
|
4427
|
-
if (cleanupProviders) {
|
|
4428
|
-
await Promise.all(app.container
|
|
4429
|
-
.getProviders()
|
|
4430
|
-
.map(provider => provider.delete()));
|
|
4431
|
-
app.isDeleted = true;
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
/**
|
|
4435
|
-
* Registers a library's name and version for platform logging purposes.
|
|
4436
|
-
* @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
|
|
4437
|
-
* @param version - Current version of that library.
|
|
4438
|
-
* @param variant - Bundle variant, e.g., node, rn, etc.
|
|
4439
|
-
*
|
|
4440
|
-
* @public
|
|
4441
|
-
*/
|
|
4442
|
-
function registerVersion(libraryKeyOrName, version, variant) {
|
|
4443
|
-
// TODO: We can use this check to whitelist strings when/if we set up
|
|
4444
|
-
// a good whitelist system.
|
|
4445
|
-
let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
|
|
4446
|
-
if (variant) {
|
|
4447
|
-
library += `-${variant}`;
|
|
4448
|
-
}
|
|
4449
|
-
const libraryMismatch = library.match(/\s|\//);
|
|
4450
|
-
const versionMismatch = version.match(/\s|\//);
|
|
4451
|
-
if (libraryMismatch || versionMismatch) {
|
|
4452
|
-
const warning = [
|
|
4453
|
-
`Unable to register library "${library}" with version "${version}":`
|
|
4454
|
-
];
|
|
4455
|
-
if (libraryMismatch) {
|
|
4456
|
-
warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
|
|
4457
|
-
}
|
|
4458
|
-
if (libraryMismatch && versionMismatch) {
|
|
4459
|
-
warning.push('and');
|
|
4460
|
-
}
|
|
4461
|
-
if (versionMismatch) {
|
|
4462
|
-
warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
|
|
4463
|
-
}
|
|
4464
|
-
logger.warn(warning.join(' '));
|
|
4465
|
-
return;
|
|
4466
|
-
}
|
|
4467
|
-
_registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
|
|
4468
|
-
}
|
|
4469
|
-
/**
|
|
4470
|
-
* Sets log handler for all Firebase SDKs.
|
|
4471
|
-
* @param logCallback - An optional custom log handler that executes user code whenever
|
|
4472
|
-
* the Firebase SDK makes a logging call.
|
|
4473
|
-
*
|
|
4474
|
-
* @public
|
|
4475
|
-
*/
|
|
4476
|
-
function onLog(logCallback, options) {
|
|
4477
|
-
if (logCallback !== null && typeof logCallback !== 'function') {
|
|
4478
|
-
throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
|
|
4479
|
-
}
|
|
4480
|
-
logger$1.setUserLogHandler(logCallback, options);
|
|
4481
|
-
}
|
|
4482
|
-
/**
|
|
4483
|
-
* Sets log level for all Firebase SDKs.
|
|
4484
|
-
*
|
|
4485
|
-
* All of the log types above the current log level are captured (i.e. if
|
|
4486
|
-
* you set the log level to `info`, errors are logged, but `debug` and
|
|
4487
|
-
* `verbose` logs are not).
|
|
4488
|
-
*
|
|
4489
|
-
* @public
|
|
4490
|
-
*/
|
|
4491
|
-
function setLogLevel(logLevel) {
|
|
4492
|
-
logger$1.setLogLevel(logLevel);
|
|
4493
|
-
}
|
|
4494
|
-
|
|
4495
|
-
/**
|
|
4496
|
-
* @license
|
|
4497
|
-
* Copyright 2021 Google LLC
|
|
4498
|
-
*
|
|
4499
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4500
|
-
* you may not use this file except in compliance with the License.
|
|
4501
|
-
* You may obtain a copy of the License at
|
|
4502
|
-
*
|
|
4503
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4504
|
-
*
|
|
4505
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4506
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4507
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4508
|
-
* See the License for the specific language governing permissions and
|
|
4509
|
-
* limitations under the License.
|
|
4510
|
-
*/
|
|
4511
|
-
const DB_NAME = 'firebase-heartbeat-database';
|
|
4512
|
-
const DB_VERSION = 1;
|
|
4513
|
-
const STORE_NAME = 'firebase-heartbeat-store';
|
|
4514
|
-
let dbPromise = null;
|
|
4515
|
-
function getDbPromise() {
|
|
4516
|
-
if (!dbPromise) {
|
|
4517
|
-
dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
|
|
4518
|
-
upgrade: (db, oldVersion) => {
|
|
4519
|
-
// We don't use 'break' in this switch statement, the fall-through
|
|
4520
|
-
// behavior is what we want, because if there are multiple versions between
|
|
4521
|
-
// the old version and the current version, we want ALL the migrations
|
|
4522
|
-
// that correspond to those versions to run, not only the last one.
|
|
4523
|
-
// eslint-disable-next-line default-case
|
|
4524
|
-
switch (oldVersion) {
|
|
4525
|
-
case 0:
|
|
4526
|
-
try {
|
|
4527
|
-
db.createObjectStore(STORE_NAME);
|
|
4528
|
-
}
|
|
4529
|
-
catch (e) {
|
|
4530
|
-
// Safari/iOS browsers throw occasional exceptions on
|
|
4531
|
-
// db.createObjectStore() that may be a bug. Avoid blocking
|
|
4532
|
-
// the rest of the app functionality.
|
|
4533
|
-
console.warn(e);
|
|
4534
|
-
}
|
|
4535
|
-
}
|
|
4536
|
-
}
|
|
4537
|
-
}).catch(e => {
|
|
4538
|
-
throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
|
|
4539
|
-
originalErrorMessage: e.message
|
|
4540
|
-
});
|
|
4541
|
-
});
|
|
4542
|
-
}
|
|
4543
|
-
return dbPromise;
|
|
4544
|
-
}
|
|
4545
|
-
async function readHeartbeatsFromIndexedDB(app) {
|
|
4546
|
-
try {
|
|
4547
|
-
const db = await getDbPromise();
|
|
4548
|
-
const tx = db.transaction(STORE_NAME);
|
|
4549
|
-
const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
|
|
4550
|
-
// We already have the value but tx.done can throw,
|
|
4551
|
-
// so we need to await it here to catch errors
|
|
4552
|
-
await tx.done;
|
|
4553
|
-
return result;
|
|
4554
|
-
}
|
|
4555
|
-
catch (e) {
|
|
4556
|
-
if (e instanceof util.FirebaseError) {
|
|
4557
|
-
logger.warn(e.message);
|
|
4558
|
-
}
|
|
4559
|
-
else {
|
|
4560
|
-
const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
|
|
4561
|
-
originalErrorMessage: e?.message
|
|
4562
|
-
});
|
|
4563
|
-
logger.warn(idbGetError.message);
|
|
4564
|
-
}
|
|
4565
|
-
}
|
|
4566
|
-
}
|
|
4567
|
-
async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
|
|
3241
|
+
_write: function(chunk) {
|
|
3242
|
+
if (!this.writable) return false;
|
|
4568
3243
|
try {
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
await objectStore.put(heartbeatObject, computeKey(app));
|
|
4573
|
-
await tx.done;
|
|
4574
|
-
}
|
|
4575
|
-
catch (e) {
|
|
4576
|
-
if (e instanceof util.FirebaseError) {
|
|
4577
|
-
logger.warn(e.message);
|
|
4578
|
-
}
|
|
4579
|
-
else {
|
|
4580
|
-
const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
|
|
4581
|
-
originalErrorMessage: e?.message
|
|
4582
|
-
});
|
|
4583
|
-
logger.warn(idbGetError.message);
|
|
4584
|
-
}
|
|
3244
|
+
return this._stream.write(chunk, 'utf8');
|
|
3245
|
+
} catch (e) {
|
|
3246
|
+
return false;
|
|
4585
3247
|
}
|
|
4586
|
-
}
|
|
4587
|
-
function computeKey(app) {
|
|
4588
|
-
return `${app.name}!${app.options.appId}`;
|
|
4589
|
-
}
|
|
3248
|
+
},
|
|
4590
3249
|
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
* Copyright 2021 Google LLC
|
|
4594
|
-
*
|
|
4595
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4596
|
-
* you may not use this file except in compliance with the License.
|
|
4597
|
-
* You may obtain a copy of the License at
|
|
4598
|
-
*
|
|
4599
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4600
|
-
*
|
|
4601
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4602
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4603
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4604
|
-
* See the License for the specific language governing permissions and
|
|
4605
|
-
* limitations under the License.
|
|
4606
|
-
*/
|
|
4607
|
-
const MAX_HEADER_BYTES = 1024;
|
|
4608
|
-
const MAX_NUM_STORED_HEARTBEATS = 30;
|
|
4609
|
-
class HeartbeatServiceImpl {
|
|
4610
|
-
constructor(container) {
|
|
4611
|
-
this.container = container;
|
|
4612
|
-
/**
|
|
4613
|
-
* In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
|
|
4614
|
-
* the header string.
|
|
4615
|
-
* Stores one record per date. This will be consolidated into the standard
|
|
4616
|
-
* format of one record per user agent string before being sent as a header.
|
|
4617
|
-
* Populated from indexedDB when the controller is instantiated and should
|
|
4618
|
-
* be kept in sync with indexedDB.
|
|
4619
|
-
* Leave public for easier testing.
|
|
4620
|
-
*/
|
|
4621
|
-
this._heartbeatsCache = null;
|
|
4622
|
-
const app = this.container.getProvider('app').getImmediate();
|
|
4623
|
-
this._storage = new HeartbeatStorageImpl(app);
|
|
4624
|
-
this._heartbeatsCachePromise = this._storage.read().then(result => {
|
|
4625
|
-
this._heartbeatsCache = result;
|
|
4626
|
-
return result;
|
|
4627
|
-
});
|
|
4628
|
-
}
|
|
4629
|
-
/**
|
|
4630
|
-
* Called to report a heartbeat. The function will generate
|
|
4631
|
-
* a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
|
|
4632
|
-
* to IndexedDB.
|
|
4633
|
-
* Note that we only store one heartbeat per day. So if a heartbeat for today is
|
|
4634
|
-
* already logged, subsequent calls to this function in the same day will be ignored.
|
|
4635
|
-
*/
|
|
4636
|
-
async triggerHeartbeat() {
|
|
4637
|
-
try {
|
|
4638
|
-
const platformLogger = this.container
|
|
4639
|
-
.getProvider('platform-logger')
|
|
4640
|
-
.getImmediate();
|
|
4641
|
-
// This is the "Firebase user agent" string from the platform logger
|
|
4642
|
-
// service, not the browser user agent.
|
|
4643
|
-
const agent = platformLogger.getPlatformInfoString();
|
|
4644
|
-
const date = getUTCDateString();
|
|
4645
|
-
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4646
|
-
this._heartbeatsCache = await this._heartbeatsCachePromise;
|
|
4647
|
-
// If we failed to construct a heartbeats cache, then return immediately.
|
|
4648
|
-
if (this._heartbeatsCache?.heartbeats == null) {
|
|
4649
|
-
return;
|
|
4650
|
-
}
|
|
4651
|
-
}
|
|
4652
|
-
// Do not store a heartbeat if one is already stored for this day
|
|
4653
|
-
// or if a header has already been sent today.
|
|
4654
|
-
if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
|
|
4655
|
-
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
|
|
4656
|
-
return;
|
|
4657
|
-
}
|
|
4658
|
-
else {
|
|
4659
|
-
// There is no entry for this date. Create one.
|
|
4660
|
-
this._heartbeatsCache.heartbeats.push({ date, agent });
|
|
4661
|
-
// If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
|
|
4662
|
-
// 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.
|
|
4663
|
-
if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
|
|
4664
|
-
const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
|
|
4665
|
-
this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
return this._storage.overwrite(this._heartbeatsCache);
|
|
4669
|
-
}
|
|
4670
|
-
catch (e) {
|
|
4671
|
-
logger.warn(e);
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
/**
|
|
4675
|
-
* Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
|
|
4676
|
-
* It also clears all heartbeats from memory as well as in IndexedDB.
|
|
4677
|
-
*
|
|
4678
|
-
* NOTE: Consuming product SDKs should not send the header if this method
|
|
4679
|
-
* returns an empty string.
|
|
4680
|
-
*/
|
|
4681
|
-
async getHeartbeatsHeader() {
|
|
4682
|
-
try {
|
|
4683
|
-
if (this._heartbeatsCache === null) {
|
|
4684
|
-
await this._heartbeatsCachePromise;
|
|
4685
|
-
}
|
|
4686
|
-
// If it's still null or the array is empty, there is no data to send.
|
|
4687
|
-
if (this._heartbeatsCache?.heartbeats == null ||
|
|
4688
|
-
this._heartbeatsCache.heartbeats.length === 0) {
|
|
4689
|
-
return '';
|
|
4690
|
-
}
|
|
4691
|
-
const date = getUTCDateString();
|
|
4692
|
-
// Extract as many heartbeats from the cache as will fit under the size limit.
|
|
4693
|
-
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
|
|
4694
|
-
const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
|
|
4695
|
-
// Store last sent date to prevent another being logged/sent for the same day.
|
|
4696
|
-
this._heartbeatsCache.lastSentHeartbeatDate = date;
|
|
4697
|
-
if (unsentEntries.length > 0) {
|
|
4698
|
-
// Store any unsent entries if they exist.
|
|
4699
|
-
this._heartbeatsCache.heartbeats = unsentEntries;
|
|
4700
|
-
// This seems more likely than emptying the array (below) to lead to some odd state
|
|
4701
|
-
// since the cache isn't empty and this will be called again on the next request,
|
|
4702
|
-
// and is probably safest if we await it.
|
|
4703
|
-
await this._storage.overwrite(this._heartbeatsCache);
|
|
4704
|
-
}
|
|
4705
|
-
else {
|
|
4706
|
-
this._heartbeatsCache.heartbeats = [];
|
|
4707
|
-
// Do not wait for this, to reduce latency.
|
|
4708
|
-
void this._storage.overwrite(this._heartbeatsCache);
|
|
4709
|
-
}
|
|
4710
|
-
return headerString;
|
|
4711
|
-
}
|
|
4712
|
-
catch (e) {
|
|
4713
|
-
logger.warn(e);
|
|
4714
|
-
return '';
|
|
4715
|
-
}
|
|
4716
|
-
}
|
|
4717
|
-
}
|
|
4718
|
-
function getUTCDateString() {
|
|
4719
|
-
const today = new Date();
|
|
4720
|
-
// Returns date format 'YYYY-MM-DD'
|
|
4721
|
-
return today.toISOString().substring(0, 10);
|
|
4722
|
-
}
|
|
4723
|
-
function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
|
|
4724
|
-
// Heartbeats grouped by user agent in the standard format to be sent in
|
|
4725
|
-
// the header.
|
|
4726
|
-
const heartbeatsToSend = [];
|
|
4727
|
-
// Single date format heartbeats that are not sent.
|
|
4728
|
-
let unsentEntries = heartbeatsCache.slice();
|
|
4729
|
-
for (const singleDateHeartbeat of heartbeatsCache) {
|
|
4730
|
-
// Look for an existing entry with the same user agent.
|
|
4731
|
-
const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
|
|
4732
|
-
if (!heartbeatEntry) {
|
|
4733
|
-
// If no entry for this user agent exists, create one.
|
|
4734
|
-
heartbeatsToSend.push({
|
|
4735
|
-
agent: singleDateHeartbeat.agent,
|
|
4736
|
-
dates: [singleDateHeartbeat.date]
|
|
4737
|
-
});
|
|
4738
|
-
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4739
|
-
// If the header would exceed max size, remove the added heartbeat
|
|
4740
|
-
// entry and stop adding to the header.
|
|
4741
|
-
heartbeatsToSend.pop();
|
|
4742
|
-
break;
|
|
4743
|
-
}
|
|
4744
|
-
}
|
|
4745
|
-
else {
|
|
4746
|
-
heartbeatEntry.dates.push(singleDateHeartbeat.date);
|
|
4747
|
-
// If the header would exceed max size, remove the added date
|
|
4748
|
-
// and stop adding to the header.
|
|
4749
|
-
if (countBytes(heartbeatsToSend) > maxSize) {
|
|
4750
|
-
heartbeatEntry.dates.pop();
|
|
4751
|
-
break;
|
|
4752
|
-
}
|
|
4753
|
-
}
|
|
4754
|
-
// Pop unsent entry from queue. (Skipped if adding the entry exceeded
|
|
4755
|
-
// quota and the loop breaks early.)
|
|
4756
|
-
unsentEntries = unsentEntries.slice(1);
|
|
4757
|
-
}
|
|
4758
|
-
return {
|
|
4759
|
-
heartbeatsToSend,
|
|
4760
|
-
unsentEntries
|
|
4761
|
-
};
|
|
4762
|
-
}
|
|
4763
|
-
class HeartbeatStorageImpl {
|
|
4764
|
-
constructor(app) {
|
|
4765
|
-
this.app = app;
|
|
4766
|
-
this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
|
|
4767
|
-
}
|
|
4768
|
-
async runIndexedDBEnvironmentCheck() {
|
|
4769
|
-
if (!util.isIndexedDBAvailable()) {
|
|
4770
|
-
return false;
|
|
4771
|
-
}
|
|
4772
|
-
else {
|
|
4773
|
-
return util.validateIndexedDBOpenable()
|
|
4774
|
-
.then(() => true)
|
|
4775
|
-
.catch(() => false);
|
|
4776
|
-
}
|
|
4777
|
-
}
|
|
4778
|
-
/**
|
|
4779
|
-
* Read all heartbeats.
|
|
4780
|
-
*/
|
|
4781
|
-
async read() {
|
|
4782
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4783
|
-
if (!canUseIndexedDB) {
|
|
4784
|
-
return { heartbeats: [] };
|
|
4785
|
-
}
|
|
4786
|
-
else {
|
|
4787
|
-
const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
|
|
4788
|
-
if (idbHeartbeatObject?.heartbeats) {
|
|
4789
|
-
return idbHeartbeatObject;
|
|
4790
|
-
}
|
|
4791
|
-
else {
|
|
4792
|
-
return { heartbeats: [] };
|
|
4793
|
-
}
|
|
4794
|
-
}
|
|
4795
|
-
}
|
|
4796
|
-
// overwrite the storage with the provided heartbeats
|
|
4797
|
-
async overwrite(heartbeatsObject) {
|
|
4798
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4799
|
-
if (!canUseIndexedDB) {
|
|
4800
|
-
return;
|
|
4801
|
-
}
|
|
4802
|
-
else {
|
|
4803
|
-
const existingHeartbeatsObject = await this.read();
|
|
4804
|
-
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4805
|
-
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4806
|
-
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4807
|
-
heartbeats: heartbeatsObject.heartbeats
|
|
4808
|
-
});
|
|
4809
|
-
}
|
|
4810
|
-
}
|
|
4811
|
-
// add heartbeats
|
|
4812
|
-
async add(heartbeatsObject) {
|
|
4813
|
-
const canUseIndexedDB = await this._canUseIndexedDBPromise;
|
|
4814
|
-
if (!canUseIndexedDB) {
|
|
4815
|
-
return;
|
|
4816
|
-
}
|
|
4817
|
-
else {
|
|
4818
|
-
const existingHeartbeatsObject = await this.read();
|
|
4819
|
-
return writeHeartbeatsToIndexedDB(this.app, {
|
|
4820
|
-
lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
|
|
4821
|
-
existingHeartbeatsObject.lastSentHeartbeatDate,
|
|
4822
|
-
heartbeats: [
|
|
4823
|
-
...existingHeartbeatsObject.heartbeats,
|
|
4824
|
-
...heartbeatsObject.heartbeats
|
|
4825
|
-
]
|
|
4826
|
-
});
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
}
|
|
4830
|
-
/**
|
|
4831
|
-
* Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
|
|
4832
|
-
* in a platform logging header JSON object, stringified, and converted
|
|
4833
|
-
* to base 64.
|
|
4834
|
-
*/
|
|
4835
|
-
function countBytes(heartbeatsCache) {
|
|
4836
|
-
// base64 has a restricted set of characters, all of which should be 1 byte.
|
|
4837
|
-
return util.base64urlEncodeWithoutPadding(
|
|
4838
|
-
// heartbeatsCache wrapper properties
|
|
4839
|
-
JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
|
|
4840
|
-
}
|
|
4841
|
-
/**
|
|
4842
|
-
* Returns the index of the heartbeat with the earliest date.
|
|
4843
|
-
* If the heartbeats array is empty, -1 is returned.
|
|
4844
|
-
*/
|
|
4845
|
-
function getEarliestHeartbeatIdx(heartbeats) {
|
|
4846
|
-
if (heartbeats.length === 0) {
|
|
4847
|
-
return -1;
|
|
4848
|
-
}
|
|
4849
|
-
let earliestHeartbeatIdx = 0;
|
|
4850
|
-
let earliestHeartbeatDate = heartbeats[0].date;
|
|
4851
|
-
for (let i = 1; i < heartbeats.length; i++) {
|
|
4852
|
-
if (heartbeats[i].date < earliestHeartbeatDate) {
|
|
4853
|
-
earliestHeartbeatDate = heartbeats[i].date;
|
|
4854
|
-
earliestHeartbeatIdx = i;
|
|
4855
|
-
}
|
|
4856
|
-
}
|
|
4857
|
-
return earliestHeartbeatIdx;
|
|
4858
|
-
}
|
|
3250
|
+
_open: function() {
|
|
3251
|
+
if (this.readyState !== API$1.CONNECTING) return;
|
|
4859
3252
|
|
|
4860
|
-
|
|
4861
|
-
* @license
|
|
4862
|
-
* Copyright 2019 Google LLC
|
|
4863
|
-
*
|
|
4864
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4865
|
-
* you may not use this file except in compliance with the License.
|
|
4866
|
-
* You may obtain a copy of the License at
|
|
4867
|
-
*
|
|
4868
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4869
|
-
*
|
|
4870
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
4871
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4872
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4873
|
-
* See the License for the specific language governing permissions and
|
|
4874
|
-
* limitations under the License.
|
|
4875
|
-
*/
|
|
4876
|
-
function registerCoreComponents(variant) {
|
|
4877
|
-
_registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4878
|
-
_registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
|
|
4879
|
-
// Register `app` package.
|
|
4880
|
-
registerVersion(name$q, version$1, variant);
|
|
4881
|
-
// BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
|
|
4882
|
-
registerVersion(name$q, version$1, 'cjs2020');
|
|
4883
|
-
// Register platform SDK identifier (no version).
|
|
4884
|
-
registerVersion('fire-js', '');
|
|
4885
|
-
}
|
|
3253
|
+
this.readyState = API$1.OPEN;
|
|
4886
3254
|
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
* @packageDocumentation
|
|
4892
|
-
*/
|
|
4893
|
-
registerCoreComponents('node');
|
|
3255
|
+
var event = new Event('open');
|
|
3256
|
+
event.initEvent('open', false, false);
|
|
3257
|
+
this.dispatchEvent(event);
|
|
3258
|
+
},
|
|
4894
3259
|
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
});
|
|
4899
|
-
exports.SDK_VERSION = SDK_VERSION;
|
|
4900
|
-
exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
|
|
4901
|
-
exports._addComponent = _addComponent;
|
|
4902
|
-
exports._addOrOverwriteComponent = _addOrOverwriteComponent;
|
|
4903
|
-
exports._apps = _apps;
|
|
4904
|
-
exports._clearComponents = _clearComponents;
|
|
4905
|
-
exports._components = _components;
|
|
4906
|
-
exports._getProvider = _getProvider;
|
|
4907
|
-
exports._isFirebaseApp = _isFirebaseApp;
|
|
4908
|
-
exports._isFirebaseServerApp = _isFirebaseServerApp;
|
|
4909
|
-
exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
|
|
4910
|
-
exports._registerComponent = _registerComponent;
|
|
4911
|
-
exports._removeServiceInstance = _removeServiceInstance;
|
|
4912
|
-
exports._serverApps = _serverApps;
|
|
4913
|
-
exports.deleteApp = deleteApp;
|
|
4914
|
-
exports.getApp = getApp;
|
|
4915
|
-
exports.getApps = getApps;
|
|
4916
|
-
exports.initializeApp = initializeApp;
|
|
4917
|
-
exports.initializeServerApp = initializeServerApp;
|
|
4918
|
-
exports.onLog = onLog;
|
|
4919
|
-
exports.registerVersion = registerVersion;
|
|
4920
|
-
exports.setLogLevel = setLogLevel;
|
|
4921
|
-
|
|
4922
|
-
}(index_cjs));
|
|
3260
|
+
write: function(message) {
|
|
3261
|
+
return this.send(message);
|
|
3262
|
+
},
|
|
4923
3263
|
|
|
4924
|
-
|
|
3264
|
+
end: function(message) {
|
|
3265
|
+
if (message !== undefined) this.write(message);
|
|
3266
|
+
this.close();
|
|
3267
|
+
},
|
|
4925
3268
|
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
3269
|
+
send: function(message, options) {
|
|
3270
|
+
if (this.readyState > API$1.OPEN) return false;
|
|
3271
|
+
|
|
3272
|
+
message = String(message).replace(/(\r\n|\r|\n)/g, '$1data: ');
|
|
3273
|
+
options = options || {};
|
|
3274
|
+
|
|
3275
|
+
var frame = '';
|
|
3276
|
+
if (options.event) frame += 'event: ' + options.event + '\r\n';
|
|
3277
|
+
if (options.id) frame += 'id: ' + options.id + '\r\n';
|
|
3278
|
+
frame += 'data: ' + message + '\r\n\r\n';
|
|
3279
|
+
|
|
3280
|
+
return this._write(frame);
|
|
3281
|
+
},
|
|
3282
|
+
|
|
3283
|
+
ping: function() {
|
|
3284
|
+
return this._write(':\r\n\r\n');
|
|
3285
|
+
},
|
|
3286
|
+
|
|
3287
|
+
close: function() {
|
|
3288
|
+
if (this.readyState > API$1.OPEN) return false;
|
|
3289
|
+
|
|
3290
|
+
this.readyState = API$1.CLOSED;
|
|
3291
|
+
this.writable = false;
|
|
3292
|
+
if (this._pingTimer) clearInterval(this._pingTimer);
|
|
3293
|
+
if (this._stream) this._stream.end();
|
|
3294
|
+
|
|
3295
|
+
var event = new Event('close');
|
|
3296
|
+
event.initEvent('close', false, false);
|
|
3297
|
+
this.dispatchEvent(event);
|
|
3298
|
+
|
|
3299
|
+
return true;
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
|
|
3303
|
+
for (var method in instance) EventSource.prototype[method] = instance[method];
|
|
3304
|
+
for (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];
|
|
3305
|
+
|
|
3306
|
+
var eventsource = EventSource;
|
|
3307
|
+
|
|
3308
|
+
var util$1 = require$$2,
|
|
3309
|
+
driver = driver$4,
|
|
3310
|
+
API = api;
|
|
3311
|
+
|
|
3312
|
+
var WebSocket$1 = function(request, socket, body, protocols, options) {
|
|
3313
|
+
options = options || {};
|
|
3314
|
+
|
|
3315
|
+
this._stream = socket;
|
|
3316
|
+
this._driver = driver.http(request, { maxLength: options.maxLength, protocols: protocols });
|
|
3317
|
+
|
|
3318
|
+
var self = this;
|
|
3319
|
+
if (!this._stream || !this._stream.writable) return;
|
|
3320
|
+
if (!this._stream.readable) return this._stream.end();
|
|
3321
|
+
|
|
3322
|
+
var catchup = function() { self._stream.removeListener('data', catchup); };
|
|
3323
|
+
this._stream.on('data', catchup);
|
|
3324
|
+
|
|
3325
|
+
API.call(this, options);
|
|
3326
|
+
|
|
3327
|
+
process.nextTick(function() {
|
|
3328
|
+
self._driver.start();
|
|
3329
|
+
self._driver.io.write(body);
|
|
3330
|
+
});
|
|
3331
|
+
};
|
|
3332
|
+
util$1.inherits(WebSocket$1, API);
|
|
3333
|
+
|
|
3334
|
+
WebSocket$1.isWebSocket = function(request) {
|
|
3335
|
+
return driver.isWebSocket(request);
|
|
3336
|
+
};
|
|
3337
|
+
|
|
3338
|
+
WebSocket$1.validateOptions = function(options, validKeys) {
|
|
3339
|
+
driver.validateOptions(options, validKeys);
|
|
3340
|
+
};
|
|
3341
|
+
|
|
3342
|
+
WebSocket$1.WebSocket = WebSocket$1;
|
|
3343
|
+
WebSocket$1.Client = client;
|
|
3344
|
+
WebSocket$1.EventSource = eventsource;
|
|
3345
|
+
|
|
3346
|
+
var websocket = WebSocket$1;
|
|
4931
3347
|
|
|
4932
|
-
|
|
3348
|
+
Object.defineProperty(index_standalone, '__esModule', { value: true });
|
|
4933
3349
|
|
|
4934
|
-
var
|
|
3350
|
+
var Websocket = websocket;
|
|
3351
|
+
var util = require$$1$3;
|
|
3352
|
+
var logger$1 = require$$2$3;
|
|
3353
|
+
var app = require$$3;
|
|
3354
|
+
var component = require$$4;
|
|
4935
3355
|
|
|
4936
3356
|
/**
|
|
4937
3357
|
* @license
|
|
@@ -15283,15 +13703,12 @@ function treeForEachChild(tree, action) {
|
|
|
15283
13703
|
* parent.
|
|
15284
13704
|
*/
|
|
15285
13705
|
function treeForEachDescendant(tree, action, includeSelf, childrenFirst) {
|
|
15286
|
-
if (includeSelf &&
|
|
13706
|
+
if (includeSelf && true) {
|
|
15287
13707
|
action(tree);
|
|
15288
13708
|
}
|
|
15289
13709
|
treeForEachChild(tree, child => {
|
|
15290
|
-
treeForEachDescendant(child, action, true
|
|
13710
|
+
treeForEachDescendant(child, action, true);
|
|
15291
13711
|
});
|
|
15292
|
-
if (includeSelf && childrenFirst) {
|
|
15293
|
-
action(tree);
|
|
15294
|
-
}
|
|
15295
13712
|
}
|
|
15296
13713
|
/**
|
|
15297
13714
|
* Calls action on each ancestor node.
|
|
@@ -15302,7 +13719,7 @@ function treeForEachDescendant(tree, action, includeSelf, childrenFirst) {
|
|
|
15302
13719
|
* @returns true if the action callback returned true.
|
|
15303
13720
|
*/
|
|
15304
13721
|
function treeForEachAncestor(tree, action, includeSelf) {
|
|
15305
|
-
let node =
|
|
13722
|
+
let node = tree.parent;
|
|
15306
13723
|
while (node !== null) {
|
|
15307
13724
|
if (action(node)) {
|
|
15308
13725
|
return true;
|
|
@@ -15521,9 +13938,6 @@ const validateFirebaseMergePaths = function (errorPrefix, mergePaths) {
|
|
|
15521
13938
|
* must be an object - e.g. for firebase.update()).
|
|
15522
13939
|
*/
|
|
15523
13940
|
const validateFirebaseMergeDataArg = function (fnName, data, path, optional) {
|
|
15524
|
-
if (optional && data === undefined) {
|
|
15525
|
-
return;
|
|
15526
|
-
}
|
|
15527
13941
|
const errorPrefix = util.errorPrefix(fnName, 'values');
|
|
15528
13942
|
if (!(data && typeof data === 'object') || Array.isArray(data)) {
|
|
15529
13943
|
throw new Error(errorPrefix + ' must be an object containing the children to replace.');
|
|
@@ -15546,9 +13960,6 @@ const validateFirebaseMergeDataArg = function (fnName, data, path, optional) {
|
|
|
15546
13960
|
validateFirebaseMergePaths(errorPrefix, mergePaths);
|
|
15547
13961
|
};
|
|
15548
13962
|
const validatePriority = function (fnName, priority, optional) {
|
|
15549
|
-
if (optional && priority === undefined) {
|
|
15550
|
-
return;
|
|
15551
|
-
}
|
|
15552
13963
|
if (isInvalidJSONNumber(priority)) {
|
|
15553
13964
|
throw new Error(util.errorPrefix(fnName, 'priority') +
|
|
15554
13965
|
'is ' +
|
|
@@ -15564,7 +13975,7 @@ const validatePriority = function (fnName, priority, optional) {
|
|
|
15564
13975
|
}
|
|
15565
13976
|
};
|
|
15566
13977
|
const validateKey = function (fnName, argumentName, key, optional) {
|
|
15567
|
-
if (
|
|
13978
|
+
if (key === undefined) {
|
|
15568
13979
|
return;
|
|
15569
13980
|
}
|
|
15570
13981
|
if (!isValidKey(key)) {
|
|
@@ -17024,7 +15435,7 @@ class CallbackContext {
|
|
|
17024
15435
|
* operation to occur each time a disconnect occurs, you'll need to re-establish
|
|
17025
15436
|
* the `onDisconnect` operations each time you reconnect.
|
|
17026
15437
|
*/
|
|
17027
|
-
|
|
15438
|
+
let OnDisconnect$1 = class OnDisconnect {
|
|
17028
15439
|
/** @hideconstructor */
|
|
17029
15440
|
constructor(_repo, _path) {
|
|
17030
15441
|
this._repo = _repo;
|
|
@@ -17096,7 +15507,7 @@ class OnDisconnect$1 {
|
|
|
17096
15507
|
setWithPriority(value, priority) {
|
|
17097
15508
|
validateWritablePath('OnDisconnect.setWithPriority', this._path);
|
|
17098
15509
|
validateFirebaseDataArg('OnDisconnect.setWithPriority', value, this._path, false);
|
|
17099
|
-
validatePriority('OnDisconnect.setWithPriority', priority
|
|
15510
|
+
validatePriority('OnDisconnect.setWithPriority', priority);
|
|
17100
15511
|
const deferred = new util.Deferred();
|
|
17101
15512
|
repoOnDisconnectSetWithPriority(this._repo, this._path, value, priority, deferred.wrapCallback(() => { }));
|
|
17102
15513
|
return deferred.promise;
|
|
@@ -17119,12 +15530,12 @@ class OnDisconnect$1 {
|
|
|
17119
15530
|
*/
|
|
17120
15531
|
update(values) {
|
|
17121
15532
|
validateWritablePath('OnDisconnect.update', this._path);
|
|
17122
|
-
validateFirebaseMergeDataArg('OnDisconnect.update', values, this._path
|
|
15533
|
+
validateFirebaseMergeDataArg('OnDisconnect.update', values, this._path);
|
|
17123
15534
|
const deferred = new util.Deferred();
|
|
17124
15535
|
repoOnDisconnectUpdate(this._repo, this._path, values, deferred.wrapCallback(() => { }));
|
|
17125
15536
|
return deferred.promise;
|
|
17126
15537
|
}
|
|
17127
|
-
}
|
|
15538
|
+
};
|
|
17128
15539
|
|
|
17129
15540
|
/**
|
|
17130
15541
|
* @license
|
|
@@ -17304,7 +15715,7 @@ class ReferenceImpl extends QueryImpl {
|
|
|
17304
15715
|
* a Database location. It cannot be modified and will never change (to modify
|
|
17305
15716
|
* data, you always call the `set()` method on a `Reference` directly).
|
|
17306
15717
|
*/
|
|
17307
|
-
|
|
15718
|
+
let DataSnapshot$1 = class DataSnapshot {
|
|
17308
15719
|
/**
|
|
17309
15720
|
* @param _node - A SnapshotNode to wrap.
|
|
17310
15721
|
* @param ref - The location this snapshot came from.
|
|
@@ -17363,7 +15774,7 @@ class DataSnapshot$1 {
|
|
|
17363
15774
|
child(path) {
|
|
17364
15775
|
const childPath = new Path(path);
|
|
17365
15776
|
const childRef = child(this.ref, path);
|
|
17366
|
-
return new DataSnapshot
|
|
15777
|
+
return new DataSnapshot(this._node.getChild(childPath), childRef, PRIORITY_INDEX);
|
|
17367
15778
|
}
|
|
17368
15779
|
/**
|
|
17369
15780
|
* Returns true if this `DataSnapshot` contains any data. It is slightly more
|
|
@@ -17410,7 +15821,7 @@ class DataSnapshot$1 {
|
|
|
17410
15821
|
const childrenNode = this._node;
|
|
17411
15822
|
// Sanitize the return value to a boolean. ChildrenNode.forEachChild has a weird return type...
|
|
17412
15823
|
return !!childrenNode.forEachChild(this._index, (key, node) => {
|
|
17413
|
-
return action(new DataSnapshot
|
|
15824
|
+
return action(new DataSnapshot(node, child(this.ref, key), PRIORITY_INDEX));
|
|
17414
15825
|
});
|
|
17415
15826
|
}
|
|
17416
15827
|
/**
|
|
@@ -17465,7 +15876,7 @@ class DataSnapshot$1 {
|
|
|
17465
15876
|
val() {
|
|
17466
15877
|
return this._node.val();
|
|
17467
15878
|
}
|
|
17468
|
-
}
|
|
15879
|
+
};
|
|
17469
15880
|
/**
|
|
17470
15881
|
*
|
|
17471
15882
|
* Returns a `Reference` representing the location in the Database
|
|
@@ -17670,7 +16081,7 @@ function set(ref, value) {
|
|
|
17670
16081
|
function setPriority(ref, priority) {
|
|
17671
16082
|
ref = util.getModularInstance(ref);
|
|
17672
16083
|
validateWritablePath('setPriority', ref._path);
|
|
17673
|
-
validatePriority('setPriority', priority
|
|
16084
|
+
validatePriority('setPriority', priority);
|
|
17674
16085
|
const deferred = new util.Deferred();
|
|
17675
16086
|
repoSetWithPriority(ref._repo, pathChild(ref._path, '.priority'), priority, null, deferred.wrapCallback(() => { }));
|
|
17676
16087
|
return deferred.promise;
|
|
@@ -17693,7 +16104,7 @@ function setPriority(ref, priority) {
|
|
|
17693
16104
|
function setWithPriority(ref, value, priority) {
|
|
17694
16105
|
validateWritablePath('setWithPriority', ref._path);
|
|
17695
16106
|
validateFirebaseDataArg('setWithPriority', value, ref._path, false);
|
|
17696
|
-
validatePriority('setWithPriority', priority
|
|
16107
|
+
validatePriority('setWithPriority', priority);
|
|
17697
16108
|
if (ref.key === '.length' || ref.key === '.keys') {
|
|
17698
16109
|
throw 'setWithPriority failed: ' + ref.key + ' is a read-only object.';
|
|
17699
16110
|
}
|
|
@@ -17737,7 +16148,7 @@ function setWithPriority(ref, value, priority) {
|
|
|
17737
16148
|
* @returns Resolves when update on server is complete.
|
|
17738
16149
|
*/
|
|
17739
16150
|
function update(ref, values) {
|
|
17740
|
-
validateFirebaseMergeDataArg('update', values, ref._path
|
|
16151
|
+
validateFirebaseMergeDataArg('update', values, ref._path);
|
|
17741
16152
|
const deferred = new util.Deferred();
|
|
17742
16153
|
repoUpdate(ref._repo, ref._path, values, deferred.wrapCallback(() => { }));
|
|
17743
16154
|
return deferred.promise;
|
|
@@ -17983,7 +16394,7 @@ class QueryEndAtConstraint extends QueryConstraint {
|
|
|
17983
16394
|
* value, or priority.
|
|
17984
16395
|
*/
|
|
17985
16396
|
function endAt(value, key) {
|
|
17986
|
-
validateKey('endAt', 'key', key
|
|
16397
|
+
validateKey('endAt', 'key', key);
|
|
17987
16398
|
return new QueryEndAtConstraint(value, key);
|
|
17988
16399
|
}
|
|
17989
16400
|
class QueryEndBeforeConstraint extends QueryConstraint {
|
|
@@ -18025,7 +16436,7 @@ class QueryEndBeforeConstraint extends QueryConstraint {
|
|
|
18025
16436
|
* child, value, or priority.
|
|
18026
16437
|
*/
|
|
18027
16438
|
function endBefore(value, key) {
|
|
18028
|
-
validateKey('endBefore', 'key', key
|
|
16439
|
+
validateKey('endBefore', 'key', key);
|
|
18029
16440
|
return new QueryEndBeforeConstraint(value, key);
|
|
18030
16441
|
}
|
|
18031
16442
|
class QueryStartAtConstraint extends QueryConstraint {
|
|
@@ -18070,7 +16481,7 @@ class QueryStartAtConstraint extends QueryConstraint {
|
|
|
18070
16481
|
* ordering by child, value, or priority.
|
|
18071
16482
|
*/
|
|
18072
16483
|
function startAt(value = null, key) {
|
|
18073
|
-
validateKey('startAt', 'key', key
|
|
16484
|
+
validateKey('startAt', 'key', key);
|
|
18074
16485
|
return new QueryStartAtConstraint(value, key);
|
|
18075
16486
|
}
|
|
18076
16487
|
class QueryStartAfterConstraint extends QueryConstraint {
|
|
@@ -18111,7 +16522,7 @@ class QueryStartAfterConstraint extends QueryConstraint {
|
|
|
18111
16522
|
* ordering by child, value, or priority.
|
|
18112
16523
|
*/
|
|
18113
16524
|
function startAfter(value, key) {
|
|
18114
|
-
validateKey('startAfter', 'key', key
|
|
16525
|
+
validateKey('startAfter', 'key', key);
|
|
18115
16526
|
return new QueryStartAfterConstraint(value, key);
|
|
18116
16527
|
}
|
|
18117
16528
|
class QueryLimitToFirstConstraint extends QueryConstraint {
|
|
@@ -18356,7 +16767,7 @@ class QueryEqualToValueConstraint extends QueryConstraint {
|
|
|
18356
16767
|
* child, value, or priority.
|
|
18357
16768
|
*/
|
|
18358
16769
|
function equalTo(value, key) {
|
|
18359
|
-
validateKey('equalTo', 'key', key
|
|
16770
|
+
validateKey('equalTo', 'key', key);
|
|
18360
16771
|
return new QueryEqualToValueConstraint(value, key);
|
|
18361
16772
|
}
|
|
18362
16773
|
/**
|
|
@@ -18400,6 +16811,7 @@ syncTreeSetReferenceConstructor(ReferenceImpl);
|
|
|
18400
16811
|
* See the License for the specific language governing permissions and
|
|
18401
16812
|
* limitations under the License.
|
|
18402
16813
|
*/
|
|
16814
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18403
16815
|
/**
|
|
18404
16816
|
* This variable is also defined in the firebase Node.js Admin SDK. Before
|
|
18405
16817
|
* modifying this definition, consult the definition in:
|
|
@@ -18515,7 +16927,7 @@ function repoManagerForceRestClient(forceRestClient) {
|
|
|
18515
16927
|
/**
|
|
18516
16928
|
* Class representing a Firebase Realtime Database.
|
|
18517
16929
|
*/
|
|
18518
|
-
|
|
16930
|
+
let Database$1 = class Database {
|
|
18519
16931
|
/** @hideconstructor */
|
|
18520
16932
|
constructor(_repoInternal,
|
|
18521
16933
|
/** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
|
|
@@ -18553,7 +16965,7 @@ class Database$1 {
|
|
|
18553
16965
|
fatal('Cannot call ' + apiName + ' on a deleted database.');
|
|
18554
16966
|
}
|
|
18555
16967
|
}
|
|
18556
|
-
}
|
|
16968
|
+
};
|
|
18557
16969
|
function checkTransportInit() {
|
|
18558
16970
|
if (TransportManager.IS_TRANSPORT_INITIALIZED) {
|
|
18559
16971
|
warn$1('Transport has already been initialized. Please call this function before calling ref or setting up a listener');
|
|
@@ -18726,7 +17138,7 @@ function increment(delta) {
|
|
|
18726
17138
|
/**
|
|
18727
17139
|
* A type for the resolve value of {@link runTransaction}.
|
|
18728
17140
|
*/
|
|
18729
|
-
|
|
17141
|
+
let TransactionResult$1 = class TransactionResult {
|
|
18730
17142
|
/** @hideconstructor */
|
|
18731
17143
|
constructor(
|
|
18732
17144
|
/** Whether the transaction was successfully committed. */
|
|
@@ -18740,7 +17152,7 @@ class TransactionResult$1 {
|
|
|
18740
17152
|
toJSON() {
|
|
18741
17153
|
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
|
18742
17154
|
}
|
|
18743
|
-
}
|
|
17155
|
+
};
|
|
18744
17156
|
/**
|
|
18745
17157
|
* Atomically modifies the data at this location.
|
|
18746
17158
|
*
|
|
@@ -18803,6 +17215,23 @@ transactionUpdate, options) {
|
|
|
18803
17215
|
repoStartTransaction(ref._repo, ref._path, transactionUpdate, promiseComplete, unwatcher, applyLocally);
|
|
18804
17216
|
return deferred.promise;
|
|
18805
17217
|
}
|
|
17218
|
+
|
|
17219
|
+
/**
|
|
17220
|
+
* @license
|
|
17221
|
+
* Copyright 2017 Google LLC
|
|
17222
|
+
*
|
|
17223
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17224
|
+
* you may not use this file except in compliance with the License.
|
|
17225
|
+
* You may obtain a copy of the License at
|
|
17226
|
+
*
|
|
17227
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17228
|
+
*
|
|
17229
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17230
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17231
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17232
|
+
* See the License for the specific language governing permissions and
|
|
17233
|
+
* limitations under the License.
|
|
17234
|
+
*/
|
|
18806
17235
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18807
17236
|
PersistentConnection.prototype.simpleListen = function (pathString, onComplete) {
|
|
18808
17237
|
this.sendRequest('q', { p: pathString }, onComplete);
|
|
@@ -18893,7 +17322,7 @@ function _initStandalone({ app, url, version, customAuthImpl, customAppCheckImpl
|
|
|
18893
17322
|
* See the License for the specific language governing permissions and
|
|
18894
17323
|
* limitations under the License.
|
|
18895
17324
|
*/
|
|
18896
|
-
setWebSocketImpl(
|
|
17325
|
+
setWebSocketImpl(Websocket.Client);
|
|
18897
17326
|
|
|
18898
17327
|
index_standalone.DataSnapshot = DataSnapshot$1;
|
|
18899
17328
|
index_standalone.Database = Database$1;
|
|
@@ -18965,7 +17394,7 @@ var update_1 = index_standalone.update = update;
|
|
|
18965
17394
|
* See the License for the specific language governing permissions and
|
|
18966
17395
|
* limitations under the License.
|
|
18967
17396
|
*/
|
|
18968
|
-
const logClient = new require$$
|
|
17397
|
+
const logClient = new require$$2$3.Logger('@firebase/database-compat');
|
|
18969
17398
|
const warn = function (msg) {
|
|
18970
17399
|
const message = 'FIREBASE WARNING: ' + msg;
|
|
18971
17400
|
logClient.warn(message);
|
|
@@ -18988,15 +17417,15 @@ const warn = function (msg) {
|
|
|
18988
17417
|
* limitations under the License.
|
|
18989
17418
|
*/
|
|
18990
17419
|
const validateBoolean = function (fnName, argumentName, bool, optional) {
|
|
18991
|
-
if (
|
|
17420
|
+
if (bool === undefined) {
|
|
18992
17421
|
return;
|
|
18993
17422
|
}
|
|
18994
17423
|
if (typeof bool !== 'boolean') {
|
|
18995
|
-
throw new Error(require$$
|
|
17424
|
+
throw new Error(require$$1$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
|
|
18996
17425
|
}
|
|
18997
17426
|
};
|
|
18998
17427
|
const validateEventType = function (fnName, eventType, optional) {
|
|
18999
|
-
if (
|
|
17428
|
+
if (eventType === undefined) {
|
|
19000
17429
|
return;
|
|
19001
17430
|
}
|
|
19002
17431
|
switch (eventType) {
|
|
@@ -19007,7 +17436,7 @@ const validateEventType = function (fnName, eventType, optional) {
|
|
|
19007
17436
|
case 'child_moved':
|
|
19008
17437
|
break;
|
|
19009
17438
|
default:
|
|
19010
|
-
throw new Error(require$$
|
|
17439
|
+
throw new Error(require$$1$3.errorPrefix(fnName, 'eventType') +
|
|
19011
17440
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19012
17441
|
'"child_changed", or "child_moved".');
|
|
19013
17442
|
}
|
|
@@ -19034,8 +17463,8 @@ class OnDisconnect {
|
|
|
19034
17463
|
this._delegate = _delegate;
|
|
19035
17464
|
}
|
|
19036
17465
|
cancel(onComplete) {
|
|
19037
|
-
require$$
|
|
19038
|
-
require$$
|
|
17466
|
+
require$$1$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
|
|
17467
|
+
require$$1$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
|
|
19039
17468
|
const result = this._delegate.cancel();
|
|
19040
17469
|
if (onComplete) {
|
|
19041
17470
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19043,8 +17472,8 @@ class OnDisconnect {
|
|
|
19043
17472
|
return result;
|
|
19044
17473
|
}
|
|
19045
17474
|
remove(onComplete) {
|
|
19046
|
-
require$$
|
|
19047
|
-
require$$
|
|
17475
|
+
require$$1$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
|
|
17476
|
+
require$$1$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
|
|
19048
17477
|
const result = this._delegate.remove();
|
|
19049
17478
|
if (onComplete) {
|
|
19050
17479
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19052,8 +17481,8 @@ class OnDisconnect {
|
|
|
19052
17481
|
return result;
|
|
19053
17482
|
}
|
|
19054
17483
|
set(value, onComplete) {
|
|
19055
|
-
require$$
|
|
19056
|
-
require$$
|
|
17484
|
+
require$$1$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
|
|
17485
|
+
require$$1$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
|
|
19057
17486
|
const result = this._delegate.set(value);
|
|
19058
17487
|
if (onComplete) {
|
|
19059
17488
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19061,8 +17490,8 @@ class OnDisconnect {
|
|
|
19061
17490
|
return result;
|
|
19062
17491
|
}
|
|
19063
17492
|
setWithPriority(value, priority, onComplete) {
|
|
19064
|
-
require$$
|
|
19065
|
-
require$$
|
|
17493
|
+
require$$1$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
|
|
17494
|
+
require$$1$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
|
|
19066
17495
|
const result = this._delegate.setWithPriority(value, priority);
|
|
19067
17496
|
if (onComplete) {
|
|
19068
17497
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19070,7 +17499,7 @@ class OnDisconnect {
|
|
|
19070
17499
|
return result;
|
|
19071
17500
|
}
|
|
19072
17501
|
update(objectToMerge, onComplete) {
|
|
19073
|
-
require$$
|
|
17502
|
+
require$$1$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
|
|
19074
17503
|
if (Array.isArray(objectToMerge)) {
|
|
19075
17504
|
const newObjectToMerge = {};
|
|
19076
17505
|
for (let i = 0; i < objectToMerge.length; ++i) {
|
|
@@ -19080,7 +17509,7 @@ class OnDisconnect {
|
|
|
19080
17509
|
warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
|
|
19081
17510
|
'existing data, or an Object with integer keys if you really do want to only update some of the children.');
|
|
19082
17511
|
}
|
|
19083
|
-
require$$
|
|
17512
|
+
require$$1$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
|
|
19084
17513
|
const result = this._delegate.update(objectToMerge);
|
|
19085
17514
|
if (onComplete) {
|
|
19086
17515
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19116,7 +17545,7 @@ class TransactionResult {
|
|
|
19116
17545
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19117
17546
|
// for end-users
|
|
19118
17547
|
toJSON() {
|
|
19119
|
-
require$$
|
|
17548
|
+
require$$1$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
|
|
19120
17549
|
return { committed: this.committed, snapshot: this.snapshot.toJSON() };
|
|
19121
17550
|
}
|
|
19122
17551
|
}
|
|
@@ -19153,7 +17582,7 @@ class DataSnapshot {
|
|
|
19153
17582
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
19154
17583
|
*/
|
|
19155
17584
|
val() {
|
|
19156
|
-
require$$
|
|
17585
|
+
require$$1$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
|
|
19157
17586
|
return this._delegate.val();
|
|
19158
17587
|
}
|
|
19159
17588
|
/**
|
|
@@ -19162,14 +17591,14 @@ class DataSnapshot {
|
|
|
19162
17591
|
* @returns JSON representation of the DataSnapshot contents, or null if empty.
|
|
19163
17592
|
*/
|
|
19164
17593
|
exportVal() {
|
|
19165
|
-
require$$
|
|
17594
|
+
require$$1$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
|
|
19166
17595
|
return this._delegate.exportVal();
|
|
19167
17596
|
}
|
|
19168
17597
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19169
17598
|
// for end-users
|
|
19170
17599
|
toJSON() {
|
|
19171
17600
|
// Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
|
|
19172
|
-
require$$
|
|
17601
|
+
require$$1$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
|
|
19173
17602
|
return this._delegate.toJSON();
|
|
19174
17603
|
}
|
|
19175
17604
|
/**
|
|
@@ -19178,7 +17607,7 @@ class DataSnapshot {
|
|
|
19178
17607
|
* @returns Whether the snapshot contains a non-null value, or is empty.
|
|
19179
17608
|
*/
|
|
19180
17609
|
exists() {
|
|
19181
|
-
require$$
|
|
17610
|
+
require$$1$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
|
|
19182
17611
|
return this._delegate.exists();
|
|
19183
17612
|
}
|
|
19184
17613
|
/**
|
|
@@ -19188,7 +17617,7 @@ class DataSnapshot {
|
|
|
19188
17617
|
* @returns DataSnapshot for child node.
|
|
19189
17618
|
*/
|
|
19190
17619
|
child(path) {
|
|
19191
|
-
require$$
|
|
17620
|
+
require$$1$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
|
|
19192
17621
|
// Ensure the childPath is a string (can be a number)
|
|
19193
17622
|
path = String(path);
|
|
19194
17623
|
_validatePathString('DataSnapshot.child', 'path', path, false);
|
|
@@ -19201,7 +17630,7 @@ class DataSnapshot {
|
|
|
19201
17630
|
* @returns Whether the child exists.
|
|
19202
17631
|
*/
|
|
19203
17632
|
hasChild(path) {
|
|
19204
|
-
require$$
|
|
17633
|
+
require$$1$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
|
|
19205
17634
|
_validatePathString('DataSnapshot.hasChild', 'path', path, false);
|
|
19206
17635
|
return this._delegate.hasChild(path);
|
|
19207
17636
|
}
|
|
@@ -19211,7 +17640,7 @@ class DataSnapshot {
|
|
|
19211
17640
|
* @returns The priority.
|
|
19212
17641
|
*/
|
|
19213
17642
|
getPriority() {
|
|
19214
|
-
require$$
|
|
17643
|
+
require$$1$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
|
|
19215
17644
|
return this._delegate.priority;
|
|
19216
17645
|
}
|
|
19217
17646
|
/**
|
|
@@ -19223,8 +17652,8 @@ class DataSnapshot {
|
|
|
19223
17652
|
* one of the child nodes.
|
|
19224
17653
|
*/
|
|
19225
17654
|
forEach(action) {
|
|
19226
|
-
require$$
|
|
19227
|
-
require$$
|
|
17655
|
+
require$$1$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
|
|
17656
|
+
require$$1$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
|
|
19228
17657
|
return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
|
|
19229
17658
|
}
|
|
19230
17659
|
/**
|
|
@@ -19232,7 +17661,7 @@ class DataSnapshot {
|
|
|
19232
17661
|
* @returns True if the DataSnapshot contains 1 or more child nodes.
|
|
19233
17662
|
*/
|
|
19234
17663
|
hasChildren() {
|
|
19235
|
-
require$$
|
|
17664
|
+
require$$1$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
|
|
19236
17665
|
return this._delegate.hasChildren();
|
|
19237
17666
|
}
|
|
19238
17667
|
get key() {
|
|
@@ -19243,7 +17672,7 @@ class DataSnapshot {
|
|
|
19243
17672
|
* @returns The number of children that this DataSnapshot contains.
|
|
19244
17673
|
*/
|
|
19245
17674
|
numChildren() {
|
|
19246
|
-
require$$
|
|
17675
|
+
require$$1$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
|
|
19247
17676
|
return this._delegate.size;
|
|
19248
17677
|
}
|
|
19249
17678
|
/**
|
|
@@ -19251,7 +17680,7 @@ class DataSnapshot {
|
|
|
19251
17680
|
* from.
|
|
19252
17681
|
*/
|
|
19253
17682
|
getRef() {
|
|
19254
|
-
require$$
|
|
17683
|
+
require$$1$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
|
|
19255
17684
|
return new Reference(this._database, this._delegate.ref);
|
|
19256
17685
|
}
|
|
19257
17686
|
get ref() {
|
|
@@ -19270,8 +17699,8 @@ class Query {
|
|
|
19270
17699
|
this._delegate = _delegate;
|
|
19271
17700
|
}
|
|
19272
17701
|
on(eventType, callback, cancelCallbackOrContext, context) {
|
|
19273
|
-
require$$
|
|
19274
|
-
require$$
|
|
17702
|
+
require$$1$3.validateArgCount('Query.on', 2, 4, arguments.length);
|
|
17703
|
+
require$$1$3.validateCallback('Query.on', 'callback', callback, false);
|
|
19275
17704
|
const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
|
|
19276
17705
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
19277
17706
|
callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
|
|
@@ -19296,16 +17725,16 @@ class Query {
|
|
|
19296
17725
|
onChildMoved_1(this._delegate, valueCallback, cancelCallback);
|
|
19297
17726
|
return callback;
|
|
19298
17727
|
default:
|
|
19299
|
-
throw new Error(require$$
|
|
17728
|
+
throw new Error(require$$1$3.errorPrefix('Query.on', 'eventType') +
|
|
19300
17729
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19301
17730
|
'"child_changed", or "child_moved".');
|
|
19302
17731
|
}
|
|
19303
17732
|
}
|
|
19304
17733
|
off(eventType, callback, context) {
|
|
19305
|
-
require$$
|
|
19306
|
-
validateEventType('Query.off', eventType
|
|
19307
|
-
require$$
|
|
19308
|
-
require$$
|
|
17734
|
+
require$$1$3.validateArgCount('Query.off', 0, 3, arguments.length);
|
|
17735
|
+
validateEventType('Query.off', eventType);
|
|
17736
|
+
require$$1$3.validateCallback('Query.off', 'callback', callback, true);
|
|
17737
|
+
require$$1$3.validateContextObject('Query.off', 'context', context, true);
|
|
19309
17738
|
if (callback) {
|
|
19310
17739
|
const valueCallback = () => { };
|
|
19311
17740
|
valueCallback.userCallback = callback;
|
|
@@ -19328,10 +17757,10 @@ class Query {
|
|
|
19328
17757
|
* Attaches a listener, waits for the first event, and then removes the listener
|
|
19329
17758
|
*/
|
|
19330
17759
|
once(eventType, callback, failureCallbackOrContext, context) {
|
|
19331
|
-
require$$
|
|
19332
|
-
require$$
|
|
17760
|
+
require$$1$3.validateArgCount('Query.once', 1, 4, arguments.length);
|
|
17761
|
+
require$$1$3.validateCallback('Query.once', 'callback', callback, true);
|
|
19333
17762
|
const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
|
|
19334
|
-
const deferred = new require$$
|
|
17763
|
+
const deferred = new require$$1$3.Deferred();
|
|
19335
17764
|
const valueCallback = (expSnapshot, previousChildName) => {
|
|
19336
17765
|
const result = new DataSnapshot(this.database, expSnapshot);
|
|
19337
17766
|
if (callback) {
|
|
@@ -19374,7 +17803,7 @@ class Query {
|
|
|
19374
17803
|
});
|
|
19375
17804
|
break;
|
|
19376
17805
|
default:
|
|
19377
|
-
throw new Error(require$$
|
|
17806
|
+
throw new Error(require$$1$3.errorPrefix('Query.once', 'eventType') +
|
|
19378
17807
|
'must be a valid event type = "value", "child_added", "child_removed", ' +
|
|
19379
17808
|
'"child_changed", or "child_moved".');
|
|
19380
17809
|
}
|
|
@@ -19384,58 +17813,58 @@ class Query {
|
|
|
19384
17813
|
* Set a limit and anchor it to the start of the window.
|
|
19385
17814
|
*/
|
|
19386
17815
|
limitToFirst(limit) {
|
|
19387
|
-
require$$
|
|
17816
|
+
require$$1$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
|
|
19388
17817
|
return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
|
|
19389
17818
|
}
|
|
19390
17819
|
/**
|
|
19391
17820
|
* Set a limit and anchor it to the end of the window.
|
|
19392
17821
|
*/
|
|
19393
17822
|
limitToLast(limit) {
|
|
19394
|
-
require$$
|
|
17823
|
+
require$$1$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
|
|
19395
17824
|
return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
|
|
19396
17825
|
}
|
|
19397
17826
|
/**
|
|
19398
17827
|
* Given a child path, return a new query ordered by the specified grandchild path.
|
|
19399
17828
|
*/
|
|
19400
17829
|
orderByChild(path) {
|
|
19401
|
-
require$$
|
|
17830
|
+
require$$1$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
|
|
19402
17831
|
return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
|
|
19403
17832
|
}
|
|
19404
17833
|
/**
|
|
19405
17834
|
* Return a new query ordered by the KeyIndex
|
|
19406
17835
|
*/
|
|
19407
17836
|
orderByKey() {
|
|
19408
|
-
require$$
|
|
17837
|
+
require$$1$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
|
|
19409
17838
|
return new Query(this.database, query_1(this._delegate, orderByKey_1()));
|
|
19410
17839
|
}
|
|
19411
17840
|
/**
|
|
19412
17841
|
* Return a new query ordered by the PriorityIndex
|
|
19413
17842
|
*/
|
|
19414
17843
|
orderByPriority() {
|
|
19415
|
-
require$$
|
|
17844
|
+
require$$1$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
|
|
19416
17845
|
return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
|
|
19417
17846
|
}
|
|
19418
17847
|
/**
|
|
19419
17848
|
* Return a new query ordered by the ValueIndex
|
|
19420
17849
|
*/
|
|
19421
17850
|
orderByValue() {
|
|
19422
|
-
require$$
|
|
17851
|
+
require$$1$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
|
|
19423
17852
|
return new Query(this.database, query_1(this._delegate, orderByValue_1()));
|
|
19424
17853
|
}
|
|
19425
17854
|
startAt(value = null, name) {
|
|
19426
|
-
require$$
|
|
17855
|
+
require$$1$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
|
|
19427
17856
|
return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
|
|
19428
17857
|
}
|
|
19429
17858
|
startAfter(value = null, name) {
|
|
19430
|
-
require$$
|
|
17859
|
+
require$$1$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
|
|
19431
17860
|
return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
|
|
19432
17861
|
}
|
|
19433
17862
|
endAt(value = null, name) {
|
|
19434
|
-
require$$
|
|
17863
|
+
require$$1$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
|
|
19435
17864
|
return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
|
|
19436
17865
|
}
|
|
19437
17866
|
endBefore(value = null, name) {
|
|
19438
|
-
require$$
|
|
17867
|
+
require$$1$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
|
|
19439
17868
|
return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
|
|
19440
17869
|
}
|
|
19441
17870
|
/**
|
|
@@ -19443,28 +17872,28 @@ class Query {
|
|
|
19443
17872
|
* the specified name.
|
|
19444
17873
|
*/
|
|
19445
17874
|
equalTo(value, name) {
|
|
19446
|
-
require$$
|
|
17875
|
+
require$$1$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
|
|
19447
17876
|
return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
|
|
19448
17877
|
}
|
|
19449
17878
|
/**
|
|
19450
17879
|
* @returns URL for this location.
|
|
19451
17880
|
*/
|
|
19452
17881
|
toString() {
|
|
19453
|
-
require$$
|
|
17882
|
+
require$$1$3.validateArgCount('Query.toString', 0, 0, arguments.length);
|
|
19454
17883
|
return this._delegate.toString();
|
|
19455
17884
|
}
|
|
19456
17885
|
// Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
|
|
19457
17886
|
// for end-users.
|
|
19458
17887
|
toJSON() {
|
|
19459
17888
|
// An optional spacer argument is unnecessary for a string.
|
|
19460
|
-
require$$
|
|
17889
|
+
require$$1$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
|
|
19461
17890
|
return this._delegate.toJSON();
|
|
19462
17891
|
}
|
|
19463
17892
|
/**
|
|
19464
17893
|
* Return true if this query and the provided query are equivalent; otherwise, return false.
|
|
19465
17894
|
*/
|
|
19466
17895
|
isEqual(other) {
|
|
19467
|
-
require$$
|
|
17896
|
+
require$$1$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
|
|
19468
17897
|
if (!(other instanceof Query)) {
|
|
19469
17898
|
const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
|
|
19470
17899
|
throw new Error(error);
|
|
@@ -19480,9 +17909,9 @@ class Query {
|
|
|
19480
17909
|
const ret = { cancel: undefined, context: undefined };
|
|
19481
17910
|
if (cancelOrContext && context) {
|
|
19482
17911
|
ret.cancel = cancelOrContext;
|
|
19483
|
-
require$$
|
|
17912
|
+
require$$1$3.validateCallback(fnName, 'cancel', ret.cancel, true);
|
|
19484
17913
|
ret.context = context;
|
|
19485
|
-
require$$
|
|
17914
|
+
require$$1$3.validateContextObject(fnName, 'context', ret.context, true);
|
|
19486
17915
|
}
|
|
19487
17916
|
else if (cancelOrContext) {
|
|
19488
17917
|
// we have either a cancel callback or a context.
|
|
@@ -19494,7 +17923,7 @@ class Query {
|
|
|
19494
17923
|
ret.cancel = cancelOrContext;
|
|
19495
17924
|
}
|
|
19496
17925
|
else {
|
|
19497
|
-
throw new Error(require$$
|
|
17926
|
+
throw new Error(require$$1$3.errorPrefix(fnName, 'cancelOrContext') +
|
|
19498
17927
|
' must either be a cancel callback or a context object.');
|
|
19499
17928
|
}
|
|
19500
17929
|
}
|
|
@@ -19519,11 +17948,11 @@ class Reference extends Query {
|
|
|
19519
17948
|
}
|
|
19520
17949
|
/** @returns {?string} */
|
|
19521
17950
|
getKey() {
|
|
19522
|
-
require$$
|
|
17951
|
+
require$$1$3.validateArgCount('Reference.key', 0, 0, arguments.length);
|
|
19523
17952
|
return this._delegate.key;
|
|
19524
17953
|
}
|
|
19525
17954
|
child(pathString) {
|
|
19526
|
-
require$$
|
|
17955
|
+
require$$1$3.validateArgCount('Reference.child', 1, 1, arguments.length);
|
|
19527
17956
|
if (typeof pathString === 'number') {
|
|
19528
17957
|
pathString = String(pathString);
|
|
19529
17958
|
}
|
|
@@ -19531,18 +17960,18 @@ class Reference extends Query {
|
|
|
19531
17960
|
}
|
|
19532
17961
|
/** @returns {?Reference} */
|
|
19533
17962
|
getParent() {
|
|
19534
|
-
require$$
|
|
17963
|
+
require$$1$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
|
|
19535
17964
|
const parent = this._delegate.parent;
|
|
19536
17965
|
return parent ? new Reference(this.database, parent) : null;
|
|
19537
17966
|
}
|
|
19538
17967
|
/** @returns {!Reference} */
|
|
19539
17968
|
getRoot() {
|
|
19540
|
-
require$$
|
|
17969
|
+
require$$1$3.validateArgCount('Reference.root', 0, 0, arguments.length);
|
|
19541
17970
|
return new Reference(this.database, this._delegate.root);
|
|
19542
17971
|
}
|
|
19543
17972
|
set(newVal, onComplete) {
|
|
19544
|
-
require$$
|
|
19545
|
-
require$$
|
|
17973
|
+
require$$1$3.validateArgCount('Reference.set', 1, 2, arguments.length);
|
|
17974
|
+
require$$1$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
|
|
19546
17975
|
const result = set_1(this._delegate, newVal);
|
|
19547
17976
|
if (onComplete) {
|
|
19548
17977
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19550,7 +17979,7 @@ class Reference extends Query {
|
|
|
19550
17979
|
return result;
|
|
19551
17980
|
}
|
|
19552
17981
|
update(values, onComplete) {
|
|
19553
|
-
require$$
|
|
17982
|
+
require$$1$3.validateArgCount('Reference.update', 1, 2, arguments.length);
|
|
19554
17983
|
if (Array.isArray(values)) {
|
|
19555
17984
|
const newObjectToMerge = {};
|
|
19556
17985
|
for (let i = 0; i < values.length; ++i) {
|
|
@@ -19563,7 +17992,7 @@ class Reference extends Query {
|
|
|
19563
17992
|
'only update some of the children.');
|
|
19564
17993
|
}
|
|
19565
17994
|
_validateWritablePath('Reference.update', this._delegate._path);
|
|
19566
|
-
require$$
|
|
17995
|
+
require$$1$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
|
|
19567
17996
|
const result = update_1(this._delegate, values);
|
|
19568
17997
|
if (onComplete) {
|
|
19569
17998
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19571,8 +18000,8 @@ class Reference extends Query {
|
|
|
19571
18000
|
return result;
|
|
19572
18001
|
}
|
|
19573
18002
|
setWithPriority(newVal, newPriority, onComplete) {
|
|
19574
|
-
require$$
|
|
19575
|
-
require$$
|
|
18003
|
+
require$$1$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
|
|
18004
|
+
require$$1$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
|
|
19576
18005
|
const result = setWithPriority_1(this._delegate, newVal, newPriority);
|
|
19577
18006
|
if (onComplete) {
|
|
19578
18007
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19580,8 +18009,8 @@ class Reference extends Query {
|
|
|
19580
18009
|
return result;
|
|
19581
18010
|
}
|
|
19582
18011
|
remove(onComplete) {
|
|
19583
|
-
require$$
|
|
19584
|
-
require$$
|
|
18012
|
+
require$$1$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
|
|
18013
|
+
require$$1$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
|
|
19585
18014
|
const result = remove_1(this._delegate);
|
|
19586
18015
|
if (onComplete) {
|
|
19587
18016
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19589,10 +18018,10 @@ class Reference extends Query {
|
|
|
19589
18018
|
return result;
|
|
19590
18019
|
}
|
|
19591
18020
|
transaction(transactionUpdate, onComplete, applyLocally) {
|
|
19592
|
-
require$$
|
|
19593
|
-
require$$
|
|
19594
|
-
require$$
|
|
19595
|
-
validateBoolean('Reference.transaction', 'applyLocally', applyLocally
|
|
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);
|
|
18024
|
+
validateBoolean('Reference.transaction', 'applyLocally', applyLocally);
|
|
19596
18025
|
const result = runTransaction_1(this._delegate, transactionUpdate, {
|
|
19597
18026
|
applyLocally
|
|
19598
18027
|
}).then(transactionResult => new TransactionResult(transactionResult.committed, new DataSnapshot(this.database, transactionResult.snapshot)));
|
|
@@ -19602,8 +18031,8 @@ class Reference extends Query {
|
|
|
19602
18031
|
return result;
|
|
19603
18032
|
}
|
|
19604
18033
|
setPriority(priority, onComplete) {
|
|
19605
|
-
require$$
|
|
19606
|
-
require$$
|
|
18034
|
+
require$$1$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
|
|
18035
|
+
require$$1$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
|
|
19607
18036
|
const result = setPriority_1(this._delegate, priority);
|
|
19608
18037
|
if (onComplete) {
|
|
19609
18038
|
result.then(() => onComplete(null), error => onComplete(error));
|
|
@@ -19611,8 +18040,8 @@ class Reference extends Query {
|
|
|
19611
18040
|
return result;
|
|
19612
18041
|
}
|
|
19613
18042
|
push(value, onComplete) {
|
|
19614
|
-
require$$
|
|
19615
|
-
require$$
|
|
18043
|
+
require$$1$3.validateArgCount('Reference.push', 0, 2, arguments.length);
|
|
18044
|
+
require$$1$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
|
|
19616
18045
|
const expPromise = push_1(this._delegate, value);
|
|
19617
18046
|
const promise = expPromise.then(expRef => new Reference(this.database, expRef));
|
|
19618
18047
|
if (onComplete) {
|
|
@@ -19654,6 +18083,7 @@ class Reference extends Query {
|
|
|
19654
18083
|
* See the License for the specific language governing permissions and
|
|
19655
18084
|
* limitations under the License.
|
|
19656
18085
|
*/
|
|
18086
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
19657
18087
|
/**
|
|
19658
18088
|
* Class representing a firebase database.
|
|
19659
18089
|
*/
|
|
@@ -19683,7 +18113,7 @@ class Database {
|
|
|
19683
18113
|
connectDatabaseEmulator_1(this._delegate, host, port, options);
|
|
19684
18114
|
}
|
|
19685
18115
|
ref(path) {
|
|
19686
|
-
require$$
|
|
18116
|
+
require$$1$3.validateArgCount('database.ref', 0, 1, arguments.length);
|
|
19687
18117
|
if (path instanceof Reference) {
|
|
19688
18118
|
const childRef = refFromURL_1(this._delegate, path.toString());
|
|
19689
18119
|
return new Reference(this, childRef);
|
|
@@ -19701,17 +18131,17 @@ class Database {
|
|
|
19701
18131
|
*/
|
|
19702
18132
|
refFromURL(url) {
|
|
19703
18133
|
const apiName = 'database.refFromURL';
|
|
19704
|
-
require$$
|
|
18134
|
+
require$$1$3.validateArgCount(apiName, 1, 1, arguments.length);
|
|
19705
18135
|
const childRef = refFromURL_1(this._delegate, url);
|
|
19706
18136
|
return new Reference(this, childRef);
|
|
19707
18137
|
}
|
|
19708
18138
|
// Make individual repo go offline.
|
|
19709
18139
|
goOffline() {
|
|
19710
|
-
require$$
|
|
18140
|
+
require$$1$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
|
|
19711
18141
|
return goOffline_1(this._delegate);
|
|
19712
18142
|
}
|
|
19713
18143
|
goOnline() {
|
|
19714
|
-
require$$
|
|
18144
|
+
require$$1$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
|
|
19715
18145
|
return goOnline_1(this._delegate);
|
|
19716
18146
|
}
|
|
19717
18147
|
}
|
|
@@ -19731,17 +18161,17 @@ Database.ServerValue = {
|
|
|
19731
18161
|
*/
|
|
19732
18162
|
function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
|
|
19733
18163
|
_setSDKVersion(version);
|
|
19734
|
-
const container = new require$$
|
|
18164
|
+
const container = new require$$4.ComponentContainer('database-standalone');
|
|
19735
18165
|
/**
|
|
19736
18166
|
* ComponentContainer('database-standalone') is just a placeholder that doesn't perform
|
|
19737
18167
|
* any actual function.
|
|
19738
18168
|
*/
|
|
19739
|
-
const authProvider = new require$$
|
|
19740
|
-
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 */));
|
|
19741
18171
|
let appCheckProvider = undefined;
|
|
19742
18172
|
if (customAppCheckImpl) {
|
|
19743
|
-
appCheckProvider = new require$$
|
|
19744
|
-
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 */));
|
|
19745
18175
|
}
|
|
19746
18176
|
return {
|
|
19747
18177
|
instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
|
|
@@ -19750,8 +18180,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
|
|
|
19750
18180
|
}
|
|
19751
18181
|
|
|
19752
18182
|
var INTERNAL = /*#__PURE__*/Object.freeze({
|
|
19753
|
-
|
|
19754
|
-
|
|
18183
|
+
__proto__: null,
|
|
18184
|
+
initStandalone: initStandalone$1
|
|
19755
18185
|
});
|
|
19756
18186
|
|
|
19757
18187
|
/**
|
|
@@ -19781,7 +18211,7 @@ const ServerValue = Database.ServerValue;
|
|
|
19781
18211
|
* @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
|
|
19782
18212
|
*/
|
|
19783
18213
|
function initStandalone(app, url, version, nodeAdmin = true) {
|
|
19784
|
-
require$$
|
|
18214
|
+
require$$1$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
|
|
19785
18215
|
return initStandalone$1({
|
|
19786
18216
|
app,
|
|
19787
18217
|
url,
|