atom.io 0.16.2 → 0.17.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.
- package/dist/chunk-H4Q5FTPZ.js +11 -0
- package/dist/chunk-H4Q5FTPZ.js.map +1 -0
- package/dist/index.cjs +35 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +12 -36
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +268 -195
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +36 -11
- package/internal/dist/index.js +258 -195
- package/internal/dist/index.js.map +1 -1
- package/internal/src/atom/create-regular-atom.ts +2 -3
- package/internal/src/families/find-in-store.ts +74 -0
- package/internal/src/families/index.ts +1 -0
- package/internal/src/get-state/get-from-store.ts +14 -0
- package/internal/src/get-state/index.ts +2 -0
- package/internal/src/{read-or-compute-value.ts → get-state/read-or-compute-value.ts} +3 -3
- package/internal/src/index.ts +1 -1
- package/internal/src/ingest-updates/ingest-atom-update.ts +2 -2
- package/internal/src/ingest-updates/ingest-transaction-update.ts +1 -0
- package/internal/src/mutable/create-mutable-atom.ts +3 -4
- package/internal/src/mutable/tracker.ts +43 -35
- package/internal/src/mutable/transceiver.ts +1 -1
- package/internal/src/not-found-error.ts +14 -3
- package/internal/src/operation.ts +2 -1
- package/internal/src/selector/create-writable-selector.ts +2 -1
- package/internal/src/selector/register-selector.ts +6 -5
- package/internal/src/set-state/index.ts +1 -0
- package/internal/src/set-state/set-atom.ts +17 -3
- package/internal/src/set-state/set-into-store.ts +24 -0
- package/internal/src/set-state/stow-update.ts +2 -4
- package/internal/src/store/store.ts +13 -4
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +1 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +5 -5
- package/internal/src/transaction/abort-transaction.ts +2 -1
- package/internal/src/transaction/apply-transaction.ts +5 -3
- package/internal/src/transaction/build-transaction.ts +20 -11
- package/internal/src/transaction/create-transaction.ts +2 -3
- package/internal/src/transaction/index.ts +3 -2
- package/internal/src/transaction/is-root-store.ts +23 -0
- package/package.json +10 -10
- package/react/dist/index.cjs +27 -21
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +8 -2
- package/react/dist/index.js +28 -22
- package/react/dist/index.js.map +1 -1
- package/react/src/index.ts +4 -1
- package/react/src/use-i.ts +35 -0
- package/react/src/use-json.ts +38 -0
- package/react/src/use-o.ts +33 -0
- package/react/src/use-tl.ts +45 -0
- package/realtime-client/dist/index.cjs +167 -64
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +10 -6
- package/realtime-client/dist/index.js +158 -63
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +2 -1
- package/realtime-client/src/pull-family-member.ts +3 -3
- package/realtime-client/src/pull-mutable-family-member.ts +4 -4
- package/realtime-client/src/pull-mutable.ts +4 -4
- package/realtime-client/src/pull-state.ts +7 -6
- package/realtime-client/src/{realtime-client-store.ts → realtime-client-stores/client-main-store.ts} +0 -8
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +15 -0
- package/realtime-client/src/realtime-client-stores/index.ts +2 -0
- package/realtime-client/src/sync-server-action.ts +134 -40
- package/realtime-client/src/sync-state.ts +19 -0
- package/realtime-react/dist/index.cjs +43 -26
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +3 -1
- package/realtime-react/dist/index.js +41 -25
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +1 -0
- package/realtime-react/src/on-mount.ts +3 -21
- package/realtime-react/src/use-realtime-service.ts +1 -1
- package/realtime-react/src/use-single-effect.ts +29 -0
- package/realtime-react/src/use-sync-server-action.ts +4 -7
- package/realtime-react/src/use-sync.ts +17 -0
- package/realtime-server/dist/index.cjs +239 -56
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +140 -9
- package/realtime-server/dist/index.js +228 -58
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +2 -0
- package/realtime-server/src/realtime-action-synchronizer.ts +95 -14
- package/realtime-server/src/realtime-family-provider.ts +11 -6
- package/realtime-server/src/realtime-mutable-family-provider.ts +8 -6
- package/realtime-server/src/realtime-mutable-provider.ts +3 -2
- package/realtime-server/src/realtime-server-stores/index.ts +2 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +115 -0
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +45 -0
- package/realtime-server/src/realtime-state-provider.ts +18 -11
- package/realtime-server/src/realtime-state-receiver.ts +2 -2
- package/realtime-server/src/realtime-state-synchronizer.ts +23 -0
- package/realtime-testing/dist/index.cjs +65 -26
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.ts +11 -7
- package/realtime-testing/dist/index.js +64 -26
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +83 -43
- package/src/find-state.ts +8 -16
- package/src/get-state.ts +2 -11
- package/src/logger.ts +1 -0
- package/src/set-state.ts +1 -13
- package/src/silo.ts +7 -3
- package/src/transaction.ts +3 -3
- package/react/src/store-hooks.ts +0 -87
- package/realtime-server/src/realtime-server-store.ts +0 -39
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ƒn as _n, TransactionUpdate, TransactionOptions, TransactionToken, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, WritableSelectorToken, ReadonlySelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken, AtomToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, SelectorToken, MutableAtomOptions, MutableAtomFamilyOptions, AtomFamily, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, Transactors, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
1
|
+
import { ƒn as _n, TransactionUpdate, TransactionOptions, TransactionToken, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, WritableSelectorToken, ReadonlySelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken, AtomToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, SelectorToken, MutableAtomOptions, MutableAtomFamilyOptions, AtomFamily, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, MutableAtomFamilyToken, RegularAtomFamilyToken, WritableSelectorFamilyToken, ReadonlySelectorFamilyToken, WritableFamilyToken, ReadableFamilyToken, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, Transactors, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
3
3
|
import { Store as Store$1 } from 'atom.io/internal';
|
|
4
4
|
|
|
@@ -6,7 +6,18 @@ declare const abortTransaction: (store: Store) => void;
|
|
|
6
6
|
|
|
7
7
|
declare const applyTransaction: <ƒ extends _n>(output: ReturnType<ƒ>, store: Store) => void;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
interface RootStore extends Store {
|
|
10
|
+
transactionMeta: TransactionEpoch;
|
|
11
|
+
parent: null;
|
|
12
|
+
child: ChildStore | null;
|
|
13
|
+
}
|
|
14
|
+
interface ChildStore extends Store {
|
|
15
|
+
transactionMeta: TransactionProgress<_n>;
|
|
16
|
+
parent: ChildStore | RootStore;
|
|
17
|
+
child: ChildStore | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare const buildTransaction: (key: string, params: any[], store: Store, id?: string) => ChildStore;
|
|
10
21
|
|
|
11
22
|
declare class Subject<T> {
|
|
12
23
|
Subscriber: (value: T) => void;
|
|
@@ -32,12 +43,14 @@ declare function createTransaction<ƒ extends _n>(options: TransactionOptions<ƒ
|
|
|
32
43
|
|
|
33
44
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
34
45
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
35
|
-
type
|
|
46
|
+
type TransactionProgress<ƒ extends _n> = {
|
|
36
47
|
phase: `applying` | `building`;
|
|
37
|
-
time: number;
|
|
38
48
|
update: TransactionUpdate<ƒ>;
|
|
39
49
|
transactors: TransactorsWithRunAndEnv;
|
|
40
50
|
};
|
|
51
|
+
type TransactionEpoch = {
|
|
52
|
+
epoch: number;
|
|
53
|
+
};
|
|
41
54
|
|
|
42
55
|
declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
|
|
43
56
|
declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>): MutableAtomToken<T, any>;
|
|
@@ -198,11 +211,11 @@ declare class Store implements Lineage {
|
|
|
198
211
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
199
212
|
transactionCreation: Subject<TransactionToken<_n>>;
|
|
200
213
|
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
201
|
-
transactionApplying: StatefulSubject<
|
|
214
|
+
transactionApplying: StatefulSubject<TransactionProgress<_n> | null>;
|
|
202
215
|
operationClose: Subject<OperationProgress>;
|
|
203
216
|
};
|
|
204
217
|
operation: OperationProgress;
|
|
205
|
-
transactionMeta:
|
|
218
|
+
transactionMeta: TransactionEpoch | TransactionProgress<_n>;
|
|
206
219
|
config: {
|
|
207
220
|
name: string;
|
|
208
221
|
};
|
|
@@ -235,7 +248,7 @@ declare function withdrawNewFamilyMember<T>(token: WritableToken<T>, store: Stor
|
|
|
235
248
|
declare function withdrawNewFamilyMember<T>(token: ReadableToken<T>, store: Store): ReadableState<T> | undefined;
|
|
236
249
|
|
|
237
250
|
interface Transceiver<Signal extends Json.Serializable> {
|
|
238
|
-
do: (update: Signal) =>
|
|
251
|
+
do: (update: Signal) => number | `OUT_OF_RANGE` | null;
|
|
239
252
|
undo: (update: Signal) => void;
|
|
240
253
|
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
241
254
|
cacheUpdateNumber: number;
|
|
@@ -324,12 +337,23 @@ declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(op
|
|
|
324
337
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>, store: Store): WritableSelectorFamily<T, K>;
|
|
325
338
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
326
339
|
|
|
340
|
+
declare function findInStore<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key, store: Store): MutableAtomToken<T, J>;
|
|
341
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key, store: Store): RegularAtomToken<T>;
|
|
342
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key, store: Store): WritableSelectorToken<T>;
|
|
343
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key, store: Store): ReadonlySelectorToken<T>;
|
|
344
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken<T, K>, key: Key, store: Store): WritableToken<T>;
|
|
345
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key, store: Store): ReadableToken<T>;
|
|
346
|
+
|
|
327
347
|
type EnvironmentData = {
|
|
328
348
|
runtime: `browser` | `node` | `unknown`;
|
|
329
349
|
store: Store;
|
|
330
350
|
};
|
|
331
351
|
declare function getEnvironmentData(store: Store): EnvironmentData;
|
|
332
352
|
|
|
353
|
+
declare function getFromStore<T>(token: ReadableToken<T>, store: Store): T;
|
|
354
|
+
|
|
355
|
+
declare const readOrComputeValue: <T>(state: ReadableState<T>, target: Store) => T;
|
|
356
|
+
|
|
333
357
|
declare function ingestAtomUpdate(applying: `newValue` | `oldValue`, atomUpdate: KeyedStateUpdate<any>, store: Store): void;
|
|
334
358
|
|
|
335
359
|
declare function ingestSelectorUpdate(applying: `newValue` | `oldValue`, selectorUpdate: TimelineSelectorUpdate<any>, store: Store): void;
|
|
@@ -365,12 +389,11 @@ declare class LazyMap<K, V> extends Map<K, V> {
|
|
|
365
389
|
delete(key: K): boolean;
|
|
366
390
|
}
|
|
367
391
|
|
|
392
|
+
type AtomIOToken = ReadableFamilyToken<any, any> | ReadableToken<any> | TimelineToken<any> | TransactionToken<any>;
|
|
368
393
|
declare class NotFoundError extends Error {
|
|
369
|
-
constructor(token:
|
|
394
|
+
constructor(token: AtomIOToken, store: Store);
|
|
370
395
|
}
|
|
371
396
|
|
|
372
|
-
declare const readOrComputeValue: <T>(state: ReadableState<T>, target: Store) => T;
|
|
373
|
-
|
|
374
397
|
declare const createReadonlySelector: <T>(options: ReadonlySelectorOptions<T>, family: FamilyMetadata | undefined, store: Store) => ReadonlySelectorToken<T>;
|
|
375
398
|
|
|
376
399
|
declare function createStandaloneSelector<T>(options: WritableSelectorOptions<T>, store: Store): WritableSelectorToken<T>;
|
|
@@ -394,6 +417,8 @@ declare const become: <T>(nextVersionOfThing: T | Modify<T>) => (originalThing:
|
|
|
394
417
|
|
|
395
418
|
declare const setAtomOrSelector: <T>(state: WritableState<T>, value: T | ((oldValue: T) => T), store: Store) => void;
|
|
396
419
|
|
|
420
|
+
declare function setIntoStore<T, New extends T>(token: WritableToken<T>, value: New | ((oldValue: T) => New), store: Store): void;
|
|
421
|
+
|
|
397
422
|
declare const subscribeToRootAtoms: <T>(selector: Selector<T>, store: Store) => (() => void)[] | null;
|
|
398
423
|
|
|
399
424
|
declare function subscribeToState<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key: string, store: Store): () => void;
|
|
@@ -435,4 +460,4 @@ type Selector<T> = ReadonlySelector<T> | WritableSelector<T>;
|
|
|
435
460
|
type WritableState<T> = Atom<T> | WritableSelector<T>;
|
|
436
461
|
type ReadableState<T> = Atom<T> | Selector<T>;
|
|
437
462
|
|
|
438
|
-
export { type Atom, type AtomKey, type BaseStateData, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type
|
|
463
|
+
export { type Atom, type AtomKey, type BaseStateData, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deleteAtom, deleteSelector, deposit, evictCachedValue, findInStore, getEnvironmentData, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isDone, isMutable, isReadonlySelectorKey, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|