faux-studio 0.3.9 → 0.3.11
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/index.js +33 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11152,6 +11152,7 @@ async function ensureFigma() {
|
|
|
11152
11152
|
}
|
|
11153
11153
|
|
|
11154
11154
|
// src/plugin-ws.ts
|
|
11155
|
+
import { execSync as execSync2 } from "child_process";
|
|
11155
11156
|
import { randomUUID } from "crypto";
|
|
11156
11157
|
import { writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
11157
11158
|
import { join as join4 } from "path";
|
|
@@ -11191,6 +11192,8 @@ var PluginWsServer = class {
|
|
|
11191
11192
|
// Server Lifecycle
|
|
11192
11193
|
// -------------------------------------------------------------------------
|
|
11193
11194
|
async start() {
|
|
11195
|
+
this.killStaleInstances();
|
|
11196
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
11194
11197
|
for (let port = DEFAULT_PORT; port < DEFAULT_PORT + PORT_RANGE; port++) {
|
|
11195
11198
|
try {
|
|
11196
11199
|
await this.listen(port);
|
|
@@ -11206,6 +11209,35 @@ var PluginWsServer = class {
|
|
|
11206
11209
|
`No available port in range ${DEFAULT_PORT}-${DEFAULT_PORT + PORT_RANGE - 1}. Another faux-studio instance may be running.`
|
|
11207
11210
|
);
|
|
11208
11211
|
}
|
|
11212
|
+
/**
|
|
11213
|
+
* Kill any node processes listening on our port range that are running
|
|
11214
|
+
* faux-studio. Uses OS-level detection — works regardless of the old
|
|
11215
|
+
* instance's version or protocol support.
|
|
11216
|
+
*/
|
|
11217
|
+
killStaleInstances() {
|
|
11218
|
+
const myPid = process.pid;
|
|
11219
|
+
for (let port = DEFAULT_PORT; port < DEFAULT_PORT + PORT_RANGE; port++) {
|
|
11220
|
+
try {
|
|
11221
|
+
let pid;
|
|
11222
|
+
if (process.platform === "win32") {
|
|
11223
|
+
const output = execSync2(
|
|
11224
|
+
`netstat -ano | findstr "LISTENING" | findstr ":${port} "`,
|
|
11225
|
+
{ encoding: "utf-8" }
|
|
11226
|
+
);
|
|
11227
|
+
pid = output.trim().split(/\s+/).pop();
|
|
11228
|
+
} else {
|
|
11229
|
+
pid = execSync2(`lsof -iTCP:${port} -sTCP:LISTEN -t`, { encoding: "utf-8" }).trim().split("\n")[0];
|
|
11230
|
+
}
|
|
11231
|
+
if (!pid || Number(pid) === myPid) continue;
|
|
11232
|
+
const cmd = process.platform === "win32" ? execSync2(`wmic process where "ProcessId=${pid}" get CommandLine /format:list`, { encoding: "utf-8" }) : execSync2(`ps -p ${pid} -o command=`, { encoding: "utf-8" });
|
|
11233
|
+
if (cmd.includes("faux-studio")) {
|
|
11234
|
+
log(`Killing stale faux-studio on port ${port} (pid ${pid})`);
|
|
11235
|
+
process.kill(Number(pid), "SIGTERM");
|
|
11236
|
+
}
|
|
11237
|
+
} catch {
|
|
11238
|
+
}
|
|
11239
|
+
}
|
|
11240
|
+
}
|
|
11209
11241
|
listen(port) {
|
|
11210
11242
|
return new Promise((resolve, reject) => {
|
|
11211
11243
|
const wss = new import_websocket_server.default({ port, host: "127.0.0.1" });
|
|
@@ -25570,7 +25602,7 @@ Resources provide quick read-only access to Figma state without tool calls:
|
|
|
25570
25602
|
- Create components for reusable UI patterns.`;
|
|
25571
25603
|
function createMcpServer(deps) {
|
|
25572
25604
|
const server2 = new Server(
|
|
25573
|
-
{ name: "faux-studio", version: "0.3.
|
|
25605
|
+
{ name: "faux-studio", version: "0.3.11" },
|
|
25574
25606
|
{
|
|
25575
25607
|
capabilities: { tools: { listChanged: true }, resources: {}, logging: {} },
|
|
25576
25608
|
instructions: INSTRUCTIONS
|