atom.io 0.14.6 → 0.14.8
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/package.json +2 -2
- package/react/dist/index.cjs +13 -16
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.js +13 -16
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +14 -16
- package/data/dist/index.d.cts +0 -158
- package/dist/index.d.cts +0 -245
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
- package/internal/dist/index.d.cts +0 -421
- package/introspection/dist/index.d.cts +0 -24
- package/json/dist/index.d.cts +0 -51
- package/react/dist/index.d.cts +0 -23
- package/react-devtools/dist/index.d.cts +0 -342
- package/realtime-client/dist/index.d.cts +0 -22
- package/realtime-react/dist/index.d.cts +0 -27
- package/realtime-server/dist/index.d.cts +0 -25
- package/realtime-testing/dist/index.d.cts +0 -49
- package/transceivers/set-rtx/dist/index.d.cts +0 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"tmp": "0.2.1",
|
|
74
74
|
"tsup": "8.0.1",
|
|
75
75
|
"typescript": "5.3.3",
|
|
76
|
-
"vite": "5.0.
|
|
76
|
+
"vite": "5.0.8",
|
|
77
77
|
"vite-tsconfig-paths": "4.2.2",
|
|
78
78
|
"vitest": "1.0.4"
|
|
79
79
|
},
|
package/react/dist/index.cjs
CHANGED
|
@@ -53,27 +53,24 @@ function useTL(token) {
|
|
|
53
53
|
const store = React2__namespace.useContext(StoreContext);
|
|
54
54
|
const id = React2__namespace.useId();
|
|
55
55
|
const timeline = internal.withdraw(token, store);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
redo: () => atom_io.redo(token)
|
|
59
|
-
});
|
|
60
|
-
const rebuildMeta = React2__namespace.useCallback(() => {
|
|
56
|
+
const tokenRef = React2__namespace.useRef(token);
|
|
57
|
+
const rebuildMeta = () => {
|
|
61
58
|
var _a, _b;
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, []);
|
|
59
|
+
return {
|
|
60
|
+
at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
|
|
61
|
+
length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN,
|
|
62
|
+
undo: () => atom_io.undo(token),
|
|
63
|
+
redo: () => atom_io.redo(token)
|
|
64
|
+
};
|
|
65
|
+
};
|
|
70
66
|
const meta = React2__namespace.useRef(rebuildMeta());
|
|
71
|
-
const retrieve =
|
|
72
|
-
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length)) {
|
|
67
|
+
const retrieve = () => {
|
|
68
|
+
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length) || tokenRef.current !== token) {
|
|
69
|
+
tokenRef.current = token;
|
|
73
70
|
meta.current = rebuildMeta();
|
|
74
71
|
}
|
|
75
72
|
return meta.current;
|
|
76
|
-
}
|
|
73
|
+
};
|
|
77
74
|
return React2__namespace.useSyncExternalStore(
|
|
78
75
|
(dispatch) => internal.subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
|
|
79
76
|
retrieve,
|
package/react/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store-context.tsx","../src/store-hooks.ts"],"names":["React"],"mappings":";AACA,SAAS,gBAAgB;AACzB,YAAY,WAAW;AAQtB;AANM,IAAM,eAAqB,oBAAqB,SAAS,KAAK;AAE9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Z,CAAC,aAAa,oBAAoB,OAAO,UAAU,UAAU,EAAE,IAAI,KAAK;AAAA,IACxE;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<Store>(IMPLICIT.STORE)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: Store\n}> = ({ children, store = IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as React from \"react\"\n\nimport { getState, redo, setState, undo } from \"atom.io\"\nimport type {\n\tMutableAtomToken,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n} from \"atom.io\"\n\nimport {\n\tgetJsonToken,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\twithdraw,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: StateToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst setter: React.MutableRefObject<\n\t\t(<New extends T>(next: New | ((old: T) => New)) => void) | null\n\t> = React.useRef(null)\n\tif (setter.current === null) {\n\t\tsetter.current = (next) => setState(token, next, store)\n\t}\n\treturn setter.current\n}\n\nexport function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),\n\t\t() => getState(token, store),\n\t\t() => getState(token, store),\n\t)\n}\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable {\n\tconst jsonToken = getJsonToken(token)\n\treturn useO(jsonToken)\n}\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken): TimelineMeta {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tconst timeline = withdraw(token, store)\n\tconst tokenRef = React.useRef(token)\n\tconst rebuildMeta = () => {\n\t\treturn {\n\t\t\tat: timeline?.at ?? NaN,\n\t\t\tlength: timeline?.history.length ?? NaN,\n\t\t\tundo: () => undo(token),\n\t\t\tredo: () => redo(token),\n\t\t}\n\t}\n\tconst meta = React.useRef<TimelineMeta>(rebuildMeta())\n\tconst retrieve = () => {\n\t\tif (\n\t\t\tmeta.current.at !== timeline?.at ||\n\t\t\tmeta.current.length !== timeline?.history.length ||\n\t\t\ttokenRef.current !== token\n\t\t) {\n\t\t\ttokenRef.current = token\n\t\t\tmeta.current = rebuildMeta()\n\t\t}\n\t\treturn meta.current\n\t}\n\treturn React.useSyncExternalStore<TimelineMeta>(\n\t\t(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),\n\t\tretrieve,\n\t\tretrieve,\n\t)\n}\n"]}
|
package/react/dist/index.js
CHANGED
|
@@ -31,27 +31,24 @@ function useTL(token) {
|
|
|
31
31
|
const store = React2.useContext(StoreContext);
|
|
32
32
|
const id = React2.useId();
|
|
33
33
|
const timeline = withdraw(token, store);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
redo: () => redo(token)
|
|
37
|
-
});
|
|
38
|
-
const rebuildMeta = React2.useCallback(() => {
|
|
34
|
+
const tokenRef = React2.useRef(token);
|
|
35
|
+
const rebuildMeta = () => {
|
|
39
36
|
var _a, _b;
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, []);
|
|
37
|
+
return {
|
|
38
|
+
at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
|
|
39
|
+
length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN,
|
|
40
|
+
undo: () => undo(token),
|
|
41
|
+
redo: () => redo(token)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
48
44
|
const meta = React2.useRef(rebuildMeta());
|
|
49
|
-
const retrieve =
|
|
50
|
-
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length)) {
|
|
45
|
+
const retrieve = () => {
|
|
46
|
+
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length) || tokenRef.current !== token) {
|
|
47
|
+
tokenRef.current = token;
|
|
51
48
|
meta.current = rebuildMeta();
|
|
52
49
|
}
|
|
53
50
|
return meta.current;
|
|
54
|
-
}
|
|
51
|
+
};
|
|
55
52
|
return React2.useSyncExternalStore(
|
|
56
53
|
(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
|
|
57
54
|
retrieve,
|
package/react/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store-context.tsx","../src/store-hooks.ts"],"names":["React"],"mappings":";;;AACA,SAAS,gBAAgB;AACzB,YAAY,WAAW;AAQtB;AANM,IAAM,eAAqB,oBAAqB,SAAS,KAAK;AAE9D,IAAM,gBAGR,CAAC,EAAE,UAAU,QAAQ,SAAS,MAAM,MACxC,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;;;ACVhD,YAAYA,YAAW;AAEvB,SAAS,UAAU,MAAM,UAAU,YAAY;AAQ/C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAIA,SAAS,KACf,OACyD;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAEI,cAAO,IAAI;AACrB,MAAI,OAAO,YAAY,MAAM;AAC5B,WAAO,UAAU,CAAC,SAAS,SAAS,OAAO,MAAM,KAAK;AAAA,EACvD;AACA,SAAO,OAAO;AACf;AAEO,SAAS,KAAQ,OAAoD;AAC3E,QAAM,QAAc,kBAAW,YAA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O,KAAK;AAAA,EAC5B;AACD;AAEO,SAAS,QACf,OACe;AACf,QAAM,YAAY,aAAa,KAAK;AACpC,SAAO,KAAK,SAAS;AACtB;AASO,SAAS,MAAM,OAAoC;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,QAAM,WAAW,SAAS,OAAO,KAAK;AACtC,QAAM,WAAiB,cAAO,KAAK;AACnC,QAAM,cAAc,MAAM;AA7D3B;AA8DE,WAAO;AAAA,MACN,KAAI,0CAAU,OAAV,YAAgB;AAAA,MACpB,SAAQ,0CAAU,QAAQ,WAAlB,YAA4B;AAAA,MACpC,MAAM,MAAM,KAAK,KAAK;AAAA,MACtB,MAAM,MAAM,KAAK,KAAK;AAAA,IACvB;AAAA,EACD;AACA,QAAM,OAAa,cAAqB,YAAY,CAAC;AACrD,QAAM,WAAW,MAAM;AACtB,QACC,KAAK,QAAQ,QAAO,qCAAU,OAC9B,KAAK,QAAQ,YAAW,qCAAU,QAAQ,WAC1C,SAAS,YAAY,OACpB;AACD,eAAS,UAAU;AACnB,WAAK,UAAU,YAAY;AAAA,IAC5B;AACA,WAAO,KAAK;AAAA,EACb;AACA,SAAa;AAAA,IACZ,CAAC,aAAa,oBAAoB,OAAO,UAAU,UAAU,EAAE,IAAI,KAAK;AAAA,IACxE;AAAA,IACA;AAAA,EACD;AACD","sourcesContent":["import type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nexport const StoreContext = React.createContext<Store>(IMPLICIT.STORE)\n\nexport const StoreProvider: React.FC<{\n\tchildren: React.ReactNode\n\tstore?: Store\n}> = ({ children, store = IMPLICIT.STORE }) => (\n\t<StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n)\n","import * as React from \"react\"\n\nimport { getState, redo, setState, undo } from \"atom.io\"\nimport type {\n\tMutableAtomToken,\n\tReadonlySelectorToken,\n\tStateToken,\n\tTimelineToken,\n} from \"atom.io\"\n\nimport {\n\tgetJsonToken,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\twithdraw,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: StateToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst setter: React.MutableRefObject<\n\t\t(<New extends T>(next: New | ((old: T) => New)) => void) | null\n\t> = React.useRef(null)\n\tif (setter.current === null) {\n\t\tsetter.current = (next) => setState(token, next, store)\n\t}\n\treturn setter.current\n}\n\nexport function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),\n\t\t() => getState(token, store),\n\t\t() => getState(token, store),\n\t)\n}\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable {\n\tconst jsonToken = getJsonToken(token)\n\treturn useO(jsonToken)\n}\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken): TimelineMeta {\n\tconst store = React.useContext(StoreContext)\n\tconst id = React.useId()\n\tconst timeline = withdraw(token, store)\n\tconst tokenRef = React.useRef(token)\n\tconst rebuildMeta = () => {\n\t\treturn {\n\t\t\tat: timeline?.at ?? NaN,\n\t\t\tlength: timeline?.history.length ?? NaN,\n\t\t\tundo: () => undo(token),\n\t\t\tredo: () => redo(token),\n\t\t}\n\t}\n\tconst meta = React.useRef<TimelineMeta>(rebuildMeta())\n\tconst retrieve = () => {\n\t\tif (\n\t\t\tmeta.current.at !== timeline?.at ||\n\t\t\tmeta.current.length !== timeline?.history.length ||\n\t\t\ttokenRef.current !== token\n\t\t) {\n\t\t\ttokenRef.current = token\n\t\t\tmeta.current = rebuildMeta()\n\t\t}\n\t\treturn meta.current\n\t}\n\treturn React.useSyncExternalStore<TimelineMeta>(\n\t\t(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),\n\t\tretrieve,\n\t\tretrieve,\n\t)\n}\n"]}
|
package/react/src/store-hooks.ts
CHANGED
|
@@ -58,29 +58,27 @@ export function useTL(token: TimelineToken): TimelineMeta {
|
|
|
58
58
|
const store = React.useContext(StoreContext)
|
|
59
59
|
const id = React.useId()
|
|
60
60
|
const timeline = withdraw(token, store)
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
base.current,
|
|
72
|
-
)
|
|
73
|
-
}, [])
|
|
61
|
+
const tokenRef = React.useRef(token)
|
|
62
|
+
const rebuildMeta = () => {
|
|
63
|
+
return {
|
|
64
|
+
at: timeline?.at ?? NaN,
|
|
65
|
+
length: timeline?.history.length ?? NaN,
|
|
66
|
+
undo: () => undo(token),
|
|
67
|
+
redo: () => redo(token),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
74
70
|
const meta = React.useRef<TimelineMeta>(rebuildMeta())
|
|
75
|
-
const retrieve =
|
|
71
|
+
const retrieve = () => {
|
|
76
72
|
if (
|
|
77
73
|
meta.current.at !== timeline?.at ||
|
|
78
|
-
meta.current.length !== timeline?.history.length
|
|
74
|
+
meta.current.length !== timeline?.history.length ||
|
|
75
|
+
tokenRef.current !== token
|
|
79
76
|
) {
|
|
77
|
+
tokenRef.current = token
|
|
80
78
|
meta.current = rebuildMeta()
|
|
81
79
|
}
|
|
82
80
|
return meta.current
|
|
83
|
-
}
|
|
81
|
+
}
|
|
84
82
|
return React.useSyncExternalStore<TimelineMeta>(
|
|
85
83
|
(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
|
|
86
84
|
retrieve,
|
package/data/dist/index.d.cts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import * as AtomIO from 'atom.io';
|
|
2
|
-
import { SelectorFamily } from 'atom.io';
|
|
3
|
-
import { Store } from 'atom.io/internal';
|
|
4
|
-
import { Json, Stringified } from 'atom.io/json';
|
|
5
|
-
|
|
6
|
-
declare function dict<State, Key extends Json.Serializable>(findState: AtomIO.AtomFamily<State, Key> | AtomIO.ReadonlySelectorFamily<State, Key> | AtomIO.SelectorFamily<State, Key>, index: AtomIO.AtomToken<Key[]> | AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.SelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
|
|
7
|
-
[K in Stringified<Key>]: State;
|
|
8
|
-
}>;
|
|
9
|
-
|
|
10
|
-
type primitive = boolean | number | string | null;
|
|
11
|
-
|
|
12
|
-
type Serializable = primitive | Readonly<{
|
|
13
|
-
[key: string]: Serializable;
|
|
14
|
-
}> | ReadonlyArray<Serializable>;
|
|
15
|
-
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
16
|
-
|
|
17
|
-
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
18
|
-
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
19
|
-
|
|
20
|
-
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
21
|
-
readonly relations: [string, string[]][];
|
|
22
|
-
readonly contents: [string, Content][];
|
|
23
|
-
}
|
|
24
|
-
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
25
|
-
readonly between: [a: ASide, b: BSide];
|
|
26
|
-
readonly cardinality: Cardinality;
|
|
27
|
-
}
|
|
28
|
-
type BaseExternalStoreConfiguration = {
|
|
29
|
-
addRelation: (a: string, b: string) => void;
|
|
30
|
-
deleteRelation: (a: string, b: string) => void;
|
|
31
|
-
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
32
|
-
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
33
|
-
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
34
|
-
has: (a: string, b?: string) => boolean;
|
|
35
|
-
};
|
|
36
|
-
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
37
|
-
getContent: (contentKey: string) => Content | undefined;
|
|
38
|
-
setContent: (contentKey: string, content: Content) => void;
|
|
39
|
-
deleteContent: (contentKey: string) => void;
|
|
40
|
-
};
|
|
41
|
-
type Empty<Obj extends object> = {
|
|
42
|
-
[Key in keyof Obj]?: undefined;
|
|
43
|
-
};
|
|
44
|
-
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
45
|
-
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
46
|
-
externalStore?: ExternalStoreConfiguration<Content>;
|
|
47
|
-
isContent?: Refinement<unknown, Content>;
|
|
48
|
-
makeContentKey?: (a: string, b: string) => string;
|
|
49
|
-
};
|
|
50
|
-
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
51
|
-
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
52
|
-
readonly a: ASide;
|
|
53
|
-
readonly b: BSide;
|
|
54
|
-
readonly cardinality: Cardinality;
|
|
55
|
-
readonly relations: Map<string, Set<string>>;
|
|
56
|
-
readonly contents: Map<string, Content>;
|
|
57
|
-
isContent: Refinement<unknown, Content> | null;
|
|
58
|
-
makeContentKey: (a: string, b: string) => string;
|
|
59
|
-
getRelatedKeys(key: string): Set<string> | undefined;
|
|
60
|
-
protected addRelation(a: string, b: string): void;
|
|
61
|
-
protected deleteRelation(a: string, b: string): void;
|
|
62
|
-
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
63
|
-
protected replaceRelationsSafely(a: string, bs: string[]): void;
|
|
64
|
-
protected getContentInternal(contentKey: string): Content | undefined;
|
|
65
|
-
protected setContent(contentKey: string, content: Content): void;
|
|
66
|
-
protected deleteContent(contentKey: string): void;
|
|
67
|
-
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
68
|
-
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
69
|
-
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
70
|
-
set(relation: {
|
|
71
|
-
[Key in ASide | BSide]: string;
|
|
72
|
-
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
73
|
-
delete(a: string, b?: string): this;
|
|
74
|
-
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
75
|
-
getRelatedKey(key: string): string | undefined;
|
|
76
|
-
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
77
|
-
reckless: boolean;
|
|
78
|
-
}): this;
|
|
79
|
-
getContent(a: string, b: string): Content | undefined;
|
|
80
|
-
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
81
|
-
has(a: string, b?: string): boolean;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> extends Json.Object, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
|
|
85
|
-
readonly key: string;
|
|
86
|
-
readonly cardinality: Cardinality;
|
|
87
|
-
}
|
|
88
|
-
type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
89
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
90
|
-
string,
|
|
91
|
-
Content
|
|
92
|
-
] | undefined, string>;
|
|
93
|
-
} : {}) & {
|
|
94
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<string | undefined, string>;
|
|
95
|
-
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
96
|
-
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<[
|
|
97
|
-
string,
|
|
98
|
-
Content
|
|
99
|
-
] | undefined, string>;
|
|
100
|
-
} & {
|
|
101
|
-
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
102
|
-
string,
|
|
103
|
-
Content
|
|
104
|
-
][], string>;
|
|
105
|
-
} : {}) & {
|
|
106
|
-
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<string | undefined, string>;
|
|
107
|
-
} & {
|
|
108
|
-
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
|
|
109
|
-
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
110
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
111
|
-
string,
|
|
112
|
-
Content
|
|
113
|
-
][], string>;
|
|
114
|
-
} : {}) & {
|
|
115
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeysOf${Capitalize<BSide>}` : `${AB}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
|
|
116
|
-
} : never;
|
|
117
|
-
declare function join<const ASide extends string, const BSide extends string, const Cardinality extends Cardinality>(options: JoinOptions<ASide, BSide, Cardinality, null>, defaultContent?: undefined, store?: Store): {
|
|
118
|
-
relations: Junction<ASide, BSide>;
|
|
119
|
-
findState: JoinState<ASide, BSide, Cardinality, null>;
|
|
120
|
-
};
|
|
121
|
-
declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Json.Object>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
|
|
122
|
-
relations: Junction<ASide, BSide, Content>;
|
|
123
|
-
findState: JoinState<ASide, BSide, Cardinality, Content>;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
declare function struct<Struct extends {
|
|
127
|
-
[key: string]: unknown;
|
|
128
|
-
}, Key extends string>(options: {
|
|
129
|
-
key: Key;
|
|
130
|
-
default: Struct;
|
|
131
|
-
}, store?: Store): [
|
|
132
|
-
{
|
|
133
|
-
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
|
|
134
|
-
},
|
|
135
|
-
AtomIO.ReadonlySelectorToken<Struct>
|
|
136
|
-
];
|
|
137
|
-
|
|
138
|
-
declare function structFamily<Struct extends object, Key extends string>(options: {
|
|
139
|
-
key: Key;
|
|
140
|
-
default: Struct;
|
|
141
|
-
}): [
|
|
142
|
-
{
|
|
143
|
-
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
|
|
144
|
-
},
|
|
145
|
-
AtomIO.ReadonlySelectorFamily<Struct>
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
type Loadable<T> = Promise<T> | T;
|
|
149
|
-
type Fated<T, E extends Error = Error> = Loadable<E | T>;
|
|
150
|
-
/**
|
|
151
|
-
* Utility for handling loadable values
|
|
152
|
-
* @param loadable Loadable value
|
|
153
|
-
* @param fallback Fallback value until Loadable is resolved
|
|
154
|
-
* @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value
|
|
155
|
-
*/
|
|
156
|
-
declare function until<T>(loadable: Loadable<T>, fallback: T): T;
|
|
157
|
-
|
|
158
|
-
export { type Fated, type JoinOptions, type JoinState, type Loadable, dict, join, struct, structFamily, until };
|
package/dist/index.d.cts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import * as Internal from 'atom.io/internal';
|
|
2
|
-
import { Transceiver, Subject, Store, Timeline, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
3
|
-
import { Json, JsonInterface } from 'atom.io/json';
|
|
4
|
-
|
|
5
|
-
type Effectors<T> = {
|
|
6
|
-
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
7
|
-
onSet: (callback: (options: {
|
|
8
|
-
newValue: T;
|
|
9
|
-
oldValue: T;
|
|
10
|
-
}) => void) => void;
|
|
11
|
-
};
|
|
12
|
-
type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
|
|
13
|
-
type AtomOptions<T> = {
|
|
14
|
-
key: string;
|
|
15
|
-
default: T | (() => T);
|
|
16
|
-
effects?: AtomEffect<T>[];
|
|
17
|
-
};
|
|
18
|
-
type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
|
|
19
|
-
default: () => T;
|
|
20
|
-
mutable: true;
|
|
21
|
-
};
|
|
22
|
-
declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
23
|
-
declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
|
|
24
|
-
type AtomFamilyOptions<T, K extends Json.Serializable> = {
|
|
25
|
-
key: string;
|
|
26
|
-
default: T | ((key: K) => T);
|
|
27
|
-
effects?: (key: K) => AtomEffect<T>[];
|
|
28
|
-
};
|
|
29
|
-
type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => AtomToken<T>) & {
|
|
30
|
-
key: string;
|
|
31
|
-
type: `atom_family`;
|
|
32
|
-
subject: Subject<AtomToken<T>>;
|
|
33
|
-
mutable?: boolean;
|
|
34
|
-
};
|
|
35
|
-
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
|
|
36
|
-
mutable: true;
|
|
37
|
-
};
|
|
38
|
-
type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends Json.Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
|
|
39
|
-
key: `${string}`;
|
|
40
|
-
type: `atom_family`;
|
|
41
|
-
subject: Subject<MutableAtomToken<Core, SerializableCore>>;
|
|
42
|
-
mutable: true;
|
|
43
|
-
};
|
|
44
|
-
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
|
|
45
|
-
declare function atomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
|
|
46
|
-
|
|
47
|
-
declare function dispose(token: ReadonlySelectorToken<any> | StateToken<any>, store?: Internal.Store): void;
|
|
48
|
-
|
|
49
|
-
declare function getState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Internal.Store): T;
|
|
50
|
-
|
|
51
|
-
declare const LoggerIconDictionary: {
|
|
52
|
-
readonly "\u231B": "Timeline event fully captured";
|
|
53
|
-
readonly "\u23E9": "Timeline redo";
|
|
54
|
-
readonly "\u23EA": "Timeline undo";
|
|
55
|
-
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
56
|
-
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
57
|
-
readonly "\u23F3": "Timeline event partially captured";
|
|
58
|
-
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
59
|
-
readonly "\uD83D\uDC81": "Notice";
|
|
60
|
-
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
61
|
-
readonly "\u2705": "Realtime transaction success";
|
|
62
|
-
readonly "\u2728": "Computation complete";
|
|
63
|
-
readonly "\u274C": "Conflict prevents attempted action";
|
|
64
|
-
readonly "\u2B55": "Operation start";
|
|
65
|
-
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
66
|
-
readonly "\uD83D\uDC40": "Subscription added";
|
|
67
|
-
readonly "\uD83D\uDC6A": "Family member added";
|
|
68
|
-
readonly "\uD83D\uDCC1": "Stow update";
|
|
69
|
-
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
70
|
-
readonly "\uD83D\uDCD6": "Read state";
|
|
71
|
-
readonly "\uD83D\uDCDD": "Write state";
|
|
72
|
-
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
73
|
-
readonly "\uD83D\uDD0C": "Register dependency";
|
|
74
|
-
readonly "\uD83D\uDD0D": "Discover root";
|
|
75
|
-
readonly "\uD83D\uDD25": "Delete state";
|
|
76
|
-
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
77
|
-
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
78
|
-
readonly "\uD83D\uDD34": "Operation complete";
|
|
79
|
-
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
80
|
-
readonly "\uD83D\uDCA5": "Caught";
|
|
81
|
-
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
82
|
-
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
83
|
-
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
84
|
-
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
85
|
-
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
86
|
-
readonly "\uD83E\uDDEE": "Computing selector";
|
|
87
|
-
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
88
|
-
readonly "\uD83E\uDE82": "Abort transaction";
|
|
89
|
-
};
|
|
90
|
-
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
91
|
-
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
92
|
-
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
93
|
-
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
94
|
-
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
95
|
-
type Logger = Record<LogLevel, LogFn>;
|
|
96
|
-
declare const simpleLog: (logLevel: keyof Logger) => LogFn;
|
|
97
|
-
declare const simpleLogger: Logger;
|
|
98
|
-
declare class AtomIOLogger implements Logger {
|
|
99
|
-
logLevel: `error` | `info` | `warn` | null;
|
|
100
|
-
private readonly filter?;
|
|
101
|
-
private readonly logger;
|
|
102
|
-
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
103
|
-
error: LogFn;
|
|
104
|
-
info: LogFn;
|
|
105
|
-
warn: LogFn;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type TransactionToken<_> = {
|
|
109
|
-
key: string;
|
|
110
|
-
type: `transaction`;
|
|
111
|
-
__brand?: _;
|
|
112
|
-
};
|
|
113
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
114
|
-
key: string;
|
|
115
|
-
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
116
|
-
params: Parameters<ƒ>;
|
|
117
|
-
output: ReturnType<ƒ>;
|
|
118
|
-
};
|
|
119
|
-
type Transactors = {
|
|
120
|
-
get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S;
|
|
121
|
-
set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void;
|
|
122
|
-
};
|
|
123
|
-
type ReadonlyTransactors = Pick<Transactors, `get`>;
|
|
124
|
-
type Read<ƒ extends ƒn> = (transactors: ReadonlyTransactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
125
|
-
type Write<ƒ extends ƒn> = (transactors: Transactors, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
126
|
-
type Act<ƒ extends ƒn> = (transactors: Transactors & {
|
|
127
|
-
run: typeof runTransaction;
|
|
128
|
-
}, ...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
129
|
-
type TransactionOptions<ƒ extends ƒn> = {
|
|
130
|
-
key: string;
|
|
131
|
-
do: Act<ƒ>;
|
|
132
|
-
};
|
|
133
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer ƒ> ? ƒ : never;
|
|
134
|
-
declare function transaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>): TransactionToken<ƒ>;
|
|
135
|
-
declare const runTransaction: <ƒ extends ƒn>(token: TransactionToken<ƒ>, store?: Store) => (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
136
|
-
|
|
137
|
-
type SelectorOptions<T> = {
|
|
138
|
-
key: string;
|
|
139
|
-
get: Read<() => T>;
|
|
140
|
-
set: Write<(newValue: T) => void>;
|
|
141
|
-
};
|
|
142
|
-
type ReadonlySelectorOptions<T> = {
|
|
143
|
-
key: string;
|
|
144
|
-
get: Read<() => T>;
|
|
145
|
-
};
|
|
146
|
-
declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
|
|
147
|
-
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
|
|
148
|
-
type SelectorFamilyOptions<T, K extends Json.Serializable> = {
|
|
149
|
-
key: string;
|
|
150
|
-
get: (key: K) => Read<() => T>;
|
|
151
|
-
set: (key: K) => Write<(newValue: T) => void>;
|
|
152
|
-
};
|
|
153
|
-
type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {
|
|
154
|
-
key: string;
|
|
155
|
-
get: (key: K) => Read<() => T>;
|
|
156
|
-
};
|
|
157
|
-
type SelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
158
|
-
key: string;
|
|
159
|
-
type: `selector_family`;
|
|
160
|
-
subject: Subject<SelectorToken<T>>;
|
|
161
|
-
};
|
|
162
|
-
type ReadonlySelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
163
|
-
key: string;
|
|
164
|
-
type: `readonly_selector_family`;
|
|
165
|
-
subject: Subject<ReadonlySelectorToken<T>>;
|
|
166
|
-
};
|
|
167
|
-
declare function selectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
|
|
168
|
-
declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
|
|
169
|
-
|
|
170
|
-
declare function setState<T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Internal.Store): void;
|
|
171
|
-
|
|
172
|
-
declare class Silo {
|
|
173
|
-
store: Store;
|
|
174
|
-
atom: typeof atom;
|
|
175
|
-
atomFamily: typeof atomFamily;
|
|
176
|
-
selector: typeof selector;
|
|
177
|
-
selectorFamily: typeof selectorFamily;
|
|
178
|
-
transaction: typeof transaction;
|
|
179
|
-
timeline: typeof timeline;
|
|
180
|
-
getState: typeof getState;
|
|
181
|
-
setState: typeof setState;
|
|
182
|
-
subscribe: typeof subscribe;
|
|
183
|
-
undo: typeof undo;
|
|
184
|
-
redo: typeof redo;
|
|
185
|
-
constructor(name: string, fromStore?: Store | null);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
type StateUpdate<T> = {
|
|
189
|
-
newValue: T;
|
|
190
|
-
oldValue: T;
|
|
191
|
-
};
|
|
192
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
193
|
-
key: string;
|
|
194
|
-
family?: FamilyMetadata;
|
|
195
|
-
};
|
|
196
|
-
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
197
|
-
type TransactionUpdateHandler<ƒ extends ƒn> = (data: TransactionUpdate<ƒ>) => void;
|
|
198
|
-
declare function subscribe<T>(token: ReadonlySelectorToken<T> | StateToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
199
|
-
declare function subscribe<ƒ extends ƒn>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key?: string, store?: Store): () => void;
|
|
200
|
-
declare function subscribe(token: TimelineToken, handleUpdate: (update: TimelineUpdate | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
|
|
201
|
-
|
|
202
|
-
type TimelineToken = {
|
|
203
|
-
key: string;
|
|
204
|
-
type: `timeline`;
|
|
205
|
-
};
|
|
206
|
-
type TimelineOptions = {
|
|
207
|
-
key: string;
|
|
208
|
-
atoms: (AtomFamily<any, any> | AtomToken<any>)[];
|
|
209
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
210
|
-
};
|
|
211
|
-
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
212
|
-
declare const timeline: (options: TimelineOptions) => TimelineToken;
|
|
213
|
-
declare const redo: (timeline: TimelineToken) => void;
|
|
214
|
-
declare const undo: (timeline: TimelineToken) => void;
|
|
215
|
-
|
|
216
|
-
type ƒn = (...parameters: any[]) => any;
|
|
217
|
-
type AtomToken<_> = {
|
|
218
|
-
key: string;
|
|
219
|
-
type: `atom`;
|
|
220
|
-
family?: FamilyMetadata;
|
|
221
|
-
__brand?: _;
|
|
222
|
-
};
|
|
223
|
-
interface MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable> extends AtomToken<T> {
|
|
224
|
-
__asJSON?: J;
|
|
225
|
-
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
226
|
-
}
|
|
227
|
-
type SelectorToken<_> = {
|
|
228
|
-
key: string;
|
|
229
|
-
type: `selector`;
|
|
230
|
-
family?: FamilyMetadata;
|
|
231
|
-
__brand?: _;
|
|
232
|
-
};
|
|
233
|
-
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
234
|
-
type ReadonlySelectorToken<_> = {
|
|
235
|
-
key: string;
|
|
236
|
-
type: `readonly_selector`;
|
|
237
|
-
family?: FamilyMetadata;
|
|
238
|
-
__brand?: _;
|
|
239
|
-
};
|
|
240
|
-
type FamilyMetadata = {
|
|
241
|
-
key: string;
|
|
242
|
-
subKey: string;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
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/metafile-cjs.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/atom.ts":{"bytes":2990,"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":21949},"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}}}
|
package/dist/metafile-esm.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/atom.ts":{"bytes":2990,"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":21949},"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}}}
|