@vite-hub/workspace 0.4.1 → 0.5.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/README.md +62 -19
- package/dist/blob-database/postgres.d.ts +424 -0
- package/dist/blob-database/postgres.js +2 -0
- package/dist/blob-database-sources-DDZ1wV9w.js +9 -0
- package/dist/blob-database.d.ts +33 -447
- package/dist/blob-database.js +637 -208
- package/dist/checkout.js +1 -1
- package/dist/cloudflare.d.ts +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/{config-D1QENneP.js → config-DiyPi3Ff.js} +7 -7
- package/dist/{config-CDeGd0RB.d.ts → config-hxABr_Gg.d.ts} +1 -1
- package/dist/durability.d.ts +11 -2
- package/dist/durability.js +46 -4
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-C0KyI408.js} +5 -1
- package/dist/{error-diagnostics-B5s9kNEA.js → error-diagnostics-Cth97txN.js} +10 -2
- package/dist/{path-uxLkzrZm.d.ts → errors-DXCZjdUU.d.ts} +0 -1
- package/dist/{file-CqG9zqiF.js → file-C1DYoGz3.js} +1 -1
- package/dist/{target-Dm9dHAVJ.js → file-metadata-Dv2JZwal.js} +1 -29
- package/dist/{files-B6wpAhEx.js → files-iHyik8jj.js} +2 -2
- package/dist/files.d.ts +13 -5
- package/dist/files.js +6 -5
- package/dist/{github-DKAlO0Vh.js → github-CFHl6RI0.js} +4 -4
- package/dist/{glob-BOqSKzSg.js → glob-BitxqDhb.js} +7 -7
- package/dist/{glob-Cjxms1t7.js → glob-Buxfvmyy.js} +1 -1
- package/dist/history-schema-BBWbpDk4.d.ts +436 -0
- package/dist/history-schema-postgres-U_ueRvmO.js +41 -0
- package/dist/{host-Bf1a2uo_.js → host-Dmr2Ctem.js} +150 -16
- package/dist/{hosted-zG7HJaE4.js → hosted-BktlvkF2.js} +20 -11
- package/dist/{hosted-vercel-blob-AbXG8fvR.js → hosted-vercel-blob-D0IPAjb1.js} +5 -5
- 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 +11 -23
- package/dist/index.js +28 -106
- package/dist/internal/workspace.d.ts +14 -0
- package/dist/internal/workspace.js +86 -0
- package/dist/{lifecycle-D8FdpBod.js → lifecycle-D6WN2dd_.js} +11 -8
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +2 -2
- package/dist/{mcp-resources-DntxtmDU.js → mcp-resources-TtxLNSL6.js} +1 -1
- package/dist/{memory-D5jq9HZW.js → memory-DjzwSng2.js} +16 -8
- package/dist/{metadata-target-DDoOQNp1.js → metadata-target-CR0aDtvS.js} +205 -60
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CI2PJGqu.d.ts} +8 -2
- package/dist/{operations-D8uCpzhM.js → operations-Cib30_dt.js} +5 -5
- package/dist/{operations-DsY2MQnG.js → operations-dtcU5LkD.js} +22 -7
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +1 -1
- package/dist/{path--wrT_Azm.js → path-BlIBpI7U.js} +1 -16
- package/dist/{plugins-CsrXCA1Q.d.ts → plugins-DKCBrH31.d.ts} +1 -1
- package/dist/{provider-sm9uzkLg.js → provider-Fc3M6bEx.js} +23 -10
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/{registry-CwryP59t.d.ts → registry-CLL0TY0L.d.ts} +5 -3
- package/dist/{registry-DmVfUe4K.js → registry-CedQvQxW.js} +8 -3
- package/dist/{registry-CFl1Htyc.d.ts → registry-DpB5PBA4.d.ts} +5 -4
- package/dist/{request-scope-Dw5n8bMC.js → request-scope-Bcv2kD8h.js} +2 -1
- package/dist/rule-keys-Bsz6jTTF.js +19 -0
- package/dist/rules-OHaPFopX.js +269 -0
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +3 -3
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +2 -2
- package/dist/runtime/registry.d.ts +2 -2
- package/dist/runtime/request.js +1 -1
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +18 -6
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +9 -8
- package/dist/runtime.js +23 -16
- package/dist/{search-C_RfoM2j.js → search-BqNV9LnO.js} +1 -1
- package/dist/{server-Cd4-iCh5.js → server-CFtrOPk6.js} +5 -5
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{shared-ovXVSV3-.js → shared-BgDjxY3J.js} +14 -3
- package/dist/source-metadata.d.ts +2 -2
- package/dist/source-metadata.js +3 -3
- package/dist/{state-C-YtsaiJ.d.ts → state-DBV6VHS6.d.ts} +13 -21
- package/dist/{store-NZoRto-Y.js → store-BRMdD8Ft.js} +37 -36
- package/dist/{sync-CrT8zjwc.js → sync-BezGVzrW.js} +4 -4
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-1Z-tKK3g.d.ts → types-9DMtFjaa.d.ts} +52 -4
- package/dist/{use-B0o5HoBl.js → use-Dm2tbI5F.js} +15 -15
- package/dist/{use-CjbF8EO9.d.ts → use-Dv973swc.d.ts} +20 -28
- package/dist/{state-Cb_hIyAw.js → use-tools-C1qvhzme.js} +4 -17
- package/dist/use-tools-CMUthOdy.d.ts +12 -0
- package/dist/{utils-Dw-WULEZ.js → utils-C0Au2R16.js} +77 -268
- package/dist/vite.d.ts +32 -3
- package/dist/vite.js +990 -1286
- package/dist/vitehub-grants-C8IAl5-M.js +38 -0
- package/dist/{workspace-DvKu5PRa.js → workspace-CFrwWhEm.js} +18 -17
- package/dist/{workspace-CIXgHeyX.d.ts → workspace-Cw4ycIW-.d.ts} +1 -1
- package/package.json +22 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as workspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { l as normalizeWorkspacePath } from "./path
|
|
3
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import { t as internalErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
+
import { l as normalizeWorkspacePath } from "./path-BlIBpI7U.js";
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Cth97txN.js";
|
|
4
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-C0KyI408.js";
|
|
5
5
|
import { t as abortable } from "./abort-BCwpdrN0.js";
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
7
|
import { gunzipSync } from "node:zlib";
|
|
@@ -53,6 +53,17 @@ const forgeEnv = {
|
|
|
53
53
|
names: ["VITEHUB_FORGEJO_WEBHOOK_SECRET", "FORGES_FORGEJO_WEBHOOK_SECRET"],
|
|
54
54
|
secret: true
|
|
55
55
|
}
|
|
56
|
+
},
|
|
57
|
+
gitea: {
|
|
58
|
+
baseUrl: { names: ["VITEHUB_GITEA_BASE_URL", "FORGES_GITEA_BASE_URL"] },
|
|
59
|
+
token: {
|
|
60
|
+
names: ["VITEHUB_GITEA_TOKEN", "FORGES_GITEA_TOKEN"],
|
|
61
|
+
secret: true
|
|
62
|
+
},
|
|
63
|
+
webhookSecret: {
|
|
64
|
+
names: ["VITEHUB_GITEA_WEBHOOK_SECRET", "FORGES_GITEA_WEBHOOK_SECRET"],
|
|
65
|
+
secret: true
|
|
66
|
+
}
|
|
56
67
|
}
|
|
57
68
|
};
|
|
58
69
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-
|
|
1
|
+
import { V as WorkspaceEntry, in as WorkspaceSourceMaterializationStatus, zt as WorkspaceRules } from "./types-9DMtFjaa.js";
|
|
2
|
+
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-hxABr_Gg.js";
|
|
3
3
|
//#region src/core/rule-keys.d.ts
|
|
4
4
|
/** Rejects rule keys that ViteHub does not enforce, such as `read`, so that a rule never looks like a protection it is not. */
|
|
5
5
|
export declare function assertWorkspaceRules(rules: WorkspaceRules | undefined): void;
|
package/dist/source-metadata.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata } from "./config-
|
|
3
|
-
import { m as readCurrentSourceSnapshot, o as resolveWorkspaceMetadataTarget } from "./metadata-target-
|
|
1
|
+
import { t as assertWorkspaceRules } from "./rule-keys-Bsz6jTTF.js";
|
|
2
|
+
import { i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata } from "./config-DiyPi3Ff.js";
|
|
3
|
+
import { m as readCurrentSourceSnapshot, o as resolveWorkspaceMetadataTarget } from "./metadata-target-CR0aDtvS.js";
|
|
4
4
|
//#region src/source-metadata.ts
|
|
5
5
|
async function listMaterializedWorkspaceEntries(workspace) {
|
|
6
6
|
return await (await resolveWorkspaceMetadataTarget(workspace))?.list?.("", { recursive: true });
|
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { t as WorkspaceRegistry } from "./registry-
|
|
4
|
-
import "./registry-
|
|
1
|
+
import { En as WorkspaceStore, T as VercelBlobWorkspaceStoreOptions, k as WorkspaceAssetsRegistry, s as GitHubWorkspaceStoreOptions, t as CloudflareArtifactsWorkspaceStoreOptions } from "./types-9DMtFjaa.js";
|
|
2
|
+
import "./use-Dv973swc.js";
|
|
3
|
+
import { t as WorkspaceRegistry } from "./registry-DpB5PBA4.js";
|
|
4
|
+
import "./registry-CLL0TY0L.js";
|
|
5
|
+
import "./use-tools-CMUthOdy.js";
|
|
6
|
+
//#region src/runtime/hosted-store-loader.d.ts
|
|
7
|
+
type HostedWorkspaceStoreOptions = CloudflareArtifactsWorkspaceStoreOptions | GitHubWorkspaceStoreOptions | VercelBlobWorkspaceStoreOptions;
|
|
8
|
+
/** Returns `undefined` when no installed hosted store handles `options.provider`. */
|
|
9
|
+
type WorkspaceHostedStoreLoader = (options: HostedWorkspaceStoreOptions, workspaceName: string) => WorkspaceStore | undefined;
|
|
10
|
+
declare function setWorkspaceHostedStoreLoader(loader: WorkspaceHostedStoreLoader | undefined): void;
|
|
11
|
+
declare function getWorkspaceHostedStoreLoader(): WorkspaceHostedStoreLoader | undefined;
|
|
12
|
+
//#endregion
|
|
5
13
|
//#region ../internal/src/runtime/cloudflare-env-lookup.d.ts
|
|
6
14
|
type CloudflareWorkerEnv = Record<string, unknown>;
|
|
7
15
|
//#endregion
|
|
8
16
|
//#region ../internal/src/runtime/cloudflare-env.d.ts
|
|
9
17
|
declare function setActiveCloudflareEnv(env: CloudflareWorkerEnv | undefined): void;
|
|
10
18
|
//#endregion
|
|
11
|
-
//#region src/core/use-tools.d.ts
|
|
12
|
-
declare function useWorkspace<Name extends WorkspaceName>(name: Name): ReadonlyWorkspaceFacade<Name>;
|
|
13
|
-
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
14
|
-
mode?: "read";
|
|
15
|
-
}): ReadonlyWorkspaceFacade<Name>;
|
|
16
|
-
declare function useWorkspace<Name extends WorkspaceName>(name: Name, options: UseWorkspaceOptions & {
|
|
17
|
-
mode: "write";
|
|
18
|
-
}): WritableWorkspaceFacade<Name>;
|
|
19
|
-
//#endregion
|
|
20
19
|
//#region src/core/workspace-cache.d.ts
|
|
21
20
|
declare function resetWorkspaceStoreCache(): void;
|
|
22
21
|
//#endregion
|
|
23
|
-
//#region src/runtime/hosted-store-loader.d.ts
|
|
24
|
-
type HostedWorkspaceStoreOptions = CloudflareArtifactsWorkspaceStoreOptions | GitHubWorkspaceStoreOptions | VercelBlobWorkspaceStoreOptions;
|
|
25
|
-
/** Returns `undefined` when no installed hosted store handles `options.provider`. */
|
|
26
|
-
type WorkspaceHostedStoreLoader = (options: HostedWorkspaceStoreOptions, workspaceName: string) => WorkspaceStore | undefined;
|
|
27
|
-
declare function setWorkspaceHostedStoreLoader(loader: WorkspaceHostedStoreLoader | undefined): void;
|
|
28
|
-
declare function getWorkspaceHostedStoreLoader(): WorkspaceHostedStoreLoader | undefined;
|
|
29
|
-
//#endregion
|
|
30
22
|
//#region src/runtime/state.d.ts
|
|
31
23
|
declare function invalidateWorkspaceStore(name: string): Promise<void>;
|
|
32
24
|
declare function setWorkspaceRuntimeRegistry(registry: WorkspaceRegistry): void;
|
|
33
25
|
declare function setWorkspaceRuntimeAssetsRegistry(registry: WorkspaceAssetsRegistry): void;
|
|
34
26
|
//#endregion
|
|
35
|
-
export {
|
|
27
|
+
export { setActiveCloudflareEnv as a, getWorkspaceHostedStoreLoader as c, resetWorkspaceStoreCache as i, setWorkspaceHostedStoreLoader as l, setWorkspaceRuntimeAssetsRegistry as n, HostedWorkspaceStoreOptions as o, setWorkspaceRuntimeRegistry as r, WorkspaceHostedStoreLoader as s, invalidateWorkspaceStore as t };
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
import { a as workspaceConflict, n as assertWorkspaceDigest, r as isWorkspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { r as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { C as githubKVKey, D as writeWorkspaceKV, O as BoundedMap, S as resolveGitHubRootOption, T as readWorkspaceKV, _ as requireGitHubOption, a as gitFileMode, b as resolveGitHubRefsOption, c as githubRequestStatus, d as preloadGitHubFiles, f as readCurrentHead, g as readGitHubFile, i as gitBlobSha, l as joinGitPath, m as readGitHubBranchState, n as commitGitHubChanges, o as githubBranchMovedConflict, p as readGitHubArchive, r as connectGitHubRepository, s as githubRequest, t as assertNoGitHubRepositoryKey, u as loadForge, v as resolveGitHubBranchOption, x as resolveGitHubRepositoryOption, y as resolveGitHubCredential } from "./shared-
|
|
2
|
+
import { a as isExcludedWorkspacePath, c as normalizeSafeWorkspacePattern, i as decodeFile, l as normalizeWorkspacePath, n as contentStreamToBytes, r as contentToBytes } from "./path-BlIBpI7U.js";
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Cth97txN.js";
|
|
4
|
+
import { d as normalizeHistoryPath, f as normalizeHistoryRef, m as rejectHistoryHead, n as createSnapshotFromEntries, p as readHistoryDeleteRef, r as diffSnapshots, u as historyConflict } from "./utils-C0Au2R16.js";
|
|
5
|
+
import { t as createWorkspaceGlobMatcher } from "./glob-Buxfvmyy.js";
|
|
6
|
+
import { a as provideWorkspaceStoreTarget, n as provideWorkspaceRevisionMaterializer } from "./vitehub-grants-C8IAl5-M.js";
|
|
7
|
+
import { C as githubKVKey, D as writeWorkspaceKV, O as BoundedMap, S as resolveGitHubRootOption, T as readWorkspaceKV, _ as requireGitHubOption, a as gitFileMode, b as resolveGitHubRefsOption, c as githubRequestStatus, d as preloadGitHubFiles, f as readCurrentHead, g as readGitHubFile, i as gitBlobSha, l as joinGitPath, m as readGitHubBranchState, n as commitGitHubChanges, o as githubBranchMovedConflict, p as readGitHubArchive, r as connectGitHubRepository, s as githubRequest, t as assertNoGitHubRepositoryKey, u as loadForge, v as resolveGitHubBranchOption, x as resolveGitHubRepositoryOption, y as resolveGitHubCredential } from "./shared-BgDjxY3J.js";
|
|
8
8
|
import { t as workspaceStoreDiscard } from "./discard-CNNtCozM.js";
|
|
9
9
|
import { ViteHubError } from "@vite-hub/runtime";
|
|
10
10
|
import { lookup } from "mrmime";
|
|
11
11
|
import { posix } from "node:path";
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
13
13
|
import * as v from "valibot";
|
|
14
|
-
//#region src/storage/materialization.ts
|
|
15
|
-
const workspaceRevisionMaterializer = Symbol.for("vitehub.workspace.revisionMaterializer");
|
|
16
|
-
function forwardWorkspaceRevisionMaterializer(source, target) {
|
|
17
|
-
const materializer = source[workspaceRevisionMaterializer];
|
|
18
|
-
if (materializer) target[workspaceRevisionMaterializer] = materializer;
|
|
19
|
-
}
|
|
20
|
-
function resolveWorkspaceRevisionMaterializer(workspace) {
|
|
21
|
-
return workspace[workspaceRevisionMaterializer];
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
14
|
//#region src/providers/github/publish-reservation.ts
|
|
25
15
|
const githubPublishReservationMs = 3e5;
|
|
26
16
|
const zeroOid = "0".repeat(40);
|
|
@@ -1246,9 +1236,20 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
1246
1236
|
await deleteBranch(temporary);
|
|
1247
1237
|
}
|
|
1248
1238
|
};
|
|
1239
|
+
const deleteRef = async (deleteOptions) => {
|
|
1240
|
+
const { ref, ifHead } = readHistoryDeleteRef(deleteOptions);
|
|
1241
|
+
if (toBranch(ref) === options.branch) throw workspaceErrorDiagnostics.WORKSPACE_DEFAULT_REF_DELETE();
|
|
1242
|
+
const { branch } = resolveRef(ref);
|
|
1243
|
+
const head = await readCurrentHead(client(), branch);
|
|
1244
|
+
if (ifHead !== void 0 && head !== ifHead) throw historyConflict(ref, ifHead, head, { repository: options.repository });
|
|
1245
|
+
if (!head) return false;
|
|
1246
|
+
await deleteBranch(branch);
|
|
1247
|
+
return true;
|
|
1248
|
+
};
|
|
1249
1249
|
return {
|
|
1250
1250
|
pullRequests,
|
|
1251
1251
|
openPullRequest,
|
|
1252
|
+
deleteRef,
|
|
1252
1253
|
merge: checkedMerge,
|
|
1253
1254
|
head: async (headOptions) => {
|
|
1254
1255
|
const { branch, ref } = resolveRef(headOptions?.ref);
|
|
@@ -1375,9 +1376,8 @@ async function waitForGitHubOperation(read, signal) {
|
|
|
1375
1376
|
var GitHubWorkspaceStore = class {
|
|
1376
1377
|
options;
|
|
1377
1378
|
workspaceName;
|
|
1379
|
+
#sessionArchive;
|
|
1378
1380
|
#baseline;
|
|
1379
|
-
#archive;
|
|
1380
|
-
#archiveReads = /* @__PURE__ */ new Map();
|
|
1381
1381
|
#baselineRefSha;
|
|
1382
1382
|
#dirty = false;
|
|
1383
1383
|
#files = /* @__PURE__ */ new Map();
|
|
@@ -1391,6 +1391,8 @@ var GitHubWorkspaceStore = class {
|
|
|
1391
1391
|
constructor(options, workspaceName) {
|
|
1392
1392
|
this.options = options;
|
|
1393
1393
|
this.workspaceName = workspaceName;
|
|
1394
|
+
provideWorkspaceStoreTarget(this, () => this.#storeTarget());
|
|
1395
|
+
provideWorkspaceRevisionMaterializer(this, this.#revisionMaterializer);
|
|
1394
1396
|
}
|
|
1395
1397
|
/**
|
|
1396
1398
|
* The repository, branch, root, and token resolve on first use. The Store is created when the Workspace Definition
|
|
@@ -1435,7 +1437,7 @@ var GitHubWorkspaceStore = class {
|
|
|
1435
1437
|
this.#ready = void 0;
|
|
1436
1438
|
});
|
|
1437
1439
|
}
|
|
1438
|
-
|
|
1440
|
+
#storeTarget() {
|
|
1439
1441
|
return {
|
|
1440
1442
|
provider: "github",
|
|
1441
1443
|
branch: this.#branch,
|
|
@@ -1443,7 +1445,7 @@ var GitHubWorkspaceStore = class {
|
|
|
1443
1445
|
...this.options.database === void 0 ? {} : { database: this.options.database }
|
|
1444
1446
|
};
|
|
1445
1447
|
}
|
|
1446
|
-
|
|
1448
|
+
#revisionMaterializer = {
|
|
1447
1449
|
currentRevision: async (options) => {
|
|
1448
1450
|
await waitForGitHubOperation(this.#mutate(async () => await this.#ensure({ refresh: options?.refresh !== false })), options?.abortSignal);
|
|
1449
1451
|
return this.#baselineRefSha;
|
|
@@ -1453,22 +1455,9 @@ var GitHubWorkspaceStore = class {
|
|
|
1453
1455
|
const revision = this.#baselineRefSha;
|
|
1454
1456
|
const paths = options?.paths;
|
|
1455
1457
|
const files = [...this.#remoteFiles.keys()].filter((path) => !isReservedWorkspacePath(path) && (!paths || paths.some((root) => path === root || path.startsWith(`${root}/`)))).length;
|
|
1456
|
-
|
|
1457
|
-
let read = this.#archiveReads.get(revision);
|
|
1458
|
-
if (!read) {
|
|
1459
|
-
read = readGitHubArchive(this.#client, revision);
|
|
1460
|
-
this.#archiveReads.set(revision, read);
|
|
1461
|
-
read.finally(() => {
|
|
1462
|
-
if (this.#archiveReads.get(revision) === read) this.#archiveReads.delete(revision);
|
|
1463
|
-
}).catch(() => {});
|
|
1464
|
-
}
|
|
1465
|
-
this.#archive = {
|
|
1466
|
-
bytes: await waitForGitHubOperation(read, options?.abortSignal),
|
|
1467
|
-
revision
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1458
|
+
const archive = !this.#dirty && paths === void 0 ? await waitForGitHubOperation(this.#readSessionArchive(revision), options?.abortSignal) : void 0;
|
|
1470
1459
|
return {
|
|
1471
|
-
...!this.#dirty &&
|
|
1460
|
+
...!this.#dirty && archive ? { archive: archive.slice() } : {},
|
|
1472
1461
|
files,
|
|
1473
1462
|
paths,
|
|
1474
1463
|
revision,
|
|
@@ -1476,6 +1465,18 @@ var GitHubWorkspaceStore = class {
|
|
|
1476
1465
|
};
|
|
1477
1466
|
}
|
|
1478
1467
|
};
|
|
1468
|
+
#readSessionArchive(revision) {
|
|
1469
|
+
if (this.#sessionArchive?.revision === revision) return this.#sessionArchive.read;
|
|
1470
|
+
const entry = {
|
|
1471
|
+
revision,
|
|
1472
|
+
read: readGitHubArchive(this.#client, revision)
|
|
1473
|
+
};
|
|
1474
|
+
this.#sessionArchive = entry;
|
|
1475
|
+
entry.read.catch(() => {
|
|
1476
|
+
if (this.#sessionArchive === entry) this.#sessionArchive = void 0;
|
|
1477
|
+
});
|
|
1478
|
+
return entry.read;
|
|
1479
|
+
}
|
|
1479
1480
|
async readFile(path) {
|
|
1480
1481
|
const normalized = normalizeSafeWorkspacePath(path);
|
|
1481
1482
|
await this.#mutate(async () => await this.#ensure({ refresh: "expired" }));
|
|
@@ -1970,4 +1971,4 @@ function createGitHubWorkspaceStore(options, workspaceName) {
|
|
|
1970
1971
|
return new GitHubWorkspaceStore(options, workspaceName);
|
|
1971
1972
|
}
|
|
1972
1973
|
//#endregion
|
|
1973
|
-
export {
|
|
1974
|
+
export { createGitHubWorkspaceStore as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
-
import {
|
|
3
|
-
import { d as sourceSyncPathClaims, f as workspaceSourceSyncStateEquals, l as readWorkspaceSourceSyncState, u as sourceSyncMetaKey } from "./workspace-
|
|
4
|
-
import { a as normalizeWorkspaceSources, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath } from "./config-
|
|
5
|
-
import { C as withWorkspaceStoreMutation, E as normalizeSourceFileMetadata, S as sourceMountOwnsPath, T as normalizeMetadataValue, w as normalizeSourceItemPath, x as createWorkspaceSourceMountAuthority } from "./metadata-target-
|
|
2
|
+
import { d as sha256, n as contentStreamToBytes } from "./path-BlIBpI7U.js";
|
|
3
|
+
import { d as sourceSyncPathClaims, f as workspaceSourceSyncStateEquals, l as readWorkspaceSourceSyncState, u as sourceSyncMetaKey } from "./workspace-CFrwWhEm.js";
|
|
4
|
+
import { a as normalizeWorkspaceSources, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath } from "./config-DiyPi3Ff.js";
|
|
5
|
+
import { C as withWorkspaceStoreMutation, E as normalizeSourceFileMetadata, S as sourceMountOwnsPath, T as normalizeMetadataValue, w as normalizeSourceItemPath, x as createWorkspaceSourceMountAuthority } from "./metadata-target-CR0aDtvS.js";
|
|
6
6
|
//#region src/sources/sync.ts
|
|
7
7
|
const sourceSyncLocks = /* @__PURE__ */ new Map();
|
|
8
8
|
const sourceSyncGrants = createWorkspaceSourceMountAuthority("Source Sync");
|
package/dist/test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as registerWorkspace } from "./registry-CLL0TY0L.js";
|
|
2
2
|
export { registerWorkspace };
|
package/dist/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as registerWorkspace } from "./registry-CedQvQxW.js";
|
|
2
2
|
export { registerWorkspace };
|
|
@@ -188,6 +188,8 @@ interface WorkspaceSessionHostFiles {
|
|
|
188
188
|
}): Promise<void>;
|
|
189
189
|
}
|
|
190
190
|
interface WorkspaceSessionHost {
|
|
191
|
+
/** Maximum compressed archive bytes accepted by `files.write`, after allowing for transport overhead. Omit to copy files individually. */
|
|
192
|
+
readonly archiveMaxBytes?: number;
|
|
191
193
|
readonly executionAuthority: ExecutionAuthority;
|
|
192
194
|
readonly inspectionConcurrency?: number;
|
|
193
195
|
/** Maximum independent workspace files copied into this host concurrently. Defaults to 1. */
|
|
@@ -253,8 +255,14 @@ declare global {
|
|
|
253
255
|
interface WorkspaceNameMap extends ViteHubWorkspaceNameMap {}
|
|
254
256
|
interface WorkspaceSourceResolutionContextMap extends ViteHubWorkspaceSourceResolutionContextMap {}
|
|
255
257
|
type WorkspaceName = [keyof ViteHubWorkspaceNameMap] extends [never] ? string : Extract<keyof ViteHubWorkspaceNameMap, string>;
|
|
258
|
+
declare const validatedWorkspaceName: unique symbol;
|
|
259
|
+
/** A name checked against the runtime Workspace registry by `isWorkspaceName()`. */
|
|
260
|
+
type ValidatedWorkspaceName = string & {
|
|
261
|
+
readonly [validatedWorkspaceName]: true;
|
|
262
|
+
};
|
|
263
|
+
type WorkspaceLookupName = WorkspaceName | ValidatedWorkspaceName;
|
|
256
264
|
type WorkspaceScopeName = [keyof ViteHubWorkspaceScopeNameMap] extends [never] ? string : Extract<keyof ViteHubWorkspaceScopeNameMap, string>;
|
|
257
|
-
type WorkspaceAssetPath<Name extends
|
|
265
|
+
type WorkspaceAssetPath<Name extends WorkspaceLookupName = WorkspaceName> = Name extends keyof ViteHubWorkspaceAssetMap ? Extract<ViteHubWorkspaceAssetMap[Name], string> : string;
|
|
258
266
|
interface WorkspaceAssets<TKey extends string = string> {
|
|
259
267
|
readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: TKey, options?: TOptions): Promise<ReadFileResult<TOptions>>;
|
|
260
268
|
stat(path: TKey): Promise<WorkspaceStat>;
|
|
@@ -517,9 +525,39 @@ interface WorkspaceHistoryExtensions {
|
|
|
517
525
|
merge?(options: WorkspaceMergeOptions): Promise<WorkspaceRevision | null>;
|
|
518
526
|
/** Open a pull request from one ref into another. */
|
|
519
527
|
openPullRequest?(options: WorkspaceOpenPullRequestOptions): Promise<WorkspacePullRequest>;
|
|
528
|
+
/**
|
|
529
|
+
* Delete a ref. Returns false when it does not exist and no `ifHead` was supplied. Deleting `main` or the Store's
|
|
530
|
+
* working ref throws `WORKSPACE_DEFAULT_REF_DELETE`.
|
|
531
|
+
* Blob + Database also deletes the ref's revisions and file bytes not used by other revisions. GitHub only deletes
|
|
532
|
+
* the branch; commits and their bytes may still be readable by SHA.
|
|
533
|
+
*/
|
|
534
|
+
deleteRef?(options: WorkspaceHistoryDeleteRefOptions): Promise<boolean>;
|
|
535
|
+
}
|
|
536
|
+
interface WorkspaceHistoryDeleteRefOptions {
|
|
537
|
+
/** The ref to delete, such as `run-42`. */
|
|
538
|
+
ref: string;
|
|
539
|
+
/**
|
|
540
|
+
* The expected head of `ref`. A mismatch throws `WORKSPACE_CONFLICT`. Blob + Database checks the head atomically
|
|
541
|
+
* with ref deletion. GitHub checks the head before sending an unconditional branch deletion request.
|
|
542
|
+
*/
|
|
543
|
+
ifHead?: string;
|
|
544
|
+
}
|
|
545
|
+
interface WorkspaceHistoryDiffOptions {
|
|
546
|
+
/** The older revision id. Leave it out to list every file of `to` as added. */
|
|
547
|
+
from?: string;
|
|
548
|
+
/** The newer revision id. Revisions can be on different refs. */
|
|
549
|
+
to: string;
|
|
550
|
+
}
|
|
551
|
+
interface WorkspaceHistoryDiffOptions {
|
|
552
|
+
/** The older revision id. Leave it out to list every file of `to` as added. */
|
|
553
|
+
from?: string;
|
|
554
|
+
/** The newer revision id. Revisions can be on different refs. */
|
|
555
|
+
to: string;
|
|
520
556
|
}
|
|
521
557
|
interface WorkspaceRetainedHistory extends WorkspaceHistoryReader, WorkspaceHistoryExtensions {
|
|
522
558
|
commit(options: WorkspaceHistoryCommitOptions): Promise<WorkspaceRevision>;
|
|
559
|
+
/** The files that were added, modified, or removed from `from` to `to`, sorted by path. Changes to bytes or retained attributes count as modifications. */
|
|
560
|
+
diff(options: WorkspaceHistoryDiffOptions): Promise<WorkspaceDiff>;
|
|
523
561
|
}
|
|
524
562
|
/** Run the Workspace commit policy on a prepared merge before the Store advances its destination ref. */
|
|
525
563
|
type WorkspaceMergeCommit = (options: WorkspaceStoreHistoryCommitOptions, apply: (checked: WorkspaceStoreHistoryCommitOptions) => Promise<WorkspaceRevision>) => Promise<WorkspaceRevision>;
|
|
@@ -530,8 +568,12 @@ interface WorkspaceStoreHistory extends WorkspaceHistoryReader, Omit<WorkspaceHi
|
|
|
530
568
|
interface WorkspaceDiffEntry {
|
|
531
569
|
path: string;
|
|
532
570
|
type: "added" | "modified" | "removed";
|
|
533
|
-
before?: WorkspaceSnapshot["entries"][string]
|
|
534
|
-
|
|
571
|
+
before?: WorkspaceSnapshot["entries"][string] & {
|
|
572
|
+
mediaType?: string;
|
|
573
|
+
};
|
|
574
|
+
after?: WorkspaceSnapshot["entries"][string] & {
|
|
575
|
+
mediaType?: string;
|
|
576
|
+
};
|
|
535
577
|
}
|
|
536
578
|
interface WorkspaceDiff {
|
|
537
579
|
from?: string;
|
|
@@ -553,6 +595,12 @@ interface WorkspaceStore {
|
|
|
553
595
|
writeFileStream?(path: string, file: WorkspaceStreamFile): Promise<WorkspaceStat & {
|
|
554
596
|
digest: string;
|
|
555
597
|
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Creates new files without replacing existing paths, then sets the metadata keys. Call `onWrite` with each file's
|
|
600
|
+
* path after it is created, so the Workspace can roll back those files if a later write fails. Startup Source
|
|
601
|
+
* materialization uses this for new files. Without it, each file and key is written on its own.
|
|
602
|
+
*/
|
|
603
|
+
writeFiles?(files: readonly WorkspaceFile[], meta?: Readonly<Record<string, unknown>>, onWrite?: (path: string) => void): Promise<void>;
|
|
556
604
|
list(prefix?: string, options?: ListOptions): Promise<WorkspaceEntry[]>;
|
|
557
605
|
glob(pattern: string | string[], options?: GlobOptions): Promise<WorkspaceEntry[]>;
|
|
558
606
|
stat(path: string): Promise<WorkspaceStat | undefined>;
|
|
@@ -977,4 +1025,4 @@ interface WorkspaceMaterializeSourcesResult {
|
|
|
977
1025
|
sources: WorkspaceSourceMaterializationStatus[];
|
|
978
1026
|
}
|
|
979
1027
|
//#endregion
|
|
980
|
-
export {
|
|
1028
|
+
export { WorkspaceHistoryDiffOptions as $, WorkspaceSourceDefinition as $t, WorkspaceAuthor as A, WorkspaceStreamFile as An, WorkspaceOptions as At, WorkspaceDiffEntry as B, WorkspaceWriteOperation as Bn, WorkspaceScopeName as Bt, SourceContextWorkspaceFiles as C, WorkspaceSourceSyncResult as Cn, WorkspaceMergeConflict as Ct, WorkspaceAssetPath as D, WorkspaceStoreHistory as Dn, WorkspaceName as Dt, Workspace as E, WorkspaceStore as En, WorkspaceMergeResolution as Et, WorkspaceContentStream as F, WorkspaceWriteCommit as Fn, WorkspaceRetainedHistory as Ft, WorkspaceFileSourceInput as G, WorkspaceSessionHost as Gt, WorkspaceFetchSourceInput as H, WorkspaceWriteValidatorResult as Hn, WorkspaceSearchQuery as Ht, WorkspaceCustomSourceInput as I, WorkspaceWriteErrorHook as In, WorkspaceRevision as It, WorkspaceHistoryChanges as J, WorkspaceSessionOptions as Jt, WorkspaceGitHubSourceInput as K, WorkspaceSessionHostFileEntry as Kt, WorkspaceDefinition as L, WorkspaceWriteHook as Ln, WorkspaceRevisionView as Lt, WorkspaceCacheOptions as M, WorkspaceSyncResultDetails as Mn, WorkspacePrepareSessionProgressEvent as Mt, WorkspaceCapabilities as N, WorkspaceSyncSnapshotOptions as Nn, WorkspacePullRequest as Nt, WorkspaceAssets as O, WorkspaceStoreHistoryCommitOptions as On, WorkspaceNameMap as Ot, WorkspaceContent as P, WorkspaceValidateMode as Pn, WorkspaceRebaseOptions as Pt, WorkspaceHistoryDeleteRefOptions as Q, WorkspaceSourceBindingInput as Qt, WorkspaceDefinitionInput as R, WorkspaceWriteInput as Rn, WorkspaceRule as Rt, SourceContext$1 as S, WorkspaceSourceSyncPolicy as Sn, WorkspaceMergeCommit as St, VercelBlobWorkspaceStoreOptions as T, WorkspaceStat as Tn, WorkspaceMergeOptions as Tt, WorkspaceFetchSourceRequestOptions as U, WriteFileOptions as Un, WorkspaceSelectedScope as Ut, WorkspaceEntry as V, WorkspaceWriteValidator as Vn, WorkspaceSearchHit as Vt, WorkspaceFile as W, WorkspaceSession as Wt, WorkspaceHistoryCommitBase as X, WorkspaceSnapshot as Xt, WorkspaceHistoryChangesCommitOptions as Y, WorkspaceSessionWriteFileOptions as Yt, WorkspaceHistoryCommitOptions as Z, WorkspaceSource as Zt, ReadFileResult as _, WorkspaceSourceResolver as _n, WorkspaceMaterializeMode as _t, GitHubWorkspaceOption as a, WorkspaceSourceMount as an, WorkspaceHistoryListResult as at, RmOptions as b, WorkspaceSourceSyncCounts as bn, WorkspaceMaterializeSourcesResult as bt, GlobOptions as c, WorkspaceSourceRequestExecutionInput as cn, WorkspaceHistoryRefOptions as ct, LocalWorkspaceStoreOptions as d, WorkspaceSourceRequestMethod as dn, WorkspaceInstructionBinding as dt, WorkspaceSourceInput as en, WorkspaceHistoryExtensions as et, Logger as f, WorkspaceSourceResolutionContext as fn, WorkspaceInstructionBindingValue as ft, ReadFileOptions as g, WorkspaceSourceResolutionResult as gn, WorkspaceLookupName as gt, MkdirOptions as h, WorkspaceSourceResolutionInvocation as hn, WorkspaceLoaderSource as ht, ExecResult as i, WorkspaceSourceMaterializationStatus as in, WorkspaceHistoryListOptions as it, WorkspaceAutoCommitPlan as j, WorkspaceSyncOptions as jn, WorkspacePlugin as jt, WorkspaceAssetsRegistry as k, WorkspaceStoreOptions as kn, WorkspaceOpenPullRequestOptions as kt, ListOptions as l, WorkspaceSourceRequestExecutionResult as ln, WorkspaceHookContext as lt, MemoryWorkspaceStoreOptions as m, WorkspaceSourceResolutionContextValueReader as mn, WorkspaceLoader as mt, DiffOptions as n, WorkspaceSourceMaterializationCounts as nn, WorkspaceHistoryFileInput as nt, GitHubWorkspaceRefs as o, WorkspaceSourceMountOptions as on, WorkspaceHistoryReader as ot, MaybePromise as p, WorkspaceSourceResolutionContextMap as pn, WorkspaceLastChange as pt, WorkspaceGlobSourceInput as q, WorkspaceSessionHostFiles as qt, ExecOptions as r, WorkspaceSourceMaterializationPathResult as rn, WorkspaceHistoryFilesCommitOptions as rt, GitHubWorkspaceStoreOptions as s, WorkspaceSourceRequestDescriptor as sn, WorkspaceHistoryRef as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceSourceItem as tn, WorkspaceHistoryFile as tt, LoaderContext as u, WorkspaceSourceRequestExecutor as un, WorkspaceHooks as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSourceSelection as vn, WorkspaceMaterializeSourcesOptions as vt, ValidatedWorkspaceName as w, WorkspaceSourceSyncStatus as wn, WorkspaceMergeConflictContext as wt, SnapshotOptions as x, WorkspaceSourceSyncPathResult as xn, WorkspaceMcpResourcesSourceInput as xt, ResolvedWorkspaceRule as y, WorkspaceSourceSyncConfig as yn, WorkspaceMaterializeSourcesProgressEvent as yt, WorkspaceDiff as z, WorkspaceWriteMode as zn, WorkspaceRules as zt };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { i as isWorkspaceError, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { g as getWorkspaceSourceRequestExecution, i as assertPublicWorkspaceMetaKey, m as attachWorkspaceSourceRequestExecution, t as createWorkspace } from "./workspace-
|
|
7
|
-
import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-
|
|
8
|
-
import {
|
|
2
|
+
import { c as normalizeSafeWorkspacePattern, d as sha256 } from "./path-BlIBpI7U.js";
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-Cth97txN.js";
|
|
4
|
+
import { f as normalizeHistoryRef, g as validateHistoryMessage, h as requireWorkspaceHistory, m as rejectHistoryHead, s as deleteWorkspaceHistoryRef, u as historyConflict } from "./utils-C0Au2R16.js";
|
|
5
|
+
import { a as provideWorkspaceStoreTarget, i as forwardWorkspaceStoreTarget, o as resolveWorkspaceStoreTarget } from "./vitehub-grants-C8IAl5-M.js";
|
|
6
|
+
import { g as getWorkspaceSourceRequestExecution, i as assertPublicWorkspaceMetaKey, m as attachWorkspaceSourceRequestExecution, t as createWorkspace } from "./workspace-CFrwWhEm.js";
|
|
7
|
+
import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-CR0aDtvS.js";
|
|
8
|
+
import { s as useRegisteredWorkspace } from "./registry-CedQvQxW.js";
|
|
9
9
|
import { n as useWorkspaceAssets } from "./asset-registry-DfBV5kmw.js";
|
|
10
|
-
import { t as createHostedWorkspaceSession } from "./host-
|
|
10
|
+
import { t as createHostedWorkspaceSession } from "./host-Dmr2Ctem.js";
|
|
11
11
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
12
12
|
import { posix } from "node:path";
|
|
13
13
|
//#region src/fs-ops.ts
|
|
@@ -178,11 +178,13 @@ function createLazyWorkspace(name, definition, options = {}) {
|
|
|
178
178
|
if (!history?.openPullRequest) throw workspaceError("[vitehub] This Workspace Store cannot open pull requests.");
|
|
179
179
|
return await history.openPullRequest(options);
|
|
180
180
|
},
|
|
181
|
+
deleteRef: async (options) => await deleteWorkspaceHistoryRef((await resolveWorkspace()).history, options),
|
|
181
182
|
head: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).head(options),
|
|
182
183
|
list: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).list(options),
|
|
183
184
|
refs: async () => await requireWorkspaceHistory(await resolveWorkspace()).refs(),
|
|
184
185
|
open: async (id) => await requireWorkspaceHistory(await resolveWorkspace()).open(id),
|
|
185
186
|
usage: async () => await requireWorkspaceHistory(await resolveWorkspace()).usage(),
|
|
187
|
+
diff: async (options) => await requireWorkspaceHistory(await resolveWorkspace()).diff(options),
|
|
186
188
|
commit: async (options) => {
|
|
187
189
|
const history = requireWorkspaceHistory(await resolveWorkspace());
|
|
188
190
|
validateHistoryMessage(options.message);
|
|
@@ -195,9 +197,6 @@ function createLazyWorkspace(name, definition, options = {}) {
|
|
|
195
197
|
async capabilities() {
|
|
196
198
|
return await (await resolveWorkspace()).capabilities?.() ?? { conditionalWrites: false };
|
|
197
199
|
},
|
|
198
|
-
async [workspaceStoreTarget]() {
|
|
199
|
-
return await (await resolveWorkspace())[workspaceStoreTarget]?.();
|
|
200
|
-
},
|
|
201
200
|
async sync(options) {
|
|
202
201
|
const resolved = await resolveWorkspace();
|
|
203
202
|
const sync = await workspaceDefinitionSyncState(resolved);
|
|
@@ -265,6 +264,7 @@ function createLazyWorkspace(name, definition, options = {}) {
|
|
|
265
264
|
return await (await resolveSyncedWorkspace()).startSession(options);
|
|
266
265
|
}
|
|
267
266
|
};
|
|
267
|
+
provideWorkspaceStoreTarget(workspace, async () => await resolveWorkspaceStoreTarget(await resolveWorkspace()));
|
|
268
268
|
attachWorkspaceMetadataTarget(workspace, async () => await resolveWorkspaceMetadataTarget(await resolveWorkspace()));
|
|
269
269
|
return attachWorkspaceSourceRequestExecution(workspace, { async executeSourceRequest(input) {
|
|
270
270
|
const resolved = await resolveSyncedWorkspace();
|
|
@@ -428,14 +428,12 @@ function createWorkspaceFileRuntime(name, options) {
|
|
|
428
428
|
if (options?.mode === "write") {
|
|
429
429
|
const workspace = createLazyWorkspace(name, options.definition);
|
|
430
430
|
const facade = {
|
|
431
|
-
[workspaceStoreTarget]: async () => {
|
|
432
|
-
return await workspace[workspaceStoreTarget]?.();
|
|
433
|
-
},
|
|
434
431
|
capabilities: async () => await workspace.capabilities(),
|
|
435
432
|
diff: async (options) => await workspace.diff(options),
|
|
436
433
|
fs: createWritableFs(name, workspace),
|
|
437
434
|
history: {
|
|
438
435
|
...workspace.history,
|
|
436
|
+
deleteRef: async (options) => await deleteWorkspaceHistoryRef(workspace.history, options),
|
|
439
437
|
checkpoint: async (options) => await workspace.snapshot({
|
|
440
438
|
name: options?.message,
|
|
441
439
|
...options?.author ? { author: options.author } : {}
|
|
@@ -450,6 +448,7 @@ function createWorkspaceFileRuntime(name, options) {
|
|
|
450
448
|
sync: async (options) => await workspace.sync(options)
|
|
451
449
|
};
|
|
452
450
|
forwardWorkspaceMetadataTarget(workspace, facade);
|
|
451
|
+
forwardWorkspaceStoreTarget(workspace, facade);
|
|
453
452
|
return {
|
|
454
453
|
mode: "write",
|
|
455
454
|
workspace,
|
|
@@ -465,7 +464,8 @@ function createWorkspaceFileRuntime(name, options) {
|
|
|
465
464
|
list: (options) => requireWorkspaceHistory(workspace).list(options),
|
|
466
465
|
refs: () => requireWorkspaceHistory(workspace).refs(),
|
|
467
466
|
open: (id) => requireWorkspaceHistory(workspace).open(id),
|
|
468
|
-
usage: () => requireWorkspaceHistory(workspace).usage()
|
|
467
|
+
usage: () => requireWorkspaceHistory(workspace).usage(),
|
|
468
|
+
diff: (options) => requireWorkspaceHistory(workspace).diff(options)
|
|
469
469
|
},
|
|
470
470
|
getMeta: async (key) => await workspace.getMeta?.(key)
|
|
471
471
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as WorkspaceHistoryDiffOptions, A as WorkspaceAuthor, Cn as WorkspaceSourceSyncResult, D as WorkspaceAssetPath, Dt as WorkspaceName, E as Workspace, Ft as WorkspaceRetainedHistory, Ht as WorkspaceSearchQuery, It as WorkspaceRevision, Jt as WorkspaceSessionOptions, L as WorkspaceDefinition, Lt as WorkspaceRevisionView, N as WorkspaceCapabilities, O as WorkspaceAssets, P as WorkspaceContent, Pt as WorkspaceRebaseOptions, Q as WorkspaceHistoryDeleteRefOptions, Tn as WorkspaceStat, Un as WriteFileOptions, V as WorkspaceEntry, Vt as WorkspaceSearchHit, Wt as WorkspaceSession, Xt as WorkspaceSnapshot, _ as ReadFileResult, at as WorkspaceHistoryListResult, b as RmOptions, bt as WorkspaceMaterializeSourcesResult, c as GlobOptions, ct as WorkspaceHistoryRefOptions, g as ReadFileOptions, gt as WorkspaceLookupName, h as MkdirOptions, it as WorkspaceHistoryListOptions, jn as WorkspaceSyncOptions, l as ListOptions, n as DiffOptions, ot as WorkspaceHistoryReader, st as WorkspaceHistoryRef, vt as WorkspaceMaterializeSourcesOptions, x as SnapshotOptions, z as WorkspaceDiff } from "./types-9DMtFjaa.js";
|
|
2
2
|
import { ExecutionBudget } from "@vite-hub/runtime";
|
|
3
3
|
import { Tool, ToolSet } from "ai";
|
|
4
4
|
//#region src/ai.d.ts
|
|
@@ -174,19 +174,8 @@ type WorkspaceTools<Operations = undefined, SourceRequests extends boolean = fal
|
|
|
174
174
|
type MaybePromise<T> = T | Promise<T>;
|
|
175
175
|
declare function createWorkspaceTools<Operations extends WorkspaceToolOperations | undefined = undefined, SourceRequests extends boolean = false>(input: Workspace | WorkspaceAssets, options?: WorkspaceToolOptions<Operations, SourceRequests>): WorkspaceTools<Operations, SourceRequests>;
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region src/storage/target.d.ts
|
|
178
|
-
declare const workspaceStoreTarget: unique symbol;
|
|
179
|
-
interface WorkspaceStoreTarget {
|
|
180
|
-
provider: string;
|
|
181
|
-
containsPath?(ancestor: string, path: string): Promise<boolean>;
|
|
182
|
-
}
|
|
183
|
-
type WorkspaceStoreTargetCarrier = {
|
|
184
|
-
[workspaceStoreTarget]?: () => Promise<WorkspaceStoreTarget | undefined> | WorkspaceStoreTarget | undefined;
|
|
185
|
-
};
|
|
186
|
-
declare function resolveWorkspaceStoreTarget(source: unknown): Promise<WorkspaceStoreTarget | undefined>;
|
|
187
|
-
//#endregion
|
|
188
177
|
//#region src/core/use.d.ts
|
|
189
|
-
type WorkspaceWritablePath<Name extends
|
|
178
|
+
type WorkspaceWritablePath<Name extends WorkspaceLookupName> = WorkspaceAssetPath<Name> | (string & {});
|
|
190
179
|
interface UseWorkspaceOptions {
|
|
191
180
|
definition?: WorkspaceDefinition;
|
|
192
181
|
mode?: "read" | "write";
|
|
@@ -227,7 +216,7 @@ type WorkspaceWriteToolSet = WorkspaceWriteTools & {
|
|
|
227
216
|
none: () => ToolSet;
|
|
228
217
|
write: <Options extends WritableWorkspaceFacadeToolOptions | undefined = undefined>(options?: Options) => WorkspaceWriteTools<Options>;
|
|
229
218
|
};
|
|
230
|
-
type ReadonlyWorkspaceFs<Name extends
|
|
219
|
+
type ReadonlyWorkspaceFs<Name extends WorkspaceLookupName = WorkspaceName> = WorkspaceAssets<WorkspaceAssetPath<Name>>;
|
|
231
220
|
interface HistoryCheckpoint {
|
|
232
221
|
createdAt: string;
|
|
233
222
|
id: string;
|
|
@@ -241,7 +230,7 @@ interface HistoryCheckpointOptions {
|
|
|
241
230
|
interface History<TCheckpoint extends HistoryCheckpoint = HistoryCheckpoint> {
|
|
242
231
|
checkpoint(options?: HistoryCheckpointOptions): Promise<TCheckpoint>;
|
|
243
232
|
}
|
|
244
|
-
interface WritableWorkspaceFs<Name extends
|
|
233
|
+
interface WritableWorkspaceFs<Name extends WorkspaceLookupName = WorkspaceName> {
|
|
245
234
|
readFile<TOptions extends ReadFileOptions | undefined = undefined>(path: WorkspaceWritablePath<Name>, options?: TOptions): Promise<ReadFileResult<TOptions>>;
|
|
246
235
|
writeFile(path: WorkspaceWritablePath<Name>, content: WorkspaceContent, options?: WriteFileOptions): Promise<string>;
|
|
247
236
|
appendFile(path: WorkspaceWritablePath<Name>, content: string): Promise<void>;
|
|
@@ -259,18 +248,20 @@ interface WritableWorkspaceFs<Name extends WorkspaceName = WorkspaceName> {
|
|
|
259
248
|
overwrite?: boolean;
|
|
260
249
|
}): Promise<void>;
|
|
261
250
|
}
|
|
262
|
-
interface ReadonlyWorkspaceFiles<Name extends
|
|
251
|
+
interface ReadonlyWorkspaceFiles<Name extends WorkspaceLookupName = WorkspaceName> {
|
|
263
252
|
fs: ReadonlyWorkspaceFs<Name>;
|
|
264
|
-
history: WorkspaceHistoryReader
|
|
253
|
+
history: WorkspaceHistoryReader & Pick<WorkspaceRetainedHistory, "diff">;
|
|
265
254
|
getMeta?(key: string): Promise<unknown>;
|
|
266
255
|
}
|
|
267
|
-
interface ReadonlyWorkspaceFacade<Name extends
|
|
256
|
+
interface ReadonlyWorkspaceFacade<Name extends WorkspaceLookupName = WorkspaceName> extends ReadonlyWorkspaceFiles<Name> {
|
|
268
257
|
tools: WorkspaceReadToolSet;
|
|
269
258
|
}
|
|
270
259
|
interface WorkspaceHistory extends History<WorkspaceSnapshot>, WorkspaceRetainedHistory {
|
|
260
|
+
/** Throws `WORKSPACE_R0069` when the Store cannot delete refs. */
|
|
261
|
+
deleteRef(options: WorkspaceHistoryDeleteRefOptions): Promise<boolean>;
|
|
271
262
|
rebase(options?: WorkspaceRebaseOptions): Promise<void>;
|
|
272
263
|
}
|
|
273
|
-
interface WritableWorkspaceFiles<Name extends
|
|
264
|
+
interface WritableWorkspaceFiles<Name extends WorkspaceLookupName = WorkspaceName> {
|
|
274
265
|
capabilities(): Promise<WorkspaceCapabilities>;
|
|
275
266
|
diff(options?: DiffOptions): Promise<WorkspaceDiff>;
|
|
276
267
|
fs: WritableWorkspaceFs<Name>;
|
|
@@ -282,15 +273,15 @@ interface WritableWorkspaceFiles<Name extends WorkspaceName = WorkspaceName> {
|
|
|
282
273
|
startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
|
|
283
274
|
sync(options: WorkspaceSyncOptions): Promise<WorkspaceSourceSyncResult>;
|
|
284
275
|
}
|
|
285
|
-
interface WritableWorkspaceFacade<Name extends
|
|
276
|
+
interface WritableWorkspaceFacade<Name extends WorkspaceLookupName = WorkspaceName> extends WritableWorkspaceFiles<Name> {
|
|
286
277
|
tools: WorkspaceWriteToolSet;
|
|
287
278
|
}
|
|
288
|
-
type WorkspaceFacade<Name extends
|
|
289
|
-
declare function createReadonlyFs<Name extends
|
|
290
|
-
declare function createWorkspaceFileRuntime<Name extends
|
|
279
|
+
type WorkspaceFacade<Name extends WorkspaceLookupName = WorkspaceName, Mode extends UseWorkspaceOptions["mode"] = "read"> = Mode extends "write" ? WritableWorkspaceFacade<Name> : ReadonlyWorkspaceFacade<Name>;
|
|
280
|
+
declare function createReadonlyFs<Name extends WorkspaceLookupName>(name: Name, workspace: Workspace): ReadonlyWorkspaceFs<Name>;
|
|
281
|
+
declare function createWorkspaceFileRuntime<Name extends WorkspaceLookupName>(name: Name, options?: UseWorkspaceOptions): {
|
|
291
282
|
mode: "write";
|
|
292
283
|
workspace: Workspace;
|
|
293
|
-
facade: WritableWorkspaceFiles<Name
|
|
284
|
+
facade: WritableWorkspaceFiles<Name>;
|
|
294
285
|
} | {
|
|
295
286
|
mode: "read";
|
|
296
287
|
workspace: Workspace;
|
|
@@ -305,17 +296,18 @@ declare function createWorkspaceFileRuntime<Name extends WorkspaceName>(name: Na
|
|
|
305
296
|
bytes: number;
|
|
306
297
|
objects: number;
|
|
307
298
|
}>;
|
|
299
|
+
diff: (options: WorkspaceHistoryDiffOptions) => Promise<WorkspaceDiff>;
|
|
308
300
|
};
|
|
309
301
|
getMeta: (key: string) => Promise<unknown>;
|
|
310
302
|
};
|
|
311
303
|
};
|
|
312
304
|
/** File and history access without constructing Agent tools or bundling a shell. */
|
|
313
|
-
declare function useWorkspaceFiles<Name extends
|
|
314
|
-
declare function useWorkspaceFiles<Name extends
|
|
305
|
+
declare function useWorkspaceFiles<Name extends WorkspaceLookupName>(name: Name): ReadonlyWorkspaceFiles<Name>;
|
|
306
|
+
declare function useWorkspaceFiles<Name extends WorkspaceLookupName>(name: Name, options: UseWorkspaceOptions & {
|
|
315
307
|
mode?: "read";
|
|
316
308
|
}): ReadonlyWorkspaceFiles<Name>;
|
|
317
|
-
declare function useWorkspaceFiles<Name extends
|
|
309
|
+
declare function useWorkspaceFiles<Name extends WorkspaceLookupName>(name: Name, options: UseWorkspaceOptions & {
|
|
318
310
|
mode: "write";
|
|
319
311
|
}): WritableWorkspaceFiles<Name>;
|
|
320
312
|
//#endregion
|
|
321
|
-
export {
|
|
313
|
+
export { WorkspaceTools as A, ShellEnabled as C, WorkspaceShellResult as D, WorkspaceReadOperations as E, WorkspaceWriteToolMap as M, createWorkspaceTools as N, WorkspaceToolOperations as O, EnabledReadCapability as S, WorkspacePathResult as T, WritableWorkspaceFiles as _, ReadonlyWorkspaceFiles as a, createWorkspaceFileRuntime as b, WorkspaceFacade as c, WorkspaceReadToolSet as d, WorkspaceReadTools as f, WritableWorkspaceFacadeToolOptions as g, WritableWorkspaceFacade as h, ReadonlyWorkspaceFacade as i, WorkspaceWriteOperations as j, WorkspaceToolOptions as k, WorkspaceFacadeToolOptions as l, WorkspaceWriteTools as m, HistoryCheckpoint as n, ReadonlyWorkspaceFs as o, WorkspaceWriteToolSet as p, HistoryCheckpointOptions as r, UseWorkspaceOptions as s, History as t, WorkspaceHistory as u, WritableWorkspaceFs as v, WorkspaceMoveResult as w, useWorkspaceFiles as x, createReadonlyFs as y };
|