@kawaiininja/fetch 1.0.22 → 1.0.23

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.
@@ -14,11 +14,28 @@ export const ApiContext = createContext(null);
14
14
  * Constructs full API URLs from relative paths using the baseUrl.
15
15
  */
16
16
  export function ApiProvider({ config, children }) {
17
- // Ensure valid config structure
18
- const baseUrl = config?.baseUrl || "";
19
- const version = config?.version || "v1";
20
- const debug = !!config?.debug;
21
- const onError = config?.onError;
17
+ // 🛡️ STABILITY: Hash the config to detect REAL changes vs identity shifts
18
+ const configHash = useMemo(() => {
19
+ try {
20
+ return JSON.stringify({
21
+ baseUrl: config?.baseUrl,
22
+ version: config?.version,
23
+ debug: config?.debug,
24
+ // We can't stringify functions, so we use their existence/identity
25
+ hasOnError: !!config?.onError,
26
+ });
27
+ }
28
+ catch {
29
+ return Math.random();
30
+ }
31
+ }, [config?.baseUrl, config?.version, config?.debug, config?.onError]);
32
+ // Extract stable values based on the hash
33
+ const { baseUrl, version, debug, onError } = useMemo(() => ({
34
+ baseUrl: config?.baseUrl || "",
35
+ version: config?.version || "v1",
36
+ debug: !!config?.debug,
37
+ onError: config?.onError,
38
+ }), [configHash]);
22
39
  /**
23
40
  * 🛡️ HYPER-STABLE URL CONSTRUCTOR
24
41
  * Memoized independently of the context value to prevent downstream loop invalidation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kawaiininja/fetch",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Core fetch utility for Onyx Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",