reqwise-react 1.0.0 → 1.1.3
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/.turbo/turbo-build.log +7 -11
- package/README.md +128 -0
- package/dist/index.js +56 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
- package/src/ReqwiseClient.ts +32 -21
- package/src/ReqwiseDevTools.tsx +37 -18
- package/src/index.ts +4 -4
- package/tsconfig.json +1 -2
- package/tsup.config.ts +3 -1
- package/dist/index.d.mts +0 -47
- package/dist/index.d.ts +0 -47
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
>
|
|
2
|
+
> reqwise-react@1.1.3 build C:\Users\PC\Desktop\Code\reqwise\packages\react
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,9 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist\index.mjs [22m[32m2.
|
|
14
|
-
[32mESM[39m [1mdist\index.mjs.map [22m[
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
-
[32mCJS[39m [1mdist\index.js [22m[32m4.
|
|
17
|
-
[32mCJS[39m [1mdist\index.js.map [22m[32m5.
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 622ms
|
|
21
|
-
[32mDTS[39m [1mdist\index.d.ts [22m[32m2.18 KB[39m
|
|
22
|
-
[32mDTS[39m [1mdist\index.d.mts [22m[32m2.18 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist\index.mjs [22m[32m2.96 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist\index.mjs.map [22m[32m5.45 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 11ms
|
|
16
|
+
[32mCJS[39m [1mdist\index.js [22m[32m4.92 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist\index.js.map [22m[32m5.62 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 11ms
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Reqwise React
|
|
2
|
+
|
|
3
|
+
React wrapper for [Reqwise DevTools](https://github.com/reqwise/reqwise) - HTTP request/response inspector panel for web applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install reqwise-react
|
|
9
|
+
# or
|
|
10
|
+
pnpm add reqwise-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { ReqwiseDevTools } from 'reqwise-react'
|
|
17
|
+
import axios from 'axios'
|
|
18
|
+
|
|
19
|
+
export default function App() {
|
|
20
|
+
const api = axios.create({
|
|
21
|
+
baseURL: 'https://api.example.com'
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<ReqwiseDevTools
|
|
27
|
+
axiosInstance={api}
|
|
28
|
+
placement="right"
|
|
29
|
+
defaultOpen={false}
|
|
30
|
+
theme="dark"
|
|
31
|
+
/>
|
|
32
|
+
{/* Your app content */}
|
|
33
|
+
</>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Props
|
|
39
|
+
|
|
40
|
+
### Core Configuration
|
|
41
|
+
|
|
42
|
+
- **`axiosInstance`** (AxiosInstance) - Axios instance to monitor (required for auto-capture)
|
|
43
|
+
- **`placement`** ('left' | 'right' | 'top' | 'bottom') - Panel position (default: 'right')
|
|
44
|
+
- **`defaultOpen`** (boolean) - Panel open on mount (default: false)
|
|
45
|
+
- **`theme`** ('dark' | 'light' | 'system') - Color theme (default: 'system')
|
|
46
|
+
- **`hotkey`** (string) - Keyboard shortcut to toggle (default: 'ctrl+shift+e')
|
|
47
|
+
- **`enabled`** (boolean) - Enable/disable panel (default: true)
|
|
48
|
+
|
|
49
|
+
### Display Options
|
|
50
|
+
|
|
51
|
+
- **`show`** ('general' | 'detailed') - Request card detail level (default: 'general')
|
|
52
|
+
- **`size`** ('sm' | 'md' | 'lg' | 'full') - Panel size (default: 'md')
|
|
53
|
+
- **`opacity`** (number) - Panel opacity 0-1 (default: 1)
|
|
54
|
+
|
|
55
|
+
### Data Management
|
|
56
|
+
|
|
57
|
+
- **`maxItems`** (number) - Max requests to store (default: 500)
|
|
58
|
+
- **`persistHistory`** (boolean) - Save history to localStorage (default: true)
|
|
59
|
+
- **`ignore`** (string[]) - URL patterns to ignore (default: [])
|
|
60
|
+
- **`maskHeaders`** (string[]) - Headers to mask in display (default: [])
|
|
61
|
+
- **`maskFields`** (string[]) - JSON fields to mask (default: [])
|
|
62
|
+
|
|
63
|
+
### Grouping & Highlighting
|
|
64
|
+
|
|
65
|
+
- **`groupBy`** ('url' | 'method' | 'status' | 'page') - Group requests by field
|
|
66
|
+
- **`highlight`** ('error' | 'slow') - Highlight requests by status
|
|
67
|
+
|
|
68
|
+
### Localization
|
|
69
|
+
|
|
70
|
+
- **`langs`** (string[]) - Supported languages (default: ['en'])
|
|
71
|
+
- **`defaultLang`** (string) - Initial language (default: 'en')
|
|
72
|
+
|
|
73
|
+
### Callbacks
|
|
74
|
+
|
|
75
|
+
- **`onRequest`** (entry => void) - Called before request is stored
|
|
76
|
+
- **`onResponse`** (entry => void) - Called after successful response
|
|
77
|
+
- **`onError`** (entry => void) - Called on request error
|
|
78
|
+
|
|
79
|
+
## Example: Full Configuration
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
<ReqwiseDevTools
|
|
83
|
+
axiosInstance={api}
|
|
84
|
+
placement="bottom"
|
|
85
|
+
size="lg"
|
|
86
|
+
theme="dark"
|
|
87
|
+
show="detailed"
|
|
88
|
+
defaultOpen={true}
|
|
89
|
+
maxItems={1000}
|
|
90
|
+
persistHistory={true}
|
|
91
|
+
ignore={['/health', '/ping']}
|
|
92
|
+
maskHeaders={['Authorization', 'X-API-Key']}
|
|
93
|
+
maskFields={['password', 'token', 'secret']}
|
|
94
|
+
groupBy="url"
|
|
95
|
+
highlight="error"
|
|
96
|
+
langs={['en', 'tr', 'es']}
|
|
97
|
+
defaultLang="tr"
|
|
98
|
+
onRequest={(e) => console.log('Request:', e.method, e.url)}
|
|
99
|
+
onResponse={(e) => console.log('Response:', e.status)}
|
|
100
|
+
onError={(e) => console.error('Error:', e.error?.message)}
|
|
101
|
+
/>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Features
|
|
105
|
+
|
|
106
|
+
✨ **Auto-Capture** - Automatically intercept Axios requests/responses
|
|
107
|
+
📊 **Detailed View** - Full request/response headers and bodies
|
|
108
|
+
🔍 **Filtering & Search** - Filter by URL, method, status
|
|
109
|
+
💾 **Persistent History** - LocalStorage support for request history
|
|
110
|
+
🎨 **Multiple Themes** - Dark/Light/System theme support
|
|
111
|
+
🌍 **i18n Ready** - 15+ languages supported
|
|
112
|
+
📱 **Responsive** - Works on mobile and desktop
|
|
113
|
+
⚡ **Zero Config** - Works out of the box with sensible defaults
|
|
114
|
+
|
|
115
|
+
## Browser Support
|
|
116
|
+
|
|
117
|
+
- Chrome/Edge 90+
|
|
118
|
+
- Firefox 88+
|
|
119
|
+
- Safari 14+
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT
|
|
124
|
+
|
|
125
|
+
## Related
|
|
126
|
+
|
|
127
|
+
- [Reqwise Core](https://github.com/reqwise/reqwise/tree/main/packages/core) - Core package
|
|
128
|
+
- [Reqwise CLI](https://github.com/reqwise/reqwise) - Command-line tool
|
package/dist/index.js
CHANGED
|
@@ -36,17 +36,17 @@ __export(index_exports, {
|
|
|
36
36
|
fetch: () => fetch,
|
|
37
37
|
get: () => get,
|
|
38
38
|
init: () => init,
|
|
39
|
+
patch: () => patch,
|
|
39
40
|
post: () => post,
|
|
40
41
|
put: () => put,
|
|
41
42
|
record: () => record,
|
|
42
|
-
setAxiosInstance: () => setAxiosInstance,
|
|
43
43
|
wrapAxios: () => wrapAxios
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(index_exports);
|
|
46
46
|
|
|
47
47
|
// src/ReqwiseDevTools.tsx
|
|
48
48
|
var import_react = require("react");
|
|
49
|
-
var
|
|
49
|
+
var import_reqwise_core2 = require("reqwise-core");
|
|
50
50
|
|
|
51
51
|
// src/ReqwiseClient.ts
|
|
52
52
|
var ReqwiseClient_exports = {};
|
|
@@ -56,65 +56,90 @@ __export(ReqwiseClient_exports, {
|
|
|
56
56
|
fetch: () => fetch,
|
|
57
57
|
get: () => get,
|
|
58
58
|
init: () => init,
|
|
59
|
+
patch: () => patch,
|
|
59
60
|
post: () => post,
|
|
60
61
|
put: () => put,
|
|
61
62
|
record: () => record,
|
|
62
|
-
setAxiosInstance: () => setAxiosInstance,
|
|
63
63
|
wrapAxios: () => wrapAxios
|
|
64
64
|
});
|
|
65
|
-
var
|
|
65
|
+
var import_reqwise_core = __toESM(require("reqwise-core"));
|
|
66
66
|
var _axiosInstance = null;
|
|
67
67
|
function init(cfg) {
|
|
68
|
-
|
|
68
|
+
import_reqwise_core.default.ReqwiseClient.init(cfg);
|
|
69
69
|
}
|
|
70
70
|
function wrapAxios(instance) {
|
|
71
71
|
_axiosInstance = instance;
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
function setAxiosInstance(instance) {
|
|
75
|
-
_axiosInstance = instance;
|
|
76
|
-
return import_core.default.ReqwiseClient.wrapAxios(instance);
|
|
72
|
+
import_reqwise_core.default.ReqwiseClient.wrapAxios(instance);
|
|
77
73
|
}
|
|
78
74
|
async function get(url, cfg) {
|
|
79
|
-
if (_axiosInstance && typeof _axiosInstance.get === "function")
|
|
80
|
-
|
|
75
|
+
if (_axiosInstance && typeof _axiosInstance.get === "function") {
|
|
76
|
+
return _axiosInstance.get(url, cfg);
|
|
77
|
+
}
|
|
78
|
+
return import_reqwise_core.default.ReqwiseClient.get(url, cfg);
|
|
81
79
|
}
|
|
82
80
|
async function post(url, body, cfg) {
|
|
83
|
-
if (_axiosInstance && typeof _axiosInstance.post === "function")
|
|
84
|
-
|
|
81
|
+
if (_axiosInstance && typeof _axiosInstance.post === "function") {
|
|
82
|
+
return _axiosInstance.post(url, body, cfg);
|
|
83
|
+
}
|
|
84
|
+
return import_reqwise_core.default.ReqwiseClient.post(url, body, cfg);
|
|
85
85
|
}
|
|
86
86
|
async function put(url, body, cfg) {
|
|
87
|
-
if (_axiosInstance && typeof _axiosInstance.put === "function")
|
|
88
|
-
|
|
87
|
+
if (_axiosInstance && typeof _axiosInstance.put === "function") {
|
|
88
|
+
return _axiosInstance.put(url, body, cfg);
|
|
89
|
+
}
|
|
90
|
+
return import_reqwise_core.default.ReqwiseClient.put(url, body, cfg);
|
|
91
|
+
}
|
|
92
|
+
async function patch(url, body, cfg) {
|
|
93
|
+
if (_axiosInstance && typeof _axiosInstance.patch === "function") {
|
|
94
|
+
return _axiosInstance.patch(url, body, cfg);
|
|
95
|
+
}
|
|
96
|
+
return import_reqwise_core.default.ReqwiseClient.patch(url, body, cfg);
|
|
89
97
|
}
|
|
90
98
|
async function del(url, cfg) {
|
|
91
|
-
if (_axiosInstance && typeof _axiosInstance.delete === "function")
|
|
92
|
-
|
|
99
|
+
if (_axiosInstance && typeof _axiosInstance.delete === "function") {
|
|
100
|
+
return _axiosInstance.delete(url, cfg);
|
|
101
|
+
}
|
|
102
|
+
return import_reqwise_core.default.ReqwiseClient.delete(url, cfg);
|
|
93
103
|
}
|
|
94
|
-
var fetch =
|
|
95
|
-
var record =
|
|
104
|
+
var fetch = import_reqwise_core.default.ReqwiseClient.fetch;
|
|
105
|
+
var record = import_reqwise_core.default.ReqwiseClient.record;
|
|
96
106
|
var ReqwiseClient_default = {
|
|
97
107
|
init,
|
|
98
108
|
wrapAxios,
|
|
99
|
-
setAxiosInstance,
|
|
100
109
|
get,
|
|
101
110
|
post,
|
|
102
111
|
put,
|
|
103
|
-
|
|
112
|
+
patch,
|
|
113
|
+
delete: del,
|
|
104
114
|
fetch,
|
|
105
115
|
record
|
|
106
116
|
};
|
|
107
117
|
|
|
108
118
|
// src/ReqwiseDevTools.tsx
|
|
109
|
-
function ReqwiseDevTools(
|
|
119
|
+
function ReqwiseDevTools(props) {
|
|
120
|
+
if (props.enabled === false) return null;
|
|
110
121
|
(0, import_react.useEffect)(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
try {
|
|
123
|
+
init(props);
|
|
124
|
+
if (props.axiosInstance) {
|
|
125
|
+
wrapAxios(props.axiosInstance);
|
|
126
|
+
}
|
|
127
|
+
(0, import_reqwise_core2.rendererSetConfig)(props);
|
|
128
|
+
import_reqwise_core2.panel.setRenderer(import_reqwise_core2.renderer);
|
|
129
|
+
import_reqwise_core2.panel.mount({
|
|
130
|
+
defaultOpen: props.defaultOpen,
|
|
131
|
+
placement: props.placement,
|
|
132
|
+
hotkey: props.hotkey,
|
|
133
|
+
theme: props.theme,
|
|
134
|
+
size: props.size,
|
|
135
|
+
opacity: props.opacity
|
|
136
|
+
});
|
|
137
|
+
return () => {
|
|
138
|
+
import_reqwise_core2.panel.unmount();
|
|
139
|
+
};
|
|
140
|
+
} catch (e) {
|
|
141
|
+
console.error("[reqwise] ReqwiseDevTools error", e);
|
|
142
|
+
}
|
|
118
143
|
}, []);
|
|
119
144
|
return null;
|
|
120
145
|
}
|
|
@@ -132,10 +157,10 @@ var index_default = _default;
|
|
|
132
157
|
fetch,
|
|
133
158
|
get,
|
|
134
159
|
init,
|
|
160
|
+
patch,
|
|
135
161
|
post,
|
|
136
162
|
put,
|
|
137
163
|
record,
|
|
138
|
-
setAxiosInstance,
|
|
139
164
|
wrapAxios
|
|
140
165
|
});
|
|
141
166
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts"],"sourcesContent":["export { ReqwiseDevTools } from './ReqwiseDevTools'\r\nexport * from './ReqwiseClient'\r\n\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\nimport { ReqwiseDevTools } from './ReqwiseDevTools'\r\n\r\nconst _default = {\r\n\tReqwiseDevTools,\r\n\t...ReqwiseClient,\r\n}\r\n\r\nexport default _default\r\n","import React, { useEffect } from 'react'\r\nimport { panel, renderer, rendererSetConfig } from 'reqwise-core'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\nimport type { ReqwiseConfig } from 'reqwise-core'\r\n\r\ntype ReqwiseDevToolsProps = ReqwiseConfig & {\r\n enabled?: boolean\r\n}\r\n\r\nexport function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null {\r\n // No-op if disabled\r\n if (props.enabled === false) return null\r\n\r\n useEffect(() => {\r\n try {\r\n // Initialize core client with config\r\n ReqwiseClient.init(props)\r\n\r\n // Wrap axios instance if provided\r\n if (props.axiosInstance) {\r\n ReqwiseClient.wrapAxios(props.axiosInstance)\r\n }\r\n\r\n // Set renderer config and mount\r\n rendererSetConfig(props)\r\n panel.setRenderer(renderer)\r\n\r\n // Mount panel into document.body\r\n panel.mount({\r\n defaultOpen: props.defaultOpen,\r\n placement: props.placement,\r\n hotkey: props.hotkey,\r\n theme: props.theme,\r\n size: props.size,\r\n opacity: props.opacity,\r\n })\r\n\r\n return () => {\r\n panel.unmount()\r\n }\r\n } catch (e) {\r\n console.error('[reqwise] ReqwiseDevTools error', e)\r\n }\r\n }, [])\r\n\r\n // Nothing to render in React tree — aside renders directly to document.body\r\n return null\r\n}\r\n","import Core from 'reqwise-core'\r\nimport type { ReqwiseConfig, RequestConfig } from 'reqwise-core'\r\n\r\nlet _axiosInstance: any = null\r\n\r\nexport function init(cfg?: Partial<ReqwiseConfig>) {\r\n Core.ReqwiseClient.init(cfg)\r\n}\r\n\r\nexport function wrapAxios(instance: any) {\r\n _axiosInstance = instance\r\n Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport async function get(url: string, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.get === 'function') {\r\n return _axiosInstance.get(url, cfg)\r\n }\r\n return Core.ReqwiseClient.get(url, cfg)\r\n}\r\n\r\nexport async function post(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.post === 'function') {\r\n return _axiosInstance.post(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.post(url, body, cfg)\r\n}\r\n\r\nexport async function put(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.put === 'function') {\r\n return _axiosInstance.put(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.put(url, body, cfg)\r\n}\r\n\r\nexport async function patch(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.patch === 'function') {\r\n return _axiosInstance.patch(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.patch(url, body, cfg)\r\n}\r\n\r\nexport async function del(url: string, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.delete === 'function') {\r\n return _axiosInstance.delete(url, cfg)\r\n }\r\n return Core.ReqwiseClient.delete(url, cfg)\r\n}\r\n\r\nexport const fetch = Core.ReqwiseClient.fetch\r\nexport const record = Core.ReqwiseClient.record\r\n\r\nexport default {\r\n init,\r\n wrapAxios,\r\n get,\r\n post,\r\n put,\r\n patch,\r\n delete: del,\r\n fetch,\r\n record,\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAiC;AACjC,IAAAA,uBAAmD;;;ACDnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiB;AAGjB,IAAI,iBAAsB;AAEnB,SAAS,KAAK,KAA8B;AACjD,sBAAAC,QAAK,cAAc,KAAK,GAAG;AAC7B;AAEO,SAAS,UAAU,UAAe;AACvC,mBAAiB;AACjB,sBAAAA,QAAK,cAAc,UAAU,QAAQ;AACvC;AAEA,eAAsB,IAAI,KAAa,KAAqB;AAC1D,MAAI,kBAAkB,OAAO,eAAe,QAAQ,YAAY;AAC9D,WAAO,eAAe,IAAI,KAAK,GAAG;AAAA,EACpC;AACA,SAAO,oBAAAA,QAAK,cAAc,IAAI,KAAK,GAAG;AACxC;AAEA,eAAsB,KAAK,KAAa,MAAY,KAAqB;AACvE,MAAI,kBAAkB,OAAO,eAAe,SAAS,YAAY;AAC/D,WAAO,eAAe,KAAK,KAAK,MAAM,GAAG;AAAA,EAC3C;AACA,SAAO,oBAAAA,QAAK,cAAc,KAAK,KAAK,MAAM,GAAG;AAC/C;AAEA,eAAsB,IAAI,KAAa,MAAY,KAAqB;AACtE,MAAI,kBAAkB,OAAO,eAAe,QAAQ,YAAY;AAC9D,WAAO,eAAe,IAAI,KAAK,MAAM,GAAG;AAAA,EAC1C;AACA,SAAO,oBAAAA,QAAK,cAAc,IAAI,KAAK,MAAM,GAAG;AAC9C;AAEA,eAAsB,MAAM,KAAa,MAAY,KAAqB;AACxE,MAAI,kBAAkB,OAAO,eAAe,UAAU,YAAY;AAChE,WAAO,eAAe,MAAM,KAAK,MAAM,GAAG;AAAA,EAC5C;AACA,SAAO,oBAAAA,QAAK,cAAc,MAAM,KAAK,MAAM,GAAG;AAChD;AAEA,eAAsB,IAAI,KAAa,KAAqB;AAC1D,MAAI,kBAAkB,OAAO,eAAe,WAAW,YAAY;AACjE,WAAO,eAAe,OAAO,KAAK,GAAG;AAAA,EACvC;AACA,SAAO,oBAAAA,QAAK,cAAc,OAAO,KAAK,GAAG;AAC3C;AAEO,IAAM,QAAQ,oBAAAA,QAAK,cAAc;AACjC,IAAM,SAAS,oBAAAA,QAAK,cAAc;AAEzC,IAAO,wBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF;;;ADrDO,SAAS,gBAAgB,OAAwD;AAEtF,MAAI,MAAM,YAAY,MAAO,QAAO;AAEpC,8BAAU,MAAM;AACd,QAAI;AAEF,MAAc,KAAK,KAAK;AAGxB,UAAI,MAAM,eAAe;AACvB,QAAc,UAAU,MAAM,aAAa;AAAA,MAC7C;AAGA,kDAAkB,KAAK;AACvB,iCAAM,YAAY,6BAAQ;AAG1B,iCAAM,MAAM;AAAA,QACV,aAAa,MAAM;AAAA,QACnB,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,QACb,MAAM,MAAM;AAAA,QACZ,SAAS,MAAM;AAAA,MACjB,CAAC;AAED,aAAO,MAAM;AACX,mCAAM,QAAQ;AAAA,MAChB;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,mCAAmC,CAAC;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,CAAC;AAGL,SAAO;AACT;;;ADzCA,IAAM,WAAW;AAAA,EAChB;AAAA,EACA,GAAG;AACJ;AAEA,IAAO,gBAAQ;","names":["import_reqwise_core","Core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/ReqwiseDevTools.tsx
|
|
8
8
|
import { useEffect } from "react";
|
|
9
|
-
import { panel, renderer } from "
|
|
9
|
+
import { panel, renderer, rendererSetConfig } from "reqwise-core";
|
|
10
10
|
|
|
11
11
|
// src/ReqwiseClient.ts
|
|
12
12
|
var ReqwiseClient_exports = {};
|
|
@@ -16,65 +16,90 @@ __export(ReqwiseClient_exports, {
|
|
|
16
16
|
fetch: () => fetch,
|
|
17
17
|
get: () => get,
|
|
18
18
|
init: () => init,
|
|
19
|
+
patch: () => patch,
|
|
19
20
|
post: () => post,
|
|
20
21
|
put: () => put,
|
|
21
22
|
record: () => record,
|
|
22
|
-
setAxiosInstance: () => setAxiosInstance,
|
|
23
23
|
wrapAxios: () => wrapAxios
|
|
24
24
|
});
|
|
25
|
-
import Core from "
|
|
25
|
+
import Core from "reqwise-core";
|
|
26
26
|
var _axiosInstance = null;
|
|
27
27
|
function init(cfg) {
|
|
28
|
-
|
|
28
|
+
Core.ReqwiseClient.init(cfg);
|
|
29
29
|
}
|
|
30
30
|
function wrapAxios(instance) {
|
|
31
31
|
_axiosInstance = instance;
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function setAxiosInstance(instance) {
|
|
35
|
-
_axiosInstance = instance;
|
|
36
|
-
return Core.ReqwiseClient.wrapAxios(instance);
|
|
32
|
+
Core.ReqwiseClient.wrapAxios(instance);
|
|
37
33
|
}
|
|
38
34
|
async function get(url, cfg) {
|
|
39
|
-
if (_axiosInstance && typeof _axiosInstance.get === "function")
|
|
40
|
-
|
|
35
|
+
if (_axiosInstance && typeof _axiosInstance.get === "function") {
|
|
36
|
+
return _axiosInstance.get(url, cfg);
|
|
37
|
+
}
|
|
38
|
+
return Core.ReqwiseClient.get(url, cfg);
|
|
41
39
|
}
|
|
42
40
|
async function post(url, body, cfg) {
|
|
43
|
-
if (_axiosInstance && typeof _axiosInstance.post === "function")
|
|
44
|
-
|
|
41
|
+
if (_axiosInstance && typeof _axiosInstance.post === "function") {
|
|
42
|
+
return _axiosInstance.post(url, body, cfg);
|
|
43
|
+
}
|
|
44
|
+
return Core.ReqwiseClient.post(url, body, cfg);
|
|
45
45
|
}
|
|
46
46
|
async function put(url, body, cfg) {
|
|
47
|
-
if (_axiosInstance && typeof _axiosInstance.put === "function")
|
|
48
|
-
|
|
47
|
+
if (_axiosInstance && typeof _axiosInstance.put === "function") {
|
|
48
|
+
return _axiosInstance.put(url, body, cfg);
|
|
49
|
+
}
|
|
50
|
+
return Core.ReqwiseClient.put(url, body, cfg);
|
|
51
|
+
}
|
|
52
|
+
async function patch(url, body, cfg) {
|
|
53
|
+
if (_axiosInstance && typeof _axiosInstance.patch === "function") {
|
|
54
|
+
return _axiosInstance.patch(url, body, cfg);
|
|
55
|
+
}
|
|
56
|
+
return Core.ReqwiseClient.patch(url, body, cfg);
|
|
49
57
|
}
|
|
50
58
|
async function del(url, cfg) {
|
|
51
|
-
if (_axiosInstance && typeof _axiosInstance.delete === "function")
|
|
52
|
-
|
|
59
|
+
if (_axiosInstance && typeof _axiosInstance.delete === "function") {
|
|
60
|
+
return _axiosInstance.delete(url, cfg);
|
|
61
|
+
}
|
|
62
|
+
return Core.ReqwiseClient.delete(url, cfg);
|
|
53
63
|
}
|
|
54
64
|
var fetch = Core.ReqwiseClient.fetch;
|
|
55
65
|
var record = Core.ReqwiseClient.record;
|
|
56
66
|
var ReqwiseClient_default = {
|
|
57
67
|
init,
|
|
58
68
|
wrapAxios,
|
|
59
|
-
setAxiosInstance,
|
|
60
69
|
get,
|
|
61
70
|
post,
|
|
62
71
|
put,
|
|
63
|
-
|
|
72
|
+
patch,
|
|
73
|
+
delete: del,
|
|
64
74
|
fetch,
|
|
65
75
|
record
|
|
66
76
|
};
|
|
67
77
|
|
|
68
78
|
// src/ReqwiseDevTools.tsx
|
|
69
|
-
function ReqwiseDevTools(
|
|
79
|
+
function ReqwiseDevTools(props) {
|
|
80
|
+
if (props.enabled === false) return null;
|
|
70
81
|
useEffect(() => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
try {
|
|
83
|
+
init(props);
|
|
84
|
+
if (props.axiosInstance) {
|
|
85
|
+
wrapAxios(props.axiosInstance);
|
|
86
|
+
}
|
|
87
|
+
rendererSetConfig(props);
|
|
88
|
+
panel.setRenderer(renderer);
|
|
89
|
+
panel.mount({
|
|
90
|
+
defaultOpen: props.defaultOpen,
|
|
91
|
+
placement: props.placement,
|
|
92
|
+
hotkey: props.hotkey,
|
|
93
|
+
theme: props.theme,
|
|
94
|
+
size: props.size,
|
|
95
|
+
opacity: props.opacity
|
|
96
|
+
});
|
|
97
|
+
return () => {
|
|
98
|
+
panel.unmount();
|
|
99
|
+
};
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error("[reqwise] ReqwiseDevTools error", e);
|
|
102
|
+
}
|
|
78
103
|
}, []);
|
|
79
104
|
return null;
|
|
80
105
|
}
|
|
@@ -92,10 +117,10 @@ export {
|
|
|
92
117
|
fetch,
|
|
93
118
|
get,
|
|
94
119
|
init,
|
|
120
|
+
patch,
|
|
95
121
|
post,
|
|
96
122
|
put,
|
|
97
123
|
record,
|
|
98
|
-
setAxiosInstance,
|
|
99
124
|
wrapAxios
|
|
100
125
|
};
|
|
101
126
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts","../src/index.ts"],"sourcesContent":["import React, { useEffect } from 'react'\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts","../src/index.ts"],"sourcesContent":["import React, { useEffect } from 'react'\r\nimport { panel, renderer, rendererSetConfig } from 'reqwise-core'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\nimport type { ReqwiseConfig } from 'reqwise-core'\r\n\r\ntype ReqwiseDevToolsProps = ReqwiseConfig & {\r\n enabled?: boolean\r\n}\r\n\r\nexport function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null {\r\n // No-op if disabled\r\n if (props.enabled === false) return null\r\n\r\n useEffect(() => {\r\n try {\r\n // Initialize core client with config\r\n ReqwiseClient.init(props)\r\n\r\n // Wrap axios instance if provided\r\n if (props.axiosInstance) {\r\n ReqwiseClient.wrapAxios(props.axiosInstance)\r\n }\r\n\r\n // Set renderer config and mount\r\n rendererSetConfig(props)\r\n panel.setRenderer(renderer)\r\n\r\n // Mount panel into document.body\r\n panel.mount({\r\n defaultOpen: props.defaultOpen,\r\n placement: props.placement,\r\n hotkey: props.hotkey,\r\n theme: props.theme,\r\n size: props.size,\r\n opacity: props.opacity,\r\n })\r\n\r\n return () => {\r\n panel.unmount()\r\n }\r\n } catch (e) {\r\n console.error('[reqwise] ReqwiseDevTools error', e)\r\n }\r\n }, [])\r\n\r\n // Nothing to render in React tree — aside renders directly to document.body\r\n return null\r\n}\r\n","import Core from 'reqwise-core'\r\nimport type { ReqwiseConfig, RequestConfig } from 'reqwise-core'\r\n\r\nlet _axiosInstance: any = null\r\n\r\nexport function init(cfg?: Partial<ReqwiseConfig>) {\r\n Core.ReqwiseClient.init(cfg)\r\n}\r\n\r\nexport function wrapAxios(instance: any) {\r\n _axiosInstance = instance\r\n Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport async function get(url: string, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.get === 'function') {\r\n return _axiosInstance.get(url, cfg)\r\n }\r\n return Core.ReqwiseClient.get(url, cfg)\r\n}\r\n\r\nexport async function post(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.post === 'function') {\r\n return _axiosInstance.post(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.post(url, body, cfg)\r\n}\r\n\r\nexport async function put(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.put === 'function') {\r\n return _axiosInstance.put(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.put(url, body, cfg)\r\n}\r\n\r\nexport async function patch(url: string, body?: any, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.patch === 'function') {\r\n return _axiosInstance.patch(url, body, cfg)\r\n }\r\n return Core.ReqwiseClient.patch(url, body, cfg)\r\n}\r\n\r\nexport async function del(url: string, cfg?: RequestConfig) {\r\n if (_axiosInstance && typeof _axiosInstance.delete === 'function') {\r\n return _axiosInstance.delete(url, cfg)\r\n }\r\n return Core.ReqwiseClient.delete(url, cfg)\r\n}\r\n\r\nexport const fetch = Core.ReqwiseClient.fetch\r\nexport const record = Core.ReqwiseClient.record\r\n\r\nexport default {\r\n init,\r\n wrapAxios,\r\n get,\r\n post,\r\n put,\r\n patch,\r\n delete: del,\r\n fetch,\r\n record,\r\n}\r\n","export { ReqwiseDevTools } from './ReqwiseDevTools'\r\nexport * from './ReqwiseClient'\r\n\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\nimport { ReqwiseDevTools } from './ReqwiseDevTools'\r\n\r\nconst _default = {\r\n\tReqwiseDevTools,\r\n\t...ReqwiseClient,\r\n}\r\n\r\nexport default _default\r\n"],"mappings":";;;;;;;AAAA,SAAgB,iBAAiB;AACjC,SAAS,OAAO,UAAU,yBAAyB;;;ACDnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAO,UAAU;AAGjB,IAAI,iBAAsB;AAEnB,SAAS,KAAK,KAA8B;AACjD,OAAK,cAAc,KAAK,GAAG;AAC7B;AAEO,SAAS,UAAU,UAAe;AACvC,mBAAiB;AACjB,OAAK,cAAc,UAAU,QAAQ;AACvC;AAEA,eAAsB,IAAI,KAAa,KAAqB;AAC1D,MAAI,kBAAkB,OAAO,eAAe,QAAQ,YAAY;AAC9D,WAAO,eAAe,IAAI,KAAK,GAAG;AAAA,EACpC;AACA,SAAO,KAAK,cAAc,IAAI,KAAK,GAAG;AACxC;AAEA,eAAsB,KAAK,KAAa,MAAY,KAAqB;AACvE,MAAI,kBAAkB,OAAO,eAAe,SAAS,YAAY;AAC/D,WAAO,eAAe,KAAK,KAAK,MAAM,GAAG;AAAA,EAC3C;AACA,SAAO,KAAK,cAAc,KAAK,KAAK,MAAM,GAAG;AAC/C;AAEA,eAAsB,IAAI,KAAa,MAAY,KAAqB;AACtE,MAAI,kBAAkB,OAAO,eAAe,QAAQ,YAAY;AAC9D,WAAO,eAAe,IAAI,KAAK,MAAM,GAAG;AAAA,EAC1C;AACA,SAAO,KAAK,cAAc,IAAI,KAAK,MAAM,GAAG;AAC9C;AAEA,eAAsB,MAAM,KAAa,MAAY,KAAqB;AACxE,MAAI,kBAAkB,OAAO,eAAe,UAAU,YAAY;AAChE,WAAO,eAAe,MAAM,KAAK,MAAM,GAAG;AAAA,EAC5C;AACA,SAAO,KAAK,cAAc,MAAM,KAAK,MAAM,GAAG;AAChD;AAEA,eAAsB,IAAI,KAAa,KAAqB;AAC1D,MAAI,kBAAkB,OAAO,eAAe,WAAW,YAAY;AACjE,WAAO,eAAe,OAAO,KAAK,GAAG;AAAA,EACvC;AACA,SAAO,KAAK,cAAc,OAAO,KAAK,GAAG;AAC3C;AAEO,IAAM,QAAQ,KAAK,cAAc;AACjC,IAAM,SAAS,KAAK,cAAc;AAEzC,IAAO,wBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF;;;ADrDO,SAAS,gBAAgB,OAAwD;AAEtF,MAAI,MAAM,YAAY,MAAO,QAAO;AAEpC,YAAU,MAAM;AACd,QAAI;AAEF,MAAc,KAAK,KAAK;AAGxB,UAAI,MAAM,eAAe;AACvB,QAAc,UAAU,MAAM,aAAa;AAAA,MAC7C;AAGA,wBAAkB,KAAK;AACvB,YAAM,YAAY,QAAQ;AAG1B,YAAM,MAAM;AAAA,QACV,aAAa,MAAM;AAAA,QACnB,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,QACb,MAAM,MAAM;AAAA,QACZ,SAAS,MAAM;AAAA,MACjB,CAAC;AAED,aAAO,MAAM;AACX,cAAM,QAAQ;AAAA,MAChB;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,mCAAmC,CAAC;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,CAAC;AAGL,SAAO;AACT;;;AEzCA,IAAM,WAAW;AAAA,EAChB;AAAA,EACA,GAAG;AACJ;AAEA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reqwise-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
8
9
|
"import": "./dist/index.mjs",
|
|
9
10
|
"require": "./dist/index.js"
|
|
10
11
|
}
|
|
@@ -20,10 +21,13 @@
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
+
"reqwise-core": "^1.1.5"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^25.8.0"
|
|
27
|
+
"@types/node": "^25.8.0",
|
|
28
|
+
"@types/react": "^18.0.0",
|
|
29
|
+
"typescript": "^5.0.0",
|
|
30
|
+
"tsup": "^8.5.0"
|
|
27
31
|
},
|
|
28
32
|
"scripts": {
|
|
29
33
|
"build": "tsup",
|
package/src/ReqwiseClient.ts
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import Core from '
|
|
1
|
+
import Core from 'reqwise-core'
|
|
2
|
+
import type { ReqwiseConfig, RequestConfig } from 'reqwise-core'
|
|
2
3
|
|
|
3
4
|
let _axiosInstance: any = null
|
|
4
5
|
|
|
5
|
-
export function init(cfg?:
|
|
6
|
-
|
|
6
|
+
export function init(cfg?: Partial<ReqwiseConfig>) {
|
|
7
|
+
Core.ReqwiseClient.init(cfg)
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export function wrapAxios(instance: any) {
|
|
10
11
|
_axiosInstance = instance
|
|
11
|
-
|
|
12
|
+
Core.ReqwiseClient.wrapAxios(instance)
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export function
|
|
15
|
-
_axiosInstance
|
|
16
|
-
|
|
15
|
+
export async function get(url: string, cfg?: RequestConfig) {
|
|
16
|
+
if (_axiosInstance && typeof _axiosInstance.get === 'function') {
|
|
17
|
+
return _axiosInstance.get(url, cfg)
|
|
18
|
+
}
|
|
19
|
+
return Core.ReqwiseClient.get(url, cfg)
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
export async function
|
|
20
|
-
if (_axiosInstance && typeof _axiosInstance.
|
|
21
|
-
|
|
22
|
+
export async function post(url: string, body?: any, cfg?: RequestConfig) {
|
|
23
|
+
if (_axiosInstance && typeof _axiosInstance.post === 'function') {
|
|
24
|
+
return _axiosInstance.post(url, body, cfg)
|
|
25
|
+
}
|
|
26
|
+
return Core.ReqwiseClient.post(url, body, cfg)
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
export async function
|
|
25
|
-
if (_axiosInstance && typeof _axiosInstance.
|
|
26
|
-
|
|
29
|
+
export async function put(url: string, body?: any, cfg?: RequestConfig) {
|
|
30
|
+
if (_axiosInstance && typeof _axiosInstance.put === 'function') {
|
|
31
|
+
return _axiosInstance.put(url, body, cfg)
|
|
32
|
+
}
|
|
33
|
+
return Core.ReqwiseClient.put(url, body, cfg)
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
export async function
|
|
30
|
-
if (_axiosInstance && typeof _axiosInstance.
|
|
31
|
-
|
|
36
|
+
export async function patch(url: string, body?: any, cfg?: RequestConfig) {
|
|
37
|
+
if (_axiosInstance && typeof _axiosInstance.patch === 'function') {
|
|
38
|
+
return _axiosInstance.patch(url, body, cfg)
|
|
39
|
+
}
|
|
40
|
+
return Core.ReqwiseClient.patch(url, body, cfg)
|
|
32
41
|
}
|
|
33
42
|
|
|
34
|
-
export async function del(url: string, cfg?:
|
|
35
|
-
if (_axiosInstance && typeof _axiosInstance.delete === 'function')
|
|
36
|
-
|
|
43
|
+
export async function del(url: string, cfg?: RequestConfig) {
|
|
44
|
+
if (_axiosInstance && typeof _axiosInstance.delete === 'function') {
|
|
45
|
+
return _axiosInstance.delete(url, cfg)
|
|
46
|
+
}
|
|
47
|
+
return Core.ReqwiseClient.delete(url, cfg)
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
export const fetch = Core.ReqwiseClient.fetch
|
|
@@ -42,11 +53,11 @@ export const record = Core.ReqwiseClient.record
|
|
|
42
53
|
export default {
|
|
43
54
|
init,
|
|
44
55
|
wrapAxios,
|
|
45
|
-
setAxiosInstance,
|
|
46
56
|
get,
|
|
47
57
|
post,
|
|
48
58
|
put,
|
|
49
|
-
|
|
59
|
+
patch,
|
|
60
|
+
delete: del,
|
|
50
61
|
fetch,
|
|
51
62
|
record,
|
|
52
63
|
}
|
package/src/ReqwiseDevTools.tsx
CHANGED
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
import React, { useEffect } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { panel, renderer, rendererSetConfig } from 'reqwise-core'
|
|
3
3
|
import * as ReqwiseClient from './ReqwiseClient'
|
|
4
|
+
import type { ReqwiseConfig } from 'reqwise-core'
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
theme?: 'light' | 'dark'
|
|
8
|
-
axiosInstance?: any
|
|
9
|
-
defaultLang?: string
|
|
10
|
-
placement?: 'left' | 'right' | 'top' | 'bottom'
|
|
6
|
+
type ReqwiseDevToolsProps = ReqwiseConfig & {
|
|
7
|
+
enabled?: boolean
|
|
11
8
|
}
|
|
12
9
|
|
|
13
|
-
export
|
|
10
|
+
export function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null {
|
|
11
|
+
// No-op if disabled
|
|
12
|
+
if (props.enabled === false) return null
|
|
13
|
+
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
try {
|
|
16
|
+
// Initialize core client with config
|
|
17
|
+
ReqwiseClient.init(props)
|
|
18
|
+
|
|
19
|
+
// Wrap axios instance if provided
|
|
20
|
+
if (props.axiosInstance) {
|
|
21
|
+
ReqwiseClient.wrapAxios(props.axiosInstance)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Set renderer config and mount
|
|
25
|
+
rendererSetConfig(props)
|
|
26
|
+
panel.setRenderer(renderer)
|
|
27
|
+
|
|
28
|
+
// Mount panel into document.body
|
|
29
|
+
panel.mount({
|
|
30
|
+
defaultOpen: props.defaultOpen,
|
|
31
|
+
placement: props.placement,
|
|
32
|
+
hotkey: props.hotkey,
|
|
33
|
+
theme: props.theme,
|
|
34
|
+
size: props.size,
|
|
35
|
+
opacity: props.opacity,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
panel.unmount()
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error('[reqwise] ReqwiseDevTools error', e)
|
|
24
43
|
}
|
|
25
44
|
}, [])
|
|
26
45
|
|
|
27
|
-
//
|
|
46
|
+
// Nothing to render in React tree — aside renders directly to document.body
|
|
28
47
|
return null
|
|
29
48
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import * as ReqwiseClient from './ReqwiseClient'
|
|
3
|
-
|
|
4
|
-
export { ReqwiseDevTools }
|
|
1
|
+
export { ReqwiseDevTools } from './ReqwiseDevTools'
|
|
5
2
|
export * from './ReqwiseClient'
|
|
6
3
|
|
|
4
|
+
import * as ReqwiseClient from './ReqwiseClient'
|
|
5
|
+
import { ReqwiseDevTools } from './ReqwiseDevTools'
|
|
6
|
+
|
|
7
7
|
const _default = {
|
|
8
8
|
ReqwiseDevTools,
|
|
9
9
|
...ReqwiseClient,
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED
package/dist/index.d.mts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as _reqwise_core from '@reqwise/core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
defaultOpen?: boolean;
|
|
6
|
-
theme?: 'light' | 'dark';
|
|
7
|
-
axiosInstance?: any;
|
|
8
|
-
defaultLang?: string;
|
|
9
|
-
placement?: 'left' | 'right' | 'top' | 'bottom';
|
|
10
|
-
};
|
|
11
|
-
declare function ReqwiseDevTools({ defaultOpen, theme, axiosInstance, defaultLang, placement }: Props): React.ReactElement | null;
|
|
12
|
-
|
|
13
|
-
declare function init(cfg?: any): void;
|
|
14
|
-
declare function wrapAxios(instance: any): void;
|
|
15
|
-
declare function setAxiosInstance(instance: any): void;
|
|
16
|
-
declare function get(url: string, cfg?: any): Promise<any>;
|
|
17
|
-
declare function post(url: string, body?: any, cfg?: any): Promise<any>;
|
|
18
|
-
declare function put(url: string, body?: any, cfg?: any): Promise<any>;
|
|
19
|
-
declare function del(url: string, cfg?: any): Promise<any>;
|
|
20
|
-
declare const fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
21
|
-
declare const record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
22
|
-
|
|
23
|
-
declare const _default: {
|
|
24
|
-
init(cfg?: any): void;
|
|
25
|
-
wrapAxios(instance: any): void;
|
|
26
|
-
setAxiosInstance(instance: any): void;
|
|
27
|
-
get(url: string, cfg?: any): Promise<any>;
|
|
28
|
-
post(url: string, body?: any, cfg?: any): Promise<any>;
|
|
29
|
-
put(url: string, body?: any, cfg?: any): Promise<any>;
|
|
30
|
-
del(url: string, cfg?: any): Promise<any>;
|
|
31
|
-
fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
32
|
-
record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
33
|
-
default: {
|
|
34
|
-
init: typeof init;
|
|
35
|
-
wrapAxios: typeof wrapAxios;
|
|
36
|
-
setAxiosInstance: typeof setAxiosInstance;
|
|
37
|
-
get: typeof get;
|
|
38
|
-
post: typeof post;
|
|
39
|
-
put: typeof put;
|
|
40
|
-
del: typeof del;
|
|
41
|
-
fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
42
|
-
record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
43
|
-
};
|
|
44
|
-
ReqwiseDevTools: typeof ReqwiseDevTools;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { ReqwiseDevTools, _default as default, del, fetch, get, init, post, put, record, setAxiosInstance, wrapAxios };
|
package/dist/index.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as _reqwise_core from '@reqwise/core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
defaultOpen?: boolean;
|
|
6
|
-
theme?: 'light' | 'dark';
|
|
7
|
-
axiosInstance?: any;
|
|
8
|
-
defaultLang?: string;
|
|
9
|
-
placement?: 'left' | 'right' | 'top' | 'bottom';
|
|
10
|
-
};
|
|
11
|
-
declare function ReqwiseDevTools({ defaultOpen, theme, axiosInstance, defaultLang, placement }: Props): React.ReactElement | null;
|
|
12
|
-
|
|
13
|
-
declare function init(cfg?: any): void;
|
|
14
|
-
declare function wrapAxios(instance: any): void;
|
|
15
|
-
declare function setAxiosInstance(instance: any): void;
|
|
16
|
-
declare function get(url: string, cfg?: any): Promise<any>;
|
|
17
|
-
declare function post(url: string, body?: any, cfg?: any): Promise<any>;
|
|
18
|
-
declare function put(url: string, body?: any, cfg?: any): Promise<any>;
|
|
19
|
-
declare function del(url: string, cfg?: any): Promise<any>;
|
|
20
|
-
declare const fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
21
|
-
declare const record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
22
|
-
|
|
23
|
-
declare const _default: {
|
|
24
|
-
init(cfg?: any): void;
|
|
25
|
-
wrapAxios(instance: any): void;
|
|
26
|
-
setAxiosInstance(instance: any): void;
|
|
27
|
-
get(url: string, cfg?: any): Promise<any>;
|
|
28
|
-
post(url: string, body?: any, cfg?: any): Promise<any>;
|
|
29
|
-
put(url: string, body?: any, cfg?: any): Promise<any>;
|
|
30
|
-
del(url: string, cfg?: any): Promise<any>;
|
|
31
|
-
fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
32
|
-
record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
33
|
-
default: {
|
|
34
|
-
init: typeof init;
|
|
35
|
-
wrapAxios: typeof wrapAxios;
|
|
36
|
-
setAxiosInstance: typeof setAxiosInstance;
|
|
37
|
-
get: typeof get;
|
|
38
|
-
post: typeof post;
|
|
39
|
-
put: typeof put;
|
|
40
|
-
del: typeof del;
|
|
41
|
-
fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
|
|
42
|
-
record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
|
|
43
|
-
};
|
|
44
|
-
ReqwiseDevTools: typeof ReqwiseDevTools;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { ReqwiseDevTools, _default as default, del, fetch, get, init, post, put, record, setAxiosInstance, wrapAxios };
|