@vite-hub/workspace 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -19
- package/dist/{abort-BCwpdrN0.js → abort-CQGxJBqa.js} +1 -2
- package/dist/{asset-registry-DfBV5kmw.js → asset-registry-0CdRAjIV.js} +2 -3
- package/dist/blob-database/postgres.d.ts +423 -0
- package/dist/blob-database/postgres.js +1 -0
- package/dist/blob-database-sources-CQPAyCz3.js +8 -0
- package/dist/blob-database.d.ts +29 -449
- package/dist/blob-database.js +636 -210
- package/dist/checkout.d.ts +1 -2
- package/dist/checkout.js +3 -4
- package/dist/cloudflare.d.ts +1 -5
- package/dist/cloudflare.js +1 -2
- package/dist/{config-B-863EgC.js → config-CsgNNVAI.js} +1 -2
- package/dist/{config-CDeGd0RB.d.ts → config-DeA287c0.d.ts} +1 -5
- package/dist/{config-D1QENneP.js → config-jo5QgE1w.js} +18 -27
- package/dist/{discard-CNNtCozM.js → discard-BkoLmmmN.js} +1 -2
- package/dist/durability.d.ts +10 -4
- package/dist/durability.js +47 -6
- package/dist/{error-diagnostics-B5s9kNEA.js → error-diagnostics-B4me-ouV.js} +11 -4
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
- package/dist/{path-uxLkzrZm.d.ts → errors-CnFDXxeJ.d.ts} +0 -3
- package/dist/{file-CqG9zqiF.js → file-BrNAXQgY.js} +4 -8
- package/dist/{target-Dm9dHAVJ.js → file-metadata-Bpsvjw_X.js} +3 -32
- package/dist/{files-B6wpAhEx.js → files--z2dLC5z.js} +3 -4
- package/dist/files.d.ts +12 -8
- package/dist/files.js +7 -6
- package/dist/{github-DKAlO0Vh.js → github-k--_LCrX.js} +7 -9
- package/dist/{glob-BOqSKzSg.js → glob-BEutagp1.js} +9 -10
- package/dist/{glob-Cjxms1t7.js → glob-BreFjNAV.js} +3 -4
- package/dist/history-schema-BR4UDPHL.d.ts +434 -0
- package/dist/history-schema-postgres-DZepCSBq.js +40 -0
- package/dist/{host-Bf1a2uo_.js → host-C8yZizfk.js} +153 -22
- package/dist/{hosted-zG7HJaE4.js → hosted-8BTKAtMX.js} +27 -21
- package/dist/{hosted-vercel-blob-AbXG8fvR.js → hosted-vercel-blob-B6kygYqn.js} +10 -12
- package/dist/hosted-vercel-blob.d.ts +1 -3
- package/dist/hosted-vercel-blob.js +1 -2
- package/dist/hosted.d.ts +1 -3
- package/dist/hosted.js +1 -2
- package/dist/index.d.ts +11 -41
- package/dist/index.js +34 -116
- package/dist/internal/path.d.ts +1 -1
- package/dist/internal/path.js +1 -2
- package/dist/internal/workspace.d.ts +10 -0
- package/dist/internal/workspace.js +85 -0
- package/dist/{lifecycle-D8FdpBod.js → lifecycle-IReZfi0b.js} +15 -13
- package/dist/lineage.d.ts +1 -3
- package/dist/lineage.js +1 -2
- package/dist/loader.d.ts +1 -7
- package/dist/loader.js +4 -6
- package/dist/{mcp-resources-DntxtmDU.js → mcp-resources-DeJnbOaw.js} +4 -5
- package/dist/{memory-D5jq9HZW.js → memory-BlSRrBH1.js} +19 -13
- package/dist/{metadata-target-DDoOQNp1.js → metadata-target-CaGLY4ay.js} +214 -77
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-DsY2MQnG.js → operations-CtRDU3cA.js} +34 -29
- package/dist/{operations-D8uCpzhM.js → operations-DfbqHWAe.js} +7 -8
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +2 -2
- package/dist/{path--wrT_Azm.js → path-Bb9OIc_F.js} +3 -19
- package/dist/{path-zHxQUbqa.d.ts → path-C0uZxDdW.d.ts} +0 -2
- package/dist/{path-DrSIenjj.js → path-CuYE8-X6.js} +2 -4
- package/dist/{plugins-CsrXCA1Q.d.ts → plugins-CLc32jvL.d.ts} +1 -3
- package/dist/{provider-sm9uzkLg.js → provider-CN14ewvx.js} +30 -22
- package/dist/providers/github/store.d.ts +2 -4
- package/dist/providers/github/store.js +1 -2
- package/dist/{registry-CFl1Htyc.d.ts → registry-B0g19sdy.d.ts} +5 -8
- package/dist/{registry-DmVfUe4K.js → registry-BbUg9vJB.js} +10 -6
- package/dist/registry-s2Ob9PeX.d.ts +9 -0
- package/dist/{request-scope-Dw5n8bMC.js → request-scope-CXCI_wCb.js} +4 -4
- package/dist/{results-DgkZUmTL.js → results-z-HpV9EP.js} +1 -2
- package/dist/{rolldown-runtime-rQ84J-ij.js → rolldown-runtime-DnNXxpGL.js} +2 -3
- package/dist/rule-keys-BLEbi1h5.js +18 -0
- package/dist/rules-BPDXypZV.js +267 -0
- package/dist/runtime/assets.d.ts +2 -3
- package/dist/runtime/assets.js +5 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -3
- package/dist/runtime/empty-assets-registry.js +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -4
- package/dist/runtime/empty-registry.js +1 -2
- package/dist/runtime/registry.d.ts +2 -2
- package/dist/runtime/registry.js +2 -3
- package/dist/runtime/request.d.ts +1 -3
- package/dist/runtime/request.js +2 -3
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +18 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -2
- package/dist/runtime.d.ts +9 -24
- package/dist/runtime.js +29 -25
- package/dist/{search-C_RfoM2j.js → search-C_nVorq7.js} +3 -4
- package/dist/{server-Cd4-iCh5.js → server-aa1a4rkV.js} +8 -10
- package/dist/server.d.ts +3 -4
- package/dist/server.js +1 -2
- package/dist/{shared-ovXVSV3-.js → shared-C20Wh1mp.js} +23 -19
- package/dist/source-metadata.d.ts +2 -6
- package/dist/source-metadata.js +4 -5
- package/dist/state-BdDfBtOR.d.ts +17 -0
- package/dist/{store-NZoRto-Y.js → store-cx3OqNTi.js} +42 -44
- package/dist/{sync-CrT8zjwc.js → sync-BBfR4g5y.js} +6 -7
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -2
- package/dist/{types-1Z-tKK3g.d.ts → types-Bel5IDmF.d.ts} +52 -6
- package/dist/{use-CjbF8EO9.d.ts → use-CpphIBof.d.ts} +20 -32
- package/dist/{use-B0o5HoBl.js → use-D0DyTMxM.js} +19 -21
- package/dist/use-tools-CAK10LTc.d.ts +10 -0
- package/dist/{state-Cb_hIyAw.js → use-tools-CHduR5k6.js} +8 -24
- package/dist/{utils-Dw-WULEZ.js → utils-DXP9xfXo.js} +80 -273
- package/dist/vite.d.ts +30 -19
- package/dist/vite.js +1481 -1617
- package/dist/vitehub-grants-Co713QTg.js +36 -0
- package/dist/workspace-BOuxrZrP.d.ts +5 -0
- package/dist/{workspace-DvKu5PRa.js → workspace-CLuPkyZR.js} +28 -36
- package/package.json +34 -24
- package/dist/registry-CwryP59t.d.ts +0 -9
- package/dist/state-C-YtsaiJ.d.ts +0 -35
- package/dist/workspace-CIXgHeyX.d.ts +0 -7
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import {
|
|
1
|
+
import { _ as redactInspectionText } from "./operations-CtRDU3cA.js";
|
|
2
|
+
import { a as workspaceConflict } from "./path-CuYE8-X6.js";
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
|
|
4
|
+
import { d as normalizeHistoryPath } from "./utils-DXP9xfXo.js";
|
|
5
|
+
import { r as contentToBytes } from "./path-Bb9OIc_F.js";
|
|
6
|
+
import { r as useWorkspaceFiles } from "./use-D0DyTMxM.js";
|
|
5
7
|
import { readDerivedFrom, staleDerivedFiles } from "./lineage.js";
|
|
6
|
-
|
|
7
|
-
import { _ as redactInspectionText } from "./operations-DsY2MQnG.js";
|
|
8
|
-
//#region src/runtime/operations.ts
|
|
8
|
+
// src/runtime/operations.ts
|
|
9
9
|
const invalidRequestCodes = /* @__PURE__ */ new Set([
|
|
10
10
|
"WORKSPACE_HISTORY_INVALID",
|
|
11
11
|
"WORKSPACE_PATH_INVALID",
|
|
@@ -385,5 +385,4 @@ function describeFailure(workspace, error) {
|
|
|
385
385
|
if (typeof own === "number" && own >= 400 && own < 500) return withStatus(error, own);
|
|
386
386
|
return withStatus(error, operationStatus[code] ?? (invalidRequestCodes.has(code) ? 400 : 500));
|
|
387
387
|
}
|
|
388
|
-
//#endregion
|
|
389
388
|
export { runWorkspaceChanges, runWorkspaceCommit, runWorkspaceOperation, runWorkspaceStale };
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
|
|
2
|
+
import { It as WorkspaceRevision } from "./types-Bel5IDmF.js";
|
|
2
3
|
import { WorkspaceStaleFile } from "./lineage.js";
|
|
3
|
-
import { t as AnyOperation } from "./operation-definition-nmRu_O3V.js";
|
|
4
|
-
//#region src/results.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The largest `workspace.commit` request body: 4 MiB of JSON, with base64 for binary files. Vercel Functions accept
|
|
7
6
|
* request bodies up to 4.5 MB and Cloudflare Workers up to 100 MB, so one push works on every host.
|
|
@@ -82,9 +81,6 @@ interface WorkspaceCommitResult {
|
|
|
82
81
|
/** Committed bytes of puts whose content changed during write validation or hooks, keyed by request path. */
|
|
83
82
|
normalized?: Record<string, Pick<WorkspaceHistoryContent, "content" | "encoding">>;
|
|
84
83
|
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/operations.d.ts
|
|
87
84
|
/** The `workspace.*` operations: history, refs, show, changes, commit, and stale. The Console, `vitehub workspace`, and agents run them. */
|
|
88
85
|
export declare const workspaceOperations: readonly AnyOperation[];
|
|
89
|
-
//#endregion
|
|
90
86
|
export type { WorkspaceChangedFile, WorkspaceChanges, WorkspaceCommitResult, WorkspaceHistoryContent, WorkspaceHistoryDetails, WorkspaceHistoryFile, WorkspaceHistoryList, WorkspaceHistoryRefs, WorkspaceHistoryRevision, WorkspaceStaleFile, WorkspaceStaleList };
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as workspaceCommitRequestBytes } from "./results-
|
|
2
|
-
import { t as workspaceOperations } from "./operations-
|
|
1
|
+
import { t as workspaceCommitRequestBytes } from "./results-z-HpV9EP.js";
|
|
2
|
+
import { t as workspaceOperations } from "./operations-CtRDU3cA.js";
|
|
3
3
|
export { workspaceCommitRequestBytes, workspaceOperations };
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as workspacePathError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
1
|
+
import { l as workspacePathError, t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
|
|
3
2
|
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
3
|
import { createHash } from "node:crypto";
|
|
5
4
|
import { minimatch } from "minimatch";
|
|
6
|
-
|
|
7
|
-
var path_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
contentStreamChunks: () => contentStreamChunks,
|
|
9
|
-
contentStreamToBytes: () => contentStreamToBytes,
|
|
10
|
-
contentToBytes: () => contentToBytes,
|
|
11
|
-
decodeFile: () => decodeFile,
|
|
12
|
-
isExcludedWorkspacePath: () => isExcludedWorkspacePath,
|
|
13
|
-
isWorkspaceBytes: () => isWorkspaceBytes,
|
|
14
|
-
matchesAny: () => matchesAny,
|
|
15
|
-
normalizeSafeWorkspacePath: () => normalizeSafeWorkspacePath,
|
|
16
|
-
normalizeSafeWorkspacePattern: () => normalizeSafeWorkspacePattern,
|
|
17
|
-
normalizeWorkspacePath: () => normalizeWorkspacePath,
|
|
18
|
-
resolveInside: () => resolveInside,
|
|
19
|
-
sha256: () => sha256
|
|
20
|
-
});
|
|
5
|
+
// src/core/path.ts
|
|
21
6
|
function normalizeWorkspacePath(path = "") {
|
|
22
7
|
return path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
23
8
|
}
|
|
@@ -109,5 +94,4 @@ async function sha256(input) {
|
|
|
109
94
|
const bytes = contentToBytes(typeof input === "string" || isWorkspaceBytes(input) ? input : JSON.stringify(input));
|
|
110
95
|
return createHash("sha256").update(bytes).digest("hex");
|
|
111
96
|
}
|
|
112
|
-
|
|
113
|
-
export { isExcludedWorkspacePath as a, normalizeSafeWorkspacePattern as c, resolveInside as d, sha256 as f, decodeFile as i, normalizeWorkspacePath as l, contentStreamToBytes as n, isWorkspaceBytes as o, contentToBytes as r, matchesAny as s, contentStreamChunks as t, path_exports as u };
|
|
97
|
+
export { isExcludedWorkspacePath as a, normalizeSafeWorkspacePattern as c, sha256 as d, decodeFile as i, normalizeWorkspacePath as l, contentStreamToBytes as n, isWorkspaceBytes as o, contentToBytes as r, matchesAny as s, contentStreamChunks as t, resolveInside as u };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/internal/path.d.ts
|
|
2
1
|
interface SafeWorkspacePathOptions {
|
|
3
2
|
allowEmpty?: boolean;
|
|
4
3
|
allowReserved?: boolean;
|
|
5
4
|
pattern?: boolean;
|
|
6
5
|
}
|
|
7
6
|
declare function normalizeSafeWorkspacePath(path?: string, options?: SafeWorkspacePathOptions): string;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { normalizeSafeWorkspacePath as n, SafeWorkspacePathOptions as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ViteHubError, getViteHubErrorShape } from "@vite-hub/runtime";
|
|
2
|
-
|
|
2
|
+
// src/core/errors.ts
|
|
3
3
|
function workspaceError(message, options) {
|
|
4
4
|
const code = message.startsWith("[vitehub] Workspace file does not exist:") || message.startsWith("[vitehub] Workspace path does not exist:") || message.startsWith("[vitehub] Custom Workspace Source file does not exist:") ? "WORKSPACE_NOT_FOUND" : "WORKSPACE_FAILED";
|
|
5
5
|
return new ViteHubError(code, message, options);
|
|
@@ -31,8 +31,7 @@ function isWorkspaceError(value) {
|
|
|
31
31
|
function isWorkspaceConflict(value) {
|
|
32
32
|
return getViteHubErrorShape(value)?.code === "WORKSPACE_CONFLICT";
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
//#region src/internal/path.ts
|
|
34
|
+
// src/internal/path.ts
|
|
36
35
|
function classifyWindowsComponent(part) {
|
|
37
36
|
const withoutStream = part.toLowerCase().split(":", 1)[0];
|
|
38
37
|
return {
|
|
@@ -55,5 +54,4 @@ function normalizeSafeWorkspacePath(path = "", options = {}) {
|
|
|
55
54
|
})) throw workspacePathError(path);
|
|
56
55
|
return normalized;
|
|
57
56
|
}
|
|
58
|
-
//#endregion
|
|
59
57
|
export { workspaceConflict as a, workspaceNotFoundError as c, isWorkspaceError as i, workspacePathError as l, assertWorkspaceDigest as n, workspaceConflictError as o, isWorkspaceConflict as r, workspaceError as s, normalizeSafeWorkspacePath as t };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/core/plugins.d.ts
|
|
1
|
+
import { jt as WorkspacePlugin } from "./types-Bel5IDmF.js";
|
|
3
2
|
/**
|
|
4
3
|
* Add a plugin's rules and hooks to a Workspace by name, including discovered Workspaces the caller does not define.
|
|
5
4
|
* Registering the same plugin id again replaces the earlier registration. A plugin declared by the Workspace Definition
|
|
6
5
|
* with the same id wins. The returned function removes this registration.
|
|
7
6
|
*/
|
|
8
7
|
declare function registerWorkspacePlugin(workspace: string, plugin: WorkspacePlugin): () => void;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { registerWorkspacePlugin as t };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as assertWorkspaceDigest, o as workspaceConflictError, s as workspaceError } from "./path-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as createWorkspaceGlobMatcher } from "./glob-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
1
|
+
import { M as readForgeEnv, j as forgeEnv, t as assertNoGitHubRepositoryKey } from "./shared-C20Wh1mp.js";
|
|
2
|
+
import { n as assertWorkspaceDigest, o as workspaceConflictError, s as workspaceError } from "./path-CuYE8-X6.js";
|
|
3
|
+
import { t as createGitHubWorkspaceStore } from "./store-cx3OqNTi.js";
|
|
4
|
+
import { t as getWorkspaceRuntimeConfig } from "./config-CsgNNVAI.js";
|
|
5
|
+
import { t as copyJsonFileMetadata } from "./file-metadata-Bpsvjw_X.js";
|
|
6
|
+
import { t as createWorkspaceGlobMatcher } from "./glob-BreFjNAV.js";
|
|
7
|
+
import { a as isExcludedWorkspacePath, d as sha256, l as normalizeWorkspacePath, r as contentToBytes, t as contentStreamChunks, u as resolveInside } from "./path-Bb9OIc_F.js";
|
|
8
|
+
import { a as provideWorkspaceStoreTarget } from "./vitehub-grants-Co713QTg.js";
|
|
9
|
+
import { r as vitehubOwnedPrefix, t as createMemoryWorkspaceStore } from "./memory-BlSRrBH1.js";
|
|
10
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
|
|
10
11
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
11
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
13
|
import { constants, createReadStream, createWriteStream } from "node:fs";
|
|
@@ -16,7 +17,7 @@ import { check, fallback, literal, object, optional, pipe, record, safeParse, st
|
|
|
16
17
|
import { Readable, Transform } from "node:stream";
|
|
17
18
|
import { pipeline } from "node:stream/promises";
|
|
18
19
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
19
|
-
|
|
20
|
+
// ../internal/src/env.ts
|
|
20
21
|
function trimmed(value) {
|
|
21
22
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
22
23
|
}
|
|
@@ -26,8 +27,7 @@ function readEnv(env, ...names) {
|
|
|
26
27
|
if (value) return value;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
//#region src/runtime/hosted-store-loader.ts
|
|
30
|
+
// src/runtime/hosted-store-loader.ts
|
|
31
31
|
const workspaceHostedStoreLoaderKey = Symbol.for("vitehub.workspace.hostedStoreLoader");
|
|
32
32
|
function workspaceHostedStoreLoaderGlobal() {
|
|
33
33
|
return globalThis;
|
|
@@ -38,8 +38,7 @@ function setWorkspaceHostedStoreLoader(loader) {
|
|
|
38
38
|
function getWorkspaceHostedStoreLoader() {
|
|
39
39
|
return workspaceHostedStoreLoaderGlobal()[workspaceHostedStoreLoaderKey];
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
//#region src/storage/local.ts
|
|
41
|
+
// src/storage/local.ts
|
|
43
42
|
const fileMetadataSchema = optional(pipe(unknown(), check((value) => !Array.isArray(value)), record(string(), unknown()), check((value) => {
|
|
44
43
|
return safeParse(optional(string()), value.source).success;
|
|
45
44
|
})));
|
|
@@ -686,7 +685,7 @@ async function fileDigest(path) {
|
|
|
686
685
|
}
|
|
687
686
|
var LocalWorkspaceStore = class {
|
|
688
687
|
root;
|
|
689
|
-
|
|
688
|
+
#storeTarget() {
|
|
690
689
|
return {
|
|
691
690
|
provider: "local",
|
|
692
691
|
containsPath: async (ancestor, path) => {
|
|
@@ -720,6 +719,7 @@ var LocalWorkspaceStore = class {
|
|
|
720
719
|
this.#processLocks = options.locks === "process";
|
|
721
720
|
this.#fileMetadataRoot = `${root}/.vitehub/file-metadata`;
|
|
722
721
|
this.#metaPath = `${root}.meta.json`;
|
|
722
|
+
provideWorkspaceStoreTarget(this, () => this.#storeTarget());
|
|
723
723
|
}
|
|
724
724
|
async #pathLock(root, path, operation, readOnly = false) {
|
|
725
725
|
return this.#processLocks ? await withProcessPathLock(root, path, operation, readOnly) : await withWorkspacePathLock(root, path, operation, readOnly);
|
|
@@ -911,7 +911,7 @@ var LocalWorkspaceStore = class {
|
|
|
911
911
|
await this.#writeFile(normalized, file);
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
|
-
async #writeFile(path, file) {
|
|
914
|
+
async #writeFile(path, file, createOnly = false) {
|
|
915
915
|
file = {
|
|
916
916
|
...file,
|
|
917
917
|
metadata: assertFileMetadata(path, file.metadata)
|
|
@@ -927,6 +927,7 @@ var LocalWorkspaceStore = class {
|
|
|
927
927
|
const bytes = contentToBytes(file.content);
|
|
928
928
|
const digest = await sha256(bytes);
|
|
929
929
|
const existing = await this.#stat(normalized);
|
|
930
|
+
if (createOnly && existing) throw workspaceError(`[vitehub] Cannot create a Workspace file over an existing path: ${normalized}.`);
|
|
930
931
|
if (existing?.type === "directory") throw workspaceError(`[vitehub] Cannot write a file over directory: ${normalized}.`);
|
|
931
932
|
if (existing?.type === "file" && existing.digest === digest) {
|
|
932
933
|
await this.#writeFileMetadata(normalized, {
|
|
@@ -1243,12 +1244,22 @@ var LocalWorkspaceStore = class {
|
|
|
1243
1244
|
return structuredClone((await this.#readMeta()).get(key));
|
|
1244
1245
|
}
|
|
1245
1246
|
async setMeta(key, value) {
|
|
1247
|
+
await this.#setMetaEntries({ [key]: value });
|
|
1248
|
+
}
|
|
1249
|
+
async #setMetaEntries(entries) {
|
|
1246
1250
|
await this.#pathLock(this.root, ".vitehub/metadata", async () => {
|
|
1247
1251
|
const metadata = new Map(await this.#readMeta());
|
|
1248
|
-
metadata.set(key, value);
|
|
1252
|
+
for (const [key, value] of Object.entries(entries)) metadata.set(key, value);
|
|
1249
1253
|
await this.#writeMeta(metadata);
|
|
1250
1254
|
});
|
|
1251
1255
|
}
|
|
1256
|
+
async writeFiles(files, meta, onWrite) {
|
|
1257
|
+
for (const file of files) {
|
|
1258
|
+
await this.#pathLock(this.root, file.path, () => this.#writeFile(file.path, file, true));
|
|
1259
|
+
onWrite?.(file.path);
|
|
1260
|
+
}
|
|
1261
|
+
if (meta && Object.keys(meta).length) await this.#setMetaEntries(meta);
|
|
1262
|
+
}
|
|
1252
1263
|
async #createSnapshot(name) {
|
|
1253
1264
|
const entries = Object.create(null);
|
|
1254
1265
|
for (const entry of await this.#list("", { recursive: true }, true)) entries[entry.path] = {
|
|
@@ -1320,8 +1331,7 @@ function createLocalWorkspaceStore(root, options = {}) {
|
|
|
1320
1331
|
if (options.ignore !== void 0 && options.ignore !== "git") throw workspaceError("[vitehub] Local workspace store ignore must be \"git\".");
|
|
1321
1332
|
return new LocalWorkspaceStore(root, options);
|
|
1322
1333
|
}
|
|
1323
|
-
|
|
1324
|
-
//#region src/storage/owned-blob-prefix.ts
|
|
1334
|
+
// src/storage/owned-blob-prefix.ts
|
|
1325
1335
|
/**
|
|
1326
1336
|
* Returns `_vitehub/<root>`, or `_vitehub/<root>/<prefix>` for a custom prefix.
|
|
1327
1337
|
* ViteHub owns every Workspace Blob object, so a custom prefix only nests below the owned root.
|
|
@@ -1331,8 +1341,7 @@ function ownedBlobPrefix(root, prefix, label) {
|
|
|
1331
1341
|
const owned = `${vitehubOwnedPrefix}${root}`;
|
|
1332
1342
|
return prefix === void 0 ? owned : `${owned}/${prefix}`;
|
|
1333
1343
|
}
|
|
1334
|
-
|
|
1335
|
-
//#region src/storage/provider.ts
|
|
1344
|
+
// src/storage/provider.ts
|
|
1336
1345
|
const MASKED_WORKSPACE_RUNTIME_VALUE = "********";
|
|
1337
1346
|
function workspaceRepoName(name) {
|
|
1338
1347
|
return name ? name.replace(/[^a-zA-Z0-9_.-]/g, "-") : void 0;
|
|
@@ -1476,5 +1485,4 @@ function resolveRuntimeVercelBlobWorkspaceStore(config, env) {
|
|
|
1476
1485
|
token
|
|
1477
1486
|
};
|
|
1478
1487
|
}
|
|
1479
|
-
//#endregion
|
|
1480
1488
|
export { resolveGitHubWorkspaceStore as a, resolveWorkspaceDefinitionStore as c, setWorkspaceHostedStoreLoader as d, resolveCloudflareArtifactsStore as i, ownedBlobPrefix as l, isWorkspaceStore as n, resolveRuntimeVercelBlobWorkspaceStore as o, normalizeWorkspaceStoreOptions as r, resolveVercelBlobWorkspaceStore as s, createWorkspaceStoreFromProvider as t, getWorkspaceHostedStoreLoader as u };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function createGitHubWorkspaceStore(options: GitHubWorkspaceStoreOptions, workspaceName: string): WorkspaceStore;
|
|
4
|
-
//#endregion
|
|
1
|
+
import { En as WorkspaceStore, s as GitHubWorkspaceStoreOptions } from "../../types-Bel5IDmF.js";
|
|
2
|
+
export declare function createGitHubWorkspaceStore(options: GitHubWorkspaceStoreOptions, workspaceName: string): WorkspaceStore;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createGitHubWorkspaceStore };
|
|
1
|
+
export { t as createGitHubWorkspaceStore } from "../../store-cx3OqNTi.js";
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/runtime/config.d.ts
|
|
1
|
+
import { R as WorkspaceDefinitionInput, v as ResolvedWorkspaceModuleOptions } from "./types-Bel5IDmF.js";
|
|
3
2
|
declare function setWorkspaceRuntimeConfig(config: false | ResolvedWorkspaceModuleOptions): void;
|
|
4
3
|
declare function getWorkspaceRuntimeConfig(): false | ResolvedWorkspaceModuleOptions;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/runtime/registry.d.ts
|
|
7
4
|
type WorkspaceRegistryModule = {
|
|
8
5
|
default?: WorkspaceDefinitionInput;
|
|
9
6
|
};
|
|
10
7
|
type WorkspaceRegistry = Record<string, () => Promise<WorkspaceRegistryModule>>;
|
|
8
|
+
type WorkspaceRegistryLoader = () => WorkspaceRegistryModule | Promise<WorkspaceRegistryModule>;
|
|
11
9
|
interface WorkspaceRuntimeRegistryState {
|
|
12
|
-
loaders:
|
|
10
|
+
loaders: Record<string, WorkspaceRegistryLoader>;
|
|
13
11
|
version: number;
|
|
14
12
|
}
|
|
15
13
|
declare function workspaceRuntimeRegistryState(): Readonly<WorkspaceRuntimeRegistryState>;
|
|
16
|
-
declare function setWorkspaceRuntimeRegistry(registry:
|
|
14
|
+
declare function setWorkspaceRuntimeRegistry(registry: WorkspaceRuntimeRegistryState["loaders"]): void;
|
|
17
15
|
declare function resetWorkspaceRuntimeRegistry(): void;
|
|
18
|
-
|
|
19
|
-
export { workspaceRuntimeRegistryState as a, setWorkspaceRuntimeRegistry as i, WorkspaceRegistryModule as n, getWorkspaceRuntimeConfig as o, resetWorkspaceRuntimeRegistry as r, setWorkspaceRuntimeConfig as s, WorkspaceRegistry as t };
|
|
16
|
+
export { setWorkspaceRuntimeRegistry as a, setWorkspaceRuntimeConfig as c, resetWorkspaceRuntimeRegistry as i, WorkspaceRegistryLoader as n, workspaceRuntimeRegistryState as o, WorkspaceRegistryModule as r, getWorkspaceRuntimeConfig as s, WorkspaceRegistry as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as workspaceNotFoundError } from "./path-
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as createWorkspace } from "./workspace-DvKu5PRa.js";
|
|
1
|
+
import { c as workspaceNotFoundError } from "./path-CuYE8-X6.js";
|
|
2
|
+
import { t as createWorkspace } from "./workspace-CLuPkyZR.js";
|
|
4
3
|
import { setWorkspaceRuntimeRegistry, workspaceRuntimeRegistryState } from "./runtime/registry.js";
|
|
4
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
|
|
5
5
|
import { getViteHubErrorShape, isRuntimeDiagnostic } from "@vite-hub/runtime";
|
|
6
|
-
|
|
6
|
+
// src/core/registry.ts
|
|
7
7
|
const workspaceRegistryStateKey = Symbol.for("vitehub.workspace.registryState");
|
|
8
8
|
function workspaceRegistryState() {
|
|
9
9
|
const scope = globalThis;
|
|
@@ -153,6 +153,11 @@ async function resolveWorkspaceDefinition(name, abortSignal) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
/** Whether a Workspace Definition has this name. Use it to check a name that comes from a request or a database. */
|
|
157
|
+
function isWorkspaceName(name) {
|
|
158
|
+
const state = workspaceRegistryState();
|
|
159
|
+
return state.registeredDefinitions.has(name) || [...state.scopedDefinitions.values()].some((definitions) => definitions.has(name)) || Object.hasOwn(workspaceRuntimeRegistryState().loaders, name);
|
|
160
|
+
}
|
|
156
161
|
async function resolveRegisteredWorkspaceDefinition(name, abortSignal) {
|
|
157
162
|
return resolveWorkspaceDefinition(name, abortSignal);
|
|
158
163
|
}
|
|
@@ -160,5 +165,4 @@ async function useRegisteredWorkspace(name, options = {}) {
|
|
|
160
165
|
const definition = await resolveWorkspaceDefinition(name);
|
|
161
166
|
return createWorkspace(definition, options);
|
|
162
167
|
}
|
|
163
|
-
|
|
164
|
-
export { setWorkspaceRuntimeDefinitions as a, setWorkspaceRegistry as i, registerWorkspace as n, useRegisteredWorkspace as o, resolveRegisteredWorkspaceDefinition as r, workspaceRegistryLoadError as s, normalizeWorkspaceDefinition as t };
|
|
168
|
+
export { setWorkspaceRegistry as a, workspaceRegistryLoadError as c, resolveRegisteredWorkspaceDefinition as i, normalizeWorkspaceDefinition as n, setWorkspaceRuntimeDefinitions as o, registerWorkspace as r, useRegisteredWorkspace as s, isWorkspaceName as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { L as WorkspaceDefinition, R as WorkspaceDefinitionInput, w as ValidatedWorkspaceName } from "./types-Bel5IDmF.js";
|
|
2
|
+
import "./registry-B0g19sdy.js";
|
|
3
|
+
declare function registerWorkspace(name: string, definition: WorkspaceDefinitionInput): WorkspaceDefinition;
|
|
4
|
+
/** Replace one generated catalog's definitions without replacing application registrations. */
|
|
5
|
+
declare function setWorkspaceRuntimeDefinitions(scope: string, definitions: Record<string, WorkspaceDefinitionInput>): void;
|
|
6
|
+
/** Whether a Workspace Definition has this name. Use it to check a name that comes from a request or a database. */
|
|
7
|
+
declare function isWorkspaceName(name: string): name is ValidatedWorkspaceName;
|
|
8
|
+
declare function resolveRegisteredWorkspaceDefinition(name: string, abortSignal?: AbortSignal): Promise<WorkspaceDefinition>;
|
|
9
|
+
export { setWorkspaceRuntimeDefinitions as i, registerWorkspace as n, resolveRegisteredWorkspaceDefinition as r, isWorkspaceName as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as workspaceStoreDiscard } from "./discard-
|
|
1
|
+
import { t as workspaceStoreDiscard } from "./discard-BkoLmmmN.js";
|
|
2
2
|
import { registerRunScope } from "@vite-hub/runtime/internal/run-scope";
|
|
3
|
-
|
|
3
|
+
// src/core/request-scope.ts
|
|
4
4
|
const runtimeGlobal = globalThis;
|
|
5
5
|
const storageKey = Symbol.for("vitehub.workspace.request");
|
|
6
6
|
const writersKey = Symbol.for("vitehub.workspace.writers");
|
|
@@ -30,7 +30,8 @@ const stagingMethods = [
|
|
|
30
30
|
"setMeta",
|
|
31
31
|
"writeFile",
|
|
32
32
|
"writeFileConditional",
|
|
33
|
-
"writeFileStream"
|
|
33
|
+
"writeFileStream",
|
|
34
|
+
"writeFiles"
|
|
34
35
|
];
|
|
35
36
|
/**
|
|
36
37
|
* Records which request stages writes in a Store that keeps them until `snapshot()`, for every caller of the Store:
|
|
@@ -79,5 +80,4 @@ async function runWorkspaceRequest(next) {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
registerRunScope(runWorkspaceRequest);
|
|
82
|
-
//#endregion
|
|
83
83
|
export { trackStagedWrites as n, runWorkspaceRequest as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/results.ts
|
|
2
2
|
/**
|
|
3
3
|
* The largest `workspace.commit` request body: 4 MiB of JSON, with base64 for binary files. Vercel Functions accept
|
|
4
4
|
* request bodies up to 4.5 MB and Cloudflare Workers up to 100 MB, so one push works on every host.
|
|
5
5
|
*/
|
|
6
6
|
const workspaceCommitRequestBytes = 4194304;
|
|
7
|
-
//#endregion
|
|
8
7
|
export { workspaceCommitRequestBytes as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
10
|
var __exportAll = (all, no_symbols) => {
|
|
11
11
|
let target = {};
|
|
12
12
|
for (var name in all) __defProp(target, name, {
|
|
@@ -30,5 +30,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
value: mod,
|
|
31
31
|
enumerable: true
|
|
32
32
|
}) : target, mod));
|
|
33
|
-
//#endregion
|
|
34
33
|
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
|
|
2
|
+
// src/core/rule-keys.ts
|
|
3
|
+
/** The rule fields that a more specific rule replaces only when it sets them. */
|
|
4
|
+
const cascadingRuleKeys = [
|
|
5
|
+
"commit",
|
|
6
|
+
"maxBytes",
|
|
7
|
+
"mediaType",
|
|
8
|
+
"write"
|
|
9
|
+
];
|
|
10
|
+
const workspaceRuleKeys = /* @__PURE__ */ new Set([...cascadingRuleKeys, "validate"]);
|
|
11
|
+
/** Rejects rule keys that ViteHub does not enforce, such as `read`, so that a rule never looks like a protection it is not. */
|
|
12
|
+
function assertWorkspaceRules(rules) {
|
|
13
|
+
for (const [pattern, rule] of Object.entries(rules ?? {})) for (const key of Object.keys(rule ?? {})) {
|
|
14
|
+
if (key === "read") throw workspaceErrorDiagnostics.WORKSPACE_R0075({ message: `[vitehub] Workspace rule "${pattern}" sets read. Workspace rules do not limit reads.` });
|
|
15
|
+
if (!workspaceRuleKeys.has(key)) throw workspaceErrorDiagnostics.WORKSPACE_R0076({ message: `[vitehub] Workspace rule "${pattern}" does not support option "${key}".` });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export { cascadingRuleKeys as n, assertWorkspaceRules as t };
|