@vite-hub/source 0.4.1 → 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/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-B8sgxw5-.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-Ln-FxVFn.js";
3
- import { o as useSource } from "./registry-CUv12y8b.js";
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> {
@@ -84,7 +81,6 @@ type SplitSourceKey<TSource extends Source> = `${SourceKey<TSource>}#${string}`;
84
81
  type SplitSourceItem<TSource extends Source, TPart extends SplitSourcePart> = Omit<TPart, "key"> & {
85
82
  key: SplitSourceKey<TSource>;
86
83
  };
87
- /** A Source with one item for each part of another Source's items. */
88
84
  type SplitSourceMeta<TSource extends Source> = NonNullable<TSource["getMeta"]> extends ((...args: any[]) => infer TResult) ? TResult : Promise<undefined>;
89
85
  type SplitSource<TSource extends Source, TPart extends SplitSourcePart> = Omit<Source<SplitSourceKey<TSource>>, "getItem" | "getItems" | "getMeta"> & {
90
86
  getItem(key: SplitSourceKey<TSource>, ctx: SourceContext): Promise<SplitSourceItem<TSource, TPart>>;
@@ -93,15 +89,9 @@ type SplitSource<TSource extends Source, TPart extends SplitSourcePart> = Omit<S
93
89
  };
94
90
  /** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
95
91
  export declare function splitSource<const TSource extends Source, TPart extends SplitSourcePart>(options: SplitSourceOptions<TSource, TPart>): SplitSource<TSource, TPart>;
96
- //#endregion
97
- //#region src/core/define.d.ts
98
92
  /** Define a loader. Open it with useSource() to bind its runtime context. */
99
93
  export declare function defineSource<const TSource extends Source>(source: TSource): TSource;
100
- //#endregion
101
- //#region src/core/errors.d.ts
102
94
  type SourceErrorCode = "SOURCE_FAILED" | "SOURCE_NOT_FOUND" | "SOURCE_PATH_INVALID";
103
- //#endregion
104
- //#region src/ignores.d.ts
105
95
  export declare const sourceIgnores: Readonly<{
106
96
  defaults: readonly string[];
107
97
  dependencies: readonly string[];
@@ -110,8 +100,6 @@ export declare const sourceIgnores: Readonly<{
110
100
  secrets: readonly string[];
111
101
  system: readonly string[];
112
102
  }>;
113
- //#endregion
114
- //#region src/sources/file.d.ts
115
103
  interface FileSourcePathOptions<TKey extends string = string> {
116
104
  path: string;
117
105
  workspacePath?: TKey;
@@ -127,8 +115,6 @@ interface FileSourceInlineOptions<TKey extends string = string> {
127
115
  type FileSourceOptions<TKey extends string = string> = FileSourcePathOptions<TKey> | FileSourceInlineOptions<TKey>;
128
116
  type FileSourceInput<TKey extends string = string> = FileSourceOptions<TKey> | TKey;
129
117
  export declare function file<const TKey extends string = string>(input: FileSourceInput<TKey>): SingleFileSource<TKey>;
130
- //#endregion
131
- //#region src/sources/files.d.ts
132
118
  interface FilesSourceOptions {
133
119
  /** Removed from the start of every path, such as the folder that an `import.meta.glob()` pattern starts with. */
134
120
  base?: string;
@@ -142,8 +128,6 @@ type FilesSourceEntry = SourceContent | (() => SourceContent | Promise<SourceCon
142
128
  * matched files in the server bundle. Call it yourself for files you hold another way.
143
129
  */
144
130
  export declare function files(entries: Record<string, FilesSourceEntry>, options?: FilesSourceOptions): FileSource<string>;
145
- //#endregion
146
- //#region src/sources/github/types.d.ts
147
131
  interface GitHubSourceOptions {
148
132
  repo: string;
149
133
  ref?: string;
@@ -262,15 +246,11 @@ type GitHubSource = FileSource<string> & Required<Pick<FileSource<string>, "getI
262
246
  signal?: AbortSignal;
263
247
  }): Promise<GitHubPullRequest[]>;
264
248
  };
265
- //#endregion
266
- //#region src/sources/github/lazy.d.ts
267
249
  /**
268
250
  * github() as the Source root exports it. The loader imports Node built-ins, ocache, and the forge client, so it loads
269
251
  * on the first read. A bundle that imports the root and never calls github() keeps none of them.
270
252
  */
271
253
  export declare function github(options: GitHubSourceOptions): GitHubSource;
272
- //#endregion
273
- //#region src/sources/glob.d.ts
274
254
  interface GlobSourceOptions {
275
255
  cwd?: string;
276
256
  dot?: boolean;
@@ -290,8 +270,5 @@ type GlobInput = string | GlobSourceOptions;
290
270
  * without a file system, such as Cloudflare Workers, serve the same files.
291
271
  */
292
272
  export declare function glob(input: GlobInput): FileSource<string>;
293
- //#endregion
294
- //#region src/sources/markdown.d.ts
295
273
  export declare function markdown<const TKey extends string = string>(options: FileSourceOptions<TKey>): SingleFileSource<TKey>;
296
- //#endregion
297
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-DZdhDQpU.js";
2
- import { r as isRecordOrFunction } from "./object-CtSHeGQO.js";
3
- import { a as parseCollectionSchema, i as createCollectionCursorCodec, n as defineCollection, r as CollectionCursorError } from "./collection-C1TZnrRP.js";
4
- import { i as sourceError, n as normalizeSafeSourcePath, o as sourcePathError, r as normalizeSourcePath } from "./path-Cm7wV1Dk.js";
5
- import { a as useSource } from "./registry-BSyFEr9r.js";
6
- import { t as normalizeGitHubRoot } from "./root-0Ef8tgF5.js";
7
- import { n as glob } from "./glob-DT9HlkyK.js";
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
- //#region src/core/array-collection.ts
9
+ // src/core/array-collection.ts
10
10
  const defaultMaxLimit = 100;
11
11
  const reservedQueryKeys = /* @__PURE__ */ new Set([
12
12
  "cursor",
@@ -17,6 +17,12 @@ const reservedQueryKeys = /* @__PURE__ */ new Set([
17
17
  function compareProtocolStrings(left, right) {
18
18
  return left < right ? -1 : left > right ? 1 : 0;
19
19
  }
20
+ function foldLatinText(value) {
21
+ return value.replace(/[A-Za-z\u00C0-\u017F\u0300-\u036F\u1E00-\u1EFF\u212A\u212B]+/g, (latin) => latin.normalize("NFD").replace(/[\u0300-\u036F]/g, "").toLowerCase());
22
+ }
23
+ function compareText(left, right) {
24
+ return compareProtocolStrings(foldLatinText(left), foldLatinText(right)) || compareProtocolStrings(left, right);
25
+ }
20
26
  const cursorCodec = createCollectionCursorCodec({ "~standard": {
21
27
  version: 1,
22
28
  vendor: "vite-hub",
@@ -33,7 +39,6 @@ const cursorCodec = createCollectionCursorCodec({ "~standard": {
33
39
  } };
34
40
  }
35
41
  } });
36
- /** Read a dot path through own properties. Arrays fan out to every element. */
37
42
  function collectionValueAt(value, path) {
38
43
  const segments = path.split(".").filter(Boolean);
39
44
  function visit(current, remaining) {
@@ -114,7 +119,7 @@ function sortItems(items, sort) {
114
119
  value: firstScalar(collectionValueAt(item, sort.field))
115
120
  })).sort(({ value: leftValue }, { value: rightValue }) => {
116
121
  if (Number(leftValue) === leftValue && Number(rightValue) === rightValue) return (leftValue - rightValue) * direction;
117
- return String(leftValue ?? "").localeCompare(String(rightValue ?? "")) * direction;
122
+ return compareText(String(leftValue ?? ""), String(rightValue ?? "")) * direction;
118
123
  }).map(({ item }) => item);
119
124
  }
120
125
  function buildFacets(items, fields, maxValues) {
@@ -124,7 +129,7 @@ function buildFacets(items, fields, maxValues) {
124
129
  return [field, [...counts].map(([value, count]) => ({
125
130
  count,
126
131
  value
127
- })).sort((left, right) => right.count - left.count || left.value.localeCompare(right.value)).slice(0, maxValues)];
132
+ })).sort((left, right) => right.count - left.count || compareText(left.value, right.value)).slice(0, maxValues)];
128
133
  }));
129
134
  }
130
135
  function array(load, options = {}) {
@@ -143,7 +148,8 @@ function array(load, options = {}) {
143
148
  search: [...searchFields].sort(),
144
149
  sort: options.sort ? {
145
150
  direction: options.sort.direction ?? "asc",
146
- field: options.sort.field
151
+ field: options.sort.field,
152
+ text: "latin-fold-v1"
147
153
  } : null
148
154
  });
149
155
  async function snapshot(signal, includeDigest) {
@@ -244,8 +250,7 @@ function array(load, options = {}) {
244
250
  }
245
251
  return source;
246
252
  }
247
- //#endregion
248
- //#region src/core/split-source.ts
253
+ // src/core/split-source.ts
249
254
  /** Split each item of a Source into parts, such as the sections of a Markdown file. Each part is an item. */
250
255
  function splitSource(options) {
251
256
  const parent = options.source;
@@ -324,14 +329,12 @@ function splitSource(options) {
324
329
  getItems
325
330
  };
326
331
  }
327
- //#endregion
328
- //#region src/core/define.ts
332
+ // src/core/define.ts
329
333
  /** Define a loader. Open it with useSource() to bind its runtime context. */
330
334
  function defineSource(source) {
331
335
  return source;
332
336
  }
333
- //#endregion
334
- //#region src/ignores.ts
337
+ // src/ignores.ts
335
338
  const dependencies = Object.freeze([
336
339
  "**/node_modules/**",
337
340
  "**/.pnpm-store/**",
@@ -367,8 +370,7 @@ const sourceIgnores = Object.freeze({
367
370
  secrets,
368
371
  system
369
372
  });
370
- //#endregion
371
- //#region src/sources/file.ts
373
+ // src/sources/file.ts
372
374
  function normalizeFileSourceOptions(input) {
373
375
  return typeof input === "string" ? { path: input } : input;
374
376
  }
@@ -424,8 +426,7 @@ function file(input) {
424
426
  }
425
427
  };
426
428
  }
427
- //#endregion
428
- //#region src/sources/files.ts
429
+ // src/sources/files.ts
429
430
  /**
430
431
  * A Source of files that the server already holds, keyed by path. A ViteHub build turns `glob()` into this, with the
431
432
  * matched files in the server bundle. Call it yourself for files you hold another way.
@@ -460,8 +461,7 @@ function files(entries, options = {}) {
460
461
  }
461
462
  };
462
463
  }
463
- //#endregion
464
- //#region src/sources/github/lazy.ts
464
+ // src/sources/github/lazy.ts
465
465
  /**
466
466
  * github() as the Source root exports it. The loader imports Node built-ins, ocache, and the forge client, so it loads
467
467
  * on the first read. A bundle that imports the root and never calls github() keeps none of them.
@@ -469,7 +469,7 @@ function files(entries, options = {}) {
469
469
  function github(options) {
470
470
  const root = normalizeGitHubRoot(options.root || "");
471
471
  let loader;
472
- const load = () => loader ??= import("./github-509beZOn.js").then((module) => module.github(options)).catch((error) => {
472
+ const load = () => loader ??= import("./github-DfF_3WEy.js").then((module) => module.github(options)).catch((error) => {
473
473
  loader = void 0;
474
474
  throw error;
475
475
  });
@@ -498,13 +498,11 @@ function github(options) {
498
498
  getItem: async (key, ctx) => await (await load()).getItem(key, ctx)
499
499
  };
500
500
  }
501
- //#endregion
502
- //#region src/sources/markdown.ts
501
+ // src/sources/markdown.ts
503
502
  function markdown(options) {
504
503
  return file({
505
504
  ...options,
506
505
  mediaType: Object.hasOwn(options, "mediaType") && options.mediaType ? options.mediaType : "text/markdown"
507
506
  });
508
507
  }
509
- //#endregion
510
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-CUv12y8b.js";
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
- import { i as registerSources, n as registerSource, r as registerSourceLoaders, t as clearSources } from "../registry-BSyFEr9r.js";
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
- //#region ../internal/src/invariant.ts
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-Ln-FxVFn.js";
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 { n as matchesAny, t as createPathMatcher } from "./path-Q-KcGmAN.js";
2
- import { t as sourceErrorDiagnostics } from "./error-diagnostics-DZdhDQpU.js";
3
- import { i as sourceError, n as normalizeSafeSourcePath } from "./path-Cm7wV1Dk.js";
4
- //#region ../internal/src/abort.ts
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
- //#endregion
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
- //#region ../internal/src/object.ts
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-Cm7wV1Dk.js";
2
- //#region \0rolldown/runtime.js
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#region src/core/errors.ts
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
- //#endregion
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-Cm7wV1Dk.js";
2
- //#region src/core/reader.ts
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
- //#endregion
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-Ln-FxVFn.js";
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-Cm7wV1Dk.js";
2
- //#region src/sources/github/root.ts
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-B8sgxw5-.js";
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 sourceErrorDiagnostics } from "./error-diagnostics-DZdhDQpU.js";
2
- import { r as CollectionCursorError, t as assertCollectionAccess } from "./collection-C1TZnrRP.js";
3
- //#region src/cached-source.ts
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,9 +37,7 @@ function cachedSource(reader, options) {
37
37
  }
38
38
  });
39
39
  }
40
- //#endregion
41
- //#region src/server.ts
42
- /** The query of a request URL. A parameter that the URL repeats becomes an array, as in H3's `getQuery()`. */
40
+ // src/server.ts
43
41
  function requestQuery(request) {
44
42
  const query = /* @__PURE__ */ new Map();
45
43
  for (const [key, value] of new URL(request.url).searchParams) {
@@ -64,7 +62,6 @@ function queryLimit(query) {
64
62
  function collectionQuery(query) {
65
63
  return Object.fromEntries(Object.entries(query).filter(([key]) => key !== "cursor" && key !== "limit"));
66
64
  }
67
- /** An error Response with the `status` and `message` fields of an H3 error body. */
68
65
  function errorResponse(status, message) {
69
66
  return Response.json({
70
67
  status,
@@ -88,7 +85,7 @@ function serializeCollectionPage(value) {
88
85
  return JSON.parse(serialized);
89
86
  }
90
87
  function isCallable(value) {
91
- return typeof value === "function" || typeof value === "undefined" && value !== void 0;
88
+ return typeof value === "function";
92
89
  }
93
90
  function hasDeclaredMethod(value, key) {
94
91
  const object = Object(value);
@@ -138,5 +135,4 @@ function defineCollectionHandler(collection, options = {}) {
138
135
  };
139
136
  return { fetch: authorize && withAuthorization ? withAuthorization(authorize, handlePage) : handlePage };
140
137
  }
141
- //#endregion
142
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;
@@ -49,6 +48,8 @@ interface ViteHubResourceSummary {
49
48
  owner: string;
50
49
  /** Absent when no id is known yet. */
51
50
  source?: ViteHubResourceIdSource;
51
+ /** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
52
+ standalone?: boolean;
52
53
  }
53
54
  interface ViteHubInspectionContributor {
54
55
  definitions?: readonly ViteHubDefinitionInspector[];
@@ -59,8 +60,6 @@ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor |
59
60
  interface ViteHubInspectionPluginMetadata {
60
61
  inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
61
62
  }
62
- //#endregion
63
- //#region ../internal/src/contributions.d.ts
64
63
  /** Roots that ViteHub passes to every contribution factory. */
65
64
  interface ContributionContext {
66
65
  /** Vite root. */
@@ -69,9 +68,9 @@ interface ContributionContext {
69
68
  projectRoot: string;
70
69
  /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
71
70
  serverDirs?: readonly string[];
71
+ /** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
72
+ plugins?: readonly unknown[];
72
73
  }
73
- //#endregion
74
- //#region src/inspect.d.ts
75
74
  interface CollectionInspectionOptions {
76
75
  projectRoot: string;
77
76
  /** Server directories, relative to `projectRoot` or absolute. Defaults to `server`. */
@@ -82,8 +81,6 @@ interface CollectionInspectionOptions {
82
81
  * does not import it, so values that are computed at runtime show as `Dynamic`.
83
82
  */
84
83
  export declare function inspectCollectionDefinitions(options: CollectionInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
85
- //#endregion
86
- //#region src/vite.d.ts
87
84
  /** A file ViteHub generates for Nitro: a route handler, or a Nitro plugin such as the Content preview scope. */
88
85
  export type GeneratedSourceHandler = GeneratedSourceRoute | GeneratedSourcePlugin;
89
86
  export interface GeneratedSourceRoute {
@@ -96,6 +93,8 @@ export interface GeneratedSourceRoute {
96
93
  * because a lazy handler does not receive `next`. Such a handler must load heavy modules itself, on demand.
97
94
  */
98
95
  lazy?: false;
96
+ /** The Nitro route meta, such as `ownAccessRouteMeta` for a route that checks its own access. */
97
+ meta?: object;
99
98
  plugin?: never;
100
99
  route: string;
101
100
  }
@@ -255,5 +254,4 @@ export declare function hubSource(options?: SourceVitePluginOptions): Plugin & {
255
254
  }>>;
256
255
  };
257
256
  };
258
- //#endregion
259
257
  export type { CollectionInspectionOptions };