@vef-framework/core 2.0.4 → 2.0.5

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 (65) hide show
  1. package/dist/cjs/api/client.cjs +1 -171
  2. package/dist/cjs/api/constants.cjs +1 -13
  3. package/dist/cjs/api/helpers.cjs +1 -12
  4. package/dist/cjs/api/index.cjs +1 -14
  5. package/dist/cjs/auth/helpers.cjs +1 -19
  6. package/dist/cjs/auth/index.cjs +1 -10
  7. package/dist/cjs/common/index.cjs +1 -3
  8. package/dist/cjs/context/api-client.cjs +1 -25
  9. package/dist/cjs/context/app.cjs +1 -15
  10. package/dist/cjs/context/context-selector.cjs +1 -65
  11. package/dist/cjs/context/disabled.cjs +1 -15
  12. package/dist/cjs/context/index.cjs +1 -19
  13. package/dist/cjs/dnd/index.cjs +1 -102
  14. package/dist/cjs/http/client.cjs +1 -445
  15. package/dist/cjs/http/errors.cjs +1 -23
  16. package/dist/cjs/http/helpers.cjs +1 -17
  17. package/dist/cjs/http/index.cjs +1 -17
  18. package/dist/cjs/immer/index.cjs +1 -40
  19. package/dist/cjs/index.cjs +1 -306
  20. package/dist/cjs/motion/features.cjs +1 -13
  21. package/dist/cjs/motion/index.cjs +1 -48
  22. package/dist/cjs/motion/motion-provider.cjs +1 -29
  23. package/dist/cjs/query/constants.cjs +1 -8
  24. package/dist/cjs/query/helpers.cjs +1 -67
  25. package/dist/cjs/query/hooks.cjs +1 -52
  26. package/dist/cjs/query/index.cjs +1 -20
  27. package/dist/cjs/state/index.cjs +1 -41
  28. package/dist/cjs/state-machine/index.cjs +1 -35
  29. package/dist/cjs/store/bound.cjs +1 -42
  30. package/dist/cjs/store/index.cjs +1 -20
  31. package/dist/cjs/store/unbound.cjs +2 -73
  32. package/dist/cjs/store/use-deep.cjs +1 -17
  33. package/dist/es/api/client.js +72 -90
  34. package/dist/es/api/constants.js +7 -8
  35. package/dist/es/api/helpers.js +6 -7
  36. package/dist/es/api/index.js +8 -4
  37. package/dist/es/auth/helpers.js +9 -14
  38. package/dist/es/auth/index.js +4 -2
  39. package/dist/es/common/index.js +1 -1
  40. package/dist/es/context/api-client.js +16 -17
  41. package/dist/es/context/app.js +8 -9
  42. package/dist/es/context/context-selector.js +30 -39
  43. package/dist/es/context/disabled.js +9 -9
  44. package/dist/es/context/index.js +13 -5
  45. package/dist/es/dnd/index.js +30 -7
  46. package/dist/es/http/client.js +173 -253
  47. package/dist/es/http/errors.js +6 -9
  48. package/dist/es/http/helpers.js +10 -10
  49. package/dist/es/http/index.js +11 -4
  50. package/dist/es/immer/index.js +15 -8
  51. package/dist/es/index.js +122 -43
  52. package/dist/es/motion/features.js +4 -2
  53. package/dist/es/motion/index.js +11 -5
  54. package/dist/es/motion/motion-provider.js +15 -17
  55. package/dist/es/query/constants.js +4 -4
  56. package/dist/es/query/helpers.js +40 -45
  57. package/dist/es/query/hooks.js +29 -20
  58. package/dist/es/query/index.js +14 -4
  59. package/dist/es/state/index.js +11 -2
  60. package/dist/es/state-machine/index.js +14 -11
  61. package/dist/es/store/bound.js +24 -26
  62. package/dist/es/store/index.js +11 -5
  63. package/dist/es/store/unbound.js +44 -63
  64. package/dist/es/store/use-deep.js +10 -11
  65. package/package.json +3 -3
@@ -1,42 +1 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const shared = require('@vef-framework/shared');
7
- const zustand = require('zustand');
8
- const middleware = require('zustand/middleware');
9
- const immer = require('zustand/middleware/immer');
10
-
11
- function createStore(initializer) {
12
- const useStore = zustand.create()(
13
- middleware.subscribeWithSelector(
14
- immer.immer(initializer)
15
- )
16
- );
17
- return useStore;
18
- }
19
- function createPersistedStore(initializer, persistenceOptions) {
20
- const {
21
- name,
22
- storage,
23
- selector
24
- } = persistenceOptions;
25
- const useStore = zustand.create()(
26
- middleware.subscribeWithSelector(
27
- middleware.persist(
28
- immer.immer(initializer),
29
- {
30
- name: `__VEF_STORE__${shared.constantCase(name)}__`,
31
- version: 1,
32
- storage: middleware.createJSONStorage(() => storage === "local" ? localStorage : sessionStorage),
33
- partialize: selector ?? shared.identity
34
- }
35
- )
36
- )
37
- );
38
- return useStore;
39
- }
40
-
41
- exports.createPersistedStore = createPersistedStore;
42
- exports.createStore = createStore;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@vef-framework/shared"),s=require("zustand"),e=require("zustand/middleware"),c=require("zustand/middleware/immer");function u(r){return s.create()(e.subscribeWithSelector(c.immer(r)))}function S(r,t){const{name:i,storage:a,selector:n}=t;return s.create()(e.subscribeWithSelector(e.persist(c.immer(r),{name:`__VEF_STORE__${o.constantCase(i)}__`,version:1,storage:e.createJSONStorage(()=>a==="local"?localStorage:sessionStorage),partialize:n??o.identity})))}exports.createPersistedStore=S;exports.createStore=u;
@@ -1,20 +1 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const bound = require('./bound.cjs');
7
- const unbound = require('./unbound.cjs');
8
- const useDeep = require('./use-deep.cjs');
9
- const shallow = require('zustand/shallow');
10
-
11
-
12
-
13
- exports.createPersistedStore = bound.createPersistedStore;
14
- exports.createStore = bound.createStore;
15
- exports.createComponentStore = unbound.createComponentStore;
16
- exports.useDeep = useDeep.useDeep;
17
- Object.defineProperty(exports, "useShallow", {
18
- enumerable: true,
19
- get: () => shallow.useShallow
20
- });
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./bound.cjs"),r=require("./unbound.cjs"),t=require("./use-deep.cjs"),o=require("zustand/shallow");exports.createPersistedStore=e.createPersistedStore;exports.createStore=e.createStore;exports.createComponentStore=r.createComponentStore;exports.useDeep=t.useDeep;Object.defineProperty(exports,"useShallow",{enumerable:!0,get:()=>o.useShallow});
@@ -1,74 +1,3 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- 'use strict';
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@emotion/react/jsx-runtime"),f=require("@vef-framework/shared"),R=require("motion/react"),o=require("react"),l=require("zustand"),g=require("zustand/middleware"),x=require("zustand/middleware/immer"),d=new Map;function q(i,h){const c=`${i}StoreContext`;let r=d.get(c);r||(r=o.createContext(null),r.displayName=c,d.set(c,r));function S(e){const{children:n}=e,t=o.useRef(null),s=o.useRef(!1),u=o.useRef(void 0);return u.current=e.initialState,(!t.current||!s.current)&&(t.current=l.createStore()(g.subscribeWithSelector(x.immer(h))),s.current=!0),R.useIsomorphicLayoutEffect(()=>{f.isPlainObject(u.current)&&t.current&&t.current.setState(p=>{f.mergeWith(p,u.current,!0)})},[]),v.jsx(r,{value:t.current,children:n})}function a(){const e=o.use(r);if(!e){const n=process.env.NODE_ENV==="development",t=`${i}Store is not found in the React context, please check if the store is wrapped in a ${i}StoreProvider`,s=n?`
3
2
 
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const jsxRuntime = require('@emotion/react/jsx-runtime');
7
- const shared = require('@vef-framework/shared');
8
- const react$1 = require('motion/react');
9
- const react = require('react');
10
- const zustand = require('zustand');
11
- const middleware = require('zustand/middleware');
12
- const immer = require('zustand/middleware/immer');
13
-
14
- const contextCache = /* @__PURE__ */ new Map();
15
- function createComponentStore(name, initializer) {
16
- const contextKey = `${name}StoreContext`;
17
- let Context = contextCache.get(contextKey);
18
- if (!Context) {
19
- Context = react.createContext(null);
20
- Context.displayName = contextKey;
21
- contextCache.set(contextKey, Context);
22
- }
23
- function StoreProvider(props) {
24
- const { children } = props;
25
- const storeRef = react.useRef(null);
26
- const storeInitializedRef = react.useRef(false);
27
- const latestInitialStateRef = react.useRef(void 0);
28
- latestInitialStateRef.current = props.initialState;
29
- if (!storeRef.current || !storeInitializedRef.current) {
30
- storeRef.current = zustand.createStore()(
31
- middleware.subscribeWithSelector(
32
- immer.immer(initializer)
33
- )
34
- );
35
- storeInitializedRef.current = true;
36
- }
37
- react$1.useIsomorphicLayoutEffect(() => {
38
- if (!shared.isPlainObject(latestInitialStateRef.current)) {
39
- return;
40
- }
41
- if (storeRef.current) {
42
- storeRef.current.setState((state) => {
43
- shared.mergeWith(
44
- state,
45
- latestInitialStateRef.current,
46
- true
47
- );
48
- });
49
- }
50
- }, []);
51
- return /* @__PURE__ */ jsxRuntime.jsx(Context, { value: storeRef.current, children });
52
- }
53
- function useStoreApi() {
54
- const store = react.use(Context);
55
- if (!store) {
56
- const isDev = process.env.NODE_ENV === "development";
57
- const errorMessage = `${name}Store is not found in the React context, please check if the store is wrapped in a ${name}StoreProvider`;
58
- const devHint = isDev ? "\n\nDev hint: If you're seeing this error after hot reload, it might be a React Fast Refresh issue. Try refreshing the page." : "";
59
- throw new Error(errorMessage + devHint);
60
- }
61
- return store;
62
- }
63
- function useStore(selector) {
64
- const store = useStoreApi();
65
- return zustand.useStore(store, selector);
66
- }
67
- return {
68
- StoreProvider,
69
- useStoreApi,
70
- useStore
71
- };
72
- }
73
-
74
- exports.createComponentStore = createComponentStore;
3
+ Dev hint: If you're seeing this error after hot reload, it might be a React Fast Refresh issue. Try refreshing the page.`:"";throw new Error(t+s)}return e}function m(e){const n=a();return l.useStore(n,e)}return{StoreProvider:S,useStoreApi:a,useStore:m}}exports.createComponentStore=q;
@@ -1,17 +1 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const shared = require('@vef-framework/shared');
7
- const react = require('react');
8
-
9
- function useDeep(selector) {
10
- const prevRef = react.useRef(null);
11
- return (state) => {
12
- const next = selector(state);
13
- return shared.isDeepEqual(prevRef.current, next) ? prevRef.current : prevRef.current = next;
14
- };
15
- }
16
-
17
- exports.useDeep = useDeep;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@vef-framework/shared"),c=require("react");function s(t){const e=c.useRef(null);return u=>{const r=t(u);return n.isDeepEqual(e.current,r)?e.current:e.current=r}}exports.useDeep=s;
@@ -1,66 +1,53 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { isFunction } from '@vef-framework/shared';
3
- import '../http/index.js';
4
- import '../query/index.js';
5
- import { QUERY_CLIENT, PROXIED_METHODS } from './constants.js';
6
- import { createHttpClient } from '../http/helpers.js';
7
- import { createQueryClient } from '../query/helpers.js';
8
-
9
- class ApiClient {
1
+ import { isFunction as o } from "@vef-framework/shared";
2
+ import "../http/index.js";
3
+ import "../query/index.js";
4
+ import { QUERY_CLIENT as y, PROXIED_METHODS as f } from "./constants.js";
5
+ import { createHttpClient as h } from "../http/helpers.js";
6
+ import { createQueryClient as p } from "../query/helpers.js";
7
+ class d {
10
8
  /**
11
9
  * The HTTP client.
12
10
  */
13
- #httpClient;
11
+ #t;
14
12
  /**
15
13
  * The query client.
16
14
  */
17
- #queryClient;
15
+ #e;
18
16
  /**
19
17
  * The current signal.
20
18
  */
21
- #currentSignal;
19
+ #r;
22
20
  /**
23
21
  * The query client.
24
22
  */
25
- get [QUERY_CLIENT]() {
26
- return this.#queryClient;
23
+ get [y]() {
24
+ return this.#e;
27
25
  }
28
26
  /**
29
27
  * Creates a new API client.
30
28
  *
31
29
  * @param options - The options for the API client.
32
30
  */
33
- constructor(options) {
31
+ constructor(e) {
34
32
  const {
35
- http,
36
- query
37
- } = options;
38
- this.#httpClient = createHttpClient(http);
39
- this.#queryClient = createQueryClient(query);
40
- const proxyCache = /* @__PURE__ */ new Map();
41
- this.#httpClient = new Proxy(this.#httpClient, {
42
- get: (target, prop, receiver) => {
43
- const value = Reflect.get(target, prop, receiver);
44
- if (!isFunction(value)) {
45
- return value;
46
- }
47
- if (!proxyCache.has(prop)) {
48
- if (PROXIED_METHODS.includes(prop)) {
49
- proxyCache.set(prop, (url, options2) => value.apply(
50
- target,
51
- [
52
- url,
53
- {
54
- ...options2,
55
- signal: this.#currentSignal
56
- }
57
- ]
58
- ));
59
- } else {
60
- proxyCache.set(prop, (...args) => value.apply(target, args));
61
- }
62
- }
63
- return proxyCache.get(prop);
33
+ http: n,
34
+ query: i
35
+ } = e;
36
+ this.#t = h(n), this.#e = p(i);
37
+ const t = /* @__PURE__ */ new Map();
38
+ this.#t = new Proxy(this.#t, {
39
+ get: (a, r, c) => {
40
+ const s = Reflect.get(a, r, c);
41
+ return o(s) ? (t.has(r) || (f.includes(r) ? t.set(r, (u, l) => s.apply(
42
+ a,
43
+ [
44
+ u,
45
+ {
46
+ ...l,
47
+ signal: this.#r
48
+ }
49
+ ]
50
+ )) : t.set(r, (...u) => s.apply(a, u))), t.get(r)) : s;
64
51
  }
65
52
  });
66
53
  }
@@ -71,34 +58,30 @@ class ApiClient {
71
58
  * @param factory - The factory function.
72
59
  * @returns The query function.
73
60
  */
74
- createQueryFn(key, factory) {
75
- const queryFn = factory(this.#httpClient);
76
- const wrapperFn = (context) => {
61
+ createQueryFn(e, n) {
62
+ const i = n(this.#t), t = (a) => {
77
63
  const {
78
- queryKey,
79
- signal,
80
- pageParam,
81
- meta
82
- } = context;
83
- const [, params] = queryKey;
64
+ queryKey: r,
65
+ signal: c,
66
+ pageParam: s,
67
+ meta: u
68
+ } = a, [, l] = r;
84
69
  try {
85
- this.#currentSignal = signal;
86
- return queryFn(
87
- params,
88
- pageParam,
89
- meta
70
+ return this.#r = c, i(
71
+ l,
72
+ s,
73
+ u
90
74
  );
91
75
  } finally {
92
- this.#currentSignal = void 0;
76
+ this.#r = void 0;
93
77
  }
94
78
  };
95
- Object.defineProperty(wrapperFn, "key", {
96
- value: key,
97
- configurable: false,
98
- writable: false,
99
- enumerable: false
100
- });
101
- return wrapperFn;
79
+ return Object.defineProperty(t, "key", {
80
+ value: e,
81
+ configurable: !1,
82
+ writable: !1,
83
+ enumerable: !1
84
+ }), t;
102
85
  }
103
86
  /**
104
87
  * Creates a new mutation function.
@@ -107,16 +90,14 @@ class ApiClient {
107
90
  * @param factory - The factory function.
108
91
  * @returns The mutation function.
109
92
  */
110
- createMutationFn(key, factory) {
111
- const mutationFn = factory(this.#httpClient);
112
- const wrapperFn = (params) => mutationFn(params);
113
- Object.defineProperty(wrapperFn, "key", {
114
- value: key,
115
- configurable: false,
116
- writable: false,
117
- enumerable: false
118
- });
119
- return wrapperFn;
93
+ createMutationFn(e, n) {
94
+ const i = n(this.#t), t = (a) => i(a);
95
+ return Object.defineProperty(t, "key", {
96
+ value: e,
97
+ configurable: !1,
98
+ writable: !1,
99
+ enumerable: !1
100
+ }), t;
120
101
  }
121
102
  /**
122
103
  * Fetches a query.
@@ -124,8 +105,8 @@ class ApiClient {
124
105
  * @param options - The options for the query.
125
106
  * @returns The result of the query.
126
107
  */
127
- async fetchQuery(options) {
128
- return await this.#queryClient.fetchQuery(options);
108
+ async fetchQuery(e) {
109
+ return await this.#e.fetchQuery(e);
129
110
  }
130
111
  /**
131
112
  * Prefetches a query and stores the result in cache.
@@ -133,8 +114,8 @@ class ApiClient {
133
114
  * @param options - The options for the query.
134
115
  * @returns A promise that resolves when the prefetch is complete.
135
116
  */
136
- async prefetchQuery(options) {
137
- return await this.#queryClient.prefetchQuery(options);
117
+ async prefetchQuery(e) {
118
+ return await this.#e.prefetchQuery(e);
138
119
  }
139
120
  /**
140
121
  * Executes a mutation outside of React components.
@@ -152,16 +133,17 @@ class ApiClient {
152
133
  * @returns A promise that resolves with the mutation result
153
134
  */
154
135
  async executeMutation({
155
- mutationFn,
156
- params,
157
- ...options
136
+ mutationFn: e,
137
+ params: n,
138
+ ...i
158
139
  }) {
159
- return await this.#queryClient.getMutationCache().build(this.#queryClient, {
160
- mutationKey: [mutationFn.key],
161
- mutationFn,
162
- ...options
163
- }).execute(params);
140
+ return await this.#e.getMutationCache().build(this.#e, {
141
+ mutationKey: [e.key],
142
+ mutationFn: e,
143
+ ...i
144
+ }).execute(n);
164
145
  }
165
146
  }
166
-
167
- export { ApiClient };
147
+ export {
148
+ d as ApiClient
149
+ };
@@ -1,8 +1,7 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import '../query/index.js';
3
- import { QUERY_CLIENT_KEY } from '../query/constants.js';
4
-
5
- const PROXIED_METHODS = ["get", "post", "put", "delete", "upload", "download"];
6
- const QUERY_CLIENT = Symbol.for(QUERY_CLIENT_KEY);
7
-
8
- export { PROXIED_METHODS, QUERY_CLIENT };
1
+ import "../query/index.js";
2
+ import { QUERY_CLIENT_KEY as o } from "../query/constants.js";
3
+ const p = ["get", "post", "put", "delete", "upload", "download"], e = Symbol.for(o);
4
+ export {
5
+ p as PROXIED_METHODS,
6
+ e as QUERY_CLIENT
7
+ };
@@ -1,8 +1,7 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { ApiClient } from './client.js';
3
-
4
- function createApiClient(options) {
5
- return new ApiClient(options);
1
+ import { ApiClient as t } from "./client.js";
2
+ function n(e) {
3
+ return new t(e);
6
4
  }
7
-
8
- export { createApiClient };
5
+ export {
6
+ n as createApiClient
7
+ };
@@ -1,4 +1,8 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- export { ApiClient } from './client.js';
3
- export { QUERY_CLIENT } from './constants.js';
4
- export { createApiClient } from './helpers.js';
1
+ import { ApiClient as o } from "./client.js";
2
+ import { QUERY_CLIENT as p } from "./constants.js";
3
+ import { createApiClient as f } from "./helpers.js";
4
+ export {
5
+ o as ApiClient,
6
+ p as QUERY_CLIENT,
7
+ f as createApiClient
8
+ };
@@ -1,15 +1,10 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { isNullish, isString } from '@vef-framework/shared';
3
-
4
- function checkPermission(hasPermission, permTokens, checkMode = "any") {
5
- if (isNullish(permTokens)) {
6
- return true;
7
- }
8
- const normalizedPermTokens = isString(permTokens) ? [permTokens] : permTokens;
9
- if (checkMode === "any") {
10
- return normalizedPermTokens.some((token) => hasPermission(token));
11
- }
12
- return normalizedPermTokens.every((token) => hasPermission(token));
1
+ import { isNullish as u, isString as o } from "@vef-framework/shared";
2
+ function f(t, r, e = "any") {
3
+ if (u(r))
4
+ return !0;
5
+ const n = o(r) ? [r] : r;
6
+ return e === "any" ? n.some((i) => t(i)) : n.every((i) => t(i));
13
7
  }
14
-
15
- export { checkPermission };
8
+ export {
9
+ f as checkPermission
10
+ };
@@ -1,2 +1,4 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- export { checkPermission } from './helpers.js';
1
+ import { checkPermission as r } from "./helpers.js";
2
+ export {
3
+ r as checkPermission
4
+ };
@@ -1 +1 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
1
+
@@ -1,20 +1,19 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { jsx } from '@emotion/react/jsx-runtime';
3
- import { QueryClientProvider } from '@tanstack/react-query';
4
- import { createContext, use } from 'react';
5
- import '../api/index.js';
6
- import { QUERY_CLIENT } from '../api/constants.js';
7
-
8
- const Context = createContext(null);
9
- function ApiClientProvider({ value, children }) {
10
- return /* @__PURE__ */ jsx(Context, { value, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: value[QUERY_CLIENT], children }) });
1
+ import { jsx as r } from "@emotion/react/jsx-runtime";
2
+ import { QueryClientProvider as i } from "@tanstack/react-query";
3
+ import { createContext as n, use as p } from "react";
4
+ import "../api/index.js";
5
+ import { QUERY_CLIENT as l } from "../api/constants.js";
6
+ const e = n(null);
7
+ function s({ value: t, children: o }) {
8
+ return /* @__PURE__ */ r(e, { value: t, children: /* @__PURE__ */ r(i, { client: t[l], children: o }) });
11
9
  }
12
- function useApiClient() {
13
- const apiClient = use(Context);
14
- if (!apiClient) {
10
+ function a() {
11
+ const t = p(e);
12
+ if (!t)
15
13
  throw new Error("No 'ApiClientContext' found in the React app, please use 'ApiClientProvider' to wrap your app.");
16
- }
17
- return apiClient;
14
+ return t;
18
15
  }
19
-
20
- export { ApiClientProvider, useApiClient };
16
+ export {
17
+ s as ApiClientProvider,
18
+ a as useApiClient
19
+ };
@@ -1,10 +1,9 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { createContext, use } from 'react';
3
-
4
- const Context = createContext({});
5
- const AppContextProvider = Context.Provider;
6
- function useAppContext() {
7
- return use(Context);
1
+ import { createContext as e, use as o } from "react";
2
+ const t = e({}), n = t.Provider;
3
+ function p() {
4
+ return o(t);
8
5
  }
9
-
10
- export { AppContextProvider, useAppContext };
6
+ export {
7
+ n as AppContextProvider,
8
+ p as useAppContext
9
+ };
@@ -1,61 +1,52 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { jsx } from '@emotion/react/jsx-runtime';
3
- import { isFunction } from '@vef-framework/shared';
4
- import { createContext, useState, useEffect, use, useSyncExternalStore } from 'react';
5
-
6
- function createContextWithSelector(defaultValue) {
7
- const Context = createContext(createStore(defaultValue));
8
- function Provider({ value, children }) {
9
- const [store] = useState(() => createStore(value));
10
- useEffect(() => {
11
- if (!Object.is(store.value, value)) {
12
- store.value = value;
13
- store.notify();
14
- }
15
- });
16
- return /* @__PURE__ */ jsx(Context, { value: store, children });
1
+ import { jsx as f } from "@emotion/react/jsx-runtime";
2
+ import { isFunction as i } from "@vef-framework/shared";
3
+ import { createContext as a, useState as l, useEffect as x, use as m, useSyncExternalStore as v } from "react";
4
+ function p(u) {
5
+ const n = a(s(u));
6
+ function e({ value: t, children: r }) {
7
+ const [o] = l(() => s(t));
8
+ return x(() => {
9
+ Object.is(o.value, t) || (o.value = t, o.notify());
10
+ }), /* @__PURE__ */ f(n, { value: o, children: r });
17
11
  }
18
- Provider.displayName = "SelectorContextProvider";
19
- function useContext(selector) {
20
- const store = use(Context);
21
- return useSyncExternalStore(
22
- store.subscribe,
12
+ e.displayName = "SelectorContextProvider";
13
+ function c(t) {
14
+ const r = m(n);
15
+ return v(
16
+ r.subscribe,
23
17
  // Get current value, applying selector if provided
24
- () => isFunction(selector) ? selector(store.value) : store.value,
18
+ () => i(t) ? t(r.value) : r.value,
25
19
  // Server-side snapshot (same as client-side for consistency)
26
- () => isFunction(selector) ? selector(store.value) : store.value
20
+ () => i(t) ? t(r.value) : r.value
27
21
  );
28
22
  }
29
23
  return {
30
- Provider,
31
- useContext
24
+ Provider: e,
25
+ useContext: c
32
26
  };
33
27
  }
34
- function createStore(value) {
35
- const listeners = /* @__PURE__ */ new Set();
28
+ function s(u) {
29
+ const n = /* @__PURE__ */ new Set();
36
30
  return {
37
- value,
31
+ value: u,
38
32
  /**
39
33
  * Subscribe to store changes
40
34
  *
41
35
  * @param listener - Function to call when store value changes
42
36
  * @returns Unsubscribe function
43
37
  */
44
- subscribe: (listener) => {
45
- listeners.add(listener);
46
- return () => {
47
- listeners.delete(listener);
48
- };
49
- },
38
+ subscribe: (e) => (n.add(e), () => {
39
+ n.delete(e);
40
+ }),
50
41
  /**
51
42
  * Notify all subscribers that the value has changed
52
43
  */
53
44
  notify: () => {
54
- for (const listener of listeners) {
55
- listener();
56
- }
45
+ for (const e of n)
46
+ e();
57
47
  }
58
48
  };
59
49
  }
60
-
61
- export { createContextWithSelector };
50
+ export {
51
+ p as createContextWithSelector
52
+ };
@@ -1,10 +1,10 @@
1
- /*! @vef-framework/core v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:14.403Z */
2
- import { createContext, use } from 'react';
3
-
4
- const DisabledContext = createContext(false);
5
- function useDisabled() {
6
- return use(DisabledContext);
1
+ import { createContext as t, use as o } from "react";
2
+ const e = t(!1);
3
+ function s() {
4
+ return o(e);
7
5
  }
8
- const DisabledProvider = DisabledContext.Provider;
9
-
10
- export { DisabledProvider, useDisabled };
6
+ const i = e.Provider;
7
+ export {
8
+ i as DisabledProvider,
9
+ s as useDisabled
10
+ };