openxiangda 1.0.56 → 1.0.57
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/package.json +1 -1
- package/packages/sdk/dist/runtime/index.cjs +19 -6
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.mjs +18 -6
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +9 -1
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.mjs +9 -1
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -3316,6 +3316,15 @@ var usePageRoute = () => {
|
|
|
3316
3316
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
3317
3317
|
init_cjs_shims();
|
|
3318
3318
|
var import_react7 = require("react");
|
|
3319
|
+
|
|
3320
|
+
// packages/sdk/src/runtime/core/fetch.ts
|
|
3321
|
+
init_cjs_shims();
|
|
3322
|
+
var createBoundFetch = (fetchImpl) => {
|
|
3323
|
+
const baseFetch = fetchImpl || globalThis.fetch;
|
|
3324
|
+
return ((input, init) => baseFetch.call(globalThis, input, init));
|
|
3325
|
+
};
|
|
3326
|
+
|
|
3327
|
+
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
3319
3328
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3320
3329
|
var OpenXiangdaRuntimeContext = (0, import_react7.createContext)(null);
|
|
3321
3330
|
var OpenXiangdaProvider = ({
|
|
@@ -3324,7 +3333,7 @@ var OpenXiangdaProvider = ({
|
|
|
3324
3333
|
fetchImpl,
|
|
3325
3334
|
children
|
|
3326
3335
|
}) => {
|
|
3327
|
-
const resolvedFetch = fetchImpl
|
|
3336
|
+
const resolvedFetch = (0, import_react7.useMemo)(() => createBoundFetch(fetchImpl), [fetchImpl]);
|
|
3328
3337
|
const resolvedAppType = (0, import_react7.useMemo)(
|
|
3329
3338
|
() => appType || resolveAppTypeFromLocation(),
|
|
3330
3339
|
[appType]
|
|
@@ -3579,7 +3588,7 @@ var parseJsonResponse = async (response) => {
|
|
|
3579
3588
|
};
|
|
3580
3589
|
var createBrowserPageBridge = (options = {}) => {
|
|
3581
3590
|
const servicePrefix = options.servicePrefix || getDefaultServicePrefix();
|
|
3582
|
-
const fetchImpl = options.fetchImpl
|
|
3591
|
+
const fetchImpl = createBoundFetch(options.fetchImpl);
|
|
3583
3592
|
const request = async (payload) => {
|
|
3584
3593
|
if (!payload?.path) {
|
|
3585
3594
|
throw new Error("transport.request \u9700\u8981 path");
|
|
@@ -3705,6 +3714,7 @@ var createBrowserPageContext = (bootstrap, options = {}) => {
|
|
|
3705
3714
|
};
|
|
3706
3715
|
};
|
|
3707
3716
|
var resolveRuntimeAssets = async (bootstrap, fetchImpl = fetch) => {
|
|
3717
|
+
const boundFetch = createBoundFetch(fetchImpl);
|
|
3708
3718
|
const fallback = {
|
|
3709
3719
|
entryUrl: bootstrap.runtimeAssets?.entryUrl || bootstrap.asset?.entryUrl || "",
|
|
3710
3720
|
cssUrls: bootstrap.runtimeAssets?.cssUrls || bootstrap.asset?.cssAssets || [],
|
|
@@ -3717,7 +3727,7 @@ var resolveRuntimeAssets = async (bootstrap, fetchImpl = fetch) => {
|
|
|
3717
3727
|
return fallback;
|
|
3718
3728
|
}
|
|
3719
3729
|
try {
|
|
3720
|
-
const response = await
|
|
3730
|
+
const response = await boundFetch(bootstrap.asset.manifestUrl, {
|
|
3721
3731
|
credentials: "omit"
|
|
3722
3732
|
});
|
|
3723
3733
|
if (!response.ok) return fallback;
|
|
@@ -3752,7 +3762,8 @@ var fetchBrowserRuntimeBootstrap = async ({
|
|
|
3752
3762
|
const path = bootstrapPath || `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3753
3763
|
appType
|
|
3754
3764
|
)}/pages/${encodeURIComponent(pageKey)}/bootstrap`;
|
|
3755
|
-
const
|
|
3765
|
+
const boundFetch = createBoundFetch(fetchImpl);
|
|
3766
|
+
const response = await boundFetch(
|
|
3756
3767
|
joinServicePath(servicePrefix || getDefaultServicePrefix(), path),
|
|
3757
3768
|
{
|
|
3758
3769
|
method: "GET",
|
|
@@ -3787,7 +3798,8 @@ var resolveBrowserRuntimeRoute = async ({
|
|
|
3787
3798
|
const endpoint = resolvePath || `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3788
3799
|
appType
|
|
3789
3800
|
)}/runtime/routes/resolve`;
|
|
3790
|
-
const
|
|
3801
|
+
const boundFetch = createBoundFetch(fetchImpl);
|
|
3802
|
+
const response = await boundFetch(
|
|
3791
3803
|
joinServicePath(servicePrefix || getDefaultServicePrefix(), endpoint),
|
|
3792
3804
|
{
|
|
3793
3805
|
method: "POST",
|
|
@@ -50116,6 +50128,7 @@ var parseRuntimeResponse = async (response) => {
|
|
|
50116
50128
|
return await response.json();
|
|
50117
50129
|
};
|
|
50118
50130
|
var createBuiltinRouteRequest = (servicePrefix = DEFAULT_SERVICE_PREFIX, fetchImpl = fetch) => async (config3) => {
|
|
50131
|
+
const boundFetch = createBoundFetch(fetchImpl);
|
|
50119
50132
|
const headers = new Headers(config3.headers);
|
|
50120
50133
|
let body;
|
|
50121
50134
|
if (config3.data !== void 0) {
|
|
@@ -50126,7 +50139,7 @@ var createBuiltinRouteRequest = (servicePrefix = DEFAULT_SERVICE_PREFIX, fetchIm
|
|
|
50126
50139
|
body = JSON.stringify(config3.data);
|
|
50127
50140
|
}
|
|
50128
50141
|
}
|
|
50129
|
-
const response = await
|
|
50142
|
+
const response = await boundFetch(appendQuery3(joinServicePath2(servicePrefix, config3.url), config3.params), {
|
|
50130
50143
|
method: normalizeMethod3(config3.method),
|
|
50131
50144
|
headers,
|
|
50132
50145
|
body,
|