atom.io 0.28.1 → 0.29.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-6WL4RQMQ.js → chunk-XPYU2HY2.js} +22 -57
- package/eslint-plugin/dist/index.js +0 -1
- package/eslint-plugin/src/walk.ts +0 -1
- package/internal/dist/index.d.ts +4 -4
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/dispose-atom.ts +0 -11
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +16 -25
- package/internal/src/operation.ts +7 -7
- package/internal/src/selector/create-writable-selector.ts +1 -1
- package/internal/src/selector/dispose-selector.ts +0 -13
- package/internal/src/set-state/become.ts +1 -3
- package/internal/src/set-state/evict-downstream.ts +2 -2
- package/internal/src/set-state/set-atom.ts +1 -1
- package/internal/src/set-state/set-into-store.ts +1 -1
- package/internal/src/set-state/stow-update.ts +2 -2
- package/internal/src/store/store.ts +1 -1
- package/introspection/dist/index.d.ts +15 -6
- package/introspection/dist/index.js +620 -1
- package/introspection/src/attach-atom-index.ts +5 -6
- package/introspection/src/attach-introspection-states.ts +5 -6
- package/introspection/src/attach-selector-index.ts +6 -7
- package/introspection/src/attach-timeline-family.ts +3 -4
- package/introspection/src/attach-timeline-index.ts +4 -8
- package/introspection/src/attach-transaction-index.ts +4 -8
- package/introspection/src/attach-transaction-logs.ts +4 -8
- package/introspection/src/attach-type-selectors.ts +13 -6
- package/introspection/src/differ.ts +1 -1
- package/introspection/src/index.ts +1 -0
- package/introspection/src/refinery.ts +9 -7
- package/introspection/src/sprawl.ts +42 -0
- package/json/dist/index.d.ts +12 -1
- package/json/dist/index.js +111 -2
- package/json/src/index.ts +29 -0
- package/package.json +12 -12
- package/react-devtools/dist/index.d.ts +159 -2
- package/react-devtools/dist/index.js +260 -663
- package/react-devtools/src/AtomIODevtools.tsx +24 -13
- package/react-devtools/src/StateEditor.tsx +5 -47
- package/react-devtools/src/StateIndex.tsx +15 -9
- package/react-devtools/src/TimelineIndex.tsx +9 -6
- package/react-devtools/src/TransactionIndex.tsx +9 -11
- package/react-devtools/src/elastic-input/ElasticInput.tsx +86 -0
- package/react-devtools/src/elastic-input/NumberInput.tsx +199 -0
- package/react-devtools/src/elastic-input/TextInput.tsx +47 -0
- package/react-devtools/src/elastic-input/index.ts +3 -0
- package/react-devtools/src/error-boundary/DefaultFallback.tsx +49 -0
- package/react-devtools/src/error-boundary/ReactErrorBoundary.tsx +56 -0
- package/react-devtools/src/error-boundary/index.ts +2 -0
- package/react-devtools/src/index.ts +3 -0
- package/react-devtools/src/json-editor/assets/Untitled-1.ai +1436 -2
- package/react-devtools/src/json-editor/assets/data-vis.ai +1548 -1
- package/react-devtools/src/json-editor/comp/json-editor-sketches.ai +1451 -3
- package/react-devtools/src/json-editor/default-components.tsx +101 -0
- package/react-devtools/src/json-editor/developer-interface.tsx +81 -0
- package/react-devtools/src/json-editor/editors-by-type/array-editor.tsx +38 -0
- package/react-devtools/src/json-editor/editors-by-type/non-json.tsx +23 -0
- package/react-devtools/src/json-editor/editors-by-type/object-editor.tsx +128 -0
- package/react-devtools/src/json-editor/editors-by-type/primitive-editors.tsx +73 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/array-elements.ts +16 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/cast-json.ts +57 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts +156 -0
- package/react-devtools/src/json-editor/editors-by-type/utilities/object-properties.ts +106 -0
- package/react-devtools/src/json-editor/index.ts +32 -0
- package/react-devtools/src/json-editor/json-editor-internal.tsx +128 -0
- package/react-devtools/src/json-editor/todo.md +7 -0
- package/react-devtools/src/store.ts +70 -46
- package/dist/chunk-D52JNVER.js +0 -721
- package/dist/chunk-YQ46F5O2.js +0 -95
|
@@ -209,9 +209,7 @@ function actUponStore(token, id, store) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
// internal/src/set-state/become.ts
|
|
212
|
-
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
213
|
-
originalThing instanceof Function ? originalThing() : originalThing
|
|
214
|
-
) : nextVersionOfThing;
|
|
212
|
+
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(originalThing) : nextVersionOfThing;
|
|
215
213
|
|
|
216
214
|
// internal/src/get-state/read-or-compute-value.ts
|
|
217
215
|
var readOrComputeValue = (state, target) => {
|
|
@@ -235,7 +233,7 @@ var readOrComputeValue = (state, target) => {
|
|
|
235
233
|
};
|
|
236
234
|
|
|
237
235
|
// internal/src/operation.ts
|
|
238
|
-
var openOperation = (
|
|
236
|
+
var openOperation = (store, token) => {
|
|
239
237
|
if (store.operation.open) {
|
|
240
238
|
const rejectionTime = performance.now();
|
|
241
239
|
store.logger.info(
|
|
@@ -272,25 +270,25 @@ var closeOperation = (store) => {
|
|
|
272
270
|
store.operation = { open: false };
|
|
273
271
|
store.on.operationClose.next(store.operation);
|
|
274
272
|
};
|
|
275
|
-
var isDone = (
|
|
273
|
+
var isDone = (store, key) => {
|
|
276
274
|
if (!store.operation.open) {
|
|
277
|
-
store.logger.
|
|
275
|
+
store.logger.error(
|
|
278
276
|
`\u{1F41E}`,
|
|
279
277
|
`unknown`,
|
|
280
278
|
key,
|
|
281
|
-
`isDone called outside of an operation. This is probably a bug.`
|
|
279
|
+
`isDone called outside of an operation. This is probably a bug in AtomIO.`
|
|
282
280
|
);
|
|
283
281
|
return true;
|
|
284
282
|
}
|
|
285
283
|
return store.operation.done.has(key);
|
|
286
284
|
};
|
|
287
|
-
var markDone = (
|
|
285
|
+
var markDone = (store, key) => {
|
|
288
286
|
if (!store.operation.open) {
|
|
289
|
-
store.logger.
|
|
287
|
+
store.logger.error(
|
|
290
288
|
`\u{1F41E}`,
|
|
291
289
|
`unknown`,
|
|
292
290
|
key,
|
|
293
|
-
`markDone called outside of an operation. This is probably a bug.`
|
|
291
|
+
`markDone called outside of an operation. This is probably a bug in AtomIO.`
|
|
294
292
|
);
|
|
295
293
|
return;
|
|
296
294
|
}
|
|
@@ -348,11 +346,11 @@ var evictDownStream = (atom, store) => {
|
|
|
348
346
|
);
|
|
349
347
|
}
|
|
350
348
|
for (const key of downstreamKeys) {
|
|
351
|
-
if (isDone(
|
|
349
|
+
if (isDone(target, key)) {
|
|
352
350
|
continue;
|
|
353
351
|
}
|
|
354
352
|
evictCachedValue(key, target);
|
|
355
|
-
markDone(
|
|
353
|
+
markDone(target, key);
|
|
356
354
|
}
|
|
357
355
|
}
|
|
358
356
|
};
|
|
@@ -362,7 +360,7 @@ function shouldUpdateBeStowed(key, update) {
|
|
|
362
360
|
if (isTransceiver(update.newValue)) {
|
|
363
361
|
return false;
|
|
364
362
|
}
|
|
365
|
-
if (key.includes(`\u{
|
|
363
|
+
if (key.includes(`\u{1F50D}`)) {
|
|
366
364
|
return false;
|
|
367
365
|
}
|
|
368
366
|
return true;
|
|
@@ -419,7 +417,7 @@ var setAtom = (atom, next, target) => {
|
|
|
419
417
|
if (isAtomDefault(atom.key, target)) {
|
|
420
418
|
markAtomAsNotDefault(atom.key, target);
|
|
421
419
|
}
|
|
422
|
-
markDone(atom.key
|
|
420
|
+
markDone(target, atom.key);
|
|
423
421
|
evictDownStream(atom, target);
|
|
424
422
|
const update = { oldValue, newValue };
|
|
425
423
|
if (isRootStore(target)) {
|
|
@@ -791,7 +789,7 @@ var createWritableSelector = (store, options, family) => {
|
|
|
791
789
|
`)`
|
|
792
790
|
);
|
|
793
791
|
cacheValue(options.key, newValue, subject, innerTarget);
|
|
794
|
-
markDone(options.key
|
|
792
|
+
markDone(innerTarget, options.key);
|
|
795
793
|
if (isRootStore(innerTarget)) {
|
|
796
794
|
subject.next({ newValue, oldValue });
|
|
797
795
|
}
|
|
@@ -879,14 +877,6 @@ function disposeSelector(selectorToken, store) {
|
|
|
879
877
|
}
|
|
880
878
|
target.valueMap.delete(key);
|
|
881
879
|
target.selectorAtoms.delete(key);
|
|
882
|
-
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
883
|
-
([downstreamSelectorKey]) => target.selectors.get(downstreamSelectorKey) ?? target.readonlySelectors.get(downstreamSelectorKey)
|
|
884
|
-
);
|
|
885
|
-
for (const downstreamToken of downstreamTokens) {
|
|
886
|
-
if (downstreamToken) {
|
|
887
|
-
disposeSelector(downstreamToken, store);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
880
|
target.selectorGraph.delete(key);
|
|
891
881
|
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
892
882
|
if (isChildStore(target) && target.transactionMeta.phase === `building`) {
|
|
@@ -1414,7 +1404,7 @@ ${disposal.trace}` : `No previous disposal trace was found.`
|
|
|
1414
1404
|
);
|
|
1415
1405
|
return;
|
|
1416
1406
|
}
|
|
1417
|
-
const rejectionTime = openOperation(
|
|
1407
|
+
const rejectionTime = openOperation(store, token);
|
|
1418
1408
|
if (rejectionTime) {
|
|
1419
1409
|
const unsubscribe = store.on.operationClose.subscribe(
|
|
1420
1410
|
`waiting to set "${token.key}" at T-${rejectionTime}`,
|
|
@@ -1449,7 +1439,7 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
|
1449
1439
|
function ingestCreationEvent(update, applying, store) {
|
|
1450
1440
|
switch (applying) {
|
|
1451
1441
|
case `newValue`: {
|
|
1452
|
-
createInStore(update
|
|
1442
|
+
createInStore(update, store);
|
|
1453
1443
|
break;
|
|
1454
1444
|
}
|
|
1455
1445
|
case `oldValue`: {
|
|
@@ -1465,34 +1455,18 @@ function ingestDisposalEvent(update, applying, store) {
|
|
|
1465
1455
|
break;
|
|
1466
1456
|
}
|
|
1467
1457
|
case `oldValue`: {
|
|
1468
|
-
createInStore(update
|
|
1458
|
+
createInStore(update, store);
|
|
1469
1459
|
store.valueMap.set(update.token.key, update.value);
|
|
1470
1460
|
break;
|
|
1471
1461
|
}
|
|
1472
1462
|
}
|
|
1473
1463
|
}
|
|
1474
|
-
function createInStore(
|
|
1475
|
-
|
|
1476
|
-
|
|
1464
|
+
function createInStore(update, store) {
|
|
1465
|
+
const { family: familyMeta } = update.token;
|
|
1466
|
+
if (familyMeta) {
|
|
1467
|
+
const family = store.families.get(familyMeta.key);
|
|
1477
1468
|
if (family) {
|
|
1478
|
-
|
|
1479
|
-
if (molecule) {
|
|
1480
|
-
growMoleculeInStore(molecule, family, store);
|
|
1481
|
-
return;
|
|
1482
|
-
}
|
|
1483
|
-
if (store.config.lifespan === `immortal`) {
|
|
1484
|
-
store.logger.error(
|
|
1485
|
-
`\u{1F41E}`,
|
|
1486
|
-
`atom`,
|
|
1487
|
-
token.family.key,
|
|
1488
|
-
`tried to create member`,
|
|
1489
|
-
`"${token.family.subKey}"`,
|
|
1490
|
-
`but a molecule with that key was not found in store`,
|
|
1491
|
-
`"${store.config.name}"`
|
|
1492
|
-
);
|
|
1493
|
-
return;
|
|
1494
|
-
}
|
|
1495
|
-
initFamilyMemberInStore(store, family, parseJson(token.family.subKey));
|
|
1469
|
+
findInStore(store, family, parseJson(familyMeta.subKey));
|
|
1496
1470
|
}
|
|
1497
1471
|
}
|
|
1498
1472
|
}
|
|
@@ -1908,7 +1882,7 @@ var Store = class {
|
|
|
1908
1882
|
lifespan: `ephemeral`
|
|
1909
1883
|
};
|
|
1910
1884
|
loggers = [
|
|
1911
|
-
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{
|
|
1885
|
+
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F50D}`))
|
|
1912
1886
|
];
|
|
1913
1887
|
logger = {
|
|
1914
1888
|
error: (...messages) => {
|
|
@@ -2715,15 +2689,6 @@ function disposeAtom(atomToken, store) {
|
|
|
2715
2689
|
}
|
|
2716
2690
|
target.atoms.delete(key);
|
|
2717
2691
|
target.valueMap.delete(key);
|
|
2718
|
-
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
2719
|
-
if (selectorKeys) {
|
|
2720
|
-
for (const selectorKey of selectorKeys) {
|
|
2721
|
-
const token = target.selectors.get(selectorKey) ?? target.readonlySelectors.get(selectorKey);
|
|
2722
|
-
if (token) {
|
|
2723
|
-
disposeSelector(token, store);
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
2692
|
target.selectorAtoms.delete(key);
|
|
2728
2693
|
target.atomsThatAreDefault.delete(key);
|
|
2729
2694
|
target.timelineTopics.delete(key);
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -207,10 +207,10 @@ type OperationProgress = {
|
|
|
207
207
|
time: number;
|
|
208
208
|
token: WritableToken<any>;
|
|
209
209
|
};
|
|
210
|
-
declare const openOperation: (token: WritableToken<any
|
|
210
|
+
declare const openOperation: (store: Store, token: WritableToken<any>) => number | undefined;
|
|
211
211
|
declare const closeOperation: (store: Store) => void;
|
|
212
|
-
declare const isDone: (
|
|
213
|
-
declare const markDone: (
|
|
212
|
+
declare const isDone: (store: Store, key: string) => boolean;
|
|
213
|
+
declare const markDone: (store: Store, key: string) => void;
|
|
214
214
|
|
|
215
215
|
type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = Flat<StateUpdate<TokenType<ManagedAtom>> & {
|
|
216
216
|
key: string;
|
|
@@ -496,7 +496,7 @@ declare const readOrComputeValue: <T>(state: ReadableState<T>, target: Store) =>
|
|
|
496
496
|
declare function ingestAtomUpdate(applying: `newValue` | `oldValue`, atomUpdate: KeyedStateUpdate<any>, store: Store): void;
|
|
497
497
|
|
|
498
498
|
declare function ingestCreationEvent(update: StateCreation<any>, applying: `newValue` | `oldValue`, store: Store): void;
|
|
499
|
-
declare function ingestDisposalEvent(update: StateDisposal<any
|
|
499
|
+
declare function ingestDisposalEvent(update: StateDisposal<ReadableToken<any>>, applying: `newValue` | `oldValue`, store: Store): void;
|
|
500
500
|
declare function ingestMoleculeCreationEvent(update: MoleculeCreation<any>, applying: `newValue` | `oldValue`, store: Store): void;
|
|
501
501
|
declare function ingestMoleculeDisposalEvent(update: MoleculeDisposal, applying: `newValue` | `oldValue`, store: Store): void;
|
|
502
502
|
|
package/internal/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-
|
|
1
|
+
export { FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, counterfeit, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateFamily, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-XPYU2HY2.js';
|
|
2
2
|
import '../../dist/chunk-IBTHB2PI.js';
|
|
3
3
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
@@ -30,17 +30,6 @@ export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
|
|
|
30
30
|
}
|
|
31
31
|
target.atoms.delete(key)
|
|
32
32
|
target.valueMap.delete(key)
|
|
33
|
-
const selectorKeys = target.selectorAtoms.getRelatedKeys(key)
|
|
34
|
-
if (selectorKeys) {
|
|
35
|
-
for (const selectorKey of selectorKeys) {
|
|
36
|
-
const token =
|
|
37
|
-
target.selectors.get(selectorKey) ??
|
|
38
|
-
target.readonlySelectors.get(selectorKey)
|
|
39
|
-
if (token) {
|
|
40
|
-
disposeSelector(token, store)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
33
|
target.selectorAtoms.delete(key)
|
|
45
34
|
target.atomsThatAreDefault.delete(key)
|
|
46
35
|
target.timelineTopics.delete(key)
|
|
@@ -7,7 +7,11 @@ import type {
|
|
|
7
7
|
} from "atom.io"
|
|
8
8
|
import { parseJson, stringifyJson } from "atom.io/json"
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
disposeFromStore,
|
|
12
|
+
findInStore,
|
|
13
|
+
initFamilyMemberInStore,
|
|
14
|
+
} from "../families"
|
|
11
15
|
import { growMoleculeInStore, makeMoleculeInStore } from "../molecule"
|
|
12
16
|
import { type Store, withdraw } from "../store"
|
|
13
17
|
|
|
@@ -18,7 +22,7 @@ export function ingestCreationEvent(
|
|
|
18
22
|
): void {
|
|
19
23
|
switch (applying) {
|
|
20
24
|
case `newValue`: {
|
|
21
|
-
createInStore(update
|
|
25
|
+
createInStore(update, store)
|
|
22
26
|
break
|
|
23
27
|
}
|
|
24
28
|
case `oldValue`: {
|
|
@@ -29,7 +33,7 @@ export function ingestCreationEvent(
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
export function ingestDisposalEvent(
|
|
32
|
-
update: StateDisposal<any
|
|
36
|
+
update: StateDisposal<ReadableToken<any>>,
|
|
33
37
|
applying: `newValue` | `oldValue`,
|
|
34
38
|
store: Store,
|
|
35
39
|
): void {
|
|
@@ -39,35 +43,22 @@ export function ingestDisposalEvent(
|
|
|
39
43
|
break
|
|
40
44
|
}
|
|
41
45
|
case `oldValue`: {
|
|
42
|
-
createInStore(update
|
|
46
|
+
createInStore(update, store)
|
|
43
47
|
store.valueMap.set(update.token.key, update.value)
|
|
44
48
|
break
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
function createInStore(
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
function createInStore(
|
|
54
|
+
update: StateCreation<any> | StateDisposal<any>,
|
|
55
|
+
store: Store,
|
|
56
|
+
): void {
|
|
57
|
+
const { family: familyMeta } = update.token
|
|
58
|
+
if (familyMeta) {
|
|
59
|
+
const family = store.families.get(familyMeta.key)
|
|
52
60
|
if (family) {
|
|
53
|
-
|
|
54
|
-
if (molecule) {
|
|
55
|
-
growMoleculeInStore(molecule, family, store)
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
if (store.config.lifespan === `immortal`) {
|
|
59
|
-
store.logger.error(
|
|
60
|
-
`🐞`,
|
|
61
|
-
`atom`,
|
|
62
|
-
token.family.key,
|
|
63
|
-
`tried to create member`,
|
|
64
|
-
`"${token.family.subKey}"`,
|
|
65
|
-
`but a molecule with that key was not found in store`,
|
|
66
|
-
`"${store.config.name}"`,
|
|
67
|
-
)
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
initFamilyMemberInStore(store, family, parseJson(token.family.subKey))
|
|
61
|
+
findInStore(store, family, parseJson(familyMeta.subKey))
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
64
|
}
|
|
@@ -16,8 +16,8 @@ export type OperationProgress =
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const openOperation = (
|
|
19
|
-
token: WritableToken<any>,
|
|
20
19
|
store: Store,
|
|
20
|
+
token: WritableToken<any>,
|
|
21
21
|
): number | undefined => {
|
|
22
22
|
if (store.operation.open) {
|
|
23
23
|
const rejectionTime = performance.now()
|
|
@@ -60,25 +60,25 @@ export const closeOperation = (store: Store): void => {
|
|
|
60
60
|
store.on.operationClose.next(store.operation)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export const isDone = (
|
|
63
|
+
export const isDone = (store: Store, key: string): boolean => {
|
|
64
64
|
if (!store.operation.open) {
|
|
65
|
-
store.logger.
|
|
65
|
+
store.logger.error(
|
|
66
66
|
`🐞`,
|
|
67
67
|
`unknown`,
|
|
68
68
|
key,
|
|
69
|
-
`isDone called outside of an operation. This is probably a bug.`,
|
|
69
|
+
`isDone called outside of an operation. This is probably a bug in AtomIO.`,
|
|
70
70
|
)
|
|
71
71
|
return true
|
|
72
72
|
}
|
|
73
73
|
return store.operation.done.has(key)
|
|
74
74
|
}
|
|
75
|
-
export const markDone = (
|
|
75
|
+
export const markDone = (store: Store, key: string): void => {
|
|
76
76
|
if (!store.operation.open) {
|
|
77
|
-
store.logger.
|
|
77
|
+
store.logger.error(
|
|
78
78
|
`🐞`,
|
|
79
79
|
`unknown`,
|
|
80
80
|
key,
|
|
81
|
-
`markDone called outside of an operation. This is probably a bug.`,
|
|
81
|
+
`markDone called outside of an operation. This is probably a bug in AtomIO.`,
|
|
82
82
|
)
|
|
83
83
|
return
|
|
84
84
|
}
|
|
@@ -48,7 +48,7 @@ export const createWritableSelector = <T>(
|
|
|
48
48
|
`)`,
|
|
49
49
|
)
|
|
50
50
|
cacheValue(options.key, newValue, subject, innerTarget)
|
|
51
|
-
markDone(options.key
|
|
51
|
+
markDone(innerTarget, options.key)
|
|
52
52
|
if (isRootStore(innerTarget)) {
|
|
53
53
|
subject.next({ newValue, oldValue })
|
|
54
54
|
}
|
|
@@ -52,19 +52,6 @@ export function disposeSelector(
|
|
|
52
52
|
}
|
|
53
53
|
target.valueMap.delete(key)
|
|
54
54
|
target.selectorAtoms.delete(key)
|
|
55
|
-
const downstreamTokens = target.selectorGraph
|
|
56
|
-
.getRelationEntries({ upstreamSelectorKey: key })
|
|
57
|
-
.filter(([_, { source }]) => source === key)
|
|
58
|
-
.map(
|
|
59
|
-
([downstreamSelectorKey]) =>
|
|
60
|
-
target.selectors.get(downstreamSelectorKey) ??
|
|
61
|
-
target.readonlySelectors.get(downstreamSelectorKey),
|
|
62
|
-
)
|
|
63
|
-
for (const downstreamToken of downstreamTokens) {
|
|
64
|
-
if (downstreamToken) {
|
|
65
|
-
disposeSelector(downstreamToken, store)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
55
|
target.selectorGraph.delete(key)
|
|
69
56
|
store.logger.info(`🔥`, selectorToken.type, key, `deleted`)
|
|
70
57
|
if (isChildStore(target) && target.transactionMeta.phase === `building`) {
|
|
@@ -4,7 +4,5 @@ export const become =
|
|
|
4
4
|
<T>(nextVersionOfThing: Modify<T> | T) =>
|
|
5
5
|
(originalThing: T): T =>
|
|
6
6
|
nextVersionOfThing instanceof Function
|
|
7
|
-
? nextVersionOfThing(
|
|
8
|
-
originalThing instanceof Function ? originalThing() : originalThing,
|
|
9
|
-
)
|
|
7
|
+
? nextVersionOfThing(originalThing)
|
|
10
8
|
: nextVersionOfThing
|
|
@@ -26,11 +26,11 @@ export const evictDownStream = <T>(atom: Atom<T>, store: Store): void => {
|
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
for (const key of downstreamKeys) {
|
|
29
|
-
if (isDone(
|
|
29
|
+
if (isDone(target, key)) {
|
|
30
30
|
continue
|
|
31
31
|
}
|
|
32
32
|
evictCachedValue(key, target)
|
|
33
|
-
markDone(
|
|
33
|
+
markDone(target, key)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -30,7 +30,7 @@ export const setAtom = <T>(
|
|
|
30
30
|
if (isAtomDefault(atom.key, target)) {
|
|
31
31
|
markAtomAsNotDefault(atom.key, target)
|
|
32
32
|
}
|
|
33
|
-
markDone(atom.key
|
|
33
|
+
markDone(target, atom.key)
|
|
34
34
|
evictDownStream(atom, target)
|
|
35
35
|
const update = { oldValue, newValue }
|
|
36
36
|
if (isRootStore(target)) {
|
|
@@ -58,7 +58,7 @@ export function setIntoStore<T, New extends T>(
|
|
|
58
58
|
return
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const rejectionTime = openOperation(
|
|
61
|
+
const rejectionTime = openOperation(store, token)
|
|
62
62
|
if (rejectionTime) {
|
|
63
63
|
const unsubscribe = store.on.operationClose.subscribe(
|
|
64
64
|
`waiting to set "${token.key}" at T-${rejectionTime}`,
|
|
@@ -11,8 +11,8 @@ function shouldUpdateBeStowed(key: string, update: StateUpdate<any>): boolean {
|
|
|
11
11
|
if (isTransceiver(update.newValue)) {
|
|
12
12
|
return false
|
|
13
13
|
}
|
|
14
|
-
// do not stow updates where the key contains
|
|
15
|
-
if (key.includes(
|
|
14
|
+
// do not stow updates where the key contains 🔍
|
|
15
|
+
if (key.includes(`🔍`)) {
|
|
16
16
|
return false
|
|
17
17
|
}
|
|
18
18
|
return true
|
|
@@ -132,7 +132,7 @@ export class Store implements Lineage {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
public loggers: AtomIOLogger[] = [
|
|
135
|
-
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(
|
|
135
|
+
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`🔍`)),
|
|
136
136
|
]
|
|
137
137
|
public logger: Logger = {
|
|
138
138
|
error: (...messages) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AtomToken, SelectorToken, ReadonlySelectorToken, TransactionToken, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken, ReadableToken } from 'atom.io';
|
|
2
2
|
import * as Internal from 'atom.io/internal';
|
|
3
|
-
import { Func, Timeline, Flat } from 'atom.io/internal';
|
|
3
|
+
import { Func, Timeline, Store, Flat } from 'atom.io/internal';
|
|
4
4
|
import { Json } from 'atom.io/json';
|
|
5
5
|
|
|
6
6
|
type AtomTokenIndex = WritableTokenIndex<AtomToken<unknown>>;
|
|
7
7
|
|
|
8
8
|
type SelectorTokenIndex = WritableTokenIndex<SelectorToken<unknown>>;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type IntrospectionStates = {
|
|
11
11
|
atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
|
|
12
12
|
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
13
13
|
transactionIndex: ReadonlySelectorToken<TransactionToken<Func>[]>;
|
|
@@ -16,6 +16,7 @@ declare const attachIntrospectionStates: (store?: Internal.Store) => {
|
|
|
16
16
|
timelineSelectors: ReadonlySelectorFamilyToken<Timeline<any>, string>;
|
|
17
17
|
typeSelectors: ReadonlySelectorFamilyToken<string, string>;
|
|
18
18
|
};
|
|
19
|
+
declare const attachIntrospectionStates: (store: Store) => IntrospectionStates;
|
|
19
20
|
|
|
20
21
|
type ListResourcesParam = {
|
|
21
22
|
atomFamilies: boolean;
|
|
@@ -78,12 +79,13 @@ declare const primitiveRefinery: Refinery<{
|
|
|
78
79
|
boolean: (input: unknown) => input is boolean;
|
|
79
80
|
null: (input: unknown) => input is null;
|
|
80
81
|
}>;
|
|
82
|
+
declare function isPlainObject(input: unknown): input is Json.Tree.Object;
|
|
81
83
|
declare const jsonTreeRefinery: Refinery<{
|
|
82
|
-
object:
|
|
84
|
+
object: typeof isPlainObject;
|
|
83
85
|
array: (input: unknown) => input is Json.Tree.Array;
|
|
84
86
|
}>;
|
|
85
87
|
declare const jsonRefinery: Refinery<{
|
|
86
|
-
object:
|
|
88
|
+
object: typeof isPlainObject;
|
|
87
89
|
array: (input: unknown) => input is Json.Tree.Array;
|
|
88
90
|
number: (input: unknown) => input is number;
|
|
89
91
|
string: (input: unknown) => input is string;
|
|
@@ -128,14 +130,21 @@ declare const prettyJson: Differ<{
|
|
|
128
130
|
boolean: (input: unknown) => input is boolean;
|
|
129
131
|
null: (input: unknown) => input is null;
|
|
130
132
|
}, {
|
|
131
|
-
object:
|
|
133
|
+
object: typeof isPlainObject;
|
|
132
134
|
array: (input: unknown) => input is Json.Tree.Array;
|
|
133
135
|
}>;
|
|
134
136
|
|
|
137
|
+
type InspectionResult = Partial<{
|
|
138
|
+
pathComplete: true;
|
|
139
|
+
jobComplete: true;
|
|
140
|
+
}>;
|
|
141
|
+
type InspectNode = (path: string[], node: unknown) => InspectionResult | void;
|
|
142
|
+
declare const sprawl: (tree: Array<unknown> | object, inspector: InspectNode) => void;
|
|
143
|
+
|
|
135
144
|
type FamilyNode<Token extends ReadableToken<unknown>> = {
|
|
136
145
|
key: string;
|
|
137
146
|
familyMembers: Map<string, Token>;
|
|
138
147
|
};
|
|
139
148
|
type WritableTokenIndex<Token extends ReadableToken<unknown>> = Map<string, FamilyNode<Token> | Token>;
|
|
140
149
|
|
|
141
|
-
export { Auditor, type ClassSignature, Differ, type FamilyNode, type JsonType, type ListResourcesParam, type Refinement, type RefinementStrategy, type RefinementSupport, Refinery, type Supported, type WritableTokenIndex, attachIntrospectionStates, diffArray, diffBoolean, diffNumber, diffObject, diffString, discoverType, jsonRefinery, jsonTreeRefinery, prettyJson, primitiveRefinery };
|
|
150
|
+
export { Auditor, type ClassSignature, Differ, type FamilyNode, type InspectNode, type InspectionResult, type IntrospectionStates, type JsonType, type ListResourcesParam, type Refinement, type RefinementStrategy, type RefinementSupport, Refinery, type Supported, type WritableTokenIndex, attachIntrospectionStates, diffArray, diffBoolean, diffNumber, diffObject, diffString, discoverType, isPlainObject, jsonRefinery, jsonTreeRefinery, prettyJson, primitiveRefinery, sprawl };
|