atom.io 0.18.0 → 0.18.1
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-OEVFAUPE.js → chunk-IZHOMSXA.js} +53 -11
- package/dist/chunk-IZHOMSXA.js.map +1 -0
- package/dist/chunk-JDUNWJFB.js +18 -0
- package/dist/chunk-JDUNWJFB.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +64 -34
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +1 -1
- package/internal/dist/index.js +64 -34
- package/internal/dist/index.js.map +1 -1
- package/internal/src/atom/delete-atom.ts +7 -6
- package/internal/src/caching.ts +6 -6
- package/internal/src/ingest-updates/ingest-atom-update.ts +6 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +5 -0
- package/internal/src/set-state/emit-update.ts +25 -11
- package/internal/src/set-state/set-atom.ts +4 -3
- package/internal/src/transaction/apply-transaction.ts +0 -1
- package/internal/src/transaction/set-epoch-number.ts +0 -1
- package/json/src/index.ts +3 -3
- package/package.json +241 -241
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.js +1 -15
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +3 -3
- package/realtime/dist/index.cjs +50 -2
- package/realtime/dist/index.cjs.map +1 -1
- package/realtime/dist/index.d.ts +110 -3
- package/realtime/dist/index.js +47 -4
- package/realtime/dist/index.js.map +1 -1
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +14 -4
- package/realtime/src/shared-room-store.ts +48 -0
- package/realtime-client/dist/index.cjs +113 -200
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +2 -5
- package/realtime-client/dist/index.js +17 -161
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +0 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +5 -5
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +10 -0
- package/realtime-client/src/sync-continuity.ts +56 -9
- package/realtime-react/dist/index.cjs +51 -26
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +2 -6
- package/realtime-react/dist/index.js +2 -17
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +0 -2
- package/realtime-server/dist/index.cjs +399 -327
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +55 -60
- package/realtime-server/dist/index.js +394 -319
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +2 -4
- package/realtime-server/src/ipc-sockets/child-socket.ts +135 -0
- package/realtime-server/src/ipc-sockets/custom-socket.ts +90 -0
- package/realtime-server/src/ipc-sockets/index.ts +3 -0
- package/realtime-server/src/ipc-sockets/parent-socket.ts +185 -0
- package/realtime-server/src/realtime-continuity-synchronizer.ts +225 -96
- package/realtime-server/src/realtime-server-stores/index.ts +2 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +50 -31
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +64 -0
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +42 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +49 -26
- package/realtime-testing/dist/index.cjs +8 -6
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.ts +1 -0
- package/realtime-testing/dist/index.js +7 -6
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +8 -6
- package/src/logger.ts +5 -1
- package/dist/chunk-OEVFAUPE.js.map +0 -1
- package/realtime-client/src/sync-server-action.ts +0 -168
- package/realtime-client/src/sync-state.ts +0 -19
- package/realtime-react/src/use-sync-server-action.ts +0 -17
- package/realtime-react/src/use-sync.ts +0 -17
- package/realtime-server/src/ipc-socket.ts +0 -230
- package/realtime-server/src/realtime-action-synchronizer.ts +0 -164
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +0 -97
package/internal/dist/index.cjs
CHANGED
|
@@ -546,6 +546,24 @@ var Future = class extends Promise {
|
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
550
|
+
function copyMutableIfNeeded(atom, origin, target) {
|
|
551
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
552
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
553
|
+
if (originValue === targetValue) {
|
|
554
|
+
if (originValue === void 0) {
|
|
555
|
+
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
556
|
+
}
|
|
557
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
558
|
+
const jsonValue = atom.toJson(originValue);
|
|
559
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
560
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
561
|
+
new Tracker(atom, origin);
|
|
562
|
+
return copiedValue;
|
|
563
|
+
}
|
|
564
|
+
return targetValue;
|
|
565
|
+
}
|
|
566
|
+
|
|
549
567
|
// internal/src/caching.ts
|
|
550
568
|
function cacheValue(key, value, subject, target) {
|
|
551
569
|
const currentValue = target.valueMap.get(key);
|
|
@@ -572,7 +590,12 @@ function cacheValue(key, value, subject, target) {
|
|
|
572
590
|
return value;
|
|
573
591
|
}
|
|
574
592
|
var readCachedValue = (token, target) => {
|
|
575
|
-
|
|
593
|
+
let value = target.valueMap.get(token.key);
|
|
594
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
595
|
+
const { parent } = target;
|
|
596
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
597
|
+
value = copiedValue;
|
|
598
|
+
}
|
|
576
599
|
return value;
|
|
577
600
|
};
|
|
578
601
|
var evictCachedValue = (key, target) => {
|
|
@@ -819,34 +842,33 @@ var markDone = (key, store) => {
|
|
|
819
842
|
store.operation.done.add(key);
|
|
820
843
|
};
|
|
821
844
|
|
|
822
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
823
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
824
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
825
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
826
|
-
if (originValue === targetValue) {
|
|
827
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
828
|
-
const jsonValue = atom.toJson(originValue);
|
|
829
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
830
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
831
|
-
new Tracker(atom, origin);
|
|
832
|
-
return copiedValue;
|
|
833
|
-
}
|
|
834
|
-
return targetValue;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
845
|
// internal/src/set-state/emit-update.ts
|
|
838
846
|
var emitUpdate = (state, update, store) => {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
847
|
+
switch (state.type) {
|
|
848
|
+
case `mutable_atom`:
|
|
849
|
+
store.logger.info(
|
|
850
|
+
`\u{1F4E2}`,
|
|
851
|
+
state.type,
|
|
852
|
+
state.key,
|
|
853
|
+
`is now (`,
|
|
854
|
+
update.newValue,
|
|
855
|
+
`) subscribers:`,
|
|
856
|
+
state.subject.subscribers
|
|
857
|
+
);
|
|
858
|
+
break;
|
|
859
|
+
default:
|
|
860
|
+
store.logger.info(
|
|
861
|
+
`\u{1F4E2}`,
|
|
862
|
+
state.type,
|
|
863
|
+
state.key,
|
|
864
|
+
`went (`,
|
|
865
|
+
update.oldValue,
|
|
866
|
+
`->`,
|
|
867
|
+
update.newValue,
|
|
868
|
+
`) subscribers:`,
|
|
869
|
+
state.subject.subscribers
|
|
870
|
+
);
|
|
871
|
+
}
|
|
850
872
|
state.subject.next(update);
|
|
851
873
|
};
|
|
852
874
|
|
|
@@ -947,14 +969,16 @@ var setAtom = (atom, next, target) => {
|
|
|
947
969
|
stowUpdate(atom, update, target);
|
|
948
970
|
} else if (atom.key.startsWith(`*`)) {
|
|
949
971
|
const mutableKey = atom.key.slice(1);
|
|
950
|
-
target.atoms.get(mutableKey);
|
|
972
|
+
const mutableAtom = target.atoms.get(mutableKey);
|
|
951
973
|
let transceiver = target.valueMap.get(mutableKey);
|
|
952
|
-
if (
|
|
974
|
+
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
953
975
|
const { parent } = target;
|
|
954
|
-
const copiedValue = copyMutableIfNeeded(
|
|
976
|
+
const copiedValue = copyMutableIfNeeded(mutableAtom, parent, target);
|
|
955
977
|
transceiver = copiedValue;
|
|
956
978
|
}
|
|
957
|
-
transceiver.do(update.newValue);
|
|
979
|
+
const accepted = transceiver.do(update.newValue) === null;
|
|
980
|
+
if (accepted)
|
|
981
|
+
evictDownStream(mutableAtom, target);
|
|
958
982
|
}
|
|
959
983
|
}
|
|
960
984
|
};
|
|
@@ -1829,6 +1853,10 @@ function deleteAtom(atomToken, store) {
|
|
|
1829
1853
|
target.selectorAtoms.delete(key);
|
|
1830
1854
|
target.atomsThatAreDefault.delete(key);
|
|
1831
1855
|
target.timelineAtoms.delete(key);
|
|
1856
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1857
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1858
|
+
deleteAtom(updateToken, store);
|
|
1859
|
+
}
|
|
1832
1860
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1833
1861
|
}
|
|
1834
1862
|
|
|
@@ -1860,7 +1888,11 @@ function getFromStore(token, store) {
|
|
|
1860
1888
|
function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
1861
1889
|
const { key, newValue, oldValue } = atomUpdate;
|
|
1862
1890
|
const value = applying === `newValue` ? newValue : oldValue;
|
|
1863
|
-
|
|
1891
|
+
const token = { key, type: `atom` };
|
|
1892
|
+
if (atomUpdate.family) {
|
|
1893
|
+
Object.assign(token, { family: atomUpdate.family });
|
|
1894
|
+
}
|
|
1895
|
+
setIntoStore(token, value, store);
|
|
1864
1896
|
}
|
|
1865
1897
|
|
|
1866
1898
|
// internal/src/ingest-updates/ingest-selector-update.ts
|
|
@@ -2328,7 +2360,6 @@ function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
|
2328
2360
|
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
2329
2361
|
if (continuityKey !== void 0) {
|
|
2330
2362
|
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2331
|
-
console.log(`epoch is now`, newEpoch);
|
|
2332
2363
|
}
|
|
2333
2364
|
}
|
|
2334
2365
|
|
|
@@ -2380,7 +2411,6 @@ var applyTransaction = (output, store) => {
|
|
|
2380
2411
|
}
|
|
2381
2412
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2382
2413
|
if (isRootStore(parent)) {
|
|
2383
|
-
console.log(child.transactionMeta.update);
|
|
2384
2414
|
setEpochNumberOfAction(
|
|
2385
2415
|
child.transactionMeta.update.key,
|
|
2386
2416
|
child.transactionMeta.update.epoch,
|