atom.io 0.16.3 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +62 -40
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.ts +8 -2
- package/data/dist/index.js +64 -42
- package/data/dist/index.js.map +1 -1
- package/data/src/dict.ts +8 -4
- package/data/src/join.ts +74 -33
- package/data/src/struct-family.ts +18 -17
- package/dist/chunk-OEVFAUPE.js +289 -0
- package/dist/chunk-OEVFAUPE.js.map +1 -0
- package/dist/index.cjs +36 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +64 -53
- package/dist/index.js +15 -36
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +211 -81
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +100 -72
- package/internal/dist/index.js +200 -75
- package/internal/dist/index.js.map +1 -1
- package/internal/src/arbitrary.ts +3 -0
- package/internal/src/atom/create-regular-atom.ts +2 -3
- package/internal/src/caching.ts +8 -6
- package/internal/src/families/find-in-store.ts +16 -0
- package/internal/src/get-environment-data.ts +4 -7
- package/internal/src/get-state/get-from-store.ts +14 -0
- package/internal/src/get-state/index.ts +2 -0
- package/internal/src/{read-or-compute-value.ts → get-state/read-or-compute-value.ts} +3 -3
- package/internal/src/index.ts +7 -6
- package/internal/src/ingest-updates/ingest-atom-update.ts +2 -2
- package/internal/src/ingest-updates/ingest-transaction-update.ts +0 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -4
- package/internal/src/mutable/tracker.ts +18 -13
- package/internal/src/selector/create-standalone-selector.ts +0 -2
- package/internal/src/selector/register-selector.ts +1 -1
- package/internal/src/set-state/index.ts +1 -0
- package/internal/src/set-state/set-atom.ts +15 -19
- package/internal/src/set-state/set-into-store.ts +24 -0
- package/internal/src/store/store.ts +14 -2
- package/internal/src/store/withdraw.ts +72 -2
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +1 -1
- package/internal/src/subscribe/subscribe-to-timeline.ts +2 -2
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +12 -1
- package/internal/src/transaction/act-upon-store.ts +19 -0
- package/internal/src/transaction/apply-transaction.ts +7 -1
- package/internal/src/transaction/assign-transaction-to-continuity.ts +18 -0
- package/internal/src/transaction/build-transaction.ts +11 -8
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/internal/src/transaction/get-epoch-number.ts +40 -0
- package/internal/src/transaction/index.ts +10 -1
- package/internal/src/transaction/set-epoch-number.ts +31 -0
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-introspection-states.ts +6 -2
- package/introspection/src/attach-timeline-family.ts +5 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.d.ts +3 -1
- package/json/src/index.ts +6 -2
- package/package.json +24 -13
- package/react/dist/index.cjs +3 -3
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js +5 -5
- package/react/dist/index.js.map +1 -1
- package/react/src/use-i.ts +2 -3
- package/react/src/use-json.ts +1 -1
- package/react/src/use-o.ts +3 -4
- package/react-devtools/dist/index.cjs +131 -134
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.ts +3 -3
- package/react-devtools/dist/index.js +103 -106
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -5
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +9 -8
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +4 -4
- package/realtime/dist/index.cjs +72 -0
- package/realtime/dist/index.cjs.map +1 -0
- package/realtime/dist/index.d.ts +39 -0
- package/realtime/dist/index.js +68 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/package.json +16 -0
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +152 -0
- package/realtime-client/dist/index.cjs +403 -59
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +16 -9
- package/realtime-client/dist/index.js +114 -48
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +8 -5
- package/realtime-client/src/{pull-family-member.ts → pull-atom-family-member.ts} +5 -5
- package/realtime-client/src/{pull-state.ts → pull-atom.ts} +5 -5
- package/realtime-client/src/{pull-mutable-family-member.ts → pull-mutable-atom-family-member.ts} +5 -5
- package/realtime-client/src/{pull-mutable.ts → pull-mutable-atom.ts} +5 -5
- package/realtime-client/src/pull-selector-family-member.ts +42 -0
- package/realtime-client/src/pull-selector.ts +38 -0
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +2 -2
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
- package/realtime-client/src/sync-continuity.ts +321 -0
- package/realtime-client/src/sync-server-action.ts +22 -21
- package/realtime-client/src/sync-state.ts +3 -3
- package/realtime-react/dist/index.cjs +330 -15
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +26 -6
- package/realtime-react/dist/index.js +43 -12
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +6 -3
- package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
- package/realtime-react/src/{use-pull.ts → use-pull-atom.ts} +6 -5
- package/realtime-react/src/{use-pull-mutable.ts → use-pull-mutable-atom.ts} +4 -3
- package/realtime-react/src/use-pull-mutable-family-member.ts +9 -4
- package/realtime-react/src/use-pull-selector-family-member.ts +21 -0
- package/realtime-react/src/{use-pull-family-member.ts → use-pull-selector.ts} +7 -5
- package/realtime-react/src/use-push.ts +3 -2
- package/realtime-react/src/use-server-action.ts +3 -2
- package/realtime-react/src/use-sync-continuity.ts +12 -0
- package/realtime-react/src/use-sync-server-action.ts +3 -2
- package/realtime-server/dist/index.cjs +582 -256
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +124 -49
- package/realtime-server/dist/index.js +566 -249
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +18 -2
- package/realtime-server/src/ipc-socket.ts +230 -0
- package/realtime-server/src/realtime-action-receiver.ts +8 -5
- package/realtime-server/src/realtime-action-synchronizer.ts +53 -35
- package/realtime-server/src/realtime-continuity-synchronizer.ts +247 -0
- package/realtime-server/src/realtime-family-provider.ts +37 -73
- package/realtime-server/src/realtime-mutable-family-provider.ts +26 -87
- package/realtime-server/src/realtime-mutable-provider.ts +3 -2
- package/realtime-server/src/realtime-server-stores/index.ts +3 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +90 -0
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +97 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +2 -72
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +14 -29
- package/realtime-server/src/realtime-state-provider.ts +3 -3
- package/realtime-server/src/realtime-state-receiver.ts +2 -3
- package/realtime-server/src/realtime-state-synchronizer.ts +3 -3
- package/realtime-testing/dist/index.cjs +28 -28
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +28 -27
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +38 -28
- package/src/atom.ts +49 -31
- package/src/get-state.ts +2 -11
- package/src/logger.ts +10 -5
- package/src/selector.ts +44 -25
- package/src/set-state.ts +1 -13
- package/src/silo.ts +7 -3
- package/src/subscribe.ts +2 -1
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +13 -17
- package/src/validators.ts +15 -9
- package/dist/chunk-H4Q5FTPZ.js +0 -11
- package/dist/chunk-H4Q5FTPZ.js.map +0 -1
- package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -19
package/react/dist/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ function useI(token, key) {
|
|
|
33
33
|
const stateToken = token.type === `atom_family` || token.type === `mutable_atom_family` || token.type === `selector_family` ? internal.findInStore(token, key, store) : token;
|
|
34
34
|
const setter = React5__namespace.useRef(null);
|
|
35
35
|
if (setter.current === null) {
|
|
36
|
-
setter.current = (next) =>
|
|
36
|
+
setter.current = (next) => internal.setIntoStore(stateToken, next, store);
|
|
37
37
|
}
|
|
38
38
|
return setter.current;
|
|
39
39
|
}
|
|
@@ -43,8 +43,8 @@ function useO(token, key) {
|
|
|
43
43
|
const id = React5__namespace.useId();
|
|
44
44
|
return React5__namespace.useSyncExternalStore(
|
|
45
45
|
(dispatch) => internal.subscribeToState(stateToken, dispatch, `use-o:${id}`, store),
|
|
46
|
-
() =>
|
|
47
|
-
() =>
|
|
46
|
+
() => internal.getFromStore(stateToken, store),
|
|
47
|
+
() => internal.getFromStore(stateToken, store)
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
package/react/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store-context.tsx","../src/use-i.ts","../src/use-json.ts","../src/use-o.ts","../src/use-tl.ts"],"names":["React","findInStore"],"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;;;
|
|
1
|
+
{"version":3,"sources":["../src/store-context.tsx","../src/use-i.ts","../src/use-json.ts","../src/use-o.ts","../src/use-tl.ts"],"names":["React","findInStore"],"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;;;ACThD,SAAS,aAAa,oBAAoB;AAE1C,YAAYA,YAAW;AAahB,SAAS,KACf,OACA,KACyD;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,iBACf,MAAM,SAAS,yBACf,MAAM,SAAS,oBACZ,YAAY,OAAO,KAAU,KAAK,IAClC;AACJ,QAAM,SAEI,cAAO,IAAI;AACrB,MAAI,OAAO,YAAY,MAAM;AAC5B,WAAO,UAAU,CAAC,SAAS,aAAa,YAAY,MAAM,KAAK;AAAA,EAChE;AACA,SAAO,OAAO;AACf;;;AC7BA,SAAS,eAAAC,cAAa,oBAAoB;AAE1C,YAAYD,YAAW;;;ACNvB,SAAS,eAAAC,cAAa,cAAc,wBAAwB;AAE5D,YAAYD,YAAW;AAWhB,SAAS,KACf,OACA,KACI;AACJ,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,iBACf,MAAM,SAAS,yBACf,MAAM,SAAS,qBACf,MAAM,SAAS,6BACZC,aAAY,OAAO,KAAU,KAAK,IAClC;AACJ,QAAM,KAAW,aAAM;AACvB,SAAa;AAAA,IACZ,CAAC,aAAa,iBAAiB,YAAY,UAAU,SAAS,EAAE,IAAI,KAAK;AAAA,IACzE,MAAM,aAAa,YAAY,KAAK;AAAA,IACpC,MAAM,aAAa,YAAY,KAAK;AAAA,EACrC;AACD;;;ADXO,SAAS,QAIf,OAGA,KACe;AACf,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,wBACZA,aAAY,OAAO,KAAY,KAAK,IACpC;AACJ,QAAM,YAAY,aAAa,UAAU;AACzC,SAAO,KAAK,SAAS;AACtB;;;AErCA,SAAS,MAAM,YAAY;AAE3B,SAAS,qBAAqB,gBAAgB;AAC9C,YAAYD,YAAW;AAWhB,SAAS,MAAM,OAAyC;AAC9D,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,QAAM,WAAW,SAAS,OAAO,KAAK;AACtC,QAAM,WAAiB,cAAO,KAAK;AACnC,QAAM,cAAc,MAAM;AAnB3B;AAoBE,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 type { ReadableToken, WritableFamilyToken, WritableToken } from \"atom.io\"\nimport { findInStore, setIntoStore } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: WritableToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void\n\nexport function useI<T, K extends Json.Serializable>(\n\ttoken: WritableFamilyToken<T, K>,\n\tkey: K,\n): <New extends T>(next: New | ((old: T) => New)) => void\n\nexport function useI<T, K extends Json.Serializable>(\n\ttoken: WritableFamilyToken<T, K> | WritableToken<T>,\n\tkey?: K,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `atom_family` ||\n\t\ttoken.type === `mutable_atom_family` ||\n\t\ttoken.type === `selector_family`\n\t\t\t? findInStore(token, key as K, store)\n\t\t\t: token\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) => setIntoStore(stateToken, next, store)\n\t}\n\treturn setter.current\n}\n","import type {\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableToken,\n} from \"atom.io\"\nimport { findInStore, getJsonToken } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\nimport { useO } from \"./use-o\"\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable\n\nexport function useJSON<\n\tSerializable extends Json.Serializable,\n\tKey extends Json.Serializable,\n>(token: MutableAtomFamilyToken<any, Serializable, Key>, key: Key): Serializable\n\nexport function useJSON<\n\tSerializable extends Json.Serializable,\n\tKey extends Serializable,\n>(\n\ttoken:\n\t\t| MutableAtomFamilyToken<any, Serializable, Key>\n\t\t| MutableAtomToken<any, Serializable>,\n\tkey?: Key,\n): Serializable {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `mutable_atom_family`\n\t\t\t? findInStore(token, key as Key, store)\n\t\t\t: token\n\tconst jsonToken = getJsonToken(stateToken)\n\treturn useO(jsonToken)\n}\n","import type { ReadableFamilyToken, ReadableToken } from \"atom.io\"\nimport { findInStore, getFromStore, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport function useO<T>(token: ReadableToken<T>): T\n\nexport function useO<T, K extends Json.Serializable>(\n\ttoken: ReadableFamilyToken<T, K>,\n\tkey: K,\n): T\n\nexport function useO<T, K extends Json.Serializable>(\n\ttoken: ReadableFamilyToken<T, K> | ReadableToken<T>,\n\tkey?: K,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `atom_family` ||\n\t\ttoken.type === `mutable_atom_family` ||\n\t\ttoken.type === `selector_family` ||\n\t\ttoken.type === `readonly_selector_family`\n\t\t\t? findInStore(token, key as K, store)\n\t\t\t: token\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(stateToken, dispatch, `use-o:${id}`, store),\n\t\t() => getFromStore(stateToken, store),\n\t\t() => getFromStore(stateToken, store),\n\t)\n}\n","import { redo, undo } from \"atom.io\"\nimport type { TimelineToken } from \"atom.io\"\nimport { subscribeToTimeline, withdraw } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken<any>): 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.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare function useI<T>(token: WritableToken<T>): <New extends T>(next: New | (
|
|
|
13
13
|
declare function useI<T, K extends Json.Serializable>(token: WritableFamilyToken<T, K>, key: K): <New extends T>(next: New | ((old: T) => New)) => void;
|
|
14
14
|
|
|
15
15
|
declare function useJSON<Serializable extends Json.Serializable>(token: MutableAtomToken<any, Serializable>): Serializable;
|
|
16
|
-
declare function useJSON<Serializable extends Json.Serializable, Key extends Serializable>(token: MutableAtomFamilyToken<any, Serializable, Key>, key: Key): Serializable;
|
|
16
|
+
declare function useJSON<Serializable extends Json.Serializable, Key extends Json.Serializable>(token: MutableAtomFamilyToken<any, Serializable, Key>, key: Key): Serializable;
|
|
17
17
|
|
|
18
18
|
declare function useO<T>(token: ReadableToken<T>): T;
|
|
19
19
|
declare function useO<T, K extends Json.Serializable>(token: ReadableFamilyToken<T, K>, key: K): T;
|
package/react/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../dist/chunk-PZLG2HP3.js';
|
|
2
|
-
import { IMPLICIT, findInStore, subscribeToState, getJsonToken, withdraw, subscribeToTimeline } from 'atom.io/internal';
|
|
2
|
+
import { IMPLICIT, findInStore, setIntoStore, subscribeToState, getFromStore, getJsonToken, withdraw, subscribeToTimeline } from 'atom.io/internal';
|
|
3
3
|
import * as React5 from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
5
|
+
import { undo, redo } from 'atom.io';
|
|
6
6
|
|
|
7
7
|
var StoreContext = React5.createContext(IMPLICIT.STORE);
|
|
8
8
|
var StoreProvider = ({ children, store = IMPLICIT.STORE }) => /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children });
|
|
@@ -11,7 +11,7 @@ function useI(token, key) {
|
|
|
11
11
|
const stateToken = token.type === `atom_family` || token.type === `mutable_atom_family` || token.type === `selector_family` ? findInStore(token, key, store) : token;
|
|
12
12
|
const setter = React5.useRef(null);
|
|
13
13
|
if (setter.current === null) {
|
|
14
|
-
setter.current = (next) =>
|
|
14
|
+
setter.current = (next) => setIntoStore(stateToken, next, store);
|
|
15
15
|
}
|
|
16
16
|
return setter.current;
|
|
17
17
|
}
|
|
@@ -21,8 +21,8 @@ function useO(token, key) {
|
|
|
21
21
|
const id = React5.useId();
|
|
22
22
|
return React5.useSyncExternalStore(
|
|
23
23
|
(dispatch) => subscribeToState(stateToken, dispatch, `use-o:${id}`, store),
|
|
24
|
-
() =>
|
|
25
|
-
() =>
|
|
24
|
+
() => getFromStore(stateToken, store),
|
|
25
|
+
() => getFromStore(stateToken, store)
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
package/react/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store-context.tsx","../src/use-i.ts","../src/use-json.ts","../src/use-o.ts","../src/use-tl.ts"],"names":["React","findInStore"],"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;;;
|
|
1
|
+
{"version":3,"sources":["../src/store-context.tsx","../src/use-i.ts","../src/use-json.ts","../src/use-o.ts","../src/use-tl.ts"],"names":["React","findInStore"],"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;;;ACThD,SAAS,aAAa,oBAAoB;AAE1C,YAAYA,YAAW;AAahB,SAAS,KACf,OACA,KACyD;AACzD,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,iBACf,MAAM,SAAS,yBACf,MAAM,SAAS,oBACZ,YAAY,OAAO,KAAU,KAAK,IAClC;AACJ,QAAM,SAEI,cAAO,IAAI;AACrB,MAAI,OAAO,YAAY,MAAM;AAC5B,WAAO,UAAU,CAAC,SAAS,aAAa,YAAY,MAAM,KAAK;AAAA,EAChE;AACA,SAAO,OAAO;AACf;;;AC7BA,SAAS,eAAAC,cAAa,oBAAoB;AAE1C,YAAYD,YAAW;;;ACNvB,SAAS,eAAAC,cAAa,cAAc,wBAAwB;AAE5D,YAAYD,YAAW;AAWhB,SAAS,KACf,OACA,KACI;AACJ,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,iBACf,MAAM,SAAS,yBACf,MAAM,SAAS,qBACf,MAAM,SAAS,6BACZC,aAAY,OAAO,KAAU,KAAK,IAClC;AACJ,QAAM,KAAW,aAAM;AACvB,SAAa;AAAA,IACZ,CAAC,aAAa,iBAAiB,YAAY,UAAU,SAAS,EAAE,IAAI,KAAK;AAAA,IACzE,MAAM,aAAa,YAAY,KAAK;AAAA,IACpC,MAAM,aAAa,YAAY,KAAK;AAAA,EACrC;AACD;;;ADXO,SAAS,QAIf,OAGA,KACe;AACf,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,aACL,MAAM,SAAS,wBACZA,aAAY,OAAO,KAAY,KAAK,IACpC;AACJ,QAAM,YAAY,aAAa,UAAU;AACzC,SAAO,KAAK,SAAS;AACtB;;;AErCA,SAAS,MAAM,YAAY;AAE3B,SAAS,qBAAqB,gBAAgB;AAC9C,YAAYD,YAAW;AAWhB,SAAS,MAAM,OAAyC;AAC9D,QAAM,QAAc,kBAAW,YAAY;AAC3C,QAAM,KAAW,aAAM;AACvB,QAAM,WAAW,SAAS,OAAO,KAAK;AACtC,QAAM,WAAiB,cAAO,KAAK;AACnC,QAAM,cAAc,MAAM;AAnB3B;AAoBE,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 type { ReadableToken, WritableFamilyToken, WritableToken } from \"atom.io\"\nimport { findInStore, setIntoStore } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport function useI<T>(\n\ttoken: WritableToken<T>,\n): <New extends T>(next: New | ((old: T) => New)) => void\n\nexport function useI<T, K extends Json.Serializable>(\n\ttoken: WritableFamilyToken<T, K>,\n\tkey: K,\n): <New extends T>(next: New | ((old: T) => New)) => void\n\nexport function useI<T, K extends Json.Serializable>(\n\ttoken: WritableFamilyToken<T, K> | WritableToken<T>,\n\tkey?: K,\n): <New extends T>(next: New | ((old: T) => New)) => void {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `atom_family` ||\n\t\ttoken.type === `mutable_atom_family` ||\n\t\ttoken.type === `selector_family`\n\t\t\t? findInStore(token, key as K, store)\n\t\t\t: token\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) => setIntoStore(stateToken, next, store)\n\t}\n\treturn setter.current\n}\n","import type {\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableToken,\n} from \"atom.io\"\nimport { findInStore, getJsonToken } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\nimport { useO } from \"./use-o\"\n\nexport function useJSON<Serializable extends Json.Serializable>(\n\ttoken: MutableAtomToken<any, Serializable>,\n): Serializable\n\nexport function useJSON<\n\tSerializable extends Json.Serializable,\n\tKey extends Json.Serializable,\n>(token: MutableAtomFamilyToken<any, Serializable, Key>, key: Key): Serializable\n\nexport function useJSON<\n\tSerializable extends Json.Serializable,\n\tKey extends Serializable,\n>(\n\ttoken:\n\t\t| MutableAtomFamilyToken<any, Serializable, Key>\n\t\t| MutableAtomToken<any, Serializable>,\n\tkey?: Key,\n): Serializable {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `mutable_atom_family`\n\t\t\t? findInStore(token, key as Key, store)\n\t\t\t: token\n\tconst jsonToken = getJsonToken(stateToken)\n\treturn useO(jsonToken)\n}\n","import type { ReadableFamilyToken, ReadableToken } from \"atom.io\"\nimport { findInStore, getFromStore, subscribeToState } from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport function useO<T>(token: ReadableToken<T>): T\n\nexport function useO<T, K extends Json.Serializable>(\n\ttoken: ReadableFamilyToken<T, K>,\n\tkey: K,\n): T\n\nexport function useO<T, K extends Json.Serializable>(\n\ttoken: ReadableFamilyToken<T, K> | ReadableToken<T>,\n\tkey?: K,\n): T {\n\tconst store = React.useContext(StoreContext)\n\tconst stateToken: ReadableToken<any> =\n\t\ttoken.type === `atom_family` ||\n\t\ttoken.type === `mutable_atom_family` ||\n\t\ttoken.type === `selector_family` ||\n\t\ttoken.type === `readonly_selector_family`\n\t\t\t? findInStore(token, key as K, store)\n\t\t\t: token\n\tconst id = React.useId()\n\treturn React.useSyncExternalStore<T>(\n\t\t(dispatch) => subscribeToState(stateToken, dispatch, `use-o:${id}`, store),\n\t\t() => getFromStore(stateToken, store),\n\t\t() => getFromStore(stateToken, store),\n\t)\n}\n","import { redo, undo } from \"atom.io\"\nimport type { TimelineToken } from \"atom.io\"\nimport { subscribeToTimeline, withdraw } from \"atom.io/internal\"\nimport * as React from \"react\"\n\nimport { StoreContext } from \"./store-context\"\n\nexport type TimelineMeta = {\n\tat: number\n\tlength: number\n\tundo: () => void\n\tredo: () => void\n}\n\nexport function useTL(token: TimelineToken<any>): 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/use-i.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { setState } from "atom.io"
|
|
2
1
|
import type { ReadableToken, WritableFamilyToken, WritableToken } from "atom.io"
|
|
3
|
-
import { findInStore } from "atom.io/internal"
|
|
2
|
+
import { findInStore, setIntoStore } from "atom.io/internal"
|
|
4
3
|
import type { Json } from "atom.io/json"
|
|
5
4
|
import * as React from "react"
|
|
6
5
|
|
|
@@ -30,7 +29,7 @@ export function useI<T, K extends Json.Serializable>(
|
|
|
30
29
|
(<New extends T>(next: New | ((old: T) => New)) => void) | null
|
|
31
30
|
> = React.useRef(null)
|
|
32
31
|
if (setter.current === null) {
|
|
33
|
-
setter.current = (next) =>
|
|
32
|
+
setter.current = (next) => setIntoStore(stateToken, next, store)
|
|
34
33
|
}
|
|
35
34
|
return setter.current
|
|
36
35
|
}
|
package/react/src/use-json.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function useJSON<Serializable extends Json.Serializable>(
|
|
|
16
16
|
|
|
17
17
|
export function useJSON<
|
|
18
18
|
Serializable extends Json.Serializable,
|
|
19
|
-
Key extends Serializable,
|
|
19
|
+
Key extends Json.Serializable,
|
|
20
20
|
>(token: MutableAtomFamilyToken<any, Serializable, Key>, key: Key): Serializable
|
|
21
21
|
|
|
22
22
|
export function useJSON<
|
package/react/src/use-o.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { getState } from "atom.io"
|
|
2
1
|
import type { ReadableFamilyToken, ReadableToken } from "atom.io"
|
|
3
|
-
import { findInStore, subscribeToState } from "atom.io/internal"
|
|
2
|
+
import { findInStore, getFromStore, subscribeToState } from "atom.io/internal"
|
|
4
3
|
import type { Json } from "atom.io/json"
|
|
5
4
|
import * as React from "react"
|
|
6
5
|
|
|
@@ -28,7 +27,7 @@ export function useO<T, K extends Json.Serializable>(
|
|
|
28
27
|
const id = React.useId()
|
|
29
28
|
return React.useSyncExternalStore<T>(
|
|
30
29
|
(dispatch) => subscribeToState(stateToken, dispatch, `use-o:${id}`, store),
|
|
31
|
-
() =>
|
|
32
|
-
() =>
|
|
30
|
+
() => getFromStore(stateToken, store),
|
|
31
|
+
() => getFromStore(stateToken, store),
|
|
33
32
|
)
|
|
34
33
|
}
|
|
@@ -61,21 +61,6 @@ var __objRest = (source, exclude) => {
|
|
|
61
61
|
return target;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
// __unstable__/web-effects/src/storage.ts
|
|
65
|
-
var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
|
|
66
|
-
const savedValue = storage.getItem(key);
|
|
67
|
-
if (savedValue != null)
|
|
68
|
-
setSelf(parse(savedValue));
|
|
69
|
-
onSet(({ newValue }) => {
|
|
70
|
-
if (newValue == null) {
|
|
71
|
-
storage.removeItem(key);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
storage.setItem(key, stringify(newValue));
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
|
|
78
|
-
|
|
79
64
|
// ../anvl/src/function/pipe.ts
|
|
80
65
|
function pipe(a2, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
81
66
|
switch (arguments.length) {
|
|
@@ -299,6 +284,116 @@ var discoverType = (input) => {
|
|
|
299
284
|
return Object.getPrototypeOf(input).constructor.name;
|
|
300
285
|
};
|
|
301
286
|
|
|
287
|
+
// ../anvl/src/json/index.ts
|
|
288
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
289
|
+
var JSON_TYPE_NAMES = [
|
|
290
|
+
`array`,
|
|
291
|
+
`boolean`,
|
|
292
|
+
`null`,
|
|
293
|
+
`number`,
|
|
294
|
+
`object`,
|
|
295
|
+
`string`
|
|
296
|
+
];
|
|
297
|
+
var JSON_DEFAULTS = {
|
|
298
|
+
array: [],
|
|
299
|
+
boolean: false,
|
|
300
|
+
null: null,
|
|
301
|
+
number: 0,
|
|
302
|
+
object: {},
|
|
303
|
+
string: ``
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// ../anvl/src/primitive/index.ts
|
|
307
|
+
var isString = (input) => {
|
|
308
|
+
return typeof input === `string`;
|
|
309
|
+
};
|
|
310
|
+
var isNumber = (input) => {
|
|
311
|
+
return typeof input === `number`;
|
|
312
|
+
};
|
|
313
|
+
var isBoolean = (input) => {
|
|
314
|
+
return typeof input === `boolean`;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// ../anvl/src/refinement/refine-json.ts
|
|
318
|
+
var JSON_PROTOTYPES = [
|
|
319
|
+
`Array`,
|
|
320
|
+
`Boolean`,
|
|
321
|
+
`Number`,
|
|
322
|
+
`Object`,
|
|
323
|
+
`String`
|
|
324
|
+
];
|
|
325
|
+
var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
|
|
326
|
+
data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
|
|
327
|
+
);
|
|
328
|
+
var isJson = (input) => {
|
|
329
|
+
var _a2;
|
|
330
|
+
if (input === null)
|
|
331
|
+
return true;
|
|
332
|
+
if (input === void 0)
|
|
333
|
+
return false;
|
|
334
|
+
const prototype = (_a2 = Object.getPrototypeOf(input)) == null ? void 0 : _a2.constructor.name;
|
|
335
|
+
const isJson2 = JSON_PROTOTYPES.includes(prototype);
|
|
336
|
+
return isJson2;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// ../anvl/src/refinement/can-exist.ts
|
|
340
|
+
var canExist = (_) => true;
|
|
341
|
+
|
|
342
|
+
// ../anvl/src/refinement/cannot-exist.ts
|
|
343
|
+
var cannotExist = (_) => false;
|
|
344
|
+
|
|
345
|
+
// ../anvl/src/refinement/is-union.ts
|
|
346
|
+
var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
|
|
347
|
+
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
|
|
348
|
+
const _ = {
|
|
349
|
+
[name]: (input) => refinements.some(
|
|
350
|
+
(refinement) => {
|
|
351
|
+
var _a2;
|
|
352
|
+
return logging && console.log(
|
|
353
|
+
refinements.map((r) => r.name || `anon`).join(` | `),
|
|
354
|
+
`>`,
|
|
355
|
+
(_a2 = refinement.name) != null ? _a2 : `anon`,
|
|
356
|
+
`:`,
|
|
357
|
+
refinement(input)
|
|
358
|
+
), refinement(input);
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
};
|
|
362
|
+
const checkTypes = Object.assign(_[name], {
|
|
363
|
+
or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
|
|
364
|
+
});
|
|
365
|
+
return checkTypes;
|
|
366
|
+
};
|
|
367
|
+
var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
|
|
368
|
+
|
|
369
|
+
// ../anvl/src/refinement/is-intersection.ts
|
|
370
|
+
function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
|
|
371
|
+
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
|
|
372
|
+
const _ = {
|
|
373
|
+
[name]: (input) => refinements.every(
|
|
374
|
+
(refinement) => (logging && console.log(
|
|
375
|
+
refinements.map((r) => r.name || `anon`).join(` & `),
|
|
376
|
+
`>`,
|
|
377
|
+
refinement.name || `anon`,
|
|
378
|
+
`:`,
|
|
379
|
+
refinement(input)
|
|
380
|
+
), refinement(input))
|
|
381
|
+
)
|
|
382
|
+
};
|
|
383
|
+
const checkTypes = Object.assign(_[name], {
|
|
384
|
+
and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
|
|
385
|
+
...refinements,
|
|
386
|
+
isTypeB
|
|
387
|
+
])
|
|
388
|
+
});
|
|
389
|
+
return checkTypes;
|
|
390
|
+
}
|
|
391
|
+
var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
|
|
392
|
+
|
|
393
|
+
// ../anvl/src/refinement/index.ts
|
|
394
|
+
var isLiteral = (value) => (input) => input === value;
|
|
395
|
+
var isWithin = (args) => (input) => args.includes(input);
|
|
396
|
+
|
|
302
397
|
// ../anvl/src/tree/differ.ts
|
|
303
398
|
function diffNumber(a2, b2) {
|
|
304
399
|
const sign = a2 < b2 ? `+` : `-`;
|
|
@@ -417,57 +512,20 @@ var Differ = class {
|
|
|
417
512
|
}
|
|
418
513
|
};
|
|
419
514
|
|
|
420
|
-
//
|
|
421
|
-
var
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
boolean: false,
|
|
433
|
-
null: null,
|
|
434
|
-
number: 0,
|
|
435
|
-
object: {},
|
|
436
|
-
string: ``
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
// ../anvl/src/primitive/index.ts
|
|
440
|
-
var isString = (input) => {
|
|
441
|
-
return typeof input === `string`;
|
|
442
|
-
};
|
|
443
|
-
var isNumber = (input) => {
|
|
444
|
-
return typeof input === `number`;
|
|
445
|
-
};
|
|
446
|
-
var isBoolean = (input) => {
|
|
447
|
-
return typeof input === `boolean`;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
// ../anvl/src/refinement/refine-json.ts
|
|
451
|
-
var JSON_PROTOTYPES = [
|
|
452
|
-
`Array`,
|
|
453
|
-
`Boolean`,
|
|
454
|
-
`Number`,
|
|
455
|
-
`Object`,
|
|
456
|
-
`String`
|
|
457
|
-
];
|
|
458
|
-
var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
|
|
459
|
-
data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
|
|
460
|
-
);
|
|
461
|
-
var isJson = (input) => {
|
|
462
|
-
var _a2;
|
|
463
|
-
if (input === null)
|
|
464
|
-
return true;
|
|
465
|
-
if (input === void 0)
|
|
466
|
-
return false;
|
|
467
|
-
const prototype = (_a2 = Object.getPrototypeOf(input)) == null ? void 0 : _a2.constructor.name;
|
|
468
|
-
const isJson2 = JSON_PROTOTYPES.includes(prototype);
|
|
469
|
-
return isJson2;
|
|
515
|
+
// __unstable__/web-effects/src/storage.ts
|
|
516
|
+
var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
|
|
517
|
+
const savedValue = storage.getItem(key);
|
|
518
|
+
if (savedValue != null)
|
|
519
|
+
setSelf(parse(savedValue));
|
|
520
|
+
onSet(({ newValue }) => {
|
|
521
|
+
if (newValue == null) {
|
|
522
|
+
storage.removeItem(key);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
storage.setItem(key, stringify(newValue));
|
|
526
|
+
});
|
|
470
527
|
};
|
|
528
|
+
var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
|
|
471
529
|
var OpenClose = ({ isOpen, setIsOpen, disabled }) => {
|
|
472
530
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
473
531
|
"button",
|
|
@@ -484,64 +542,6 @@ var button = {
|
|
|
484
542
|
OpenClose
|
|
485
543
|
};
|
|
486
544
|
|
|
487
|
-
// ../anvl/src/refinement/can-exist.ts
|
|
488
|
-
var canExist = (_) => true;
|
|
489
|
-
|
|
490
|
-
// ../anvl/src/refinement/cannot-exist.ts
|
|
491
|
-
var cannotExist = (_) => false;
|
|
492
|
-
|
|
493
|
-
// ../anvl/src/refinement/is-union.ts
|
|
494
|
-
var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
|
|
495
|
-
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
|
|
496
|
-
const _ = {
|
|
497
|
-
[name]: (input) => refinements.some(
|
|
498
|
-
(refinement) => {
|
|
499
|
-
var _a2;
|
|
500
|
-
return logging && console.log(
|
|
501
|
-
refinements.map((r) => r.name || `anon`).join(` | `),
|
|
502
|
-
`>`,
|
|
503
|
-
(_a2 = refinement.name) != null ? _a2 : `anon`,
|
|
504
|
-
`:`,
|
|
505
|
-
refinement(input)
|
|
506
|
-
), refinement(input);
|
|
507
|
-
}
|
|
508
|
-
)
|
|
509
|
-
};
|
|
510
|
-
const checkTypes = Object.assign(_[name], {
|
|
511
|
-
or: (isTypeB) => mustSatisfyOneOfTheFollowing(isTypeB, logging, [...refinements, isTypeB])
|
|
512
|
-
});
|
|
513
|
-
return checkTypes;
|
|
514
|
-
};
|
|
515
|
-
var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
|
|
516
|
-
|
|
517
|
-
// ../anvl/src/refinement/is-intersection.ts
|
|
518
|
-
function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
|
|
519
|
-
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
|
|
520
|
-
const _ = {
|
|
521
|
-
[name]: (input) => refinements.every(
|
|
522
|
-
(refinement) => (logging && console.log(
|
|
523
|
-
refinements.map((r) => r.name || `anon`).join(` & `),
|
|
524
|
-
`>`,
|
|
525
|
-
refinement.name || `anon`,
|
|
526
|
-
`:`,
|
|
527
|
-
refinement(input)
|
|
528
|
-
), refinement(input))
|
|
529
|
-
)
|
|
530
|
-
};
|
|
531
|
-
const checkTypes = Object.assign(_[name], {
|
|
532
|
-
and: (isTypeB) => mustSatisfyAllOfTheFollowing(isTypeB, logging, [
|
|
533
|
-
...refinements,
|
|
534
|
-
isTypeB
|
|
535
|
-
])
|
|
536
|
-
});
|
|
537
|
-
return checkTypes;
|
|
538
|
-
}
|
|
539
|
-
var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
|
|
540
|
-
|
|
541
|
-
// ../anvl/src/refinement/index.ts
|
|
542
|
-
var isLiteral = (value) => (input) => input === value;
|
|
543
|
-
var isWithin = (args) => (input) => args.includes(input);
|
|
544
|
-
|
|
545
545
|
// ../anvl/src/join/core-relation-data.ts
|
|
546
546
|
var RELATION_TYPES = [`1:1`, `1:n`, `n:n`];
|
|
547
547
|
var isRelationType = (x) => RELATION_TYPES.includes(x);
|
|
@@ -1131,7 +1131,7 @@ var JsonEditor_INTERNAL = ({
|
|
|
1131
1131
|
] }) });
|
|
1132
1132
|
};
|
|
1133
1133
|
|
|
1134
|
-
// ../hamr/
|
|
1134
|
+
// ../hamr/react-json-editor/src/editors-by-type/utilities/array-elements.ts
|
|
1135
1135
|
var makeElementSetters = (data, set) => data.map(
|
|
1136
1136
|
(value, index) => (newValue) => set(() => {
|
|
1137
1137
|
const newData = [...data];
|
|
@@ -1613,7 +1613,7 @@ var castToJson = (input) => {
|
|
|
1613
1613
|
};
|
|
1614
1614
|
};
|
|
1615
1615
|
|
|
1616
|
-
// ../hamr/
|
|
1616
|
+
// ../hamr/react-json-editor/src/editors-by-type/utilities/object-properties.ts
|
|
1617
1617
|
var makePropertySetters = (data, set) => mapObject(
|
|
1618
1618
|
data,
|
|
1619
1619
|
(value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]: become(newValue)(value[key]) }))
|
|
@@ -1939,7 +1939,7 @@ var JsonEditor = ({
|
|
|
1939
1939
|
);
|
|
1940
1940
|
};
|
|
1941
1941
|
|
|
1942
|
-
// ../hamr/
|
|
1942
|
+
// ../hamr/react-json-editor/src/index.ts
|
|
1943
1943
|
var SubEditors = {
|
|
1944
1944
|
array: ArrayEditor,
|
|
1945
1945
|
boolean: BooleanEditor,
|
|
@@ -2331,9 +2331,6 @@ var Id = ({ id }) => {
|
|
|
2331
2331
|
) })
|
|
2332
2332
|
] });
|
|
2333
2333
|
};
|
|
2334
|
-
|
|
2335
|
-
// ../hamr/src/react-data-designer/RelationEditor.module.scss
|
|
2336
|
-
var RelationEditor_module_default = {};
|
|
2337
2334
|
var RelationEditor = (props) => {
|
|
2338
2335
|
const seen = /* @__PURE__ */ new Set();
|
|
2339
2336
|
const data = Object.entries(props.data.relations).sort(([_, a2], [__, b2]) => b2.length - a2.length).filter(([head, tail]) => {
|
|
@@ -2345,7 +2342,7 @@ var RelationEditor = (props) => {
|
|
|
2345
2342
|
}
|
|
2346
2343
|
return true;
|
|
2347
2344
|
});
|
|
2348
|
-
return /* @__PURE__ */ jsxRuntime.jsx("article", { className:
|
|
2345
|
+
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "relation-editor-0123456789", children: data.map(([head, tail]) => /* @__PURE__ */ jsxRuntime.jsxs("section", { children: [
|
|
2349
2346
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(Id, { id: head }) }),
|
|
2350
2347
|
":",
|
|
2351
2348
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: tail.map((child) => /* @__PURE__ */ jsxRuntime.jsx(Id, { id: child })) })
|
|
@@ -2671,8 +2668,8 @@ var TimelineIndex = () => {
|
|
|
2671
2668
|
TimelineLog,
|
|
2672
2669
|
{
|
|
2673
2670
|
token,
|
|
2674
|
-
isOpenState: findViewIsOpenState
|
|
2675
|
-
timelineState: findTimelineState
|
|
2671
|
+
isOpenState: atom_io.findState(findViewIsOpenState, token.key),
|
|
2672
|
+
timelineState: atom_io.findState(findTimelineState, token.key)
|
|
2676
2673
|
},
|
|
2677
2674
|
token.key
|
|
2678
2675
|
);
|
|
@@ -2711,8 +2708,8 @@ var TransactionIndex = () => {
|
|
|
2711
2708
|
TransactionLog,
|
|
2712
2709
|
{
|
|
2713
2710
|
token,
|
|
2714
|
-
isOpenState: findViewIsOpenState
|
|
2715
|
-
logState: findTransactionLogState
|
|
2711
|
+
isOpenState: atom_io.findState(findViewIsOpenState, token.key),
|
|
2712
|
+
logState: atom_io.findState(findTransactionLogState, token.key)
|
|
2716
2713
|
},
|
|
2717
2714
|
token.key
|
|
2718
2715
|
);
|