@vitemcp/server 1.6.4 → 1.7.0
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/ViteMCP.cjs +35 -12
- package/dist/ViteMCP.cjs.map +1 -1
- package/dist/ViteMCP.js +34 -11
- package/dist/ViteMCP.js.map +1 -1
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-J2FAZRSL.js → chunk-GCCQBATS.js} +12 -3
- package/dist/chunk-GCCQBATS.js.map +1 -0
- package/dist/{chunk-252JIXOL.cjs → chunk-VTEMGFQZ.cjs} +12 -3
- package/dist/chunk-VTEMGFQZ.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-252JIXOL.cjs.map +0 -1
- package/dist/chunk-J2FAZRSL.js.map +0 -1
package/dist/ViteMCP.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
requireAuth,
|
|
13
13
|
requireRole,
|
|
14
14
|
requireScopes
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GCCQBATS.js";
|
|
16
16
|
|
|
17
17
|
// src/ViteMCP.ts
|
|
18
18
|
import {
|
|
@@ -222,9 +222,11 @@ var DiscoveryDocumentCache = class {
|
|
|
222
222
|
return this.#cache.size;
|
|
223
223
|
}
|
|
224
224
|
#cache = /* @__PURE__ */ new Map();
|
|
225
|
+
#generation = 0;
|
|
225
226
|
#inFlight = /* @__PURE__ */ new Map();
|
|
226
227
|
#timeoutMs;
|
|
227
228
|
#ttl;
|
|
229
|
+
#urlGenerations = /* @__PURE__ */ new Map();
|
|
228
230
|
/**
|
|
229
231
|
* @param options - configuration options
|
|
230
232
|
* @param options.timeoutMs - timeout in miliseconds for the upstream fetch
|
|
@@ -240,8 +242,13 @@ var DiscoveryDocumentCache = class {
|
|
|
240
242
|
clear(url) {
|
|
241
243
|
if (url) {
|
|
242
244
|
this.#cache.delete(url);
|
|
245
|
+
this.#inFlight.delete(url);
|
|
246
|
+
this.#urlGenerations.set(url, (this.#urlGenerations.get(url) ?? 0) + 1);
|
|
243
247
|
} else {
|
|
244
248
|
this.#cache.clear();
|
|
249
|
+
this.#inFlight.clear();
|
|
250
|
+
this.#urlGenerations.clear();
|
|
251
|
+
this.#generation++;
|
|
245
252
|
}
|
|
246
253
|
}
|
|
247
254
|
/**
|
|
@@ -263,13 +270,19 @@ var DiscoveryDocumentCache = class {
|
|
|
263
270
|
if (inFlight) {
|
|
264
271
|
return inFlight;
|
|
265
272
|
}
|
|
266
|
-
const fetchPromise = this.#fetchAndCache(
|
|
273
|
+
const fetchPromise = this.#fetchAndCache(
|
|
274
|
+
url,
|
|
275
|
+
this.#generation,
|
|
276
|
+
this.#urlGenerations.get(url) ?? 0
|
|
277
|
+
);
|
|
267
278
|
this.#inFlight.set(url, fetchPromise);
|
|
268
279
|
try {
|
|
269
280
|
const data = await fetchPromise;
|
|
270
281
|
return data;
|
|
271
282
|
} finally {
|
|
272
|
-
this.#inFlight.
|
|
283
|
+
if (this.#inFlight.get(url) === fetchPromise) {
|
|
284
|
+
this.#inFlight.delete(url);
|
|
285
|
+
}
|
|
273
286
|
}
|
|
274
287
|
}
|
|
275
288
|
/**
|
|
@@ -288,7 +301,7 @@ var DiscoveryDocumentCache = class {
|
|
|
288
301
|
}
|
|
289
302
|
return true;
|
|
290
303
|
}
|
|
291
|
-
async #fetchAndCache(url) {
|
|
304
|
+
async #fetchAndCache(url, generation, urlGeneration) {
|
|
292
305
|
let res;
|
|
293
306
|
try {
|
|
294
307
|
res = await fetch(url, {
|
|
@@ -310,10 +323,12 @@ var DiscoveryDocumentCache = class {
|
|
|
310
323
|
}
|
|
311
324
|
const data = await res.json();
|
|
312
325
|
const expiresAt = Date.now() + this.#ttl;
|
|
313
|
-
this.#
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
326
|
+
if (this.#generation === generation && (this.#urlGenerations.get(url) ?? 0) === urlGeneration) {
|
|
327
|
+
this.#cache.set(url, {
|
|
328
|
+
data,
|
|
329
|
+
expiresAt
|
|
330
|
+
});
|
|
331
|
+
}
|
|
317
332
|
return data;
|
|
318
333
|
}
|
|
319
334
|
};
|
|
@@ -370,7 +385,7 @@ async function compileSchema(schema) {
|
|
|
370
385
|
function toIssue(error) {
|
|
371
386
|
const path = error.instancePath.split("/").filter(Boolean).map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~")).map((segment) => {
|
|
372
387
|
const index = Number(segment);
|
|
373
|
-
return Number.
|
|
388
|
+
return /^(?:0|[1-9]\d*)$/.test(segment) && Number.isSafeInteger(index) ? index : segment;
|
|
374
389
|
});
|
|
375
390
|
const missingProperty = error.params?.missingProperty;
|
|
376
391
|
if (error.keyword === "required" && typeof missingProperty === "string") {
|
|
@@ -1264,8 +1279,16 @@ var promptArgsSchema = (prompt) => {
|
|
|
1264
1279
|
}
|
|
1265
1280
|
const shape = {};
|
|
1266
1281
|
for (const arg of args) {
|
|
1267
|
-
const
|
|
1268
|
-
const
|
|
1282
|
+
const explicitCompleter = arg.complete ?? (prompt.complete ? (value) => prompt.complete(arg.name, value) : void 0);
|
|
1283
|
+
const enumValues = arg.enum;
|
|
1284
|
+
const completer = explicitCompleter ?? (enumValues?.length ? async (value) => ({
|
|
1285
|
+
// An empty value is how an editor asks for the whole set before the
|
|
1286
|
+
// user has typed anything; filtering it would answer with nothing.
|
|
1287
|
+
values: value ? enumValues.filter(
|
|
1288
|
+
(option) => option.toLowerCase().includes(value.toLowerCase())
|
|
1289
|
+
) : [...enumValues]
|
|
1290
|
+
}) : void 0);
|
|
1291
|
+
const valueSchema = enumValues?.length ? z.enum(enumValues) : z.string();
|
|
1269
1292
|
const described = arg.description ? valueSchema.describe(arg.description) : valueSchema;
|
|
1270
1293
|
const base = completer ? completable(
|
|
1271
1294
|
described,
|