@vef-framework/core 2.0.10 → 2.1.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.
Files changed (152) hide show
  1. package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/ai/index.cjs +1 -0
  3. package/dist/cjs/api/client.cjs +1 -1
  4. package/dist/cjs/api/constants.cjs +1 -1
  5. package/dist/cjs/api/helpers.cjs +1 -1
  6. package/dist/cjs/api/index.cjs +1 -1
  7. package/dist/cjs/auth/helpers.cjs +1 -1
  8. package/dist/cjs/auth/index.cjs +1 -1
  9. package/dist/cjs/context/api-client.cjs +1 -1
  10. package/dist/cjs/context/app.cjs +1 -1
  11. package/dist/cjs/context/context-selector.cjs +1 -1
  12. package/dist/cjs/context/disabled.cjs +1 -1
  13. package/dist/cjs/context/index.cjs +1 -1
  14. package/dist/cjs/dnd/index.cjs +1 -1
  15. package/dist/cjs/http/client.cjs +1 -1
  16. package/dist/cjs/http/constants.cjs +1 -0
  17. package/dist/cjs/http/errors.cjs +1 -1
  18. package/dist/cjs/http/helpers.cjs +1 -1
  19. package/dist/cjs/http/index.cjs +1 -1
  20. package/dist/cjs/immer/index.cjs +1 -1
  21. package/dist/cjs/index.cjs +1 -1
  22. package/dist/cjs/motion/features.cjs +1 -1
  23. package/dist/cjs/motion/index.cjs +1 -1
  24. package/dist/cjs/motion/motion-provider.cjs +1 -1
  25. package/dist/cjs/query/constants.cjs +1 -1
  26. package/dist/cjs/query/helpers.cjs +1 -1
  27. package/dist/cjs/query/hooks.cjs +1 -1
  28. package/dist/cjs/query/index.cjs +1 -1
  29. package/dist/cjs/sse/client.cjs +1 -0
  30. package/dist/cjs/sse/helpers.cjs +1 -0
  31. package/dist/cjs/sse/index.cjs +1 -0
  32. package/dist/cjs/state/index.cjs +1 -1
  33. package/dist/cjs/state-machine/index.cjs +1 -1
  34. package/dist/cjs/store/bound.cjs +1 -1
  35. package/dist/cjs/store/index.cjs +1 -1
  36. package/dist/cjs/store/unbound.cjs +1 -3
  37. package/dist/cjs/store/use-deep.cjs +1 -1
  38. package/dist/es/ai/index.js +3 -0
  39. package/dist/es/api/client.js +72 -147
  40. package/dist/es/api/constants.js +14 -7
  41. package/dist/es/api/helpers.js +7 -6
  42. package/dist/es/api/index.js +4 -8
  43. package/dist/es/auth/helpers.js +9 -9
  44. package/dist/es/auth/index.js +2 -4
  45. package/dist/es/context/api-client.js +21 -17
  46. package/dist/es/context/app.js +8 -8
  47. package/dist/es/context/context-selector.js +38 -50
  48. package/dist/es/context/disabled.js +9 -9
  49. package/dist/es/context/index.js +5 -13
  50. package/dist/es/dnd/index.js +8 -30
  51. package/dist/es/http/client.js +186 -359
  52. package/dist/es/http/constants.js +5 -0
  53. package/dist/es/http/errors.js +10 -15
  54. package/dist/es/http/helpers.js +8 -11
  55. package/dist/es/http/index.js +5 -11
  56. package/dist/es/immer/index.js +6 -15
  57. package/dist/es/index.js +27 -122
  58. package/dist/es/motion/features.js +3 -4
  59. package/dist/es/motion/index.js +5 -11
  60. package/dist/es/motion/motion-provider.js +22 -21
  61. package/dist/es/query/constants.js +5 -4
  62. package/dist/es/query/helpers.js +40 -54
  63. package/dist/es/query/hooks.js +18 -28
  64. package/dist/es/query/index.js +4 -14
  65. package/dist/es/sse/client.js +121 -0
  66. package/dist/es/sse/helpers.js +8 -0
  67. package/dist/es/sse/index.js +3 -0
  68. package/dist/es/state/index.js +3 -11
  69. package/dist/es/state-machine/index.js +13 -14
  70. package/dist/es/store/bound.js +18 -33
  71. package/dist/es/store/index.js +6 -11
  72. package/dist/es/store/unbound.js +43 -50
  73. package/dist/es/store/use-deep.js +12 -11
  74. package/dist/types/ai/index.d.ts +6 -0
  75. package/dist/types/api/client.d.ts +15 -35
  76. package/dist/types/api/constants.d.ts +7 -3
  77. package/dist/types/api/index.d.ts +1 -1
  78. package/dist/types/auth/helpers.d.ts +5 -5
  79. package/dist/types/auth/index.d.ts +2 -2
  80. package/dist/types/common/index.d.ts +1 -1
  81. package/dist/types/common/types.d.ts +3 -0
  82. package/dist/types/context/api-client.d.ts +9 -10
  83. package/dist/types/context/app.d.ts +9 -1
  84. package/dist/types/context/context-selector.d.ts +7 -19
  85. package/dist/types/context/disabled.d.ts +2 -2
  86. package/dist/types/context/index.d.ts +3 -2
  87. package/dist/types/context/types.d.ts +0 -1
  88. package/dist/types/dnd/index.d.ts +4 -2
  89. package/dist/types/http/client.d.ts +39 -71
  90. package/dist/types/http/constants.d.ts +24 -0
  91. package/dist/types/http/index.d.ts +2 -1
  92. package/dist/types/index.d.ts +4 -2
  93. package/dist/types/motion/index.d.ts +2 -2
  94. package/dist/types/motion/motion-provider.d.ts +8 -3
  95. package/dist/types/query/helpers.d.ts +1 -4
  96. package/dist/types/query/hooks.d.ts +6 -45
  97. package/dist/types/query/types.d.ts +12 -12
  98. package/dist/types/src/ai/index.d.ts +6 -0
  99. package/dist/types/src/api/client.d.ts +55 -0
  100. package/dist/types/src/api/constants.d.ts +12 -0
  101. package/dist/types/src/api/helpers.d.ts +9 -0
  102. package/dist/types/src/api/index.d.ts +4 -0
  103. package/dist/types/src/api/types.d.ts +48 -0
  104. package/dist/types/src/auth/helpers.d.ts +11 -0
  105. package/dist/types/src/auth/index.d.ts +2 -0
  106. package/dist/types/src/auth/types.d.ts +1 -0
  107. package/dist/types/src/common/index.d.ts +1 -0
  108. package/dist/types/src/common/types.d.ts +98 -0
  109. package/dist/types/src/context/api-client.d.ts +17 -0
  110. package/dist/types/src/context/app.d.ts +12 -0
  111. package/dist/types/src/context/context-selector.d.ts +32 -0
  112. package/dist/types/src/context/disabled.d.ts +9 -0
  113. package/dist/types/src/context/index.d.ts +6 -0
  114. package/dist/types/src/context/types.d.ts +26 -0
  115. package/dist/types/src/dnd/index.d.ts +8 -0
  116. package/dist/types/src/http/client.d.ts +112 -0
  117. package/dist/types/src/http/constants.d.ts +24 -0
  118. package/dist/types/src/http/errors.d.ts +14 -0
  119. package/dist/types/src/http/helpers.d.ts +17 -0
  120. package/dist/types/src/http/index.d.ts +5 -0
  121. package/dist/types/src/http/types.d.ts +101 -0
  122. package/dist/types/src/immer/index.d.ts +2 -0
  123. package/dist/types/src/index.d.ts +16 -0
  124. package/dist/types/src/motion/features.d.ts +1 -0
  125. package/dist/types/src/motion/index.d.ts +4 -0
  126. package/dist/types/src/motion/motion-provider.d.ts +10 -0
  127. package/dist/types/src/query/constants.d.ts +1 -0
  128. package/dist/types/src/query/helpers.d.ts +7 -0
  129. package/dist/types/src/query/hooks.d.ts +27 -0
  130. package/dist/types/src/query/index.d.ts +4 -0
  131. package/dist/types/src/query/types.d.ts +51 -0
  132. package/dist/types/src/sse/client.d.ts +16 -0
  133. package/dist/types/src/sse/helpers.d.ts +9 -0
  134. package/dist/types/src/sse/index.d.ts +3 -0
  135. package/dist/types/src/sse/types.d.ts +98 -0
  136. package/dist/types/src/state/index.d.ts +1 -0
  137. package/dist/types/src/state-machine/index.d.ts +15 -0
  138. package/dist/types/src/store/bound.d.ts +28 -0
  139. package/dist/types/src/store/index.d.ts +5 -0
  140. package/dist/types/src/store/types.d.ts +50 -0
  141. package/dist/types/src/store/unbound.d.ts +26 -0
  142. package/dist/types/src/store/use-deep.d.ts +8 -0
  143. package/dist/types/sse/client.d.ts +16 -0
  144. package/dist/types/sse/helpers.d.ts +9 -0
  145. package/dist/types/sse/index.d.ts +3 -0
  146. package/dist/types/sse/types.d.ts +98 -0
  147. package/dist/types/state-machine/index.d.ts +2 -1
  148. package/dist/types/store/unbound.d.ts +6 -6
  149. package/dist/types/store/use-deep.d.ts +4 -3
  150. package/package.json +18 -16
  151. package/dist/cjs/common/index.cjs +0 -1
  152. package/dist/es/common/index.js +0 -1
@@ -0,0 +1,112 @@
1
+ import { AxiosProgressEvent } from 'axios';
2
+ import { ApiResult, HttpClientOptions, RequestOptions } from './types';
3
+ /**
4
+ * The HTTP client.
5
+ */
6
+ export declare class HttpClient {
7
+ #private;
8
+ constructor(options: HttpClientOptions);
9
+ private initInterceptors;
10
+ /**
11
+ * Check if the code matches the target code(s).
12
+ */
13
+ private matchesCode;
14
+ /**
15
+ * Handle the request interceptor.
16
+ */
17
+ private handleRequest;
18
+ /**
19
+ * Handle the request error interceptor.
20
+ */
21
+ private handleRequestError;
22
+ /**
23
+ * Handle the response interceptor.
24
+ */
25
+ private handleResponse;
26
+ /**
27
+ * Handle the response error interceptor.
28
+ */
29
+ private handleResponseError;
30
+ /**
31
+ * Handle 401 unauthorized response.
32
+ */
33
+ private handleUnauthorized;
34
+ /**
35
+ * Log info message using configured handler or console.
36
+ */
37
+ private logInfo;
38
+ /**
39
+ * Log warning message using configured handler or console.
40
+ */
41
+ private logWarning;
42
+ /**
43
+ * Log error message using configured handler or console.
44
+ */
45
+ private logError;
46
+ /**
47
+ * Inject access token into request Authorization header.
48
+ */
49
+ private injectAccessToken;
50
+ /**
51
+ * Replace path parameters in the URL (e.g., /users/:id -> /users/123).
52
+ */
53
+ private replacePathParams;
54
+ /**
55
+ * Ensure the token is refreshed. Can be called proactively by external code
56
+ * (e.g., fetch-based SSE) to refresh token before/after request.
57
+ *
58
+ * @param triggerCallback - Whether to trigger onUnauthenticated callback on failure.
59
+ * @returns True if token refresh succeeded, false otherwise.
60
+ */
61
+ ensureTokenRefreshed(triggerCallback?: boolean): Promise<boolean>;
62
+ /**
63
+ * Try to refresh the token using the provided refresh callback.
64
+ */
65
+ private tryRefreshToken;
66
+ /**
67
+ * Retry the request with refreshed token.
68
+ */
69
+ private retryRequest;
70
+ /**
71
+ * GET request.
72
+ */
73
+ get<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
74
+ params?: P;
75
+ }): Promise<ApiResult<R>>;
76
+ /**
77
+ * POST request.
78
+ */
79
+ post<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
80
+ data?: D;
81
+ params?: P;
82
+ }): Promise<ApiResult<R>>;
83
+ /**
84
+ * PUT request.
85
+ */
86
+ put<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
87
+ data?: D;
88
+ params?: P;
89
+ }): Promise<ApiResult<R>>;
90
+ /**
91
+ * DELETE request.
92
+ */
93
+ delete<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
94
+ params?: P;
95
+ }): Promise<ApiResult<R>>;
96
+ /**
97
+ * Upload file via multipart/form-data.
98
+ */
99
+ upload<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
100
+ params?: P;
101
+ data: FormData;
102
+ onProgress?: (event: AxiosProgressEvent) => void;
103
+ }): Promise<ApiResult<R>>;
104
+ /**
105
+ * Download file as blob and trigger browser download.
106
+ */
107
+ download<P = unknown>(url: string, options?: RequestOptions & {
108
+ params?: P;
109
+ onProgress?: (progress: AxiosProgressEvent) => void;
110
+ filename?: string | ((filename: string) => string);
111
+ }): Promise<void>;
112
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The key for the HTTP client in dependency injection.
3
+ */
4
+ export declare const HTTP_CLIENT_KEY = "__vef_http_client_key";
5
+ /**
6
+ * The regex for path parameters in URLs (e.g., /users/:id).
7
+ */
8
+ export declare const PATH_PARAM_REGEX: RegExp;
9
+ /**
10
+ * The regex for extracting filename from Content-Disposition header.
11
+ */
12
+ export declare const CONTENT_DISPOSITION_FILENAME_REGEX: RegExp;
13
+ /**
14
+ * The header name for skipping authentication.
15
+ */
16
+ export declare const SKIP_AUTH_HEADER = "X-Skip-Authentication";
17
+ /**
18
+ * The header value for skipping authentication.
19
+ */
20
+ export declare const SKIP_AUTH_VALUE = "1";
21
+ /**
22
+ * Default request timeout in milliseconds (30 seconds).
23
+ */
24
+ export declare const DEFAULT_TIMEOUT = 30000;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Business error returned by the API when the response code indicates a business logic failure.
3
+ */
4
+ export declare class BusinessError extends Error {
5
+ /**
6
+ * The business error code from the API response.
7
+ */
8
+ readonly code: number;
9
+ /**
10
+ * The original API response data.
11
+ */
12
+ readonly data?: unknown;
13
+ constructor(code: number, message: string, data?: unknown);
14
+ }
@@ -0,0 +1,17 @@
1
+ import { HttpClientOptions } from './types';
2
+ import { HttpClient } from './client';
3
+ import { BusinessError } from './errors';
4
+ /**
5
+ * Create the http client.
6
+ *
7
+ * @param options - The options for the http client.
8
+ * @returns The http client.
9
+ */
10
+ export declare function createHttpClient(options: HttpClientOptions): Readonly<HttpClient>;
11
+ /**
12
+ * Type guard to check if an error is a BusinessError.
13
+ *
14
+ * @param error - The error to check.
15
+ * @returns True if the error is a BusinessError.
16
+ */
17
+ export declare function isBusinessError(error: unknown): error is BusinessError;
@@ -0,0 +1,5 @@
1
+ export { HttpClient } from './client';
2
+ export { CONTENT_DISPOSITION_FILENAME_REGEX, DEFAULT_TIMEOUT, HTTP_CLIENT_KEY, PATH_PARAM_REGEX, SKIP_AUTH_HEADER, SKIP_AUTH_VALUE, SKIP_AUTH_HEADER as skipAuthenticationHeader, SKIP_AUTH_VALUE as skipAuthenticationValue } from './constants';
3
+ export { BusinessError } from './errors';
4
+ export { createHttpClient, isBusinessError } from './helpers';
5
+ export type * from './types';
@@ -0,0 +1,101 @@
1
+ import { Awaitable, MaybeArray, MaybeUndefined } from '@vef-framework/shared';
2
+ import { AxiosProgressEvent, GenericAbortSignal, RawAxiosRequestHeaders } from 'axios';
3
+ export type ProgressEvent = AxiosProgressEvent;
4
+ /**
5
+ * The result of the API.
6
+ */
7
+ export interface ApiResult<T = unknown> {
8
+ /**
9
+ * The code of the API.
10
+ */
11
+ readonly code: number;
12
+ /**
13
+ * The message of the API.
14
+ */
15
+ readonly message: string;
16
+ /**
17
+ * The data of the API.
18
+ */
19
+ readonly data: T;
20
+ }
21
+ /**
22
+ * The authenticated tokens.
23
+ */
24
+ export interface AuthTokens {
25
+ /**
26
+ * The access token
27
+ */
28
+ accessToken: string;
29
+ /**
30
+ * The refresh token
31
+ */
32
+ refreshToken: string;
33
+ }
34
+ /**
35
+ * The options for the HTTP client.
36
+ */
37
+ export interface HttpClientOptions {
38
+ /**
39
+ * The base URL of the API.
40
+ */
41
+ baseUrl: string;
42
+ /**
43
+ * The timeout of the request.
44
+ */
45
+ timeout?: number;
46
+ /**
47
+ * The function to get the authentication tokens.
48
+ */
49
+ getAuthTokens?: () => Awaitable<MaybeUndefined<Readonly<AuthTokens>>>;
50
+ /**
51
+ * The function to set the authentication tokens.
52
+ */
53
+ setAuthTokens?: (tokens: Readonly<AuthTokens>) => Awaitable<void>;
54
+ /**
55
+ * The function to refresh the authentication tokens.
56
+ * Receives the current tokens and should return new tokens.
57
+ * If refresh fails, the promise should reject.
58
+ */
59
+ refreshToken?: (tokens: Readonly<AuthTokens>) => Awaitable<Readonly<AuthTokens>>;
60
+ /**
61
+ * The codes that are considered as successful.
62
+ */
63
+ okCode?: MaybeArray<number>;
64
+ /**
65
+ * The codes that are considered as authentication token expired.
66
+ */
67
+ tokenExpiredCode?: MaybeArray<number>;
68
+ /**
69
+ * The function to handle the unauthenticated error.
70
+ */
71
+ onUnauthenticated?: () => Awaitable<void>;
72
+ /**
73
+ * The function to handle the access denied error.
74
+ */
75
+ onAccessDenied?: () => Awaitable<void>;
76
+ /**
77
+ * The function to show the info message.
78
+ */
79
+ showInfoMessage?: (message: string) => void;
80
+ /**
81
+ * The function to show the warning message.
82
+ */
83
+ showWarningMessage?: (message: string) => void;
84
+ /**
85
+ * The function to show the error message.
86
+ */
87
+ showErrorMessage?: (message: string) => void;
88
+ }
89
+ /**
90
+ * The options for the request.
91
+ */
92
+ export interface RequestOptions {
93
+ /**
94
+ * The signal for the request.
95
+ */
96
+ signal?: GenericAbortSignal;
97
+ /**
98
+ * The headers for the request.
99
+ */
100
+ headers?: RawAxiosRequestHeaders;
101
+ }
@@ -0,0 +1,2 @@
1
+ export { applyPatches, current as currentState, original as originalState, produce, produceWithPatches } from 'immer';
2
+ export { useImmer, useImmerReducer } from 'use-immer';
@@ -0,0 +1,16 @@
1
+ export * from './ai';
2
+ export { ApiClient, createApiClient, HTTP_CLIENT, QUERY_CLIENT, type ApiClientOptions, type MutationFunction, type QueryFunction, type QueryKey } from './api';
3
+ export { checkPermission, type PermissionCheckMode } from './auth';
4
+ export { type DataOption, type DataOptionWithPinyin, type PaginationParams, type PaginationResult } from './common';
5
+ export { ApiClientProvider, AppContextProvider, createContextWithSelector, DisabledProvider, useApiClient, useAppContext, useDisabled, type AppContext, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context';
6
+ export { AxisModifier, DragDropContext, DragDropProvider, Draggable, DragOverlay, Droppable, KeyboardSensor, moveArrayItem, moveDragItem, PointerSensor, restrictShapeToBoundingRectangle, RestrictToElement, RestrictToHorizontalAxis, RestrictToVerticalAxis, RestrictToWindow, SnapModifier, swapArrayItem, swapDragItem, useDragDropMonitor, useDraggable, useDroppable, useSortable, type DragDropContextProps, type DragDropEventHandlers, type DragDropEvents, type DraggableChildrenFn, type DraggableId, type DraggableLocation, type DraggableProps, type DraggableProvided, type DraggableProvidedDraggableProps, type DraggableProvidedDragHandleProps, type DraggableRubric, type DraggableStateSnapshot, type DroppableId, type DroppableProps, type DroppableProvided, type DroppableProvidedProps, type DroppableStateSnapshot, type DropResult, type OnBeforeCaptureResponder, type OnBeforeDragStartResponder, type OnDragEndResponder, type OnDragStartResponder, type OnDragUpdateResponder } from './dnd';
7
+ export type { ApiResult, AuthTokens, BusinessError, HttpClient, HttpClientOptions, isBusinessError, ProgressEvent, RequestOptions } from './http';
8
+ export { skipAuthenticationHeader, skipAuthenticationValue } from './http';
9
+ export { applyPatches, currentState, originalState, produce, produceWithPatches, useImmer, useImmerReducer } from './immer';
10
+ export { AnimatePresence, LayoutGroup, motion, MotionProvider, Reorder, useDragControls, useInView, type MotionProps, type ResolvedValues, type TargetAndTransition, type Transition, type Variant, type VariantLabels, type Variants } from './motion';
11
+ export { keepPreviousData, matchMutation, matchQuery, skipQueryToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, useQueries, useQuery, useQueryErrorResetBoundary, type DefinedInitialDataOptions, type DefinedUseQueryResult, type InitialDataFunction, type MutationFunctionContext, type MutationMeta, type MutationScope, type PlaceholderDataFunction, type QueryClientOptions, type QueryKeyHashFunction, type QueryMeta, type RefetchOptions, type RetryDelayFunction, type RetryDelayValue, type RetryValue, type ShouldRetryFunction, type SkipQueryToken, type StaleTime, type UndefinedInitialDataOptions, type UseInfiniteQueryOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult } from './query';
12
+ export { createSseClient, SseClient, type SseClientOptions, type SseEventHandlers, type SseMessageEvent, type SseRequestConfig } from './sse';
13
+ export { atom, AtomStoreProvider, createAtomStore, getDefaultAtomStore, useAtom, useAtomStore, useAtomValue, useSetAtom, type Atom, type AtomGetter, type AtomSetter, type ExtractAtomArgs, type ExtractAtomResult, type ExtractAtomValue, type PrimitiveAtom, type SetStateAction, type WritableAtom } from './state';
14
+ export { Actor, createActor, createMachine, updateContext, useActor, useActorRef, type ActorLogic, type ActorOptions, type AnyActorLogic, type AnyMachineSnapshot, type AnyStateMachine, type MachineConfig, type MachineContext, type MachineSnapshot, type RequiredActorOptionsKeys, type SnapshotFrom, type StateMachine } from './state-machine';
15
+ export { createComponentStore, createPersistedStore, createStore, useDeep, useShallow, type PersistenceOptions, type ReturnedComponentStoreResult, type SliceStateCreator, type StoreProviderProps, type UnboundStore, type UseBoundStore, type UseBoundStoreWithPersist, type UseStore } from './store';
16
+ export { clsx, type ClassArray, type ClassDictionary, type ClassValue } from 'clsx';
@@ -0,0 +1 @@
1
+ export { domMax as default } from 'motion/react';
@@ -0,0 +1,4 @@
1
+ export { default as MotionProvider } from './motion-provider.js';
2
+ export type { MotionProps, ResolvedValues, TargetAndTransition, Transition, Variant, VariantLabels, Variants } from 'motion/react';
3
+ export { AnimatePresence, LayoutGroup, Reorder, useDragControls, useInView } from 'motion/react';
4
+ export * as motion from 'motion/react-m';
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ interface MotionProviderProps {
3
+ children: ReactNode;
4
+ }
5
+ /**
6
+ * Motion provider component that wraps the application with LazyMotion and MotionConfig.
7
+ * Uses lazy loading for motion features to optimize bundle size.
8
+ */
9
+ export default function MotionProvider({ children }: MotionProviderProps): ReactNode;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare const QUERY_CLIENT_KEY = "__vef_query_client_key";
@@ -0,0 +1,7 @@
1
+ import { QueryClientOptions } from './types';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ /**
4
+ * Creates a configured QueryClient instance with mutation cache and default options
5
+ */
6
+ export declare function createQueryClient(options?: QueryClientOptions): QueryClient;
7
+ export { keepPreviousData } from '@tanstack/react-query';
@@ -0,0 +1,27 @@
1
+ import { DefinedInitialDataInfiniteOptions, DefinedInitialDataOptions, DefinedUseInfiniteQueryResult, DefinedUseQueryResult, InfiniteData, MutationFilters, MutationState, NoInfer, QueriesResults, QueryFilters, UndefinedInitialDataInfiniteOptions, UndefinedInitialDataOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, useMutationState as useMutationStateInternal, useQueries as useQueriesInternal } from '@tanstack/react-query';
2
+ import { QueryKey } from '../api';
3
+ export declare function useQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = never>(options: DefinedInitialDataOptions<TQueryFnData, Error, TData, QueryKey<TParams>>): DefinedUseQueryResult<NoInfer<TData>, Error>;
4
+ export declare function useQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = never>(options: UndefinedInitialDataOptions<TQueryFnData, Error, TData, QueryKey<TParams>> | UseQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>>): UseQueryResult<NoInfer<TData>, Error>;
5
+ export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): DefinedUseInfiniteQueryResult<TData, Error>;
6
+ export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): UseInfiniteQueryResult<TData, Error>;
7
+ /**
8
+ * Hook for executing multiple queries in parallel
9
+ */
10
+ export declare function useQueries<T extends unknown[], TCombinedResult = QueriesResults<T>>(options: Parameters<typeof useQueriesInternal<T, TCombinedResult>>[0]): TCombinedResult;
11
+ /**
12
+ * Hook for executing mutations with automatic error typing
13
+ */
14
+ export declare function useMutation<TData = unknown, TParams = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, Error, TParams, TOnMutateResult>): UseMutationResult<TData, Error, TParams, TOnMutateResult>;
15
+ /**
16
+ * Hook for accessing mutation state across the application
17
+ */
18
+ export declare function useMutationState<TResult = MutationState>(options?: Parameters<typeof useMutationStateInternal<TResult>>[0]): TResult[];
19
+ /**
20
+ * Hook for getting the count of currently fetching queries
21
+ */
22
+ export declare function useIsFetching(filters?: QueryFilters): number;
23
+ /**
24
+ * Hook for getting the count of currently executing mutations
25
+ */
26
+ export declare function useIsMutating(filters?: MutationFilters): number;
27
+ export { matchMutation, matchQuery, skipToken as skipQueryToken, useQueryErrorResetBoundary } from '@tanstack/react-query';
@@ -0,0 +1,4 @@
1
+ export { QUERY_CLIENT_KEY } from './constants';
2
+ export { createQueryClient, keepPreviousData } from './helpers';
3
+ export { matchMutation, matchQuery, skipQueryToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, useQueries, useQuery, useQueryErrorResetBoundary } from './hooks';
4
+ export type * from './types';
@@ -0,0 +1,51 @@
1
+ import { DefinedInitialDataOptions as DefinedInitialDataOptionsInternal, DefinedUseQueryResult as DefinedUseQueryResultInternal, QueryKeyHashFunction as QueryKeyHashFunctionInternal, UndefinedInitialDataOptions as UndefinedInitialDataOptionsInternal, UseInfiniteQueryOptions as UseInfiniteQueryOptionsInternal, UseMutationResult as UseMutationResultInternal, UseQueryOptions as UseQueryOptionsInternal, UseQueryResult as UseQueryResultInternal } from '@tanstack/react-query';
2
+ import { MaybeUndefined } from '@vef-framework/shared';
3
+ import { QueryKey } from '../api';
4
+ declare module "@tanstack/react-query" {
5
+ interface Register {
6
+ mutationMeta: {
7
+ /**
8
+ * Query keys to invalidate on successful mutation
9
+ */
10
+ invalidates?: Array<QueryKey<never> | QueryKey<unknown>>;
11
+ /**
12
+ * Whether to show success feedback (default: true)
13
+ */
14
+ shouldShowSuccessFeedback?: boolean;
15
+ };
16
+ }
17
+ }
18
+ /**
19
+ * Options for creating a QueryClient instance
20
+ */
21
+ export interface QueryClientOptions {
22
+ /**
23
+ * Time in ms before data is considered stale (default: 5000)
24
+ */
25
+ staleTime?: number;
26
+ /**
27
+ * Time in ms before inactive queries are garbage collected (default: 300000)
28
+ */
29
+ gcTime?: number;
30
+ /**
31
+ * Callback to display success message from mutation response
32
+ */
33
+ showSuccessMessage?: (message: string) => void;
34
+ }
35
+ export type ShouldRetryFunction = (failureCount: number, error: Error) => boolean;
36
+ export type RetryValue = boolean | number | ShouldRetryFunction;
37
+ export type RetryDelayFunction = (failureCount: number, error: Error) => number;
38
+ export type RetryDelayValue = number | RetryDelayFunction;
39
+ export type PlaceholderDataFunction<TData = unknown> = (previousData: MaybeUndefined<TData>) => MaybeUndefined<TData>;
40
+ export interface RefetchOptions {
41
+ cancelRefetch?: boolean;
42
+ }
43
+ export type QueryKeyHashFunction<TParams = never> = QueryKeyHashFunctionInternal<QueryKey<TParams>>;
44
+ export type UseQueryResult<TData = unknown> = UseQueryResultInternal<TData, Error>;
45
+ export type DefinedUseQueryResult<TData = unknown> = DefinedUseQueryResultInternal<TData, Error>;
46
+ export type UseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UseQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
47
+ export type DefinedInitialDataOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = DefinedInitialDataOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
48
+ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UndefinedInitialDataOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
49
+ export type UseInfiniteQueryOptions<TQueryFnData, TData = TQueryFnData, TParams = never, TPageParam = never> = UseInfiniteQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>;
50
+ export type UseMutationResult<TData = unknown, TParams = unknown, TOnMutateResult = unknown> = UseMutationResultInternal<TData, Error, TParams, TOnMutateResult>;
51
+ export type { InitialDataFunction, MutationFunctionContext, MutationMeta, MutationScope, QueryMeta, SkipToken as SkipQueryToken, StaleTime } from '@tanstack/react-query';
@@ -0,0 +1,16 @@
1
+ import { SseClientOptions, SseEventHandlers, SseRequestConfig } from './types';
2
+ /**
3
+ * SSE client wrapper around @microsoft/fetch-event-source.
4
+ */
5
+ export declare class SseClient {
6
+ #private;
7
+ constructor(options?: SseClientOptions);
8
+ /**
9
+ * Start an SSE stream request.
10
+ */
11
+ stream(config: SseRequestConfig, handlers: SseEventHandlers): Promise<void>;
12
+ /**
13
+ * Abort all active stream requests.
14
+ */
15
+ abort(): void;
16
+ }
@@ -0,0 +1,9 @@
1
+ import { SseClientOptions } from './types';
2
+ import { SseClient } from './client';
3
+ /**
4
+ * Create an SSE client instance (factory).
5
+ *
6
+ * @param options - SSE client options.
7
+ * @returns SSE client instance.
8
+ */
9
+ export declare function createSseClient(options: SseClientOptions): SseClient;
@@ -0,0 +1,3 @@
1
+ export { SseClient } from './client';
2
+ export { createSseClient } from './helpers';
3
+ export type * from './types';
@@ -0,0 +1,98 @@
1
+ import { Awaitable, MaybeUndefined } from '@vef-framework/shared';
2
+ import { AuthTokens } from '../http';
3
+ /**
4
+ * SSE client options.
5
+ */
6
+ export interface SseClientOptions {
7
+ /**
8
+ * Retrieve auth tokens (optional, used to auto-inject Authorization header).
9
+ */
10
+ getAuthTokens?: () => Awaitable<MaybeUndefined<Readonly<Pick<AuthTokens, "accessToken">>>>;
11
+ /**
12
+ * Whether to enable automatic retries.
13
+ *
14
+ * @default true
15
+ */
16
+ enableRetry?: boolean;
17
+ /**
18
+ * Maximum retry attempts.
19
+ *
20
+ * @default 3
21
+ */
22
+ maxRetries?: number;
23
+ /**
24
+ * Optional error message handler.
25
+ */
26
+ showErrorMessage?: (message: string) => void;
27
+ /**
28
+ * Callback when token expires (401 response).
29
+ * Return true if token was refreshed and request should be retried.
30
+ * Return false to abort the request.
31
+ */
32
+ onTokenExpired?: () => Awaitable<boolean>;
33
+ }
34
+ /**
35
+ * SSE request configuration.
36
+ */
37
+ export interface SseRequestConfig {
38
+ /**
39
+ * Request URL.
40
+ */
41
+ url: string;
42
+ /**
43
+ * HTTP method.
44
+ *
45
+ * @default "POST"
46
+ */
47
+ method?: "GET" | "POST" | "PUT" | "DELETE";
48
+ /**
49
+ * Request headers.
50
+ */
51
+ headers?: Record<string, string>;
52
+ /**
53
+ * Request body (POST/PUT only).
54
+ */
55
+ body?: string | object;
56
+ /**
57
+ * AbortSignal for canceling the request.
58
+ */
59
+ signal?: AbortSignal;
60
+ }
61
+ /**
62
+ * SSE message event.
63
+ */
64
+ export interface SseMessageEvent {
65
+ /**
66
+ * Event ID.
67
+ */
68
+ id?: string;
69
+ /**
70
+ * Event type.
71
+ */
72
+ event?: string;
73
+ /**
74
+ * Message data.
75
+ */
76
+ data: string;
77
+ }
78
+ /**
79
+ * SSE event handlers.
80
+ */
81
+ export interface SseEventHandlers {
82
+ /**
83
+ * Connection opened callback.
84
+ */
85
+ onOpen?: (response: Response) => Awaitable<void>;
86
+ /**
87
+ * Message received callback.
88
+ */
89
+ onMessage: (event: SseMessageEvent) => void;
90
+ /**
91
+ * Error callback.
92
+ */
93
+ onError?: (error: Error) => void;
94
+ /**
95
+ * Connection closed callback.
96
+ */
97
+ onClose?: () => void;
98
+ }
@@ -0,0 +1 @@
1
+ export { atom, Provider as AtomStoreProvider, createStore as createAtomStore, getDefaultStore as getDefaultAtomStore, useAtom, useStore as useAtomStore, useAtomValue, useSetAtom, type Atom, type Getter as AtomGetter, type Setter as AtomSetter, type ExtractAtomArgs, type ExtractAtomResult, type ExtractAtomValue, type PrimitiveAtom, type SetStateAction, type WritableAtom } from 'jotai';
@@ -0,0 +1,15 @@
1
+ import { ActorOptions, AnyActorLogic, ConditionalRequired, IsNotNever, RequiredActorOptionsKeys, SnapshotFrom, Actor } from 'xstate';
2
+ /**
3
+ * Custom hook for creating and using an XState actor with state selection.
4
+ * Combines actor creation with selector-based state subscription.
5
+ *
6
+ * @param logic - The actor logic (state machine or other actor logic)
7
+ * @param selector - Function to select specific data from the actor's snapshot
8
+ * @param options - Optional actor configuration options
9
+ * @returns A tuple containing [selectedState, sendFunction, actorRef]
10
+ */
11
+ export declare function useActor<TLogic extends AnyActorLogic, TSelected>(logic: TLogic, selector: (snapshot: SnapshotFrom<TLogic>) => TSelected, ...[options]: ConditionalRequired<[
12
+ options?: ActorOptions<TLogic> & Record<RequiredActorOptionsKeys<TLogic>, unknown>
13
+ ], IsNotNever<RequiredActorOptionsKeys<TLogic>>>): [TSelected, Actor<TLogic>["send"], Actor<TLogic>];
14
+ export { useActorRef } from '@xstate/react';
15
+ export { Actor, createActor, createMachine, assign as updateContext, type ActorLogic, type ActorOptions, type AnyActorLogic, type AnyMachineSnapshot, type AnyStateMachine, type MachineConfig, type MachineContext, type MachineSnapshot, type RequiredActorOptionsKeys, type SnapshotFrom, type StateMachine } from 'xstate';
@@ -0,0 +1,28 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { PersistenceOptions, UseBoundStore, UseBoundStoreWithPersist } from './types';
3
+ /**
4
+ * Create a store with the given initializer
5
+ *
6
+ * @param initializer - The initializer for the store
7
+ * @returns The store
8
+ */
9
+ export declare function createStore<TState extends {
10
+ name: string;
11
+ }>(initializer: StateCreator<TState, [
12
+ ["zustand/subscribeWithSelector", never],
13
+ ["zustand/immer", never]
14
+ ], [
15
+ ]>): UseBoundStore<TState>;
16
+ /**
17
+ * Create a persisted store with the given initializer and persistence options
18
+ *
19
+ * @param initializer - The initializer for the store
20
+ * @param persistenceOptions - The persistence options for the store
21
+ * @returns The store
22
+ */
23
+ export declare function createPersistedStore<TState>(initializer: StateCreator<TState, [
24
+ ["zustand/subscribeWithSelector", never],
25
+ ["zustand/persist", unknown],
26
+ ["zustand/immer", never]
27
+ ], [
28
+ ]>, persistenceOptions: PersistenceOptions<TState, unknown>): UseBoundStoreWithPersist<TState>;
@@ -0,0 +1,5 @@
1
+ export { createPersistedStore, createStore } from './bound';
2
+ export type * from './types';
3
+ export { createComponentStore, type ComponentStoreResult as ReturnedComponentStoreResult, type UseStore } from './unbound';
4
+ export { useDeep } from './use-deep';
5
+ export { useShallow } from 'zustand/shallow';
@@ -0,0 +1,50 @@
1
+ import { If, IsNever } from '@vef-framework/shared';
2
+ import { PropsWithChildren } from 'react';
3
+ import { Mutate, StateCreator, StoreApi, UseBoundStore as UseBoundStoreInternal } from 'zustand';
4
+ export type SliceStateCreator<TState, TSlice, TPersist extends boolean = false> = StateCreator<TState, [
5
+ [
6
+ "zustand/subscribeWithSelector",
7
+ never
8
+ ],
9
+ If<TPersist, ["zustand/persist", unknown], never>,
10
+ [
11
+ "zustand/immer",
12
+ never
13
+ ]
14
+ ], [
15
+ If<TPersist, never, ["zustand/immer", never]>
16
+ ], TSlice>;
17
+ export type UnboundStore<TState> = Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]]>;
18
+ export type UseBoundStore<TState> = UseBoundStoreInternal<Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]]>>;
19
+ export type UseBoundStoreWithPersist<TState> = UseBoundStoreInternal<Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/persist", unknown], ["zustand/immer", never]]>>;
20
+ /**
21
+ * The options for the persistence
22
+ */
23
+ export interface PersistenceOptions<TState, TSelectedState = TState> {
24
+ /**
25
+ * The unique name of the store
26
+ */
27
+ name: string;
28
+ /**
29
+ * The storage type of the store
30
+ */
31
+ storage?: "local" | "session";
32
+ /**
33
+ * The selector of the store
34
+ */
35
+ selector?: (state: TState) => TSelectedState;
36
+ }
37
+ /**
38
+ * The props of the store provider
39
+ */
40
+ export type StoreProviderProps<TInitialState> = PropsWithChildren<If<IsNever<TInitialState>, {
41
+ /**
42
+ * The initial state of the store
43
+ */
44
+ initialState?: never;
45
+ }, {
46
+ /**
47
+ * The initial state of the store
48
+ */
49
+ initialState: TInitialState;
50
+ }>>;