1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | var react = _interopDefault(require('react'));
|
8 | var reactDom = _interopDefault(require('react-dom'));
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | function sprintf(format, ...args) {
|
22 | let index = 0;
|
23 | return format.replace(/%s/g, () => String(args[index++]));
|
24 | }
|
25 |
|
26 | var Recoil_sprintf = sprintf;
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | function expectationViolation(format, ...args) {
|
33 |
|
34 | {
|
35 |
|
36 | const message = Recoil_sprintf.call(null, format, ...args);
|
37 |
|
38 | const error = new Error(message);
|
39 |
|
40 | error.name = 'Expectation Violation';
|
41 |
|
42 | console.error(error);
|
43 | }
|
44 |
|
45 | }
|
46 |
|
47 |
|
48 | var Recoil_expectationViolation = expectationViolation;
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function recoverableViolation( // @oss-only
|
67 | message, // @oss-only
|
68 | projectName, // @oss-only
|
69 | {
|
70 | error
|
71 | } = {}) {
|
72 |
|
73 | {
|
74 |
|
75 | console.error(message, error);
|
76 | }
|
77 |
|
78 |
|
79 | return null;
|
80 | }
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | var Recoil_recoverableViolation = recoverableViolation;
|
87 |
|
88 | function _defineProperty(obj, key, value) {
|
89 | if (key in obj) {
|
90 | Object.defineProperty(obj, key, {
|
91 | value: value,
|
92 | enumerable: true,
|
93 | configurable: true,
|
94 | writable: true
|
95 | });
|
96 | } else {
|
97 | obj[key] = value;
|
98 | }
|
99 |
|
100 | return obj;
|
101 | }
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | class AbstractRecoilValue {
|
116 | constructor(newKey) {
|
117 | _defineProperty(this, "key", void 0);
|
118 |
|
119 | this.key = newKey;
|
120 | }
|
121 |
|
122 | }
|
123 |
|
124 | class RecoilState extends AbstractRecoilValue {}
|
125 |
|
126 | class RecoilValueReadOnly extends AbstractRecoilValue {}
|
127 |
|
128 | function isRecoilValue(x) {
|
129 | return x instanceof RecoilState || x instanceof RecoilValueReadOnly;
|
130 | }
|
131 |
|
132 | var Recoil_RecoilValue = {
|
133 | AbstractRecoilValue,
|
134 | RecoilState,
|
135 | RecoilValueReadOnly,
|
136 | isRecoilValue
|
137 | };
|
138 |
|
139 | var Recoil_RecoilValue_1 = Recoil_RecoilValue.AbstractRecoilValue;
|
140 | var Recoil_RecoilValue_2 = Recoil_RecoilValue.RecoilState;
|
141 | var Recoil_RecoilValue_3 = Recoil_RecoilValue.RecoilValueReadOnly;
|
142 | var Recoil_RecoilValue_4 = Recoil_RecoilValue.isRecoilValue;
|
143 |
|
144 | var Recoil_RecoilValue$1 = Object.freeze({
|
145 | __proto__: null,
|
146 | AbstractRecoilValue: Recoil_RecoilValue_1,
|
147 | RecoilState: Recoil_RecoilValue_2,
|
148 | RecoilValueReadOnly: Recoil_RecoilValue_3,
|
149 | isRecoilValue: Recoil_RecoilValue_4
|
150 | });
|
151 |
|
152 | class DefaultValue {}
|
153 |
|
154 | const DEFAULT_VALUE = new DefaultValue();
|
155 |
|
156 | class RecoilValueNotReady extends Error {
|
157 | constructor(key) {
|
158 | super(`Tried to set the value of Recoil selector ${key} using an updater function, but it is an async selector in a pending or error state; this is not supported.`);
|
159 | }
|
160 |
|
161 | }
|
162 |
|
163 |
|
164 | const nodes = new Map();
|
165 |
|
166 |
|
167 | function registerNode(node) {
|
168 | if (nodes.has(node.key)) {
|
169 | const message = `Duplicate atom key "${node.key}". This is a FATAL ERROR in
|
170 | production. But it is safe to ignore this warning if it occurred because of
|
171 | hot module replacement.`;
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | Recoil_recoverableViolation(message);
|
183 | }
|
184 |
|
185 | nodes.set(node.key, node);
|
186 | return node.set == null ? new Recoil_RecoilValue$1.RecoilValueReadOnly(node.key) : new Recoil_RecoilValue$1.RecoilState(node.key);
|
187 | }
|
188 |
|
189 |
|
190 |
|
191 | class NodeMissingError extends Error {}
|
192 |
|
193 |
|
194 | function getNode(key) {
|
195 | const node = nodes.get(key);
|
196 |
|
197 | if (node == null) {
|
198 | throw new NodeMissingError(`Missing definition for RecoilValue: "${key}""`);
|
199 | }
|
200 |
|
201 | return node;
|
202 | }
|
203 |
|
204 | var Recoil_Node = {
|
205 | nodes,
|
206 | registerNode,
|
207 | getNode,
|
208 | NodeMissingError,
|
209 | DefaultValue,
|
210 | DEFAULT_VALUE,
|
211 | RecoilValueNotReady
|
212 | };
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 | function enqueueExecution(s, f) {
|
226 | f();
|
227 | }
|
228 |
|
229 | var Recoil_Queue = {
|
230 | enqueueExecution
|
231 | };
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | function setByAddingToSet(set, v) {
|
247 | const next = new Set(set);
|
248 | next.add(v);
|
249 | return next;
|
250 | }
|
251 |
|
252 | function setByDeletingFromSet(set, v) {
|
253 | const next = new Set(set);
|
254 | next.delete(v);
|
255 | return next;
|
256 | }
|
257 |
|
258 | function mapBySettingInMap(map, k, v) {
|
259 | const next = new Map(map);
|
260 | next.set(k, v);
|
261 | return next;
|
262 | }
|
263 |
|
264 | function mapByUpdatingInMap(map, k, updater) {
|
265 | const next = new Map(map);
|
266 | next.set(k, updater(next.get(k)));
|
267 | return next;
|
268 | }
|
269 |
|
270 | function mapByDeletingFromMap(map, k) {
|
271 | const next = new Map(map);
|
272 | next.delete(k);
|
273 | return next;
|
274 | }
|
275 |
|
276 | var Recoil_CopyOnWrite = {
|
277 | setByAddingToSet,
|
278 | setByDeletingFromSet,
|
279 | mapBySettingInMap,
|
280 | mapByUpdatingInMap,
|
281 | mapByDeletingFromMap
|
282 | };
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 | function trace(message, node, fn) {
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | return fn();
|
329 | }
|
330 |
|
331 | function wrap(fn) {
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | return fn;
|
343 | }
|
344 |
|
345 | var Recoil_Tracing = {
|
346 | trace,
|
347 | wrap
|
348 | };
|
349 |
|
350 | const {
|
351 | mapByDeletingFromMap: mapByDeletingFromMap$1,
|
352 | mapBySettingInMap: mapBySettingInMap$1,
|
353 | mapByUpdatingInMap: mapByUpdatingInMap$1,
|
354 | setByAddingToSet: setByAddingToSet$1
|
355 | } = Recoil_CopyOnWrite;
|
356 |
|
357 |
|
358 |
|
359 | const {
|
360 | getNode: getNode$1
|
361 | } = Recoil_Node;
|
362 |
|
363 |
|
364 | const emptyMap = Object.freeze(new Map());
|
365 |
|
366 | const emptySet = Object.freeze(new Set());
|
367 |
|
368 | class ReadOnlyRecoilValueError extends Error {}
|
369 |
|
370 |
|
371 |
|
372 |
|
373 | function getNodeLoadable(store, state, key) {
|
374 | return getNode$1(key).get(store, state);
|
375 | }
|
376 |
|
377 |
|
378 |
|
379 | function peekNodeLoadable(store, state, key) {
|
380 | return getNodeLoadable(store, state, key)[1];
|
381 | }
|
382 |
|
383 |
|
384 |
|
385 | function setUnvalidatedAtomValue(state, key, newValue) {
|
386 | return { ...state,
|
387 | atomValues: mapByDeletingFromMap$1(state.atomValues, key),
|
388 | nonvalidatedAtoms: mapBySettingInMap$1(state.nonvalidatedAtoms, key, newValue),
|
389 | dirtyAtoms: setByAddingToSet$1(state.dirtyAtoms, key)
|
390 | };
|
391 | }
|
392 |
|
393 |
|
394 |
|
395 | function setNodeValue(store, state, key, newValue) {
|
396 | const node = getNode$1(key);
|
397 |
|
398 | if (node.set == null) {
|
399 | throw new ReadOnlyRecoilValueError(`Attempt to set read-only RecoilValue: ${key}`);
|
400 | }
|
401 |
|
402 | const [newState, writtenNodes] = node.set(store, state, newValue);
|
403 | return [newState, writtenNodes];
|
404 | }
|
405 |
|
406 |
|
407 | function getDownstreamNodes(state, keys) {
|
408 | const dependentNodes = new Set();
|
409 | const visitedNodes = new Set();
|
410 | const visitingNodes = Array.from(keys);
|
411 |
|
412 | for (let key = visitingNodes.pop(); key; key = visitingNodes.pop()) {
|
413 | var _state$nodeToNodeSubs;
|
414 |
|
415 | dependentNodes.add(key);
|
416 | visitedNodes.add(key);
|
417 | const subscribedNodes = (_state$nodeToNodeSubs = state.nodeToNodeSubscriptions.get(key)) !== null && _state$nodeToNodeSubs !== void 0 ? _state$nodeToNodeSubs : emptySet;
|
418 |
|
419 | for (const downstreamNode of subscribedNodes) {
|
420 | if (!visitedNodes.has(downstreamNode)) {
|
421 | visitingNodes.push(downstreamNode);
|
422 | }
|
423 | }
|
424 | }
|
425 |
|
426 | return dependentNodes;
|
427 | }
|
428 |
|
429 | let subscriptionID = 0;
|
430 |
|
431 | function subscribeComponentToNode(state, key, callback) {
|
432 | const subID = subscriptionID++;
|
433 | const newState = { ...state,
|
434 | nodeToComponentSubscriptions: mapByUpdatingInMap$1(state.nodeToComponentSubscriptions, key, subsForAtom => mapBySettingInMap$1(subsForAtom !== null && subsForAtom !== void 0 ? subsForAtom : emptyMap, subID, ['TODO debug name', callback]))
|
435 | };
|
436 |
|
437 | function release(state) {
|
438 | const newState = { ...state,
|
439 | nodeToComponentSubscriptions: mapByUpdatingInMap$1(state.nodeToComponentSubscriptions, key, subsForAtom => mapByDeletingFromMap$1(subsForAtom !== null && subsForAtom !== void 0 ? subsForAtom : emptyMap, subID))
|
440 | };
|
441 | return newState;
|
442 | }
|
443 |
|
444 | return [newState, release];
|
445 | }
|
446 |
|
447 |
|
448 |
|
449 | function fireNodeSubscriptions(store, updatedNodes, when) {
|
450 | var _store$getState$nextT;
|
451 |
|
452 | |
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | const state = when === 'enqueue' ? (_store$getState$nextT = store.getState().nextTree) !== null && _store$getState$nextT !== void 0 ? _store$getState$nextT : store.getState().currentTree : store.getState().currentTree;
|
461 | const dependentNodes = getDownstreamNodes(state, updatedNodes);
|
462 |
|
463 | for (const key of dependentNodes) {
|
464 | var _state$nodeToComponen;
|
465 |
|
466 | ((_state$nodeToComponen = state.nodeToComponentSubscriptions.get(key)) !== null && _state$nodeToComponen !== void 0 ? _state$nodeToComponen : []).forEach(([_debugName, cb]) => {
|
467 | when === 'enqueue' ? store.getState().queuedComponentCallbacks.push(cb) : cb(state);
|
468 | });
|
469 | }
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | Recoil_Tracing.trace('value became available, waking components', Array.from(updatedNodes).join(', '), () => {
|
478 | const resolvers = store.getState().suspendedComponentResolvers;
|
479 | resolvers.forEach(r => r());
|
480 | resolvers.clear();
|
481 | });
|
482 | }
|
483 |
|
484 | function detectCircularDependencies(state, stack) {
|
485 | if (!stack.length) {
|
486 | return;
|
487 | }
|
488 |
|
489 | const leaf = stack[stack.length - 1];
|
490 | const downstream = state.nodeToNodeSubscriptions.get(leaf);
|
491 |
|
492 | if (!(downstream === null || downstream === void 0 ? void 0 : downstream.size)) {
|
493 | return;
|
494 | }
|
495 |
|
496 | const root = stack[0];
|
497 |
|
498 | if (downstream.has(root)) {
|
499 | throw new Error(`Recoil selector has circular dependencies: ${[...stack, root].reverse().join(' \u2192 ')}`);
|
500 | }
|
501 |
|
502 | for (const next of downstream) {
|
503 | detectCircularDependencies(state, [...stack, next]);
|
504 | }
|
505 | }
|
506 |
|
507 | var Recoil_FunctionalCore = {
|
508 | getNodeLoadable,
|
509 | peekNodeLoadable,
|
510 | setNodeValue,
|
511 | setUnvalidatedAtomValue,
|
512 | subscribeComponentToNode,
|
513 | fireNodeSubscriptions,
|
514 | detectCircularDependencies
|
515 | };
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 | function mapMap(map, callback) {
|
533 | const result = new Map();
|
534 | map.forEach((value, key) => {
|
535 | result.set(key, callback(value, key));
|
536 | });
|
537 | return result;
|
538 | }
|
539 |
|
540 | var Recoil_mapMap = mapMap;
|
541 |
|
542 | const {
|
543 | getNodeLoadable: getNodeLoadable$1,
|
544 | peekNodeLoadable: peekNodeLoadable$1,
|
545 | setNodeValue: setNodeValue$1,
|
546 | setUnvalidatedAtomValue: setUnvalidatedAtomValue$1,
|
547 | subscribeComponentToNode: subscribeComponentToNode$1
|
548 | } = Recoil_FunctionalCore;
|
549 |
|
550 | const {
|
551 | RecoilValueNotReady: RecoilValueNotReady$1
|
552 | } = Recoil_Node;
|
553 |
|
554 | const {
|
555 | AbstractRecoilValue: AbstractRecoilValue$1,
|
556 | RecoilState: RecoilState$1,
|
557 | RecoilValueReadOnly: RecoilValueReadOnly$1
|
558 | } = Recoil_RecoilValue$1;
|
559 |
|
560 | function getRecoilValueAsLoadable(store, {
|
561 | key
|
562 | }) {
|
563 | let result;
|
564 |
|
565 |
|
566 | Recoil_Tracing.trace('get RecoilValue', key, () => store.replaceState(Recoil_Tracing.wrap(state => {
|
567 | const [newState, loadable] = getNodeLoadable$1(store, state, key);
|
568 | result = loadable;
|
569 | return newState;
|
570 | })));
|
571 | return result;
|
572 | }
|
573 |
|
574 | function setRecoilValue(store, {
|
575 | key
|
576 | }, newValue) {
|
577 | Recoil_Tracing.trace('set RecoilValue', key, () => store.replaceState(Recoil_Tracing.wrap(state => {
|
578 | const [newState, writtenNodes] = setNodeValue$1(store, state, key, newValue);
|
579 | store.fireNodeSubscriptions(writtenNodes, 'enqueue');
|
580 | return newState;
|
581 | })));
|
582 | }
|
583 |
|
584 | function setUnvalidatedRecoilValue(store, {
|
585 | key
|
586 | }, newValue) {
|
587 | Recoil_Tracing.trace('set unvalidated persisted atom', key, () => store.replaceState(Recoil_Tracing.wrap(state => {
|
588 | const newState = setUnvalidatedAtomValue$1(state, key, newValue);
|
589 | store.fireNodeSubscriptions(new Set([key]), 'enqueue');
|
590 | return newState;
|
591 | })));
|
592 | }
|
593 |
|
594 | function valueFromValueOrUpdater(store, {
|
595 | key
|
596 | }, valueOrUpdater) {
|
597 | if (typeof valueOrUpdater === 'function') {
|
598 | var _storeState$nextTree;
|
599 |
|
600 |
|
601 |
|
602 |
|
603 | const storeState = store.getState();
|
604 | const state = (_storeState$nextTree = storeState.nextTree) !== null && _storeState$nextTree !== void 0 ? _storeState$nextTree : storeState.currentTree;
|
605 |
|
606 | const current = peekNodeLoadable$1(store, state, key);
|
607 |
|
608 | if (current.state === 'loading') {
|
609 | throw new RecoilValueNotReady$1(key);
|
610 | } else if (current.state === 'hasError') {
|
611 | throw current.contents;
|
612 | }
|
613 |
|
614 |
|
615 | return valueOrUpdater(current.contents);
|
616 | } else {
|
617 | return valueOrUpdater;
|
618 | }
|
619 | }
|
620 |
|
621 | function subscribeToRecoilValue(store, {
|
622 | key
|
623 | }, callback) {
|
624 | let newState, releaseFn;
|
625 | Recoil_Tracing.trace('subscribe component to RecoilValue', key, () => store.replaceState(Recoil_Tracing.wrap(state => {
|
626 | [newState, releaseFn] = subscribeComponentToNode$1(state, key, callback);
|
627 | return newState;
|
628 | })));
|
629 | return {
|
630 | release: store => store.replaceState(releaseFn)
|
631 | };
|
632 | }
|
633 |
|
634 | var Recoil_RecoilValueInterface = {
|
635 | RecoilValueReadOnly: RecoilValueReadOnly$1,
|
636 | AbstractRecoilValue: AbstractRecoilValue$1,
|
637 | RecoilState: RecoilState$1,
|
638 | valueFromValueOrUpdater,
|
639 | getRecoilValueAsLoadable,
|
640 | setRecoilValue,
|
641 | setUnvalidatedRecoilValue,
|
642 | subscribeToRecoilValue
|
643 | };
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 | function makeEmptyTreeState() {
|
663 | return {
|
664 | transactionMetadata: {},
|
665 | atomValues: new Map(),
|
666 | nonvalidatedAtoms: new Map(),
|
667 | dirtyAtoms: new Set(),
|
668 | nodeDeps: new Map(),
|
669 | nodeToNodeSubscriptions: new Map(),
|
670 | nodeToComponentSubscriptions: new Map()
|
671 | };
|
672 | }
|
673 |
|
674 | function makeStoreState(treeState) {
|
675 | return {
|
676 | currentTree: treeState,
|
677 | nextTree: null,
|
678 | transactionSubscriptions: new Map(),
|
679 | queuedComponentCallbacks: [],
|
680 | suspendedComponentResolvers: new Set()
|
681 | };
|
682 | }
|
683 |
|
684 | function makeEmptyStoreState() {
|
685 | return makeStoreState(makeEmptyTreeState());
|
686 | }
|
687 |
|
688 | var Recoil_State = {
|
689 | makeEmptyTreeState,
|
690 | makeEmptyStoreState,
|
691 | makeStoreState
|
692 | };
|
693 |
|
694 | const {
|
695 | DEFAULT_VALUE: DEFAULT_VALUE$1
|
696 | } = Recoil_Node;
|
697 |
|
698 | const {
|
699 | getRecoilValueAsLoadable: getRecoilValueAsLoadable$1,
|
700 | setRecoilValue: setRecoilValue$1,
|
701 | valueFromValueOrUpdater: valueFromValueOrUpdater$1
|
702 | } = Recoil_RecoilValueInterface;
|
703 |
|
704 | const {
|
705 | makeEmptyTreeState: makeEmptyTreeState$1,
|
706 | makeStoreState: makeStoreState$1
|
707 | } = Recoil_State;
|
708 |
|
709 | function makeStore(treeState) {
|
710 | const storeState = makeStoreState$1(treeState);
|
711 | const store = {
|
712 | getState: () => storeState,
|
713 | replaceState: replacer => {
|
714 | storeState.currentTree = replacer(storeState.currentTree);
|
715 | },
|
716 | subscribeToTransactions: () => {
|
717 | throw new Error('Cannot subscribe to Snapshots');
|
718 | },
|
719 | addTransactionMetadata: () => {
|
720 | throw new Error('Cannot subscribe to Snapshots');
|
721 | },
|
722 | fireNodeSubscriptions: () => {}
|
723 | };
|
724 | return store;
|
725 | }
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | class Snapshot {
|
731 | constructor(treeState) {
|
732 | _defineProperty(this, "_store", void 0);
|
733 |
|
734 | _defineProperty(this, "getLoadable", recoilValue => getRecoilValueAsLoadable$1(this._store, recoilValue));
|
735 |
|
736 | _defineProperty(this, "getPromise", recoilValue => this.getLoadable(recoilValue).toPromise());
|
737 |
|
738 | _defineProperty(this, "map", mapper => {
|
739 | const mutableSnapshot = new MutableSnapshot(this._store.getState().currentTree);
|
740 | mapper(mutableSnapshot);
|
741 | const newState = mutableSnapshot.getStore_INTERNAL().getState().currentTree;
|
742 | return cloneSnapshot(newState);
|
743 | });
|
744 |
|
745 | _defineProperty(this, "asyncMap", async mapper => {
|
746 | const mutableSnapshot = new MutableSnapshot(this._store.getState().currentTree);
|
747 | await mapper(mutableSnapshot);
|
748 | const newState = mutableSnapshot.getStore_INTERNAL().getState().currentTree;
|
749 | return cloneSnapshot(newState);
|
750 | });
|
751 |
|
752 | this._store = makeStore(treeState);
|
753 | }
|
754 |
|
755 | getStore_INTERNAL() {
|
756 | return this._store;
|
757 | }
|
758 |
|
759 | }
|
760 |
|
761 | function cloneTreeState(treeState) {
|
762 | return {
|
763 | transactionMetadata: { ...treeState.transactionMetadata
|
764 | },
|
765 | atomValues: new Map(treeState.atomValues),
|
766 | nonvalidatedAtoms: new Map(treeState.nonvalidatedAtoms),
|
767 | dirtyAtoms: new Set(treeState.dirtyAtoms),
|
768 | nodeDeps: new Map(treeState.nodeDeps),
|
769 | nodeToNodeSubscriptions: Recoil_mapMap(treeState.nodeToNodeSubscriptions, keys => new Set(keys)),
|
770 | nodeToComponentSubscriptions: new Map()
|
771 | };
|
772 | }
|
773 |
|
774 |
|
775 | function freshSnapshot() {
|
776 | return new Snapshot(makeEmptyTreeState$1());
|
777 | }
|
778 |
|
779 |
|
780 | function cloneSnapshot(treeState) {
|
781 | return new Snapshot(cloneTreeState(treeState));
|
782 | }
|
783 |
|
784 | class MutableSnapshot extends Snapshot {
|
785 | constructor(treeState) {
|
786 | super(cloneTreeState(treeState));
|
787 |
|
788 | _defineProperty(this, "set", (recoilState, newValueOrUpdater) => {
|
789 | const store = this.getStore_INTERNAL();
|
790 | const newValue = valueFromValueOrUpdater$1(store, recoilState, newValueOrUpdater);
|
791 | setRecoilValue$1(store, recoilState, newValue);
|
792 | });
|
793 |
|
794 | _defineProperty(this, "reset", recoilState => setRecoilValue$1(this.getStore_INTERNAL(), recoilState, DEFAULT_VALUE$1));
|
795 | }
|
796 |
|
797 |
|
798 |
|
799 | }
|
800 |
|
801 | var Recoil_Snapshot = {
|
802 | Snapshot,
|
803 | MutableSnapshot,
|
804 | freshSnapshot,
|
805 | cloneSnapshot
|
806 | };
|
807 |
|
808 | var Recoil_Snapshot_1 = Recoil_Snapshot.Snapshot;
|
809 | var Recoil_Snapshot_2 = Recoil_Snapshot.MutableSnapshot;
|
810 | var Recoil_Snapshot_3 = Recoil_Snapshot.freshSnapshot;
|
811 | var Recoil_Snapshot_4 = Recoil_Snapshot.cloneSnapshot;
|
812 |
|
813 | var Recoil_Snapshot$1 = Object.freeze({
|
814 | __proto__: null,
|
815 | Snapshot: Recoil_Snapshot_1,
|
816 | MutableSnapshot: Recoil_Snapshot_2,
|
817 | freshSnapshot: Recoil_Snapshot_3,
|
818 | cloneSnapshot: Recoil_Snapshot_4
|
819 | });
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 | function nullthrows(x, message) {
|
833 | if (x != null) {
|
834 | return x;
|
835 | }
|
836 |
|
837 | throw new Error(message !== null && message !== void 0 ? message : 'Got unexpected null or undefined');
|
838 | }
|
839 |
|
840 | var Recoil_nullthrows = nullthrows;
|
841 |
|
842 | const {
|
843 | useContext,
|
844 | useEffect,
|
845 | useRef,
|
846 | useState
|
847 | } = react;
|
848 |
|
849 |
|
850 |
|
851 | const {
|
852 | fireNodeSubscriptions: fireNodeSubscriptions$1,
|
853 | setNodeValue: setNodeValue$2,
|
854 | setUnvalidatedAtomValue: setUnvalidatedAtomValue$2
|
855 | } = Recoil_FunctionalCore;
|
856 |
|
857 | const {
|
858 | freshSnapshot: freshSnapshot$1
|
859 | } = Recoil_Snapshot$1;
|
860 |
|
861 | const {
|
862 | makeEmptyStoreState: makeEmptyStoreState$1,
|
863 | makeStoreState: makeStoreState$2
|
864 | } = Recoil_State;
|
865 |
|
866 |
|
867 |
|
868 | function notInAContext() {
|
869 | throw new Error('This component must be used inside a <RecoilRoot> component.');
|
870 | }
|
871 |
|
872 | const defaultStore = Object.freeze({
|
873 | getState: notInAContext,
|
874 | replaceState: notInAContext,
|
875 | subscribeToTransactions: notInAContext,
|
876 | addTransactionMetadata: notInAContext,
|
877 | fireNodeSubscriptions: notInAContext
|
878 | });
|
879 |
|
880 | function startNextTreeIfNeeded(storeState) {
|
881 | if (storeState.nextTree === null) {
|
882 | storeState.nextTree = { ...storeState.currentTree,
|
883 | dirtyAtoms: new Set(),
|
884 | transactionMetadata: {}
|
885 | };
|
886 | }
|
887 | }
|
888 |
|
889 | const AppContext = react.createContext({
|
890 | current: defaultStore
|
891 | });
|
892 |
|
893 | const useStoreRef = () => useContext(AppContext);
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 | function Batcher(props) {
|
903 | const storeRef = useStoreRef();
|
904 | const [_, setState] = useState([]);
|
905 | props.setNotifyBatcherOfChange(() => setState({}));
|
906 | useEffect(() => {
|
907 |
|
908 |
|
909 |
|
910 | Recoil_Queue.enqueueExecution('Batcher', () => {
|
911 | const storeState = storeRef.current.getState();
|
912 | const {
|
913 | nextTree
|
914 | } = storeState;
|
915 |
|
916 |
|
917 | if (nextTree === null) {
|
918 | return;
|
919 | }
|
920 |
|
921 |
|
922 | const dirtyAtoms = nextTree.dirtyAtoms;
|
923 |
|
924 | if (dirtyAtoms.size) {
|
925 | storeState.transactionSubscriptions.forEach(sub => sub(storeRef.current));
|
926 | }
|
927 |
|
928 |
|
929 |
|
930 | storeState.queuedComponentCallbacks.forEach(cb => cb(nextTree));
|
931 | storeState.queuedComponentCallbacks.splice(0, storeState.queuedComponentCallbacks.length);
|
932 |
|
933 |
|
934 | storeState.currentTree = nextTree;
|
935 | storeState.nextTree = null;
|
936 | });
|
937 | });
|
938 | return null;
|
939 | }
|
940 |
|
941 | {
|
942 | if (typeof window !== 'undefined' && !window.$recoilDebugStates) {
|
943 | window.$recoilDebugStates = [];
|
944 | }
|
945 | }
|
946 |
|
947 | function initialStoreState_DEPRECATED(store, initializeState) {
|
948 | const initial = makeEmptyStoreState$1();
|
949 | initializeState({
|
950 | set: (atom, value) => {
|
951 | initial.currentTree = setNodeValue$2(store, initial.currentTree, atom.key, value)[0];
|
952 | },
|
953 | setUnvalidatedAtomValues: atomValues => {
|
954 | atomValues.forEach((v, k) => {
|
955 | initial.currentTree = setUnvalidatedAtomValue$2(initial.currentTree, k, v);
|
956 | });
|
957 | }
|
958 | });
|
959 | return initial;
|
960 | }
|
961 |
|
962 | function initialStoreState(initializeState) {
|
963 | const snapshot = freshSnapshot$1().map(initializeState);
|
964 | return makeStoreState$2(snapshot.getStore_INTERNAL().getState().currentTree);
|
965 | }
|
966 |
|
967 | let nextID = 0;
|
968 |
|
969 | function RecoilRoot({
|
970 | initializeState_DEPRECATED,
|
971 | initializeState,
|
972 | children
|
973 | }) {
|
974 | let storeState;
|
975 |
|
976 | const subscribeToTransactions = callback => {
|
977 | const id = nextID++;
|
978 | storeRef.current.getState().transactionSubscriptions.set(id, callback);
|
979 | return {
|
980 | release: () => {
|
981 | storeRef.current.getState().transactionSubscriptions.delete(id);
|
982 | }
|
983 | };
|
984 | };
|
985 |
|
986 | const addTransactionMetadata = metadata => {
|
987 | startNextTreeIfNeeded(storeRef.current.getState());
|
988 |
|
989 | for (const k of Object.keys(metadata)) {
|
990 | Recoil_nullthrows(storeRef.current.getState().nextTree).transactionMetadata[k] = metadata[k];
|
991 | }
|
992 | };
|
993 |
|
994 | function fireNodeSubscriptionsForStore(updatedNodes, when) {
|
995 | fireNodeSubscriptions$1(storeRef.current, updatedNodes, when);
|
996 | }
|
997 |
|
998 | const replaceState = replacer => {
|
999 | const storeState = storeRef.current.getState();
|
1000 | startNextTreeIfNeeded(storeState);
|
1001 |
|
1002 | const nextTree = Recoil_nullthrows(storeState.nextTree);
|
1003 | const replaced = replacer(nextTree);
|
1004 |
|
1005 | if (replaced === nextTree) {
|
1006 | return;
|
1007 | }
|
1008 |
|
1009 | {
|
1010 | if (typeof window !== 'undefined') {
|
1011 | window.$recoilDebugStates.push(replaced);
|
1012 | }
|
1013 | }
|
1014 |
|
1015 |
|
1016 | storeState.nextTree = replaced;
|
1017 | Recoil_nullthrows(notifyBatcherOfChange.current)();
|
1018 | };
|
1019 |
|
1020 | const notifyBatcherOfChange = useRef(null);
|
1021 |
|
1022 | function setNotifyBatcherOfChange(x) {
|
1023 | notifyBatcherOfChange.current = x;
|
1024 | }
|
1025 |
|
1026 | const store = {
|
1027 | getState: () => storeState.current,
|
1028 | replaceState,
|
1029 | subscribeToTransactions,
|
1030 | addTransactionMetadata,
|
1031 | fireNodeSubscriptions: fireNodeSubscriptionsForStore
|
1032 | };
|
1033 | const storeRef = useRef(store);
|
1034 | storeState = useRef(initializeState_DEPRECATED != null ? initialStoreState_DEPRECATED(store, initializeState_DEPRECATED) : initializeState != null ? initialStoreState(initializeState) : makeEmptyStoreState$1());
|
1035 | return react.createElement(AppContext.Provider, {
|
1036 | value: storeRef
|
1037 | }, react.createElement(Batcher, {
|
1038 | setNotifyBatcherOfChange: setNotifyBatcherOfChange
|
1039 | }), children);
|
1040 | }
|
1041 |
|
1042 | var Recoil_RecoilRoot_react = {
|
1043 | useStoreRef,
|
1044 | RecoilRoot
|
1045 | };
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | function differenceSets(set, ...setsWithValuesToRemove) {
|
1066 | const ret = new Set();
|
1067 |
|
1068 | FIRST: for (const value of set) {
|
1069 | for (const otherSet of setsWithValuesToRemove) {
|
1070 | if (otherSet.has(value)) {
|
1071 | continue FIRST;
|
1072 | }
|
1073 | }
|
1074 |
|
1075 | ret.add(value);
|
1076 | }
|
1077 |
|
1078 | return ret;
|
1079 | }
|
1080 |
|
1081 | var Recoil_differenceSets = differenceSets;
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 | function filterMap(map, callback) {
|
1099 | const result = new Map();
|
1100 |
|
1101 | for (const [key, value] of map) {
|
1102 | if (callback(value, key)) {
|
1103 | result.set(key, value);
|
1104 | }
|
1105 | }
|
1106 |
|
1107 | return result;
|
1108 | }
|
1109 |
|
1110 | var Recoil_filterMap = filterMap;
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 | function intersectSets(first, ...rest) {
|
1130 | const ret = new Set();
|
1131 |
|
1132 | FIRST: for (const value of first) {
|
1133 | for (const otherSet of rest) {
|
1134 | if (!otherSet.has(value)) {
|
1135 | continue FIRST;
|
1136 | }
|
1137 | }
|
1138 |
|
1139 | ret.add(value);
|
1140 | }
|
1141 |
|
1142 | return ret;
|
1143 | }
|
1144 |
|
1145 | var Recoil_intersectSets = intersectSets;
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 | function invariant(condition, message) {
|
1160 |
|
1161 | if (!condition) {
|
1162 |
|
1163 | throw new Error(message);
|
1164 | }
|
1165 |
|
1166 | }
|
1167 |
|
1168 |
|
1169 | var Recoil_invariant = invariant;
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 | function mergeMaps(...maps) {
|
1183 | const result = new Map();
|
1184 |
|
1185 | for (let i = 0; i < maps.length; i++) {
|
1186 | const iterator = maps[i].keys();
|
1187 | let nextKey;
|
1188 |
|
1189 | while (!(nextKey = iterator.next()).done) {
|
1190 |
|
1191 | result.set(nextKey.value, maps[i].get(nextKey.value));
|
1192 | }
|
1193 | }
|
1194 | |
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 | return result;
|
1200 | }
|
1201 |
|
1202 | var Recoil_mergeMaps = mergeMaps;
|
1203 |
|
1204 | const {
|
1205 | useCallback,
|
1206 | useEffect: useEffect$1,
|
1207 | useMemo,
|
1208 | useRef: useRef$1,
|
1209 | useState: useState$1
|
1210 | } = react;
|
1211 |
|
1212 |
|
1213 |
|
1214 | const {
|
1215 | peekNodeLoadable: peekNodeLoadable$2,
|
1216 | setNodeValue: setNodeValue$3
|
1217 | } = Recoil_FunctionalCore;
|
1218 |
|
1219 | const {
|
1220 | DEFAULT_VALUE: DEFAULT_VALUE$2,
|
1221 | getNode: getNode$2,
|
1222 | nodes: nodes$1
|
1223 | } = Recoil_Node;
|
1224 |
|
1225 | const {
|
1226 | useStoreRef: useStoreRef$1
|
1227 | } = Recoil_RecoilRoot_react;
|
1228 |
|
1229 | const {
|
1230 | isRecoilValue: isRecoilValue$1
|
1231 | } = Recoil_RecoilValue$1;
|
1232 |
|
1233 | const {
|
1234 | AbstractRecoilValue: AbstractRecoilValue$2,
|
1235 | getRecoilValueAsLoadable: getRecoilValueAsLoadable$2,
|
1236 | setRecoilValue: setRecoilValue$2,
|
1237 | setUnvalidatedRecoilValue: setUnvalidatedRecoilValue$1,
|
1238 | subscribeToRecoilValue: subscribeToRecoilValue$1,
|
1239 | valueFromValueOrUpdater: valueFromValueOrUpdater$2
|
1240 | } = Recoil_RecoilValueInterface;
|
1241 |
|
1242 | const {
|
1243 | Snapshot: Snapshot$1,
|
1244 | cloneSnapshot: cloneSnapshot$1
|
1245 | } = Recoil_Snapshot$1;
|
1246 |
|
1247 | const {
|
1248 | setByAddingToSet: setByAddingToSet$2
|
1249 | } = Recoil_CopyOnWrite;
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 | function cloneState_DEPRECATED(state) {
|
1270 | return {
|
1271 | transactionMetadata: { ...state.transactionMetadata
|
1272 | },
|
1273 | atomValues: new Map(state.atomValues),
|
1274 | nonvalidatedAtoms: new Map(state.nonvalidatedAtoms),
|
1275 | dirtyAtoms: new Set(state.dirtyAtoms),
|
1276 | nodeDeps: new Map(state.nodeDeps),
|
1277 | nodeToNodeSubscriptions: Recoil_mapMap(state.nodeToNodeSubscriptions, keys => new Set(keys)),
|
1278 | nodeToComponentSubscriptions: Recoil_mapMap(state.nodeToComponentSubscriptions, subsByAtom => new Map(subsByAtom))
|
1279 | };
|
1280 | }
|
1281 |
|
1282 | function handleLoadable(loadable, atom, storeRef) {
|
1283 |
|
1284 |
|
1285 |
|
1286 | if (loadable.state === 'hasValue') {
|
1287 | return loadable.contents;
|
1288 | } else if (loadable.state === 'loading') {
|
1289 | const promise = new Promise(resolve => {
|
1290 | storeRef.current.getState().suspendedComponentResolvers.add(resolve);
|
1291 | });
|
1292 | throw promise;
|
1293 | } else if (loadable.state === 'hasError') {
|
1294 | throw loadable.contents;
|
1295 | } else {
|
1296 | throw new Error(`Invalid value of loadable atom "${atom.key}"`);
|
1297 | }
|
1298 | }
|
1299 |
|
1300 | function validateRecoilValue(recoilValue, hookName) {
|
1301 | if (!isRecoilValue$1(recoilValue)) {
|
1302 | throw new Error(`Invalid argument to ${hookName}: expected an atom or selector but got ${String(recoilValue)}`);
|
1303 | }
|
1304 | }
|
1305 |
|
1306 | function useInterface() {
|
1307 | const storeRef = useStoreRef$1();
|
1308 | const [_, forceUpdate] = useState$1([]);
|
1309 | const recoilValuesUsed = useRef$1(new Set());
|
1310 | recoilValuesUsed.current = new Set();
|
1311 |
|
1312 | const previousSubscriptions = useRef$1(new Set());
|
1313 | const subscriptions = useRef$1(new Map());
|
1314 | const unsubscribeFrom = useCallback(key => {
|
1315 | const sub = subscriptions.current.get(key);
|
1316 |
|
1317 | if (sub) {
|
1318 | sub.release(storeRef.current);
|
1319 | subscriptions.current.delete(key);
|
1320 | }
|
1321 | }, [storeRef, subscriptions]);
|
1322 | useEffect$1(() => {
|
1323 | const store = storeRef.current;
|
1324 |
|
1325 | function updateState(_state, key) {
|
1326 | if (!subscriptions.current.has(key)) {
|
1327 | return;
|
1328 | }
|
1329 |
|
1330 | forceUpdate([]);
|
1331 | }
|
1332 |
|
1333 | Recoil_differenceSets(recoilValuesUsed.current, previousSubscriptions.current).forEach(key => {
|
1334 | if (subscriptions.current.has(key)) {
|
1335 | Recoil_expectationViolation(`Double subscription to RecoilValue "${key}"`);
|
1336 | return;
|
1337 | }
|
1338 |
|
1339 | const sub = subscribeToRecoilValue$1(store, new AbstractRecoilValue$2(key), state => {
|
1340 | Recoil_Tracing.trace('RecoilValue subscription fired', key, () => {
|
1341 | updateState(state, key);
|
1342 | });
|
1343 | });
|
1344 | subscriptions.current.set(key, sub);
|
1345 | Recoil_Tracing.trace('initial update on subscribing', key, () => {
|
1346 | updateState(store.getState(), key);
|
1347 | });
|
1348 | });
|
1349 | Recoil_differenceSets(previousSubscriptions.current, recoilValuesUsed.current).forEach(key => {
|
1350 | unsubscribeFrom(key);
|
1351 | });
|
1352 | previousSubscriptions.current = recoilValuesUsed.current;
|
1353 | });
|
1354 | useEffect$1(() => {
|
1355 | const subs = subscriptions.current;
|
1356 | return () => subs.forEach((_, key) => unsubscribeFrom(key));
|
1357 | }, [unsubscribeFrom]);
|
1358 | return useMemo(() => {
|
1359 | function useSetRecoilState(recoilState) {
|
1360 | {
|
1361 | validateRecoilValue(recoilState, 'useSetRecoilState');
|
1362 | }
|
1363 |
|
1364 | return newValueOrUpdater => {
|
1365 | const newValue = valueFromValueOrUpdater$2(storeRef.current, recoilState, newValueOrUpdater);
|
1366 | setRecoilValue$2(storeRef.current, recoilState, newValue);
|
1367 | };
|
1368 | }
|
1369 |
|
1370 | function useResetRecoilState(recoilState) {
|
1371 | {
|
1372 | validateRecoilValue(recoilState, 'useResetRecoilState');
|
1373 | }
|
1374 |
|
1375 | return () => setRecoilValue$2(storeRef.current, recoilState, DEFAULT_VALUE$2);
|
1376 | }
|
1377 |
|
1378 | function useRecoilValueLoadable(recoilValue) {
|
1379 | {
|
1380 | validateRecoilValue(recoilValue, 'useRecoilValueLoadable');
|
1381 | }
|
1382 |
|
1383 | if (!recoilValuesUsed.current.has(recoilValue.key)) {
|
1384 | recoilValuesUsed.current = setByAddingToSet$2(recoilValuesUsed.current, recoilValue.key);
|
1385 | }
|
1386 |
|
1387 |
|
1388 | return getRecoilValueAsLoadable$2(storeRef.current, recoilValue);
|
1389 | }
|
1390 |
|
1391 | function useRecoilValue(recoilValue) {
|
1392 | {
|
1393 | validateRecoilValue(recoilValue, 'useRecoilValue');
|
1394 | }
|
1395 |
|
1396 | const loadable = useRecoilValueLoadable(recoilValue);
|
1397 | return handleLoadable(loadable, recoilValue, storeRef);
|
1398 | }
|
1399 |
|
1400 | function useRecoilState(recoilState) {
|
1401 | {
|
1402 | validateRecoilValue(recoilState, 'useRecoilState');
|
1403 | }
|
1404 |
|
1405 | return [useRecoilValue(recoilState), useSetRecoilState(recoilState)];
|
1406 | }
|
1407 |
|
1408 | function useRecoilStateLoadable(recoilState) {
|
1409 | {
|
1410 | validateRecoilValue(recoilState, 'useRecoilStateLoadable');
|
1411 | }
|
1412 |
|
1413 | return [useRecoilValueLoadable(recoilState), useSetRecoilState(recoilState)];
|
1414 | }
|
1415 |
|
1416 | return {
|
1417 | getRecoilValue: useRecoilValue,
|
1418 | getRecoilValueLoadable: useRecoilValueLoadable,
|
1419 | getRecoilState: useRecoilState,
|
1420 | getRecoilStateLoadable: useRecoilStateLoadable,
|
1421 | getSetRecoilState: useSetRecoilState,
|
1422 | getResetRecoilState: useResetRecoilState
|
1423 | };
|
1424 | }, [recoilValuesUsed, storeRef]);
|
1425 | }
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 | function useRecoilValue(recoilValue) {
|
1435 | return useInterface().getRecoilValue(recoilValue);
|
1436 | }
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 | function useRecoilValueLoadable(recoilValue) {
|
1444 | return useInterface().getRecoilValueLoadable(recoilValue);
|
1445 | }
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 | function useSetRecoilState(recoilState) {
|
1453 | return useCallback(useInterface().getSetRecoilState(recoilState), [recoilState]);
|
1454 | }
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 | function useResetRecoilState(recoilState) {
|
1461 | return useCallback(useInterface().getResetRecoilState(recoilState), [recoilState]);
|
1462 | }
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 | function useRecoilState(recoilState) {
|
1473 | const recoilInterface = useInterface();
|
1474 | const [value] = recoilInterface.getRecoilState(recoilState);
|
1475 | const setValue = useCallback(recoilInterface.getSetRecoilState(recoilState), [recoilState]);
|
1476 | return [value, setValue];
|
1477 | }
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 | function useRecoilStateLoadable(recoilState) {
|
1486 | const recoilInterface = useInterface();
|
1487 | const [value] = recoilInterface.getRecoilStateLoadable(recoilState);
|
1488 | const setValue = useCallback(recoilInterface.getSetRecoilState(recoilState), [recoilState]);
|
1489 | return [value, setValue];
|
1490 | }
|
1491 |
|
1492 | function useTransactionSubscription(callback) {
|
1493 | const storeRef = useStoreRef$1();
|
1494 | useEffect$1(() => {
|
1495 | const sub = storeRef.current.subscribeToTransactions(callback);
|
1496 | return sub.release;
|
1497 | }, [callback, storeRef]);
|
1498 | }
|
1499 |
|
1500 |
|
1501 | function useTreeStateClone_DEPRECATED() {
|
1502 | const [_, setState] = useState$1(0);
|
1503 | const forceUpdate = useCallback(() => setState(x => x + 1), []);
|
1504 | useTransactionSubscription(forceUpdate);
|
1505 | const storeRef = useStoreRef$1();
|
1506 | return cloneState_DEPRECATED(storeRef.current.getState().currentTree);
|
1507 | }
|
1508 |
|
1509 | function useSnapshotWithStateChange_DEPRECATED(transaction) {
|
1510 | const storeRef = useStoreRef$1();
|
1511 | let snapshot = useTreeStateClone_DEPRECATED();
|
1512 |
|
1513 | const update = ({
|
1514 | key
|
1515 | }, updater) => {
|
1516 | [snapshot] = setNodeValue$3(storeRef.current, snapshot, key, peekNodeLoadable$2(storeRef.current, snapshot, key).map(updater));
|
1517 | };
|
1518 |
|
1519 | transaction(update);
|
1520 | const atomValues = Recoil_mapMap(snapshot.atomValues, v => v.contents);
|
1521 |
|
1522 | const updatedAtoms = Recoil_intersectSets(snapshot.dirtyAtoms, new Set(atomValues.keys()));
|
1523 | return {
|
1524 | atomValues,
|
1525 | updatedAtoms
|
1526 | };
|
1527 | }
|
1528 |
|
1529 | function externallyVisibleAtomValuesInState(state) {
|
1530 | const atomValues = state.atomValues;
|
1531 | const persistedAtomContentsValues = Recoil_mapMap(Recoil_filterMap(atomValues, (v, k) => {
|
1532 | var _node$options;
|
1533 |
|
1534 | const node = getNode$2(k);
|
1535 | const persistence = (_node$options = node.options) === null || _node$options === void 0 ? void 0 : _node$options.persistence_UNSTABLE;
|
1536 | return persistence != null && persistence.type !== 'none' && v.state === 'hasValue';
|
1537 | }), v => v.contents);
|
1538 |
|
1539 |
|
1540 | return Recoil_mergeMaps(state.nonvalidatedAtoms, persistedAtomContentsValues);
|
1541 | }
|
1542 |
|
1543 |
|
1544 |
|
1545 |
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 | function useTransactionObservation_DEPRECATED(callback) {
|
1568 | useTransactionSubscription(useCallback(store => {
|
1569 | const previousState = store.getState().currentTree;
|
1570 | let nextState = store.getState().nextTree;
|
1571 |
|
1572 | if (!nextState) {
|
1573 | Recoil_recoverableViolation('Transaction subscribers notified without a next tree being present -- this is a bug in Recoil');
|
1574 | nextState = store.getState().currentTree;
|
1575 | }
|
1576 |
|
1577 | const atomValues = externallyVisibleAtomValuesInState(nextState);
|
1578 | const previousAtomValues = externallyVisibleAtomValuesInState(previousState);
|
1579 | const atomInfo = Recoil_mapMap(nodes$1, node => {
|
1580 | var _node$options$persist, _node$options2, _node$options2$persis, _node$options$persist2, _node$options3, _node$options3$persis;
|
1581 |
|
1582 | return {
|
1583 | persistence_UNSTABLE: {
|
1584 | type: (_node$options$persist = (_node$options2 = node.options) === null || _node$options2 === void 0 ? void 0 : (_node$options2$persis = _node$options2.persistence_UNSTABLE) === null || _node$options2$persis === void 0 ? void 0 : _node$options2$persis.type) !== null && _node$options$persist !== void 0 ? _node$options$persist : 'none',
|
1585 | backButton: (_node$options$persist2 = (_node$options3 = node.options) === null || _node$options3 === void 0 ? void 0 : (_node$options3$persis = _node$options3.persistence_UNSTABLE) === null || _node$options3$persis === void 0 ? void 0 : _node$options3$persis.backButton) !== null && _node$options$persist2 !== void 0 ? _node$options$persist2 : false
|
1586 | }
|
1587 | };
|
1588 | });
|
1589 | const modifiedAtoms = new Set(nextState.dirtyAtoms);
|
1590 | callback({
|
1591 | atomValues,
|
1592 | previousAtomValues,
|
1593 | atomInfo,
|
1594 | modifiedAtoms,
|
1595 | transactionMetadata: { ...nextState.transactionMetadata
|
1596 | }
|
1597 | });
|
1598 | }, [callback]));
|
1599 | }
|
1600 |
|
1601 | function useRecoilTransactionObserver(callback) {
|
1602 | useTransactionSubscription(useCallback(store => {
|
1603 | const previousState = store.getState().currentTree;
|
1604 | let nextState = store.getState().nextTree;
|
1605 |
|
1606 | if (!nextState) {
|
1607 | Recoil_recoverableViolation('Transaction subscribers notified without a next tree being present -- this is a bug in Recoil');
|
1608 | nextState = previousState;
|
1609 | }
|
1610 |
|
1611 | callback({
|
1612 | snapshot: cloneSnapshot$1(nextState),
|
1613 | previousSnapshot: cloneSnapshot$1(previousState)
|
1614 | });
|
1615 | }, [callback]));
|
1616 | }
|
1617 |
|
1618 |
|
1619 | function useRecoilSnapshot() {
|
1620 | const store = useStoreRef$1();
|
1621 | const [snapshot, setSnapshot] = useState$1(() => cloneSnapshot$1(store.current.getState().currentTree));
|
1622 | useTransactionSubscription(useCallback(store => {
|
1623 | var _store$getState$nextT;
|
1624 |
|
1625 | return setSnapshot(cloneSnapshot$1((_store$getState$nextT = store.getState().nextTree) !== null && _store$getState$nextT !== void 0 ? _store$getState$nextT : store.getState().currentTree));
|
1626 | }, []));
|
1627 | return snapshot;
|
1628 | }
|
1629 |
|
1630 | function useGoToSnapshot_DEPRECATED() {
|
1631 | const storeRef = useStoreRef$1();
|
1632 | return snapshot => {
|
1633 | reactDom.unstable_batchedUpdates(() => {
|
1634 | snapshot.updatedAtoms.forEach(key => {
|
1635 | setRecoilValue$2(storeRef.current, new AbstractRecoilValue$2(key), snapshot.atomValues.get(key));
|
1636 | });
|
1637 | });
|
1638 | };
|
1639 | }
|
1640 |
|
1641 | function useGotoRecoilSnapshot() {
|
1642 | const storeRef = useStoreRef$1();
|
1643 | return useCallback(snapshot => {
|
1644 | reactDom.unstable_batchedUpdates(() => {
|
1645 | storeRef.current.replaceState(prevState => {
|
1646 | const nextState = snapshot.getStore_INTERNAL().getState().currentTree;
|
1647 |
|
1648 | const updatedKeys = new Set();
|
1649 |
|
1650 | for (const keys of [prevState.atomValues.keys(), nextState.atomValues.keys()]) {
|
1651 | for (const key of keys) {
|
1652 | var _prevState$atomValues, _nextState$atomValues;
|
1653 |
|
1654 | if (((_prevState$atomValues = prevState.atomValues.get(key)) === null || _prevState$atomValues === void 0 ? void 0 : _prevState$atomValues.contents) !== ((_nextState$atomValues = nextState.atomValues.get(key)) === null || _nextState$atomValues === void 0 ? void 0 : _nextState$atomValues.contents)) {
|
1655 | updatedKeys.add(key);
|
1656 | }
|
1657 | }
|
1658 | }
|
1659 |
|
1660 | storeRef.current.fireNodeSubscriptions(updatedKeys, 'enqueue');
|
1661 | return { ...nextState,
|
1662 | nodeToComponentSubscriptions: prevState.nodeToComponentSubscriptions
|
1663 | };
|
1664 | });
|
1665 | });
|
1666 | }, [storeRef]);
|
1667 | }
|
1668 |
|
1669 | function useSetUnvalidatedAtomValues() {
|
1670 | const storeRef = useStoreRef$1();
|
1671 | return (values, transactionMetadata = {}) => {
|
1672 | reactDom.unstable_batchedUpdates(() => {
|
1673 | storeRef.current.addTransactionMetadata(transactionMetadata);
|
1674 | values.forEach((value, key) => setUnvalidatedRecoilValue$1(storeRef.current, new AbstractRecoilValue$2(key), value));
|
1675 | });
|
1676 | };
|
1677 | }
|
1678 |
|
1679 | class Sentinel {}
|
1680 |
|
1681 | const SENTINEL = new Sentinel();
|
1682 |
|
1683 | function useRecoilCallback(fn, deps) {
|
1684 | const storeRef = useStoreRef$1();
|
1685 | const gotoSnapshot = useGotoRecoilSnapshot();
|
1686 | return useCallback((...args) => {
|
1687 |
|
1688 | const snapshot = cloneSnapshot$1(storeRef.current.getState().currentTree);
|
1689 |
|
1690 | function set(recoilState, newValueOrUpdater) {
|
1691 | const newValue = valueFromValueOrUpdater$2(storeRef.current, recoilState, newValueOrUpdater);
|
1692 | setRecoilValue$2(storeRef.current, recoilState, newValue);
|
1693 | }
|
1694 |
|
1695 | function reset(recoilState) {
|
1696 | setRecoilValue$2(storeRef.current, recoilState, DEFAULT_VALUE$2);
|
1697 | }
|
1698 |
|
1699 | let ret = SENTINEL;
|
1700 | reactDom.unstable_batchedUpdates(() => {
|
1701 |
|
1702 | ret = fn({
|
1703 | set,
|
1704 | reset,
|
1705 | snapshot,
|
1706 | gotoSnapshot
|
1707 | })(...args);
|
1708 | });
|
1709 | !!(ret instanceof Sentinel) ? Recoil_invariant(false, 'unstable_batchedUpdates should return immediately') : void 0;
|
1710 | return ret;
|
1711 | }, deps != null ? [...deps, storeRef] : undefined // eslint-disable-line fb-www/react-hooks-deps
|
1712 | );
|
1713 | }
|
1714 |
|
1715 | var Recoil_Hooks = {
|
1716 | useRecoilCallback,
|
1717 | useRecoilValue,
|
1718 | useRecoilValueLoadable,
|
1719 | useRecoilState,
|
1720 | useRecoilStateLoadable,
|
1721 | useSetRecoilState,
|
1722 | useResetRecoilState,
|
1723 | useRecoilInterface: useInterface,
|
1724 | useSnapshotWithStateChange_DEPRECATED,
|
1725 | useTransactionSubscription_DEPRECATED: useTransactionSubscription,
|
1726 | useTransactionObservation_DEPRECATED,
|
1727 | useRecoilTransactionObserver,
|
1728 | useRecoilSnapshot,
|
1729 | useGoToSnapshot_DEPRECATED,
|
1730 | useGotoRecoilSnapshot,
|
1731 | useSetUnvalidatedAtomValues
|
1732 | };
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 | function isPromise(p) {
|
1750 | return !!p && typeof p.then === 'function';
|
1751 | }
|
1752 |
|
1753 | var Recoil_isPromise = isPromise;
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 | const loadableAccessors = {
|
1760 | getValue() {
|
1761 | if (this.state !== 'hasValue') {
|
1762 | throw this.contents;
|
1763 | }
|
1764 |
|
1765 | return this.contents;
|
1766 | },
|
1767 |
|
1768 | toPromise() {
|
1769 | return this.state === 'hasValue' ? Promise.resolve(this.contents) : this.state === 'hasError' ? Promise.reject(this.contents) : this.contents;
|
1770 | },
|
1771 |
|
1772 | valueMaybe() {
|
1773 | return this.state === 'hasValue' ? this.contents : undefined;
|
1774 | },
|
1775 |
|
1776 | valueOrThrow() {
|
1777 | if (this.state !== 'hasValue') {
|
1778 | throw new Error(`Loadable expected value, but in "${this.state}" state`);
|
1779 | }
|
1780 |
|
1781 | return this.contents;
|
1782 | },
|
1783 |
|
1784 | errorMaybe() {
|
1785 | return this.state === 'hasError' ? this.contents : undefined;
|
1786 | },
|
1787 |
|
1788 | errorOrThrow() {
|
1789 | if (this.state !== 'hasError') {
|
1790 | throw new Error(`Loadable expected error, but in "${this.state}" state`);
|
1791 | }
|
1792 |
|
1793 | return this.contents;
|
1794 | },
|
1795 |
|
1796 | promiseMaybe() {
|
1797 | return this.state === 'loading' ? this.contents : undefined;
|
1798 | },
|
1799 |
|
1800 | promiseOrThrow() {
|
1801 | if (this.state !== 'loading') {
|
1802 | throw new Error(`Loadable expected promise, but in "${this.state}" state`);
|
1803 | }
|
1804 |
|
1805 | return this.contents;
|
1806 | },
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 | map(map) {
|
1812 | if (this.state === 'hasError') {
|
1813 | return this;
|
1814 | }
|
1815 |
|
1816 | if (this.state === 'hasValue') {
|
1817 | try {
|
1818 | const next = map(this.contents);
|
1819 |
|
1820 | return Recoil_isPromise(next) ? loadableWithPromise(next) : loadableWithValue(next);
|
1821 | } catch (e) {
|
1822 | return Recoil_isPromise(e) ?
|
1823 |
|
1824 | loadableWithPromise(e.next(() => map(this.contents))) : loadableWithError(e);
|
1825 | }
|
1826 | }
|
1827 |
|
1828 | if (this.state === 'loading') {
|
1829 | return loadableWithPromise(this.contents
|
1830 | .then(map).catch(e => {
|
1831 | if (Recoil_isPromise(e)) {
|
1832 |
|
1833 | return e.then(() => map(this.contents));
|
1834 | }
|
1835 |
|
1836 | throw e;
|
1837 | }));
|
1838 | }
|
1839 |
|
1840 | throw new Error('Invalid Loadable state');
|
1841 | }
|
1842 |
|
1843 | };
|
1844 |
|
1845 | function loadableWithValue(value) {
|
1846 |
|
1847 | return Object.freeze({
|
1848 | state: 'hasValue',
|
1849 | contents: value,
|
1850 | ...loadableAccessors
|
1851 | });
|
1852 | }
|
1853 |
|
1854 | function loadableWithError(error) {
|
1855 | return Object.freeze({
|
1856 | state: 'hasError',
|
1857 | contents: error,
|
1858 | ...loadableAccessors
|
1859 | });
|
1860 | }
|
1861 |
|
1862 | function loadableWithPromise(promise) {
|
1863 | return Object.freeze({
|
1864 | state: 'loading',
|
1865 | contents: promise,
|
1866 | ...loadableAccessors
|
1867 | });
|
1868 | }
|
1869 |
|
1870 | function loadableLoading() {
|
1871 | return loadableWithPromise(new Promise(() => {}));
|
1872 | }
|
1873 |
|
1874 | function loadableAll(inputs) {
|
1875 | return inputs.every(i => i.state === 'hasValue') ? loadableWithValue(inputs.map(i => i.contents)) : inputs.some(i => i.state === 'hasError') ? loadableWithError(
|
1876 | Recoil_nullthrows(inputs.find(i => i.state === 'hasError'), 'Invalid loadable passed to loadableAll').contents) : loadableWithPromise( Promise.all(inputs.map(i => i.contents)));
|
1877 | }
|
1878 |
|
1879 | var Recoil_Loadable = {
|
1880 | loadableWithValue,
|
1881 | loadableWithError,
|
1882 | loadableWithPromise,
|
1883 | loadableLoading,
|
1884 | loadableAll
|
1885 | };
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 | function isNode(object) {
|
1899 | var _ownerDocument, _doc$defaultView;
|
1900 |
|
1901 | if (typeof window === 'undefined') {
|
1902 | return false;
|
1903 | }
|
1904 |
|
1905 | const doc = object != null ? (_ownerDocument = object.ownerDocument) !== null && _ownerDocument !== void 0 ? _ownerDocument : object : document;
|
1906 | const defaultView = (_doc$defaultView = doc.defaultView) !== null && _doc$defaultView !== void 0 ? _doc$defaultView : window;
|
1907 | return !!(object != null && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
|
1908 | }
|
1909 |
|
1910 | var Recoil_isNode = isNode;
|
1911 |
|
1912 | function shouldNotBeFrozen(value) {
|
1913 |
|
1914 | if (value === null || typeof value !== 'object') {
|
1915 | return true;
|
1916 | }
|
1917 |
|
1918 |
|
1919 | switch (typeof value.$$typeof) {
|
1920 | case 'symbol':
|
1921 | return true;
|
1922 |
|
1923 | case 'number':
|
1924 | return true;
|
1925 | }
|
1926 |
|
1927 |
|
1928 | if (value['@@__IMMUTABLE_ITERABLE__@@'] != null || value['@@__IMMUTABLE_KEYED__@@'] != null || value['@@__IMMUTABLE_INDEXED__@@'] != null || value['@@__IMMUTABLE_ORDERED__@@'] != null || value['@@__IMMUTABLE_RECORD__@@'] != null) {
|
1929 | return true;
|
1930 | }
|
1931 |
|
1932 |
|
1933 | if (Recoil_isNode(value)) {
|
1934 | return true;
|
1935 | }
|
1936 |
|
1937 | if (Recoil_isPromise(value)) {
|
1938 | return true;
|
1939 | }
|
1940 |
|
1941 | return false;
|
1942 | }
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 | function deepFreezeValue(value) {
|
1948 | if (typeof value !== 'object' || shouldNotBeFrozen(value)) {
|
1949 | return;
|
1950 | }
|
1951 |
|
1952 | Object.freeze(value);
|
1953 |
|
1954 | for (const key in value) {
|
1955 | if (Object.prototype.hasOwnProperty.call(value, key)) {
|
1956 | const prop = value[key];
|
1957 |
|
1958 | if (typeof prop === 'object' && prop != null && !Object.isFrozen(prop)) {
|
1959 | deepFreezeValue(prop);
|
1960 | }
|
1961 | }
|
1962 | }
|
1963 |
|
1964 | Object.seal(value);
|
1965 | }
|
1966 |
|
1967 | var Recoil_deepFreezeValue = deepFreezeValue;
|
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 | const LEAF = Symbol('ArrayKeyedMap');
|
1986 | const emptyMap$1 = new Map();
|
1987 |
|
1988 | class ArrayKeyedMap {
|
1989 |
|
1990 | constructor(existing) {
|
1991 |
|
1992 | this._base = new Map();
|
1993 |
|
1994 | if (existing instanceof ArrayKeyedMap) {
|
1995 | for (const [k, v] of existing.entries()) {
|
1996 | this.set(k, v);
|
1997 | }
|
1998 | } else if (existing) {
|
1999 | for (const [k, v] of existing) {
|
2000 | this.set(k, v);
|
2001 | }
|
2002 | }
|
2003 |
|
2004 | return this;
|
2005 | }
|
2006 |
|
2007 | get(key) {
|
2008 | const ks = Array.isArray(key) ? key : [key];
|
2009 |
|
2010 | let map = this._base;
|
2011 | ks.forEach(k => {
|
2012 | var _map$get;
|
2013 |
|
2014 | map = (_map$get = map.get(k)) !== null && _map$get !== void 0 ? _map$get : emptyMap$1;
|
2015 | });
|
2016 | return map === undefined ? undefined : map.get(LEAF);
|
2017 | }
|
2018 |
|
2019 | set(key, value) {
|
2020 | const ks = Array.isArray(key) ? key : [key];
|
2021 |
|
2022 | let map = this._base;
|
2023 | let next = map;
|
2024 | ks.forEach(k => {
|
2025 | next = map.get(k);
|
2026 |
|
2027 | if (!next) {
|
2028 | next = new Map();
|
2029 | map.set(k, next);
|
2030 | }
|
2031 |
|
2032 | map = next;
|
2033 | });
|
2034 | next.set(LEAF, value);
|
2035 | return this;
|
2036 | }
|
2037 |
|
2038 | delete(key) {
|
2039 | const ks = Array.isArray(key) ? key : [key];
|
2040 |
|
2041 | let map = this._base;
|
2042 | let next = map;
|
2043 | ks.forEach(k => {
|
2044 | next = map.get(k);
|
2045 |
|
2046 | if (!next) {
|
2047 | next = new Map();
|
2048 | map.set(k, next);
|
2049 | }
|
2050 |
|
2051 | map = next;
|
2052 | });
|
2053 | next.delete(LEAF);
|
2054 |
|
2055 | return this;
|
2056 | }
|
2057 |
|
2058 | entries() {
|
2059 | const answer = [];
|
2060 |
|
2061 | function recurse(level, prefix) {
|
2062 | level.forEach((v, k) => {
|
2063 | if (k === LEAF) {
|
2064 | answer.push([prefix, v]);
|
2065 | } else {
|
2066 | recurse(v, prefix.concat(k));
|
2067 | }
|
2068 | });
|
2069 | }
|
2070 |
|
2071 |
|
2072 | recurse(this._base, []);
|
2073 | return answer.values();
|
2074 | }
|
2075 |
|
2076 | toBuiltInMap() {
|
2077 | return new Map(this.entries());
|
2078 | }
|
2079 |
|
2080 | }
|
2081 |
|
2082 | var Recoil_ArrayKeyedMap = ArrayKeyedMap;
|
2083 |
|
2084 | function cacheWithReferenceEquality() {
|
2085 | return new Recoil_ArrayKeyedMap();
|
2086 | }
|
2087 |
|
2088 | var Recoil_cacheWithReferenceEquality = cacheWithReferenceEquality;
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 | function everySet(set, callback, context) {
|
2106 | const iterator = set.entries();
|
2107 | let current = iterator.next();
|
2108 |
|
2109 | while (!current.done) {
|
2110 | const entry = current.value;
|
2111 |
|
2112 | if (!callback.call(context, entry[1], entry[0], set)) {
|
2113 | return false;
|
2114 | }
|
2115 |
|
2116 | current = iterator.next();
|
2117 | }
|
2118 |
|
2119 | return true;
|
2120 | }
|
2121 |
|
2122 | var Recoil_everySet = everySet;
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 | function equalsSet(one, two) {
|
2130 | if (one.size !== two.size) {
|
2131 | return false;
|
2132 | }
|
2133 |
|
2134 | return Recoil_everySet(one, value => two.has(value));
|
2135 | }
|
2136 |
|
2137 | var Recoil_equalsSet = equalsSet;
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 | function startPerfBlock(_id) {
|
2152 | return () => null;
|
2153 | }
|
2154 |
|
2155 | var Recoil_PerformanceTimings = {
|
2156 | startPerfBlock
|
2157 | };
|
2158 |
|
2159 | const emptySet$1 = Object.freeze(new Set());
|
2160 |
|
2161 | const {
|
2162 | mapBySettingInMap: mapBySettingInMap$2,
|
2163 | mapByUpdatingInMap: mapByUpdatingInMap$2,
|
2164 | setByAddingToSet: setByAddingToSet$3,
|
2165 | setByDeletingFromSet: setByDeletingFromSet$1
|
2166 | } = Recoil_CopyOnWrite;
|
2167 |
|
2168 |
|
2169 |
|
2170 | const {
|
2171 | detectCircularDependencies: detectCircularDependencies$1,
|
2172 | getNodeLoadable: getNodeLoadable$2,
|
2173 | setNodeValue: setNodeValue$4
|
2174 | } = Recoil_FunctionalCore;
|
2175 |
|
2176 | const {
|
2177 | loadableWithError: loadableWithError$1,
|
2178 | loadableWithPromise: loadableWithPromise$1,
|
2179 | loadableWithValue: loadableWithValue$1
|
2180 | } = Recoil_Loadable;
|
2181 |
|
2182 | const {
|
2183 | DEFAULT_VALUE: DEFAULT_VALUE$3,
|
2184 | RecoilValueNotReady: RecoilValueNotReady$2,
|
2185 | registerNode: registerNode$1
|
2186 | } = Recoil_Node;
|
2187 |
|
2188 | const {
|
2189 | startPerfBlock: startPerfBlock$1
|
2190 | } = Recoil_PerformanceTimings;
|
2191 |
|
2192 | const {
|
2193 | isRecoilValue: isRecoilValue$2
|
2194 | } = Recoil_RecoilValue$1;
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 | const emptySet$2 = Object.freeze(new Set());
|
2206 |
|
2207 | function cacheKeyFromDepValues(depValues) {
|
2208 | const answer = [];
|
2209 |
|
2210 | for (const key of Array.from(depValues.keys()).sort()) {
|
2211 | const loadable = Recoil_nullthrows(depValues.get(key));
|
2212 | answer.push(key);
|
2213 | answer.push(loadable.contents);
|
2214 | }
|
2215 |
|
2216 | return answer;
|
2217 | }
|
2218 |
|
2219 |
|
2220 |
|
2221 | function selector(options) {
|
2222 | const {
|
2223 | key,
|
2224 | get,
|
2225 | cacheImplementation_UNSTABLE: cacheImplementation
|
2226 | } = options;
|
2227 | const set = options.set != null ? options.set : undefined; // flow
|
2228 |
|
2229 | let cache = cacheImplementation !== null && cacheImplementation !== void 0 ? cacheImplementation : Recoil_cacheWithReferenceEquality();
|
2230 |
|
2231 | function putIntoCache(store, cacheKey, loadable) {
|
2232 | if (loadable.state !== 'loading') {
|
2233 |
|
2234 | if (!options.dangerouslyAllowMutability === true) {
|
2235 | Recoil_deepFreezeValue(loadable.contents);
|
2236 | }
|
2237 | } else {
|
2238 |
|
2239 |
|
2240 |
|
2241 | loadable.contents.then(result => {
|
2242 |
|
2243 | if (!options.dangerouslyAllowMutability === true) {
|
2244 | Recoil_deepFreezeValue(result);
|
2245 | }
|
2246 |
|
2247 | cache = cache.set(cacheKey, loadableWithValue$1(result));
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 | store.fireNodeSubscriptions(new Set([key]), 'now');
|
2265 | return result;
|
2266 | }).catch(error => {
|
2267 |
|
2268 |
|
2269 | if (Recoil_isPromise(error)) {
|
2270 | return error;
|
2271 | }
|
2272 |
|
2273 |
|
2274 |
|
2275 | if (!options.dangerouslyAllowMutability === true) {
|
2276 | Recoil_deepFreezeValue(error);
|
2277 | }
|
2278 |
|
2279 | cache = cache.set(cacheKey, loadableWithError$1(error));
|
2280 | store.fireNodeSubscriptions(new Set([key]), 'now');
|
2281 | return error;
|
2282 | });
|
2283 | }
|
2284 |
|
2285 | cache = cache.set(cacheKey, loadable);
|
2286 | }
|
2287 |
|
2288 | function getFromCache(store, state) {
|
2289 | var _state$nodeDeps$get;
|
2290 |
|
2291 | let newState = state; // First, get the current deps for this selector
|
2292 |
|
2293 | const currentDeps = (_state$nodeDeps$get = state.nodeDeps.get(key)) !== null && _state$nodeDeps$get !== void 0 ? _state$nodeDeps$get : emptySet$2;
|
2294 | const depValues = new Map(Array.from(currentDeps).sort().map(depKey => {
|
2295 | const [nextState, loadable] = getNodeLoadable$2(store, newState, depKey);
|
2296 | newState = nextState;
|
2297 | return [depKey, loadable];
|
2298 | }));
|
2299 |
|
2300 |
|
2301 | const cacheKey = cacheKeyFromDepValues(depValues);
|
2302 | const cached = cache.get(cacheKey);
|
2303 |
|
2304 | if (cached != null) {
|
2305 | return [newState, cached];
|
2306 | }
|
2307 |
|
2308 |
|
2309 | const [nextState, loadable, newDepValues] = computeAndSubscribeSelector(store, newState);
|
2310 | newState = nextState;
|
2311 |
|
2312 | const newCacheKey = cacheKeyFromDepValues(newDepValues);
|
2313 | putIntoCache(store, newCacheKey, loadable);
|
2314 | return [newState, loadable];
|
2315 | }
|
2316 |
|
2317 | function evaluateSelectorFunction(store, state) {
|
2318 | const endPerfBlock = startPerfBlock$1(key);
|
2319 | let newState = state;
|
2320 | const depValues = new Map();
|
2321 |
|
2322 | function getRecoilValue({
|
2323 | key
|
2324 | }) {
|
2325 | let loadable;
|
2326 | [newState, loadable] = getNodeLoadable$2(store, newState, key);
|
2327 | depValues.set(key, loadable);
|
2328 |
|
2329 | if (loadable.state === 'hasValue') {
|
2330 | return loadable.contents;
|
2331 | } else {
|
2332 | throw loadable.contents;
|
2333 | }
|
2334 | }
|
2335 |
|
2336 | try {
|
2337 |
|
2338 | const output = get({
|
2339 | get: getRecoilValue
|
2340 | });
|
2341 | const result = isRecoilValue$2(output) ? getRecoilValue(output) : output; // TODO Allow user to also return Loadables for improved composability
|
2342 |
|
2343 | const loadable = !Recoil_isPromise(result) ? ( // The selector returned a simple synchronous value, so let's use it!
|
2344 | endPerfBlock(), loadableWithValue$1(result)) : // The user returned a promise for an asynchronous selector. This will
|
2345 | // resolve to the proper value of the selector when available.
|
2346 | loadableWithPromise$1(result.finally(endPerfBlock));
|
2347 | return [newState, loadable, depValues];
|
2348 | } catch (errorOrDepPromise) {
|
2349 | const loadable = !Recoil_isPromise(errorOrDepPromise) ? (
|
2350 | endPerfBlock(), loadableWithError$1(errorOrDepPromise)) :
|
2351 |
|
2352 | loadableWithPromise$1(errorOrDepPromise.then(() => {
|
2353 |
|
2354 |
|
2355 | let loadable = loadableWithError$1(new Error('Internal Recoil Selector Error')
|
2356 | );
|
2357 |
|
2358 | store.replaceState(asyncState => {
|
2359 | let newAsyncState;
|
2360 | [newAsyncState, loadable] = getFromCache(store, asyncState);
|
2361 | return newAsyncState;
|
2362 | });
|
2363 |
|
2364 | if (loadable.state === 'hasError') {
|
2365 | throw loadable.contents;
|
2366 | }
|
2367 |
|
2368 |
|
2369 |
|
2370 | return loadable.contents;
|
2371 | }).finally(endPerfBlock));
|
2372 | return [newState, loadable, depValues];
|
2373 | }
|
2374 | }
|
2375 |
|
2376 | function computeAndSubscribeSelector(store, state) {
|
2377 | var _state$nodeDeps$get2;
|
2378 |
|
2379 |
|
2380 | const [newStateFromEvaluate, loadable, newDepValues] = evaluateSelectorFunction(store, state);
|
2381 | let newState = newStateFromEvaluate;
|
2382 |
|
2383 | const oldDeps = (_state$nodeDeps$get2 = state.nodeDeps.get(key)) !== null && _state$nodeDeps$get2 !== void 0 ? _state$nodeDeps$get2 : emptySet$2;
|
2384 | const newDeps = new Set(newDepValues.keys());
|
2385 | newState = Recoil_equalsSet(oldDeps, newDeps) ? newState : { ...newState,
|
2386 | nodeDeps: mapBySettingInMap$2(newState.nodeDeps, key, newDeps)
|
2387 | };
|
2388 |
|
2389 | const addedDeps = Recoil_differenceSets(newDeps, oldDeps);
|
2390 | const removedDeps = Recoil_differenceSets(oldDeps, newDeps);
|
2391 |
|
2392 | for (const upstreamNode of addedDeps) {
|
2393 | newState = { ...newState,
|
2394 | nodeToNodeSubscriptions: mapByUpdatingInMap$2(newState.nodeToNodeSubscriptions, upstreamNode, subs => setByAddingToSet$3(subs !== null && subs !== void 0 ? subs : emptySet$2, key))
|
2395 | };
|
2396 | }
|
2397 |
|
2398 | for (const upstreamNode of removedDeps) {
|
2399 | newState = { ...newState,
|
2400 | nodeToNodeSubscriptions: mapByUpdatingInMap$2(newState.nodeToNodeSubscriptions, upstreamNode, subs => setByDeletingFromSet$1(subs !== null && subs !== void 0 ? subs : emptySet$2, key))
|
2401 | };
|
2402 | }
|
2403 |
|
2404 | {
|
2405 | detectCircularDependencies$1(newState, [key]);
|
2406 | }
|
2407 |
|
2408 | return [newState, loadable, newDepValues];
|
2409 | }
|
2410 |
|
2411 | function myGet(store, state) {
|
2412 |
|
2413 |
|
2414 |
|
2415 | return getFromCache(store, state);
|
2416 | }
|
2417 |
|
2418 | if (set != null) {
|
2419 | function mySet(store, state, newValue) {
|
2420 | let newState = state;
|
2421 | const writtenNodes = new Set();
|
2422 |
|
2423 | function getRecoilValue({
|
2424 | key
|
2425 | }) {
|
2426 | const [nextState, loadable] = getNodeLoadable$2(store, newState, key);
|
2427 | newState = nextState;
|
2428 |
|
2429 | if (loadable.state === 'hasValue') {
|
2430 | return loadable.contents;
|
2431 | } else if (loadable.state === 'loading') {
|
2432 | throw new RecoilValueNotReady$2(key);
|
2433 | } else {
|
2434 | throw loadable.contents;
|
2435 | }
|
2436 | }
|
2437 |
|
2438 | function setRecoilState(recoilState, valueOrUpdater) {
|
2439 | const newValue = typeof valueOrUpdater === 'function' ?
|
2440 |
|
2441 | valueOrUpdater(getRecoilValue(recoilState)) : valueOrUpdater;
|
2442 | let written;
|
2443 | [newState, written] = setNodeValue$4(store, newState, recoilState.key, newValue);
|
2444 | written.forEach(atom => writtenNodes.add(atom));
|
2445 | }
|
2446 |
|
2447 | function resetRecoilState(recoilState) {
|
2448 | setRecoilState(recoilState, DEFAULT_VALUE$3);
|
2449 | }
|
2450 |
|
2451 | set({
|
2452 | set: setRecoilState,
|
2453 | get: getRecoilValue,
|
2454 | reset: resetRecoilState
|
2455 | }, newValue);
|
2456 | return [newState, writtenNodes];
|
2457 | }
|
2458 |
|
2459 | return registerNode$1({
|
2460 | key,
|
2461 | options,
|
2462 | get: myGet,
|
2463 | set: mySet
|
2464 | });
|
2465 | } else {
|
2466 | return registerNode$1({
|
2467 | key,
|
2468 | options,
|
2469 | get: myGet
|
2470 | });
|
2471 | }
|
2472 | }
|
2473 | /* eslint-enable no-redeclare */
|
2474 |
|
2475 |
|
2476 | var Recoil_selector_OLD = selector;
|
2477 |
|
2478 | const selector$1 = Recoil_selector_OLD;
|
2479 | var Recoil_selector = selector$1;
|
2480 |
|
2481 | // @fb-only: import type {ScopeRules} from './Recoil_ScopedAtom';
|
2482 | const {
|
2483 | loadableWithValue: loadableWithValue$2
|
2484 | } = Recoil_Loadable;
|
2485 |
|
2486 | const {
|
2487 | DEFAULT_VALUE: DEFAULT_VALUE$4,
|
2488 | DefaultValue: DefaultValue$1,
|
2489 | registerNode: registerNode$2
|
2490 | } = Recoil_Node;
|
2491 |
|
2492 | const {
|
2493 | isRecoilValue: isRecoilValue$3
|
2494 | } = Recoil_RecoilValue$1;
|
2495 |
|
2496 | const {
|
2497 | mapByDeletingFromMap: mapByDeletingFromMap$2,
|
2498 | mapBySettingInMap: mapBySettingInMap$3,
|
2499 | setByAddingToSet: setByAddingToSet$4
|
2500 | } = Recoil_CopyOnWrite;
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 | function baseAtom(options) {
|
2518 | const {
|
2519 | key,
|
2520 | persistence_UNSTABLE: persistence
|
2521 | } = options;
|
2522 | return registerNode$2({
|
2523 | key,
|
2524 | options,
|
2525 | get: (_store, state) => {
|
2526 | if (state.atomValues.has(key)) {
|
2527 |
|
2528 | return [state, Recoil_nullthrows(state.atomValues.get(key))];
|
2529 | } else if (state.nonvalidatedAtoms.has(key)) {
|
2530 | if (persistence == null) {
|
2531 | Recoil_expectationViolation(`Tried to restore a persisted value for atom ${key} but it has no persistence settings.`);
|
2532 | return [state, loadableWithValue$2(options.default)];
|
2533 | }
|
2534 |
|
2535 | const nonvalidatedValue = state.nonvalidatedAtoms.get(key);
|
2536 | const validatedValue = persistence.validator(nonvalidatedValue, DEFAULT_VALUE$4);
|
2537 | return validatedValue instanceof DefaultValue$1 ? [{ ...state,
|
2538 | nonvalidatedAtoms: mapByDeletingFromMap$2(state.nonvalidatedAtoms, key)
|
2539 | }, loadableWithValue$2(options.default)] : [{ ...state,
|
2540 | atomValues: mapBySettingInMap$3(state.atomValues, key, loadableWithValue$2(validatedValue)),
|
2541 | nonvalidatedAtoms: mapByDeletingFromMap$2(state.nonvalidatedAtoms, key)
|
2542 | }, loadableWithValue$2(validatedValue)];
|
2543 | } else {
|
2544 | return [state, loadableWithValue$2(options.default)];
|
2545 | }
|
2546 | },
|
2547 | set: (_store, state, newValue) => {
|
2548 | if (options.dangerouslyAllowMutability !== true) {
|
2549 | Recoil_deepFreezeValue(newValue);
|
2550 | }
|
2551 |
|
2552 | return [{ ...state,
|
2553 | dirtyAtoms: setByAddingToSet$4(state.dirtyAtoms, key),
|
2554 | atomValues: newValue instanceof DefaultValue$1 ? mapByDeletingFromMap$2(state.atomValues, key) : mapBySettingInMap$3(state.atomValues, key, loadableWithValue$2(newValue)),
|
2555 | nonvalidatedAtoms: mapByDeletingFromMap$2(state.nonvalidatedAtoms, key)
|
2556 | }, new Set([key])];
|
2557 | }
|
2558 | });
|
2559 | }
|
2560 |
|
2561 |
|
2562 | function atom(options) {
|
2563 | const {
|
2564 | default: optionsDefault,
|
2565 |
|
2566 | ...restOptions
|
2567 | } = options;
|
2568 |
|
2569 | if (isRecoilValue$3(optionsDefault) || Recoil_isPromise(optionsDefault)) {
|
2570 | return atomWithFallback({ ...restOptions,
|
2571 | default: optionsDefault
|
2572 |
|
2573 | });
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 | } else {
|
2580 | return baseAtom({ ...restOptions,
|
2581 | default: optionsDefault
|
2582 | });
|
2583 | }
|
2584 | }
|
2585 |
|
2586 | function atomWithFallback(options) {
|
2587 | const base = atom({ ...options,
|
2588 | default: DEFAULT_VALUE$4,
|
2589 | persistence_UNSTABLE: options.persistence_UNSTABLE === undefined ? undefined : { ...options.persistence_UNSTABLE,
|
2590 | validator: storedValue => storedValue instanceof DefaultValue$1 ? storedValue : Recoil_nullthrows(options.persistence_UNSTABLE).validator(storedValue, DEFAULT_VALUE$4)
|
2591 | }
|
2592 | });
|
2593 | return Recoil_selector({
|
2594 | key: `${options.key}__withFallback`,
|
2595 | get: ({
|
2596 | get
|
2597 | }) => {
|
2598 | const baseValue = get(base);
|
2599 | return baseValue instanceof DefaultValue$1 ? options.default : baseValue;
|
2600 | },
|
2601 | set: ({
|
2602 | set
|
2603 | }, newValue) => set(base, newValue),
|
2604 | dangerouslyAllowMutability: options.dangerouslyAllowMutability
|
2605 | });
|
2606 | }
|
2607 |
|
2608 | var Recoil_atom = atom;
|
2609 |
|
2610 | /**
|
2611 | * Copyright (c) Facebook, Inc. and its affiliates.
|
2612 | *
|
2613 | * This source code is licensed under the MIT license found in the
|
2614 | * LICENSE file in the root directory of this source tree.
|
2615 | *
|
2616 | * @emails oncall+recoil
|
2617 | *
|
2618 | * @format
|
2619 | */
|
2620 |
|
2621 | var Recoil_ParameterizedAtomTaggedValue_DEPRECATED = /*#__PURE__*/Object.freeze({
|
2622 | __proto__: null
|
2623 | });
|
2624 |
|
2625 | const TIME_WARNING_THRESHOLD_MS = 15;
|
2626 |
|
2627 | function stringify(x, opt, key) {
|
2628 |
|
2629 |
|
2630 | if (typeof x === 'string' && !x.includes('"') && !x.includes('\\')) {
|
2631 | return `"${x}"`;
|
2632 | }
|
2633 |
|
2634 |
|
2635 | switch (typeof x) {
|
2636 | case 'undefined':
|
2637 | return '';
|
2638 |
|
2639 |
|
2640 | case 'boolean':
|
2641 | return x ? 'true' : 'false';
|
2642 |
|
2643 | case 'number':
|
2644 | case 'symbol':
|
2645 |
|
2646 | return String(x);
|
2647 |
|
2648 | case 'string':
|
2649 |
|
2650 | return JSON.stringify(x);
|
2651 |
|
2652 | case 'function':
|
2653 | if ((opt === null || opt === void 0 ? void 0 : opt.allowFunctions) !== true) {
|
2654 | throw new Error('Attempt to serialize function in a Recoil cache key');
|
2655 | }
|
2656 |
|
2657 | return `__FUNCTION(${x.name})__`;
|
2658 | }
|
2659 |
|
2660 | if (x === null) {
|
2661 | return 'null';
|
2662 | }
|
2663 |
|
2664 |
|
2665 | if (typeof x !== 'object') {
|
2666 | var _JSON$stringify;
|
2667 |
|
2668 | return (_JSON$stringify = JSON.stringify(x)) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : '';
|
2669 | }
|
2670 |
|
2671 |
|
2672 | if (Recoil_isPromise(x)) {
|
2673 | return '__PROMISE__';
|
2674 | }
|
2675 |
|
2676 |
|
2677 | if (Array.isArray(x)) {
|
2678 | return `[${x.map((v, i) => stringify(v, opt, i.toString()))}]`;
|
2679 | }
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 | if (typeof x.toJSON === 'function') {
|
2686 |
|
2687 | return stringify(x.toJSON(key), opt, key);
|
2688 | }
|
2689 |
|
2690 |
|
2691 |
|
2692 | if (x instanceof Map) {
|
2693 | return stringify(
|
2694 | Array.from(x).reduce((obj, [k, v]) => ({ ...obj,
|
2695 |
|
2696 | [typeof k === 'string' ? k : stringify(k, opt)]: v
|
2697 | }), {}), opt, key);
|
2698 | }
|
2699 |
|
2700 |
|
2701 |
|
2702 | if (x instanceof Set) {
|
2703 | return stringify(Array.from(x).sort((a, b) => stringify(a, opt).localeCompare(stringify(b, opt))), opt, key);
|
2704 | }
|
2705 |
|
2706 |
|
2707 | if (x[Symbol.iterator] != null && typeof x[Symbol.iterator] === 'function') {
|
2708 |
|
2709 | return stringify(Array.from(x), opt, key);
|
2710 | }
|
2711 |
|
2712 |
|
2713 | return `{${Object.keys(x).filter(key => x[key] !== undefined).sort() // stringify the key to add quotes and escape any nested slashes or quotes.
|
2714 | .map(key => `${stringify(key, opt)}:${stringify(x[key], opt, key)}`).join(',')}}`;
|
2715 | }
|
2716 |
|
2717 |
|
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 | function stableStringify(x, opt = {
|
2728 | allowFunctions: false
|
2729 | }) {
|
2730 | {
|
2731 | if (typeof window !== 'undefined') {
|
2732 | const startTime = window.performance ? window.performance.now() : 0;
|
2733 | const str = stringify(x, opt);
|
2734 | const endTime = window.performance ? window.performance.now() : 0;
|
2735 |
|
2736 | if (endTime - startTime > TIME_WARNING_THRESHOLD_MS) {
|
2737 |
|
2738 | console.groupCollapsed(`Recoil: Spent ${endTime - startTime}ms computing a cache key`);
|
2739 | console.warn(x, str);
|
2740 | console.groupEnd();
|
2741 |
|
2742 | }
|
2743 |
|
2744 | return str;
|
2745 | }
|
2746 | }
|
2747 |
|
2748 | return stringify(x, opt);
|
2749 | }
|
2750 |
|
2751 | var Recoil_stableStringify = stableStringify;
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 | function cacheWithValueEquality() {
|
2770 | const map = new Map();
|
2771 | const cache = {
|
2772 | get: key => map.get(Recoil_stableStringify(key)),
|
2773 | set: (key, value) => {
|
2774 | map.set(Recoil_stableStringify(key), value);
|
2775 | return cache;
|
2776 | },
|
2777 | map
|
2778 |
|
2779 | };
|
2780 | return cache;
|
2781 | }
|
2782 |
|
2783 | var Recoil_cacheWithValueEquality = cacheWithValueEquality;
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 | let nextIndex = 0;
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 | function selectorFamily(options) {
|
2807 | var _options$cacheImpleme, _options$cacheImpleme2;
|
2808 |
|
2809 | let selectorCache = (_options$cacheImpleme = (_options$cacheImpleme2 = options.cacheImplementationForParams_UNSTABLE) === null || _options$cacheImpleme2 === void 0 ? void 0 : _options$cacheImpleme2.call(options)) !== null && _options$cacheImpleme !== void 0 ? _options$cacheImpleme : Recoil_cacheWithValueEquality();
|
2810 | return params => {
|
2811 | var _stableStringify, _options$cacheImpleme3;
|
2812 |
|
2813 | const cachedSelector = selectorCache.get(params);
|
2814 |
|
2815 | if (cachedSelector != null) {
|
2816 | return cachedSelector;
|
2817 | }
|
2818 |
|
2819 | const myKey = `${options.key}__selectorFamily/${(_stableStringify = Recoil_stableStringify(params, {
|
2820 | // It is possible to use functions in parameters if the user uses
|
2821 | // a cache with reference equality thanks to the incrementing index.
|
2822 | allowFunctions: true
|
2823 | })) !== null && _stableStringify !== void 0 ? _stableStringify : 'void'}/${nextIndex++}`;
|
2824 |
|
2825 | const myGet = callbacks => options.get(params)(callbacks);
|
2826 |
|
2827 | const myCacheImplementation = (_options$cacheImpleme3 = options.cacheImplementation_UNSTABLE) === null || _options$cacheImpleme3 === void 0 ? void 0 : _options$cacheImpleme3.call(options);
|
2828 | let newSelector;
|
2829 |
|
2830 | if (options.set != null) {
|
2831 | const set = options.set;
|
2832 |
|
2833 | const mySet = (callbacks, newValue) => set(params)(callbacks, newValue);
|
2834 |
|
2835 | newSelector = Recoil_selector({
|
2836 | key: myKey,
|
2837 | get: myGet,
|
2838 | set: mySet,
|
2839 | cacheImplementation_UNSTABLE: myCacheImplementation,
|
2840 | dangerouslyAllowMutability: options.dangerouslyAllowMutability
|
2841 | });
|
2842 | } else {
|
2843 | newSelector = Recoil_selector({
|
2844 | key: myKey,
|
2845 | get: myGet,
|
2846 | cacheImplementation_UNSTABLE: myCacheImplementation,
|
2847 | dangerouslyAllowMutability: options.dangerouslyAllowMutability
|
2848 | });
|
2849 | }
|
2850 |
|
2851 | selectorCache = selectorCache.set(params, newSelector);
|
2852 | return newSelector;
|
2853 | };
|
2854 | }
|
2855 | /* eslint-enable no-redeclare */
|
2856 |
|
2857 |
|
2858 | var Recoil_selectorFamily = selectorFamily;
|
2859 |
|
2860 | // @fb-only: import type {ScopeRules} from './Recoil_ScopedAtom';
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 | const {
|
2866 | DEFAULT_VALUE: DEFAULT_VALUE$5,
|
2867 | DefaultValue: DefaultValue$2
|
2868 | } = Recoil_Node;
|
2869 |
|
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 | function isSuperset(setA, setB) {
|
2880 | return Recoil_everySet(setB, b => setA.has(b));
|
2881 | }
|
2882 |
|
2883 | const pick = (object, chosenKeys) => Array.from(chosenKeys).reduce((obj, key) => ({ ...obj,
|
2884 | [key]: object[key]
|
2885 | }), {});
|
2886 |
|
2887 | function getParameterizedValue_DEPRECATED(baseValue, parameter) {
|
2888 |
|
2889 | if (!(baseValue instanceof Recoil_ParameterizedAtomTaggedValue_DEPRECATED)) {
|
2890 | return baseValue;
|
2891 | }
|
2892 |
|
2893 |
|
2894 | if (typeof parameter !== 'object' || parameter == null || Array.isArray(parameter)) {
|
2895 | return DEFAULT_VALUE$5;
|
2896 | }
|
2897 |
|
2898 | const entries = baseValue.value;
|
2899 | const parameterKeys = new Set(Object.keys(parameter));
|
2900 |
|
2901 | for (const [entryParameterKeys, entryMap] of entries) {
|
2902 | if (isSuperset(parameterKeys, entryParameterKeys)) {
|
2903 | const contextOrSubcontext = parameterKeys.size === entryParameterKeys.size
|
2904 | ? parameter : pick(parameter, entryParameterKeys);
|
2905 | const value = entryMap.get(Recoil_stableStringify(contextOrSubcontext));
|
2906 |
|
2907 | if (value !== undefined) {
|
2908 | return value;
|
2909 | }
|
2910 | }
|
2911 | }
|
2912 |
|
2913 | return DEFAULT_VALUE$5;
|
2914 | }
|
2915 |
|
2916 | function mapPersistenceSettings_DEPRECATED(settings) {
|
2917 | if (settings == null) {
|
2918 | return undefined;
|
2919 | }
|
2920 |
|
2921 | const { ...passthrough
|
2922 | } = settings;
|
2923 | return { ...passthrough,
|
2924 | validator: storedValue => {
|
2925 | if (storedValue instanceof Recoil_ParameterizedAtomTaggedValue_DEPRECATED) {
|
2926 | return new Recoil_ParameterizedAtomTaggedValue_DEPRECATED(storedValue.value.filter(([keys, map]) => keys instanceof Set && map instanceof Map).map(([keys, map]) => [keys, Array.from(map.entries()).reduce((acc, [k, v]) => {
|
2927 | const validatedValue = passthrough.validator(v, DEFAULT_VALUE$5);
|
2928 |
|
2929 | if (validatedValue instanceof DefaultValue$2) {
|
2930 | return acc;
|
2931 | }
|
2932 |
|
2933 | acc.set(k, validatedValue);
|
2934 | return acc;
|
2935 | }, new Map())]));
|
2936 | } else {
|
2937 | return passthrough.validator(storedValue, DEFAULT_VALUE$5);
|
2938 | }
|
2939 | }
|
2940 | };
|
2941 | }
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 |
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 | function atomFamily(options) {
|
2960 | let atomCache = Recoil_cacheWithValueEquality();
|
2961 |
|
2962 | const legacyAtomOptions = {
|
2963 | key: options.key,
|
2964 |
|
2965 | default: DEFAULT_VALUE$5,
|
2966 |
|
2967 | persistence_UNSTABLE: mapPersistenceSettings_DEPRECATED(options.persistence_UNSTABLE)
|
2968 | };
|
2969 | let legacyAtom;
|
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 |
|
2977 |
|
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 |
|
2983 | legacyAtom = Recoil_atom(legacyAtomOptions);
|
2984 |
|
2985 |
|
2986 |
|
2987 | const atomFamilyDefault = Recoil_selectorFamily({
|
2988 | key: `${options.key}__atomFamily/Default`,
|
2989 | get: param => ({
|
2990 | get
|
2991 | }) => {
|
2992 | const legacyValue = get(typeof legacyAtom === 'function' ? legacyAtom(param) : legacyAtom);
|
2993 |
|
2994 | if (!(legacyValue instanceof DefaultValue$2)) {
|
2995 |
|
2996 |
|
2997 |
|
2998 | const upgradedValue = getParameterizedValue_DEPRECATED(legacyValue, param);
|
2999 |
|
3000 | if (!(upgradedValue instanceof DefaultValue$2)) {
|
3001 | return upgradedValue;
|
3002 | }
|
3003 | }
|
3004 |
|
3005 |
|
3006 | return typeof options.default === 'function' ?
|
3007 |
|
3008 | options.default(param)
|
3009 | :
|
3010 | options.default;
|
3011 | },
|
3012 | dangerouslyAllowMutability: options.dangerouslyAllowMutability
|
3013 | });
|
3014 |
|
3015 |
|
3016 | return params => {
|
3017 | var _stableStringify;
|
3018 |
|
3019 | const cachedAtom = atomCache.get(params);
|
3020 |
|
3021 | if (cachedAtom != null) {
|
3022 | return cachedAtom;
|
3023 | }
|
3024 |
|
3025 | const newAtom = Recoil_atom({
|
3026 | key: `${options.key}__${(_stableStringify = Recoil_stableStringify(params)) !== null && _stableStringify !== void 0 ? _stableStringify : 'void'}`,
|
3027 | default: atomFamilyDefault(params),
|
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 | persistence_UNSTABLE: options.persistence_UNSTABLE,
|
3034 | dangerouslyAllowMutability: options.dangerouslyAllowMutability
|
3035 | });
|
3036 | atomCache = atomCache.set(params, newAtom);
|
3037 | return newAtom;
|
3038 | };
|
3039 | }
|
3040 |
|
3041 | var Recoil_atomFamily = atomFamily;
|
3042 |
|
3043 |
|
3044 |
|
3045 |
|
3046 | const constantSelector = Recoil_selectorFamily({
|
3047 | key: '__constant',
|
3048 | get: constant => () => constant,
|
3049 | cacheImplementationForParams_UNSTABLE: Recoil_cacheWithReferenceEquality
|
3050 | }); // Function that returns a selector which always produces the
|
3051 | // same constant value. It may be called multiple times with the
|
3052 | // same value, based on reference equality, and will provide the
|
3053 | // same selector.
|
3054 |
|
3055 | function constSelector(constant) {
|
3056 | return constantSelector(constant);
|
3057 | }
|
3058 |
|
3059 | var Recoil_constSelector = constSelector;
|
3060 |
|
3061 |
|
3062 |
|
3063 |
|
3064 | const throwingSelector = Recoil_selectorFamily({
|
3065 | key: '__error',
|
3066 | get: message => () => {
|
3067 | throw new Error(message);
|
3068 | },
|
3069 | cacheImplementationForParams_UNSTABLE: Recoil_cacheWithReferenceEquality
|
3070 | });
|
3071 |
|
3072 |
|
3073 | function errorSelector(message) {
|
3074 | return throwingSelector(message);
|
3075 | }
|
3076 |
|
3077 | var Recoil_errorSelector = errorSelector;
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 | function readOnlySelector(atom) {
|
3093 |
|
3094 | return atom;
|
3095 | }
|
3096 |
|
3097 | var Recoil_readOnlySelector = readOnlySelector;
|
3098 |
|
3099 | const {
|
3100 | loadableWithError: loadableWithError$2,
|
3101 | loadableWithPromise: loadableWithPromise$2,
|
3102 | loadableWithValue: loadableWithValue$3
|
3103 | } = Recoil_Loadable;
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 |
|
3120 |
|
3121 |
|
3122 | function concurrentRequests(getRecoilValue, deps) {
|
3123 | const results = Array(deps.length).fill(undefined);
|
3124 | const exceptions = Array(deps.length).fill(undefined);
|
3125 |
|
3126 | for (const [i, dep] of deps.entries()) {
|
3127 | try {
|
3128 | results[i] = getRecoilValue(dep);
|
3129 | } catch (e) {
|
3130 |
|
3131 | exceptions[i] = e;
|
3132 | }
|
3133 | }
|
3134 |
|
3135 | return [results, exceptions];
|
3136 | }
|
3137 |
|
3138 | function isError(exp) {
|
3139 | return exp != null && !Recoil_isPromise(exp);
|
3140 | }
|
3141 |
|
3142 | function unwrapDependencies(dependencies) {
|
3143 | return Array.isArray(dependencies) ? dependencies : Object.getOwnPropertyNames(dependencies).map(key => dependencies[key]);
|
3144 | }
|
3145 |
|
3146 | function wrapResults(dependencies, results) {
|
3147 | return Array.isArray(dependencies) ? results :
|
3148 | Object.getOwnPropertyNames(dependencies).reduce((out, key, idx) => ({ ...out,
|
3149 | [key]: results[idx]
|
3150 | }), {});
|
3151 | }
|
3152 |
|
3153 | function wrapLoadables(dependencies, results, exceptions) {
|
3154 | const output = exceptions.map((exception, idx) => exception == null ? loadableWithValue$3(results[idx]) : Recoil_isPromise(exception) ? loadableWithPromise$2(exception) : loadableWithError$2(exception));
|
3155 | return wrapResults(dependencies, output);
|
3156 | }
|
3157 |
|
3158 |
|
3159 |
|
3160 | const waitForNone = Recoil_selectorFamily({
|
3161 | key: '__waitForNone',
|
3162 | get: dependencies => ({
|
3163 | get
|
3164 | }) => {
|
3165 |
|
3166 | const deps = unwrapDependencies(dependencies);
|
3167 | const [results, exceptions] = concurrentRequests(get, deps); // Always return the current status of the results; never block.
|
3168 |
|
3169 | return wrapLoadables(dependencies, results, exceptions);
|
3170 | }
|
3171 | }); // Selector that requests all dependencies in parallel and waits for at least
|
3172 | // one to be available before returning results. It will only error if all
|
3173 | // dependencies have errors.
|
3174 |
|
3175 | const waitForAny = Recoil_selectorFamily({
|
3176 | key: '__waitForAny',
|
3177 | get: dependencies => ({
|
3178 | get
|
3179 | }) => {
|
3180 |
|
3181 |
|
3182 | const deps = unwrapDependencies(dependencies);
|
3183 | const [results, exceptions] = concurrentRequests(get, deps); // If any results are available, return the current status
|
3184 |
|
3185 | if (exceptions.some(exp => exp == null)) {
|
3186 | return wrapLoadables(dependencies, results, exceptions);
|
3187 | }
|
3188 |
|
3189 |
|
3190 |
|
3191 | if (exceptions.every(isError)) {
|
3192 | throw exceptions.find(isError);
|
3193 | }
|
3194 |
|
3195 | {
|
3196 | throw new Promise((resolve, reject) => {
|
3197 | for (const [i, exp] of exceptions.entries()) {
|
3198 | if (Recoil_isPromise(exp)) {
|
3199 | exp.then(result => {
|
3200 | results[i] = result;
|
3201 | exceptions[i] = null;
|
3202 | resolve(wrapLoadables(dependencies, results, exceptions));
|
3203 | }).catch(error => {
|
3204 | exceptions[i] = error;
|
3205 |
|
3206 | if (exceptions.every(isError)) {
|
3207 | reject(exceptions[0]);
|
3208 | }
|
3209 | });
|
3210 | }
|
3211 | }
|
3212 | });
|
3213 | }
|
3214 | }
|
3215 | });
|
3216 |
|
3217 |
|
3218 | const waitForAll = Recoil_selectorFamily({
|
3219 | key: '__waitForAll',
|
3220 | get: dependencies => ({
|
3221 | get
|
3222 | }) => {
|
3223 |
|
3224 |
|
3225 | const deps = unwrapDependencies(dependencies);
|
3226 | const [results, exceptions] = concurrentRequests(get, deps); // If all results are available, return the results
|
3227 |
|
3228 | if (exceptions.every(exp => exp == null)) {
|
3229 | return wrapResults(dependencies, results);
|
3230 | }
|
3231 |
|
3232 |
|
3233 | const error = exceptions.find(isError);
|
3234 |
|
3235 | if (error != null) {
|
3236 | throw error;
|
3237 | }
|
3238 |
|
3239 | {
|
3240 | throw Promise.all(exceptions).then(results => wrapResults(dependencies, results));
|
3241 | }
|
3242 | }
|
3243 | });
|
3244 | const noWait = Recoil_selectorFamily({
|
3245 | key: '__noWait',
|
3246 | get: dependency => ({
|
3247 | get
|
3248 | }) => {
|
3249 | try {
|
3250 | return loadableWithValue$3(get(dependency));
|
3251 | } catch (exception) {
|
3252 | return Recoil_isPromise(exception) ? loadableWithPromise$2(exception) : loadableWithError$2(exception);
|
3253 | }
|
3254 | }
|
3255 | });
|
3256 | var Recoil_WaitFor = {
|
3257 | waitForNone,
|
3258 | waitForAny,
|
3259 | waitForAll,
|
3260 | noWait
|
3261 | };
|
3262 |
|
3263 | const {
|
3264 | DefaultValue: DefaultValue$3
|
3265 | } = Recoil_Node;
|
3266 |
|
3267 | const {
|
3268 | RecoilRoot: RecoilRoot$1
|
3269 | } = Recoil_RecoilRoot_react;
|
3270 |
|
3271 | const {
|
3272 | isRecoilValue: isRecoilValue$4
|
3273 | } = Recoil_RecoilValue$1;
|
3274 |
|
3275 | const {
|
3276 | useGotoRecoilSnapshot: useGotoRecoilSnapshot$1,
|
3277 | useRecoilCallback: useRecoilCallback$1,
|
3278 | useRecoilSnapshot: useRecoilSnapshot$1,
|
3279 | useRecoilState: useRecoilState$1,
|
3280 | useRecoilStateLoadable: useRecoilStateLoadable$1,
|
3281 | useRecoilTransactionObserver: useRecoilTransactionObserver$1,
|
3282 | useRecoilValue: useRecoilValue$1,
|
3283 | useRecoilValueLoadable: useRecoilValueLoadable$1,
|
3284 | useResetRecoilState: useResetRecoilState$1,
|
3285 | useSetRecoilState: useSetRecoilState$1,
|
3286 | useSetUnvalidatedAtomValues: useSetUnvalidatedAtomValues$1,
|
3287 | useTransactionObservation_DEPRECATED: useTransactionObservation_DEPRECATED$1
|
3288 | } = Recoil_Hooks;
|
3289 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 | const {
|
3305 | noWait: noWait$1,
|
3306 | waitForAll: waitForAll$1,
|
3307 | waitForAny: waitForAny$1,
|
3308 | waitForNone: waitForNone$1
|
3309 | } = Recoil_WaitFor;
|
3310 |
|
3311 | var Recoil_index = {
|
3312 |
|
3313 | DefaultValue: DefaultValue$3,
|
3314 |
|
3315 | RecoilRoot: RecoilRoot$1,
|
3316 |
|
3317 | atom: Recoil_atom,
|
3318 | selector: Recoil_selector,
|
3319 |
|
3320 | atomFamily: Recoil_atomFamily,
|
3321 | selectorFamily: Recoil_selectorFamily,
|
3322 | constSelector: Recoil_constSelector,
|
3323 | errorSelector: Recoil_errorSelector,
|
3324 | readOnlySelector: Recoil_readOnlySelector,
|
3325 |
|
3326 | useRecoilValue: useRecoilValue$1,
|
3327 | useRecoilValueLoadable: useRecoilValueLoadable$1,
|
3328 | useRecoilState: useRecoilState$1,
|
3329 | useRecoilStateLoadable: useRecoilStateLoadable$1,
|
3330 | useSetRecoilState: useSetRecoilState$1,
|
3331 | useResetRecoilState: useResetRecoilState$1,
|
3332 |
|
3333 | useRecoilCallback: useRecoilCallback$1,
|
3334 |
|
3335 | useGotoRecoilSnapshot: useGotoRecoilSnapshot$1,
|
3336 | useRecoilSnapshot: useRecoilSnapshot$1,
|
3337 | useRecoilTransactionObserver_UNSTABLE: useRecoilTransactionObserver$1,
|
3338 | useTransactionObservation_UNSTABLE: useTransactionObservation_DEPRECATED$1,
|
3339 | useSetUnvalidatedAtomValues_UNSTABLE: useSetUnvalidatedAtomValues$1,
|
3340 |
|
3341 | noWait: noWait$1,
|
3342 | waitForNone: waitForNone$1,
|
3343 | waitForAny: waitForAny$1,
|
3344 | waitForAll: waitForAll$1,
|
3345 |
|
3346 | isRecoilValue: isRecoilValue$4
|
3347 | };
|
3348 | var Recoil_index_1 = Recoil_index.DefaultValue;
|
3349 | var Recoil_index_2 = Recoil_index.RecoilRoot;
|
3350 | var Recoil_index_3 = Recoil_index.atom;
|
3351 | var Recoil_index_4 = Recoil_index.selector;
|
3352 | var Recoil_index_5 = Recoil_index.atomFamily;
|
3353 | var Recoil_index_6 = Recoil_index.selectorFamily;
|
3354 | var Recoil_index_7 = Recoil_index.constSelector;
|
3355 | var Recoil_index_8 = Recoil_index.errorSelector;
|
3356 | var Recoil_index_9 = Recoil_index.readOnlySelector;
|
3357 | var Recoil_index_10 = Recoil_index.useRecoilValue;
|
3358 | var Recoil_index_11 = Recoil_index.useRecoilValueLoadable;
|
3359 | var Recoil_index_12 = Recoil_index.useRecoilState;
|
3360 | var Recoil_index_13 = Recoil_index.useRecoilStateLoadable;
|
3361 | var Recoil_index_14 = Recoil_index.useSetRecoilState;
|
3362 | var Recoil_index_15 = Recoil_index.useResetRecoilState;
|
3363 | var Recoil_index_16 = Recoil_index.useRecoilCallback;
|
3364 | var Recoil_index_17 = Recoil_index.useGotoRecoilSnapshot;
|
3365 | var Recoil_index_18 = Recoil_index.useRecoilSnapshot;
|
3366 | var Recoil_index_19 = Recoil_index.useRecoilTransactionObserver_UNSTABLE;
|
3367 | var Recoil_index_20 = Recoil_index.useTransactionObservation_UNSTABLE;
|
3368 | var Recoil_index_21 = Recoil_index.useSetUnvalidatedAtomValues_UNSTABLE;
|
3369 | var Recoil_index_22 = Recoil_index.noWait;
|
3370 | var Recoil_index_23 = Recoil_index.waitForNone;
|
3371 | var Recoil_index_24 = Recoil_index.waitForAny;
|
3372 | var Recoil_index_25 = Recoil_index.waitForAll;
|
3373 | var Recoil_index_26 = Recoil_index.isRecoilValue;
|
3374 |
|
3375 | exports.DefaultValue = Recoil_index_1;
|
3376 | exports.RecoilRoot = Recoil_index_2;
|
3377 | exports.atom = Recoil_index_3;
|
3378 | exports.atomFamily = Recoil_index_5;
|
3379 | exports.constSelector = Recoil_index_7;
|
3380 | exports.default = Recoil_index;
|
3381 | exports.errorSelector = Recoil_index_8;
|
3382 | exports.isRecoilValue = Recoil_index_26;
|
3383 | exports.noWait = Recoil_index_22;
|
3384 | exports.readOnlySelector = Recoil_index_9;
|
3385 | exports.selector = Recoil_index_4;
|
3386 | exports.selectorFamily = Recoil_index_6;
|
3387 | exports.useGotoRecoilSnapshot = Recoil_index_17;
|
3388 | exports.useRecoilCallback = Recoil_index_16;
|
3389 | exports.useRecoilSnapshot = Recoil_index_18;
|
3390 | exports.useRecoilState = Recoil_index_12;
|
3391 | exports.useRecoilStateLoadable = Recoil_index_13;
|
3392 | exports.useRecoilTransactionObserver_UNSTABLE = Recoil_index_19;
|
3393 | exports.useRecoilValue = Recoil_index_10;
|
3394 | exports.useRecoilValueLoadable = Recoil_index_11;
|
3395 | exports.useResetRecoilState = Recoil_index_15;
|
3396 | exports.useSetRecoilState = Recoil_index_14;
|
3397 | exports.useSetUnvalidatedAtomValues_UNSTABLE = Recoil_index_21;
|
3398 | exports.useTransactionObservation_UNSTABLE = Recoil_index_20;
|
3399 | exports.waitForAll = Recoil_index_25;
|
3400 | exports.waitForAny = Recoil_index_24;
|
3401 | exports.waitForNone = Recoil_index_23;
|