atom.io 0.15.3 → 0.15.4
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/data/dist/index.cjs +9 -0
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.js +9 -0
- package/data/dist/index.js.map +1 -1
- package/data/src/join.ts +9 -0
- package/dist/{chunk-K22LR3V6.js → chunk-RLZQ6IIY.js} +11 -2
- package/dist/chunk-RLZQ6IIY.js.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +89 -72
- package/dist/index.js +1 -1
- package/internal/dist/index.cjs +16 -16
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +18 -18
- package/internal/dist/index.js +17 -17
- package/internal/dist/index.js.map +1 -1
- package/internal/src/atom/create-regular-atom.ts +1 -1
- package/internal/src/mutable/tracker.ts +3 -3
- package/internal/src/operation.ts +1 -1
- package/internal/src/selector/create-read-write-selector.ts +1 -1
- package/internal/src/selector/create-readonly-selector.ts +1 -1
- package/internal/src/store/store.ts +4 -4
- package/internal/src/store/withdraw.ts +7 -9
- package/internal/src/subscribe/subscribe-to-timeline.ts +4 -4
- package/internal/src/timeline/add-atom-to-timeline.ts +7 -7
- package/internal/src/timeline/create-timeline.ts +29 -21
- package/internal/src/timeline/time-travel.ts +1 -1
- package/internal/src/transaction/apply-transaction.ts +2 -2
- package/internal/src/transaction/build-transaction.ts +1 -1
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/introspection/dist/index.cjs +9 -9
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +2 -2
- package/introspection/dist/index.js +9 -9
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-atom-index.ts +2 -2
- package/introspection/src/attach-introspection-states.ts +2 -2
- package/introspection/src/attach-selector-index.ts +2 -2
- package/introspection/src/attach-timeline-family.ts +6 -6
- package/introspection/src/attach-timeline-index.ts +6 -4
- package/introspection/src/attach-transaction-index.ts +1 -1
- package/package.json +8 -9
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +1 -1
- package/react-devtools/dist/index.cjs +7 -9
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.ts +7 -262
- package/react-devtools/dist/index.js +7 -9
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/TimelineIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/realtime-client/dist/index.cjs +1 -1
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +2 -2
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/realtime-state.ts +3 -3
- package/realtime-react/dist/index.cjs +2 -4
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.js +2 -4
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/realtime-context.tsx +2 -4
- package/src/index.ts +10 -0
- package/src/subscribe.ts +7 -11
- package/src/timeline.ts +18 -10
- package/src/validators.ts +74 -0
- package/dist/chunk-K22LR3V6.js.map +0 -1
- package/internal/src/set-state/copy-mutable-into-new-store.ts +0 -34
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FamilyMetadata as FamilyMetadata$1, SelectorOptions, SelectorToken, ReadonlySelectorOptions, ReadonlySelectorToken, Transactors, StateToken, ƒn as _n, TransactionUpdate, TransactionOptions, TransactionToken, TransactorsWithRun, AtomToken, MutableAtomOptions, MutableAtomToken, MutableAtomFamilyOptions, MutableAtomFamily, SelectorFamily, AtomFamily, StateUpdate, TimelineUpdate, TimelineOptions, TimelineToken, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomOptions, AtomFamilyOptions, ReadonlySelectorFamilyOptions, SelectorFamilyOptions, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
1
|
+
import { FamilyMetadata as FamilyMetadata$1, SelectorOptions, SelectorToken, ReadonlySelectorOptions, ReadonlySelectorToken, Transactors, StateToken, ƒn as _n, TransactionUpdate, TransactionOptions, TransactionToken, TransactorsWithRun, AtomToken, MutableAtomOptions, MutableAtomToken, MutableAtomFamilyOptions, MutableAtomFamily, SelectorFamily, AtomFamily, TimelineManageable, StateUpdate, TokenType, TimelineUpdate, TimelineOptions, TimelineToken, ReadonlySelectorFamily, AtomIOLogger, Logger, ReadableToken, AtomOptions, AtomFamilyOptions, ReadonlySelectorFamilyOptions, SelectorFamilyOptions, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json } from 'atom.io/json';
|
|
3
3
|
import { Store as Store$1 } from 'atom.io/internal';
|
|
4
4
|
|
|
@@ -253,40 +253,40 @@ declare const closeOperation: (store: Store) => void;
|
|
|
253
253
|
declare const isDone: (key: string, store: Store) => boolean;
|
|
254
254
|
declare const markDone: (key: string, store: Store) => void;
|
|
255
255
|
|
|
256
|
-
type TimelineAtomUpdate = StateUpdate<
|
|
256
|
+
type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = StateUpdate<TokenType<ManagedAtom>> & {
|
|
257
257
|
key: string;
|
|
258
258
|
type: `atom_update`;
|
|
259
259
|
timestamp: number;
|
|
260
260
|
family?: FamilyMetadata$1;
|
|
261
261
|
};
|
|
262
|
-
type TimelineSelectorUpdate = {
|
|
262
|
+
type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
|
|
263
263
|
key: string;
|
|
264
264
|
type: `selector_update`;
|
|
265
265
|
timestamp: number;
|
|
266
|
-
atomUpdates: Omit<TimelineAtomUpdate
|
|
266
|
+
atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[];
|
|
267
267
|
};
|
|
268
268
|
type TimelineTransactionUpdate = TransactionUpdate<_n> & {
|
|
269
269
|
key: string;
|
|
270
270
|
type: `transaction_update`;
|
|
271
271
|
timestamp: number;
|
|
272
272
|
};
|
|
273
|
-
type Timeline = {
|
|
273
|
+
type Timeline<ManagedAtom extends TimelineManageable> = {
|
|
274
274
|
type: `timeline`;
|
|
275
275
|
key: string;
|
|
276
276
|
at: number;
|
|
277
|
-
shouldCapture?: (update: TimelineUpdate
|
|
277
|
+
shouldCapture?: (update: TimelineUpdate<TimelineManageable>, timeline: Timeline<ManagedAtom>) => boolean;
|
|
278
278
|
timeTraveling: `into_future` | `into_past` | null;
|
|
279
|
-
history: TimelineUpdate[];
|
|
279
|
+
history: TimelineUpdate<ManagedAtom>[];
|
|
280
280
|
selectorTime: number | null;
|
|
281
281
|
transactionKey: string | null;
|
|
282
282
|
install: (store: Store) => void;
|
|
283
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
283
|
+
subject: Subject<TimelineAtomUpdate<ManagedAtom> | TimelineSelectorUpdate<ManagedAtom> | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
284
284
|
};
|
|
285
|
-
declare function createTimeline(options: TimelineOptions
|
|
285
|
+
declare function createTimeline<ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>, store: Store, data?: Timeline<ManagedAtom>): TimelineToken<ManagedAtom>;
|
|
286
286
|
|
|
287
|
-
declare const addAtomToTimeline: (atomToken: AtomToken<any>, tl: Timeline
|
|
287
|
+
declare const addAtomToTimeline: (atomToken: AtomToken<any>, tl: Timeline<any>, store: Store) => void;
|
|
288
288
|
|
|
289
|
-
declare const timeTravel: (direction: `backward` | `forward`, token: TimelineToken
|
|
289
|
+
declare const timeTravel: (direction: `backward` | `forward`, token: TimelineToken<any>, store: Store) => void;
|
|
290
290
|
|
|
291
291
|
declare class Store implements Lineage {
|
|
292
292
|
parent: Store | null;
|
|
@@ -297,7 +297,7 @@ declare class Store implements Lineage {
|
|
|
297
297
|
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
298
298
|
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
299
299
|
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
300
|
-
timelines: Map<string, Timeline
|
|
300
|
+
timelines: Map<string, Timeline<any>>;
|
|
301
301
|
transactions: Map<string, Transaction<_n>>;
|
|
302
302
|
atomsThatAreDefault: Set<string>;
|
|
303
303
|
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
@@ -305,13 +305,13 @@ declare class Store implements Lineage {
|
|
|
305
305
|
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
306
306
|
source: string;
|
|
307
307
|
}>;
|
|
308
|
-
|
|
308
|
+
on: {
|
|
309
309
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
310
310
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
311
311
|
transactionCreation: Subject<TransactionToken<_n>>;
|
|
312
|
-
timelineCreation: Subject<TimelineToken
|
|
312
|
+
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
313
313
|
transactionApplying: StatefulSubject<TransactionMeta<_n> | null>;
|
|
314
|
-
|
|
314
|
+
operationClose: Subject<OperationProgress>;
|
|
315
315
|
};
|
|
316
316
|
operation: OperationProgress;
|
|
317
317
|
transactionMeta: TransactionMeta<_n> | null;
|
|
@@ -333,8 +333,8 @@ declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T>
|
|
|
333
333
|
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T> | undefined;
|
|
334
334
|
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | undefined;
|
|
335
335
|
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends _n ? T : never> | undefined;
|
|
336
|
-
declare function withdraw<T>(token:
|
|
337
|
-
declare function withdraw<T>(token: TimelineToken
|
|
336
|
+
declare function withdraw<T>(token: ReadableToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | undefined;
|
|
337
|
+
declare function withdraw<T>(token: TimelineToken<T>, store: Store): Timeline<T extends TimelineManageable ? T : never> | undefined;
|
|
338
338
|
|
|
339
339
|
declare function withdrawNewFamilyMember<T>(token: AtomToken<T>, store: Store): Atom<T> | undefined;
|
|
340
340
|
declare function withdrawNewFamilyMember<T>(token: SelectorToken<T>, store: Store): Selector<T> | undefined;
|
|
@@ -422,7 +422,7 @@ declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>
|
|
|
422
422
|
|
|
423
423
|
declare function subscribeToState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key: string, store: Store): () => void;
|
|
424
424
|
|
|
425
|
-
declare const subscribeToTimeline: (token: TimelineToken
|
|
425
|
+
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void, key: string, store: Store$1) => (() => void);
|
|
426
426
|
|
|
427
427
|
declare const subscribeToTransaction: <ƒ extends _n>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key: string, store: Store$1) => (() => void);
|
|
428
428
|
|
package/internal/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getState as getState$1, setState as setState$1, runTransaction } from '../../dist/chunk-
|
|
1
|
+
import { getState as getState$1, setState as setState$1, runTransaction } from '../../dist/chunk-RLZQ6IIY.js';
|
|
2
2
|
import { Junction } from '../../dist/chunk-NYTGCPHB.js';
|
|
3
3
|
import { __spreadValues, __spreadProps } from '../../dist/chunk-PZLG2HP3.js';
|
|
4
4
|
import { selectJson, stringifyJson, parseJson, selectJsonFamily } from 'atom.io/json';
|
|
@@ -187,7 +187,7 @@ var closeOperation = (store) => {
|
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
store.operation = { open: false };
|
|
190
|
-
store.
|
|
190
|
+
store.on.operationClose.next(store.operation);
|
|
191
191
|
};
|
|
192
192
|
var isDone = (key, store) => {
|
|
193
193
|
if (!store.operation.open) {
|
|
@@ -413,13 +413,13 @@ var Store = class {
|
|
|
413
413
|
makeContentKey: (...keys) => keys.sort().join(`:`)
|
|
414
414
|
}
|
|
415
415
|
);
|
|
416
|
-
this.
|
|
416
|
+
this.on = {
|
|
417
417
|
atomCreation: new Subject(),
|
|
418
418
|
selectorCreation: new Subject(),
|
|
419
419
|
transactionCreation: new Subject(),
|
|
420
420
|
timelineCreation: new Subject(),
|
|
421
421
|
transactionApplying: new StatefulSubject(null),
|
|
422
|
-
|
|
422
|
+
operationClose: new Subject()
|
|
423
423
|
};
|
|
424
424
|
this.operation = { open: false };
|
|
425
425
|
this.transactionMeta = null;
|
|
@@ -712,7 +712,7 @@ var createReadWriteSelector = (options, family, store) => {
|
|
|
712
712
|
if (family) {
|
|
713
713
|
token.family = family;
|
|
714
714
|
}
|
|
715
|
-
store.
|
|
715
|
+
store.on.selectorCreation.next(token);
|
|
716
716
|
return token;
|
|
717
717
|
};
|
|
718
718
|
|
|
@@ -748,7 +748,7 @@ var createReadonlySelector = (options, family, store) => {
|
|
|
748
748
|
if (family) {
|
|
749
749
|
token.family = family;
|
|
750
750
|
}
|
|
751
|
-
store.
|
|
751
|
+
store.on.selectorCreation.next(token);
|
|
752
752
|
return token;
|
|
753
753
|
};
|
|
754
754
|
|
|
@@ -959,7 +959,7 @@ var Tracker = class {
|
|
|
959
959
|
`tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
|
|
960
960
|
(update) => {
|
|
961
961
|
if (target.operation.open) {
|
|
962
|
-
const unsubscribe = target.
|
|
962
|
+
const unsubscribe = target.on.operationClose.subscribe(
|
|
963
963
|
mutableState.key,
|
|
964
964
|
() => {
|
|
965
965
|
unsubscribe();
|
|
@@ -982,7 +982,7 @@ var Tracker = class {
|
|
|
982
982
|
`tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
|
|
983
983
|
(update2) => {
|
|
984
984
|
if (target2.operation.open) {
|
|
985
|
-
const unsubscribe = target2.
|
|
985
|
+
const unsubscribe = target2.on.operationClose.subscribe(
|
|
986
986
|
mutableState.key,
|
|
987
987
|
() => {
|
|
988
988
|
unsubscribe();
|
|
@@ -1034,7 +1034,7 @@ var Tracker = class {
|
|
|
1034
1034
|
return;
|
|
1035
1035
|
}
|
|
1036
1036
|
}
|
|
1037
|
-
const unsubscribe = store.
|
|
1037
|
+
const unsubscribe = store.on.operationClose.subscribe(
|
|
1038
1038
|
latestUpdateState.key,
|
|
1039
1039
|
() => {
|
|
1040
1040
|
unsubscribe();
|
|
@@ -1392,7 +1392,7 @@ function createRegularAtom(options, family, store) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
};
|
|
1394
1394
|
}
|
|
1395
|
-
store.
|
|
1395
|
+
store.on.atomCreation.next(token);
|
|
1396
1396
|
return token;
|
|
1397
1397
|
}
|
|
1398
1398
|
|
|
@@ -1505,8 +1505,8 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1505
1505
|
const target = newest(store);
|
|
1506
1506
|
const currentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
|
|
1507
1507
|
const currentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
|
|
1508
|
-
const currentTransactionKey = (_a = target.
|
|
1509
|
-
const currentTransactionTime = (_b = target.
|
|
1508
|
+
const currentTransactionKey = (_a = target.on.transactionApplying.state) == null ? void 0 : _a.update.key;
|
|
1509
|
+
const currentTransactionTime = (_b = target.on.transactionApplying.state) == null ? void 0 : _b.time;
|
|
1510
1510
|
store.logger.info(
|
|
1511
1511
|
`\u23F3`,
|
|
1512
1512
|
`timeline`,
|
|
@@ -1786,7 +1786,7 @@ function createTimeline(options, store, data) {
|
|
|
1786
1786
|
key: timelineKey,
|
|
1787
1787
|
type: `timeline`
|
|
1788
1788
|
};
|
|
1789
|
-
store.
|
|
1789
|
+
store.on.timelineCreation.next(token);
|
|
1790
1790
|
return token;
|
|
1791
1791
|
}
|
|
1792
1792
|
var timeTravel = (direction, token, store) => {
|
|
@@ -1940,7 +1940,7 @@ var applyTransaction = (output, store) => {
|
|
|
1940
1940
|
child.transactionMeta.phase = `applying`;
|
|
1941
1941
|
child.transactionMeta.update.output = output;
|
|
1942
1942
|
parent.child = null;
|
|
1943
|
-
parent.
|
|
1943
|
+
parent.on.transactionApplying.next(child.transactionMeta);
|
|
1944
1944
|
const { updates } = child.transactionMeta.update;
|
|
1945
1945
|
store.logger.info(
|
|
1946
1946
|
`\u{1F6C4}`,
|
|
@@ -1985,7 +1985,7 @@ var applyTransaction = (output, store) => {
|
|
|
1985
1985
|
} else {
|
|
1986
1986
|
parent.transactionMeta.update.updates.push(child.transactionMeta.update);
|
|
1987
1987
|
}
|
|
1988
|
-
parent.
|
|
1988
|
+
parent.on.transactionApplying.next(null);
|
|
1989
1989
|
};
|
|
1990
1990
|
|
|
1991
1991
|
// internal/src/transaction/build-transaction.ts
|
|
@@ -1994,7 +1994,7 @@ var buildTransaction = (key, params, store) => {
|
|
|
1994
1994
|
const child = {
|
|
1995
1995
|
parent,
|
|
1996
1996
|
child: null,
|
|
1997
|
-
|
|
1997
|
+
on: parent.on,
|
|
1998
1998
|
loggers: parent.loggers,
|
|
1999
1999
|
logger: parent.logger,
|
|
2000
2000
|
config: parent.config,
|
|
@@ -2065,7 +2065,7 @@ function createTransaction(options, store) {
|
|
|
2065
2065
|
const target = newest(store);
|
|
2066
2066
|
target.transactions.set(newTransaction.key, newTransaction);
|
|
2067
2067
|
const token = deposit(newTransaction);
|
|
2068
|
-
store.
|
|
2068
|
+
store.on.transactionCreation.next(token);
|
|
2069
2069
|
return token;
|
|
2070
2070
|
}
|
|
2071
2071
|
|