@mcpc-tech/unplugin-dev-inspector-mcp 0.0.16 → 0.0.18
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/README.md +3 -4
- package/client/dist/inspector.iife.js +320 -320
- package/dist/index.cjs +68 -69
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +68 -69
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,6 @@ async function launchBrowserWithDevTools(options) {
|
|
|
43
43
|
//#region src/core.ts
|
|
44
44
|
const unplugin$1 = (0, unplugin.createUnplugin)((options = {}) => {
|
|
45
45
|
const enabled = options.enabled ?? process.env.NODE_ENV !== "production";
|
|
46
|
-
const enableMcp = options.enableMcp ?? true;
|
|
47
46
|
const virtualModuleName = options.virtualModuleName ?? "virtual:dev-inspector-mcp";
|
|
48
47
|
const webpackModuleName = virtualModuleName.replace("virtual:", "");
|
|
49
48
|
let resolvedHost = options.host || "localhost";
|
|
@@ -67,7 +66,8 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
67
66
|
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
68
67
|
host: '${resolvedHost}',
|
|
69
68
|
port: '${resolvedPort}',
|
|
70
|
-
base: '/'
|
|
69
|
+
base: '/',
|
|
70
|
+
showInspectorBar: ${options.showInspectorBar ?? true}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
// Dynamically load inspector script
|
|
@@ -122,6 +122,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
122
122
|
const host = options.host ?? (typeof viteHost === "string" ? viteHost : viteHost === true ? "0.0.0.0" : "localhost");
|
|
123
123
|
const port = options.port ?? server?.config.server.port ?? 5173;
|
|
124
124
|
const base = server?.config.base ?? "/";
|
|
125
|
+
const showInspectorBar = options.showInspectorBar ?? true;
|
|
125
126
|
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
126
127
|
return html.replace("</body>", `<dev-inspector-mcp></dev-inspector-mcp><script>
|
|
127
128
|
(function() {
|
|
@@ -131,7 +132,8 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
131
132
|
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
132
133
|
host: '${displayHost}',
|
|
133
134
|
port: '${port}',
|
|
134
|
-
base: '${base}'
|
|
135
|
+
base: '${base}',
|
|
136
|
+
showInspectorBar: ${showInspectorBar}
|
|
135
137
|
};
|
|
136
138
|
var script = document.createElement('script');
|
|
137
139
|
var config = window.__DEV_INSPECTOR_CONFIG__;
|
|
@@ -148,45 +150,44 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
148
150
|
}
|
|
149
151
|
},
|
|
150
152
|
async configureServer(server) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
185
|
-
}
|
|
153
|
+
const viteHost = server.config.server.host;
|
|
154
|
+
const serverContext = {
|
|
155
|
+
host: options.host ?? (typeof viteHost === "string" ? viteHost : viteHost === true ? "0.0.0.0" : "localhost"),
|
|
156
|
+
port: options.port ?? server.config.server.port ?? 5173
|
|
157
|
+
};
|
|
158
|
+
const displayHost = serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host;
|
|
159
|
+
const baseUrl = `http://${displayHost}:${serverContext.port}/__mcp__/sse`;
|
|
160
|
+
console.log(`[dev-inspector] 📡 MCP: ${baseUrl}\n`);
|
|
161
|
+
await require_config_updater.setupMcpMiddleware(server.middlewares, serverContext);
|
|
162
|
+
require_config_updater.setupAcpMiddleware(server.middlewares, serverContext, {
|
|
163
|
+
acpMode: options.acpMode,
|
|
164
|
+
acpModel: options.acpModel,
|
|
165
|
+
acpDelay: options.acpDelay
|
|
166
|
+
});
|
|
167
|
+
const root = server.config.root;
|
|
168
|
+
await require_config_updater.updateMcpConfigs(root, baseUrl, {
|
|
169
|
+
updateConfig: options.updateConfig,
|
|
170
|
+
updateConfigServerName: options.updateConfigServerName,
|
|
171
|
+
updateConfigAdditionalServers: options.updateConfigAdditionalServers,
|
|
172
|
+
customEditors: options.customEditors
|
|
173
|
+
});
|
|
174
|
+
if (options.autoOpenBrowser ?? false) {
|
|
175
|
+
const targetUrl = options.browserUrl ?? `http://${displayHost}:${serverContext.port}`;
|
|
176
|
+
setTimeout(async () => {
|
|
177
|
+
if (await launchBrowserWithDevTools({
|
|
178
|
+
url: targetUrl,
|
|
179
|
+
serverContext
|
|
180
|
+
})) console.log(`[dev-inspector] 🌐 Browser opened: ${targetUrl}`);
|
|
181
|
+
else console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to open browser manually.\n`);
|
|
182
|
+
}, 1e3);
|
|
183
|
+
} else {
|
|
184
|
+
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
185
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
186
186
|
}
|
|
187
187
|
require_config_updater.setupInspectorMiddleware(server.middlewares, {
|
|
188
188
|
agents: options.agents,
|
|
189
|
-
defaultAgent: options.defaultAgent
|
|
189
|
+
defaultAgent: options.defaultAgent,
|
|
190
|
+
showInspectorBar: options.showInspectorBar
|
|
190
191
|
});
|
|
191
192
|
},
|
|
192
193
|
handleHotUpdate() {}
|
|
@@ -213,36 +214,34 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
213
214
|
host,
|
|
214
215
|
port
|
|
215
216
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
245
|
-
}
|
|
217
|
+
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
218
|
+
const baseUrl = `http://${displayHost}:${port}/__mcp__/sse`;
|
|
219
|
+
console.log(`[dev-inspector] 📡 MCP (Standalone): ${baseUrl}\n`);
|
|
220
|
+
require_config_updater.setupMcpMiddleware(server, serverContext);
|
|
221
|
+
require_config_updater.setupAcpMiddleware(server, serverContext, {
|
|
222
|
+
acpMode: options.acpMode,
|
|
223
|
+
acpModel: options.acpModel,
|
|
224
|
+
acpDelay: options.acpDelay
|
|
225
|
+
});
|
|
226
|
+
const root = compiler.context;
|
|
227
|
+
await require_config_updater.updateMcpConfigs(root, baseUrl, {
|
|
228
|
+
updateConfig: options.updateConfig,
|
|
229
|
+
updateConfigServerName: options.updateConfigServerName,
|
|
230
|
+
updateConfigAdditionalServers: options.updateConfigAdditionalServers,
|
|
231
|
+
customEditors: options.customEditors
|
|
232
|
+
});
|
|
233
|
+
if (options.autoOpenBrowser ?? false) {
|
|
234
|
+
const targetUrl = options.browserUrl ?? `http://${displayHost}:${port}`;
|
|
235
|
+
setTimeout(async () => {
|
|
236
|
+
if (await launchBrowserWithDevTools({
|
|
237
|
+
url: targetUrl,
|
|
238
|
+
serverContext
|
|
239
|
+
})) console.log(`[dev-inspector] 🌐 Browser opened: ${targetUrl}`);
|
|
240
|
+
else console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to open browser manually.\n`);
|
|
241
|
+
}, 1e3);
|
|
242
|
+
} else {
|
|
243
|
+
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
244
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
246
245
|
}
|
|
247
246
|
require_config_updater.setupInspectorMiddleware(server, {
|
|
248
247
|
agents: options.agents,
|
package/dist/index.d.cts
CHANGED
|
@@ -74,11 +74,6 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
74
74
|
* @default true (automatically disabled in production)
|
|
75
75
|
*/
|
|
76
76
|
enabled?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Enable MCP server for AI integration
|
|
79
|
-
* @default true
|
|
80
|
-
*/
|
|
81
|
-
enableMcp?: boolean;
|
|
82
77
|
/**
|
|
83
78
|
* Custom host for MCP server URL
|
|
84
79
|
* Useful when behind a proxy or in Docker containers
|
|
@@ -121,7 +116,7 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
121
116
|
/**
|
|
122
117
|
* Automatically open browser with Chrome DevTools when dev server starts
|
|
123
118
|
* Uses Chrome DevTools Protocol for full debugging capabilities (console, network, etc.)
|
|
124
|
-
* @default
|
|
119
|
+
* @default false
|
|
125
120
|
*/
|
|
126
121
|
autoOpenBrowser?: boolean;
|
|
127
122
|
/**
|
|
@@ -130,6 +125,12 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
130
125
|
* @example "http://localhost:5173/dashboard"
|
|
131
126
|
*/
|
|
132
127
|
browserUrl?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Whether to show the inspector bar UI
|
|
130
|
+
* Set to false if you only want to use the editor integration
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
showInspectorBar?: boolean;
|
|
133
134
|
}
|
|
134
135
|
declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
135
136
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -74,11 +74,6 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
74
74
|
* @default true (automatically disabled in production)
|
|
75
75
|
*/
|
|
76
76
|
enabled?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Enable MCP server for AI integration
|
|
79
|
-
* @default true
|
|
80
|
-
*/
|
|
81
|
-
enableMcp?: boolean;
|
|
82
77
|
/**
|
|
83
78
|
* Custom host for MCP server URL
|
|
84
79
|
* Useful when behind a proxy or in Docker containers
|
|
@@ -121,7 +116,7 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
121
116
|
/**
|
|
122
117
|
* Automatically open browser with Chrome DevTools when dev server starts
|
|
123
118
|
* Uses Chrome DevTools Protocol for full debugging capabilities (console, network, etc.)
|
|
124
|
-
* @default
|
|
119
|
+
* @default false
|
|
125
120
|
*/
|
|
126
121
|
autoOpenBrowser?: boolean;
|
|
127
122
|
/**
|
|
@@ -130,6 +125,12 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
130
125
|
* @example "http://localhost:5173/dashboard"
|
|
131
126
|
*/
|
|
132
127
|
browserUrl?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Whether to show the inspector bar UI
|
|
130
|
+
* Set to false if you only want to use the editor integration
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
133
|
+
showInspectorBar?: boolean;
|
|
133
134
|
}
|
|
134
135
|
declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
135
136
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,6 @@ async function launchBrowserWithDevTools(options) {
|
|
|
42
42
|
//#region src/core.ts
|
|
43
43
|
const unplugin = createUnplugin((options = {}) => {
|
|
44
44
|
const enabled = options.enabled ?? process.env.NODE_ENV !== "production";
|
|
45
|
-
const enableMcp = options.enableMcp ?? true;
|
|
46
45
|
const virtualModuleName = options.virtualModuleName ?? "virtual:dev-inspector-mcp";
|
|
47
46
|
const webpackModuleName = virtualModuleName.replace("virtual:", "");
|
|
48
47
|
let resolvedHost = options.host || "localhost";
|
|
@@ -66,7 +65,8 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
66
65
|
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
67
66
|
host: '${resolvedHost}',
|
|
68
67
|
port: '${resolvedPort}',
|
|
69
|
-
base: '/'
|
|
68
|
+
base: '/',
|
|
69
|
+
showInspectorBar: ${options.showInspectorBar ?? true}
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
// Dynamically load inspector script
|
|
@@ -121,6 +121,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
121
121
|
const host = options.host ?? (typeof viteHost === "string" ? viteHost : viteHost === true ? "0.0.0.0" : "localhost");
|
|
122
122
|
const port = options.port ?? server?.config.server.port ?? 5173;
|
|
123
123
|
const base = server?.config.base ?? "/";
|
|
124
|
+
const showInspectorBar = options.showInspectorBar ?? true;
|
|
124
125
|
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
125
126
|
return html.replace("</body>", `<dev-inspector-mcp></dev-inspector-mcp><script>
|
|
126
127
|
(function() {
|
|
@@ -130,7 +131,8 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
130
131
|
window.__DEV_INSPECTOR_CONFIG__ = {
|
|
131
132
|
host: '${displayHost}',
|
|
132
133
|
port: '${port}',
|
|
133
|
-
base: '${base}'
|
|
134
|
+
base: '${base}',
|
|
135
|
+
showInspectorBar: ${showInspectorBar}
|
|
134
136
|
};
|
|
135
137
|
var script = document.createElement('script');
|
|
136
138
|
var config = window.__DEV_INSPECTOR_CONFIG__;
|
|
@@ -147,45 +149,44 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
147
149
|
}
|
|
148
150
|
},
|
|
149
151
|
async configureServer(server) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
184
|
-
}
|
|
152
|
+
const viteHost = server.config.server.host;
|
|
153
|
+
const serverContext = {
|
|
154
|
+
host: options.host ?? (typeof viteHost === "string" ? viteHost : viteHost === true ? "0.0.0.0" : "localhost"),
|
|
155
|
+
port: options.port ?? server.config.server.port ?? 5173
|
|
156
|
+
};
|
|
157
|
+
const displayHost = serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host;
|
|
158
|
+
const baseUrl = `http://${displayHost}:${serverContext.port}/__mcp__/sse`;
|
|
159
|
+
console.log(`[dev-inspector] 📡 MCP: ${baseUrl}\n`);
|
|
160
|
+
await setupMcpMiddleware(server.middlewares, serverContext);
|
|
161
|
+
setupAcpMiddleware(server.middlewares, serverContext, {
|
|
162
|
+
acpMode: options.acpMode,
|
|
163
|
+
acpModel: options.acpModel,
|
|
164
|
+
acpDelay: options.acpDelay
|
|
165
|
+
});
|
|
166
|
+
const root = server.config.root;
|
|
167
|
+
await updateMcpConfigs(root, baseUrl, {
|
|
168
|
+
updateConfig: options.updateConfig,
|
|
169
|
+
updateConfigServerName: options.updateConfigServerName,
|
|
170
|
+
updateConfigAdditionalServers: options.updateConfigAdditionalServers,
|
|
171
|
+
customEditors: options.customEditors
|
|
172
|
+
});
|
|
173
|
+
if (options.autoOpenBrowser ?? false) {
|
|
174
|
+
const targetUrl = options.browserUrl ?? `http://${displayHost}:${serverContext.port}`;
|
|
175
|
+
setTimeout(async () => {
|
|
176
|
+
if (await launchBrowserWithDevTools({
|
|
177
|
+
url: targetUrl,
|
|
178
|
+
serverContext
|
|
179
|
+
})) console.log(`[dev-inspector] 🌐 Browser opened: ${targetUrl}`);
|
|
180
|
+
else console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to open browser manually.\n`);
|
|
181
|
+
}, 1e3);
|
|
182
|
+
} else {
|
|
183
|
+
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
184
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
185
185
|
}
|
|
186
186
|
setupInspectorMiddleware(server.middlewares, {
|
|
187
187
|
agents: options.agents,
|
|
188
|
-
defaultAgent: options.defaultAgent
|
|
188
|
+
defaultAgent: options.defaultAgent,
|
|
189
|
+
showInspectorBar: options.showInspectorBar
|
|
189
190
|
});
|
|
190
191
|
},
|
|
191
192
|
handleHotUpdate() {}
|
|
@@ -212,36 +213,34 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
212
213
|
host,
|
|
213
214
|
port
|
|
214
215
|
};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
244
|
-
}
|
|
216
|
+
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
217
|
+
const baseUrl = `http://${displayHost}:${port}/__mcp__/sse`;
|
|
218
|
+
console.log(`[dev-inspector] 📡 MCP (Standalone): ${baseUrl}\n`);
|
|
219
|
+
setupMcpMiddleware(server, serverContext);
|
|
220
|
+
setupAcpMiddleware(server, serverContext, {
|
|
221
|
+
acpMode: options.acpMode,
|
|
222
|
+
acpModel: options.acpModel,
|
|
223
|
+
acpDelay: options.acpDelay
|
|
224
|
+
});
|
|
225
|
+
const root = compiler.context;
|
|
226
|
+
await updateMcpConfigs(root, baseUrl, {
|
|
227
|
+
updateConfig: options.updateConfig,
|
|
228
|
+
updateConfigServerName: options.updateConfigServerName,
|
|
229
|
+
updateConfigAdditionalServers: options.updateConfigAdditionalServers,
|
|
230
|
+
customEditors: options.customEditors
|
|
231
|
+
});
|
|
232
|
+
if (options.autoOpenBrowser ?? false) {
|
|
233
|
+
const targetUrl = options.browserUrl ?? `http://${displayHost}:${port}`;
|
|
234
|
+
setTimeout(async () => {
|
|
235
|
+
if (await launchBrowserWithDevTools({
|
|
236
|
+
url: targetUrl,
|
|
237
|
+
serverContext
|
|
238
|
+
})) console.log(`[dev-inspector] 🌐 Browser opened: ${targetUrl}`);
|
|
239
|
+
else console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to open browser manually.\n`);
|
|
240
|
+
}, 1e3);
|
|
241
|
+
} else {
|
|
242
|
+
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
243
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to enable.\n`);
|
|
245
244
|
}
|
|
246
245
|
setupInspectorMiddleware(server, {
|
|
247
246
|
agents: options.agents,
|
package/package.json
CHANGED