@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,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,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
+ }
@@ -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
- * The type for the useStore hook
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
- * The type for the returned component store result
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 initializer for the store
24
- * @returns The component store result
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
- * A hook that returns a memoized selector function that is deeply equal to the previous selector function.
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 The memoized selector function.
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.10",
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
- "source": "./src/index.ts",
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.1.21",
52
- "@dnd-kit/dom": "^0.1.21",
53
- "@dnd-kit/helpers": "^0.1.21",
54
- "@dnd-kit/react": "^0.1.21",
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
- "@tanstack/react-query": "^5.90.11",
58
- "@xstate/react": "^6.0.0",
59
- "axios": "^1.13.2",
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.0.0",
62
- "jotai": "^2.15.1",
63
- "motion": "^12.23.24",
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.24.0",
66
- "zustand": "^5.0.8",
67
- "@vef-framework/shared": "2.0.10"
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.0"
72
+ "react": "^19.2.4"
71
73
  },
72
74
  "scripts": {
73
75
  "clean": "rimraf dist",
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
-