@vite-hub/workspace 0.1.0 → 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.
Files changed (134) hide show
  1. package/README.md +164 -107
  2. package/dist/abort-BCwpdrN0.js +32 -0
  3. package/dist/blob-database.d.ts +70 -117
  4. package/dist/blob-database.js +48 -41
  5. package/dist/checkout.d.ts +128 -0
  6. package/dist/checkout.js +849 -0
  7. package/dist/cloudflare.d.ts +2 -2
  8. package/dist/cloudflare.js +1 -1
  9. package/dist/config-B-863EgC.js +15 -0
  10. package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
  11. package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
  12. package/dist/discard-CNNtCozM.js +8 -0
  13. package/dist/durability.d.ts +22 -0
  14. package/dist/durability.js +70 -0
  15. package/dist/error-diagnostics-CtKjGtGb.js +188 -0
  16. package/dist/error-diagnostics-DSkCJC_L.js +266 -0
  17. package/dist/file-2pFYNtsU.js +22 -0
  18. package/dist/{files-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
  19. package/dist/files.d.ts +38 -0
  20. package/dist/files.js +6 -0
  21. package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
  22. package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
  23. package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
  24. package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
  25. package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
  26. package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
  27. package/dist/hosted-vercel-blob.d.ts +2 -2
  28. package/dist/hosted-vercel-blob.js +1 -1
  29. package/dist/hosted.d.ts +5 -3
  30. package/dist/hosted.js +2 -2
  31. package/dist/index.d.ts +9 -51
  32. package/dist/index.js +21 -91
  33. package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
  34. package/dist/lineage.d.ts +26 -0
  35. package/dist/lineage.js +76 -0
  36. package/dist/loader.d.ts +1 -1
  37. package/dist/loader.js +2 -2
  38. package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
  39. package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
  40. package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
  41. package/dist/object-Da1zyPCR.js +11 -0
  42. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  43. package/dist/operations-C6FpR8Rr.js +389 -0
  44. package/dist/operations-CE2drFih.js +1234 -0
  45. package/dist/operations.d.ts +41 -4
  46. package/dist/operations.js +3 -2
  47. package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
  48. package/dist/path-AxMho1wo.d.ts +7 -0
  49. package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
  50. package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
  51. package/dist/providers/github/store.d.ts +1 -1
  52. package/dist/providers/github/store.js +1 -1
  53. package/dist/registry-B3BBm4Ts.d.ts +19 -0
  54. package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
  55. package/dist/registry-CYNN623b.d.ts +9 -0
  56. package/dist/request-scope-Dw5n8bMC.js +83 -0
  57. package/dist/results-DgkZUmTL.js +8 -0
  58. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
  59. package/dist/runtime/assets.d.ts +1 -1
  60. package/dist/runtime/assets.js +3 -3
  61. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  62. package/dist/runtime/empty-registry.d.ts +2 -1
  63. package/dist/runtime/registry.d.ts +2 -0
  64. package/dist/runtime/registry.js +23 -0
  65. package/dist/runtime/request.d.ts +4 -0
  66. package/dist/runtime/request.js +8 -0
  67. package/dist/runtime/state.d.ts +5 -4
  68. package/dist/runtime/state.js +8 -18
  69. package/dist/runtime/workspace.d.ts +1 -1
  70. package/dist/runtime/workspace.js +1 -1
  71. package/dist/runtime.d.ts +9 -8
  72. package/dist/runtime.js +23 -26
  73. package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
  74. package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
  75. package/dist/server.d.ts +17 -8
  76. package/dist/server.js +1 -1
  77. package/dist/shared-B3_EUk89.js +848 -0
  78. package/dist/source-metadata.d.ts +6 -2
  79. package/dist/source-metadata.js +8 -8
  80. package/dist/state-BISnUf1s.d.ts +35 -0
  81. package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
  82. package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
  83. package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
  84. package/dist/target-jWhTdIuF.js +89 -0
  85. package/dist/test.d.ts +1 -1
  86. package/dist/test.js +1 -1
  87. package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
  88. package/dist/use-C6lV3-wC.d.ts +321 -0
  89. package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
  90. package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
  91. package/dist/vite.d.ts +585 -2
  92. package/dist/vite.js +21368 -1
  93. package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
  94. package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
  95. package/package.json +46 -55
  96. package/dist/ai-BW2ZhizI.d.ts +0 -177
  97. package/dist/ai.d.ts +0 -3
  98. package/dist/ai.js +0 -2
  99. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
  100. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  101. package/dist/error-diagnostics-DY5GP47p.js +0 -96
  102. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
  103. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
  104. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
  105. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
  106. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
  107. package/dist/file-C0_aPWSS.js +0 -26
  108. package/dist/file-metadata-CxDy-E2H.js +0 -58
  109. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
  110. package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
  111. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
  112. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
  113. package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
  114. package/dist/inspect-BoObD2cJ.js +0 -167
  115. package/dist/mountx.d.ts +0 -8
  116. package/dist/mountx.js +0 -145
  117. package/dist/nitro.d.ts +0 -2
  118. package/dist/nitro.js +0 -2
  119. package/dist/nuxt.d.ts +0 -27
  120. package/dist/nuxt.js +0 -38
  121. package/dist/operations-BcpWr41m.js +0 -159
  122. package/dist/operations-CGqY1XeG.js +0 -965
  123. package/dist/operations-DnOwKsJT.d.ts +0 -136
  124. package/dist/registry-Cg1TJVVZ.d.ts +0 -10
  125. package/dist/request-execution-Dk9rY-Yh.js +0 -84
  126. package/dist/shared-DalXdP0i.js +0 -2158
  127. package/dist/state-B8zbLi5t.d.ts +0 -26
  128. package/dist/target-D4Bqb1eH.js +0 -11
  129. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
  130. package/dist/token-CO62GglH.js +0 -61
  131. package/dist/use-DhwhbAVV.d.ts +0 -108
  132. package/dist/vite-BEvgU2GY.js +0 -20909
  133. package/dist/vite-CcZmMQ7S.d.ts +0 -476
  134. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
@@ -1,167 +0,0 @@
1
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
2
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3
- function normalizeWindowsPath(input = "") {
4
- if (!input) return input;
5
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
6
- }
7
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
8
- const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
9
- const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
10
- function cwd() {
11
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
12
- return "/";
13
- }
14
- const resolve = function(...arguments_) {
15
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
16
- let resolvedPath = "";
17
- let resolvedAbsolute = false;
18
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
19
- const path = index >= 0 ? arguments_[index] : cwd();
20
- if (!path || path.length === 0) continue;
21
- resolvedPath = `${path}/${resolvedPath}`;
22
- resolvedAbsolute = isAbsolute(path);
23
- }
24
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
25
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
26
- return resolvedPath.length > 0 ? resolvedPath : ".";
27
- };
28
- function normalizeString(path, allowAboveRoot) {
29
- let res = "";
30
- let lastSegmentLength = 0;
31
- let lastSlash = -1;
32
- let dots = 0;
33
- let char = null;
34
- for (let index = 0; index <= path.length; ++index) {
35
- if (index < path.length) char = path[index];
36
- else if (char === "/") break;
37
- else char = "/";
38
- if (char === "/") {
39
- if (lastSlash === index - 1 || dots === 1);
40
- else if (dots === 2) {
41
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
42
- if (res.length > 2) {
43
- const lastSlashIndex = res.lastIndexOf("/");
44
- if (lastSlashIndex === -1) {
45
- res = "";
46
- lastSegmentLength = 0;
47
- } else {
48
- res = res.slice(0, lastSlashIndex);
49
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
50
- }
51
- lastSlash = index;
52
- dots = 0;
53
- continue;
54
- } else if (res.length > 0) {
55
- res = "";
56
- lastSegmentLength = 0;
57
- lastSlash = index;
58
- dots = 0;
59
- continue;
60
- }
61
- }
62
- if (allowAboveRoot) {
63
- res += res.length > 0 ? "/.." : "..";
64
- lastSegmentLength = 2;
65
- }
66
- } else {
67
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
68
- else res = path.slice(lastSlash + 1, index);
69
- lastSegmentLength = index - lastSlash - 1;
70
- }
71
- lastSlash = index;
72
- dots = 0;
73
- } else if (char === "." && dots !== -1) ++dots;
74
- else dots = -1;
75
- }
76
- return res;
77
- }
78
- const isAbsolute = function(p) {
79
- return _IS_ABSOLUTE_RE.test(p);
80
- };
81
- const relative = function(from, to) {
82
- const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
83
- const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
84
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
85
- const _fromCopy = [..._from];
86
- for (const segment of _fromCopy) {
87
- if (_to[0] !== segment) break;
88
- _from.shift();
89
- _to.shift();
90
- }
91
- return [..._from.map(() => ".."), ..._to].join("/");
92
- };
93
- const dirname = function(p) {
94
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
95
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
96
- return segments.join("/") || (isAbsolute(p) ? "/" : ".");
97
- };
98
- //#endregion
99
- //#region ../internal/src/inspect.ts
100
- function relativeDefinitionFile(projectRoot, file) {
101
- return relative(projectRoot, file).replaceAll("\\", "/");
102
- }
103
- const redactedInspectionValue = "[redacted]";
104
- const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
105
- const secretValuePattern = /^(?:[a-z][a-z0-9+.-]*:\/\/[^/\s?#]*@|bearer\s)/i;
106
- /** Whether an inspection field names a credential, regardless of its value. */
107
- function isSecretInspectionKey(key) {
108
- return secretKeyPattern.test(key);
109
- }
110
- const embeddedUrlCredentialPattern = /\b([a-z][a-z0-9+.-]*:\/\/)[^/\s?#]*@/gi;
111
- const embeddedCookiePattern = /\b([\w-]*cookie[\w-]*["']?\s*[:=]\s*)(?:"(?:\\[^\r\n]|[^"\\\r\n])*"(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|'(?:\\[^\r\n]|[^'\\\r\n])*'(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|[^\r\n]+?(?=\s*(?:;\s*[^;=\r\n/]+\s*(?:\r?\n|$)|&|\r?\n|$)))/gi;
112
- const embeddedBearerPattern = /\bbearer\s+[^\s,;]+/gi;
113
- const embeddedAuthorizationPattern = new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
114
- const embeddedSecretAssignmentPattern = new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
115
- /**
116
- * Removes credentials inside free text, for example an error message. URL credentials, bearer tokens, and
117
- * `name=value` pairs with a secret name are replaced with `[redacted]`.
118
- */
119
- function redactInspectionText(value) {
120
- return value.replace(embeddedUrlCredentialPattern, `$1${redactedInspectionValue}@`).replace(embeddedAuthorizationPattern, `$1${redactedInspectionValue}`).replace(embeddedCookiePattern, `$1${redactedInspectionValue}`).replace(embeddedBearerPattern, `Bearer ${redactedInspectionValue}`).replace(embeddedSecretAssignmentPattern, `$1${redactedInspectionValue}`);
121
- }
122
- /**
123
- * Removes values that can carry credentials before inspection output leaves the process.
124
- * Keys that name secrets, plaintext Worker `vars`, and URLs with embedded credentials are redacted.
125
- */
126
- function redactInspectionValue(value, key) {
127
- const seen = /* @__PURE__ */ new WeakSet();
128
- let remaining = 1e3;
129
- function visit(entry, entryKey, depth = 0) {
130
- if (entryKey && isSecretInspectionKey(entryKey)) return redactedInspectionValue;
131
- if (--remaining < 0 || depth > 10) return "[truncated]";
132
- if (typeof entry === "string") {
133
- const text = entry.slice(0, 1e4);
134
- return secretValuePattern.test(text) ? redactedInspectionValue : redactInspectionText(text);
135
- }
136
- if (typeof entry === "bigint") return entry.toString();
137
- if (typeof entry === "number") return Number.isFinite(entry) ? entry : String(entry);
138
- if (entry === null || typeof entry === "boolean") return entry;
139
- if (typeof entry !== "object") return entry === void 0 ? null : "[unsupported]";
140
- if (seen.has(entry)) return "[circular]";
141
- seen.add(entry);
142
- try {
143
- let dateTime;
144
- try {
145
- dateTime = Date.prototype.getTime.call(entry);
146
- } catch {}
147
- if (dateTime !== void 0) return Number.isNaN(dateTime) ? "Invalid Date" : Date.prototype.toISOString.call(entry);
148
- if (Array.isArray(entry)) return entry.slice(0, 100).map((item) => visit(item, void 0, depth + 1));
149
- let setValues;
150
- try {
151
- setValues = [...Set.prototype.values.call(entry)];
152
- } catch {}
153
- if (setValues) return setValues.slice(0, 100).map((item) => visit(item, void 0, depth + 1));
154
- let mapEntries;
155
- try {
156
- mapEntries = [...Map.prototype.entries.call(entry)];
157
- } catch {}
158
- const entries = mapEntries ? mapEntries.map(([name, item]) => [String(name), item]) : Object.entries(entry);
159
- return Object.fromEntries(entries.slice(0, 100).map(([name, item]) => [name, name === "vars" && item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).slice(0, 100).map((variable) => [variable, redactedInspectionValue])) : visit(item, name, depth + 1)]));
160
- } finally {
161
- seen.delete(entry);
162
- }
163
- }
164
- return visit(value, key);
165
- }
166
- //#endregion
167
- export { isAbsolute as a, dirname as i, redactInspectionValue as n, relative as o, relativeDefinitionFile as r, resolve as s, redactInspectionText as t };
package/dist/mountx.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Rt as WorkspaceSession } from "./types-DeK9GIxy.js";
2
- import { FsDriver } from "mountx";
3
- //#region src/mountx.d.ts
4
- export interface WorkspaceMountXDriverOptions {
5
- readOnly?: boolean;
6
- }
7
- export declare function createWorkspaceDriver(session: WorkspaceSession, options?: WorkspaceMountXDriverOptions): FsDriver;
8
- //#endregion
package/dist/mountx.js DELETED
@@ -1,145 +0,0 @@
1
- import { o as isWorkspaceBytes } from "./path-CNAwN7pw.js";
2
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
3
- import { posix } from "node:path";
4
- import { createUnstorageDriver } from "mountx/drivers/unstorage";
5
- //#region src/mountx.ts
6
- function keyToPath(key) {
7
- return key.split(":").join("/");
8
- }
9
- function pathToKey(path) {
10
- return path.split("/").join(":");
11
- }
12
- function valueToBytes(value) {
13
- if (isWorkspaceBytes(value)) return value;
14
- if (value instanceof ArrayBuffer) return new Uint8Array(value);
15
- if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
16
- return new TextEncoder().encode(typeof value === "string" ? value : JSON.stringify(value));
17
- }
18
- async function findEntry(session, path) {
19
- if (!path) return void 0;
20
- const parent = posix.dirname(path);
21
- return (await session.list(parent === "." ? "" : parent)).find((entry) => entry.path === path);
22
- }
23
- function assertProjectablePath(path) {
24
- const invalidName = path.split("/").find((segment) => segment.includes(":") || segment.includes("?") || segment.endsWith("$"));
25
- if (invalidName) throw Object.assign(workspaceErrorDiagnostics.WORKSPACE_R0031({ message: `Workspace filename is not representable as an unstorage key: ${invalidName}` }), {
26
- code: "EINVAL",
27
- path
28
- });
29
- }
30
- function assertProjectableEntry(entry) {
31
- if (entry) assertProjectablePath(entry.path);
32
- if (entry?.metadata?.gitMode !== "120000") return entry;
33
- throw Object.assign(workspaceErrorDiagnostics.WORKSPACE_R0032({ message: `MountX cannot project Workspace symlink semantics: ${entry.path}` }), {
34
- code: "ENOTSUP",
35
- path: entry.path
36
- });
37
- }
38
- function createWorkspaceStorage(session, readOnly) {
39
- const writeOptionsByValue = /* @__PURE__ */ new WeakMap();
40
- async function readItem(key) {
41
- const path = keyToPath(key);
42
- const entry = assertProjectableEntry(await findEntry(session, path));
43
- if (entry?.type !== "file") return null;
44
- const value = valueToBytes(await session.readFile(path, { encoding: "binary" }));
45
- writeOptionsByValue.set(value, {
46
- mediaType: entry.mediaType,
47
- metadata: entry.metadata
48
- });
49
- return value;
50
- }
51
- return {
52
- getItem: readItem,
53
- getItemRaw: readItem,
54
- async getKeys(base) {
55
- const path = keyToPath(base);
56
- return (await session.list(path, { recursive: true })).filter((entry) => assertProjectableEntry(entry)?.type === "file").map((entry) => pathToKey(entry.path));
57
- },
58
- async getMeta(key) {
59
- const entry = assertProjectableEntry(await findEntry(session, keyToPath(key)));
60
- if (!entry) return null;
61
- return {
62
- mtime: entry.mtime === void 0 ? void 0 : new Date(entry.mtime),
63
- size: entry.size
64
- };
65
- },
66
- async hasItem(key) {
67
- return assertProjectableEntry(await findEntry(session, keyToPath(key)))?.type === "file";
68
- },
69
- ...!readOnly ? {
70
- async removeItem(key) {
71
- await session.rm(keyToPath(key), { force: true });
72
- },
73
- async setItemRaw(key, value) {
74
- const path = keyToPath(key);
75
- const entry = assertProjectableEntry(await findEntry(session, path));
76
- const writeOptions = isWorkspaceBytes(value) ? writeOptionsByValue.get(value) : void 0;
77
- await session.writeFile(path, valueToBytes(value), writeOptions ?? {
78
- mediaType: entry?.mediaType,
79
- metadata: entry?.metadata
80
- });
81
- }
82
- } : void 0
83
- };
84
- }
85
- function createWorkspaceDriver(session, options = {}) {
86
- const readOnly = options.readOnly ?? false;
87
- const driver = createUnstorageDriver(createWorkspaceStorage(session, readOnly), { readOnly });
88
- function projectExecutableMode(stats, executable) {
89
- if (executable) stats.mode |= 73;
90
- return stats;
91
- }
92
- async function projectStats(path, stats) {
93
- return projectExecutableMode(stats, assertProjectableEntry(await findEntry(session, path.replace(/^\/+/, "")))?.metadata?.gitMode === "100755");
94
- }
95
- async function stat(path) {
96
- assertProjectablePath(path);
97
- return await projectStats(path, await driver.stat(path));
98
- }
99
- const singlePathMethods = /* @__PURE__ */ new Set([
100
- "chmod",
101
- "chown",
102
- "lchown",
103
- "lutimes",
104
- "mkdir",
105
- "readlink",
106
- "readdir",
107
- "rmdir",
108
- "statfs",
109
- "truncate",
110
- "unlink",
111
- "utimes"
112
- ]);
113
- const twoPathMethods = /* @__PURE__ */ new Set(["link", "rename"]);
114
- return new Proxy(driver, { get(target, property) {
115
- if (property === "stat" || property === "lstat") return stat;
116
- const value = Reflect.get(target, property, target);
117
- if (typeof value !== "function") return value;
118
- if (property === "open") return async (path, ...args) => {
119
- assertProjectablePath(path);
120
- const executable = assertProjectableEntry(await findEntry(session, path.replace(/^\/+/, "")))?.metadata?.gitMode === "100755";
121
- const handle = await value.call(target, path, ...args);
122
- return new Proxy(handle, { get(handleTarget, handleProperty) {
123
- if (handleProperty === "stat") return async () => projectExecutableMode(await handleTarget.stat(), executable);
124
- const handleValue = Reflect.get(handleTarget, handleProperty, handleTarget);
125
- return typeof handleValue === "function" ? handleValue.bind(handleTarget) : handleValue;
126
- } });
127
- };
128
- if (singlePathMethods.has(property)) return (path, ...args) => {
129
- assertProjectablePath(path);
130
- return value.call(target, path, ...args);
131
- };
132
- if (twoPathMethods.has(property)) return (from, to, ...args) => {
133
- assertProjectablePath(from);
134
- assertProjectablePath(to);
135
- return value.call(target, from, to, ...args);
136
- };
137
- if (property === "symlink") return (linkTarget, path, ...args) => {
138
- assertProjectablePath(path);
139
- return value.call(target, linkTarget, path, ...args);
140
- };
141
- return value.bind(target);
142
- } });
143
- }
144
- //#endregion
145
- export { createWorkspaceDriver };
package/dist/nitro.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { _ as createWorkspaceNitroConfig, m as WorkspaceNitroConfigOptions, p as NitroConfig } from "./vite-CcZmMQ7S.js";
2
- export { type NitroConfig, type WorkspaceNitroConfigOptions, createWorkspaceNitroConfig };
package/dist/nitro.js DELETED
@@ -1,2 +0,0 @@
1
- import { t as createWorkspaceNitroConfig } from "./vite-BEvgU2GY.js";
2
- export { createWorkspaceNitroConfig };
package/dist/nuxt.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { xt as WorkspaceModuleOptions } from "./types-DeK9GIxy.js";
2
- //#region src/nuxt.d.ts
3
- export interface WorkspaceNuxtModuleOptions extends WorkspaceModuleOptions {}
4
- type NuxtLike = {
5
- hook?: (name: "nitro:config", handler: (nitroConfig: Record<string, unknown>) => void | Promise<void>) => void;
6
- options: {
7
- alias?: Record<string, string>;
8
- dev?: boolean;
9
- rootDir?: string;
10
- serverDir?: string;
11
- srcDir?: string;
12
- _layers?: ReadonlyArray<{
13
- config?: {
14
- rootDir?: string;
15
- serverDir?: string;
16
- srcDir?: string;
17
- };
18
- cwd?: string;
19
- }>;
20
- vite?: {
21
- plugins?: unknown[];
22
- workspace?: false | WorkspaceModuleOptions;
23
- };
24
- };
25
- };
26
- export default function viteHubWorkspaceNuxtModule(options?: WorkspaceNuxtModuleOptions, nuxt?: NuxtLike): void;
27
- //#endregion
package/dist/nuxt.js DELETED
@@ -1,38 +0,0 @@
1
- import { c as resolveNuxtServerDirs, n as hubWorkspace, r as setWorkspaceVitePluginHosting, t as createWorkspaceNitroConfig } from "./vite-BEvgU2GY.js";
2
- //#region src/nuxt.ts
3
- function isWorkspaceVitePlugin(value) {
4
- return Boolean(value && typeof value === "object" && value.name === "@vite-hub/workspace/vite");
5
- }
6
- function resolveWorkspaceOptions(options, viteOptions) {
7
- if (viteOptions !== void 0) return viteOptions;
8
- return Object.keys(options).length > 0 ? options : void 0;
9
- }
10
- function viteHubWorkspaceNuxtModule(options = {}, nuxt) {
11
- if (!nuxt) return;
12
- nuxt.options.vite ??= {};
13
- const workspaceOptions = resolveWorkspaceOptions(options, nuxt.options.vite.workspace);
14
- let resolvedNitroHosting;
15
- const plugins = Array.isArray(nuxt.options.vite.plugins) ? nuxt.options.vite.plugins : [];
16
- if (!plugins.some(isWorkspaceVitePlugin)) plugins.push(hubWorkspace({
17
- ...workspaceOptions,
18
- hosting: () => resolvedNitroHosting
19
- }));
20
- for (const plugin of plugins) if (isWorkspaceVitePlugin(plugin)) setWorkspaceVitePluginHosting(plugin, () => resolvedNitroHosting);
21
- nuxt.options.vite.plugins = plugins;
22
- nuxt.hook?.("nitro:config", async (nitroConfig) => {
23
- resolvedNitroHosting = typeof nitroConfig.preset === "string" ? nitroConfig.preset : void 0;
24
- const rootDir = nuxt.options.rootDir || process.cwd();
25
- const nitro = await createWorkspaceNitroConfig({
26
- aliases: nuxt.options.alias,
27
- command: nuxt.options.dev ? "serve" : "build",
28
- nitro: nitroConfig,
29
- plugins: nuxt.options.vite?.plugins,
30
- serverDirs: resolveNuxtServerDirs(nuxt.options),
31
- viteRoot: nuxt.options.srcDir || rootDir,
32
- workspace: workspaceOptions
33
- });
34
- if (nitro) Object.assign(nitroConfig, nitro);
35
- });
36
- }
37
- //#endregion
38
- export { viteHubWorkspaceNuxtModule as default };
@@ -1,159 +0,0 @@
1
- import { t as useWorkspace } from "./use-BQj7nSz6.js";
2
- import { t as redactInspectionText } from "./inspect-BoObD2cJ.js";
3
- import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
4
- //#region src/runtime/operations.ts
5
- const invalidRequestCodes = /* @__PURE__ */ new Set([
6
- "WORKSPACE_PATH_INVALID",
7
- "WORKSPACE_R0070",
8
- "WORKSPACE_R0071"
9
- ]);
10
- /** A history read failure with its HTTP status. */
11
- var WorkspaceOperationError = class extends Error {
12
- code;
13
- status;
14
- constructor(code, status, message) {
15
- super(message);
16
- this.code = code;
17
- this.status = status;
18
- this.name = "WorkspaceOperationError";
19
- }
20
- };
21
- /** Reads the code of a ViteHub error or a Workspace diagnostic. */
22
- function errorCode(error) {
23
- const code = Object(error) === error ? Reflect.get(Object(error), "code") : void 0;
24
- return hasRuntimeType(code, "string") ? code : void 0;
25
- }
26
- function isoTime(value) {
27
- const time = Date.parse(value);
28
- return Number.isNaN(time) ? value : new Date(time).toISOString();
29
- }
30
- function describeRevision(revision) {
31
- const author = revision.metadata?.author;
32
- const result = {
33
- ...revision,
34
- createdAt: isoTime(revision.createdAt)
35
- };
36
- if (hasRuntimeType(author, "string") && author) result.author = author;
37
- return result;
38
- }
39
- function describeFile(entry) {
40
- const result = { path: entry.path };
41
- if (entry.size !== void 0) result.size = entry.size;
42
- if (entry.mediaType !== void 0) result.mediaType = entry.mediaType;
43
- if (entry.digest !== void 0) result.digest = entry.digest;
44
- return result;
45
- }
46
- function encodeContent(bytes) {
47
- try {
48
- return {
49
- content: new TextDecoder("utf-8", { fatal: true }).decode(bytes),
50
- encoding: "utf8"
51
- };
52
- } catch {
53
- let binary = "";
54
- for (let index = 0; index < bytes.length; index += 32768) binary += String.fromCharCode(...bytes.subarray(index, index + 32768));
55
- return {
56
- content: btoa(binary),
57
- encoding: "base64"
58
- };
59
- }
60
- }
61
- async function listHistory(workspace, history, request) {
62
- const limit = request.limit ?? 20;
63
- if (request.ref !== void 0) {
64
- const page = await history.list({
65
- cursor: request.cursor,
66
- limit,
67
- ref: request.ref
68
- });
69
- return {
70
- workspace,
71
- ref: request.ref,
72
- revisions: page.revisions.map(describeRevision),
73
- cursor: page.cursor,
74
- more: Boolean(page.cursor)
75
- };
76
- }
77
- const pages = await Promise.all((await history.refs()).map(async (ref) => await history.list({
78
- limit,
79
- ref: ref.name
80
- })));
81
- const revisions = pages.flatMap((page) => page.revisions).map(describeRevision).sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt));
82
- return {
83
- workspace,
84
- revisions: revisions.slice(0, limit),
85
- more: revisions.length > limit || pages.some((page) => page.cursor)
86
- };
87
- }
88
- async function showRevision(workspace, history, request) {
89
- const ref = (await history.refs()).find((entry) => entry.name === request.target);
90
- let view;
91
- try {
92
- view = await history.open(ref ? ref.head.id : request.target);
93
- } catch (error) {
94
- if (errorCode(error) !== "WORKSPACE_NOT_FOUND") throw error;
95
- throw new WorkspaceOperationError("WORKSPACE_NOT_FOUND", 404, `Workspace "${workspace}" has no ref or revision "${request.target}". Run \`vitehub workspace refs ${workspace}\` to list refs.`);
96
- }
97
- const revision = describeRevision(view.revision);
98
- if (request.path === void 0) return {
99
- workspace,
100
- revision,
101
- files: (await view.list("", { recursive: true })).filter((entry) => entry.type === "file").map(describeFile)
102
- };
103
- let stat;
104
- try {
105
- stat = await view.stat(request.path);
106
- } catch (error) {
107
- if (errorCode(error) !== "WORKSPACE_NOT_FOUND") throw error;
108
- throw new WorkspaceOperationError("WORKSPACE_NOT_FOUND", 404, `Revision ${revision.id} has no path "${request.path}".`);
109
- }
110
- if (stat.type === "directory") {
111
- const files = (await view.list(stat.path, { recursive: true })).filter((entry) => entry.type === "file").map(describeFile);
112
- return {
113
- workspace,
114
- revision,
115
- path: stat.path,
116
- files
117
- };
118
- }
119
- const bytes = await view.readFile(stat.path, { encoding: "binary" });
120
- return {
121
- workspace,
122
- revision,
123
- path: stat.path,
124
- file: {
125
- ...describeFile(stat),
126
- ...encodeContent(bytes)
127
- }
128
- };
129
- }
130
- async function runWorkspaceOperation(operation, input) {
131
- try {
132
- if (operation === "history" && "cursor" in input && input.cursor !== void 0 && input.ref === void 0) throw new WorkspaceOperationError("WORKSPACE_HISTORY_INVALID", 400, "The cursor belongs to one ref. Pass the same ref.");
133
- const { history } = useWorkspace(input.workspace);
134
- if (operation === "refs") {
135
- const refs = await history.refs();
136
- return {
137
- workspace: input.workspace,
138
- refs: refs.map((ref) => ({
139
- name: ref.name,
140
- head: describeRevision(ref.head)
141
- }))
142
- };
143
- }
144
- if (operation === "history") return await listHistory(input.workspace, history, input);
145
- return await showRevision(input.workspace, history, input);
146
- } catch (error) {
147
- throw describeFailure(input.workspace, error);
148
- }
149
- }
150
- function describeFailure(workspace, error) {
151
- if (error instanceof WorkspaceOperationError) return new WorkspaceOperationError(error.code, error.status, redactInspectionText(error.message));
152
- const code = errorCode(error);
153
- if (code === "WORKSPACE_R0069") return new WorkspaceOperationError(code, 409, `Workspace "${workspace}" has no retained history because its Store does not keep revisions. Use the Blob + Database Store, createBlobDatabaseWorkspaceStore() from @vite-hub/workspace/blob-database, to keep refs and revisions.`);
154
- if (code === "WORKSPACE_NOT_FOUND" && error instanceof Error && error.message.includes(`Workspace "${workspace}" is not registered.`)) return new WorkspaceOperationError(code, 404, `Unknown Workspace: ${workspace}.`);
155
- const status = code === "WORKSPACE_NOT_FOUND" ? 404 : code && invalidRequestCodes.has(code) ? 400 : 500;
156
- return new WorkspaceOperationError(code ?? "WORKSPACE_HISTORY_FAILED", status, redactInspectionText(error instanceof Error ? error.message : String(error)));
157
- }
158
- //#endregion
159
- export { runWorkspaceOperation };