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