@kheopskit/react 0.0.26 → 1.0.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/dist/index.d.mts CHANGED
@@ -2,10 +2,29 @@ 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 KheopskitProvider: FC<PropsWithChildren & {
5
+ type KheopskitProviderProps = PropsWithChildren & {
6
6
  config?: Partial<KheopskitConfig>;
7
- }>;
7
+ /**
8
+ * Cookie string for SSR hydration.
9
+ * Pass the request cookie header (e.g., from Next.js headers or TanStack Start)
10
+ * to hydrate wallet state on the server.
11
+ *
12
+ * @remarks
13
+ * This value should be stable per render to avoid unnecessary store recreation.
14
+ * Compute it once in your server component or layout and pass it down.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * // Next.js App Router
19
+ * const cookieStore = await cookies();
20
+ * const ssrCookies = cookieStore.getAll().map(c => `${c.name}=${c.value}`).join('; ');
21
+ * return <Providers ssrCookies={ssrCookies}>{children}</Providers>
22
+ * ```
23
+ */
24
+ ssrCookies?: string;
25
+ };
26
+ declare const KheopskitProvider: FC<KheopskitProviderProps>;
8
27
 
9
28
  declare const useWallets: () => _kheopskit_core.KheopskitState;
10
29
 
11
- export { KheopskitProvider, useWallets };
30
+ export { KheopskitProvider, type KheopskitProviderProps, useWallets };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,29 @@ 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 KheopskitProvider: FC<PropsWithChildren & {
5
+ type KheopskitProviderProps = PropsWithChildren & {
6
6
  config?: Partial<KheopskitConfig>;
7
- }>;
7
+ /**
8
+ * Cookie string for SSR hydration.
9
+ * Pass the request cookie header (e.g., from Next.js headers or TanStack Start)
10
+ * to hydrate wallet state on the server.
11
+ *
12
+ * @remarks
13
+ * This value should be stable per render to avoid unnecessary store recreation.
14
+ * Compute it once in your server component or layout and pass it down.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * // Next.js App Router
19
+ * const cookieStore = await cookies();
20
+ * const ssrCookies = cookieStore.getAll().map(c => `${c.name}=${c.value}`).join('; ');
21
+ * return <Providers ssrCookies={ssrCookies}>{children}</Providers>
22
+ * ```
23
+ */
24
+ ssrCookies?: string;
25
+ };
26
+ declare const KheopskitProvider: FC<KheopskitProviderProps>;
8
27
 
9
28
  declare const useWallets: () => _kheopskit_core.KheopskitState;
10
29
 
11
- export { KheopskitProvider, useWallets };
30
+ export { KheopskitProvider, type KheopskitProviderProps, useWallets };
package/dist/index.js CHANGED
@@ -34,24 +34,43 @@ var import_react = require("react");
34
34
  var KheopskitContext = (0, import_react.createContext)(null);
35
35
 
36
36
  // src/createStore.ts
37
- var import_rxjs = require("rxjs");
38
- var createStore = (observable$, initialValue) => {
39
- const subject = new import_rxjs.BehaviorSubject(initialValue);
40
- const sub = observable$.subscribe((value) => {
41
- subject.next(value);
42
- });
43
- const getSnapshot = () => subject.getValue();
37
+ var createStore = (observable$, initialValue, serverValue) => {
38
+ let latestValue = null;
39
+ let subscription = null;
40
+ let subscriberCount = 0;
41
+ const listeners = /* @__PURE__ */ new Set();
42
+ const ensureSubscription = () => {
43
+ if (!subscription || subscription.closed) {
44
+ subscription = observable$.subscribe((value) => {
45
+ latestValue = value;
46
+ for (const listener of listeners) {
47
+ listener(value);
48
+ }
49
+ });
50
+ }
51
+ };
52
+ ensureSubscription();
53
+ const getSnapshot = () => latestValue ?? initialValue;
54
+ const getServerSnapshot = () => serverValue ?? initialValue;
44
55
  const subscribe = (callback) => {
45
- const sub2 = subject.subscribe(callback);
56
+ subscriberCount++;
57
+ listeners.add(callback);
58
+ ensureSubscription();
59
+ callback(getSnapshot());
46
60
  return () => {
47
- sub2.unsubscribe();
61
+ subscriberCount--;
62
+ listeners.delete(callback);
48
63
  };
49
64
  };
50
65
  const destroy = () => {
51
- sub.unsubscribe();
66
+ if (subscriberCount === 0 && subscription) {
67
+ subscription.unsubscribe();
68
+ subscription = null;
69
+ }
52
70
  };
53
71
  return {
54
72
  getSnapshot,
73
+ getServerSnapshot,
55
74
  subscribe,
56
75
  destroy
57
76
  };
@@ -59,20 +78,67 @@ var createStore = (observable$, initialValue) => {
59
78
 
60
79
  // src/KheopskitProvider.tsx
61
80
  var import_jsx_runtime = require("react/jsx-runtime");
62
- var KheopskitProvider = ({ children, config }) => {
63
- const defaultValue = (0, import_react2.useMemo)(
64
- () => ({
65
- wallets: [],
66
- accounts: [],
67
- config: (0, import_core.resolveConfig)(config)
81
+ var KheopskitProvider = ({
82
+ children,
83
+ config,
84
+ ssrCookies
85
+ }) => {
86
+ const resolvedConfig = (0, import_react2.useMemo)(() => (0, import_core.resolveConfig)(config), [config]);
87
+ const kheopskitStore = (0, import_react2.useMemo)(
88
+ () => (0, import_core.createKheopskitStore)({
89
+ ssrCookies,
90
+ storageKey: resolvedConfig.storageKey
68
91
  }),
69
- [config]
92
+ [ssrCookies, resolvedConfig.storageKey]
70
93
  );
94
+ const serverValue = (0, import_react2.useMemo)(() => {
95
+ if (ssrCookies === void 0) {
96
+ return {
97
+ wallets: [],
98
+ accounts: [],
99
+ config: resolvedConfig,
100
+ isHydrating: true
101
+ };
102
+ }
103
+ const cached = kheopskitStore.getCachedState();
104
+ return {
105
+ wallets: cached.wallets.map(import_core.hydrateWallet),
106
+ accounts: cached.accounts.map(import_core.hydrateAccount),
107
+ config: resolvedConfig,
108
+ isHydrating: true
109
+ };
110
+ }, [ssrCookies, kheopskitStore, resolvedConfig]);
111
+ const initialValue = (0, import_react2.useMemo)(() => {
112
+ const enrichedWallets = serverValue.wallets.map((w) => {
113
+ if (!w.icon) {
114
+ const cachedIcon = (0, import_core.getCachedIcon)(w.id);
115
+ if (cachedIcon) {
116
+ return { ...w, icon: cachedIcon };
117
+ }
118
+ }
119
+ return w;
120
+ });
121
+ return {
122
+ ...serverValue,
123
+ wallets: enrichedWallets
124
+ };
125
+ }, [serverValue]);
71
126
  const store = (0, import_react2.useMemo)(
72
- () => createStore((0, import_core.getKheopskit$)(config), defaultValue),
73
- [config, defaultValue]
127
+ () => createStore(
128
+ (0, import_core.getKheopskit$)(config, ssrCookies, kheopskitStore),
129
+ initialValue,
130
+ serverValue
131
+ ),
132
+ [config, ssrCookies, kheopskitStore, initialValue, serverValue]
133
+ );
134
+ (0, import_react2.useEffect)(() => {
135
+ return () => store.destroy();
136
+ }, [store]);
137
+ const state = (0, import_react2.useSyncExternalStore)(
138
+ store.subscribe,
139
+ store.getSnapshot,
140
+ store.getServerSnapshot
74
141
  );
75
- const state = (0, import_react2.useSyncExternalStore)(store.subscribe, store.getSnapshot);
76
142
  const value = (0, import_react2.useMemo)(() => ({ state }), [state]);
77
143
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KheopskitContext.Provider, { value, children });
78
144
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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"]}
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\tcreateKheopskitStore,\n\tgetCachedIcon,\n\tgetKheopskit$,\n\thydrateAccount,\n\thydrateWallet,\n\ttype KheopskitConfig,\n\ttype KheopskitState,\n\tresolveConfig,\n} from \"@kheopskit/core\";\nimport {\n\ttype FC,\n\ttype PropsWithChildren,\n\tuseEffect,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport type KheopskitProviderProps = PropsWithChildren & {\n\tconfig?: Partial<KheopskitConfig>;\n\t/**\n\t * Cookie string for SSR hydration.\n\t * Pass the request cookie header (e.g., from Next.js headers or TanStack Start)\n\t * to hydrate wallet state on the server.\n\t *\n\t * @remarks\n\t * This value should be stable per render to avoid unnecessary store recreation.\n\t * Compute it once in your server component or layout and pass it down.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Next.js App Router\n\t * const cookieStore = await cookies();\n\t * const ssrCookies = cookieStore.getAll().map(c => `${c.name}=${c.value}`).join('; ');\n\t * return <Providers ssrCookies={ssrCookies}>{children}</Providers>\n\t * ```\n\t */\n\tssrCookies?: string;\n};\n\nexport const KheopskitProvider: FC<KheopskitProviderProps> = ({\n\tchildren,\n\tconfig,\n\tssrCookies,\n}) => {\n\tconst resolvedConfig = useMemo(() => resolveConfig(config), [config]);\n\n\t// Create a single store for both reading cached state and powering the observable\n\tconst kheopskitStore = useMemo(\n\t\t() =>\n\t\t\tcreateKheopskitStore({\n\t\t\t\tssrCookies,\n\t\t\t\tstorageKey: resolvedConfig.storageKey,\n\t\t\t}),\n\t\t[ssrCookies, resolvedConfig.storageKey],\n\t);\n\n\t// Read cached state from the store for SSR hydration\n\t// This produces wallets WITHOUT localStorage icons (Ethereum wallets have no icon)\n\t// because localStorage isn't available on server\n\tconst serverValue = useMemo<KheopskitState>(() => {\n\t\tif (ssrCookies === undefined) {\n\t\t\treturn {\n\t\t\t\twallets: [],\n\t\t\t\taccounts: [],\n\t\t\t\tconfig: resolvedConfig,\n\t\t\t\tisHydrating: true,\n\t\t\t};\n\t\t}\n\t\tconst cached = kheopskitStore.getCachedState();\n\t\treturn {\n\t\t\twallets: cached.wallets.map(hydrateWallet),\n\t\t\taccounts: cached.accounts.map(hydrateAccount),\n\t\t\tconfig: resolvedConfig,\n\t\t\tisHydrating: true,\n\t\t};\n\t}, [ssrCookies, kheopskitStore, resolvedConfig]);\n\n\t// Initial value for client includes localStorage icons\n\t// This is what we WANT the client to render, not what server rendered\n\tconst initialValue = useMemo<KheopskitState>(() => {\n\t\t// On client, enrich wallets with localStorage icons\n\t\t// getCachedIcon returns empty on server (no localStorage), so this is safe\n\t\tconst enrichedWallets = serverValue.wallets.map((w) => {\n\t\t\tif (!w.icon) {\n\t\t\t\tconst cachedIcon = getCachedIcon(w.id);\n\t\t\t\tif (cachedIcon) {\n\t\t\t\t\treturn { ...w, icon: cachedIcon };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn w;\n\t\t});\n\t\treturn {\n\t\t\t...serverValue,\n\t\t\twallets: enrichedWallets,\n\t\t};\n\t}, [serverValue]);\n\n\tconst store = useMemo(\n\t\t() =>\n\t\t\tcreateStore(\n\t\t\t\tgetKheopskit$(config, ssrCookies, kheopskitStore),\n\t\t\t\tinitialValue,\n\t\t\t\tserverValue,\n\t\t\t),\n\t\t[config, ssrCookies, kheopskitStore, initialValue, serverValue],\n\t);\n\n\t// Cleanup store subscriptions when store changes or component unmounts\n\tuseEffect(() => {\n\t\treturn () => store.destroy();\n\t}, [store]);\n\n\tconst state = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\tstore.getSnapshot,\n\t\tstore.getServerSnapshot,\n\t);\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 type { Observable, Subscription } from \"rxjs\";\n\nexport const createStore = <T>(\n\tobservable$: Observable<T>,\n\tinitialValue: T,\n\tserverValue?: T,\n) => {\n\t// Use null as sentinel to indicate we haven't received first emission yet\n\tlet latestValue: T | null = null;\n\tlet subscription: Subscription | null = null;\n\tlet subscriberCount = 0;\n\tconst listeners = new Set<(value: T) => void>();\n\n\tconst ensureSubscription = () => {\n\t\tif (!subscription || subscription.closed) {\n\t\t\tsubscription = observable$.subscribe((value) => {\n\t\t\t\tlatestValue = value;\n\t\t\t\tfor (const listener of listeners) {\n\t\t\t\t\tlistener(value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t// Start subscription immediately\n\tensureSubscription();\n\n\t// If observable emitted synchronously, use that value\n\t// Otherwise fall back to initialValue\n\tconst getSnapshot = () => latestValue ?? initialValue;\n\n\t/**\n\t * Returns the server-side snapshot for SSR hydration.\n\t * This prevents hydration mismatches by providing a consistent\n\t * value during server rendering. Must return the same value as\n\t * what the server rendered.\n\t */\n\tconst getServerSnapshot = () => serverValue ?? initialValue;\n\n\tconst subscribe = (callback: (value: T) => void) => {\n\t\tsubscriberCount++;\n\t\tlisteners.add(callback);\n\t\t// Ensure observable subscription is active when someone subscribes\n\t\tensureSubscription();\n\n\t\t// Immediately emit current value (BehaviorSubject semantics)\n\t\tcallback(getSnapshot());\n\n\t\treturn () => {\n\t\t\tsubscriberCount--;\n\t\t\tlisteners.delete(callback);\n\t\t\t// Don't close the observable subscription on unsubscribe\n\t\t\t// Let destroy() handle that when the store is truly being disposed\n\t\t};\n\t};\n\n\tconst destroy = () => {\n\t\t// Only unsubscribe if no one is listening\n\t\t// React StrictMode may call destroy and then immediately resubscribe\n\t\tif (subscriberCount === 0 && subscription) {\n\t\t\tsubscription.unsubscribe();\n\t\t\tsubscription = null;\n\t\t}\n\t};\n\n\treturn {\n\t\tgetSnapshot,\n\t\tgetServerSnapshot,\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":"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","names":["import_react","import_react"]}
package/dist/index.mjs CHANGED
@@ -1,9 +1,14 @@
1
1
  // src/KheopskitProvider.tsx
2
2
  import {
3
+ createKheopskitStore,
4
+ getCachedIcon,
3
5
  getKheopskit$,
6
+ hydrateAccount,
7
+ hydrateWallet,
4
8
  resolveConfig
5
9
  } from "@kheopskit/core";
6
10
  import {
11
+ useEffect,
7
12
  useMemo,
8
13
  useSyncExternalStore
9
14
  } from "react";
@@ -13,24 +18,43 @@ import { createContext } from "react";
13
18
  var KheopskitContext = createContext(null);
14
19
 
15
20
  // src/createStore.ts
16
- import { BehaviorSubject } from "rxjs";
17
- var createStore = (observable$, initialValue) => {
18
- const subject = new BehaviorSubject(initialValue);
19
- const sub = observable$.subscribe((value) => {
20
- subject.next(value);
21
- });
22
- const getSnapshot = () => subject.getValue();
21
+ var createStore = (observable$, initialValue, serverValue) => {
22
+ let latestValue = null;
23
+ let subscription = null;
24
+ let subscriberCount = 0;
25
+ const listeners = /* @__PURE__ */ new Set();
26
+ const ensureSubscription = () => {
27
+ if (!subscription || subscription.closed) {
28
+ subscription = observable$.subscribe((value) => {
29
+ latestValue = value;
30
+ for (const listener of listeners) {
31
+ listener(value);
32
+ }
33
+ });
34
+ }
35
+ };
36
+ ensureSubscription();
37
+ const getSnapshot = () => latestValue ?? initialValue;
38
+ const getServerSnapshot = () => serverValue ?? initialValue;
23
39
  const subscribe = (callback) => {
24
- const sub2 = subject.subscribe(callback);
40
+ subscriberCount++;
41
+ listeners.add(callback);
42
+ ensureSubscription();
43
+ callback(getSnapshot());
25
44
  return () => {
26
- sub2.unsubscribe();
45
+ subscriberCount--;
46
+ listeners.delete(callback);
27
47
  };
28
48
  };
29
49
  const destroy = () => {
30
- sub.unsubscribe();
50
+ if (subscriberCount === 0 && subscription) {
51
+ subscription.unsubscribe();
52
+ subscription = null;
53
+ }
31
54
  };
32
55
  return {
33
56
  getSnapshot,
57
+ getServerSnapshot,
34
58
  subscribe,
35
59
  destroy
36
60
  };
@@ -38,20 +62,67 @@ var createStore = (observable$, initialValue) => {
38
62
 
39
63
  // src/KheopskitProvider.tsx
40
64
  import { jsx } from "react/jsx-runtime";
41
- var KheopskitProvider = ({ children, config }) => {
42
- const defaultValue = useMemo(
43
- () => ({
44
- wallets: [],
45
- accounts: [],
46
- config: resolveConfig(config)
65
+ var KheopskitProvider = ({
66
+ children,
67
+ config,
68
+ ssrCookies
69
+ }) => {
70
+ const resolvedConfig = useMemo(() => resolveConfig(config), [config]);
71
+ const kheopskitStore = useMemo(
72
+ () => createKheopskitStore({
73
+ ssrCookies,
74
+ storageKey: resolvedConfig.storageKey
47
75
  }),
48
- [config]
76
+ [ssrCookies, resolvedConfig.storageKey]
49
77
  );
78
+ const serverValue = useMemo(() => {
79
+ if (ssrCookies === void 0) {
80
+ return {
81
+ wallets: [],
82
+ accounts: [],
83
+ config: resolvedConfig,
84
+ isHydrating: true
85
+ };
86
+ }
87
+ const cached = kheopskitStore.getCachedState();
88
+ return {
89
+ wallets: cached.wallets.map(hydrateWallet),
90
+ accounts: cached.accounts.map(hydrateAccount),
91
+ config: resolvedConfig,
92
+ isHydrating: true
93
+ };
94
+ }, [ssrCookies, kheopskitStore, resolvedConfig]);
95
+ const initialValue = useMemo(() => {
96
+ const enrichedWallets = serverValue.wallets.map((w) => {
97
+ if (!w.icon) {
98
+ const cachedIcon = getCachedIcon(w.id);
99
+ if (cachedIcon) {
100
+ return { ...w, icon: cachedIcon };
101
+ }
102
+ }
103
+ return w;
104
+ });
105
+ return {
106
+ ...serverValue,
107
+ wallets: enrichedWallets
108
+ };
109
+ }, [serverValue]);
50
110
  const store = useMemo(
51
- () => createStore(getKheopskit$(config), defaultValue),
52
- [config, defaultValue]
111
+ () => createStore(
112
+ getKheopskit$(config, ssrCookies, kheopskitStore),
113
+ initialValue,
114
+ serverValue
115
+ ),
116
+ [config, ssrCookies, kheopskitStore, initialValue, serverValue]
117
+ );
118
+ useEffect(() => {
119
+ return () => store.destroy();
120
+ }, [store]);
121
+ const state = useSyncExternalStore(
122
+ store.subscribe,
123
+ store.getSnapshot,
124
+ store.getServerSnapshot
53
125
  );
54
- const state = useSyncExternalStore(store.subscribe, store.getSnapshot);
55
126
  const value = useMemo(() => ({ state }), [state]);
56
127
  return /* @__PURE__ */ jsx(KheopskitContext.Provider, { value, children });
57
128
  };
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["../src/KheopskitProvider.tsx","../src/context.ts","../src/createStore.ts","../src/useWallets.ts"],"sourcesContent":["import {\n\tcreateKheopskitStore,\n\tgetCachedIcon,\n\tgetKheopskit$,\n\thydrateAccount,\n\thydrateWallet,\n\ttype KheopskitConfig,\n\ttype KheopskitState,\n\tresolveConfig,\n} from \"@kheopskit/core\";\nimport {\n\ttype FC,\n\ttype PropsWithChildren,\n\tuseEffect,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { KheopskitContext } from \"./context\";\nimport { createStore } from \"./createStore\";\n\nexport type KheopskitProviderProps = PropsWithChildren & {\n\tconfig?: Partial<KheopskitConfig>;\n\t/**\n\t * Cookie string for SSR hydration.\n\t * Pass the request cookie header (e.g., from Next.js headers or TanStack Start)\n\t * to hydrate wallet state on the server.\n\t *\n\t * @remarks\n\t * This value should be stable per render to avoid unnecessary store recreation.\n\t * Compute it once in your server component or layout and pass it down.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Next.js App Router\n\t * const cookieStore = await cookies();\n\t * const ssrCookies = cookieStore.getAll().map(c => `${c.name}=${c.value}`).join('; ');\n\t * return <Providers ssrCookies={ssrCookies}>{children}</Providers>\n\t * ```\n\t */\n\tssrCookies?: string;\n};\n\nexport const KheopskitProvider: FC<KheopskitProviderProps> = ({\n\tchildren,\n\tconfig,\n\tssrCookies,\n}) => {\n\tconst resolvedConfig = useMemo(() => resolveConfig(config), [config]);\n\n\t// Create a single store for both reading cached state and powering the observable\n\tconst kheopskitStore = useMemo(\n\t\t() =>\n\t\t\tcreateKheopskitStore({\n\t\t\t\tssrCookies,\n\t\t\t\tstorageKey: resolvedConfig.storageKey,\n\t\t\t}),\n\t\t[ssrCookies, resolvedConfig.storageKey],\n\t);\n\n\t// Read cached state from the store for SSR hydration\n\t// This produces wallets WITHOUT localStorage icons (Ethereum wallets have no icon)\n\t// because localStorage isn't available on server\n\tconst serverValue = useMemo<KheopskitState>(() => {\n\t\tif (ssrCookies === undefined) {\n\t\t\treturn {\n\t\t\t\twallets: [],\n\t\t\t\taccounts: [],\n\t\t\t\tconfig: resolvedConfig,\n\t\t\t\tisHydrating: true,\n\t\t\t};\n\t\t}\n\t\tconst cached = kheopskitStore.getCachedState();\n\t\treturn {\n\t\t\twallets: cached.wallets.map(hydrateWallet),\n\t\t\taccounts: cached.accounts.map(hydrateAccount),\n\t\t\tconfig: resolvedConfig,\n\t\t\tisHydrating: true,\n\t\t};\n\t}, [ssrCookies, kheopskitStore, resolvedConfig]);\n\n\t// Initial value for client includes localStorage icons\n\t// This is what we WANT the client to render, not what server rendered\n\tconst initialValue = useMemo<KheopskitState>(() => {\n\t\t// On client, enrich wallets with localStorage icons\n\t\t// getCachedIcon returns empty on server (no localStorage), so this is safe\n\t\tconst enrichedWallets = serverValue.wallets.map((w) => {\n\t\t\tif (!w.icon) {\n\t\t\t\tconst cachedIcon = getCachedIcon(w.id);\n\t\t\t\tif (cachedIcon) {\n\t\t\t\t\treturn { ...w, icon: cachedIcon };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn w;\n\t\t});\n\t\treturn {\n\t\t\t...serverValue,\n\t\t\twallets: enrichedWallets,\n\t\t};\n\t}, [serverValue]);\n\n\tconst store = useMemo(\n\t\t() =>\n\t\t\tcreateStore(\n\t\t\t\tgetKheopskit$(config, ssrCookies, kheopskitStore),\n\t\t\t\tinitialValue,\n\t\t\t\tserverValue,\n\t\t\t),\n\t\t[config, ssrCookies, kheopskitStore, initialValue, serverValue],\n\t);\n\n\t// Cleanup store subscriptions when store changes or component unmounts\n\tuseEffect(() => {\n\t\treturn () => store.destroy();\n\t}, [store]);\n\n\tconst state = useSyncExternalStore(\n\t\tstore.subscribe,\n\t\tstore.getSnapshot,\n\t\tstore.getServerSnapshot,\n\t);\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 type { Observable, Subscription } from \"rxjs\";\n\nexport const createStore = <T>(\n\tobservable$: Observable<T>,\n\tinitialValue: T,\n\tserverValue?: T,\n) => {\n\t// Use null as sentinel to indicate we haven't received first emission yet\n\tlet latestValue: T | null = null;\n\tlet subscription: Subscription | null = null;\n\tlet subscriberCount = 0;\n\tconst listeners = new Set<(value: T) => void>();\n\n\tconst ensureSubscription = () => {\n\t\tif (!subscription || subscription.closed) {\n\t\t\tsubscription = observable$.subscribe((value) => {\n\t\t\t\tlatestValue = value;\n\t\t\t\tfor (const listener of listeners) {\n\t\t\t\t\tlistener(value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\t// Start subscription immediately\n\tensureSubscription();\n\n\t// If observable emitted synchronously, use that value\n\t// Otherwise fall back to initialValue\n\tconst getSnapshot = () => latestValue ?? initialValue;\n\n\t/**\n\t * Returns the server-side snapshot for SSR hydration.\n\t * This prevents hydration mismatches by providing a consistent\n\t * value during server rendering. Must return the same value as\n\t * what the server rendered.\n\t */\n\tconst getServerSnapshot = () => serverValue ?? initialValue;\n\n\tconst subscribe = (callback: (value: T) => void) => {\n\t\tsubscriberCount++;\n\t\tlisteners.add(callback);\n\t\t// Ensure observable subscription is active when someone subscribes\n\t\tensureSubscription();\n\n\t\t// Immediately emit current value (BehaviorSubject semantics)\n\t\tcallback(getSnapshot());\n\n\t\treturn () => {\n\t\t\tsubscriberCount--;\n\t\t\tlisteners.delete(callback);\n\t\t\t// Don't close the observable subscription on unsubscribe\n\t\t\t// Let destroy() handle that when the store is truly being disposed\n\t\t};\n\t};\n\n\tconst destroy = () => {\n\t\t// Only unsubscribe if no one is listening\n\t\t// React StrictMode may call destroy and then immediately resubscribe\n\t\tif (subscriberCount === 0 && subscription) {\n\t\t\tsubscription.unsubscribe();\n\t\t\tsubscription = null;\n\t\t}\n\t};\n\n\treturn {\n\t\tgetSnapshot,\n\t\tgetServerSnapshot,\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":"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","names":[]}
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "@kheopskit/react",
3
- "version": "0.0.26",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
5
  "private": false,
9
6
  "files": [
10
7
  "dist"
11
8
  ],
12
- "main": "dist/index.cjs",
13
- "module": "dist/index.mjs",
14
- "types": "dist/index.d.ts",
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.ts",
15
12
  "exports": {
16
13
  ".": {
17
14
  "types": "./dist/index.d.ts",
@@ -19,6 +16,9 @@
19
16
  "require": "./dist/index.cjs"
20
17
  }
21
18
  },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
22
  "keywords": [],
23
23
  "author": "Kheops (https://github.com/0xKheops)",
24
24
  "repository": {
@@ -27,23 +27,24 @@
27
27
  },
28
28
  "license": "ISC",
29
29
  "peerDependencies": {
30
+ "@kheopskit/core": "^0.1.0",
30
31
  "react": ">=18.0.0",
31
32
  "react-dom": ">=18.0.0",
32
- "rxjs": ">=7.0.0",
33
- "@kheopskit/core": "0.0.22"
33
+ "rxjs": ">=7.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/react": "^19.1.5",
37
- "@types/react-dom": "^19.1.5",
38
- "react": "^19.1.0",
39
- "react-dom": "^19.1.0",
36
+ "@types/react": "^19.2.11",
37
+ "@types/react-dom": "^19.2.3",
38
+ "react": "^19.2.4",
39
+ "react-dom": "^19.2.4",
40
40
  "rxjs": "^7.8.2",
41
- "@kheopskit/core": "0.0.22"
41
+ "@kheopskit/core": "0.1.0"
42
42
  },
43
43
  "tsup": {
44
44
  "entry": [
45
45
  "src/index.ts"
46
46
  ],
47
+ "tsconfig": "tsconfig.build.json",
47
48
  "splitting": false,
48
49
  "sourcemap": true,
49
50
  "clean": true,