@kheopskit/react 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,10 +2,10 @@ import * as _kheopskit_core from '@kheopskit/core';
2
2
  import { KheopskitConfig } from '@kheopskit/core';
3
3
  import { FC, PropsWithChildren } from 'react';
4
4
 
5
- declare const useWallets: () => _kheopskit_core.KheopskitState;
6
-
7
5
  declare const KheopskitProvider: FC<PropsWithChildren & {
8
6
  config?: Partial<KheopskitConfig>;
9
7
  }>;
10
8
 
9
+ declare const useWallets: () => _kheopskit_core.KheopskitState;
10
+
11
11
  export { KheopskitProvider, useWallets };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,10 @@ import * as _kheopskit_core from '@kheopskit/core';
2
2
  import { KheopskitConfig } from '@kheopskit/core';
3
3
  import { FC, PropsWithChildren } from 'react';
4
4
 
5
- declare const useWallets: () => _kheopskit_core.KheopskitState;
6
-
7
5
  declare const KheopskitProvider: FC<PropsWithChildren & {
8
6
  config?: Partial<KheopskitConfig>;
9
7
  }>;
10
8
 
9
+ declare const useWallets: () => _kheopskit_core.KheopskitState;
10
+
11
11
  export { KheopskitProvider, useWallets };
package/dist/index.js CHANGED
@@ -25,25 +25,14 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
- // src/useWallets.ts
28
+ // src/KheopskitProvider.tsx
29
+ var import_core = require("@kheopskit/core");
29
30
  var import_react2 = require("react");
30
31
 
31
32
  // src/context.ts
32
33
  var import_react = require("react");
33
34
  var KheopskitContext = (0, import_react.createContext)(null);
34
35
 
35
- // src/useWallets.ts
36
- var useWallets = () => {
37
- const ctx = (0, import_react2.useContext)(KheopskitContext);
38
- if (!ctx)
39
- throw new Error("useWallets can't be used without a KheopskitProvider");
40
- return ctx.state;
41
- };
42
-
43
- // src/KheopskitProvider.tsx
44
- var import_core = require("@kheopskit/core");
45
- var import_react3 = require("react");
46
-
47
36
  // src/createStore.ts
48
37
  var import_rxjs = require("rxjs");
49
38
  var createStore = (observable$, initialValue) => {
@@ -71,7 +60,7 @@ var createStore = (observable$, initialValue) => {
71
60
  // src/KheopskitProvider.tsx
72
61
  var import_jsx_runtime = require("react/jsx-runtime");
73
62
  var KheopskitProvider = ({ children, config }) => {
74
- const defaultValue = (0, import_react3.useMemo)(
63
+ const defaultValue = (0, import_react2.useMemo)(
75
64
  () => ({
76
65
  wallets: [],
77
66
  accounts: [],
@@ -79,14 +68,23 @@ var KheopskitProvider = ({ children, config }) => {
79
68
  }),
80
69
  [config]
81
70
  );
82
- const store = (0, import_react3.useMemo)(
71
+ const store = (0, import_react2.useMemo)(
83
72
  () => createStore((0, import_core.getKheopskit$)(config), defaultValue),
84
73
  [config, defaultValue]
85
74
  );
86
- const state = (0, import_react3.useSyncExternalStore)(store.subscribe, store.getSnapshot);
87
- const value = (0, import_react3.useMemo)(() => ({ state }), [state]);
75
+ const state = (0, import_react2.useSyncExternalStore)(store.subscribe, store.getSnapshot);
76
+ const value = (0, import_react2.useMemo)(() => ({ state }), [state]);
88
77
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KheopskitContext.Provider, { value, children });
89
78
  };
79
+
80
+ // src/useWallets.ts
81
+ var import_react3 = require("react");
82
+ var useWallets = () => {
83
+ const ctx = (0, import_react3.useContext)(KheopskitContext);
84
+ if (!ctx)
85
+ throw new Error("useWallets can't be used without a KheopskitProvider");
86
+ return ctx.state;
87
+ };
90
88
  // Annotate the CommonJS export names for ESM import in node:
91
89
  0 && (module.exports = {
92
90
  KheopskitProvider,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/useWallets.ts","../src/context.ts","../src/KheopskitProvider.tsx","../src/createStore.ts"],"sourcesContent":["export * from \"./useWallets\";\nexport * from \"./KheopskitProvider\";\n","import { useContext } from \"react\";\nimport { KheopskitContext } from \"./context\";\n\nexport const useWallets = () => {\n const ctx = useContext(KheopskitContext);\n\n // useEffect(() => {\n // console.debug(\n // \"useWallets wallets:%s accounts:%s\",\n // ctx?.state.wallets.length ?? 0,\n // ctx?.state.accounts.length ?? 0,\n // );\n // }, [ctx?.state]);\n\n if (!ctx)\n throw new Error(\"useWallets can't be used without a KheopskitProvider\");\n\n return ctx.state;\n};\n","import type { KheopskitState } from \"@kheopskit/core\";\nimport { createContext } from \"react\";\n\nexport const KheopskitContext = createContext<{\n state: KheopskitState;\n} | null>(null);\n","import {\n type KheopskitConfig,\n type KheopskitState,\n getKheopskit$,\n resolveConfig,\n} from \"@kheopskit/core\";\nimport {\n type FC,\n type PropsWithChildren,\n useMemo,\n useSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport const KheopskitProvider: FC<\n PropsWithChildren & { config?: Partial<KheopskitConfig> }\n> = ({ children, config }) => {\n const defaultValue = useMemo<KheopskitState>(\n () => ({\n wallets: [],\n accounts: [],\n config: resolveConfig(config),\n }),\n [config],\n );\n\n const store = useMemo(\n () => createStore(getKheopskit$(config), defaultValue),\n [config, defaultValue],\n );\n\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const value = useMemo(() => ({ state }), [state]);\n\n return (\n <KheopskitContext.Provider value={value}>\n {children}\n </KheopskitContext.Provider>\n );\n};\n","import { BehaviorSubject, type Observable } from \"rxjs\";\n\nexport const createStore = <T>(observable$: Observable<T>, initialValue: T) => {\n const subject = new BehaviorSubject<T>(initialValue);\n\n const sub = observable$.subscribe((value) => {\n subject.next(value);\n });\n\n const getSnapshot = () => subject.getValue();\n\n const subscribe = (callback: (value: T) => void) => {\n const sub = subject.subscribe(callback);\n\n return () => {\n sub.unsubscribe();\n };\n };\n\n const destroy = () => {\n sub.unsubscribe();\n };\n\n return {\n getSnapshot,\n subscribe,\n destroy,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA2B;;;ACC3B,mBAA8B;AAEvB,IAAM,uBAAmB,4BAEtB,IAAI;;;ADFP,IAAM,aAAa,MAAM;AAC9B,QAAM,UAAM,0BAAW,gBAAgB;AAUvC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,sDAAsD;AAExE,SAAO,IAAI;AACb;;;AElBA,kBAKO;AACP,IAAAC,gBAKO;;;ACXP,kBAAiD;AAE1C,IAAM,cAAc,CAAI,aAA4B,iBAAoB;AAC7E,QAAM,UAAU,IAAI,4BAAmB,YAAY;AAEnD,QAAM,MAAM,YAAY,UAAU,CAAC,UAAU;AAC3C,YAAQ,KAAK,KAAK;AAAA,EACpB,CAAC;AAED,QAAM,cAAc,MAAM,QAAQ,SAAS;AAE3C,QAAM,YAAY,CAAC,aAAiC;AAClD,UAAMC,OAAM,QAAQ,UAAU,QAAQ;AAEtC,WAAO,MAAM;AACX,MAAAA,KAAI,YAAY;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,UAAU,MAAM;AACpB,QAAI,YAAY;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ADSI;AAtBG,IAAM,oBAET,CAAC,EAAE,UAAU,OAAO,MAAM;AAC5B,QAAM,mBAAe;AAAA,IACnB,OAAO;AAAA,MACL,SAAS,CAAC;AAAA,MACV,UAAU,CAAC;AAAA,MACX,YAAQ,2BAAc,MAAM;AAAA,IAC9B;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,YAAQ;AAAA,IACZ,MAAM,gBAAY,2BAAc,MAAM,GAAG,YAAY;AAAA,IACrD,CAAC,QAAQ,YAAY;AAAA,EACvB;AAEA,QAAM,YAAQ,oCAAqB,MAAM,WAAW,MAAM,WAAW;AAErE,QAAM,YAAQ,uBAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;AAEhD,SACE,4CAAC,iBAAiB,UAAjB,EAA0B,OACxB,UACH;AAEJ;","names":["import_react","import_react","sub"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/KheopskitProvider.tsx","../src/context.ts","../src/createStore.ts","../src/useWallets.ts"],"sourcesContent":["export * from \"./KheopskitProvider\";\nexport * from \"./useWallets\";\n","import {\n\tgetKheopskit$,\n\ttype KheopskitConfig,\n\ttype KheopskitState,\n\tresolveConfig,\n} from \"@kheopskit/core\";\nimport {\n\ttype FC,\n\ttype PropsWithChildren,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport const KheopskitProvider: FC<\n\tPropsWithChildren & { config?: Partial<KheopskitConfig> }\n> = ({ children, config }) => {\n\tconst defaultValue = useMemo<KheopskitState>(\n\t\t() => ({\n\t\t\twallets: [],\n\t\t\taccounts: [],\n\t\t\tconfig: resolveConfig(config),\n\t\t}),\n\t\t[config],\n\t);\n\n\tconst store = useMemo(\n\t\t() => createStore(getKheopskit$(config), defaultValue),\n\t\t[config, defaultValue],\n\t);\n\n\tconst state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n\tconst value = useMemo(() => ({ state }), [state]);\n\n\treturn (\n\t\t<KheopskitContext.Provider value={value}>\n\t\t\t{children}\n\t\t</KheopskitContext.Provider>\n\t);\n};\n","import type { KheopskitState } from \"@kheopskit/core\";\nimport { createContext } from \"react\";\n\nexport const KheopskitContext = createContext<{\n\tstate: KheopskitState;\n} | null>(null);\n","import { BehaviorSubject, type Observable } from \"rxjs\";\n\nexport const createStore = <T>(observable$: Observable<T>, initialValue: T) => {\n\tconst subject = new BehaviorSubject<T>(initialValue);\n\n\tconst sub = observable$.subscribe((value) => {\n\t\tsubject.next(value);\n\t});\n\n\tconst getSnapshot = () => subject.getValue();\n\n\tconst subscribe = (callback: (value: T) => void) => {\n\t\tconst sub = subject.subscribe(callback);\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t};\n\t};\n\n\tconst destroy = () => {\n\t\tsub.unsubscribe();\n\t};\n\n\treturn {\n\t\tgetSnapshot,\n\t\tsubscribe,\n\t\tdestroy,\n\t};\n};\n","import { useContext } from \"react\";\nimport { KheopskitContext } from \"./context\";\n\nexport const useWallets = () => {\n\tconst ctx = useContext(KheopskitContext);\n\n\t// useEffect(() => {\n\t// console.debug(\n\t// \"useWallets wallets:%s accounts:%s\",\n\t// ctx?.state.wallets.length ?? 0,\n\t// ctx?.state.accounts.length ?? 0,\n\t// );\n\t// }, [ctx?.state]);\n\n\tif (!ctx)\n\t\tthrow new Error(\"useWallets can't be used without a KheopskitProvider\");\n\n\treturn ctx.state;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAKO;AACP,IAAAA,gBAKO;;;ACVP,mBAA8B;AAEvB,IAAM,uBAAmB,4BAEtB,IAAI;;;ACLd,kBAAiD;AAE1C,IAAM,cAAc,CAAI,aAA4B,iBAAoB;AAC9E,QAAM,UAAU,IAAI,4BAAmB,YAAY;AAEnD,QAAM,MAAM,YAAY,UAAU,CAAC,UAAU;AAC5C,YAAQ,KAAK,KAAK;AAAA,EACnB,CAAC;AAED,QAAM,cAAc,MAAM,QAAQ,SAAS;AAE3C,QAAM,YAAY,CAAC,aAAiC;AACnD,UAAMC,OAAM,QAAQ,UAAU,QAAQ;AAEtC,WAAO,MAAM;AACZ,MAAAA,KAAI,YAAY;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,UAAU,MAAM;AACrB,QAAI,YAAY;AAAA,EACjB;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;AFSE;AAtBK,IAAM,oBAET,CAAC,EAAE,UAAU,OAAO,MAAM;AAC7B,QAAM,mBAAe;AAAA,IACpB,OAAO;AAAA,MACN,SAAS,CAAC;AAAA,MACV,UAAU,CAAC;AAAA,MACX,YAAQ,2BAAc,MAAM;AAAA,IAC7B;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,QAAM,YAAQ;AAAA,IACb,MAAM,gBAAY,2BAAc,MAAM,GAAG,YAAY;AAAA,IACrD,CAAC,QAAQ,YAAY;AAAA,EACtB;AAEA,QAAM,YAAQ,oCAAqB,MAAM,WAAW,MAAM,WAAW;AAErE,QAAM,YAAQ,uBAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;AAEhD,SACC,4CAAC,iBAAiB,UAAjB,EAA0B,OACzB,UACF;AAEF;;;AGzCA,IAAAC,gBAA2B;AAGpB,IAAM,aAAa,MAAM;AAC/B,QAAM,UAAM,0BAAW,gBAAgB;AAUvC,MAAI,CAAC;AACJ,UAAM,IAAI,MAAM,sDAAsD;AAEvE,SAAO,IAAI;AACZ;","names":["import_react","sub","import_react"]}
package/dist/index.mjs CHANGED
@@ -1,18 +1,3 @@
1
- // src/useWallets.ts
2
- import { useContext } from "react";
3
-
4
- // src/context.ts
5
- import { createContext } from "react";
6
- var KheopskitContext = createContext(null);
7
-
8
- // src/useWallets.ts
9
- var useWallets = () => {
10
- const ctx = useContext(KheopskitContext);
11
- if (!ctx)
12
- throw new Error("useWallets can't be used without a KheopskitProvider");
13
- return ctx.state;
14
- };
15
-
16
1
  // src/KheopskitProvider.tsx
17
2
  import {
18
3
  getKheopskit$,
@@ -23,6 +8,10 @@ import {
23
8
  useSyncExternalStore
24
9
  } from "react";
25
10
 
11
+ // src/context.ts
12
+ import { createContext } from "react";
13
+ var KheopskitContext = createContext(null);
14
+
26
15
  // src/createStore.ts
27
16
  import { BehaviorSubject } from "rxjs";
28
17
  var createStore = (observable$, initialValue) => {
@@ -66,6 +55,15 @@ var KheopskitProvider = ({ children, config }) => {
66
55
  const value = useMemo(() => ({ state }), [state]);
67
56
  return /* @__PURE__ */ jsx(KheopskitContext.Provider, { value, children });
68
57
  };
58
+
59
+ // src/useWallets.ts
60
+ import { useContext } from "react";
61
+ var useWallets = () => {
62
+ const ctx = useContext(KheopskitContext);
63
+ if (!ctx)
64
+ throw new Error("useWallets can't be used without a KheopskitProvider");
65
+ return ctx.state;
66
+ };
69
67
  export {
70
68
  KheopskitProvider,
71
69
  useWallets
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/useWallets.ts","../src/context.ts","../src/KheopskitProvider.tsx","../src/createStore.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { KheopskitContext } from \"./context\";\n\nexport const useWallets = () => {\n const ctx = useContext(KheopskitContext);\n\n // useEffect(() => {\n // console.debug(\n // \"useWallets wallets:%s accounts:%s\",\n // ctx?.state.wallets.length ?? 0,\n // ctx?.state.accounts.length ?? 0,\n // );\n // }, [ctx?.state]);\n\n if (!ctx)\n throw new Error(\"useWallets can't be used without a KheopskitProvider\");\n\n return ctx.state;\n};\n","import type { KheopskitState } from \"@kheopskit/core\";\nimport { createContext } from \"react\";\n\nexport const KheopskitContext = createContext<{\n state: KheopskitState;\n} | null>(null);\n","import {\n type KheopskitConfig,\n type KheopskitState,\n getKheopskit$,\n resolveConfig,\n} from \"@kheopskit/core\";\nimport {\n type FC,\n type PropsWithChildren,\n useMemo,\n useSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport const KheopskitProvider: FC<\n PropsWithChildren & { config?: Partial<KheopskitConfig> }\n> = ({ children, config }) => {\n const defaultValue = useMemo<KheopskitState>(\n () => ({\n wallets: [],\n accounts: [],\n config: resolveConfig(config),\n }),\n [config],\n );\n\n const store = useMemo(\n () => createStore(getKheopskit$(config), defaultValue),\n [config, defaultValue],\n );\n\n const state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const value = useMemo(() => ({ state }), [state]);\n\n return (\n <KheopskitContext.Provider value={value}>\n {children}\n </KheopskitContext.Provider>\n );\n};\n","import { BehaviorSubject, type Observable } from \"rxjs\";\n\nexport const createStore = <T>(observable$: Observable<T>, initialValue: T) => {\n const subject = new BehaviorSubject<T>(initialValue);\n\n const sub = observable$.subscribe((value) => {\n subject.next(value);\n });\n\n const getSnapshot = () => subject.getValue();\n\n const subscribe = (callback: (value: T) => void) => {\n const sub = subject.subscribe(callback);\n\n return () => {\n sub.unsubscribe();\n };\n };\n\n const destroy = () => {\n sub.unsubscribe();\n };\n\n return {\n getSnapshot,\n subscribe,\n destroy,\n };\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B,SAAS,qBAAqB;AAEvB,IAAM,mBAAmB,cAEtB,IAAI;;;ADFP,IAAM,aAAa,MAAM;AAC9B,QAAM,MAAM,WAAW,gBAAgB;AAUvC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,sDAAsD;AAExE,SAAO,IAAI;AACb;;;AElBA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,OACK;;;ACXP,SAAS,uBAAwC;AAE1C,IAAM,cAAc,CAAI,aAA4B,iBAAoB;AAC7E,QAAM,UAAU,IAAI,gBAAmB,YAAY;AAEnD,QAAM,MAAM,YAAY,UAAU,CAAC,UAAU;AAC3C,YAAQ,KAAK,KAAK;AAAA,EACpB,CAAC;AAED,QAAM,cAAc,MAAM,QAAQ,SAAS;AAE3C,QAAM,YAAY,CAAC,aAAiC;AAClD,UAAMA,OAAM,QAAQ,UAAU,QAAQ;AAEtC,WAAO,MAAM;AACX,MAAAA,KAAI,YAAY;AAAA,IAClB;AAAA,EACF;AAEA,QAAM,UAAU,MAAM;AACpB,QAAI,YAAY;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ADSI;AAtBG,IAAM,oBAET,CAAC,EAAE,UAAU,OAAO,MAAM;AAC5B,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,MACL,SAAS,CAAC;AAAA,MACV,UAAU,CAAC;AAAA,MACX,QAAQ,cAAc,MAAM;AAAA,IAC9B;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,QAAQ;AAAA,IACZ,MAAM,YAAY,cAAc,MAAM,GAAG,YAAY;AAAA,IACrD,CAAC,QAAQ,YAAY;AAAA,EACvB;AAEA,QAAM,QAAQ,qBAAqB,MAAM,WAAW,MAAM,WAAW;AAErE,QAAM,QAAQ,QAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;AAEhD,SACE,oBAAC,iBAAiB,UAAjB,EAA0B,OACxB,UACH;AAEJ;","names":["sub"]}
1
+ {"version":3,"sources":["../src/KheopskitProvider.tsx","../src/context.ts","../src/createStore.ts","../src/useWallets.ts"],"sourcesContent":["import {\n\tgetKheopskit$,\n\ttype KheopskitConfig,\n\ttype KheopskitState,\n\tresolveConfig,\n} from \"@kheopskit/core\";\nimport {\n\ttype FC,\n\ttype PropsWithChildren,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport const KheopskitProvider: FC<\n\tPropsWithChildren & { config?: Partial<KheopskitConfig> }\n> = ({ children, config }) => {\n\tconst defaultValue = useMemo<KheopskitState>(\n\t\t() => ({\n\t\t\twallets: [],\n\t\t\taccounts: [],\n\t\t\tconfig: resolveConfig(config),\n\t\t}),\n\t\t[config],\n\t);\n\n\tconst store = useMemo(\n\t\t() => createStore(getKheopskit$(config), defaultValue),\n\t\t[config, defaultValue],\n\t);\n\n\tconst state = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n\tconst value = useMemo(() => ({ state }), [state]);\n\n\treturn (\n\t\t<KheopskitContext.Provider value={value}>\n\t\t\t{children}\n\t\t</KheopskitContext.Provider>\n\t);\n};\n","import type { KheopskitState } from \"@kheopskit/core\";\nimport { createContext } from \"react\";\n\nexport const KheopskitContext = createContext<{\n\tstate: KheopskitState;\n} | null>(null);\n","import { BehaviorSubject, type Observable } from \"rxjs\";\n\nexport const createStore = <T>(observable$: Observable<T>, initialValue: T) => {\n\tconst subject = new BehaviorSubject<T>(initialValue);\n\n\tconst sub = observable$.subscribe((value) => {\n\t\tsubject.next(value);\n\t});\n\n\tconst getSnapshot = () => subject.getValue();\n\n\tconst subscribe = (callback: (value: T) => void) => {\n\t\tconst sub = subject.subscribe(callback);\n\n\t\treturn () => {\n\t\t\tsub.unsubscribe();\n\t\t};\n\t};\n\n\tconst destroy = () => {\n\t\tsub.unsubscribe();\n\t};\n\n\treturn {\n\t\tgetSnapshot,\n\t\tsubscribe,\n\t\tdestroy,\n\t};\n};\n","import { useContext } from \"react\";\nimport { KheopskitContext } from \"./context\";\n\nexport const useWallets = () => {\n\tconst ctx = useContext(KheopskitContext);\n\n\t// useEffect(() => {\n\t// console.debug(\n\t// \"useWallets wallets:%s accounts:%s\",\n\t// ctx?.state.wallets.length ?? 0,\n\t// ctx?.state.accounts.length ?? 0,\n\t// );\n\t// }, [ctx?.state]);\n\n\tif (!ctx)\n\t\tthrow new Error(\"useWallets can't be used without a KheopskitProvider\");\n\n\treturn ctx.state;\n};\n"],"mappings":";AAAA;AAAA,EACC;AAAA,EAGA;AAAA,OACM;AACP;AAAA,EAGC;AAAA,EACA;AAAA,OACM;;;ACVP,SAAS,qBAAqB;AAEvB,IAAM,mBAAmB,cAEtB,IAAI;;;ACLd,SAAS,uBAAwC;AAE1C,IAAM,cAAc,CAAI,aAA4B,iBAAoB;AAC9E,QAAM,UAAU,IAAI,gBAAmB,YAAY;AAEnD,QAAM,MAAM,YAAY,UAAU,CAAC,UAAU;AAC5C,YAAQ,KAAK,KAAK;AAAA,EACnB,CAAC;AAED,QAAM,cAAc,MAAM,QAAQ,SAAS;AAE3C,QAAM,YAAY,CAAC,aAAiC;AACnD,UAAMA,OAAM,QAAQ,UAAU,QAAQ;AAEtC,WAAO,MAAM;AACZ,MAAAA,KAAI,YAAY;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,UAAU,MAAM;AACrB,QAAI,YAAY;AAAA,EACjB;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;AFSE;AAtBK,IAAM,oBAET,CAAC,EAAE,UAAU,OAAO,MAAM;AAC7B,QAAM,eAAe;AAAA,IACpB,OAAO;AAAA,MACN,SAAS,CAAC;AAAA,MACV,UAAU,CAAC;AAAA,MACX,QAAQ,cAAc,MAAM;AAAA,IAC7B;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,QAAM,QAAQ;AAAA,IACb,MAAM,YAAY,cAAc,MAAM,GAAG,YAAY;AAAA,IACrD,CAAC,QAAQ,YAAY;AAAA,EACtB;AAEA,QAAM,QAAQ,qBAAqB,MAAM,WAAW,MAAM,WAAW;AAErE,QAAM,QAAQ,QAAQ,OAAO,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;AAEhD,SACC,oBAAC,iBAAiB,UAAjB,EAA0B,OACzB,UACF;AAEF;;;AGzCA,SAAS,kBAAkB;AAGpB,IAAM,aAAa,MAAM;AAC/B,QAAM,MAAM,WAAW,gBAAgB;AAUvC,MAAI,CAAC;AACJ,UAAM,IAAI,MAAM,sDAAsD;AAEvE,SAAO,IAAI;AACZ;","names":["sub"]}
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@kheopskit/react",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "private": false,
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "main": "dist/index.cjs",
10
13
  "module": "dist/index.mjs",
11
14
  "types": "dist/index.d.ts",
@@ -27,7 +30,7 @@
27
30
  "react": ">=18.0.0",
28
31
  "react-dom": ">=18.0.0",
29
32
  "rxjs": ">=7.0.0",
30
- "@kheopskit/core": "0.0.20"
33
+ "@kheopskit/core": "0.0.22"
31
34
  },
32
35
  "devDependencies": {
33
36
  "@types/react": "^19.1.5",
@@ -35,7 +38,7 @@
35
38
  "react": "^19.1.0",
36
39
  "react-dom": "^19.1.0",
37
40
  "rxjs": "^7.8.2",
38
- "@kheopskit/core": "0.0.20"
41
+ "@kheopskit/core": "0.0.22"
39
42
  },
40
43
  "tsup": {
41
44
  "entry": [
@@ -55,6 +58,7 @@
55
58
  "test": "echo \"Error: no test specified\" && exit 1",
56
59
  "dev": "tsup --watch",
57
60
  "build": "tsup",
58
- "clean": "rm -rf ./dist && rm -rf ./node_modules"
61
+ "clean": "rm -rf ./dist && rm -rf ./node_modules",
62
+ "typecheck": "tsc --noEmit"
59
63
  }
60
64
  }
package/CHANGELOG.md DELETED
@@ -1,211 +0,0 @@
1
- # @kheopskit/react
2
-
3
- ## 0.0.24
4
-
5
- ### Patch Changes
6
-
7
- - [`920ed5b`](https://github.com/kheopskit/kheopskit/commit/920ed5babefc6d38ddc18bde3d68ff945cd1a0af) Thanks [@0xKheops](https://github.com/0xKheops)! - fix: peer dep to core
8
-
9
- ## 0.0.23
10
-
11
- ### Patch Changes
12
-
13
- - [`87bbfb0`](https://github.com/kheopskit/kheopskit/commit/87bbfb016b15bd0378a62943ccbe1403a6e5d07e) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset2
14
-
15
- - Updated dependencies [[`87bbfb0`](https://github.com/kheopskit/kheopskit/commit/87bbfb016b15bd0378a62943ccbe1403a6e5d07e)]:
16
- - @kheopskit/core@0.0.20
17
-
18
- ## 0.0.22
19
-
20
- ### Patch Changes
21
-
22
- - [`e68aaa5`](https://github.com/kheopskit/kheopskit/commit/e68aaa5019630b03660d1cb5e95a9188cf972ebf) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
23
-
24
- - Updated dependencies [[`e68aaa5`](https://github.com/kheopskit/kheopskit/commit/e68aaa5019630b03660d1cb5e95a9188cf972ebf)]:
25
- - @kheopskit/core@0.0.19
26
-
27
- ## 0.0.21
28
-
29
- ### Patch Changes
30
-
31
- - [`a35e7f9`](https://github.com/kheopskit/kheopskit/commit/a35e7f9808bd215088dbfb7747d217622e429618) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
32
-
33
- ## 0.0.20
34
-
35
- ### Patch Changes
36
-
37
- - [`0ada998`](https://github.com/kheopskit/kheopskit/commit/0ada998099206c0ba11451b25e0212cd511d6bcf) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
38
-
39
- ## 0.0.19
40
-
41
- ### Patch Changes
42
-
43
- - [`c660e23`](https://github.com/kheopskit/kheopskit/commit/c660e231aaed809d885b9ec29fd81b550a30c159) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
44
-
45
- ## 0.0.18
46
-
47
- ### Patch Changes
48
-
49
- - [`2e04a98`](https://github.com/kheopskit/kheopskit/commit/2e04a9893795e6aa43c942dee61443b4700c3294) Thanks [@0xKheops](https://github.com/0xKheops)! - fix: sync changesets
50
-
51
- - Updated dependencies [[`2e04a98`](https://github.com/kheopskit/kheopskit/commit/2e04a9893795e6aa43c942dee61443b4700c3294)]:
52
- - @kheopskit/core@0.0.18
53
-
54
- ## 0.0.17
55
-
56
- ### Patch Changes
57
-
58
- - [`91fe482`](https://github.com/kheopskit/kheopskit/commit/91fe4821c159f7b970b1a8aa52544b9eb63776bc) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
59
-
60
- ## 0.0.16
61
-
62
- ### Patch Changes
63
-
64
- - [`b69943f`](https://github.com/kheopskit/kheopskit/commit/b69943fafbbe34b8035e8030b615684c3c8d1a7e) Thanks [@0xKheops](https://github.com/0xKheops)! - test: changeset
65
-
66
- ## 0.0.15
67
-
68
- ### Patch Changes
69
-
70
- - [`a540c06`](https://github.com/kheopskit/kheopskit/commit/a540c06e90816656a1a21df3d95d0328bff78455) Thanks [@0xKheops](https://github.com/0xKheops)! - test: one more changeset
71
-
72
- - Updated dependencies [[`a540c06`](https://github.com/kheopskit/kheopskit/commit/a540c06e90816656a1a21df3d95d0328bff78455)]:
73
- - @kheopskit/core@0.0.15
74
-
75
- ## 0.0.14
76
-
77
- ### Patch Changes
78
-
79
- - Updated dependencies [[`b8242ab`](https://github.com/kheopskit/kheopskit/commit/b8242abd31a6512b16399dd44ca5e5d82f6c70bf)]:
80
- - @kheopskit/core@0.0.14
81
-
82
- ## 0.0.13
83
-
84
- ### Patch Changes
85
-
86
- - Updated dependencies [[`5e07091`](https://github.com/kheopskit/kheopskit/commit/5e070910229cb9202f5d2f1869bfb16c5180d273)]:
87
- - @kheopskit/core@0.0.13
88
-
89
- ## 0.0.12
90
-
91
- ### Patch Changes
92
-
93
- - Updated dependencies [[`2f34f0c`](https://github.com/kheopskit/kheopskit/commit/2f34f0c16c7866a4187b4474a45f93e2ad07f5c7)]:
94
- - @kheopskit/core@0.0.12
95
-
96
- ## 0.0.11
97
-
98
- ### Patch Changes
99
-
100
- - Updated dependencies [[`9d4f86e`](https://github.com/kheopskit/kheopskit/commit/9d4f86e7632843fad089ce930b209aee9b9e2b41)]:
101
- - @kheopskit/core@0.0.11
102
-
103
- ## 0.0.10
104
-
105
- ### Patch Changes
106
-
107
- - [`c7dea32`](https://github.com/kheopskit/kheopskit/commit/c7dea32e2921716cef82b53e1960c3cdb4c8e5ae) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
108
-
109
- - Updated dependencies [[`c7dea32`](https://github.com/kheopskit/kheopskit/commit/c7dea32e2921716cef82b53e1960c3cdb4c8e5ae)]:
110
- - @kheopskit/core@0.0.10
111
-
112
- ## 0.0.9
113
-
114
- ### Patch Changes
115
-
116
- - [`961f6a3`](https://github.com/kheopskit/kheopskit/commit/961f6a371c73d4065e9157c95ca4d996012098e7) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
117
-
118
- - Updated dependencies [[`961f6a3`](https://github.com/kheopskit/kheopskit/commit/961f6a371c73d4065e9157c95ca4d996012098e7)]:
119
- - @kheopskit/core@0.0.9
120
-
121
- ## 0.0.8
122
-
123
- ### Patch Changes
124
-
125
- - [`b76185f`](https://github.com/kheopskit/kheopskit/commit/b76185f99a78c5a82a8b9aead65b0708f17b0bd5) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
126
-
127
- - Updated dependencies [[`b76185f`](https://github.com/kheopskit/kheopskit/commit/b76185f99a78c5a82a8b9aead65b0708f17b0bd5)]:
128
- - @kheopskit/core@0.0.8
129
-
130
- ## 0.0.7
131
-
132
- ### Patch Changes
133
-
134
- - [`07f8406`](https://github.com/kheopskit/kheopskit/commit/07f8406d3f176e6a8b3b06fe16396bf2b6b1db88) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
135
-
136
- - Updated dependencies [[`07f8406`](https://github.com/kheopskit/kheopskit/commit/07f8406d3f176e6a8b3b06fe16396bf2b6b1db88)]:
137
- - @kheopskit/core@0.0.7
138
-
139
- ## 0.0.6
140
-
141
- ### Patch Changes
142
-
143
- - [`5319326`](https://github.com/kheopskit/kheopskit/commit/53193262e80fec9e242986f818d7f7b53f92357a) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
144
-
145
- - Updated dependencies [[`5319326`](https://github.com/kheopskit/kheopskit/commit/53193262e80fec9e242986f818d7f7b53f92357a)]:
146
- - @kheopskit/core@0.0.6
147
-
148
- ## 0.0.5
149
-
150
- ### Patch Changes
151
-
152
- - [`d865842`](https://github.com/kheopskit/kheopskit/commit/d86584236e51730e82baaa9068604fa7e703e9c2) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
153
-
154
- - Updated dependencies [[`d865842`](https://github.com/kheopskit/kheopskit/commit/d86584236e51730e82baaa9068604fa7e703e9c2)]:
155
- - @kheopskit/core@0.0.5
156
-
157
- ## 0.0.4
158
-
159
- ### Patch Changes
160
-
161
- - [`4a61939`](https://github.com/kheopskit/kheopskit/commit/4a61939b9a5c4ea6fb119a0427704a5fc684343e) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
162
-
163
- - Updated dependencies [[`4a61939`](https://github.com/kheopskit/kheopskit/commit/4a61939b9a5c4ea6fb119a0427704a5fc684343e)]:
164
- - @kheopskit/core@0.0.4
165
-
166
- ## 0.0.3
167
-
168
- ### Patch Changes
169
-
170
- - [`7a0ea89`](https://github.com/kheopskit/kheopskit/commit/7a0ea890982570ae89934fead69d319fff46dd98) Thanks [@0xKheops](https://github.com/0xKheops)! - test changeset
171
-
172
- - Updated dependencies [[`7a0ea89`](https://github.com/kheopskit/kheopskit/commit/7a0ea890982570ae89934fead69d319fff46dd98)]:
173
- - @kheopskit/core@0.0.3
174
-
175
- ## 0.0.2
176
-
177
- ### Patch Changes
178
-
179
- - [`806b8d3`](https://github.com/kheopskit/kheopskit/commit/806b8d394ba7c2576c76d9de72a15d7927bcff9e) - update peer deps
180
-
181
- - Updated dependencies [[`806b8d3`](https://github.com/kheopskit/kheopskit/commit/806b8d394ba7c2576c76d9de72a15d7927bcff9e)]:
182
- - @kheopskit/core@0.0.2
183
-
184
- ## 0.0.1
185
-
186
- ### Patch Changes
187
-
188
- - [`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd) - refactor property names
189
-
190
- - [`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd) - initial alpha release
191
-
192
- - Updated dependencies [[`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd), [`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd)]:
193
- - @kheopskit/core@0.0.1
194
-
195
- ## 0.0.1-alpha.1
196
-
197
- ### Patch Changes
198
-
199
- - [`4f378f9`](https://github.com/0xKheops/kheopskit-alpha/commit/4f378f9b61e555b7b66ef3bfaf107ab8e6ac62b1) - refactor property names
200
-
201
- - Updated dependencies [[`4f378f9`](https://github.com/0xKheops/kheopskit-alpha/commit/4f378f9b61e555b7b66ef3bfaf107ab8e6ac62b1)]:
202
- - @kheopskit/core@0.0.1-alpha.1
203
-
204
- ## 0.0.1-alpha.0
205
-
206
- ### Patch Changes
207
-
208
- - [`3216d3b`](https://github.com/0xKheops/kheopskit-alpha/commit/3216d3b4ca1f2fadbebe9a4275e7b864ac89d222) - initial alpha release
209
-
210
- - Updated dependencies [[`3216d3b`](https://github.com/0xKheops/kheopskit-alpha/commit/3216d3b4ca1f2fadbebe9a4275e7b864ac89d222)]:
211
- - @kheopskit/core@0.0.1-alpha.0
@@ -1,42 +0,0 @@
1
- import {
2
- type KheopskitConfig,
3
- type KheopskitState,
4
- getKheopskit$,
5
- resolveConfig,
6
- } from "@kheopskit/core";
7
- import {
8
- type FC,
9
- type PropsWithChildren,
10
- useMemo,
11
- useSyncExternalStore,
12
- } from "react";
13
- import { KheopskitContext } from "./context";
14
- import { createStore } from "./createStore";
15
-
16
- export const KheopskitProvider: FC<
17
- PropsWithChildren & { config?: Partial<KheopskitConfig> }
18
- > = ({ children, config }) => {
19
- const defaultValue = useMemo<KheopskitState>(
20
- () => ({
21
- wallets: [],
22
- accounts: [],
23
- config: resolveConfig(config),
24
- }),
25
- [config],
26
- );
27
-
28
- const store = useMemo(
29
- () => createStore(getKheopskit$(config), defaultValue),
30
- [config, defaultValue],
31
- );
32
-
33
- const state = useSyncExternalStore(store.subscribe, store.getSnapshot);
34
-
35
- const value = useMemo(() => ({ state }), [state]);
36
-
37
- return (
38
- <KheopskitContext.Provider value={value}>
39
- {children}
40
- </KheopskitContext.Provider>
41
- );
42
- };
package/src/context.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { KheopskitState } from "@kheopskit/core";
2
- import { createContext } from "react";
3
-
4
- export const KheopskitContext = createContext<{
5
- state: KheopskitState;
6
- } | null>(null);
@@ -1,29 +0,0 @@
1
- import { BehaviorSubject, type Observable } from "rxjs";
2
-
3
- export const createStore = <T>(observable$: Observable<T>, initialValue: T) => {
4
- const subject = new BehaviorSubject<T>(initialValue);
5
-
6
- const sub = observable$.subscribe((value) => {
7
- subject.next(value);
8
- });
9
-
10
- const getSnapshot = () => subject.getValue();
11
-
12
- const subscribe = (callback: (value: T) => void) => {
13
- const sub = subject.subscribe(callback);
14
-
15
- return () => {
16
- sub.unsubscribe();
17
- };
18
- };
19
-
20
- const destroy = () => {
21
- sub.unsubscribe();
22
- };
23
-
24
- return {
25
- getSnapshot,
26
- subscribe,
27
- destroy,
28
- };
29
- };
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./useWallets";
2
- export * from "./KheopskitProvider";
package/src/useWallets.ts DELETED
@@ -1,19 +0,0 @@
1
- import { useContext } from "react";
2
- import { KheopskitContext } from "./context";
3
-
4
- export const useWallets = () => {
5
- const ctx = useContext(KheopskitContext);
6
-
7
- // useEffect(() => {
8
- // console.debug(
9
- // "useWallets wallets:%s accounts:%s",
10
- // ctx?.state.wallets.length ?? 0,
11
- // ctx?.state.accounts.length ?? 0,
12
- // );
13
- // }, [ctx?.state]);
14
-
15
- if (!ctx)
16
- throw new Error("useWallets can't be used without a KheopskitProvider");
17
-
18
- return ctx.state;
19
- };
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base",
3
- "include": ["src", "tests"],
4
- "compilerOptions": {
5
- "jsx": "react-jsx",
6
- "baseUrl": "src",
7
- "paths": {
8
- "@/*": ["*"]
9
- }
10
- }
11
- }