vite-plugin-ai-annotator 1.14.7 → 1.14.9
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/annotator-toolbar.d.ts +2 -0
- package/dist/annotator-toolbar.js +35 -81
- package/dist/index.cjs +35 -35
- package/dist/mcp-tools.d.ts +25 -0
- package/dist/nuxt-module.js +21 -19
- package/dist/nuxt-module.js.map +2 -2
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/xpath.d.ts +0 -4
- package/dist/vite-plugin.js +20 -17
- package/dist/vite-plugin.js.map +2 -2
- package/dist/ws-server.d.ts +5 -5
- package/package.json +1 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -1196,7 +1196,7 @@ function injectSourceLocations(code, id, root) {
|
|
|
1196
1196
|
const s = new MagicString(code);
|
|
1197
1197
|
const relativePath = relative(root, id);
|
|
1198
1198
|
let hasChanges = false;
|
|
1199
|
-
const tagRegex = /<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+[^>]
|
|
1199
|
+
const tagRegex = /<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"'\/=]+(?:=(?:"[^"]*"|'[^']*'|[^\s>"']+))?|\s))*)\s*\/?>/g;
|
|
1200
1200
|
const skipTags = /* @__PURE__ */ new Set([
|
|
1201
1201
|
"script",
|
|
1202
1202
|
"style",
|
|
@@ -1330,10 +1330,6 @@ var AiAnnotatorServer = class {
|
|
|
1330
1330
|
env: process.env,
|
|
1331
1331
|
stdio: this.options.verbose ? "inherit" : "pipe"
|
|
1332
1332
|
});
|
|
1333
|
-
if (!this.options.verbose && this.serverProcess.stdout) {
|
|
1334
|
-
this.serverProcess.stdout.on("data", (_data) => {
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
1333
|
if (!this.options.verbose && this.serverProcess.stderr) {
|
|
1338
1334
|
this.serverProcess.stderr.on("data", (data) => {
|
|
1339
1335
|
console.error(`[ai-annotator-server] Error: ${data}`);
|
|
@@ -1348,7 +1344,12 @@ var AiAnnotatorServer = class {
|
|
|
1348
1344
|
}
|
|
1349
1345
|
this.serverProcess = null;
|
|
1350
1346
|
});
|
|
1351
|
-
|
|
1347
|
+
const deadline = Date.now() + 5e3;
|
|
1348
|
+
while (Date.now() < deadline) {
|
|
1349
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1350
|
+
if (await this.isServerRunning()) return;
|
|
1351
|
+
}
|
|
1352
|
+
this.log("Server did not respond to health check within 5 seconds");
|
|
1352
1353
|
}
|
|
1353
1354
|
async stop() {
|
|
1354
1355
|
if (this.serverProcess) {
|
|
@@ -1454,36 +1455,38 @@ function aiAnnotator(options = {}) {
|
|
|
1454
1455
|
},
|
|
1455
1456
|
// For SSR frameworks like Nuxt - intercept HTML responses
|
|
1456
1457
|
configureServer(server) {
|
|
1458
|
+
server.httpServer?.on("close", () => {
|
|
1459
|
+
serverManager.stop();
|
|
1460
|
+
});
|
|
1457
1461
|
server.middlewares.use((_req, res, next) => {
|
|
1458
1462
|
if (!serverManager) {
|
|
1459
1463
|
return next();
|
|
1460
1464
|
}
|
|
1461
|
-
const originalWrite = res.write.bind(res);
|
|
1462
1465
|
const originalEnd = res.end.bind(res);
|
|
1463
1466
|
let chunks = [];
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
const contentType = res.getHeader("content-type");
|
|
1467
|
-
if (typeof contentType === "string" && contentType.includes("text/html")) {
|
|
1468
|
-
isHtml = true;
|
|
1469
|
-
}
|
|
1470
|
-
if (isHtml && chunk) {
|
|
1467
|
+
res.write = function(chunk, ..._args) {
|
|
1468
|
+
if (chunk) {
|
|
1471
1469
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1472
|
-
return true;
|
|
1473
1470
|
}
|
|
1474
|
-
return
|
|
1471
|
+
return true;
|
|
1475
1472
|
};
|
|
1476
1473
|
res.end = function(chunk, ...args) {
|
|
1477
1474
|
if (chunk) {
|
|
1478
1475
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1479
1476
|
}
|
|
1477
|
+
const contentType = res.getHeader("content-type");
|
|
1478
|
+
const isHtml = typeof contentType === "string" && contentType.includes("text/html");
|
|
1480
1479
|
if (isHtml && chunks.length > 0) {
|
|
1481
1480
|
const html = Buffer.concat(chunks).toString("utf-8");
|
|
1482
1481
|
const injectedHtml = injectScriptIntoHtml(html, serverManager.getInjectScript());
|
|
1483
1482
|
res.setHeader("content-length", Buffer.byteLength(injectedHtml));
|
|
1484
1483
|
return originalEnd(injectedHtml, ...args);
|
|
1485
1484
|
}
|
|
1486
|
-
|
|
1485
|
+
if (chunks.length > 0) {
|
|
1486
|
+
const body = Buffer.concat(chunks);
|
|
1487
|
+
return originalEnd(body, ...args);
|
|
1488
|
+
}
|
|
1489
|
+
return originalEnd(void 0, ...args);
|
|
1487
1490
|
};
|
|
1488
1491
|
next();
|
|
1489
1492
|
});
|