atom.io 0.13.0 → 0.14.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.
Files changed (141) hide show
  1. package/data/dist/index.cjs +1473 -52
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +315 -16
  4. package/data/dist/index.js +10 -267
  5. package/data/dist/index.js.map +1 -1
  6. package/data/package.json +5 -5
  7. package/data/src/join.ts +3 -3
  8. package/dist/chunk-5VJ77LZE.js +176 -0
  9. package/dist/chunk-5VJ77LZE.js.map +1 -0
  10. package/dist/chunk-CK7GNCU5.js +309 -0
  11. package/dist/chunk-CK7GNCU5.js.map +1 -0
  12. package/dist/chunk-KW7RA7IM.js +67 -0
  13. package/dist/chunk-KW7RA7IM.js.map +1 -0
  14. package/dist/chunk-LFXB7Y6M.js +68 -0
  15. package/dist/chunk-LFXB7Y6M.js.map +1 -0
  16. package/dist/chunk-NYCVSXQB.js +181 -0
  17. package/dist/chunk-NYCVSXQB.js.map +1 -0
  18. package/dist/chunk-TE3ZSTQ6.js +2516 -0
  19. package/dist/chunk-TE3ZSTQ6.js.map +1 -0
  20. package/dist/index.cjs +2250 -126
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +272 -25
  23. package/dist/index.js +1 -215
  24. package/dist/index.js.map +1 -1
  25. package/dist/metafile-cjs.json +1 -1
  26. package/internal/dist/index.cjs +885 -684
  27. package/internal/dist/index.cjs.map +1 -1
  28. package/internal/dist/index.d.cts +230 -24
  29. package/internal/dist/index.js +1 -2171
  30. package/internal/dist/index.js.map +1 -1
  31. package/internal/package.json +5 -5
  32. package/internal/src/atom/create-atom.ts +3 -2
  33. package/internal/src/mutable/create-mutable-atom.ts +3 -2
  34. package/internal/src/mutable/tracker.ts +6 -4
  35. package/internal/src/selector/register-selector.ts +1 -1
  36. package/internal/src/selector/update-selector-atoms.ts +3 -3
  37. package/internal/src/subscribe/index.ts +3 -0
  38. package/internal/src/subscribe/recall-state.ts +0 -6
  39. package/internal/src/subscribe/subscribe-to-state.ts +47 -0
  40. package/internal/src/subscribe/subscribe-to-timeline.ts +28 -0
  41. package/internal/src/subscribe/subscribe-to-transaction.ts +33 -0
  42. package/introspection/dist/index.cjs +1618 -46
  43. package/introspection/dist/index.cjs.map +1 -1
  44. package/introspection/dist/index.d.cts +374 -4
  45. package/introspection/dist/index.js +2 -316
  46. package/introspection/dist/index.js.map +1 -1
  47. package/introspection/package.json +5 -5
  48. package/json/dist/index.cjs +1560 -8
  49. package/json/dist/index.cjs.map +1 -1
  50. package/json/dist/index.d.cts +371 -7
  51. package/json/dist/index.js +1 -76
  52. package/json/dist/index.js.map +1 -1
  53. package/json/package.json +5 -5
  54. package/package.json +10 -9
  55. package/react/dist/index.cjs +1638 -10
  56. package/react/dist/index.cjs.map +1 -1
  57. package/react/dist/index.d.cts +383 -5
  58. package/react/dist/index.js +2 -31
  59. package/react/dist/index.js.map +1 -1
  60. package/react/package.json +5 -5
  61. package/react/src/store-hooks.ts +52 -3
  62. package/react-devtools/dist/index.cjs +2268 -198
  63. package/react-devtools/dist/index.cjs.map +1 -1
  64. package/react-devtools/dist/index.css +2 -2
  65. package/react-devtools/dist/index.d.cts +148 -24
  66. package/react-devtools/dist/index.js +57 -297
  67. package/react-devtools/dist/index.js.map +1 -1
  68. package/react-devtools/package.json +5 -5
  69. package/realtime-client/dist/index.cjs +1585 -34
  70. package/realtime-client/dist/index.cjs.map +1 -1
  71. package/realtime-client/dist/index.d.cts +382 -11
  72. package/realtime-client/dist/index.js +2 -164
  73. package/realtime-client/dist/index.js.map +1 -1
  74. package/realtime-client/package.json +5 -5
  75. package/realtime-client/src/use-push.ts +4 -4
  76. package/realtime-client/src/use-server-action.ts +4 -4
  77. package/realtime-react/dist/index.cjs +1782 -35
  78. package/realtime-react/dist/index.cjs.map +1 -1
  79. package/realtime-react/dist/index.d.cts +49 -9
  80. package/realtime-react/dist/index.js +4 -66
  81. package/realtime-react/dist/index.js.map +1 -1
  82. package/realtime-react/package.json +5 -5
  83. package/realtime-server/dist/index.cjs +1627 -60
  84. package/realtime-server/dist/index.cjs.map +1 -1
  85. package/realtime-server/dist/index.d.cts +391 -11
  86. package/realtime-server/dist/index.js +59 -32
  87. package/realtime-server/dist/index.js.map +1 -1
  88. package/realtime-server/package.json +6 -6
  89. package/realtime-server/src/hook-composition/expose-family.ts +7 -3
  90. package/realtime-server/src/hook-composition/expose-mutable-family.ts +13 -5
  91. package/realtime-server/src/hook-composition/expose-mutable.ts +11 -3
  92. package/realtime-server/src/hook-composition/expose-single.ts +6 -2
  93. package/realtime-server/src/hook-composition/receive-transaction.ts +14 -5
  94. package/realtime-testing/dist/index.cjs +2352 -16
  95. package/realtime-testing/dist/index.cjs.map +1 -1
  96. package/realtime-testing/dist/index.d.cts +486 -3
  97. package/realtime-testing/dist/index.js +10 -31
  98. package/realtime-testing/dist/index.js.map +1 -1
  99. package/realtime-testing/package.json +5 -5
  100. package/src/subscribe.ts +37 -91
  101. package/transceivers/set-rtx/dist/index.cjs +31 -10
  102. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  103. package/transceivers/set-rtx/dist/index.d.cts +29 -3
  104. package/transceivers/set-rtx/dist/index.js +2 -3
  105. package/transceivers/set-rtx/dist/index.js.map +1 -1
  106. package/transceivers/set-rtx/package.json +6 -6
  107. package/data/dist/index.d.ts +0 -158
  108. package/data/dist/metafile-cjs.json +0 -1
  109. package/data/dist/metafile-esm.json +0 -1
  110. package/dist/index.d.ts +0 -243
  111. package/dist/metafile-esm.json +0 -1
  112. package/internal/dist/index.d.ts +0 -414
  113. package/internal/dist/metafile-cjs.json +0 -1
  114. package/internal/dist/metafile-esm.json +0 -1
  115. package/introspection/dist/index.d.ts +0 -24
  116. package/introspection/dist/metafile-cjs.json +0 -1
  117. package/introspection/dist/metafile-esm.json +0 -1
  118. package/json/dist/index.d.ts +0 -51
  119. package/json/dist/metafile-cjs.json +0 -1
  120. package/json/dist/metafile-esm.json +0 -1
  121. package/react/dist/index.d.ts +0 -16
  122. package/react/dist/metafile-cjs.json +0 -1
  123. package/react/dist/metafile-esm.json +0 -1
  124. package/react-devtools/dist/index.d.ts +0 -341
  125. package/react-devtools/dist/metafile-cjs.json +0 -1
  126. package/react-devtools/dist/metafile-esm.json +0 -1
  127. package/realtime-client/dist/index.d.ts +0 -21
  128. package/realtime-client/dist/metafile-cjs.json +0 -1
  129. package/realtime-client/dist/metafile-esm.json +0 -1
  130. package/realtime-react/dist/index.d.ts +0 -27
  131. package/realtime-react/dist/metafile-cjs.json +0 -1
  132. package/realtime-react/dist/metafile-esm.json +0 -1
  133. package/realtime-server/dist/index.d.ts +0 -25
  134. package/realtime-server/dist/metafile-cjs.json +0 -1
  135. package/realtime-server/dist/metafile-esm.json +0 -1
  136. package/realtime-testing/dist/index.d.ts +0 -49
  137. package/realtime-testing/dist/metafile-cjs.json +0 -1
  138. package/realtime-testing/dist/metafile-esm.json +0 -1
  139. package/transceivers/set-rtx/dist/index.d.ts +0 -40
  140. package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
  141. package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
@@ -0,0 +1,309 @@
1
+ import { IMPLICIT, createAtom, newest, createSelector, createAtomFamily, Subject, __spreadValues, createSelectorFamily, __spreadProps } from './chunk-TE3ZSTQ6.js';
2
+
3
+ // introspection/src/attach-atom-index.ts
4
+ var attachAtomIndex = (store = IMPLICIT.STORE) => {
5
+ const atomTokenIndexState__INTERNAL = createAtom(
6
+ {
7
+ key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
8
+ default: () => {
9
+ const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
10
+ acc[key] = { key, type: `atom` };
11
+ return acc;
12
+ }, {});
13
+ return defaultAtomIndex;
14
+ },
15
+ effects: [
16
+ ({ setSelf }) => {
17
+ store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
18
+ if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
19
+ return;
20
+ }
21
+ const set = () => setSelf((state) => {
22
+ const { key, family } = atomToken;
23
+ if (family) {
24
+ const { key: familyKey, subKey } = family;
25
+ const current = state[familyKey];
26
+ if (current === void 0 || `familyMembers` in current) {
27
+ const familyKeyState = current || {
28
+ key: familyKey,
29
+ familyMembers: {}
30
+ };
31
+ return __spreadProps(__spreadValues({}, state), {
32
+ [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
33
+ familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
34
+ [subKey]: atomToken
35
+ })
36
+ })
37
+ });
38
+ }
39
+ }
40
+ return __spreadProps(__spreadValues({}, state), {
41
+ [key]: atomToken
42
+ });
43
+ });
44
+ if (newest(store).operation.open) {
45
+ const unsubscribe = store.subject.operationStatus.subscribe(
46
+ `introspection: waiting to update atom index`,
47
+ () => {
48
+ unsubscribe();
49
+ set();
50
+ }
51
+ );
52
+ } else {
53
+ set();
54
+ }
55
+ });
56
+ }
57
+ ]
58
+ },
59
+ void 0,
60
+ store
61
+ );
62
+ return createSelector(
63
+ {
64
+ key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
65
+ get: ({ get }) => get(atomTokenIndexState__INTERNAL)
66
+ },
67
+ void 0,
68
+ store
69
+ );
70
+ };
71
+
72
+ // introspection/src/attach-selector-index.ts
73
+ var attachSelectorIndex = (store = IMPLICIT.STORE) => {
74
+ const readonlySelectorTokenIndexState__INTERNAL = createAtom(
75
+ {
76
+ key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
77
+ default: () => Object.assign(
78
+ [...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
79
+ acc[key] = { key, type: `readonly_selector` };
80
+ return acc;
81
+ }, {}),
82
+ [...store.selectors].reduce((acc, [key]) => {
83
+ acc[key] = { key, type: `selector` };
84
+ return acc;
85
+ }, {})
86
+ ),
87
+ effects: [
88
+ ({ setSelf }) => {
89
+ store.subject.selectorCreation.subscribe(
90
+ `introspection`,
91
+ (selectorToken) => {
92
+ if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
93
+ return;
94
+ }
95
+ const set = () => setSelf((state) => {
96
+ const { key, family } = selectorToken;
97
+ if (family) {
98
+ const { key: familyKey, subKey } = family;
99
+ const current = state[familyKey];
100
+ if (current === void 0 || `familyMembers` in current) {
101
+ const familyKeyState = current || {
102
+ key: familyKey,
103
+ familyMembers: {}
104
+ };
105
+ return __spreadProps(__spreadValues({}, state), {
106
+ [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
107
+ familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
108
+ [subKey]: selectorToken
109
+ })
110
+ })
111
+ });
112
+ }
113
+ }
114
+ return __spreadProps(__spreadValues({}, state), {
115
+ [key]: selectorToken
116
+ });
117
+ });
118
+ if (newest(store).operation.open) {
119
+ const unsubscribe = store.subject.operationStatus.subscribe(
120
+ `introspection: waiting to update selector index`,
121
+ () => {
122
+ unsubscribe();
123
+ set();
124
+ }
125
+ );
126
+ } else {
127
+ set();
128
+ }
129
+ }
130
+ );
131
+ }
132
+ ]
133
+ },
134
+ void 0,
135
+ store
136
+ );
137
+ return createSelector(
138
+ {
139
+ key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
140
+ get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
141
+ },
142
+ void 0,
143
+ IMPLICIT.STORE
144
+ );
145
+ };
146
+
147
+ // introspection/src/attach-timeline-family.ts
148
+ var attachTimelineFamily = (store = IMPLICIT.STORE) => {
149
+ const findTimelineLogState__INTERNAL = createAtomFamily(
150
+ {
151
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
152
+ default: (key) => {
153
+ var _a;
154
+ return (_a = store.timelines.get(key)) != null ? _a : {
155
+ type: `timeline`,
156
+ key: ``,
157
+ at: 0,
158
+ timeTraveling: null,
159
+ history: [],
160
+ selectorTime: null,
161
+ transactionKey: null,
162
+ install: () => {
163
+ },
164
+ subject: new Subject()
165
+ };
166
+ },
167
+ effects: (key) => [
168
+ ({ setSelf }) => {
169
+ const tl = store.timelines.get(key);
170
+ tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
171
+ if (store.operation.open === true) {
172
+ const unsubscribe = store.subject.operationStatus.subscribe(
173
+ `introspection`,
174
+ (operationStatus) => {
175
+ if (operationStatus.open === false) {
176
+ unsubscribe();
177
+ setSelf(__spreadValues({}, tl));
178
+ }
179
+ }
180
+ );
181
+ } else {
182
+ setSelf(__spreadValues({}, tl));
183
+ }
184
+ });
185
+ }
186
+ ]
187
+ },
188
+ store
189
+ );
190
+ const findTimelineLogState = createSelectorFamily(
191
+ {
192
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
193
+ get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
194
+ },
195
+ store
196
+ );
197
+ return findTimelineLogState;
198
+ };
199
+
200
+ // introspection/src/attach-timeline-index.ts
201
+ var attachTimelineIndex = (store = IMPLICIT.STORE) => {
202
+ const timelineTokenIndexState__INTERNAL = createAtom(
203
+ {
204
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
205
+ default: () => [...store.timelines].map(([key]) => {
206
+ return { key, type: `timeline` };
207
+ }),
208
+ effects: [
209
+ ({ setSelf }) => {
210
+ store.subject.timelineCreation.subscribe(
211
+ `introspection`,
212
+ (timelineToken) => {
213
+ setSelf((state) => [...state, timelineToken]);
214
+ }
215
+ );
216
+ }
217
+ ]
218
+ },
219
+ void 0,
220
+ store
221
+ );
222
+ const timelineTokenIndex = createSelector(
223
+ {
224
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
225
+ get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
226
+ },
227
+ void 0,
228
+ store
229
+ );
230
+ return timelineTokenIndex;
231
+ };
232
+
233
+ // introspection/src/attach-transaction-index.ts
234
+ var attachTransactionIndex = (store = IMPLICIT.STORE) => {
235
+ const transactionTokenIndexState__INTERNAL = createAtom(
236
+ {
237
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
238
+ default: () => [...store.transactions].map(([key]) => {
239
+ return { key, type: `transaction` };
240
+ }),
241
+ effects: [
242
+ ({ setSelf }) => {
243
+ store.subject.transactionCreation.subscribe(
244
+ `introspection`,
245
+ (transactionToken) => {
246
+ setSelf((state) => [...state, transactionToken]);
247
+ }
248
+ );
249
+ }
250
+ ]
251
+ },
252
+ void 0,
253
+ store
254
+ );
255
+ const transactionTokenIndex = createSelector(
256
+ {
257
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
258
+ get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
259
+ },
260
+ void 0,
261
+ store
262
+ );
263
+ return transactionTokenIndex;
264
+ };
265
+
266
+ // introspection/src/attach-transaction-logs.ts
267
+ var attachTransactionLogs = (store = IMPLICIT.STORE) => {
268
+ const findTransactionUpdateLog = createAtomFamily(
269
+ {
270
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
271
+ default: () => [],
272
+ effects: (key) => [
273
+ ({ setSelf }) => {
274
+ const tx = store.transactions.get(key);
275
+ tx == null ? void 0 : tx.subject.subscribe(`introspection`, (transactionUpdate) => {
276
+ if (transactionUpdate.key === key) {
277
+ setSelf((state) => [...state, transactionUpdate]);
278
+ }
279
+ });
280
+ }
281
+ ]
282
+ },
283
+ store
284
+ );
285
+ const findTransactionUpdateLogState = createSelectorFamily(
286
+ {
287
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
288
+ get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
289
+ },
290
+ store
291
+ );
292
+ return findTransactionUpdateLogState;
293
+ };
294
+
295
+ // introspection/src/attach-introspection-states.ts
296
+ var attachIntrospectionStates = (store = IMPLICIT.STORE) => {
297
+ return {
298
+ atomIndex: attachAtomIndex(store),
299
+ selectorIndex: attachSelectorIndex(store),
300
+ transactionIndex: attachTransactionIndex(store),
301
+ findTransactionLogState: attachTransactionLogs(store),
302
+ timelineIndex: attachTimelineIndex(store),
303
+ findTimelineState: attachTimelineFamily(store)
304
+ };
305
+ };
306
+
307
+ export { attachIntrospectionStates };
308
+ //# sourceMappingURL=out.js.map
309
+ //# sourceMappingURL=chunk-CK7GNCU5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../introspection/src/attach-atom-index.ts","../introspection/src/attach-selector-index.ts","../introspection/src/attach-timeline-family.ts","../introspection/src/attach-timeline-index.ts","../introspection/src/attach-transaction-index.ts","../introspection/src/attach-transaction-logs.ts","../introspection/src/attach-introspection-states.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAQO,IAAM,kBAAkB,CAC9B,QAAe,SAAS,UACmB;AAC3C,QAAM,gCAAgC;AAAA,IACrC;AAAA,MACC,KAAK;AAAA,MACL,SAAS,MAAM;AACd,cAAM,mBAAmB,CAAC,GAAG,MAAM,KAAK,EACtC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,SAAS,0BAAO,CAAC,EACxC,OAAuB,CAAC,KAAK,CAAC,GAAG,MAAM;AACvC,cAAI,GAAG,IAAI,EAAE,KAAK,MAAM,OAAO;AAC/B,iBAAO;AAAA,QACR,GAAG,CAAC,CAAC;AACN,eAAO;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACR,CAAC,EAAE,QAAQ,MAAM;AAChB,gBAAM,QAAQ,aAAa,UAAU,iBAAiB,CAAC,cAAc;AACpE,gBAAI,UAAU,IAAI,SAAS,0BAAO,GAAG;AACpC;AAAA,YACD;AACA,kBAAM,MAAM,MACX,QAAQ,CAAC,UAAU;AAClB,oBAAM,EAAE,KAAK,OAAO,IAAI;AACxB,kBAAI,QAAQ;AACX,sBAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AACnC,sBAAM,UAAU,MAAM,SAAS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;AAAA,IAC3D;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;;;AC/BO,IAAM,wBAAwB,CACpC,QAAe,SAAS,UAC6B;AACrD,QAAM,2BAA2B;AAAA,IAIhC;AAAA,MACC,KAAK;AAAA,MACL,SAAS,MAAM,CAAC;AAAA,MAChB,SAAS,CAAC,QAAQ;AAAA,QACjB,CAAC,EAAE,QAAQ,MAAM;AAChB,gBAAM,KAAK,MAAM,aAAa,IAAI,GAAG;AACrC,mCAAI,QAAQ,UAAU,iBAAiB,CAAC,sBAAsB;AAC7D,gBAAI,kBAAkB,QAAQ,KAAK;AAClC,sBAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,iBAAiB,CAAC;AAAA,YACjD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,EACD;AACA,QAAM,gCAAgC;AAAA,IAIrC;AAAA,MACC,KAAK;AAAA,MACL,KACC,CAAC,QACD,CAAC,EAAE,IAAI,MACN,IAAI,yBAAyB,GAAG,CAAC;AAAA,IACpC;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;;;AC1BO,IAAM,4BAA4B,CACxC,QAAiC,SAAS,UAQtC;AACJ,SAAO;AAAA,IACN,WAAW,gBAAgB,KAAK;AAAA,IAChC,eAAe,oBAAoB,KAAK;AAAA,IACxC,kBAAkB,uBAAuB,KAAK;AAAA,IAC9C,yBAAyB,sBAAsB,KAAK;AAAA,IACpD,eAAe,oBAAoB,KAAK;AAAA,IACxC,mBAAmB,qBAAqB,KAAK;AAAA,EAC9C;AACD","sourcesContent":["import type { AtomToken, ReadonlySelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, newest } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\n\nexport const attachAtomIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<AtomTokenIndex> => {\n\tconst atomTokenIndexState__INTERNAL = createAtom<AtomTokenIndex>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Atom Token Index (Internal)`,\n\t\t\tdefault: () => {\n\t\t\t\tconst defaultAtomIndex = [...store.atoms]\n\t\t\t\t\t.filter(([key]) => !key.includes(`👁‍🗨`))\n\t\t\t\t\t.reduce<AtomTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\tacc[key] = { key, type: `atom` }\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, {})\n\t\t\t\treturn defaultAtomIndex\n\t\t\t},\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.atomCreation.subscribe(`introspection`, (atomToken) => {\n\t\t\t\t\t\tif (atomToken.key.includes(`👁‍🗨`)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\tconst { key, family } = atomToken\n\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: atomToken,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t[key]: atomToken,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\tif (newest(store).operation.open) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection: waiting to update atom index`,\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `👁‍🗨 Atom Token Index`,\n\t\t\tget: ({ get }) => get(atomTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","import type { ReadonlySelectorToken, SelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, newest } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type SelectorTokenIndex = StateTokenIndex<\n\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachSelectorIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n\tconst readonlySelectorTokenIndexState__INTERNAL =\n\t\tcreateAtom<SelectorTokenIndex>(\n\t\t\t{\n\t\t\t\tkey: `👁‍🗨 Selector Token Index (Internal)`,\n\t\t\t\tdefault: () =>\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t[...store.readonlySelectors]\n\t\t\t\t\t\t\t.filter(([key]) => !key.includes(`👁‍🗨`))\n\t\t\t\t\t\t\t.reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\t\tacc[key] = { key, type: `readonly_selector` }\n\t\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\tacc[key] = { key, type: `selector` }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t),\n\t\t\t\teffects: [\n\t\t\t\t\t({ setSelf }) => {\n\t\t\t\t\t\tstore.subject.selectorCreation.subscribe(\n\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t(selectorToken) => {\n\t\t\t\t\t\t\t\tif (selectorToken.key.includes(`👁‍🗨`)) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\t\t\tconst { key, family } = selectorToken\n\t\t\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[key]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\tif (newest(store).operation.open) {\n\t\t\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t\t\t`introspection: waiting to update selector index`,\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `👁‍🗨 Selector Token Index`,\n\t\t\tget: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tIMPLICIT.STORE,\n\t)\n}\n","import type { ReadonlySelectorFamily } from \"atom.io\"\nimport type { Store, Timeline } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tSubject,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTimelineFamily = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<Timeline> => {\n\tconst findTimelineLogState__INTERNAL = createAtomFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Timeline Update Log (Internal)`,\n\t\t\tdefault: (key) =>\n\t\t\t\tstore.timelines.get(key) ?? {\n\t\t\t\t\ttype: `timeline`,\n\t\t\t\t\tkey: ``,\n\t\t\t\t\tat: 0,\n\t\t\t\t\ttimeTraveling: null,\n\t\t\t\t\thistory: [],\n\t\t\t\t\tselectorTime: null,\n\t\t\t\t\ttransactionKey: null,\n\t\t\t\t\tinstall: () => {},\n\t\t\t\t\tsubject: new Subject(),\n\t\t\t\t},\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tl = store.timelines.get(key)\n\t\t\t\t\ttl?.subject.subscribe(`introspection`, (_) => {\n\t\t\t\t\t\tif (store.operation.open === true) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t\t(operationStatus) => {\n\t\t\t\t\t\t\t\t\tif (operationStatus.open === false) {\n\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTimelineLogState = createSelectorFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Timeline Update Log`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\tget(findTimelineLogState__INTERNAL(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTimelineLogState\n}\n","import type { ReadonlySelectorToken, TimelineToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTimelineIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TimelineToken[]> => {\n\tconst timelineTokenIndexState__INTERNAL = createAtom<TimelineToken[]>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Timeline Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.timelines].map(([key]): TimelineToken => {\n\t\t\t\t\treturn { key, type: `timeline` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.timelineCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(timelineToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, timelineToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst timelineTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `👁‍🗨 Timeline Token Index`,\n\t\t\tget: ({ get }) => get(timelineTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn timelineTokenIndex\n}\n","import type { ReadonlySelectorToken, TransactionToken, ƒn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTransactionIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {\n\tconst transactionTokenIndexState__INTERNAL = createAtom<\n\t\tTransactionToken<ƒn>[]\n\t>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Transaction Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.transactions].map(([key]): TransactionToken<ƒn> => {\n\t\t\t\t\treturn { key, type: `transaction` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.transactionCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(transactionToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst transactionTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `👁‍🗨 Transaction Token Index`,\n\t\t\tget: ({ get }) => get(transactionTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn transactionTokenIndex\n}\n","import type { ReadonlySelectorFamily, TransactionUpdate, ƒn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTransactionLogs = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<TransactionUpdate<ƒn>[]> => {\n\tconst findTransactionUpdateLog = createAtomFamily<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Transaction Update Log (Internal)`,\n\t\t\tdefault: () => [],\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tx = store.transactions.get(key)\n\t\t\t\t\ttx?.subject.subscribe(`introspection`, (transactionUpdate) => {\n\t\t\t\t\t\tif (transactionUpdate.key === key) {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionUpdate])\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTransactionUpdateLogState = createSelectorFamily<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁‍🗨 Transaction Update Log`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\tget(findTransactionUpdateLog(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTransactionUpdateLogState\n}\n","import type {\n\tReadonlySelectorFamily,\n\tReadonlySelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tƒn,\n} from \"atom.io\"\nimport * as Internal from \"atom.io/internal\"\nimport type { Timeline } from \"atom.io/internal\"\n\nimport { type AtomTokenIndex, attachAtomIndex } from \"./attach-atom-index\"\nimport type { SelectorTokenIndex } from \"./attach-selector-index\"\nimport { attachSelectorIndex } from \"./attach-selector-index\"\nimport { attachTimelineFamily } from \"./attach-timeline-family\"\nimport { attachTimelineIndex } from \"./attach-timeline-index\"\nimport { attachTransactionIndex } from \"./attach-transaction-index\"\nimport { attachTransactionLogs } from \"./attach-transaction-logs\"\n\nexport const attachIntrospectionStates = (\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): {\n\tatomIndex: ReadonlySelectorToken<AtomTokenIndex>\n\tselectorIndex: ReadonlySelectorToken<SelectorTokenIndex>\n\ttransactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>\n\tfindTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>\n\ttimelineIndex: ReadonlySelectorToken<TimelineToken[]>\n\tfindTimelineState: ReadonlySelectorFamily<Timeline>\n} => {\n\treturn {\n\t\tatomIndex: attachAtomIndex(store),\n\t\tselectorIndex: attachSelectorIndex(store),\n\t\ttransactionIndex: attachTransactionIndex(store),\n\t\tfindTransactionLogState: attachTransactionLogs(store),\n\t\ttimelineIndex: attachTimelineIndex(store),\n\t\tfindTimelineState: attachTimelineFamily(store),\n\t}\n}\n"]}
@@ -0,0 +1,67 @@
1
+ import { useI, StoreContext } from './chunk-LFXB7Y6M.js';
2
+ import { myIdState__INTERNAL, pullState, pullFamilyMember, pullMutableState, pullMutableFamilyMember, pushState, synchronizeTransactionResults } from './chunk-5VJ77LZE.js';
3
+ import { runTransaction } from './chunk-TE3ZSTQ6.js';
4
+ import * as React6 from 'react';
5
+ import { io } from 'socket.io-client';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ var RealtimeContext = React6.createContext({
9
+ socket: io()
10
+ });
11
+ var RealtimeProvider = ({ children, socket }) => {
12
+ const setMyId = useI(myIdState__INTERNAL);
13
+ React6.useEffect(() => {
14
+ socket.on(`connect`, () => {
15
+ setMyId(socket.id);
16
+ });
17
+ socket.on(`disconnect`, () => {
18
+ setMyId(null);
19
+ });
20
+ }, [socket, setMyId]);
21
+ return /* @__PURE__ */ jsx(RealtimeContext.Provider, { value: { socket }, children });
22
+ };
23
+ function usePull(token) {
24
+ const { socket } = React6.useContext(RealtimeContext);
25
+ const store = React6.useContext(StoreContext);
26
+ React6.useEffect(() => pullState(token, socket, store), [token.key]);
27
+ }
28
+ function usePullFamilyMember(token) {
29
+ const { socket } = React6.useContext(RealtimeContext);
30
+ const store = React6.useContext(StoreContext);
31
+ React6.useEffect(() => pullFamilyMember(token, socket, store), [token.key]);
32
+ }
33
+ function usePullMutable(token) {
34
+ const { socket } = React6.useContext(RealtimeContext);
35
+ const store = React6.useContext(StoreContext);
36
+ React6.useEffect(() => pullMutableState(token, socket, store), [token.key]);
37
+ }
38
+ function usePullMutableFamilyMember(token) {
39
+ const { socket } = React6.useContext(RealtimeContext);
40
+ const store = React6.useContext(StoreContext);
41
+ React6.useEffect(
42
+ () => pullMutableFamilyMember(token, socket, store),
43
+ [token.key]
44
+ );
45
+ }
46
+ function usePush(token) {
47
+ const { socket } = React6.useContext(RealtimeContext);
48
+ const store = React6.useContext(StoreContext);
49
+ const id = React6.useId();
50
+ React6.useEffect(
51
+ () => pushState(token, socket, `use-push:${id}`, store),
52
+ [token.key]
53
+ );
54
+ }
55
+ function useServerAction(token) {
56
+ const store = React6.useContext(StoreContext);
57
+ const { socket } = React6.useContext(RealtimeContext);
58
+ React6.useEffect(
59
+ () => synchronizeTransactionResults(token, socket, store),
60
+ [token.key]
61
+ );
62
+ return runTransaction(token, store);
63
+ }
64
+
65
+ export { RealtimeContext, RealtimeProvider, usePull, usePullFamilyMember, usePullMutable, usePullMutableFamilyMember, usePush, useServerAction };
66
+ //# sourceMappingURL=out.js.map
67
+ //# sourceMappingURL=chunk-KW7RA7IM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../realtime-react/src/realtime-context.tsx","../realtime-react/src/use-pull.ts","../realtime-react/src/use-pull-family-member.ts","../realtime-react/src/use-pull-mutable.ts","../realtime-react/src/use-pull-mutable-family-member.ts","../realtime-react/src/use-push.ts","../realtime-react/src/use-server-action.ts"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,YAAY,WAAW;AAEvB,SAAS,UAAU;AAoBjB;AAlBK,IAAM,kBAAwB,oBAAkC;AAAA,EACtE,QAAQ,GAAG;AACZ,CAAC;AAEM,IAAM,mBAGR,CAAC,EAAE,UAAU,OAAO,MAAM;AAC9B,QAAM,UAAU,KAAS,mBAAmB;AAC5C,EAAM,gBAAU,MAAM;AACrB,WAAO,GAAG,WAAW,MAAM;AAC1B,cAAQ,OAAO,EAAE;AAAA,IAClB,CAAC;AACD,WAAO,GAAG,cAAc,MAAM;AAC7B,cAAQ,IAAI;AAAA,IACb,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SACC,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,OAAO,GACxC,UACF;AAEF;;;ACxBA,YAAYA,YAAW;AAIhB,SAAS,QACf,OACO;AACP,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY;AAC3C,EAAM,iBAAU,MAAU,UAAU,OAAO,QAAQ,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC;AACvE;;;ACVA,YAAYA,YAAW;AAIhB,SAAS,oBACf,OACO;AACP,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY;AAC3C,EAAM,iBAAU,MAAU,iBAAiB,OAAO,QAAQ,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC;AAC9E;;;ACTA,YAAYA,YAAW;AAIhB,SAAS,eAGd,OAA4C;AAC7C,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY;AAC3C,EAAM,iBAAU,MAAU,iBAAiB,OAAO,QAAQ,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC;AAC9E;;;ACXA,YAAYA,YAAW;AAIhB,SAAS,2BAGd,OAA4C;AAC7C,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY;AAC3C,EAAM;AAAA,IACL,MAAU,wBAAwB,OAAO,QAAQ,KAAK;AAAA,IACtD,CAAC,MAAM,GAAG;AAAA,EACX;AACD;;;ACfA,YAAYA,YAAW;AAIhB,SAAS,QACf,OACO;AACP,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,EAAM;AAAA,IACL,MAAU,UAAU,OAAO,QAAQ,YAAY,EAAE,IAAI,KAAK;AAAA,IAC1D,CAAC,MAAM,GAAG;AAAA,EACX;AACD;;;ACfA,YAAYA,YAAW;AAIhB,SAAS,gBACf,OACkD;AAClD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,EAAM;AAAA,IACL,MAAU,8BAA8B,OAAO,QAAQ,KAAK;AAAA,IAC5D,CAAC,MAAM,GAAG;AAAA,EACX;AACA,SAAc,eAAe,OAAO,KAAK;AAC1C","sourcesContent":["import { useI } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\nimport type { Socket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport const RealtimeContext = React.createContext<{ socket: Socket }>({\n\tsocket: io(),\n})\n\nexport const RealtimeProvider: React.FC<{\n\tchildren: React.ReactNode\n\tsocket: Socket\n}> = ({ children, socket }) => {\n\tconst setMyId = useI(RTC.myIdState__INTERNAL)\n\tReact.useEffect(() => {\n\t\tsocket.on(`connect`, () => {\n\t\t\tsetMyId(socket.id)\n\t\t})\n\t\tsocket.on(`disconnect`, () => {\n\t\t\tsetMyId(null)\n\t\t})\n\t}, [socket, setMyId])\n\treturn (\n\t\t<RealtimeContext.Provider value={{ socket }}>\n\t\t\t{children}\n\t\t</RealtimeContext.Provider>\n\t)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePull<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullState(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullFamilyMember<J extends Json.Serializable>(\n\ttoken: AtomIO.AtomToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullFamilyMember(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullMutable<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(token: AtomIO.MutableAtomToken<T, J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(() => RTC.pullMutableState(token, socket, store), [token.key])\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePullMutableFamilyMember<\n\tT extends Transceiver<Json.Serializable>,\n\tJ extends Json.Serializable,\n>(token: AtomIO.MutableAtomToken<T, J>): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tReact.useEffect(\n\t\t() => RTC.pullMutableFamilyMember(token, socket, store),\n\t\t[token.key],\n\t)\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function usePush<J extends Json.Serializable>(\n\ttoken: AtomIO.StateToken<J>,\n): void {\n\tconst { socket } = React.useContext(RealtimeContext)\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tReact.useEffect(\n\t\t() => RTC.pushState(token, socket, `use-push:${id}`, store),\n\t\t[token.key],\n\t)\n}\n","import * as AtomIO from \"atom.io\"\nimport { StoreContext } from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-client\"\nimport * as React from \"react\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nexport function useServerAction<ƒ extends AtomIO.ƒn>(\n\ttoken: AtomIO.TransactionToken<ƒ>,\n): (...parameters: Parameters<ƒ>) => ReturnType<ƒ> {\n\tconst store = React.useContext(StoreContext)\n\tconst { socket } = React.useContext(RealtimeContext)\n\tReact.useEffect(\n\t\t() => RTC.synchronizeTransactionResults(token, socket, store),\n\t\t[token.key],\n\t)\n\treturn AtomIO.runTransaction(token, store)\n}\n"]}
@@ -0,0 +1,68 @@
1
+ import { IMPLICIT, setState, subscribeToState, getState, getJsonToken, withdraw, undo, redo, subscribeToTimeline } from './chunk-TE3ZSTQ6.js';
2
+ import * as React2 from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var StoreContext = React2.createContext(IMPLICIT.STORE);
6
+ var StoreProvider = ({ children, store = IMPLICIT.STORE }) => /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children });
7
+ function useI(token) {
8
+ const store = React2.useContext(StoreContext);
9
+ const setter = React2.useRef(null);
10
+ if (setter.current === null) {
11
+ setter.current = (next) => setState(token, next, store);
12
+ }
13
+ return setter.current;
14
+ }
15
+ function useO(token) {
16
+ const store = React2.useContext(StoreContext);
17
+ const id = React2.useId();
18
+ return React2.useSyncExternalStore(
19
+ (dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),
20
+ () => getState(token, store),
21
+ () => getState(token, store)
22
+ );
23
+ }
24
+ function useJSON(token) {
25
+ const jsonToken = getJsonToken(token);
26
+ return useO(jsonToken);
27
+ }
28
+ function useTL(token) {
29
+ const store = React2.useContext(StoreContext);
30
+ const id = React2.useId();
31
+ const timeline = withdraw(token, store);
32
+ if (timeline === void 0) {
33
+ store.logger.error(
34
+ `\u274C`,
35
+ `timeline`,
36
+ token.key,
37
+ `Failed to use timeline because it does not exist`
38
+ );
39
+ return {
40
+ at: NaN,
41
+ length: NaN,
42
+ undo: () => {
43
+ },
44
+ redo: () => {
45
+ }
46
+ };
47
+ }
48
+ const meta = React2.useRef({
49
+ at: timeline.at,
50
+ length: timeline.history.length,
51
+ undo: () => undo(token),
52
+ redo: () => redo(token)
53
+ });
54
+ const retrieve = React2.useCallback(() => {
55
+ meta.current.at = timeline.at;
56
+ meta.current.length = timeline.history.length;
57
+ return meta.current;
58
+ }, [meta]);
59
+ return React2.useSyncExternalStore(
60
+ (dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
61
+ retrieve,
62
+ retrieve
63
+ );
64
+ }
65
+
66
+ export { StoreContext, StoreProvider, useI, useJSON, useO, useTL };
67
+ //# sourceMappingURL=out.js.map
68
+ //# sourceMappingURL=chunk-LFXB7Y6M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../react/src/store-context.tsx","../react/src/store-hooks.ts"],"names":["React"],"mappings":";;;;;;;;;;;;;AAEA,YAAY,WAAW;AAQtB;AANM,IAAM,eAAqB,oBAAqB,SAAS,KAAK;AAE9D,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAQ,SAAS,MAAM,MACxC,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACVhD,YAAYA,YAAW;AAmBhB,SAAS,KACf,OACyD;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAEI,cAAO,IAAI;AACrB,MAAI,OAAO,YAAY,MAAM;AAC5B,WAAO,UAAU,CAAC,SAAS,SAAS,OAAO,MAAM,KAAK;AAAA,EACvD;AACA,SAAO,OAAO;AACf;AAEO,SAAS,KAAQ,OAAoD;AAC3E,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,SAAa;AAAA,IACZ,CAAC,aAAa,iBAAiB,OAAO,UAAU,SAAS,EAAE,IAAI,KAAK;AAAA,IACpE,MAAM,SAAS,OAAO,KAAK;AAAA,IAC3B,MAAM,SAAS,OAAO,KAAK;AAAA,EAC5B;AACD;AAEO,SAAS,QACf,OACe;AACf,QAAM,YAAY,aAAa,KAAK;AACpC,SAAO,KAAK,SAAS;AACtB;AASO,SAAS,MAAM,OAAoC;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,QAAM,WAAW,SAAS,OAAO,KAAK;AACtC,MAAI,aAAa,QAAW;AAC3B,UAAM,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACD;AACA,WAAO;AAAA,MACN,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,MAAM,MAAM;AAAA,MAAC;AAAA,MACb,MAAM,MAAM;AAAA,MAAC;AAAA,IACd;AAAA,EACD;AACA,QAAM,OAAa,cAAqB;AAAA,IACvC,IAAI,SAAS;AAAA,IACb,QAAQ,SAAS,QAAQ;AAAA,IACzB,MAAM,MAAM,KAAK,KAAK;AAAA,IACtB,MAAM,MAAM,KAAK,KAAK;AAAA,EACvB,CAAC;AACD,QAAM,WAAiB,mBAAY,MAAM;AACxC,SAAK,QAAQ,KAAK,SAAS;AAC3B,SAAK,QAAQ,SAAS,SAAS,QAAQ;AACvC,WAAO,KAAK;AAAA,EACb,GAAG,CAAC,IAAI,CAAC;AACT,SAAa;AAAA,IACZ,CAAC,aAAa,oBAAoB,OAAO,UAAU,UAAU,EAAE,IAAI,KAAK;AAAA,IACxE;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<Store>(IMPLICIT.STORE)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: Store\n}> = ({ children, store = IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as React from \"react\"\n\nimport { getState, redo, setState, undo } from \"atom.io\"\nimport type {\n\tMutableAtomToken,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n} from \"atom.io\"\n\nimport {\n\tgetJsonToken,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\twithdraw,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: StateToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst setter: React.MutableRefObject<\n\t\t(<New extends T>(next: New | ((old: T) => New)) => void) | null\n\t> = React.useRef(null)\n\tif (setter.current === null) {\n\t\tsetter.current = (next) => setState(token, next, store)\n\t}\n\treturn setter.current\n}\n\nexport function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),\n\t\t() => getState(token, store),\n\t\t() => getState(token, store),\n\t)\n}\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable {\n\tconst jsonToken = getJsonToken(token)\n\treturn useO(jsonToken)\n}\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken): TimelineMeta {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tconst timeline = withdraw(token, store)\n\tif (timeline === undefined) {\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to use timeline because it does not exist`,\n\t\t)\n\t\treturn {\n\t\t\tat: NaN,\n\t\t\tlength: NaN,\n\t\t\tundo: () => {},\n\t\t\tredo: () => {},\n\t\t}\n\t}\n\tconst meta = React.useRef<TimelineMeta>({\n\t\tat: timeline.at,\n\t\tlength: timeline.history.length,\n\t\tundo: () => undo(token),\n\t\tredo: () => redo(token),\n\t})\n\tconst retrieve = React.useCallback(() => {\n\t\tmeta.current.at = timeline.at\n\t\tmeta.current.length = timeline.history.length\n\t\treturn meta.current\n\t}, [meta])\n\treturn React.useSyncExternalStore<TimelineMeta>(\n\t\t(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),\n\t\tretrieve,\n\t\tretrieve,\n\t)\n}\n"]}