@vite-hub/source 0.0.2 → 0.0.4

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 (62) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +167 -1
  3. package/dist/auth-Ddw55OUG.js +1261 -0
  4. package/dist/client-CDfTmtQu.js +7903 -0
  5. package/dist/client.d.ts +32 -0
  6. package/dist/client.js +121 -0
  7. package/dist/collection-B8pXGM2d.js +141 -0
  8. package/dist/collection-CF2ON__k.d.ts +92 -0
  9. package/dist/collection-route-Dw7QLFyx.js +6 -0
  10. package/dist/content/client.d.ts +3 -0
  11. package/dist/content/client.js +2 -0
  12. package/dist/content.d.ts +44 -0
  13. package/dist/content.js +157 -0
  14. package/dist/file-BSWQg9Qv.js +503 -0
  15. package/dist/{file-slFAccIZ.d.ts → file-EQ3AjVM6.d.ts} +1 -1
  16. package/dist/file.d.ts +2 -0
  17. package/dist/file.js +2 -0
  18. package/dist/{index-CJpN2j6c.d.ts → github.d.ts} +4 -4
  19. package/dist/github.js +1033 -0
  20. package/dist/glob.d.ts +15 -0
  21. package/dist/glob.js +895 -0
  22. package/dist/index.d.ts +69 -10
  23. package/dist/index.js +70 -108
  24. package/dist/{markdown-Beo-0cqc.d.ts → markdown.d.ts} +3 -3
  25. package/dist/{sources/markdown.js → markdown.js} +1 -1
  26. package/dist/mcp.d.ts +152 -0
  27. package/dist/mcp.js +6115 -0
  28. package/dist/{path-B5QNI5sY.js → path-BzmU4Eni.js} +2 -10
  29. package/dist/path-CUhvUREm.js +1936 -0
  30. package/dist/registry-C8skfCSV.js +120 -0
  31. package/dist/server.d.ts +15 -0
  32. package/dist/server.js +71 -0
  33. package/dist/sse-CE9Q2JqM.js +407 -0
  34. package/dist/streamableHttp-BszaXLmg.js +491 -0
  35. package/dist/types-AIBmt_m6.js +6275 -0
  36. package/dist/types-Bu3WvNX9.d.ts +71 -0
  37. package/dist/vite.d.ts +41 -0
  38. package/dist/vite.js +629 -0
  39. package/package.json +68 -30
  40. package/tsconfig.vite.json +6 -0
  41. package/types/source/fallback.d.ts +1 -0
  42. package/types/source/index.d.ts +1 -0
  43. package/dist/chunk-D7D4PA-g.js +0 -13
  44. package/dist/custom-EnZvMLiy.d.ts +0 -6
  45. package/dist/github-B4lgrzXQ.js +0 -565
  46. package/dist/glob-CuxZwoC3.d.ts +0 -15
  47. package/dist/mcp-resources-C7-5Qeh4.d.ts +0 -41
  48. package/dist/mcp-resources-DSDqTfbK.js +0 -307
  49. package/dist/sources/custom.d.ts +0 -2
  50. package/dist/sources/custom.js +0 -6
  51. package/dist/sources/file.d.ts +0 -2
  52. package/dist/sources/file.js +0 -57
  53. package/dist/sources/github.d.ts +0 -2
  54. package/dist/sources/github.js +0 -2
  55. package/dist/sources/glob.d.ts +0 -2
  56. package/dist/sources/glob.js +0 -110
  57. package/dist/sources/index.d.ts +0 -13
  58. package/dist/sources/index.js +0 -18
  59. package/dist/sources/markdown.d.ts +0 -2
  60. package/dist/sources/mcp-resources.d.ts +0 -2
  61. package/dist/sources/mcp-resources.js +0 -2
  62. package/dist/types-f6Lyjq8g.d.ts +0 -73
@@ -1,6 +1,4 @@
1
1
  import { ViteHubError, getViteHubErrorShape } from "@vite-hub/runtime";
2
- import picomatch from "picomatch";
3
- import { isAbsolute } from "pathe";
4
2
  //#region src/core/errors.ts
5
3
  function sourceError(message, options) {
6
4
  return new ViteHubError("SOURCE_FAILED", message, options);
@@ -26,19 +24,13 @@ function normalizeSafeSourcePath(path = "", options = {}) {
26
24
  const normalized = normalizeSourcePath(path);
27
25
  const parts = normalized.split("/").filter(Boolean);
28
26
  if (!options.allowEmpty && !normalized) throw sourcePathError(path);
29
- if (isAbsolute(raw) || parts.some((part) => part === "." || part === "..")) throw sourcePathError(path);
27
+ if (raw.startsWith("/") || /^[a-z]:\//i.test(raw) || parts.some((part) => part === "." || part === "..")) throw sourcePathError(path);
30
28
  if (!options.allowReserved && (parts[0] === ".git" || parts[0] === ".vitehub")) throw sourcePathError(path);
31
29
  return normalized;
32
30
  }
33
- function matchesAny(path, patterns) {
34
- if (!patterns) return true;
35
- const list = Array.isArray(patterns) ? patterns : [patterns];
36
- const normalizedPath = normalizeSourcePath(path);
37
- return picomatch.isMatch(normalizedPath, list.map((pattern) => normalizeSourcePath(pattern)), { dot: true });
38
- }
39
31
  function decodeSourceContent(content, options) {
40
32
  if (options?.encoding === "binary") return typeof content === "string" ? new TextEncoder().encode(content) : content;
41
33
  return typeof content === "string" ? content : new TextDecoder().decode(content);
42
34
  }
43
35
  //#endregion
44
- export { isSourceError as a, sourcePathError as c, normalizeSourcePath as i, matchesAny as n, sourceError as o, normalizeSafeSourcePath as r, sourceNotFoundError as s, decodeSourceContent as t };
36
+ export { sourceError as a, isSourceError as i, normalizeSafeSourcePath as n, sourceNotFoundError as o, normalizeSourcePath as r, sourcePathError as s, decodeSourceContent as t };