reactfire 4.0.0 → 4.0.1-exp.f6d2351

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.
@@ -1,2089 +0,0 @@
1
- import { useMemo, createElement, useContext, createContext, version as version$1, Fragment, useState, useEffect, Suspense, useLayoutEffect } from 'react';
2
- import { user } from 'rxfire/auth';
3
- import { from, of, empty, Subject, Observable } from 'rxjs';
4
- import { switchMap, map, tap, catchError, shareReplay, first } from 'rxjs/operators';
5
- import { getApps, registerVersion, initializeApp } from 'firebase/app';
6
- import { object, objectVal, list, listVal } from 'rxfire/database';
7
- import { doc, docData, fromRef, collectionData } from 'rxfire/firestore';
8
- import { queryEqual } from 'firebase/firestore';
9
- import { ensureInitialized, getValue as getValue$1, getString as getString$1, getNumber as getNumber$1, getBoolean as getBoolean$1, getAll as getAll$1 } from 'firebase/remote-config';
10
- import { getDownloadURL } from 'rxfire/storage';
11
- import { ref } from 'firebase/storage';
12
-
13
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
- try {
15
- var info = gen[key](arg);
16
- var value = info.value;
17
- } catch (error) {
18
- reject(error);
19
- return;
20
- }
21
-
22
- if (info.done) {
23
- resolve(value);
24
- } else {
25
- Promise.resolve(value).then(_next, _throw);
26
- }
27
- }
28
-
29
- function _asyncToGenerator(fn) {
30
- return function () {
31
- var self = this,
32
- args = arguments;
33
- return new Promise(function (resolve, reject) {
34
- var gen = fn.apply(self, args);
35
-
36
- function _next(value) {
37
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
38
- }
39
-
40
- function _throw(err) {
41
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
42
- }
43
-
44
- _next(undefined);
45
- });
46
- };
47
- }
48
-
49
- function _defineProperties(target, props) {
50
- for (var i = 0; i < props.length; i++) {
51
- var descriptor = props[i];
52
- descriptor.enumerable = descriptor.enumerable || false;
53
- descriptor.configurable = true;
54
- if ("value" in descriptor) descriptor.writable = true;
55
- Object.defineProperty(target, descriptor.key, descriptor);
56
- }
57
- }
58
-
59
- function _createClass(Constructor, protoProps, staticProps) {
60
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
61
- if (staticProps) _defineProperties(Constructor, staticProps);
62
- return Constructor;
63
- }
64
-
65
- function _extends() {
66
- _extends = Object.assign || function (target) {
67
- for (var i = 1; i < arguments.length; i++) {
68
- var source = arguments[i];
69
-
70
- for (var key in source) {
71
- if (Object.prototype.hasOwnProperty.call(source, key)) {
72
- target[key] = source[key];
73
- }
74
- }
75
- }
76
-
77
- return target;
78
- };
79
-
80
- return _extends.apply(this, arguments);
81
- }
82
-
83
- function _inheritsLoose(subClass, superClass) {
84
- subClass.prototype = Object.create(superClass.prototype);
85
- subClass.prototype.constructor = subClass;
86
-
87
- _setPrototypeOf(subClass, superClass);
88
- }
89
-
90
- function _getPrototypeOf(o) {
91
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
92
- return o.__proto__ || Object.getPrototypeOf(o);
93
- };
94
- return _getPrototypeOf(o);
95
- }
96
-
97
- function _setPrototypeOf(o, p) {
98
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
99
- o.__proto__ = p;
100
- return o;
101
- };
102
-
103
- return _setPrototypeOf(o, p);
104
- }
105
-
106
- function _isNativeReflectConstruct() {
107
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
108
- if (Reflect.construct.sham) return false;
109
- if (typeof Proxy === "function") return true;
110
-
111
- try {
112
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
113
- return true;
114
- } catch (e) {
115
- return false;
116
- }
117
- }
118
-
119
- function _construct(Parent, args, Class) {
120
- if (_isNativeReflectConstruct()) {
121
- _construct = Reflect.construct;
122
- } else {
123
- _construct = function _construct(Parent, args, Class) {
124
- var a = [null];
125
- a.push.apply(a, args);
126
- var Constructor = Function.bind.apply(Parent, a);
127
- var instance = new Constructor();
128
- if (Class) _setPrototypeOf(instance, Class.prototype);
129
- return instance;
130
- };
131
- }
132
-
133
- return _construct.apply(null, arguments);
134
- }
135
-
136
- function _isNativeFunction(fn) {
137
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
138
- }
139
-
140
- function _wrapNativeSuper(Class) {
141
- var _cache = typeof Map === "function" ? new Map() : undefined;
142
-
143
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
144
- if (Class === null || !_isNativeFunction(Class)) return Class;
145
-
146
- if (typeof Class !== "function") {
147
- throw new TypeError("Super expression must either be null or a function");
148
- }
149
-
150
- if (typeof _cache !== "undefined") {
151
- if (_cache.has(Class)) return _cache.get(Class);
152
-
153
- _cache.set(Class, Wrapper);
154
- }
155
-
156
- function Wrapper() {
157
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
158
- }
159
-
160
- Wrapper.prototype = Object.create(Class.prototype, {
161
- constructor: {
162
- value: Wrapper,
163
- enumerable: false,
164
- writable: true,
165
- configurable: true
166
- }
167
- });
168
- return _setPrototypeOf(Wrapper, Class);
169
- };
170
-
171
- return _wrapNativeSuper(Class);
172
- }
173
-
174
- function _objectWithoutPropertiesLoose(source, excluded) {
175
- if (source == null) return {};
176
- var target = {};
177
- var sourceKeys = Object.keys(source);
178
- var key, i;
179
-
180
- for (i = 0; i < sourceKeys.length; i++) {
181
- key = sourceKeys[i];
182
- if (excluded.indexOf(key) >= 0) continue;
183
- target[key] = source[key];
184
- }
185
-
186
- return target;
187
- }
188
-
189
- function _assertThisInitialized(self) {
190
- if (self === void 0) {
191
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
192
- }
193
-
194
- return self;
195
- }
196
-
197
- function createCommonjsModule(fn, module) {
198
- return module = { exports: {} }, fn(module, module.exports), module.exports;
199
- }
200
-
201
- var runtime_1 = createCommonjsModule(function (module) {
202
- /**
203
- * Copyright (c) 2014-present, Facebook, Inc.
204
- *
205
- * This source code is licensed under the MIT license found in the
206
- * LICENSE file in the root directory of this source tree.
207
- */
208
-
209
- var runtime = (function (exports) {
210
-
211
- var Op = Object.prototype;
212
- var hasOwn = Op.hasOwnProperty;
213
- var undefined$1; // More compressible than void 0.
214
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
215
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
216
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
217
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
218
-
219
- function define(obj, key, value) {
220
- Object.defineProperty(obj, key, {
221
- value: value,
222
- enumerable: true,
223
- configurable: true,
224
- writable: true
225
- });
226
- return obj[key];
227
- }
228
- try {
229
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
230
- define({}, "");
231
- } catch (err) {
232
- define = function(obj, key, value) {
233
- return obj[key] = value;
234
- };
235
- }
236
-
237
- function wrap(innerFn, outerFn, self, tryLocsList) {
238
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
239
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
240
- var generator = Object.create(protoGenerator.prototype);
241
- var context = new Context(tryLocsList || []);
242
-
243
- // The ._invoke method unifies the implementations of the .next,
244
- // .throw, and .return methods.
245
- generator._invoke = makeInvokeMethod(innerFn, self, context);
246
-
247
- return generator;
248
- }
249
- exports.wrap = wrap;
250
-
251
- // Try/catch helper to minimize deoptimizations. Returns a completion
252
- // record like context.tryEntries[i].completion. This interface could
253
- // have been (and was previously) designed to take a closure to be
254
- // invoked without arguments, but in all the cases we care about we
255
- // already have an existing method we want to call, so there's no need
256
- // to create a new function object. We can even get away with assuming
257
- // the method takes exactly one argument, since that happens to be true
258
- // in every case, so we don't have to touch the arguments object. The
259
- // only additional allocation required is the completion record, which
260
- // has a stable shape and so hopefully should be cheap to allocate.
261
- function tryCatch(fn, obj, arg) {
262
- try {
263
- return { type: "normal", arg: fn.call(obj, arg) };
264
- } catch (err) {
265
- return { type: "throw", arg: err };
266
- }
267
- }
268
-
269
- var GenStateSuspendedStart = "suspendedStart";
270
- var GenStateSuspendedYield = "suspendedYield";
271
- var GenStateExecuting = "executing";
272
- var GenStateCompleted = "completed";
273
-
274
- // Returning this object from the innerFn has the same effect as
275
- // breaking out of the dispatch switch statement.
276
- var ContinueSentinel = {};
277
-
278
- // Dummy constructor functions that we use as the .constructor and
279
- // .constructor.prototype properties for functions that return Generator
280
- // objects. For full spec compliance, you may wish to configure your
281
- // minifier not to mangle the names of these two functions.
282
- function Generator() {}
283
- function GeneratorFunction() {}
284
- function GeneratorFunctionPrototype() {}
285
-
286
- // This is a polyfill for %IteratorPrototype% for environments that
287
- // don't natively support it.
288
- var IteratorPrototype = {};
289
- define(IteratorPrototype, iteratorSymbol, function () {
290
- return this;
291
- });
292
-
293
- var getProto = Object.getPrototypeOf;
294
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
295
- if (NativeIteratorPrototype &&
296
- NativeIteratorPrototype !== Op &&
297
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
298
- // This environment has a native %IteratorPrototype%; use it instead
299
- // of the polyfill.
300
- IteratorPrototype = NativeIteratorPrototype;
301
- }
302
-
303
- var Gp = GeneratorFunctionPrototype.prototype =
304
- Generator.prototype = Object.create(IteratorPrototype);
305
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
306
- define(Gp, "constructor", GeneratorFunctionPrototype);
307
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
308
- GeneratorFunction.displayName = define(
309
- GeneratorFunctionPrototype,
310
- toStringTagSymbol,
311
- "GeneratorFunction"
312
- );
313
-
314
- // Helper for defining the .next, .throw, and .return methods of the
315
- // Iterator interface in terms of a single ._invoke method.
316
- function defineIteratorMethods(prototype) {
317
- ["next", "throw", "return"].forEach(function(method) {
318
- define(prototype, method, function(arg) {
319
- return this._invoke(method, arg);
320
- });
321
- });
322
- }
323
-
324
- exports.isGeneratorFunction = function(genFun) {
325
- var ctor = typeof genFun === "function" && genFun.constructor;
326
- return ctor
327
- ? ctor === GeneratorFunction ||
328
- // For the native GeneratorFunction constructor, the best we can
329
- // do is to check its .name property.
330
- (ctor.displayName || ctor.name) === "GeneratorFunction"
331
- : false;
332
- };
333
-
334
- exports.mark = function(genFun) {
335
- if (Object.setPrototypeOf) {
336
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
337
- } else {
338
- genFun.__proto__ = GeneratorFunctionPrototype;
339
- define(genFun, toStringTagSymbol, "GeneratorFunction");
340
- }
341
- genFun.prototype = Object.create(Gp);
342
- return genFun;
343
- };
344
-
345
- // Within the body of any async function, `await x` is transformed to
346
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
347
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
348
- // meant to be awaited.
349
- exports.awrap = function(arg) {
350
- return { __await: arg };
351
- };
352
-
353
- function AsyncIterator(generator, PromiseImpl) {
354
- function invoke(method, arg, resolve, reject) {
355
- var record = tryCatch(generator[method], generator, arg);
356
- if (record.type === "throw") {
357
- reject(record.arg);
358
- } else {
359
- var result = record.arg;
360
- var value = result.value;
361
- if (value &&
362
- typeof value === "object" &&
363
- hasOwn.call(value, "__await")) {
364
- return PromiseImpl.resolve(value.__await).then(function(value) {
365
- invoke("next", value, resolve, reject);
366
- }, function(err) {
367
- invoke("throw", err, resolve, reject);
368
- });
369
- }
370
-
371
- return PromiseImpl.resolve(value).then(function(unwrapped) {
372
- // When a yielded Promise is resolved, its final value becomes
373
- // the .value of the Promise<{value,done}> result for the
374
- // current iteration.
375
- result.value = unwrapped;
376
- resolve(result);
377
- }, function(error) {
378
- // If a rejected Promise was yielded, throw the rejection back
379
- // into the async generator function so it can be handled there.
380
- return invoke("throw", error, resolve, reject);
381
- });
382
- }
383
- }
384
-
385
- var previousPromise;
386
-
387
- function enqueue(method, arg) {
388
- function callInvokeWithMethodAndArg() {
389
- return new PromiseImpl(function(resolve, reject) {
390
- invoke(method, arg, resolve, reject);
391
- });
392
- }
393
-
394
- return previousPromise =
395
- // If enqueue has been called before, then we want to wait until
396
- // all previous Promises have been resolved before calling invoke,
397
- // so that results are always delivered in the correct order. If
398
- // enqueue has not been called before, then it is important to
399
- // call invoke immediately, without waiting on a callback to fire,
400
- // so that the async generator function has the opportunity to do
401
- // any necessary setup in a predictable way. This predictability
402
- // is why the Promise constructor synchronously invokes its
403
- // executor callback, and why async functions synchronously
404
- // execute code before the first await. Since we implement simple
405
- // async functions in terms of async generators, it is especially
406
- // important to get this right, even though it requires care.
407
- previousPromise ? previousPromise.then(
408
- callInvokeWithMethodAndArg,
409
- // Avoid propagating failures to Promises returned by later
410
- // invocations of the iterator.
411
- callInvokeWithMethodAndArg
412
- ) : callInvokeWithMethodAndArg();
413
- }
414
-
415
- // Define the unified helper method that is used to implement .next,
416
- // .throw, and .return (see defineIteratorMethods).
417
- this._invoke = enqueue;
418
- }
419
-
420
- defineIteratorMethods(AsyncIterator.prototype);
421
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
422
- return this;
423
- });
424
- exports.AsyncIterator = AsyncIterator;
425
-
426
- // Note that simple async functions are implemented on top of
427
- // AsyncIterator objects; they just return a Promise for the value of
428
- // the final result produced by the iterator.
429
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
430
- if (PromiseImpl === void 0) PromiseImpl = Promise;
431
-
432
- var iter = new AsyncIterator(
433
- wrap(innerFn, outerFn, self, tryLocsList),
434
- PromiseImpl
435
- );
436
-
437
- return exports.isGeneratorFunction(outerFn)
438
- ? iter // If outerFn is a generator, return the full iterator.
439
- : iter.next().then(function(result) {
440
- return result.done ? result.value : iter.next();
441
- });
442
- };
443
-
444
- function makeInvokeMethod(innerFn, self, context) {
445
- var state = GenStateSuspendedStart;
446
-
447
- return function invoke(method, arg) {
448
- if (state === GenStateExecuting) {
449
- throw new Error("Generator is already running");
450
- }
451
-
452
- if (state === GenStateCompleted) {
453
- if (method === "throw") {
454
- throw arg;
455
- }
456
-
457
- // Be forgiving, per 25.3.3.3.3 of the spec:
458
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
459
- return doneResult();
460
- }
461
-
462
- context.method = method;
463
- context.arg = arg;
464
-
465
- while (true) {
466
- var delegate = context.delegate;
467
- if (delegate) {
468
- var delegateResult = maybeInvokeDelegate(delegate, context);
469
- if (delegateResult) {
470
- if (delegateResult === ContinueSentinel) continue;
471
- return delegateResult;
472
- }
473
- }
474
-
475
- if (context.method === "next") {
476
- // Setting context._sent for legacy support of Babel's
477
- // function.sent implementation.
478
- context.sent = context._sent = context.arg;
479
-
480
- } else if (context.method === "throw") {
481
- if (state === GenStateSuspendedStart) {
482
- state = GenStateCompleted;
483
- throw context.arg;
484
- }
485
-
486
- context.dispatchException(context.arg);
487
-
488
- } else if (context.method === "return") {
489
- context.abrupt("return", context.arg);
490
- }
491
-
492
- state = GenStateExecuting;
493
-
494
- var record = tryCatch(innerFn, self, context);
495
- if (record.type === "normal") {
496
- // If an exception is thrown from innerFn, we leave state ===
497
- // GenStateExecuting and loop back for another invocation.
498
- state = context.done
499
- ? GenStateCompleted
500
- : GenStateSuspendedYield;
501
-
502
- if (record.arg === ContinueSentinel) {
503
- continue;
504
- }
505
-
506
- return {
507
- value: record.arg,
508
- done: context.done
509
- };
510
-
511
- } else if (record.type === "throw") {
512
- state = GenStateCompleted;
513
- // Dispatch the exception by looping back around to the
514
- // context.dispatchException(context.arg) call above.
515
- context.method = "throw";
516
- context.arg = record.arg;
517
- }
518
- }
519
- };
520
- }
521
-
522
- // Call delegate.iterator[context.method](context.arg) and handle the
523
- // result, either by returning a { value, done } result from the
524
- // delegate iterator, or by modifying context.method and context.arg,
525
- // setting context.delegate to null, and returning the ContinueSentinel.
526
- function maybeInvokeDelegate(delegate, context) {
527
- var method = delegate.iterator[context.method];
528
- if (method === undefined$1) {
529
- // A .throw or .return when the delegate iterator has no .throw
530
- // method always terminates the yield* loop.
531
- context.delegate = null;
532
-
533
- if (context.method === "throw") {
534
- // Note: ["return"] must be used for ES3 parsing compatibility.
535
- if (delegate.iterator["return"]) {
536
- // If the delegate iterator has a return method, give it a
537
- // chance to clean up.
538
- context.method = "return";
539
- context.arg = undefined$1;
540
- maybeInvokeDelegate(delegate, context);
541
-
542
- if (context.method === "throw") {
543
- // If maybeInvokeDelegate(context) changed context.method from
544
- // "return" to "throw", let that override the TypeError below.
545
- return ContinueSentinel;
546
- }
547
- }
548
-
549
- context.method = "throw";
550
- context.arg = new TypeError(
551
- "The iterator does not provide a 'throw' method");
552
- }
553
-
554
- return ContinueSentinel;
555
- }
556
-
557
- var record = tryCatch(method, delegate.iterator, context.arg);
558
-
559
- if (record.type === "throw") {
560
- context.method = "throw";
561
- context.arg = record.arg;
562
- context.delegate = null;
563
- return ContinueSentinel;
564
- }
565
-
566
- var info = record.arg;
567
-
568
- if (! info) {
569
- context.method = "throw";
570
- context.arg = new TypeError("iterator result is not an object");
571
- context.delegate = null;
572
- return ContinueSentinel;
573
- }
574
-
575
- if (info.done) {
576
- // Assign the result of the finished delegate to the temporary
577
- // variable specified by delegate.resultName (see delegateYield).
578
- context[delegate.resultName] = info.value;
579
-
580
- // Resume execution at the desired location (see delegateYield).
581
- context.next = delegate.nextLoc;
582
-
583
- // If context.method was "throw" but the delegate handled the
584
- // exception, let the outer generator proceed normally. If
585
- // context.method was "next", forget context.arg since it has been
586
- // "consumed" by the delegate iterator. If context.method was
587
- // "return", allow the original .return call to continue in the
588
- // outer generator.
589
- if (context.method !== "return") {
590
- context.method = "next";
591
- context.arg = undefined$1;
592
- }
593
-
594
- } else {
595
- // Re-yield the result returned by the delegate method.
596
- return info;
597
- }
598
-
599
- // The delegate iterator is finished, so forget it and continue with
600
- // the outer generator.
601
- context.delegate = null;
602
- return ContinueSentinel;
603
- }
604
-
605
- // Define Generator.prototype.{next,throw,return} in terms of the
606
- // unified ._invoke helper method.
607
- defineIteratorMethods(Gp);
608
-
609
- define(Gp, toStringTagSymbol, "Generator");
610
-
611
- // A Generator should always return itself as the iterator object when the
612
- // @@iterator function is called on it. Some browsers' implementations of the
613
- // iterator prototype chain incorrectly implement this, causing the Generator
614
- // object to not be returned from this call. This ensures that doesn't happen.
615
- // See https://github.com/facebook/regenerator/issues/274 for more details.
616
- define(Gp, iteratorSymbol, function() {
617
- return this;
618
- });
619
-
620
- define(Gp, "toString", function() {
621
- return "[object Generator]";
622
- });
623
-
624
- function pushTryEntry(locs) {
625
- var entry = { tryLoc: locs[0] };
626
-
627
- if (1 in locs) {
628
- entry.catchLoc = locs[1];
629
- }
630
-
631
- if (2 in locs) {
632
- entry.finallyLoc = locs[2];
633
- entry.afterLoc = locs[3];
634
- }
635
-
636
- this.tryEntries.push(entry);
637
- }
638
-
639
- function resetTryEntry(entry) {
640
- var record = entry.completion || {};
641
- record.type = "normal";
642
- delete record.arg;
643
- entry.completion = record;
644
- }
645
-
646
- function Context(tryLocsList) {
647
- // The root entry object (effectively a try statement without a catch
648
- // or a finally block) gives us a place to store values thrown from
649
- // locations where there is no enclosing try statement.
650
- this.tryEntries = [{ tryLoc: "root" }];
651
- tryLocsList.forEach(pushTryEntry, this);
652
- this.reset(true);
653
- }
654
-
655
- exports.keys = function(object) {
656
- var keys = [];
657
- for (var key in object) {
658
- keys.push(key);
659
- }
660
- keys.reverse();
661
-
662
- // Rather than returning an object with a next method, we keep
663
- // things simple and return the next function itself.
664
- return function next() {
665
- while (keys.length) {
666
- var key = keys.pop();
667
- if (key in object) {
668
- next.value = key;
669
- next.done = false;
670
- return next;
671
- }
672
- }
673
-
674
- // To avoid creating an additional object, we just hang the .value
675
- // and .done properties off the next function object itself. This
676
- // also ensures that the minifier will not anonymize the function.
677
- next.done = true;
678
- return next;
679
- };
680
- };
681
-
682
- function values(iterable) {
683
- if (iterable) {
684
- var iteratorMethod = iterable[iteratorSymbol];
685
- if (iteratorMethod) {
686
- return iteratorMethod.call(iterable);
687
- }
688
-
689
- if (typeof iterable.next === "function") {
690
- return iterable;
691
- }
692
-
693
- if (!isNaN(iterable.length)) {
694
- var i = -1, next = function next() {
695
- while (++i < iterable.length) {
696
- if (hasOwn.call(iterable, i)) {
697
- next.value = iterable[i];
698
- next.done = false;
699
- return next;
700
- }
701
- }
702
-
703
- next.value = undefined$1;
704
- next.done = true;
705
-
706
- return next;
707
- };
708
-
709
- return next.next = next;
710
- }
711
- }
712
-
713
- // Return an iterator with no values.
714
- return { next: doneResult };
715
- }
716
- exports.values = values;
717
-
718
- function doneResult() {
719
- return { value: undefined$1, done: true };
720
- }
721
-
722
- Context.prototype = {
723
- constructor: Context,
724
-
725
- reset: function(skipTempReset) {
726
- this.prev = 0;
727
- this.next = 0;
728
- // Resetting context._sent for legacy support of Babel's
729
- // function.sent implementation.
730
- this.sent = this._sent = undefined$1;
731
- this.done = false;
732
- this.delegate = null;
733
-
734
- this.method = "next";
735
- this.arg = undefined$1;
736
-
737
- this.tryEntries.forEach(resetTryEntry);
738
-
739
- if (!skipTempReset) {
740
- for (var name in this) {
741
- // Not sure about the optimal order of these conditions:
742
- if (name.charAt(0) === "t" &&
743
- hasOwn.call(this, name) &&
744
- !isNaN(+name.slice(1))) {
745
- this[name] = undefined$1;
746
- }
747
- }
748
- }
749
- },
750
-
751
- stop: function() {
752
- this.done = true;
753
-
754
- var rootEntry = this.tryEntries[0];
755
- var rootRecord = rootEntry.completion;
756
- if (rootRecord.type === "throw") {
757
- throw rootRecord.arg;
758
- }
759
-
760
- return this.rval;
761
- },
762
-
763
- dispatchException: function(exception) {
764
- if (this.done) {
765
- throw exception;
766
- }
767
-
768
- var context = this;
769
- function handle(loc, caught) {
770
- record.type = "throw";
771
- record.arg = exception;
772
- context.next = loc;
773
-
774
- if (caught) {
775
- // If the dispatched exception was caught by a catch block,
776
- // then let that catch block handle the exception normally.
777
- context.method = "next";
778
- context.arg = undefined$1;
779
- }
780
-
781
- return !! caught;
782
- }
783
-
784
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
785
- var entry = this.tryEntries[i];
786
- var record = entry.completion;
787
-
788
- if (entry.tryLoc === "root") {
789
- // Exception thrown outside of any try block that could handle
790
- // it, so set the completion value of the entire function to
791
- // throw the exception.
792
- return handle("end");
793
- }
794
-
795
- if (entry.tryLoc <= this.prev) {
796
- var hasCatch = hasOwn.call(entry, "catchLoc");
797
- var hasFinally = hasOwn.call(entry, "finallyLoc");
798
-
799
- if (hasCatch && hasFinally) {
800
- if (this.prev < entry.catchLoc) {
801
- return handle(entry.catchLoc, true);
802
- } else if (this.prev < entry.finallyLoc) {
803
- return handle(entry.finallyLoc);
804
- }
805
-
806
- } else if (hasCatch) {
807
- if (this.prev < entry.catchLoc) {
808
- return handle(entry.catchLoc, true);
809
- }
810
-
811
- } else if (hasFinally) {
812
- if (this.prev < entry.finallyLoc) {
813
- return handle(entry.finallyLoc);
814
- }
815
-
816
- } else {
817
- throw new Error("try statement without catch or finally");
818
- }
819
- }
820
- }
821
- },
822
-
823
- abrupt: function(type, arg) {
824
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
825
- var entry = this.tryEntries[i];
826
- if (entry.tryLoc <= this.prev &&
827
- hasOwn.call(entry, "finallyLoc") &&
828
- this.prev < entry.finallyLoc) {
829
- var finallyEntry = entry;
830
- break;
831
- }
832
- }
833
-
834
- if (finallyEntry &&
835
- (type === "break" ||
836
- type === "continue") &&
837
- finallyEntry.tryLoc <= arg &&
838
- arg <= finallyEntry.finallyLoc) {
839
- // Ignore the finally entry if control is not jumping to a
840
- // location outside the try/catch block.
841
- finallyEntry = null;
842
- }
843
-
844
- var record = finallyEntry ? finallyEntry.completion : {};
845
- record.type = type;
846
- record.arg = arg;
847
-
848
- if (finallyEntry) {
849
- this.method = "next";
850
- this.next = finallyEntry.finallyLoc;
851
- return ContinueSentinel;
852
- }
853
-
854
- return this.complete(record);
855
- },
856
-
857
- complete: function(record, afterLoc) {
858
- if (record.type === "throw") {
859
- throw record.arg;
860
- }
861
-
862
- if (record.type === "break" ||
863
- record.type === "continue") {
864
- this.next = record.arg;
865
- } else if (record.type === "return") {
866
- this.rval = this.arg = record.arg;
867
- this.method = "return";
868
- this.next = "end";
869
- } else if (record.type === "normal" && afterLoc) {
870
- this.next = afterLoc;
871
- }
872
-
873
- return ContinueSentinel;
874
- },
875
-
876
- finish: function(finallyLoc) {
877
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
878
- var entry = this.tryEntries[i];
879
- if (entry.finallyLoc === finallyLoc) {
880
- this.complete(entry.completion, entry.afterLoc);
881
- resetTryEntry(entry);
882
- return ContinueSentinel;
883
- }
884
- }
885
- },
886
-
887
- "catch": function(tryLoc) {
888
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
889
- var entry = this.tryEntries[i];
890
- if (entry.tryLoc === tryLoc) {
891
- var record = entry.completion;
892
- if (record.type === "throw") {
893
- var thrown = record.arg;
894
- resetTryEntry(entry);
895
- }
896
- return thrown;
897
- }
898
- }
899
-
900
- // The context.catch method must only be called with a location
901
- // argument that corresponds to a known catch block.
902
- throw new Error("illegal catch attempt");
903
- },
904
-
905
- delegateYield: function(iterable, resultName, nextLoc) {
906
- this.delegate = {
907
- iterator: values(iterable),
908
- resultName: resultName,
909
- nextLoc: nextLoc
910
- };
911
-
912
- if (this.method === "next") {
913
- // Deliberately forget the last sent value so that we don't
914
- // accidentally pass it on to the delegate.
915
- this.arg = undefined$1;
916
- }
917
-
918
- return ContinueSentinel;
919
- }
920
- };
921
-
922
- // Regardless of whether this script is executing as a CommonJS module
923
- // or not, return the runtime object so that we can declare the variable
924
- // regeneratorRuntime in the outer scope, which allows this module to be
925
- // injected easily by `bin/regenerator --include-runtime script.js`.
926
- return exports;
927
-
928
- }(
929
- // If this script is executing as a CommonJS module, use module.exports
930
- // as the regeneratorRuntime namespace. Otherwise create a new empty
931
- // object. Either way, the resulting object will be used to initialize
932
- // the regeneratorRuntime variable at the top of this file.
933
- module.exports
934
- ));
935
-
936
- try {
937
- regeneratorRuntime = runtime;
938
- } catch (accidentalStrictMode) {
939
- // This module should not be running in strict mode, so the above
940
- // assignment should always work unless something is misconfigured. Just
941
- // in case runtime.js accidentally runs in strict mode, in modern engines
942
- // we can explicitly access globalThis. In older engines we can escape
943
- // strict mode using a global Function call. This could conceivably fail
944
- // if a Content Security Policy forbids using Function, but in that case
945
- // the proper solution is to fix the accidental strict mode problem. If
946
- // you've misconfigured your bundler to force strict mode and applied a
947
- // CSP to forbid Function, and you're not willing to fix either of those
948
- // problems, please detail your unique predicament in a GitHub issue.
949
- if (typeof globalThis === "object") {
950
- globalThis.regeneratorRuntime = runtime;
951
- } else {
952
- Function("r", "regeneratorRuntime = r")(runtime);
953
- }
954
- }
955
- });
956
-
957
- var DEFAULT_APP_NAME = '[DEFAULT]';
958
- var FirebaseAppContext = /*#__PURE__*/createContext(undefined);
959
- var SuspenseEnabledContext = /*#__PURE__*/createContext(false); // @ts-ignore: "__REACTFIRE_VERSION__" is replaced with actual ReactFire version (see babel.config.js)
960
-
961
- var version = "4.0.0";
962
-
963
- var shallowEq = function shallowEq(a, b) {
964
- return a === b || [].concat(Object.keys(a), Object.keys(b)).every(function (key) {
965
- return a[key] === b[key];
966
- });
967
- };
968
-
969
- function FirebaseAppProvider(props) {
970
- var firebaseConfig = props.firebaseConfig,
971
- appName = props.appName,
972
- suspense = props.suspense;
973
- var firebaseApp = useMemo(function () {
974
- if (props.firebaseApp) {
975
- return props.firebaseApp;
976
- }
977
-
978
- var existingApp = getApps().find(function (app) {
979
- return app.name === (appName || DEFAULT_APP_NAME);
980
- });
981
-
982
- if (existingApp) {
983
- if (firebaseConfig && shallowEq(existingApp.options, firebaseConfig)) {
984
- return existingApp;
985
- } else {
986
- throw new Error("Does not match the options already provided to the " + (appName || 'default') + " firebase app instance, give this new instance a different appName.");
987
- }
988
- } else {
989
- if (!firebaseConfig) {
990
- throw new Error('No firebaseConfig provided');
991
- }
992
-
993
- var reactVersion = version$1 || 'unknown';
994
- registerVersion('react', reactVersion);
995
- registerVersion('reactfire', version);
996
- return initializeApp(firebaseConfig, appName);
997
- }
998
- }, [props.firebaseApp, firebaseConfig, appName]);
999
- return createElement(FirebaseAppContext.Provider, {
1000
- value: firebaseApp
1001
- }, createElement(SuspenseEnabledContext.Provider, _extends({
1002
- value: suspense != null ? suspense : false
1003
- }, props)));
1004
- }
1005
- function useIsSuspenseEnabled() {
1006
- var suspense = useContext(SuspenseEnabledContext); // default to false if not available in context
1007
-
1008
- return suspense != null ? suspense : false;
1009
- }
1010
- function useSuspenseEnabledFromConfigAndContext(suspenseFromConfig) {
1011
- var suspenseFromContext = useContext(SuspenseEnabledContext); // prioritize config over context
1012
-
1013
- if (suspenseFromConfig !== undefined) {
1014
- return suspenseFromConfig;
1015
- }
1016
-
1017
- return suspenseFromContext;
1018
- }
1019
- function useFirebaseApp() {
1020
- var firebaseApp = useContext(FirebaseAppContext);
1021
-
1022
- if (!firebaseApp) {
1023
- throw new Error('Cannot call useFirebaseApp unless your component is within a FirebaseAppProvider');
1024
- }
1025
-
1026
- return firebaseApp;
1027
- }
1028
-
1029
- function preloadUser(_x) {
1030
- return _preloadUser.apply(this, arguments);
1031
- }
1032
- /**
1033
- * Subscribe to Firebase auth state changes, including token refresh
1034
- *
1035
- * @param options
1036
- */
1037
-
1038
- function _preloadUser() {
1039
- _preloadUser = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(authResolver) {
1040
- var auth, user$;
1041
- return runtime_1.wrap(function _callee$(_context) {
1042
- while (1) {
1043
- switch (_context.prev = _context.next) {
1044
- case 0:
1045
- _context.next = 2;
1046
- return authResolver();
1047
-
1048
- case 2:
1049
- auth = _context.sent;
1050
- user$ = preloadObservable(user(auth), "auth:user:" + auth.name);
1051
- return _context.abrupt("return", user$.toPromise());
1052
-
1053
- case 5:
1054
- case "end":
1055
- return _context.stop();
1056
- }
1057
- }
1058
- }, _callee);
1059
- }));
1060
- return _preloadUser.apply(this, arguments);
1061
- }
1062
-
1063
- function useUser(options) {
1064
- var _options$initialData;
1065
-
1066
- var auth = useAuth();
1067
- var observableId = "auth:user:" + auth.name;
1068
- var observable$ = user(auth);
1069
- var currentUser = auth.currentUser; // Only use options.initialData if auth.currentUser is unavailable
1070
-
1071
- if (!currentUser && ((_options$initialData = options == null ? void 0 : options.initialData) != null ? _options$initialData : options == null ? void 0 : options.startWithValue)) {
1072
- var _options$initialData2;
1073
-
1074
- currentUser = (_options$initialData2 = options.initialData) != null ? _options$initialData2 : options.startWithValue;
1075
- }
1076
-
1077
- return useObservable(observableId, observable$, _extends({}, options, {
1078
- initialData: currentUser
1079
- }));
1080
- }
1081
- function useIdTokenResult(user, forceRefresh, options) {
1082
- if (forceRefresh === void 0) {
1083
- forceRefresh = false;
1084
- }
1085
-
1086
- if (!user) {
1087
- throw new Error('you must provide a user');
1088
- }
1089
-
1090
- var observableId = "auth:idTokenResult:" + user.uid + ":forceRefresh=" + forceRefresh;
1091
- var observable$ = from(user.getIdTokenResult(forceRefresh));
1092
- return useObservable(observableId, observable$, options);
1093
- }
1094
- /**
1095
- * Subscribe to the signed-in status of a user.
1096
- *
1097
- * ```ts
1098
- * const { status, data:signInCheckResult } = useSigninCheck();
1099
- *
1100
- * if (status === 'loading') {
1101
- * return <LoadingSpinner />}
1102
- *
1103
- *
1104
- * if (signInCheckResult.signedIn === true) {
1105
- * return <ProfilePage user={signInCheckResult.user}/>
1106
- * } else {
1107
- * return <SignInForm />
1108
- * }
1109
- * ```
1110
- *
1111
- * Optionally check [custom claims](https://firebase.google.com/docs/auth/admin/custom-claims) of a user as well.
1112
- *
1113
- * ```ts
1114
- * // pass in an object describing the custom claims a user must have
1115
- * const {status, data: signInCheckResult} = useSignInCheck({requiredClaims: {admin: true}});
1116
- *
1117
- * // pass in a custom claims validator function
1118
- * const {status, data: signInCheckResult} = useSignInCheck({validateCustomClaims: (userClaims) => {
1119
- * // custom validation logic...
1120
- * }});
1121
- *
1122
- * // You can optionally force-refresh the token
1123
- * const {status, data: signInCheckResult} = useSignInCheck({forceRefresh: true, requiredClaims: {admin: true}});
1124
- * ```
1125
- */
1126
-
1127
- function useSigninCheck(options) {
1128
- // If both `requiredClaims` and `validateCustomClaims` are provided, we won't know which one to use
1129
- if (options != null && options.hasOwnProperty('requiredClaims') && options != null && options.hasOwnProperty('validateCustomClaims')) {
1130
- throw new Error('Cannot have both "requiredClaims" and "validateCustomClaims". Use one or the other.');
1131
- }
1132
-
1133
- var auth = useAuth(); // ObservableId should change for different options configurations to ensure no cache collisions
1134
-
1135
- var observableId = "auth:signInCheck:" + auth.name + "::forceRefresh:" + !!(options != null && options.forceRefresh);
1136
-
1137
- if (options != null && options.forceRefresh) {
1138
- observableId = observableId + ":forceRefresh:" + options.forceRefresh;
1139
- }
1140
-
1141
- if (options != null && options.hasOwnProperty('requiredClaims')) {
1142
- observableId = observableId + ":requiredClaims:" + JSON.stringify(options.requiredClaims);
1143
- } else if (options != null && options.hasOwnProperty('validateCustomClaims')) {
1144
- // TODO(jamesdaniels): Check if stringifying this function breaks in IE11
1145
- observableId = observableId + ":validateCustomClaims:" + JSON.stringify(options.validateCustomClaims);
1146
- }
1147
-
1148
- var observable = user(auth).pipe(switchMap(function (user) {
1149
- if (!user) {
1150
- var result = {
1151
- signedIn: false,
1152
- hasRequiredClaims: false,
1153
- errors: {},
1154
- user: null
1155
- };
1156
- return of(result);
1157
- } else if (options && (options.hasOwnProperty('requiredClaims') || options.hasOwnProperty('validateCustomClaims'))) {
1158
- var _options$forceRefresh;
1159
-
1160
- return from(user.getIdTokenResult((_options$forceRefresh = options == null ? void 0 : options.forceRefresh) != null ? _options$forceRefresh : false)).pipe(map(function (idTokenResult) {
1161
- var validator;
1162
-
1163
- if (options.hasOwnProperty('requiredClaims')) {
1164
- validator = getClaimsObjectValidator(options.requiredClaims);
1165
- } else {
1166
- validator = options.validateCustomClaims;
1167
- }
1168
-
1169
- var _validator = validator(idTokenResult.claims),
1170
- hasRequiredClaims = _validator.hasRequiredClaims,
1171
- errors = _validator.errors;
1172
-
1173
- var result = {
1174
- signedIn: true,
1175
- hasRequiredClaims: hasRequiredClaims,
1176
- errors: errors,
1177
- user: user
1178
- };
1179
- return result;
1180
- }));
1181
- } else {
1182
- // If no claims are provided to be checked, `hasRequiredClaims` is true
1183
- var _result = {
1184
- signedIn: true,
1185
- hasRequiredClaims: true,
1186
- errors: {},
1187
- user: user
1188
- };
1189
- return of(_result);
1190
- }
1191
- }));
1192
- return useObservable(observableId, observable);
1193
- }
1194
-
1195
- function getClaimsObjectValidator(requiredClaims) {
1196
- return function claimsObjectValidator(userClaims) {
1197
- var errors = {};
1198
- Object.keys(requiredClaims).forEach(function (claim) {
1199
- if (requiredClaims[claim] !== userClaims[claim]) {
1200
- errors[claim] = [new ReactFireError('auth/missing-claim', "Expected \"" + requiredClaims[claim] + "\", but user has \"" + userClaims[claim] + "\" instead")];
1201
- }
1202
- });
1203
- return {
1204
- hasRequiredClaims: Object.keys(errors).length === 0,
1205
- errors: errors
1206
- };
1207
- };
1208
- }
1209
- /**
1210
- * @deprecated Use `useSignInCheck` instead
1211
- *
1212
- * Conditionally render children based on [custom claims](https://firebase.google.com/docs/auth/admin/custom-claims).
1213
- *
1214
- * Meant for Concurrent mode only (`<FirebaseAppProvider suspense=true />`). [More detail](https://github.com/FirebaseExtended/reactfire/issues/325#issuecomment-827654376).
1215
- */
1216
-
1217
-
1218
- function ClaimsCheck(_ref) {
1219
- var user = _ref.user,
1220
- fallback = _ref.fallback,
1221
- children = _ref.children,
1222
- requiredClaims = _ref.requiredClaims;
1223
-
1224
- var _useIdTokenResult = useIdTokenResult(user, false),
1225
- data = _useIdTokenResult.data;
1226
-
1227
- var claims = data.claims;
1228
- var missingClaims = {};
1229
- var suspenseMode = useSuspenseEnabledFromConfigAndContext();
1230
-
1231
- if (!suspenseMode) {
1232
- console.warn('ClaimsCheck is deprecated and only works when ReactFire is in experimental Suspense Mode. Use useSigninCheck or set suspense={true} in FirebaseAppProvider if you want to use this component.');
1233
- }
1234
-
1235
- if (requiredClaims) {
1236
- Object.keys(requiredClaims).forEach(function (claim) {
1237
- if (requiredClaims[claim] !== claims[claim]) {
1238
- var _claims$claim;
1239
-
1240
- missingClaims[claim] = {
1241
- expected: requiredClaims[claim],
1242
- actual: (_claims$claim = claims[claim]) == null ? void 0 : _claims$claim.toString()
1243
- };
1244
- }
1245
- });
1246
- }
1247
-
1248
- if (Object.keys(missingClaims).length === 0) {
1249
- return createElement(Fragment, null, children);
1250
- } else {
1251
- return createElement(Fragment, null, fallback);
1252
- }
1253
- }
1254
- /**
1255
- * @deprecated Use `useSignInCheck` instead
1256
- *
1257
- * Conditionally render children based on signed-in status and [custom claims](https://firebase.google.com/docs/auth/admin/custom-claims).
1258
- *
1259
- * Meant for Concurrent mode only (`<FirebaseAppProvider suspense=true />`). [More detail](https://github.com/FirebaseExtended/reactfire/issues/325#issuecomment-827654376).
1260
- */
1261
-
1262
- function AuthCheck(_ref2) {
1263
- var fallback = _ref2.fallback,
1264
- children = _ref2.children,
1265
- requiredClaims = _ref2.requiredClaims;
1266
-
1267
- var _useUser = useUser(),
1268
- user = _useUser.data;
1269
-
1270
- var suspenseMode = useSuspenseEnabledFromConfigAndContext();
1271
-
1272
- if (!suspenseMode) {
1273
- console.warn('AuthCheck is deprecated and only works when ReactFire is in experimental Suspense Mode. Use useSigninCheck or set suspense={true} in FirebaseAppProvider if you want to use this component.');
1274
- }
1275
-
1276
- if (user) {
1277
- return requiredClaims ? createElement(ClaimsCheck, {
1278
- user: user,
1279
- fallback: fallback,
1280
- requiredClaims: requiredClaims
1281
- }, children) : createElement(Fragment, null, children);
1282
- } else {
1283
- return createElement(Fragment, null, fallback);
1284
- }
1285
- }
1286
-
1287
- var cachedQueries = globalThis._reactFireDatabaseCachedQueries || [];
1288
-
1289
- if (!globalThis._reactFireDatabaseCachedQueries) {
1290
- globalThis._reactFireDatabaseCachedQueries = cachedQueries;
1291
- }
1292
-
1293
- function getUniqueIdForDatabaseQuery(query) {
1294
- var index = cachedQueries.findIndex(function (cachedQuery) {
1295
- return cachedQuery.isEqual(query);
1296
- });
1297
-
1298
- if (index > -1) {
1299
- return index;
1300
- }
1301
-
1302
- return cachedQueries.push(query) - 1;
1303
- }
1304
- /**
1305
- * Subscribe to a Realtime Database object
1306
- *
1307
- * @param ref - Reference to the DB object you want to listen to
1308
- * @param options
1309
- */
1310
-
1311
-
1312
- function useDatabaseObject(ref, options) {
1313
- var observableId = "database:object:" + ref.toString();
1314
- var observable$ = object(ref);
1315
- return useObservable(observableId, observable$, options);
1316
- }
1317
- function useDatabaseObjectData(ref, options) {
1318
- var idField = options ? checkIdField(options) : 'NO_ID_FIELD';
1319
- var observableId = "database:objectVal:" + ref.toString() + ":idField=" + idField;
1320
- var observable$ = objectVal(ref, {
1321
- keyField: idField
1322
- });
1323
- return useObservable(observableId, observable$, options);
1324
- }
1325
- /**
1326
- * Subscribe to a Realtime Database list
1327
- *
1328
- * @param ref - Reference to the DB List you want to listen to
1329
- * @param options
1330
- */
1331
-
1332
- function useDatabaseList(ref, options) {
1333
- var hash = "database:list:" + getUniqueIdForDatabaseQuery(ref);
1334
- var observable$ = list(ref);
1335
- return useObservable(hash, observable$, options);
1336
- }
1337
- function useDatabaseListData(ref, options) {
1338
- var idField = options ? checkIdField(options) : 'NO_ID_FIELD';
1339
- var observableId = "database:listVal:" + getUniqueIdForDatabaseQuery(ref) + ":idField=" + idField;
1340
- var observable$ = listVal(ref, {
1341
- keyField: idField
1342
- });
1343
- return useObservable(observableId, observable$, options);
1344
- }
1345
-
1346
- var SuspenseSubject = /*#__PURE__*/function (_Subject) {
1347
- _inheritsLoose(SuspenseSubject, _Subject);
1348
-
1349
- // @ts-ignore: TODO: double check to see if this is an RXJS thing or if we should listen to TS
1350
- // @ts-ignore: TODO: double check to see if this is an RXJS thing or if we should listen to TS
1351
- function SuspenseSubject(innerObservable, _timeoutWindow) {
1352
- var _this;
1353
-
1354
- _this = _Subject.call(this) || this;
1355
- _this._timeoutWindow = void 0;
1356
- _this._value = void 0;
1357
- _this._hasValue = false;
1358
- _this._timeoutHandler = void 0;
1359
- _this._firstEmission = void 0;
1360
- _this._error = undefined;
1361
- _this._innerObservable = void 0;
1362
- _this._warmupSubscription = void 0;
1363
- _this._innerSubscriber = void 0;
1364
- _this._resolveFirstEmission = void 0;
1365
- _this._timeoutWindow = _timeoutWindow;
1366
- _this._firstEmission = new Promise(function (resolve) {
1367
- return _this._resolveFirstEmission = resolve;
1368
- });
1369
- _this._innerObservable = innerObservable.pipe(tap({
1370
- next: function next(v) {
1371
- _this._next(v);
1372
- },
1373
- error: function error(e) {
1374
- // save the error, so that we can raise on subscription or .value
1375
- // resolve the promise, so suspense tries again
1376
- _this._error = e;
1377
-
1378
- _this._resolveFirstEmission();
1379
- }
1380
- }), catchError(function () {
1381
- return empty();
1382
- }), shareReplay(1)); // warm up the observable
1383
-
1384
- _this._warmupSubscription = _this._innerObservable.subscribe(); // set a timeout for resetting the cache, subscriptions will cancel the timeout
1385
- // and reschedule again on unsubscribe
1386
-
1387
- _this._timeoutHandler = setTimeout(_this._reset.bind(_assertThisInitialized(_this)), _this._timeoutWindow);
1388
- return _this;
1389
- }
1390
-
1391
- var _proto = SuspenseSubject.prototype;
1392
-
1393
- _proto._next = function _next(value) {
1394
- this._hasValue = true;
1395
- this._value = value;
1396
-
1397
- this._resolveFirstEmission();
1398
- };
1399
-
1400
- _proto._reset = function _reset() {
1401
- var _this2 = this;
1402
-
1403
- // seems to be undefined in tests?
1404
- if (this._warmupSubscription) {
1405
- this._warmupSubscription.unsubscribe();
1406
- }
1407
-
1408
- this._hasValue = false;
1409
- this._value = undefined;
1410
- this._error = undefined;
1411
- this._firstEmission = new Promise(function (resolve) {
1412
- return _this2._resolveFirstEmission = resolve;
1413
- });
1414
- };
1415
-
1416
- _proto._subscribe = function _subscribe(subscriber) {
1417
- if (this._timeoutHandler) {
1418
- clearTimeout(this._timeoutHandler);
1419
- }
1420
-
1421
- this._innerSubscriber = this._innerObservable.subscribe(subscriber);
1422
- return this._innerSubscriber;
1423
- };
1424
-
1425
- _createClass(SuspenseSubject, [{
1426
- key: "hasValue",
1427
- get: function get() {
1428
- // hasValue returns true if there's an error too
1429
- // so that after we resolve the promise & useObservable is called again
1430
- // we won't throw again
1431
- return this._hasValue || !!this._error;
1432
- }
1433
- }, {
1434
- key: "value",
1435
- get: function get() {
1436
- // TODO figure out how to reset the cache here, if I _reset() here before throwing
1437
- // it doesn't seem to work.
1438
- // As it is now, this will burn the cache entry until the timeout fires.
1439
- if (this._error) {
1440
- throw this._error;
1441
- }
1442
-
1443
- return this._value;
1444
- }
1445
- }, {
1446
- key: "firstEmission",
1447
- get: function get() {
1448
- return this._firstEmission;
1449
- }
1450
- }, {
1451
- key: "ourError",
1452
- get: function get() {
1453
- return this._error;
1454
- }
1455
- }]);
1456
-
1457
- return SuspenseSubject;
1458
- }(Subject);
1459
-
1460
- var DEFAULT_TIMEOUT = 30000; // Since we're side-effect free, we need to ensure our observable cache is global
1461
-
1462
- var preloadedObservables = globalThis._reactFirePreloadedObservables || /*#__PURE__*/new Map();
1463
-
1464
- if (!globalThis._reactFirePreloadedObservables) {
1465
- globalThis._reactFirePreloadedObservables = preloadedObservables;
1466
- } // Starts listening to an Observable.
1467
- // Call this once you know you're going to render a
1468
- // child that will consume the observable
1469
-
1470
-
1471
- function preloadObservable(source, id) {
1472
- if (preloadedObservables.has(id)) {
1473
- return preloadedObservables.get(id);
1474
- } else {
1475
- var observable = new SuspenseSubject(source, DEFAULT_TIMEOUT);
1476
- preloadedObservables.set(id, observable);
1477
- return observable;
1478
- }
1479
- }
1480
- function useObservable(observableId, source, config) {
1481
- var _config$initialData, _config, _config2;
1482
-
1483
- if (config === void 0) {
1484
- config = {};
1485
- }
1486
-
1487
- if (!observableId) {
1488
- throw new Error('cannot call useObservable without an observableId');
1489
- }
1490
-
1491
- var observable = preloadObservable(source, observableId);
1492
- var hasInitialData = config.hasOwnProperty('initialData') || config.hasOwnProperty('startWithValue');
1493
- var suspenseEnabled = useSuspenseEnabledFromConfigAndContext(config.suspense);
1494
-
1495
- if (suspenseEnabled === true && !observable.hasValue && ((_config$initialData = !((_config = config) != null && _config.initialData)) != null ? _config$initialData : !((_config2 = config) != null && _config2.startWithValue))) {
1496
- throw observable.firstEmission;
1497
- }
1498
-
1499
- var _React$useState = useState(function () {
1500
- var _config$initialData2;
1501
-
1502
- return observable.hasValue ? observable.value : (_config$initialData2 = config.initialData) != null ? _config$initialData2 : config.startWithValue;
1503
- }),
1504
- latest = _React$useState[0],
1505
- setValue = _React$useState[1];
1506
-
1507
- var _React$useState2 = useState(false),
1508
- isComplete = _React$useState2[0],
1509
- setIsComplete = _React$useState2[1];
1510
-
1511
- var _React$useState3 = useState(false),
1512
- hasError = _React$useState3[0],
1513
- setHasError = _React$useState3[1];
1514
-
1515
- useEffect(function () {
1516
- var subscription = observable.subscribe({
1517
- next: function next(v) {
1518
- setValue(function () {
1519
- return v;
1520
- });
1521
- },
1522
- error: function error(e) {
1523
- setHasError(true);
1524
- throw e;
1525
- },
1526
- complete: function complete() {
1527
- setIsComplete(true);
1528
- }
1529
- });
1530
- return function () {
1531
- return subscription.unsubscribe();
1532
- };
1533
- }, [observable]);
1534
- var status;
1535
-
1536
- if (hasError) {
1537
- status = 'error';
1538
- } else if (observable.hasValue || hasInitialData) {
1539
- status = 'success';
1540
- } else {
1541
- status = 'loading';
1542
- }
1543
-
1544
- return {
1545
- status: status,
1546
- hasEmitted: observable.hasValue || hasInitialData,
1547
- isComplete: isComplete,
1548
- data: latest,
1549
- error: observable.ourError,
1550
- firstValuePromise: observable.firstEmission
1551
- };
1552
- }
1553
-
1554
- var cachedQueries$1 = globalThis._reactFireFirestoreQueryCache || [];
1555
-
1556
- if (!globalThis._reactFireFirestoreQueryCache) {
1557
- globalThis._reactFireFirestoreQueryCache = cachedQueries$1;
1558
- }
1559
-
1560
- function getUniqueIdForFirestoreQuery(query) {
1561
- var index = cachedQueries$1.findIndex(function (cachedQuery) {
1562
- return queryEqual(cachedQuery, query);
1563
- });
1564
-
1565
- if (index > -1) {
1566
- return index;
1567
- }
1568
-
1569
- return cachedQueries$1.push(query) - 1;
1570
- }
1571
- /**
1572
- * Preload a subscription to a Firestore document reference.
1573
- *
1574
- * Use this to warm up `useFirestoreDoc` for a specific document
1575
- */
1576
-
1577
-
1578
- function preloadFirestoreDoc(_x) {
1579
- return _preloadFirestoreDoc.apply(this, arguments);
1580
- }
1581
-
1582
- function _preloadFirestoreDoc() {
1583
- _preloadFirestoreDoc = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(refProvider) {
1584
- var ref;
1585
- return runtime_1.wrap(function _callee$(_context) {
1586
- while (1) {
1587
- switch (_context.prev = _context.next) {
1588
- case 0:
1589
- _context.next = 2;
1590
- return refProvider();
1591
-
1592
- case 2:
1593
- ref = _context.sent;
1594
- return _context.abrupt("return", preloadObservable(doc(ref), getDocObservableId(ref)));
1595
-
1596
- case 4:
1597
- case "end":
1598
- return _context.stop();
1599
- }
1600
- }
1601
- }, _callee);
1602
- }));
1603
- return _preloadFirestoreDoc.apply(this, arguments);
1604
- }
1605
-
1606
- function getDocObservableId(ref) {
1607
- return "firestore:doc:" + ref.firestore.app.name + ":" + ref.path;
1608
- }
1609
- /**
1610
- * Suscribe to Firestore Document changes
1611
- *
1612
- * You can preload data for this hook by calling `preloadFirestoreDoc`
1613
- */
1614
-
1615
-
1616
- function useFirestoreDoc(ref, options) {
1617
- var observableId = getDocObservableId(ref);
1618
- var observable$ = doc(ref);
1619
- return useObservable(observableId, observable$, options);
1620
- }
1621
- /**
1622
- * Get a firestore document and don't subscribe to changes
1623
- */
1624
-
1625
- function useFirestoreDocOnce(ref, options) {
1626
- var observableId = "firestore:docOnce:" + ref.firestore.app.name + ":" + ref.path;
1627
- var observable$ = doc(ref).pipe(first());
1628
- return useObservable(observableId, observable$, options);
1629
- }
1630
- /**
1631
- * Suscribe to Firestore Document changes and unwrap the document into a plain object
1632
- */
1633
-
1634
- function useFirestoreDocData(ref, options) {
1635
- var idField = options ? checkIdField(options) : 'NO_ID_FIELD';
1636
- var observableId = "firestore:docData:" + ref.firestore.app.name + ":" + ref.path + ":idField=" + idField;
1637
- var observable = docData(ref, {
1638
- idField: idField
1639
- });
1640
- return useObservable(observableId, observable, options);
1641
- }
1642
- /**
1643
- * Get a Firestore document, unwrap the document into a plain object, and don't subscribe to changes
1644
- */
1645
-
1646
- function useFirestoreDocDataOnce(ref, options) {
1647
- var idField = options ? checkIdField(options) : 'NO_ID_FIELD';
1648
- var observableId = "firestore:docDataOnce:" + ref.firestore.app.name + ":" + ref.path + ":idField=" + idField;
1649
- var observable$ = docData(ref, {
1650
- idField: idField
1651
- }).pipe(first());
1652
- return useObservable(observableId, observable$, options);
1653
- }
1654
- /**
1655
- * Subscribe to a Firestore collection
1656
- */
1657
-
1658
- function useFirestoreCollection(query, options) {
1659
- var observableId = "firestore:collection:" + getUniqueIdForFirestoreQuery(query);
1660
- var observable$ = fromRef(query);
1661
- return useObservable(observableId, observable$, options);
1662
- }
1663
- /**
1664
- * Subscribe to a Firestore collection and unwrap the snapshot into an array.
1665
- */
1666
-
1667
- function useFirestoreCollectionData(query, options) {
1668
- var idField = options ? checkIdField(options) : 'NO_ID_FIELD';
1669
- var observableId = "firestore:collectionData:" + getUniqueIdForFirestoreQuery(query) + ":idField=" + idField;
1670
- var observable$ = collectionData(query, {
1671
- idField: idField
1672
- });
1673
- return useObservable(observableId, observable$, options);
1674
- }
1675
-
1676
- function SuspenseWithPerf(_ref) {
1677
- var _performance;
1678
-
1679
- var children = _ref.children,
1680
- traceId = _ref.traceId,
1681
- fallback = _ref.fallback;
1682
- // TODO: Should this import firebase/performance?
1683
- var entries = ((_performance = performance) == null ? void 0 : _performance.getEntriesByName == null ? void 0 : _performance.getEntriesByName(traceId, 'measure')) || [];
1684
- var startMarkName = "_" + traceId + "Start[" + entries.length + "]";
1685
- var endMarkName = "_" + traceId + "End[" + entries.length + "]";
1686
-
1687
- var Fallback = function Fallback() {
1688
- useLayoutEffect(function () {
1689
- var _performance2;
1690
-
1691
- (_performance2 = performance) == null ? void 0 : _performance2.mark == null ? void 0 : _performance2.mark(startMarkName);
1692
- return function () {
1693
- var _performance3, _performance4;
1694
-
1695
- (_performance3 = performance) == null ? void 0 : _performance3.mark == null ? void 0 : _performance3.mark(endMarkName);
1696
- (_performance4 = performance) == null ? void 0 : _performance4.measure == null ? void 0 : _performance4.measure(traceId, startMarkName, endMarkName);
1697
- };
1698
- }, []);
1699
- return createElement(Fragment, null, fallback);
1700
- };
1701
-
1702
- return createElement(Suspense, {
1703
- fallback: createElement(Fallback, null)
1704
- }, children);
1705
- }
1706
-
1707
- function parameter$(_ref) {
1708
- var remoteConfig = _ref.remoteConfig,
1709
- key = _ref.key,
1710
- getter = _ref.getter;
1711
- return new Observable(function (subscriber) {
1712
- ensureInitialized(remoteConfig).then(function () {
1713
- // 'this' for the getter loses context in the next()
1714
- // call, so it needs to be bound.
1715
- subscriber.next(getter.bind(remoteConfig)(key));
1716
- });
1717
- });
1718
- }
1719
-
1720
- function getValue(remoteConfig, key) {
1721
- var getter = function getter() {
1722
- return getValue$1(remoteConfig, key);
1723
- };
1724
-
1725
- return parameter$({
1726
- remoteConfig: remoteConfig,
1727
- key: key,
1728
- getter: getter
1729
- });
1730
- }
1731
- function getString(remoteConfig, key) {
1732
- var getter = function getter() {
1733
- return getString$1(remoteConfig, key);
1734
- };
1735
-
1736
- return parameter$({
1737
- remoteConfig: remoteConfig,
1738
- key: key,
1739
- getter: getter
1740
- });
1741
- }
1742
- function getNumber(remoteConfig, key) {
1743
- var getter = function getter() {
1744
- return getNumber$1(remoteConfig, key);
1745
- };
1746
-
1747
- return parameter$({
1748
- remoteConfig: remoteConfig,
1749
- key: key,
1750
- getter: getter
1751
- });
1752
- }
1753
- function getBoolean(remoteConfig, key) {
1754
- var getter = function getter() {
1755
- return getBoolean$1(remoteConfig, key);
1756
- };
1757
-
1758
- return parameter$({
1759
- remoteConfig: remoteConfig,
1760
- key: key,
1761
- getter: getter
1762
- });
1763
- }
1764
- function getAll(remoteConfig) {
1765
- var getter = function getter() {
1766
- return getAll$1(remoteConfig);
1767
- }; // No key is needed for getAll()
1768
-
1769
-
1770
- return parameter$({
1771
- remoteConfig: remoteConfig,
1772
- key: '',
1773
- getter: getter
1774
- });
1775
- }
1776
-
1777
- /**
1778
- * Helper function to construct type safe functions. Since Remote Config has
1779
- * methods that return different types for values, we need to be extra safe
1780
- * to make sure we are not returning improper types by accident.
1781
- * @param key
1782
- * @param getter
1783
- * @param remoteConfig
1784
- */
1785
-
1786
- function useRemoteConfigValue_INTERNAL(key, getter) {
1787
- var _remoteConfig$_storag;
1788
-
1789
- var remoteConfig = useRemoteConfig(); // INVESTIGATE need to use a public API to get at the app name, one doesn't appear to exist...
1790
- // we might need to iterate over the Firebase apps and check for remoteConfig equality? this works for now
1791
-
1792
- var appName = (_remoteConfig$_storag = remoteConfig._storage) == null ? void 0 : _remoteConfig$_storag.appName;
1793
- var $value = getter(remoteConfig, key);
1794
- var observableId = "remoteConfig:" + key + ":" + getter.name + ":" + appName;
1795
- return useObservable(observableId, $value);
1796
- }
1797
- /**
1798
- * Accepts a key and optionally a Remote Config instance. Returns a
1799
- * Remote Config Value.
1800
- *
1801
- * @param key The parameter key in Remote Config
1802
- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
1803
- */
1804
-
1805
-
1806
- function useRemoteConfigValue(key) {
1807
- return useRemoteConfigValue_INTERNAL(key, getValue);
1808
- }
1809
- /**
1810
- * Convience method similar to useRemoteConfigValue. Returns a `string` from a Remote Config parameter.
1811
- * @param key The parameter key in Remote Config
1812
- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
1813
- */
1814
-
1815
- function useRemoteConfigString(key) {
1816
- return useRemoteConfigValue_INTERNAL(key, getString);
1817
- }
1818
- /**
1819
- * Convience method similar to useRemoteConfigValue. Returns a `number` from a Remote Config parameter.
1820
- * @param key The parameter key in Remote Config
1821
- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
1822
- */
1823
-
1824
- function useRemoteConfigNumber(key) {
1825
- return useRemoteConfigValue_INTERNAL(key, getNumber);
1826
- }
1827
- /**
1828
- * Convience method similar to useRemoteConfigValue. Returns a `boolean` from a Remote Config parameter.
1829
- * @param key The parameter key in Remote Config
1830
- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
1831
- */
1832
-
1833
- function useRemoteConfigBoolean(key) {
1834
- return useRemoteConfigValue_INTERNAL(key, getBoolean);
1835
- }
1836
- /**
1837
- * Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.
1838
- * @param key The parameter key in Remote Config
1839
- * @param remoteConfig Optional instance. If not provided ReactFire will either grab the default instance or lazy load.
1840
- */
1841
-
1842
- function useRemoteConfigAll(key) {
1843
- return useRemoteConfigValue_INTERNAL(key, getAll);
1844
- }
1845
-
1846
- var _excluded = ["storage", "storagePath", "suspense", "placeHolder"];
1847
- /**
1848
- * modified version of rxFire's _fromTask
1849
- *
1850
- * @param task
1851
- */
1852
-
1853
- function _fromTask(task) {
1854
- return new Observable(function (subscriber) {
1855
- var progress = function progress(snap) {
1856
- return subscriber.next(snap);
1857
- };
1858
-
1859
- var error = function error(e) {
1860
- return subscriber.error(e);
1861
- };
1862
-
1863
- var complete = function complete() {
1864
- return subscriber.complete();
1865
- };
1866
-
1867
- task.on('state_changed', progress, error, complete); // I REMOVED THE UNSUBSCRIBE RETURN BECAUSE IT CANCELS THE UPLOAD
1868
- // https://github.com/firebase/firebase-js-sdk/issues/1659
1869
- });
1870
- }
1871
- /**
1872
- * Subscribe to the progress of a storage task
1873
- *
1874
- * @param task - the task you want to listen to
1875
- * @param ref - reference to the blob the task is acting on
1876
- * @param options
1877
- */
1878
-
1879
-
1880
- function useStorageTask(task, ref, options) {
1881
- var observableId = "storage:task:" + ref.toString();
1882
-
1883
- var observable$ = _fromTask(task);
1884
-
1885
- return useObservable(observableId, observable$, options);
1886
- }
1887
- /**
1888
- * Subscribe to a storage ref's download URL
1889
- *
1890
- * @param ref - reference to the blob you want to download
1891
- * @param options
1892
- */
1893
-
1894
- function useStorageDownloadURL(ref, options) {
1895
- var observableId = "storage:downloadUrl:" + ref.toString();
1896
- var observable$ = getDownloadURL(ref);
1897
- return useObservable(observableId, observable$, options);
1898
- }
1899
-
1900
- function StorageFromContext(props) {
1901
- var storage = useStorage();
1902
- props = _extends({}, props, {
1903
- storage: storage
1904
- });
1905
- return createElement(INTERNALStorageImage, _extends({}, props));
1906
- }
1907
-
1908
- function INTERNALStorageImage(props) {
1909
- var storage = props.storage,
1910
- storagePath = props.storagePath,
1911
- suspense = props.suspense,
1912
- placeHolder = props.placeHolder,
1913
- imgProps = _objectWithoutPropertiesLoose(props, _excluded);
1914
-
1915
- var reactfireOptions = {
1916
- suspense: useSuspenseEnabledFromConfigAndContext(suspense)
1917
- };
1918
-
1919
- if (!storage) {
1920
- throw new Error('Storage was not passed to component INTERNALStorageImage. This should not be possible');
1921
- }
1922
-
1923
- var _useStorageDownloadUR = useStorageDownloadURL(ref(storage, storagePath), reactfireOptions),
1924
- status = _useStorageDownloadUR.status,
1925
- imgSrc = _useStorageDownloadUR.data;
1926
-
1927
- if (status === 'success') {
1928
- if (!(imgProps.alt || imgProps.alt === '')) {
1929
- console.warn("No alt prop provided for StorageImage with storagePath \"" + storagePath + "\"", 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images');
1930
- }
1931
-
1932
- return createElement("img", _extends({
1933
- src: imgSrc,
1934
- alt: imgProps.alt
1935
- }, imgProps));
1936
- } else {
1937
- return placeHolder != null ? placeHolder : createElement(Fragment, null, "''");
1938
- }
1939
- }
1940
-
1941
- function StorageImage(props) {
1942
- var storage = props.storage;
1943
-
1944
- if (storage) {
1945
- return createElement(INTERNALStorageImage, _extends({}, props));
1946
- } else {
1947
- return createElement(StorageFromContext, _extends({}, props));
1948
- }
1949
- }
1950
-
1951
- var AuthSdkContext = /*#__PURE__*/createContext(undefined);
1952
- var DatabaseSdkContext = /*#__PURE__*/createContext(undefined);
1953
- var FirestoreSdkContext = /*#__PURE__*/createContext(undefined);
1954
- var StorageSdkContext = /*#__PURE__*/createContext(undefined);
1955
- var PerformanceSdkContext = /*#__PURE__*/createContext(undefined);
1956
- var RemoteConfigSdkContext = /*#__PURE__*/createContext(undefined);
1957
-
1958
- function getSdkProvider(SdkContext) {
1959
- return function SdkProvider(props) {
1960
- var contextualAppName = useFirebaseApp().name;
1961
- var sdkAppName; // @ts-ignore Auth doesn't have field 'app'
1962
-
1963
- if (props.sdk.app) {
1964
- // @ts-ignore Auth doesn't have field 'app'
1965
- sdkAppName = props.sdk.app.name; // @ts-ignore only Auth has field 'name'
1966
- } else if (props.sdk.name) {
1967
- // @ts-ignore only Auth has field 'name'
1968
- sdkAppName = props.sdk.name;
1969
- }
1970
-
1971
- if (sdkAppName !== contextualAppName) {
1972
- throw new Error('sdk was initialized with a different firebase app');
1973
- }
1974
-
1975
- if (!props.sdk) {
1976
- throw new Error('no sdk provided');
1977
- }
1978
-
1979
- return createElement(SdkContext.Provider, _extends({
1980
- value: props.sdk
1981
- }, props));
1982
- };
1983
- }
1984
-
1985
- function useSdk(SdkContext) {
1986
- var sdk = useContext(SdkContext);
1987
-
1988
- if (!sdk) {
1989
- throw new Error('SDK not found. useSdk must be called from within a provider');
1990
- }
1991
-
1992
- return sdk;
1993
- }
1994
-
1995
- function useInitSdk(sdkName, SdkContext, sdkInitializer, options) {
1996
- var firebaseApp = useFirebaseApp(); // Some initialization functions (like Firestore's `enableIndexedDbPersistence`)
1997
- // can only be called before anything else. So if an sdk is already available in context,
1998
- // it isn't safe to call initialization functions again.
1999
-
2000
- if (useContext(SdkContext)) {
2001
- throw new Error("Cannot initialize SDK " + sdkName + " because it already exists in Context");
2002
- }
2003
-
2004
- var initializeSdk = useMemo(function () {
2005
- return sdkInitializer(firebaseApp);
2006
- }, [firebaseApp]);
2007
- return useObservable("firebase-sdk:" + sdkName + ":" + firebaseApp.name, from(initializeSdk), options);
2008
- }
2009
-
2010
- var AuthProvider = /*#__PURE__*/getSdkProvider(AuthSdkContext);
2011
- var DatabaseProvider = /*#__PURE__*/getSdkProvider(DatabaseSdkContext);
2012
- var FirestoreProvider = /*#__PURE__*/getSdkProvider(FirestoreSdkContext);
2013
- var PerformanceProvider = /*#__PURE__*/getSdkProvider(PerformanceSdkContext);
2014
- var StorageProvider = /*#__PURE__*/getSdkProvider(StorageSdkContext);
2015
- var RemoteConfigProvider = /*#__PURE__*/getSdkProvider(RemoteConfigSdkContext);
2016
- var useAuth = function useAuth() {
2017
- return useSdk(AuthSdkContext);
2018
- };
2019
- var useDatabase = function useDatabase() {
2020
- return useSdk(DatabaseSdkContext);
2021
- };
2022
- var useFirestore = function useFirestore() {
2023
- return useSdk(FirestoreSdkContext);
2024
- };
2025
- var usePerformance = function usePerformance() {
2026
- return useSdk(PerformanceSdkContext);
2027
- };
2028
- var useStorage = function useStorage() {
2029
- return useSdk(StorageSdkContext);
2030
- };
2031
- var useRemoteConfig = function useRemoteConfig() {
2032
- return useSdk(RemoteConfigSdkContext);
2033
- };
2034
- var useInitAuth = function useInitAuth(initializer, options) {
2035
- return useInitSdk('auth', AuthSdkContext, initializer, options);
2036
- };
2037
- var useInitDatabase = function useInitDatabase(initializer, options) {
2038
- return useInitSdk('database', DatabaseSdkContext, initializer, options);
2039
- };
2040
- var useInitFirestore = function useInitFirestore(initializer, options) {
2041
- return useInitSdk('firestore', FirestoreSdkContext, initializer, options);
2042
- };
2043
- var useInitPerformance = function useInitPerformance(initializer, options) {
2044
- return useInitSdk('performance', PerformanceSdkContext, initializer, options);
2045
- };
2046
- var useInitRemoteConfig = function useInitRemoteConfig(initializer, options) {
2047
- return useInitSdk('remoteconfig', RemoteConfigSdkContext, initializer, options);
2048
- };
2049
- var useInitStorage = function useInitStorage(initializer, options) {
2050
- return useInitSdk('storage', StorageSdkContext, initializer, options);
2051
- };
2052
-
2053
- var ReactFireError = /*#__PURE__*/function (_Error) {
2054
- _inheritsLoose(ReactFireError, _Error);
2055
-
2056
- function ReactFireError(code, message, customData) {
2057
- var _this;
2058
-
2059
- _this = _Error.call(this, message) || this;
2060
- _this.code = void 0;
2061
- _this.customData = void 0;
2062
- _this.name = 'ReactFireError';
2063
- _this.code = code;
2064
- _this.customData = customData; // Fix For ES5
2065
- // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
2066
-
2067
- Object.setPrototypeOf(_assertThisInitialized(_this), ReactFireError.prototype);
2068
- return _this;
2069
- }
2070
-
2071
- return ReactFireError;
2072
- }( /*#__PURE__*/_wrapNativeSuper(Error));
2073
- function checkOptions(options, field) {
2074
- // make sure the field passed in is a valid key of ReactFire Options
2075
- if (field === 'idField' || field === 'initialData' || field === 'suspense') {
2076
- return options ? options[field] : undefined;
2077
- }
2078
-
2079
- throw new Error("Field \"" + field + "\" is not a valid key in ReactFireOptions");
2080
- }
2081
- function checkinitialData(options) {
2082
- return checkOptions(options, 'initialData');
2083
- }
2084
- function checkIdField(options) {
2085
- return checkOptions(options, 'idField');
2086
- }
2087
-
2088
- export { AuthCheck, AuthProvider, ClaimsCheck, DatabaseProvider, FirebaseAppProvider, FirestoreProvider, PerformanceProvider, ReactFireError, RemoteConfigProvider, StorageImage, StorageProvider, SuspenseWithPerf, checkIdField, checkOptions, checkinitialData, preloadFirestoreDoc, preloadObservable, preloadUser, useAuth, useDatabase, useDatabaseList, useDatabaseListData, useDatabaseObject, useDatabaseObjectData, useFirebaseApp, useFirestore, useFirestoreCollection, useFirestoreCollectionData, useFirestoreDoc, useFirestoreDocData, useFirestoreDocDataOnce, useFirestoreDocOnce, useIdTokenResult, useInitAuth, useInitDatabase, useInitFirestore, useInitPerformance, useInitRemoteConfig, useInitStorage, useIsSuspenseEnabled, useObservable, usePerformance, useRemoteConfig, useRemoteConfigAll, useRemoteConfigBoolean, useRemoteConfigNumber, useRemoteConfigString, useRemoteConfigValue, useSigninCheck, useStorage, useStorageDownloadURL, useStorageTask, useSuspenseEnabledFromConfigAndContext, useUser, version };
2089
- //# sourceMappingURL=reactfire.esm.js.map