@chipi-stack/nextjs 11.6.0 → 11.8.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/ChipiClientProvider.d.mts +2 -2
- package/dist/app-router/client/ChipiProvider.d.mts +2 -2
- package/dist/cjs/ChipiClientProvider.d.ts +2 -2
- package/dist/cjs/ChipiClientProvider.js +3 -3
- package/dist/cjs/ChipiClientProvider.js.map +1 -1
- package/dist/cjs/app-router/client/ChipiProvider.d.ts +2 -2
- package/dist/cjs/app-router/client/ChipiProvider.js +3 -3
- package/dist/cjs/app-router/client/ChipiProvider.js.map +1 -1
- package/dist/cjs/app-router/server/ChipiProvider.js +7 -8
- package/dist/cjs/app-router/server/ChipiProvider.js.map +1 -1
- package/dist/cjs/client/ChipiProvider.js +1 -1
- package/dist/cjs/client/ChipiProvider.js.map +1 -1
- package/dist/cjs/client-boundary/ChipiProvider.d.ts +2 -2
- package/dist/cjs/client-boundary/ChipiProvider.js +2 -2
- package/dist/cjs/client-boundary/ChipiProvider.js.map +1 -1
- package/dist/cjs/hooks.d.ts +1 -1
- package/dist/cjs/hooks.js +6 -0
- package/dist/cjs/hooks.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/server/createChipiServer.js +2 -2
- package/dist/cjs/server/createChipiServer.js.map +1 -1
- package/dist/cjs/test/setup.d.ts +2 -0
- package/dist/cjs/test/setup.js +3 -0
- package/dist/cjs/test/setup.js.map +1 -0
- package/dist/client-boundary/ChipiProvider.d.mts +2 -2
- package/dist/esm/ChipiClientProvider.js +3 -3
- package/dist/esm/ChipiClientProvider.js.map +1 -1
- package/dist/esm/app-router/client/ChipiProvider.js +3 -3
- package/dist/esm/app-router/client/ChipiProvider.js.map +1 -1
- package/dist/esm/app-router/server/ChipiProvider.js +7 -8
- package/dist/esm/app-router/server/ChipiProvider.js.map +1 -1
- package/dist/esm/client/ChipiProvider.js +1 -1
- package/dist/esm/client/ChipiProvider.js.map +1 -1
- package/dist/esm/client-boundary/ChipiProvider.js +2 -2
- package/dist/esm/client-boundary/ChipiProvider.js.map +1 -1
- package/dist/esm/hooks.js +6 -0
- package/dist/esm/hooks.js.map +1 -1
- package/dist/esm/server/createChipiServer.js +2 -2
- package/dist/esm/server/createChipiServer.js.map +1 -1
- package/dist/esm/test/setup.js +2 -0
- package/dist/esm/test/setup.js.map +1 -0
- package/dist/hooks.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/test/setup.d.mts +2 -0
- package/package.json +12 -7
|
@@ -4,12 +4,12 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiClientProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper?: "True" | "False";
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Pure client component that handles all React hook imports
|
|
11
11
|
* This component is marked with 'use client' to avoid server-side issues
|
|
12
12
|
*/
|
|
13
|
-
declare function ChipiClientProvider({ children, apiPublicKey,
|
|
13
|
+
declare function ChipiClientProvider({ children, apiPublicKey, isInternalChipiDeveloper, }: ChipiClientProviderProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
export { ChipiClientProvider };
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper: 'True' | 'False';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Client-side Chipi Provider for Next.js App Router
|
|
@@ -15,6 +15,6 @@ interface ChipiProviderProps {
|
|
|
15
15
|
* Since this component is marked with 'use client', it's safe to import
|
|
16
16
|
* from @chipi-stack/chipi-react directly as it will never run on the server.
|
|
17
17
|
*/
|
|
18
|
-
declare function ChipiProvider({ children, apiPublicKey,
|
|
18
|
+
declare function ChipiProvider({ children, apiPublicKey, isInternalChipiDeveloper }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
19
|
|
|
20
20
|
export { ChipiProvider, type ChipiProviderProps };
|
|
@@ -4,12 +4,12 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiClientProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper?: "True" | "False";
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Pure client component that handles all React hook imports
|
|
11
11
|
* This component is marked with 'use client' to avoid server-side issues
|
|
12
12
|
*/
|
|
13
|
-
declare function ChipiClientProvider({ children, apiPublicKey,
|
|
13
|
+
declare function ChipiClientProvider({ children, apiPublicKey, isInternalChipiDeveloper, }: ChipiClientProviderProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
export { ChipiClientProvider };
|
|
@@ -38,14 +38,14 @@ var import_chipi_react = require("@chipi-stack/chipi-react");
|
|
|
38
38
|
function ChipiClientProvider({
|
|
39
39
|
children,
|
|
40
40
|
apiPublicKey,
|
|
41
|
-
|
|
41
|
+
isInternalChipiDeveloper = "False"
|
|
42
42
|
}) {
|
|
43
43
|
const config = import_react.default.useMemo(
|
|
44
44
|
() => ({
|
|
45
45
|
apiPublicKey,
|
|
46
|
-
|
|
46
|
+
isInternalChipiDeveloper: isInternalChipiDeveloper === "True" ? "True" : "False"
|
|
47
47
|
}),
|
|
48
|
-
[apiPublicKey,
|
|
48
|
+
[apiPublicKey, isInternalChipiDeveloper]
|
|
49
49
|
);
|
|
50
50
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_chipi_react.ChipiProvider, { config, children });
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ChipiClientProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiClientProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/ChipiClientProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiClientProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n isInternalChipiDeveloper?: \"True\" | \"False\";\n}\n\n/**\n * Pure client component that handles all React hook imports\n * This component is marked with 'use client' to avoid server-side issues\n */\nexport function ChipiClientProvider({\n children,\n apiPublicKey,\n isInternalChipiDeveloper = \"False\",\n}: ChipiClientProviderProps) {\n // Create config\n const config = React.useMemo(\n (): ChipiSDKConfig => ({\n apiPublicKey,\n isInternalChipiDeveloper: isInternalChipiDeveloper === \"True\" ? \"True\" : \"False\",\n }),\n [apiPublicKey, isInternalChipiDeveloper]\n );\n\n return <ChipiProvider config={config}>{children}</ChipiProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BS;AA5BT,mBAAkB;AAClB,yBAA8B;AAavB,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAA6B;AAE3B,QAAM,SAAS,aAAAA,QAAM;AAAA,IACnB,OAAuB;AAAA,MACrB;AAAA,MACA,0BAA0B,6BAA6B,SAAS,SAAS;AAAA,IAC3E;AAAA,IACA,CAAC,cAAc,wBAAwB;AAAA,EACzC;AAEA,SAAO,4CAAC,oCAAc,QAAiB,UAAS;AAClD;","names":["React"]}
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper: 'True' | 'False';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Client-side Chipi Provider for Next.js App Router
|
|
@@ -15,6 +15,6 @@ interface ChipiProviderProps {
|
|
|
15
15
|
* Since this component is marked with 'use client', it's safe to import
|
|
16
16
|
* from @chipi-stack/chipi-react directly as it will never run on the server.
|
|
17
17
|
*/
|
|
18
|
-
declare function ChipiProvider({ children, apiPublicKey,
|
|
18
|
+
declare function ChipiProvider({ children, apiPublicKey, isInternalChipiDeveloper }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
19
|
|
|
20
20
|
export { ChipiProvider, type ChipiProviderProps };
|
|
@@ -58,13 +58,13 @@ const createDefaultQueryClient = () => new import_react_query.QueryClient({
|
|
|
58
58
|
function ChipiProvider({
|
|
59
59
|
children,
|
|
60
60
|
apiPublicKey,
|
|
61
|
-
|
|
61
|
+
isInternalChipiDeveloper = "False"
|
|
62
62
|
}) {
|
|
63
63
|
const queryClient = import_react.default.useMemo(() => createDefaultQueryClient(), []);
|
|
64
64
|
const config = import_react.default.useMemo(() => ({
|
|
65
65
|
apiPublicKey,
|
|
66
|
-
|
|
67
|
-
}), [apiPublicKey,
|
|
66
|
+
isInternalChipiDeveloper
|
|
67
|
+
}), [apiPublicKey, isInternalChipiDeveloper]);
|
|
68
68
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_chipi_react.ChipiProvider, { config, children }) });
|
|
69
69
|
}
|
|
70
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/client/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChipiProvider as ReactChipiProvider } from '@chipi-stack/chipi-react';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChipiProvider as ReactChipiProvider } from '@chipi-stack/chipi-react';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n isInternalChipiDeveloper: 'True' | 'False';\n}\n\n// Default QueryClient configuration for Next.js\nconst createDefaultQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000, // 1 minute\n gcTime: 10 * 60 * 1000, // 10 minutes (formerly cacheTime)\n retry: (failureCount, error: any) => {\n // Don't retry on 4xx errors\n if (error?.status >= 400 && error?.status < 500) {\n return false;\n }\n return failureCount < 3;\n },\n },\n mutations: {\n retry: false,\n },\n },\n });\n\n/**\n * Client-side Chipi Provider for Next.js App Router\n * \n * This is the client component version that handles client-side functionality.\n * It wraps children with QueryClient and the React Chipi provider.\n * \n * Since this component is marked with 'use client', it's safe to import\n * from @chipi-stack/chipi-react directly as it will never run on the server.\n */\nexport function ChipiProvider({ \n children, \n apiPublicKey,\n isInternalChipiDeveloper = 'False'\n}: ChipiProviderProps) {\n // Create QueryClient\n const queryClient = React.useMemo(() => createDefaultQueryClient(), []);\n\n // Create config\n const config = React.useMemo(() => ({\n apiPublicKey,\n isInternalChipiDeveloper,\n }), [apiPublicKey, isInternalChipiDeveloper]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <ReactChipiProvider config={config}>\n {children}\n </ReactChipiProvider>\n </QueryClientProvider>\n );\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DM;AAxDN,mBAAkB;AAClB,yBAAiD;AACjD,yBAAoD;AASpD,MAAM,2BAA2B,MAC/B,IAAI,+BAAY;AAAA,EACd,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,WAAW,KAAK;AAAA;AAAA,MAChB,QAAQ,KAAK,KAAK;AAAA;AAAA,MAClB,OAAO,CAAC,cAAc,UAAe;AAEnC,YAAI,OAAO,UAAU,OAAO,OAAO,SAAS,KAAK;AAC/C,iBAAO;AAAA,QACT;AACA,eAAO,eAAe;AAAA,MACxB;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF,CAAC;AAWI,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAAuB;AAErB,QAAM,cAAc,aAAAA,QAAM,QAAQ,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAGtE,QAAM,SAAS,aAAAA,QAAM,QAAQ,OAAO;AAAA,IAClC;AAAA,IACA;AAAA,EACF,IAAI,CAAC,cAAc,wBAAwB,CAAC;AAE5C,SACE,4CAAC,0CAAoB,QAAQ,aAC3B,sDAAC,mBAAAC,eAAA,EAAmB,QACjB,UACH,GACF;AAEJ;","names":["React","ReactChipiProvider"]}
|
|
@@ -27,15 +27,14 @@ var import_ChipiProvider = require("../client/ChipiProvider");
|
|
|
27
27
|
async function ChipiProvider({ children }) {
|
|
28
28
|
const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;
|
|
29
29
|
const apiSecretKey = process.env.CHIPI_SECRET_KEY;
|
|
30
|
-
let
|
|
30
|
+
let isInternalChipiDeveloper = "False";
|
|
31
31
|
console.log(
|
|
32
|
-
"process.env.
|
|
33
|
-
process.env.
|
|
32
|
+
"process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER",
|
|
33
|
+
process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER
|
|
34
34
|
);
|
|
35
|
-
if (process.env.
|
|
36
|
-
|
|
35
|
+
if (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === "True") {
|
|
36
|
+
isInternalChipiDeveloper = "True";
|
|
37
37
|
}
|
|
38
|
-
console.log("environment?", environment);
|
|
39
38
|
if (!apiPublicKey) {
|
|
40
39
|
throw new Error(
|
|
41
40
|
" NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env file."
|
|
@@ -49,10 +48,10 @@ async function ChipiProvider({ children }) {
|
|
|
49
48
|
(0, import_createChipiServer.createChipiServer)({
|
|
50
49
|
apiSecretKey,
|
|
51
50
|
apiPublicKey,
|
|
52
|
-
|
|
51
|
+
isInternalChipiDeveloper
|
|
53
52
|
// debug: environment === "development",
|
|
54
53
|
});
|
|
55
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChipiProvider.ChipiProvider, { apiPublicKey,
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChipiProvider.ChipiProvider, { apiPublicKey, isInternalChipiDeveloper, children });
|
|
56
55
|
}
|
|
57
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
57
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/ChipiProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { createChipiServer } from \"../../server/createChipiServer\";\nimport { ChipiProvider as ChipiClientProvider } from \"../client/ChipiProvider\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Server-side Chipi Provider for Next.js App Router\n *\n * This is the server component version that runs during SSR.\n * It initializes the server SDK and passes configuration to the client provider.\n */\nexport async function ChipiProvider({ children }: ChipiProviderProps) {\n // Read environment variables on the server\n const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n const apiSecretKey = process.env.CHIPI_SECRET_KEY;\n let
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/server/ChipiProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { createChipiServer } from \"../../server/createChipiServer\";\nimport { ChipiProvider as ChipiClientProvider } from \"../client/ChipiProvider\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Server-side Chipi Provider for Next.js App Router\n *\n * This is the server component version that runs during SSR.\n * It initializes the server SDK and passes configuration to the client provider.\n */\nexport async function ChipiProvider({ children }: ChipiProviderProps) {\n // Read environment variables on the server\n const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n const apiSecretKey = process.env.CHIPI_SECRET_KEY;\n let isInternalChipiDeveloper = \"False\" as \"False\" | \"True\";\n console.log(\n \"process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER\",\n process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER\n );\n if (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === \"True\") {\n isInternalChipiDeveloper = \"True\";\n }\n\n \n // Validate required environment variables\n if (!apiPublicKey) {\n throw new Error(\n \" NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env file.\"\n );\n }\n\n if (!apiSecretKey) {\n throw new Error(\n \"Missing CHIPI_SECRET_KEY environment variable. Server-side features will not work properly.\"\n );\n }\n\n // Initialize server SDK (this runs on server only)\n createChipiServer({\n apiSecretKey,\n apiPublicKey,\n isInternalChipiDeveloper,\n // debug: environment === \"development\",\n });\n\n // Return the client provider which will hydrate on the client\n // Note: This works because ChipiClientProvider is marked with 'use client'\n return (\n <ChipiClientProvider apiPublicKey={apiPublicKey} isInternalChipiDeveloper={isInternalChipiDeveloper}>\n {children}\n </ChipiClientProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDI;AAnDJ,+BAAkC;AAClC,2BAAqD;AAYrD,eAAsB,cAAc,EAAE,SAAS,GAAuB;AAEpE,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,eAAe,QAAQ,IAAI;AACjC,MAAI,2BAA2B;AAC/B,UAAQ;AAAA,IACN;AAAA,IACA,QAAQ,IAAI;AAAA,EACd;AACA,MAAI,QAAQ,IAAI,mCAAmC,QAAQ;AACzD,+BAA2B;AAAA,EAC7B;AAIA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,kDAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAEF,CAAC;AAID,SACE,4CAAC,qBAAAA,eAAA,EAAoB,cAA4B,0BAC9C,UACH;AAEJ;","names":["ChipiClientProvider"]}
|
|
@@ -42,7 +42,7 @@ function ChipiProvider({
|
|
|
42
42
|
const config = import_react.default.useMemo(() => {
|
|
43
43
|
const envConfig = {
|
|
44
44
|
apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY,
|
|
45
|
-
|
|
45
|
+
isInternalChipiDeveloper: process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === "True" ? "True" : "False"
|
|
46
46
|
};
|
|
47
47
|
return { ...envConfig, ...userConfig };
|
|
48
48
|
}, [userConfig]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/ChipiProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider as BaseChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n /**\n * Configuration for the Chipi SDK\n */\n config?: Partial<ChipiSDKConfig>;\n}\n\n/**\n * Client-side Chipi Provider for Next.js applications\n *\n * This provider wraps the base ChipiProvider and provides Next.js-specific\n * optimizations like automatic environment variable configuration.\n *\n * Note: For most use cases, use the main ChipiProvider from '@chipi-stack/nextjs'\n * instead of this client-only provider.\n *\n * @example\n * ```tsx\n * // Advanced usage - client-only provider\n * 'use client';\n *\n * import { ChipiProvider } from '@chipi-stack/nextjs/client';\n *\n * export function ClientProviders({ children }: { children: React.ReactNode }) {\n * return (\n * <ChipiProvider\n * config={{\n * apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n * environment: 'production'\n * }}\n * >\n * {children}\n * </ChipiProvider>\n * );\n * }\n * ```\n */\nexport function ChipiProvider({\n children,\n config: userConfig,\n}: ChipiProviderProps) {\n // Automatically get configuration from environment variables\n // Siento que esta madre no se usa\n const config = React.useMemo(() => {\n const envConfig: ChipiSDKConfig = {\n apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ChipiProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider as BaseChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n /**\n * Configuration for the Chipi SDK\n */\n config?: Partial<ChipiSDKConfig>;\n}\n\n/**\n * Client-side Chipi Provider for Next.js applications\n *\n * This provider wraps the base ChipiProvider and provides Next.js-specific\n * optimizations like automatic environment variable configuration.\n *\n * Note: For most use cases, use the main ChipiProvider from '@chipi-stack/nextjs'\n * instead of this client-only provider.\n *\n * @example\n * ```tsx\n * // Advanced usage - client-only provider\n * 'use client';\n *\n * import { ChipiProvider } from '@chipi-stack/nextjs/client';\n *\n * export function ClientProviders({ children }: { children: React.ReactNode }) {\n * return (\n * <ChipiProvider\n * config={{\n * apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n * environment: 'production'\n * }}\n * >\n * {children}\n * </ChipiProvider>\n * );\n * }\n * ```\n */\nexport function ChipiProvider({\n children,\n config: userConfig,\n}: ChipiProviderProps) {\n // Automatically get configuration from environment variables\n // Siento que esta madre no se usa\n const config = React.useMemo(() => {\n const envConfig: ChipiSDKConfig = {\n apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n isInternalChipiDeveloper: (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === \"True\"\n ? \"True\"\n : \"False\") as \"True\" | \"False\",\n };\n\n // Merge with user-provided config\n return { ...envConfig, ...userConfig };\n }, [userConfig]);\n\n // Validate required configuration\n if (!config.apiPublicKey) {\n throw new Error(\n \"Missing NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env.local file.\"\n );\n }\n\n return <BaseChipiProvider config={config}>{children}</BaseChipiProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqES;AAnET,mBAAkB;AAClB,yBAAmD;AAyC5C,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,QAAQ;AACV,GAAuB;AAGrB,QAAM,SAAS,aAAAA,QAAM,QAAQ,MAAM;AACjC,UAAM,YAA4B;AAAA,MAChC,cAAc,QAAQ,IAAI;AAAA,MAC1B,0BAA2B,QAAQ,IAAI,mCAAmC,SACtE,SACA;AAAA,IACN;AAGA,WAAO,EAAE,GAAG,WAAW,GAAG,WAAW;AAAA,EACvC,GAAG,CAAC,UAAU,CAAC;AAGf,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,4CAAC,mBAAAC,eAAA,EAAkB,QAAiB,UAAS;AACtD;","names":["React","BaseChipiProvider"]}
|
|
@@ -4,12 +4,12 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey?: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper?: 'True' | 'False';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* This is a compatibility layer that provides a client-only ChipiProvider.
|
|
11
11
|
* This is used when the conditional export resolves to the client boundary.
|
|
12
12
|
*/
|
|
13
|
-
declare function ChipiProvider({ children, apiPublicKey,
|
|
13
|
+
declare function ChipiProvider({ children, apiPublicKey, isInternalChipiDeveloper }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
export { ChipiProvider, type ChipiProviderProps };
|
|
@@ -27,7 +27,7 @@ var import_ChipiProvider = require("../app-router/client/ChipiProvider");
|
|
|
27
27
|
function ChipiProvider({
|
|
28
28
|
children,
|
|
29
29
|
apiPublicKey,
|
|
30
|
-
|
|
30
|
+
isInternalChipiDeveloper = "True"
|
|
31
31
|
}) {
|
|
32
32
|
const finalApiPublicKey = apiPublicKey || process.env.NEXT_PUBLIC_CHIPI_API_KEY;
|
|
33
33
|
if (!finalApiPublicKey) {
|
|
@@ -39,7 +39,7 @@ function ChipiProvider({
|
|
|
39
39
|
import_ChipiProvider.ChipiProvider,
|
|
40
40
|
{
|
|
41
41
|
apiPublicKey: finalApiPublicKey,
|
|
42
|
-
|
|
42
|
+
isInternalChipiDeveloper,
|
|
43
43
|
children
|
|
44
44
|
}
|
|
45
45
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client-boundary/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { ChipiProvider as ClientChipiProvider } from '../app-router/client/ChipiProvider';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/client-boundary/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { ChipiProvider as ClientChipiProvider } from '../app-router/client/ChipiProvider';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey?: string;\n isInternalChipiDeveloper?: 'True' | 'False';\n}\n\n/**\n * This is a compatibility layer that provides a client-only ChipiProvider.\n * This is used when the conditional export resolves to the client boundary.\n */\nexport function ChipiProvider({ \n children, \n apiPublicKey,\n isInternalChipiDeveloper = 'True' \n}: ChipiProviderProps) {\n // For client-only usage, allow apiPublicKey to be passed as prop\n // or read from environment\n const finalApiPublicKey = apiPublicKey || process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n\n if (!finalApiPublicKey) {\n throw new Error(\n 'Missing NEXT_PUBLIC_CHIPI_API_KEY environment variable or apiPublicKey prop. Please provide one.'\n );\n }\n\n return (\n <ClientChipiProvider \n apiPublicKey={finalApiPublicKey} \n isInternalChipiDeveloper={isInternalChipiDeveloper}\n >\n {children}\n </ClientChipiProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BI;AA5BJ,2BAAqD;AAY9C,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAAuB;AAGrB,QAAM,oBAAoB,gBAAgB,QAAQ,IAAI;AAEtD,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SACE;AAAA,IAAC,qBAAAA;AAAA,IAAA;AAAA,MACC,cAAc;AAAA,MACd;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["ClientChipiProvider"]}
|
package/dist/cjs/hooks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
1
|
+
export { useApprove, useCallAnyContract, useChipiContext, useCreateSkuTransaction, useCreateWallet, useGetSkuTransactionById, useGetSkus, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -22,7 +22,10 @@ __export(hooks_exports, {
|
|
|
22
22
|
useApprove: () => import_chipi_react.useApprove,
|
|
23
23
|
useCallAnyContract: () => import_chipi_react.useCallAnyContract,
|
|
24
24
|
useChipiContext: () => import_chipi_react.useChipiContext,
|
|
25
|
+
useCreateSkuTransaction: () => import_chipi_react.useCreateSkuTransaction,
|
|
25
26
|
useCreateWallet: () => import_chipi_react.useCreateWallet,
|
|
27
|
+
useGetSkuTransactionById: () => import_chipi_react.useGetSkuTransactionById,
|
|
28
|
+
useGetSkus: () => import_chipi_react.useGetSkus,
|
|
26
29
|
useGetTokenBalance: () => import_chipi_react.useGetTokenBalance,
|
|
27
30
|
useGetWallet: () => import_chipi_react.useGetWallet,
|
|
28
31
|
useRecordSendTransaction: () => import_chipi_react.useRecordSendTransaction,
|
|
@@ -37,7 +40,10 @@ var import_chipi_react = require("@chipi-stack/chipi-react");
|
|
|
37
40
|
useApprove,
|
|
38
41
|
useCallAnyContract,
|
|
39
42
|
useChipiContext,
|
|
43
|
+
useCreateSkuTransaction,
|
|
40
44
|
useCreateWallet,
|
|
45
|
+
useGetSkuTransactionById,
|
|
46
|
+
useGetSkus,
|
|
41
47
|
useGetTokenBalance,
|
|
42
48
|
useGetWallet,
|
|
43
49
|
useRecordSendTransaction,
|
package/dist/cjs/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks.ts"],"sourcesContent":["\"use client\";\n\n// Client-side hooks for Next.js Chipi SDK\n// These are re-exported from @chipi-stack/chipi-react for convenience\n// This file is marked as 'use client' to ensure it only runs on the client\n\nexport {\n // Context hook\n useChipiContext,\n\n // Wallet hooks\n useCreateWallet,\n useGetWallet,\n\n // Transaction hooks\n useApprove,\n useTransfer,\n\n // SKU hooks\n\n // Specialized transaction hooks\n useStakeVesuUsdc,\n useWithdrawVesuUsdc,\n useCallAnyContract,\n\n // Record send transaction hook\n useRecordSendTransaction,\n\n // Token balance hook\n useGetTokenBalance,\n} from \"@chipi-stack/chipi-react\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks.ts"],"sourcesContent":["\"use client\";\n\n// Client-side hooks for Next.js Chipi SDK\n// These are re-exported from @chipi-stack/chipi-react for convenience\n// This file is marked as 'use client' to ensure it only runs on the client\n\nexport {\n // Context hook\n useChipiContext,\n\n // Wallet hooks\n useCreateWallet,\n useGetWallet,\n\n // Transaction hooks\n useApprove,\n useTransfer,\n\n // SKU hooks\n useGetSkus,\n\n\n // SKU Transaction hooks\n useCreateSkuTransaction,\n useGetSkuTransactionById,\n \n\n // Specialized transaction hooks\n useStakeVesuUsdc,\n useWithdrawVesuUsdc,\n useCallAnyContract,\n\n // Record send transaction hook\n useRecordSendTransaction,\n\n // Token balance hook\n useGetTokenBalance,\n} from \"@chipi-stack/chipi-react\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBA+BO;","names":[]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServerComponentsServerModuleTypes } from './components.server.js';
|
|
2
2
|
export { ChipiProvider as ChipiClientProvider } from './app-router/client/ChipiProvider.js';
|
|
3
|
-
export { useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
3
|
+
export { useApprove, useCallAnyContract, useChipiContext, useCreateSkuTransaction, useCreateWallet, useGetSkuTransactionById, useGetSkus, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
4
4
|
export * from '@chipi-stack/types';
|
|
5
5
|
export { createChipiServer, getChipiServer, resetChipiServer } from './server/createChipiServer.js';
|
|
6
6
|
import './app-router/server/ChipiProvider.js';
|
|
@@ -27,12 +27,12 @@ var import_backend = require("@chipi-stack/backend");
|
|
|
27
27
|
let serverInstance = null;
|
|
28
28
|
function createChipiServer(config) {
|
|
29
29
|
if (!config.apiPublicKey) {
|
|
30
|
-
throw new Error(" apiPublicKey in config");
|
|
30
|
+
throw new Error("Missing apiPublicKey in config");
|
|
31
31
|
}
|
|
32
32
|
if (!config.apiSecretKey) {
|
|
33
33
|
throw new Error("Missing apiSecretKey in config");
|
|
34
34
|
}
|
|
35
|
-
if (config.
|
|
35
|
+
if (config.isInternalChipiDeveloper === "True") {
|
|
36
36
|
return new import_backend.ChipiServerSDK(config);
|
|
37
37
|
}
|
|
38
38
|
if (!serverInstance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/createChipiServer.ts"],"sourcesContent":["import { ChipiServerSDK, ChipiServerSDKConfig } from \"@chipi-stack/backend\";\n\n/**\n * Global server instance\n */\nlet serverInstance: ChipiServerSDK | null = null;\n\n/**\n * Create or get the Chipi server instance\n * This ensures a singleton pattern for server-side operations\n * Uses only the passed config (no environment variable fallbacks)\n */\nexport function createChipiServer(\n config: ChipiServerSDKConfig\n): ChipiServerSDK {\n // Validate required fields\n if (!config.apiPublicKey) {\n throw new Error(\" apiPublicKey in config\");\n }\n\n if (!config.apiSecretKey) {\n throw new Error(\"Missing apiSecretKey in config\");\n }\n\n // In development, always create a new instance to support hot reloading\n if (config.
|
|
1
|
+
{"version":3,"sources":["../../../src/server/createChipiServer.ts"],"sourcesContent":["import { ChipiServerSDK, ChipiServerSDKConfig } from \"@chipi-stack/backend\";\n\n/**\n * Global server instance\n */\nlet serverInstance: ChipiServerSDK | null = null;\n\n/**\n * Create or get the Chipi server instance\n * This ensures a singleton pattern for server-side operations\n * Uses only the passed config (no environment variable fallbacks)\n */\nexport function createChipiServer(\n config: ChipiServerSDKConfig\n): ChipiServerSDK {\n // Validate required fields\n if (!config.apiPublicKey) {\n throw new Error(\"Missing apiPublicKey in config\");\n }\n\n if (!config.apiSecretKey) {\n throw new Error(\"Missing apiSecretKey in config\");\n }\n\n // In development, always create a new instance to support hot reloading\n if (config.isInternalChipiDeveloper === \"True\") {\n return new ChipiServerSDK(config);\n }\n\n // In production, use singleton pattern\n if (!serverInstance) {\n serverInstance = new ChipiServerSDK(config);\n }\n\n return serverInstance;\n}\n\n/**\n * Get the current server instance\n * Throws an error if no instance has been created\n */\nexport function getChipiServer(): ChipiServerSDK {\n if (!serverInstance) {\n throw new Error(\n \"Chipi server instance not found. Make sure to call createChipiServer() first.\"\n );\n }\n\n return serverInstance;\n}\n\n/**\n * Reset the server instance (useful for testing)\n */\nexport function resetChipiServer(): void {\n serverInstance = null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqD;AAKrD,IAAI,iBAAwC;AAOrC,SAAS,kBACd,QACgB;AAEhB,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAGA,MAAI,OAAO,6BAA6B,QAAQ;AAC9C,WAAO,IAAI,8BAAe,MAAM;AAAA,EAClC;AAGA,MAAI,CAAC,gBAAgB;AACnB,qBAAiB,IAAI,8BAAe,MAAM;AAAA,EAC5C;AAEA,SAAO;AACT;AAMO,SAAS,iBAAiC;AAC/C,MAAI,CAAC,gBAAgB;AACnB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,mBAAyB;AACvC,mBAAiB;AACnB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/setup.ts"],"sourcesContent":["import '@testing-library/jest-dom'\n"],"mappings":";AAAA,sBAAO;","names":[]}
|
|
@@ -4,12 +4,12 @@ import React from 'react';
|
|
|
4
4
|
interface ChipiProviderProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
apiPublicKey?: string;
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper?: 'True' | 'False';
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* This is a compatibility layer that provides a client-only ChipiProvider.
|
|
11
11
|
* This is used when the conditional export resolves to the client boundary.
|
|
12
12
|
*/
|
|
13
|
-
declare function ChipiProvider({ children, apiPublicKey,
|
|
13
|
+
declare function ChipiProvider({ children, apiPublicKey, isInternalChipiDeveloper }: ChipiProviderProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
export { ChipiProvider, type ChipiProviderProps };
|
|
@@ -5,14 +5,14 @@ import { ChipiProvider } from "@chipi-stack/chipi-react";
|
|
|
5
5
|
function ChipiClientProvider({
|
|
6
6
|
children,
|
|
7
7
|
apiPublicKey,
|
|
8
|
-
|
|
8
|
+
isInternalChipiDeveloper = "False"
|
|
9
9
|
}) {
|
|
10
10
|
const config = React.useMemo(
|
|
11
11
|
() => ({
|
|
12
12
|
apiPublicKey,
|
|
13
|
-
|
|
13
|
+
isInternalChipiDeveloper: isInternalChipiDeveloper === "True" ? "True" : "False"
|
|
14
14
|
}),
|
|
15
|
-
[apiPublicKey,
|
|
15
|
+
[apiPublicKey, isInternalChipiDeveloper]
|
|
16
16
|
);
|
|
17
17
|
return /* @__PURE__ */ jsx(ChipiProvider, { config, children });
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ChipiClientProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiClientProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/ChipiClientProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\ninterface ChipiClientProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n isInternalChipiDeveloper?: \"True\" | \"False\";\n}\n\n/**\n * Pure client component that handles all React hook imports\n * This component is marked with 'use client' to avoid server-side issues\n */\nexport function ChipiClientProvider({\n children,\n apiPublicKey,\n isInternalChipiDeveloper = \"False\",\n}: ChipiClientProviderProps) {\n // Create config\n const config = React.useMemo(\n (): ChipiSDKConfig => ({\n apiPublicKey,\n isInternalChipiDeveloper: isInternalChipiDeveloper === \"True\" ? \"True\" : \"False\",\n }),\n [apiPublicKey, isInternalChipiDeveloper]\n );\n\n return <ChipiProvider config={config}>{children}</ChipiProvider>;\n}\n"],"mappings":";AA8BS;AA5BT,OAAO,WAAW;AAClB,SAAS,qBAAqB;AAavB,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAA6B;AAE3B,QAAM,SAAS,MAAM;AAAA,IACnB,OAAuB;AAAA,MACrB;AAAA,MACA,0BAA0B,6BAA6B,SAAS,SAAS;AAAA,IAC3E;AAAA,IACA,CAAC,cAAc,wBAAwB;AAAA,EACzC;AAEA,SAAO,oBAAC,iBAAc,QAAiB,UAAS;AAClD;","names":[]}
|
|
@@ -25,13 +25,13 @@ const createDefaultQueryClient = () => new QueryClient({
|
|
|
25
25
|
function ChipiProvider({
|
|
26
26
|
children,
|
|
27
27
|
apiPublicKey,
|
|
28
|
-
|
|
28
|
+
isInternalChipiDeveloper = "False"
|
|
29
29
|
}) {
|
|
30
30
|
const queryClient = React.useMemo(() => createDefaultQueryClient(), []);
|
|
31
31
|
const config = React.useMemo(() => ({
|
|
32
32
|
apiPublicKey,
|
|
33
|
-
|
|
34
|
-
}), [apiPublicKey,
|
|
33
|
+
isInternalChipiDeveloper
|
|
34
|
+
}), [apiPublicKey, isInternalChipiDeveloper]);
|
|
35
35
|
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(ReactChipiProvider, { config, children }) });
|
|
36
36
|
}
|
|
37
37
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/client/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChipiProvider as ReactChipiProvider } from '@chipi-stack/chipi-react';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChipiProvider as ReactChipiProvider } from '@chipi-stack/chipi-react';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey: string;\n isInternalChipiDeveloper: 'True' | 'False';\n}\n\n// Default QueryClient configuration for Next.js\nconst createDefaultQueryClient = () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000, // 1 minute\n gcTime: 10 * 60 * 1000, // 10 minutes (formerly cacheTime)\n retry: (failureCount, error: any) => {\n // Don't retry on 4xx errors\n if (error?.status >= 400 && error?.status < 500) {\n return false;\n }\n return failureCount < 3;\n },\n },\n mutations: {\n retry: false,\n },\n },\n });\n\n/**\n * Client-side Chipi Provider for Next.js App Router\n * \n * This is the client component version that handles client-side functionality.\n * It wraps children with QueryClient and the React Chipi provider.\n * \n * Since this component is marked with 'use client', it's safe to import\n * from @chipi-stack/chipi-react directly as it will never run on the server.\n */\nexport function ChipiProvider({ \n children, \n apiPublicKey,\n isInternalChipiDeveloper = 'False'\n}: ChipiProviderProps) {\n // Create QueryClient\n const queryClient = React.useMemo(() => createDefaultQueryClient(), []);\n\n // Create config\n const config = React.useMemo(() => ({\n apiPublicKey,\n isInternalChipiDeveloper,\n }), [apiPublicKey, isInternalChipiDeveloper]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <ReactChipiProvider config={config}>\n {children}\n </ReactChipiProvider>\n </QueryClientProvider>\n );\n}"],"mappings":";AA0DM;AAxDN,OAAO,WAAW;AAClB,SAAS,aAAa,2BAA2B;AACjD,SAAS,iBAAiB,0BAA0B;AASpD,MAAM,2BAA2B,MAC/B,IAAI,YAAY;AAAA,EACd,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,WAAW,KAAK;AAAA;AAAA,MAChB,QAAQ,KAAK,KAAK;AAAA;AAAA,MAClB,OAAO,CAAC,cAAc,UAAe;AAEnC,YAAI,OAAO,UAAU,OAAO,OAAO,SAAS,KAAK;AAC/C,iBAAO;AAAA,QACT;AACA,eAAO,eAAe;AAAA,MACxB;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF,CAAC;AAWI,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAAuB;AAErB,QAAM,cAAc,MAAM,QAAQ,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAGtE,QAAM,SAAS,MAAM,QAAQ,OAAO;AAAA,IAClC;AAAA,IACA;AAAA,EACF,IAAI,CAAC,cAAc,wBAAwB,CAAC;AAE5C,SACE,oBAAC,uBAAoB,QAAQ,aAC3B,8BAAC,sBAAmB,QACjB,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -4,15 +4,14 @@ import { ChipiProvider as ChipiClientProvider } from "../client/ChipiProvider";
|
|
|
4
4
|
async function ChipiProvider({ children }) {
|
|
5
5
|
const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;
|
|
6
6
|
const apiSecretKey = process.env.CHIPI_SECRET_KEY;
|
|
7
|
-
let
|
|
7
|
+
let isInternalChipiDeveloper = "False";
|
|
8
8
|
console.log(
|
|
9
|
-
"process.env.
|
|
10
|
-
process.env.
|
|
9
|
+
"process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER",
|
|
10
|
+
process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER
|
|
11
11
|
);
|
|
12
|
-
if (process.env.
|
|
13
|
-
|
|
12
|
+
if (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === "True") {
|
|
13
|
+
isInternalChipiDeveloper = "True";
|
|
14
14
|
}
|
|
15
|
-
console.log("environment?", environment);
|
|
16
15
|
if (!apiPublicKey) {
|
|
17
16
|
throw new Error(
|
|
18
17
|
" NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env file."
|
|
@@ -26,10 +25,10 @@ async function ChipiProvider({ children }) {
|
|
|
26
25
|
createChipiServer({
|
|
27
26
|
apiSecretKey,
|
|
28
27
|
apiPublicKey,
|
|
29
|
-
|
|
28
|
+
isInternalChipiDeveloper
|
|
30
29
|
// debug: environment === "development",
|
|
31
30
|
});
|
|
32
|
-
return /* @__PURE__ */ jsx(ChipiClientProvider, { apiPublicKey,
|
|
31
|
+
return /* @__PURE__ */ jsx(ChipiClientProvider, { apiPublicKey, isInternalChipiDeveloper, children });
|
|
33
32
|
}
|
|
34
33
|
export {
|
|
35
34
|
ChipiProvider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/ChipiProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { createChipiServer } from \"../../server/createChipiServer\";\nimport { ChipiProvider as ChipiClientProvider } from \"../client/ChipiProvider\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Server-side Chipi Provider for Next.js App Router\n *\n * This is the server component version that runs during SSR.\n * It initializes the server SDK and passes configuration to the client provider.\n */\nexport async function ChipiProvider({ children }: ChipiProviderProps) {\n // Read environment variables on the server\n const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n const apiSecretKey = process.env.CHIPI_SECRET_KEY;\n let
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/server/ChipiProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { createChipiServer } from \"../../server/createChipiServer\";\nimport { ChipiProvider as ChipiClientProvider } from \"../client/ChipiProvider\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Server-side Chipi Provider for Next.js App Router\n *\n * This is the server component version that runs during SSR.\n * It initializes the server SDK and passes configuration to the client provider.\n */\nexport async function ChipiProvider({ children }: ChipiProviderProps) {\n // Read environment variables on the server\n const apiPublicKey = process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n const apiSecretKey = process.env.CHIPI_SECRET_KEY;\n let isInternalChipiDeveloper = \"False\" as \"False\" | \"True\";\n console.log(\n \"process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER\",\n process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER\n );\n if (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === \"True\") {\n isInternalChipiDeveloper = \"True\";\n }\n\n \n // Validate required environment variables\n if (!apiPublicKey) {\n throw new Error(\n \" NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env file.\"\n );\n }\n\n if (!apiSecretKey) {\n throw new Error(\n \"Missing CHIPI_SECRET_KEY environment variable. Server-side features will not work properly.\"\n );\n }\n\n // Initialize server SDK (this runs on server only)\n createChipiServer({\n apiSecretKey,\n apiPublicKey,\n isInternalChipiDeveloper,\n // debug: environment === \"development\",\n });\n\n // Return the client provider which will hydrate on the client\n // Note: This works because ChipiClientProvider is marked with 'use client'\n return (\n <ChipiClientProvider apiPublicKey={apiPublicKey} isInternalChipiDeveloper={isInternalChipiDeveloper}>\n {children}\n </ChipiClientProvider>\n );\n}\n"],"mappings":"AAoDI;AAnDJ,SAAS,yBAAyB;AAClC,SAAS,iBAAiB,2BAA2B;AAYrD,eAAsB,cAAc,EAAE,SAAS,GAAuB;AAEpE,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,eAAe,QAAQ,IAAI;AACjC,MAAI,2BAA2B;AAC/B,UAAQ;AAAA,IACN;AAAA,IACA,QAAQ,IAAI;AAAA,EACd;AACA,MAAI,QAAQ,IAAI,mCAAmC,QAAQ;AACzD,+BAA2B;AAAA,EAC7B;AAIA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,oBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAEF,CAAC;AAID,SACE,oBAAC,uBAAoB,cAA4B,0BAC9C,UACH;AAEJ;","names":[]}
|
|
@@ -9,7 +9,7 @@ function ChipiProvider({
|
|
|
9
9
|
const config = React.useMemo(() => {
|
|
10
10
|
const envConfig = {
|
|
11
11
|
apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY,
|
|
12
|
-
|
|
12
|
+
isInternalChipiDeveloper: process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === "True" ? "True" : "False"
|
|
13
13
|
};
|
|
14
14
|
return { ...envConfig, ...userConfig };
|
|
15
15
|
}, [userConfig]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/ChipiProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider as BaseChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n /**\n * Configuration for the Chipi SDK\n */\n config?: Partial<ChipiSDKConfig>;\n}\n\n/**\n * Client-side Chipi Provider for Next.js applications\n *\n * This provider wraps the base ChipiProvider and provides Next.js-specific\n * optimizations like automatic environment variable configuration.\n *\n * Note: For most use cases, use the main ChipiProvider from '@chipi-stack/nextjs'\n * instead of this client-only provider.\n *\n * @example\n * ```tsx\n * // Advanced usage - client-only provider\n * 'use client';\n *\n * import { ChipiProvider } from '@chipi-stack/nextjs/client';\n *\n * export function ClientProviders({ children }: { children: React.ReactNode }) {\n * return (\n * <ChipiProvider\n * config={{\n * apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n * environment: 'production'\n * }}\n * >\n * {children}\n * </ChipiProvider>\n * );\n * }\n * ```\n */\nexport function ChipiProvider({\n children,\n config: userConfig,\n}: ChipiProviderProps) {\n // Automatically get configuration from environment variables\n // Siento que esta madre no se usa\n const config = React.useMemo(() => {\n const envConfig: ChipiSDKConfig = {\n apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ChipiProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { ChipiProvider as BaseChipiProvider } from \"@chipi-stack/chipi-react\";\nimport type { ChipiSDKConfig } from \"@chipi-stack/types\";\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n /**\n * Configuration for the Chipi SDK\n */\n config?: Partial<ChipiSDKConfig>;\n}\n\n/**\n * Client-side Chipi Provider for Next.js applications\n *\n * This provider wraps the base ChipiProvider and provides Next.js-specific\n * optimizations like automatic environment variable configuration.\n *\n * Note: For most use cases, use the main ChipiProvider from '@chipi-stack/nextjs'\n * instead of this client-only provider.\n *\n * @example\n * ```tsx\n * // Advanced usage - client-only provider\n * 'use client';\n *\n * import { ChipiProvider } from '@chipi-stack/nextjs/client';\n *\n * export function ClientProviders({ children }: { children: React.ReactNode }) {\n * return (\n * <ChipiProvider\n * config={{\n * apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n * environment: 'production'\n * }}\n * >\n * {children}\n * </ChipiProvider>\n * );\n * }\n * ```\n */\nexport function ChipiProvider({\n children,\n config: userConfig,\n}: ChipiProviderProps) {\n // Automatically get configuration from environment variables\n // Siento que esta madre no se usa\n const config = React.useMemo(() => {\n const envConfig: ChipiSDKConfig = {\n apiPublicKey: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,\n isInternalChipiDeveloper: (process.env.NEXT_PUBLIC_IS_CHIPI_DEVELOPER === \"True\"\n ? \"True\"\n : \"False\") as \"True\" | \"False\",\n };\n\n // Merge with user-provided config\n return { ...envConfig, ...userConfig };\n }, [userConfig]);\n\n // Validate required configuration\n if (!config.apiPublicKey) {\n throw new Error(\n \"Missing NEXT_PUBLIC_CHIPI_API_KEY environment variable. Please add it to your .env.local file.\"\n );\n }\n\n return <BaseChipiProvider config={config}>{children}</BaseChipiProvider>;\n}\n"],"mappings":";AAqES;AAnET,OAAO,WAAW;AAClB,SAAS,iBAAiB,yBAAyB;AAyC5C,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,QAAQ;AACV,GAAuB;AAGrB,QAAM,SAAS,MAAM,QAAQ,MAAM;AACjC,UAAM,YAA4B;AAAA,MAChC,cAAc,QAAQ,IAAI;AAAA,MAC1B,0BAA2B,QAAQ,IAAI,mCAAmC,SACtE,SACA;AAAA,IACN;AAGA,WAAO,EAAE,GAAG,WAAW,GAAG,WAAW;AAAA,EACvC,GAAG,CAAC,UAAU,CAAC;AAGf,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,oBAAC,qBAAkB,QAAiB,UAAS;AACtD;","names":[]}
|
|
@@ -4,7 +4,7 @@ import { ChipiProvider as ClientChipiProvider } from "../app-router/client/Chipi
|
|
|
4
4
|
function ChipiProvider({
|
|
5
5
|
children,
|
|
6
6
|
apiPublicKey,
|
|
7
|
-
|
|
7
|
+
isInternalChipiDeveloper = "True"
|
|
8
8
|
}) {
|
|
9
9
|
const finalApiPublicKey = apiPublicKey || process.env.NEXT_PUBLIC_CHIPI_API_KEY;
|
|
10
10
|
if (!finalApiPublicKey) {
|
|
@@ -16,7 +16,7 @@ function ChipiProvider({
|
|
|
16
16
|
ClientChipiProvider,
|
|
17
17
|
{
|
|
18
18
|
apiPublicKey: finalApiPublicKey,
|
|
19
|
-
|
|
19
|
+
isInternalChipiDeveloper,
|
|
20
20
|
children
|
|
21
21
|
}
|
|
22
22
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client-boundary/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { ChipiProvider as ClientChipiProvider } from '../app-router/client/ChipiProvider';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/client-boundary/ChipiProvider.tsx"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport { ChipiProvider as ClientChipiProvider } from '../app-router/client/ChipiProvider';\n\nexport interface ChipiProviderProps {\n children: React.ReactNode;\n apiPublicKey?: string;\n isInternalChipiDeveloper?: 'True' | 'False';\n}\n\n/**\n * This is a compatibility layer that provides a client-only ChipiProvider.\n * This is used when the conditional export resolves to the client boundary.\n */\nexport function ChipiProvider({ \n children, \n apiPublicKey,\n isInternalChipiDeveloper = 'True' \n}: ChipiProviderProps) {\n // For client-only usage, allow apiPublicKey to be passed as prop\n // or read from environment\n const finalApiPublicKey = apiPublicKey || process.env.NEXT_PUBLIC_CHIPI_API_KEY;\n\n if (!finalApiPublicKey) {\n throw new Error(\n 'Missing NEXT_PUBLIC_CHIPI_API_KEY environment variable or apiPublicKey prop. Please provide one.'\n );\n }\n\n return (\n <ClientChipiProvider \n apiPublicKey={finalApiPublicKey} \n isInternalChipiDeveloper={isInternalChipiDeveloper}\n >\n {children}\n </ClientChipiProvider>\n );\n}\n"],"mappings":";AA+BI;AA5BJ,SAAS,iBAAiB,2BAA2B;AAY9C,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,2BAA2B;AAC7B,GAAuB;AAGrB,QAAM,oBAAoB,gBAAgB,QAAQ,IAAI;AAEtD,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
package/dist/esm/hooks.js
CHANGED
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
useGetWallet,
|
|
6
6
|
useApprove,
|
|
7
7
|
useTransfer,
|
|
8
|
+
useGetSkus,
|
|
9
|
+
useCreateSkuTransaction,
|
|
10
|
+
useGetSkuTransactionById,
|
|
8
11
|
useStakeVesuUsdc,
|
|
9
12
|
useWithdrawVesuUsdc,
|
|
10
13
|
useCallAnyContract,
|
|
@@ -15,7 +18,10 @@ export {
|
|
|
15
18
|
useApprove,
|
|
16
19
|
useCallAnyContract,
|
|
17
20
|
useChipiContext,
|
|
21
|
+
useCreateSkuTransaction,
|
|
18
22
|
useCreateWallet,
|
|
23
|
+
useGetSkuTransactionById,
|
|
24
|
+
useGetSkus,
|
|
19
25
|
useGetTokenBalance,
|
|
20
26
|
useGetWallet,
|
|
21
27
|
useRecordSendTransaction,
|
package/dist/esm/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks.ts"],"sourcesContent":["\"use client\";\n\n// Client-side hooks for Next.js Chipi SDK\n// These are re-exported from @chipi-stack/chipi-react for convenience\n// This file is marked as 'use client' to ensure it only runs on the client\n\nexport {\n // Context hook\n useChipiContext,\n\n // Wallet hooks\n useCreateWallet,\n useGetWallet,\n\n // Transaction hooks\n useApprove,\n useTransfer,\n\n // SKU hooks\n\n // Specialized transaction hooks\n useStakeVesuUsdc,\n useWithdrawVesuUsdc,\n useCallAnyContract,\n\n // Record send transaction hook\n useRecordSendTransaction,\n\n // Token balance hook\n useGetTokenBalance,\n} from \"@chipi-stack/chipi-react\";\n"],"mappings":";AAMA;AAAA,EAEE;AAAA,EAGA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks.ts"],"sourcesContent":["\"use client\";\n\n// Client-side hooks for Next.js Chipi SDK\n// These are re-exported from @chipi-stack/chipi-react for convenience\n// This file is marked as 'use client' to ensure it only runs on the client\n\nexport {\n // Context hook\n useChipiContext,\n\n // Wallet hooks\n useCreateWallet,\n useGetWallet,\n\n // Transaction hooks\n useApprove,\n useTransfer,\n\n // SKU hooks\n useGetSkus,\n\n\n // SKU Transaction hooks\n useCreateSkuTransaction,\n useGetSkuTransactionById,\n \n\n // Specialized transaction hooks\n useStakeVesuUsdc,\n useWithdrawVesuUsdc,\n useCallAnyContract,\n\n // Record send transaction hook\n useRecordSendTransaction,\n\n // Token balance hook\n useGetTokenBalance,\n} from \"@chipi-stack/chipi-react\";\n"],"mappings":";AAMA;AAAA,EAEE;AAAA,EAGA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EAGA;AAAA,EAIA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EAGA;AAAA,OACK;","names":[]}
|
|
@@ -2,12 +2,12 @@ import { ChipiServerSDK } from "@chipi-stack/backend";
|
|
|
2
2
|
let serverInstance = null;
|
|
3
3
|
function createChipiServer(config) {
|
|
4
4
|
if (!config.apiPublicKey) {
|
|
5
|
-
throw new Error(" apiPublicKey in config");
|
|
5
|
+
throw new Error("Missing apiPublicKey in config");
|
|
6
6
|
}
|
|
7
7
|
if (!config.apiSecretKey) {
|
|
8
8
|
throw new Error("Missing apiSecretKey in config");
|
|
9
9
|
}
|
|
10
|
-
if (config.
|
|
10
|
+
if (config.isInternalChipiDeveloper === "True") {
|
|
11
11
|
return new ChipiServerSDK(config);
|
|
12
12
|
}
|
|
13
13
|
if (!serverInstance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/createChipiServer.ts"],"sourcesContent":["import { ChipiServerSDK, ChipiServerSDKConfig } from \"@chipi-stack/backend\";\n\n/**\n * Global server instance\n */\nlet serverInstance: ChipiServerSDK | null = null;\n\n/**\n * Create or get the Chipi server instance\n * This ensures a singleton pattern for server-side operations\n * Uses only the passed config (no environment variable fallbacks)\n */\nexport function createChipiServer(\n config: ChipiServerSDKConfig\n): ChipiServerSDK {\n // Validate required fields\n if (!config.apiPublicKey) {\n throw new Error(\" apiPublicKey in config\");\n }\n\n if (!config.apiSecretKey) {\n throw new Error(\"Missing apiSecretKey in config\");\n }\n\n // In development, always create a new instance to support hot reloading\n if (config.
|
|
1
|
+
{"version":3,"sources":["../../../src/server/createChipiServer.ts"],"sourcesContent":["import { ChipiServerSDK, ChipiServerSDKConfig } from \"@chipi-stack/backend\";\n\n/**\n * Global server instance\n */\nlet serverInstance: ChipiServerSDK | null = null;\n\n/**\n * Create or get the Chipi server instance\n * This ensures a singleton pattern for server-side operations\n * Uses only the passed config (no environment variable fallbacks)\n */\nexport function createChipiServer(\n config: ChipiServerSDKConfig\n): ChipiServerSDK {\n // Validate required fields\n if (!config.apiPublicKey) {\n throw new Error(\"Missing apiPublicKey in config\");\n }\n\n if (!config.apiSecretKey) {\n throw new Error(\"Missing apiSecretKey in config\");\n }\n\n // In development, always create a new instance to support hot reloading\n if (config.isInternalChipiDeveloper === \"True\") {\n return new ChipiServerSDK(config);\n }\n\n // In production, use singleton pattern\n if (!serverInstance) {\n serverInstance = new ChipiServerSDK(config);\n }\n\n return serverInstance;\n}\n\n/**\n * Get the current server instance\n * Throws an error if no instance has been created\n */\nexport function getChipiServer(): ChipiServerSDK {\n if (!serverInstance) {\n throw new Error(\n \"Chipi server instance not found. Make sure to call createChipiServer() first.\"\n );\n }\n\n return serverInstance;\n}\n\n/**\n * Reset the server instance (useful for testing)\n */\nexport function resetChipiServer(): void {\n serverInstance = null;\n}\n"],"mappings":"AAAA,SAAS,sBAA4C;AAKrD,IAAI,iBAAwC;AAOrC,SAAS,kBACd,QACgB;AAEhB,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,MAAI,CAAC,OAAO,cAAc;AACxB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAGA,MAAI,OAAO,6BAA6B,QAAQ;AAC9C,WAAO,IAAI,eAAe,MAAM;AAAA,EAClC;AAGA,MAAI,CAAC,gBAAgB;AACnB,qBAAiB,IAAI,eAAe,MAAM;AAAA,EAC5C;AAEA,SAAO;AACT;AAMO,SAAS,iBAAiC;AAC/C,MAAI,CAAC,gBAAgB;AACnB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,mBAAyB;AACvC,mBAAiB;AACnB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/setup.ts"],"sourcesContent":["import '@testing-library/jest-dom'\n"],"mappings":"AAAA,OAAO;","names":[]}
|
package/dist/hooks.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
1
|
+
export { useApprove, useCallAnyContract, useChipiContext, useCreateSkuTransaction, useCreateWallet, useGetSkuTransactionById, useGetSkus, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServerComponentsServerModuleTypes } from './components.server.mjs';
|
|
2
2
|
export { ChipiProvider as ChipiClientProvider } from './app-router/client/ChipiProvider.mjs';
|
|
3
|
-
export { useApprove, useCallAnyContract, useChipiContext, useCreateWallet, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
3
|
+
export { useApprove, useCallAnyContract, useChipiContext, useCreateSkuTransaction, useCreateWallet, useGetSkuTransactionById, useGetSkus, useGetTokenBalance, useGetWallet, useRecordSendTransaction, useStakeVesuUsdc, useTransfer, useWithdrawVesuUsdc } from '@chipi-stack/chipi-react';
|
|
4
4
|
export * from '@chipi-stack/types';
|
|
5
5
|
export { createChipiServer, getChipiServer, resetChipiServer } from './server/createChipiServer.mjs';
|
|
6
6
|
import './app-router/server/ChipiProvider.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipi-stack/nextjs",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.0",
|
|
4
4
|
"description": "Chipi SDK for Next.js applications with server-side support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chipi",
|
|
@@ -69,14 +69,15 @@
|
|
|
69
69
|
"react-dom": "^18.3.0",
|
|
70
70
|
"rimraf": "^5.0.0",
|
|
71
71
|
"tsup": "^8.3.6",
|
|
72
|
-
"typescript": "^5.7.3"
|
|
72
|
+
"typescript": "^5.7.3",
|
|
73
|
+
"vitest": "^3.2.4"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
76
|
"@tanstack/react-query": "^5.85.0",
|
|
76
|
-
"@chipi-stack/
|
|
77
|
-
"@chipi-stack/shared": "^11.
|
|
78
|
-
"@chipi-stack/
|
|
79
|
-
"@chipi-stack/
|
|
77
|
+
"@chipi-stack/chipi-react": "^11.8.0",
|
|
78
|
+
"@chipi-stack/shared": "^11.8.0",
|
|
79
|
+
"@chipi-stack/backend": "^11.8.0",
|
|
80
|
+
"@chipi-stack/types": "^11.8.0"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|
|
82
83
|
"next": ">=13.0.0",
|
|
@@ -97,6 +98,10 @@
|
|
|
97
98
|
"format": "prettier --write src/**/*.{ts,tsx}",
|
|
98
99
|
"format:check": "prettier --check src/**/*.{ts,tsx}",
|
|
99
100
|
"lint": "eslint src",
|
|
100
|
-
"typecheck": "tsc --noEmit"
|
|
101
|
+
"typecheck": "tsc --noEmit",
|
|
102
|
+
"test": "vitest run",
|
|
103
|
+
"test:watch": "vitest watch",
|
|
104
|
+
"test:ui": "vitest --ui",
|
|
105
|
+
"test:coverage": "vitest run --coverage"
|
|
101
106
|
}
|
|
102
107
|
}
|