atom.io 0.46.9 → 0.46.11
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-CKcAJnC7.js → chunk-Dms8e946.js} +2 -2
- package/dist/eslint-plugin/index.js +2 -2
- package/dist/internal/index.js +60 -60
- package/dist/internal/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +4 -4
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js +17 -15
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts +2 -2
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js +6 -5
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +1 -1
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js +23 -11
- package/dist/realtime-server/index.js.map +1 -1
- package/package.json +9 -9
- package/src/realtime-client/realtime-client-stores/client-main-store.ts +30 -38
- package/src/realtime-react/use-pull-mutable-family-member.ts +0 -2
- package/src/realtime-react/use-realtime-rooms.ts +11 -8
- package/src/realtime-server/ipc-sockets/parent-socket.ts +17 -4
- package/src/realtime-server/provide-rooms.ts +10 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region rolldown:runtime
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var
|
|
3
|
+
var __exportAll = (all, symbols) => {
|
|
4
4
|
let target = {};
|
|
5
5
|
for (var name in all) {
|
|
6
6
|
__defProp(target, name, {
|
|
@@ -15,4 +15,4 @@ var __export = (all, symbols) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
export {
|
|
18
|
+
export { __exportAll as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "../chunk-Dms8e946.js";
|
|
2
2
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
|
|
4
4
|
//#region src/eslint-plugin/rules/exact-catch-types.ts
|
|
@@ -199,7 +199,7 @@ const explicitStateTypes = createRule({
|
|
|
199
199
|
|
|
200
200
|
//#endregion
|
|
201
201
|
//#region src/eslint-plugin/rules/index.ts
|
|
202
|
-
var rules_exports = /* @__PURE__ */
|
|
202
|
+
var rules_exports = /* @__PURE__ */ __exportAll({
|
|
203
203
|
exactCatchTypes: () => exactCatchTypes,
|
|
204
204
|
explicitStateTypes: () => explicitStateTypes
|
|
205
205
|
});
|
package/dist/internal/index.js
CHANGED
|
@@ -1165,20 +1165,20 @@ var Store = class {
|
|
|
1165
1165
|
family.install(this);
|
|
1166
1166
|
}
|
|
1167
1167
|
const mutableHelpers = /* @__PURE__ */ new Set();
|
|
1168
|
-
for (const [, atom] of store.atoms) {
|
|
1169
|
-
if (mutableHelpers.has(atom.key)) continue;
|
|
1170
|
-
atom.install(this);
|
|
1171
|
-
if (atom.type === `mutable_atom`) {
|
|
1172
|
-
const originalJsonToken = getJsonToken(store, atom);
|
|
1173
|
-
const originalUpdateToken = getUpdateToken(atom);
|
|
1168
|
+
for (const [, atom$1] of store.atoms) {
|
|
1169
|
+
if (mutableHelpers.has(atom$1.key)) continue;
|
|
1170
|
+
atom$1.install(this);
|
|
1171
|
+
if (atom$1.type === `mutable_atom`) {
|
|
1172
|
+
const originalJsonToken = getJsonToken(store, atom$1);
|
|
1173
|
+
const originalUpdateToken = getUpdateToken(atom$1);
|
|
1174
1174
|
mutableHelpers.add(originalJsonToken.key);
|
|
1175
1175
|
mutableHelpers.add(originalUpdateToken.key);
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
|
-
for (const [, selector] of store.readonlySelectors) selector.install(this);
|
|
1179
|
-
for (const [, selector] of store.writableSelectors) {
|
|
1180
|
-
if (mutableHelpers.has(selector.key)) continue;
|
|
1181
|
-
selector.install(this);
|
|
1178
|
+
for (const [, selector$1] of store.readonlySelectors) selector$1.install(this);
|
|
1179
|
+
for (const [, selector$1] of store.writableSelectors) {
|
|
1180
|
+
if (mutableHelpers.has(selector$1.key)) continue;
|
|
1181
|
+
selector$1.install(this);
|
|
1182
1182
|
}
|
|
1183
1183
|
for (const [, tx] of store.transactions) tx.install(this);
|
|
1184
1184
|
for (const [, timeline] of store.timelines) timeline.install(this);
|
|
@@ -1903,23 +1903,23 @@ function dispatchOrDeferStateUpdate(target, state, proto, stateIsNewlyCreated, f
|
|
|
1903
1903
|
//#endregion
|
|
1904
1904
|
//#region src/internal/set-state/set-atom.ts
|
|
1905
1905
|
const UNSET = Symbol(`UNSET`);
|
|
1906
|
-
const setAtom = (target, atom, next) => {
|
|
1906
|
+
const setAtom = (target, atom$1, next) => {
|
|
1907
1907
|
let oldValue;
|
|
1908
1908
|
let newValue;
|
|
1909
1909
|
if (isFn(next)) {
|
|
1910
|
-
const prev = readOrComputeValue(target, atom, `mut`);
|
|
1910
|
+
const prev = readOrComputeValue(target, atom$1, `mut`);
|
|
1911
1911
|
oldValue = prev;
|
|
1912
1912
|
newValue = next(prev);
|
|
1913
1913
|
} else {
|
|
1914
|
-
if (target.valueMap.has(atom.key)) oldValue = readFromCache(target, atom, `mut`);
|
|
1915
|
-
else if (atom.type === `atom` && !isFn(atom.default)) oldValue = atom.default;
|
|
1914
|
+
if (target.valueMap.has(atom$1.key)) oldValue = readFromCache(target, atom$1, `mut`);
|
|
1915
|
+
else if (atom$1.type === `atom` && !isFn(atom$1.default)) oldValue = atom$1.default;
|
|
1916
1916
|
else oldValue = UNSET;
|
|
1917
1917
|
newValue = next;
|
|
1918
1918
|
}
|
|
1919
|
-
target.logger.info(`⭐`, `atom`, atom.key, `setting value`, newValue);
|
|
1920
|
-
newValue = writeToCache(target, atom, newValue);
|
|
1921
|
-
markDone(target, atom.key);
|
|
1922
|
-
evictDownstreamFromAtom(target, atom);
|
|
1919
|
+
target.logger.info(`⭐`, `atom`, atom$1.key, `setting value`, newValue);
|
|
1920
|
+
newValue = writeToCache(target, atom$1, newValue);
|
|
1921
|
+
markDone(target, atom$1.key);
|
|
1922
|
+
evictDownstreamFromAtom(target, atom$1);
|
|
1923
1923
|
if (oldValue === UNSET) return { newValue };
|
|
1924
1924
|
return {
|
|
1925
1925
|
oldValue,
|
|
@@ -1929,14 +1929,14 @@ const setAtom = (target, atom, next) => {
|
|
|
1929
1929
|
|
|
1930
1930
|
//#endregion
|
|
1931
1931
|
//#region src/internal/set-state/reset-atom-or-selector.ts
|
|
1932
|
-
function resetAtom(target, atom) {
|
|
1933
|
-
switch (atom.type) {
|
|
1934
|
-
case `mutable_atom`: return setAtom(target, atom, new atom.class());
|
|
1932
|
+
function resetAtom(target, atom$1) {
|
|
1933
|
+
switch (atom$1.type) {
|
|
1934
|
+
case `mutable_atom`: return setAtom(target, atom$1, new atom$1.class());
|
|
1935
1935
|
case `atom`: {
|
|
1936
1936
|
let def;
|
|
1937
|
-
if (isFn(atom.default)) def = safeCompute(target, atom);
|
|
1938
|
-
else def = atom.default;
|
|
1939
|
-
return setAtom(target, atom, def);
|
|
1937
|
+
if (isFn(atom$1.default)) def = safeCompute(target, atom$1);
|
|
1938
|
+
else def = atom$1.default;
|
|
1939
|
+
return setAtom(target, atom$1, def);
|
|
1940
1940
|
}
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
@@ -1950,7 +1950,7 @@ function resetAtomOrSelector(target, state) {
|
|
|
1950
1950
|
case `writable_held_selector`:
|
|
1951
1951
|
{
|
|
1952
1952
|
const atoms = traceRootSelectorAtoms(target, state.key);
|
|
1953
|
-
for (const atom of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
|
|
1953
|
+
for (const atom$1 of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
|
|
1954
1954
|
const value = state.getFrom(target);
|
|
1955
1955
|
protoUpdate = {
|
|
1956
1956
|
oldValue: value,
|
|
@@ -1962,7 +1962,7 @@ function resetAtomOrSelector(target, state) {
|
|
|
1962
1962
|
{
|
|
1963
1963
|
const oldValue = safeCompute(target, state);
|
|
1964
1964
|
const atoms = traceRootSelectorAtoms(target, state.key);
|
|
1965
|
-
for (const atom of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
|
|
1965
|
+
for (const atom$1 of atoms.values()) dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
|
|
1966
1966
|
protoUpdate = {
|
|
1967
1967
|
oldValue,
|
|
1968
1968
|
newValue: safeCompute(target, state)
|
|
@@ -1988,26 +1988,26 @@ function resetInStore(store, ...params) {
|
|
|
1988
1988
|
|
|
1989
1989
|
//#endregion
|
|
1990
1990
|
//#region src/internal/set-state/set-selector.ts
|
|
1991
|
-
function setSelector(target, selector, next) {
|
|
1991
|
+
function setSelector(target, selector$1, next) {
|
|
1992
1992
|
let oldValue;
|
|
1993
1993
|
let newValue;
|
|
1994
1994
|
let constant;
|
|
1995
|
-
const { type, key } = selector;
|
|
1996
|
-
switch (selector.type) {
|
|
1995
|
+
const { type, key } = selector$1;
|
|
1996
|
+
switch (selector$1.type) {
|
|
1997
1997
|
case `writable_pure_selector`:
|
|
1998
|
-
oldValue = readOrComputeValue(target, selector, `mut`);
|
|
1998
|
+
oldValue = readOrComputeValue(target, selector$1, `mut`);
|
|
1999
1999
|
newValue = become(next, oldValue);
|
|
2000
|
-
newValue = writeToCache(target, selector, newValue);
|
|
2000
|
+
newValue = writeToCache(target, selector$1, newValue);
|
|
2001
2001
|
break;
|
|
2002
2002
|
case `writable_held_selector`:
|
|
2003
|
-
constant = selector.const;
|
|
2003
|
+
constant = selector$1.const;
|
|
2004
2004
|
become(next, constant);
|
|
2005
2005
|
oldValue = constant;
|
|
2006
2006
|
newValue = constant;
|
|
2007
2007
|
}
|
|
2008
2008
|
target.logger.info(`⭐`, type, key, `setting to`, newValue);
|
|
2009
2009
|
markDone(target, key);
|
|
2010
|
-
selector.setSelf(newValue);
|
|
2010
|
+
selector$1.setSelf(newValue);
|
|
2011
2011
|
return {
|
|
2012
2012
|
oldValue,
|
|
2013
2013
|
newValue
|
|
@@ -2112,8 +2112,8 @@ function traceRootSelectorAtoms(store, selectorKey, covered = /* @__PURE__ */ ne
|
|
|
2112
2112
|
if (covered.has(dependencyKey)) continue;
|
|
2113
2113
|
covered.add(dependencyKey);
|
|
2114
2114
|
if (isAtomKey(store, dependencyKey)) {
|
|
2115
|
-
const atom = store.atoms.get(dependencyKey);
|
|
2116
|
-
roots.set(atom.key, atom);
|
|
2115
|
+
const atom$1 = store.atoms.get(dependencyKey);
|
|
2116
|
+
roots.set(atom$1.key, atom$1);
|
|
2117
2117
|
} else dependencies.push(...getSelectorDependencyKeys(store, dependencyKey));
|
|
2118
2118
|
}
|
|
2119
2119
|
return roots;
|
|
@@ -2455,13 +2455,13 @@ const recallState = (store, state) => {
|
|
|
2455
2455
|
|
|
2456
2456
|
//#endregion
|
|
2457
2457
|
//#region src/internal/subscribe/subscribe-to-root-atoms.ts
|
|
2458
|
-
const subscribeToRootDependency = (target, selector, atom) => {
|
|
2459
|
-
return atom.subject.subscribe(`${selector.type}:${selector.key}`, (atomChange) => {
|
|
2460
|
-
target.logger.info(`📢`, selector.type, selector.key, `root`, atom.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
|
|
2461
|
-
const oldValue = recallState(target, selector);
|
|
2462
|
-
const newValue = readOrComputeValue(target, selector);
|
|
2463
|
-
target.logger.info(`✨`, selector.type, selector.key, `went`, oldValue, `->`, newValue);
|
|
2464
|
-
selector.subject.next({
|
|
2458
|
+
const subscribeToRootDependency = (target, selector$1, atom$1) => {
|
|
2459
|
+
return atom$1.subject.subscribe(`${selector$1.type}:${selector$1.key}`, (atomChange) => {
|
|
2460
|
+
target.logger.info(`📢`, selector$1.type, selector$1.key, `root`, atom$1.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
|
|
2461
|
+
const oldValue = recallState(target, selector$1);
|
|
2462
|
+
const newValue = readOrComputeValue(target, selector$1);
|
|
2463
|
+
target.logger.info(`✨`, selector$1.type, selector$1.key, `went`, oldValue, `->`, newValue);
|
|
2464
|
+
selector$1.subject.next({
|
|
2465
2465
|
newValue,
|
|
2466
2466
|
oldValue
|
|
2467
2467
|
});
|
|
@@ -2483,7 +2483,7 @@ function subscribeToState(store, token, key, handleUpdate) {
|
|
|
2483
2483
|
let updateHandler = safelyHandleUpdate;
|
|
2484
2484
|
if (isSelector) {
|
|
2485
2485
|
readOrComputeValue(store, state);
|
|
2486
|
-
for (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key)) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
|
|
2486
|
+
for (const [atomKey, atom$1] of traceRootSelectorAtoms(store, state.key)) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
|
|
2487
2487
|
updateHandler = function updateRootsBeforeHandlingUpdate(update) {
|
|
2488
2488
|
const dependencies = traceRootSelectorAtoms(store, state.key);
|
|
2489
2489
|
for (const [previousRootKey, unsub] of rootSubs) if (dependencies.get(previousRootKey)) dependencies.delete(previousRootKey);
|
|
@@ -2491,7 +2491,7 @@ function subscribeToState(store, token, key, handleUpdate) {
|
|
|
2491
2491
|
unsub();
|
|
2492
2492
|
rootSubs.delete(previousRootKey);
|
|
2493
2493
|
}
|
|
2494
|
-
for (const [atomKey, atom] of dependencies) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
|
|
2494
|
+
for (const [atomKey, atom$1] of dependencies) rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
|
|
2495
2495
|
safelyHandleUpdate(update);
|
|
2496
2496
|
};
|
|
2497
2497
|
}
|
|
@@ -2891,9 +2891,9 @@ function evictCachedValue(target, key) {
|
|
|
2891
2891
|
|
|
2892
2892
|
//#endregion
|
|
2893
2893
|
//#region src/internal/set-state/evict-downstream.ts
|
|
2894
|
-
function evictDownstreamFromAtom(store, atom) {
|
|
2894
|
+
function evictDownstreamFromAtom(store, atom$1) {
|
|
2895
2895
|
const target = newest(store);
|
|
2896
|
-
const { key, type } = atom;
|
|
2896
|
+
const { key, type } = atom$1;
|
|
2897
2897
|
const downstreamKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
2898
2898
|
target.logger.info(`🧹`, type, key, downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`, downstreamKeys ?? `to evict`);
|
|
2899
2899
|
if (downstreamKeys) {
|
|
@@ -2971,9 +2971,9 @@ function createRegularAtom(store, options, family, internalRoles) {
|
|
|
2971
2971
|
//#endregion
|
|
2972
2972
|
//#region src/internal/atom/has-role.ts
|
|
2973
2973
|
const INTERNAL_ROLES = [`tracker:signal`];
|
|
2974
|
-
function hasRole(atom, role) {
|
|
2975
|
-
if (`internalRoles` in atom === false) return false;
|
|
2976
|
-
return atom.internalRoles.includes(role);
|
|
2974
|
+
function hasRole(atom$1, role) {
|
|
2975
|
+
if (`internalRoles` in atom$1 === false) return false;
|
|
2976
|
+
return atom$1.internalRoles.includes(role);
|
|
2977
2977
|
}
|
|
2978
2978
|
|
|
2979
2979
|
//#endregion
|
|
@@ -2981,11 +2981,11 @@ function hasRole(atom, role) {
|
|
|
2981
2981
|
function disposeAtom(store, atomToken) {
|
|
2982
2982
|
const target = newest(store);
|
|
2983
2983
|
const { key, family } = atomToken;
|
|
2984
|
-
const atom = withdraw(target, atomToken);
|
|
2984
|
+
const atom$1 = withdraw(target, atomToken);
|
|
2985
2985
|
if (!family) store.logger.error(`❌`, `atom`, key, `Standalone atoms cannot be disposed.`);
|
|
2986
2986
|
else {
|
|
2987
|
-
atom.cleanup?.();
|
|
2988
|
-
const lastValue = store.valueMap.get(atom.key);
|
|
2987
|
+
atom$1.cleanup?.();
|
|
2988
|
+
const lastValue = store.valueMap.get(atom$1.key);
|
|
2989
2989
|
const subject = withdraw(store, getFamilyOfToken(store, atomToken)).subject;
|
|
2990
2990
|
const disposalEvent = {
|
|
2991
2991
|
type: `state_disposal`,
|
|
@@ -3009,8 +3009,8 @@ function disposeAtom(store, atomToken) {
|
|
|
3009
3009
|
store.logger.info(`🔥`, `atom`, key, `deleted`);
|
|
3010
3010
|
if (isChild && target.transactionMeta.phase === `building`) {
|
|
3011
3011
|
const mostRecentUpdate = target.transactionMeta.update.subEvents.at(-1);
|
|
3012
|
-
const updateAlreadyCaptured = mostRecentUpdate?.type === `molecule_disposal` && mostRecentUpdate.values.some(([k]) => k === atom.family?.key);
|
|
3013
|
-
const isTracker = hasRole(atom, `tracker:signal`);
|
|
3012
|
+
const updateAlreadyCaptured = mostRecentUpdate?.type === `molecule_disposal` && mostRecentUpdate.values.some(([k]) => k === atom$1.family?.key);
|
|
3013
|
+
const isTracker = hasRole(atom$1, `tracker:signal`);
|
|
3014
3014
|
if (!updateAlreadyCaptured && !isTracker) target.transactionMeta.update.subEvents.push(disposalEvent);
|
|
3015
3015
|
} else store.on.atomDisposal.next(atomToken);
|
|
3016
3016
|
}
|
|
@@ -3395,12 +3395,12 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3395
3395
|
reduceReference(store, atomToken);
|
|
3396
3396
|
let maybeAtom = withdraw(store, atomToken);
|
|
3397
3397
|
if (maybeAtom.type === `mutable_atom`) maybeAtom = withdraw(store, getUpdateToken(maybeAtom));
|
|
3398
|
-
const atom = maybeAtom;
|
|
3398
|
+
const atom$1 = maybeAtom;
|
|
3399
3399
|
store.timelineTopics.set({
|
|
3400
|
-
topicKey: atom.key,
|
|
3400
|
+
topicKey: atom$1.key,
|
|
3401
3401
|
timelineKey: tl.key
|
|
3402
3402
|
}, { topicType: `atom` });
|
|
3403
|
-
tl.subscriptions.set(atom.key, atom.subject.subscribe(`timeline`, function timelineCapturesAtomUpdate(update) {
|
|
3403
|
+
tl.subscriptions.set(atom$1.key, atom$1.subject.subscribe(`timeline`, function timelineCapturesAtomUpdate(update) {
|
|
3404
3404
|
const target = newest(store);
|
|
3405
3405
|
const currentSelectorToken = store.operation.open && store.operation.token.type === `writable_pure_selector` ? store.operation.token : null;
|
|
3406
3406
|
const currentSelectorTime = store.operation.open && store.operation.token.type === `writable_pure_selector` ? store.operation.timestamp : null;
|
|
@@ -3414,11 +3414,11 @@ function addAtomToTimeline(store, atomToken, tl) {
|
|
|
3414
3414
|
const atomUpdate = {
|
|
3415
3415
|
checkpoint: true,
|
|
3416
3416
|
type: `atom_update`,
|
|
3417
|
-
token: deposit(atom),
|
|
3417
|
+
token: deposit(atom$1),
|
|
3418
3418
|
update,
|
|
3419
3419
|
timestamp
|
|
3420
3420
|
};
|
|
3421
|
-
store.logger.info(`⌛`, `timeline`, tl.key, `got an atom_update to "${atom.key}"`);
|
|
3421
|
+
store.logger.info(`⌛`, `timeline`, tl.key, `got an atom_update to "${atom$1.key}"`);
|
|
3422
3422
|
addToHistory(tl, atomUpdate);
|
|
3423
3423
|
}
|
|
3424
3424
|
}));
|
|
@@ -3432,7 +3432,7 @@ function addAtomFamilyToTimeline(store, atomFamilyToken, tl) {
|
|
|
3432
3432
|
tl.subscriptions.set(family.key, family.subject.subscribe(`timeline`, function timelineCapturesStateLifecycleEvent(creationOrDisposal) {
|
|
3433
3433
|
handleStateLifecycleEvent(store, creationOrDisposal, tl);
|
|
3434
3434
|
}));
|
|
3435
|
-
for (const atom of store.atoms.values()) if (atom.family?.key === family.key) addAtomToTimeline(store, atom, tl);
|
|
3435
|
+
for (const atom$1 of store.atoms.values()) if (atom$1.family?.key === family.key) addAtomToTimeline(store, atom$1, tl);
|
|
3436
3436
|
}
|
|
3437
3437
|
function joinTransaction(store, tl, txUpdateInProgress) {
|
|
3438
3438
|
const currentTxKey = txUpdateInProgress.token.key;
|