atom.io 0.6.3 → 0.6.5

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 (62) hide show
  1. package/dist/index.d.mts +25 -13
  2. package/dist/index.d.ts +25 -13
  3. package/dist/index.js +106 -50
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +103 -47
  6. package/dist/index.mjs.map +1 -1
  7. package/json/package.json +13 -13
  8. package/package.json +23 -15
  9. package/react/dist/index.d.mts +1 -1
  10. package/react/dist/index.d.ts +1 -1
  11. package/react/dist/index.js +8 -4
  12. package/react/dist/index.js.map +1 -1
  13. package/react/dist/index.mjs +8 -4
  14. package/react/dist/index.mjs.map +1 -1
  15. package/react/package.json +13 -13
  16. package/react-devtools/dist/index.js +693 -181
  17. package/react-devtools/dist/index.js.map +1 -1
  18. package/react-devtools/dist/index.mjs +689 -177
  19. package/react-devtools/dist/index.mjs.map +1 -1
  20. package/react-devtools/package.json +13 -13
  21. package/realtime/dist/index.js.map +1 -1
  22. package/realtime/dist/index.mjs.map +1 -1
  23. package/realtime/package.json +13 -13
  24. package/realtime-react/dist/index.js +14 -10
  25. package/realtime-react/dist/index.js.map +1 -1
  26. package/realtime-react/dist/index.mjs +14 -10
  27. package/realtime-react/dist/index.mjs.map +1 -1
  28. package/realtime-react/package.json +13 -13
  29. package/realtime-testing/dist/index.d.mts +1 -1
  30. package/realtime-testing/dist/index.d.ts +1 -1
  31. package/realtime-testing/dist/index.js +14 -2
  32. package/realtime-testing/dist/index.js.map +1 -1
  33. package/realtime-testing/dist/index.mjs +14 -2
  34. package/realtime-testing/dist/index.mjs.map +1 -1
  35. package/realtime-testing/package.json +13 -13
  36. package/src/atom.ts +2 -3
  37. package/src/internal/atom-internal.ts +3 -3
  38. package/src/internal/families-internal.ts +4 -5
  39. package/src/internal/index.ts +1 -0
  40. package/src/internal/selector/create-read-write-selector.ts +2 -2
  41. package/src/internal/selector/create-readonly-selector.ts +2 -2
  42. package/src/internal/selector-internal.ts +3 -4
  43. package/src/internal/store.ts +10 -10
  44. package/src/internal/subject.ts +24 -0
  45. package/src/internal/timeline-internal.ts +3 -4
  46. package/src/internal/transaction-internal.ts +3 -3
  47. package/src/react/store-context.tsx +1 -2
  48. package/src/react/store-hooks.ts +1 -2
  49. package/src/react-devtools/AtomIODevtools.tsx +2 -3
  50. package/src/react-devtools/StateEditor.tsx +1 -2
  51. package/src/react-devtools/TokenList.tsx +2 -3
  52. package/src/react-explorer/AtomIOExplorer.tsx +1 -2
  53. package/src/react-explorer/explorer-effects.ts +3 -3
  54. package/src/react-explorer/space-states.ts +3 -3
  55. package/src/realtime-react/realtime-context.tsx +1 -2
  56. package/src/realtime-react/use-pull-family-member.ts +1 -2
  57. package/src/realtime-react/use-pull-family.ts +1 -2
  58. package/src/realtime-react/use-pull.ts +1 -2
  59. package/src/realtime-react/use-push.ts +1 -2
  60. package/src/realtime-react/use-server-action.ts +1 -2
  61. package/src/realtime-testing/setup-realtime-test.tsx +1 -2
  62. package/src/selector.ts +3 -4
package/dist/index.mjs CHANGED
@@ -42,6 +42,7 @@ var internal_exports = {};
42
42
  __export(internal_exports, {
43
43
  IMPLICIT: () => IMPLICIT,
44
44
  META: () => meta_exports,
45
+ Subject: () => Subject,
45
46
  TRANSACTION_PHASES: () => TRANSACTION_PHASES,
46
47
  abortTransaction: () => abortTransaction,
47
48
  applyTransaction: () => applyTransaction,
@@ -99,7 +100,6 @@ __export(internal_exports, {
99
100
 
100
101
  // src/internal/atom-internal.ts
101
102
  import HAMT5 from "hamt_plus";
102
- import * as Rx3 from "rxjs";
103
103
 
104
104
  // src/internal/get.ts
105
105
  import HAMT from "hamt_plus";
@@ -160,7 +160,6 @@ import HAMT3 from "hamt_plus";
160
160
 
161
161
  // src/internal/store.ts
162
162
  import HAMT2 from "hamt_plus";
163
- import * as Rx from "rxjs";
164
163
 
165
164
  // ../anvl/src/function/index.ts
166
165
  var doNothing = () => void 0;
@@ -169,8 +168,62 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
169
168
  ) : nextVersionOfThing;
170
169
  var pass = (...params) => (fn) => fn(...params);
171
170
 
172
- // ../anvl/src/join/core-relation-data.ts
173
- import { isString } from "fp-ts/string";
171
+ // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/function.js
172
+ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
173
+ switch (arguments.length) {
174
+ case 1:
175
+ return a;
176
+ case 2:
177
+ return ab(a);
178
+ case 3:
179
+ return bc(ab(a));
180
+ case 4:
181
+ return cd(bc(ab(a)));
182
+ case 5:
183
+ return de(cd(bc(ab(a))));
184
+ case 6:
185
+ return ef(de(cd(bc(ab(a)))));
186
+ case 7:
187
+ return fg(ef(de(cd(bc(ab(a))))));
188
+ case 8:
189
+ return gh(fg(ef(de(cd(bc(ab(a)))))));
190
+ case 9:
191
+ return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
192
+ default: {
193
+ var ret = arguments[0];
194
+ for (var i = 1; i < arguments.length; i++) {
195
+ ret = arguments[i](ret);
196
+ }
197
+ return ret;
198
+ }
199
+ }
200
+ }
201
+
202
+ // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/string.js
203
+ var Eq = {
204
+ equals: function(first, second) {
205
+ return first === second;
206
+ }
207
+ };
208
+ var Semigroup = {
209
+ concat: function(first, second) {
210
+ return first + second;
211
+ }
212
+ };
213
+ var empty = "";
214
+ var Monoid = {
215
+ concat: Semigroup.concat,
216
+ empty
217
+ };
218
+ var Ord = {
219
+ equals: Eq.equals,
220
+ compare: function(first, second) {
221
+ return first < second ? -1 : first > second ? 1 : 0;
222
+ }
223
+ };
224
+ var isString = function(u) {
225
+ return typeof u === "string";
226
+ };
174
227
 
175
228
  // ../anvl/src/array/venn.ts
176
229
  var includesAll = (items) => (array) => {
@@ -191,9 +244,6 @@ var addTo = (a) => (x) => a.includes(x) ? a : [...a, x];
191
244
  var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
192
245
  var isOneOf = (...args) => (input) => args.includes(input);
193
246
 
194
- // ../anvl/src/object/refinement.ts
195
- import { pipe as pipe2 } from "fp-ts/function";
196
-
197
247
  // ../anvl/src/object/access.ts
198
248
  var access = (k) => Object.assign((obj) => obj[k], {
199
249
  in: (obj) => obj[k]
@@ -204,7 +254,6 @@ var recordToEntries = (obj) => Object.entries(obj);
204
254
  var entriesToRecord = (entries) => Object.fromEntries(entries);
205
255
 
206
256
  // ../anvl/src/object/mapObject.ts
207
- import { pipe } from "fp-ts/function";
208
257
  var mapObject = (obj, fn) => pipe(
209
258
  obj,
210
259
  recordToEntries,
@@ -227,14 +276,14 @@ var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
227
276
  isValue
228
277
  ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
229
278
  const _ = {
230
- [name]: (input) => isPlainObject(input) && pipe2(
279
+ [name]: (input) => isPlainObject(input) && pipe(
231
280
  isValue,
232
281
  Object.entries,
233
282
  every(([key, val]) => key in input || val(void 0))
234
- ) && pipe2(
283
+ ) && pipe(
235
284
  input,
236
285
  mob(
237
- (val, key) => pipe2(
286
+ (val, key) => pipe(
238
287
  isValue,
239
288
  access(key),
240
289
  ifNullish(() => options.allowExtraProperties),
@@ -352,9 +401,6 @@ var makeJsonInterface = (join, ...params) => {
352
401
  };
353
402
  };
354
403
 
355
- // ../anvl/src/join/relation-contents.ts
356
- import { pipe as pipe5 } from "fp-ts/function";
357
-
358
404
  // ../anvl/src/join/relation-record.ts
359
405
  var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
360
406
  idB,
@@ -362,12 +408,7 @@ var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).m
362
408
  ]);
363
409
  var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
364
410
 
365
- // ../anvl/src/join/remove-relation.ts
366
- import { pipe as pipe4 } from "fp-ts/function";
367
- import { isString as isString2 } from "fp-ts/string";
368
-
369
411
  // ../anvl/src/object/index.ts
370
- import { pipe as pipe3 } from "fp-ts/function";
371
412
  var treeShake = (shouldDiscard = isUndefined) => (obj) => {
372
413
  const newObj = {};
373
414
  const entries = Object.entries(obj);
@@ -384,7 +425,7 @@ var split = (separator) => (str) => str.split(separator);
384
425
  var removeSpecific = (current, idA, idB) => {
385
426
  const isIdForRemoval = isOneOf(idA, idB);
386
427
  return __spreadProps(__spreadValues({}, current), {
387
- relations: pipe4(
428
+ relations: pipe(
388
429
  current.relations,
389
430
  recordToEntries,
390
431
  map(([id, relations]) => [
@@ -394,17 +435,17 @@ var removeSpecific = (current, idA, idB) => {
394
435
  entriesToRecord,
395
436
  treeShake(isEmptyArray)
396
437
  ),
397
- contents: pipe4(
438
+ contents: pipe(
398
439
  current.contents,
399
440
  treeShake(
400
- (_, key) => isString2(key) && pipe4(key, split(`/`), comprises([idA, idB]))
441
+ (_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))
401
442
  )
402
443
  )
403
444
  });
404
445
  };
405
446
  var removeAll = (current, idToRemove) => {
406
447
  const next = __spreadProps(__spreadValues({}, current), {
407
- relations: pipe4(
448
+ relations: pipe(
408
449
  current.relations,
409
450
  recordToEntries,
410
451
  map(([id, relations]) => [
@@ -414,10 +455,10 @@ var removeAll = (current, idToRemove) => {
414
455
  entriesToRecord,
415
456
  treeShake((val, key) => key === idToRemove || isEmptyArray(val))
416
457
  ),
417
- contents: pipe4(
458
+ contents: pipe(
418
459
  current.contents,
419
460
  treeShake(
420
- (_, key) => isString2(key) && key.split(`/`).includes(idToRemove)
461
+ (_, key) => isString(key) && key.split(`/`).includes(idToRemove)
421
462
  )
422
463
  )
423
464
  });
@@ -499,7 +540,7 @@ var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
499
540
  var setRelations = (current, subject, relations) => {
500
541
  const idA = subject[current.a];
501
542
  const idB = subject[current.b];
502
- return pipe5(
543
+ return pipe(
503
544
  current,
504
545
  (relationData) => {
505
546
  const relatedIds = getRelatedIds(current, idA);
@@ -627,10 +668,10 @@ var createStore = (name, store = null) => {
627
668
  timelines: HAMT2.make(),
628
669
  timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
629
670
  subject: __spreadValues({
630
- atomCreation: new Rx.Subject(),
631
- selectorCreation: new Rx.Subject(),
632
- transactionCreation: new Rx.Subject(),
633
- timelineCreation: new Rx.Subject()
671
+ atomCreation: new Subject(),
672
+ selectorCreation: new Subject(),
673
+ transactionCreation: new Subject(),
674
+ timelineCreation: new Subject()
634
675
  }, store == null ? void 0 : store.subject),
635
676
  operation: __spreadValues({
636
677
  open: false
@@ -648,7 +689,7 @@ var createStore = (name, store = null) => {
648
689
  })
649
690
  });
650
691
  store == null ? void 0 : store.atoms.forEach((atom2) => {
651
- const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Rx.Subject() });
692
+ const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
652
693
  copiedStore.atoms = HAMT2.set(atom2.key, copiedAtom, copiedStore.atoms);
653
694
  });
654
695
  store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
@@ -771,7 +812,6 @@ var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
771
812
 
772
813
  // src/internal/transaction-internal.ts
773
814
  import HAMT4 from "hamt_plus";
774
- import * as Rx2 from "rxjs";
775
815
  function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
776
816
  const newTransaction = {
777
817
  key: options.key,
@@ -796,7 +836,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
796
836
  }
797
837
  },
798
838
  install: (store2) => transaction__INTERNAL(options, store2),
799
- subject: new Rx2.Subject()
839
+ subject: new Subject()
800
840
  };
801
841
  const core = target(store);
802
842
  core.transactions = HAMT4.set(
@@ -821,7 +861,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
821
861
  );
822
862
  return deposit(core.atoms.get(options.key));
823
863
  }
824
- const subject = new Rx3.Subject();
864
+ const subject = new Subject();
825
865
  const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
826
866
  subject,
827
867
  type: `atom`
@@ -841,16 +881,12 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
841
881
  return token;
842
882
  }
843
883
 
844
- // src/internal/families-internal.ts
845
- import * as Rx4 from "rxjs";
846
-
847
884
  // ../anvl/src/json/index.ts
848
- import { pipe as pipe6 } from "fp-ts/function";
849
885
  var stringifyJson = (json) => JSON.stringify(json);
850
886
 
851
887
  // src/internal/families-internal.ts
852
888
  function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
853
- const subject = new Rx4.Subject();
889
+ const subject = new Subject();
854
890
  return Object.assign(
855
891
  (key) => {
856
892
  var _a;
@@ -879,7 +915,7 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
879
915
  }
880
916
  function readonlySelectorFamily__INTERNAL(options, store) {
881
917
  const core = target(store);
882
- const subject = new Rx4.Subject();
918
+ const subject = new Subject();
883
919
  return Object.assign(
884
920
  (key) => {
885
921
  const subKey = stringifyJson(key);
@@ -911,7 +947,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
911
947
  return readonlySelectorFamily__INTERNAL(options, store);
912
948
  }
913
949
  const core = target(store);
914
- const subject = new Rx4.Subject();
950
+ const subject = new Subject();
915
951
  return Object.assign(
916
952
  (key) => {
917
953
  const subKey = stringifyJson(key);
@@ -1059,10 +1095,9 @@ import HAMT9 from "hamt_plus";
1059
1095
 
1060
1096
  // src/internal/selector/create-read-write-selector.ts
1061
1097
  import HAMT6 from "hamt_plus";
1062
- import * as Rx5 from "rxjs";
1063
1098
  var createReadWriteSelector = (options, family, store, core) => {
1064
1099
  var _a;
1065
- const subject = new Rx5.Subject();
1100
+ const subject = new Subject();
1066
1101
  const { get, set } = registerSelector(options.key, store);
1067
1102
  const getSelf = () => {
1068
1103
  const value = options.get({ get });
@@ -1102,7 +1137,6 @@ var createReadWriteSelector = (options, family, store, core) => {
1102
1137
 
1103
1138
  // src/internal/selector/create-readonly-selector.ts
1104
1139
  import HAMT8 from "hamt_plus";
1105
- import * as Rx6 from "rxjs";
1106
1140
 
1107
1141
  // src/internal/selector/lookup-selector-sources.ts
1108
1142
  var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
@@ -1279,7 +1313,7 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
1279
1313
  // src/internal/selector/create-readonly-selector.ts
1280
1314
  var createReadonlySelector = (options, family, store, core) => {
1281
1315
  var _a;
1282
- const subject = new Rx6.Subject();
1316
+ const subject = new Subject();
1283
1317
  const { get } = registerSelector(options.key, store);
1284
1318
  const getSelf = () => {
1285
1319
  const value = options.get({ get });
@@ -1323,6 +1357,29 @@ function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
1323
1357
  return createReadWriteSelector(options, family, store, core);
1324
1358
  }
1325
1359
 
1360
+ // src/internal/subject.ts
1361
+ var Subject = class {
1362
+ constructor() {
1363
+ this.subscribers = [];
1364
+ }
1365
+ subscribe(subscriber) {
1366
+ this.subscribers.push(subscriber);
1367
+ const unsubscribe = () => this.unsubscribe(subscriber);
1368
+ return { unsubscribe };
1369
+ }
1370
+ unsubscribe(subscriber) {
1371
+ const subscriberIndex = this.subscribers.indexOf(subscriber);
1372
+ if (subscriberIndex !== -1) {
1373
+ this.subscribers.splice(subscriberIndex, 1);
1374
+ }
1375
+ }
1376
+ next(value) {
1377
+ for (const subscriber of this.subscribers) {
1378
+ subscriber(value);
1379
+ }
1380
+ }
1381
+ };
1382
+
1326
1383
  // src/internal/subscribe-internal.ts
1327
1384
  var prepareUpdate = (state, store) => {
1328
1385
  const oldValue = recallState(state, store);
@@ -1462,7 +1519,6 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1462
1519
 
1463
1520
  // src/internal/timeline-internal.ts
1464
1521
  import HAMT10 from "hamt_plus";
1465
- import * as Rx7 from "rxjs";
1466
1522
 
1467
1523
  // src/internal/timeline/add-atom-to-timeline.ts
1468
1524
  var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
@@ -1610,7 +1666,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
1610
1666
  }, data), {
1611
1667
  history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
1612
1668
  install: (store2) => timeline__INTERNAL(options, store2, tl),
1613
- subject: new Rx7.Subject()
1669
+ subject: new Subject()
1614
1670
  });
1615
1671
  const core = target(store);
1616
1672
  for (const tokenOrFamily of options.atoms) {