reqwise-react 1.0.0 → 1.1.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @reqwise/react@0.0.0 build C:\Users\PC\Desktop\Code\reqwise\packages\react
2
+ > reqwise-react@1.0.0 build C:\Users\PC\Desktop\Code\reqwise\packages\react
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  CJS Build start
12
12
  ESM Build start
13
- ESM dist\index.mjs 2.86 KB
14
- ESM dist\index.mjs.map 4.93 KB
13
+ CJS dist\index.js 4.69 KB
14
+ CJS dist\index.js.map 5.41 KB
15
+ CJS ⚡️ Build success in 15ms
16
+ ESM dist\index.mjs 2.85 KB
17
+ ESM dist\index.mjs.map 5.25 KB
15
18
  ESM ⚡️ Build success in 16ms
16
- CJS dist\index.js 4.70 KB
17
- CJS dist\index.js.map 5.09 KB
18
- CJS ⚡️ Build success in 16ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 622ms
21
- DTS dist\index.d.ts 2.18 KB
22
- DTS dist\index.d.mts 2.18 KB
20
+ DTS ⚡️ Build success in 602ms
21
+ DTS dist\index.d.ts 2.17 KB
22
+ DTS dist\index.d.mts 2.17 KB
package/dist/index.d.mts CHANGED
@@ -1,47 +1,44 @@
1
1
  import * as _reqwise_core from '@reqwise/core';
2
+ import { ReqwiseConfig, RequestConfig } from '@reqwise/core';
2
3
  import React from 'react';
3
4
 
4
- type Props = {
5
- defaultOpen?: boolean;
6
- theme?: 'light' | 'dark';
7
- axiosInstance?: any;
8
- defaultLang?: string;
9
- placement?: 'left' | 'right' | 'top' | 'bottom';
5
+ type ReqwiseDevToolsProps = ReqwiseConfig & {
6
+ enabled?: boolean;
10
7
  };
11
- declare function ReqwiseDevTools({ defaultOpen, theme, axiosInstance, defaultLang, placement }: Props): React.ReactElement | null;
8
+ declare function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null;
12
9
 
13
- declare function init(cfg?: any): void;
10
+ declare function init(cfg?: Partial<ReqwiseConfig>): void;
14
11
  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>;
12
+ declare function get(url: string, cfg?: RequestConfig): Promise<any>;
13
+ declare function post(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
14
+ declare function put(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
15
+ declare function patch(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
16
+ declare function del(url: string, cfg?: RequestConfig): Promise<any>;
17
+ declare const fetch: (input: RequestInfo, init?: RequestInit & RequestConfig) => Promise<Response>;
21
18
  declare const record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
22
19
 
23
20
  declare const _default: {
24
- init(cfg?: any): void;
21
+ init(cfg?: Partial<_reqwise_core.ReqwiseConfig>): void;
25
22
  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>;
23
+ get(url: string, cfg?: _reqwise_core.RequestConfig): Promise<any>;
24
+ post(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
25
+ put(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
26
+ patch(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
27
+ del(url: string, cfg?: _reqwise_core.RequestConfig): Promise<any>;
31
28
  fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
32
29
  record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
33
30
  default: {
34
31
  init: typeof init;
35
32
  wrapAxios: typeof wrapAxios;
36
- setAxiosInstance: typeof setAxiosInstance;
37
33
  get: typeof get;
38
34
  post: typeof post;
39
35
  put: typeof put;
40
- del: typeof del;
36
+ patch: typeof patch;
37
+ delete: typeof del;
41
38
  fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
42
39
  record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
43
40
  };
44
41
  ReqwiseDevTools: typeof ReqwiseDevTools;
45
42
  };
46
43
 
47
- export { ReqwiseDevTools, _default as default, del, fetch, get, init, post, put, record, setAxiosInstance, wrapAxios };
44
+ export { ReqwiseDevTools, _default as default, del, fetch, get, init, patch, post, put, record, wrapAxios };
package/dist/index.d.ts CHANGED
@@ -1,47 +1,44 @@
1
1
  import * as _reqwise_core from '@reqwise/core';
2
+ import { ReqwiseConfig, RequestConfig } from '@reqwise/core';
2
3
  import React from 'react';
3
4
 
4
- type Props = {
5
- defaultOpen?: boolean;
6
- theme?: 'light' | 'dark';
7
- axiosInstance?: any;
8
- defaultLang?: string;
9
- placement?: 'left' | 'right' | 'top' | 'bottom';
5
+ type ReqwiseDevToolsProps = ReqwiseConfig & {
6
+ enabled?: boolean;
10
7
  };
11
- declare function ReqwiseDevTools({ defaultOpen, theme, axiosInstance, defaultLang, placement }: Props): React.ReactElement | null;
8
+ declare function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null;
12
9
 
13
- declare function init(cfg?: any): void;
10
+ declare function init(cfg?: Partial<ReqwiseConfig>): void;
14
11
  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>;
12
+ declare function get(url: string, cfg?: RequestConfig): Promise<any>;
13
+ declare function post(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
14
+ declare function put(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
15
+ declare function patch(url: string, body?: any, cfg?: RequestConfig): Promise<any>;
16
+ declare function del(url: string, cfg?: RequestConfig): Promise<any>;
17
+ declare const fetch: (input: RequestInfo, init?: RequestInit & RequestConfig) => Promise<Response>;
21
18
  declare const record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
22
19
 
23
20
  declare const _default: {
24
- init(cfg?: any): void;
21
+ init(cfg?: Partial<_reqwise_core.ReqwiseConfig>): void;
25
22
  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>;
23
+ get(url: string, cfg?: _reqwise_core.RequestConfig): Promise<any>;
24
+ post(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
25
+ put(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
26
+ patch(url: string, body?: any, cfg?: _reqwise_core.RequestConfig): Promise<any>;
27
+ del(url: string, cfg?: _reqwise_core.RequestConfig): Promise<any>;
31
28
  fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
32
29
  record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
33
30
  default: {
34
31
  init: typeof init;
35
32
  wrapAxios: typeof wrapAxios;
36
- setAxiosInstance: typeof setAxiosInstance;
37
33
  get: typeof get;
38
34
  post: typeof post;
39
35
  put: typeof put;
40
- del: typeof del;
36
+ patch: typeof patch;
37
+ delete: typeof del;
41
38
  fetch: (input: RequestInfo, init?: RequestInit & _reqwise_core.RequestConfig) => Promise<Response>;
42
39
  record: (entry: Partial<_reqwise_core.ReqwiseEntry>) => void;
43
40
  };
44
41
  ReqwiseDevTools: typeof ReqwiseDevTools;
45
42
  };
46
43
 
47
- export { ReqwiseDevTools, _default as default, del, fetch, get, init, post, put, record, setAxiosInstance, wrapAxios };
44
+ export { ReqwiseDevTools, _default as default, del, fetch, get, init, patch, post, put, record, wrapAxios };
package/dist/index.js CHANGED
@@ -36,10 +36,10 @@ __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);
@@ -56,65 +56,87 @@ __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
65
  var import_core = __toESM(require("@reqwise/core"));
66
66
  var _axiosInstance = null;
67
67
  function init(cfg) {
68
- return import_core.default.ReqwiseClient.init(cfg);
68
+ import_core.default.ReqwiseClient.init(cfg);
69
69
  }
70
70
  function wrapAxios(instance) {
71
71
  _axiosInstance = instance;
72
- return import_core.default.ReqwiseClient.wrapAxios(instance);
73
- }
74
- function setAxiosInstance(instance) {
75
- _axiosInstance = instance;
76
- return import_core.default.ReqwiseClient.wrapAxios(instance);
72
+ import_core.default.ReqwiseClient.wrapAxios(instance);
77
73
  }
78
74
  async function get(url, cfg) {
79
- if (_axiosInstance && typeof _axiosInstance.get === "function") return _axiosInstance.get(url, cfg);
80
- return import_core.default.ReqwiseClient.fetch(url, { method: "GET", ...cfg || {} });
75
+ if (_axiosInstance && typeof _axiosInstance.get === "function") {
76
+ return _axiosInstance.get(url, cfg);
77
+ }
78
+ return import_core.default.ReqwiseClient.get(url, cfg);
81
79
  }
82
80
  async function post(url, body, cfg) {
83
- if (_axiosInstance && typeof _axiosInstance.post === "function") return _axiosInstance.post(url, body, cfg);
84
- return import_core.default.ReqwiseClient.fetch(url, { method: "POST", body: JSON.stringify(body), ...cfg || {} });
81
+ if (_axiosInstance && typeof _axiosInstance.post === "function") {
82
+ return _axiosInstance.post(url, body, cfg);
83
+ }
84
+ return import_core.default.ReqwiseClient.post(url, body, cfg);
85
85
  }
86
86
  async function put(url, body, cfg) {
87
- if (_axiosInstance && typeof _axiosInstance.put === "function") return _axiosInstance.put(url, body, cfg);
88
- return import_core.default.ReqwiseClient.fetch(url, { method: "PUT", body: JSON.stringify(body), ...cfg || {} });
87
+ if (_axiosInstance && typeof _axiosInstance.put === "function") {
88
+ return _axiosInstance.put(url, body, cfg);
89
+ }
90
+ return import_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_core.default.ReqwiseClient.patch(url, body, cfg);
89
97
  }
90
98
  async function del(url, cfg) {
91
- if (_axiosInstance && typeof _axiosInstance.delete === "function") return _axiosInstance.delete(url, cfg);
92
- return import_core.default.ReqwiseClient.fetch(url, { method: "DELETE", ...cfg || {} });
99
+ if (_axiosInstance && typeof _axiosInstance.delete === "function") {
100
+ return _axiosInstance.delete(url, cfg);
101
+ }
102
+ return import_core.default.ReqwiseClient.delete(url, cfg);
93
103
  }
94
104
  var fetch = import_core.default.ReqwiseClient.fetch;
95
105
  var record = import_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
- del,
112
+ patch,
113
+ delete: del,
104
114
  fetch,
105
115
  record
106
116
  };
107
117
 
108
118
  // src/ReqwiseDevTools.tsx
109
- function ReqwiseDevTools({ defaultOpen = false, theme = "dark", axiosInstance, defaultLang = "en", placement = "right" }) {
119
+ function ReqwiseDevTools(props) {
120
+ if (props.enabled === false) return null;
110
121
  (0, import_react.useEffect)(() => {
111
- init({ defaultOpen, defaultLang });
112
- if (axiosInstance) setAxiosInstance(axiosInstance);
113
- import_core2.panel.setRenderer(import_core2.renderer);
114
- import_core2.panel.mount({ defaultOpen, theme, placement });
115
- return () => {
116
- import_core2.panel.unmount();
117
- };
122
+ try {
123
+ init(props);
124
+ if (props.axiosInstance) {
125
+ wrapAxios(props.axiosInstance);
126
+ }
127
+ import_core2.panel.setRenderer(import_core2.renderer);
128
+ import_core2.panel.mount({
129
+ defaultOpen: props.defaultOpen,
130
+ placement: props.placement,
131
+ hotkey: props.hotkey,
132
+ theme: props.theme
133
+ });
134
+ return () => {
135
+ import_core2.panel.unmount();
136
+ };
137
+ } catch (e) {
138
+ console.error("[reqwise] ReqwiseDevTools error", e);
139
+ }
118
140
  }, []);
119
141
  return null;
120
142
  }
@@ -132,10 +154,10 @@ var index_default = _default;
132
154
  fetch,
133
155
  get,
134
156
  init,
157
+ patch,
135
158
  post,
136
159
  put,
137
160
  record,
138
- setAxiosInstance,
139
161
  wrapAxios
140
162
  });
141
163
  //# 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":["import ReqwiseDevTools from './ReqwiseDevTools'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\nexport { ReqwiseDevTools }\r\nexport * from './ReqwiseClient'\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 { storage, panel, renderer } from '@reqwise/core'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\ntype Props = {\r\n defaultOpen?: boolean\r\n theme?: 'light' | 'dark'\r\n axiosInstance?: any\r\n defaultLang?: string\r\n placement?: 'left' | 'right' | 'top' | 'bottom'\r\n}\r\n\r\nexport default function ReqwiseDevTools({ defaultOpen = false, theme = 'dark', axiosInstance, defaultLang = 'en', placement = 'right' }: Props): React.ReactElement | null {\r\n useEffect(() => {\r\n // initialize core client with default config and default language\r\n ReqwiseClient.init({ defaultOpen, defaultLang })\r\n if (axiosInstance) ReqwiseClient.setAxiosInstance(axiosInstance)\r\n // set renderer BEFORE mounting so it's ready when defaultOpen triggers render\r\n panel.setRenderer(renderer)\r\n // now mount the core panel into document.body\r\n panel.mount({ defaultOpen, theme: theme as any, placement })\r\n return () => {\r\n panel.unmount()\r\n }\r\n }, [])\r\n\r\n // panel renders its own toggle button and aside nothing to render here\r\n return null\r\n}\r\n","import Core from '@reqwise/core'\r\n\r\nlet _axiosInstance: any = null\r\n\r\nexport function init(cfg?: any) {\r\n return Core.ReqwiseClient.init(cfg)\r\n}\r\n\r\nexport function wrapAxios(instance: any) {\r\n _axiosInstance = instance\r\n return Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport function setAxiosInstance(instance: any) {\r\n _axiosInstance = instance\r\n return Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport async function get(url: string, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.get === 'function') return _axiosInstance.get(url, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'GET', ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function post(url: string, body?: any, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.post === 'function') return _axiosInstance.post(url, body, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'POST', body: JSON.stringify(body), ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function put(url: string, body?: any, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.put === 'function') return _axiosInstance.put(url, body, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'PUT', body: JSON.stringify(body), ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function del(url: string, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.delete === 'function') return _axiosInstance.delete(url, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'DELETE', ...(cfg || {}) } as any)\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 setAxiosInstance,\r\n get,\r\n post,\r\n put,\r\n 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,eAAyC;;;ACDzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,IAAI,iBAAsB;AAEnB,SAAS,KAAK,KAAW;AAC9B,SAAO,YAAAC,QAAK,cAAc,KAAK,GAAG;AACpC;AAEO,SAAS,UAAU,UAAe;AACvC,mBAAiB;AACjB,SAAO,YAAAA,QAAK,cAAc,UAAU,QAAQ;AAC9C;AAEO,SAAS,iBAAiB,UAAe;AAC9C,mBAAiB;AACjB,SAAO,YAAAA,QAAK,cAAc,UAAU,QAAQ;AAC9C;AAEA,eAAsB,IAAI,KAAa,KAAW;AAChD,MAAI,kBAAkB,OAAO,eAAe,QAAQ,WAAY,QAAO,eAAe,IAAI,KAAK,GAAG;AAClG,SAAO,YAAAA,QAAK,cAAc,MAAM,KAAK,EAAE,QAAQ,OAAO,GAAI,OAAO,CAAC,EAAG,CAAQ;AAC/E;AAEA,eAAsB,KAAK,KAAa,MAAY,KAAW;AAC7D,MAAI,kBAAkB,OAAO,eAAe,SAAS,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,EAChB;AAAA,EACA,GAAG;AACJ;AAEA,IAAO,gBAAQ;","names":["import_core","Core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts"],"sourcesContent":["import ReqwiseDevTools from './ReqwiseDevTools'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\nexport { ReqwiseDevTools }\r\nexport * from './ReqwiseClient'\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 } 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 default 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 before mounting\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 })\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,eAAgC;;;ACDhC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AK,cAAc;AAEzC,IAAO,wBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF;;;ADrDe,SAAR,gBAAiC,OAAwD;AAE9F,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,yBAAM,YAAY,qBAAQ;AAG1B,yBAAM,MAAM;AAAA,QACV,aAAa,MAAM;AAAA,QACnB,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,MACf,CAAC;AAED,aAAO,MAAM;AACX,2BAAM,QAAQ;AAAA,MAChB;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,mCAAmC,CAAC;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,CAAC;AAGL,SAAO;AACT;;;ADtCA,IAAM,WAAW;AAAA,EAChB;AAAA,EACA,GAAG;AACJ;AAEA,IAAO,gBAAQ;","names":["import_core","Core"]}
package/dist/index.mjs CHANGED
@@ -16,65 +16,87 @@ __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
25
  import Core from "@reqwise/core";
26
26
  var _axiosInstance = null;
27
27
  function init(cfg) {
28
- return Core.ReqwiseClient.init(cfg);
28
+ Core.ReqwiseClient.init(cfg);
29
29
  }
30
30
  function wrapAxios(instance) {
31
31
  _axiosInstance = instance;
32
- return Core.ReqwiseClient.wrapAxios(instance);
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") return _axiosInstance.get(url, cfg);
40
- return Core.ReqwiseClient.fetch(url, { method: "GET", ...cfg || {} });
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") return _axiosInstance.post(url, body, cfg);
44
- return Core.ReqwiseClient.fetch(url, { method: "POST", body: JSON.stringify(body), ...cfg || {} });
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") return _axiosInstance.put(url, body, cfg);
48
- return Core.ReqwiseClient.fetch(url, { method: "PUT", body: JSON.stringify(body), ...cfg || {} });
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") return _axiosInstance.delete(url, cfg);
52
- return Core.ReqwiseClient.fetch(url, { method: "DELETE", ...cfg || {} });
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
- del,
72
+ patch,
73
+ delete: del,
64
74
  fetch,
65
75
  record
66
76
  };
67
77
 
68
78
  // src/ReqwiseDevTools.tsx
69
- function ReqwiseDevTools({ defaultOpen = false, theme = "dark", axiosInstance, defaultLang = "en", placement = "right" }) {
79
+ function ReqwiseDevTools(props) {
80
+ if (props.enabled === false) return null;
70
81
  useEffect(() => {
71
- init({ defaultOpen, defaultLang });
72
- if (axiosInstance) setAxiosInstance(axiosInstance);
73
- panel.setRenderer(renderer);
74
- panel.mount({ defaultOpen, theme, placement });
75
- return () => {
76
- panel.unmount();
77
- };
82
+ try {
83
+ init(props);
84
+ if (props.axiosInstance) {
85
+ wrapAxios(props.axiosInstance);
86
+ }
87
+ panel.setRenderer(renderer);
88
+ panel.mount({
89
+ defaultOpen: props.defaultOpen,
90
+ placement: props.placement,
91
+ hotkey: props.hotkey,
92
+ theme: props.theme
93
+ });
94
+ return () => {
95
+ panel.unmount();
96
+ };
97
+ } catch (e) {
98
+ console.error("[reqwise] ReqwiseDevTools error", e);
99
+ }
78
100
  }, []);
79
101
  return null;
80
102
  }
@@ -92,10 +114,10 @@ export {
92
114
  fetch,
93
115
  get,
94
116
  init,
117
+ patch,
95
118
  post,
96
119
  put,
97
120
  record,
98
- setAxiosInstance,
99
121
  wrapAxios
100
122
  };
101
123
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts","../src/index.ts"],"sourcesContent":["import React, { useEffect } from 'react'\r\nimport { storage, panel, renderer } from '@reqwise/core'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\ntype Props = {\r\n defaultOpen?: boolean\r\n theme?: 'light' | 'dark'\r\n axiosInstance?: any\r\n defaultLang?: string\r\n placement?: 'left' | 'right' | 'top' | 'bottom'\r\n}\r\n\r\nexport default function ReqwiseDevTools({ defaultOpen = false, theme = 'dark', axiosInstance, defaultLang = 'en', placement = 'right' }: Props): React.ReactElement | null {\r\n useEffect(() => {\r\n // initialize core client with default config and default language\r\n ReqwiseClient.init({ defaultOpen, defaultLang })\r\n if (axiosInstance) ReqwiseClient.setAxiosInstance(axiosInstance)\r\n // set renderer BEFORE mounting so it's ready when defaultOpen triggers render\r\n panel.setRenderer(renderer)\r\n // now mount the core panel into document.body\r\n panel.mount({ defaultOpen, theme: theme as any, placement })\r\n return () => {\r\n panel.unmount()\r\n }\r\n }, [])\r\n\r\n // panel renders its own toggle button and aside nothing to render here\r\n return null\r\n}\r\n","import Core from '@reqwise/core'\r\n\r\nlet _axiosInstance: any = null\r\n\r\nexport function init(cfg?: any) {\r\n return Core.ReqwiseClient.init(cfg)\r\n}\r\n\r\nexport function wrapAxios(instance: any) {\r\n _axiosInstance = instance\r\n return Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport function setAxiosInstance(instance: any) {\r\n _axiosInstance = instance\r\n return Core.ReqwiseClient.wrapAxios(instance)\r\n}\r\n\r\nexport async function get(url: string, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.get === 'function') return _axiosInstance.get(url, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'GET', ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function post(url: string, body?: any, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.post === 'function') return _axiosInstance.post(url, body, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'POST', body: JSON.stringify(body), ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function put(url: string, body?: any, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.put === 'function') return _axiosInstance.put(url, body, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'PUT', body: JSON.stringify(body), ...(cfg || {}) } as any)\r\n}\r\n\r\nexport async function del(url: string, cfg?: any) {\r\n if (_axiosInstance && typeof _axiosInstance.delete === 'function') return _axiosInstance.delete(url, cfg)\r\n return Core.ReqwiseClient.fetch(url, { method: 'DELETE', ...(cfg || {}) } as any)\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 setAxiosInstance,\r\n get,\r\n post,\r\n put,\r\n del,\r\n fetch,\r\n record,\r\n}\r\n","import ReqwiseDevTools from './ReqwiseDevTools'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\nexport { ReqwiseDevTools }\r\nexport * from './ReqwiseClient'\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,SAAkB,OAAO,gBAAgB;;;ACDzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAO,UAAU;AAEjB,IAAI,iBAAsB;AAEnB,SAAS,KAAK,KAAW;AAC9B,SAAO,KAAK,cAAc,KAAK,GAAG;AACpC;AAEO,SAAS,UAAU,UAAe;AACvC,mBAAiB;AACjB,SAAO,KAAK,cAAc,UAAU,QAAQ;AAC9C;AAEO,SAAS,iBAAiB,UAAe;AAC9C,mBAAiB;AACjB,SAAO,KAAK,cAAc,UAAU,QAAQ;AAC9C;AAEA,eAAsB,IAAI,KAAa,KAAW;AAChD,MAAI,kBAAkB,OAAO,eAAe,QAAQ,WAAY,QAAO,eAAe,IAAI,KAAK,GAAG;AAClG,SAAO,KAAK,cAAc,MAAM,KAAK,EAAE,QAAQ,OAAO,GAAI,OAAO,CAAC,EAAG,CAAQ;AAC/E;AAEA,eAAsB,KAAK,KAAa,MAAY,KAAW;AAC7D,MAAI,kBAAkB,OAAO,eAAe,SAAS,WAAY,QAAO,eAAe,KAAK,KAAK,MAA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["../src/ReqwiseDevTools.tsx","../src/ReqwiseClient.ts","../src/index.ts"],"sourcesContent":["import React, { useEffect } from 'react'\r\nimport { panel, renderer } 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 default 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 before mounting\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 })\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","import ReqwiseDevTools from './ReqwiseDevTools'\r\nimport * as ReqwiseClient from './ReqwiseClient'\r\n\r\nexport { ReqwiseDevTools }\r\nexport * from './ReqwiseClient'\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,gBAAgB;;;ACDhC;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;AA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AAK,KAAK;AAGxB,UAAI,MAAM,eAAe;AACvB,QAAc,UAAU,MAAM,aAAa;AAAA,MAC7C;AAGA,YAAM,YAAY,QAAQ;AAG1B,YAAM,MAAM;AAAA,QACV,aAAa,MAAM;AAAA,QACnB,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA,QACd,OAAO,MAAM;AAAA,MACf,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;;;AEtCA,IAAM,WAAW;AAAA,EAChB;AAAA,EACA,GAAG;AACJ;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "reqwise-react",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
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
  }
11
12
  },
12
13
  "types": "dist/index.d.ts",
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "type-check": "tsc -p tsconfig.json --noEmit"
17
+ },
13
18
  "peerDependencies": {
14
19
  "axios": ">=1.0.0",
15
20
  "react": ">=17.0.0"
@@ -20,13 +25,9 @@
20
25
  }
21
26
  },
22
27
  "dependencies": {
23
- "@reqwise/core": "npm:reqwise-core@^1.0.0"
28
+ "@reqwise/core": "workspace:^"
24
29
  },
25
30
  "devDependencies": {
26
31
  "@types/node": "^25.8.0"
27
- },
28
- "scripts": {
29
- "build": "tsup",
30
- "type-check": "tsc -p tsconfig.json --noEmit"
31
32
  }
32
- }
33
+ }
@@ -1,39 +1,50 @@
1
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?: any) {
6
- return Core.ReqwiseClient.init(cfg)
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
- return Core.ReqwiseClient.wrapAxios(instance)
12
+ Core.ReqwiseClient.wrapAxios(instance)
12
13
  }
13
14
 
14
- export function setAxiosInstance(instance: any) {
15
- _axiosInstance = instance
16
- return Core.ReqwiseClient.wrapAxios(instance)
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 get(url: string, cfg?: any) {
20
- if (_axiosInstance && typeof _axiosInstance.get === 'function') return _axiosInstance.get(url, cfg)
21
- return Core.ReqwiseClient.fetch(url, { method: 'GET', ...(cfg || {}) } as any)
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 post(url: string, body?: any, cfg?: any) {
25
- if (_axiosInstance && typeof _axiosInstance.post === 'function') return _axiosInstance.post(url, body, cfg)
26
- return Core.ReqwiseClient.fetch(url, { method: 'POST', body: JSON.stringify(body), ...(cfg || {}) } as any)
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 put(url: string, body?: any, cfg?: any) {
30
- if (_axiosInstance && typeof _axiosInstance.put === 'function') return _axiosInstance.put(url, body, cfg)
31
- return Core.ReqwiseClient.fetch(url, { method: 'PUT', body: JSON.stringify(body), ...(cfg || {}) } as any)
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?: any) {
35
- if (_axiosInstance && typeof _axiosInstance.delete === 'function') return _axiosInstance.delete(url, cfg)
36
- return Core.ReqwiseClient.fetch(url, { method: 'DELETE', ...(cfg || {}) } as any)
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
- del,
59
+ patch,
60
+ delete: del,
50
61
  fetch,
51
62
  record,
52
63
  }
@@ -1,29 +1,47 @@
1
1
  import React, { useEffect } from 'react'
2
- import { storage, panel, renderer } from '@reqwise/core'
2
+ import { panel, renderer } from '@reqwise/core'
3
3
  import * as ReqwiseClient from './ReqwiseClient'
4
+ import type { ReqwiseConfig } from '@reqwise/core'
4
5
 
5
- type Props = {
6
- defaultOpen?: boolean
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 default function ReqwiseDevTools({ defaultOpen = false, theme = 'dark', axiosInstance, defaultLang = 'en', placement = 'right' }: Props): React.ReactElement | null {
10
+ export default function ReqwiseDevTools(props: ReqwiseDevToolsProps): React.ReactElement | null {
11
+ // No-op if disabled
12
+ if (props.enabled === false) return null
13
+
14
14
  useEffect(() => {
15
- // initialize core client with default config and default language
16
- ReqwiseClient.init({ defaultOpen, defaultLang })
17
- if (axiosInstance) ReqwiseClient.setAxiosInstance(axiosInstance)
18
- // set renderer BEFORE mounting so it's ready when defaultOpen triggers render
19
- panel.setRenderer(renderer)
20
- // now mount the core panel into document.body
21
- panel.mount({ defaultOpen, theme: theme as any, placement })
22
- return () => {
23
- panel.unmount()
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 before mounting
25
+ panel.setRenderer(renderer)
26
+
27
+ // Mount panel into document.body
28
+ panel.mount({
29
+ defaultOpen: props.defaultOpen,
30
+ placement: props.placement,
31
+ hotkey: props.hotkey,
32
+ theme: props.theme,
33
+ size: props.size,
34
+ opacity: props.opacity,
35
+ })
36
+
37
+ return () => {
38
+ panel.unmount()
39
+ }
40
+ } catch (e) {
41
+ console.error('[reqwise] ReqwiseDevTools error', e)
24
42
  }
25
43
  }, [])
26
44
 
27
- // panel renders its own toggle button and aside nothing to render here
45
+ // Nothing to render in React tree aside renders directly to document.body
28
46
  return null
29
47
  }
package/tsup.config.ts CHANGED
@@ -3,7 +3,11 @@ import { defineConfig } from 'tsup'
3
3
  export default defineConfig({
4
4
  entry: ['src/index.ts'],
5
5
  format: ['cjs', 'esm'],
6
- dts: true,
6
+ dts: {
7
+ resolve: true,
8
+ compilerOptions: { skipLibCheck: true }
9
+ },
7
10
  sourcemap: true,
8
11
  clean: true,
12
+ splitting: false,
9
13
  })