atom.io 0.13.0 โ†’ 0.14.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 (64) hide show
  1. package/dist/index.cjs +9 -74
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +4 -4
  4. package/dist/index.d.ts +4 -4
  5. package/dist/index.js +11 -74
  6. package/dist/index.js.map +1 -1
  7. package/dist/metafile-cjs.json +1 -1
  8. package/dist/metafile-esm.json +1 -1
  9. package/internal/dist/index.cjs +802 -730
  10. package/internal/dist/index.cjs.map +1 -1
  11. package/internal/dist/index.d.cts +9 -2
  12. package/internal/dist/index.d.ts +9 -2
  13. package/internal/dist/index.js +800 -731
  14. package/internal/dist/index.js.map +1 -1
  15. package/internal/dist/metafile-cjs.json +1 -1
  16. package/internal/dist/metafile-esm.json +1 -1
  17. package/internal/src/atom/create-atom.ts +3 -2
  18. package/internal/src/mutable/create-mutable-atom.ts +3 -2
  19. package/internal/src/mutable/tracker.ts +6 -4
  20. package/internal/src/selector/register-selector.ts +1 -1
  21. package/internal/src/selector/update-selector-atoms.ts +3 -3
  22. package/internal/src/subscribe/index.ts +3 -0
  23. package/internal/src/subscribe/recall-state.ts +0 -6
  24. package/internal/src/subscribe/subscribe-to-state.ts +47 -0
  25. package/internal/src/subscribe/subscribe-to-timeline.ts +28 -0
  26. package/internal/src/subscribe/subscribe-to-transaction.ts +33 -0
  27. package/package.json +8 -8
  28. package/react/dist/index.cjs +39 -1
  29. package/react/dist/index.cjs.map +1 -1
  30. package/react/dist/index.d.cts +9 -2
  31. package/react/dist/index.d.ts +9 -2
  32. package/react/dist/index.js +41 -4
  33. package/react/dist/index.js.map +1 -1
  34. package/react/dist/metafile-cjs.json +1 -1
  35. package/react/dist/metafile-esm.json +1 -1
  36. package/react/src/store-hooks.ts +52 -3
  37. package/react-devtools/dist/index.cjs.map +1 -1
  38. package/react-devtools/dist/index.js.map +1 -1
  39. package/react-devtools/dist/metafile-cjs.json +1 -1
  40. package/react-devtools/dist/metafile-esm.json +1 -1
  41. package/realtime-client/dist/index.cjs +8 -7
  42. package/realtime-client/dist/index.cjs.map +1 -1
  43. package/realtime-client/dist/index.d.cts +3 -2
  44. package/realtime-client/dist/index.d.ts +3 -2
  45. package/realtime-client/dist/index.js +3 -2
  46. package/realtime-client/dist/index.js.map +1 -1
  47. package/realtime-client/dist/metafile-cjs.json +1 -1
  48. package/realtime-client/dist/metafile-esm.json +1 -1
  49. package/realtime-client/src/use-push.ts +4 -4
  50. package/realtime-client/src/use-server-action.ts +4 -4
  51. package/realtime-server/dist/index.cjs +46 -25
  52. package/realtime-server/dist/index.cjs.map +1 -1
  53. package/realtime-server/dist/index.d.cts +5 -5
  54. package/realtime-server/dist/index.d.ts +5 -5
  55. package/realtime-server/dist/index.js +38 -17
  56. package/realtime-server/dist/index.js.map +1 -1
  57. package/realtime-server/dist/metafile-cjs.json +1 -1
  58. package/realtime-server/dist/metafile-esm.json +1 -1
  59. package/realtime-server/src/hook-composition/expose-family.ts +7 -3
  60. package/realtime-server/src/hook-composition/expose-mutable-family.ts +13 -5
  61. package/realtime-server/src/hook-composition/expose-mutable.ts +11 -3
  62. package/realtime-server/src/hook-composition/expose-single.ts +6 -2
  63. package/realtime-server/src/hook-composition/receive-transaction.ts +14 -5
  64. package/src/subscribe.ts +37 -91
package/dist/index.cjs CHANGED
@@ -137,80 +137,17 @@ var Silo = class {
137
137
  }
138
138
  };
139
139
  function subscribe(token, handleUpdate, key = Math.random().toString(36).slice(2), store = Internal3.IMPLICIT.STORE) {
140
- const state = Internal3.withdraw(token, store);
141
- if (state === void 0) {
142
- throw new Error(
143
- `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
144
- );
140
+ switch (token.type) {
141
+ case `atom`:
142
+ case `readonly_selector`:
143
+ case `selector`:
144
+ return Internal3.subscribeToState(token, handleUpdate, key, store);
145
+ case `transaction`:
146
+ return Internal3.subscribeToTransaction(token, handleUpdate, key, store);
147
+ case `timeline`:
148
+ return Internal3.subscribeToTimeline(token, handleUpdate, key, store);
145
149
  }
146
- const unsubFunction = state.subject.subscribe(key, handleUpdate);
147
- store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
148
- const dependencyUnsubFunctions = state.type !== `atom` ? Internal3.subscribeToRootAtoms(state, store) : null;
149
- const unsubscribe = dependencyUnsubFunctions === null ? () => {
150
- store.logger.info(
151
- `\u{1F648}`,
152
- state.type,
153
- state.key,
154
- `Removing subscription "${key}"`
155
- );
156
- unsubFunction();
157
- } : () => {
158
- store.logger.info(
159
- `\u{1F648}`,
160
- state.type,
161
- state.key,
162
- `Removing subscription "${key}"`
163
- );
164
- unsubFunction();
165
- for (const unsubFromDependency of dependencyUnsubFunctions) {
166
- unsubFromDependency();
167
- }
168
- };
169
- return unsubscribe;
170
150
  }
171
- var subscribeToTransaction = (token, handleUpdate, key = Math.random().toString(36).slice(2), store = Internal3.IMPLICIT.STORE) => {
172
- const tx = Internal3.withdraw(token, store);
173
- if (tx === void 0) {
174
- throw new Error(
175
- `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
176
- );
177
- }
178
- store.logger.info(
179
- `\u{1F440}`,
180
- `transaction`,
181
- token.key,
182
- `Adding subscription "${key}"`
183
- );
184
- const unsubscribe = tx.subject.subscribe(key, handleUpdate);
185
- return () => {
186
- store.logger.info(
187
- `\u{1F648}`,
188
- `transaction`,
189
- token.key,
190
- `Removing subscription "${key}"`
191
- );
192
- unsubscribe();
193
- };
194
- };
195
- var subscribeToTimeline = (token, handleUpdate, key = Math.random().toString(36).slice(2), store = Internal3.IMPLICIT.STORE) => {
196
- const tl = Internal3.withdraw(token, store);
197
- if (tl === void 0) {
198
- throw new Error(
199
- `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
200
- );
201
- }
202
- store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
203
- const unsubscribe = tl.subject.subscribe(key, handleUpdate);
204
- return () => {
205
- store.logger.info(
206
- `\u{1F648}`,
207
- `timeline`,
208
- token.key,
209
- `Removing subscription "${key}" from timeline`
210
- );
211
- unsubscribe();
212
- };
213
- };
214
151
  var timeline = (options) => {
215
152
  return Internal3.createTimeline(options, Internal3.IMPLICIT.STORE);
216
153
  };
@@ -248,8 +185,6 @@ exports.setState = setState;
248
185
  exports.simpleLog = simpleLog;
249
186
  exports.simpleLogger = simpleLogger;
250
187
  exports.subscribe = subscribe;
251
- exports.subscribeToTimeline = subscribeToTimeline;
252
- exports.subscribeToTransaction = subscribeToTransaction;
253
188
  exports.timeline = timeline;
254
189
  exports.transaction = transaction;
255
190
  exports.undo = undo;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/atom.ts","../src/dispose.ts","../src/get-state.ts","../src/logger.ts","../src/selector.ts","../src/set-state.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["Internal","IMPLICIT","createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","withdraw","createTimeline","timeTravel","timeline","createTransaction"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AA8BA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,SAAS,SAAS,KAAK;AAAA,EACjD;AACA,SAAO,WAAc,SAAS,QAAW,SAAS,KAAK;AACxD;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,SAAS,SAAS,KAAK;AAAA,EACvD;AACA,SAAO,iBAAuB,SAAS,SAAS,KAAK;AACtD;;;AClGA,YAAY,cAAc;AAInB,SAAS,QACf,OACA,QAAiC,kBAAS,OACnC;AACP,UAAQ,MAAM,MAAM;AAAA,IACnB,KAAK;AACJ,MAAS,oBAAW,OAAO,KAAK;AAChC;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ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AU,kBAAAQ,iBAAgB,cAAAC,mBAAkB;AAoB9C,IAAM,WAAW,CAAC,YAA4C;AACpE,SAAOD,gBAAe,SAASR,UAAS,KAAK;AAC9C;AAEO,IAAM,OAAO,CAACU,cAAkC;AACtD,EAAAD,YAAW,WAAWC,WAAUV,UAAS,KAAK;AAC/C;AAEO,IAAM,OAAO,CAACU,cAAkC;AACtD,EAAAD,YAAW,YAAYC,WAAUV,UAAS,KAAK;AAChD;;;ACnCA,SAAS,YAAAA,WAAU,qBAAAW,oBAAmB,YAAAJ,iBAAgB;AA8C/C,SAAS,YACf,SACsB;AACtB,SAAOI,mBAAkB,SAASX,UAAS,KAAK;AACjD;AAEO,IAAM,iBACZ,CAAe,OAA4B,QAAeA,UAAS,UACnE,IAAI,eAA6C;AAChD,QAAM,KAAKO,UAAS,OAAO,KAAK;AAChC,MAAI,IAAI;AACP,WAAO,GAAG,IAAI,GAAG,UAAU;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACT,2BAA2B,MAAM,GAAG,sCAAsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD","sourcesContent":["import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n// biome-ignore format: complex intersection\nexport type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = \n\t& JsonInterface<T, J>\n\t& Omit<AtomOptions<T>, `default`> \n\t& { \n\t\t\tdefault: ()\t=> T\n\t\t\tmutable: true\n\t\t}\n\nexport function atom<T extends Transceiver<any>, J extends Json.Serializable>(\n\toptions: MutableAtomOptions<T, J>,\n): MutableAtomToken<T, J>\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T>\nexport function atom<T>(\n\toptions: AtomOptions<any> | MutableAtomOptions<any, any>,\n): AtomToken<any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtom(options, IMPLICIT.STORE)\n\t}\n\treturn createAtom<T>(options, undefined, IMPLICIT.STORE)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n// biome-ignore format: intersection\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n> = \n\t& AtomFamilyOptions<T, K>\n\t& JsonInterface<T, J>\n\t& { mutable: true }\n\n// biome-ignore format: intersection\nexport type MutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends Json.Serializable,\n> = \n\t& JsonInterface<Core, SerializableCore>\n\t& ((key: Key) => MutableAtomToken<Core, SerializableCore>) \n\t& {\n\t\t\tkey: `${string}::mutable`\n\t\t\ttype: `atom_family`\n\t\t\tsubject: Subject<MutableAtomToken<Core, SerializableCore>>\n\t\t}\n\nexport function atomFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,\n): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtomFamily(options, IMPLICIT.STORE)\n\t}\n\treturn createAtomFamily<T, K>(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function dispose(\n\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\t\tInternal.deleteAtom(token, store)\n\t\t\tbreak\n\t\tcase `selector`:\n\t\tcase `readonly_selector`:\n\t\t\tInternal.deleteSelector(token, store)\n\t\t\tbreak\n\t}\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function getState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): T {\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\treturn Internal.readOrComputeValue(state, store)\n}\n","const LoggerIconDictionary = {\n\t\"โŒ›\": `Timeline event fully captured`,\n\t\"โฉ\": `Timeline redo`,\n\t\"โช\": `Timeline undo`,\n\t\"โญ๏ธ\": `Transaction redo`,\n\t\"โฎ๏ธ\": `Transaction undo`,\n\t\"โณ\": `Timeline event partially captured`,\n\t\"โน๏ธ\": `Time-travel complete`,\n\t\"๐Ÿ’\": `Notice`,\n\t\"๐Ÿ”„\": `Realtime transaction synchronized`,\n\t\"โœ…\": `Realtime transaction success`,\n\t\"โœจ\": `Computation complete`,\n\t\"โŒ\": `Conflict prevents attempted action`,\n\t\"โญ•\": `Operation start`,\n\t\"๐Ÿž\": `Possible bug in AtomIO`,\n\t\"๐Ÿ‘€\": `Subscription added`,\n\t\"๐Ÿ‘ช\": `Family member added`,\n\t\"๐Ÿ“\": `Stow update`,\n\t\"๐Ÿ“ƒ\": `Copy mutable`,\n\t\"๐Ÿ“–\": `Read state`,\n\t\"๐Ÿ“\": `Write state`,\n\t\"๐Ÿ“ข\": `Notify subscribers`,\n\t\"๐Ÿ”Œ\": `Register dependency`,\n\t\"๐Ÿ”\": `Discover root`,\n\t\"๐Ÿ”ฅ\": `Delete state`,\n\t\"๐Ÿ”ง\": `Create mutable atom`,\n\t\"๐Ÿ”จ\": `Create immutable atom`,\n\t\"๐Ÿ”ด\": `Operation complete`,\n\t\"๐Ÿ—‘\": `Evict cached value`,\n\t\"๐Ÿ’ฅ\": `Caught`,\n\t\"๐Ÿ™ˆ\": `Subscription canceled`,\n\t\"๐Ÿ›„\": `Apply transaction`,\n\t\"๐Ÿ› ๏ธ\": `Install atom into store`,\n\t\"๐Ÿ›ซ\": `Begin transaction`,\n\t\"๐Ÿ›ฌ\": `Complete transaction`,\n\t\"๐Ÿงฎ\": `Computing selector`,\n\t\"๐Ÿงน\": `Prepare to evict`,\n\t\"๐Ÿช‚\": `Abort transaction`,\n} as const\nexport type LoggerIcon = keyof typeof LoggerIconDictionary\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\ttokenType:\n\t\t| `atom`\n\t\t| `readonly_selector`\n\t\t| `selector`\n\t\t| `state`\n\t\t| `timeline`\n\t\t| `transaction`\n\t\t| `unknown`,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (...params: Parameters<LogFn>) => boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, tokenType, tokenKey, message, ...rest) => {\n\t\tconsole[logLevel](`${icon} ${tokenType} \"${tokenKey}\" ${message}`, ...rest)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic constructor(\n\t\tpublic logLevel: `error` | `info` | `warn` | null,\n\t\tprivate readonly filter?: LogFilter,\n\t\tprivate readonly logger: Logger = simpleLogger,\n\t) {}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel !== null) {\n\t\t\tthis.logger.error(...args)\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {\n\t\t\tthis.logger.info(...args)\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (\n\t\t\t(this.filter?.(...args) ?? true) &&\n\t\t\tthis.logLevel !== `error` &&\n\t\t\tthis.logLevel !== null\n\t\t) {\n\t\t\tthis.logger.warn(...args)\n\t\t}\n\t}\n}\n","import type { Subject } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector, createSelectorFamily } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn createSelector(options, undefined, IMPLICIT.STORE)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn createSelectorFamily(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { StateToken } from \".\"\n\nexport function setState<T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tconst rejection = Internal.openOperation(token, store)\n\tif (rejection) {\n\t\treturn\n\t}\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\tInternal.setAtomOrSelector(state, value, store)\n\tInternal.closeOperation(store)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tcreateTimeline,\n\tcreateTransaction,\n\ttimeTravel,\n} from \"atom.io/internal\"\n\nimport type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport class Silo {\n\tpublic store: Store\n\tpublic atom: typeof atom\n\tpublic atomFamily: typeof atomFamily\n\tpublic selector: typeof selector\n\tpublic selectorFamily: typeof selectorFamily\n\tpublic transaction: typeof transaction\n\tpublic timeline: typeof timeline\n\tpublic getState: typeof getState\n\tpublic setState: typeof setState\n\tpublic subscribe: typeof subscribe\n\tpublic undo: typeof undo\n\tpublic redo: typeof redo\n\tpublic constructor(name: string, fromStore: Store | null = null) {\n\t\tconst s = new Store(name, fromStore)\n\t\tthis.store = s\n\t\tthis.atom = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtom(options, s)\n\t\t\t}\n\t\t\treturn createAtom(options, undefined, s)\n\t\t}\n\t\tthis.atomFamily = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtomFamily(options, s) as any\n\t\t\t}\n\t\t\treturn createAtomFamily(options, s)\n\t\t}\n\t\tthis.selector = (options) => createSelector(options, undefined, s) as any\n\t\tthis.selectorFamily = (options) => createSelectorFamily(options, s) as any\n\t\tthis.transaction = (options) => createTransaction(options, s)\n\t\tthis.timeline = (options) => createTimeline(options, s)\n\t\tthis.getState = (token) => getState(token, s)\n\t\tthis.setState = (token, newValue) => setState(token, newValue, s)\n\t\tthis.subscribe = (token, handler, key) => subscribe(token, handler, key, s)\n\t\tthis.undo = (token) => timeTravel(`backward`, token, s)\n\t\tthis.redo = (token) => timeTravel(`forward`, token, s)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"atom.io/internal\"\n\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n\tฦ’n,\n} from \".\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & {\n\tkey: string\n\tfamily?: FamilyMetadata\n}\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport function subscribe<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore: Store = IMPLICIT.STORE,\n): () => void {\n\tconst state = withdraw<T>(token, store)\n\tif (state === undefined) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst unsubFunction = state.subject.subscribe(key, handleUpdate)\n\tstore.logger.info(`๐Ÿ‘€`, state.type, state.key, `Adding subscription \"${key}\"`)\n\tconst dependencyUnsubFunctions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencyUnsubFunctions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`๐Ÿ™ˆ`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`๐Ÿ™ˆ`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t\t\tfor (const unsubFromDependency of dependencyUnsubFunctions) {\n\t\t\t\t\t\tunsubFromDependency()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n\nexport type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (\n\tdata: TransactionUpdate<ฦ’>,\n) => void\n\nexport const subscribeToTransaction = <ฦ’ extends ฦ’n>(\n\ttoken: TransactionToken<ฦ’>,\n\thandleUpdate: TransactionUpdateHandler<ฦ’>,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tx = withdraw(token, store)\n\tif (tx === undefined) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.logger.info(\n\t\t`๐Ÿ‘€`,\n\t\t`transaction`,\n\t\ttoken.key,\n\t\t`Adding subscription \"${key}\"`,\n\t)\n\tconst unsubscribe = tx.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`๐Ÿ™ˆ`,\n\t\t\t`transaction`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\"`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === undefined) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.logger.info(`๐Ÿ‘€`, `timeline`, token.key, `Adding subscription \"${key}\"`)\n\tconst unsubscribe = tl.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`๐Ÿ™ˆ`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\" from timeline`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n","import type {\n\tTimeline,\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"atom.io/internal\"\nimport { IMPLICIT, createTimeline, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamily, AtomToken } from \".\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n\tshouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn createTimeline(options, IMPLICIT.STORE)\n}\n\nexport const redo = (timeline: TimelineToken): void => {\n\ttimeTravel(`forward`, timeline, IMPLICIT.STORE)\n}\n\nexport const undo = (timeline: TimelineToken): void => {\n\ttimeTravel(`backward`, timeline, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createTransaction, withdraw } from \"atom.io/internal\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken, ฦ’n } from \".\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tupdates: (KeyedStateUpdate<unknown> | TransactionUpdate<ฦ’n>)[]\n\tparams: Parameters<ฦ’>\n\toutput: ReturnType<ฦ’>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ฦ’ extends ฦ’n> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Write<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Act<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors & { run: typeof runTransaction },\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type TransactionOptions<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tdo: Act<ฦ’>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ฦ’> ? ฦ’ : never\n\nexport function transaction<ฦ’ extends ฦ’n>(\n\toptions: TransactionOptions<ฦ’>,\n): TransactionToken<ฦ’> {\n\treturn createTransaction(options, IMPLICIT.STORE)\n}\n\nexport const runTransaction =\n\t<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ฦ’>): ReturnType<ฦ’> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n"]}
1
+ {"version":3,"sources":["../src/atom.ts","../src/dispose.ts","../src/get-state.ts","../src/logger.ts","../src/selector.ts","../src/set-state.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["Internal","IMPLICIT","createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","createTimeline","timeTravel","timeline","createTransaction","withdraw"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AA8BA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,SAAS,SAAS,KAAK;AAAA,EACjD;AACA,SAAO,WAAc,SAAS,QAAW,SAAS,KAAK;AACxD;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WA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AO,iBAAgB,cAAAC,mBAAkB;AAoB9C,IAAM,WAAW,CAAC,YAA4C;AACpE,SAAOD,gBAAe,SAASP,UAAS,KAAK;AAC9C;AAEO,IAAM,OAAO,CAACS,cAAkC;AACtD,EAAAD,YAAW,WAAWC,WAAUT,UAAS,KAAK;AAC/C;AAEO,IAAM,OAAO,CAACS,cAAkC;AACtD,EAAAD,YAAW,YAAYC,WAAUT,UAAS,KAAK;AAChD;;;ACnCA,SAAS,YAAAA,WAAU,qBAAAU,oBAAmB,YAAAC,iBAAgB;AA8C/C,SAAS,YACf,SACsB;AACtB,SAAOD,mBAAkB,SAASV,UAAS,KAAK;AACjD;AAEO,IAAM,iBACZ,CAAe,OAA4B,QAAeA,UAAS,UACnE,IAAI,eAA6C;AAChD,QAAM,KAAKW,UAAS,OAAO,KAAK;AAChC,MAAI,IAAI;AACP,WAAO,GAAG,IAAI,GAAG,UAAU;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACT,2BAA2B,MAAM,GAAG,sCAAsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD","sourcesContent":["import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n// biome-ignore format: complex intersection\nexport type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = \n\t& JsonInterface<T, J>\n\t& Omit<AtomOptions<T>, `default`> \n\t& { \n\t\t\tdefault: ()\t=> T\n\t\t\tmutable: true\n\t\t}\n\nexport function atom<T extends Transceiver<any>, J extends Json.Serializable>(\n\toptions: MutableAtomOptions<T, J>,\n): MutableAtomToken<T, J>\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T>\nexport function atom<T>(\n\toptions: AtomOptions<any> | MutableAtomOptions<any, any>,\n): AtomToken<any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtom(options, IMPLICIT.STORE)\n\t}\n\treturn createAtom<T>(options, undefined, IMPLICIT.STORE)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n// biome-ignore format: intersection\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n> = \n\t& AtomFamilyOptions<T, K>\n\t& JsonInterface<T, J>\n\t& { mutable: true }\n\n// biome-ignore format: intersection\nexport type MutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends Json.Serializable,\n> = \n\t& JsonInterface<Core, SerializableCore>\n\t& ((key: Key) => MutableAtomToken<Core, SerializableCore>) \n\t& {\n\t\t\tkey: `${string}::mutable`\n\t\t\ttype: `atom_family`\n\t\t\tsubject: Subject<MutableAtomToken<Core, SerializableCore>>\n\t\t}\n\nexport function atomFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,\n): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtomFamily(options, IMPLICIT.STORE)\n\t}\n\treturn createAtomFamily<T, K>(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function dispose(\n\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\t\tInternal.deleteAtom(token, store)\n\t\t\tbreak\n\t\tcase `selector`:\n\t\tcase `readonly_selector`:\n\t\t\tInternal.deleteSelector(token, store)\n\t\t\tbreak\n\t}\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function getState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): T {\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\treturn Internal.readOrComputeValue(state, store)\n}\n","const LoggerIconDictionary = {\n\t\"โŒ›\": `Timeline event fully captured`,\n\t\"โฉ\": `Timeline redo`,\n\t\"โช\": `Timeline undo`,\n\t\"โญ๏ธ\": `Transaction redo`,\n\t\"โฎ๏ธ\": `Transaction undo`,\n\t\"โณ\": `Timeline event partially captured`,\n\t\"โน๏ธ\": `Time-travel complete`,\n\t\"๐Ÿ’\": `Notice`,\n\t\"๐Ÿ”„\": `Realtime transaction synchronized`,\n\t\"โœ…\": `Realtime transaction success`,\n\t\"โœจ\": `Computation complete`,\n\t\"โŒ\": `Conflict prevents attempted action`,\n\t\"โญ•\": `Operation start`,\n\t\"๐Ÿž\": `Possible bug in AtomIO`,\n\t\"๐Ÿ‘€\": `Subscription added`,\n\t\"๐Ÿ‘ช\": `Family member added`,\n\t\"๐Ÿ“\": `Stow update`,\n\t\"๐Ÿ“ƒ\": `Copy mutable`,\n\t\"๐Ÿ“–\": `Read state`,\n\t\"๐Ÿ“\": `Write state`,\n\t\"๐Ÿ“ข\": `Notify subscribers`,\n\t\"๐Ÿ”Œ\": `Register dependency`,\n\t\"๐Ÿ”\": `Discover root`,\n\t\"๐Ÿ”ฅ\": `Delete state`,\n\t\"๐Ÿ”ง\": `Create mutable atom`,\n\t\"๐Ÿ”จ\": `Create immutable atom`,\n\t\"๐Ÿ”ด\": `Operation complete`,\n\t\"๐Ÿ—‘\": `Evict cached value`,\n\t\"๐Ÿ’ฅ\": `Caught`,\n\t\"๐Ÿ™ˆ\": `Subscription canceled`,\n\t\"๐Ÿ›„\": `Apply transaction`,\n\t\"๐Ÿ› ๏ธ\": `Install atom into store`,\n\t\"๐Ÿ›ซ\": `Begin transaction`,\n\t\"๐Ÿ›ฌ\": `Complete transaction`,\n\t\"๐Ÿงฎ\": `Computing selector`,\n\t\"๐Ÿงน\": `Prepare to evict`,\n\t\"๐Ÿช‚\": `Abort transaction`,\n} as const\nexport type LoggerIcon = keyof typeof LoggerIconDictionary\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\ttokenType:\n\t\t| `atom`\n\t\t| `readonly_selector`\n\t\t| `selector`\n\t\t| `state`\n\t\t| `timeline`\n\t\t| `transaction`\n\t\t| `unknown`,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (...params: Parameters<LogFn>) => boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, tokenType, tokenKey, message, ...rest) => {\n\t\tconsole[logLevel](`${icon} ${tokenType} \"${tokenKey}\" ${message}`, ...rest)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic constructor(\n\t\tpublic logLevel: `error` | `info` | `warn` | null,\n\t\tprivate readonly filter?: LogFilter,\n\t\tprivate readonly logger: Logger = simpleLogger,\n\t) {}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel !== null) {\n\t\t\tthis.logger.error(...args)\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {\n\t\t\tthis.logger.info(...args)\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (\n\t\t\t(this.filter?.(...args) ?? true) &&\n\t\t\tthis.logLevel !== `error` &&\n\t\t\tthis.logLevel !== null\n\t\t) {\n\t\t\tthis.logger.warn(...args)\n\t\t}\n\t}\n}\n","import type { Subject } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector, createSelectorFamily } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn createSelector(options, undefined, IMPLICIT.STORE)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn createSelectorFamily(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { StateToken } from \".\"\n\nexport function setState<T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tconst rejection = Internal.openOperation(token, store)\n\tif (rejection) {\n\t\treturn\n\t}\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\tInternal.setAtomOrSelector(state, value, store)\n\tInternal.closeOperation(store)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tcreateTimeline,\n\tcreateTransaction,\n\ttimeTravel,\n} from \"atom.io/internal\"\n\nimport type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport class Silo {\n\tpublic store: Store\n\tpublic atom: typeof atom\n\tpublic atomFamily: typeof atomFamily\n\tpublic selector: typeof selector\n\tpublic selectorFamily: typeof selectorFamily\n\tpublic transaction: typeof transaction\n\tpublic timeline: typeof timeline\n\tpublic getState: typeof getState\n\tpublic setState: typeof setState\n\tpublic subscribe: typeof subscribe\n\tpublic undo: typeof undo\n\tpublic redo: typeof redo\n\tpublic constructor(name: string, fromStore: Store | null = null) {\n\t\tconst s = new Store(name, fromStore)\n\t\tthis.store = s\n\t\tthis.atom = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtom(options, s)\n\t\t\t}\n\t\t\treturn createAtom(options, undefined, s)\n\t\t}\n\t\tthis.atomFamily = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtomFamily(options, s) as any\n\t\t\t}\n\t\t\treturn createAtomFamily(options, s)\n\t\t}\n\t\tthis.selector = (options) => createSelector(options, undefined, s) as any\n\t\tthis.selectorFamily = (options) => createSelectorFamily(options, s) as any\n\t\tthis.transaction = (options) => createTransaction(options, s)\n\t\tthis.timeline = (options) => createTimeline(options, s)\n\t\tthis.getState = (token) => getState(token, s)\n\t\tthis.setState = (token, newValue) => setState(token, newValue, s)\n\t\tthis.subscribe = (token, handler, key) => subscribe(token, handler, key, s)\n\t\tthis.undo = (token) => timeTravel(`backward`, token, s)\n\t\tthis.redo = (token) => timeTravel(`forward`, token, s)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\n\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n\tฦ’n,\n} from \".\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & {\n\tkey: string\n\tfamily?: FamilyMetadata\n}\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (\n\tdata: TransactionUpdate<ฦ’>,\n) => void\n\nexport function subscribe<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe<ฦ’ extends ฦ’n>(\n\ttoken: TransactionToken<ฦ’>,\n\thandleUpdate: TransactionUpdateHandler<ฦ’>,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe(\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe(\n\ttoken:\n\t\t| ReadonlySelectorToken<any>\n\t\t| StateToken<any>\n\t\t| TimelineToken\n\t\t| TransactionToken<any>,\n\thandleUpdate: (update: any) => void,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): () => void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\tcase `readonly_selector`:\n\t\tcase `selector`:\n\t\t\treturn subscribeToState(token, handleUpdate, key, store)\n\t\tcase `transaction`:\n\t\t\treturn subscribeToTransaction(token, handleUpdate, key, store)\n\t\tcase `timeline`:\n\t\t\treturn subscribeToTimeline(token, handleUpdate, key, store)\n\t}\n}\n","import type {\n\tTimeline,\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"atom.io/internal\"\nimport { IMPLICIT, createTimeline, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamily, AtomToken } from \".\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n\tshouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn createTimeline(options, IMPLICIT.STORE)\n}\n\nexport const redo = (timeline: TimelineToken): void => {\n\ttimeTravel(`forward`, timeline, IMPLICIT.STORE)\n}\n\nexport const undo = (timeline: TimelineToken): void => {\n\ttimeTravel(`backward`, timeline, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createTransaction, withdraw } from \"atom.io/internal\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken, ฦ’n } from \".\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tupdates: (KeyedStateUpdate<unknown> | TransactionUpdate<ฦ’n>)[]\n\tparams: Parameters<ฦ’>\n\toutput: ReturnType<ฦ’>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ฦ’ extends ฦ’n> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Write<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Act<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors & { run: typeof runTransaction },\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type TransactionOptions<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tdo: Act<ฦ’>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ฦ’> ? ฦ’ : never\n\nexport function transaction<ฦ’ extends ฦ’n>(\n\toptions: TransactionOptions<ฦ’>,\n): TransactionToken<ฦ’> {\n\treturn createTransaction(options, IMPLICIT.STORE)\n}\n\nexport const runTransaction =\n\t<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ฦ’>): ReturnType<ฦ’> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n"]}
package/dist/index.d.cts CHANGED
@@ -192,10 +192,10 @@ type KeyedStateUpdate<T> = StateUpdate<T> & {
192
192
  family?: FamilyMetadata;
193
193
  };
194
194
  type UpdateHandler<T> = (update: StateUpdate<T>) => void;
195
- declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
196
195
  type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (data: TransactionUpdate<ฦ’>) => void;
197
- declare const subscribeToTransaction: <ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, handleUpdate: TransactionUpdateHandler<ฦ’>, key?: string, store?: Store) => (() => void);
198
- declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store) => (() => void);
196
+ declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
197
+ declare function subscribe<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, handleUpdate: TransactionUpdateHandler<ฦ’>, key?: string, store?: Store): () => void;
198
+ declare function subscribe(token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
199
199
 
200
200
  type TimelineToken = {
201
201
  key: string;
@@ -240,4 +240,4 @@ type FamilyMetadata = {
240
240
  subKey: string;
241
241
  };
242
242
 
243
- export { type Act, type AtomEffect, type AtomFamily, type AtomFamilyOptions, AtomIOLogger, type AtomOptions, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type SelectorFamily, type SelectorFamilyOptions, type SelectorOptions, type SelectorToken, Silo, type StateToken, type StateUpdate, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateHandler, type Transactors, type UpdateHandler, type Write, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, type ฦ’n };
243
+ export { type Act, type AtomEffect, type AtomFamily, type AtomFamilyOptions, AtomIOLogger, type AtomOptions, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type SelectorFamily, type SelectorFamilyOptions, type SelectorOptions, type SelectorToken, Silo, type StateToken, type StateUpdate, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateHandler, type Transactors, type UpdateHandler, type Write, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo, type ฦ’n };
package/dist/index.d.ts CHANGED
@@ -192,10 +192,10 @@ type KeyedStateUpdate<T> = StateUpdate<T> & {
192
192
  family?: FamilyMetadata;
193
193
  };
194
194
  type UpdateHandler<T> = (update: StateUpdate<T>) => void;
195
- declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
196
195
  type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (data: TransactionUpdate<ฦ’>) => void;
197
- declare const subscribeToTransaction: <ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, handleUpdate: TransactionUpdateHandler<ฦ’>, key?: string, store?: Store) => (() => void);
198
- declare const subscribeToTimeline: (token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store) => (() => void);
196
+ declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
197
+ declare function subscribe<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, handleUpdate: TransactionUpdateHandler<ฦ’>, key?: string, store?: Store): () => void;
198
+ declare function subscribe(token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
199
199
 
200
200
  type TimelineToken = {
201
201
  key: string;
@@ -240,4 +240,4 @@ type FamilyMetadata = {
240
240
  subKey: string;
241
241
  };
242
242
 
243
- export { type Act, type AtomEffect, type AtomFamily, type AtomFamilyOptions, AtomIOLogger, type AtomOptions, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type SelectorFamily, type SelectorFamilyOptions, type SelectorOptions, type SelectorToken, Silo, type StateToken, type StateUpdate, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateHandler, type Transactors, type UpdateHandler, type Write, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo, type ฦ’n };
243
+ export { type Act, type AtomEffect, type AtomFamily, type AtomFamilyOptions, AtomIOLogger, type AtomOptions, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type SelectorFamily, type SelectorFamilyOptions, type SelectorOptions, type SelectorToken, Silo, type StateToken, type StateUpdate, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateHandler, type Transactors, type UpdateHandler, type Write, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo, type ฦ’n };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Internal3 from 'atom.io/internal';
2
- import { createMutableAtom, IMPLICIT, createAtom, createMutableAtomFamily, createAtomFamily, createSelector, createSelectorFamily, Store, createTransaction, createTimeline, timeTravel, withdraw, subscribeToRootAtoms } from 'atom.io/internal';
2
+ import { createMutableAtom, IMPLICIT, createAtom, createMutableAtomFamily, createAtomFamily, createSelector, createSelectorFamily, Store, createTransaction, createTimeline, timeTravel, subscribeToTimeline, subscribeToTransaction, subscribeToState, withdraw } from 'atom.io/internal';
3
3
 
4
4
  // src/atom.ts
5
5
  function atom(options) {
@@ -116,80 +116,17 @@ var Silo = class {
116
116
  }
117
117
  };
118
118
  function subscribe(token, handleUpdate, key = Math.random().toString(36).slice(2), store = IMPLICIT.STORE) {
119
- const state = withdraw(token, store);
120
- if (state === void 0) {
121
- throw new Error(
122
- `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
123
- );
119
+ switch (token.type) {
120
+ case `atom`:
121
+ case `readonly_selector`:
122
+ case `selector`:
123
+ return subscribeToState(token, handleUpdate, key, store);
124
+ case `transaction`:
125
+ return subscribeToTransaction(token, handleUpdate, key, store);
126
+ case `timeline`:
127
+ return subscribeToTimeline(token, handleUpdate, key, store);
124
128
  }
125
- const unsubFunction = state.subject.subscribe(key, handleUpdate);
126
- store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
127
- const dependencyUnsubFunctions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
128
- const unsubscribe = dependencyUnsubFunctions === null ? () => {
129
- store.logger.info(
130
- `\u{1F648}`,
131
- state.type,
132
- state.key,
133
- `Removing subscription "${key}"`
134
- );
135
- unsubFunction();
136
- } : () => {
137
- store.logger.info(
138
- `\u{1F648}`,
139
- state.type,
140
- state.key,
141
- `Removing subscription "${key}"`
142
- );
143
- unsubFunction();
144
- for (const unsubFromDependency of dependencyUnsubFunctions) {
145
- unsubFromDependency();
146
- }
147
- };
148
- return unsubscribe;
149
129
  }
150
- var subscribeToTransaction = (token, handleUpdate, key = Math.random().toString(36).slice(2), store = IMPLICIT.STORE) => {
151
- const tx = withdraw(token, store);
152
- if (tx === void 0) {
153
- throw new Error(
154
- `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
155
- );
156
- }
157
- store.logger.info(
158
- `\u{1F440}`,
159
- `transaction`,
160
- token.key,
161
- `Adding subscription "${key}"`
162
- );
163
- const unsubscribe = tx.subject.subscribe(key, handleUpdate);
164
- return () => {
165
- store.logger.info(
166
- `\u{1F648}`,
167
- `transaction`,
168
- token.key,
169
- `Removing subscription "${key}"`
170
- );
171
- unsubscribe();
172
- };
173
- };
174
- var subscribeToTimeline = (token, handleUpdate, key = Math.random().toString(36).slice(2), store = IMPLICIT.STORE) => {
175
- const tl = withdraw(token, store);
176
- if (tl === void 0) {
177
- throw new Error(
178
- `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
179
- );
180
- }
181
- store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
182
- const unsubscribe = tl.subject.subscribe(key, handleUpdate);
183
- return () => {
184
- store.logger.info(
185
- `\u{1F648}`,
186
- `timeline`,
187
- token.key,
188
- `Removing subscription "${key}" from timeline`
189
- );
190
- unsubscribe();
191
- };
192
- };
193
130
  var timeline = (options) => {
194
131
  return createTimeline(options, IMPLICIT.STORE);
195
132
  };
@@ -212,6 +149,6 @@ var runTransaction = (token, store = IMPLICIT.STORE) => (...parameters) => {
212
149
  );
213
150
  };
214
151
 
215
- export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, subscribeToTimeline, subscribeToTransaction, timeline, transaction, undo };
152
+ export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, dispose, getState, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
216
153
  //# sourceMappingURL=out.js.map
217
154
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/atom.ts","../src/dispose.ts","../src/get-state.ts","../src/logger.ts","../src/selector.ts","../src/set-state.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["Internal","IMPLICIT","createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","withdraw","createTimeline","timeTravel","timeline","createTransaction"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AA8BA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,SAAS,SAAS,KAAK;AAAA,EACjD;AACA,SAAO,WAAc,SAAS,QAAW,SAAS,KAAK;AACxD;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,SAAS,SAAS,KAAK;AAAA,EACvD;AACA,SAAO,iBAAuB,SAAS,SAAS,KAAK;AACtD;;;AClGA,YAAY,cAAc;AAInB,SAAS,QACf,OACA,QAAiC,kBAAS,OACnC;AACP,UAAQ,MAAM,MAAM;AAAA,IACnB,KAAK;AACJ,MAAS,oBAAW,OAAO,KAAK;AAChC;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,MAAS,wBAAe,OAAO,KAAK;AACpC;AAAA,EACF;AACD;;;ACjBA,YAAYA,eAAc;AAInB,SAAS,SACf,OACA,QAAiC,mBAAS,OACtC;AAPL;AAQC,QAAM,SACL,KAAS,mBAAS,OAAO,KAAK,MAA9B,YACS,kCAAwB,OAAO,KAAK;AAC9C,MAAI,UAAU,QAAW;AACxB,UAAM,IAAa,wBAAc,OAAO,KAAK;AAAA,EAC9C;AACA,SAAgB,6BAAmB,OAAO,KAAK;AAChD;;;AC0BO,IAAM,aAAa,CAAC,QAAQ,QAAQ,OAAO;AAqB3C,IAAM,YACZ,CAAC,aACD,CAAC,MAAM,WAAW,UAAU,YAAY,SAAS;AAChD,UAAQ,QAAQ,EAAE,GAAG,IAAI,IAAI,SAAS,KAAK,QAAQ,KAAK,OAAO,IAAI,GAAG,IAAI;AAC3E;AACM,IAAM,eAAuB;AAAA,EACnC,OAAO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GAAG,UAAU;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACT,2BAA2B,MAAM,GAAG,sCAAsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD","sourcesContent":["import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n// biome-ignore format: complex intersection\nexport type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = \n\t& JsonInterface<T, J>\n\t& Omit<AtomOptions<T>, `default`> \n\t& { \n\t\t\tdefault: ()\t=> T\n\t\t\tmutable: true\n\t\t}\n\nexport function atom<T extends Transceiver<any>, J extends Json.Serializable>(\n\toptions: MutableAtomOptions<T, J>,\n): MutableAtomToken<T, J>\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T>\nexport function atom<T>(\n\toptions: AtomOptions<any> | MutableAtomOptions<any, any>,\n): AtomToken<any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtom(options, IMPLICIT.STORE)\n\t}\n\treturn createAtom<T>(options, undefined, IMPLICIT.STORE)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n// biome-ignore format: intersection\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n> = \n\t& AtomFamilyOptions<T, K>\n\t& JsonInterface<T, J>\n\t& { mutable: true }\n\n// biome-ignore format: intersection\nexport type MutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends Json.Serializable,\n> = \n\t& JsonInterface<Core, SerializableCore>\n\t& ((key: Key) => MutableAtomToken<Core, SerializableCore>) \n\t& {\n\t\t\tkey: `${string}::mutable`\n\t\t\ttype: `atom_family`\n\t\t\tsubject: Subject<MutableAtomToken<Core, SerializableCore>>\n\t\t}\n\nexport function atomFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,\n): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtomFamily(options, IMPLICIT.STORE)\n\t}\n\treturn createAtomFamily<T, K>(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function dispose(\n\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\t\tInternal.deleteAtom(token, store)\n\t\t\tbreak\n\t\tcase `selector`:\n\t\tcase `readonly_selector`:\n\t\t\tInternal.deleteSelector(token, store)\n\t\t\tbreak\n\t}\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function getState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): T {\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\treturn Internal.readOrComputeValue(state, store)\n}\n","const LoggerIconDictionary = {\n\t\"โŒ›\": `Timeline event fully captured`,\n\t\"โฉ\": `Timeline redo`,\n\t\"โช\": `Timeline undo`,\n\t\"โญ๏ธ\": `Transaction redo`,\n\t\"โฎ๏ธ\": `Transaction undo`,\n\t\"โณ\": `Timeline event partially captured`,\n\t\"โน๏ธ\": `Time-travel complete`,\n\t\"๐Ÿ’\": `Notice`,\n\t\"๐Ÿ”„\": `Realtime transaction synchronized`,\n\t\"โœ…\": `Realtime transaction success`,\n\t\"โœจ\": `Computation complete`,\n\t\"โŒ\": `Conflict prevents attempted action`,\n\t\"โญ•\": `Operation start`,\n\t\"๐Ÿž\": `Possible bug in AtomIO`,\n\t\"๐Ÿ‘€\": `Subscription added`,\n\t\"๐Ÿ‘ช\": `Family member added`,\n\t\"๐Ÿ“\": `Stow update`,\n\t\"๐Ÿ“ƒ\": `Copy mutable`,\n\t\"๐Ÿ“–\": `Read state`,\n\t\"๐Ÿ“\": `Write state`,\n\t\"๐Ÿ“ข\": `Notify subscribers`,\n\t\"๐Ÿ”Œ\": `Register dependency`,\n\t\"๐Ÿ”\": `Discover root`,\n\t\"๐Ÿ”ฅ\": `Delete state`,\n\t\"๐Ÿ”ง\": `Create mutable atom`,\n\t\"๐Ÿ”จ\": `Create immutable atom`,\n\t\"๐Ÿ”ด\": `Operation complete`,\n\t\"๐Ÿ—‘\": `Evict cached value`,\n\t\"๐Ÿ’ฅ\": `Caught`,\n\t\"๐Ÿ™ˆ\": `Subscription canceled`,\n\t\"๐Ÿ›„\": `Apply transaction`,\n\t\"๐Ÿ› ๏ธ\": `Install atom into store`,\n\t\"๐Ÿ›ซ\": `Begin transaction`,\n\t\"๐Ÿ›ฌ\": `Complete transaction`,\n\t\"๐Ÿงฎ\": `Computing selector`,\n\t\"๐Ÿงน\": `Prepare to evict`,\n\t\"๐Ÿช‚\": `Abort transaction`,\n} as const\nexport type LoggerIcon = keyof typeof LoggerIconDictionary\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\ttokenType:\n\t\t| `atom`\n\t\t| `readonly_selector`\n\t\t| `selector`\n\t\t| `state`\n\t\t| `timeline`\n\t\t| `transaction`\n\t\t| `unknown`,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (...params: Parameters<LogFn>) => boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, tokenType, tokenKey, message, ...rest) => {\n\t\tconsole[logLevel](`${icon} ${tokenType} \"${tokenKey}\" ${message}`, ...rest)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic constructor(\n\t\tpublic logLevel: `error` | `info` | `warn` | null,\n\t\tprivate readonly filter?: LogFilter,\n\t\tprivate readonly logger: Logger = simpleLogger,\n\t) {}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel !== null) {\n\t\t\tthis.logger.error(...args)\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {\n\t\t\tthis.logger.info(...args)\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (\n\t\t\t(this.filter?.(...args) ?? true) &&\n\t\t\tthis.logLevel !== `error` &&\n\t\t\tthis.logLevel !== null\n\t\t) {\n\t\t\tthis.logger.warn(...args)\n\t\t}\n\t}\n}\n","import type { Subject } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector, createSelectorFamily } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn createSelector(options, undefined, IMPLICIT.STORE)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn createSelectorFamily(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { StateToken } from \".\"\n\nexport function setState<T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tconst rejection = Internal.openOperation(token, store)\n\tif (rejection) {\n\t\treturn\n\t}\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\tInternal.setAtomOrSelector(state, value, store)\n\tInternal.closeOperation(store)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tcreateTimeline,\n\tcreateTransaction,\n\ttimeTravel,\n} from \"atom.io/internal\"\n\nimport type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport class Silo {\n\tpublic store: Store\n\tpublic atom: typeof atom\n\tpublic atomFamily: typeof atomFamily\n\tpublic selector: typeof selector\n\tpublic selectorFamily: typeof selectorFamily\n\tpublic transaction: typeof transaction\n\tpublic timeline: typeof timeline\n\tpublic getState: typeof getState\n\tpublic setState: typeof setState\n\tpublic subscribe: typeof subscribe\n\tpublic undo: typeof undo\n\tpublic redo: typeof redo\n\tpublic constructor(name: string, fromStore: Store | null = null) {\n\t\tconst s = new Store(name, fromStore)\n\t\tthis.store = s\n\t\tthis.atom = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtom(options, s)\n\t\t\t}\n\t\t\treturn createAtom(options, undefined, s)\n\t\t}\n\t\tthis.atomFamily = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtomFamily(options, s) as any\n\t\t\t}\n\t\t\treturn createAtomFamily(options, s)\n\t\t}\n\t\tthis.selector = (options) => createSelector(options, undefined, s) as any\n\t\tthis.selectorFamily = (options) => createSelectorFamily(options, s) as any\n\t\tthis.transaction = (options) => createTransaction(options, s)\n\t\tthis.timeline = (options) => createTimeline(options, s)\n\t\tthis.getState = (token) => getState(token, s)\n\t\tthis.setState = (token, newValue) => setState(token, newValue, s)\n\t\tthis.subscribe = (token, handler, key) => subscribe(token, handler, key, s)\n\t\tthis.undo = (token) => timeTravel(`backward`, token, s)\n\t\tthis.redo = (token) => timeTravel(`forward`, token, s)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, subscribeToRootAtoms, withdraw } from \"atom.io/internal\"\n\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n\tฦ’n,\n} from \".\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & {\n\tkey: string\n\tfamily?: FamilyMetadata\n}\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport function subscribe<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore: Store = IMPLICIT.STORE,\n): () => void {\n\tconst state = withdraw<T>(token, store)\n\tif (state === undefined) {\n\t\tthrow new Error(\n\t\t\t`State \"${token.key}\" not found in this store. Did you forget to initialize with the \"atom\" or \"selector\" function?`,\n\t\t)\n\t}\n\tconst unsubFunction = state.subject.subscribe(key, handleUpdate)\n\tstore.logger.info(`๐Ÿ‘€`, state.type, state.key, `Adding subscription \"${key}\"`)\n\tconst dependencyUnsubFunctions =\n\t\tstate.type !== `atom` ? subscribeToRootAtoms(state, store) : null\n\n\tconst unsubscribe =\n\t\tdependencyUnsubFunctions === null\n\t\t\t? () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`๐Ÿ™ˆ`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t }\n\t\t\t: () => {\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`๐Ÿ™ˆ`,\n\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\tstate.key,\n\t\t\t\t\t\t`Removing subscription \"${key}\"`,\n\t\t\t\t\t)\n\t\t\t\t\tunsubFunction()\n\t\t\t\t\tfor (const unsubFromDependency of dependencyUnsubFunctions) {\n\t\t\t\t\t\tunsubFromDependency()\n\t\t\t\t\t}\n\t\t\t }\n\n\treturn unsubscribe\n}\n\nexport type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (\n\tdata: TransactionUpdate<ฦ’>,\n) => void\n\nexport const subscribeToTransaction = <ฦ’ extends ฦ’n>(\n\ttoken: TransactionToken<ฦ’>,\n\thandleUpdate: TransactionUpdateHandler<ฦ’>,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tx = withdraw(token, store)\n\tif (tx === undefined) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.logger.info(\n\t\t`๐Ÿ‘€`,\n\t\t`transaction`,\n\t\ttoken.key,\n\t\t`Adding subscription \"${key}\"`,\n\t)\n\tconst unsubscribe = tx.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`๐Ÿ™ˆ`,\n\t\t\t`transaction`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\"`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n\nexport const subscribeToTimeline = (\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): (() => void) => {\n\tconst tl = withdraw(token, store)\n\tif (tl === undefined) {\n\t\tthrow new Error(\n\t\t\t`Cannot subscribe to timeline \"${token.key}\": timeline not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n\tstore.logger.info(`๐Ÿ‘€`, `timeline`, token.key, `Adding subscription \"${key}\"`)\n\tconst unsubscribe = tl.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`๐Ÿ™ˆ`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\" from timeline`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n","import type {\n\tTimeline,\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"atom.io/internal\"\nimport { IMPLICIT, createTimeline, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamily, AtomToken } from \".\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n\tshouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn createTimeline(options, IMPLICIT.STORE)\n}\n\nexport const redo = (timeline: TimelineToken): void => {\n\ttimeTravel(`forward`, timeline, IMPLICIT.STORE)\n}\n\nexport const undo = (timeline: TimelineToken): void => {\n\ttimeTravel(`backward`, timeline, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createTransaction, withdraw } from \"atom.io/internal\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken, ฦ’n } from \".\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tupdates: (KeyedStateUpdate<unknown> | TransactionUpdate<ฦ’n>)[]\n\tparams: Parameters<ฦ’>\n\toutput: ReturnType<ฦ’>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ฦ’ extends ฦ’n> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Write<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Act<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors & { run: typeof runTransaction },\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type TransactionOptions<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tdo: Act<ฦ’>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ฦ’> ? ฦ’ : never\n\nexport function transaction<ฦ’ extends ฦ’n>(\n\toptions: TransactionOptions<ฦ’>,\n): TransactionToken<ฦ’> {\n\treturn createTransaction(options, IMPLICIT.STORE)\n}\n\nexport const runTransaction =\n\t<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ฦ’>): ReturnType<ฦ’> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n"]}
1
+ {"version":3,"sources":["../src/atom.ts","../src/dispose.ts","../src/get-state.ts","../src/logger.ts","../src/selector.ts","../src/set-state.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["Internal","IMPLICIT","createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","createTimeline","timeTravel","timeline","createTransaction","withdraw"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AA8BA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,SAAS,SAAS,KAAK;AAAA,EACjD;AACA,SAAO,WAAc,SAAS,QAAW,SAAS,KAAK;AACxD;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,SAAS,SAAS,KAAK;AAAA,EACvD;AACA,SAAO,iBAAuB,SAAS,SAAS,KAAK;AACtD;;;AClGA,YAAY,cAAc;AAInB,SAAS,QACf,OACA,QAAiC,kBAAS,OACnC;AACP,UAAQ,MAAM,MAAM;AAAA,IACnB,KAAK;AACJ,MAAS,oBAAW,OAAO,KAAK;AAChC;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,MAAS,wBAAe,OAAO,KAAK;AACpC;AAAA,EACF;AACD;;;ACjBA,YAAYA,eAAc;AAInB,SAAS,SACf,OACA,QAAiC,mBAAS,OACtC;AAPL;AAQC,QAAM,SACL,KAAS,mBAAS,OAAO,KAAK,MAA9B,YACS,kCAAwB,OAAO,KAAK;AAC9C,MAAI,UAAU,QAAW;AACxB,UAAM,IAAa,wBAAc,OAAO,KAAK;AAAA,EAC9C;AACA,SAAgB,6BAAmB,OAAO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;AAAA,EAC5B;AACA,QAAM,IAAI;AAAA,IACT,2BAA2B,MAAM,GAAG,sCAAsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD","sourcesContent":["import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport type Effectors<T> = {\n\tsetSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void\n\tonSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void\n}\n\nexport type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void\n\nexport type AtomOptions<T> = {\n\tkey: string\n\tdefault: T | (() => T)\n\teffects?: AtomEffect<T>[]\n}\n// biome-ignore format: complex intersection\nexport type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = \n\t& JsonInterface<T, J>\n\t& Omit<AtomOptions<T>, `default`> \n\t& { \n\t\t\tdefault: ()\t=> T\n\t\t\tmutable: true\n\t\t}\n\nexport function atom<T extends Transceiver<any>, J extends Json.Serializable>(\n\toptions: MutableAtomOptions<T, J>,\n): MutableAtomToken<T, J>\nexport function atom<T>(options: AtomOptions<T>): AtomToken<T>\nexport function atom<T>(\n\toptions: AtomOptions<any> | MutableAtomOptions<any, any>,\n): AtomToken<any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtom(options, IMPLICIT.STORE)\n\t}\n\treturn createAtom<T>(options, undefined, IMPLICIT.STORE)\n}\n\nexport type AtomFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tdefault: T | ((key: K) => T)\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n\nexport type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((\n\tkey: K,\n) => AtomToken<T>) & {\n\tkey: string\n\ttype: `atom_family`\n\tsubject: Subject<AtomToken<T>>\n}\n// biome-ignore format: intersection\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n> = \n\t& AtomFamilyOptions<T, K>\n\t& JsonInterface<T, J>\n\t& { mutable: true }\n\n// biome-ignore format: intersection\nexport type MutableAtomFamily<\n\tCore extends Transceiver<any>,\n\tSerializableCore extends Json.Serializable,\n\tKey extends Json.Serializable,\n> = \n\t& JsonInterface<Core, SerializableCore>\n\t& ((key: Key) => MutableAtomToken<Core, SerializableCore>) \n\t& {\n\t\t\tkey: `${string}::mutable`\n\t\t\ttype: `atom_family`\n\t\t\tsubject: Subject<MutableAtomToken<Core, SerializableCore>>\n\t\t}\n\nexport function atomFamily<\n\tT extends Transceiver<any>,\n\tJ extends Json.Serializable,\n\tK extends Json.Serializable,\n>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K>,\n): AtomFamily<T, K>\nexport function atomFamily<T, K extends Json.Serializable>(\n\toptions: AtomFamilyOptions<T, K> | MutableAtomFamilyOptions<any, any, any>,\n): AtomFamily<T, K> | MutableAtomFamily<any, any, any> {\n\tif (`mutable` in options) {\n\t\treturn createMutableAtomFamily(options, IMPLICIT.STORE)\n\t}\n\treturn createAtomFamily<T, K>(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function dispose(\n\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\t\tInternal.deleteAtom(token, store)\n\t\t\tbreak\n\t\tcase `selector`:\n\t\tcase `readonly_selector`:\n\t\t\tInternal.deleteSelector(token, store)\n\t\t\tbreak\n\t}\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport function getState<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): T {\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\treturn Internal.readOrComputeValue(state, store)\n}\n","const LoggerIconDictionary = {\n\t\"โŒ›\": `Timeline event fully captured`,\n\t\"โฉ\": `Timeline redo`,\n\t\"โช\": `Timeline undo`,\n\t\"โญ๏ธ\": `Transaction redo`,\n\t\"โฎ๏ธ\": `Transaction undo`,\n\t\"โณ\": `Timeline event partially captured`,\n\t\"โน๏ธ\": `Time-travel complete`,\n\t\"๐Ÿ’\": `Notice`,\n\t\"๐Ÿ”„\": `Realtime transaction synchronized`,\n\t\"โœ…\": `Realtime transaction success`,\n\t\"โœจ\": `Computation complete`,\n\t\"โŒ\": `Conflict prevents attempted action`,\n\t\"โญ•\": `Operation start`,\n\t\"๐Ÿž\": `Possible bug in AtomIO`,\n\t\"๐Ÿ‘€\": `Subscription added`,\n\t\"๐Ÿ‘ช\": `Family member added`,\n\t\"๐Ÿ“\": `Stow update`,\n\t\"๐Ÿ“ƒ\": `Copy mutable`,\n\t\"๐Ÿ“–\": `Read state`,\n\t\"๐Ÿ“\": `Write state`,\n\t\"๐Ÿ“ข\": `Notify subscribers`,\n\t\"๐Ÿ”Œ\": `Register dependency`,\n\t\"๐Ÿ”\": `Discover root`,\n\t\"๐Ÿ”ฅ\": `Delete state`,\n\t\"๐Ÿ”ง\": `Create mutable atom`,\n\t\"๐Ÿ”จ\": `Create immutable atom`,\n\t\"๐Ÿ”ด\": `Operation complete`,\n\t\"๐Ÿ—‘\": `Evict cached value`,\n\t\"๐Ÿ’ฅ\": `Caught`,\n\t\"๐Ÿ™ˆ\": `Subscription canceled`,\n\t\"๐Ÿ›„\": `Apply transaction`,\n\t\"๐Ÿ› ๏ธ\": `Install atom into store`,\n\t\"๐Ÿ›ซ\": `Begin transaction`,\n\t\"๐Ÿ›ฌ\": `Complete transaction`,\n\t\"๐Ÿงฎ\": `Computing selector`,\n\t\"๐Ÿงน\": `Prepare to evict`,\n\t\"๐Ÿช‚\": `Abort transaction`,\n} as const\nexport type LoggerIcon = keyof typeof LoggerIconDictionary\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\ttokenType:\n\t\t| `atom`\n\t\t| `readonly_selector`\n\t\t| `selector`\n\t\t| `state`\n\t\t| `timeline`\n\t\t| `transaction`\n\t\t| `unknown`,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (...params: Parameters<LogFn>) => boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, tokenType, tokenKey, message, ...rest) => {\n\t\tconsole[logLevel](`${icon} ${tokenType} \"${tokenKey}\" ${message}`, ...rest)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic constructor(\n\t\tpublic logLevel: `error` | `info` | `warn` | null,\n\t\tprivate readonly filter?: LogFilter,\n\t\tprivate readonly logger: Logger = simpleLogger,\n\t) {}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel !== null) {\n\t\t\tthis.logger.error(...args)\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {\n\t\t\tthis.logger.info(...args)\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (\n\t\t\t(this.filter?.(...args) ?? true) &&\n\t\t\tthis.logLevel !== `error` &&\n\t\t\tthis.logLevel !== null\n\t\t) {\n\t\t\tthis.logger.warn(...args)\n\t\t}\n\t}\n}\n","import type { Subject } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector, createSelectorFamily } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\n\nimport type { ReadonlySelectorToken, SelectorToken } from \".\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type SelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n\tset: Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorOptions<T> = {\n\tkey: string\n\tget: Read<() => T>\n}\n\nexport function selector<T>(options: SelectorOptions<T>): SelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T>,\n): ReadonlySelectorToken<T>\nexport function selector<T>(\n\toptions: ReadonlySelectorOptions<T> | SelectorOptions<T>,\n): ReadonlySelectorToken<T> | SelectorToken<T> {\n\treturn createSelector(options, undefined, IMPLICIT.STORE)\n}\n\nexport type SelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {\n\tkey: string\n\tget: (key: K) => Read<() => T>\n}\n\nexport type SelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => SelectorToken<T>) & {\n\tkey: string\n\ttype: `selector_family`\n\tsubject: Subject<SelectorToken<T>>\n}\n\nexport type ReadonlySelectorFamily<\n\tT,\n\tK extends Json.Serializable = Json.Serializable,\n> = ((key: K) => ReadonlySelectorToken<T>) & {\n\tkey: string\n\ttype: `readonly_selector_family`\n\tsubject: Subject<ReadonlySelectorToken<T>>\n}\n\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: SelectorFamilyOptions<T, K>,\n): SelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K>\nexport function selectorFamily<T, K extends Json.Serializable>(\n\toptions: ReadonlySelectorFamilyOptions<T, K> | SelectorFamilyOptions<T, K>,\n): ReadonlySelectorFamily<T, K> | SelectorFamily<T, K> {\n\treturn createSelectorFamily(options, IMPLICIT.STORE)\n}\n","import * as Internal from \"atom.io/internal\"\n\nimport type { StateToken } from \".\"\n\nexport function setState<T, New extends T>(\n\ttoken: StateToken<T>,\n\tvalue: New | ((oldValue: T) => New),\n\tstore: Internal.Store = Internal.IMPLICIT.STORE,\n): void {\n\tconst rejection = Internal.openOperation(token, store)\n\tif (rejection) {\n\t\treturn\n\t}\n\tconst state =\n\t\tInternal.withdraw(token, store) ??\n\t\tInternal.withdrawNewFamilyMember(token, store)\n\tif (state === undefined) {\n\t\tthrow new Internal.NotFoundError(token, store)\n\t}\n\tInternal.setAtomOrSelector(state, value, store)\n\tInternal.closeOperation(store)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tcreateTimeline,\n\tcreateTransaction,\n\ttimeTravel,\n} from \"atom.io/internal\"\n\nimport type { redo, timeline, undo } from \".\"\nimport { getState, setState, subscribe } from \".\"\nimport type { atom, atomFamily } from \"./atom\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { transaction } from \"./transaction\"\n\nexport class Silo {\n\tpublic store: Store\n\tpublic atom: typeof atom\n\tpublic atomFamily: typeof atomFamily\n\tpublic selector: typeof selector\n\tpublic selectorFamily: typeof selectorFamily\n\tpublic transaction: typeof transaction\n\tpublic timeline: typeof timeline\n\tpublic getState: typeof getState\n\tpublic setState: typeof setState\n\tpublic subscribe: typeof subscribe\n\tpublic undo: typeof undo\n\tpublic redo: typeof redo\n\tpublic constructor(name: string, fromStore: Store | null = null) {\n\t\tconst s = new Store(name, fromStore)\n\t\tthis.store = s\n\t\tthis.atom = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtom(options, s)\n\t\t\t}\n\t\t\treturn createAtom(options, undefined, s)\n\t\t}\n\t\tthis.atomFamily = (options) => {\n\t\t\tif (`mutable` in options) {\n\t\t\t\treturn createMutableAtomFamily(options, s) as any\n\t\t\t}\n\t\t\treturn createAtomFamily(options, s)\n\t\t}\n\t\tthis.selector = (options) => createSelector(options, undefined, s) as any\n\t\tthis.selectorFamily = (options) => createSelectorFamily(options, s) as any\n\t\tthis.transaction = (options) => createTransaction(options, s)\n\t\tthis.timeline = (options) => createTimeline(options, s)\n\t\tthis.getState = (token) => getState(token, s)\n\t\tthis.setState = (token, newValue) => setState(token, newValue, s)\n\t\tthis.subscribe = (token, handler, key) => subscribe(token, handler, key, s)\n\t\tthis.undo = (token) => timeTravel(`backward`, token, s)\n\t\tthis.redo = (token) => timeTravel(`forward`, token, s)\n\t}\n}\n","import type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\tsubscribeToTransaction,\n} from \"atom.io/internal\"\n\nimport type {\n\tFamilyMetadata,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n\tTimelineUpdate,\n\tTransactionToken,\n\tTransactionUpdate,\n\tฦ’n,\n} from \".\"\n\nexport type StateUpdate<T> = { newValue: T; oldValue: T }\nexport type KeyedStateUpdate<T> = StateUpdate<T> & {\n\tkey: string\n\tfamily?: FamilyMetadata\n}\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\n\nexport type TransactionUpdateHandler<ฦ’ extends ฦ’n> = (\n\tdata: TransactionUpdate<ฦ’>,\n) => void\n\nexport function subscribe<T>(\n\ttoken: ReadonlySelectorToken<T> | StateToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe<ฦ’ extends ฦ’n>(\n\ttoken: TransactionToken<ฦ’>,\n\thandleUpdate: TransactionUpdateHandler<ฦ’>,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe(\n\ttoken: TimelineToken,\n\thandleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void,\n\tkey?: string,\n\tstore?: Store,\n): () => void\nexport function subscribe(\n\ttoken:\n\t\t| ReadonlySelectorToken<any>\n\t\t| StateToken<any>\n\t\t| TimelineToken\n\t\t| TransactionToken<any>,\n\thandleUpdate: (update: any) => void,\n\tkey: string = Math.random().toString(36).slice(2),\n\tstore = IMPLICIT.STORE,\n): () => void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\tcase `readonly_selector`:\n\t\tcase `selector`:\n\t\t\treturn subscribeToState(token, handleUpdate, key, store)\n\t\tcase `transaction`:\n\t\t\treturn subscribeToTransaction(token, handleUpdate, key, store)\n\t\tcase `timeline`:\n\t\t\treturn subscribeToTimeline(token, handleUpdate, key, store)\n\t}\n}\n","import type {\n\tTimeline,\n\tTimelineAtomUpdate,\n\tTimelineSelectorUpdate,\n\tTimelineTransactionUpdate,\n} from \"atom.io/internal\"\nimport { IMPLICIT, createTimeline, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamily, AtomToken } from \".\"\n\nexport type TimelineToken = {\n\tkey: string\n\ttype: `timeline`\n}\n\nexport type TimelineOptions = {\n\tkey: string\n\tatoms: (AtomFamily<any, any> | AtomToken<any>)[]\n\tshouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean\n}\n\nexport type TimelineUpdate =\n\t| TimelineAtomUpdate\n\t| TimelineSelectorUpdate\n\t| TimelineTransactionUpdate\n\nexport const timeline = (options: TimelineOptions): TimelineToken => {\n\treturn createTimeline(options, IMPLICIT.STORE)\n}\n\nexport const redo = (timeline: TimelineToken): void => {\n\ttimeTravel(`forward`, timeline, IMPLICIT.STORE)\n}\n\nexport const undo = (timeline: TimelineToken): void => {\n\ttimeTravel(`backward`, timeline, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createTransaction, withdraw } from \"atom.io/internal\"\n\nimport type { KeyedStateUpdate, ReadonlySelectorToken, StateToken, ฦ’n } from \".\"\n\nexport type TransactionToken<_> = {\n\tkey: string\n\ttype: `transaction`\n\t__brand?: _\n}\n\nexport type TransactionUpdate<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tupdates: (KeyedStateUpdate<unknown> | TransactionUpdate<ฦ’n>)[]\n\tparams: Parameters<ฦ’>\n\toutput: ReturnType<ฦ’>\n}\n\nexport type Transactors = {\n\tget: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S\n\tset: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void\n}\nexport type ReadonlyTransactors = Pick<Transactors, `get`>\n\nexport type Read<ฦ’ extends ฦ’n> = (\n\ttransactors: ReadonlyTransactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Write<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors,\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type Act<ฦ’ extends ฦ’n> = (\n\ttransactors: Transactors & { run: typeof runTransaction },\n\t...parameters: Parameters<ฦ’>\n) => ReturnType<ฦ’>\n\nexport type TransactionOptions<ฦ’ extends ฦ’n> = {\n\tkey: string\n\tdo: Act<ฦ’>\n}\n\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer ฦ’> ? ฦ’ : never\n\nexport function transaction<ฦ’ extends ฦ’n>(\n\toptions: TransactionOptions<ฦ’>,\n): TransactionToken<ฦ’> {\n\treturn createTransaction(options, IMPLICIT.STORE)\n}\n\nexport const runTransaction =\n\t<ฦ’ extends ฦ’n>(token: TransactionToken<ฦ’>, store: Store = IMPLICIT.STORE) =>\n\t(...parameters: Parameters<ฦ’>): ReturnType<ฦ’> => {\n\t\tconst tx = withdraw(token, store)\n\t\tif (tx) {\n\t\t\treturn tx.run(...parameters)\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Cannot run transaction \"${token.key}\": transaction not found in store \"${store.config.name}\".`,\n\t\t)\n\t}\n"]}
@@ -1 +1 @@
1
- {"inputs":{"src/atom.ts":{"bytes":2963,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/dispose.ts":{"bytes":431,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/get-state.ts":{"bytes":475,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/logger.ts":{"bytes":2714,"imports":[],"format":"esm"},"src/selector.ts":{"bytes":2080,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/set-state.ts":{"bytes":598,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/silo.ts":{"bytes":1914,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"."}],"format":"esm"},"src/subscribe.ts":{"bytes":3215,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/timeline.ts":{"bytes":928,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/transaction.ts":{"bytes":1822,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1053,"imports":[{"path":"src/atom.ts","kind":"import-statement","original":"./atom"},{"path":"src/dispose.ts","kind":"import-statement","original":"./dispose"},{"path":"src/get-state.ts","kind":"import-statement","original":"./get-state"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"},{"path":"src/selector.ts","kind":"import-statement","original":"./selector"},{"path":"src/set-state.ts","kind":"import-statement","original":"./set-state"},{"path":"src/silo.ts","kind":"import-statement","original":"./silo"},{"path":"src/subscribe.ts","kind":"import-statement","original":"./subscribe"},{"path":"src/timeline.ts","kind":"import-statement","original":"./timeline"},{"path":"src/transaction.ts","kind":"import-statement","original":"./transaction"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":25049},"dist/index.cjs":{"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true}],"exports":["AtomIOLogger","LOG_LEVELS","Silo","atom","atomFamily","dispose","getState","redo","runTransaction","selector","selectorFamily","setState","simpleLog","simpleLogger","subscribe","subscribeToTimeline","subscribeToTransaction","timeline","transaction","undo"],"entryPoint":"src/index.ts","inputs":{"src/atom.ts":{"bytesInOutput":479},"src/index.ts":{"bytesInOutput":0},"src/dispose.ts":{"bytesInOutput":315},"src/get-state.ts":{"bytesInOutput":376},"src/logger.ts":{"bytesInOutput":1203},"src/selector.ts":{"bytesInOutput":280},"src/set-state.ts":{"bytesInOutput":511},"src/silo.ts":{"bytesInOutput":1431},"src/subscribe.ts":{"bytesInOutput":2517},"src/timeline.ts":{"bytesInOutput":376},"src/transaction.ts":{"bytesInOutput":504}},"bytes":8474}}}
1
+ {"inputs":{"src/atom.ts":{"bytes":2963,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/dispose.ts":{"bytes":431,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/get-state.ts":{"bytes":475,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/logger.ts":{"bytes":2714,"imports":[],"format":"esm"},"src/selector.ts":{"bytes":2080,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/set-state.ts":{"bytes":598,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/silo.ts":{"bytes":1914,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"."}],"format":"esm"},"src/subscribe.ts":{"bytes":1696,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/timeline.ts":{"bytes":928,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/transaction.ts":{"bytes":1822,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1053,"imports":[{"path":"src/atom.ts","kind":"import-statement","original":"./atom"},{"path":"src/dispose.ts","kind":"import-statement","original":"./dispose"},{"path":"src/get-state.ts","kind":"import-statement","original":"./get-state"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"},{"path":"src/selector.ts","kind":"import-statement","original":"./selector"},{"path":"src/set-state.ts","kind":"import-statement","original":"./set-state"},{"path":"src/silo.ts","kind":"import-statement","original":"./silo"},{"path":"src/subscribe.ts","kind":"import-statement","original":"./subscribe"},{"path":"src/timeline.ts","kind":"import-statement","original":"./timeline"},{"path":"src/transaction.ts","kind":"import-statement","original":"./transaction"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":21916},"dist/index.cjs":{"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true}],"exports":["AtomIOLogger","LOG_LEVELS","Silo","atom","atomFamily","dispose","getState","redo","runTransaction","selector","selectorFamily","setState","simpleLog","simpleLogger","subscribe","timeline","transaction","undo"],"entryPoint":"src/index.ts","inputs":{"src/atom.ts":{"bytesInOutput":479},"src/index.ts":{"bytesInOutput":0},"src/dispose.ts":{"bytesInOutput":315},"src/get-state.ts":{"bytesInOutput":376},"src/logger.ts":{"bytesInOutput":1203},"src/selector.ts":{"bytesInOutput":280},"src/set-state.ts":{"bytesInOutput":511},"src/silo.ts":{"bytesInOutput":1431},"src/subscribe.ts":{"bytesInOutput":583},"src/timeline.ts":{"bytesInOutput":376},"src/transaction.ts":{"bytesInOutput":504}},"bytes":6491}}}
@@ -1 +1 @@
1
- {"inputs":{"src/atom.ts":{"bytes":2963,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/dispose.ts":{"bytes":431,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/get-state.ts":{"bytes":475,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/logger.ts":{"bytes":2714,"imports":[],"format":"esm"},"src/selector.ts":{"bytes":2080,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/set-state.ts":{"bytes":598,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/silo.ts":{"bytes":1914,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"."}],"format":"esm"},"src/subscribe.ts":{"bytes":3215,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/timeline.ts":{"bytes":928,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/transaction.ts":{"bytes":1822,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1053,"imports":[{"path":"src/atom.ts","kind":"import-statement","original":"./atom"},{"path":"src/dispose.ts","kind":"import-statement","original":"./dispose"},{"path":"src/get-state.ts","kind":"import-statement","original":"./get-state"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"},{"path":"src/selector.ts","kind":"import-statement","original":"./selector"},{"path":"src/set-state.ts","kind":"import-statement","original":"./set-state"},{"path":"src/silo.ts","kind":"import-statement","original":"./silo"},{"path":"src/subscribe.ts","kind":"import-statement","original":"./subscribe"},{"path":"src/timeline.ts","kind":"import-statement","original":"./timeline"},{"path":"src/transaction.ts","kind":"import-statement","original":"./transaction"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":25049},"dist/index.js":{"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true}],"exports":["AtomIOLogger","LOG_LEVELS","Silo","atom","atomFamily","dispose","getState","redo","runTransaction","selector","selectorFamily","setState","simpleLog","simpleLogger","subscribe","subscribeToTimeline","subscribeToTransaction","timeline","transaction","undo"],"entryPoint":"src/index.ts","inputs":{"src/atom.ts":{"bytesInOutput":479},"src/index.ts":{"bytesInOutput":0},"src/dispose.ts":{"bytesInOutput":315},"src/get-state.ts":{"bytesInOutput":376},"src/logger.ts":{"bytesInOutput":1203},"src/selector.ts":{"bytesInOutput":280},"src/set-state.ts":{"bytesInOutput":511},"src/silo.ts":{"bytesInOutput":1431},"src/subscribe.ts":{"bytesInOutput":2517},"src/timeline.ts":{"bytesInOutput":376},"src/transaction.ts":{"bytesInOutput":504}},"bytes":8474}}}
1
+ {"inputs":{"src/atom.ts":{"bytes":2963,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/dispose.ts":{"bytes":431,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/get-state.ts":{"bytes":475,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/logger.ts":{"bytes":2714,"imports":[],"format":"esm"},"src/selector.ts":{"bytes":2080,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/set-state.ts":{"bytes":598,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/silo.ts":{"bytes":1914,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"src/index.ts","kind":"import-statement","original":"."}],"format":"esm"},"src/subscribe.ts":{"bytes":1696,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/timeline.ts":{"bytes":928,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/transaction.ts":{"bytes":1822,"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1053,"imports":[{"path":"src/atom.ts","kind":"import-statement","original":"./atom"},{"path":"src/dispose.ts","kind":"import-statement","original":"./dispose"},{"path":"src/get-state.ts","kind":"import-statement","original":"./get-state"},{"path":"src/logger.ts","kind":"import-statement","original":"./logger"},{"path":"src/selector.ts","kind":"import-statement","original":"./selector"},{"path":"src/set-state.ts","kind":"import-statement","original":"./set-state"},{"path":"src/silo.ts","kind":"import-statement","original":"./silo"},{"path":"src/subscribe.ts","kind":"import-statement","original":"./subscribe"},{"path":"src/timeline.ts","kind":"import-statement","original":"./timeline"},{"path":"src/transaction.ts","kind":"import-statement","original":"./transaction"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":21916},"dist/index.js":{"imports":[{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true},{"path":"atom.io/internal","kind":"import-statement","external":true}],"exports":["AtomIOLogger","LOG_LEVELS","Silo","atom","atomFamily","dispose","getState","redo","runTransaction","selector","selectorFamily","setState","simpleLog","simpleLogger","subscribe","timeline","transaction","undo"],"entryPoint":"src/index.ts","inputs":{"src/atom.ts":{"bytesInOutput":479},"src/index.ts":{"bytesInOutput":0},"src/dispose.ts":{"bytesInOutput":315},"src/get-state.ts":{"bytesInOutput":376},"src/logger.ts":{"bytesInOutput":1203},"src/selector.ts":{"bytesInOutput":280},"src/set-state.ts":{"bytesInOutput":511},"src/silo.ts":{"bytesInOutput":1431},"src/subscribe.ts":{"bytesInOutput":583},"src/timeline.ts":{"bytesInOutput":376},"src/transaction.ts":{"bytesInOutput":504}},"bytes":6491}}}