@vite-hub/source 0.0.3 → 0.1.0
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 +302 -31
- package/dist/auth-B-tX_rp0.js +1426 -0
- package/dist/client-BwstxtdY.js +8280 -0
- package/dist/client.d.ts +49 -0
- package/dist/client.js +179 -0
- package/dist/collection-B_4w_J8h.d.ts +257 -0
- package/dist/collection-cursor-WzV1Jd6v.js +124 -0
- package/dist/collection-route-BplWPxHR.js +10 -0
- package/dist/drizzle.d.ts +41 -0
- package/dist/drizzle.js +89 -0
- package/dist/error-diagnostics-X0kuFjBT.js +51 -0
- package/dist/file-BX0FSvgE.js +60 -0
- package/dist/file-DadN9dbN.d.ts +19 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +2 -0
- package/dist/files.d.ts +15 -0
- package/dist/files.js +38 -0
- package/dist/github.d.ts +20 -0
- package/dist/github.js +1332 -0
- package/dist/glob-BmFqTvJY.js +993 -0
- package/dist/glob.d.ts +23 -0
- package/dist/glob.js +2 -0
- package/dist/index.d.ts +165 -172
- package/dist/index.js +600 -1113
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +10 -0
- package/dist/mcp.d.ts +151 -0
- package/dist/mcp.js +497 -0
- package/dist/mrmime-40h5OOIp.js +448 -0
- package/dist/path-BS8rYm0n.js +1956 -0
- package/dist/path-DOBpV8ol.js +32 -0
- package/dist/server.d.ts +265 -0
- package/dist/server.js +149 -0
- package/dist/sse-D9gqqNPj.js +448 -0
- package/dist/streamableHttp-BL-E7pl5.js +509 -0
- package/dist/types-BigOktIj.d.ts +93 -0
- package/dist/types-CoWcW8oz.js +7590 -0
- package/dist/vite.d.ts +162 -0
- package/dist/vite.js +2284 -0
- package/package.json +102 -17
- package/tsconfig.vite.json +6 -0
- package/types/source/fallback.d.ts +1 -0
- package/types/source/index.d.ts +1 -0
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
//#region ../internal/src/inspect.d.ts
|
|
3
|
+
interface ViteHubDefinitionField {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
/** Serializable summary of one discovered Definition. Files are relative to the project root. */
|
|
8
|
+
interface ViteHubDefinitionSummary {
|
|
9
|
+
fields: readonly ViteHubDefinitionField[];
|
|
10
|
+
file: string;
|
|
11
|
+
name: string;
|
|
12
|
+
source: string;
|
|
13
|
+
}
|
|
14
|
+
/** Lists the Definitions that one owner package discovered for the resolved Vite config. */
|
|
15
|
+
interface ViteHubDefinitionInspector {
|
|
16
|
+
/** Stable singular kind, for example `queue` or `rate-limit`. */
|
|
17
|
+
kind: string;
|
|
18
|
+
label: string;
|
|
19
|
+
list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
|
|
20
|
+
}
|
|
21
|
+
/** One generated Provider Output file or directory that an owner package can write. */
|
|
22
|
+
interface ViteHubProviderOutputEntry {
|
|
23
|
+
description: string;
|
|
24
|
+
owner: string;
|
|
25
|
+
/** Absolute path. */
|
|
26
|
+
path: string;
|
|
27
|
+
}
|
|
28
|
+
interface ViteHubInspectionContributor {
|
|
29
|
+
definitions?: readonly ViteHubDefinitionInspector[];
|
|
30
|
+
providerOutput?: readonly ViteHubProviderOutputEntry[];
|
|
31
|
+
}
|
|
32
|
+
type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
|
|
33
|
+
interface ViteHubInspectionPluginMetadata {
|
|
34
|
+
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/inspect.d.ts
|
|
38
|
+
interface CollectionInspectionOptions {
|
|
39
|
+
projectRoot: string;
|
|
40
|
+
/** Server directories, relative to `projectRoot` or absolute. Defaults to `server`. */
|
|
41
|
+
serverDirs?: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Lists Collections in `server/collections` with their source kind and static options. It reads the module text and
|
|
45
|
+
* does not import it, so values that are computed at runtime show as `Dynamic`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function inspectCollectionDefinitions(options: CollectionInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/vite.d.ts
|
|
50
|
+
/** A file ViteHub generates for Nitro: a route handler, or a Nitro plugin such as the Content preview scope. */
|
|
51
|
+
export type GeneratedSourceHandler = GeneratedSourceRoute | GeneratedSourcePlugin;
|
|
52
|
+
export interface GeneratedSourceRoute {
|
|
53
|
+
handler: string;
|
|
54
|
+
method?: "get";
|
|
55
|
+
plugin?: never;
|
|
56
|
+
route: string;
|
|
57
|
+
}
|
|
58
|
+
/** A generated Nitro plugin. It registers no route, so it never conflicts with one. */
|
|
59
|
+
export interface GeneratedSourcePlugin {
|
|
60
|
+
handler: string;
|
|
61
|
+
method?: never;
|
|
62
|
+
plugin: true;
|
|
63
|
+
route?: never;
|
|
64
|
+
}
|
|
65
|
+
export interface SourceGenerationOptions {
|
|
66
|
+
/** Pass Auth's `withAuthorization` to generated Collection routes. Requires the Auth Vite plugin. */
|
|
67
|
+
auth?: boolean;
|
|
68
|
+
contentImportBase?: string;
|
|
69
|
+
importBase?: string;
|
|
70
|
+
projectRoot: string;
|
|
71
|
+
serverDirs?: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface SourceVitePluginOptions {
|
|
74
|
+
/** Pass Auth's `withAuthorization` to generated Collection routes when the Auth Vite plugin has a Definition. */
|
|
75
|
+
auth?: boolean | ((input: {
|
|
76
|
+
configuredAuth?: boolean;
|
|
77
|
+
projectRoot: string;
|
|
78
|
+
serverDirs?: string[];
|
|
79
|
+
}) => boolean);
|
|
80
|
+
contentImportBase?: string;
|
|
81
|
+
importBase?: string;
|
|
82
|
+
}
|
|
83
|
+
/** The discovered `server/content.ts` file. It exports the Content runtime as `content`. */
|
|
84
|
+
export interface ContentDefinitionFile {
|
|
85
|
+
handler: string;
|
|
86
|
+
}
|
|
87
|
+
export type GeneratedSourceHandlersListener = (handlers: GeneratedSourceHandler[]) => Promise<void> | void;
|
|
88
|
+
export interface GeneratedSourceHandlersListenerOptions {
|
|
89
|
+
handlesHostRestart?: boolean;
|
|
90
|
+
projectRoot?: string;
|
|
91
|
+
}
|
|
92
|
+
interface NitroGeneratedConfig {
|
|
93
|
+
handlers?: Array<{
|
|
94
|
+
handler: string;
|
|
95
|
+
method?: string;
|
|
96
|
+
middleware?: boolean;
|
|
97
|
+
route?: string;
|
|
98
|
+
}>;
|
|
99
|
+
modules?: unknown[];
|
|
100
|
+
plugins?: unknown[];
|
|
101
|
+
}
|
|
102
|
+
interface SourceNitroHost extends NitroRouteGuard {
|
|
103
|
+
options: NitroGeneratedConfig;
|
|
104
|
+
routing: {
|
|
105
|
+
sync(): void;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
interface NitroRouteGuard {
|
|
109
|
+
hooks: {
|
|
110
|
+
hook(name: "build:before", callback: () => void): void;
|
|
111
|
+
};
|
|
112
|
+
scannedHandlers: Array<{
|
|
113
|
+
method?: string;
|
|
114
|
+
middleware?: boolean;
|
|
115
|
+
route?: string;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
export declare function mergeGeneratedSourceNitroConfig(value: unknown, generatedHandlers: GeneratedSourceHandler[]): NitroGeneratedConfig;
|
|
119
|
+
export declare function toRuntimeModuleSpecifier(file: string): string;
|
|
120
|
+
export declare function toTypeModuleSpecifier(file: string): string;
|
|
121
|
+
/**
|
|
122
|
+
* Find the `server/content.{ts,js}` file that exports the application Content runtime as `content`. Returns undefined when
|
|
123
|
+
* the project has none. The generated `/api/content/**` route and the Console content editor import the same file.
|
|
124
|
+
*/
|
|
125
|
+
export declare function findContentEntry(options: Pick<SourceGenerationOptions, "projectRoot" | "serverDirs">): Promise<string | undefined>;
|
|
126
|
+
/** What a Content module's `defineContent()` call may define, as far as reading the file without running it can tell. */
|
|
127
|
+
export interface ContentEntryFeatures {
|
|
128
|
+
/** Public HTTP route. True unless `route` is literally false. */
|
|
129
|
+
route: boolean;
|
|
130
|
+
/** Editable `collections`. True when discovery cannot follow the options. */
|
|
131
|
+
collections: boolean;
|
|
132
|
+
/** `seo: { sitemap }` that is not literally false. */
|
|
133
|
+
sitemap: boolean;
|
|
134
|
+
/** `seo: { robots }` that is not literally false. */
|
|
135
|
+
robots: boolean;
|
|
136
|
+
/** `live` that is not literally false: Content edits Markdown documents live where Realtime has a room authority. */
|
|
137
|
+
live: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Read the `defineContent()` call that initializes the `content` export. Collections count as present unless the call
|
|
141
|
+
* provably has no non-empty `collections` object. SEO routes count only when the call has a `seo` option: a literal
|
|
142
|
+
* `sitemap` or `robots` that is not `false`, or a `seo` value that discovery cannot follow.
|
|
143
|
+
*/
|
|
144
|
+
export declare function inspectContentModule(program: unknown, contentImportBase?: string): ContentEntryFeatures;
|
|
145
|
+
/** Read what the Content module defines without running it. A file that does not parse counts as defining everything. */
|
|
146
|
+
export declare function inspectContentEntry(file: string, contentImportBase?: string): Promise<ContentEntryFeatures>;
|
|
147
|
+
export declare function prepareSourceGeneration(options: SourceGenerationOptions): Promise<GeneratedSourceHandler[]>;
|
|
148
|
+
export declare function hubSource(options?: SourceVitePluginOptions): Plugin & {
|
|
149
|
+
api: {
|
|
150
|
+
/** The `server/content.ts` file found by the last preparation of `projectRoot` (default: the latest root). */
|
|
151
|
+
getContentDefinition: (projectRoot?: string) => ContentDefinitionFile | undefined;
|
|
152
|
+
onGeneratedHandlersChanged: (listener: GeneratedSourceHandlersListener, options?: GeneratedSourceHandlersListenerOptions) => () => void;
|
|
153
|
+
prepareSources: (options: Omit<SourceGenerationOptions, "auth" | "contentImportBase" | "importBase">) => Promise<GeneratedSourceHandler[]>;
|
|
154
|
+
};
|
|
155
|
+
nitro: {
|
|
156
|
+
name: string;
|
|
157
|
+
setup(nitro: SourceNitroHost): void;
|
|
158
|
+
};
|
|
159
|
+
vitehub: ViteHubInspectionPluginMetadata;
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
162
|
+
export type { CollectionInspectionOptions };
|