atom.io 0.19.3 → 0.20.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.
Files changed (104) hide show
  1. package/data/dist/index.js +1 -1
  2. package/data/src/dict.ts +1 -1
  3. package/data/src/join.ts +1 -1
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +5 -3
  6. package/eslint-plugin/dist/index.cjs +53 -0
  7. package/eslint-plugin/dist/index.js +52 -0
  8. package/eslint-plugin/src/index.ts +1 -0
  9. package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
  10. package/eslint-plugin/src/rules/index.ts +1 -0
  11. package/internal/dist/index.cjs +127 -92
  12. package/internal/dist/index.d.ts +13 -9
  13. package/internal/dist/index.js +127 -92
  14. package/internal/src/atom/index.ts +1 -1
  15. package/internal/src/caching.ts +13 -9
  16. package/internal/src/families/create-atom-family.ts +1 -1
  17. package/internal/src/families/find-in-store.ts +2 -2
  18. package/internal/src/families/index.ts +1 -1
  19. package/internal/src/future.ts +52 -15
  20. package/internal/src/index.ts +2 -2
  21. package/internal/src/mutable/create-mutable-atom-family.ts +2 -3
  22. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  23. package/internal/src/mutable/get-update-token.ts +1 -0
  24. package/internal/src/selector/delete-selector.ts +1 -1
  25. package/internal/src/selector/register-selector.ts +1 -1
  26. package/internal/src/store/deposit.ts +1 -1
  27. package/internal/src/store/store.ts +2 -2
  28. package/internal/src/store/withdraw-new-family-member.ts +1 -1
  29. package/internal/src/store/withdraw.ts +2 -3
  30. package/internal/src/subscribe/subscribe-to-state.ts +1 -0
  31. package/internal/src/subscribe/subscribe-to-timeline.ts +1 -0
  32. package/internal/src/subscribe/subscribe-to-transaction.ts +2 -1
  33. package/internal/src/timeline/add-atom-to-timeline.ts +2 -2
  34. package/internal/src/timeline/create-timeline.ts +1 -1
  35. package/internal/src/transaction/act-upon-store.ts +1 -1
  36. package/internal/src/transaction/apply-transaction.ts +1 -1
  37. package/internal/src/transaction/build-transaction.ts +2 -2
  38. package/internal/src/transaction/create-transaction.ts +2 -2
  39. package/internal/src/transaction/index.ts +1 -1
  40. package/internal/src/transaction/is-root-store.ts +1 -1
  41. package/introspection/src/attach-atom-index.ts +1 -1
  42. package/introspection/src/attach-introspection-states.ts +2 -2
  43. package/introspection/src/attach-selector-index.ts +1 -1
  44. package/introspection/src/attach-timeline-family.ts +2 -2
  45. package/introspection/src/attach-timeline-index.ts +1 -1
  46. package/introspection/src/attach-transaction-index.ts +2 -2
  47. package/introspection/src/attach-transaction-logs.ts +2 -2
  48. package/json/dist/index.cjs +35 -33
  49. package/json/dist/index.d.ts +5 -5
  50. package/json/dist/index.js +5 -5
  51. package/json/src/index.ts +2 -3
  52. package/json/src/select-json-family.ts +6 -6
  53. package/json/src/select-json.ts +1 -2
  54. package/package.json +18 -15
  55. package/react/src/use-tl.ts +1 -1
  56. package/react-devtools/dist/index.cjs +99 -99
  57. package/react-devtools/dist/index.css +0 -3
  58. package/react-devtools/dist/index.d.ts +2 -2
  59. package/react-devtools/dist/index.js +77 -77
  60. package/react-devtools/src/AtomIODevtools.tsx +2 -2
  61. package/react-devtools/src/TransactionIndex.tsx +2 -2
  62. package/react-devtools/src/Updates.tsx +1 -1
  63. package/react-devtools/src/devtools.scss +0 -3
  64. package/react-devtools/src/index.ts +1 -1
  65. package/realtime/src/realtime-continuity.ts +1 -1
  66. package/realtime/src/shared-room-store.ts +1 -1
  67. package/realtime-client/dist/index.js +1 -1
  68. package/realtime-client/src/pull-atom-family-member.ts +1 -1
  69. package/realtime-client/src/pull-atom.ts +1 -1
  70. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  71. package/realtime-client/src/sync-continuity.ts +1 -1
  72. package/realtime-react/dist/index.js +1 -1
  73. package/realtime-react/src/use-realtime-service.ts +1 -0
  74. package/realtime-react/src/use-sync-continuity.ts +2 -1
  75. package/realtime-server/dist/index.cjs +98 -98
  76. package/realtime-server/dist/index.d.ts +17 -18
  77. package/realtime-server/dist/index.js +100 -100
  78. package/realtime-server/src/index.ts +5 -5
  79. package/realtime-server/src/ipc-sockets/parent-socket.ts +3 -3
  80. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  81. package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -3
  82. package/realtime-server/src/realtime-family-provider.ts +1 -1
  83. package/realtime-server/src/realtime-mutable-family-provider.ts +1 -1
  84. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  85. package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +2 -2
  86. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
  87. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -0
  88. package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
  89. package/realtime-server/src/realtime-state-provider.ts +1 -1
  90. package/realtime-server/src/realtime-state-synchronizer.ts +1 -1
  91. package/realtime-testing/dist/index.js +2 -2
  92. package/realtime-testing/src/setup-realtime-test.tsx +3 -2
  93. package/src/atom.ts +1 -1
  94. package/src/find-state.ts +1 -1
  95. package/src/index.ts +1 -0
  96. package/src/selector.ts +1 -1
  97. package/src/silo.ts +4 -4
  98. package/src/subscribe.ts +2 -2
  99. package/src/timeline.ts +1 -1
  100. package/src/transaction.ts +3 -3
  101. package/transceivers/set-rtx/src/set-rtx.ts +1 -1
  102. package/dist/{chunk-ATKDGVTV.js → chunk-2AIFLP2B.js} +0 -0
  103. package/dist/{chunk-CC7IF7QF.js → chunk-3V3VWQ7X.js} +6 -6
  104. /package/dist/{chunk-MSCJWACE.js → chunk-SMZRGPN6.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { pipe, ifDefined, isArray, isRecord, doesExtend, isPlainObject, raiseError, sprawl, recordToEntries, fallback, doNothing, become, mapObject, delve } from '../../dist/chunk-CC7IF7QF.js';
1
+ import { pipe, ifDefined, isArray, isRecord, doesExtend, isPlainObject, raiseError, sprawl, recordToEntries, fallback, doNothing, become, mapObject, delve } from '../../dist/chunk-3V3VWQ7X.js';
2
2
  import { lazyLocalStorageEffect } from '../../dist/chunk-BWWVY5O5.js';
3
3
  import { JSON_TYPE_NAMES, isString, isNumber, isBoolean, stringifyJson, JSON_DEFAULTS } from '../../dist/chunk-BF4MVQF6.js';
4
4
  import { __spreadProps, __spreadValues, __objRest, __restKey } from '../../dist/chunk-F2X4B4VY.js';
@@ -9,6 +9,82 @@ import { motion, spring, LayoutGroup } from 'framer-motion';
9
9
  import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, Component, useId } from 'react';
10
10
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
11
11
 
12
+ // ../anvl/src/refinement/can-exist.ts
13
+ var canExist = (_) => true;
14
+
15
+ // ../anvl/src/refinement/cannot-exist.ts
16
+ var cannotExist = (_) => false;
17
+
18
+ // ../anvl/src/refinement/is-intersection.ts
19
+ function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
20
+ const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
21
+ const _ = {
22
+ [name]: (input) => refinements.every(
23
+ (refinement) => (logging && console.log(
24
+ refinements.map((r) => r.name || `anon`).join(` & `),
25
+ `>`,
26
+ refinement.name || `anon`,
27
+ `:`,
28
+ refinement(input)
29
+ ), refinement(input))
30
+ )
31
+ };
32
+ const checkTypes = Object.assign(_[name], {
33
+ and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
34
+ ...refinements,
35
+ isTypeB
36
+ ])
37
+ });
38
+ return checkTypes;
39
+ }
40
+ var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
41
+
42
+ // ../anvl/src/refinement/is-union.ts
43
+ var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
44
+ const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
45
+ const _ = {
46
+ [name]: (input) => refinements.some(
47
+ (refinement) => {
48
+ var _a;
49
+ return logging && console.log(
50
+ refinements.map((r) => r.name || `anon`).join(` | `),
51
+ `>`,
52
+ (_a = refinement.name) != null ? _a : `anon`,
53
+ `:`,
54
+ refinement(input)
55
+ ), refinement(input);
56
+ }
57
+ )
58
+ };
59
+ const checkTypes = Object.assign(_[name], {
60
+ or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
61
+ });
62
+ return checkTypes;
63
+ };
64
+ var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
65
+
66
+ // ../anvl/src/refinement/refine-json.ts
67
+ var JSON_PROTOTYPES = [
68
+ `Array`,
69
+ `Boolean`,
70
+ `Number`,
71
+ `Object`,
72
+ `String`
73
+ ];
74
+ var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
75
+ data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
76
+ );
77
+ var isJson = (input) => {
78
+ var _a;
79
+ if (input === null)
80
+ return true;
81
+ if (input === void 0)
82
+ return false;
83
+ const prototype = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor.name;
84
+ const refine = JSON_PROTOTYPES.includes(prototype);
85
+ return refine;
86
+ };
87
+
12
88
  // ../anvl/src/refinement/refinery.ts
13
89
  var Refinery = class {
14
90
  constructor(supported) {
@@ -54,82 +130,6 @@ var discoverType = (input) => {
54
130
  return Object.getPrototypeOf(input).constructor.name;
55
131
  };
56
132
 
57
- // ../anvl/src/refinement/refine-json.ts
58
- var JSON_PROTOTYPES = [
59
- `Array`,
60
- `Boolean`,
61
- `Number`,
62
- `Object`,
63
- `String`
64
- ];
65
- var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
66
- data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
67
- );
68
- var isJson = (input) => {
69
- var _a;
70
- if (input === null)
71
- return true;
72
- if (input === void 0)
73
- return false;
74
- const prototype = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor.name;
75
- const refine = JSON_PROTOTYPES.includes(prototype);
76
- return refine;
77
- };
78
-
79
- // ../anvl/src/refinement/can-exist.ts
80
- var canExist = (_) => true;
81
-
82
- // ../anvl/src/refinement/cannot-exist.ts
83
- var cannotExist = (_) => false;
84
-
85
- // ../anvl/src/refinement/is-union.ts
86
- var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
87
- const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
88
- const _ = {
89
- [name]: (input) => refinements.some(
90
- (refinement) => {
91
- var _a;
92
- return logging && console.log(
93
- refinements.map((r) => r.name || `anon`).join(` | `),
94
- `>`,
95
- (_a = refinement.name) != null ? _a : `anon`,
96
- `:`,
97
- refinement(input)
98
- ), refinement(input);
99
- }
100
- )
101
- };
102
- const checkTypes = Object.assign(_[name], {
103
- or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
104
- });
105
- return checkTypes;
106
- };
107
- var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
108
-
109
- // ../anvl/src/refinement/is-intersection.ts
110
- function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
111
- const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
112
- const _ = {
113
- [name]: (input) => refinements.every(
114
- (refinement) => (logging && console.log(
115
- refinements.map((r) => r.name || `anon`).join(` & `),
116
- `>`,
117
- refinement.name || `anon`,
118
- `:`,
119
- refinement(input)
120
- ), refinement(input))
121
- )
122
- };
123
- const checkTypes = Object.assign(_[name], {
124
- and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
125
- ...refinements,
126
- isTypeB
127
- ])
128
- });
129
- return checkTypes;
130
- }
131
- var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
132
-
133
133
  // ../anvl/src/refinement/index.ts
134
134
  var isLiteral = (value) => (input) => input === value;
135
135
  var isWithin = (args) => (input) => args.includes(input);
@@ -1,3 +1,5 @@
1
+ import "./devtools.scss"
2
+
1
3
  import { useI, useO } from "atom.io/react"
2
4
  import { LayoutGroup, motion, spring } from "framer-motion"
3
5
  import { useRef } from "react"
@@ -13,8 +15,6 @@ import { StateIndex } from "./StateIndex"
13
15
  import { TimelineIndex } from "./TimelineIndex"
14
16
  import { TransactionIndex } from "./TransactionIndex"
15
17
 
16
- import "./devtools.scss"
17
-
18
18
  export const AtomIODevtools = (): JSX.Element => {
19
19
  const constraintsRef = useRef(null)
20
20
 
@@ -1,10 +1,10 @@
1
1
  import {
2
+ findState,
3
+ type Func,
2
4
  type ReadonlySelectorToken,
3
5
  type RegularAtomToken,
4
6
  type TransactionToken,
5
7
  type TransactionUpdate,
6
- findState,
7
- type Func,
8
8
  } from "atom.io"
9
9
  import { useI, useO } from "atom.io/react"
10
10
  import type { FC } from "react"
@@ -1,8 +1,8 @@
1
1
  import type {
2
+ Func,
2
3
  KeyedStateUpdate,
3
4
  TimelineUpdate,
4
5
  TransactionUpdate,
5
- Func,
6
6
  } from "atom.io"
7
7
  import * as React from "react"
8
8
 
@@ -130,9 +130,6 @@ main.atom_io_devtools {
130
130
  }
131
131
  section.transaction_log {
132
132
  margin-top: 0;
133
- header: {
134
- padding: 5px;
135
- }
136
133
  main {
137
134
  display: flex;
138
135
  flex-flow: row wrap;
@@ -4,9 +4,9 @@ import { attachIntrospectionStates } from "atom.io/introspection"
4
4
  import { isPlainObject } from "~/packages/anvl/src/object"
5
5
  import { Refinery } from "~/packages/anvl/src/refinement"
6
6
  import {
7
- Differ,
8
7
  diffArray,
9
8
  diffBoolean,
9
+ Differ,
10
10
  diffNumber,
11
11
  diffObject,
12
12
  diffString,
@@ -6,9 +6,9 @@ import type {
6
6
  TransactionToken,
7
7
  } from "atom.io"
8
8
  import {
9
- IMPLICIT,
10
9
  assignTransactionToContinuity,
11
10
  getUpdateToken,
11
+ IMPLICIT,
12
12
  setEpochNumberOfContinuity,
13
13
  } from "atom.io/internal"
14
14
  import type { Json } from "atom.io/json"
@@ -12,7 +12,7 @@ export const usersInThisRoomIndex = atom<SetRTX<string>, SetRTXJson<string>>({
12
12
  fromJson: (json) => SetRTX.fromJSON(json),
13
13
  })
14
14
 
15
- export const roomIndex = atom({
15
+ export const roomIndex = atom<SetRTX<string>, SetRTXJson<string>>({
16
16
  key: `roomIndex`,
17
17
  default: () => new SetRTX<string>(),
18
18
  mutable: true,
@@ -1,4 +1,4 @@
1
- export { syncContinuity } from '../../dist/chunk-ATKDGVTV.js';
1
+ export { syncContinuity } from '../../dist/chunk-2AIFLP2B.js';
2
2
  export { confirmedUpdateQueue, myIdState, myIdState__INTERNAL, myUsernameState, optimisticUpdateQueue } from '../../dist/chunk-O47EQUM6.js';
3
3
  import '../../dist/chunk-BWWVY5O5.js';
4
4
  import '../../dist/chunk-F2X4B4VY.js';
@@ -1,5 +1,5 @@
1
1
  import type * as AtomIO from "atom.io"
2
- import { type Store, setIntoStore } from "atom.io/internal"
2
+ import { setIntoStore, type Store } from "atom.io/internal"
3
3
  import type { Json } from "atom.io/json"
4
4
  import { parseJson } from "atom.io/json"
5
5
  import type { Socket } from "socket.io-client"
@@ -1,5 +1,5 @@
1
1
  import type * as AtomIO from "atom.io"
2
- import { type Store, setIntoStore } from "atom.io/internal"
2
+ import { setIntoStore, type Store } from "atom.io/internal"
3
3
  import type { Json } from "atom.io/json"
4
4
  import type { Socket } from "socket.io-client"
5
5
 
@@ -1,8 +1,8 @@
1
1
  import type * as AtomIO from "atom.io"
2
- import { getJsonToken, getUpdateToken, setIntoStore } from "atom.io/internal"
3
2
  import type { Store, Transceiver } from "atom.io/internal"
4
- import { parseJson } from "atom.io/json"
3
+ import { getJsonToken, getUpdateToken, setIntoStore } from "atom.io/internal"
5
4
  import type { Json } from "atom.io/json"
5
+ import { parseJson } from "atom.io/json"
6
6
  import type { Socket } from "socket.io-client"
7
7
 
8
8
  export function pullMutableAtomFamilyMember<
@@ -1,9 +1,9 @@
1
1
  import type * as AtomIO from "atom.io"
2
2
  import type { Store } from "atom.io/internal"
3
- import { deleteAtom } from "atom.io/internal"
4
3
  import {
5
4
  actUponStore,
6
5
  assignTransactionToContinuity,
6
+ deleteAtom,
7
7
  getEpochNumberOfContinuity,
8
8
  getFromStore,
9
9
  getJsonToken,
@@ -1,4 +1,4 @@
1
- import { syncContinuity } from '../../dist/chunk-ATKDGVTV.js';
1
+ import { syncContinuity } from '../../dist/chunk-2AIFLP2B.js';
2
2
  import '../../dist/chunk-F2X4B4VY.js';
3
3
  import { useI, StoreContext, useO } from 'atom.io/react';
4
4
  import * as RTC from 'atom.io/realtime-client';
@@ -1,5 +1,6 @@
1
1
  import * as React from "react"
2
2
  import type { Socket } from "socket.io-client"
3
+
3
4
  import { onMount } from "./on-mount"
4
5
  import { RealtimeContext } from "./realtime-context"
5
6
 
@@ -1,7 +1,8 @@
1
1
  import { StoreContext } from "atom.io/react"
2
2
  import * as React from "react"
3
- import { syncContinuity } from "../../realtime-client/src/sync-continuity"
3
+
4
4
  import type { ContinuityToken } from "../../realtime/src/realtime-continuity"
5
+ import { syncContinuity } from "../../realtime-client/src/sync-continuity"
5
6
  import { useRealtimeService } from "./use-realtime-service"
6
7
 
7
8
  export function useSyncContinuity(token: ContinuityToken): void {
@@ -344,6 +344,31 @@ var ParentSocket = class extends CustomSocket {
344
344
  this.relayServices.push(attachServices);
345
345
  }
346
346
  };
347
+ function realtimeActionReceiver({
348
+ socket,
349
+ store = internal.IMPLICIT.STORE
350
+ }) {
351
+ return function actionReceiver(tx) {
352
+ const fillTransactionRequest = (update) => {
353
+ const performanceKey = `tx-run:${tx.key}:${update.id}`;
354
+ const performanceKeyStart = `${performanceKey}:start`;
355
+ const performanceKeyEnd = `${performanceKey}:end`;
356
+ performance.mark(performanceKeyStart);
357
+ internal.actUponStore(tx, update.id, store)(...update.params);
358
+ performance.mark(performanceKeyEnd);
359
+ const metric = performance.measure(
360
+ performanceKey,
361
+ performanceKeyStart,
362
+ performanceKeyEnd
363
+ );
364
+ store == null ? void 0 : store.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
365
+ };
366
+ socket.on(`tx-run:${tx.key}`, fillTransactionRequest);
367
+ return () => {
368
+ socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
369
+ };
370
+ };
371
+ }
347
372
  function capitalize(string) {
348
373
  return string[0].toUpperCase() + string.slice(1);
349
374
  }
@@ -913,55 +938,6 @@ function realtimeContinuitySynchronizer({
913
938
  };
914
939
  };
915
940
  }
916
- function realtimeStateProvider({
917
- socket,
918
- store = internal.IMPLICIT.STORE
919
- }) {
920
- return function stateProvider(token) {
921
- let unsubscribeFromStateUpdates;
922
- const fillSubRequest = () => {
923
- socket.emit(`serve:${token.key}`, internal.getFromStore(token, store));
924
- unsubscribeFromStateUpdates = internal.subscribeToState(
925
- token,
926
- ({ newValue }) => {
927
- socket.emit(`serve:${token.key}`, newValue);
928
- },
929
- `expose-single:${socket.id}`,
930
- store
931
- );
932
- const fillUnsubRequest = () => {
933
- socket.off(`unsub:${token.key}`, fillUnsubRequest);
934
- if (unsubscribeFromStateUpdates) {
935
- unsubscribeFromStateUpdates();
936
- unsubscribeFromStateUpdates = void 0;
937
- }
938
- };
939
- socket.on(`unsub:${token.key}`, fillUnsubRequest);
940
- };
941
- socket.on(`sub:${token.key}`, fillSubRequest);
942
- return () => {
943
- socket.off(`sub:${token.key}`, fillSubRequest);
944
- if (unsubscribeFromStateUpdates) {
945
- unsubscribeFromStateUpdates();
946
- unsubscribeFromStateUpdates = void 0;
947
- }
948
- };
949
- };
950
- }
951
- function realtimeStateSynchronizer({
952
- socket,
953
- store = internal.IMPLICIT.STORE
954
- }) {
955
- return function stateSynchronizer(token) {
956
- const fillGetRequest = () => {
957
- socket.emit(`value:${token.key}`, internal.getFromStore(token, store));
958
- };
959
- socket.on(`get:${token.key}`, fillGetRequest);
960
- return () => {
961
- socket.off(`get:${token.key}`, fillGetRequest);
962
- };
963
- };
964
- }
965
941
  function realtimeAtomFamilyProvider({
966
942
  socket,
967
943
  store = internal.IMPLICIT.STORE
@@ -1008,38 +984,6 @@ function realtimeAtomFamilyProvider({
1008
984
  };
1009
985
  };
1010
986
  }
1011
- function realtimeMutableProvider({
1012
- socket,
1013
- store = internal.IMPLICIT.STORE
1014
- }) {
1015
- return function mutableProvider(token) {
1016
- let unsubscribeFromStateUpdates = null;
1017
- const jsonToken = internal.getJsonToken(token);
1018
- const trackerToken = internal.getUpdateToken(token);
1019
- const fillUnsubRequest = () => {
1020
- socket.off(`unsub:${token.key}`, fillUnsubRequest);
1021
- unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
1022
- unsubscribeFromStateUpdates = null;
1023
- };
1024
- const fillSubRequest = () => {
1025
- socket.emit(`init:${token.key}`, internal.getFromStore(jsonToken, store));
1026
- unsubscribeFromStateUpdates = internal.subscribeToState(
1027
- trackerToken,
1028
- ({ newValue }) => {
1029
- socket.emit(`next:${token.key}`, newValue);
1030
- },
1031
- `expose-single:${socket.id}`,
1032
- store
1033
- );
1034
- socket.on(`unsub:${token.key}`, fillUnsubRequest);
1035
- };
1036
- socket.on(`sub:${token.key}`, fillSubRequest);
1037
- return () => {
1038
- socket.off(`sub:${token.key}`, fillSubRequest);
1039
- unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
1040
- };
1041
- };
1042
- }
1043
987
  function realtimeMutableFamilyProvider({
1044
988
  socket,
1045
989
  store = internal.IMPLICIT.STORE
@@ -1088,6 +1032,73 @@ function realtimeMutableFamilyProvider({
1088
1032
  };
1089
1033
  };
1090
1034
  }
1035
+ function realtimeMutableProvider({
1036
+ socket,
1037
+ store = internal.IMPLICIT.STORE
1038
+ }) {
1039
+ return function mutableProvider(token) {
1040
+ let unsubscribeFromStateUpdates = null;
1041
+ const jsonToken = internal.getJsonToken(token);
1042
+ const trackerToken = internal.getUpdateToken(token);
1043
+ const fillUnsubRequest = () => {
1044
+ socket.off(`unsub:${token.key}`, fillUnsubRequest);
1045
+ unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
1046
+ unsubscribeFromStateUpdates = null;
1047
+ };
1048
+ const fillSubRequest = () => {
1049
+ socket.emit(`init:${token.key}`, internal.getFromStore(jsonToken, store));
1050
+ unsubscribeFromStateUpdates = internal.subscribeToState(
1051
+ trackerToken,
1052
+ ({ newValue }) => {
1053
+ socket.emit(`next:${token.key}`, newValue);
1054
+ },
1055
+ `expose-single:${socket.id}`,
1056
+ store
1057
+ );
1058
+ socket.on(`unsub:${token.key}`, fillUnsubRequest);
1059
+ };
1060
+ socket.on(`sub:${token.key}`, fillSubRequest);
1061
+ return () => {
1062
+ socket.off(`sub:${token.key}`, fillSubRequest);
1063
+ unsubscribeFromStateUpdates == null ? void 0 : unsubscribeFromStateUpdates();
1064
+ };
1065
+ };
1066
+ }
1067
+ function realtimeStateProvider({
1068
+ socket,
1069
+ store = internal.IMPLICIT.STORE
1070
+ }) {
1071
+ return function stateProvider(token) {
1072
+ let unsubscribeFromStateUpdates;
1073
+ const fillSubRequest = () => {
1074
+ socket.emit(`serve:${token.key}`, internal.getFromStore(token, store));
1075
+ unsubscribeFromStateUpdates = internal.subscribeToState(
1076
+ token,
1077
+ ({ newValue }) => {
1078
+ socket.emit(`serve:${token.key}`, newValue);
1079
+ },
1080
+ `expose-single:${socket.id}`,
1081
+ store
1082
+ );
1083
+ const fillUnsubRequest = () => {
1084
+ socket.off(`unsub:${token.key}`, fillUnsubRequest);
1085
+ if (unsubscribeFromStateUpdates) {
1086
+ unsubscribeFromStateUpdates();
1087
+ unsubscribeFromStateUpdates = void 0;
1088
+ }
1089
+ };
1090
+ socket.on(`unsub:${token.key}`, fillUnsubRequest);
1091
+ };
1092
+ socket.on(`sub:${token.key}`, fillSubRequest);
1093
+ return () => {
1094
+ socket.off(`sub:${token.key}`, fillSubRequest);
1095
+ if (unsubscribeFromStateUpdates) {
1096
+ unsubscribeFromStateUpdates();
1097
+ unsubscribeFromStateUpdates = void 0;
1098
+ }
1099
+ };
1100
+ };
1101
+ }
1091
1102
  function realtimeStateReceiver({
1092
1103
  socket,
1093
1104
  store = internal.IMPLICIT.STORE
@@ -1111,28 +1122,17 @@ function realtimeStateReceiver({
1111
1122
  };
1112
1123
  };
1113
1124
  }
1114
- function realtimeActionReceiver({
1125
+ function realtimeStateSynchronizer({
1115
1126
  socket,
1116
1127
  store = internal.IMPLICIT.STORE
1117
1128
  }) {
1118
- return function actionReceiver(tx) {
1119
- const fillTransactionRequest = (update) => {
1120
- const performanceKey = `tx-run:${tx.key}:${update.id}`;
1121
- const performanceKeyStart = `${performanceKey}:start`;
1122
- const performanceKeyEnd = `${performanceKey}:end`;
1123
- performance.mark(performanceKeyStart);
1124
- internal.actUponStore(tx, update.id, store)(...update.params);
1125
- performance.mark(performanceKeyEnd);
1126
- const metric = performance.measure(
1127
- performanceKey,
1128
- performanceKeyStart,
1129
- performanceKeyEnd
1130
- );
1131
- store == null ? void 0 : store.logger.info(`\u{1F680}`, `transaction`, tx.key, update.id, metric.duration);
1129
+ return function stateSynchronizer(token) {
1130
+ const fillGetRequest = () => {
1131
+ socket.emit(`value:${token.key}`, internal.getFromStore(token, store));
1132
1132
  };
1133
- socket.on(`tx-run:${tx.key}`, fillTransactionRequest);
1133
+ socket.on(`get:${token.key}`, fillGetRequest);
1134
1134
  return () => {
1135
- socket.off(`tx-run:${tx.key}`, fillTransactionRequest);
1135
+ socket.off(`get:${token.key}`, fillGetRequest);
1136
1136
  };
1137
1137
  };
1138
1138
  }
@@ -1,13 +1,12 @@
1
1
  import { Subject, Transceiver, Store } from 'atom.io/internal';
2
2
  import { Json, Stringified, JsonIO } from 'atom.io/json';
3
3
  import { ChildProcessWithoutNullStreams } from 'node:child_process';
4
- import { ContinuityToken, UserInRoomMeta } from 'atom.io/realtime';
5
4
  import * as AtomIO from 'atom.io';
6
5
  import { TransactionUpdateContent, TransactionUpdate, WritableToken } from 'atom.io';
6
+ import { ContinuityToken, UserInRoomMeta } from 'atom.io/realtime';
7
7
  import * as atom_io_data from 'atom.io/data';
8
8
  import { Loadable } from 'atom.io/data';
9
- import * as atom_io_transceivers_set_rtx from 'atom.io/transceivers/set-rtx';
10
- import { SetRTX } from 'atom.io/transceivers/set-rtx';
9
+ import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
11
10
 
12
11
  type Events = Json.Object<string, Json.Serializable[]>;
13
12
  type StringifiedEvent<Key extends string, Params extends Json.Serializable[]> = Stringified<[Key, ...Params]>;
@@ -82,9 +81,21 @@ declare class ParentSocket<I extends Events & {
82
81
  relay(attachServices: (socket: SubjectSocket<any, any>) => (() => void) | void): void;
83
82
  }
84
83
 
84
+ type ActionReceiver = ReturnType<typeof realtimeActionReceiver>;
85
+ declare function realtimeActionReceiver({ socket, store, }: ServerConfig): <F extends JsonIO>(tx: AtomIO.TransactionToken<F>) => () => void;
86
+
85
87
  type RealtimeContinuitySynchronizer = ReturnType<typeof realtimeContinuitySynchronizer>;
86
88
  declare function realtimeContinuitySynchronizer({ socket: initialSocket, store, }: ServerConfig): (continuity: ContinuityToken) => () => void;
87
89
 
90
+ type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>;
91
+ declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
92
+
93
+ type MutableFamilyProvider = ReturnType<typeof realtimeMutableFamilyProvider>;
94
+ declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
95
+
96
+ type MutableProvider = ReturnType<typeof realtimeMutableProvider>;
97
+ declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
98
+
88
99
  declare const createRoomTX: AtomIO.TransactionToken<(roomId: string, script: string, options?: string[]) => Loadable<ChildSocket<any, any>>>;
89
100
  type CreateRoomIO = AtomIO.TransactionIO<typeof createRoomTX>;
90
101
  declare const joinRoomTX: AtomIO.TransactionToken<(roomId: string, userId: string, enteredAtEpoch: number) => UserInRoomMeta>;
@@ -104,29 +115,17 @@ declare const actionOcclusionAtoms: AtomIO.RegularAtomFamilyTokenWithCall<{
104
115
  declare const userUnacknowledgedQueues: AtomIO.RegularAtomFamilyTokenWithCall<Pick<TransactionUpdate<any>, "key" | "epoch" | "id" | "updates" | "output">[], string>;
105
116
 
106
117
  declare const socketAtoms: AtomIO.RegularAtomFamilyTokenWithCall<Socket | null, string>;
107
- declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
108
- declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, atom_io_transceivers_set_rtx.SetRTXJson<string>>;
118
+ declare const socketIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
119
+ declare const userIndex: AtomIO.MutableAtomToken<SetRTX<string>, SetRTXJson<string>>;
109
120
  declare const usersOfSockets: atom_io_data.JoinToken<"user", "socket", "1:1", null>;
110
121
 
111
122
  type StateProvider = ReturnType<typeof realtimeStateProvider>;
112
123
  declare function realtimeStateProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;
113
124
 
114
- declare function realtimeStateSynchronizer({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;
115
-
116
- type FamilyProvider = ReturnType<typeof realtimeAtomFamilyProvider>;
117
- declare function realtimeAtomFamilyProvider({ socket, store, }: ServerConfig): <J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.RegularAtomFamilyToken<J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
118
-
119
- type MutableProvider = ReturnType<typeof realtimeMutableProvider>;
120
- declare function realtimeMutableProvider({ socket, store, }: ServerConfig): <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(token: AtomIO.MutableAtomToken<Core, SerializableCore>) => () => void;
121
-
122
- type MutableFamilyProvider = ReturnType<typeof realtimeMutableFamilyProvider>;
123
- declare function realtimeMutableFamilyProvider({ socket, store, }: ServerConfig): <T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(family: AtomIO.MutableAtomFamilyToken<T, J, K>, index: AtomIO.ReadableToken<Iterable<K>>) => () => void;
124
-
125
125
  type StateReceiver = ReturnType<typeof realtimeStateReceiver>;
126
126
  declare function realtimeStateReceiver({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: WritableToken<J>) => () => void;
127
127
 
128
- type ActionReceiver = ReturnType<typeof realtimeActionReceiver>;
129
- declare function realtimeActionReceiver({ socket, store, }: ServerConfig): <F extends JsonIO>(tx: AtomIO.TransactionToken<F>) => () => void;
128
+ declare function realtimeStateSynchronizer({ socket, store, }: ServerConfig): <J extends Json.Serializable>(token: AtomIO.WritableToken<J>) => () => void;
130
129
 
131
130
  type Socket = {
132
131
  id: string;