@fanvue/builder-sdk 0.3.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/README.md +427 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core-CvVOMyqr.js +5826 -0
- package/dist/core-CvVOMyqr.js.map +1 -0
- package/dist/index-CweVyIKX.d.ts +48 -0
- package/dist/index-CweVyIKX.d.ts.map +1 -0
- package/dist/index-pS9wR5yg.d.ts +2776 -0
- package/dist/index-pS9wR5yg.d.ts.map +1 -0
- package/dist/nextjs/embedded-app/index.d.ts +105 -0
- package/dist/nextjs/embedded-app/index.d.ts.map +1 -0
- package/dist/nextjs/embedded-app/index.js +162 -0
- package/dist/nextjs/embedded-app/index.js.map +1 -0
- package/dist/nextjs/off-platform/index.d.ts +74 -0
- package/dist/nextjs/off-platform/index.d.ts.map +1 -0
- package/dist/nextjs/off-platform/index.js +257 -0
- package/dist/nextjs/off-platform/index.js.map +1 -0
- package/dist/nextjs-CESI_EiU.js +80 -0
- package/dist/nextjs-CESI_EiU.js.map +1 -0
- package/dist/react/index.d.ts +96 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +192 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { T as HEADER_UPDATED_SESSION, i as getThemeFromUrl, r as getSessionTokenFromUrl, w as BEARER_PREFIX } from "../core-CvVOMyqr.js";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/react/auth-context.tsx
|
|
6
|
+
const STORAGE_KEY = "fanvue:jwt";
|
|
7
|
+
/**
|
|
8
|
+
* Retrieve the JWT from session storage, or `null` if unavailable.
|
|
9
|
+
*
|
|
10
|
+
* Exported for sibling hooks that need a synchronous storage check inside
|
|
11
|
+
* effects (which can run before this provider's mount effect has loaded the
|
|
12
|
+
* stored JWT into state). Not part of the public package API.
|
|
13
|
+
*/
|
|
14
|
+
function getStoredJwt() {
|
|
15
|
+
try {
|
|
16
|
+
return sessionStorage.getItem(STORAGE_KEY);
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Persist the JWT into session storage. */
|
|
22
|
+
function setStoredJwt(jwt) {
|
|
23
|
+
try {
|
|
24
|
+
sessionStorage.setItem(STORAGE_KEY, jwt);
|
|
25
|
+
} catch {}
|
|
26
|
+
}
|
|
27
|
+
/** Remove the JWT from session storage. */
|
|
28
|
+
function removeStoredJwt() {
|
|
29
|
+
try {
|
|
30
|
+
sessionStorage.removeItem(STORAGE_KEY);
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
const AuthContext = createContext(null);
|
|
34
|
+
/**
|
|
35
|
+
* Provides authentication state to the React component tree.
|
|
36
|
+
*
|
|
37
|
+
* Wrap your application (or the authenticated section) with this provider
|
|
38
|
+
* so that descendant components can access auth helpers via {@link useAuth}.
|
|
39
|
+
*/
|
|
40
|
+
function AuthProvider(props) {
|
|
41
|
+
const { children } = props;
|
|
42
|
+
const [jwt, setJwtState] = useState(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const stored = getStoredJwt();
|
|
45
|
+
if (stored !== null) setJwtState(stored);
|
|
46
|
+
}, []);
|
|
47
|
+
const setJwt = useCallback((token) => {
|
|
48
|
+
setStoredJwt(token);
|
|
49
|
+
setJwtState(token);
|
|
50
|
+
}, []);
|
|
51
|
+
const clearJwt = useCallback(() => {
|
|
52
|
+
removeStoredJwt();
|
|
53
|
+
setJwtState(null);
|
|
54
|
+
}, []);
|
|
55
|
+
const authFetch = useCallback(async (input, init) => {
|
|
56
|
+
const currentJwt = getStoredJwt();
|
|
57
|
+
const headers = new Headers(init?.headers);
|
|
58
|
+
if (currentJwt) headers.set("Authorization", `${BEARER_PREFIX}${currentJwt}`);
|
|
59
|
+
const response = await fetch(input, {
|
|
60
|
+
...init,
|
|
61
|
+
headers
|
|
62
|
+
});
|
|
63
|
+
const updatedToken = response.headers.get(HEADER_UPDATED_SESSION);
|
|
64
|
+
if (updatedToken) {
|
|
65
|
+
setStoredJwt(updatedToken);
|
|
66
|
+
setJwtState(updatedToken);
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}, []);
|
|
70
|
+
const value = useMemo(() => ({
|
|
71
|
+
jwt,
|
|
72
|
+
isAuthenticated: jwt != null,
|
|
73
|
+
setJwt,
|
|
74
|
+
clearJwt,
|
|
75
|
+
authFetch
|
|
76
|
+
}), [
|
|
77
|
+
jwt,
|
|
78
|
+
setJwt,
|
|
79
|
+
clearJwt,
|
|
80
|
+
authFetch
|
|
81
|
+
]);
|
|
82
|
+
return /* @__PURE__ */ jsx(AuthContext.Provider, {
|
|
83
|
+
value,
|
|
84
|
+
children
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Access the current authentication context.
|
|
89
|
+
*
|
|
90
|
+
* Must be called from a component that is a descendant of {@link AuthProvider}.
|
|
91
|
+
*
|
|
92
|
+
* @throws {Error} If called outside of an `AuthProvider`.
|
|
93
|
+
*/
|
|
94
|
+
function useAuth() {
|
|
95
|
+
const ctx = useContext(AuthContext);
|
|
96
|
+
if (!ctx) throw new Error("useAuth must be used within an <AuthProvider>");
|
|
97
|
+
return ctx;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/react/use-embedded-auth.ts
|
|
101
|
+
const DEFAULT_EXCHANGE_PATH = "/api/fanvue/session";
|
|
102
|
+
/**
|
|
103
|
+
* Completes embedded authentication when the app is opened inside Fanvue.
|
|
104
|
+
*
|
|
105
|
+
* On mount, reads the short-lived session token that Fanvue appends to the
|
|
106
|
+
* iframe URL (`?token=`), exchanges it with your backend session route
|
|
107
|
+
* (created by `createSessionExchangeHandler`), and stores the returned
|
|
108
|
+
* session JWT in the auth context — after which `authFetch` automatically
|
|
109
|
+
* authenticates your API calls.
|
|
110
|
+
*
|
|
111
|
+
* Must be used inside an `AuthProvider`.
|
|
112
|
+
*
|
|
113
|
+
* @param opts - Optional overrides (e.g. a custom `exchangePath`).
|
|
114
|
+
* @returns The exchange {@link EmbeddedAuthStatus} and error code, if any.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* function EmbeddedHome() {
|
|
118
|
+
* const { status, error, theme } = useEmbeddedAuth();
|
|
119
|
+
* if (status === 'exchanging') return <p>Connecting…</p>;
|
|
120
|
+
* if (status === 'error') return <p>Auth failed: {error}</p>;
|
|
121
|
+
* return <Dashboard theme={theme ?? 'light'} />;
|
|
122
|
+
* }
|
|
123
|
+
*/
|
|
124
|
+
function useEmbeddedAuth(opts) {
|
|
125
|
+
const { isAuthenticated, setJwt } = useAuth();
|
|
126
|
+
const [status, setStatus] = useState(isAuthenticated ? "authenticated" : "idle");
|
|
127
|
+
const [error, setError] = useState(null);
|
|
128
|
+
const [theme, setTheme] = useState(null);
|
|
129
|
+
const startedRef = useRef(false);
|
|
130
|
+
const exchangePath = opts?.exchangePath ?? DEFAULT_EXCHANGE_PATH;
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (startedRef.current) return;
|
|
133
|
+
startedRef.current = true;
|
|
134
|
+
setTheme(getThemeFromUrl(window.location.href));
|
|
135
|
+
if (isAuthenticated || getStoredJwt() !== null) {
|
|
136
|
+
setStatus("authenticated");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const token = getSessionTokenFromUrl(window.location.href);
|
|
140
|
+
if (!token) {
|
|
141
|
+
setStatus("idle");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
setStatus("exchanging");
|
|
145
|
+
(async () => {
|
|
146
|
+
let response;
|
|
147
|
+
try {
|
|
148
|
+
response = await fetch(exchangePath, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
headers: { "Content-Type": "application/json" },
|
|
151
|
+
body: JSON.stringify({ token })
|
|
152
|
+
});
|
|
153
|
+
} catch {
|
|
154
|
+
setError("network_error");
|
|
155
|
+
setStatus("error");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let body;
|
|
159
|
+
try {
|
|
160
|
+
body = await response.json();
|
|
161
|
+
} catch {
|
|
162
|
+
body = null;
|
|
163
|
+
}
|
|
164
|
+
if (!response.ok) {
|
|
165
|
+
setError(body !== null && typeof body === "object" && "error" in body ? String(body.error) : "exchange_failed");
|
|
166
|
+
setStatus("error");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const jwt = body !== null && typeof body === "object" && "jwt" in body ? body.jwt : null;
|
|
170
|
+
if (typeof jwt !== "string" || jwt.length === 0) {
|
|
171
|
+
setError("exchange_failed");
|
|
172
|
+
setStatus("error");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
setJwt(jwt);
|
|
176
|
+
setStatus("authenticated");
|
|
177
|
+
})();
|
|
178
|
+
}, [
|
|
179
|
+
exchangePath,
|
|
180
|
+
isAuthenticated,
|
|
181
|
+
setJwt
|
|
182
|
+
]);
|
|
183
|
+
return {
|
|
184
|
+
status,
|
|
185
|
+
error,
|
|
186
|
+
theme
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { AuthProvider, useAuth, useEmbeddedAuth };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/react/auth-context.tsx","../../src/react/use-embedded-auth.ts"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { BEARER_PREFIX, HEADER_UPDATED_SESSION } from '../core/index.js';\n\nconst STORAGE_KEY = 'fanvue:jwt';\n\n/**\n * Retrieve the JWT from session storage, or `null` if unavailable.\n *\n * Exported for sibling hooks that need a synchronous storage check inside\n * effects (which can run before this provider's mount effect has loaded the\n * stored JWT into state). Not part of the public package API.\n */\nexport function getStoredJwt(): string | null {\n try {\n return sessionStorage.getItem(STORAGE_KEY);\n } catch {\n return null;\n }\n}\n\n/** Persist the JWT into session storage. */\nfunction setStoredJwt(jwt: string): void {\n try {\n sessionStorage.setItem(STORAGE_KEY, jwt);\n } catch {\n // sessionStorage may be unavailable (e.g. sandboxed iframe)\n }\n}\n\n/** Remove the JWT from session storage. */\nfunction removeStoredJwt(): void {\n try {\n sessionStorage.removeItem(STORAGE_KEY);\n } catch {\n // sessionStorage may be unavailable\n }\n}\n\n/**\n * The value exposed by {@link AuthProvider} via React context.\n *\n * Includes the current JWT, authentication status, and helpers for\n * managing credentials and making authenticated requests.\n */\nexport interface AuthContextValue {\n jwt: string | null;\n isAuthenticated: boolean;\n setJwt: (jwt: string) => void;\n clearJwt: () => void;\n authFetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n}\n\nconst AuthContext = createContext<AuthContextValue | null>(null);\n\n/**\n * Provides authentication state to the React component tree.\n *\n * Wrap your application (or the authenticated section) with this provider\n * so that descendant components can access auth helpers via {@link useAuth}.\n */\nexport function AuthProvider(props: { children: ReactNode }): ReactNode {\n const { children } = props;\n // Start at null so the first client render matches the server-rendered HTML\n // (the server can't see sessionStorage); load any stored JWT after mount.\n // Reading storage in the useState initializer causes hydration mismatches\n // (React error #418) whenever a JWT is already stored.\n const [jwt, setJwtState] = useState<string | null>(null);\n\n useEffect(() => {\n const stored = getStoredJwt();\n if (stored !== null) {\n setJwtState(stored);\n }\n }, []);\n\n const setJwt = useCallback((token: string): void => {\n setStoredJwt(token);\n setJwtState(token);\n }, []);\n\n const clearJwt = useCallback((): void => {\n removeStoredJwt();\n setJwtState(null);\n }, []);\n\n const authFetch = useCallback(\n async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const currentJwt = getStoredJwt();\n const headers = new Headers(init?.headers);\n if (currentJwt) {\n headers.set('Authorization', `${BEARER_PREFIX}${currentJwt}`);\n }\n\n const response = await fetch(input, { ...init, headers });\n\n const updatedToken = response.headers.get(HEADER_UPDATED_SESSION);\n if (updatedToken) {\n setStoredJwt(updatedToken);\n setJwtState(updatedToken);\n }\n\n return response;\n },\n [],\n );\n\n const value = useMemo<AuthContextValue>(\n () => ({ jwt, isAuthenticated: jwt != null, setJwt, clearJwt, authFetch }),\n [jwt, setJwt, clearJwt, authFetch],\n );\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n\n/**\n * Access the current authentication context.\n *\n * Must be called from a component that is a descendant of {@link AuthProvider}.\n *\n * @throws {Error} If called outside of an `AuthProvider`.\n */\nexport function useAuth(): AuthContextValue {\n const ctx = useContext(AuthContext);\n if (!ctx) {\n throw new Error('useAuth must be used within an <AuthProvider>');\n }\n return ctx;\n}\n","'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getSessionTokenFromUrl, getThemeFromUrl, type FanvueTheme } from '../core/index.js';\n\nimport { useAuth, getStoredJwt } from './auth-context.js';\n\nconst DEFAULT_EXCHANGE_PATH = '/api/fanvue/session';\n\n/**\n * The state of the embedded session exchange.\n *\n * - `idle` — no session token in the URL (the page was not opened from a\n * Fanvue embedded surface) and no existing session.\n * - `exchanging` — the session token is being exchanged with the backend.\n * - `authenticated` — a session JWT is available; `authFetch` will attach it.\n * - `error` — the exchange failed; see `error` for the cause.\n */\nexport type EmbeddedAuthStatus = 'idle' | 'exchanging' | 'authenticated' | 'error';\n\n/**\n * Options for {@link useEmbeddedAuth}.\n *\n * @property exchangePath - The path of the session-exchange route created by\n * `createSessionExchangeHandler`. Defaults to `/api/fanvue/session`.\n */\nexport interface UseEmbeddedAuthOptions {\n exchangePath?: string;\n}\n\n/**\n * The value returned by {@link useEmbeddedAuth}.\n *\n * @property status - The current state of the embedded session exchange.\n * @property error - The error code when `status` is `error` (e.g.\n * `consent_required`, `invalid_session_token`), otherwise `null`.\n * @property theme - The creator's active colour scheme (`'light'` or `'dark'`)\n * read from the iframe URL, or `null` when absent (e.g. the app was opened\n * outside Fanvue). Use it to theme-match Fanvue.\n */\nexport interface UseEmbeddedAuthResult {\n status: EmbeddedAuthStatus;\n error: string | null;\n theme: FanvueTheme | null;\n}\n\n/**\n * Completes embedded authentication when the app is opened inside Fanvue.\n *\n * On mount, reads the short-lived session token that Fanvue appends to the\n * iframe URL (`?token=`), exchanges it with your backend session route\n * (created by `createSessionExchangeHandler`), and stores the returned\n * session JWT in the auth context — after which `authFetch` automatically\n * authenticates your API calls.\n *\n * Must be used inside an `AuthProvider`.\n *\n * @param opts - Optional overrides (e.g. a custom `exchangePath`).\n * @returns The exchange {@link EmbeddedAuthStatus} and error code, if any.\n *\n * @example\n * function EmbeddedHome() {\n * const { status, error, theme } = useEmbeddedAuth();\n * if (status === 'exchanging') return <p>Connecting…</p>;\n * if (status === 'error') return <p>Auth failed: {error}</p>;\n * return <Dashboard theme={theme ?? 'light'} />;\n * }\n */\nexport function useEmbeddedAuth(opts?: UseEmbeddedAuthOptions): UseEmbeddedAuthResult {\n const { isAuthenticated, setJwt } = useAuth();\n const [status, setStatus] = useState<EmbeddedAuthStatus>(\n isAuthenticated ? 'authenticated' : 'idle',\n );\n const [error, setError] = useState<string | null>(null);\n // Start at null so the first client render matches the server-rendered HTML\n // (the server can't read window.location); read the theme after mount.\n const [theme, setTheme] = useState<FanvueTheme | null>(null);\n const startedRef = useRef(false);\n const exchangePath = opts?.exchangePath ?? DEFAULT_EXCHANGE_PATH;\n\n useEffect(() => {\n // Guard against React Strict Mode double-invocation: the session token is\n // single-use, so the exchange must only run once.\n if (startedRef.current) return;\n startedRef.current = true;\n\n // The theme is read from the URL independently of the (single-use) token\n // exchange, so capture it before any of the auth-status early returns.\n setTheme(getThemeFromUrl(window.location.href));\n\n // Check storage directly as well as context state: this effect runs\n // before the provider's mount effect has loaded any stored JWT, and the\n // session token in the URL is single-use — a re-exchange would fail.\n if (isAuthenticated || getStoredJwt() !== null) {\n setStatus('authenticated');\n return;\n }\n\n const token = getSessionTokenFromUrl(window.location.href);\n if (!token) {\n setStatus('idle');\n return;\n }\n\n setStatus('exchanging');\n\n void (async (): Promise<void> => {\n let response: Response;\n try {\n response = await fetch(exchangePath, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ token }),\n });\n } catch {\n setError('network_error');\n setStatus('error');\n return;\n }\n\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = null;\n }\n\n if (!response.ok) {\n const errorCode =\n body !== null && typeof body === 'object' && 'error' in body\n ? String((body as { error: unknown }).error)\n : 'exchange_failed';\n setError(errorCode);\n setStatus('error');\n return;\n }\n\n const jwt =\n body !== null && typeof body === 'object' && 'jwt' in body\n ? (body as { jwt: unknown }).jwt\n : null;\n if (typeof jwt !== 'string' || jwt.length === 0) {\n setError('exchange_failed');\n setStatus('error');\n return;\n }\n\n setJwt(jwt);\n setStatus('authenticated');\n })();\n }, [exchangePath, isAuthenticated, setJwt]);\n\n return { status, error, theme };\n}\n"],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fanvue/builder-sdk",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "OAuth authentication library for the Fanvue API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/fanvue/builder-sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/fanvue/builder-sdk#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/fanvue/builder-sdk/issues"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/core/index.js",
|
|
17
|
+
"types": "./dist/core/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./nextjs/off-platform": {
|
|
20
|
+
"import": "./dist/nextjs/off-platform/index.js",
|
|
21
|
+
"types": "./dist/nextjs/off-platform/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./nextjs/embedded-app": {
|
|
24
|
+
"import": "./dist/nextjs/embedded-app/index.js",
|
|
25
|
+
"types": "./dist/nextjs/embedded-app/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./react": {
|
|
28
|
+
"import": "./dist/react/index.js",
|
|
29
|
+
"types": "./dist/react/index.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsdown",
|
|
41
|
+
"dev": "tsdown --watch",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"lint": "eslint src/",
|
|
47
|
+
"lint:fix": "eslint src/ --fix",
|
|
48
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
49
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
50
|
+
"check": "pnpm format && pnpm lint && pnpm typecheck && pnpm test:coverage",
|
|
51
|
+
"prepare": "(git config core.hooksPath .hooks || true) && pnpm run build"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"jose": "^6.0.11",
|
|
55
|
+
"neverthrow": "^8.2.0",
|
|
56
|
+
"oauth4webapi": "^3.5.0",
|
|
57
|
+
"zod": "^4.3.6"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@eslint/js": "^10.0.1",
|
|
61
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
62
|
+
"@testing-library/react": "^16.3.2",
|
|
63
|
+
"@types/node": "^25.4.0",
|
|
64
|
+
"@types/react": "^19.0.0",
|
|
65
|
+
"@types/react-dom": "^19.2.3",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
67
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
68
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
69
|
+
"eslint": "^10.0.3",
|
|
70
|
+
"eslint-config-prettier": "^10.1.8",
|
|
71
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
72
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
73
|
+
"jsdom": "^28.1.0",
|
|
74
|
+
"next": "^15.0.0",
|
|
75
|
+
"prettier": "^3.8.1",
|
|
76
|
+
"react": "^19.0.0",
|
|
77
|
+
"tsdown": "^0.21.4",
|
|
78
|
+
"typescript": "^5.7.0",
|
|
79
|
+
"typescript-eslint": "^8.57.0",
|
|
80
|
+
"vitest": "^4.1.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"next": ">=14.0.0",
|
|
84
|
+
"react": ">=18.0.0"
|
|
85
|
+
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"next": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"react": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|