@vite-hub/source 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +135 -1
- package/dist/auth-Ddw55OUG.js +1261 -0
- package/dist/client-CDfTmtQu.js +7903 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.js +121 -0
- package/dist/collection-B8pXGM2d.js +141 -0
- package/dist/collection-CF2ON__k.d.ts +92 -0
- package/dist/collection-route-Dw7QLFyx.js +6 -0
- package/dist/content/client.d.ts +3 -0
- package/dist/content/client.js +2 -0
- package/dist/content.d.ts +44 -0
- package/dist/content.js +157 -0
- package/dist/file-BSWQg9Qv.js +503 -0
- package/dist/file-EQ3AjVM6.d.ts +20 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +2 -0
- package/dist/github.d.ts +17 -0
- package/dist/github.js +1033 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +895 -0
- package/dist/index.d.ts +64 -162
- package/dist/index.js +66 -1188
- package/dist/markdown.d.ts +7 -0
- package/dist/markdown.js +10 -0
- package/dist/mcp.d.ts +152 -0
- package/dist/mcp.js +6115 -0
- package/dist/path-BzmU4Eni.js +36 -0
- package/dist/path-CUhvUREm.js +1936 -0
- package/dist/registry-C8skfCSV.js +120 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +71 -0
- package/dist/sse-CE9Q2JqM.js +407 -0
- package/dist/streamableHttp-BszaXLmg.js +491 -0
- package/dist/types-AIBmt_m6.js +6275 -0
- package/dist/types-Bu3WvNX9.d.ts +71 -0
- package/dist/vite.d.ts +41 -0
- package/dist/vite.js +629 -0
- package/package.json +75 -9
- package/tsconfig.vite.json +6 -0
- package/types/source/fallback.d.ts +1 -0
- package/types/source/index.d.ts +1 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
type SourceContent = string | Uint8Array;
|
|
3
|
+
interface ReadSourceOptions {
|
|
4
|
+
encoding?: "utf8" | "binary";
|
|
5
|
+
}
|
|
6
|
+
type ReadSourceResult<TOptions extends ReadSourceOptions | undefined = undefined> = TOptions extends {
|
|
7
|
+
encoding: "binary";
|
|
8
|
+
} ? Uint8Array : string;
|
|
9
|
+
interface SourceContext {
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
revision?: SourceRevision;
|
|
12
|
+
rootDir: string;
|
|
13
|
+
sourceRootDir?: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
workspace?: string;
|
|
16
|
+
}
|
|
17
|
+
interface SourceCacheOptions {
|
|
18
|
+
maxAge?: number;
|
|
19
|
+
}
|
|
20
|
+
interface SourceRevision {
|
|
21
|
+
id: string;
|
|
22
|
+
immutable: boolean;
|
|
23
|
+
ref?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SourceItem<TKey extends string = string, TData = unknown, TMetadata extends object = Record<string, unknown>> {
|
|
26
|
+
key: TKey;
|
|
27
|
+
path?: string;
|
|
28
|
+
content?: SourceContent;
|
|
29
|
+
data?: TData;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
metadata?: TMetadata;
|
|
32
|
+
}
|
|
33
|
+
interface Source<TKey extends string = string, TData = unknown, TMetadata extends object = Record<string, unknown>> {
|
|
34
|
+
name: string;
|
|
35
|
+
cache?: false | SourceCacheOptions;
|
|
36
|
+
fingerprint?: unknown;
|
|
37
|
+
resolveRevision?(ctx: SourceContext): Promise<SourceRevision | undefined>;
|
|
38
|
+
prepare?(ctx: SourceContext): Promise<void>;
|
|
39
|
+
getKeys(ctx: SourceContext): Promise<TKey[]>;
|
|
40
|
+
getItem(key: TKey, ctx: SourceContext): Promise<SourceItem<TKey, TData, TMetadata>>;
|
|
41
|
+
getItems?(ctx: SourceContext): Promise<SourceItem<TKey, TData, TMetadata>[]>;
|
|
42
|
+
getMeta?(key: TKey, ctx: SourceContext): Promise<TMetadata | undefined>;
|
|
43
|
+
}
|
|
44
|
+
interface SourceListEntry<TKey extends string = string> {
|
|
45
|
+
key: TKey;
|
|
46
|
+
type: "file" | "directory";
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface ViteHubSourceMap {}
|
|
50
|
+
}
|
|
51
|
+
interface SourceMap extends ViteHubSourceMap {}
|
|
52
|
+
type SourceKeyOf<TSource> = TSource extends Source<infer TKey, any, any> ? TKey : string;
|
|
53
|
+
type SourceDataOf<TSource> = TSource extends Source<any, infer TData, any> ? TData : unknown;
|
|
54
|
+
type SourceMetadataOf<TSource> = TSource extends Source<any, any, infer TMetadata> ? TMetadata : Record<string, unknown>;
|
|
55
|
+
type RegisteredSource<TName extends SourceName> = TName extends keyof ViteHubSourceMap ? ViteHubSourceMap[TName] : Source;
|
|
56
|
+
type SourceName = [keyof ViteHubSourceMap] extends [never] ? string : Extract<keyof ViteHubSourceMap, string>;
|
|
57
|
+
type SourceKey<TName extends SourceName = SourceName> = Extract<SourceKeyOf<RegisteredSource<TName>>, string>;
|
|
58
|
+
type SourceData<TName extends SourceName = SourceName> = SourceDataOf<RegisteredSource<TName>>;
|
|
59
|
+
type SourceMetadata<TName extends SourceName = SourceName> = SourceMetadataOf<RegisteredSource<TName>>;
|
|
60
|
+
interface SourceReader<TName extends SourceName = SourceName> {
|
|
61
|
+
revision(): Promise<SourceRevision | undefined>;
|
|
62
|
+
keys(): Promise<SourceKey<TName>[]>;
|
|
63
|
+
get(key: SourceKey<TName>): Promise<SourceItem<SourceKey<TName>, SourceData<TName>, SourceMetadata<TName>>>;
|
|
64
|
+
items(): Promise<Array<SourceItem<SourceKey<TName>, SourceData<TName>, SourceMetadata<TName>>>>;
|
|
65
|
+
read<TOptions extends ReadSourceOptions | undefined = undefined>(key: SourceKey<TName>, options?: TOptions): Promise<ReadSourceResult<TOptions>>;
|
|
66
|
+
meta(key: SourceKey<TName>): Promise<SourceMetadata<TName> | undefined>;
|
|
67
|
+
exists(key: SourceKey<TName>): Promise<boolean>;
|
|
68
|
+
list(prefix?: SourceKey<TName> | (string & {}) | ""): Promise<SourceListEntry<SourceKey<TName>>[]>;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { SourceContent as a, SourceItem as c, SourceMap as d, SourceMetadata as f, SourceRevision as h, SourceCacheOptions as i, SourceKey as l, SourceReader as m, ReadSourceResult as n, SourceContext as o, SourceName as p, Source as r, SourceData as s, ReadSourceOptions as t, SourceListEntry as u };
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/vite.d.ts
|
|
4
|
+
interface GeneratedSourceHandler {
|
|
5
|
+
handler: string;
|
|
6
|
+
method?: "get";
|
|
7
|
+
route: string;
|
|
8
|
+
}
|
|
9
|
+
interface SourceGenerationOptions {
|
|
10
|
+
importBase?: string;
|
|
11
|
+
projectRoot: string;
|
|
12
|
+
serverDirs?: string[];
|
|
13
|
+
}
|
|
14
|
+
interface SourceVitePluginOptions {
|
|
15
|
+
importBase?: string;
|
|
16
|
+
}
|
|
17
|
+
type GeneratedSourceHandlersListener = (handlers: GeneratedSourceHandler[]) => Promise<void> | void;
|
|
18
|
+
interface GeneratedSourceHandlersListenerOptions {
|
|
19
|
+
handlesHostRestart?: boolean;
|
|
20
|
+
projectRoot?: string;
|
|
21
|
+
}
|
|
22
|
+
interface NitroGeneratedConfig {
|
|
23
|
+
handlers?: Array<{
|
|
24
|
+
handler: string;
|
|
25
|
+
method?: string;
|
|
26
|
+
route?: string;
|
|
27
|
+
}>;
|
|
28
|
+
modules?: unknown[];
|
|
29
|
+
}
|
|
30
|
+
declare function mergeGeneratedSourceNitroConfig(value: unknown, generatedHandlers: GeneratedSourceHandler[]): NitroGeneratedConfig;
|
|
31
|
+
declare function toRuntimeModuleSpecifier(file: string): string;
|
|
32
|
+
declare function toTypeModuleSpecifier(file: string): string;
|
|
33
|
+
declare function prepareSourceGeneration(options: SourceGenerationOptions): Promise<GeneratedSourceHandler[]>;
|
|
34
|
+
declare function hubSource(options?: SourceVitePluginOptions): Plugin & {
|
|
35
|
+
api: {
|
|
36
|
+
onGeneratedHandlersChanged: (listener: GeneratedSourceHandlersListener, options?: GeneratedSourceHandlersListenerOptions) => () => void;
|
|
37
|
+
prepareSources: (options: Omit<SourceGenerationOptions, "importBase">) => Promise<GeneratedSourceHandler[]>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { GeneratedSourceHandler, GeneratedSourceHandlersListener, GeneratedSourceHandlersListenerOptions, SourceGenerationOptions, SourceVitePluginOptions, hubSource, mergeGeneratedSourceNitroConfig, prepareSourceGeneration, toRuntimeModuleSpecifier, toTypeModuleSpecifier };
|