atom.io 0.6.1 → 0.6.2
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.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/timeline.ts +1 -1
- package/json/dist/index.d.mts +0 -18
- package/json/dist/index.d.ts +0 -18
- package/json/dist/index.js +0 -51
- package/json/dist/index.js.map +0 -1
- package/json/dist/index.mjs +0 -15
- package/json/dist/index.mjs.map +0 -1
- package/react/dist/index.d.mts +0 -24
- package/react/dist/index.d.ts +0 -24
- package/react/dist/index.js +0 -83
- package/react/dist/index.js.map +0 -1
- package/react/dist/index.mjs +0 -41
- package/react/dist/index.mjs.map +0 -1
- package/react-devtools/dist/index.css +0 -26
- package/react-devtools/dist/index.css.map +0 -1
- package/react-devtools/dist/index.d.mts +0 -15
- package/react-devtools/dist/index.d.ts +0 -15
- package/react-devtools/dist/index.js +0 -1582
- package/react-devtools/dist/index.js.map +0 -1
- package/react-devtools/dist/index.mjs +0 -1554
- package/react-devtools/dist/index.mjs.map +0 -1
- package/realtime/dist/index.d.mts +0 -27
- package/realtime/dist/index.d.ts +0 -27
- package/realtime/dist/index.js +0 -191
- package/realtime/dist/index.js.map +0 -1
- package/realtime/dist/index.mjs +0 -152
- package/realtime/dist/index.mjs.map +0 -1
- package/realtime-react/dist/index.d.mts +0 -45
- package/realtime-react/dist/index.d.ts +0 -45
- package/realtime-react/dist/index.js +0 -213
- package/realtime-react/dist/index.js.map +0 -1
- package/realtime-react/dist/index.mjs +0 -168
- package/realtime-react/dist/index.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/realtime-react/realtime-context.tsx","../../src/realtime-react/realtime-state.ts","../../src/realtime-react/use-pull.ts","../../src/react/store-context.tsx","../../src/realtime-react/use-pull-family.ts","../../src/realtime-react/use-pull-family-member.ts","../../src/realtime-react/use-push.ts","../../src/realtime-react/use-server-action.ts","../../src/realtime-react/realtime-hooks.ts"],"sourcesContent":["import * as React from \"react\"\n\nimport * as AR from \"atom.io/react\"\nimport type { Socket } from \"socket.io-client\"\nimport { io } from \"socket.io-client\"\n\nimport { myIdState__INTERNAL } from \"./realtime-state\"\n\nexport const RealtimeContext = React.createContext<{ socket: Socket }>({\n socket: io(),\n})\n\nexport const RealtimeProvider: React.FC<{\n children: React.ReactNode\n socket: Socket\n}> = ({ children, socket }) => {\n const setMyId = AR.useI(myIdState__INTERNAL)\n React.useEffect(() => {\n socket.on(`connect`, () => {\n setMyId(socket.id)\n })\n socket.on(`disconnect`, () => {\n setMyId(null)\n })\n }, [socket, setMyId])\n return (\n <RealtimeContext.Provider value={{ socket }}>\n {children}\n </RealtimeContext.Provider>\n )\n}\n","import * as AtomIO from \"atom.io\"\n\nexport const myIdState__INTERNAL = AtomIO.atom<string | null>({\n key: `myId__INTERNAL`,\n default: null,\n})\nexport const myIdState = AtomIO.selector<string | null>({\n key: `myId`,\n get: ({ get }) => get(myIdState__INTERNAL),\n})\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePull<J extends Json>(token: AtomIO.StateToken<J>): void {\n const { socket } = React.useContext(RealtimeContext)\n const store = React.useContext(StoreContext)\n React.useEffect(() => {\n socket.on(`serve:${token.key}`, (data: J) => {\n AtomIO.setState(token, data, store)\n })\n socket.emit(`sub:${token.key}`)\n return () => {\n socket.off(`serve:${token.key}`)\n socket.emit(`unsub:${token.key}`)\n }\n }, [token.key])\n}\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\n\nexport const StoreContext = React.createContext<AtomIO.Store>(\n AtomIO.__INTERNAL__.IMPLICIT.STORE\n)\n\nexport const StoreProvider: React.FC<{\n children: React.ReactNode\n store?: AtomIO.Store\n}> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (\n <StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePullFamily<J extends Json>(\n family: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>\n): void {\n const { socket } = React.useContext(RealtimeContext)\n const store = React.useContext(StoreContext)\n React.useEffect(() => {\n socket.on(`serve:${family.key}`, (key: Json, data: J) => {\n AtomIO.setState(family(key), data, store)\n })\n socket?.emit(`sub:${family.key}`)\n return () => {\n socket?.off(`serve:${family.key}`)\n socket?.emit(`unsub:${family.key}`)\n }\n }, [family.key])\n}\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePullFamilyMember<J extends Json>(\n family: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n subKey: AtomIO.Serializable\n): void {\n const token = family(subKey)\n const { socket } = React.useContext(RealtimeContext)\n const store = React.useContext(StoreContext)\n React.useEffect(() => {\n socket?.on(`serve:${token.key}`, (data: J) => {\n AtomIO.setState(family(subKey), data, store)\n })\n socket?.emit(`sub:${family.key}`, subKey)\n return () => {\n socket?.off(`serve:${token.key}`)\n socket?.emit(`unsub:${token.key}`)\n }\n }, [family.key])\n}\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\n\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { RealtimeContext } from \"./realtime-context\"\nimport { StoreContext } from \"../react\"\n\nexport function usePush<J extends Json>(token: AtomIO.StateToken<J>): void {\n const { socket } = React.useContext(RealtimeContext)\n const store = React.useContext(StoreContext)\n React.useEffect(() => {\n socket.emit(`claim:${token.key}`)\n AtomIO.subscribe(\n token,\n ({ newValue }) => {\n socket.emit(`pub:${token.key}`, newValue)\n },\n store\n )\n return () => {\n socket.emit(`unclaim:${token.key}`)\n }\n }, [token.key])\n}\n","import * as React from \"react\"\n\nimport * as AtomIO from \"atom.io\"\nimport { StoreContext } from \"atom.io/react\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\n\nimport { RealtimeContext } from \"./realtime-context\"\n\nconst TX_SUBS = new Map<string, number>()\nexport function useServerAction<ƒ extends ƒn>(\n token: AtomIO.TransactionToken<ƒ>\n): (...parameters: Parameters<ƒ>) => ReturnType<ƒ> {\n const store = React.useContext(StoreContext)\n const { socket } = React.useContext(RealtimeContext)\n React.useEffect(() => {\n const count = TX_SUBS.get(token.key) ?? 0\n TX_SUBS.set(token.key, count + 1)\n const unsubscribe =\n count === 0\n ? AtomIO.subscribeToTransaction(\n token,\n (update) => socket.emit(`tx:${token.key}`, update),\n store\n )\n : () => null\n return () => {\n const newCount = TX_SUBS.get(token.key) ?? 0\n TX_SUBS.set(token.key, newCount - 1)\n unsubscribe()\n }\n }, [token.key])\n return AtomIO.runTransaction(token, store)\n}\n","import type * as AtomIO from \"atom.io\"\n\nimport type { ƒn } from \"~/packages/anvl/src/function\"\nimport type { Json } from \"~/packages/anvl/src/json\"\n\nimport { usePull } from \"./use-pull\"\nimport { usePullFamily } from \"./use-pull-family\"\nimport { usePullFamilyMember } from \"./use-pull-family-member\"\nimport { usePush } from \"./use-push\"\nimport { useServerAction } from \"./use-server-action\"\n\nexport type RealtimeHooks = {\n usePull: <J extends Json>(token: AtomIO.StateToken<J>) => void\n usePullFamily: <J extends Json>(\n family: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>\n ) => void\n usePullFamilyMember: <J extends Json>(\n family: AtomIO.AtomFamily<J> | AtomIO.SelectorFamily<J>,\n subKey: string\n ) => void\n usePush: <J extends Json>(token: AtomIO.StateToken<J>) => void\n useServerAction: <ƒ extends ƒn>(\n token: AtomIO.TransactionToken<ƒ>\n ) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>\n}\n\nexport const realtimeHooks: RealtimeHooks = {\n usePull,\n usePullFamily,\n usePullFamilyMember,\n usePush,\n useServerAction,\n}\n\nexport * from \"./use-pull\"\nexport * from \"./use-pull-family\"\nexport * from \"./use-pull-family-member\"\nexport * from \"./use-push\"\nexport * from \"./use-server-action\"\n"],"mappings":";AAAA,YAAY,WAAW;AAEvB,YAAY,QAAQ;AAEpB,SAAS,UAAU;;;ACJnB,YAAY,YAAY;AAEjB,IAAM,sBAA6B,YAAoB;AAAA,EAC5D,KAAK;AAAA,EACL,SAAS;AACX,CAAC;AACM,IAAM,YAAmB,gBAAwB;AAAA,EACtD,KAAK;AAAA,EACL,KAAK,CAAC,EAAE,IAAI,MAAM,IAAI,mBAAmB;AAC3C,CAAC;;;ADiBG;AAlBG,IAAM,kBAAwB,oBAAkC;AAAA,EACrE,QAAQ,GAAG;AACb,CAAC;AAEM,IAAM,mBAGR,CAAC,EAAE,UAAU,OAAO,MAAM;AAC7B,QAAM,UAAa,QAAK,mBAAmB;AAC3C,EAAM,gBAAU,MAAM;AACpB,WAAO,GAAG,WAAW,MAAM;AACzB,cAAQ,OAAO,EAAE;AAAA,IACnB,CAAC;AACD,WAAO,GAAG,cAAc,MAAM;AAC5B,cAAQ,IAAI;AAAA,IACd,CAAC;AAAA,EACH,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,OAAO,GACvC,UACH;AAEJ;;;AE9BA,YAAYA,YAAW;AAEvB,YAAYC,aAAY;;;ACFxB,YAAYC,YAAW;AAEvB,YAAYC,aAAY;AAUtB,gBAAAC,YAAA;AARK,IAAM,eAAqB;AAAA,EACzB,qBAAa,SAAS;AAC/B;;;ADGO,SAAS,QAAwB,OAAmC;AACzE,QAAM,EAAE,OAAO,IAAU,kBAAW,eAAe;AACnD,QAAM,QAAc,kBAAW,YAAY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AAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,MAAM,GAAG,CAAC;AACd,SAAc,uBAAe,OAAO,KAAK;AAC3C;;;ACPO,IAAM,gBAA+B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["React","AtomIO","React","AtomIO","jsx","React","AtomIO","React","AtomIO","React","AtomIO","React","AtomIO","StoreContext","StoreContext","_a"]}
|