@mcpc-tech/unplugin-dev-inspector-mcp 0.1.29 → 0.1.31
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/cli.cjs +24 -5
- package/dist/cli.js +24 -5
- package/dist/config-updater.cjs +5 -1
- package/dist/config-updater.js +5 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -232,9 +232,8 @@ function transformViteConfig(code, options) {
|
|
|
232
232
|
error: "Could not find plugins array in config",
|
|
233
233
|
message: "Please add DevInspector manually to your plugins array"
|
|
234
234
|
};
|
|
235
|
-
if (options.host || options.allowedHosts?.length)
|
|
236
|
-
|
|
237
|
-
const configObj = path$1.node.declaration.arguments[0];
|
|
235
|
+
if (options.host || options.allowedHosts?.length) {
|
|
236
|
+
const injectServerConfig = (configObj) => {
|
|
238
237
|
const serverProp = configObj.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "server");
|
|
239
238
|
const serverIndent = indent.repeat(2);
|
|
240
239
|
if (serverProp?.value.start != null) {
|
|
@@ -251,8 +250,28 @@ function transformViteConfig(code, options) {
|
|
|
251
250
|
injection += `${indent}},`;
|
|
252
251
|
s.appendLeft(configObj.start + 1, injection);
|
|
253
252
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
253
|
+
};
|
|
254
|
+
const extractConfigFromFunction = (fn) => {
|
|
255
|
+
if (fn.type === "ArrowFunctionExpression" && fn.body.type === "ObjectExpression") return fn.body;
|
|
256
|
+
if (fn.body.type === "BlockStatement") {
|
|
257
|
+
for (const stmt of fn.body.body) if (stmt.type === "ReturnStatement" && stmt.argument?.type === "ObjectExpression") return stmt.argument;
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
};
|
|
261
|
+
traverse$2(ast, { ExportDefaultDeclaration(path$1) {
|
|
262
|
+
const decl = path$1.node.declaration;
|
|
263
|
+
if (decl.type === "CallExpression" && decl.arguments[0]?.type === "ObjectExpression") {
|
|
264
|
+
injectServerConfig(decl.arguments[0]);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (decl.type === "CallExpression" && (decl.arguments[0]?.type === "ArrowFunctionExpression" || decl.arguments[0]?.type === "FunctionExpression")) {
|
|
268
|
+
const configObj = extractConfigFromFunction(decl.arguments[0]);
|
|
269
|
+
if (configObj) injectServerConfig(configObj);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (decl.type === "ObjectExpression") injectServerConfig(decl);
|
|
273
|
+
} });
|
|
274
|
+
}
|
|
256
275
|
if (s.toString() === code) return {
|
|
257
276
|
success: true,
|
|
258
277
|
modified: false,
|
package/dist/cli.js
CHANGED
|
@@ -230,9 +230,8 @@ function transformViteConfig(code, options) {
|
|
|
230
230
|
error: "Could not find plugins array in config",
|
|
231
231
|
message: "Please add DevInspector manually to your plugins array"
|
|
232
232
|
};
|
|
233
|
-
if (options.host || options.allowedHosts?.length)
|
|
234
|
-
|
|
235
|
-
const configObj = path$1.node.declaration.arguments[0];
|
|
233
|
+
if (options.host || options.allowedHosts?.length) {
|
|
234
|
+
const injectServerConfig = (configObj) => {
|
|
236
235
|
const serverProp = configObj.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "server");
|
|
237
236
|
const serverIndent = indent.repeat(2);
|
|
238
237
|
if (serverProp?.value.start != null) {
|
|
@@ -249,8 +248,28 @@ function transformViteConfig(code, options) {
|
|
|
249
248
|
injection += `${indent}},`;
|
|
250
249
|
s.appendLeft(configObj.start + 1, injection);
|
|
251
250
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
251
|
+
};
|
|
252
|
+
const extractConfigFromFunction = (fn) => {
|
|
253
|
+
if (fn.type === "ArrowFunctionExpression" && fn.body.type === "ObjectExpression") return fn.body;
|
|
254
|
+
if (fn.body.type === "BlockStatement") {
|
|
255
|
+
for (const stmt of fn.body.body) if (stmt.type === "ReturnStatement" && stmt.argument?.type === "ObjectExpression") return stmt.argument;
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
};
|
|
259
|
+
traverse$2(ast, { ExportDefaultDeclaration(path$1) {
|
|
260
|
+
const decl = path$1.node.declaration;
|
|
261
|
+
if (decl.type === "CallExpression" && decl.arguments[0]?.type === "ObjectExpression") {
|
|
262
|
+
injectServerConfig(decl.arguments[0]);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (decl.type === "CallExpression" && (decl.arguments[0]?.type === "ArrowFunctionExpression" || decl.arguments[0]?.type === "FunctionExpression")) {
|
|
266
|
+
const configObj = extractConfigFromFunction(decl.arguments[0]);
|
|
267
|
+
if (configObj) injectServerConfig(configObj);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (decl.type === "ObjectExpression") injectServerConfig(decl);
|
|
271
|
+
} });
|
|
272
|
+
}
|
|
254
273
|
if (s.toString() === code) return {
|
|
255
274
|
success: true,
|
|
256
275
|
modified: false,
|
package/dist/config-updater.cjs
CHANGED
|
@@ -177,9 +177,13 @@ var StandaloneServer = class {
|
|
|
177
177
|
listen(...args) {
|
|
178
178
|
return this.server.listen(...args);
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Start the standalone server.
|
|
182
|
+
* Host resolution: string value used as-is, `true` = '0.0.0.0', default = 'localhost'
|
|
183
|
+
*/
|
|
180
184
|
async start(options = {}) {
|
|
181
185
|
const startPort = options.port || getDefaultPort();
|
|
182
|
-
this.host = options.host
|
|
186
|
+
this.host = typeof options.host === "string" ? options.host : options.host === true ? "0.0.0.0" : "localhost";
|
|
183
187
|
this.allowedHosts = options.allowedHosts || [];
|
|
184
188
|
for (let port = startPort; port < startPort + 100; port++) try {
|
|
185
189
|
await new Promise((resolve$1, reject) => {
|
package/dist/config-updater.js
CHANGED
|
@@ -169,9 +169,13 @@ var StandaloneServer = class {
|
|
|
169
169
|
listen(...args) {
|
|
170
170
|
return this.server.listen(...args);
|
|
171
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Start the standalone server.
|
|
174
|
+
* Host resolution: string value used as-is, `true` = '0.0.0.0', default = 'localhost'
|
|
175
|
+
*/
|
|
172
176
|
async start(options = {}) {
|
|
173
177
|
const startPort = options.port || getDefaultPort();
|
|
174
|
-
this.host = options.host
|
|
178
|
+
this.host = typeof options.host === "string" ? options.host : options.host === true ? "0.0.0.0" : "localhost";
|
|
175
179
|
this.allowedHosts = options.allowedHosts || [];
|
|
176
180
|
for (let port = startPort; port < startPort + 100; port++) try {
|
|
177
181
|
await new Promise((resolve$2, reject) => {
|
package/dist/index.cjs
CHANGED
|
@@ -61,7 +61,10 @@ const createDevInspectorPlugin = (name, transformFactory) => {
|
|
|
61
61
|
const ensureStandaloneServer$1 = async (root) => {
|
|
62
62
|
if (standaloneServerStarted) return;
|
|
63
63
|
standaloneServerStarted = true;
|
|
64
|
-
const { server, host, port } = await require_config_updater.startStandaloneServer({
|
|
64
|
+
const { server, host, port } = await require_config_updater.startStandaloneServer({
|
|
65
|
+
port: options.port,
|
|
66
|
+
host: options.host
|
|
67
|
+
});
|
|
65
68
|
resolvedHost = host;
|
|
66
69
|
resolvedPort = port;
|
|
67
70
|
const serverContext = {
|
package/dist/index.d.cts
CHANGED
|
@@ -131,12 +131,14 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
131
131
|
*/
|
|
132
132
|
enabled?: boolean;
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
134
|
+
* Host address for the standalone server to bind to.
|
|
135
|
+
* - `"localhost"` (default): Only accessible locally, avoids Mixed Content errors (HTTPS→HTTP allowed)
|
|
136
|
+
* - `"0.0.0.0"` or `true`: Accessible from all network interfaces (useful for Docker, remote access)
|
|
137
|
+
* - Custom hostname: Bind to specific interface
|
|
136
138
|
* @default "localhost"
|
|
137
|
-
* @example
|
|
139
|
+
* @example true
|
|
138
140
|
*/
|
|
139
|
-
host?: string;
|
|
141
|
+
host?: string | boolean;
|
|
140
142
|
/**
|
|
141
143
|
* Custom port for MCP server URL
|
|
142
144
|
* Useful when behind a proxy or port forwarding (e.g., Docker, SSH tunnels)
|
|
@@ -148,12 +150,17 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
148
150
|
/**
|
|
149
151
|
* Public base URL (including protocol) that editors/browsers should use to reach the dev server.
|
|
150
152
|
*
|
|
151
|
-
* Use this when the dev server runs in a
|
|
152
|
-
* reachable URL
|
|
153
|
+
* Use this when the dev server runs in a cloud IDE or behind a reverse proxy where the externally
|
|
154
|
+
* reachable URL differs from the internal host/port.
|
|
155
|
+
*
|
|
156
|
+
* Common use cases:
|
|
157
|
+
* - Cloud IDEs: Fly.io (`https://app-5137.fly.dev`), Gitpod, GitHub Codespaces
|
|
158
|
+
* - Docker with port mapping
|
|
159
|
+
* - Reverse proxy / tunnel (ngrok, cloudflared)
|
|
153
160
|
*
|
|
154
161
|
* If provided, it will be used for MCP config auto-update and console output.
|
|
155
162
|
*
|
|
156
|
-
* @example "https://
|
|
163
|
+
* @example "https://my-app-5137.fly.dev"
|
|
157
164
|
*/
|
|
158
165
|
publicBaseUrl?: string;
|
|
159
166
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -131,12 +131,14 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
131
131
|
*/
|
|
132
132
|
enabled?: boolean;
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
134
|
+
* Host address for the standalone server to bind to.
|
|
135
|
+
* - `"localhost"` (default): Only accessible locally, avoids Mixed Content errors (HTTPS→HTTP allowed)
|
|
136
|
+
* - `"0.0.0.0"` or `true`: Accessible from all network interfaces (useful for Docker, remote access)
|
|
137
|
+
* - Custom hostname: Bind to specific interface
|
|
136
138
|
* @default "localhost"
|
|
137
|
-
* @example
|
|
139
|
+
* @example true
|
|
138
140
|
*/
|
|
139
|
-
host?: string;
|
|
141
|
+
host?: string | boolean;
|
|
140
142
|
/**
|
|
141
143
|
* Custom port for MCP server URL
|
|
142
144
|
* Useful when behind a proxy or port forwarding (e.g., Docker, SSH tunnels)
|
|
@@ -148,12 +150,17 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
148
150
|
/**
|
|
149
151
|
* Public base URL (including protocol) that editors/browsers should use to reach the dev server.
|
|
150
152
|
*
|
|
151
|
-
* Use this when the dev server runs in a
|
|
152
|
-
* reachable URL
|
|
153
|
+
* Use this when the dev server runs in a cloud IDE or behind a reverse proxy where the externally
|
|
154
|
+
* reachable URL differs from the internal host/port.
|
|
155
|
+
*
|
|
156
|
+
* Common use cases:
|
|
157
|
+
* - Cloud IDEs: Fly.io (`https://app-5137.fly.dev`), Gitpod, GitHub Codespaces
|
|
158
|
+
* - Docker with port mapping
|
|
159
|
+
* - Reverse proxy / tunnel (ngrok, cloudflared)
|
|
153
160
|
*
|
|
154
161
|
* If provided, it will be used for MCP config auto-update and console output.
|
|
155
162
|
*
|
|
156
|
-
* @example "https://
|
|
163
|
+
* @example "https://my-app-5137.fly.dev"
|
|
157
164
|
*/
|
|
158
165
|
publicBaseUrl?: string;
|
|
159
166
|
/**
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,10 @@ const createDevInspectorPlugin = (name, transformFactory) => {
|
|
|
57
57
|
const ensureStandaloneServer$1 = async (root) => {
|
|
58
58
|
if (standaloneServerStarted) return;
|
|
59
59
|
standaloneServerStarted = true;
|
|
60
|
-
const { server, host, port } = await startStandaloneServer({
|
|
60
|
+
const { server, host, port } = await startStandaloneServer({
|
|
61
|
+
port: options.port,
|
|
62
|
+
host: options.host
|
|
63
|
+
});
|
|
61
64
|
resolvedHost = host;
|
|
62
65
|
resolvedPort = port;
|
|
63
66
|
const serverContext = {
|
package/package.json
CHANGED