@vite-hub/workspace 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 +13 -2
- package/dist/{ai-Ce3PtWFW.js → ai-BqCC8BpY.js} +2 -2
- package/dist/{ai-nmHdzjCM.d.ts → ai-CjxvGqM0.d.ts} +1 -1
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-CaG9b7tf.js → asset-registry-8QI3ML3K.js} +1 -1
- package/dist/chunk-2rV9d50f.js +35 -0
- package/dist/cloudflare.d.ts +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/collections.d.ts +2 -2
- package/dist/collections.js +1 -1
- package/dist/{config-CZLO0m9h.js → config-Bc3c4Su1.js} +213 -120
- package/dist/{config-CDoyls2X.js → config-CHLLWklZ.js} +9 -3
- package/dist/{config-3I1BnsdO.d.ts → config-DE9xlaIw.d.ts} +1 -1
- package/dist/{file-CHfsZpso.js → file-Bc1X7pco.js} +3 -3
- package/dist/{files-QRV55OCx.js → files-Q6xZjDHA.js} +20 -9
- package/dist/{github-CfA5vpJ5.js → github-DHnjxQIX.js} +24 -15
- package/dist/{glob-D0vD_wRY.js → glob-CEZKeZFC.js} +5 -4
- package/dist/host-DJH8cuoU.js +1030 -0
- package/dist/{hosted-C1-tTTTf.js → hosted-RPeJOCFz.js} +121 -31
- package/dist/hosted-vercel-blob-d6C8ND5j.js +23580 -0
- package/dist/hosted-vercel-blob.d.ts +1 -1
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +42 -51
- package/dist/index.js +124 -419
- package/dist/lifecycle-LrL3sA4n.js +316 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/metadata-target-B0tOmVW7.js +717 -0
- package/dist/mountx.d.ts +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +8 -2
- package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
- package/dist/{provider-C3_elpEh.js → provider-B1yLjCJJ.js} +194 -47
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/publish.d.ts +1 -1
- package/dist/publish.js +2 -2
- package/dist/registry-D3yzt8HQ.js +127 -0
- package/dist/{registry-BIQVCBWI.d.ts → registry-Uj6IVxes.d.ts} +3 -3
- package/dist/{request-execution-u9mgUXKX.js → request-execution-B-dSFlGB.js} +8 -4
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +4 -2
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +1 -1
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +10 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime-type-iEE6BjQJ.js +34 -0
- package/dist/runtime.d.ts +42 -7
- package/dist/runtime.js +275 -82
- package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +23 -50
- package/dist/{shared-jfogBrd5.js → shared-DTR1Hhma.js} +97 -39
- package/dist/source-metadata.d.ts +9 -2
- package/dist/source-metadata.js +34 -2
- package/dist/{state-TTqa3x3Y.d.ts → state-tYcRWEh2.d.ts} +13 -12
- package/dist/store-Dt_Jyys3.js +608 -0
- package/dist/{sync-DiuDmSGk.js → sync-DnTQwt8r.js} +6 -5
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/token-CVzURBxC.js +61 -0
- package/dist/{types-60Yn149G.d.ts → types-CYuwjJ4V.d.ts} +94 -27
- package/dist/{use-CsV3oIxH.js → use-BTNDR5Rd.js} +145 -31
- package/dist/{use-CUFSnFCS.d.ts → use-BiHzt0xA.d.ts} +21 -4
- package/dist/vite-BptCrpv2.js +4526 -0
- package/dist/vite-CtA9guIM.d.ts +66 -0
- package/dist/vite.d.ts +2 -50
- package/dist/vite.js +2 -2
- package/dist/{workspace-C4k92Ow8.js → workspace-Dq08Yn72.js} +224 -529
- package/dist/{workspace-66SKyiec.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
- package/package.json +15 -18
- package/dist/chunk-8H4AJuhK.js +0 -14
- package/dist/host-CAnbugpI.js +0 -370
- package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
- package/dist/lifecycle-BYoa9hVb.js +0 -176
- package/dist/registry-CqyDTW9Y.js +0 -74
- package/dist/store-Bs1SLh55.js +0 -414
- package/dist/vite-tbfDxtlu.js +0 -2191
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
+
import { a as require_token_error, i as require_dist, r as require_token_util } from "./hosted-vercel-blob-d6C8ND5j.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@vercel+oidc@3.8.2/node_modules/@vercel/oidc/dist/token.js
|
|
4
|
+
var require_token = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var token_exports = {};
|
|
26
|
+
__export(token_exports, { refreshToken: () => refreshToken });
|
|
27
|
+
module.exports = __toCommonJS(token_exports);
|
|
28
|
+
var import_cli_config = require_dist();
|
|
29
|
+
var import_token_error = require_token_error();
|
|
30
|
+
var import_token_util = require_token_util();
|
|
31
|
+
async function refreshToken(options) {
|
|
32
|
+
let projectId = options?.project;
|
|
33
|
+
let teamId = options?.team;
|
|
34
|
+
if (!projectId && !teamId) {
|
|
35
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
36
|
+
projectId = projectInfo.projectId;
|
|
37
|
+
teamId = projectInfo.teamId;
|
|
38
|
+
} else if (!projectId || !teamId) {
|
|
39
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
40
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
41
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
42
|
+
}
|
|
43
|
+
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
44
|
+
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
45
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
46
|
+
const configDir = (0, import_cli_config.getGlobalPathConfig)();
|
|
47
|
+
if ((0, import_cli_config.getLikelyEffectiveCredStorage)(configDir) === "keyring") maybeToken = await (0, import_token_util.getVercelOidcTokenFromCli)(projectId, teamId);
|
|
48
|
+
else {
|
|
49
|
+
const authToken = await (0, import_token_util.getVercelToken)({ expirationBufferMs: options?.expirationBufferMs });
|
|
50
|
+
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
51
|
+
}
|
|
52
|
+
if (!maybeToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
53
|
+
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
54
|
+
}
|
|
55
|
+
process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
|
|
56
|
+
}
|
|
57
|
+
0 && (module.exports = { refreshToken });
|
|
58
|
+
}));
|
|
59
|
+
//#endregion
|
|
60
|
+
export default require_token();
|
|
61
|
+
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ExecutionAuthority } from "@vite-hub/runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Source, SourceContext, SourceRevision } from "@vite-hub/source";
|
|
3
|
+
import { FileSourceOptions } from "@vite-hub/source/file";
|
|
4
|
+
import { GitHubSourceOptions } from "@vite-hub/source/github";
|
|
5
|
+
import { GlobSourceOptions } from "@vite-hub/source/glob";
|
|
6
|
+
import { McpResourcesSourceOptions } from "@vite-hub/source/mcp";
|
|
3
7
|
|
|
4
8
|
//#region src/core/types.d.ts
|
|
5
9
|
type WorkspaceContent = string | Uint8Array;
|
|
@@ -11,10 +15,14 @@ type ReadFileResult<TOptions extends ReadFileOptions | undefined = undefined> =
|
|
|
11
15
|
encoding: "binary";
|
|
12
16
|
} ? Uint8Array : string;
|
|
13
17
|
interface WriteFileOptions {
|
|
18
|
+
ifDigest?: string | null;
|
|
14
19
|
mediaType?: string;
|
|
15
20
|
metadata?: Record<string, unknown>;
|
|
21
|
+
preservePath?: boolean;
|
|
16
22
|
}
|
|
23
|
+
type WorkspaceSessionWriteFileOptions = Omit<WriteFileOptions, "ifDigest" | "preservePath">;
|
|
17
24
|
interface ListOptions {
|
|
25
|
+
exclude?: string[];
|
|
18
26
|
recursive?: boolean;
|
|
19
27
|
}
|
|
20
28
|
interface GlobOptions {
|
|
@@ -107,32 +115,51 @@ interface WorkspaceSyncOptions {
|
|
|
107
115
|
sources: WorkspaceSourceSelection;
|
|
108
116
|
}
|
|
109
117
|
interface WorkspaceSessionOptions {
|
|
118
|
+
abortSignal?: AbortSignal;
|
|
110
119
|
attach?: boolean;
|
|
111
120
|
host?: WorkspaceSessionHost;
|
|
121
|
+
materializeSources?: false;
|
|
122
|
+
onProgress?: (event: WorkspacePrepareSessionProgressEvent) => void | Promise<void>;
|
|
112
123
|
paths?: readonly string[];
|
|
113
124
|
target?: string;
|
|
125
|
+
writeBack?: false | {
|
|
126
|
+
exclude?: readonly string[];
|
|
127
|
+
};
|
|
114
128
|
}
|
|
115
129
|
interface WorkspaceSessionHostFileEntry {
|
|
130
|
+
executable?: boolean;
|
|
116
131
|
path: string;
|
|
117
132
|
size?: number;
|
|
118
133
|
type: "directory" | "file" | "symlink";
|
|
119
134
|
}
|
|
120
135
|
interface WorkspaceSessionHostFiles {
|
|
121
|
-
exists(path: string
|
|
136
|
+
exists(path: string, options?: {
|
|
137
|
+
signal?: AbortSignal;
|
|
138
|
+
}): Promise<boolean>;
|
|
122
139
|
list(path: string, options?: {
|
|
140
|
+
exclude?: readonly string[];
|
|
123
141
|
recursive?: boolean;
|
|
142
|
+
signal?: AbortSignal;
|
|
124
143
|
}): Promise<readonly WorkspaceSessionHostFileEntry[]>;
|
|
125
144
|
mkdir(path: string, options?: {
|
|
126
145
|
recursive?: boolean;
|
|
146
|
+
signal?: AbortSignal;
|
|
127
147
|
}): Promise<void>;
|
|
128
|
-
read(path: string
|
|
148
|
+
read(path: string, options?: {
|
|
149
|
+
signal?: AbortSignal;
|
|
150
|
+
}): Promise<Uint8Array | null>;
|
|
129
151
|
remove(path: string, options?: {
|
|
130
152
|
recursive?: boolean;
|
|
153
|
+
signal?: AbortSignal;
|
|
154
|
+
}): Promise<void>;
|
|
155
|
+
write(path: string, content: Uint8Array, options?: {
|
|
156
|
+
signal?: AbortSignal;
|
|
131
157
|
}): Promise<void>;
|
|
132
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
133
158
|
}
|
|
134
159
|
interface WorkspaceSessionHost {
|
|
135
160
|
readonly executionAuthority: ExecutionAuthority;
|
|
161
|
+
readonly inspectionConcurrency?: number;
|
|
162
|
+
detachAbortSignal?(): void;
|
|
136
163
|
files: WorkspaceSessionHostFiles;
|
|
137
164
|
exec(command: string, args?: readonly string[], options?: {
|
|
138
165
|
cwd?: string;
|
|
@@ -161,21 +188,26 @@ interface ExecResult {
|
|
|
161
188
|
interface WorkspaceSession {
|
|
162
189
|
readonly executionAuthority: ExecutionAuthority;
|
|
163
190
|
readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
|
|
164
|
-
writeFile(path: string, content: WorkspaceContent, options?:
|
|
191
|
+
writeFile(path: string, content: WorkspaceContent, options?: WorkspaceSessionWriteFileOptions): Promise<void>;
|
|
165
192
|
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
166
193
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
167
194
|
list(path?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
|
|
168
195
|
glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
|
|
169
196
|
search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
|
|
170
|
-
diff(
|
|
197
|
+
diff(options?: {
|
|
198
|
+
abortSignal?: AbortSignal;
|
|
199
|
+
}): Promise<WorkspaceDiff>;
|
|
171
200
|
commit(options?: {
|
|
201
|
+
abortSignal?: AbortSignal;
|
|
172
202
|
message?: string;
|
|
173
203
|
}): Promise<void>;
|
|
174
204
|
exec(command: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
|
|
175
205
|
tools?: {
|
|
176
206
|
aiSdk?(): Promise<Record<string, unknown>>;
|
|
177
207
|
};
|
|
178
|
-
close(
|
|
208
|
+
close(options?: {
|
|
209
|
+
abortSignal?: AbortSignal;
|
|
210
|
+
}): Promise<void>;
|
|
179
211
|
}
|
|
180
212
|
declare global {
|
|
181
213
|
interface ViteHubWorkspaceNameMap {}
|
|
@@ -248,16 +280,23 @@ interface WorkspaceAutoCommitPlan {
|
|
|
248
280
|
message: string;
|
|
249
281
|
paths: string[];
|
|
250
282
|
}
|
|
283
|
+
interface WorkspaceRebaseOptions {
|
|
284
|
+
takeRemote?: string[];
|
|
285
|
+
}
|
|
251
286
|
interface WorkspaceStore {
|
|
252
287
|
readFile(path: string): Promise<WorkspaceFile | undefined>;
|
|
253
288
|
writeFile(path: string, file: WorkspaceFile): Promise<void>;
|
|
254
|
-
|
|
289
|
+
writeFileConditional?(path: string, file: WorkspaceFile, ifDigest: string | null): Promise<void>;
|
|
290
|
+
writeFileStream?(path: string, file: WorkspaceStreamFile): Promise<WorkspaceStat & {
|
|
291
|
+
digest: string;
|
|
292
|
+
}>;
|
|
255
293
|
list(prefix?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
|
|
256
294
|
glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
|
|
257
295
|
stat(path: string): Promise<WorkspaceStat | undefined>;
|
|
258
296
|
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
259
297
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
260
298
|
snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
|
|
299
|
+
rebase?(options?: WorkspaceRebaseOptions): Promise<void>;
|
|
261
300
|
diff(options?: DiffOptions): Promise<WorkspaceDiff>;
|
|
262
301
|
getMeta?(key: string): Promise<unknown>;
|
|
263
302
|
setMeta?(key: string, value: unknown): Promise<void>;
|
|
@@ -267,13 +306,9 @@ interface SourceContextWorkspaceFiles {
|
|
|
267
306
|
stat(path: string): Promise<WorkspaceStat | undefined>;
|
|
268
307
|
exists(path: string): Promise<boolean>;
|
|
269
308
|
}
|
|
270
|
-
interface SourceContext {
|
|
271
|
-
abortSignal?: AbortSignal;
|
|
309
|
+
interface SourceContext$1 extends SourceContext {
|
|
272
310
|
mountPath?: string;
|
|
273
|
-
rootDir: string;
|
|
274
311
|
selectedWorkspaceScope?: WorkspaceSelectedScope;
|
|
275
|
-
source?: string;
|
|
276
|
-
sourceRootDir?: string;
|
|
277
312
|
workspace: string;
|
|
278
313
|
workspaceFiles?: SourceContextWorkspaceFiles;
|
|
279
314
|
}
|
|
@@ -281,7 +316,7 @@ type MaybePromise<T> = T | Promise<T>;
|
|
|
281
316
|
interface WorkspaceSourceResolutionContextValueReader<TContextMap extends object = WorkspaceSourceResolutionContextMap> {
|
|
282
317
|
entries(): IterableIterator<[string, unknown]>;
|
|
283
318
|
get<K extends Extract<keyof TContextMap, string>>(id: K): TContextMap[K] | undefined;
|
|
284
|
-
get
|
|
319
|
+
get(id: string): unknown;
|
|
285
320
|
has(id: string): boolean;
|
|
286
321
|
toJSON?(): Record<string, unknown>;
|
|
287
322
|
}
|
|
@@ -313,7 +348,7 @@ type WorkspaceSourceResolutionContext<TContextMap extends object = WorkspaceSour
|
|
|
313
348
|
};
|
|
314
349
|
type WorkspaceSourceResolutionResult = WorkspaceSource | false | null | undefined;
|
|
315
350
|
type WorkspaceSourceResolver<TContextMap extends object = WorkspaceSourceResolutionContextMap, TScopeName extends string = WorkspaceScopeName> = (context: WorkspaceSourceResolutionContext<TContextMap, TScopeName>) => MaybePromise<WorkspaceSourceResolutionResult>;
|
|
316
|
-
type WorkspaceMaterializeMode = "build" | "lazy" | "none";
|
|
351
|
+
type WorkspaceMaterializeMode = "build" | "startup" | "lazy" | "none";
|
|
317
352
|
type WorkspaceValidateMode = false | "request";
|
|
318
353
|
interface WorkspaceCacheOptions {
|
|
319
354
|
maxAge?: number;
|
|
@@ -369,8 +404,10 @@ interface WorkspaceSourceRequestExecutionResult {
|
|
|
369
404
|
metadata?: Record<string, unknown>;
|
|
370
405
|
status?: number;
|
|
371
406
|
}
|
|
372
|
-
type WorkspaceSourceRequestExecutor = (input: WorkspaceSourceRequestExecutionInput, context: SourceContext) => MaybePromise<WorkspaceSourceRequestExecutionResult>;
|
|
407
|
+
type WorkspaceSourceRequestExecutor = (input: WorkspaceSourceRequestExecutionInput, context: SourceContext$1) => MaybePromise<WorkspaceSourceRequestExecutionResult>;
|
|
373
408
|
interface WorkspaceSource {
|
|
409
|
+
/** Stable provider name used for inspection and diagnostics. */
|
|
410
|
+
name?: string;
|
|
374
411
|
mount?: WorkspaceSourceMount;
|
|
375
412
|
materialize?: WorkspaceMaterializeMode;
|
|
376
413
|
cache?: false | WorkspaceCacheOptions;
|
|
@@ -379,13 +416,12 @@ interface WorkspaceSource {
|
|
|
379
416
|
probeKeys?: string[];
|
|
380
417
|
fingerprint?: unknown;
|
|
381
418
|
resolve?: WorkspaceSourceResolver;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
watch?: unknown[];
|
|
419
|
+
resolveRevision?(ctx: SourceContext$1): Promise<SourceRevision | undefined>;
|
|
420
|
+
prepare?(ctx: SourceContext$1): Promise<void>;
|
|
421
|
+
getKeys(ctx: SourceContext$1): Promise<string[]>;
|
|
422
|
+
getItem(key: string, ctx: SourceContext$1): Promise<WorkspaceSourceItem>;
|
|
423
|
+
getItems?(ctx: SourceContext$1): Promise<WorkspaceSourceItem[]>;
|
|
424
|
+
getMeta?(key: string, ctx: SourceContext$1): Promise<Record<string, unknown> | undefined>;
|
|
389
425
|
}
|
|
390
426
|
interface WorkspaceSourceSyncPolicy {
|
|
391
427
|
concurrency?: "skip" | "queue";
|
|
@@ -402,11 +438,13 @@ type WorkspaceFileSourceInput<TKey extends string = string> = TKey | (FileSource
|
|
|
402
438
|
interface WorkspaceFetchSourceRequestOptions {
|
|
403
439
|
body?: unknown;
|
|
404
440
|
headers?: Record<string, string>;
|
|
441
|
+
maxResponseBytes?: number;
|
|
405
442
|
method?: "GET" | "HEAD" | "POST";
|
|
406
443
|
query?: Record<string, unknown>;
|
|
407
444
|
timeout?: number;
|
|
408
445
|
}
|
|
409
446
|
interface WorkspaceFetchSourceInput<TResponse = unknown, TOutput = TResponse> extends WorkspaceSourceBindingOptions {
|
|
447
|
+
maxResponseBytes?: number;
|
|
410
448
|
method?: "GET" | "HEAD" | "POST";
|
|
411
449
|
path?: string;
|
|
412
450
|
request?: WorkspaceFetchSourceRequestOptions | (() => WorkspaceFetchSourceRequestOptions | Promise<WorkspaceFetchSourceRequestOptions>);
|
|
@@ -416,13 +454,16 @@ interface WorkspaceFetchSourceInput<TResponse = unknown, TOutput = TResponse> ex
|
|
|
416
454
|
url: string | URL;
|
|
417
455
|
}
|
|
418
456
|
type WorkspaceGlobSourceInput = GlobSourceOptions & WorkspaceSourceBindingOptions;
|
|
419
|
-
type WorkspaceGitHubSourceInput = GitHubSourceOptions &
|
|
457
|
+
type WorkspaceGitHubSourceInput = Omit<GitHubSourceOptions, "ignore"> & {
|
|
458
|
+
ignore?: false | string | readonly string[];
|
|
459
|
+
} & WorkspaceSourceBindingOptions;
|
|
420
460
|
type WorkspaceMcpResourcesSourceInput<TKey extends string = string> = Omit<McpResourcesSourceOptions<TKey>, "cache"> & WorkspaceSourceBindingOptions;
|
|
421
461
|
type WorkspaceSourceInput = WorkspaceSourceBindingInput | WorkspaceCustomSourceInput | WorkspaceFileSourceInput | WorkspaceFetchSourceInput | WorkspaceGlobSourceInput | WorkspaceGitHubSourceInput | WorkspaceMcpResourcesSourceInput;
|
|
422
462
|
interface WorkspaceLoaderSource extends WorkspaceSource {
|
|
423
463
|
key: string;
|
|
424
464
|
}
|
|
425
465
|
interface LoaderContext {
|
|
466
|
+
abortSignal?: AbortSignal;
|
|
426
467
|
workspace: string;
|
|
427
468
|
rootDir: string;
|
|
428
469
|
sourceRootDir?: string;
|
|
@@ -443,6 +484,7 @@ interface WorkspaceLoader {
|
|
|
443
484
|
load(ctx: LoaderContext): Promise<void>;
|
|
444
485
|
}
|
|
445
486
|
interface PublishContext {
|
|
487
|
+
abortSignal?: AbortSignal;
|
|
446
488
|
durable: boolean;
|
|
447
489
|
workspace: WorkspaceDefinition;
|
|
448
490
|
store: WorkspaceStore;
|
|
@@ -519,14 +561,18 @@ interface ResolvedWorkspaceModuleOptions {
|
|
|
519
561
|
assets?: boolean | string[];
|
|
520
562
|
store: Exclude<WorkspaceStoreOptions, WorkspaceStore>;
|
|
521
563
|
}
|
|
564
|
+
interface WorkspaceCapabilities {
|
|
565
|
+
conditionalWrites: boolean;
|
|
566
|
+
}
|
|
522
567
|
interface Workspace {
|
|
523
568
|
name: string;
|
|
569
|
+
capabilities?(): Promise<WorkspaceCapabilities>;
|
|
524
570
|
sync(options: WorkspaceSyncOptions): Promise<WorkspaceSourceSyncResult>;
|
|
525
571
|
materializeSources?(options?: WorkspaceMaterializeSourcesOptions): Promise<WorkspaceMaterializeSourcesResult>;
|
|
526
572
|
getMeta?(key: string): Promise<unknown>;
|
|
527
573
|
setMeta?(key: string, value: unknown): Promise<void>;
|
|
528
574
|
readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: string, options?: TOptions): Promise<ReadFileResult<TOptions>>;
|
|
529
|
-
writeFile(path: string, content: WorkspaceContent, options?: WriteFileOptions): Promise<
|
|
575
|
+
writeFile(path: string, content: WorkspaceContent, options?: WriteFileOptions): Promise<string>;
|
|
530
576
|
list(path?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
|
|
531
577
|
glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
|
|
532
578
|
search(query: WorkspaceSearchQuery): Promise<WorkspaceSearchHit[]>;
|
|
@@ -536,6 +582,7 @@ interface Workspace {
|
|
|
536
582
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
537
583
|
publish(options?: WorkspacePublishOptions): Promise<void>;
|
|
538
584
|
snapshot(options?: SnapshotOptions): Promise<WorkspaceSnapshot>;
|
|
585
|
+
rebase(options?: WorkspaceRebaseOptions): Promise<void>;
|
|
539
586
|
diff(options?: DiffOptions): Promise<WorkspaceDiff>;
|
|
540
587
|
startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
|
|
541
588
|
}
|
|
@@ -566,28 +613,48 @@ interface WorkspaceSourceSyncResult {
|
|
|
566
613
|
status: "error" | "partial" | "ready" | "skipped";
|
|
567
614
|
}
|
|
568
615
|
interface WorkspaceSourceMaterializationStatus {
|
|
616
|
+
cacheStatus?: "bypassed" | "disabled" | "hit" | "miss";
|
|
617
|
+
counts?: WorkspaceSourceMaterializationCounts;
|
|
618
|
+
durationMs?: number;
|
|
569
619
|
source: string;
|
|
570
620
|
mountPath: string;
|
|
621
|
+
paths?: WorkspaceSourceMaterializationPathResult[];
|
|
622
|
+
provider?: string;
|
|
571
623
|
status: "lazy" | "updating" | "ready" | "error";
|
|
572
|
-
|
|
624
|
+
revision?: SourceRevision;
|
|
573
625
|
materializedAt?: string;
|
|
574
626
|
files?: number;
|
|
575
627
|
bytes?: number;
|
|
576
628
|
error?: string;
|
|
577
629
|
}
|
|
630
|
+
interface WorkspaceSourceMaterializationCounts {
|
|
631
|
+
added: number;
|
|
632
|
+
removed: number;
|
|
633
|
+
unchanged: number;
|
|
634
|
+
updated: number;
|
|
635
|
+
}
|
|
636
|
+
interface WorkspaceSourceMaterializationPathResult {
|
|
637
|
+
path: string;
|
|
638
|
+
status: "added" | "removed" | "unchanged" | "updated";
|
|
639
|
+
}
|
|
578
640
|
interface WorkspaceMaterializeSourcesProgressEvent {
|
|
579
641
|
bytes?: number;
|
|
642
|
+
cacheStatus?: WorkspaceSourceMaterializationStatus["cacheStatus"];
|
|
643
|
+
counts?: WorkspaceSourceMaterializationCounts;
|
|
580
644
|
directories?: number;
|
|
581
645
|
durationMs?: number;
|
|
582
646
|
error?: string;
|
|
583
647
|
files?: number;
|
|
584
648
|
mountPath: string;
|
|
585
649
|
path: string;
|
|
650
|
+
provider?: string;
|
|
651
|
+
revision?: SourceRevision;
|
|
586
652
|
source: string;
|
|
587
653
|
status: "started" | "updating" | "completed" | "failed";
|
|
588
654
|
}
|
|
589
655
|
interface WorkspaceMaterializeSourcesOptions {
|
|
590
656
|
abortSignal?: AbortSignal;
|
|
657
|
+
details?: "paths";
|
|
591
658
|
onProgress?: (event: WorkspaceMaterializeSourcesProgressEvent) => void | Promise<void>;
|
|
592
659
|
sources?: string[];
|
|
593
660
|
path?: string;
|
|
@@ -609,4 +676,4 @@ interface WorkspaceMaterializeSourcesResult {
|
|
|
609
676
|
sources: WorkspaceSourceMaterializationStatus[];
|
|
610
677
|
}
|
|
611
678
|
//#endregion
|
|
612
|
-
export {
|
|
679
|
+
export { WorkspaceMaterializeSourcesOptions as $, WorkspaceStore as $t, WorkspaceCacheOptions as A, WorkspaceSourceMaterializationPathResult as At, WorkspaceFetchSourceInput as B, WorkspaceSourceResolutionContextMap as Bt, SourceContextWorkspaceFiles as C, WorkspaceSnapshot as Ct, WorkspaceAssets as D, WorkspaceSourceInput as Dt, WorkspaceAssetPath as E, WorkspaceSourceDefinition as Et, WorkspaceDefinition as F, WorkspaceSourceRequestExecutionInput as Ft, WorkspaceGlobSourceInput as G, WorkspaceSourceSelection as Gt, WorkspaceFile as H, WorkspaceSourceResolutionInvocation as Ht, WorkspaceDefinitionInput as I, WorkspaceSourceRequestExecutionResult as It, WorkspaceInstructionBinding as J, WorkspaceSourceSyncPathResult as Jt, WorkspaceHookContext as K, WorkspaceSourceSyncConfig as Kt, WorkspaceDiff as L, WorkspaceSourceRequestExecutor as Lt, WorkspaceContent as M, WorkspaceSourceMount as Mt, WorkspaceContentStream as N, WorkspaceSourceMountOptions as Nt, WorkspaceAssetsRegistry as O, WorkspaceSourceItem as Ot, WorkspaceCustomSourceInput as P, WorkspaceSourceRequestDescriptor as Pt, WorkspaceMaterializeMode as Q, WorkspaceStat as Qt, WorkspaceDiffEntry as R, WorkspaceSourceRequestMethod as Rt, SourceContext$1 as S, WorkspaceSessionWriteFileOptions as St, Workspace as T, WorkspaceSourceBindingInput as Tt, WorkspaceFileSourceInput as U, WorkspaceSourceResolutionResult as Ut, WorkspaceFetchSourceRequestOptions as V, WorkspaceSourceResolutionContextValueReader as Vt, WorkspaceGitHubSourceInput as W, WorkspaceSourceResolver as Wt, WorkspaceLoader as X, WorkspaceSourceSyncResult as Xt, WorkspaceInstructionBindingValue as Y, WorkspaceSourceSyncPolicy as Yt, WorkspaceLoaderSource as Z, WorkspaceSourceSyncStatus as Zt, ReadFileResult as _, WorkspaceSession as _t, GitHubWorkspaceOption as a, WorkspaceValidateMode as an, WorkspaceNameMap as at, RmOptions as b, WorkspaceSessionHostFiles as bt, ListOptions as c, WorkspaceWriteInput as cn, WorkspacePublishOptions as ct, Logger as d, WorkspaceWriteValidator as dn, WorkspaceRule as dt, WorkspaceStoreOptions as en, WorkspaceMaterializeSourcesProgressEvent as et, MaybePromise as f, WorkspaceWriteValidatorResult as fn, WorkspaceRules as ft, ReadFileOptions as g, WorkspaceSelectedScope as gt, PublishContext as h, WorkspaceSearchQuery as ht, ExecResult as i, WorkspaceSyncSnapshotOptions as in, WorkspaceName as it, WorkspaceCapabilities as j, WorkspaceSourceMaterializationStatus as jt, WorkspaceAutoCommitPlan as k, WorkspaceSourceMaterializationCounts as kt, LoaderContext as l, WorkspaceWriteMode as ln, WorkspacePublisher as lt, MkdirOptions as m, WorkspaceSearchHit as mt, DiffOptions as n, WorkspaceSyncOptions as nn, WorkspaceMcpResourcesSourceInput as nt, GitHubWorkspaceStoreOptions as o, WorkspaceWriteErrorHook as on, WorkspacePlugin as ot, MemoryWorkspaceStoreOptions as p, WriteFileOptions as pn, WorkspaceScopeName as pt, WorkspaceHooks as q, WorkspaceSourceSyncCounts as qt, ExecOptions as r, WorkspaceSyncResultDetails as rn, WorkspaceModuleOptions as rt, GlobOptions as s, WorkspaceWriteHook as sn, WorkspacePrepareSessionProgressEvent as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceStreamFile as tn, WorkspaceMaterializeSourcesResult as tt, LocalWorkspaceStoreOptions as u, WorkspaceWriteOperation as un, WorkspaceRebaseOptions as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSessionHost as vt, VercelBlobWorkspaceStoreOptions as w, WorkspaceSource as wt, SnapshotOptions as x, WorkspaceSessionOptions as xt, ResolvedWorkspaceRule as y, WorkspaceSessionHostFileEntry as yt, WorkspaceEntry as z, WorkspaceSourceResolutionContext as zt };
|
|
@@ -1,12 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as copyWorkspacePath, i as appendWorkspaceFile, t as createWorkspaceTools } from "./ai-
|
|
3
|
-
import { r as getWorkspaceSourceRequestExecution, t as attachWorkspaceSourceRequestExecution } from "./request-execution-
|
|
1
|
+
import { _ as workspaceError, c as normalizeSafeWorkspacePattern, s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
|
|
2
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, t as createWorkspaceTools } from "./ai-BqCC8BpY.js";
|
|
3
|
+
import { r as getWorkspaceSourceRequestExecution, t as attachWorkspaceSourceRequestExecution } from "./request-execution-B-dSFlGB.js";
|
|
4
4
|
import { r as workspaceStoreTarget } from "./target-D4Bqb1eH.js";
|
|
5
|
-
import { n as useWorkspaceAssets } from "./asset-registry-
|
|
6
|
-
import { t as createWorkspace } from "./workspace-
|
|
7
|
-
import {
|
|
5
|
+
import { n as useWorkspaceAssets } from "./asset-registry-8QI3ML3K.js";
|
|
6
|
+
import { t as createWorkspace } from "./workspace-Dq08Yn72.js";
|
|
7
|
+
import { r as workspaceMetadataTarget, t as forwardWorkspaceMetadataTarget } from "./metadata-target-B0tOmVW7.js";
|
|
8
|
+
import { a as useRegisteredWorkspace } from "./registry-D3yzt8HQ.js";
|
|
9
|
+
import { t as createHostedWorkspaceSession } from "./host-DJH8cuoU.js";
|
|
8
10
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
9
11
|
//#region src/core/use.ts
|
|
12
|
+
const workspaceDefinitionSyncStates = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
async function workspaceDefinitionSyncState(workspace) {
|
|
14
|
+
const owner = await workspace[workspaceMetadataTarget]?.() ?? workspace;
|
|
15
|
+
const key = workspace.__workspaceDefinitionSyncKey ?? workspace;
|
|
16
|
+
let states = workspaceDefinitionSyncStates.get(owner);
|
|
17
|
+
if (!states) {
|
|
18
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
workspaceDefinitionSyncStates.set(owner, states);
|
|
20
|
+
}
|
|
21
|
+
let state = states.get(key);
|
|
22
|
+
if (!state) {
|
|
23
|
+
state = {};
|
|
24
|
+
states.set(key, state);
|
|
25
|
+
}
|
|
26
|
+
return state;
|
|
27
|
+
}
|
|
28
|
+
async function waitForWorkspaceSync(pending, signal) {
|
|
29
|
+
if (!signal) return await pending;
|
|
30
|
+
signal.throwIfAborted();
|
|
31
|
+
let onAbort;
|
|
32
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
33
|
+
onAbort = () => reject(signal.reason);
|
|
34
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
return await Promise.race([pending, aborted]);
|
|
38
|
+
} finally {
|
|
39
|
+
signal.removeEventListener("abort", onAbort);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
10
42
|
function normalizePath(path, allowEmpty = false) {
|
|
11
43
|
const reserved = normalizeSafeWorkspacePath(path, {
|
|
12
44
|
allowEmpty,
|
|
@@ -39,41 +71,82 @@ async function materializeWorkspaceSources(workspace, options) {
|
|
|
39
71
|
}
|
|
40
72
|
function createLazyWorkspace(name, definition) {
|
|
41
73
|
let workspacePromise;
|
|
42
|
-
let syncPromise;
|
|
43
74
|
async function resolveWorkspace() {
|
|
44
75
|
workspacePromise ||= definition ? Promise.resolve(createWorkspace(definition)) : useRegisteredWorkspace(name);
|
|
45
76
|
return await workspacePromise;
|
|
46
77
|
}
|
|
47
|
-
async function resolveSyncedWorkspace() {
|
|
78
|
+
async function resolveSyncedWorkspace(abortSignal) {
|
|
48
79
|
const workspace = await resolveWorkspace();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
const sync = await workspaceDefinitionSyncState(workspace);
|
|
81
|
+
while (true) {
|
|
82
|
+
if (sync.explicitPromise) {
|
|
83
|
+
const explicit = sync.explicitPromise;
|
|
84
|
+
await waitForWorkspaceSync(explicit, abortSignal);
|
|
85
|
+
if (sync.explicitPromise === explicit) sync.explicitPromise = void 0;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!sync.promise) {
|
|
89
|
+
const next = workspace.__syncWorkspaceDefinition?.(abortSignal) ?? Promise.resolve();
|
|
90
|
+
sync.promise = next;
|
|
91
|
+
sync.abortSignal = abortSignal;
|
|
92
|
+
next.catch(() => {
|
|
93
|
+
if (sync.promise === next) {
|
|
94
|
+
sync.promise = void 0;
|
|
95
|
+
sync.abortSignal = void 0;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const current = sync.promise;
|
|
100
|
+
const currentAbortSignal = sync.abortSignal;
|
|
101
|
+
try {
|
|
102
|
+
await waitForWorkspaceSync(current, abortSignal);
|
|
103
|
+
return workspace;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (abortSignal?.aborted) {
|
|
106
|
+
if (abortSignal === currentAbortSignal) await current.catch(() => {});
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
if (!currentAbortSignal?.aborted) throw error;
|
|
110
|
+
if (sync.promise === current) {
|
|
111
|
+
sync.promise = void 0;
|
|
112
|
+
sync.abortSignal = void 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
55
115
|
}
|
|
56
|
-
|
|
57
|
-
|
|
116
|
+
}
|
|
117
|
+
async function resolvePublishWorkspace() {
|
|
118
|
+
const workspace = await resolveWorkspace();
|
|
119
|
+
const sync = await workspaceDefinitionSyncState(workspace);
|
|
120
|
+
if (sync.explicitPromise) await waitForWorkspaceSync(sync.explicitPromise);
|
|
121
|
+
return sync.promise ? await resolveSyncedWorkspace() : workspace;
|
|
58
122
|
}
|
|
59
123
|
return attachWorkspaceSourceRequestExecution({
|
|
124
|
+
async [workspaceMetadataTarget]() {
|
|
125
|
+
return (await resolveWorkspace())[workspaceMetadataTarget]?.();
|
|
126
|
+
},
|
|
60
127
|
name,
|
|
128
|
+
async capabilities() {
|
|
129
|
+
return await (await resolveWorkspace()).capabilities?.() ?? { conditionalWrites: false };
|
|
130
|
+
},
|
|
61
131
|
async [workspaceStoreTarget]() {
|
|
62
132
|
return await (await resolveWorkspace())[workspaceStoreTarget]?.();
|
|
63
133
|
},
|
|
64
134
|
async sync(options) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
next.
|
|
68
|
-
|
|
69
|
-
|
|
135
|
+
const resolved = await resolveWorkspace();
|
|
136
|
+
const sync = await workspaceDefinitionSyncState(resolved);
|
|
137
|
+
const next = resolved.sync(options);
|
|
138
|
+
const pending = next.then(() => void 0);
|
|
139
|
+
sync.explicitPromise = pending;
|
|
140
|
+
pending.finally(() => {
|
|
141
|
+
if (sync.explicitPromise === pending) sync.explicitPromise = void 0;
|
|
142
|
+
}).catch(() => void 0);
|
|
70
143
|
return await next;
|
|
71
144
|
},
|
|
72
145
|
async readFile(path, options) {
|
|
73
146
|
return await (await resolveSyncedWorkspace()).readFile(normalizePath(path), options);
|
|
74
147
|
},
|
|
75
148
|
async writeFile(path, content, options) {
|
|
76
|
-
await (await resolveSyncedWorkspace()).writeFile(normalizePath(path), content, options);
|
|
149
|
+
return await (await resolveSyncedWorkspace()).writeFile(normalizePath(path), content, options);
|
|
77
150
|
},
|
|
78
151
|
async list(path, options) {
|
|
79
152
|
return await (await resolveSyncedWorkspace()).list(path ? normalizeListPath(path) : "", options);
|
|
@@ -101,15 +174,20 @@ function createLazyWorkspace(name, definition) {
|
|
|
101
174
|
await (await resolveSyncedWorkspace()).rm(normalizePath(path), options);
|
|
102
175
|
},
|
|
103
176
|
async materializeSources(options) {
|
|
104
|
-
return await materializeWorkspaceSources(await resolveSyncedWorkspace(), options);
|
|
177
|
+
return await materializeWorkspaceSources(await resolveSyncedWorkspace(options?.abortSignal), options);
|
|
105
178
|
},
|
|
106
179
|
async publish(options) {
|
|
107
|
-
|
|
108
|
-
await (await resolveWorkspace()).publish(options);
|
|
180
|
+
await (await resolvePublishWorkspace()).publish(options);
|
|
109
181
|
},
|
|
110
182
|
async snapshot(options) {
|
|
111
183
|
return await (await resolveSyncedWorkspace()).snapshot(options);
|
|
112
184
|
},
|
|
185
|
+
async rebase(options) {
|
|
186
|
+
await (await resolveSyncedWorkspace()).rebase({
|
|
187
|
+
...options,
|
|
188
|
+
takeRemote: options?.takeRemote?.map((path) => normalizePath(path))
|
|
189
|
+
});
|
|
190
|
+
},
|
|
113
191
|
async diff(options) {
|
|
114
192
|
return await (await resolveSyncedWorkspace()).diff(options);
|
|
115
193
|
},
|
|
@@ -128,7 +206,7 @@ function createLazyWorkspace(name, definition) {
|
|
|
128
206
|
return await executor.executeSourceRequest(input);
|
|
129
207
|
} });
|
|
130
208
|
}
|
|
131
|
-
function createWritableFs(workspace) {
|
|
209
|
+
function createWritableFs(name, workspace) {
|
|
132
210
|
return attachWorkspaceSourceRequestExecution({
|
|
133
211
|
readFile: async (path, options) => await workspace.readFile(normalizePath(path), options),
|
|
134
212
|
writeFile: async (path, content, options) => await workspace.writeFile(normalizePath(path), content, options),
|
|
@@ -191,7 +269,8 @@ function mergeSearchHits(primary = [], fallback = []) {
|
|
|
191
269
|
}
|
|
192
270
|
function createReadonlyFs(name, workspace) {
|
|
193
271
|
const assets = useOptionalWorkspaceAssets(name);
|
|
194
|
-
|
|
272
|
+
let readonlyFs;
|
|
273
|
+
readonlyFs = attachWorkspaceSourceRequestExecution({
|
|
195
274
|
readFile: async (path, options) => {
|
|
196
275
|
const normalized = normalizePath(path);
|
|
197
276
|
try {
|
|
@@ -246,8 +325,34 @@ function createReadonlyFs(name, workspace) {
|
|
|
246
325
|
path: options?.path || "",
|
|
247
326
|
sources: []
|
|
248
327
|
},
|
|
249
|
-
startSession: async (options) =>
|
|
328
|
+
startSession: async (options) => {
|
|
329
|
+
if (!assets || !options?.host) return await workspace.startSession(options);
|
|
330
|
+
return await createHostedWorkspaceSession(Object.assign(Object.create(workspace), {
|
|
331
|
+
exists: readonlyFs.exists,
|
|
332
|
+
glob: readonlyFs.glob,
|
|
333
|
+
list: readonlyFs.list,
|
|
334
|
+
readFile: readonlyFs.readFile,
|
|
335
|
+
search: readonlyFs.search,
|
|
336
|
+
stat: readonlyFs.stat
|
|
337
|
+
}), {
|
|
338
|
+
...options,
|
|
339
|
+
host: options.host
|
|
340
|
+
});
|
|
341
|
+
}
|
|
250
342
|
}, getWorkspaceSourceRequestExecution(workspace));
|
|
343
|
+
const resolveMetadata = workspace[workspaceMetadataTarget];
|
|
344
|
+
if (resolveMetadata) readonlyFs[workspaceMetadataTarget] = async () => {
|
|
345
|
+
const metadata = await ignoreMissingWorkspace(async () => await resolveMetadata.call(workspace));
|
|
346
|
+
if (!metadata && !assets) return;
|
|
347
|
+
return {
|
|
348
|
+
getMeta: metadata?.getMeta?.bind(metadata),
|
|
349
|
+
list: async (path, options) => {
|
|
350
|
+
const assetPath = path;
|
|
351
|
+
return mergeEntries(assets ? await assets.list(assetPath, options) : [], await metadata?.list?.(path, options) ?? []);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
return readonlyFs;
|
|
251
356
|
}
|
|
252
357
|
function toReadOperations(options) {
|
|
253
358
|
return {
|
|
@@ -303,8 +408,13 @@ function useWorkspace(name, options) {
|
|
|
303
408
|
[workspaceStoreTarget]: async () => {
|
|
304
409
|
return await workspace[workspaceStoreTarget]?.();
|
|
305
410
|
},
|
|
411
|
+
capabilities: async () => await workspace.capabilities(),
|
|
306
412
|
diff: async (options) => await workspace.diff(options),
|
|
307
|
-
fs: createWritableFs(workspace),
|
|
413
|
+
fs: createWritableFs(name, workspace),
|
|
414
|
+
history: {
|
|
415
|
+
checkpoint: async (options) => await workspace.snapshot({ name: options?.message }),
|
|
416
|
+
rebase: async (options) => await workspace.rebase(options)
|
|
417
|
+
},
|
|
308
418
|
getMeta: async (key) => await workspace.getMeta?.(key),
|
|
309
419
|
materializeSources: async (options) => await materializeWorkspaceSources(workspace, options),
|
|
310
420
|
publish: async (options) => await workspace.publish(options),
|
|
@@ -315,7 +425,8 @@ function useWorkspace(name, options) {
|
|
|
315
425
|
tools
|
|
316
426
|
};
|
|
317
427
|
}
|
|
318
|
-
const
|
|
428
|
+
const workspace = createLazyWorkspace(name, options?.definition);
|
|
429
|
+
const fs = createReadonlyFs(name, workspace);
|
|
319
430
|
const createTools = (opts) => createWorkspaceTools(fs, {
|
|
320
431
|
broadSearchPaths: opts?.broadSearchPaths,
|
|
321
432
|
cwd: opts?.cwd,
|
|
@@ -327,10 +438,13 @@ function useWorkspace(name, options) {
|
|
|
327
438
|
const tools = createDefaultToolSet(createTools);
|
|
328
439
|
tools.inspect = createTools;
|
|
329
440
|
tools.none = emptyTools;
|
|
330
|
-
|
|
441
|
+
const facade = {
|
|
331
442
|
fs,
|
|
443
|
+
getMeta: async (key) => await workspace.getMeta?.(key),
|
|
332
444
|
tools
|
|
333
445
|
};
|
|
446
|
+
forwardWorkspaceMetadataTarget(fs, facade);
|
|
447
|
+
return facade;
|
|
334
448
|
}
|
|
335
449
|
//#endregion
|
|
336
450
|
export { useWorkspace as t };
|