msw-dev-tool 1.1.6 → 1.1.8
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/cjs/index.js +20 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/msw-dev-tool.css +1 -1
- package/dist/esm/index.js +20 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/msw-dev-tool.css +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
@@ -27960,13 +27960,14 @@ const useUiControlStore = zustand.create((set) => ({
|
|
27960
27960
|
const HttpControl = () => {
|
27961
27961
|
const table = useFlattenHandlersTable();
|
27962
27962
|
const { setDebuggerHandler } = useUiControlStore();
|
27963
|
+
const currentHandler = useUiControlStore((state) => state.currentHandler);
|
27963
27964
|
return (React.createElement(p$3, { style: { flex: 3, overflowY: "auto" }, direction: "column", gap: "4" },
|
27964
27965
|
React.createElement(r$8, { as: "h2", size: "5" }, "Handlers"),
|
27965
27966
|
React.createElement(m, { onDragStart: (e) => e.stopPropagation(), style: { userSelect: "text" } },
|
27966
27967
|
React.createElement(d, null, table.getHeaderGroups().map((headerGroup) => (React.createElement(P, { key: headerGroup.id }, headerGroup.headers.map((header) => (React.createElement(f$1, { key: header.id }, header.isPlaceholder
|
27967
27968
|
? null
|
27968
27969
|
: flexRender(header.column.columnDef.header, header.getContext())))))))),
|
27969
|
-
React.createElement(b, null, table.getRowModel().rows.map((row) => (React.createElement(P, { key: row.id, align: "center", className:
|
27970
|
+
React.createElement(b, null, table.getRowModel().rows.map((row) => (React.createElement(P, { key: row.id, align: "center", className: `msw-dt-http-control-row ${row.original.handler === currentHandler && "msw-dt-current-row"}`, onClick: () => {
|
27970
27971
|
setDebuggerHandler(row.original.handler);
|
27971
27972
|
} }, row.getVisibleCells().map((cell) => (React.createElement(T, { key: cell.id }, flexRender(cell.column.columnDef.cell, cell.getContext())))))))))));
|
27972
27973
|
};
|
@@ -28129,41 +28130,35 @@ const RequestPreview = ({ url, paramValues, headers = {}, searchParams = {}, })
|
|
28129
28130
|
} }, JSON.stringify(response, null, 2)))))));
|
28130
28131
|
};
|
28131
28132
|
|
28133
|
+
/**
|
28134
|
+
* - It uses `zustand` global state.
|
28135
|
+
* - remounting of the inner component that uses local states.
|
28136
|
+
* - To force a component to be remounted, use `key` prop.
|
28137
|
+
*/
|
28132
28138
|
const HandlerDebugger = () => {
|
28133
|
-
var _a;
|
28134
28139
|
const { currentHandler: handler } = useUiControlStore();
|
28135
|
-
const
|
28140
|
+
const key = `${handler === null || handler === void 0 ? void 0 : handler.info.path}-${handler === null || handler === void 0 ? void 0 : handler.info.method}`;
|
28141
|
+
return (React.createElement(Container, null, handler ? (React.createElement(_HandlerDebugger, { handler: handler, key: key })) : (React.createElement(p$b, null, "Select a handler from the table to debug"))));
|
28142
|
+
};
|
28143
|
+
const _HandlerDebugger = ({ handler }) => {
|
28144
|
+
const path = handler === null || handler === void 0 ? void 0 : handler.info.path;
|
28136
28145
|
const url = new URL(String(path), location.href);
|
28137
28146
|
const { params } = msw.matchRequestUrl(url, path, url.origin);
|
28138
|
-
const [paramValues, setParamValues] = React.useState(
|
28147
|
+
const [paramValues, setParamValues] = React.useState(params
|
28148
|
+
? Object.keys(params).reduce((acc, key) => ({
|
28149
|
+
...acc,
|
28150
|
+
[key]: "",
|
28151
|
+
}), {})
|
28152
|
+
: undefined);
|
28139
28153
|
const [headers, setHeaders] = React.useState({});
|
28140
28154
|
const [searchParams, setSearchParams] = React.useState({});
|
28141
|
-
/**
|
28142
|
-
* Initialize state to clear previous handler data
|
28143
|
-
*/
|
28144
|
-
React.useEffect(() => {
|
28145
|
-
if (params) {
|
28146
|
-
setParamValues(Object.keys(params).reduce((acc, key) => ({
|
28147
|
-
...acc,
|
28148
|
-
[key]: "",
|
28149
|
-
}), {}));
|
28150
|
-
}
|
28151
|
-
else {
|
28152
|
-
setParamValues(undefined);
|
28153
|
-
}
|
28154
|
-
setHeaders({});
|
28155
|
-
setSearchParams({});
|
28156
|
-
}, [handler]);
|
28157
28155
|
const handleParamChange = (key, value) => {
|
28158
28156
|
setParamValues((prev) => ({
|
28159
28157
|
...prev,
|
28160
28158
|
[key]: value,
|
28161
28159
|
}));
|
28162
28160
|
};
|
28163
|
-
|
28164
|
-
return (React.createElement(Container, null,
|
28165
|
-
React.createElement(p$b, null, "Select a handler from the table to debug")));
|
28166
|
-
return (React.createElement(Container, null,
|
28161
|
+
return (React.createElement(React.Fragment, null,
|
28167
28162
|
React.createElement(p$b, { className: "msw-dt-sub-text", style: { overflowX: "scroll" } }, url.toString()),
|
28168
28163
|
React.createElement(PathParamSetter, { paramValues: paramValues, onParamChange: handleParamChange }),
|
28169
28164
|
React.createElement(KeyValueInputList, { items: searchParams, setItems: setSearchParams, title: "Search Params" }),
|
@@ -28208,6 +28203,7 @@ const MSWDevTool = () => {
|
|
28208
28203
|
borderRadius: "50%",
|
28209
28204
|
width: "3.5rem",
|
28210
28205
|
height: "3.5rem",
|
28206
|
+
margin: "1rem",
|
28211
28207
|
} }, "M")),
|
28212
28208
|
React.createElement(Drawer.Portal, null,
|
28213
28209
|
React.createElement(ThemeProvider, null,
|