@vite-hub/workspace 0.0.0 → 0.0.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/README.md +89 -1
- package/dist/ai-Bk3LLnit.js +352 -0
- package/dist/ai.d.ts +86 -0
- package/dist/ai.js +2 -0
- package/dist/asset-registry-CMuQbyvl.js +14 -0
- package/dist/chunk-DrSxFLj_.js +14 -0
- package/dist/cloudflare-env-DL94Uvpz.js +12 -0
- package/dist/config-CvS-7sre.js +49 -0
- package/dist/errors-BUL8SoFS.js +21 -0
- package/dist/files-DbsIjBya.js +50 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +656 -0
- package/dist/lifecycle-uD82JeGh.js +92 -0
- package/dist/loader.d.ts +17 -0
- package/dist/loader.js +22 -0
- package/dist/module-8LZUMEXC.js +922 -0
- package/dist/nitro.d.ts +31 -0
- package/dist/nitro.js +2 -0
- package/dist/path-BVv9OXhg.js +63 -0
- package/dist/provider-BZuKAV4e.js +494 -0
- package/dist/providers/cloudflare/artifacts-store.d.ts +6 -0
- package/dist/providers/cloudflare/artifacts-store.js +384 -0
- package/dist/providers/vercel/blob-store.d.ts +6 -0
- package/dist/providers/vercel/blob-store.js +176 -0
- package/dist/publish.d.ts +34 -0
- package/dist/publish.js +206 -0
- package/dist/registry-Cnr0NoKv.js +932 -0
- package/dist/registry-D4Qzq26I.d.ts +10 -0
- package/dist/runtime/assets.d.ts +11 -0
- package/dist/runtime/assets.js +138 -0
- package/dist/runtime/empty-assets-registry.d.ts +6 -0
- package/dist/runtime/empty-assets-registry.js +4 -0
- package/dist/runtime/empty-registry.d.ts +6 -0
- package/dist/runtime/empty-registry.js +4 -0
- package/dist/runtime/nitro-plugin.d.ts +6 -0
- package/dist/runtime/nitro-plugin.js +14 -0
- package/dist/runtime/state.d.ts +21 -0
- package/dist/runtime/state.js +12 -0
- package/dist/sandbox-DtGXCWRq.js +198 -0
- package/dist/search-DtaEyjpO.js +39 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.js +2 -0
- package/dist/types-CwNcWTdt.d.ts +378 -0
- package/dist/utils-BtAm_K5P.js +51 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +131 -0
- package/package.json +101 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { o as normalizeWorkspacePath, r as matchesAny } from "./path-BVv9OXhg.js";
|
|
2
|
+
//#region src/loaders/files.ts
|
|
3
|
+
function shouldLoad(path, options) {
|
|
4
|
+
if (options.include && !matchesAny(path, options.include)) return false;
|
|
5
|
+
if (options.exclude && matchesAny(path, options.exclude)) return false;
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
function files(options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
name: "files",
|
|
11
|
+
async load(ctx) {
|
|
12
|
+
const sourceContext = {
|
|
13
|
+
rootDir: ctx.rootDir,
|
|
14
|
+
sourceRootDir: ctx.sourceRootDir,
|
|
15
|
+
workspace: ctx.workspace
|
|
16
|
+
};
|
|
17
|
+
for (const source of ctx.sources) {
|
|
18
|
+
await source.prepare?.(sourceContext);
|
|
19
|
+
for (const key of await source.getKeys(sourceContext)) {
|
|
20
|
+
const rawItem = await source.getItem(key, sourceContext);
|
|
21
|
+
const rawPath = normalizeWorkspacePath(rawItem.path || rawItem.key);
|
|
22
|
+
if (!shouldLoad(rawPath, options)) continue;
|
|
23
|
+
const transformed = options.transform ? await options.transform(rawItem) : rawItem;
|
|
24
|
+
const item = typeof transformed === "string" || transformed instanceof Uint8Array ? {
|
|
25
|
+
...rawItem,
|
|
26
|
+
content: transformed
|
|
27
|
+
} : transformed;
|
|
28
|
+
const path = normalizeWorkspacePath(item.path || rawPath);
|
|
29
|
+
const content = item.content ?? (typeof item.data === "undefined" ? "" : JSON.stringify(item.data, null, 2));
|
|
30
|
+
const digest = ctx.generateDigest({
|
|
31
|
+
content,
|
|
32
|
+
metadata: item.metadata,
|
|
33
|
+
mediaType: item.mediaType
|
|
34
|
+
});
|
|
35
|
+
const metaKey = `loader:files:${source.key}:${path}:digest`;
|
|
36
|
+
if (await ctx.store.getMeta?.(metaKey) === digest && await ctx.store.stat(path)) continue;
|
|
37
|
+
await ctx.store.writeFile(path, {
|
|
38
|
+
path,
|
|
39
|
+
content,
|
|
40
|
+
mediaType: item.mediaType,
|
|
41
|
+
metadata: item.metadata
|
|
42
|
+
});
|
|
43
|
+
await ctx.store.setMeta?.(metaKey, digest);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { files as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { $ as WorkspaceSession, A as WorkspaceDiff, B as WorkspaceMaterializeSourcesResult, C as WorkspaceAssets, D as WorkspaceContent, E as WorkspaceCacheOptions, F as WorkspaceHooks, G as WorkspaceName, H as WorkspaceMount, I as WorkspaceLoader, J as WorkspacePublisher, K as WorkspaceNameMap, L as WorkspaceLoaderSource, M as WorkspaceEntry, N as WorkspaceFile, O as WorkspaceDefinition, P as WorkspaceHookContext, Q as WorkspaceSearchQuery, R as WorkspaceMaterializeMode, S as WorkspaceAssetPath, T as WorkspaceAutoCommitPlan, U as WorkspaceMountMode, V as WorkspaceModuleOptions, W as WorkspaceMountOptions, X as WorkspaceRules, Y as WorkspaceRule, Z as WorkspaceSearchHit, _ as RmOptions, _t as WorkspaceWriteValidator, a as GlobOptions, at as WorkspaceSourceMount, b as VercelBlobWorkspaceStoreOptions, c as LocalWorkspaceStoreOptions, ct as WorkspaceStore, d as MkdirOptions, dt as WorkspaceValidateMode, et as WorkspaceSessionOptions, f as PublishContext, ft as WorkspaceWriteErrorHook, g as ResolvedWorkspaceRule, gt as WorkspaceWriteOperation, h as ResolvedWorkspaceModuleOptions, ht as WorkspaceWriteMode, i as ExecResult, it as WorkspaceSourceMaterializationStatus, j as WorkspaceDiffEntry, k as WorkspaceDefinitionInput, l as Logger, lt as WorkspaceStoreOptions, m as ReadFileResult, mt as WorkspaceWriteInput, n as DiffOptions, nt as WorkspaceSource, o as ListOptions, ot as WorkspaceSourceMountOptions, p as ReadFileOptions, pt as WorkspaceWriteHook, q as WorkspacePlugin, r as ExecOptions, rt as WorkspaceSourceItem, s as LoaderContext, st as WorkspaceStat, t as CloudflareArtifactsWorkspaceStoreOptions, tt as WorkspaceSnapshot, u as MemoryWorkspaceStoreOptions, ut as WorkspaceSyncOptions, v as SnapshotOptions, vt as WorkspaceWriteValidatorResult, w as WorkspaceAssetsRegistry, x as Workspace, y as SourceContext, yt as WriteFileOptions, z as WorkspaceMaterializeSourcesOptions } from "./types-CwNcWTdt.js";
|
|
2
|
+
import { EnabledReadCapability, ShellEnabled, WorkspaceMoveResult, WorkspacePathResult, WorkspaceReadOperations, WorkspaceShellResult, WorkspaceToolOperations, WorkspaceToolOptions, WorkspaceTools, WorkspaceWriteOperations, WorkspaceWriteToolMap, createWorkspaceTools } from "./ai.js";
|
|
3
|
+
import { FileSourceOptions, GitHubSourceOptions, GlobSourceOptions } from "@vite-hub/source";
|
|
4
|
+
import { Tool, ToolSet } from "ai";
|
|
5
|
+
|
|
6
|
+
//#region src/core/define.d.ts
|
|
7
|
+
declare function defineWorkspace(definition: WorkspaceDefinitionInput): WorkspaceDefinitionInput;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/sources/custom.d.ts
|
|
10
|
+
declare function custom(source: WorkspaceSource): WorkspaceSource;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/sources/file.d.ts
|
|
13
|
+
type SourceRuntimeOptions$3 = Pick<WorkspaceSource, "cache" | "materialize" | "mount" | "validate">;
|
|
14
|
+
type FileSourceOptions$1<TKey extends string = string> = FileSourceOptions<TKey> & SourceRuntimeOptions$3;
|
|
15
|
+
type FileSourceInput<TKey extends string = string> = FileSourceOptions$1<TKey> | TKey;
|
|
16
|
+
declare function file$1<const TKey extends string = string>(input: FileSourceInput<TKey>): WorkspaceSource;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/sources/fetch.d.ts
|
|
19
|
+
type FetchSourceMethod = "GET" | "HEAD" | "POST";
|
|
20
|
+
type FetchSourceResponseType = "json" | "text";
|
|
21
|
+
interface FetchSourceStandardSchemaResultSuccess<T = unknown> {
|
|
22
|
+
issues?: undefined;
|
|
23
|
+
value: T;
|
|
24
|
+
}
|
|
25
|
+
interface FetchSourceStandardSchemaResultFailure {
|
|
26
|
+
issues: readonly unknown[];
|
|
27
|
+
}
|
|
28
|
+
interface FetchSourceStandardSchemaV1<T = unknown> {
|
|
29
|
+
"~standard": {
|
|
30
|
+
validate: (input: unknown) => FetchSourceStandardSchemaResultSuccess<T> | FetchSourceStandardSchemaResultFailure | Promise<FetchSourceStandardSchemaResultSuccess<T> | FetchSourceStandardSchemaResultFailure>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
type SourceRuntimeOptions$2 = Pick<WorkspaceSource, "cache">;
|
|
34
|
+
interface FetchSourceRequestOptions {
|
|
35
|
+
body?: unknown;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
method?: FetchSourceMethod;
|
|
38
|
+
query?: Record<string, unknown>;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}
|
|
41
|
+
type FetchSourceRequest = FetchSourceRequestOptions | (() => FetchSourceRequestOptions | Promise<FetchSourceRequestOptions>);
|
|
42
|
+
interface FetchSourceOptions<TResponse = unknown, TOutput = TResponse> extends SourceRuntimeOptions$2 {
|
|
43
|
+
method?: FetchSourceMethod;
|
|
44
|
+
path?: string;
|
|
45
|
+
request?: FetchSourceRequest;
|
|
46
|
+
responseType?: FetchSourceResponseType;
|
|
47
|
+
schema?: FetchSourceStandardSchemaV1<TResponse>;
|
|
48
|
+
transform?: (data: TResponse) => TOutput | Promise<TOutput>;
|
|
49
|
+
url: string | URL;
|
|
50
|
+
}
|
|
51
|
+
declare function fetch<TResponse = unknown, TOutput = TResponse>(options: FetchSourceOptions<TResponse, TOutput>): WorkspaceSource;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/sources/github.d.ts
|
|
54
|
+
type SourceRuntimeOptions$1 = Pick<WorkspaceSource, "cache" | "materialize" | "mount" | "validate">;
|
|
55
|
+
type GitHubAuth = NonNullable<GitHubSourceOptions["auth"]>;
|
|
56
|
+
interface GitHubSourceOptions$1 extends Omit<GitHubSourceOptions, "auth">, SourceRuntimeOptions$1 {
|
|
57
|
+
auth?: GitHubAuth;
|
|
58
|
+
}
|
|
59
|
+
declare function github$1(options: GitHubSourceOptions$1): WorkspaceSource;
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/sources/glob.d.ts
|
|
62
|
+
type SourceRuntimeOptions = Pick<WorkspaceSource, "cache" | "materialize" | "mount" | "validate">;
|
|
63
|
+
type GlobSourceOptions$1 = GlobSourceOptions & SourceRuntimeOptions;
|
|
64
|
+
declare function glob$1(options: GlobSourceOptions$1): WorkspaceSource;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/sources/markdown.d.ts
|
|
67
|
+
declare function markdown$1(options: FileSourceOptions$1): WorkspaceSource;
|
|
68
|
+
declare namespace index_d_exports {
|
|
69
|
+
export { FetchSourceOptions, FetchSourceRequest, FetchSourceRequestOptions, FileSourceOptions$1 as FileSourceOptions, GitHubSourceOptions$1 as GitHubSourceOptions, GlobSourceOptions$1 as GlobSourceOptions, custom, fetch, file$1 as file, github$1 as github, glob$1 as glob, markdown$1 as markdown };
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/core/rules.d.ts
|
|
73
|
+
declare function resolveWorkspaceAutoCommit(definition: WorkspaceDefinition, diff: WorkspaceDiff): WorkspaceAutoCommitPlan | undefined;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/core/use.d.ts
|
|
76
|
+
type WorkspaceWritablePath<Name extends WorkspaceName> = WorkspaceAssetPath<Name> | (string & {});
|
|
77
|
+
interface UseWorkspaceOptions {
|
|
78
|
+
mode?: "read" | "write";
|
|
79
|
+
}
|
|
80
|
+
interface WorkspaceFacadeToolOptions extends WorkspaceReadOperations {
|
|
81
|
+
broadSearchPaths?: string[];
|
|
82
|
+
cwd?: string;
|
|
83
|
+
maxShellCalls?: number;
|
|
84
|
+
maxOutputLength?: number;
|
|
85
|
+
timeout?: number;
|
|
86
|
+
}
|
|
87
|
+
interface WritableWorkspaceFacadeToolOptions extends WorkspaceFacadeToolOptions, WorkspaceWriteOperations {}
|
|
88
|
+
type EnabledWriteCapability<Options, Key extends keyof WorkspaceWriteOperations> = Options extends Record<Key, infer Value> ? Value extends false ? false : true : true;
|
|
89
|
+
type WorkspaceReadTools<Options = undefined> = ((ShellEnabled<Options> extends true ? {
|
|
90
|
+
shell: Tool<{
|
|
91
|
+
command: string;
|
|
92
|
+
}, WorkspaceShellResult>;
|
|
93
|
+
} : {}) & (Options extends {
|
|
94
|
+
materialize: true;
|
|
95
|
+
} ? {
|
|
96
|
+
materialize_sources: Tool<{
|
|
97
|
+
path?: string;
|
|
98
|
+
sources?: string[];
|
|
99
|
+
}, WorkspaceMaterializeSourcesResult>;
|
|
100
|
+
} : {}) & ToolSet);
|
|
101
|
+
type WorkspaceWriteTools<Options = undefined> = WorkspaceReadTools<Options> & { [Key in keyof WorkspaceWriteToolMap as EnabledWriteCapability<Options, Key> extends true ? Key : never]: WorkspaceWriteToolMap[Key] } & ToolSet;
|
|
102
|
+
type WorkspaceReadToolSet = WorkspaceReadTools & {
|
|
103
|
+
inspect: <Options extends WorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceReadTools<Options>;
|
|
104
|
+
none: () => ToolSet;
|
|
105
|
+
};
|
|
106
|
+
type WorkspaceWriteToolSet = WorkspaceWriteTools & {
|
|
107
|
+
inspect: <Options extends WorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceReadTools<Options>;
|
|
108
|
+
none: () => ToolSet;
|
|
109
|
+
write: <Options extends WritableWorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceWriteTools<Options>;
|
|
110
|
+
};
|
|
111
|
+
type ReadonlyWorkspaceFs<Name extends WorkspaceName = WorkspaceName> = WorkspaceAssets<WorkspaceAssetPath<Name>>;
|
|
112
|
+
interface WritableWorkspaceFs<Name extends WorkspaceName = WorkspaceName> {
|
|
113
|
+
readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: WorkspaceWritablePath<Name>, options?: TOptions): Promise<ReadFileResult<TOptions>>;
|
|
114
|
+
writeFile(path: WorkspaceWritablePath<Name>, content: WorkspaceContent, options?: WriteFileOptions): Promise<void>;
|
|
115
|
+
appendFile(path: WorkspaceWritablePath<Name>, content: string): Promise<void>;
|
|
116
|
+
stat(path: WorkspaceWritablePath<Name>): Promise<WorkspaceStat>;
|
|
117
|
+
exists(path: WorkspaceWritablePath<Name>): Promise<boolean>;
|
|
118
|
+
list(path?: WorkspaceWritablePath<Name> | "", options?: ListOptions): Promise<WorkspaceEntry[]>;
|
|
119
|
+
glob(pattern: WorkspaceWritablePath<Name> | Array<WorkspaceWritablePath<Name>>, options?: GlobOptions): Promise<WorkspaceEntry[]>;
|
|
120
|
+
search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
|
|
121
|
+
mkdir(path: WorkspaceWritablePath<Name>, options?: MkdirOptions): Promise<void>;
|
|
122
|
+
rm(path: WorkspaceWritablePath<Name>, options?: RmOptions): Promise<void>;
|
|
123
|
+
movePath(from: WorkspaceWritablePath<Name>, to: WorkspaceWritablePath<Name>, options?: {
|
|
124
|
+
overwrite?: boolean;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
copyPath(from: WorkspaceWritablePath<Name>, to: WorkspaceWritablePath<Name>, options?: {
|
|
127
|
+
overwrite?: boolean;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
interface ReadonlyWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
131
|
+
fs: ReadonlyWorkspaceFs<Name>;
|
|
132
|
+
tools: WorkspaceReadToolSet;
|
|
133
|
+
}
|
|
134
|
+
interface WritableWorkspaceFacade<Name extends WorkspaceName = WorkspaceName> {
|
|
135
|
+
diff(options?: DiffOptions): Promise<WorkspaceDiff>;
|
|
136
|
+
fs: WritableWorkspaceFs<Name>;
|
|
137
|
+
snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
|
|
138
|
+
startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
|
|
139
|
+
tools: WorkspaceWriteToolSet;
|
|
140
|
+
}
|
|
141
|
+
type WorkspaceFacade<Name extends WorkspaceName = WorkspaceName, Mode extends UseWorkspaceOptions["mode"] = "read"> = Mode extends "write" ? WritableWorkspaceFacade<Name> : ReadonlyWorkspaceFacade<Name>;
|
|
142
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name): ReadonlyWorkspaceFacade<Name>;
|
|
143
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: {
|
|
144
|
+
mode: "read";
|
|
145
|
+
}): ReadonlyWorkspaceFacade<Name>;
|
|
146
|
+
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: {
|
|
147
|
+
mode: "write";
|
|
148
|
+
}): WritableWorkspaceFacade<Name>;
|
|
149
|
+
//#endregion
|
|
150
|
+
export { CloudflareArtifactsWorkspaceStoreOptions, DiffOptions, EnabledReadCapability, ExecOptions, ExecResult, GlobOptions, ListOptions, LoaderContext, LocalWorkspaceStoreOptions, Logger, MemoryWorkspaceStoreOptions, MkdirOptions, PublishContext, ReadFileOptions, ReadFileResult, ReadonlyWorkspaceFacade, ReadonlyWorkspaceFs, ResolvedWorkspaceModuleOptions, ResolvedWorkspaceRule, RmOptions, ShellEnabled, SnapshotOptions, SourceContext, UseWorkspaceOptions, VercelBlobWorkspaceStoreOptions, Workspace, WorkspaceAssetPath, WorkspaceAssets, WorkspaceAssetsRegistry, WorkspaceAutoCommitPlan, WorkspaceCacheOptions, WorkspaceContent, WorkspaceDefinition, WorkspaceDefinitionInput, WorkspaceDiff, WorkspaceDiffEntry, WorkspaceEntry, WorkspaceFacade, WorkspaceFacadeToolOptions, WorkspaceFile, WorkspaceHookContext, WorkspaceHooks, WorkspaceLoader, WorkspaceLoaderSource, WorkspaceMaterializeMode, WorkspaceMaterializeSourcesOptions, WorkspaceMaterializeSourcesResult, WorkspaceModuleOptions, WorkspaceMount, WorkspaceMountMode, WorkspaceMountOptions, WorkspaceMoveResult, WorkspaceName, WorkspaceNameMap, WorkspacePathResult, WorkspacePlugin, WorkspacePublisher, WorkspaceReadOperations, WorkspaceReadToolSet, WorkspaceReadTools, WorkspaceRule, WorkspaceRules, WorkspaceSearchHit, WorkspaceSearchQuery, WorkspaceSession, WorkspaceSessionOptions, WorkspaceShellResult, WorkspaceSnapshot, WorkspaceSource, WorkspaceSourceItem, WorkspaceSourceMaterializationStatus, WorkspaceSourceMount, WorkspaceSourceMountOptions, WorkspaceStat, WorkspaceStore, WorkspaceStoreOptions, WorkspaceSyncOptions, WorkspaceToolOperations, WorkspaceToolOptions, WorkspaceTools, WorkspaceValidateMode, WorkspaceWriteErrorHook, WorkspaceWriteHook, WorkspaceWriteInput, WorkspaceWriteMode, WorkspaceWriteOperation, WorkspaceWriteOperations, WorkspaceWriteToolMap, WorkspaceWriteToolSet, WorkspaceWriteTools, WorkspaceWriteValidator, WorkspaceWriteValidatorResult, WritableWorkspaceFacade, WritableWorkspaceFacadeToolOptions, WritableWorkspaceFs, WriteFileOptions, createWorkspaceTools, defineWorkspace, resolveWorkspaceAutoCommit, index_d_exports as source, useWorkspace };
|