recoil-next 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,573 @@
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode } from 'react';
3
+
4
+ /**
5
+ * TypeScript port of Recoil_Loadable.js
6
+ */
7
+ declare abstract class BaseLoadable<T> {
8
+ getValue(): T;
9
+ toPromise(): Promise<T>;
10
+ valueMaybe(): T | undefined;
11
+ valueOrThrow(): T;
12
+ promiseMaybe(): Promise<T> | undefined;
13
+ promiseOrThrow(): Promise<T>;
14
+ errorMaybe(): unknown | undefined;
15
+ errorOrThrow(): unknown;
16
+ is(other: Loadable<any>): boolean;
17
+ }
18
+ declare class ValueLoadable<T> extends BaseLoadable<T> {
19
+ state: 'hasValue';
20
+ contents: T;
21
+ constructor(value: T);
22
+ getValue(): T;
23
+ toPromise(): Promise<T>;
24
+ valueMaybe(): T;
25
+ valueOrThrow(): T;
26
+ promiseMaybe(): undefined;
27
+ errorMaybe(): undefined;
28
+ map<S>(map: (value: T) => Promise<S> | Loadable<S> | S): Loadable<S>;
29
+ }
30
+ declare class ErrorLoadable<T> extends BaseLoadable<T> {
31
+ state: 'hasError';
32
+ contents: unknown;
33
+ constructor(error: unknown);
34
+ getValue(): T;
35
+ toPromise(): Promise<T>;
36
+ valueMaybe(): undefined;
37
+ promiseMaybe(): undefined;
38
+ errorMaybe(): unknown;
39
+ errorOrThrow(): unknown;
40
+ map<S>(_map: (value: T) => Promise<S> | Loadable<S> | S): Loadable<S>;
41
+ }
42
+ declare class LoadingLoadable<T> extends BaseLoadable<T> {
43
+ state: 'loading';
44
+ contents: Promise<T>;
45
+ constructor(promise: Promise<T>);
46
+ getValue(): T;
47
+ toPromise(): Promise<T>;
48
+ valueMaybe(): undefined;
49
+ promiseMaybe(): Promise<T>;
50
+ promiseOrThrow(): Promise<T>;
51
+ errorMaybe(): undefined;
52
+ map<S>(map: (value: T) => Promise<S> | Loadable<S> | S): Loadable<S>;
53
+ }
54
+ type Loadable<T> = Readonly<ValueLoadable<T>> | Readonly<ErrorLoadable<T>> | Readonly<LoadingLoadable<T>>;
55
+ declare function loadableAll<Inputs extends ReadonlyArray<Loadable<any> | Promise<any> | any> | Readonly<{
56
+ [key: string]: Loadable<any> | Promise<any> | any;
57
+ }>>(inputs: Inputs): Loadable<any>;
58
+ declare function isLoadable(x: unknown): x is Loadable<unknown>;
59
+ declare const RecoilLoadable: {
60
+ of: <T>(value: Promise<T> | Loadable<T> | T) => Loadable<T>;
61
+ error: <T>(error: unknown) => Readonly<ErrorLoadable<T>>;
62
+ loading: <T>() => Readonly<LoadingLoadable<T>>;
63
+ all: typeof loadableAll;
64
+ isLoadable: typeof isLoadable;
65
+ };
66
+
67
+ /**
68
+ * TypeScript port of Recoil_RetentionZone.js
69
+ */
70
+ declare class RetentionZone {
71
+ }
72
+ declare function retentionZone(): RetentionZone;
73
+
74
+ /**
75
+ * TypeScript port of Recoil_RetainedBy.js
76
+ */
77
+
78
+ type RetainedBy = 'components' | 'recoilRoot' | RetentionZone | Array<RetentionZone>;
79
+
80
+ /**
81
+ * TypeScript port of Recoil_Keys.js
82
+ */
83
+ type NodeKey = string;
84
+ type StateID = number & {
85
+ readonly __state: unique symbol;
86
+ };
87
+ type StoreID = number & {
88
+ readonly __store: unique symbol;
89
+ };
90
+ type ComponentID = number & {
91
+ readonly __component: unique symbol;
92
+ };
93
+
94
+ /**
95
+ * TypeScript port of Recoil_PersistentMap.js
96
+ */
97
+ interface PersistentMap<K extends string, V> {
98
+ keys(): Iterable<K>;
99
+ entries(): Iterable<[K, V]>;
100
+ get(key: K): V | void;
101
+ has(key: K): boolean;
102
+ set(key: K, value: V): PersistentMap<K, V>;
103
+ delete(key: K): PersistentMap<K, V>;
104
+ clone(): PersistentMap<K, V>;
105
+ toMap(): Map<K, V>;
106
+ }
107
+
108
+ /**
109
+ * TypeScript port of Recoil_GraphTypes.js
110
+ */
111
+
112
+ type Graph = Readonly<{
113
+ nodeDeps: Map<NodeKey, ReadonlySet<NodeKey>>;
114
+ nodeToNodeSubscriptions: Map<NodeKey, Set<NodeKey>>;
115
+ }>;
116
+
117
+ type AtomValues = PersistentMap<NodeKey, Loadable<unknown>>;
118
+ type ComponentCallback = (treeState: TreeState) => void;
119
+ type Retainable$1 = RetentionZone | NodeKey;
120
+ interface TreeState {
121
+ /**
122
+ * Version always increments when moving from one state to another, even
123
+ * if the same state has been seen before.
124
+ */
125
+ version: StateID;
126
+ /**
127
+ * State ID usually increments, but when going to a snapshot that was
128
+ * previously rendered the state ID will be re-used.
129
+ */
130
+ stateID: StateID;
131
+ transactionMetadata: Record<string, unknown>;
132
+ dirtyAtoms: Set<NodeKey>;
133
+ atomValues: AtomValues;
134
+ nonvalidatedAtoms: PersistentMap<NodeKey, unknown>;
135
+ }
136
+ interface StoreState {
137
+ currentTree: TreeState;
138
+ nextTree: TreeState | null;
139
+ previousTree: TreeState | null;
140
+ commitDepth: number;
141
+ knownAtoms: Set<NodeKey>;
142
+ knownSelectors: Set<NodeKey>;
143
+ retention: {
144
+ referenceCounts: Map<NodeKey | RetentionZone, number>;
145
+ nodesRetainedByZone: Map<RetentionZone, Set<NodeKey>>;
146
+ retainablesToCheckForRelease: Set<Retainable$1>;
147
+ };
148
+ nodeCleanupFunctions: Map<NodeKey, () => void>;
149
+ nodeToComponentSubscriptions: Map<NodeKey, Map<ComponentID, [string, ComponentCallback]>>;
150
+ graphsByVersion: Map<StateID, Graph>;
151
+ transactionSubscriptions: Map<number, (store: Store) => void>;
152
+ nodeTransactionSubscriptions: Map<NodeKey, Map<number, (store: Store) => void>>;
153
+ queuedComponentCallbacks_DEPRECATED: ComponentCallback[];
154
+ suspendedComponentResolvers: Set<() => void>;
155
+ }
156
+ interface Store {
157
+ storeID: StoreID;
158
+ parentStoreID?: StoreID;
159
+ getState(): StoreState;
160
+ replaceState(cb: (treeState: TreeState) => TreeState): void;
161
+ getGraph(version: StateID): Graph;
162
+ subscribeToTransactions(callback: (store: Store) => void, nodeKey?: NodeKey): {
163
+ release: () => void;
164
+ };
165
+ addTransactionMetadata(metadata: Record<string, unknown>): void;
166
+ skipCircularDependencyDetection_DANGEROUS?: boolean;
167
+ }
168
+
169
+ declare class AbstractRecoilValue<T> {
170
+ readonly key: NodeKey;
171
+ constructor(key: NodeKey);
172
+ toJSON(): {
173
+ key: string;
174
+ };
175
+ }
176
+ declare class RecoilState<T> extends AbstractRecoilValue<T> {
177
+ }
178
+ declare class RecoilValueReadOnly<T> extends AbstractRecoilValue<T> {
179
+ }
180
+ type RecoilValue<T> = RecoilValueReadOnly<T> | RecoilState<T>;
181
+ declare function isRecoilValue(x: unknown): x is RecoilValue<unknown>;
182
+
183
+ declare class DefaultValue {
184
+ }
185
+ type PersistenceType = 'url' | 'other' | 'none';
186
+ type PersistenceInfo = {
187
+ type: PersistenceType;
188
+ backButton?: boolean;
189
+ };
190
+ type Trigger = 'get' | 'set';
191
+
192
+ /**
193
+ * TypeScript port of Recoil_callbackTypes.js
194
+ */
195
+
196
+ type ValueOrUpdater<T> = T | DefaultValue | ((prevValue: T) => T | DefaultValue);
197
+ type GetRecoilValue = <T>(recoilValue: RecoilValue<T>) => T;
198
+ type SetRecoilState = <T>(recoilState: RecoilState<T>, valueOrUpdater: ValueOrUpdater<T>) => void;
199
+ type ResetRecoilState = <T>(recoilState: RecoilState<T>) => void;
200
+
201
+ /**
202
+ * TypeScript port of Recoil_AtomicUpdates.js
203
+ */
204
+
205
+ interface TransactionInterface {
206
+ get<T>(rv: RecoilValue<T>): T;
207
+ set<T>(state: RecoilState<T>, valueOrUpdater: ValueOrUpdater<T>): void;
208
+ reset<T>(state: RecoilState<T>): void;
209
+ }
210
+
211
+ /**
212
+ * TypeScript port of Recoil_FunctionalCore.js
213
+ */
214
+
215
+ type ComponentInfo = {
216
+ name: string;
217
+ };
218
+ type RecoilValueInfo<T> = {
219
+ loadable: Loadable<T> | null;
220
+ isActive: boolean;
221
+ isSet: boolean;
222
+ isModified: boolean;
223
+ type: 'atom' | 'selector';
224
+ deps: Iterable<RecoilValue<unknown>>;
225
+ subscribers: {
226
+ nodes: Iterable<RecoilValue<unknown>>;
227
+ components: Iterable<ComponentInfo>;
228
+ };
229
+ };
230
+
231
+ /**
232
+ * Typescript port of Recoil_Snapshot.js
233
+ */
234
+
235
+ type SnapshotID = StateID;
236
+ declare class Snapshot {
237
+ _store: Store;
238
+ _refCount: number;
239
+ constructor(storeState: StoreState, parentStoreID?: StoreID);
240
+ retain(): () => void;
241
+ /**
242
+ * Release the snapshot on the next tick. This means the snapshot is retained
243
+ * during the execution of the current function using it.
244
+ */
245
+ autoRelease_INTERNAL(): void;
246
+ _release(): void;
247
+ isRetained(): boolean;
248
+ checkRefCount_INTERNAL(): void;
249
+ getStore_INTERNAL(): Store;
250
+ getID(): SnapshotID;
251
+ getStoreID(): StoreID;
252
+ getLoadable: <T>(recoilValue: RecoilValue<T>) => Loadable<T>;
253
+ getPromise: <T>(recoilValue: RecoilValue<T>) => Promise<T>;
254
+ getNodes_UNSTABLE: (opt?: {
255
+ isModified?: boolean;
256
+ isInitialized?: boolean;
257
+ }) => Iterable<RecoilValue<any>>;
258
+ getInfo_UNSTABLE: <T>(recoilValue: RecoilValue<T>) => RecoilValueInfo<T>;
259
+ map: (mapper: (mutableSnapshot: MutableSnapshot) => void) => Snapshot;
260
+ asyncMap: (mapper: (mutableSnapshot: MutableSnapshot) => Promise<void>) => Promise<Snapshot>;
261
+ }
262
+ declare function freshSnapshot(initializeState?: (mutableSnapshot: MutableSnapshot) => void): Snapshot;
263
+ declare class MutableSnapshot extends Snapshot {
264
+ _batch: (fn: () => void) => void;
265
+ constructor(snapshot: Snapshot, batch: (fn: () => void) => void);
266
+ set: SetRecoilState;
267
+ reset: ResetRecoilState;
268
+ setUnvalidatedAtomValues_DEPRECATED: (values: Map<NodeKey, any>) => void;
269
+ }
270
+
271
+ /**
272
+ * TypeScript port of Recoil_Hooks.js
273
+ */
274
+
275
+ type SetterOrUpdater<T> = (newValue: T | DefaultValue | ((currVal: T) => T | DefaultValue)) => void;
276
+ type Resetter = () => void;
277
+ declare function useRecoilValueLoadable<T>(recoilValue: RecoilValue<T>): Loadable<T>;
278
+ declare function useRecoilValue<T>(recoilValue: RecoilValue<T>): T;
279
+ declare function useSetRecoilState<T>(recoilState: RecoilState<T>): SetterOrUpdater<T>;
280
+ declare function useResetRecoilState<T>(recoilState: RecoilState<T>): Resetter;
281
+ declare function useRecoilState<T>(recoilState: RecoilState<T>): [T, SetterOrUpdater<T>];
282
+ declare function useRecoilStateLoadable<T>(recoilState: RecoilState<T>): [Loadable<T>, SetterOrUpdater<T>];
283
+ declare function useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE<T>(recoilValue: RecoilValue<T>): Loadable<T>;
284
+ declare function useRecoilValue_TRANSITION_SUPPORT_UNSTABLE<T>(recoilValue: RecoilValue<T>): T;
285
+ declare function useRecoilState_TRANSITION_SUPPORT_UNSTABLE<T>(recoilState: RecoilState<T>): [T, SetterOrUpdater<T>];
286
+
287
+ /**
288
+ * TypeScript port of Recoil_useRecoilBridgeAcrossReactRoots
289
+ */
290
+
291
+ type RecoilBridge = React.ComponentType<{
292
+ children: React.ReactNode;
293
+ }>;
294
+ declare function useRecoilBridgeAcrossReactRoots(): RecoilBridge;
295
+
296
+ /**
297
+ * TypeScript port of Recoil_useRecoilCallback
298
+ */
299
+
300
+ type RecoilCallbackInterface = Readonly<{
301
+ set: <T>(recoilState: RecoilState<T>, newValue: T | ((currValue: T) => T)) => void;
302
+ reset: <T>(recoilState: RecoilState<T>) => void;
303
+ refresh: <T>(recoilValue: RecoilValue<T>) => void;
304
+ snapshot: Snapshot;
305
+ gotoSnapshot: (snapshot: Snapshot) => void;
306
+ transact_UNSTABLE: (transaction: (iface: TransactionInterface) => void) => void;
307
+ }>;
308
+ declare function useRecoilCallback<Args extends ReadonlyArray<unknown>, Return>(fn: (iface: RecoilCallbackInterface) => (...args: Args) => Return, deps?: ReadonlyArray<unknown>): (...args: Args) => Return;
309
+
310
+ /**
311
+ * TypeScript port of Recoil_Wrapper.js
312
+ */
313
+ declare class WrappedValue<T> {
314
+ value: T;
315
+ constructor(value: T);
316
+ }
317
+
318
+ type PersistenceSettings<Stored> = Readonly<PersistenceInfo & {
319
+ validator: (storedValue: unknown, defaultValue: DefaultValue) => Stored | DefaultValue;
320
+ }>;
321
+ type NewValueOrUpdater<T> = T | DefaultValue | Promise<T | DefaultValue> | WrappedValue<T> | ((currVal: T | DefaultValue) => T | DefaultValue | Promise<T | DefaultValue> | WrappedValue<T>);
322
+ type AtomEffect<T> = (ctx: {
323
+ node: RecoilState<T>;
324
+ storeID: StoreID;
325
+ parentStoreID_UNSTABLE?: StoreID;
326
+ trigger: Trigger;
327
+ setSelf: (value: NewValueOrUpdater<T>) => void;
328
+ resetSelf: () => void;
329
+ onSet: (handler: (newValue: T, oldValue: T | DefaultValue, isReset: boolean) => void) => void;
330
+ getPromise: <S>(recoilValue: RecoilValue<S>) => Promise<S>;
331
+ getLoadable: <S>(recoilValue: RecoilValue<S>) => Loadable<S>;
332
+ getInfo_UNSTABLE: <S>(recoilValue: RecoilValue<S>) => RecoilValueInfo<S>;
333
+ }) => void | (() => void);
334
+ type AtomOptionsWithoutDefault<T> = Readonly<{
335
+ key: NodeKey;
336
+ effects?: ReadonlyArray<AtomEffect<T>>;
337
+ effects_UNSTABLE?: ReadonlyArray<AtomEffect<T>>;
338
+ persistence_UNSTABLE?: PersistenceSettings<T>;
339
+ dangerouslyAllowMutability?: boolean;
340
+ retainedBy_UNSTABLE?: RetainedBy;
341
+ }>;
342
+ type AtomOptionsWithDefault<T> = Readonly<AtomOptionsWithoutDefault<T> & {
343
+ default: RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T> | T;
344
+ }>;
345
+ type AtomOptions<T> = AtomOptionsWithDefault<T> | AtomOptionsWithoutDefault<T>;
346
+ declare function atom<T>(options: AtomOptions<T>): RecoilState<T>;
347
+ declare const atomWithWrappedValue: typeof atom & {
348
+ value: <T>(value: T) => WrappedValue<T>;
349
+ };
350
+
351
+ /**
352
+ * TypeScript port of Recoil_CachePolicy.js
353
+ */
354
+ type EqualityPolicy = 'reference' | 'value';
355
+ type CachePolicy = {
356
+ eviction: 'lru';
357
+ maxSize: number;
358
+ equality?: EqualityPolicy;
359
+ } | {
360
+ eviction: 'keep-all';
361
+ equality?: EqualityPolicy;
362
+ } | {
363
+ eviction: 'most-recent';
364
+ equality?: EqualityPolicy;
365
+ } | {
366
+ equality: EqualityPolicy;
367
+ };
368
+ type CachePolicyWithoutEviction = {
369
+ equality: EqualityPolicy;
370
+ };
371
+
372
+ /**
373
+ * TypeScript port of Recoil_selector.js
374
+ */
375
+
376
+ type SelectorCallbackInterface<T> = Readonly<RecoilCallbackInterface & {
377
+ node: RecoilState<T>;
378
+ }>;
379
+ type GetCallback<T> = <Args extends ReadonlyArray<unknown>, Return>(fn: (callbackInterface: SelectorCallbackInterface<T>) => (...args: Args) => Return) => (...args: Args) => Return;
380
+ type BaseSelectorOptions = Readonly<{
381
+ key: string;
382
+ dangerouslyAllowMutability?: boolean;
383
+ retainedBy_UNSTABLE?: RetainedBy;
384
+ cachePolicy_UNSTABLE?: CachePolicy;
385
+ }>;
386
+ type ReadOnlySelectorOptions<T> = Readonly<BaseSelectorOptions & {
387
+ get: (opts: {
388
+ get: GetRecoilValue;
389
+ getCallback: GetCallback<T>;
390
+ }) => RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T> | T;
391
+ }>;
392
+ type ReadWriteSelectorOptions<T> = Readonly<ReadOnlySelectorOptions<T> & {
393
+ set: (opts: {
394
+ set: SetRecoilState;
395
+ get: GetRecoilValue;
396
+ reset: ResetRecoilState;
397
+ }, newValue: T | DefaultValue) => void;
398
+ }>;
399
+ declare function selector<T>(options: ReadOnlySelectorOptions<T>): RecoilValueReadOnly<T>;
400
+ declare function selector<T>(options: ReadWriteSelectorOptions<T>): RecoilState<T>;
401
+
402
+ /**
403
+ * TypeScript port of Recoil_selectorFamily.js
404
+ */
405
+
406
+ type Primitive = void | null | boolean | number | string;
407
+ interface HasToJSON {
408
+ toJSON(): Parameter;
409
+ }
410
+ type Parameter = Primitive | HasToJSON | ReadonlySet<Parameter> | ReadonlyMap<Parameter, Parameter> | ReadonlyArray<Parameter> | {
411
+ [key: string]: Parameter;
412
+ };
413
+ type BaseSelectorFamilyOptions<P extends Parameter> = Readonly<{
414
+ key: string;
415
+ cachePolicyForParams_UNSTABLE?: CachePolicyWithoutEviction;
416
+ cachePolicy_UNSTABLE?: CachePolicy;
417
+ dangerouslyAllowMutability?: boolean;
418
+ retainedBy_UNSTABLE?: RetainedBy | ((param: P) => RetainedBy);
419
+ }>;
420
+ type ReadOnlySelectorFamilyOptions<T, P extends Parameter> = Readonly<BaseSelectorFamilyOptions<P> & {
421
+ get: (param: P) => (callbacks: {
422
+ get: GetRecoilValue;
423
+ getCallback: GetCallback<T>;
424
+ }) => Promise<T> | Loadable<T> | WrappedValue<T> | RecoilValue<T> | T;
425
+ }>;
426
+ type ReadWriteSelectorFamilyOptions<T, P extends Parameter> = Readonly<ReadOnlySelectorFamilyOptions<T, P> & {
427
+ set: (param: P) => (callbacks: {
428
+ set: SetRecoilState;
429
+ get: GetRecoilValue;
430
+ reset: ResetRecoilState;
431
+ }, newValue: T | DefaultValue) => void;
432
+ }>;
433
+ type SelectorFamilyOptions<T, P extends Parameter> = ReadOnlySelectorFamilyOptions<T, P> | ReadWriteSelectorFamilyOptions<T, P>;
434
+ declare function selectorFamily<T, Params extends Parameter>(options: ReadOnlySelectorFamilyOptions<T, Params>): (params: Params) => RecoilValueReadOnly<T>;
435
+ declare function selectorFamily<T, Params extends Parameter>(options: ReadWriteSelectorFamilyOptions<T, Params>): (params: Params) => RecoilState<T>;
436
+
437
+ /**
438
+ * TypeScript port of Recoil_RecoilEnv.js
439
+ */
440
+ type RecoilEnv = {
441
+ RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED: boolean;
442
+ RECOIL_GKS_ENABLED: Set<string>;
443
+ };
444
+ declare const env: RecoilEnv;
445
+
446
+ /**
447
+ * Typescript port of Recoil_RecoilRoot.js
448
+ */
449
+
450
+ type Props = {
451
+ initializeState_DEPRECATED?: (options: {
452
+ set: <T>(recoilValue: RecoilValue<T>, value: T) => void;
453
+ setUnvalidatedAtomValues: (values: Map<string, unknown>) => void;
454
+ }) => void;
455
+ initializeState?: (mutableSnapshot: MutableSnapshot) => void;
456
+ store_INTERNAL?: Store;
457
+ store?: Store;
458
+ override?: true;
459
+ children: ReactNode;
460
+ skipCircularDependencyDetection_DANGEROUS?: boolean;
461
+ } | {
462
+ store_INTERNAL?: Store;
463
+ store?: Store;
464
+ /**
465
+ * Defaults to true. If override is true, this RecoilRoot will create a
466
+ * new Recoil scope. If override is false and this RecoilRoot is nested
467
+ * within another RecoilRoot, this RecoilRoot will perform no function.
468
+ * Children of this RecoilRoot will access the Recoil values of the
469
+ * nearest ancestor RecoilRoot.
470
+ */
471
+ override: false;
472
+ children: ReactNode;
473
+ skipCircularDependencyDetection_DANGEROUS?: boolean;
474
+ };
475
+ declare function RecoilRoot(props: Props): React__default.ReactElement;
476
+ declare function useRecoilStoreID(): StoreID;
477
+
478
+ /**
479
+ * TypeScript port of Recoil_SnapshotHooks
480
+ */
481
+
482
+ declare function useRecoilTransactionObserver(callback: (info: {
483
+ snapshot: Snapshot;
484
+ previousSnapshot: Snapshot;
485
+ }) => void): void;
486
+ declare function useRecoilSnapshot(): Snapshot;
487
+ declare function useGotoRecoilSnapshot(): (snapshot: Snapshot) => void;
488
+
489
+ declare function useGetRecoilValueInfo(): (<T>(recoilValue: RecoilValue<T>) => RecoilValueInfo<T>);
490
+
491
+ declare function useRecoilRefresher<T>(recoilValue: RecoilValue<T>): () => void;
492
+
493
+ declare function useRecoilTransaction<Args extends ReadonlyArray<unknown>>(fn: (ti: TransactionInterface) => (...args: Args) => void, deps?: ReadonlyArray<unknown>): (...args: Args) => void;
494
+
495
+ /**
496
+ * TypeScript port of Recoil_useRetain.js
497
+ */
498
+
499
+ type Retainable = RecoilValue<unknown> | RetentionZone;
500
+ declare function useRetain(retainable: Retainable): void;
501
+
502
+ /**
503
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
504
+ *
505
+ * This source code is licensed under the MIT license found in the
506
+ * LICENSE file in the root directory of this source tree.
507
+ *
508
+ * @oncall recoil
509
+ */
510
+
511
+ type AtomFamilyOptionsWithoutDefault<T, P extends Parameter> = Readonly<AtomOptionsWithoutDefault<T> & {
512
+ effects?: ReadonlyArray<AtomEffect<T>> | ((param: P) => ReadonlyArray<AtomEffect<T>>);
513
+ retainedBy_UNSTABLE?: RetainedBy | ((param: P) => RetainedBy);
514
+ cachePolicyForParams_UNSTABLE?: CachePolicyWithoutEviction;
515
+ }>;
516
+ type AtomFamilyOptions<T, P extends Parameter> = (Readonly<AtomFamilyOptionsWithoutDefault<T, P> & {
517
+ default: RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T> | T | ((param: P) => T | RecoilValue<T> | Promise<T> | Loadable<T> | WrappedValue<T>);
518
+ }>) | AtomFamilyOptionsWithoutDefault<T, P>;
519
+ declare function atomFamily<T, P extends Parameter>(options: AtomFamilyOptions<T, P>): (params: P) => RecoilState<T>;
520
+
521
+ /**
522
+ * TypeScript port of Recoil_constSelector.js
523
+ */
524
+
525
+ declare function constSelector<T extends Parameter>(constant: T): RecoilValueReadOnly<T>;
526
+
527
+ /**
528
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
529
+ *
530
+ * This source code is licensed under the MIT license found in the
531
+ * LICENSE file in the root directory of this source tree.
532
+ *
533
+ * @oncall recoil
534
+ */
535
+
536
+ declare function errorSelector<T>(message: string): RecoilValueReadOnly<T>;
537
+
538
+ /**
539
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
540
+ *
541
+ * This source code is licensed under the MIT license found in the
542
+ * LICENSE file in the root directory of this source tree.
543
+ *
544
+ * Wraps another recoil value and prevents writing to it.
545
+ *
546
+ * @oncall recoil
547
+ */
548
+
549
+ declare function readOnlySelector<T>(atom: RecoilValue<T>): RecoilValueReadOnly<T>;
550
+
551
+ /**
552
+ * TypeScript port of Recoil_WaitFor.js
553
+ */
554
+
555
+ type RecoilValues = ReadonlyArray<RecoilValueReadOnly<unknown>> | Readonly<{
556
+ [key: string]: RecoilValueReadOnly<unknown>;
557
+ }>;
558
+ declare const waitForNone: <T extends RecoilValues>(recoilValues: T) => RecoilValueReadOnly<T extends ReadonlyArray<RecoilValueReadOnly<any>> | Readonly<{}> ? {
559
+ [K in keyof T]: Loadable<T[K] extends RecoilValue<infer V> ? V : never>;
560
+ } : never>;
561
+ declare const waitForAny: <T extends RecoilValues>(recoilValues: T) => RecoilValueReadOnly<T extends ReadonlyArray<RecoilValueReadOnly<any>> | Readonly<{}> ? {
562
+ [K in keyof T]: Loadable<T[K] extends RecoilValue<infer V> ? V : never>;
563
+ } : never>;
564
+ declare const waitForAll: <T extends RecoilValues>(recoilValues: T) => RecoilValueReadOnly<T extends ReadonlyArray<RecoilValueReadOnly<any>> | Readonly<{}> ? {
565
+ [K in keyof T]: T[K] extends RecoilValue<infer V> ? V : never;
566
+ } : never>;
567
+ declare const waitForAllSettled: <T extends RecoilValues>(recoilValues: T) => RecoilValueReadOnly<T extends ReadonlyArray<RecoilValueReadOnly<any>> | Readonly<{}> ? {
568
+ [K in keyof T]: Loadable<T[K] extends RecoilValue<infer V> ? V : never>;
569
+ } : never>;
570
+ declare const noWait: <T>(recoilValue: RecoilValue<T>) => RecoilValueReadOnly<Loadable<T>>;
571
+
572
+ export { DefaultValue, MutableSnapshot, env as RecoilEnv, RecoilLoadable, RecoilRoot, RecoilState, RecoilValueReadOnly, Snapshot, atomWithWrappedValue as atom, atomFamily, constSelector, errorSelector, isRecoilValue, noWait, readOnlySelector, retentionZone, selector, selectorFamily, freshSnapshot as snapshot_UNSTABLE, useGetRecoilValueInfo as useGetRecoilValueInfo_UNSTABLE, useGotoRecoilSnapshot, useRecoilBridgeAcrossReactRoots as useRecoilBridgeAcrossReactRoots_UNSTABLE, useRecoilCallback, useRecoilRefresher as useRecoilRefresher_UNSTABLE, useRecoilSnapshot, useRecoilState, useRecoilStateLoadable, useRecoilState_TRANSITION_SUPPORT_UNSTABLE, useRecoilStoreID, useRecoilTransactionObserver as useRecoilTransactionObserver_UNSTABLE, useRecoilTransaction as useRecoilTransaction_UNSTABLE, useRecoilValue, useRecoilValueLoadable, useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE, useRecoilValue_TRANSITION_SUPPORT_UNSTABLE, useResetRecoilState, useRetain, useSetRecoilState, waitForAll, waitForAllSettled, waitForAny, waitForNone };
573
+ export type { AtomEffect, GetRecoilValue, Loadable, Parameter, PersistenceSettings, PersistenceType, RecoilBridge, RecoilCallbackInterface, RecoilValue, ResetRecoilState, SelectorFamilyOptions, SetRecoilState, SetterOrUpdater, SnapshotID, StoreID, TransactionInterface };