@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.
- package/LICENSE +201 -0
- package/README.md +167 -1
- package/dist/auth-Ddw55OUG.js +1261 -0
- package/dist/client-CDfTmtQu.js +7903 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.js +121 -0
- package/dist/collection-B8pXGM2d.js +141 -0
- package/dist/collection-CF2ON__k.d.ts +92 -0
- package/dist/collection-route-Dw7QLFyx.js +6 -0
- package/dist/content/client.d.ts +3 -0
- package/dist/content/client.js +2 -0
- package/dist/content.d.ts +44 -0
- package/dist/content.js +157 -0
- package/dist/file-BSWQg9Qv.js +503 -0
- package/dist/{file-slFAccIZ.d.ts → file-EQ3AjVM6.d.ts} +1 -1
- package/dist/file.d.ts +2 -0
- package/dist/file.js +2 -0
- package/dist/{index-CJpN2j6c.d.ts → github.d.ts} +4 -4
- package/dist/github.js +1033 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +895 -0
- package/dist/index.d.ts +69 -10
- package/dist/index.js +70 -108
- package/dist/{markdown-Beo-0cqc.d.ts → markdown.d.ts} +3 -3
- package/dist/{sources/markdown.js → markdown.js} +1 -1
- package/dist/mcp.d.ts +152 -0
- package/dist/mcp.js +6115 -0
- package/dist/{path-B5QNI5sY.js → path-BzmU4Eni.js} +2 -10
- package/dist/path-CUhvUREm.js +1936 -0
- package/dist/registry-C8skfCSV.js +120 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +71 -0
- package/dist/sse-CE9Q2JqM.js +407 -0
- package/dist/streamableHttp-BszaXLmg.js +491 -0
- package/dist/types-AIBmt_m6.js +6275 -0
- package/dist/types-Bu3WvNX9.d.ts +71 -0
- package/dist/vite.d.ts +41 -0
- package/dist/vite.js +629 -0
- package/package.json +68 -30
- package/tsconfig.vite.json +6 -0
- package/types/source/fallback.d.ts +1 -0
- package/types/source/index.d.ts +1 -0
- package/dist/chunk-D7D4PA-g.js +0 -13
- package/dist/custom-EnZvMLiy.d.ts +0 -6
- package/dist/github-B4lgrzXQ.js +0 -565
- package/dist/glob-CuxZwoC3.d.ts +0 -15
- package/dist/mcp-resources-C7-5Qeh4.d.ts +0 -41
- package/dist/mcp-resources-DSDqTfbK.js +0 -307
- package/dist/sources/custom.d.ts +0 -2
- package/dist/sources/custom.js +0 -6
- package/dist/sources/file.d.ts +0 -2
- package/dist/sources/file.js +0 -57
- package/dist/sources/github.d.ts +0 -2
- package/dist/sources/github.js +0 -2
- package/dist/sources/glob.d.ts +0 -2
- package/dist/sources/glob.js +0 -110
- package/dist/sources/index.d.ts +0 -13
- package/dist/sources/index.js +0 -18
- package/dist/sources/markdown.d.ts +0 -2
- package/dist/sources/mcp-resources.d.ts +0 -2
- package/dist/sources/mcp-resources.js +0 -2
- 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 (
|
|
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 {
|
|
36
|
+
export { sourceError as a, isSourceError as i, normalizeSafeSourcePath as n, sourceNotFoundError as o, normalizeSourcePath as r, sourcePathError as s, decodeSourceContent as t };
|