@vef-framework/core 2.0.11 → 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.
- package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/ai/index.cjs +1 -0
- package/dist/cjs/api/client.cjs +1 -1
- package/dist/cjs/api/constants.cjs +1 -1
- package/dist/cjs/api/helpers.cjs +1 -1
- package/dist/cjs/api/index.cjs +1 -1
- package/dist/cjs/auth/helpers.cjs +1 -1
- package/dist/cjs/auth/index.cjs +1 -1
- package/dist/cjs/context/api-client.cjs +1 -1
- package/dist/cjs/context/app.cjs +1 -1
- package/dist/cjs/context/context-selector.cjs +1 -1
- package/dist/cjs/context/disabled.cjs +1 -1
- package/dist/cjs/context/index.cjs +1 -1
- package/dist/cjs/dnd/index.cjs +1 -1
- package/dist/cjs/http/client.cjs +1 -1
- package/dist/cjs/http/constants.cjs +1 -0
- package/dist/cjs/http/errors.cjs +1 -1
- package/dist/cjs/http/helpers.cjs +1 -1
- package/dist/cjs/http/index.cjs +1 -1
- package/dist/cjs/immer/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/motion/features.cjs +1 -1
- package/dist/cjs/motion/index.cjs +1 -1
- package/dist/cjs/motion/motion-provider.cjs +1 -1
- package/dist/cjs/query/constants.cjs +1 -1
- package/dist/cjs/query/helpers.cjs +1 -1
- package/dist/cjs/query/hooks.cjs +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/sse/client.cjs +1 -0
- package/dist/cjs/sse/helpers.cjs +1 -0
- package/dist/cjs/sse/index.cjs +1 -0
- package/dist/cjs/state/index.cjs +1 -1
- package/dist/cjs/state-machine/index.cjs +1 -1
- package/dist/cjs/store/bound.cjs +1 -1
- package/dist/cjs/store/index.cjs +1 -1
- package/dist/cjs/store/unbound.cjs +1 -3
- package/dist/cjs/store/use-deep.cjs +1 -1
- package/dist/es/ai/index.js +3 -0
- package/dist/es/api/client.js +72 -147
- package/dist/es/api/constants.js +14 -7
- package/dist/es/api/helpers.js +7 -6
- package/dist/es/api/index.js +4 -8
- package/dist/es/auth/helpers.js +9 -9
- package/dist/es/auth/index.js +2 -4
- package/dist/es/context/api-client.js +21 -17
- package/dist/es/context/app.js +8 -8
- package/dist/es/context/context-selector.js +38 -50
- package/dist/es/context/disabled.js +9 -9
- package/dist/es/context/index.js +5 -13
- package/dist/es/dnd/index.js +8 -30
- package/dist/es/http/client.js +186 -359
- package/dist/es/http/constants.js +5 -0
- package/dist/es/http/errors.js +10 -15
- package/dist/es/http/helpers.js +8 -11
- package/dist/es/http/index.js +5 -11
- package/dist/es/immer/index.js +6 -15
- package/dist/es/index.js +27 -122
- package/dist/es/motion/features.js +3 -4
- package/dist/es/motion/index.js +5 -11
- package/dist/es/motion/motion-provider.js +22 -21
- package/dist/es/query/constants.js +5 -4
- package/dist/es/query/helpers.js +40 -54
- package/dist/es/query/hooks.js +18 -28
- package/dist/es/query/index.js +4 -14
- package/dist/es/sse/client.js +121 -0
- package/dist/es/sse/helpers.js +8 -0
- package/dist/es/sse/index.js +3 -0
- package/dist/es/state/index.js +3 -11
- package/dist/es/state-machine/index.js +13 -14
- package/dist/es/store/bound.js +18 -33
- package/dist/es/store/index.js +6 -11
- package/dist/es/store/unbound.js +43 -50
- package/dist/es/store/use-deep.js +12 -11
- package/dist/types/ai/index.d.ts +6 -0
- package/dist/types/api/client.d.ts +15 -35
- package/dist/types/api/constants.d.ts +7 -3
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/auth/helpers.d.ts +5 -5
- package/dist/types/auth/index.d.ts +2 -2
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/types.d.ts +3 -0
- package/dist/types/context/api-client.d.ts +9 -10
- package/dist/types/context/app.d.ts +9 -1
- package/dist/types/context/context-selector.d.ts +7 -19
- package/dist/types/context/disabled.d.ts +2 -2
- package/dist/types/context/index.d.ts +3 -2
- package/dist/types/context/types.d.ts +0 -1
- package/dist/types/dnd/index.d.ts +4 -2
- package/dist/types/http/client.d.ts +39 -71
- package/dist/types/http/constants.d.ts +24 -0
- package/dist/types/http/index.d.ts +2 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/motion/index.d.ts +2 -2
- package/dist/types/motion/motion-provider.d.ts +8 -3
- package/dist/types/query/helpers.d.ts +1 -4
- package/dist/types/query/hooks.d.ts +6 -45
- package/dist/types/query/types.d.ts +12 -12
- package/dist/types/src/ai/index.d.ts +6 -0
- package/dist/types/src/api/client.d.ts +55 -0
- package/dist/types/src/api/constants.d.ts +12 -0
- package/dist/types/src/api/helpers.d.ts +9 -0
- package/dist/types/src/api/index.d.ts +4 -0
- package/dist/types/src/api/types.d.ts +48 -0
- package/dist/types/src/auth/helpers.d.ts +11 -0
- package/dist/types/src/auth/index.d.ts +2 -0
- package/dist/types/src/auth/types.d.ts +1 -0
- package/dist/types/src/common/index.d.ts +1 -0
- package/dist/types/src/common/types.d.ts +98 -0
- package/dist/types/src/context/api-client.d.ts +17 -0
- package/dist/types/src/context/app.d.ts +12 -0
- package/dist/types/src/context/context-selector.d.ts +32 -0
- package/dist/types/src/context/disabled.d.ts +9 -0
- package/dist/types/src/context/index.d.ts +6 -0
- package/dist/types/src/context/types.d.ts +26 -0
- package/dist/types/src/dnd/index.d.ts +8 -0
- package/dist/types/src/http/client.d.ts +112 -0
- package/dist/types/src/http/constants.d.ts +24 -0
- package/dist/types/src/http/errors.d.ts +14 -0
- package/dist/types/src/http/helpers.d.ts +17 -0
- package/dist/types/src/http/index.d.ts +5 -0
- package/dist/types/src/http/types.d.ts +101 -0
- package/dist/types/src/immer/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +16 -0
- package/dist/types/src/motion/features.d.ts +1 -0
- package/dist/types/src/motion/index.d.ts +4 -0
- package/dist/types/src/motion/motion-provider.d.ts +10 -0
- package/dist/types/src/query/constants.d.ts +1 -0
- package/dist/types/src/query/helpers.d.ts +7 -0
- package/dist/types/src/query/hooks.d.ts +27 -0
- package/dist/types/src/query/index.d.ts +4 -0
- package/dist/types/src/query/types.d.ts +51 -0
- package/dist/types/src/sse/client.d.ts +16 -0
- package/dist/types/src/sse/helpers.d.ts +9 -0
- package/dist/types/src/sse/index.d.ts +3 -0
- package/dist/types/src/sse/types.d.ts +98 -0
- package/dist/types/src/state/index.d.ts +1 -0
- package/dist/types/src/state-machine/index.d.ts +15 -0
- package/dist/types/src/store/bound.d.ts +28 -0
- package/dist/types/src/store/index.d.ts +5 -0
- package/dist/types/src/store/types.d.ts +50 -0
- package/dist/types/src/store/unbound.d.ts +26 -0
- package/dist/types/src/store/use-deep.d.ts +8 -0
- package/dist/types/sse/client.d.ts +16 -0
- package/dist/types/sse/helpers.d.ts +9 -0
- package/dist/types/sse/index.d.ts +3 -0
- package/dist/types/sse/types.d.ts +98 -0
- package/dist/types/state-machine/index.d.ts +2 -1
- package/dist/types/store/unbound.d.ts +6 -6
- package/dist/types/store/use-deep.d.ts +4 -3
- package/package.json +18 -16
- package/dist/cjs/common/index.cjs +0 -1
- package/dist/es/common/index.js +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { StateCreator } from 'zustand';
|
|
3
|
+
import { StoreProviderProps, UnboundStore } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Hook signature for accessing store state with optional selector
|
|
6
|
+
*/
|
|
7
|
+
export interface UseStore<in out TState> {
|
|
8
|
+
(): TState;
|
|
9
|
+
<TSelected>(selector: (state: TState) => TSelected): NoInfer<TSelected>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Result type returned by createComponentStore
|
|
13
|
+
*/
|
|
14
|
+
export interface ComponentStoreResult<TState, TInitialState extends Partial<TState> = never> {
|
|
15
|
+
StoreProvider: ComponentType<StoreProviderProps<TInitialState>>;
|
|
16
|
+
useStoreApi: <TStrictState extends TState = TState>() => UnboundStore<TStrictState>;
|
|
17
|
+
useStore: UseStore<TState>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a component-scoped store with React Context
|
|
21
|
+
*
|
|
22
|
+
* @param name - The name of the store (used for context display name and error messages)
|
|
23
|
+
* @param initializer - The Zustand state initializer function
|
|
24
|
+
* @returns Object containing StoreProvider, useStoreApi, and useStore
|
|
25
|
+
*/
|
|
26
|
+
export declare function createComponentStore<TState, TInitialState extends Partial<TState> = never>(name: string, initializer: StateCreator<TState, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]], []>): ComponentStoreResult<TState, TInitialState>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a memoized selector that uses deep equality comparison.
|
|
3
|
+
* Returns the previous value if deeply equal to prevent unnecessary re-renders.
|
|
4
|
+
*
|
|
5
|
+
* @param selector - The selector function to memoize
|
|
6
|
+
* @returns A memoized selector function
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDeep<TState, TSelected>(selector: (state: TState) => TSelected): (state: TState) => TSelected;
|
|
@@ -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,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
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ActorOptions, AnyActorLogic, ConditionalRequired, IsNotNever, RequiredActorOptionsKeys, SnapshotFrom, Actor } from 'xstate';
|
|
2
2
|
/**
|
|
3
|
-
* Custom hook for creating and using an XState actor with state selection
|
|
3
|
+
* Custom hook for creating and using an XState actor with state selection.
|
|
4
|
+
* Combines actor creation with selector-based state subscription.
|
|
4
5
|
*
|
|
5
6
|
* @param logic - The actor logic (state machine or other actor logic)
|
|
6
7
|
* @param selector - Function to select specific data from the actor's snapshot
|
|
@@ -2,14 +2,14 @@ import { ComponentType } from 'react';
|
|
|
2
2
|
import { StateCreator } from 'zustand';
|
|
3
3
|
import { StoreProviderProps, UnboundStore } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Hook signature for accessing store state with optional selector
|
|
6
6
|
*/
|
|
7
7
|
export interface UseStore<in out TState> {
|
|
8
8
|
(): TState;
|
|
9
9
|
<TSelected>(selector: (state: TState) => TSelected): NoInfer<TSelected>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Result type returned by createComponentStore
|
|
13
13
|
*/
|
|
14
14
|
export interface ComponentStoreResult<TState, TInitialState extends Partial<TState> = never> {
|
|
15
15
|
StoreProvider: ComponentType<StoreProviderProps<TInitialState>>;
|
|
@@ -17,10 +17,10 @@ export interface ComponentStoreResult<TState, TInitialState extends Partial<TSta
|
|
|
17
17
|
useStore: UseStore<TState>;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Creates a component store
|
|
20
|
+
* Creates a component-scoped store with React Context
|
|
21
21
|
*
|
|
22
|
-
* @param name - The name of the store
|
|
23
|
-
* @param initializer - The
|
|
24
|
-
* @returns
|
|
22
|
+
* @param name - The name of the store (used for context display name and error messages)
|
|
23
|
+
* @param initializer - The Zustand state initializer function
|
|
24
|
+
* @returns Object containing StoreProvider, useStoreApi, and useStore
|
|
25
25
|
*/
|
|
26
26
|
export declare function createComponentStore<TState, TInitialState extends Partial<TState> = never>(name: string, initializer: StateCreator<TState, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]], []>): ComponentStoreResult<TState, TInitialState>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Creates a memoized selector that uses deep equality comparison.
|
|
3
|
+
* Returns the previous value if deeply equal to prevent unnecessary re-renders.
|
|
3
4
|
*
|
|
4
|
-
* @param selector - The selector function to memoize
|
|
5
|
-
* @returns
|
|
5
|
+
* @param selector - The selector function to memoize
|
|
6
|
+
* @returns A memoized selector function
|
|
6
7
|
*/
|
|
7
8
|
export declare function useDeep<TState, TSelected>(selector: (state: TState) => TSelected): (state: TState) => TSelected;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Core features for VEF framework",
|
|
7
7
|
"author": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"
|
|
23
|
+
"vef": "./src/index.ts",
|
|
24
24
|
"import": {
|
|
25
25
|
"types": "./dist/types/index.d.ts",
|
|
26
26
|
"default": "./dist/es/index.js"
|
|
@@ -48,26 +48,28 @@
|
|
|
48
48
|
"react": ">=19"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@dnd-kit/abstract": "^0.
|
|
52
|
-
"@dnd-kit/dom": "^0.
|
|
53
|
-
"@dnd-kit/helpers": "^0.
|
|
54
|
-
"@dnd-kit/react": "^0.
|
|
51
|
+
"@dnd-kit/abstract": "^0.3.2",
|
|
52
|
+
"@dnd-kit/dom": "^0.3.2",
|
|
53
|
+
"@dnd-kit/helpers": "^0.3.2",
|
|
54
|
+
"@dnd-kit/react": "^0.3.2",
|
|
55
55
|
"@emotion/react": "^11.14.0",
|
|
56
56
|
"@hello-pangea/dnd": "^18.0.1",
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
57
|
+
"@microsoft/fetch-event-source": "^2.0.1",
|
|
58
|
+
"@tanstack/react-query": "^5.95.2",
|
|
59
|
+
"@xstate/react": "^6.1.0",
|
|
60
|
+
"ai": "6.0.138",
|
|
61
|
+
"axios": "^1.13.6",
|
|
60
62
|
"clsx": "^2.1.1",
|
|
61
|
-
"immer": "^11.
|
|
62
|
-
"jotai": "^2.
|
|
63
|
-
"motion": "^12.
|
|
63
|
+
"immer": "^11.1.4",
|
|
64
|
+
"jotai": "^2.19.0",
|
|
65
|
+
"motion": "^12.38.0",
|
|
64
66
|
"use-immer": "^0.11.0",
|
|
65
|
-
"xstate": "^5.
|
|
66
|
-
"zustand": "^5.0.
|
|
67
|
-
"@vef-framework/shared": "2.0
|
|
67
|
+
"xstate": "^5.29.0",
|
|
68
|
+
"zustand": "^5.0.12",
|
|
69
|
+
"@vef-framework/shared": "2.1.0"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
|
-
"react": "^19.2.
|
|
72
|
+
"react": "^19.2.4"
|
|
71
73
|
},
|
|
72
74
|
"scripts": {
|
|
73
75
|
"clean": "rimraf dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/es/common/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|