@vite-hub/workspace 0.0.4 → 0.3.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 +339 -115
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/blob-database.d.ts +474 -0
- package/dist/blob-database.js +608 -0
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +6 -7
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/config-BAgL2dtB.js +1076 -0
- package/dist/{config-DE9xlaIw.d.ts → config-BQKcPawI.d.ts} +1 -2
- package/dist/discard-CNNtCozM.js +8 -0
- package/dist/durability.d.ts +22 -0
- package/dist/durability.js +70 -0
- package/dist/error-diagnostics-CtKjGtGb.js +188 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/file-2pFYNtsU.js +22 -0
- package/dist/{files-Q6xZjDHA.js → files-BOo4SbwE.js} +3 -3
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-DHnjxQIX.js → github-CrYp4v8k.js} +44 -24
- package/dist/glob-B8YGvTrZ.js +21 -0
- package/dist/glob-Cjxms1t7.js +30 -0
- package/dist/{host-DJH8cuoU.js → host-BFBpXn0N.js} +144 -77
- package/dist/{hosted-RPeJOCFz.js → hosted-KcUR_jPv.js} +303 -97
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +6 -7
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +10 -9
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +26 -47
- package/dist/index.js +30 -100
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-B-enk_4A.js +596 -0
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-DF0F5rcL.js +39 -0
- package/dist/memory-BOexthyW.js +247 -0
- package/dist/metadata-target-CWz6KHKq.js +1589 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-C6FpR8Rr.js +389 -0
- package/dist/operations-CE2drFih.js +1234 -0
- package/dist/operations.d.ts +90 -0
- package/dist/operations.js +3 -0
- package/dist/path--wrT_Azm.js +113 -0
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-C8C0auoW.d.ts +10 -0
- package/dist/provider-9s4Ufkm5.js +1479 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-D3yzt8HQ.js → registry-CNphafBx.js} +60 -23
- package/dist/registry-CYNN623b.d.ts +9 -0
- package/dist/request-scope-Dw5n8bMC.js +83 -0
- package/dist/results-DgkZUmTL.js +8 -0
- package/dist/{chunk-2rV9d50f.js → rolldown-runtime-rQ84J-ij.js} +3 -4
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +7 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -2
- package/dist/runtime/registry.d.ts +2 -0
- package/dist/runtime/registry.js +23 -0
- package/dist/runtime/request.d.ts +4 -0
- package/dist/runtime/request.js +8 -0
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +8 -18
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +52 -17
- package/dist/runtime.js +324 -67
- package/dist/{search-BpiCF2Tw.js → search-C_RfoM2j.js} +10 -9
- package/dist/server-8tGltlGz.js +303 -0
- package/dist/server.d.ts +36 -39
- package/dist/server.js +2 -328
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +10 -7
- package/dist/source-metadata.js +12 -12
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BqCC8BpY.js → state-DbrW-njQ.js} +237 -114
- package/dist/store-ybhyD38Z.js +1873 -0
- package/dist/{sync-DnTQwt8r.js → sync-CCD_VYC8.js} +61 -41
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-CYuwjJ4V.d.ts → types-BbtwmBZ5.d.ts} +321 -35
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BTNDR5Rd.js → use-CSpT5W87.js} +141 -107
- package/dist/utils-CgMZCHsX.js +616 -0
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21369 -2
- package/dist/workspace-CYB2xZ1T.d.ts +7 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-sPWn2Jxj.js} +441 -225
- package/package.json +97 -72
- package/dist/ai-CjxvGqM0.d.ts +0 -162
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-Bc3c4Su1.js +0 -7904
- package/dist/config-CHLLWklZ.js +0 -36
- package/dist/file-Bc1X7pco.js +0 -23
- package/dist/glob-CEZKeZFC.js +0 -18
- package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
- package/dist/lifecycle-LrL3sA4n.js +0 -316
- package/dist/metadata-target-B0tOmVW7.js +0 -717
- package/dist/mountx.d.ts +0 -10
- package/dist/mountx.js +0 -143
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -26
- package/dist/nuxt.js +0 -42
- package/dist/path-Cp59koVz.js +0 -139
- package/dist/provider-B1yLjCJJ.js +0 -746
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-Uj6IVxes.d.ts +0 -11
- package/dist/request-execution-B-dSFlGB.js +0 -84
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/state-tYcRWEh2.d.ts +0 -26
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/token-CVzURBxC.js +0 -61
- package/dist/use-BiHzt0xA.d.ts +0 -103
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
- package/dist/workspace-Xddf4G1B.d.ts +0 -6
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jt as WorkspaceRevision } from "./types-BbtwmBZ5.js";
|
|
2
|
+
import { WorkspaceStaleFile } from "./lineage.js";
|
|
3
|
+
import { t as AnyOperation } from "./operation-definition-8gOe-ubD.js";
|
|
4
|
+
//#region src/results.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The largest `workspace.commit` request body: 4 MiB of JSON, with base64 for binary files. Vercel Functions accept
|
|
7
|
+
* request bodies up to 4.5 MB and Cloudflare Workers up to 100 MB, so one push works on every host.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workspaceCommitRequestBytes: number;
|
|
10
|
+
/** A retained revision as `workspace.history`, `workspace.refs`, and `workspace.show` report it. */
|
|
11
|
+
interface WorkspaceHistoryRevision extends WorkspaceRevision {
|
|
12
|
+
/** The `author` string from the revision metadata, when it has one. */
|
|
13
|
+
author?: string;
|
|
14
|
+
}
|
|
15
|
+
interface WorkspaceHistoryList {
|
|
16
|
+
workspace: string;
|
|
17
|
+
/** Set when the list reads one ref. Without it, the list merges every ref, newest first. */
|
|
18
|
+
ref?: string;
|
|
19
|
+
revisions: WorkspaceHistoryRevision[];
|
|
20
|
+
/** Pass to the next request with the same ref. */
|
|
21
|
+
cursor?: string;
|
|
22
|
+
/** True when older revisions exist than the ones in this list. */
|
|
23
|
+
more: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface WorkspaceHistoryRefs {
|
|
26
|
+
workspace: string;
|
|
27
|
+
refs: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
head: WorkspaceHistoryRevision;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
interface WorkspaceHistoryFile {
|
|
33
|
+
path: string;
|
|
34
|
+
size?: number;
|
|
35
|
+
mediaType?: string;
|
|
36
|
+
/** SHA-256 of the retained bytes, when the Store reports it. */
|
|
37
|
+
digest?: string;
|
|
38
|
+
}
|
|
39
|
+
interface WorkspaceHistoryContent extends WorkspaceHistoryFile {
|
|
40
|
+
/** `utf8` for valid UTF-8 text. Other bytes use `base64`. */
|
|
41
|
+
encoding: "base64" | "utf8";
|
|
42
|
+
content: string;
|
|
43
|
+
}
|
|
44
|
+
interface WorkspaceHistoryDetails {
|
|
45
|
+
workspace: string;
|
|
46
|
+
revision: WorkspaceHistoryRevision;
|
|
47
|
+
/** The path inside the revision, when the request names one. */
|
|
48
|
+
path?: string;
|
|
49
|
+
/** Files of the revision, or of the directory at `path`. */
|
|
50
|
+
files?: WorkspaceHistoryFile[];
|
|
51
|
+
/** The file at `path`. */
|
|
52
|
+
file?: WorkspaceHistoryContent;
|
|
53
|
+
}
|
|
54
|
+
/** A file that differs between two revisions of a ref, as `workspace.changes` reports it. */
|
|
55
|
+
interface WorkspaceChangedFile {
|
|
56
|
+
path: string;
|
|
57
|
+
/** True when the head no longer has the file. */
|
|
58
|
+
deleted?: true;
|
|
59
|
+
/** The file at the head. Missing when it was deleted, or when the call asked for no content. */
|
|
60
|
+
head?: Pick<WorkspaceHistoryContent, "content" | "encoding">;
|
|
61
|
+
/** The file at the base revision, for a three-way merge. Missing when the file is new. */
|
|
62
|
+
base?: Pick<WorkspaceHistoryContent, "content" | "encoding">;
|
|
63
|
+
}
|
|
64
|
+
interface WorkspaceChanges {
|
|
65
|
+
workspace: string;
|
|
66
|
+
ref: string;
|
|
67
|
+
/** The head of the ref, or null when the ref has no revision yet. */
|
|
68
|
+
head: WorkspaceHistoryRevision | null;
|
|
69
|
+
/** Files that changed since the base revision, sorted by path. Every file of the head without a base. */
|
|
70
|
+
files: WorkspaceChangedFile[];
|
|
71
|
+
}
|
|
72
|
+
interface WorkspaceStaleList {
|
|
73
|
+
workspace: string;
|
|
74
|
+
ref: string;
|
|
75
|
+
/** The head that the list reads, or null when the ref has no revision yet. */
|
|
76
|
+
head: string | null;
|
|
77
|
+
stale: WorkspaceStaleFile[];
|
|
78
|
+
}
|
|
79
|
+
interface WorkspaceCommitResult {
|
|
80
|
+
workspace: string;
|
|
81
|
+
revision: WorkspaceHistoryRevision;
|
|
82
|
+
/** Committed bytes of puts whose content changed during write validation or hooks, keyed by request path. */
|
|
83
|
+
normalized?: Record<string, Pick<WorkspaceHistoryContent, "content" | "encoding">>;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/operations.d.ts
|
|
87
|
+
/** The `workspace.*` operations: history, refs, show, changes, commit, and stale. The Console, `vitehub workspace`, and agents run them. */
|
|
88
|
+
export declare const workspaceOperations: readonly AnyOperation[];
|
|
89
|
+
//#endregion
|
|
90
|
+
export type { WorkspaceChangedFile, WorkspaceChanges, WorkspaceCommitResult, WorkspaceHistoryContent, WorkspaceHistoryDetails, WorkspaceHistoryFile, WorkspaceHistoryList, WorkspaceHistoryRefs, WorkspaceHistoryRevision, WorkspaceStaleFile, WorkspaceStaleList };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
|
|
2
|
+
import { l as workspacePathError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
3
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { minimatch } from "minimatch";
|
|
6
|
+
//#region src/core/path.ts
|
|
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
|
+
});
|
|
21
|
+
function normalizeWorkspacePath(path = "") {
|
|
22
|
+
return path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
23
|
+
}
|
|
24
|
+
function isExcludedWorkspacePath(path, excluded = []) {
|
|
25
|
+
const normalized = normalizeWorkspacePath(path);
|
|
26
|
+
return excluded.some((item) => {
|
|
27
|
+
const excludedPath = normalizeWorkspacePath(item);
|
|
28
|
+
return excludedPath === "" || normalized === excludedPath || normalized.startsWith(`${excludedPath}/`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function normalizeSafeWorkspacePattern(pattern) {
|
|
32
|
+
return normalizeSafeWorkspacePath(pattern, {
|
|
33
|
+
allowEmpty: true,
|
|
34
|
+
pattern: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function resolveInside(root, path = "") {
|
|
38
|
+
const resolvedRoot = resolve(root);
|
|
39
|
+
const normalized = normalizeSafeWorkspacePath(path, {
|
|
40
|
+
allowEmpty: true,
|
|
41
|
+
allowReserved: true
|
|
42
|
+
});
|
|
43
|
+
const resolved = resolve(resolvedRoot, normalized);
|
|
44
|
+
const rel = relative(resolvedRoot, resolved);
|
|
45
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) throw workspacePathError(path);
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
function matchesAny(path, patterns) {
|
|
49
|
+
if (!patterns) return true;
|
|
50
|
+
const list = Array.isArray(patterns) ? patterns : [patterns];
|
|
51
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
52
|
+
return list.some((pattern) => minimatch(normalizedPath, normalizeWorkspacePath(pattern), { dot: true }));
|
|
53
|
+
}
|
|
54
|
+
const typedArrayTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag)?.get;
|
|
55
|
+
/** Recognize byte arrays from VM and sandbox realms. */
|
|
56
|
+
function isWorkspaceBytes(value) {
|
|
57
|
+
return ArrayBuffer.isView(value) && typedArrayTag?.call(value) === "Uint8Array";
|
|
58
|
+
}
|
|
59
|
+
function contentToBytes(content) {
|
|
60
|
+
return typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
61
|
+
}
|
|
62
|
+
function isReadableStream(value) {
|
|
63
|
+
return Boolean(value && typeof value.getReader === "function");
|
|
64
|
+
}
|
|
65
|
+
async function* contentStreamChunks(stream) {
|
|
66
|
+
if (isReadableStream(stream)) {
|
|
67
|
+
const reader = stream.getReader();
|
|
68
|
+
let completed = false;
|
|
69
|
+
try {
|
|
70
|
+
while (true) {
|
|
71
|
+
const chunk = await reader.read();
|
|
72
|
+
if (chunk.done) {
|
|
73
|
+
completed = true;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
yield chunk.value;
|
|
77
|
+
}
|
|
78
|
+
} finally {
|
|
79
|
+
try {
|
|
80
|
+
if (!completed) await reader.cancel();
|
|
81
|
+
} finally {
|
|
82
|
+
reader.releaseLock();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
yield* stream;
|
|
88
|
+
}
|
|
89
|
+
async function contentStreamToBytes(stream) {
|
|
90
|
+
const chunks = [];
|
|
91
|
+
let size = 0;
|
|
92
|
+
for await (const chunk of contentStreamChunks(stream)) {
|
|
93
|
+
chunks.push(chunk);
|
|
94
|
+
size += chunk.byteLength;
|
|
95
|
+
}
|
|
96
|
+
const bytes = new Uint8Array(size);
|
|
97
|
+
let offset = 0;
|
|
98
|
+
for (const chunk of chunks) {
|
|
99
|
+
bytes.set(chunk, offset);
|
|
100
|
+
offset += chunk.byteLength;
|
|
101
|
+
}
|
|
102
|
+
return bytes;
|
|
103
|
+
}
|
|
104
|
+
function decodeFile(content, options) {
|
|
105
|
+
if (options?.encoding === "binary") return content;
|
|
106
|
+
return typeof content === "string" ? content : new TextDecoder().decode(content);
|
|
107
|
+
}
|
|
108
|
+
async function sha256(input) {
|
|
109
|
+
const bytes = contentToBytes(typeof input === "string" || isWorkspaceBytes(input) ? input : JSON.stringify(input));
|
|
110
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
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 };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./types-BbtwmBZ5.js";
|
|
2
|
+
import { ViteHubError } from "@vite-hub/runtime";
|
|
3
|
+
//#region src/core/errors.d.ts
|
|
4
|
+
type WorkspaceErrorCode = "WORKSPACE_CONFLICT" | "WORKSPACE_FAILED" | "WORKSPACE_NOT_FOUND" | "WORKSPACE_PATH_INVALID";
|
|
5
|
+
declare function isWorkspaceConflict(value: unknown): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isWorkspaceConflict as n, WorkspaceErrorCode as t };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ViteHubError, getViteHubErrorShape } from "@vite-hub/runtime";
|
|
2
|
+
//#region src/core/errors.ts
|
|
3
|
+
function workspaceError(message, options) {
|
|
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
|
+
return new ViteHubError(code, message, options);
|
|
6
|
+
}
|
|
7
|
+
function workspaceConflict(message, options) {
|
|
8
|
+
return new ViteHubError("WORKSPACE_CONFLICT", message, options);
|
|
9
|
+
}
|
|
10
|
+
function workspaceConflictError(path, expected, actual) {
|
|
11
|
+
return workspaceConflict(`[vitehub] Workspace path changed before the conditional write: ${path}.`, { details: {
|
|
12
|
+
actual,
|
|
13
|
+
expected,
|
|
14
|
+
path
|
|
15
|
+
} });
|
|
16
|
+
}
|
|
17
|
+
function assertWorkspaceDigest(path, expected, actual) {
|
|
18
|
+
if (expected === null ? actual !== void 0 : actual !== expected) throw workspaceConflictError(path, expected, actual);
|
|
19
|
+
}
|
|
20
|
+
function workspaceNotFoundError(name) {
|
|
21
|
+
return new ViteHubError("WORKSPACE_NOT_FOUND", `[vitehub] Workspace "${name}" is not registered.`, { details: { name } });
|
|
22
|
+
}
|
|
23
|
+
function workspacePathError(path) {
|
|
24
|
+
const publicPath = path.slice(0, 4096);
|
|
25
|
+
return new ViteHubError("WORKSPACE_PATH_INVALID", `[vitehub] Workspace path escapes the workspace root: ${JSON.stringify(publicPath)}.`, { details: { path: publicPath } });
|
|
26
|
+
}
|
|
27
|
+
function isWorkspaceError(value) {
|
|
28
|
+
const code = getViteHubErrorShape(value)?.code;
|
|
29
|
+
return code === "WORKSPACE_CONFLICT" || code === "WORKSPACE_FAILED" || code === "WORKSPACE_NOT_FOUND" || code === "WORKSPACE_PATH_INVALID";
|
|
30
|
+
}
|
|
31
|
+
function isWorkspaceConflict(value) {
|
|
32
|
+
return getViteHubErrorShape(value)?.code === "WORKSPACE_CONFLICT";
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/internal/path.ts
|
|
36
|
+
function classifyWindowsComponent(part) {
|
|
37
|
+
const withoutStream = part.toLowerCase().split(":", 1)[0];
|
|
38
|
+
return {
|
|
39
|
+
normalized: withoutStream.replace(/[ .]+$/, ""),
|
|
40
|
+
isTraversal: /^(?:\.(?: +[. ]*)?|\.\.(?: +[. ]*)?)$/.test(withoutStream)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizeSafeWorkspacePath(path = "", options = {}) {
|
|
44
|
+
const raw = path.replace(/\\/g, "/");
|
|
45
|
+
const normalized = raw.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
46
|
+
const parts = normalized.split("/").filter(Boolean);
|
|
47
|
+
if (!options.allowEmpty && !normalized) throw workspacePathError(path);
|
|
48
|
+
if (raw.startsWith("/") || /^[a-z]:/i.test(raw) || raw.includes("\0")) throw workspacePathError(path);
|
|
49
|
+
if (parts.some((part, index) => {
|
|
50
|
+
const name = part.toLowerCase();
|
|
51
|
+
const classification = classifyWindowsComponent(part);
|
|
52
|
+
const reserved = classification.normalized === ".git" || /^git~\d+$/.test(classification.normalized) || index === 0 && classification.normalized === ".vitehub" || index === 0 && /^vitehu~\d+$/.test(classification.normalized);
|
|
53
|
+
const canonical = (classification.normalized === ".git" || index === 0 && classification.normalized === ".vitehub") && name === classification.normalized;
|
|
54
|
+
return classification.isTraversal || reserved && (!options.allowReserved || !canonical);
|
|
55
|
+
})) throw workspacePathError(path);
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/internal/path.d.ts
|
|
2
|
+
interface SafeWorkspacePathOptions {
|
|
3
|
+
allowEmpty?: boolean;
|
|
4
|
+
allowReserved?: boolean;
|
|
5
|
+
pattern?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function normalizeSafeWorkspacePath(path?: string, options?: SafeWorkspacePathOptions): string;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { normalizeSafeWorkspacePath as n, SafeWorkspacePathOptions as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Et as WorkspacePlugin } from "./types-BbtwmBZ5.js";
|
|
2
|
+
//#region src/core/plugins.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Add a plugin's rules and hooks to a Workspace by name, including discovered Workspaces the caller does not define.
|
|
5
|
+
* Registering the same plugin id again replaces the earlier registration. A plugin declared by the Workspace Definition
|
|
6
|
+
* with the same id wins. The returned function removes this registration.
|
|
7
|
+
*/
|
|
8
|
+
declare function registerWorkspacePlugin(workspace: string, plugin: WorkspacePlugin): () => void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { registerWorkspacePlugin as t };
|