atom.io 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -91,7 +91,7 @@ declare const LoggerIconDictionary: {
91
91
  type LoggerIcon = keyof typeof LoggerIconDictionary;
92
92
  declare const LOG_LEVELS: readonly ["info", "warn", "error"];
93
93
  type LogLevel = typeof LOG_LEVELS[number];
94
- type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: any[]) => void;
94
+ type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
95
95
  type LogFilter = (...params: Parameters<LogFn>) => boolean;
96
96
  type Logger = Record<LogLevel, LogFn>;
97
97
  declare const simpleLog: (logLevel: keyof Logger) => LogFn;
package/dist/index.d.ts CHANGED
@@ -91,7 +91,7 @@ declare const LoggerIconDictionary: {
91
91
  type LoggerIcon = keyof typeof LoggerIconDictionary;
92
92
  declare const LOG_LEVELS: readonly ["info", "warn", "error"];
93
93
  type LogLevel = typeof LOG_LEVELS[number];
94
- type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: any[]) => void;
94
+ type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
95
95
  type LogFilter = (...params: Parameters<LogFn>) => boolean;
96
96
  type Logger = Record<LogLevel, LogFn>;
97
97
  declare const simpleLog: (logLevel: keyof Logger) => LogFn;
package/dist/index.js CHANGED
@@ -68,10 +68,7 @@ var NotFoundError = class extends Error {
68
68
  // src/logger.ts
69
69
  var LOG_LEVELS = [`info`, `warn`, `error`];
70
70
  var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
71
- console[logLevel](
72
- `${icon} ${tokenType} "${tokenKey}" ${message}`,
73
- ...rest.map((arg) => JSON.stringify(arg))
74
- );
71
+ console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
75
72
  };
76
73
  var simpleLogger = {
77
74
  error: simpleLog(`error`),
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/atom.ts","../src/get-set.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","IMPLICIT","withdraw","redo__INTERNAL","timeline__INTERNAL","undo__INTERNAL","transaction__INTERNAL"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAgCA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,OAAO;AAAA,EACjC;AACA,SAAO,WAAc,OAAO;AAC7B;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,OAAO;AAAA,EACvC;AACA,SAAO,iBAAuB,OAAO;AACtC;;;ACpGA,YAAY,cAAc;AAGnB,IAAM,WAAW,CACvB,OACA,QAAiC,kBAAS,UACnC;AANR;AAOC,QAAM,SACL,KAAS,kBAAS,OAAO,KAAK,MAA9B,YACS,iCAAwB,OAAO,KAAK;AAC9C,MAAI,UAAU,QAAW;AACxB,UAAM,IAAI,cAAc,OAAO,KAAK;AAAA,EACrC;AACA,SAAgB,4BAAmB,OAAO,KAAK;AAChD;AAEO,IAAM,WAAW,CACvB,OACA,OACA,QAAiC,kBAAS,UAChC;AApBX;AAqBC,QAAM,YAAqB,uBAAc,OAAO,KAAK;AACrD,MAAI,WAAW;AACd;AAAA,EACD;AACA,QAAM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e,OAAOF,UAAS,KAAK;AACrC;AAEO,IAAM,OAAO,CAAC,UAA+B;AACnD,EAAAI,gBAAe,OAAOJ,UAAS,KAAK;AACrC;;;ACxCA,SAAS,YAAAA,WAAU,yBAAAK,wBAAuB,YAAAJ,iBAAgB;AAyCnD,SAAS,YACf,SACsB;AACtB,SAAOI,uBAAsB,OAAO;AACrC;AAEO,IAAM,iBACZ,CAAe,OAA4B,QAAeL,UAAS,UACnE,IAAI,eAA6C;AAChD,QAAM,KAAKC,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\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tdeleteAtom,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport { deleteAtom }\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\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)\n\t}\n\treturn createAtom<T>(options)\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)\n\t}\n\treturn createAtomFamily<T, K>(options)\n}\n","import * as Internal from \"atom.io/internal\"\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport const 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 NotFoundError(token, store)\n\t}\n\treturn Internal.getState__INTERNAL(state, store)\n}\n\nexport const 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 NotFoundError(token, store)\n\t}\n\tInternal.setState__INTERNAL(state, value, store)\n\tInternal.closeOperation(store)\n}\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nexport class NotFoundError extends Error {\n\tpublic constructor(\n\t\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\t\tstore: Internal.Store,\n\t) {\n\t\tsuper(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\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: any[]\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](\n\t\t\t`${icon} ${tokenType} \"${tokenKey}\" ${message}`,\n\t\t\t...rest.map((arg) => JSON.stringify(arg)),\n\t\t)\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 { 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)\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)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\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) => transaction__INTERNAL(options, s)\n\t\tthis.timeline = (options) => timeline__INTERNAL(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) => undo__INTERNAL(token, s)\n\t\tthis.redo = (token) => redo__INTERNAL(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 {\n\tIMPLICIT,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\tundo__INTERNAL,\n} 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 timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, transaction__INTERNAL, 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\tatomUpdates: KeyedStateUpdate<unknown>[]\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 TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\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 transaction__INTERNAL(options)\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/get-set.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","IMPLICIT","withdraw","redo__INTERNAL","timeline__INTERNAL","undo__INTERNAL","transaction__INTERNAL"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAgCA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,OAAO;AAAA,EACjC;AACA,SAAO,WAAc,OAAO;AAC7B;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,OAAO;AAAA,EACvC;AACA,SAAO,iBAAuB,OAAO;AACtC;;;ACpGA,YAAY,cAAc;AAGnB,IAAM,WAAW,CACvB,OACA,QAAiC,kBAAS,UACnC;AANR;AAOC,QAAM,SACL,KAAS,kBAAS,OAAO,KAAK,MAA9B,YACS,iCAAwB,OAAO,KAAK;AAC9C,MAAI,UAAU,QAAW;AACxB,UAAM,IAAI,cAAc,OAAO,KAAK;AAAA,EACrC;AACA,SAAgB,4BAAmB,OAAO,KAAK;AAChD;AAEO,IAAM,WAAW,CACvB,OACA,OACA,QAAiC,kBAAS,UAChC;AApBX;AAqBC,QAAM,YAAqB,uBAAc,OAAO,KAAK;AACrD,MAAI,WAAW;AACd;AAAA,EACD;AACA,QAAM,SACL,KAAS,kBAAS,OAAO,KAAK,MAA9B,YACS,iCAAwB,OAAO,KAAK;AAC9C,MAAI,UAAU,QAAW;AACxB,UAAM,IAAI,cAAc,OAAO,KAAK;AAAA,EACrC;AACA,EAAS,4BAAmB,OAAO,OAAO,KAAK;AAC/C,EAAS,wBAAe,KAAK;AAC9B;AAEA,IAAM,aAAa,CAAC,QAAgB,IAAI,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAC/D,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACjC,YACN,OACA,OACC;AACD;AAAA,MACC,GAAG,WAAW,MAAM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AsC,MAAM,OAAO,IAAI;AAAA,EAC5F;AACD","sourcesContent":["import type { Subject, Transceiver } from \"atom.io/internal\"\nimport {\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tdeleteAtom,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport { deleteAtom }\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\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)\n\t}\n\treturn createAtom<T>(options)\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)\n\t}\n\treturn createAtomFamily<T, K>(options)\n}\n","import * as Internal from \"atom.io/internal\"\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport const 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 NotFoundError(token, store)\n\t}\n\treturn Internal.getState__INTERNAL(state, store)\n}\n\nexport const 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 NotFoundError(token, store)\n\t}\n\tInternal.setState__INTERNAL(state, value, store)\n\tInternal.closeOperation(store)\n}\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nexport class NotFoundError extends Error {\n\tpublic constructor(\n\t\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\t\tstore: Internal.Store,\n\t) {\n\t\tsuper(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\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 { 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)\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)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\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) => transaction__INTERNAL(options, s)\n\t\tthis.timeline = (options) => timeline__INTERNAL(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) => undo__INTERNAL(token, s)\n\t\tthis.redo = (token) => redo__INTERNAL(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 {\n\tIMPLICIT,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\tundo__INTERNAL,\n} 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 timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, transaction__INTERNAL, 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\tatomUpdates: KeyedStateUpdate<unknown>[]\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 TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\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 transaction__INTERNAL(options)\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.mjs CHANGED
@@ -48,10 +48,7 @@ var NotFoundError = class extends Error {
48
48
  // src/logger.ts
49
49
  var LOG_LEVELS = [`info`, `warn`, `error`];
50
50
  var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
51
- console[logLevel](
52
- `${icon} ${tokenType} "${tokenKey}" ${message}`,
53
- ...rest.map((arg) => JSON.stringify(arg))
54
- );
51
+ console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
55
52
  };
56
53
  var simpleLogger = {
57
54
  error: simpleLog(`error`),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/atom.ts","../src/get-set.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","IMPLICIT","withdraw","redo__INTERNAL","timeline__INTERNAL","undo__INTERNAL","transaction__INTER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transceiver } from \"atom.io/internal\"\nimport {\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tdeleteAtom,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport { deleteAtom }\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\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)\n\t}\n\treturn createAtom<T>(options)\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)\n\t}\n\treturn createAtomFamily<T, K>(options)\n}\n","import * as Internal from \"atom.io/internal\"\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport const 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 NotFoundError(token, store)\n\t}\n\treturn Internal.getState__INTERNAL(state, store)\n}\n\nexport const 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 NotFoundError(token, store)\n\t}\n\tInternal.setState__INTERNAL(state, value, store)\n\tInternal.closeOperation(store)\n}\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nexport class NotFoundError extends Error {\n\tpublic constructor(\n\t\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\t\tstore: Internal.Store,\n\t) {\n\t\tsuper(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\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: any[]\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](\n\t\t\t`${icon} ${tokenType} \"${tokenKey}\" ${message}`,\n\t\t\t...rest.map((arg) => JSON.stringify(arg)),\n\t\t)\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 { 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)\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)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\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) => transaction__INTERNAL(options, s)\n\t\tthis.timeline = (options) => timeline__INTERNAL(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) => undo__INTERNAL(token, s)\n\t\tthis.redo = (token) => redo__INTERNAL(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 {\n\tIMPLICIT,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\tundo__INTERNAL,\n} 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 timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, transaction__INTERNAL, 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\tatomUpdates: KeyedStateUpdate<unknown>[]\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 TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\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 transaction__INTERNAL(options)\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/get-set.ts","../src/logger.ts","../src/selector.ts","../src/silo.ts","../src/subscribe.ts","../src/timeline.ts","../src/transaction.ts"],"names":["createAtom","createAtomFamily","createMutableAtom","createMutableAtomFamily","createSelector","createSelectorFamily","IMPLICIT","withdraw","redo__INTERNAL","timeline__INTERNAL","undo__INTERNAL","transaction__INTERNAL"],"mappings":";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAgCA,SAAS,KACf,SACiB;AACjB,MAAI,aAAa,SAAS;AACzB,WAAO,kBAAkB,OAAO;AAAA,EACjC;AACA,SAAO,WAAc,OAAO;AAC7B;AA+CO,SAAS,WACf,SACsD;AACtD,MAAI,aAAa,SAAS;AACzB,WAAO,wBAAwB,OAAO;AAAA,EACvC;AACA,SAAO,iBAAuB,OAAO;AACtC;;;ACpGA,YAAY,cAAc;AAGnB,IAAM,WAAW,CACvB,OACA,QAAiC,kBA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AAA,MACN,0BAA0B,GAAG;AAAA,IAC9B;AACA,gBAAY;AAAA,EACb;AACD;;;ACpHA;AAAA,EACC,YAAAD;AAAA,EACA,kBAAAE;AAAA,EACA,sBAAAC;AAAA,EACA,kBAAAC;AAAA,OACM;AAoBA,IAAM,WAAW,CAAC,YAA4C;AACpE,SAAOD,oBAAmB,OAAO;AAClC;AAEO,IAAM,OAAO,CAAC,UAA+B;AACnD,EAAAD,gBAAe,OAAOF,UAAS,KAAK;AACrC;AAEO,IAAM,OAAO,CAAC,UAA+B;AACnD,EAAAI,gBAAe,OAAOJ,UAAS,KAAK;AACrC;;;ACxCA,SAAS,YAAAA,WAAU,yBAAAK,wBAAuB,YAAAJ,iBAAgB;AAyCnD,SAAS,YACf,SACsB;AACtB,SAAOI,uBAAsB,OAAO;AACrC;AAEO,IAAM,iBACZ,CAAe,OAA4B,QAAeL,UAAS,UACnE,IAAI,eAA6C;AAChD,QAAM,KAAKC,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\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tdeleteAtom,\n} from \"atom.io/internal\"\nimport type { Json, JsonInterface } from \"atom.io/json\"\n\nimport type { AtomToken, MutableAtomToken } from \".\"\n\nexport { deleteAtom }\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\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)\n\t}\n\treturn createAtom<T>(options)\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)\n\t}\n\treturn createAtomFamily<T, K>(options)\n}\n","import * as Internal from \"atom.io/internal\"\nimport type { ReadonlySelectorToken, StateToken } from \".\"\n\nexport const 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 NotFoundError(token, store)\n\t}\n\treturn Internal.getState__INTERNAL(state, store)\n}\n\nexport const 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 NotFoundError(token, store)\n\t}\n\tInternal.setState__INTERNAL(state, value, store)\n\tInternal.closeOperation(store)\n}\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nexport class NotFoundError extends Error {\n\tpublic constructor(\n\t\ttoken: ReadonlySelectorToken<any> | StateToken<any>,\n\t\tstore: Internal.Store,\n\t) {\n\t\tsuper(\n\t\t\t`${capitalize(token.type)} \"${token.key}\" not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\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 { 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)\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)\n}\n","import {\n\tStore,\n\tcreateAtom,\n\tcreateAtomFamily,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateSelector,\n\tcreateSelectorFamily,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\ttransaction__INTERNAL,\n\tundo__INTERNAL,\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) => transaction__INTERNAL(options, s)\n\t\tthis.timeline = (options) => timeline__INTERNAL(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) => undo__INTERNAL(token, s)\n\t\tthis.redo = (token) => redo__INTERNAL(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 {\n\tIMPLICIT,\n\tredo__INTERNAL,\n\ttimeline__INTERNAL,\n\tundo__INTERNAL,\n} 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 timeline__INTERNAL(options)\n}\n\nexport const redo = (token: TimelineToken): void => {\n\tredo__INTERNAL(token, IMPLICIT.STORE)\n}\n\nexport const undo = (token: TimelineToken): void => {\n\tundo__INTERNAL(token, IMPLICIT.STORE)\n}\n","import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, transaction__INTERNAL, 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\tatomUpdates: KeyedStateUpdate<unknown>[]\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 TransactionOptions<ƒ extends ƒn> = {\n\tkey: string\n\tdo: Write<ƒ>\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 transaction__INTERNAL(options)\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -70,9 +70,9 @@
70
70
  "socket.io": "4.7.2",
71
71
  "socket.io-client": "4.7.2",
72
72
  "tmp": "0.2.1",
73
- "tsup": "8.0.0",
73
+ "tsup": "8.0.1",
74
74
  "typescript": "5.3.2",
75
- "vite": "4.5.0",
75
+ "vite": "5.0.2",
76
76
  "vite-tsconfig-paths": "4.2.1",
77
77
  "vitest": "0.34.6"
78
78
  },
package/src/logger.ts CHANGED
@@ -54,7 +54,7 @@ export type LogFn = (
54
54
  | `unknown`,
55
55
  tokenKey: string,
56
56
  message: string,
57
- ...rest: any[]
57
+ ...rest: unknown[]
58
58
  ) => void
59
59
  export type LogFilter = (...params: Parameters<LogFn>) => boolean
60
60
 
@@ -63,10 +63,7 @@ export type Logger = Record<LogLevel, LogFn>
63
63
  export const simpleLog =
64
64
  (logLevel: keyof Logger): LogFn =>
65
65
  (icon, tokenType, tokenKey, message, ...rest) => {
66
- console[logLevel](
67
- `${icon} ${tokenType} "${tokenKey}" ${message}`,
68
- ...rest.map((arg) => JSON.stringify(arg)),
69
- )
66
+ console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest)
70
67
  }
71
68
  export const simpleLogger: Logger = {
72
69
  error: simpleLog(`error`),