@vite-hub/source 0.1.0 → 0.3.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.
Files changed (48) hide show
  1. package/README.md +83 -49
  2. package/dist/client.d.ts +1 -1
  3. package/dist/client.js +30 -4
  4. package/dist/{collection-B_4w_J8h.d.ts → collection-B8sgxw5-.d.ts} +52 -19
  5. package/dist/collection-C0Rvrx3p.js +297 -0
  6. package/dist/drizzle.d.ts +11 -4
  7. package/dist/drizzle.js +6 -8
  8. package/dist/error-diagnostics-ClQKdi7c.js +194 -0
  9. package/dist/github-D5S0dEZe.js +1312 -0
  10. package/dist/{glob-BmFqTvJY.js → glob-DmdMVqjx.js} +1 -2
  11. package/dist/index.d.ts +186 -55
  12. package/dist/index.js +152 -207
  13. package/dist/invariant-DolT9EEx.js +22 -0
  14. package/dist/mcp.d.ts +1 -1
  15. package/dist/mcp.js +25 -140
  16. package/dist/object-CtSHeGQO.js +17 -0
  17. package/dist/{path-BS8rYm0n.js → path-DFlSryRA.js} +32 -2
  18. package/dist/root-DJNmqCEW.js +11 -0
  19. package/dist/server.d.ts +7 -244
  20. package/dist/server.js +38 -45
  21. package/dist/{types-BigOktIj.d.ts → types-Ln-FxVFn.d.ts} +6 -1
  22. package/dist/vite.d.ts +77 -10
  23. package/dist/vite.js +619 -713
  24. package/package.json +25 -47
  25. package/dist/auth-B-tX_rp0.js +0 -1426
  26. package/dist/client-BwstxtdY.js +0 -8280
  27. package/dist/collection-cursor-WzV1Jd6v.js +0 -124
  28. package/dist/error-diagnostics-X0kuFjBT.js +0 -51
  29. package/dist/file-BX0FSvgE.js +0 -60
  30. package/dist/file-DadN9dbN.d.ts +0 -19
  31. package/dist/file.d.ts +0 -2
  32. package/dist/file.js +0 -2
  33. package/dist/files.d.ts +0 -15
  34. package/dist/files.js +0 -38
  35. package/dist/github.d.ts +0 -20
  36. package/dist/github.js +0 -1332
  37. package/dist/glob.d.ts +0 -23
  38. package/dist/glob.js +0 -2
  39. package/dist/markdown.d.ts +0 -5
  40. package/dist/markdown.js +0 -10
  41. package/dist/mrmime-40h5OOIp.js +0 -448
  42. package/dist/path-DOBpV8ol.js +0 -32
  43. package/dist/sse-D9gqqNPj.js +0 -448
  44. package/dist/streamableHttp-BL-E7pl5.js +0 -509
  45. package/dist/types-CoWcW8oz.js +0 -7590
  46. package/tsconfig.vite.json +0 -6
  47. package/types/source/fallback.d.ts +0 -1
  48. package/types/source/index.d.ts +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
- import { t as sourceErrorDiagnostics } from "./error-diagnostics-X0kuFjBT.js";
2
- import { n as createCollectionCursorCodec, r as parseCollectionSchema, t as CollectionCursorError } from "./collection-cursor-WzV1Jd6v.js";
3
- import { a as sourceNotFoundError, i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath, t as decodeSourceContent } from "./path-DOBpV8ol.js";
1
+ import { a as normalizeSafeSourcePath, c as sourceNotFoundError, i as decodeSourceContent, l as sourcePathError, o as normalizeSourcePath, s as sourceError } from "./path-DFlSryRA.js";
2
+ import { t as sourceErrorDiagnostics } from "./error-diagnostics-ClQKdi7c.js";
3
+ import { r as isRecordOrFunction } from "./object-CtSHeGQO.js";
4
+ import { a as parseCollectionSchema, i as createCollectionCursorCodec, n as defineCollection, r as CollectionCursorError } from "./collection-C0Rvrx3p.js";
5
+ import { t as normalizeGitHubRoot } from "./root-DJNmqCEW.js";
6
+ import { n as glob } from "./glob-DmdMVqjx.js";
7
+ import { lookup } from "mrmime";
4
8
  //#region src/core/array-collection.ts
5
- const defaultMaxLimit$1 = 100;
9
+ const defaultMaxLimit = 100;
6
10
  const reservedQueryKeys = /* @__PURE__ */ new Set([
7
11
  "cursor",
8
12
  "empty",
@@ -28,16 +32,13 @@ const cursorCodec = createCollectionCursorCodec({ "~standard": {
28
32
  } };
29
33
  }
30
34
  } });
31
- function isRecord(value) {
32
- return Object(value) === value && !Array.isArray(value);
33
- }
34
35
  /** Read a dot path through own properties. Arrays fan out to every element. */
35
36
  function collectionValueAt(value, path) {
36
37
  const segments = path.split(".").filter(Boolean);
37
38
  function visit(current, remaining) {
38
39
  if (!remaining.length) return current;
39
40
  if (Array.isArray(current)) return current.map((item) => visit(item, remaining)).filter((item) => item !== void 0);
40
- if (!isRecord(current)) return;
41
+ if (!isRecordOrFunction(current)) return;
41
42
  const segment = remaining[0];
42
43
  if (!Object.hasOwn(current, segment)) return;
43
44
  return visit(current[segment], remaining.slice(1));
@@ -131,12 +132,12 @@ function array(load, options = {}) {
131
132
  assertFieldList("facets", options.facets);
132
133
  const reserved = options.filters?.find((field) => reservedQueryKeys.has(field));
133
134
  if (reserved) throw sourceErrorDiagnostics.SOURCE_R0028({ message: `[vitehub] array() filter ${JSON.stringify(reserved)} collides with a reserved query key.` });
134
- if (options.sort !== void 0 && (!isRecord(options.sort) || String(options.sort.field) !== options.sort.field || !options.sort.field)) throw sourceErrorDiagnostics.SOURCE_R0028({ message: "[vitehub] array() sort must name a field." });
135
+ if (options.sort !== void 0 && (!isRecordOrFunction(options.sort) || String(options.sort.field) !== options.sort.field || !options.sort.field)) throw sourceErrorDiagnostics.SOURCE_R0028({ message: "[vitehub] array() sort must name a field." });
135
136
  const filters = new Set(options.filters ?? []);
136
137
  const isFilter = (key) => filters.has(key);
137
138
  const searchFields = options.search ?? [];
138
139
  const facetFields = options.facets ?? [];
139
- const maxValues = options.maxLimit ?? defaultMaxLimit$1;
140
+ const maxValues = options.maxLimit ?? defaultMaxLimit;
140
141
  const signatureFields = JSON.stringify({
141
142
  search: [...searchFields].sort(),
142
143
  sort: options.sort ? {
@@ -179,7 +180,7 @@ function array(load, options = {}) {
179
180
  version: 1,
180
181
  vendor: "vite-hub",
181
182
  validate(value) {
182
- if (!isRecord(value)) return { issues: [{ message: "Collection query must be an object." }] };
183
+ if (!isRecordOrFunction(value)) return { issues: [{ message: "Collection query must be an object." }] };
183
184
  const filterValues = Object.create(null);
184
185
  let empty;
185
186
  let search;
@@ -243,198 +244,6 @@ function array(load, options = {}) {
243
244
  return source;
244
245
  }
245
246
  //#endregion
246
- //#region src/core/collection.ts
247
- const defaultPageLimit = 50;
248
- const defaultMaxLimit = 100;
249
- function isCollectionFacets(value) {
250
- return Object(value) === value && !Array.isArray(value) && Object.values(Object(value)).every((entries) => Array.isArray(entries) && entries.every((entry) => Object(entry) === entry && String(Reflect.get(entry, "value")) === Reflect.get(entry, "value") && Number.isSafeInteger(Reflect.get(entry, "count")) && Number(Reflect.get(entry, "count")) >= 0));
251
- }
252
- function assertPositiveInteger(value, label) {
253
- if (!Number.isSafeInteger(value) || value < 1) throw sourceErrorDiagnostics.SOURCE_R0004({ message: `[vitehub] Collection ${label} must be a positive integer.` });
254
- }
255
- function resolveLimit(limit, defaultLimit, maxLimit) {
256
- if (limit !== void 0) assertPositiveInteger(limit, "limit");
257
- return Math.min(limit ?? defaultLimit, maxLimit);
258
- }
259
- function defineCollection(input, options) {
260
- const [load, definition] = typeof input === "function" ? [input, options] : sourceDefinition(input);
261
- if (!definition) throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] defineCollection() requires a loader with options, or { source }." });
262
- const defaultLimit = definition.defaultLimit ?? defaultPageLimit;
263
- const maxLimit = definition.maxLimit ?? defaultMaxLimit;
264
- assertPositiveInteger(defaultLimit, "defaultLimit");
265
- assertPositiveInteger(maxLimit, "maxLimit");
266
- if (defaultLimit > maxLimit) throw sourceErrorDiagnostics.SOURCE_R0008({ message: "[vitehub] Collection defaultLimit cannot exceed maxLimit." });
267
- const cursorDefinition = "cursorSchema" in definition ? definition : void 0;
268
- const cursorCodec = cursorDefinition ? createCollectionCursorCodec(cursorDefinition.cursorSchema) : void 0;
269
- const authorize = definition.authorize;
270
- if (authorize !== void 0 && authorize !== true && typeof authorize !== "function") throw sourceErrorDiagnostics.SOURCE_R0024({ message: "[vitehub] Collection authorize must be true or a function." });
271
- const collection = {
272
- ...authorize ? { authorize } : {},
273
- route: definition.route,
274
- async page(request) {
275
- request.signal?.throwIfAborted();
276
- const limit = resolveLimit(request.limit, defaultLimit, maxLimit);
277
- if (!cursorDefinition || !cursorCodec) {
278
- const result = await load({
279
- cursor: request.cursor,
280
- limit,
281
- query: request.query,
282
- signal: request.signal
283
- });
284
- request.signal?.throwIfAborted();
285
- if (!result || !Array.isArray(result.items) || result.nextCursor !== null && !isProviderCursor(result.nextCursor)) throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] Provider Collection load() must return items and nextCursor." });
286
- const transformedItems = definition.transform ? await Promise.all(result.items.map(definition.transform)) : result.items;
287
- request.signal?.throwIfAborted();
288
- const page = {
289
- items: transformedItems,
290
- nextCursor: result.nextCursor
291
- };
292
- if (result.total !== void 0) {
293
- if (!Number.isSafeInteger(result.total) || result.total < 0) throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] Provider Collection total must be a non-negative integer." });
294
- page.total = result.total;
295
- }
296
- if (result.facets !== void 0) {
297
- if (!isCollectionFacets(result.facets)) throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] Provider Collection facets must map fields to { value, count } lists." });
298
- page.facets = result.facets;
299
- }
300
- return page;
301
- }
302
- const decodedCursor = await cursorCodec.decode(request.cursor);
303
- request.signal?.throwIfAborted();
304
- const sourceItems = await load({
305
- cursor: decodedCursor,
306
- limit: limit + 1,
307
- query: request.query,
308
- signal: request.signal
309
- });
310
- request.signal?.throwIfAborted();
311
- if (!Array.isArray(sourceItems)) throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] Collection load() must return an array." });
312
- const hasMore = sourceItems.length > limit;
313
- const pageItems = sourceItems.slice(0, limit);
314
- const nextCursor = hasMore && pageItems.length ? cursorCodec.encode(cursorDefinition.cursor(pageItems[pageItems.length - 1])) : null;
315
- const transformedItems = definition.transform ? await Promise.all(pageItems.map(definition.transform)) : pageItems;
316
- request.signal?.throwIfAborted();
317
- return {
318
- items: transformedItems,
319
- nextCursor
320
- };
321
- },
322
- async parseQuery(input) {
323
- if (definition.querySchema) return await parseCollectionSchema(definition.querySchema, input);
324
- return input;
325
- },
326
- query(input = {}) {
327
- const project = (item, keys) => keys ? Object.fromEntries(keys.map((key) => [key, item[key]])) : item;
328
- const build = (keys) => ({
329
- select(...selected) {
330
- return build(selected);
331
- },
332
- async page(options = {}) {
333
- options.signal?.throwIfAborted();
334
- const query = await collection.parseQuery(input);
335
- const result = await collection.page({
336
- ...options,
337
- query
338
- });
339
- return {
340
- ...result,
341
- items: result.items.map((item) => project(item, keys))
342
- };
343
- },
344
- async all(options = {}) {
345
- options.signal?.throwIfAborted();
346
- const items = [];
347
- const query = await collection.parseQuery(input);
348
- let cursor;
349
- const seen = /* @__PURE__ */ new Set();
350
- do {
351
- options.signal?.throwIfAborted();
352
- const result = await collection.page({
353
- ...options,
354
- cursor,
355
- query
356
- });
357
- for (const item of result.items) items.push(project(item, keys));
358
- cursor = result.nextCursor ?? void 0;
359
- if (cursor !== void 0) {
360
- if (seen.has(cursor)) throw new CollectionCursorError("[vitehub] Collection loader repeated a pagination cursor.");
361
- seen.add(cursor);
362
- }
363
- } while (cursor !== void 0);
364
- return items;
365
- }
366
- });
367
- return build();
368
- },
369
- async all(options = {}) {
370
- return collection.query(options.query).all(options);
371
- },
372
- ...definition.querySchema ? { querySchema: definition.querySchema } : {}
373
- };
374
- const get = definition.get;
375
- if (get) {
376
- const lookup = async (key, options) => {
377
- options?.signal?.throwIfAborted();
378
- const item = await get(key, options ?? {});
379
- options?.signal?.throwIfAborted();
380
- if (item === null || item === void 0) return item;
381
- const result = definition.transform ? await definition.transform(item) : item;
382
- options?.signal?.throwIfAborted();
383
- return result;
384
- };
385
- Object.assign(collection, { get: lookup });
386
- }
387
- return collection;
388
- }
389
- function sourceDefinition(input) {
390
- const { authorize, route, source, transform } = input;
391
- if (Object(source) !== source || typeof source.load !== "function") throw sourceErrorDiagnostics.SOURCE_R0009({ message: "[vitehub] defineCollection({ source }) requires a Collection source with load()." });
392
- const shared = {
393
- authorize,
394
- route,
395
- get: source.get,
396
- defaultLimit: source.defaultLimit,
397
- maxLimit: source.maxLimit,
398
- querySchema: source.querySchema,
399
- transform
400
- };
401
- return source.pagination === "provider" ? [source.load, {
402
- ...shared,
403
- pagination: "provider"
404
- }] : [source.load, {
405
- ...shared,
406
- cursor: source.cursor,
407
- cursorSchema: source.cursorSchema
408
- }];
409
- }
410
- function isProviderCursor(value) {
411
- return value === String(value);
412
- }
413
- //#endregion
414
- //#region src/core/combine-sources.ts
415
- function combineSources(definition) {
416
- const sources = definition.sources;
417
- async function get(identity) {
418
- if (!Array.isArray(identity) || identity.length !== 2 || String(identity[0]) !== identity[0] || String(identity[1]) !== identity[1]) throw sourceErrorDiagnostics.SOURCE_R0010({ message: "[vitehub] Combined Source identity must be a [source, key] string tuple." });
419
- const [source, key] = identity;
420
- if (!Object.hasOwn(sources, source)) throw sourceError(`[vitehub] Combined Source alias ${JSON.stringify(source)} is not defined.`);
421
- return await sources[source].get(key);
422
- }
423
- async function items() {
424
- const entries = Object.entries(sources);
425
- for (const [source, reader] of entries) if (typeof reader.items !== "function") throw sourceError(`[vitehub] Combined Source alias ${JSON.stringify(source)} is not enumerable.`);
426
- return (await Promise.all(entries.map(async ([source, reader]) => (await reader.items()).map((item) => ({
427
- ...item,
428
- identity: [source, item.key],
429
- source
430
- }))))).flat();
431
- }
432
- return Object.values(sources).every((source) => typeof source.items === "function") ? {
433
- get,
434
- items
435
- } : { get };
436
- }
437
- //#endregion
438
247
  //#region src/core/split-source.ts
439
248
  /** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
440
249
  function splitSource(options) {
@@ -520,9 +329,6 @@ function splitSource(options) {
520
329
  function defineSource(source) {
521
330
  return source;
522
331
  }
523
- function defineSources(sources) {
524
- return sources;
525
- }
526
332
  //#endregion
527
333
  //#region src/core/reader.ts
528
334
  function createSourceContext(name, context = {}) {
@@ -687,4 +493,143 @@ const sourceIgnores = Object.freeze({
687
493
  system
688
494
  });
689
495
  //#endregion
690
- export { CollectionCursorError, array, clearSources, combineSources, createSource, defineCollection, defineSource, defineSources, getRegisteredSource, registerSource, registerSources, sourceIgnores, splitSource, useSource };
496
+ //#region src/sources/file.ts
497
+ function normalizeFileSourceOptions(input) {
498
+ return typeof input === "string" ? { path: input } : input;
499
+ }
500
+ function sourceKey(options) {
501
+ if (Object.hasOwn(options, "workspacePath") && options.workspacePath) return normalizeSafeSourcePath(options.workspacePath);
502
+ if (Object.hasOwn(options, "path") && options.path) return normalizeSourcePath(normalizeSafeSourcePath(options.path));
503
+ throw sourceErrorDiagnostics.SOURCE_R0017({ message: "[vitehub] file requires a path or workspacePath." });
504
+ }
505
+ function resolveSourceRoot(ctx) {
506
+ return ctx.sourceRootDir || ctx.rootDir;
507
+ }
508
+ async function readSourceFile(options, ctx) {
509
+ if (!Object.hasOwn(options, "path") || !options.path) throw sourceErrorDiagnostics.SOURCE_R0018({ message: "[vitehub] file requires path when content is not provided." });
510
+ const { readFile } = await import("node:fs/promises");
511
+ const content = await readFile(await resolveSafeSourceFilePath(options.path, ctx));
512
+ return content.byteOffset === 0 && content.byteLength === content.buffer.byteLength ? new Uint8Array(content.buffer) : new Uint8Array(content);
513
+ }
514
+ async function resolveSafeSourceFilePath(path, ctx) {
515
+ const { realpath } = await import("node:fs/promises");
516
+ const { isAbsolute, relative, resolve, sep } = await import("node:path");
517
+ const root = await realpath(resolve(resolveSourceRoot(ctx)));
518
+ const target = await realpath(resolve(root, normalizeSafeSourcePath(path)));
519
+ const rel = relative(root, target);
520
+ if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) throw sourcePathError(path);
521
+ return target;
522
+ }
523
+ function file(input) {
524
+ const options = normalizeFileSourceOptions(input);
525
+ const key = sourceKey(options);
526
+ const mediaType = Object.hasOwn(options, "mediaType") && options.mediaType ? options.mediaType : lookup(key);
527
+ return {
528
+ name: "file",
529
+ key,
530
+ async getKeys() {
531
+ return [key];
532
+ },
533
+ async getMeta(requestedKey, ctx) {
534
+ if (requestedKey !== key) return;
535
+ if (!Object.hasOwn(options, "path") || !options.path) return;
536
+ const { stat } = await import("node:fs/promises");
537
+ const info = await stat(await resolveSafeSourceFilePath(options.path, ctx));
538
+ return { digest: `${info.size}:${info.mtimeMs}` };
539
+ },
540
+ async getItem(requestedKey, ctx) {
541
+ if (requestedKey !== key) throw sourceError(`[vitehub] file could not find ${JSON.stringify(requestedKey)}.`);
542
+ const content = Object.hasOwn(options, "content") && options.content !== void 0 ? options.content : await readSourceFile(options, ctx);
543
+ return {
544
+ key,
545
+ path: key,
546
+ content,
547
+ mediaType
548
+ };
549
+ }
550
+ };
551
+ }
552
+ //#endregion
553
+ //#region src/sources/files.ts
554
+ /**
555
+ * A Source of files that the server already holds, keyed by path. A ViteHub build turns `glob()` into this, with the
556
+ * matched files in the server bundle. Call it yourself for files you hold another way.
557
+ */
558
+ function files(entries, options = {}) {
559
+ const base = options.base ? `${options.base.replace(/\\/g, "/").replace(/\/+$/, "")}/` : "";
560
+ const items = /* @__PURE__ */ new Map();
561
+ for (const [path, content] of Object.entries(entries)) {
562
+ const portable = path.replace(/\\/g, "/");
563
+ if (base && !portable.startsWith(base)) throw sourceError(`[vitehub] files() path ${JSON.stringify(path)} does not start with base ${JSON.stringify(options.base)}.`);
564
+ const key = normalizeSafeSourcePath(portable.slice(base.length).replace(/^\.\//, ""));
565
+ if (items.has(key)) throw sourceError(`[vitehub] files() has two files at ${JSON.stringify(key)}.`);
566
+ items.set(key, content);
567
+ }
568
+ const keys = [...items.keys()].sort((left, right) => left.localeCompare(right));
569
+ const prefix = normalizeSafeSourcePath(options.prefix || "", { allowEmpty: true });
570
+ return {
571
+ name: "files",
572
+ async getKeys() {
573
+ return keys.slice();
574
+ },
575
+ async getItem(key) {
576
+ const entry = items.get(key);
577
+ if (entry === void 0) throw sourceError(`[vitehub] files() could not find ${JSON.stringify(key)}.`);
578
+ const content = typeof entry === "function" ? await entry() : entry;
579
+ return {
580
+ key,
581
+ path: normalizeSourcePath(prefix ? `${prefix}/${key}` : key),
582
+ content,
583
+ mediaType: lookup(key)
584
+ };
585
+ }
586
+ };
587
+ }
588
+ //#endregion
589
+ //#region src/sources/github/lazy.ts
590
+ /**
591
+ * github() as the Source root exports it. The loader imports Node built-ins, ocache, and the forge client, so it loads
592
+ * on the first read. A bundle that imports the root and never calls github() keeps none of them.
593
+ */
594
+ function github(options) {
595
+ const root = normalizeGitHubRoot(options.root || "");
596
+ let loader;
597
+ const load = () => loader ??= import("./github-D5S0dEZe.js").then((module) => module.github(options)).catch((error) => {
598
+ loader = void 0;
599
+ throw error;
600
+ });
601
+ return {
602
+ cache: options.cache,
603
+ fingerprint: {
604
+ ignore: options.ignore,
605
+ include: options.include,
606
+ ref: options.ref || "default",
607
+ repo: options.repo,
608
+ root
609
+ },
610
+ name: "github",
611
+ authenticated: async () => await (await load()).authenticated(),
612
+ history: async (key, historyOptions) => await (await load()).history(key, historyOptions),
613
+ latest: async (keys, latestOptions) => await (await load()).latest(keys, latestOptions),
614
+ changes: async (base, head) => await (await load()).changes(base, head),
615
+ pullChanges: async (number) => await (await load()).pullChanges(number),
616
+ resolveRef: async (ref, refOptions) => await (await load()).resolveRef(ref, refOptions),
617
+ contains: async (sha, refOptions) => await (await load()).contains(sha, refOptions),
618
+ pullsAt: async (sha, refOptions) => await (await load()).pullsAt(sha, refOptions),
619
+ resolveRevision: async (ctx) => await (await load()).resolveRevision(ctx),
620
+ getKeys: async (ctx) => await (await load()).getKeys(ctx),
621
+ getItems: async (ctx) => await (await load()).getItems(ctx),
622
+ getMeta: async (key, ctx) => await (await load()).getMeta(key, ctx),
623
+ getItem: async (key, ctx) => await (await load()).getItem(key, ctx)
624
+ };
625
+ }
626
+ //#endregion
627
+ //#region src/sources/markdown.ts
628
+ function markdown(options) {
629
+ return file({
630
+ ...options,
631
+ mediaType: Object.hasOwn(options, "mediaType") && options.mediaType ? options.mediaType : "text/markdown"
632
+ });
633
+ }
634
+ //#endregion
635
+ export { CollectionCursorError, array, clearSources, createSource, defineCollection, defineSource, file, files, github, glob, markdown, registerSource, registerSources, sourceIgnores, splitSource, useSource };
@@ -0,0 +1,22 @@
1
+ import { defineDiagnostics } from "nostics";
2
+ //#region ../internal/src/invariant.ts
3
+ const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
4
+ docsBase: "https://vitehub.dev/docs/development/diagnostics",
5
+ codes: { INTERNAL_INVARIANT_FAILED: {
6
+ why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
7
+ fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
8
+ } }
9
+ });
10
+ /**
11
+ * The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
12
+ * Use a code from the package catalog when a developer can cause the error or fix it.
13
+ */
14
+ function invariantError(what) {
15
+ return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
16
+ }
17
+ /** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
18
+ function invariant(condition, what) {
19
+ if (!condition) throw invariantError(what);
20
+ }
21
+ //#endregion
22
+ export { invariantError as n, invariant as t };
package/dist/mcp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as SourceContext, o as SourceCacheOptions, t as FileSource } from "./types-BigOktIj.js";
1
+ import { l as SourceContext, s as SourceCacheOptions, t as FileSource } from "./types-Ln-FxVFn.js";
2
2
  //#region src/sources/mcp-resources.d.ts
3
3
  interface McpResourcesRequestOptions {
4
4
  maxTotalTimeout?: number;