atom.io 0.41.0 → 0.42.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 (52) hide show
  1. package/dist/internal/index.d.ts +21 -38
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +82 -263
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/main/index.d.ts +18 -36
  6. package/dist/main/index.d.ts.map +1 -1
  7. package/dist/main/index.js +13 -2
  8. package/dist/main/index.js.map +1 -1
  9. package/dist/realtime/index.d.ts +2 -3
  10. package/dist/realtime/index.d.ts.map +1 -1
  11. package/dist/realtime/index.js +1 -1
  12. package/dist/realtime/index.js.map +1 -1
  13. package/dist/realtime-server/index.js +1 -1
  14. package/dist/realtime-server/index.js.map +1 -1
  15. package/dist/realtime-testing/index.js +1 -1
  16. package/dist/struct/index.d.ts +14 -0
  17. package/dist/struct/index.d.ts.map +1 -0
  18. package/dist/struct/index.js +35 -0
  19. package/dist/struct/index.js.map +1 -0
  20. package/dist/transceivers/o-list/index.d.ts +10 -6
  21. package/dist/transceivers/o-list/index.d.ts.map +1 -1
  22. package/dist/transceivers/o-list/index.js +170 -169
  23. package/dist/transceivers/o-list/index.js.map +1 -1
  24. package/dist/transceivers/set-rtx/index.d.ts +1 -0
  25. package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
  26. package/dist/transceivers/set-rtx/index.js.map +1 -1
  27. package/dist/transceivers/u-list/index.d.ts +10 -6
  28. package/dist/transceivers/u-list/index.d.ts.map +1 -1
  29. package/dist/transceivers/u-list/index.js +23 -22
  30. package/dist/transceivers/u-list/index.js.map +1 -1
  31. package/dist/utility-types-aZkJVERa.d.ts +10 -0
  32. package/dist/utility-types-aZkJVERa.d.ts.map +1 -0
  33. package/package.json +13 -9
  34. package/src/internal/index.ts +0 -1
  35. package/src/internal/join/create-join.ts +8 -11
  36. package/src/internal/join/edit-relations-in-store.ts +6 -8
  37. package/src/internal/join/find-relations-in-store.ts +11 -67
  38. package/src/internal/join/get-internal-relations-from-store.ts +11 -5
  39. package/src/internal/join/get-join.ts +7 -9
  40. package/src/internal/join/join-internal.ts +154 -394
  41. package/src/internal/mutable/transceiver.ts +1 -5
  42. package/src/internal/set-state/dispatch-state-update.ts +1 -1
  43. package/src/internal/store/store.ts +1 -1
  44. package/src/main/join.ts +68 -151
  45. package/src/main/realm.ts +4 -4
  46. package/src/realtime/shared-room-store.ts +5 -15
  47. package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +1 -1
  48. package/src/struct/index.ts +1 -0
  49. package/src/{internal → struct}/micro.ts +1 -1
  50. package/src/transceivers/o-list/o-list.ts +175 -171
  51. package/src/transceivers/set-rtx/set-rtx.ts +4 -0
  52. package/src/transceivers/u-list/u-list.ts +37 -33
@@ -1,4 +1,5 @@
1
- import { Subject, enumeration, packValue, unpackValue } from "atom.io/internal";
1
+ import { Subject } from "atom.io/internal";
2
+ import { enumeration, packValue, unpackValue } from "atom.io/struct";
2
3
 
3
4
  //#region src/transceivers/u-list/u-list.ts
4
5
  const SET_UPDATE_ENUM = enumeration([
@@ -6,23 +7,6 @@ const SET_UPDATE_ENUM = enumeration([
6
7
  `delete`,
7
8
  `clear`
8
9
  ]);
9
- function packSetUpdate(update) {
10
- const head = SET_UPDATE_ENUM[update.type] + `\u001F`;
11
- if (update.type === `clear`) return head + update.values.map(packValue).join(`\u001E`);
12
- return head + packValue(update.value);
13
- }
14
- function unpackSetUpdate(packed) {
15
- const [type, tail] = packed.split(`\u001F`);
16
- const head = SET_UPDATE_ENUM[type];
17
- if (head === `clear`) return {
18
- type: `clear`,
19
- values: tail.split(`\u001E`).map(unpackValue)
20
- };
21
- return {
22
- type: head,
23
- value: unpackValue(tail)
24
- };
25
- }
26
10
  var UList = class UList extends Set {
27
11
  mode = `record`;
28
12
  subject = new Subject();
@@ -65,11 +49,11 @@ var UList = class UList extends Set {
65
49
  return this.subject.subscribe(key, fn);
66
50
  }
67
51
  emit(update) {
68
- this.subject.next(packSetUpdate(update));
52
+ this.subject.next(UList.packUpdate(update));
69
53
  }
70
54
  do(packed) {
71
55
  this.mode = `playback`;
72
- const update = unpackSetUpdate(packed);
56
+ const update = UList.unpackUpdate(packed);
73
57
  switch (update.type) {
74
58
  case `add`:
75
59
  this.add(update.value);
@@ -83,7 +67,7 @@ var UList = class UList extends Set {
83
67
  return null;
84
68
  }
85
69
  undo(packed) {
86
- const update = unpackSetUpdate(packed);
70
+ const update = UList.unpackUpdate(packed);
87
71
  this.mode = `playback`;
88
72
  switch (update.type) {
89
73
  case `add`:
@@ -100,8 +84,25 @@ var UList = class UList extends Set {
100
84
  this.mode = `record`;
101
85
  return null;
102
86
  }
87
+ static packUpdate(update) {
88
+ const head = SET_UPDATE_ENUM[update.type] + `\u001F`;
89
+ if (update.type === `clear`) return head + update.values.map(packValue).join(`\u001E`);
90
+ return head + packValue(update.value);
91
+ }
92
+ static unpackUpdate(packed) {
93
+ const [type, tail] = packed.split(`\u001F`);
94
+ const head = SET_UPDATE_ENUM[type];
95
+ if (head === `clear`) return {
96
+ type: `clear`,
97
+ values: tail.split(`\u001E`).map(unpackValue)
98
+ };
99
+ return {
100
+ type: head,
101
+ value: unpackValue(tail)
102
+ };
103
+ }
103
104
  };
104
105
 
105
106
  //#endregion
106
- export { SET_UPDATE_ENUM, UList, packSetUpdate, unpackSetUpdate };
107
+ export { SET_UPDATE_ENUM, UList };
107
108
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]>"],"sources":["../../../src/transceivers/u-list/u-list.ts"],"sourcesContent":["import type {\n\tEnumeration,\n\tFn,\n\tTransceiver,\n\tTransceiverMode,\n} from \"atom.io/internal\"\nimport { enumeration, packValue, Subject, unpackValue } from \"atom.io/internal\"\nimport type { primitive } from \"atom.io/json\"\n\nexport type SetMutations = Exclude<\n\tkeyof Set<any>,\n\tsymbol | keyof ReadonlySet<any>\n>\nexport type SetUpdate<P extends primitive> =\n\t| {\n\t\t\ttype: `add` | `delete`\n\t\t\tvalue: P\n\t }\n\t| {\n\t\t\ttype: `clear`\n\t\t\tvalues: P[]\n\t }\nexport type UListUpdateType = SetUpdate<any>[`type`]\ntrue satisfies SetMutations extends UListUpdateType\n\t? true\n\t: Exclude<SetMutations, UListUpdateType>\n\nexport type PackedSetUpdate<P extends primitive> = string & {\n\tupdate?: SetUpdate<P>\n}\n\nexport const SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]> =\n\tenumeration([`add`, `delete`, `clear`] as const)\n\nexport function packSetUpdate<P extends primitive>(\n\tupdate: SetUpdate<P>,\n): PackedSetUpdate<P> {\n\tconst head = SET_UPDATE_ENUM[update.type] + `\\u001F`\n\tif (update.type === `clear`) {\n\t\treturn head + update.values.map(packValue).join(`\\u001E`)\n\t}\n\treturn head + packValue(update.value)\n}\nexport function unpackSetUpdate<P extends primitive>(\n\tpacked: PackedSetUpdate<P>,\n): SetUpdate<P> {\n\tconst [type, tail] = packed.split(`\\u001F`) as [0 | 1 | 2, string]\n\tconst head = SET_UPDATE_ENUM[type]\n\tif (head === `clear`) {\n\t\tconst values = tail.split(`\\u001E`).map(unpackValue) as P[]\n\t\treturn { type: `clear`, values }\n\t}\n\treturn { type: head, value: unpackValue(tail) as P }\n}\n\nexport type SetMutationHandler = { [K in UListUpdateType]: Fn }\n\nexport class UList<P extends primitive>\n\textends Set<P>\n\timplements\n\t\tTransceiver<ReadonlySet<P>, PackedSetUpdate<P>, ReadonlyArray<P>>,\n\t\tSetMutationHandler\n{\n\tpublic mode: TransceiverMode = `record`\n\tpublic readonly subject: Subject<PackedSetUpdate<P>> = new Subject()\n\n\tpublic constructor(values?: Iterable<P>) {\n\t\tsuper(values)\n\t\tif (values instanceof UList) {\n\t\t}\n\t}\n\n\tpublic readonly READONLY_VIEW: ReadonlySet<P> = this\n\n\tpublic toJSON(): ReadonlyArray<P> {\n\t\treturn [...this]\n\t}\n\n\tpublic static fromJSON<P extends primitive>(json: ReadonlyArray<P>): UList<P> {\n\t\treturn new UList<P>(json)\n\t}\n\n\tpublic add(value: P): this {\n\t\tconst result = super.add(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `add`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic clear(): void {\n\t\tconst capturedContents = this.mode === `record` ? [...this] : null\n\t\tsuper.clear()\n\t\tif (capturedContents) {\n\t\t\tthis.emit({ type: `clear`, values: capturedContents })\n\t\t}\n\t}\n\n\tpublic delete(value: P): boolean {\n\t\tconst result = super.delete(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `delete`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic subscribe(\n\t\tkey: string,\n\t\tfn: (update: PackedSetUpdate<P>) => void,\n\t): () => void {\n\t\treturn this.subject.subscribe(key, fn)\n\t}\n\n\tpublic emit(update: SetUpdate<P>): void {\n\t\tthis.subject.next(packSetUpdate(update))\n\t}\n\n\tpublic do(packed: PackedSetUpdate<P>): null {\n\t\tthis.mode = `playback`\n\t\tconst update = unpackSetUpdate(packed)\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`:\n\t\t\t\tthis.clear()\n\t\t}\n\t\tthis.mode = `record`\n\t\treturn null\n\t}\n\n\tpublic undo(packed: PackedSetUpdate<P>): number | null {\n\t\tconst update = unpackSetUpdate(packed)\n\t\tthis.mode = `playback`\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`: {\n\t\t\t\tconst values = update.values\n\t\t\t\tfor (const v of values) this.add(v)\n\t\t\t}\n\t\t}\n\t\tthis.m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KAAK,SAAS,SACjB,MAAK,KAAK;GAAE,MAAM;GAAU;GAAO,CAAC;AAErC,SAAO;;CAGR,AAAO,UACN,KACA,IACa;AACb,SAAO,KAAK,QAAQ,UAAU,KAAK,GAAG;;CAGvC,AAAO,KAAK,QAA4B;AACvC,OAAK,QAAQ,KAAK,cAAc,OAAO,CAAC;;CAGzC,AAAO,GAAG,QAAkC;AAC3C,OAAK,OAAO;EACZ,MAAM,SAAS,gBAAgB,OAAO;AACtC,UAAQ,OAAO,MAAf;GACC,KAAK;AACJ,SAAK,IAAI,OAAO,MAAM;AACtB;GACD,KAAK;AACJ,SAAK,OAAO,OAAO,MAAM;AACzB;GACD,KAAK,QACJ,MAAK,OAAO;;AAEd,OAAK,OAAO;AACZ,SAAO;;CAGR,AAAO,KAAK,QAA2C;EACtD,MAAM,SAAS,gBAAgB,OAAO;AACtC,OAAK,OAAO;AACZ,UAAQ,OAAO,MAAf;GACC,KAAK;AACJ,SAAK,OAAO,OAAO,MAAM;AACzB;GACD,KAAK;AACJ,SAAK,IAAI,OAAO,MAAM;AACtB;GACD,KAAK,SAAS;IACb,MAAM,SAAS,OAAO;AACtB,SAAK,MAAM,KAAK,OAAQ,MAAK,IAAI,EAAE;;;AAGrC,OAAK,OAAO;AACZ,SAAO"}
1
+ {"version":3,"file":"index.js","names":["SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]>"],"sources":["../../../src/transceivers/u-list/u-list.ts"],"sourcesContent":["import type { Fn, Transceiver, TransceiverMode } from \"atom.io/internal\"\nimport { Subject } from \"atom.io/internal\"\nimport type { primitive } from \"atom.io/json\"\nimport type { Enumeration } from \"atom.io/struct\"\nimport { enumeration, packValue, unpackValue } from \"atom.io/struct\"\n\nexport type SetMutations = Exclude<\n\tkeyof Set<any>,\n\tsymbol | keyof ReadonlySet<any>\n>\nexport type SetUpdate<P extends primitive> =\n\t| {\n\t\t\ttype: `add` | `delete`\n\t\t\tvalue: P\n\t }\n\t| {\n\t\t\ttype: `clear`\n\t\t\tvalues: P[]\n\t }\nexport type UListUpdateType = SetUpdate<any>[`type`]\ntrue satisfies SetMutations extends UListUpdateType\n\t? true\n\t: Exclude<SetMutations, UListUpdateType>\n\nexport type PackedSetUpdate<P extends primitive> = string & {\n\tupdate?: SetUpdate<P>\n}\n\nexport const SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]> =\n\tenumeration([`add`, `delete`, `clear`] as const)\n\nexport type SetMutationHandler = { [K in UListUpdateType]: Fn }\n\nexport type UListView<P extends primitive> = ReadonlySet<P> & {\n\tsubscribe: (\n\t\tkey: string,\n\t\tfn: (update: PackedSetUpdate<P>) => void,\n\t) => () => void\n}\n\nexport class UList<P extends primitive>\n\textends Set<P>\n\timplements\n\t\tTransceiver<UListView<P>, PackedSetUpdate<P>, ReadonlyArray<P>>,\n\t\tSetMutationHandler\n{\n\tpublic mode: TransceiverMode = `record`\n\tpublic readonly subject: Subject<PackedSetUpdate<P>> = new Subject()\n\n\tpublic constructor(values?: Iterable<P>) {\n\t\tsuper(values)\n\t\tif (values instanceof UList) {\n\t\t}\n\t}\n\n\tpublic readonly READONLY_VIEW: UListView<P> = this\n\n\tpublic toJSON(): ReadonlyArray<P> {\n\t\treturn [...this]\n\t}\n\n\tpublic static fromJSON<P extends primitive>(json: ReadonlyArray<P>): UList<P> {\n\t\treturn new UList<P>(json)\n\t}\n\n\tpublic add(value: P): this {\n\t\tconst result = super.add(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `add`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic clear(): void {\n\t\tconst capturedContents = this.mode === `record` ? [...this] : null\n\t\tsuper.clear()\n\t\tif (capturedContents) {\n\t\t\tthis.emit({ type: `clear`, values: capturedContents })\n\t\t}\n\t}\n\n\tpublic delete(value: P): boolean {\n\t\tconst result = super.delete(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `delete`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic subscribe(\n\t\tkey: string,\n\t\tfn: (update: PackedSetUpdate<P>) => void,\n\t): () => void {\n\t\treturn this.subject.subscribe(key, fn)\n\t}\n\n\tpublic emit(update: SetUpdate<P>): void {\n\t\tthis.subject.next(UList.packUpdate(update))\n\t}\n\n\tpublic do(packed: PackedSetUpdate<P>): null {\n\t\tthis.mode = `playback`\n\t\tconst update = UList.unpackUpdate(packed)\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`:\n\t\t\t\tthis.clear()\n\t\t}\n\t\tthis.mode = `record`\n\t\treturn null\n\t}\n\n\tpublic undo(packed: PackedSetUpdate<P>): number | null {\n\t\tconst update = UList.unpackUpdate(packed)\n\t\tthis.mode = `playback`\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`: {\n\t\t\t\tconst values = update.values\n\t\t\t\tfor (const v of values) this.add(v)\n\t\t\t}\n\t\t}\n\t\tthis.mode = `record`\n\t\treturn null\n\t}\n\n\tpublic static packUpdate<P extends primitive>(\n\t\tupdate: SetUpdate<P>,\n\t): PackedSetUpdate<P> {\n\t\tconst head = SET_UPDATE_ENUM[update.type] + `\\u001F`\n\t\tif (update.type === `clear`) {\n\t\t\treturn head + update.values.map(packValue).join(`\\u001E`)\n\t\t}\n\t\treturn head + packValue(update.value)\n\t}\n\tpublic static unpackUpdate<P extends primitive>(\n\t\tpacked: PackedSetUpdate<P>,\n\t): SetUpdate<P> {\n\t\tconst [type, tail] = packed.split(`\\u001F`) as [0 | 1 | 2, string]\n\t\tconst head = SET_UPDATE_ENUM[type]\n\t\tif (head === `clear`) {\n\t\t\tconst values = tail.split(`\\u001E`).map(unpackValue) as P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AAK,OAAO,OAAO,MAAM;AACzB;GACD,KAAK,QACJ,MAAK,OAAO;;AAEd,OAAK,OAAO;AACZ,SAAO;;CAGR,AAAO,KAAK,QAA2C;EACtD,MAAM,SAAS,MAAM,aAAa,OAAO;AACzC,OAAK,OAAO;AACZ,UAAQ,OAAO,MAAf;GACC,KAAK;AACJ,SAAK,OAAO,OAAO,MAAM;AACzB;GACD,KAAK;AACJ,SAAK,IAAI,OAAO,MAAM;AACtB;GACD,KAAK,SAAS;IACb,MAAM,SAAS,OAAO;AACtB,SAAK,MAAM,KAAK,OAAQ,MAAK,IAAI,EAAE;;;AAGrC,OAAK,OAAO;AACZ,SAAO;;CAGR,OAAc,WACb,QACqB;EACrB,MAAM,OAAO,gBAAgB,OAAO,QAAQ;AAC5C,MAAI,OAAO,SAAS,QACnB,QAAO,OAAO,OAAO,OAAO,IAAI,UAAU,CAAC,KAAK,SAAS;AAE1D,SAAO,OAAO,UAAU,OAAO,MAAM;;CAEtC,OAAc,aACb,QACe;EACf,MAAM,CAAC,MAAM,QAAQ,OAAO,MAAM,SAAS;EAC3C,MAAM,OAAO,gBAAgB;AAC7B,MAAI,SAAS,QAEZ,QAAO;GAAE,MAAM;GAAS,QADT,KAAK,MAAM,SAAS,CAAC,IAAI,YAAY;GACpB;AAEjC,SAAO;GAAE,MAAM;GAAM,OAAO,YAAY,KAAK;GAAO"}
@@ -0,0 +1,10 @@
1
+ //#region src/internal/utility-types.d.ts
2
+ type Fn = (...parameters: any[]) => any;
3
+ type Ctor<T> = new (...args: any[]) => T;
4
+ type Flat<R extends { [K in PropertyKey]: any }> = { [K in keyof R]: R[K] };
5
+ type Count<N extends number, A extends any[] = []> = [...A, any][`length`] extends N ? A[`length`] : A[`length`] | Count<N, [...A, any]>;
6
+ type Each<E extends any[]> = { [P in Count<E[`length`]>]: E[P] };
7
+ type Refinement<A, B extends A> = (a: A) => a is B;
8
+ //#endregion
9
+ export { Count, Ctor, Each, Flat, Fn, Refinement };
10
+ //# sourceMappingURL=utility-types-aZkJVERa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility-types-aZkJVERa.d.ts","names":[],"sources":["../src/internal/utility-types.ts"],"sourcesContent":[],"mappings":";KAAY,EAAA;AAAA,KAEA,IAFA,CAAA,CAAA,CAAA,GAAA,KAAA,GAAA,IAAA,EAAA,GAAA,EAAA,EAAA,GAEkC,CAFlC;AAEA,KAEA,IAFA,CAAA,UAAkC,QAEX,WAFW,GAAA,GAAA,EAAA,CAAA,GAAA,QAAA,MAGjC,CAHiC,GAG7B,CAH6B,CAG3B,CAH2B,CAAA,EAAA;AAElC,KAIA,KAJA,CAAA,UAAA,MAAA,YAAuB,GAAA,EAAA,GAAA,EAAA,QAK/B,CAJS,EAAA,GAAA,CAAA,CAAA,QAAA,CAAA,SAMO,CANP,GAOV,CAPU,CAAA,QAAA,CAAA,GAQV,CARU,CAAA,QAAA,CAAA,GAQI,KARJ,CAQU,CARV,EAAA,CAAA,GAQiB,CARjB,EAAA,GAAA,CAAA,CAAA;AAAI,KAUL,IAVK,CAAA,UAAA,GAAA,EAAA,CAAA,GAAA,QAWV,KAXU,CAWJ,CAXI,CAAA,QAAA,CAAA,CAAA,GAWW,CAXX,CAWa,CAXb,CAAA,EAAA;AAAE,KAcP,UAdO,CAAA,CAAA,EAGnB,UAWoC,CAXxB,CAAA,GAAA,CAAA,CAAA,EAWiC,CAXjC,EAAA,GAAA,CAAA,IAW4C,CAX5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -61,9 +61,9 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@eslint/core": "0.15.2",
64
- "@storybook/addon-docs": "9.1.6",
65
- "@storybook/addon-onboarding": "9.1.6",
66
- "@storybook/react-vite": "9.1.6",
64
+ "@storybook/addon-docs": "9.1.7",
65
+ "@storybook/addon-onboarding": "9.1.7",
66
+ "@storybook/react-vite": "9.1.7",
67
67
  "@testing-library/react": "16.3.0",
68
68
  "@types/bun": "npm:bun-types@1.2.22",
69
69
  "@types/eslint": "9.6.1",
@@ -80,10 +80,10 @@
80
80
  "concurrently": "9.2.1",
81
81
  "drizzle-kit": "0.31.4",
82
82
  "drizzle-orm": "0.44.5",
83
- "eslint": "9.35.0",
83
+ "eslint": "9.36.0",
84
84
  "happy-dom": "18.0.1",
85
85
  "http-proxy": "1.18.1",
86
- "motion": "12.23.13",
86
+ "motion": "12.23.16",
87
87
  "npmlog": "7.0.1",
88
88
  "nyc": "17.1.0",
89
89
  "postgres": "3.4.7",
@@ -94,11 +94,11 @@
94
94
  "recoverage": "0.1.11",
95
95
  "socket.io": "4.8.1",
96
96
  "socket.io-client": "4.8.1",
97
- "storybook": "9.1.6",
97
+ "storybook": "9.1.7",
98
98
  "tmp": "0.2.5",
99
- "tsdown": "0.15.2",
99
+ "tsdown": "0.15.4",
100
100
  "typescript": "5.9.2",
101
- "vite": "7.1.5",
101
+ "vite": "7.1.6",
102
102
  "vite-tsconfig-paths": "5.1.4",
103
103
  "vitest": "3.2.4",
104
104
  "zod": "3.25.76",
@@ -166,6 +166,10 @@
166
166
  "import": "./dist/realtime-testing/index.js",
167
167
  "types": "./dist/realtime-testing/index.d.ts"
168
168
  },
169
+ "./struct": {
170
+ "import": "./dist/struct/index.js",
171
+ "types": "./dist/struct/index.d.ts"
172
+ },
169
173
  "./transceivers/o-list": {
170
174
  "import": "./dist/transceivers/o-list/index.js",
171
175
  "types": "./dist/transceivers/o-list/index.d.ts"
@@ -14,7 +14,6 @@ export * from "./join"
14
14
  export * from "./junction"
15
15
  export * from "./keys"
16
16
  export * from "./lineage"
17
- export * from "./micro"
18
17
  export * from "./molecule"
19
18
  export * from "./mutable"
20
19
  export * from "./not-found-error"
@@ -1,23 +1,20 @@
1
1
  import type { JoinOptions, JoinToken } from "atom.io"
2
- import type { Json } from "atom.io/json"
3
2
 
4
3
  import type { RootStore } from "../transaction"
5
4
  import { Join } from "./join-internal"
6
5
 
7
6
  export function createJoin<
8
- ASide extends string,
9
- AType extends string,
10
- BSide extends string,
11
- BType extends string,
7
+ AName extends string,
8
+ A extends string,
9
+ BName extends string,
10
+ B extends string,
12
11
  Cardinality extends `1:1` | `1:n` | `n:n`,
13
- Content extends Json.Object,
14
12
  >(
15
13
  store: RootStore,
16
- options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>,
17
- defaultContent: Content | undefined,
18
- ): JoinToken<ASide, AType, BSide, BType, Cardinality, Content> {
19
- store.joins.set(options.key, new Join(options, defaultContent, store))
20
- const token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content> = {
14
+ options: JoinOptions<AName, A, BName, B, Cardinality>,
15
+ ): JoinToken<AName, A, BName, B, Cardinality> {
16
+ store.joins.set(options.key, new Join(options))
17
+ const token: JoinToken<AName, A, BName, B, Cardinality> = {
21
18
  key: options.key,
22
19
  type: `join`,
23
20
  a: options.between[0],
@@ -1,5 +1,4 @@
1
1
  import type { JoinToken } from "atom.io"
2
- import type { Json } from "atom.io/json"
3
2
 
4
3
  import type { Junction } from "../junction"
5
4
  import { newest } from "../lineage"
@@ -8,15 +7,14 @@ import { isChildStore } from "../transaction"
8
7
  import { getJoin } from "./get-join"
9
8
 
10
9
  export function editRelationsInStore<
11
- ASide extends string,
12
- AType extends string,
13
- BSide extends string,
14
- BType extends string,
10
+ AName extends string,
11
+ A extends string,
12
+ BName extends string,
13
+ B extends string,
15
14
  Cardinality extends `1:1` | `1:n` | `n:n`,
16
- Content extends Json.Object | null,
17
15
  >(
18
- token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>,
19
- change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void,
16
+ token: JoinToken<AName, A, BName, B, Cardinality>,
17
+ change: (relations: Junction<AName, A, BName, B>) => void,
20
18
  store: Store,
21
19
  ): void {
22
20
  const myJoin = getJoin(token, store)
@@ -1,5 +1,4 @@
1
1
  import type { JoinStates, JoinToken } from "atom.io"
2
- import type { Json } from "atom.io/json"
3
2
 
4
3
  import { capitalize } from "../capitalize"
5
4
  import { findInStore } from "../families"
@@ -7,19 +6,18 @@ import type { RootStore } from "../transaction"
7
6
  import { getJoin } from "./get-join"
8
7
 
9
8
  export function findRelationsInStore<
10
- ASide extends string,
11
- AType extends string,
12
- BSide extends string,
13
- BType extends string,
9
+ AName extends string,
10
+ A extends string,
11
+ BName extends string,
12
+ B extends string,
14
13
  Cardinality extends `1:1` | `1:n` | `n:n`,
15
- Content extends Json.Object | null,
16
14
  >(
17
- token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>,
18
- key: AType | BType,
15
+ token: JoinToken<AName, A, BName, B, Cardinality>,
16
+ key: A | B,
19
17
  store: RootStore,
20
- ): JoinStates<ASide, AType, BSide, BType, Cardinality, Content> {
18
+ ): JoinStates<AName, A, BName, B, Cardinality> {
21
19
  const myJoin = getJoin(token, store)
22
- let relations: JoinStates<ASide, AType, BSide, BType, Cardinality, Content>
20
+ let relations: JoinStates<AName, A, BName, B, Cardinality>
23
21
  switch (token.cardinality satisfies `1:1` | `1:n` | `n:n`) {
24
22
  case `1:1`: {
25
23
  const keyAB = `${token.a}KeyOf${capitalize(token.b)}`
@@ -37,25 +35,7 @@ export function findRelationsInStore<
37
35
  const state = findInStore(store, familyBA, key)
38
36
  return state
39
37
  },
40
- } as JoinStates<ASide, AType, BSide, BType, Cardinality, Content>
41
- const entryAB = `${token.a}EntryOf${capitalize(token.b)}`
42
- if (entryAB in myJoin.states) {
43
- const entryBA = `${token.b}EntryOf${capitalize(token.a)}`
44
- Object.assign(relations, {
45
- get [entryAB]() {
46
- // @ts-expect-error way too complicated to represent
47
- const familyAB = myJoin.states[entryAB as any]
48
- const state = findInStore(store, familyAB, key)
49
- return state
50
- },
51
- get [entryBA]() {
52
- // @ts-expect-error way too complicated to represent
53
- const familyBA = myJoin.states[entryBA as any]
54
- const state = findInStore(store, familyBA, key)
55
- return state
56
- },
57
- })
58
- }
38
+ } as JoinStates<AName, A, BName, B, Cardinality>
59
39
  break
60
40
  }
61
41
  case `1:n`: {
@@ -74,25 +54,7 @@ export function findRelationsInStore<
74
54
  const state = findInStore(store, familyBA, key)
75
55
  return state
76
56
  },
77
- } as JoinStates<ASide, AType, BSide, BType, Cardinality, Content>
78
- const entryAB = `${token.a}EntryOf${capitalize(token.b)}`
79
- if (entryAB in myJoin.states) {
80
- const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`
81
- Object.assign(relations, {
82
- get [entryAB]() {
83
- // @ts-expect-error way too complicated to represent
84
- const familyAB = myJoin.states[entryAB as any]
85
- const state = findInStore(store, familyAB, key)
86
- return state
87
- },
88
- get [entriesBA]() {
89
- // @ts-expect-error way too complicated to represent
90
- const familyBA = myJoin.states[entriesBA as any]
91
- const state = findInStore(store, familyBA, key)
92
- return state
93
- },
94
- })
95
- }
57
+ } as JoinStates<AName, A, BName, B, Cardinality>
96
58
  break
97
59
  }
98
60
  case `n:n`: {
@@ -111,25 +73,7 @@ export function findRelationsInStore<
111
73
  const state = findInStore(store, familyBA, key)
112
74
  return state
113
75
  },
114
- } as JoinStates<ASide, AType, BSide, BType, Cardinality, Content>
115
- const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`
116
- if (entriesAB in myJoin.states) {
117
- const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`
118
- Object.assign(relations, {
119
- get [entriesAB]() {
120
- // @ts-expect-error way too complicated to represent
121
- const familyAB = myJoin.states[entriesAB as any]
122
- const state = findInStore(store, familyAB, key)
123
- return state
124
- },
125
- get [entriesBA]() {
126
- // @ts-expect-error way too complicated to represent
127
- const familyBA = myJoin.states[entriesBA as any]
128
- const state = findInStore(store, familyBA, key)
129
- return state
130
- },
131
- })
132
- }
76
+ } as JoinStates<AName, A, BName, B, Cardinality>
133
77
  }
134
78
  }
135
79
  return relations
@@ -1,14 +1,20 @@
1
1
  import type { JoinToken, MutableAtomFamilyToken } from "atom.io"
2
- import type { SetRTX } from "atom.io/transceivers/set-rtx"
2
+ import type { UList } from "atom.io/transceivers/u-list"
3
3
 
4
4
  import type { RootStore } from "../transaction"
5
5
  import { getJoin } from "./get-join"
6
6
 
7
- export function getInternalRelationsFromStore(
8
- token: JoinToken<any, any, any, any, any, any>,
7
+ export function getInternalRelationsFromStore<
8
+ AName extends string,
9
+ BName extends string,
10
+ >(
11
+ token: JoinToken<any, AName, any, BName, any>,
9
12
  store: RootStore,
10
- ): MutableAtomFamilyToken<SetRTX<string>, string> {
13
+ ): MutableAtomFamilyToken<UList<AName> | UList<BName>, string> {
11
14
  const myJoin = getJoin(token, store)
12
- const family = myJoin.core.relatedKeysAtoms
15
+ const family = myJoin.relatedKeysAtoms as MutableAtomFamilyToken<
16
+ UList<AName> | UList<BName>,
17
+ string
18
+ >
13
19
  return family
14
20
  }
@@ -1,5 +1,4 @@
1
1
  import type { JoinToken } from "atom.io"
2
- import type { Json } from "atom.io/json"
3
2
 
4
3
  import { eldest } from "../lineage"
5
4
  import type { Store } from "../store"
@@ -7,16 +6,15 @@ import { IMPLICIT } from "../store"
7
6
  import { Join } from "./join-internal"
8
7
 
9
8
  export function getJoin<
10
- ASide extends string,
11
- AType extends string,
12
- BSide extends string,
13
- BType extends string,
9
+ AName extends string,
10
+ A extends string,
11
+ BName extends string,
12
+ B extends string,
14
13
  Cardinality extends `1:1` | `1:n` | `n:n`,
15
- Content extends Json.Object | null,
16
14
  >(
17
- token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>,
15
+ token: JoinToken<AName, A, BName, B, Cardinality>,
18
16
  store: Store,
19
- ): Join<ASide, AType, BSide, BType, Cardinality, Content> {
17
+ ): Join<AName, A, BName, B, Cardinality> {
20
18
  let myJoin = store.joins.get(token.key)
21
19
  if (myJoin === undefined) {
22
20
  const rootJoinMap = IMPLICIT.STORE.joins
@@ -27,7 +25,7 @@ export function getJoin<
27
25
  )
28
26
  }
29
27
  const root = eldest(store)
30
- myJoin = new Join(rootJoin.options, rootJoin.defaultContent, root)
28
+ myJoin = new Join(rootJoin.options, root)
31
29
  store.joins.set(token.key, myJoin)
32
30
  }
33
31
  return myJoin