atom.io 0.6.3 → 0.6.4

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 (60) hide show
  1. package/dist/index.d.mts +25 -13
  2. package/dist/index.d.ts +25 -13
  3. package/dist/index.js +37 -22
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +37 -22
  6. package/dist/index.mjs.map +1 -1
  7. package/json/package.json +13 -13
  8. package/package.json +22 -13
  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/realtime-react/realtime-context.tsx +1 -2
  54. package/src/realtime-react/use-pull-family-member.ts +1 -2
  55. package/src/realtime-react/use-pull-family.ts +1 -2
  56. package/src/realtime-react/use-pull.ts +1 -2
  57. package/src/realtime-react/use-push.ts +1 -2
  58. package/src/realtime-react/use-server-action.ts +1 -2
  59. package/src/realtime-testing/setup-realtime-test.tsx +1 -2
  60. package/src/selector.ts +3 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/realtime-testing/setup-realtime-test.tsx"],"sourcesContent":["import * as http from \"http\"\n\nimport * as React from \"react\"\n\nimport { prettyDOM, render, type RenderResult } from \"@testing-library/react\"\nimport * as AtomIO from \"atom.io\"\nimport * as AR from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-react\"\nimport * as RR from \"fp-ts/ReadonlyRecord\"\nimport * as Happy from \"happy-dom\"\nimport * as SocketIO from \"socket.io\"\nimport type { Socket as ClientSocket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport type TestSetupOptions = {\n\tserver: (tools: { socket: SocketIO.Socket; silo: AtomIO.Silo }) => void\n}\nexport type TestSetupOptions__SingleClient = TestSetupOptions & {\n\tclient: React.FC\n}\nexport type TestSetupOptions__MultiClient<ClientNames extends string> =\n\tTestSetupOptions & {\n\t\tclients: {\n\t\t\t[K in ClientNames]: React.FC\n\t\t}\n\t}\n\nexport type RealtimeTestTools = {\n\tname: string\n\tsilo: AtomIO.Silo\n\tdispose: () => void\n}\nexport type RealtimeTestClient = RealtimeTestTools & {\n\trenderResult: RenderResult\n\tprettyPrint: () => void\n\treconnect: () => void\n\tdisconnect: () => void\n}\nexport type RealtimeTestServer = RealtimeTestTools & {\n\tport: number\n}\n\nexport type RealtimeTestAPI = {\n\tserver: RealtimeTestServer\n\tteardown: () => void\n}\nexport type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {\n\tclient: RealtimeTestClient\n}\nexport type RealtimeTestAPI__MultiClient<ClientNames extends string> =\n\tRealtimeTestAPI & {\n\t\tclients: Record<ClientNames, RealtimeTestClient>\n\t}\n\nexport const setupRealtimeTestServer = (\n\toptions: TestSetupOptions,\n): RealtimeTestServer => {\n\tconst httpServer = http.createServer((_, res) => res.end(`Hello World!`))\n\tconst address = httpServer.listen().address()\n\tconst port =\n\t\ttypeof address === `string` ? 80 : address === null ? null : address.port\n\tif (port === null) throw new Error(`Could not determine port for test server`)\n\tconst server = new SocketIO.Server(httpServer)\n\tconst silo = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tserver.on(`connection`, (socket: SocketIO.Socket) => {\n\t\toptions.server({ socket, silo })\n\t})\n\n\tconst dispose = () => {\n\t\tserver.close()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname: `SERVER`,\n\t\tsilo,\n\t\tdispose,\n\t\tport,\n\t}\n}\nexport const setupRealtimeTestClient = (\n\toptions: TestSetupOptions__SingleClient,\n\tname: string,\n\tport: number,\n): RealtimeTestClient => {\n\tconst socket: ClientSocket = io(`http://localhost:${port}/`)\n\tconst silo = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tconst { document } = new Happy.Window()\n\tdocument.body.innerHTML = `<div id=\"app\"></div>`\n\tconst renderResult = render(\n\t\t<AR.StoreProvider store={silo.store}>\n\t\t\t<RTC.RealtimeProvider socket={socket}>\n\t\t\t\t<options.client />\n\t\t\t</RTC.RealtimeProvider>\n\t\t</AR.StoreProvider>,\n\t\t{\n\t\t\tcontainer: document.querySelector(`#app`) as unknown as HTMLElement,\n\t\t},\n\t)\n\n\tconst prettyPrint = () => console.log(prettyDOM(renderResult.container))\n\n\tconst disconnect = () => socket.disconnect()\n\tconst reconnect = () => socket.connect()\n\n\tconst dispose = () => {\n\t\tsocket.disconnect()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname,\n\t\tsilo,\n\t\trenderResult,\n\t\tprettyPrint,\n\t\tdisconnect,\n\t\treconnect,\n\t\tdispose,\n\t}\n}\n\nexport const singleClient = (\n\toptions: TestSetupOptions__SingleClient,\n): RealtimeTestAPI__SingleClient => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst client = setupRealtimeTestClient(options, `CLIENT`, server.port)\n\n\treturn {\n\t\tclient,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tclient.dispose()\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n\nexport const multiClient = <ClientNames extends string>(\n\toptions: TestSetupOptions__MultiClient<ClientNames>,\n): RealtimeTestAPI__MultiClient<ClientNames> => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst clients = RR.toEntries(options.clients).reduce(\n\t\t(clients, [name, client]) => ({\n\t\t\t...clients,\n\t\t\t[name]: setupRealtimeTestClient({ ...options, client }, name, server.port),\n\t\t}),\n\t\t{} as Record<ClientNames, RealtimeTestClient>,\n\t)\n\n\treturn {\n\t\tclients,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tRR.toEntries(clients).forEach(([, client]) => client.dispose())\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,UAAU;AAItB,SAAS,WAAW,cAAiC;AACrD,YAAY,YAAY;AACxB,YAAY,QAAQ;AACpB,YAAY,SAAS;AACrB,YAAY,QAAQ;AACpB,YAAY,WAAW;AACvB,YAAY,cAAc;AAE1B,SAAS,U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,WAAO,WAAW;AAClB,IAAO,oBAAa,WAAWA,MAAK,KAAK;AAAA,EAC1C;AAEA,SAAO;AAAA,IACN;AAAA,IACA,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEO,IAAM,eAAe,CAC3B,YACmC;AACnC,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,SAAS,wBAAwB,SAAS,UAAU,OAAO,IAAI;AAErE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,aAAO,QAAQ;AACf,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;AAEO,IAAM,cAAc,CAC1B,YAC+C;AAC/C,QAAM,SAAS,wBAAwB,OAAO;AAC9C,QAAM,UAAa,aAAU,QAAQ,OAAO,EAAE;AAAA,IAC7C,CAACC,UAAS,CAAC,MAAM,MAAM,MAAO,iCAC1BA,WAD0B;AAAA,MAE7B,CAAC,IAAI,GAAG,wBAAwB,iCAAK,UAAL,EAAc,OAAO,IAAG,MAAM,OAAO,IAAI;AAAA,IAC1E;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,UAAU,MAAM;AACf,MAAG,aAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,MAAM,OAAO,QAAQ,CAAC;AAC9D,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;","names":["silo","clients"]}
1
+ {"version":3,"sources":["../../src/realtime-testing/setup-realtime-test.tsx"],"sourcesContent":["import * as http from \"http\"\n\nimport { prettyDOM, render, type RenderResult } from \"@testing-library/react\"\nimport * as AtomIO from \"atom.io\"\nimport * as AR from \"atom.io/react\"\nimport * as RTC from \"atom.io/realtime-react\"\nimport * as RR from \"fp-ts/ReadonlyRecord\"\nimport * as Happy from \"happy-dom\"\nimport * as React from \"react\"\nimport * as SocketIO from \"socket.io\"\nimport type { Socket as ClientSocket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nexport type TestSetupOptions = {\n\tserver: (tools: { socket: SocketIO.Socket; silo: AtomIO.Silo }) => void\n}\nexport type TestSetupOptions__SingleClient = TestSetupOptions & {\n\tclient: React.FC\n}\nexport type TestSetupOptions__MultiClient<ClientNames extends string> =\n\tTestSetupOptions & {\n\t\tclients: {\n\t\t\t[K in ClientNames]: React.FC\n\t\t}\n\t}\n\nexport type RealtimeTestTools = {\n\tname: string\n\tsilo: AtomIO.Silo\n\tdispose: () => void\n}\nexport type RealtimeTestClient = RealtimeTestTools & {\n\trenderResult: RenderResult\n\tprettyPrint: () => void\n\treconnect: () => void\n\tdisconnect: () => void\n}\nexport type RealtimeTestServer = RealtimeTestTools & {\n\tport: number\n}\n\nexport type RealtimeTestAPI = {\n\tserver: RealtimeTestServer\n\tteardown: () => void\n}\nexport type RealtimeTestAPI__SingleClient = RealtimeTestAPI & {\n\tclient: RealtimeTestClient\n}\nexport type RealtimeTestAPI__MultiClient<ClientNames extends string> =\n\tRealtimeTestAPI & {\n\t\tclients: Record<ClientNames, RealtimeTestClient>\n\t}\n\nexport const setupRealtimeTestServer = (\n\toptions: TestSetupOptions,\n): RealtimeTestServer => {\n\tconst httpServer = http.createServer((_, res) => res.end(`Hello World!`))\n\tconst address = httpServer.listen().address()\n\tconst port =\n\t\ttypeof address === `string` ? 80 : address === null ? null : address.port\n\tif (port === null) throw new Error(`Could not determine port for test server`)\n\tconst server = new SocketIO.Server(httpServer)\n\tconst silo = AtomIO.silo(`SERVER`, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tserver.on(`connection`, (socket: SocketIO.Socket) => {\n\t\toptions.server({ socket, silo })\n\t})\n\n\tconst dispose = () => {\n\t\tserver.close()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname: `SERVER`,\n\t\tsilo,\n\t\tdispose,\n\t\tport,\n\t}\n}\nexport const setupRealtimeTestClient = (\n\toptions: TestSetupOptions__SingleClient,\n\tname: string,\n\tport: number,\n): RealtimeTestClient => {\n\tconst socket: ClientSocket = io(`http://localhost:${port}/`)\n\tconst silo = AtomIO.silo(name, AtomIO.__INTERNAL__.IMPLICIT.STORE)\n\n\tconst { document } = new Happy.Window()\n\tdocument.body.innerHTML = `<div id=\"app\"></div>`\n\tconst renderResult = render(\n\t\t<AR.StoreProvider store={silo.store}>\n\t\t\t<RTC.RealtimeProvider socket={socket}>\n\t\t\t\t<options.client />\n\t\t\t</RTC.RealtimeProvider>\n\t\t</AR.StoreProvider>,\n\t\t{\n\t\t\tcontainer: document.querySelector(`#app`) as unknown as HTMLElement,\n\t\t},\n\t)\n\n\tconst prettyPrint = () => console.log(prettyDOM(renderResult.container))\n\n\tconst disconnect = () => socket.disconnect()\n\tconst reconnect = () => socket.connect()\n\n\tconst dispose = () => {\n\t\tsocket.disconnect()\n\t\tAtomIO.__INTERNAL__.clearStore(silo.store)\n\t}\n\n\treturn {\n\t\tname,\n\t\tsilo,\n\t\trenderResult,\n\t\tprettyPrint,\n\t\tdisconnect,\n\t\treconnect,\n\t\tdispose,\n\t}\n}\n\nexport const singleClient = (\n\toptions: TestSetupOptions__SingleClient,\n): RealtimeTestAPI__SingleClient => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst client = setupRealtimeTestClient(options, `CLIENT`, server.port)\n\n\treturn {\n\t\tclient,\n\t\tserver,\n\t\tteardown: () => {\n\t\t\tclient.dispose()\n\t\t\tserver.dispose()\n\t\t},\n\t}\n}\n\nexport const multiClient = <ClientNames extends string>(\n\toptions: TestSetupOptions__MultiClient<ClientNames>,\n): RealtimeTestAPI__MultiClient<ClientNames> => {\n\tconst server = setupRealtimeTestServer(options)\n\tconst clients = RR.toEntries(options.clients).reduce(\n\t\t(clients, [name, client]) => ({\n\t\t\t...clients,\n\t\t\t[name]: setupRealtimeTestClient({ ...options, client }, name, server.port),\n\t\t}),\n\t\t{} as Record<ClientNames, RealtimeTestClient>,\n\t)\n\n\tretur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C,CAAC,EAAE,MAAM,MAAM,OAAO,QAAQ,CAAC;AAC9D,aAAO,QAAQ;AAAA,IAChB;AAAA,EACD;AACD;","names":["silo","clients"]}
@@ -1,15 +1,15 @@
1
1
  {
2
- "name": "atom.io-realtime-testing",
3
- "private": true,
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "module": "dist/index.mjs",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "browser": "./dist/index.mjs",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- }
2
+ "name": "atom.io-realtime-testing",
3
+ "private": true,
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "browser": "./dist/index.mjs",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ }
15
15
  }
package/src/atom.ts CHANGED
@@ -1,8 +1,7 @@
1
- import type * as Rx from "rxjs"
2
-
3
1
  import type { Serializable } from "~/packages/anvl/src/json"
4
2
 
5
3
  import type { AtomToken } from "."
4
+ import type { Subject } from "./internal"
6
5
  import { atomFamily__INTERNAL, atom__INTERNAL } from "./internal"
7
6
 
8
7
  export type Effectors<T> = {
@@ -33,7 +32,7 @@ export type AtomFamily<T, K extends Serializable = Serializable> = ((
33
32
  ) => AtomToken<T>) & {
34
33
  key: string
35
34
  type: `atom_family`
36
- subject: Rx.Subject<AtomToken<T>>
35
+ subject: Subject<AtomToken<T>>
37
36
  }
38
37
 
39
38
  export function atomFamily<T, K extends Serializable>(
@@ -1,6 +1,6 @@
1
1
  import HAMT from "hamt_plus"
2
- import * as Rx from "rxjs"
3
2
 
3
+ import { Subject } from "."
4
4
  import { deposit } from "./get"
5
5
  import { markAtomAsDefault } from "./is-default"
6
6
  import { cacheValue, hasKeyBeenUsed } from "./operation"
@@ -15,7 +15,7 @@ export type Atom<T> = {
15
15
  key: string
16
16
  type: `atom`
17
17
  family?: FamilyMetadata
18
- subject: Rx.Subject<{ newValue: T; oldValue: T }>
18
+ subject: Subject<{ newValue: T; oldValue: T }>
19
19
  default: T
20
20
  }
21
21
 
@@ -31,7 +31,7 @@ export function atom__INTERNAL<T>(
31
31
  )
32
32
  return deposit(core.atoms.get(options.key))
33
33
  }
34
- const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()
34
+ const subject = new Subject<{ newValue: T; oldValue: T }>()
35
35
  const newAtom = {
36
36
  ...options,
37
37
  subject,
@@ -1,10 +1,9 @@
1
- import * as Rx from "rxjs"
2
-
3
1
  import type { Serializable } from "~/packages/anvl/src/json"
4
2
  import { stringifyJson } from "~/packages/anvl/src/json"
5
3
 
6
4
  import type { Store } from "."
7
5
  import {
6
+ Subject,
8
7
  atom__INTERNAL,
9
8
  withdraw,
10
9
  selector__INTERNAL,
@@ -29,7 +28,7 @@ export function atomFamily__INTERNAL<T, K extends Serializable>(
29
28
  options: AtomFamilyOptions<T, K>,
30
29
  store: Store = IMPLICIT.STORE,
31
30
  ): AtomFamily<T, K> {
32
- const subject = new Rx.Subject<AtomToken<T>>()
31
+ const subject = new Subject<AtomToken<T>>()
33
32
  return Object.assign(
34
33
  (key: K): AtomToken<T> => {
35
34
  const subKey = stringifyJson(key)
@@ -66,7 +65,7 @@ export function readonlySelectorFamily__INTERNAL<T, K extends Serializable>(
66
65
  store?: Store,
67
66
  ): ReadonlySelectorFamily<T, K> {
68
67
  const core = target(store)
69
- const subject = new Rx.Subject<ReadonlySelectorToken<T>>()
68
+ const subject = new Subject<ReadonlySelectorToken<T>>()
70
69
  return Object.assign(
71
70
  (key: K): ReadonlySelectorToken<T> => {
72
71
  const subKey = stringifyJson(key)
@@ -111,7 +110,7 @@ export function selectorFamily__INTERNAL<T, K extends Serializable>(
111
110
  return readonlySelectorFamily__INTERNAL(options, store)
112
111
  }
113
112
  const core = target(store)
114
- const subject = new Rx.Subject<SelectorToken<T>>()
113
+ const subject = new Subject<SelectorToken<T>>()
115
114
 
116
115
  return Object.assign(
117
116
  (key: K): SelectorToken<T> => {
@@ -8,6 +8,7 @@ export * from "./selector-internal"
8
8
  export * from "./selector"
9
9
  export * from "./set"
10
10
  export * from "./store"
11
+ export * from "./subject"
11
12
  export * from "./subscribe-internal"
12
13
  export * from "./time-travel-internal"
13
14
  export * from "./timeline-internal"
@@ -1,8 +1,8 @@
1
1
  import HAMT from "hamt_plus"
2
- import * as Rx from "rxjs"
3
2
 
4
3
  import { become } from "~/packages/anvl/src/function"
5
4
 
5
+ import { Subject } from ".."
6
6
  import {
7
7
  type Store,
8
8
  type Selector,
@@ -20,7 +20,7 @@ export const createReadWriteSelector = <T>(
20
20
  store: Store,
21
21
  core: StoreCore,
22
22
  ): SelectorToken<T> => {
23
- const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()
23
+ const subject = new Subject<{ newValue: T; oldValue: T }>()
24
24
 
25
25
  const { get, set } = registerSelector(options.key, store)
26
26
  const getSelf = () => {
@@ -1,7 +1,7 @@
1
1
  import HAMT from "hamt_plus"
2
- import * as Rx from "rxjs"
3
2
 
4
3
  import { registerSelector } from "./register-selector"
4
+ import { Subject } from ".."
5
5
  import type {
6
6
  FamilyMetadata,
7
7
  ReadonlySelectorOptions,
@@ -18,7 +18,7 @@ export const createReadonlySelector = <T>(
18
18
  store: Store,
19
19
  core: StoreCore,
20
20
  ): ReadonlySelectorToken<T> => {
21
- const subject = new Rx.Subject<{ newValue: T; oldValue: T }>()
21
+ const subject = new Subject<{ newValue: T; oldValue: T }>()
22
22
 
23
23
  const { get } = registerSelector(options.key, store)
24
24
  const getSelf = () => {
@@ -1,8 +1,7 @@
1
1
  import HAMT from "hamt_plus"
2
- import type * as Rx from "rxjs"
3
2
 
4
- import type { Store } from "."
5
3
  import { target, IMPLICIT } from "."
4
+ import type { Store, Subject } from "."
6
5
  import { createReadWriteSelector } from "./selector/create-read-write-selector"
7
6
  import { createReadonlySelector } from "./selector/create-readonly-selector"
8
7
  import type {
@@ -18,7 +17,7 @@ export type Selector<T> = {
18
17
  type: `selector`
19
18
  family?: FamilyMetadata
20
19
  install: (store: Store) => void
21
- subject: Rx.Subject<{ newValue: T; oldValue: T }>
20
+ subject: Subject<{ newValue: T; oldValue: T }>
22
21
  get: () => T
23
22
  set: (newValue: T | ((oldValue: T) => T)) => void
24
23
  }
@@ -27,7 +26,7 @@ export type ReadonlySelector<T> = {
27
26
  type: `readonly_selector`
28
27
  family?: FamilyMetadata
29
28
  install: (store: Store) => void
30
- subject: Rx.Subject<{ newValue: T; oldValue: T }>
29
+ subject: Subject<{ newValue: T; oldValue: T }>
31
30
  get: () => T
32
31
  }
33
32
 
@@ -1,11 +1,11 @@
1
1
  import type { Hamt } from "hamt_plus"
2
2
  import HAMT from "hamt_plus"
3
- import * as Rx from "rxjs"
4
3
 
5
4
  import type { ƒn } from "~/packages/anvl/src/function"
6
5
  import { doNothing } from "~/packages/anvl/src/function"
7
6
  import { Join } from "~/packages/anvl/src/join"
8
7
 
8
+ import { Subject } from "."
9
9
  import type {
10
10
  Atom,
11
11
  OperationProgress,
@@ -52,12 +52,12 @@ export interface Store {
52
52
  valueMap: Hamt<any, string>
53
53
 
54
54
  subject: {
55
- atomCreation: Rx.Subject<AtomToken<unknown>>
56
- selectorCreation: Rx.Subject<
55
+ atomCreation: Subject<AtomToken<unknown>>
56
+ selectorCreation: Subject<
57
57
  ReadonlySelectorToken<unknown> | SelectorToken<unknown>
58
58
  >
59
- transactionCreation: Rx.Subject<TransactionToken<unknown>>
60
- timelineCreation: Rx.Subject<TimelineToken>
59
+ transactionCreation: Subject<TransactionToken<unknown>>
60
+ timelineCreation: Subject<TimelineToken>
61
61
  }
62
62
 
63
63
  operation: OperationProgress
@@ -92,10 +92,10 @@ export const createStore = (name: string, store: Store | null = null): Store =>
92
92
  .to(`atomKey`),
93
93
 
94
94
  subject: {
95
- atomCreation: new Rx.Subject(),
96
- selectorCreation: new Rx.Subject(),
97
- transactionCreation: new Rx.Subject(),
98
- timelineCreation: new Rx.Subject(),
95
+ atomCreation: new Subject(),
96
+ selectorCreation: new Subject(),
97
+ transactionCreation: new Subject(),
98
+ timelineCreation: new Subject(),
99
99
  ...store?.subject,
100
100
  },
101
101
 
@@ -120,7 +120,7 @@ export const createStore = (name: string, store: Store | null = null): Store =>
120
120
  } satisfies Store
121
121
 
122
122
  store?.atoms.forEach((atom) => {
123
- const copiedAtom = { ...atom, subject: new Rx.Subject() } satisfies Atom<any>
123
+ const copiedAtom = { ...atom, subject: new Subject() } satisfies Atom<any>
124
124
  copiedStore.atoms = HAMT.set(atom.key, copiedAtom, copiedStore.atoms)
125
125
  })
126
126
  store?.readonlySelectors.forEach((selector) => {
@@ -0,0 +1,24 @@
1
+ type Subscriber<T> = (value: T) => void
2
+
3
+ export class Subject<T> {
4
+ public subscribers: Subscriber<T>[] = []
5
+
6
+ public subscribe(subscriber: Subscriber<T>): { unsubscribe: () => void } {
7
+ this.subscribers.push(subscriber)
8
+ const unsubscribe = () => this.unsubscribe(subscriber)
9
+ return { unsubscribe }
10
+ }
11
+
12
+ private unsubscribe(subscriber: Subscriber<T>) {
13
+ const subscriberIndex = this.subscribers.indexOf(subscriber)
14
+ if (subscriberIndex !== -1) {
15
+ this.subscribers.splice(subscriberIndex, 1)
16
+ }
17
+ }
18
+
19
+ public next(value: T): void {
20
+ for (const subscriber of this.subscribers) {
21
+ subscriber(value)
22
+ }
23
+ }
24
+ }
@@ -1,10 +1,9 @@
1
1
  import HAMT from "hamt_plus"
2
- import * as Rx from "rxjs"
3
2
 
4
3
  import type { ƒn } from "~/packages/anvl/src/function"
5
4
 
6
5
  import type { Store } from "."
7
- import { target, IMPLICIT } from "."
6
+ import { Subject, target, IMPLICIT } from "."
8
7
  import { addAtomToTimeline } from "./timeline/add-atom-to-timeline"
9
8
  import type {
10
9
  StateUpdate,
@@ -39,7 +38,7 @@ export type Timeline = {
39
38
  selectorTime: number | null
40
39
  transactionKey: string | null
41
40
  install: (store: Store) => void
42
- subject: Rx.Subject<
41
+ subject: Subject<
43
42
  TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate
44
43
  >
45
44
  }
@@ -58,7 +57,7 @@ export function timeline__INTERNAL(
58
57
  ...data,
59
58
  history: data?.history.map((update) => ({ ...update })) ?? [],
60
59
  install: (store) => timeline__INTERNAL(options, store, tl),
61
- subject: new Rx.Subject(),
60
+ subject: new Subject(),
62
61
  }
63
62
 
64
63
  const core = target(store)
@@ -1,10 +1,10 @@
1
1
  import HAMT from "hamt_plus"
2
- import * as Rx from "rxjs"
3
2
 
4
3
  import type { ƒn } from "~/packages/anvl/src/function"
5
4
 
6
5
  import type { Store, StoreCore } from "."
7
6
  import {
7
+ Subject,
8
8
  abortTransaction,
9
9
  applyTransaction,
10
10
  buildTransaction,
@@ -18,7 +18,7 @@ export type Transaction<ƒ extends ƒn> = {
18
18
  key: string
19
19
  type: `transaction`
20
20
  install: (store: Store) => void
21
- subject: Rx.Subject<TransactionUpdate<ƒ>>
21
+ subject: Subject<TransactionUpdate<ƒ>>
22
22
  run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>
23
23
  }
24
24
 
@@ -48,7 +48,7 @@ export function transaction__INTERNAL<ƒ extends ƒn>(
48
48
  }
49
49
  },
50
50
  install: (store) => transaction__INTERNAL(options, store),
51
- subject: new Rx.Subject(),
51
+ subject: new Subject(),
52
52
  }
53
53
  const core = target(store)
54
54
  core.transactions = HAMT.set(
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  export const StoreContext = React.createContext<AtomIO.Store>(
6
5
  AtomIO.__INTERNAL__.IMPLICIT.STORE,
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  import type { Modifier } from "~/packages/anvl/src/function"
6
5
 
@@ -1,10 +1,9 @@
1
- import type { FC } from "react"
2
- import { useRef } from "react"
3
-
4
1
  import { atom, __INTERNAL__ } from "atom.io"
5
2
  import type { StoreHooks } from "atom.io/react"
6
3
  import { useI, useO, useIO } from "atom.io/react"
7
4
  import { LayoutGroup, motion, spring } from "framer-motion"
5
+ import { useRef } from "react"
6
+ import type { FC } from "react"
8
7
 
9
8
  import { TokenList } from "./TokenList"
10
9
  import { lazyLocalStorageEffect } from "../web-effects"
@@ -1,7 +1,6 @@
1
- import type { FC } from "react"
2
-
3
1
  import type { ReadonlySelectorToken, StateToken } from "atom.io"
4
2
  import type { StoreHooks } from "atom.io/react"
3
+ import type { FC } from "react"
5
4
 
6
5
  import { isPlainJson } from "~/packages/anvl/src/json"
7
6
  import { ElasticInput } from "~/packages/hamr/src/react-elastic-input"
@@ -1,6 +1,3 @@
1
- import type { FC } from "react"
2
- import { Fragment } from "react"
3
-
4
1
  import type {
5
2
  AtomToken,
6
3
  ReadonlySelectorToken,
@@ -9,6 +6,8 @@ import type {
9
6
  } from "atom.io"
10
7
  import { getState } from "atom.io"
11
8
  import type { StoreHooks } from "atom.io/react"
9
+ import { Fragment } from "react"
10
+ import type { FC } from "react"
12
11
 
13
12
  import { recordToEntries } from "~/packages/anvl/src/object"
14
13
 
@@ -1,7 +1,6 @@
1
+ import type { StoreHooks } from "atom.io/react"
1
2
  import type { FC, ReactNode } from "react"
2
3
  import { useEffect } from "react"
3
-
4
- import type { StoreHooks } from "atom.io/react"
5
4
  import { Link, MemoryRouter, useLocation } from "react-router-dom"
6
5
 
7
6
  import { ErrorBoundary } from "~/packages/hamr/src/react-error-boundary"
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AR from "atom.io/react"
2
+ import * as React from "react"
4
3
  import type { Socket } from "socket.io-client"
5
4
  import { io } from "socket.io-client"
6
5
 
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  import type { Json } from "~/packages/anvl/src/json"
6
5
 
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  import type { Json } from "~/packages/anvl/src/json"
6
5
 
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  import type { Json } from "~/packages/anvl/src/json"
6
5
 
@@ -1,6 +1,5 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
2
+ import * as React from "react"
4
3
 
5
4
  import type { Json } from "~/packages/anvl/src/json"
6
5
 
@@ -1,7 +1,6 @@
1
- import * as React from "react"
2
-
3
1
  import * as AtomIO from "atom.io"
4
2
  import { StoreContext } from "atom.io/react"
3
+ import * as React from "react"
5
4
 
6
5
  import type { ƒn } from "~/packages/anvl/src/function"
7
6
 
@@ -1,13 +1,12 @@
1
1
  import * as http from "http"
2
2
 
3
- import * as React from "react"
4
-
5
3
  import { prettyDOM, render, type RenderResult } from "@testing-library/react"
6
4
  import * as AtomIO from "atom.io"
7
5
  import * as AR from "atom.io/react"
8
6
  import * as RTC from "atom.io/realtime-react"
9
7
  import * as RR from "fp-ts/ReadonlyRecord"
10
8
  import * as Happy from "happy-dom"
9
+ import * as React from "react"
11
10
  import * as SocketIO from "socket.io"
12
11
  import type { Socket as ClientSocket } from "socket.io-client"
13
12
  import { io } from "socket.io-client"
package/src/selector.ts CHANGED
@@ -1,8 +1,7 @@
1
- import type * as Rx from "rxjs"
2
-
3
1
  import type { Serializable } from "~/packages/anvl/src/json"
4
2
 
5
3
  import type { ReadonlySelectorToken, SelectorToken } from "."
4
+ import type { Subject } from "./internal"
6
5
  import { selectorFamily__INTERNAL, selector__INTERNAL } from "./internal"
7
6
  import type { Read, Write } from "./transaction"
8
7
 
@@ -41,7 +40,7 @@ export type SelectorFamily<T, K extends Serializable = Serializable> = ((
41
40
  ) => SelectorToken<T>) & {
42
41
  key: string
43
42
  type: `selector_family`
44
- subject: Rx.Subject<SelectorToken<T>>
43
+ subject: Subject<SelectorToken<T>>
45
44
  }
46
45
 
47
46
  export type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((
@@ -49,7 +48,7 @@ export type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = (
49
48
  ) => ReadonlySelectorToken<T>) & {
50
49
  key: string
51
50
  type: `readonly_selector_family`
52
- subject: Rx.Subject<ReadonlySelectorToken<T>>
51
+ subject: Subject<ReadonlySelectorToken<T>>
53
52
  }
54
53
 
55
54
  export function selectorFamily<T, K extends Serializable>(