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