atom.io 0.14.1 → 0.14.3
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 +12 -64
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +2 -0
- package/data/dist/index.d.ts +459 -0
- package/data/dist/index.js +1 -1
- package/dist/{chunk-KW7RA7IM.js → chunk-C4YZZNRH.js} +4 -4
- package/dist/{chunk-LFXB7Y6M.js → chunk-CWKKQKVQ.js} +2 -2
- package/dist/{chunk-CK7GNCU5.js → chunk-GMN5KH6A.js} +2 -2
- package/dist/{chunk-5VJ77LZE.js → chunk-N7ADBQJG.js} +2 -2
- package/dist/{chunk-TE3ZSTQ6.js → chunk-PURABO5G.js} +92 -27
- package/dist/chunk-PURABO5G.js.map +1 -0
- package/dist/index.cjs +106 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +493 -0
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -0
- package/internal/dist/index.cjs +93 -29
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +6 -4
- package/internal/dist/index.d.ts +622 -0
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-atom.ts +3 -1
- package/internal/src/families/create-atom-family.ts +3 -4
- package/internal/src/mutable/get-update-family.ts +23 -0
- package/internal/src/mutable/index.ts +1 -4
- package/internal/src/mutable/is-mutable.ts +44 -0
- package/internal/src/mutable/tracker.ts +9 -2
- package/internal/src/subject.ts +2 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
- package/internal/src/timeline/create-timeline.ts +44 -16
- package/introspection/dist/index.cjs +12 -64
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +2 -0
- package/introspection/dist/index.d.ts +396 -0
- package/introspection/dist/index.js +2 -2
- package/json/dist/index.cjs +9 -64
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +2 -0
- package/json/dist/index.d.ts +417 -0
- package/json/dist/index.js +1 -1
- package/package.json +3 -2
- package/react/dist/index.cjs +9 -64
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +2 -0
- package/react/dist/index.d.ts +396 -0
- package/react/dist/index.js +2 -2
- package/react-devtools/dist/index.cjs +12 -64
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +2 -0
- package/react-devtools/dist/index.d.ts +467 -0
- package/react-devtools/dist/index.js +3 -3
- package/realtime-client/dist/index.cjs +9 -64
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +2 -0
- package/realtime-client/dist/index.d.ts +394 -0
- package/realtime-client/dist/index.js +2 -2
- package/realtime-react/dist/index.cjs +9 -64
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +67 -0
- package/realtime-react/dist/index.js +4 -4
- package/realtime-server/dist/index.cjs +9 -64
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +4 -1
- package/realtime-server/dist/index.d.ts +408 -0
- package/realtime-server/dist/index.js +1 -1
- package/realtime-testing/dist/index.cjs +104 -79
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +4 -1
- package/realtime-testing/dist/index.d.ts +535 -0
- package/realtime-testing/dist/index.js +4 -4
- package/src/atom.ts +3 -1
- package/transceivers/set-rtx/dist/index.cjs +2 -1
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.ts +66 -0
- package/transceivers/set-rtx/dist/index.js +1 -1
- package/dist/chunk-TE3ZSTQ6.js.map +0 -1
- package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
- /package/dist/{chunk-KW7RA7IM.js.map → chunk-C4YZZNRH.js.map} +0 -0
- /package/dist/{chunk-LFXB7Y6M.js.map → chunk-CWKKQKVQ.js.map} +0 -0
- /package/dist/{chunk-CK7GNCU5.js.map → chunk-GMN5KH6A.js.map} +0 -0
- /package/dist/{chunk-5VJ77LZE.js.map → chunk-N7ADBQJG.js.map} +0 -0
|
@@ -422,7 +422,8 @@ var Subject = class {
|
|
|
422
422
|
this.subscribers.delete(key);
|
|
423
423
|
}
|
|
424
424
|
next(value) {
|
|
425
|
-
|
|
425
|
+
const subscribers = this.subscribers.values();
|
|
426
|
+
for (const subscriber of subscribers) {
|
|
426
427
|
subscriber(value);
|
|
427
428
|
}
|
|
428
429
|
}
|
|
@@ -1407,7 +1408,8 @@ var Tracker = class {
|
|
|
1407
1408
|
}
|
|
1408
1409
|
initializeState(mutableState, store) {
|
|
1409
1410
|
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1410
|
-
|
|
1411
|
+
store.atoms.delete(latestUpdateStateKey);
|
|
1412
|
+
store.valueMap.delete(latestUpdateStateKey);
|
|
1411
1413
|
const familyMetaData = mutableState.family ? {
|
|
1412
1414
|
key: `*${mutableState.family.key}`,
|
|
1413
1415
|
subKey: mutableState.family.subKey
|
|
@@ -1420,6 +1422,10 @@ var Tracker = class {
|
|
|
1420
1422
|
familyMetaData,
|
|
1421
1423
|
store
|
|
1422
1424
|
);
|
|
1425
|
+
if (store.parent) {
|
|
1426
|
+
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
1427
|
+
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
1428
|
+
}
|
|
1423
1429
|
return latestUpdateState;
|
|
1424
1430
|
}
|
|
1425
1431
|
observeCore(mutableState, latestUpdateState, store) {
|
|
@@ -1500,7 +1506,7 @@ var Tracker = class {
|
|
|
1500
1506
|
() => {
|
|
1501
1507
|
unsubscribe();
|
|
1502
1508
|
const mutable = getState(mutableState, store);
|
|
1503
|
-
const updateNumber = mutable.getUpdateNumber(newValue);
|
|
1509
|
+
const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
|
|
1504
1510
|
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1505
1511
|
if (newValue && eventOffset === 1) {
|
|
1506
1512
|
setState(
|
|
@@ -1575,6 +1581,9 @@ function createAtomFamily(options, store) {
|
|
|
1575
1581
|
subject
|
|
1576
1582
|
}
|
|
1577
1583
|
);
|
|
1584
|
+
if (`mutable` in options && typeof options.mutable === `boolean`) {
|
|
1585
|
+
Object.assign(atomFamily2, { mutable: options.mutable });
|
|
1586
|
+
}
|
|
1578
1587
|
const target = newest(store);
|
|
1579
1588
|
target.families.set(options.key, atomFamily2);
|
|
1580
1589
|
return atomFamily2;
|
|
@@ -1729,19 +1738,19 @@ var getUpdateToken = (mutableAtomToken) => {
|
|
|
1729
1738
|
return updateToken;
|
|
1730
1739
|
};
|
|
1731
1740
|
|
|
1732
|
-
// internal/src/mutable/
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1741
|
+
// internal/src/mutable/get-update-family.ts
|
|
1742
|
+
var getUpdateFamily = (mutableAtomFamily, store) => {
|
|
1743
|
+
const target = newest(store);
|
|
1744
|
+
const key = `*${mutableAtomFamily.key}`;
|
|
1745
|
+
const updateFamily = target.families.get(key);
|
|
1746
|
+
return updateFamily;
|
|
1747
|
+
};
|
|
1736
1748
|
|
|
1737
1749
|
// internal/src/mutable/transceiver.ts
|
|
1738
1750
|
function isTransceiver(value) {
|
|
1739
1751
|
return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
|
|
1740
1752
|
}
|
|
1741
1753
|
|
|
1742
|
-
// internal/src/mutable/index.ts
|
|
1743
|
-
var isAtomMutable = (atom2) => `isMutable` in atom2;
|
|
1744
|
-
|
|
1745
1754
|
// internal/src/atom/is-default.ts
|
|
1746
1755
|
var isAtomDefault = (key, store) => {
|
|
1747
1756
|
const core = newest(store);
|
|
@@ -1910,7 +1919,13 @@ var NotFoundError = class extends Error {
|
|
|
1910
1919
|
|
|
1911
1920
|
// internal/src/timeline/add-atom-to-timeline.ts
|
|
1912
1921
|
var addAtomToTimeline = (atomToken, tl, store) => {
|
|
1913
|
-
|
|
1922
|
+
let maybeAtom = withdraw(atomToken, store);
|
|
1923
|
+
if (maybeAtom == null ? void 0 : maybeAtom.mutable) {
|
|
1924
|
+
console.log(`adding transceiver to timeline`, atomToken.key);
|
|
1925
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1926
|
+
maybeAtom = withdraw(updateToken, store);
|
|
1927
|
+
}
|
|
1928
|
+
const atom2 = maybeAtom;
|
|
1914
1929
|
if (atom2 === void 0) {
|
|
1915
1930
|
throw new Error(
|
|
1916
1931
|
`Cannot subscribe to atom "${atomToken.key}" because it has not been initialized in store "${store.config.name}"`
|
|
@@ -2100,6 +2115,30 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
2100
2115
|
});
|
|
2101
2116
|
};
|
|
2102
2117
|
|
|
2118
|
+
// internal/src/mutable/is-mutable.ts
|
|
2119
|
+
function isMutable(atomOrTokenOrFamily, store) {
|
|
2120
|
+
if (`mutable` in atomOrTokenOrFamily) {
|
|
2121
|
+
return atomOrTokenOrFamily.mutable;
|
|
2122
|
+
}
|
|
2123
|
+
if (atomOrTokenOrFamily.type === `atom_family`) {
|
|
2124
|
+
return false;
|
|
2125
|
+
}
|
|
2126
|
+
if (`default` in atomOrTokenOrFamily) {
|
|
2127
|
+
return false;
|
|
2128
|
+
}
|
|
2129
|
+
if (!store) {
|
|
2130
|
+
throw new Error(`Cannot check mutability without a store`);
|
|
2131
|
+
}
|
|
2132
|
+
const atom2 = withdraw(atomOrTokenOrFamily, store);
|
|
2133
|
+
if (!atom2) {
|
|
2134
|
+
throw new Error(`Cannot check mutability without an atom`);
|
|
2135
|
+
}
|
|
2136
|
+
if (`mutable` in atom2) {
|
|
2137
|
+
return atom2.mutable;
|
|
2138
|
+
}
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2103
2142
|
// internal/src/timeline/create-timeline.ts
|
|
2104
2143
|
function createTimeline(options, store, data) {
|
|
2105
2144
|
var _a, _b;
|
|
@@ -2118,20 +2157,26 @@ function createTimeline(options, store, data) {
|
|
|
2118
2157
|
if (options.shouldCapture) {
|
|
2119
2158
|
tl.shouldCapture = options.shouldCapture;
|
|
2120
2159
|
}
|
|
2160
|
+
const timelineKey = options.key;
|
|
2121
2161
|
const target = newest(store);
|
|
2122
2162
|
for (const tokenOrFamily of options.atoms) {
|
|
2123
|
-
|
|
2124
|
-
|
|
2163
|
+
let atomKey = tokenOrFamily.key;
|
|
2164
|
+
const existingTimelineKey = target.timelineAtoms.getRelatedKey(atomKey);
|
|
2165
|
+
if (existingTimelineKey) {
|
|
2125
2166
|
store.logger.error(
|
|
2126
2167
|
`\u274C`,
|
|
2127
2168
|
`timeline`,
|
|
2128
2169
|
options.key,
|
|
2129
|
-
`Failed to add atom "${
|
|
2170
|
+
`Failed to add atom "${atomKey}" because it already belongs to timeline "${existingTimelineKey}"`
|
|
2130
2171
|
);
|
|
2131
2172
|
continue;
|
|
2132
2173
|
}
|
|
2133
2174
|
if (tokenOrFamily.type === `atom_family`) {
|
|
2134
|
-
|
|
2175
|
+
let family = tokenOrFamily;
|
|
2176
|
+
if (isMutable(family)) {
|
|
2177
|
+
family = getUpdateFamily(family, store);
|
|
2178
|
+
atomKey = family.key;
|
|
2179
|
+
}
|
|
2135
2180
|
family.subject.subscribe(`timeline:${options.key}`, (token2) => {
|
|
2136
2181
|
addAtomToTimeline(token2, tl, store);
|
|
2137
2182
|
});
|
|
@@ -2141,31 +2186,51 @@ function createTimeline(options, store, data) {
|
|
|
2141
2186
|
}
|
|
2142
2187
|
}
|
|
2143
2188
|
} else {
|
|
2144
|
-
|
|
2145
|
-
if (
|
|
2189
|
+
let atom2 = withdraw(tokenOrFamily, store);
|
|
2190
|
+
if (atom2 === void 0) {
|
|
2191
|
+
store.logger.error(
|
|
2192
|
+
`\u274C`,
|
|
2193
|
+
`timeline`,
|
|
2194
|
+
options.key,
|
|
2195
|
+
`Failed to add atom "${atomKey}" because it does not exist in the store`
|
|
2196
|
+
);
|
|
2197
|
+
continue;
|
|
2198
|
+
}
|
|
2199
|
+
if (isMutable(atom2)) {
|
|
2200
|
+
const updateAtom = withdraw(getUpdateToken(atom2), store);
|
|
2201
|
+
if (updateAtom === void 0) {
|
|
2202
|
+
store.logger.error(
|
|
2203
|
+
`\u274C`,
|
|
2204
|
+
`timeline`,
|
|
2205
|
+
options.key,
|
|
2206
|
+
`Failed to add update atom "${atomKey}" because it does not exist in the store`
|
|
2207
|
+
);
|
|
2208
|
+
continue;
|
|
2209
|
+
}
|
|
2210
|
+
atom2 = updateAtom;
|
|
2211
|
+
atomKey = atom2.key;
|
|
2212
|
+
}
|
|
2213
|
+
if (`family` in atom2) {
|
|
2146
2214
|
const familyTimelineKey = target.timelineAtoms.getRelatedKey(
|
|
2147
|
-
|
|
2215
|
+
atom2.family.key
|
|
2148
2216
|
);
|
|
2149
2217
|
if (familyTimelineKey) {
|
|
2150
2218
|
store.logger.error(
|
|
2151
2219
|
`\u274C`,
|
|
2152
2220
|
`timeline`,
|
|
2153
2221
|
options.key,
|
|
2154
|
-
`Failed to add atom "${
|
|
2222
|
+
`Failed to add atom "${atom2.key}" because its family "${atom2.family.key}" already belongs to timeline "${familyTimelineKey}"`
|
|
2155
2223
|
);
|
|
2156
2224
|
continue;
|
|
2157
2225
|
}
|
|
2158
2226
|
}
|
|
2159
|
-
addAtomToTimeline(
|
|
2227
|
+
addAtomToTimeline(atom2, tl, store);
|
|
2160
2228
|
}
|
|
2161
|
-
target.timelineAtoms
|
|
2162
|
-
atomKey: tokenOrFamily.key,
|
|
2163
|
-
timelineKey: options.key
|
|
2164
|
-
});
|
|
2229
|
+
target.timelineAtoms.set({ atomKey, timelineKey });
|
|
2165
2230
|
}
|
|
2166
2231
|
store.timelines.set(options.key, tl);
|
|
2167
2232
|
const token = {
|
|
2168
|
-
key:
|
|
2233
|
+
key: timelineKey,
|
|
2169
2234
|
type: `timeline`
|
|
2170
2235
|
};
|
|
2171
2236
|
store.subject.timelineCreation.next(token);
|
|
@@ -2511,6 +2576,6 @@ var selectJsonFamily = (atomFamily2, transform, store = IMPLICIT.STORE) => {
|
|
|
2511
2576
|
return jsonFamily;
|
|
2512
2577
|
};
|
|
2513
2578
|
|
|
2514
|
-
export { AtomIOLogger, FamilyTracker, Future, IMPLICIT, JSON_DEFAULTS, JSON_TYPE_NAMES, Junction, LOG_LEVELS, LazyMap, NotFoundError, Silo, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, __objRest, __restKey, __spreadProps, __spreadValues, abortTransaction, addAtomToTimeline, applyTransaction, atom, atomFamily, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, dispose, eldest, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getState, getUpdateToken, isAtomDefault, isAtomKey,
|
|
2579
|
+
export { AtomIOLogger, FamilyTracker, Future, IMPLICIT, JSON_DEFAULTS, JSON_TYPE_NAMES, Junction, LOG_LEVELS, LazyMap, NotFoundError, Silo, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, __objRest, __restKey, __spreadProps, __spreadValues, abortTransaction, addAtomToTimeline, applyTransaction, atom, atomFamily, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, dispose, eldest, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getState, getUpdateFamily, getUpdateToken, isAtomDefault, isAtomKey, isBoolean, isDone, isNull, isNumber, isPrimitive, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isString, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, parseJson, readCachedValue, readOrComputeValue, redo, redoTransactionUpdate, registerSelector, runTransaction, selectJson, selectJsonFamily, selector, selectorFamily, setAtomOrSelector, setState, simpleLog, simpleLogger, stringSetJsonInterface, stringifyJson, subscribe, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, timeline, traceAllSelectorAtoms, traceSelectorAtoms, transaction, undo, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
2515
2580
|
//# sourceMappingURL=out.js.map
|
|
2516
|
-
//# sourceMappingURL=chunk-
|
|
2581
|
+
//# sourceMappingURL=chunk-PURABO5G.js.map
|