@vite-hub/workspace 0.3.1 → 0.4.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 +17 -13
- package/dist/blob-database.d.ts +1 -1
- package/dist/blob-database.js +6 -6
- package/dist/checkout.js +1 -1
- package/dist/cloudflare.d.ts +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/{config-BQKcPawI.d.ts → config-CDeGd0RB.d.ts} +1 -1
- package/dist/{config-BAgL2dtB.js → config-D1QENneP.js} +21 -21
- package/dist/durability.d.ts +1 -1
- package/dist/durability.js +2 -2
- package/dist/{error-diagnostics-CtKjGtGb.js → error-diagnostics-B5s9kNEA.js} +10 -6
- package/dist/{error-diagnostics-DSkCJC_L.js → error-diagnostics-CQ4BUqRe.js} +5 -1
- package/dist/{file-2pFYNtsU.js → file-CqG9zqiF.js} +1 -1
- package/dist/{files-BOo4SbwE.js → files-B6wpAhEx.js} +1 -1
- package/dist/files.d.ts +5 -5
- package/dist/files.js +4 -4
- package/dist/{github-CrYp4v8k.js → github-DKAlO0Vh.js} +3 -3
- package/dist/{glob-B8YGvTrZ.js → glob-BOqSKzSg.js} +1 -1
- package/dist/{host-BFBpXn0N.js → host-Bf1a2uo_.js} +4 -4
- package/dist/{hosted-vercel-blob-B3-wRdUm.js → hosted-vercel-blob-AbXG8fvR.js} +3 -3
- package/dist/hosted-vercel-blob.d.ts +1 -1
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/{hosted-KcUR_jPv.js → hosted-zG7HJaE4.js} +6 -6
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +15 -15
- package/dist/{lifecycle-B-enk_4A.js → lifecycle-D8FdpBod.js} +4 -4
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/{mcp-resources-DF0F5rcL.js → mcp-resources-DntxtmDU.js} +1 -1
- package/dist/{memory-BOexthyW.js → memory-D5jq9HZW.js} +1 -1
- package/dist/{metadata-target-CWz6KHKq.js → metadata-target-DDoOQNp1.js} +3 -3
- package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-nmRu_O3V.d.ts} +5 -0
- package/dist/{operations-C6FpR8Rr.js → operations-D8uCpzhM.js} +4 -4
- package/dist/{operations-CE2drFih.js → operations-DsY2MQnG.js} +207 -141
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +1 -1
- package/dist/{path-AxMho1wo.d.ts → path-uxLkzrZm.d.ts} +1 -1
- package/dist/{plugins-C8C0auoW.d.ts → plugins-CsrXCA1Q.d.ts} +1 -1
- package/dist/{provider-9s4Ufkm5.js → provider-sm9uzkLg.js} +7 -6
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/{registry-B3BBm4Ts.d.ts → registry-CFl1Htyc.d.ts} +1 -1
- package/dist/{registry-CYNN623b.d.ts → registry-CwryP59t.d.ts} +2 -2
- package/dist/{registry-CNphafBx.js → registry-DmVfUe4K.js} +2 -2
- package/dist/runtime/assets.d.ts +1 -1
- 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 +1 -1
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +6 -6
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +7 -7
- package/dist/runtime.js +13 -13
- package/dist/{server-8tGltlGz.js → server-Cd4-iCh5.js} +4 -4
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{shared-B3_EUk89.js → shared-ovXVSV3-.js} +9 -5
- package/dist/source-metadata.d.ts +2 -2
- package/dist/source-metadata.js +3 -3
- package/dist/{state-BISnUf1s.d.ts → state-C-YtsaiJ.d.ts} +4 -4
- package/dist/{state-DbrW-njQ.js → state-Cb_hIyAw.js} +4 -4
- package/dist/{store-ybhyD38Z.js → store-NZoRto-Y.js} +107 -7
- package/dist/{sync-CCD_VYC8.js → sync-CrT8zjwc.js} +3 -3
- package/dist/{target-jWhTdIuF.js → target-Dm9dHAVJ.js} +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-BbtwmBZ5.d.ts → types-1Z-tKK3g.d.ts} +17 -2
- package/dist/{use-CSpT5W87.js → use-B0o5HoBl.js} +8 -8
- package/dist/{use-C6lV3-wC.d.ts → use-CjbF8EO9.d.ts} +1 -1
- package/dist/{utils-CgMZCHsX.js → utils-Dw-WULEZ.js} +10 -4
- package/dist/vite.d.ts +4 -2
- package/dist/vite.js +559 -354
- package/dist/{workspace-CYB2xZ1T.d.ts → workspace-CIXgHeyX.d.ts} +1 -1
- package/dist/{workspace-sPWn2Jxj.js → workspace-DvKu5PRa.js} +12 -12
- package/package.json +14 -14
package/dist/runtime.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { t as createMemoryWorkspaceStore } from "./memory-
|
|
1
|
+
import { t as createMemoryWorkspaceStore } from "./memory-D5jq9HZW.js";
|
|
2
2
|
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
3
|
-
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-
|
|
3
|
+
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-Dm9dHAVJ.js";
|
|
4
4
|
import { l as normalizeWorkspacePath } from "./path--wrT_Azm.js";
|
|
5
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
6
|
-
import { a as createWorkspaceHistoryReader, c as forwardWorkspaceHistoryMerge,
|
|
5
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
6
|
+
import { _ as registerWorkspacePlugin, a as createWorkspaceHistoryReader, c as forwardWorkspaceHistoryMerge, h as createWorkspaceWritePolicy, i as createWorkspaceHistory, s as forwardWorkspaceHistoryFiles } from "./utils-Dw-WULEZ.js";
|
|
7
7
|
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
8
|
-
import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "./provider-
|
|
8
|
+
import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "./provider-sm9uzkLg.js";
|
|
9
9
|
import { n as setWorkspaceRuntimeConfig, t as getWorkspaceRuntimeConfig } from "./config-B-863EgC.js";
|
|
10
|
-
import { _ as workspaceSourceRequestMatches, a as isInternalWorkspaceMetaKey, c as isWorkspaceSourceSyncMetaKey, g as getWorkspaceSourceRequestExecution, h as createWorkspaceSourceRequestExecution, m as attachWorkspaceSourceRequestExecution, o as createWorkspaceSourceView, p as resolveWorkspacePath, r as resetWorkspaceStoreCache, v as createBasicWorkspaceSession } from "./workspace-
|
|
11
|
-
import { _ as isWorkspaceSourceRequestOnly, a as normalizeWorkspaceSources, b as markLiveWorkspaceSource, f as prepareWorkspaceSource, h as getWorkspaceSourceRequestDescriptor, i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata, r as normalizeWorkspaceSource, t as copyWorkspaceSourceMetadata, u as ownSourceOption, v as workspaceSourceRequestDescriptorPath } from "./config-
|
|
12
|
-
import { M as registerWorkspaceStoreAlias, a as resolveWorkspaceMetadataMutationTarget, i as forwardWorkspaceMetadataView, n as createWorkspaceMetadataTarget, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, s as setWorkspaceMetadata, t as attachWorkspaceMetadataTarget } from "./metadata-target-
|
|
13
|
-
import { a as setWorkspaceRuntimeDefinitions, n as registerWorkspace, r as resolveRegisteredWorkspaceDefinition } from "./registry-
|
|
14
|
-
import { a as copyWorkspacePath, i as appendWorkspaceFile, r as useWorkspaceFiles } from "./use-
|
|
15
|
-
import { a as createWorkspaceTools, i as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, o as getWorkspaceDependencyRuntimeLoaders, r as setWorkspaceRuntimeRegistry, s as setWorkspaceDependencyRuntimeLoaders, t as invalidateWorkspaceStore } from "./state-
|
|
10
|
+
import { _ as workspaceSourceRequestMatches, a as isInternalWorkspaceMetaKey, c as isWorkspaceSourceSyncMetaKey, g as getWorkspaceSourceRequestExecution, h as createWorkspaceSourceRequestExecution, m as attachWorkspaceSourceRequestExecution, o as createWorkspaceSourceView, p as resolveWorkspacePath, r as resetWorkspaceStoreCache, v as createBasicWorkspaceSession } from "./workspace-DvKu5PRa.js";
|
|
11
|
+
import { _ as isWorkspaceSourceRequestOnly, a as normalizeWorkspaceSources, b as markLiveWorkspaceSource, f as prepareWorkspaceSource, h as getWorkspaceSourceRequestDescriptor, i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata, r as normalizeWorkspaceSource, t as copyWorkspaceSourceMetadata, u as ownSourceOption, v as workspaceSourceRequestDescriptorPath } from "./config-D1QENneP.js";
|
|
12
|
+
import { M as registerWorkspaceStoreAlias, a as resolveWorkspaceMetadataMutationTarget, i as forwardWorkspaceMetadataView, n as createWorkspaceMetadataTarget, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, s as setWorkspaceMetadata, t as attachWorkspaceMetadataTarget } from "./metadata-target-DDoOQNp1.js";
|
|
13
|
+
import { a as setWorkspaceRuntimeDefinitions, n as registerWorkspace, r as resolveRegisteredWorkspaceDefinition } from "./registry-DmVfUe4K.js";
|
|
14
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, r as useWorkspaceFiles } from "./use-B0o5HoBl.js";
|
|
15
|
+
import { a as createWorkspaceTools, i as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, o as getWorkspaceDependencyRuntimeLoaders, r as setWorkspaceRuntimeRegistry, s as setWorkspaceDependencyRuntimeLoaders, t as invalidateWorkspaceStore } from "./state-Cb_hIyAw.js";
|
|
16
16
|
import { join, resolve } from "node:path";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
18
|
import { lstat, readdir, rename, rm } from "node:fs/promises";
|
|
@@ -284,7 +284,7 @@ function createWritableFacadeStore(workspace, sourceSync) {
|
|
|
284
284
|
async function startOverlayWorkspaceSession(_definition, workspace, options) {
|
|
285
285
|
const host = options?.host;
|
|
286
286
|
if (host) {
|
|
287
|
-
const { createHostedWorkspaceSession } = await import("./host-
|
|
287
|
+
const { createHostedWorkspaceSession } = await import("./host-Bf1a2uo_.js").then((n) => n.n);
|
|
288
288
|
return await createHostedWorkspaceSession(workspace, {
|
|
289
289
|
...options,
|
|
290
290
|
host
|
|
@@ -549,7 +549,7 @@ async function createWorkspaceSourceResolutionFacade(workspace, definition, opti
|
|
|
549
549
|
},
|
|
550
550
|
stat: writeFs.stat,
|
|
551
551
|
sync: async (options) => {
|
|
552
|
-
const { syncWorkspaceSources } = await import("./sync-
|
|
552
|
+
const { syncWorkspaceSources } = await import("./sync-CrT8zjwc.js");
|
|
553
553
|
return await syncWorkspaceSources(resolvedDefinition, syncStore, options);
|
|
554
554
|
},
|
|
555
555
|
writeFile: writeFs.writeFile
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
2
|
import { s as matchesAny } from "./path--wrT_Azm.js";
|
|
3
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import {
|
|
5
|
-
import { r as useWorkspaceFiles } from "./use-
|
|
6
|
-
import { r as withWorkspaceProgress } from "./host-
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
4
|
+
import { g as resolveWorkspaceAutoCommit, v as workspaceDefinitionPlugins } from "./utils-Dw-WULEZ.js";
|
|
5
|
+
import { r as useWorkspaceFiles } from "./use-B0o5HoBl.js";
|
|
6
|
+
import { r as withWorkspaceProgress } from "./host-Bf1a2uo_.js";
|
|
7
7
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
8
8
|
import { lookup } from "mrmime";
|
|
9
9
|
//#region ../internal/src/secret.ts
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bt as
|
|
2
|
-
import { _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles } from "./use-
|
|
1
|
+
import { Bt as WorkspaceSession, Ct as WorkspaceName, I as WorkspaceDefinition, Ot as WorkspacePrepareSessionProgressEvent, Vt as WorkspaceSessionHost, Wt as WorkspaceSessionOptions, i as ExecResult } from "./types-1Z-tKK3g.js";
|
|
2
|
+
import { _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles } from "./use-CjbF8EO9.js";
|
|
3
3
|
//#region src/server.d.ts
|
|
4
4
|
export declare const workspaceDevRoute = "/__vitehub/workspace/dev";
|
|
5
5
|
export declare const workspaceDevHeader = "x-vitehub-workspace-dev";
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, i as readWorkspaceFileResponse, l as workspaceDevHeaderValue, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, t as defineWorkspaceFileHandler, u as workspaceDevRoute } from "./server-
|
|
1
|
+
import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, i as readWorkspaceFileResponse, l as workspaceDevHeaderValue, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, t as defineWorkspaceFileHandler, u as workspaceDevRoute } from "./server-Cd4-iCh5.js";
|
|
2
2
|
export { defineWorkspaceFileHandler, ensureWorkspaceDevToken, readWorkspaceDevToken, readWorkspaceFileResponse, refreshWorkspaceDevToken, runWorkspaceDevCommand, validateWorkspaceDevToken, workspaceDevHeader, workspaceDevHeaderValue, workspaceDevRoute, workspaceDevTokenHeader, workspaceDevTokenServerId };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as workspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
2
|
import { l as normalizeWorkspacePath } from "./path--wrT_Azm.js";
|
|
3
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import { t as internalErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
4
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-CQ4BUqRe.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";
|
|
@@ -576,7 +576,7 @@ function readGitHubEnvToken(env = typeof process !== "undefined" ? process.env :
|
|
|
576
576
|
return readForgeEnv(forgeEnv.github.token, env);
|
|
577
577
|
}
|
|
578
578
|
function requireGitHubOption(label, value) {
|
|
579
|
-
if (!value) throw workspaceErrorDiagnostics.WORKSPACE_R0072({ message: `[vitehub] GitHub workspace store requires ${label}.${label === "a token" ? " Set VITEHUB_GITHUB_TOKEN, the token option, or a GitHub App with VITEHUB_GITHUB_APP_ID and VITEHUB_GITHUB_PRIVATE_KEY." : label === "a repository" ? " Set the
|
|
579
|
+
if (!value) throw workspaceErrorDiagnostics.WORKSPACE_R0072({ message: `[vitehub] GitHub workspace store requires ${label}.${label === "a token" ? " Set VITEHUB_GITHUB_TOKEN, the token option, or a GitHub App with VITEHUB_GITHUB_APP_ID and VITEHUB_GITHUB_PRIVATE_KEY." : label === "a repository" ? " Set the repo option or VITEHUB_WORKSPACE_GITHUB_REPOSITORY." : ""}` });
|
|
580
580
|
return value;
|
|
581
581
|
}
|
|
582
582
|
function splitGitHubRepository(repository) {
|
|
@@ -619,8 +619,12 @@ async function gitBlobSha(bytes) {
|
|
|
619
619
|
function gitFileMode(value) {
|
|
620
620
|
return value === "120000" || value === "100755" ? value : "100644";
|
|
621
621
|
}
|
|
622
|
+
/** Fails when a GitHub store sets the renamed `repository` key, which the store would not read. */
|
|
623
|
+
function assertNoGitHubRepositoryKey(options) {
|
|
624
|
+
if (Object.hasOwn(options, "repository")) throw workspaceErrorDiagnostics.WORKSPACE_RENAMED_STORE_REPOSITORY_KEY();
|
|
625
|
+
}
|
|
622
626
|
function resolveGitHubRepositoryOption(options, env = typeof process !== "undefined" ? process.env : {}) {
|
|
623
|
-
return resolveGitHubOption(options.
|
|
627
|
+
return resolveGitHubOption(options.repo) || readLocationEnv("VITEHUB_WORKSPACE_GITHUB_REPOSITORY", env);
|
|
624
628
|
}
|
|
625
629
|
function resolveGitHubBranchOption(options, env = typeof process !== "undefined" ? process.env : {}) {
|
|
626
630
|
return resolveGitHubOption(options.branch) || readLocationEnv("VITEHUB_WORKSPACE_GITHUB_BRANCH", env) || "main";
|
|
@@ -845,4 +849,4 @@ async function commitGitHubChanges(input) {
|
|
|
845
849
|
}
|
|
846
850
|
}
|
|
847
851
|
//#endregion
|
|
848
|
-
export {
|
|
852
|
+
export { setActiveCloudflareEnv as A, githubKVKey as C, writeWorkspaceKV as D, registerWorkspaceKV as E, readForgeEnv as M, BoundedMap as O, resolveGitHubRootOption as S, readWorkspaceKV as T, requireGitHubOption as _, gitFileMode as a, resolveGitHubRefsOption as b, githubRequestStatus as c, preloadGitHubFiles as d, readCurrentHead as f, readGitHubFile as g, readGitHubEnvToken as h, gitBlobSha as i, forgeEnv as j, getActiveCloudflareBinding as k, joinGitPath as l, readGitHubBranchState as m, commitGitHubChanges as n, githubBranchMovedConflict as o, readGitHubArchive as p, connectGitHubRepository as r, githubRequest as s, assertNoGitHubRepositoryKey as t, loadForge as u, resolveGitHubBranchOption as v, readGitHubReadStats as w, resolveGitHubRepositoryOption as x, resolveGitHubCredential as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-
|
|
1
|
+
import { B as WorkspaceEntry, Ft as WorkspaceRules, en as WorkspaceSourceMaterializationStatus } from "./types-1Z-tKK3g.js";
|
|
2
|
+
import { i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, r as normalizeWorkspaceSourcesMetadata, t as WorkspaceSourceMetadata } from "./config-CDeGd0RB.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 { i as assertWorkspaceRules } from "./target-
|
|
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 { i as assertWorkspaceRules } from "./target-Dm9dHAVJ.js";
|
|
2
|
+
import { i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata } from "./config-D1QENneP.js";
|
|
3
|
+
import { m as readCurrentSourceSnapshot, o as resolveWorkspaceMetadataTarget } from "./metadata-target-DDoOQNp1.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,7 +1,7 @@
|
|
|
1
|
-
import { O as WorkspaceAssetsRegistry,
|
|
2
|
-
import { h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions } from "./use-
|
|
3
|
-
import { t as WorkspaceRegistry } from "./registry-
|
|
4
|
-
import "./registry-
|
|
1
|
+
import { Ct as WorkspaceName, O as WorkspaceAssetsRegistry, Sn as WorkspaceStore, s as GitHubWorkspaceStoreOptions, t as CloudflareArtifactsWorkspaceStoreOptions, w as VercelBlobWorkspaceStoreOptions } from "./types-1Z-tKK3g.js";
|
|
2
|
+
import { h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions } from "./use-CjbF8EO9.js";
|
|
3
|
+
import { t as WorkspaceRegistry } from "./registry-CFl1Htyc.js";
|
|
4
|
+
import "./registry-CwryP59t.js";
|
|
5
5
|
//#region ../internal/src/runtime/cloudflare-env-lookup.d.ts
|
|
6
6
|
type CloudflareWorkerEnv = Record<string, unknown>;
|
|
7
7
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
-
import { g as getWorkspaceSourceRequestExecution, n as invalidateCachedWorkspaceStore } from "./workspace-
|
|
4
|
-
import { i as setWorkspaceRegistry, r as resolveRegisteredWorkspaceDefinition } from "./registry-
|
|
2
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
3
|
+
import { g as getWorkspaceSourceRequestExecution, n as invalidateCachedWorkspaceStore } from "./workspace-DvKu5PRa.js";
|
|
4
|
+
import { i as setWorkspaceRegistry, r as resolveRegisteredWorkspaceDefinition } from "./registry-DmVfUe4K.js";
|
|
5
5
|
import { t as setWorkspaceAssetsRegistry } from "./asset-registry-DfBV5kmw.js";
|
|
6
|
-
import { a as copyWorkspacePath, i as appendWorkspaceFile, n as createWorkspaceFileRuntime, t as createReadonlyFs } from "./use-
|
|
6
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, n as createWorkspaceFileRuntime, t as createReadonlyFs } from "./use-B0o5HoBl.js";
|
|
7
7
|
import { executionBudgetCharged, executionBudgetOverride, markExecutionBudgetHandled } from "@vite-hub/runtime/internal/execution-budget";
|
|
8
8
|
//#region src/runtime/dependency-loaders.ts
|
|
9
9
|
const shellWorkspaceSpecifier = "@vite-hub/shell/workspace";
|
|
@@ -1,10 +1,10 @@
|
|
|
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 workspaceStoreTarget } from "./target-
|
|
2
|
+
import { r as workspaceStoreTarget } from "./target-Dm9dHAVJ.js";
|
|
3
3
|
import { a as isExcludedWorkspacePath, c as normalizeSafeWorkspacePattern, i as decodeFile, l as normalizeWorkspacePath, n as contentStreamToBytes, r as contentToBytes } from "./path--wrT_Azm.js";
|
|
4
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
5
|
-
import { d as normalizeHistoryRef, l as historyConflict, n as createSnapshotFromEntries, r as diffSnapshots, u as normalizeHistoryPath } from "./utils-
|
|
4
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
5
|
+
import { d as normalizeHistoryRef, f as rejectHistoryHead, l as historyConflict, n as createSnapshotFromEntries, r as diffSnapshots, u as normalizeHistoryPath } from "./utils-Dw-WULEZ.js";
|
|
6
6
|
import { t as createWorkspaceGlobMatcher } from "./glob-Cjxms1t7.js";
|
|
7
|
-
import { _ as
|
|
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-ovXVSV3-.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";
|
|
@@ -163,6 +163,20 @@ const reservedTrailerPattern = /^Vitehub-Metadata:/m;
|
|
|
163
163
|
/** The most bytes of commit metadata as JSON, and of a commit message, that the Store writes. */
|
|
164
164
|
const githubMaxMetadataBytes = 65536;
|
|
165
165
|
const githubMaxMessageBytes = 16384;
|
|
166
|
+
/** Paths per GitHub file history request. */
|
|
167
|
+
const lastChangedBatch = 100;
|
|
168
|
+
const lastChangedHistoryLimit = 100;
|
|
169
|
+
const pathHistory = v.object({ nodes: v.array(v.object({
|
|
170
|
+
oid: v.string(),
|
|
171
|
+
authoredDate: v.string()
|
|
172
|
+
})) });
|
|
173
|
+
const fileHistoryResponse = v.object({
|
|
174
|
+
data: v.optional(v.nullable(v.object({ repository: v.nullable(v.object({ object: v.nullable(v.looseObject({ recent: v.object({ nodes: v.array(v.object({
|
|
175
|
+
oid: v.string(),
|
|
176
|
+
parents: v.object({ nodes: v.array(v.object({ oid: v.string() })) })
|
|
177
|
+
})) }) })) })) }))),
|
|
178
|
+
errors: v.optional(v.array(v.object({ message: v.string() })))
|
|
179
|
+
});
|
|
166
180
|
function nonEmptyString(value) {
|
|
167
181
|
return typeof value === "string" && value.length > 0;
|
|
168
182
|
}
|
|
@@ -381,6 +395,7 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
381
395
|
const commitCache = new BoundedMap(2e3);
|
|
382
396
|
const treeCache = new BoundedMap(32);
|
|
383
397
|
const commitRefs = new BoundedMap(2e3);
|
|
398
|
+
const lastChanges = new BoundedMap(32);
|
|
384
399
|
const readCommit = async (id) => {
|
|
385
400
|
const cached = commitCache.get(id);
|
|
386
401
|
if (cached) return cached;
|
|
@@ -572,7 +587,8 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
572
587
|
const heads = branches.filter((branch) => branch.commit === id);
|
|
573
588
|
let branch = heads.find((branch) => branch.name === options.branch) ?? heads[0];
|
|
574
589
|
if (!branch) {
|
|
575
|
-
const
|
|
590
|
+
const rank = (name) => name === options.branch ? 0 : name === options.refs?.published || name === options.refs?.draft ? 1 : 2;
|
|
591
|
+
const ordered = [...branches].sort((left, right) => rank(left.name) - rank(right.name));
|
|
576
592
|
for (const candidate of ordered) if (await githubRequest(client(), async (provider, repo) => {
|
|
577
593
|
try {
|
|
578
594
|
const compare = (await provider.request("GET", `${repoPath(repo)}/compare/${encodeURIComponent(candidate.commit)}...${encodeURIComponent(id)}`, { query: { per_page: 1 } })).data;
|
|
@@ -590,6 +606,76 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
590
606
|
commitRefs.set(id, ref);
|
|
591
607
|
return ref;
|
|
592
608
|
};
|
|
609
|
+
/**
|
|
610
|
+
* GitHub can simplify path history through a merge's side parent. Trust only the linear prefix from `sha` and
|
|
611
|
+
* cache only proven answers. Each request checks at most 100 paths.
|
|
612
|
+
*/
|
|
613
|
+
const lastChanged = async (sha, gitPaths) => {
|
|
614
|
+
const cacheKey = await githubKVKey(options.repository, `first-parent-last-changed:${sha}`);
|
|
615
|
+
let known = lastChanges.get(sha);
|
|
616
|
+
if (!known) {
|
|
617
|
+
known = new Map(Object.entries(await readWorkspaceKV(cacheKey) ?? {}));
|
|
618
|
+
lastChanges.set(sha, known);
|
|
619
|
+
}
|
|
620
|
+
const missing = [...new Set(gitPaths)].filter((path) => !known.has(path));
|
|
621
|
+
let changed = false;
|
|
622
|
+
for (let start = 0; start < missing.length; start += lastChangedBatch) {
|
|
623
|
+
const paths = missing.slice(start, start + lastChangedBatch);
|
|
624
|
+
const query = [
|
|
625
|
+
`query FileHistory($owner: String!, $name: String!, $sha: GitObjectID!${paths.map((_, index) => `, $p${index}: String!`).join("")}) {`,
|
|
626
|
+
" repository(owner: $owner, name: $name) { object(oid: $sha) { ... on Commit {",
|
|
627
|
+
` recent: history(first: ${lastChangedHistoryLimit}) { nodes { oid parents(first: 2) { nodes { oid } } } }`,
|
|
628
|
+
...paths.map((_, index) => ` p${index}: history(first: 1, path: $p${index}) { nodes { oid authoredDate } }`),
|
|
629
|
+
" } } }",
|
|
630
|
+
"}"
|
|
631
|
+
].join("\n");
|
|
632
|
+
const response = await githubRequest(client(), async (provider, repo) => (await provider.request("POST", "/graphql", {
|
|
633
|
+
body: {
|
|
634
|
+
query,
|
|
635
|
+
operationName: "FileHistory",
|
|
636
|
+
variables: {
|
|
637
|
+
owner: repo.owner,
|
|
638
|
+
name: repo.name,
|
|
639
|
+
sha,
|
|
640
|
+
...Object.fromEntries(paths.map((path, index) => [`p${index}`, path]))
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
mutates: false
|
|
644
|
+
})).data, "file history");
|
|
645
|
+
const parsed = v.safeParse(fileHistoryResponse, response);
|
|
646
|
+
if (!parsed.success || parsed.output.errors?.length || !parsed.output.data?.repository?.object) throw workspaceError(`[vitehub] GitHub workspace file history request failed for ${options.repository}${parsed.success && parsed.output.errors?.length ? `: ${parsed.output.errors.map((error) => error.message).join("; ")}` : "."}`);
|
|
647
|
+
const commit = parsed.output.data.repository.object;
|
|
648
|
+
const linear = /* @__PURE__ */ new Set();
|
|
649
|
+
let next = sha;
|
|
650
|
+
let reachedRoot = false;
|
|
651
|
+
for (const node of commit.recent.nodes) {
|
|
652
|
+
if (node.oid !== next || node.parents.nodes.length > 1) break;
|
|
653
|
+
linear.add(node.oid);
|
|
654
|
+
next = node.parents.nodes[0]?.oid;
|
|
655
|
+
if (!next) {
|
|
656
|
+
reachedRoot = true;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
paths.forEach((path, index) => {
|
|
661
|
+
const history = v.safeParse(pathHistory, commit[`p${index}`]);
|
|
662
|
+
if (!history.success) return;
|
|
663
|
+
const node = history.output.nodes[0];
|
|
664
|
+
if (node && linear.has(node.oid)) {
|
|
665
|
+
known.set(path, {
|
|
666
|
+
id: node.oid,
|
|
667
|
+
createdAt: new Date(node.authoredDate).toISOString()
|
|
668
|
+
});
|
|
669
|
+
changed = true;
|
|
670
|
+
} else if (!node && reachedRoot) {
|
|
671
|
+
known.set(path, null);
|
|
672
|
+
changed = true;
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (changed) await writeWorkspaceKV(cacheKey, Object.fromEntries(known));
|
|
677
|
+
return known;
|
|
678
|
+
};
|
|
593
679
|
const open = async (id) => {
|
|
594
680
|
if (!nonEmptyString(id)) throw workspaceError("[vitehub] Workspace revision id must be a non-empty string.");
|
|
595
681
|
let commit;
|
|
@@ -666,6 +752,16 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
666
752
|
}] : [];
|
|
667
753
|
});
|
|
668
754
|
await preloadGitHubFiles(client(), commit.sha, entries);
|
|
755
|
+
},
|
|
756
|
+
lastChanged: async (paths) => {
|
|
757
|
+
const gitPaths = paths.map((path) => [path, joinGitPath(options.root, normalizeHistoryPath(path))]);
|
|
758
|
+
const changes = await lastChanged(commit.sha, gitPaths.map(([, gitPath]) => gitPath));
|
|
759
|
+
const found = /* @__PURE__ */ new Map();
|
|
760
|
+
for (const [path, gitPath] of gitPaths) {
|
|
761
|
+
const change = changes.get(gitPath);
|
|
762
|
+
if (change !== void 0) found.set(path, change);
|
|
763
|
+
}
|
|
764
|
+
return found;
|
|
669
765
|
}
|
|
670
766
|
});
|
|
671
767
|
};
|
|
@@ -711,7 +807,7 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
711
807
|
const actual = state.branchExists ? state.refSha : null;
|
|
712
808
|
if (actual !== commitOptions.ifHead) {
|
|
713
809
|
heads.delete(branch);
|
|
714
|
-
|
|
810
|
+
rejectHistoryHead(commitOptions, historyConflict(ref, commitOptions.ifHead, actual));
|
|
715
811
|
}
|
|
716
812
|
for (const [expectedRef, expectedHead] of Object.entries(commitOptions.ifHeads ?? {})) {
|
|
717
813
|
const expected = resolveRef(expectedRef);
|
|
@@ -762,7 +858,10 @@ function createGitHubWorkspaceHistory(input) {
|
|
|
762
858
|
remoteModes: new Map([...state.files.values()].map((entry) => [entry.path, entry.mode])),
|
|
763
859
|
repository: client()
|
|
764
860
|
}).catch((error) => {
|
|
765
|
-
if (isWorkspaceConflict(error))
|
|
861
|
+
if (isWorkspaceConflict(error)) {
|
|
862
|
+
heads.delete(branch);
|
|
863
|
+
rejectHistoryHead(commitOptions, error);
|
|
864
|
+
}
|
|
766
865
|
throw error;
|
|
767
866
|
});
|
|
768
867
|
heads.set(branch, {
|
|
@@ -1867,6 +1966,7 @@ var GitHubWorkspaceStore = class {
|
|
|
1867
1966
|
}
|
|
1868
1967
|
};
|
|
1869
1968
|
function createGitHubWorkspaceStore(options, workspaceName) {
|
|
1969
|
+
assertNoGitHubRepositoryKey(options);
|
|
1870
1970
|
return new GitHubWorkspaceStore(options, workspaceName);
|
|
1871
1971
|
}
|
|
1872
1972
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
2
|
import { f as sha256, n as contentStreamToBytes } from "./path--wrT_Azm.js";
|
|
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-
|
|
3
|
+
import { d as sourceSyncPathClaims, f as workspaceSourceSyncStateEquals, l as readWorkspaceSourceSyncState, u as sourceSyncMetaKey } from "./workspace-DvKu5PRa.js";
|
|
4
|
+
import { a as normalizeWorkspaceSources, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath } from "./config-D1QENneP.js";
|
|
5
|
+
import { C as withWorkspaceStoreMutation, E as normalizeSourceFileMetadata, S as sourceMountOwnsPath, T as normalizeMetadataValue, w as normalizeSourceItemPath, x as createWorkspaceSourceMountAuthority } from "./metadata-target-DDoOQNp1.js";
|
|
6
6
|
//#region src/sources/sync.ts
|
|
7
7
|
const sourceSyncLocks = /* @__PURE__ */ new Map();
|
|
8
8
|
const sourceSyncGrants = createWorkspaceSourceMountAuthority("Source Sync");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
3
3
|
//#region src/core/file-metadata.ts
|
|
4
4
|
function invalidMetadata(path) {
|
|
5
5
|
return workspaceError(`[vitehub] Invalid Workspace metadata for ${path}. Metadata must contain only JSON-safe plain objects, dense arrays, strings, booleans, null, and finite numbers other than negative zero.`);
|
package/dist/test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as registerWorkspace } from "./registry-
|
|
1
|
+
import { t as registerWorkspace } from "./registry-CwryP59t.js";
|
|
2
2
|
export { registerWorkspace };
|
package/dist/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as registerWorkspace } from "./registry-
|
|
1
|
+
import { n as registerWorkspace } from "./registry-DmVfUe4K.js";
|
|
2
2
|
export { registerWorkspace };
|
|
@@ -341,6 +341,8 @@ interface WorkspaceHistoryCommitBase extends WorkspaceHistoryRefOptions {
|
|
|
341
341
|
ifHead: string | null;
|
|
342
342
|
/** Expected heads of other refs that must remain unchanged for the commit. */
|
|
343
343
|
ifHeads?: Record<string, string | null>;
|
|
344
|
+
/** Observe a rejection of this commit's own `ifHead` condition. The commit still throws the error. */
|
|
345
|
+
onHeadConflict?: (error: unknown) => void;
|
|
344
346
|
/**
|
|
345
347
|
* With `ifHead: null`, start the new ref from this revision instead of from the ref that `history.forksFrom(ref)`
|
|
346
348
|
* names. Only Stores with `forksFrom` accept it. The caller has read the files of that revision.
|
|
@@ -396,6 +398,19 @@ interface WorkspaceRevisionView {
|
|
|
396
398
|
* them from one archive of the commit. Stores without it read each file on its own.
|
|
397
399
|
*/
|
|
398
400
|
preload?(paths: readonly string[]): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* The last revision that changed each path on the first-parent history, including deletions. A null value means
|
|
403
|
+
* the path has no change. A missing key means the Store could not prove the answer. To resolve missing keys,
|
|
404
|
+
* or when a Store does not implement this method, compare each revision's files with those of its first parent.
|
|
405
|
+
*/
|
|
406
|
+
lastChanged?(paths: readonly string[]): Promise<ReadonlyMap<string, WorkspaceLastChange | null>>;
|
|
407
|
+
}
|
|
408
|
+
/** The revision that last changed a path, as `WorkspaceRevisionView.lastChanged()` answers. */
|
|
409
|
+
interface WorkspaceLastChange {
|
|
410
|
+
/** The revision id: the commit sha for the GitHub Store. */
|
|
411
|
+
id: string;
|
|
412
|
+
/** When the revision was made, as an ISO date: the commit's author date for the GitHub Store. */
|
|
413
|
+
createdAt: string;
|
|
399
414
|
}
|
|
400
415
|
/** An open pull request on a forge, for a Store whose refs are branches. */
|
|
401
416
|
interface WorkspacePullRequest {
|
|
@@ -813,8 +828,8 @@ interface GitHubWorkspaceStoreOptions {
|
|
|
813
828
|
*/
|
|
814
829
|
database?: unknown;
|
|
815
830
|
refs?: GitHubWorkspaceRefs;
|
|
831
|
+
/** The repository, as `owner/name`. Defaults to `VITEHUB_WORKSPACE_GITHUB_REPOSITORY`. */
|
|
816
832
|
repo?: GitHubWorkspaceOption;
|
|
817
|
-
repository?: GitHubWorkspaceOption;
|
|
818
833
|
/** The folder of the Workspace in the repository. An empty string is the repository root. Defaults to `.vitehub/workspaces/<workspace>`. */
|
|
819
834
|
root?: GitHubWorkspaceOption;
|
|
820
835
|
token?: GitHubWorkspaceOption;
|
|
@@ -962,4 +977,4 @@ interface WorkspaceMaterializeSourcesResult {
|
|
|
962
977
|
sources: WorkspaceSourceMaterializationStatus[];
|
|
963
978
|
}
|
|
964
979
|
//#endregion
|
|
965
|
-
export { WorkspaceHistoryFileInput as $,
|
|
980
|
+
export { WorkspaceHistoryFileInput as $, WorkspaceSourceMaterializationPathResult as $t, WorkspaceAutoCommitPlan as A, WorkspaceValidateMode as An, WorkspaceRebaseOptions as At, WorkspaceEntry as B, WorkspaceSession as Bt, SourceContextWorkspaceFiles as C, WorkspaceStoreHistory as Cn, WorkspaceName as Ct, WorkspaceAssets as D, WorkspaceSyncOptions as Dn, WorkspacePlugin as Dt, WorkspaceAssetPath as E, WorkspaceStreamFile as En, WorkspaceOptions as Et, WorkspaceCustomSourceInput as F, WorkspaceWriteMode as Fn, WorkspaceRules as Ft, WorkspaceGitHubSourceInput as G, WorkspaceSessionWriteFileOptions as Gt, WorkspaceFetchSourceRequestOptions as H, WorkspaceSessionHostFileEntry as Ht, WorkspaceDefinition as I, WorkspaceWriteOperation as In, WorkspaceScopeName as It, WorkspaceHistoryChangesCommitOptions as J, WorkspaceSourceBindingInput as Jt, WorkspaceGlobSourceInput as K, WorkspaceSnapshot as Kt, WorkspaceDefinitionInput as L, WorkspaceWriteValidator as Ln, WorkspaceSearchHit as Lt, WorkspaceCapabilities as M, WorkspaceWriteErrorHook as Mn, WorkspaceRevision as Mt, WorkspaceContent as N, WorkspaceWriteHook as Nn, WorkspaceRevisionView as Nt, WorkspaceAssetsRegistry as O, WorkspaceSyncResultDetails as On, WorkspacePrepareSessionProgressEvent as Ot, WorkspaceContentStream as P, WorkspaceWriteInput as Pn, WorkspaceRule as Pt, WorkspaceHistoryFile as Q, WorkspaceSourceMaterializationCounts as Qt, WorkspaceDiff as R, WorkspaceWriteValidatorResult as Rn, WorkspaceSearchQuery as Rt, SourceContext$1 as S, WorkspaceStore as Sn, WorkspaceMergeResolution as St, Workspace as T, WorkspaceStoreOptions as Tn, WorkspaceOpenPullRequestOptions as Tt, WorkspaceFile as U, WorkspaceSessionHostFiles as Ut, WorkspaceFetchSourceInput as V, WorkspaceSessionHost as Vt, WorkspaceFileSourceInput as W, WorkspaceSessionOptions as Wt, WorkspaceHistoryCommitOptions as X, WorkspaceSourceInput as Xt, WorkspaceHistoryCommitBase as Y, WorkspaceSourceDefinition as Yt, WorkspaceHistoryExtensions as Z, WorkspaceSourceItem as Zt, ReadFileResult as _, WorkspaceSourceSyncPathResult as _n, WorkspaceMcpResourcesSourceInput as _t, GitHubWorkspaceOption as a, WorkspaceSourceRequestExecutionResult as an, WorkspaceHistoryRefOptions as at, RmOptions as b, WorkspaceSourceSyncStatus as bn, WorkspaceMergeConflictContext as bt, GlobOptions as c, WorkspaceSourceResolutionContext as cn, WorkspaceInstructionBinding as ct, LocalWorkspaceStoreOptions as d, WorkspaceSourceResolutionInvocation as dn, WorkspaceLoader as dt, WorkspaceSourceMaterializationStatus as en, WorkspaceHistoryFilesCommitOptions as et, Logger as f, WorkspaceSourceResolutionResult as fn, WorkspaceLoaderSource as ft, ReadFileOptions as g, WorkspaceSourceSyncCounts as gn, WorkspaceMaterializeSourcesResult as gt, MkdirOptions as h, WorkspaceSourceSyncConfig as hn, WorkspaceMaterializeSourcesProgressEvent as ht, ExecResult as i, WorkspaceSourceRequestExecutionInput as in, WorkspaceHistoryRef as it, WorkspaceCacheOptions as j, WorkspaceWriteCommit as jn, WorkspaceRetainedHistory as jt, WorkspaceAuthor as k, WorkspaceSyncSnapshotOptions as kn, WorkspacePullRequest as kt, ListOptions as l, WorkspaceSourceResolutionContextMap as ln, WorkspaceInstructionBindingValue as lt, MemoryWorkspaceStoreOptions as m, WorkspaceSourceSelection as mn, WorkspaceMaterializeSourcesOptions as mt, DiffOptions as n, WorkspaceSourceMountOptions as nn, WorkspaceHistoryListResult as nt, GitHubWorkspaceRefs as o, WorkspaceSourceRequestExecutor as on, WorkspaceHookContext as ot, MaybePromise as p, WorkspaceSourceResolver as pn, WorkspaceMaterializeMode as pt, WorkspaceHistoryChanges as q, WorkspaceSource as qt, ExecOptions as r, WorkspaceSourceRequestDescriptor as rn, WorkspaceHistoryReader as rt, GitHubWorkspaceStoreOptions as s, WorkspaceSourceRequestMethod as sn, WorkspaceHooks as st, CloudflareArtifactsWorkspaceStoreOptions as t, WorkspaceSourceMount as tn, WorkspaceHistoryListOptions as tt, LoaderContext as u, WorkspaceSourceResolutionContextValueReader as un, WorkspaceLastChange as ut, ResolvedWorkspaceModuleOptions as v, WorkspaceSourceSyncPolicy as vn, WorkspaceMergeCommit as vt, VercelBlobWorkspaceStoreOptions as w, WorkspaceStoreHistoryCommitOptions as wn, WorkspaceNameMap as wt, SnapshotOptions as x, WorkspaceStat as xn, WorkspaceMergeOptions as xt, ResolvedWorkspaceRule as y, WorkspaceSourceSyncResult as yn, WorkspaceMergeConflict as yt, WorkspaceDiffEntry as z, WriteFileOptions as zn, WorkspaceSelectedScope as zt };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { i as isWorkspaceError, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-
|
|
2
|
+
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-Dm9dHAVJ.js";
|
|
3
3
|
import { c as normalizeSafeWorkspacePattern, f as sha256 } from "./path--wrT_Azm.js";
|
|
4
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
5
|
-
import { d as normalizeHistoryRef, f as
|
|
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 { o as useRegisteredWorkspace } from "./registry-
|
|
4
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
5
|
+
import { d as normalizeHistoryRef, f as rejectHistoryHead, l as historyConflict, m as validateHistoryMessage, p as requireWorkspaceHistory } from "./utils-Dw-WULEZ.js";
|
|
6
|
+
import { g as getWorkspaceSourceRequestExecution, i as assertPublicWorkspaceMetaKey, m as attachWorkspaceSourceRequestExecution, t as createWorkspace } from "./workspace-DvKu5PRa.js";
|
|
7
|
+
import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-DDoOQNp1.js";
|
|
8
|
+
import { o as useRegisteredWorkspace } from "./registry-DmVfUe4K.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-Bf1a2uo_.js";
|
|
11
11
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
12
12
|
import { posix } from "node:path";
|
|
13
13
|
//#region src/fs-ops.ts
|
|
@@ -188,7 +188,7 @@ function createLazyWorkspace(name, definition, options = {}) {
|
|
|
188
188
|
validateHistoryMessage(options.message);
|
|
189
189
|
const ref = normalizeHistoryRef(options.ref);
|
|
190
190
|
const head = await history.head({ ref });
|
|
191
|
-
if ((head?.id ?? null) !== options.ifHead)
|
|
191
|
+
if ((head?.id ?? null) !== options.ifHead) rejectHistoryHead(options, historyConflict(ref, options.ifHead, head?.id ?? null));
|
|
192
192
|
return await requireWorkspaceHistory(await resolveSyncedWorkspace()).commit(options);
|
|
193
193
|
}
|
|
194
194
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as
|
|
1
|
+
import { At as WorkspaceRebaseOptions, B as WorkspaceEntry, Bt as WorkspaceSession, Ct as WorkspaceName, D as WorkspaceAssets, Dn as WorkspaceSyncOptions, E as WorkspaceAssetPath, I as WorkspaceDefinition, Kt as WorkspaceSnapshot, Lt as WorkspaceSearchHit, M as WorkspaceCapabilities, Mt as WorkspaceRevision, N as WorkspaceContent, Nt as WorkspaceRevisionView, R as WorkspaceDiff, Rt as WorkspaceSearchQuery, T as Workspace, Wt as WorkspaceSessionOptions, _ as ReadFileResult, at as WorkspaceHistoryRefOptions, b as RmOptions, c as GlobOptions, g as ReadFileOptions, gt as WorkspaceMaterializeSourcesResult, h as MkdirOptions, it as WorkspaceHistoryRef, jt as WorkspaceRetainedHistory, k as WorkspaceAuthor, l as ListOptions, mt as WorkspaceMaterializeSourcesOptions, n as DiffOptions, nt as WorkspaceHistoryListResult, rt as WorkspaceHistoryReader, tt as WorkspaceHistoryListOptions, x as SnapshotOptions, xn as WorkspaceStat, yn as WorkspaceSourceSyncResult, zn as WriteFileOptions } from "./types-1Z-tKK3g.js";
|
|
2
2
|
import { ExecutionBudget } from "@vite-hub/runtime";
|
|
3
3
|
import { Tool, ToolSet } from "ai";
|
|
4
4
|
//#region src/ai.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as workspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { a as cascadingRuleKeys, i as assertWorkspaceRules, o as copyJsonFileMetadata, s as copyJsonWorkspaceMetadata } from "./target-
|
|
2
|
+
import { a as cascadingRuleKeys, i as assertWorkspaceRules, o as copyJsonFileMetadata, s as copyJsonWorkspaceMetadata } from "./target-Dm9dHAVJ.js";
|
|
3
3
|
import { f as sha256, l as normalizeWorkspacePath, o as isWorkspaceBytes, r as contentToBytes } from "./path--wrT_Azm.js";
|
|
4
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B5s9kNEA.js";
|
|
5
5
|
import { lookup } from "mrmime";
|
|
6
6
|
import { isRuntimeObject } from "@vite-hub/runtime/internal/runtime-type";
|
|
7
7
|
import { minimatch } from "minimatch";
|
|
@@ -289,6 +289,7 @@ function forwardWorkspaceHistoryFiles(options) {
|
|
|
289
289
|
ref: options.ref,
|
|
290
290
|
ifHead: options.ifHead,
|
|
291
291
|
ifHeads: options.ifHeads,
|
|
292
|
+
onHeadConflict: options.onHeadConflict,
|
|
292
293
|
startFrom: options.startFrom,
|
|
293
294
|
message: options.message,
|
|
294
295
|
metadata: options.metadata
|
|
@@ -356,6 +357,10 @@ function historyConflict(ref, expected, actual, details = {}) {
|
|
|
356
357
|
actual
|
|
357
358
|
} });
|
|
358
359
|
}
|
|
360
|
+
function rejectHistoryHead(options, error) {
|
|
361
|
+
options.onHeadConflict?.(error);
|
|
362
|
+
throw error;
|
|
363
|
+
}
|
|
359
364
|
function readHistoryFiles(files, label) {
|
|
360
365
|
if (!isRuntimeObject(files) || Array.isArray(files)) throw workspaceError(`[vitehub] History ${label} must be an object keyed by file path.`);
|
|
361
366
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -422,7 +427,7 @@ function createWorkspaceHistory(definition, store, files) {
|
|
|
422
427
|
const commit = readHistoryCommit(options);
|
|
423
428
|
const metadata = copyJsonWorkspaceMetadata("history revision", options.metadata);
|
|
424
429
|
const current = await retained.head({ ref });
|
|
425
|
-
if ((current?.id ?? null) !== options.ifHead)
|
|
430
|
+
if ((current?.id ?? null) !== options.ifHead) rejectHistoryHead(options, historyConflict(ref, options.ifHead, current?.id ?? null));
|
|
426
431
|
if (options.startFrom !== void 0 && (typeof options.startFrom !== "string" || !options.startFrom || options.ifHead !== null || !store.history?.forksFrom)) throw workspaceError("[vitehub] History commit startFrom needs a revision id, ifHead null, and a Store that starts missing refs from another ref.");
|
|
427
432
|
const forkRef = current || options.startFrom ? void 0 : await store.history?.forksFrom?.(ref);
|
|
428
433
|
const startId = current?.id ?? options.startFrom ?? (forkRef ? (await retained.head({ ref: forkRef }))?.id : void 0);
|
|
@@ -497,6 +502,7 @@ function createWorkspaceHistory(definition, store, files) {
|
|
|
497
502
|
ref,
|
|
498
503
|
ifHead: options.ifHead,
|
|
499
504
|
ifHeads: options.ifHeads,
|
|
505
|
+
onHeadConflict: options.onHeadConflict,
|
|
500
506
|
startFrom: current ? options.startFrom : startId,
|
|
501
507
|
message: options.message,
|
|
502
508
|
metadata
|
|
@@ -613,4 +619,4 @@ function diffSnapshots(from, to) {
|
|
|
613
619
|
};
|
|
614
620
|
}
|
|
615
621
|
//#endregion
|
|
616
|
-
export {
|
|
622
|
+
export { registerWorkspacePlugin as _, createWorkspaceHistoryReader as a, forwardWorkspaceHistoryMerge as c, normalizeHistoryRef as d, rejectHistoryHead as f, resolveWorkspaceAutoCommit as g, createWorkspaceWritePolicy as h, createWorkspaceHistory as i, historyConflict as l, validateHistoryMessage as m, createSnapshotFromEntries as n, defaultWorkspaceHistoryRef as o, requireWorkspaceHistory as p, diffSnapshots as r, forwardWorkspaceHistoryFiles as s, createCurrentSnapshotFromStore as t, normalizeHistoryPath as u, workspaceDefinitionPlugins as v };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as OperationContributionEntry } from "./operation-definition-
|
|
1
|
+
import { Et as WorkspaceOptions } from "./types-1Z-tKK3g.js";
|
|
2
|
+
import { n as OperationContributionEntry } from "./operation-definition-nmRu_O3V.js";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
//#region ../internal/src/durability.d.ts
|
|
5
5
|
/**
|
|
@@ -550,6 +550,8 @@ interface ViteHubConsoleDocumentHint {
|
|
|
550
550
|
* failing without a reason.
|
|
551
551
|
*/
|
|
552
552
|
interface ViteHubConsoleDocumentSetup {
|
|
553
|
+
/** The project has GitHub Sources but no document collections. */
|
|
554
|
+
sourceHeadsOnly?: true;
|
|
553
555
|
/** Present when no user can read anything because the owner has no access policy. */
|
|
554
556
|
access?: ViteHubConsoleDocumentHint;
|
|
555
557
|
/**
|