openxiangda 1.0.90 → 1.0.92

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.
@@ -1314,6 +1314,7 @@ interface OpenXiangdaRuntimeStore extends RuntimeRequestState<RuntimeBootstrap>
1314
1314
  appType: string;
1315
1315
  servicePrefix: string;
1316
1316
  fetchImpl: typeof fetch;
1317
+ baseFetchImpl: typeof fetch;
1317
1318
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1318
1319
  setAccessToken: (accessToken?: string | null) => void;
1319
1320
  }
@@ -1326,6 +1327,7 @@ declare const useAppMenus: () => {
1326
1327
  appType: string;
1327
1328
  servicePrefix: string;
1328
1329
  fetchImpl: typeof fetch;
1330
+ baseFetchImpl: typeof fetch;
1329
1331
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1330
1332
  setAccessToken: (accessToken?: string | null) => void;
1331
1333
  loading: boolean;
@@ -1336,6 +1338,7 @@ declare const usePermission: () => {
1336
1338
  appType: string;
1337
1339
  servicePrefix: string;
1338
1340
  fetchImpl: typeof fetch;
1341
+ baseFetchImpl: typeof fetch;
1339
1342
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1340
1343
  setAccessToken: (accessToken?: string | null) => void;
1341
1344
  loading: boolean;
@@ -1314,6 +1314,7 @@ interface OpenXiangdaRuntimeStore extends RuntimeRequestState<RuntimeBootstrap>
1314
1314
  appType: string;
1315
1315
  servicePrefix: string;
1316
1316
  fetchImpl: typeof fetch;
1317
+ baseFetchImpl: typeof fetch;
1317
1318
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1318
1319
  setAccessToken: (accessToken?: string | null) => void;
1319
1320
  }
@@ -1326,6 +1327,7 @@ declare const useAppMenus: () => {
1326
1327
  appType: string;
1327
1328
  servicePrefix: string;
1328
1329
  fetchImpl: typeof fetch;
1330
+ baseFetchImpl: typeof fetch;
1329
1331
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1330
1332
  setAccessToken: (accessToken?: string | null) => void;
1331
1333
  loading: boolean;
@@ -1336,6 +1338,7 @@ declare const usePermission: () => {
1336
1338
  appType: string;
1337
1339
  servicePrefix: string;
1338
1340
  fetchImpl: typeof fetch;
1341
+ baseFetchImpl: typeof fetch;
1339
1342
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
1340
1343
  setAccessToken: (accessToken?: string | null) => void;
1341
1344
  loading: boolean;
@@ -2480,6 +2480,7 @@ import {
2480
2480
  useContext as useContext2,
2481
2481
  useEffect as useEffect4,
2482
2482
  useMemo as useMemo5,
2483
+ useRef as useRef2,
2483
2484
  useState as useState4
2484
2485
  } from "react";
2485
2486
 
@@ -3324,9 +3325,12 @@ var OpenXiangdaProvider = ({
3324
3325
  [appType]
3325
3326
  );
3326
3327
  const [accessToken, setAccessTokenState] = useState4(null);
3328
+ const accessTokenRef = useRef2(null);
3327
3329
  const setAccessToken = useCallback4(
3328
3330
  (nextAccessToken) => {
3329
- setAccessTokenState(nextAccessToken || null);
3331
+ const normalizedAccessToken = nextAccessToken || null;
3332
+ accessTokenRef.current = normalizedAccessToken;
3333
+ setAccessTokenState(normalizedAccessToken);
3330
3334
  },
3331
3335
  []
3332
3336
  );
@@ -3352,7 +3356,7 @@ var OpenXiangdaProvider = ({
3352
3356
  return;
3353
3357
  }
3354
3358
  setState((prev) => ({ ...prev, loading: true, error: null }));
3355
- const requestFetch = options.accessToken !== void 0 ? createAuthorizedFetch(resolvedFetch, options.accessToken || null) : authorizedFetch;
3359
+ const requestFetch = options.accessToken !== void 0 ? createAuthorizedFetch(resolvedFetch, options.accessToken || null) : createAuthorizedFetch(resolvedFetch, accessTokenRef.current);
3356
3360
  try {
3357
3361
  const response = await requestFetch(
3358
3362
  buildServiceUrl2(
@@ -3386,7 +3390,7 @@ var OpenXiangdaProvider = ({
3386
3390
  error: normalizeRuntimeError(error)
3387
3391
  });
3388
3392
  }
3389
- }, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
3393
+ }, [resolvedAppType, resolvedFetch, servicePrefix]);
3390
3394
  useEffect4(() => {
3391
3395
  void reload();
3392
3396
  }, [reload]);
@@ -3396,10 +3400,11 @@ var OpenXiangdaProvider = ({
3396
3400
  appType: resolvedAppType,
3397
3401
  servicePrefix,
3398
3402
  fetchImpl: authorizedFetch,
3403
+ baseFetchImpl: resolvedFetch,
3399
3404
  reload,
3400
3405
  setAccessToken
3401
3406
  }),
3402
- [authorizedFetch, reload, resolvedAppType, servicePrefix, state]
3407
+ [authorizedFetch, reload, resolvedAppType, resolvedFetch, servicePrefix, state]
3403
3408
  );
3404
3409
  return /* @__PURE__ */ jsx4(OpenXiangdaRuntimeContext.Provider, { value, children });
3405
3410
  };
@@ -4061,14 +4066,14 @@ var usePublicAccess = (options = {}) => {
4061
4066
  const {
4062
4067
  appType: runtimeAppType,
4063
4068
  servicePrefix: runtimeServicePrefix,
4064
- fetchImpl: runtimeFetchImpl,
4069
+ baseFetchImpl: runtimeBaseFetchImpl,
4065
4070
  reload: reloadRuntime,
4066
4071
  setAccessToken
4067
4072
  } = runtime;
4068
4073
  const {
4069
4074
  appType = runtimeAppType,
4070
4075
  servicePrefix = runtimeServicePrefix,
4071
- fetchImpl = runtimeFetchImpl,
4076
+ fetchImpl = runtimeBaseFetchImpl,
4072
4077
  autoStart = true,
4073
4078
  ...sessionInput
4074
4079
  } = options;