atom.io 0.14.3 → 0.14.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/{chunk-CWKKQKVQ.js → chunk-HQWWV67P.js} +17 -23
- package/dist/chunk-HQWWV67P.js.map +1 -0
- package/dist/{chunk-C4YZZNRH.js → chunk-MK4OJD24.js} +2 -2
- package/package.json +1 -1
- package/react/dist/index.cjs +16 -22
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.js +1 -1
- package/react/src/store-hooks.ts +18 -20
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.js +1 -1
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.js +2 -2
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +2 -2
- package/dist/chunk-CWKKQKVQ.js.map +0 -1
- /package/dist/{chunk-C4YZZNRH.js.map → chunk-MK4OJD24.js.map} +0 -0
|
@@ -29,33 +29,27 @@ function useTL(token) {
|
|
|
29
29
|
const store = React2.useContext(StoreContext);
|
|
30
30
|
const id = React2.useId();
|
|
31
31
|
const timeline = withdraw(token, store);
|
|
32
|
-
|
|
33
|
-
store.logger.error(
|
|
34
|
-
`\u274C`,
|
|
35
|
-
`timeline`,
|
|
36
|
-
token.key,
|
|
37
|
-
`Failed to use timeline because it does not exist`
|
|
38
|
-
);
|
|
39
|
-
return {
|
|
40
|
-
at: NaN,
|
|
41
|
-
length: NaN,
|
|
42
|
-
undo: () => {
|
|
43
|
-
},
|
|
44
|
-
redo: () => {
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const meta = React2.useRef({
|
|
49
|
-
at: timeline.at,
|
|
50
|
-
length: timeline.history.length,
|
|
32
|
+
const base = React2.useRef({
|
|
51
33
|
undo: () => undo(token),
|
|
52
34
|
redo: () => redo(token)
|
|
53
35
|
});
|
|
36
|
+
const rebuildMeta = React2.useCallback(() => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return Object.assign(
|
|
39
|
+
{
|
|
40
|
+
at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
|
|
41
|
+
length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN
|
|
42
|
+
},
|
|
43
|
+
base.current
|
|
44
|
+
);
|
|
45
|
+
}, []);
|
|
46
|
+
const meta = React2.useRef(rebuildMeta());
|
|
54
47
|
const retrieve = React2.useCallback(() => {
|
|
55
|
-
meta.current.at
|
|
56
|
-
|
|
48
|
+
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length)) {
|
|
49
|
+
meta.current = rebuildMeta();
|
|
50
|
+
}
|
|
57
51
|
return meta.current;
|
|
58
|
-
}, [
|
|
52
|
+
}, []);
|
|
59
53
|
return React2.useSyncExternalStore(
|
|
60
54
|
(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
|
|
61
55
|
retrieve,
|
|
@@ -65,4 +59,4 @@ function useTL(token) {
|
|
|
65
59
|
|
|
66
60
|
export { StoreContext, StoreProvider, useI, useJSON, useO, useTL };
|
|
67
61
|
//# sourceMappingURL=out.js.map
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-HQWWV67P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../react/src/store-context.tsx","../react/src/store-hooks.ts"],"names":["React"],"mappings":";;;;;;;;;;;;;AAEA,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;AAmBhB,SAAS,KACf,OACyD;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,SAEI,cAAO,IAAI;AACr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;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 base = React.useRef({\n\t\tundo: () => undo(token),\n\t\tredo: () => redo(token),\n\t})\n\tconst rebuildMeta = React.useCallback(() => {\n\t\treturn Object.assign(\n\t\t\t{\n\t\t\t\tat: timeline?.at ?? NaN,\n\t\t\t\tlength: timeline?.history.length ?? NaN,\n\t\t\t},\n\t\t\tbase.current,\n\t\t)\n\t}, [])\n\tconst meta = React.useRef<TimelineMeta>(rebuildMeta())\n\tconst retrieve = React.useCallback(() => {\n\t\tif (\n\t\t\tmeta.current.at !== timeline?.at ||\n\t\t\tmeta.current.length !== timeline?.history.length\n\t\t) {\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useI, StoreContext } from './chunk-
|
|
1
|
+
import { useI, StoreContext } from './chunk-HQWWV67P.js';
|
|
2
2
|
import { myIdState__INTERNAL, pullState, pullFamilyMember, pullMutableState, pullMutableFamilyMember, pushState, synchronizeTransactionResults } from './chunk-N7ADBQJG.js';
|
|
3
3
|
import { runTransaction } from './chunk-PURABO5G.js';
|
|
4
4
|
import * as React6 from 'react';
|
|
@@ -64,4 +64,4 @@ function useServerAction(token) {
|
|
|
64
64
|
|
|
65
65
|
export { RealtimeContext, RealtimeProvider, usePull, usePullFamilyMember, usePullMutable, usePullMutableFamilyMember, usePush, useServerAction };
|
|
66
66
|
//# sourceMappingURL=out.js.map
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-MK4OJD24.js.map
|
package/package.json
CHANGED
package/react/dist/index.cjs
CHANGED
|
@@ -1588,33 +1588,27 @@ function useTL(token) {
|
|
|
1588
1588
|
const store = React2__namespace.useContext(StoreContext);
|
|
1589
1589
|
const id = React2__namespace.useId();
|
|
1590
1590
|
const timeline = withdraw(token, store);
|
|
1591
|
-
|
|
1592
|
-
store.logger.error(
|
|
1593
|
-
`\u274C`,
|
|
1594
|
-
`timeline`,
|
|
1595
|
-
token.key,
|
|
1596
|
-
`Failed to use timeline because it does not exist`
|
|
1597
|
-
);
|
|
1598
|
-
return {
|
|
1599
|
-
at: NaN,
|
|
1600
|
-
length: NaN,
|
|
1601
|
-
undo: () => {
|
|
1602
|
-
},
|
|
1603
|
-
redo: () => {
|
|
1604
|
-
}
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
const meta = React2__namespace.useRef({
|
|
1608
|
-
at: timeline.at,
|
|
1609
|
-
length: timeline.history.length,
|
|
1591
|
+
const base = React2__namespace.useRef({
|
|
1610
1592
|
undo: () => undo(token),
|
|
1611
1593
|
redo: () => redo(token)
|
|
1612
1594
|
});
|
|
1595
|
+
const rebuildMeta = React2__namespace.useCallback(() => {
|
|
1596
|
+
var _a, _b;
|
|
1597
|
+
return Object.assign(
|
|
1598
|
+
{
|
|
1599
|
+
at: (_a = timeline == null ? void 0 : timeline.at) != null ? _a : NaN,
|
|
1600
|
+
length: (_b = timeline == null ? void 0 : timeline.history.length) != null ? _b : NaN
|
|
1601
|
+
},
|
|
1602
|
+
base.current
|
|
1603
|
+
);
|
|
1604
|
+
}, []);
|
|
1605
|
+
const meta = React2__namespace.useRef(rebuildMeta());
|
|
1613
1606
|
const retrieve = React2__namespace.useCallback(() => {
|
|
1614
|
-
meta.current.at
|
|
1615
|
-
|
|
1607
|
+
if (meta.current.at !== (timeline == null ? void 0 : timeline.at) || meta.current.length !== (timeline == null ? void 0 : timeline.history.length)) {
|
|
1608
|
+
meta.current = rebuildMeta();
|
|
1609
|
+
}
|
|
1616
1610
|
return meta.current;
|
|
1617
|
-
}, [
|
|
1611
|
+
}, []);
|
|
1618
1612
|
return React2__namespace.useSyncExternalStore(
|
|
1619
1613
|
(dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
|
|
1620
1614
|
retrieve,
|