@readyfor/api-client-base 1.22.0-pr1284.8c3c6e8 → 1.22.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.
- package/dist/apiClientConfigStore.d.ts +10 -11
- package/dist/apiClientConfigStore.js +37 -10
- package/dist/apiClientConfigStore.mjs +12 -9
- package/dist/apiError.d.ts +25 -24
- package/dist/apiError.js +95 -68
- package/dist/apiError.mjs +18 -70
- package/dist/chunk-3SEO7S3Q.mjs +23 -0
- package/dist/chunk-5JS6U5IM.mjs +37 -0
- package/dist/chunk-DH33ZDBG.mjs +19 -0
- package/dist/chunk-FNLUAQWC.mjs +80 -0
- package/dist/chunk-GD4RTKUU.mjs +22 -0
- package/dist/chunk-JCZWXJBU.mjs +10 -0
- package/dist/chunk-NOC6G3HZ.mjs +21 -0
- package/dist/chunk-NYICHGY2.mjs +30 -0
- package/dist/chunk-OVR3ZT2S.mjs +118 -0
- package/dist/chunk-QXFPBYPL.mjs +25 -0
- package/dist/chunk-TZUKIYFN.mjs +14 -0
- package/dist/chunk-WBQAMGXK.mjs +0 -0
- package/dist/fetcher.d.ts +7 -8
- package/dist/fetcher.js +125 -57
- package/dist/fetcher.mjs +20 -63
- package/dist/index.d.ts +10 -10
- package/dist/index.js +38 -31
- package/dist/index.mjs +63 -10
- package/dist/react/ApiClientConfigProvider.d.ts +9 -10
- package/dist/react/ApiClientConfigProvider.js +41 -24
- package/dist/react/ApiClientConfigProvider.mjs +12 -22
- package/dist/react/index.d.ts +7 -4
- package/dist/react/index.js +26 -10
- package/dist/react/index.mjs +24 -4
- package/dist/react/swr.d.ts +9 -10
- package/dist/react/swr.js +37 -24
- package/dist/react/swr.mjs +5 -25
- package/dist/react/useApiClientConfig.d.ts +5 -5
- package/dist/react/useApiClientConfig.js +50 -18
- package/dist/react/useApiClientConfig.mjs +15 -19
- package/dist/requestUrl.d.ts +2 -3
- package/dist/requestUrl.js +49 -14
- package/dist/requestUrl.mjs +10 -13
- package/dist/store.d.ts +5 -6
- package/dist/store.js +43 -20
- package/dist/store.mjs +5 -20
- package/dist/types.d.ts +11 -5
- package/dist/types.js +16 -0
- package/dist/types.mjs +1 -1
- package/dist/utils/headersInit.d.ts +2 -3
- package/dist/utils/headersInit.js +49 -45
- package/dist/utils/headersInit.mjs +7 -46
- package/dist/utils/requestInit.d.ts +3 -10
- package/dist/utils/requestInit.js +31 -14
- package/dist/utils/requestInit.mjs +7 -15
- package/dist/zod.d.ts +3 -4
- package/dist/zod.js +30 -6
- package/dist/zod.mjs +7 -6
- package/package.json +18 -3
- package/dist/_virtual/_rolldown/runtime.js +0 -23
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import {
|
|
2
|
+
createBlobFetcher,
|
|
3
|
+
createFileOrBlobFetcher,
|
|
4
|
+
createJsonFetcher,
|
|
5
|
+
createTextFetcher,
|
|
6
|
+
createVoidFetcher
|
|
7
|
+
} from "./chunk-OVR3ZT2S.mjs";
|
|
8
|
+
import {
|
|
9
|
+
HTTPError,
|
|
10
|
+
errorStatusCode,
|
|
11
|
+
errorTitle,
|
|
12
|
+
getErrorStatus,
|
|
13
|
+
getHttpErrorBody,
|
|
14
|
+
getHttpErrorBodyReason,
|
|
15
|
+
isHttpErrorWithStatus
|
|
16
|
+
} from "./chunk-FNLUAQWC.mjs";
|
|
17
|
+
import {
|
|
18
|
+
__internal__requestUrl
|
|
19
|
+
} from "./chunk-GD4RTKUU.mjs";
|
|
20
|
+
import {
|
|
21
|
+
buildRequestInitWithDefaultConfig,
|
|
22
|
+
setApiClientConfig,
|
|
23
|
+
store
|
|
24
|
+
} from "./chunk-NOC6G3HZ.mjs";
|
|
25
|
+
import {
|
|
26
|
+
mergeRequestInit
|
|
27
|
+
} from "./chunk-TZUKIYFN.mjs";
|
|
28
|
+
import {
|
|
29
|
+
mergeHeadersInit,
|
|
30
|
+
toHeadersInit
|
|
31
|
+
} from "./chunk-NYICHGY2.mjs";
|
|
32
|
+
import {
|
|
33
|
+
createStore
|
|
34
|
+
} from "./chunk-3SEO7S3Q.mjs";
|
|
35
|
+
import "./chunk-WBQAMGXK.mjs";
|
|
36
|
+
import {
|
|
37
|
+
isZodError,
|
|
38
|
+
schemaForType
|
|
39
|
+
} from "./chunk-JCZWXJBU.mjs";
|
|
40
|
+
export {
|
|
41
|
+
HTTPError,
|
|
42
|
+
__internal__requestUrl,
|
|
43
|
+
buildRequestInitWithDefaultConfig,
|
|
44
|
+
createBlobFetcher,
|
|
45
|
+
createFileOrBlobFetcher,
|
|
46
|
+
createJsonFetcher,
|
|
47
|
+
createStore,
|
|
48
|
+
createTextFetcher,
|
|
49
|
+
createVoidFetcher,
|
|
50
|
+
errorStatusCode,
|
|
51
|
+
errorTitle,
|
|
52
|
+
getErrorStatus,
|
|
53
|
+
getHttpErrorBody,
|
|
54
|
+
getHttpErrorBodyReason,
|
|
55
|
+
isHttpErrorWithStatus,
|
|
56
|
+
isZodError,
|
|
57
|
+
mergeHeadersInit,
|
|
58
|
+
mergeRequestInit,
|
|
59
|
+
schemaForType,
|
|
60
|
+
setApiClientConfig,
|
|
61
|
+
store,
|
|
62
|
+
toHeadersInit
|
|
63
|
+
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Config } from
|
|
3
|
-
import {
|
|
4
|
-
import { SWRConfiguration } from
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { Config } from '../apiClientConfigStore.js';
|
|
3
|
+
import { Store } from '../store.js';
|
|
4
|
+
import { SWRConfiguration } from 'swr';
|
|
5
5
|
|
|
6
|
-
//#region src/react/ApiClientConfigProvider.d.ts
|
|
7
6
|
type Configuration = Config & {
|
|
8
|
-
|
|
7
|
+
swr?: SWRConfiguration;
|
|
9
8
|
};
|
|
10
9
|
type Props = {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
config: Configuration;
|
|
11
|
+
children: ReactNode;
|
|
13
12
|
};
|
|
14
13
|
declare const ApiClientConfigProvider: FC<Props>;
|
|
15
14
|
declare const useApiClientConfigContext: () => Store<Config>;
|
|
16
|
-
|
|
17
|
-
export { ApiClientConfigProvider, useApiClientConfigContext };
|
|
15
|
+
|
|
16
|
+
export { ApiClientConfigProvider, useApiClientConfigContext };
|
|
@@ -1,26 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ApiClientConfigProvider_exports = {};
|
|
20
|
+
__export(ApiClientConfigProvider_exports, {
|
|
21
|
+
ApiClientConfigProvider: () => ApiClientConfigProvider,
|
|
22
|
+
useApiClientConfigContext: () => useApiClientConfigContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ApiClientConfigProvider_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_apiClientConfigStore = require("../apiClientConfigStore");
|
|
28
|
+
var import_swr = require("swr");
|
|
29
|
+
var import_swr2 = require("./swr");
|
|
30
|
+
const ApiClientConfigContext = (0, import_react.createContext)(import_apiClientConfigStore.store);
|
|
10
31
|
const ApiClientConfigProvider = (props) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value: require_apiClientConfigStore.store,
|
|
17
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(swr.SWRConfig, {
|
|
18
|
-
value: require_react_swr.createSwrConfig(swr$1),
|
|
19
|
-
children: props.children
|
|
20
|
-
})
|
|
21
|
-
});
|
|
32
|
+
const { swr, ...config } = props.config;
|
|
33
|
+
(0, import_react.useEffect)(() => {
|
|
34
|
+
import_apiClientConfigStore.store.setState(() => config);
|
|
35
|
+
}, [config]);
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ApiClientConfigContext.Provider, { value: import_apiClientConfigStore.store, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_swr.SWRConfig, { value: (0, import_swr2.createSwrConfig)(swr), children: props.children }) });
|
|
22
37
|
};
|
|
23
|
-
const useApiClientConfigContext = () => (0,
|
|
24
|
-
|
|
25
|
-
exports
|
|
26
|
-
|
|
38
|
+
const useApiClientConfigContext = () => (0, import_react.useContext)(ApiClientConfigContext) || import_apiClientConfigStore.store;
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
ApiClientConfigProvider,
|
|
42
|
+
useApiClientConfigContext
|
|
43
|
+
});
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return /* @__PURE__ */ jsx(ApiClientConfigContext.Provider, {
|
|
14
|
-
value: store,
|
|
15
|
-
children: /* @__PURE__ */ jsx(SWRConfig, {
|
|
16
|
-
value: createSwrConfig(swr),
|
|
17
|
-
children: props.children
|
|
18
|
-
})
|
|
19
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
ApiClientConfigProvider,
|
|
3
|
+
useApiClientConfigContext
|
|
4
|
+
} from "../chunk-QXFPBYPL.mjs";
|
|
5
|
+
import "../chunk-DH33ZDBG.mjs";
|
|
6
|
+
import "../chunk-NOC6G3HZ.mjs";
|
|
7
|
+
import "../chunk-TZUKIYFN.mjs";
|
|
8
|
+
import "../chunk-NYICHGY2.mjs";
|
|
9
|
+
import "../chunk-3SEO7S3Q.mjs";
|
|
10
|
+
export {
|
|
11
|
+
ApiClientConfigProvider,
|
|
12
|
+
useApiClientConfigContext
|
|
20
13
|
};
|
|
21
|
-
const useApiClientConfigContext = () => useContext(ApiClientConfigContext) || store;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ApiClientConfigProvider, useApiClientConfigContext };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export { ApiClientConfigProvider, useApiClientConfigContext } from './ApiClientConfigProvider.js';
|
|
2
|
+
export { Configuration, createSwrConfig } from './swr.js';
|
|
3
|
+
export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } from './useApiClientConfig.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../apiClientConfigStore.js';
|
|
6
|
+
import '../store.js';
|
|
7
|
+
import 'swr';
|
package/dist/react/index.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var react_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(react_exports);
|
|
18
|
+
__reExport(react_exports, require("./ApiClientConfigProvider"), module.exports);
|
|
19
|
+
__reExport(react_exports, require("./swr"), module.exports);
|
|
20
|
+
__reExport(react_exports, require("./useApiClientConfig"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./ApiClientConfigProvider"),
|
|
24
|
+
...require("./swr"),
|
|
25
|
+
...require("./useApiClientConfig")
|
|
26
|
+
});
|
package/dist/react/index.mjs
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
useApiClientConfig,
|
|
3
|
+
useApiClientConfigWithSelector,
|
|
4
|
+
useRequestInit
|
|
5
|
+
} from "../chunk-5JS6U5IM.mjs";
|
|
6
|
+
import {
|
|
7
|
+
ApiClientConfigProvider,
|
|
8
|
+
useApiClientConfigContext
|
|
9
|
+
} from "../chunk-QXFPBYPL.mjs";
|
|
10
|
+
import {
|
|
11
|
+
createSwrConfig
|
|
12
|
+
} from "../chunk-DH33ZDBG.mjs";
|
|
13
|
+
import "../chunk-NOC6G3HZ.mjs";
|
|
14
|
+
import "../chunk-TZUKIYFN.mjs";
|
|
15
|
+
import "../chunk-NYICHGY2.mjs";
|
|
16
|
+
import "../chunk-3SEO7S3Q.mjs";
|
|
17
|
+
export {
|
|
18
|
+
ApiClientConfigProvider,
|
|
19
|
+
createSwrConfig,
|
|
20
|
+
useApiClientConfig,
|
|
21
|
+
useApiClientConfigContext,
|
|
22
|
+
useApiClientConfigWithSelector,
|
|
23
|
+
useRequestInit
|
|
24
|
+
};
|
package/dist/react/swr.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { SWRConfiguration } from
|
|
1
|
+
import { SWRConfiguration } from 'swr';
|
|
2
2
|
|
|
3
|
-
//#region src/react/swr.d.ts
|
|
4
3
|
type Configuration<T> = SWRConfiguration<T> & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
/**
|
|
5
|
+
* fetchを止めるかどうかのオプション
|
|
6
|
+
* trueの場合: useSWRの第一引数にnullが渡されます
|
|
7
|
+
* false,または未指定の場合: useSWRの第一引数にURLが渡されます
|
|
8
|
+
*/
|
|
9
|
+
shouldNotFetch?: boolean;
|
|
11
10
|
};
|
|
12
11
|
declare const createSwrConfig: (config?: SWRConfiguration) => SWRConfiguration;
|
|
13
|
-
|
|
14
|
-
export { Configuration, createSwrConfig };
|
|
12
|
+
|
|
13
|
+
export { type Configuration, createSwrConfig };
|
package/dist/react/swr.js
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var swr_exports = {};
|
|
20
|
+
__export(swr_exports, {
|
|
21
|
+
createSwrConfig: () => createSwrConfig
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(swr_exports);
|
|
24
|
+
var import_react = require("react");
|
|
12
25
|
const abortMiddleware = (useSWRNext) => (key, fetcher, config) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
} : fetcher, config);
|
|
26
|
+
const ctrlRef = (0, import_react.useRef)(void 0);
|
|
27
|
+
const extendedFetcher = fetcher ? (key2, params) => {
|
|
28
|
+
ctrlRef.current?.abort();
|
|
29
|
+
ctrlRef.current = new AbortController();
|
|
30
|
+
return fetcher(key2, { ...params, signal: ctrlRef.current.signal });
|
|
31
|
+
} : fetcher;
|
|
32
|
+
return useSWRNext(key, extendedFetcher, config);
|
|
22
33
|
};
|
|
23
34
|
const createSwrConfig = (config) => ({
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
...config,
|
|
36
|
+
use: [...config?.use ?? [], abortMiddleware]
|
|
37
|
+
});
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
createSwrConfig
|
|
26
41
|
});
|
|
27
|
-
//#endregion
|
|
28
|
-
exports.createSwrConfig = createSwrConfig;
|
package/dist/react/swr.mjs
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* 同一hookにおいて、keyが更新されるなどにより、一つ前のrequestが返る前に再度fetchが行われる場合がある
|
|
7
|
-
* その場合、一つ前のfetchが戻ってきた値がそのまま捨てられるため、responseに時間がかかるAPIの場合、純粋な負荷増加に繋がってしまう
|
|
8
|
-
* そのため、最新のrequestのみを返すように、一つ前のrequestをabortする
|
|
9
|
-
*/
|
|
10
|
-
const abortMiddleware = (useSWRNext) => (key, fetcher, config) => {
|
|
11
|
-
const ctrlRef = useRef(void 0);
|
|
12
|
-
return useSWRNext(key, fetcher ? (key, params) => {
|
|
13
|
-
ctrlRef.current?.abort();
|
|
14
|
-
ctrlRef.current = new AbortController();
|
|
15
|
-
return fetcher(key, {
|
|
16
|
-
...params,
|
|
17
|
-
signal: ctrlRef.current.signal
|
|
18
|
-
});
|
|
19
|
-
} : fetcher, config);
|
|
1
|
+
import {
|
|
2
|
+
createSwrConfig
|
|
3
|
+
} from "../chunk-DH33ZDBG.mjs";
|
|
4
|
+
export {
|
|
5
|
+
createSwrConfig
|
|
20
6
|
};
|
|
21
|
-
const createSwrConfig = (config) => ({
|
|
22
|
-
...config,
|
|
23
|
-
use: [...config?.use ?? [], abortMiddleware]
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
export { createSwrConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Config } from
|
|
1
|
+
import { Config } from '../apiClientConfigStore.js';
|
|
2
|
+
import '../store.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
declare const useApiClientConfig: () => any;
|
|
4
|
+
declare const useApiClientConfig: () => Config;
|
|
5
5
|
declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
|
|
6
6
|
declare const useRequestInit: (customRequestInit?: RequestInit) => RequestInit;
|
|
7
|
-
|
|
8
|
-
export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
|
|
7
|
+
|
|
8
|
+
export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
|
|
@@ -1,24 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useApiClientConfig_exports = {};
|
|
20
|
+
__export(useApiClientConfig_exports, {
|
|
21
|
+
useApiClientConfig: () => useApiClientConfig,
|
|
22
|
+
useApiClientConfigWithSelector: () => useApiClientConfigWithSelector,
|
|
23
|
+
useRequestInit: () => useRequestInit
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useApiClientConfig_exports);
|
|
26
|
+
var import_ApiClientConfigProvider = require("./ApiClientConfigProvider");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_requestInit = require("../utils/requestInit");
|
|
29
|
+
var import_shim = require("use-sync-external-store/shim/index.js");
|
|
30
|
+
var import_with_selector = require("use-sync-external-store/shim/with-selector.js");
|
|
9
31
|
const useApiClientConfig = () => {
|
|
10
|
-
|
|
11
|
-
|
|
32
|
+
const store = (0, import_ApiClientConfigProvider.useApiClientConfigContext)();
|
|
33
|
+
return (0, import_shim.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
12
34
|
};
|
|
13
35
|
const useApiClientConfigWithSelector = (selector) => {
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
const store = (0, import_ApiClientConfigProvider.useApiClientConfigContext)();
|
|
37
|
+
return (0, import_with_selector.useSyncExternalStoreWithSelector)(
|
|
38
|
+
store.subscribe,
|
|
39
|
+
store.getState,
|
|
40
|
+
store.getState,
|
|
41
|
+
selector
|
|
42
|
+
);
|
|
16
43
|
};
|
|
17
44
|
const useRequestInit = (customRequestInit = {}) => {
|
|
18
|
-
|
|
19
|
-
|
|
45
|
+
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
46
|
+
return (0, import_react.useMemo)(
|
|
47
|
+
() => (0, import_requestInit.mergeRequestInit)(defaultRequestInit, customRequestInit),
|
|
48
|
+
[defaultRequestInit, customRequestInit]
|
|
49
|
+
);
|
|
20
50
|
};
|
|
21
|
-
|
|
22
|
-
exports
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
useApiClientConfig,
|
|
54
|
+
useApiClientConfigWithSelector,
|
|
55
|
+
useRequestInit
|
|
56
|
+
});
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
useApiClientConfig,
|
|
3
|
+
useApiClientConfigWithSelector,
|
|
4
|
+
useRequestInit
|
|
5
|
+
} from "../chunk-5JS6U5IM.mjs";
|
|
6
|
+
import "../chunk-QXFPBYPL.mjs";
|
|
7
|
+
import "../chunk-DH33ZDBG.mjs";
|
|
8
|
+
import "../chunk-NOC6G3HZ.mjs";
|
|
9
|
+
import "../chunk-TZUKIYFN.mjs";
|
|
10
|
+
import "../chunk-NYICHGY2.mjs";
|
|
11
|
+
import "../chunk-3SEO7S3Q.mjs";
|
|
12
|
+
export {
|
|
13
|
+
useApiClientConfig,
|
|
14
|
+
useApiClientConfigWithSelector,
|
|
15
|
+
useRequestInit
|
|
10
16
|
};
|
|
11
|
-
const useApiClientConfigWithSelector = (selector) => {
|
|
12
|
-
const store = useApiClientConfigContext();
|
|
13
|
-
return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector);
|
|
14
|
-
};
|
|
15
|
-
const useRequestInit = (customRequestInit = {}) => {
|
|
16
|
-
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
17
|
-
return useMemo(() => mergeRequestInit(defaultRequestInit, customRequestInit), [defaultRequestInit, customRequestInit]);
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
|
package/dist/requestUrl.d.ts
CHANGED
package/dist/requestUrl.js
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var requestUrl_exports = {};
|
|
30
|
+
__export(requestUrl_exports, {
|
|
31
|
+
__internal__requestUrl: () => __internal__requestUrl
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(requestUrl_exports);
|
|
34
|
+
var import_qs = __toESM(require("qs"));
|
|
35
|
+
var import_apiClientConfigStore = require("./apiClientConfigStore");
|
|
7
36
|
function __internal__requestUrl(...args) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
const config = import_apiClientConfigStore.store.getState();
|
|
38
|
+
const rawPath = args[0];
|
|
39
|
+
const params = args[1] || {};
|
|
40
|
+
const query = args[2];
|
|
41
|
+
const hostName = config.hostName ? typeof config.hostName === "string" ? config.hostName : config.hostName(rawPath) : "";
|
|
42
|
+
const path = hostName + Object.entries(params).reduce(
|
|
43
|
+
(path2, [key, value]) => path2.replace(`{${key}}`, String(value)),
|
|
44
|
+
rawPath
|
|
45
|
+
);
|
|
46
|
+
return query ? `${path}?${import_qs.default.stringify(query)}` : path;
|
|
14
47
|
}
|
|
15
|
-
|
|
16
|
-
exports
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
__internal__requestUrl
|
|
51
|
+
});
|
package/dist/requestUrl.mjs
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { __internal__requestUrl };
|
|
1
|
+
import {
|
|
2
|
+
__internal__requestUrl
|
|
3
|
+
} from "./chunk-GD4RTKUU.mjs";
|
|
4
|
+
import "./chunk-NOC6G3HZ.mjs";
|
|
5
|
+
import "./chunk-TZUKIYFN.mjs";
|
|
6
|
+
import "./chunk-NYICHGY2.mjs";
|
|
7
|
+
import "./chunk-3SEO7S3Q.mjs";
|
|
8
|
+
export {
|
|
9
|
+
__internal__requestUrl
|
|
10
|
+
};
|