@vite-hub/source 0.5.0 → 0.5.1
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/client.d.ts +2 -3
- package/dist/client.js +3 -4
- package/dist/{collection-BYbbVAf8.js → collection-BNG6XUBS.js} +5 -8
- package/dist/{collection-DTk0O1SE.d.ts → collection-DXi2zyTi.d.ts} +0 -4
- package/dist/{collection-route-BplWPxHR.js → collection-route-DhDZBuGk.js} +1 -2
- package/dist/drizzle.d.ts +2 -3
- package/dist/drizzle.js +2 -3
- package/dist/{error-diagnostics-DZdhDQpU.js → error-diagnostics-TunlTPXq.js} +1 -2
- package/dist/{github-D5JBLnyA.js → github-DfF_3WEy.js} +17 -20
- package/dist/{glob-DT9HlkyK.js → glob-BphSHshh.js} +5 -8
- package/dist/index.d.ts +3 -25
- package/dist/index.js +16 -24
- package/dist/internal/registry.d.ts +1 -1
- package/dist/internal/registry.js +1 -2
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/mcp.d.ts +1 -3
- package/dist/mcp.js +5 -7
- package/dist/{object-CtSHeGQO.js → object-D8cOtgW3.js} +1 -2
- package/dist/{path-Q-KcGmAN.js → path-8MJ_XVEB.js} +10 -18
- package/dist/{path-Cm7wV1Dk.js → path-ZomRTEWV.js} +2 -4
- package/dist/{registry-BSyFEr9r.js → registry-BNY8hxZp.js} +3 -5
- package/dist/{registry-CUv12y8b.d.ts → registry-CDV7weMm.d.ts} +1 -3
- package/dist/{root-0Ef8tgF5.js → root-gdkJ8uqd.js} +2 -3
- package/dist/server.d.ts +1 -5
- package/dist/server.js +4 -6
- package/dist/{types-Ln-FxVFn.d.ts → types-CYDwACKn.d.ts} +0 -2
- package/dist/vite.d.ts +0 -8
- package/dist/vite.js +36 -38
- package/package.json +14 -14
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as CollectionClientItem, c as CollectionFacets, h as CollectionQuery, p as CollectionPage, t as AnyCollection } from "./collection-
|
|
1
|
+
import { a as CollectionClientItem, c as CollectionFacets, h as CollectionQuery, p as CollectionPage, t as AnyCollection } from "./collection-DXi2zyTi.js";
|
|
2
2
|
import { Diagnostic } from "nostics";
|
|
3
3
|
import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
4
|
-
//#region src/client.d.ts
|
|
5
4
|
export interface CollectionRequestOptions {
|
|
6
5
|
query?: Record<string, unknown>;
|
|
7
6
|
signal: AbortSignal;
|
|
@@ -46,4 +45,4 @@ export declare class CollectionAccessError extends Diagnostic {
|
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
47
|
export declare function useCollection<TName extends CollectionName>(name: TName, options?: UseCollectionOptions<RegisteredCollection<TName>>): UseCollectionReturn<RegisteredCollection<TName>>;
|
|
49
|
-
|
|
48
|
+
export {};
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as encodeCollectionRouteSegment } from "./collection-route-
|
|
2
|
-
import { t as sourceErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { n as encodeCollectionRouteSegment } from "./collection-route-DhDZBuGk.js";
|
|
2
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
3
3
|
import { Diagnostic } from "nostics";
|
|
4
4
|
import { computed, onScopeDispose, ref, toValue, watch } from "vue";
|
|
5
|
-
|
|
5
|
+
// src/client.ts
|
|
6
6
|
var CollectionRequestError = class CollectionRequestError extends Diagnostic {
|
|
7
7
|
status;
|
|
8
8
|
constructor(endpoint, status) {
|
|
@@ -200,5 +200,4 @@ function useCollection(name, options = {}) {
|
|
|
200
200
|
total
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
//#endregion
|
|
204
203
|
export { CollectionAccessError, useCollection };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { t as sourceErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { t as isPlainRecord } from "./object-
|
|
1
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
2
|
+
import { t as isPlainRecord } from "./object-D8cOtgW3.js";
|
|
3
3
|
import { Diagnostic } from "nostics";
|
|
4
|
-
|
|
4
|
+
// src/core/schema.ts
|
|
5
5
|
async function parseCollectionSchema(schema, value) {
|
|
6
6
|
const result = await schema["~standard"].validate(value);
|
|
7
7
|
if (result.issues) throw sourceErrorDiagnostics.SOURCE_R0006({ message: result.issues[0]?.message ?? "Collection value is invalid." });
|
|
8
8
|
return result.value;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
//#region src/core/collection-cursor.ts
|
|
10
|
+
// src/core/collection-cursor.ts
|
|
12
11
|
/** A Collection cursor was rejected. Routes answer `400` for `malformed` and `409` for `stale`. */
|
|
13
12
|
var CollectionCursorError = class CollectionCursorError extends Diagnostic {
|
|
14
13
|
reason;
|
|
@@ -103,8 +102,7 @@ function createCollectionCursorCodec(schema) {
|
|
|
103
102
|
}
|
|
104
103
|
};
|
|
105
104
|
}
|
|
106
|
-
|
|
107
|
-
//#region src/core/collection.ts
|
|
105
|
+
// src/core/collection.ts
|
|
108
106
|
const untransformedTableRows = Symbol.for("@vite-hub/source/untransformed-table-rows");
|
|
109
107
|
const defaultPageLimit = 50;
|
|
110
108
|
const defaultMaxLimit = 100;
|
|
@@ -292,5 +290,4 @@ function assertCollectionAccess(definition) {
|
|
|
292
290
|
function isProviderCursor(value) {
|
|
293
291
|
return value === String(value);
|
|
294
292
|
}
|
|
295
|
-
//#endregion
|
|
296
293
|
export { parseCollectionSchema as a, createCollectionCursorCodec as i, defineCollection as n, CollectionCursorError as r, assertCollectionAccess as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Diagnostic } from "nostics";
|
|
2
2
|
import { AccessAuthorizeOption, ViteHubContext } from "@vite-hub/runtime";
|
|
3
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
//#region src/core/collection-cursor.d.ts
|
|
5
4
|
/** Why a Collection rejected a cursor: it cannot be decoded, or it belongs to other data or another query. */
|
|
6
5
|
type CollectionCursorErrorReason = "malformed" | "stale";
|
|
7
6
|
interface CollectionCursorErrorOptions extends ErrorOptions {
|
|
@@ -12,8 +11,6 @@ declare class CollectionCursorError extends Diagnostic {
|
|
|
12
11
|
readonly reason: CollectionCursorErrorReason;
|
|
13
12
|
constructor(message?: string, options?: CollectionCursorErrorOptions);
|
|
14
13
|
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/core/collection.d.ts
|
|
17
14
|
declare const collectionQueryInput: unique symbol;
|
|
18
15
|
type CollectionRequestQuery = Record<string, string | readonly string[] | undefined>;
|
|
19
16
|
type CollectionCursorValue = boolean | null | number | string | readonly CollectionCursorValue[] | {
|
|
@@ -272,5 +269,4 @@ declare function defineCollection<TSourceItem, TCursorSchema extends StandardSch
|
|
|
272
269
|
querySchema?: undefined;
|
|
273
270
|
transform?: undefined;
|
|
274
271
|
}): Collection<TSourceItem, CollectionRequestQuery, CollectionRequestQuery>;
|
|
275
|
-
//#endregion
|
|
276
272
|
export { CollectionCursorErrorReason as A, ProviderCollectionOptions as C, defineCollection as D, SourceCollectionOptions as E, CollectionCursorError as O, ProviderCollectionLoader as S, ProviderCollectionSource as T, CollectionQueryInput as _, CollectionClientItem as a, CollectionSource as b, CollectionFacets as c, CollectionLoader as d, CollectionOptions as f, CollectionQueryBuilder as g, CollectionQuery as h, CollectionAccess as i, CollectionCursorErrorOptions as k, CollectionItem as l, CollectionPageOptions as m, AnyCollectionSource as n, CollectionCursorValue as o, CollectionPage as p, Collection as r, CollectionFacetValue as s, AnyCollection as t, CollectionLoadOptions as u, CollectionReadOptions as v, ProviderCollectionPage as w, CursorCollectionSource as x, CollectionRequestQuery as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/collection-route.ts
|
|
2
2
|
function encodeCollectionRouteSegment(segment) {
|
|
3
3
|
return encodeURIComponent(segment).replaceAll("*", "%2A");
|
|
4
4
|
}
|
|
@@ -6,5 +6,4 @@ function encodeCollectionRouteSegment(segment) {
|
|
|
6
6
|
function collectionRoutePath(name) {
|
|
7
7
|
return `/api/${name.split("/").map(encodeCollectionRouteSegment).join("/")}`;
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { encodeCollectionRouteSegment as n, collectionRoutePath as t };
|
package/dist/drizzle.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { _ as CollectionQueryInput, b as CollectionSource, y as CollectionRequestQuery } from "./collection-
|
|
1
|
+
import { _ as CollectionQueryInput, b as CollectionSource, y as CollectionRequestQuery } from "./collection-DXi2zyTi.js";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
//#region src/drizzle.d.ts
|
|
4
3
|
interface TableShape {
|
|
5
4
|
readonly _: {
|
|
6
5
|
readonly columns: Record<string, unknown>;
|
|
@@ -45,4 +44,4 @@ export declare function table<TTable extends TableShape>(options: TableSourceOpt
|
|
|
45
44
|
}): CollectionSource<TTable["$inferSelect"], CollectionRequestQuery, KeysetCursor> & {
|
|
46
45
|
rawRows: true;
|
|
47
46
|
};
|
|
48
|
-
|
|
47
|
+
export {};
|
package/dist/drizzle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as sourceErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
2
2
|
import { and, asc, desc, eq, getTableColumns, gt, lt, or } from "drizzle-orm";
|
|
3
|
-
|
|
3
|
+
// src/drizzle.ts
|
|
4
4
|
const requestQuerySchema = { "~standard": {
|
|
5
5
|
version: 1,
|
|
6
6
|
vendor: "vite-hub",
|
|
@@ -83,5 +83,4 @@ function table(input) {
|
|
|
83
83
|
rawRows: true
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
//#endregion
|
|
87
86
|
export { table };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
4
|
const sourceErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
5
|
docsBase: "https://vitehub.dev/docs/source/diagnostics",
|
|
@@ -198,5 +198,4 @@ const sourceErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
|
-
//#endregion
|
|
202
201
|
export { sourceErrorDiagnostics as t };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath } from "./path-ZomRTEWV.js";
|
|
2
|
+
import { t as createPathMatcher } from "./path-8MJ_XVEB.js";
|
|
3
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
4
|
+
import { n as isRecord } from "./object-D8cOtgW3.js";
|
|
5
|
+
import { n as invariantError } from "./invariant-Dj2R1eMr.js";
|
|
6
|
+
import { t as normalizeGitHubRoot } from "./root-gdkJ8uqd.js";
|
|
7
7
|
import { defineDiagnostics } from "nostics";
|
|
8
8
|
import { devNull } from "node:os";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { gunzipSync } from "node:zlib";
|
|
11
11
|
import { defineCachedFunction } from "ocache";
|
|
12
12
|
import { Buffer } from "node:buffer";
|
|
13
|
-
|
|
13
|
+
// ../internal/src/error-diagnostics.ts
|
|
14
14
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
15
15
|
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
16
16
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
@@ -267,6 +267,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
267
267
|
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
268
268
|
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
269
269
|
},
|
|
270
|
+
INTERNAL_SITE_TOKEN_TOO_LONG: {
|
|
271
|
+
why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
|
|
272
|
+
fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
|
|
273
|
+
},
|
|
270
274
|
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
271
275
|
why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
|
|
272
276
|
fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
|
|
@@ -281,8 +285,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
287
|
});
|
|
284
|
-
|
|
285
|
-
//#region src/sources/github/archive.ts
|
|
288
|
+
// src/sources/github/archive.ts
|
|
286
289
|
function parseGitHubArchive(bytes) {
|
|
287
290
|
const tar = gunzipSync(bytes);
|
|
288
291
|
const files = [];
|
|
@@ -348,8 +351,7 @@ function stripArchiveRoot(path) {
|
|
|
348
351
|
return;
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
|
-
|
|
352
|
-
//#region src/sources/github/cache.ts
|
|
354
|
+
// src/sources/github/cache.ts
|
|
353
355
|
function normalizeGitHubCache(options) {
|
|
354
356
|
if (options.cache === false) return;
|
|
355
357
|
if (options.cache && typeof options.cache === "object") return { maxAge: options.cache.maxAge };
|
|
@@ -369,8 +371,7 @@ function createGitHubCacheKey(input) {
|
|
|
369
371
|
function githubAuthenticationScope(token) {
|
|
370
372
|
return token ? createHash("sha256").update(token).digest("hex") : "anonymous";
|
|
371
373
|
}
|
|
372
|
-
|
|
373
|
-
//#region ../internal/src/forge.ts
|
|
374
|
+
// ../internal/src/forge.ts
|
|
374
375
|
/**
|
|
375
376
|
* Server Env of each Forge, keyed by the `env.server.<forge>.<field>` path.
|
|
376
377
|
* Channels, Capabilities, Workspaces and Sources read the same names.
|
|
@@ -466,8 +467,7 @@ function forgeImportError(error, feature) {
|
|
|
466
467
|
function isMissingForge(error) {
|
|
467
468
|
return error instanceof Error && /(?:cannot find (?:package|module)|no such module|could not resolve) ['"]@vite-hub\/forge['"]/i.test(error.message);
|
|
468
469
|
}
|
|
469
|
-
|
|
470
|
-
//#region src/sources/github/client.ts
|
|
470
|
+
// src/sources/github/client.ts
|
|
471
471
|
/** `@vite-hub/forge`, an optional peer. A GitHub Source loads it on its first request. */
|
|
472
472
|
async function loadForge() {
|
|
473
473
|
try {
|
|
@@ -778,8 +778,7 @@ function createGitHubClient(repo) {
|
|
|
778
778
|
}
|
|
779
779
|
};
|
|
780
780
|
}
|
|
781
|
-
|
|
782
|
-
//#region src/sources/github/git.ts
|
|
781
|
+
// src/sources/github/git.ts
|
|
783
782
|
function createGitEnv(home, authHeader, baseEnv = process.env) {
|
|
784
783
|
const env = { ...baseEnv };
|
|
785
784
|
for (const key of [
|
|
@@ -957,8 +956,7 @@ async function loadGitArchiveFiles(input, executeGit = runGit) {
|
|
|
957
956
|
});
|
|
958
957
|
}
|
|
959
958
|
}
|
|
960
|
-
|
|
961
|
-
//#region src/sources/github/index.ts
|
|
959
|
+
// src/sources/github/index.ts
|
|
962
960
|
const historyBatch = 150;
|
|
963
961
|
const historyBatchMin = 20;
|
|
964
962
|
const historyConcurrency = 4;
|
|
@@ -1319,5 +1317,4 @@ function github(options) {
|
|
|
1319
1317
|
}
|
|
1320
1318
|
};
|
|
1321
1319
|
}
|
|
1322
|
-
//#endregion
|
|
1323
1320
|
export { github };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as __toESM, r as require_picomatch, t as createPathMatcher } from "./path-
|
|
2
|
-
import { i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath } from "./path-
|
|
1
|
+
import { i as __toESM, r as require_picomatch, t as createPathMatcher } from "./path-8MJ_XVEB.js";
|
|
2
|
+
import { i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath } from "./path-ZomRTEWV.js";
|
|
3
3
|
import * as nativeFs from "fs";
|
|
4
4
|
import { readdir, readdirSync, realpath, realpathSync, stat, statSync } from "fs";
|
|
5
5
|
import { basename, dirname, isAbsolute, normalize, posix, relative, resolve, sep } from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
-
|
|
7
|
+
// ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.7/node_modules/fdir/dist/index.mjs
|
|
8
8
|
function cleanPath(path) {
|
|
9
9
|
let normalized = normalize(path);
|
|
10
10
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
@@ -505,8 +505,7 @@ var Builder = class {
|
|
|
505
505
|
return this;
|
|
506
506
|
}
|
|
507
507
|
};
|
|
508
|
-
|
|
509
|
-
//#region ../../node_modules/.pnpm/tinyglobby@0.2.17/node_modules/tinyglobby/dist/index.mjs
|
|
508
|
+
// ../../node_modules/.pnpm/tinyglobby@0.2.17/node_modules/tinyglobby/dist/index.mjs
|
|
510
509
|
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
511
510
|
const isReadonlyArray = Array.isArray;
|
|
512
511
|
const BACKSLASHES = /\\/g;
|
|
@@ -783,8 +782,7 @@ async function glob$1(globInput, options) {
|
|
|
783
782
|
const [crawler, relative] = getCrawler(globInput, options);
|
|
784
783
|
return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
|
|
785
784
|
}
|
|
786
|
-
|
|
787
|
-
//#region src/sources/glob.ts
|
|
785
|
+
// src/sources/glob.ts
|
|
788
786
|
/**
|
|
789
787
|
* The options a pattern stands for: the folders before its first wildcard are `cwd`, so keys are the paths below
|
|
790
788
|
* them (`content/docs/**\/*.md` keys `guide/setup.md`). A pattern without a wildcard names a folder: every file in it.
|
|
@@ -989,5 +987,4 @@ async function resolveRootedGlobFilePath(key, paths, followSymlinks) {
|
|
|
989
987
|
function isUnavailablePathError(error) {
|
|
990
988
|
return error instanceof Error && ["ENOENT", "ELOOP"].includes(String(Reflect.get(error, "code")));
|
|
991
989
|
}
|
|
992
|
-
//#endregion
|
|
993
990
|
export { resolveGlobInput as i, glob as n, globFilePath as r, collectGlobFiles as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { A as CollectionCursorErrorReason, C as ProviderCollectionOptions, D as defineCollection, E as SourceCollectionOptions, O as CollectionCursorError, S as ProviderCollectionLoader, T as ProviderCollectionSource, _ as CollectionQueryInput, a as CollectionClientItem, b as CollectionSource, c as CollectionFacets, d as CollectionLoader, f as CollectionOptions, g as CollectionQueryBuilder, h as CollectionQuery, i as CollectionAccess, k as CollectionCursorErrorOptions, l as CollectionItem, m as CollectionPageOptions, n as AnyCollectionSource, o as CollectionCursorValue, p as CollectionPage, r as Collection, s as CollectionFacetValue, t as AnyCollection, u as CollectionLoadOptions, v as CollectionReadOptions, w as ProviderCollectionPage, x as CursorCollectionSource, y as CollectionRequestQuery } from "./collection-
|
|
2
|
-
import { _ as SourceMetadata, a as SingleFileSource, b as SourceRevision, c as SourceContent, d as SourceEntry, f as SourceFile, g as SourceMap, h as SourceListEntry, i as RegisteredSource, l as SourceContext, m as SourceKey, n as ReadSourceOptions, o as Source, p as SourceItem, r as ReadSourceResult, s as SourceCacheOptions, t as FileSource, u as SourceData, v as SourceName, y as SourceReader } from "./types-
|
|
3
|
-
import { o as useSource } from "./registry-
|
|
1
|
+
import { A as CollectionCursorErrorReason, C as ProviderCollectionOptions, D as defineCollection, E as SourceCollectionOptions, O as CollectionCursorError, S as ProviderCollectionLoader, T as ProviderCollectionSource, _ as CollectionQueryInput, a as CollectionClientItem, b as CollectionSource, c as CollectionFacets, d as CollectionLoader, f as CollectionOptions, g as CollectionQueryBuilder, h as CollectionQuery, i as CollectionAccess, k as CollectionCursorErrorOptions, l as CollectionItem, m as CollectionPageOptions, n as AnyCollectionSource, o as CollectionCursorValue, p as CollectionPage, r as Collection, s as CollectionFacetValue, t as AnyCollection, u as CollectionLoadOptions, v as CollectionReadOptions, w as ProviderCollectionPage, x as CursorCollectionSource, y as CollectionRequestQuery } from "./collection-DXi2zyTi.js";
|
|
2
|
+
import { _ as SourceMetadata, a as SingleFileSource, b as SourceRevision, c as SourceContent, d as SourceEntry, f as SourceFile, g as SourceMap, h as SourceListEntry, i as RegisteredSource, l as SourceContext, m as SourceKey, n as ReadSourceOptions, o as Source, p as SourceItem, r as ReadSourceResult, s as SourceCacheOptions, t as FileSource, u as SourceData, v as SourceName, y as SourceReader } from "./types-CYDwACKn.js";
|
|
3
|
+
import { o as useSource } from "./registry-CDV7weMm.js";
|
|
4
4
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
-
//#region src/core/array-collection.d.ts
|
|
7
6
|
interface ArrayCollectionSort {
|
|
8
7
|
direction?: "asc" | "desc";
|
|
9
8
|
/** Field path to sort by. Numbers sort numerically; other values sort as strings. */
|
|
@@ -66,8 +65,6 @@ export declare function array<TSchema extends StandardSchemaV1, const TFilter ex
|
|
|
66
65
|
export declare function array<TItem, const TFilter extends string = never>(load: readonly TItem[] | ArrayCollectionLoader<TItem>, options?: ArrayCollectionOptions<TFilter> & {
|
|
67
66
|
schema?: undefined;
|
|
68
67
|
}): ProviderCollectionSource<TItem, ArrayCollectionQuery<TFilter>, ArrayCollectionQueryInput<TFilter>>;
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/core/split-source.d.ts
|
|
71
68
|
/** One part of a parent item. Its key is unique inside the parent and has no `#`. */
|
|
72
69
|
type SplitSourcePart = SourceItem<string, unknown, object>;
|
|
73
70
|
interface SplitSourceOptions<TSource extends Source, TPart extends SplitSourcePart> {
|
|
@@ -92,15 +89,9 @@ type SplitSource<TSource extends Source, TPart extends SplitSourcePart> = Omit<S
|
|
|
92
89
|
};
|
|
93
90
|
/** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
|
|
94
91
|
export declare function splitSource<const TSource extends Source, TPart extends SplitSourcePart>(options: SplitSourceOptions<TSource, TPart>): SplitSource<TSource, TPart>;
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/core/define.d.ts
|
|
97
92
|
/** Define a loader. Open it with useSource() to bind its runtime context. */
|
|
98
93
|
export declare function defineSource<const TSource extends Source>(source: TSource): TSource;
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/core/errors.d.ts
|
|
101
94
|
type SourceErrorCode = "SOURCE_FAILED" | "SOURCE_NOT_FOUND" | "SOURCE_PATH_INVALID";
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/ignores.d.ts
|
|
104
95
|
export declare const sourceIgnores: Readonly<{
|
|
105
96
|
defaults: readonly string[];
|
|
106
97
|
dependencies: readonly string[];
|
|
@@ -109,8 +100,6 @@ export declare const sourceIgnores: Readonly<{
|
|
|
109
100
|
secrets: readonly string[];
|
|
110
101
|
system: readonly string[];
|
|
111
102
|
}>;
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/sources/file.d.ts
|
|
114
103
|
interface FileSourcePathOptions<TKey extends string = string> {
|
|
115
104
|
path: string;
|
|
116
105
|
workspacePath?: TKey;
|
|
@@ -126,8 +115,6 @@ interface FileSourceInlineOptions<TKey extends string = string> {
|
|
|
126
115
|
type FileSourceOptions<TKey extends string = string> = FileSourcePathOptions<TKey> | FileSourceInlineOptions<TKey>;
|
|
127
116
|
type FileSourceInput<TKey extends string = string> = FileSourceOptions<TKey> | TKey;
|
|
128
117
|
export declare function file<const TKey extends string = string>(input: FileSourceInput<TKey>): SingleFileSource<TKey>;
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/sources/files.d.ts
|
|
131
118
|
interface FilesSourceOptions {
|
|
132
119
|
/** Removed from the start of every path, such as the folder that an `import.meta.glob()` pattern starts with. */
|
|
133
120
|
base?: string;
|
|
@@ -141,8 +128,6 @@ type FilesSourceEntry = SourceContent | (() => SourceContent | Promise<SourceCon
|
|
|
141
128
|
* matched files in the server bundle. Call it yourself for files you hold another way.
|
|
142
129
|
*/
|
|
143
130
|
export declare function files(entries: Record<string, FilesSourceEntry>, options?: FilesSourceOptions): FileSource<string>;
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/sources/github/types.d.ts
|
|
146
131
|
interface GitHubSourceOptions {
|
|
147
132
|
repo: string;
|
|
148
133
|
ref?: string;
|
|
@@ -261,15 +246,11 @@ type GitHubSource = FileSource<string> & Required<Pick<FileSource<string>, "getI
|
|
|
261
246
|
signal?: AbortSignal;
|
|
262
247
|
}): Promise<GitHubPullRequest[]>;
|
|
263
248
|
};
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/sources/github/lazy.d.ts
|
|
266
249
|
/**
|
|
267
250
|
* github() as the Source root exports it. The loader imports Node built-ins, ocache, and the forge client, so it loads
|
|
268
251
|
* on the first read. A bundle that imports the root and never calls github() keeps none of them.
|
|
269
252
|
*/
|
|
270
253
|
export declare function github(options: GitHubSourceOptions): GitHubSource;
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/sources/glob.d.ts
|
|
273
254
|
interface GlobSourceOptions {
|
|
274
255
|
cwd?: string;
|
|
275
256
|
dot?: boolean;
|
|
@@ -289,8 +270,5 @@ type GlobInput = string | GlobSourceOptions;
|
|
|
289
270
|
* without a file system, such as Cloudflare Workers, serve the same files.
|
|
290
271
|
*/
|
|
291
272
|
export declare function glob(input: GlobInput): FileSource<string>;
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/sources/markdown.d.ts
|
|
294
273
|
export declare function markdown<const TKey extends string = string>(options: FileSourceOptions<TKey>): SingleFileSource<TKey>;
|
|
295
|
-
//#endregion
|
|
296
274
|
export { type AnyCollection, type AnyCollectionSource, type ArrayCollectionLoader, type ArrayCollectionOptions, type ArrayCollectionQuery, type ArrayCollectionQueryInput, type ArrayCollectionSnapshot, type ArrayCollectionSort, type Collection, type CollectionAccess, type CollectionClientItem, CollectionCursorError, type CollectionCursorErrorOptions, type CollectionCursorErrorReason, type CollectionCursorValue, type CollectionFacetValue, type CollectionFacets, type CollectionItem, type CollectionLoadOptions, type CollectionLoader, type CollectionOptions, type CollectionPage, type CollectionPageOptions, type CollectionQuery, type CollectionQueryBuilder, type CollectionQueryInput, type CollectionReadOptions, type CollectionRequestQuery, type CollectionSource, type CursorCollectionSource, type FileSource, type FileSourceInlineOptions, type FileSourceOptions, type FileSourcePathOptions, type FilesSourceEntry, type FilesSourceOptions, type GitHubFileCommit, type GitHubHistoryOptions, type GitHubPullRequest, type GitHubRef, type GitHubRefTarget, type GitHubSource, type GitHubSourceOptions, type GlobInput, type GlobSourceOptions, type ProviderCollectionLoader, type ProviderCollectionOptions, type ProviderCollectionPage, type ProviderCollectionSource, type ReadSourceOptions, type ReadSourceResult, type RegisteredSource, type SingleFileSource, type Source, type SourceCacheOptions, type SourceCollectionOptions, type SourceContent, type SourceContext, type SourceData, type SourceEntry, type SourceErrorCode, type SourceFile, type SourceItem, type SourceKey, type SourceListEntry, type SourceMap, type SourceMetadata, type SourceName, type SourceReader, type SourceRevision, type SplitSource, type SplitSourceItem, type SplitSourceKey, type SplitSourceOptions, type SplitSourcePart, defineCollection, useSource };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { t as sourceErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import { r as
|
|
3
|
-
import {
|
|
4
|
-
import { i as sourceError, n as normalizeSafeSourcePath, o as sourcePathError, r as normalizeSourcePath } from "./path-
|
|
5
|
-
import { a as useSource } from "./registry-
|
|
6
|
-
import { t as normalizeGitHubRoot } from "./root-
|
|
7
|
-
import { n as glob } from "./glob-
|
|
1
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
2
|
+
import { a as parseCollectionSchema, i as createCollectionCursorCodec, n as defineCollection, r as CollectionCursorError } from "./collection-BNG6XUBS.js";
|
|
3
|
+
import { r as isRecordOrFunction } from "./object-D8cOtgW3.js";
|
|
4
|
+
import { i as sourceError, n as normalizeSafeSourcePath, o as sourcePathError, r as normalizeSourcePath } from "./path-ZomRTEWV.js";
|
|
5
|
+
import { a as useSource } from "./registry-BNY8hxZp.js";
|
|
6
|
+
import { t as normalizeGitHubRoot } from "./root-gdkJ8uqd.js";
|
|
7
|
+
import { n as glob } from "./glob-BphSHshh.js";
|
|
8
8
|
import { lookup } from "mrmime";
|
|
9
|
-
|
|
9
|
+
// src/core/array-collection.ts
|
|
10
10
|
const defaultMaxLimit = 100;
|
|
11
11
|
const reservedQueryKeys = /* @__PURE__ */ new Set([
|
|
12
12
|
"cursor",
|
|
@@ -250,8 +250,7 @@ function array(load, options = {}) {
|
|
|
250
250
|
}
|
|
251
251
|
return source;
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
//#region src/core/split-source.ts
|
|
253
|
+
// src/core/split-source.ts
|
|
255
254
|
/** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
|
|
256
255
|
function splitSource(options) {
|
|
257
256
|
const parent = options.source;
|
|
@@ -330,14 +329,12 @@ function splitSource(options) {
|
|
|
330
329
|
getItems
|
|
331
330
|
};
|
|
332
331
|
}
|
|
333
|
-
|
|
334
|
-
//#region src/core/define.ts
|
|
332
|
+
// src/core/define.ts
|
|
335
333
|
/** Define a loader. Open it with useSource() to bind its runtime context. */
|
|
336
334
|
function defineSource(source) {
|
|
337
335
|
return source;
|
|
338
336
|
}
|
|
339
|
-
|
|
340
|
-
//#region src/ignores.ts
|
|
337
|
+
// src/ignores.ts
|
|
341
338
|
const dependencies = Object.freeze([
|
|
342
339
|
"**/node_modules/**",
|
|
343
340
|
"**/.pnpm-store/**",
|
|
@@ -373,8 +370,7 @@ const sourceIgnores = Object.freeze({
|
|
|
373
370
|
secrets,
|
|
374
371
|
system
|
|
375
372
|
});
|
|
376
|
-
|
|
377
|
-
//#region src/sources/file.ts
|
|
373
|
+
// src/sources/file.ts
|
|
378
374
|
function normalizeFileSourceOptions(input) {
|
|
379
375
|
return typeof input === "string" ? { path: input } : input;
|
|
380
376
|
}
|
|
@@ -430,8 +426,7 @@ function file(input) {
|
|
|
430
426
|
}
|
|
431
427
|
};
|
|
432
428
|
}
|
|
433
|
-
|
|
434
|
-
//#region src/sources/files.ts
|
|
429
|
+
// src/sources/files.ts
|
|
435
430
|
/**
|
|
436
431
|
* A Source of files that the server already holds, keyed by path. A ViteHub build turns `glob()` into this, with the
|
|
437
432
|
* matched files in the server bundle. Call it yourself for files you hold another way.
|
|
@@ -466,8 +461,7 @@ function files(entries, options = {}) {
|
|
|
466
461
|
}
|
|
467
462
|
};
|
|
468
463
|
}
|
|
469
|
-
|
|
470
|
-
//#region src/sources/github/lazy.ts
|
|
464
|
+
// src/sources/github/lazy.ts
|
|
471
465
|
/**
|
|
472
466
|
* github() as the Source root exports it. The loader imports Node built-ins, ocache, and the forge client, so it loads
|
|
473
467
|
* on the first read. A bundle that imports the root and never calls github() keeps none of them.
|
|
@@ -475,7 +469,7 @@ function files(entries, options = {}) {
|
|
|
475
469
|
function github(options) {
|
|
476
470
|
const root = normalizeGitHubRoot(options.root || "");
|
|
477
471
|
let loader;
|
|
478
|
-
const load = () => loader ??= import("./github-
|
|
472
|
+
const load = () => loader ??= import("./github-DfF_3WEy.js").then((module) => module.github(options)).catch((error) => {
|
|
479
473
|
loader = void 0;
|
|
480
474
|
throw error;
|
|
481
475
|
});
|
|
@@ -504,13 +498,11 @@ function github(options) {
|
|
|
504
498
|
getItem: async (key, ctx) => await (await load()).getItem(key, ctx)
|
|
505
499
|
};
|
|
506
500
|
}
|
|
507
|
-
|
|
508
|
-
//#region src/sources/markdown.ts
|
|
501
|
+
// src/sources/markdown.ts
|
|
509
502
|
function markdown(options) {
|
|
510
503
|
return file({
|
|
511
504
|
...options,
|
|
512
505
|
mediaType: Object.hasOwn(options, "mediaType") && options.mediaType ? options.mediaType : "text/markdown"
|
|
513
506
|
});
|
|
514
507
|
}
|
|
515
|
-
//#endregion
|
|
516
508
|
export { CollectionCursorError, array, defineCollection, defineSource, file, files, github, glob, markdown, sourceIgnores, splitSource, useSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as registerSources, i as registerSourceLoaders, n as clearSources, r as registerSource, t as SourceModuleLoader } from "../registry-
|
|
1
|
+
import { a as registerSources, i as registerSourceLoaders, n as clearSources, r as registerSource, t as SourceModuleLoader } from "../registry-CDV7weMm.js";
|
|
2
2
|
export { type SourceModuleLoader, clearSources, registerSource, registerSourceLoaders, registerSources };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { clearSources, registerSource, registerSourceLoaders, registerSources };
|
|
1
|
+
export { t as clearSources, n as registerSource, r as registerSourceLoaders, i as registerSources } from "../registry-BNY8hxZp.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
|
-
|
|
2
|
+
// ../internal/src/invariant.ts
|
|
3
3
|
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
4
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
5
5
|
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
@@ -18,5 +18,4 @@ function invariantError(what) {
|
|
|
18
18
|
function invariant(condition, what) {
|
|
19
19
|
if (!condition) throw invariantError(what);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { invariantError as n, invariant as t };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { l as SourceContext, s as SourceCacheOptions, t as FileSource } from "./types-
|
|
2
|
-
//#region src/sources/mcp-resources.d.ts
|
|
1
|
+
import { l as SourceContext, s as SourceCacheOptions, t as FileSource } from "./types-CYDwACKn.js";
|
|
3
2
|
interface McpResourcesRequestOptions {
|
|
4
3
|
maxTotalTimeout?: number;
|
|
5
4
|
onprogress?: (progress: {
|
|
@@ -147,5 +146,4 @@ interface McpResourcesSourceOptions<TKey extends string = string> {
|
|
|
147
146
|
server: McpResourcesServer;
|
|
148
147
|
}
|
|
149
148
|
export declare function mcpResources<const TKey extends string = string>(options: McpResourcesSourceOptions<TKey>): FileSource<TKey>;
|
|
150
|
-
//#endregion
|
|
151
149
|
export type { McpResourceContent, McpResourceDescriptor, McpResourcesClient, McpResourcesClientConfig, McpResourcesRequestOptions, McpResourcesServer, McpResourcesSourceOptions, McpResourcesTransport, McpResourcesTransportConfig };
|
package/dist/mcp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { i as sourceError, n as normalizeSafeSourcePath } from "./path-ZomRTEWV.js";
|
|
2
|
+
import { n as matchesAny, t as createPathMatcher } from "./path-8MJ_XVEB.js";
|
|
3
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
4
|
+
// ../internal/src/abort.ts
|
|
5
5
|
/**
|
|
6
6
|
* Runs `task` and rejects as soon as `signal` aborts, without waiting for the task.
|
|
7
7
|
*
|
|
@@ -31,8 +31,7 @@ function abortReason(signal, message) {
|
|
|
31
31
|
if (signal?.reason !== void 0) return signal.reason;
|
|
32
32
|
return new DOMException(message, "AbortError");
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
//#region src/sources/mcp-resources.ts
|
|
34
|
+
// src/sources/mcp-resources.ts
|
|
36
35
|
const mcpInterruptedMessage = "[vitehub] MCP Resource Source operation was interrupted.";
|
|
37
36
|
function isMcpResourcesClient(value) {
|
|
38
37
|
return typeof value === "object" && value !== null && hasDeclaredFunction(value, "listResources") && hasDeclaredFunction(value, "readResource");
|
|
@@ -379,5 +378,4 @@ function mcpResources(options) {
|
|
|
379
378
|
}
|
|
380
379
|
};
|
|
381
380
|
}
|
|
382
|
-
//#endregion
|
|
383
381
|
export { mcpResources };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../internal/src/object.ts
|
|
2
2
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -13,5 +13,4 @@ function isPlainRecord(value) {
|
|
|
13
13
|
if (prototype === null) return true;
|
|
14
14
|
return Object.getPrototypeOf(prototype) === null && Object.hasOwn(prototype, "constructor") && prototype.constructor?.name === "Object";
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { isRecord as n, isRecordOrFunction as r, isPlainRecord as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { r as normalizeSourcePath } from "./path-
|
|
2
|
-
|
|
1
|
+
import { r as normalizeSourcePath } from "./path-ZomRTEWV.js";
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
12
|
key = keys[i];
|
|
@@ -21,8 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
value: mod,
|
|
22
22
|
enumerable: true
|
|
23
23
|
}) : target, mod));
|
|
24
|
-
|
|
25
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js
|
|
24
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js
|
|
26
25
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
27
26
|
const WIN_SLASH = "\\\\/";
|
|
28
27
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
@@ -190,8 +189,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
190
189
|
}
|
|
191
190
|
};
|
|
192
191
|
}));
|
|
193
|
-
|
|
194
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js
|
|
192
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js
|
|
195
193
|
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
196
194
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
197
195
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
@@ -238,8 +236,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
238
236
|
return last;
|
|
239
237
|
};
|
|
240
238
|
}));
|
|
241
|
-
|
|
242
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js
|
|
239
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js
|
|
243
240
|
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
244
241
|
const utils = require_utils();
|
|
245
242
|
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
@@ -535,8 +532,7 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
535
532
|
};
|
|
536
533
|
module.exports = scan;
|
|
537
534
|
}));
|
|
538
|
-
|
|
539
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js
|
|
535
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js
|
|
540
536
|
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
541
537
|
const constants = require_constants();
|
|
542
538
|
const utils = require_utils();
|
|
@@ -1612,8 +1608,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1612
1608
|
};
|
|
1613
1609
|
module.exports = parse;
|
|
1614
1610
|
}));
|
|
1615
|
-
|
|
1616
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js
|
|
1611
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js
|
|
1617
1612
|
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1618
1613
|
const scan = require_scan();
|
|
1619
1614
|
const parse = require_parse();
|
|
@@ -1926,8 +1921,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1926
1921
|
*/
|
|
1927
1922
|
module.exports = picomatch;
|
|
1928
1923
|
}));
|
|
1929
|
-
|
|
1930
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js
|
|
1924
|
+
// ../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js
|
|
1931
1925
|
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1932
1926
|
const pico = require_picomatch$1();
|
|
1933
1927
|
const utils = require_utils();
|
|
@@ -1941,8 +1935,7 @@ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1941
1935
|
Object.assign(picomatch, pico);
|
|
1942
1936
|
module.exports = picomatch;
|
|
1943
1937
|
}));
|
|
1944
|
-
|
|
1945
|
-
//#region src/sources/path.ts
|
|
1938
|
+
// src/sources/path.ts
|
|
1946
1939
|
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
|
|
1947
1940
|
function createPathMatcher(patterns) {
|
|
1948
1941
|
if (!patterns) return () => true;
|
|
@@ -1952,5 +1945,4 @@ function createPathMatcher(patterns) {
|
|
|
1952
1945
|
function matchesAny(path, patterns) {
|
|
1953
1946
|
return createPathMatcher(patterns)(path);
|
|
1954
1947
|
}
|
|
1955
|
-
//#endregion
|
|
1956
1948
|
export { __toESM as i, matchesAny as n, require_picomatch as r, createPathMatcher as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
2
|
-
|
|
2
|
+
// src/core/errors.ts
|
|
3
3
|
function sourceError(message, options) {
|
|
4
4
|
return new ViteHubError("SOURCE_FAILED", message, options);
|
|
5
5
|
}
|
|
@@ -10,8 +10,7 @@ function sourcePathError(path) {
|
|
|
10
10
|
const publicPath = path.slice(0, 4096);
|
|
11
11
|
return new ViteHubError("SOURCE_PATH_INVALID", `[vitehub] Source path escapes the source root: ${JSON.stringify(publicPath)}.`, { details: { path: publicPath } });
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
//#region src/core/path.ts
|
|
13
|
+
// src/core/path.ts
|
|
15
14
|
function normalizeSourcePath(path = "") {
|
|
16
15
|
return path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
17
16
|
}
|
|
@@ -28,5 +27,4 @@ function decodeSourceContent(content, options) {
|
|
|
28
27
|
if (options?.encoding === "binary") return typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
29
28
|
return typeof content === "string" ? content : new TextDecoder().decode(content);
|
|
30
29
|
}
|
|
31
|
-
//#endregion
|
|
32
30
|
export { sourceNotFoundError as a, sourceError as i, normalizeSafeSourcePath as n, sourcePathError as o, normalizeSourcePath as r, decodeSourceContent as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as sourceNotFoundError, i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath, t as decodeSourceContent } from "./path-
|
|
2
|
-
|
|
1
|
+
import { a as sourceNotFoundError, i as sourceError, n as normalizeSafeSourcePath, r as normalizeSourcePath, t as decodeSourceContent } from "./path-ZomRTEWV.js";
|
|
2
|
+
// src/core/reader.ts
|
|
3
3
|
function createSourceContext(name, context = {}) {
|
|
4
4
|
return {
|
|
5
5
|
abortSignal: context.abortSignal,
|
|
@@ -101,8 +101,7 @@ function openSource(load, name, context) {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
//#region src/core/registry.ts
|
|
104
|
+
// src/core/registry.ts
|
|
106
105
|
const registryKey = Symbol.for("vitehub.source.registry");
|
|
107
106
|
function sourceRegistry() {
|
|
108
107
|
const store = globalThis;
|
|
@@ -152,5 +151,4 @@ function useSource(input, context) {
|
|
|
152
151
|
source: context?.source ?? input
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
|
-
//#endregion
|
|
156
154
|
export { useSource as a, registerSources as i, registerSource as n, registerSourceLoaders as r, clearSources as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as RegisteredSource, l as SourceContext, o as Source, v as SourceName, y as SourceReader } from "./types-
|
|
2
|
-
//#region src/core/registry.d.ts
|
|
1
|
+
import { i as RegisteredSource, l as SourceContext, o as Source, v as SourceName, y as SourceReader } from "./types-CYDwACKn.js";
|
|
3
2
|
/** Imports the module of a Source file, such as `() => import("./server/sources/docs.ts")`. */
|
|
4
3
|
type SourceModuleLoader = () => Promise<{
|
|
5
4
|
default: Source;
|
|
@@ -19,5 +18,4 @@ declare function clearSources(): void;
|
|
|
19
18
|
*/
|
|
20
19
|
declare function useSource<TName extends SourceName>(name: TName, context?: Partial<SourceContext>): SourceReader<RegisteredSource<TName>>;
|
|
21
20
|
declare function useSource<const TSource extends Source>(source: TSource, context?: Partial<SourceContext>): SourceReader<TSource>;
|
|
22
|
-
//#endregion
|
|
23
21
|
export { registerSources as a, registerSourceLoaders as i, clearSources as n, useSource as o, registerSource as r, SourceModuleLoader as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as normalizeSafeSourcePath } from "./path-
|
|
2
|
-
|
|
1
|
+
import { n as normalizeSafeSourcePath } from "./path-ZomRTEWV.js";
|
|
2
|
+
// src/sources/github/root.ts
|
|
3
3
|
function normalizeGitHubRoot(path = "") {
|
|
4
4
|
const root = path.replace(/\\/g, "/").split("/").filter((part) => part !== ".").join("/");
|
|
5
5
|
return normalizeSafeSourcePath(root, {
|
|
@@ -7,5 +7,4 @@ function normalizeGitHubRoot(path = "") {
|
|
|
7
7
|
allowReserved: true
|
|
8
8
|
}).split("/").filter(Boolean).join("/");
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { normalizeGitHubRoot as t };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { r as Collection } from "./collection-
|
|
1
|
+
import { r as Collection } from "./collection-DXi2zyTi.js";
|
|
2
2
|
import { AccessAuthorizeOption, ViteHubContext } from "@vite-hub/runtime";
|
|
3
3
|
import { CacheOptions } from "ocache";
|
|
4
|
-
//#region src/cached-source.d.ts
|
|
5
4
|
interface KeyedSourceReader {
|
|
6
5
|
get(key: never): Promise<unknown>;
|
|
7
6
|
}
|
|
@@ -11,8 +10,6 @@ type SourceReaderCacheOptions<TKey, TValue> = Omit<CacheOptions<TValue, [key: TK
|
|
|
11
10
|
};
|
|
12
11
|
/** Cache `get(key)` in the Nitro `cache` storage. Other reader operations pass through unchanged. */
|
|
13
12
|
export declare function cachedSource<const TReader extends KeyedSourceReader>(reader: TReader & ValidCachedGet<TReader>, options: SourceReaderCacheOptions<Parameters<TReader["get"]>[0], Awaited<ReturnType<TReader["get"]>>>): TReader;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/server.d.ts
|
|
16
13
|
/** A Collection route as a Fetchable. Mount it as a Nitro route, or call `fetch()` with a Web Request. */
|
|
17
14
|
export interface CollectionHandler {
|
|
18
15
|
fetch(request: Request): Promise<Response>;
|
|
@@ -24,5 +21,4 @@ export interface CollectionHandlerOptions {
|
|
|
24
21
|
withAuthorization?: CollectionAuthorizationGuard;
|
|
25
22
|
}
|
|
26
23
|
export declare function defineCollectionHandler<TItem, TQuery extends object, TQueryInput extends object>(collection: Collection<TItem, TQuery, TQueryInput>, options?: CollectionHandlerOptions): CollectionHandler;
|
|
27
|
-
//#endregion
|
|
28
24
|
export type { SourceReaderCacheOptions };
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { r as CollectionCursorError, t as assertCollectionAccess } from "./collection-BNG6XUBS.js";
|
|
2
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
3
|
+
// src/cached-source.ts
|
|
4
4
|
/** Cache `get(key)` in the Nitro `cache` storage. Other reader operations pass through unchanged. */
|
|
5
5
|
function cachedSource(reader, options) {
|
|
6
6
|
let cachedGet;
|
|
@@ -37,8 +37,7 @@ function cachedSource(reader, options) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
//#region src/server.ts
|
|
40
|
+
// src/server.ts
|
|
42
41
|
function requestQuery(request) {
|
|
43
42
|
const query = /* @__PURE__ */ new Map();
|
|
44
43
|
for (const [key, value] of new URL(request.url).searchParams) {
|
|
@@ -136,5 +135,4 @@ function defineCollectionHandler(collection, options = {}) {
|
|
|
136
135
|
};
|
|
137
136
|
return { fetch: authorize && withAuthorization ? withAuthorization(authorize, handlePage) : handlePage };
|
|
138
137
|
}
|
|
139
|
-
//#endregion
|
|
140
138
|
export { cachedSource, defineCollectionHandler };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/types.d.ts
|
|
2
1
|
type SourceContent = string | Uint8Array;
|
|
3
2
|
interface ReadSourceOptions {
|
|
4
3
|
encoding?: "utf8" | "binary";
|
|
@@ -94,5 +93,4 @@ type SourceReader<TSource extends Source = Source> = {
|
|
|
94
93
|
} & (SourceEntry<TSource> extends {
|
|
95
94
|
content: SourceContent;
|
|
96
95
|
} ? SourceFileMethods<SourceKey<TSource>> : object);
|
|
97
|
-
//#endregion
|
|
98
96
|
export { SourceMetadata as _, SingleFileSource as a, SourceRevision as b, SourceContent as c, SourceEntry as d, SourceFile as f, SourceMap as g, SourceListEntry as h, RegisteredSource as i, SourceContext as l, SourceKey as m, ReadSourceOptions as n, Source as o, SourceItem as p, ReadSourceResult as r, SourceCacheOptions as s, FileSource as t, SourceData as u, SourceName as v, SourceReader as y };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
|
-
//#region ../internal/src/inspect.d.ts
|
|
3
2
|
interface ViteHubDefinitionField {
|
|
4
3
|
label: string;
|
|
5
4
|
value: string;
|
|
@@ -61,8 +60,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
|
|
|
61
60
|
interface ViteHubInspectionPluginMetadata {
|
|
62
61
|
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
63
62
|
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region ../internal/src/contributions.d.ts
|
|
66
63
|
/** Roots that ViteHub passes to every contribution factory. */
|
|
67
64
|
interface ContributionContext {
|
|
68
65
|
/** Vite root. */
|
|
@@ -74,8 +71,6 @@ interface ContributionContext {
|
|
|
74
71
|
/** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
|
|
75
72
|
plugins?: readonly unknown[];
|
|
76
73
|
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/inspect.d.ts
|
|
79
74
|
interface CollectionInspectionOptions {
|
|
80
75
|
projectRoot: string;
|
|
81
76
|
/** Server directories, relative to `projectRoot` or absolute. Defaults to `server`. */
|
|
@@ -86,8 +81,6 @@ interface CollectionInspectionOptions {
|
|
|
86
81
|
* does not import it, so values that are computed at runtime show as `Dynamic`.
|
|
87
82
|
*/
|
|
88
83
|
export declare function inspectCollectionDefinitions(options: CollectionInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/vite.d.ts
|
|
91
84
|
/** A file ViteHub generates for Nitro: a route handler, or a Nitro plugin such as the Content preview scope. */
|
|
92
85
|
export type GeneratedSourceHandler = GeneratedSourceRoute | GeneratedSourcePlugin;
|
|
93
86
|
export interface GeneratedSourceRoute {
|
|
@@ -261,5 +254,4 @@ export declare function hubSource(options?: SourceVitePluginOptions): Plugin & {
|
|
|
261
254
|
}>>;
|
|
262
255
|
};
|
|
263
256
|
};
|
|
264
|
-
//#endregion
|
|
265
257
|
export type { CollectionInspectionOptions };
|
package/dist/vite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
1
|
+
import { n as isRecord, r as isRecordOrFunction } from "./object-D8cOtgW3.js";
|
|
2
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
3
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
4
|
+
import { t as collectionRoutePath } from "./collection-route-DhDZBuGk.js";
|
|
5
|
+
import { i as resolveGlobInput, r as globFilePath, t as collectGlobFiles } from "./glob-BphSHshh.js";
|
|
6
6
|
import { formatDiagnostic } from "nostics";
|
|
7
7
|
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, dirname, extname, isAbsolute, join, parse, relative, resolve } from "node:path";
|
|
@@ -14,7 +14,7 @@ import { randomUUID } from "node:crypto";
|
|
|
14
14
|
import { once } from "node:events";
|
|
15
15
|
import { createServer } from "node:http";
|
|
16
16
|
import { gzipSync } from "node:zlib";
|
|
17
|
-
|
|
17
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
18
18
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
19
19
|
function normalizeWindowsPath(input = "") {
|
|
20
20
|
if (!input) return input;
|
|
@@ -111,16 +111,14 @@ const dirname$1 = function(p) {
|
|
|
111
111
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
112
112
|
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
113
113
|
};
|
|
114
|
-
|
|
115
|
-
//#region ../internal/src/inspect.ts
|
|
114
|
+
// ../internal/src/inspect.ts
|
|
116
115
|
function relativeDefinitionFile(projectRoot, file) {
|
|
117
116
|
return relative$1(projectRoot, file).replaceAll("\\", "/");
|
|
118
117
|
}
|
|
119
118
|
const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
|
|
120
119
|
new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
|
|
121
120
|
new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
|
|
122
|
-
|
|
123
|
-
//#region ../internal/src/build/vite.ts
|
|
121
|
+
// ../internal/src/build/vite.ts
|
|
124
122
|
const projectRootDirectoryMarkers = [
|
|
125
123
|
["server", "agents"],
|
|
126
124
|
["server", "channels"],
|
|
@@ -195,8 +193,7 @@ function isMissingProjectMarker(error) {
|
|
|
195
193
|
const code = error.code;
|
|
196
194
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
197
195
|
}
|
|
198
|
-
|
|
199
|
-
//#region ../internal/src/build/ast-walk.ts
|
|
196
|
+
// ../internal/src/build/ast-walk.ts
|
|
200
197
|
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
201
198
|
function moduleLanguage(file) {
|
|
202
199
|
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
@@ -219,8 +216,7 @@ function walk$1(node, visit, parent) {
|
|
|
219
216
|
} else if (isNode$1(child)) walk$1(child, visit, node);
|
|
220
217
|
}
|
|
221
218
|
}
|
|
222
|
-
|
|
223
|
-
//#region ../internal/src/build/scan-module.ts
|
|
219
|
+
// ../internal/src/build/scan-module.ts
|
|
224
220
|
/**
|
|
225
221
|
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
226
222
|
* the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
|
|
@@ -371,8 +367,7 @@ function staticString(node) {
|
|
|
371
367
|
const value = staticValue(node);
|
|
372
368
|
return typeof value === "string" ? value : void 0;
|
|
373
369
|
}
|
|
374
|
-
|
|
375
|
-
//#region ../internal/src/hints.ts
|
|
370
|
+
// ../internal/src/hints.ts
|
|
376
371
|
/**
|
|
377
372
|
* The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
|
|
378
373
|
* about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
|
|
@@ -486,8 +481,7 @@ function createNitroServerKit(value = {}) {
|
|
|
486
481
|
}
|
|
487
482
|
};
|
|
488
483
|
}
|
|
489
|
-
|
|
490
|
-
//#region ../internal/src/build/paths.ts
|
|
484
|
+
// ../internal/src/build/paths.ts
|
|
491
485
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
492
486
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
493
487
|
return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
|
|
@@ -514,8 +508,7 @@ function findPackageDir(file) {
|
|
|
514
508
|
function ownModule(importMetaUrl, modulePath) {
|
|
515
509
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
516
510
|
}
|
|
517
|
-
|
|
518
|
-
//#region src/internal/content-types-writer.ts
|
|
511
|
+
// src/internal/content-types-writer.ts
|
|
519
512
|
const installed = /* @__PURE__ */ new WeakMap();
|
|
520
513
|
/** Keep writes in the Nitro host, including when its runtime runs in workerd. */
|
|
521
514
|
function installContentTypesWriter(host, plugin) {
|
|
@@ -564,8 +557,7 @@ async function startWriter(host, plugin) {
|
|
|
564
557
|
host.options.runtimeConfig ??= {};
|
|
565
558
|
host.options.runtimeConfig.vitehubContentTypesWriter = `http://127.0.0.1:${address.port}${path}`;
|
|
566
559
|
}
|
|
567
|
-
|
|
568
|
-
//#region src/internal/content-types-plugin.injected.ts
|
|
560
|
+
// src/internal/content-types-plugin.injected.ts
|
|
569
561
|
/**
|
|
570
562
|
* Source of the generated Nitro plugin that writes the types of `content.get()`, `content.list()`, and
|
|
571
563
|
* `content.query()` in development. `importBase` and `contentModule` are JSON string literals of import paths. The
|
|
@@ -585,8 +577,7 @@ function renderContentTypesPlugin(importBase, contentModule) {
|
|
|
585
577
|
""
|
|
586
578
|
].join("\n");
|
|
587
579
|
}
|
|
588
|
-
|
|
589
|
-
//#region src/internal/collection-discovery.ts
|
|
580
|
+
// src/internal/collection-discovery.ts
|
|
590
581
|
function declarationInitializers(module, name, exportedOnly) {
|
|
591
582
|
return module.program.body.flatMap((statement) => {
|
|
592
583
|
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : exportedOnly ? void 0 : statement;
|
|
@@ -717,8 +708,7 @@ async function discoverCollections(options) {
|
|
|
717
708
|
}
|
|
718
709
|
return collections;
|
|
719
710
|
}
|
|
720
|
-
|
|
721
|
-
//#region src/inspect.ts
|
|
711
|
+
// src/inspect.ts
|
|
722
712
|
const dynamic = "Dynamic";
|
|
723
713
|
function objectLiteral(value) {
|
|
724
714
|
return value?.type === "ObjectExpression" ? value : void 0;
|
|
@@ -955,8 +945,7 @@ function summarizeCollection(projectRoot, collection) {
|
|
|
955
945
|
async function inspectCollectionDefinitions(options) {
|
|
956
946
|
return (await discoverCollections(options)).map((collection) => summarizeCollection(options.projectRoot, collection));
|
|
957
947
|
}
|
|
958
|
-
|
|
959
|
-
//#region src/internal/bundle-glob.ts
|
|
948
|
+
// src/internal/bundle-glob.ts
|
|
960
949
|
/** Prefix of the generated modules' ids. `\0` keeps other plugins from resolving or transforming them. */
|
|
961
950
|
const BUNDLED_GLOB_ID = "\0vitehub-source-glob:";
|
|
962
951
|
/** Matches those ids, for Rolldown's hook filters. */
|
|
@@ -1112,8 +1101,7 @@ async function loadBundledGlob(id, rootDir) {
|
|
|
1112
1101
|
watched
|
|
1113
1102
|
};
|
|
1114
1103
|
}
|
|
1115
|
-
|
|
1116
|
-
//#region src/internal/source-discovery.ts
|
|
1104
|
+
// src/internal/source-discovery.ts
|
|
1117
1105
|
/** Lists the Source files under `<serverDir>/sources`. Each default export is one Source. It reads the files and does not import them. */
|
|
1118
1106
|
async function discoverSources(options) {
|
|
1119
1107
|
const serverDirs = options.serverDirs === void 0 ? [resolve(options.projectRoot, "server")] : options.serverDirs.map((directory) => resolve(options.projectRoot, directory));
|
|
@@ -1139,8 +1127,7 @@ async function discoverSources(options) {
|
|
|
1139
1127
|
}
|
|
1140
1128
|
return sources;
|
|
1141
1129
|
}
|
|
1142
|
-
|
|
1143
|
-
//#region src/vite.ts
|
|
1130
|
+
// src/vite.ts
|
|
1144
1131
|
const collectionTypesEntry = ".vitehub/types/source/collections.d.ts";
|
|
1145
1132
|
const sourceTypesEntry = ".vitehub/types/source/sources.d.ts";
|
|
1146
1133
|
const sourceRegistryEntry = ".vitehub/source/registry.mjs";
|
|
@@ -1914,6 +1901,7 @@ function hubSource(options = {}) {
|
|
|
1914
1901
|
};
|
|
1915
1902
|
const configurationTransitionByRoot = /* @__PURE__ */ new Map();
|
|
1916
1903
|
let legacyServerBuild = false;
|
|
1904
|
+
let nitroBuildHints;
|
|
1917
1905
|
let resolvedConfig;
|
|
1918
1906
|
const generatedHandlersListeners = /* @__PURE__ */ new Set();
|
|
1919
1907
|
const prepareSources = (input) => {
|
|
@@ -2007,11 +1995,14 @@ function hubSource(options = {}) {
|
|
|
2007
1995
|
},
|
|
2008
1996
|
handler(code, id, options) {
|
|
2009
1997
|
const environment = this.environment?.config;
|
|
2010
|
-
|
|
2011
|
-
|
|
1998
|
+
const nitroBuild = environment ? void 0 : nitroBuildHints;
|
|
1999
|
+
if (!(environment ? environment.consumer === "server" : options?.ssr === true && (legacyServerBuild || nitroBuild)) || environment && environment.command !== "build") return;
|
|
2000
|
+
const file = id.split(/[?#]/, 1)[0] ?? id;
|
|
2001
|
+
const lang = /\.[cm]?tsx$/.test(file) ? "tsx" : /\.[cm]?jsx$/.test(file) ? "jsx" : /\.[cm]?ts$/.test(file) ? "ts" : "js";
|
|
2002
|
+
const calls = findGlobCalls(this.parse(code, nitroBuild ? { lang } : void 0));
|
|
2012
2003
|
for (const call of calls.filter((call) => call.input === void 0)) {
|
|
2013
2004
|
const hint = sourceErrorDiagnostics.SOURCE_GLOB_OPTIONS_NOT_LITERAL();
|
|
2014
|
-
const config = environment ?? resolvedConfig;
|
|
2005
|
+
const config = environment ?? nitroBuild ?? resolvedConfig;
|
|
2015
2006
|
if (!config) {
|
|
2016
2007
|
this.warn({
|
|
2017
2008
|
message: `[vitehub] ${hint.why}`,
|
|
@@ -2020,7 +2011,7 @@ function hubSource(options = {}) {
|
|
|
2020
2011
|
continue;
|
|
2021
2012
|
}
|
|
2022
2013
|
const lines = code.slice(0, call.start).split("\n");
|
|
2023
|
-
hint.sources = [`${relative(config.root,
|
|
2014
|
+
hint.sources = [`${relative(config.root, file)}:${lines.length}:${lines.at(-1).length + 1}`];
|
|
2024
2015
|
reportViteHubHint(config, hint);
|
|
2025
2016
|
}
|
|
2026
2017
|
if (calls.some((call) => call.input !== void 0)) return {
|
|
@@ -2075,7 +2066,15 @@ function hubSource(options = {}) {
|
|
|
2075
2066
|
},
|
|
2076
2067
|
async config(config, env) {
|
|
2077
2068
|
const viteConfig = config;
|
|
2078
|
-
if (viteConfig["__vitehubNitroConfigContext"])
|
|
2069
|
+
if (viteConfig["__vitehubNitroConfigContext"]) {
|
|
2070
|
+
nitroBuildHints = env.command === "build" ? {
|
|
2071
|
+
...config,
|
|
2072
|
+
command: env.command,
|
|
2073
|
+
root: viteConfig["__vitehubProjectRoot"] ?? config.root ?? process.cwd(),
|
|
2074
|
+
[VITEHUB_NUXT_HINTS]: true
|
|
2075
|
+
} : void 0;
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2079
2078
|
legacyServerBuild = env.command === "build" && config.build?.ssr === true;
|
|
2080
2079
|
const projectRoot = viteConfig["__vitehubProjectRoot"] ? resolve(viteConfig[VITEHUB_PROJECT_ROOT]) : resolveViteHubProjectRoot(viteConfig.root || process.cwd());
|
|
2081
2080
|
latestProjectRoot = projectRoot;
|
|
@@ -2334,5 +2333,4 @@ function hubSource(options = {}) {
|
|
|
2334
2333
|
}
|
|
2335
2334
|
};
|
|
2336
2335
|
}
|
|
2337
|
-
//#endregion
|
|
2338
2336
|
export { findContentEntry, hubSource, inspectCollectionDefinitions, inspectCollectionModule, inspectContentEntry, inspectContentModule, mergeGeneratedSourceNitroConfig, prepareSourceGeneration, toRuntimeModuleSpecifier, toTypeModuleSpecifier };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/source",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Typed source retrieval primitives for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"content",
|
|
@@ -67,37 +67,37 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@standard-schema/spec": "^1.1.0",
|
|
70
|
-
"@vite-hub/runtime": "0.5.
|
|
70
|
+
"@vite-hub/runtime": "0.5.1",
|
|
71
71
|
"mrmime": "^2.0.1",
|
|
72
72
|
"nostics": "1.4.0",
|
|
73
|
-
"ocache": "^0.3.
|
|
73
|
+
"ocache": "^0.3.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
77
|
-
"@types/node": "^24.19.
|
|
76
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
77
|
+
"@types/node": "^24.19.2",
|
|
78
78
|
"@types/picomatch": "^4.0.3",
|
|
79
|
-
"@vite-hub/forge": "0.5.
|
|
79
|
+
"@vite-hub/forge": "0.5.1",
|
|
80
80
|
"@vite-hub/internal": "0.0.1",
|
|
81
|
-
"drizzle-orm": "1.0.0-rc.
|
|
81
|
+
"drizzle-orm": "1.0.0-rc.6",
|
|
82
82
|
"h3": "^2.0.8",
|
|
83
83
|
"nitro": "^3.0.261103-rc",
|
|
84
84
|
"picomatch": "^4.0.7",
|
|
85
85
|
"publint": "^0.3.25",
|
|
86
86
|
"tinyglobby": "^0.2.17",
|
|
87
87
|
"typescript": "^6.0.3",
|
|
88
|
-
"vite": "^8.
|
|
88
|
+
"vite": "^8.3.8",
|
|
89
89
|
"valibot": "^1.5.0",
|
|
90
|
-
"vite-plus": "^
|
|
91
|
-
"vitest": "
|
|
92
|
-
"vue": "3.5.
|
|
90
|
+
"vite-plus": "^1.7.0",
|
|
91
|
+
"vitest": "5.1.0",
|
|
92
|
+
"vue": "3.5.46"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
96
|
-
"drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
|
|
95
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
96
|
+
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0",
|
|
97
97
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
98
98
|
"vite": ">=8.0.0",
|
|
99
99
|
"vue": "^3.5.0",
|
|
100
|
-
"@vite-hub/forge": "0.5.
|
|
100
|
+
"@vite-hub/forge": "0.5.1"
|
|
101
101
|
},
|
|
102
102
|
"peerDependenciesMeta": {
|
|
103
103
|
"@modelcontextprotocol/sdk": {
|