@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.
Files changed (137) hide show
  1. package/README.md +339 -115
  2. package/dist/abort-BCwpdrN0.js +32 -0
  3. package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
  4. package/dist/blob-database.d.ts +474 -0
  5. package/dist/blob-database.js +608 -0
  6. package/dist/checkout.d.ts +128 -0
  7. package/dist/checkout.js +849 -0
  8. package/dist/cloudflare.d.ts +6 -7
  9. package/dist/cloudflare.js +1 -1
  10. package/dist/config-B-863EgC.js +15 -0
  11. package/dist/config-BAgL2dtB.js +1076 -0
  12. package/dist/{config-DE9xlaIw.d.ts → config-BQKcPawI.d.ts} +1 -2
  13. package/dist/discard-CNNtCozM.js +8 -0
  14. package/dist/durability.d.ts +22 -0
  15. package/dist/durability.js +70 -0
  16. package/dist/error-diagnostics-CtKjGtGb.js +188 -0
  17. package/dist/error-diagnostics-DSkCJC_L.js +266 -0
  18. package/dist/file-2pFYNtsU.js +22 -0
  19. package/dist/{files-Q6xZjDHA.js → files-BOo4SbwE.js} +3 -3
  20. package/dist/files.d.ts +38 -0
  21. package/dist/files.js +6 -0
  22. package/dist/{github-DHnjxQIX.js → github-CrYp4v8k.js} +44 -24
  23. package/dist/glob-B8YGvTrZ.js +21 -0
  24. package/dist/glob-Cjxms1t7.js +30 -0
  25. package/dist/{host-DJH8cuoU.js → host-BFBpXn0N.js} +144 -77
  26. package/dist/{hosted-RPeJOCFz.js → hosted-KcUR_jPv.js} +303 -97
  27. package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
  28. package/dist/hosted-vercel-blob.d.ts +6 -7
  29. package/dist/hosted-vercel-blob.js +1 -1
  30. package/dist/hosted.d.ts +10 -9
  31. package/dist/hosted.js +2 -2
  32. package/dist/index.d.ts +26 -47
  33. package/dist/index.js +30 -100
  34. package/dist/internal/path.d.ts +2 -0
  35. package/dist/internal/path.js +2 -0
  36. package/dist/lifecycle-B-enk_4A.js +596 -0
  37. package/dist/lineage.d.ts +26 -0
  38. package/dist/lineage.js +76 -0
  39. package/dist/loader.d.ts +5 -6
  40. package/dist/loader.js +3 -2
  41. package/dist/mcp-resources-DF0F5rcL.js +39 -0
  42. package/dist/memory-BOexthyW.js +247 -0
  43. package/dist/metadata-target-CWz6KHKq.js +1589 -0
  44. package/dist/object-Da1zyPCR.js +11 -0
  45. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  46. package/dist/operations-C6FpR8Rr.js +389 -0
  47. package/dist/operations-CE2drFih.js +1234 -0
  48. package/dist/operations.d.ts +90 -0
  49. package/dist/operations.js +3 -0
  50. package/dist/path--wrT_Azm.js +113 -0
  51. package/dist/path-AxMho1wo.d.ts +7 -0
  52. package/dist/path-DrSIenjj.js +59 -0
  53. package/dist/path-zHxQUbqa.d.ts +9 -0
  54. package/dist/plugins-C8C0auoW.d.ts +10 -0
  55. package/dist/provider-9s4Ufkm5.js +1479 -0
  56. package/dist/providers/github/store.d.ts +3 -5
  57. package/dist/providers/github/store.js +1 -1
  58. package/dist/registry-B3BBm4Ts.d.ts +19 -0
  59. package/dist/{registry-D3yzt8HQ.js → registry-CNphafBx.js} +60 -23
  60. package/dist/registry-CYNN623b.d.ts +9 -0
  61. package/dist/request-scope-Dw5n8bMC.js +83 -0
  62. package/dist/results-DgkZUmTL.js +8 -0
  63. package/dist/{chunk-2rV9d50f.js → rolldown-runtime-rQ84J-ij.js} +3 -4
  64. package/dist/runtime/assets.d.ts +3 -5
  65. package/dist/runtime/assets.js +7 -6
  66. package/dist/runtime/empty-assets-registry.d.ts +1 -2
  67. package/dist/runtime/empty-registry.d.ts +2 -2
  68. package/dist/runtime/registry.d.ts +2 -0
  69. package/dist/runtime/registry.js +23 -0
  70. package/dist/runtime/request.d.ts +4 -0
  71. package/dist/runtime/request.js +8 -0
  72. package/dist/runtime/state.d.ts +5 -4
  73. package/dist/runtime/state.js +8 -18
  74. package/dist/runtime/workspace.d.ts +1 -1
  75. package/dist/runtime/workspace.js +1 -1
  76. package/dist/runtime.d.ts +52 -17
  77. package/dist/runtime.js +324 -67
  78. package/dist/{search-BpiCF2Tw.js → search-C_RfoM2j.js} +10 -9
  79. package/dist/server-8tGltlGz.js +303 -0
  80. package/dist/server.d.ts +36 -39
  81. package/dist/server.js +2 -328
  82. package/dist/shared-B3_EUk89.js +848 -0
  83. package/dist/source-metadata.d.ts +10 -7
  84. package/dist/source-metadata.js +12 -12
  85. package/dist/state-BISnUf1s.d.ts +35 -0
  86. package/dist/{ai-BqCC8BpY.js → state-DbrW-njQ.js} +237 -114
  87. package/dist/store-ybhyD38Z.js +1873 -0
  88. package/dist/{sync-DnTQwt8r.js → sync-CCD_VYC8.js} +61 -41
  89. package/dist/target-jWhTdIuF.js +89 -0
  90. package/dist/test.d.ts +1 -1
  91. package/dist/test.js +1 -1
  92. package/dist/{types-CYuwjJ4V.d.ts → types-BbtwmBZ5.d.ts} +321 -35
  93. package/dist/use-C6lV3-wC.d.ts +321 -0
  94. package/dist/{use-BTNDR5Rd.js → use-CSpT5W87.js} +141 -107
  95. package/dist/utils-CgMZCHsX.js +616 -0
  96. package/dist/vite.d.ts +585 -2
  97. package/dist/vite.js +21369 -2
  98. package/dist/workspace-CYB2xZ1T.d.ts +7 -0
  99. package/dist/{workspace-Dq08Yn72.js → workspace-sPWn2Jxj.js} +441 -225
  100. package/package.json +97 -72
  101. package/dist/ai-CjxvGqM0.d.ts +0 -162
  102. package/dist/ai.d.ts +0 -3
  103. package/dist/ai.js +0 -2
  104. package/dist/collections/client.d.ts +0 -39
  105. package/dist/collections/client.js +0 -137
  106. package/dist/collections.d.ts +0 -59
  107. package/dist/collections.js +0 -159
  108. package/dist/config-Bc3c4Su1.js +0 -7904
  109. package/dist/config-CHLLWklZ.js +0 -36
  110. package/dist/file-Bc1X7pco.js +0 -23
  111. package/dist/glob-CEZKeZFC.js +0 -18
  112. package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
  113. package/dist/lifecycle-LrL3sA4n.js +0 -316
  114. package/dist/metadata-target-B0tOmVW7.js +0 -717
  115. package/dist/mountx.d.ts +0 -10
  116. package/dist/mountx.js +0 -143
  117. package/dist/nitro.d.ts +0 -2
  118. package/dist/nitro.js +0 -2
  119. package/dist/nuxt.d.ts +0 -26
  120. package/dist/nuxt.js +0 -42
  121. package/dist/path-Cp59koVz.js +0 -139
  122. package/dist/provider-B1yLjCJJ.js +0 -746
  123. package/dist/publish.d.ts +0 -35
  124. package/dist/publish.js +0 -112
  125. package/dist/registry-Uj6IVxes.d.ts +0 -11
  126. package/dist/request-execution-B-dSFlGB.js +0 -84
  127. package/dist/runtime-options-BsPSv5O7.js +0 -13
  128. package/dist/runtime-type-iEE6BjQJ.js +0 -34
  129. package/dist/shared-DTR1Hhma.js +0 -331
  130. package/dist/state-tYcRWEh2.d.ts +0 -26
  131. package/dist/store-Dt_Jyys3.js +0 -608
  132. package/dist/target-D4Bqb1eH.js +0 -11
  133. package/dist/token-CVzURBxC.js +0 -61
  134. package/dist/use-BiHzt0xA.d.ts +0 -103
  135. package/dist/vite-BptCrpv2.js +0 -4526
  136. package/dist/vite-CtA9guIM.d.ts +0 -66
  137. package/dist/workspace-Xddf4G1B.d.ts +0 -6
package/dist/mountx.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { _t as WorkspaceSession } from "./types-CYuwjJ4V.js";
2
- import { FsDriver } from "mountx";
3
-
4
- //#region src/mountx.d.ts
5
- interface WorkspaceMountXDriverOptions {
6
- readOnly?: boolean;
7
- }
8
- declare function createWorkspaceDriver(session: WorkspaceSession, options?: WorkspaceMountXDriverOptions): FsDriver;
9
- //#endregion
10
- export { WorkspaceMountXDriverOptions, createWorkspaceDriver };
package/dist/mountx.js DELETED
@@ -1,143 +0,0 @@
1
- import { posix } from "node:path";
2
- import { createUnstorageDriver } from "mountx/drivers/unstorage";
3
- //#region src/mountx.ts
4
- function keyToPath(key) {
5
- return key.split(":").join("/");
6
- }
7
- function pathToKey(path) {
8
- return path.split("/").join(":");
9
- }
10
- function valueToBytes(value) {
11
- if (value instanceof Uint8Array) return value;
12
- if (value instanceof ArrayBuffer) return new Uint8Array(value);
13
- if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
14
- return new TextEncoder().encode(typeof value === "string" ? value : JSON.stringify(value));
15
- }
16
- async function findEntry(session, path) {
17
- if (!path) return void 0;
18
- const parent = posix.dirname(path);
19
- return (await session.list(parent === "." ? "" : parent)).find((entry) => entry.path === path);
20
- }
21
- function assertProjectablePath(path) {
22
- const invalidName = path.split("/").find((segment) => segment.includes(":") || segment.includes("?") || segment.endsWith("$"));
23
- if (invalidName) throw Object.assign(/* @__PURE__ */ new Error(`Workspace filename is not representable as an unstorage key: ${invalidName}`), {
24
- code: "EINVAL",
25
- path
26
- });
27
- }
28
- function assertProjectableEntry(entry) {
29
- if (entry) assertProjectablePath(entry.path);
30
- if (entry?.metadata?.gitMode !== "120000") return entry;
31
- throw Object.assign(/* @__PURE__ */ new Error(`MountX cannot project Workspace symlink semantics: ${entry.path}`), {
32
- code: "ENOTSUP",
33
- path: entry.path
34
- });
35
- }
36
- function createWorkspaceStorage(session, readOnly) {
37
- const writeOptionsByValue = /* @__PURE__ */ new WeakMap();
38
- async function readItem(key) {
39
- const path = keyToPath(key);
40
- const entry = assertProjectableEntry(await findEntry(session, path));
41
- if (entry?.type !== "file") return null;
42
- const value = valueToBytes(await session.readFile(path, { encoding: "binary" }));
43
- writeOptionsByValue.set(value, {
44
- mediaType: entry.mediaType,
45
- metadata: entry.metadata
46
- });
47
- return value;
48
- }
49
- return {
50
- getItem: readItem,
51
- getItemRaw: readItem,
52
- async getKeys(base) {
53
- const path = keyToPath(base);
54
- return (await session.list(path, { recursive: true })).filter((entry) => assertProjectableEntry(entry)?.type === "file").map((entry) => pathToKey(entry.path));
55
- },
56
- async getMeta(key) {
57
- const entry = assertProjectableEntry(await findEntry(session, keyToPath(key)));
58
- if (!entry) return null;
59
- return {
60
- mtime: entry.mtime === void 0 ? void 0 : new Date(entry.mtime),
61
- size: entry.size
62
- };
63
- },
64
- async hasItem(key) {
65
- return assertProjectableEntry(await findEntry(session, keyToPath(key)))?.type === "file";
66
- },
67
- ...readOnly ? {} : {
68
- async removeItem(key) {
69
- await session.rm(keyToPath(key), { force: true });
70
- },
71
- async setItemRaw(key, value) {
72
- const path = keyToPath(key);
73
- const entry = assertProjectableEntry(await findEntry(session, path));
74
- const writeOptions = value instanceof Uint8Array ? writeOptionsByValue.get(value) : void 0;
75
- await session.writeFile(path, valueToBytes(value), writeOptions ?? {
76
- mediaType: entry?.mediaType,
77
- metadata: entry?.metadata
78
- });
79
- }
80
- }
81
- };
82
- }
83
- function createWorkspaceDriver(session, options = {}) {
84
- const readOnly = options.readOnly ?? false;
85
- const driver = createUnstorageDriver(createWorkspaceStorage(session, readOnly), { readOnly });
86
- function projectExecutableMode(stats, executable) {
87
- if (executable) stats.mode |= 73;
88
- return stats;
89
- }
90
- async function projectStats(path, stats) {
91
- return projectExecutableMode(stats, assertProjectableEntry(await findEntry(session, path.replace(/^\/+/, "")))?.metadata?.gitMode === "100755");
92
- }
93
- async function stat(path) {
94
- assertProjectablePath(path);
95
- return await projectStats(path, await driver.stat(path));
96
- }
97
- const singlePathMethods = new Set([
98
- "chmod",
99
- "chown",
100
- "lchown",
101
- "lutimes",
102
- "mkdir",
103
- "readlink",
104
- "readdir",
105
- "rmdir",
106
- "statfs",
107
- "truncate",
108
- "unlink",
109
- "utimes"
110
- ]);
111
- const twoPathMethods = new Set(["link", "rename"]);
112
- return new Proxy(driver, { get(target, property) {
113
- if (property === "stat" || property === "lstat") return stat;
114
- const value = Reflect.get(target, property, target);
115
- if (typeof value !== "function") return value;
116
- if (property === "open") return async (path, ...args) => {
117
- assertProjectablePath(path);
118
- const executable = assertProjectableEntry(await findEntry(session, path.replace(/^\/+/, "")))?.metadata?.gitMode === "100755";
119
- const handle = await value.call(target, path, ...args);
120
- return new Proxy(handle, { get(handleTarget, handleProperty) {
121
- if (handleProperty === "stat") return async () => projectExecutableMode(await handleTarget.stat(), executable);
122
- const handleValue = Reflect.get(handleTarget, handleProperty, handleTarget);
123
- return typeof handleValue === "function" ? handleValue.bind(handleTarget) : handleValue;
124
- } });
125
- };
126
- if (singlePathMethods.has(property)) return (path, ...args) => {
127
- assertProjectablePath(path);
128
- return value.call(target, path, ...args);
129
- };
130
- if (twoPathMethods.has(property)) return (from, to, ...args) => {
131
- assertProjectablePath(from);
132
- assertProjectablePath(to);
133
- return value.call(target, from, to, ...args);
134
- };
135
- if (property === "symlink") return (linkTarget, path, ...args) => {
136
- assertProjectablePath(path);
137
- return value.call(target, linkTarget, path, ...args);
138
- };
139
- return value.bind(target);
140
- } });
141
- }
142
- //#endregion
143
- export { createWorkspaceDriver };
package/dist/nitro.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { i as WorkspaceNitroConfigOptions, r as NitroConfig, s as createWorkspaceNitroConfig } from "./vite-CtA9guIM.js";
2
- export { type NitroConfig, type WorkspaceNitroConfigOptions, createWorkspaceNitroConfig };
package/dist/nitro.js DELETED
@@ -1,2 +0,0 @@
1
- import { t as createWorkspaceNitroConfig } from "./vite-BptCrpv2.js";
2
- export { createWorkspaceNitroConfig };
package/dist/nuxt.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { rt as WorkspaceModuleOptions } from "./types-CYuwjJ4V.js";
2
-
3
- //#region src/nuxt.d.ts
4
- interface WorkspaceNuxtModuleOptions extends WorkspaceModuleOptions {}
5
- type NuxtLike = {
6
- hook?: (name: "nitro:config", handler: (nitroConfig: Record<string, unknown>) => void | Promise<void>) => void;
7
- options: {
8
- alias?: Record<string, string>;
9
- dev?: boolean;
10
- imports?: {
11
- imports?: Array<{
12
- from: string;
13
- name: string;
14
- }>;
15
- };
16
- rootDir?: string;
17
- srcDir?: string;
18
- vite?: {
19
- plugins?: unknown[];
20
- workspace?: false | WorkspaceModuleOptions;
21
- };
22
- };
23
- };
24
- declare function viteHubWorkspaceNuxtModule(options?: WorkspaceNuxtModuleOptions, nuxt?: NuxtLike): void;
25
- //#endregion
26
- export { WorkspaceNuxtModuleOptions, viteHubWorkspaceNuxtModule as default };
package/dist/nuxt.js DELETED
@@ -1,42 +0,0 @@
1
- import { n as hubWorkspace, r as setWorkspaceVitePluginHosting, t as createWorkspaceNitroConfig } from "./vite-BptCrpv2.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.imports ??= {};
13
- nuxt.options.imports.imports ??= [];
14
- for (const name of ["useWorkspaceCollection", "useWorkspaceCollectionItem"]) if (!nuxt.options.imports.imports.some((entry) => entry.name === name)) nuxt.options.imports.imports.push({
15
- from: "@vite-hub/workspace/collections/client",
16
- name
17
- });
18
- nuxt.options.vite ??= {};
19
- const workspaceOptions = resolveWorkspaceOptions(options, nuxt.options.vite.workspace);
20
- let resolvedNitroHosting;
21
- const plugins = Array.isArray(nuxt.options.vite.plugins) ? nuxt.options.vite.plugins : [];
22
- if (!plugins.some(isWorkspaceVitePlugin)) plugins.push(hubWorkspace({
23
- ...workspaceOptions || {},
24
- hosting: () => resolvedNitroHosting
25
- }));
26
- for (const plugin of plugins) if (isWorkspaceVitePlugin(plugin)) setWorkspaceVitePluginHosting(plugin, () => resolvedNitroHosting);
27
- nuxt.options.vite.plugins = plugins;
28
- nuxt.hook?.("nitro:config", async (nitroConfig) => {
29
- resolvedNitroHosting = typeof nitroConfig.preset === "string" ? nitroConfig.preset : void 0;
30
- const rootDir = nuxt.options.rootDir || process.cwd();
31
- const nitro = await createWorkspaceNitroConfig({
32
- aliases: nuxt.options.alias,
33
- command: nuxt.options.dev ? "serve" : "build",
34
- nitro: nitroConfig,
35
- viteRoot: nuxt.options.srcDir || rootDir,
36
- workspace: workspaceOptions
37
- });
38
- if (nitro) Object.assign(nitroConfig, nitro);
39
- });
40
- }
41
- //#endregion
42
- export { viteHubWorkspaceNuxtModule as default };
@@ -1,139 +0,0 @@
1
- import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
- import { relative, resolve, sep } from "node:path";
3
- import { createHash } from "node:crypto";
4
- import { minimatch } from "minimatch";
5
- import { ViteHubError, getViteHubErrorShape } from "@vite-hub/runtime";
6
- //#region src/core/errors.ts
7
- function workspaceError(message, options) {
8
- return new ViteHubError("WORKSPACE_FAILED", message, options);
9
- }
10
- function workspaceConflict(message, options) {
11
- return new ViteHubError("WORKSPACE_CONFLICT", message, options);
12
- }
13
- function workspaceConflictError(path, expected, actual) {
14
- return workspaceConflict(`[vitehub] Workspace path changed before the conditional write: ${path}.`, { details: {
15
- actual,
16
- expected,
17
- path
18
- } });
19
- }
20
- function assertWorkspaceDigest(path, expected, actual) {
21
- if (expected === null ? actual !== void 0 : actual !== expected) throw workspaceConflictError(path, expected, actual);
22
- }
23
- function workspaceNotFoundError(name) {
24
- return new ViteHubError("WORKSPACE_NOT_FOUND", `[vitehub] Workspace "${name}" is not registered.`, { details: { name } });
25
- }
26
- function workspacePathError(path) {
27
- const publicPath = path.slice(0, 4096);
28
- return new ViteHubError("WORKSPACE_PATH_INVALID", `[vitehub] Workspace path escapes the workspace root: ${JSON.stringify(publicPath)}.`, { details: { path: publicPath } });
29
- }
30
- function isWorkspaceError(value) {
31
- const code = getViteHubErrorShape(value)?.code;
32
- return code === "WORKSPACE_COLLECTION_CURSOR_INVALID" || code === "WORKSPACE_CONFLICT" || code === "WORKSPACE_FAILED" || code === "WORKSPACE_NOT_FOUND" || code === "WORKSPACE_PATH_INVALID";
33
- }
34
- function isWorkspaceConflict(value) {
35
- return getViteHubErrorShape(value)?.code === "WORKSPACE_CONFLICT";
36
- }
37
- //#endregion
38
- //#region src/core/path.ts
39
- var path_exports = /* @__PURE__ */ __exportAll({
40
- contentStreamChunks: () => contentStreamChunks,
41
- contentStreamToBytes: () => contentStreamToBytes,
42
- contentToBytes: () => contentToBytes,
43
- decodeFile: () => decodeFile,
44
- isExcludedWorkspacePath: () => isExcludedWorkspacePath,
45
- matchesAny: () => matchesAny,
46
- normalizeSafeWorkspacePath: () => normalizeSafeWorkspacePath,
47
- normalizeSafeWorkspacePattern: () => normalizeSafeWorkspacePattern,
48
- normalizeWorkspacePath: () => normalizeWorkspacePath,
49
- resolveInside: () => resolveInside,
50
- sha256: () => sha256
51
- });
52
- function normalizeWorkspacePath(path = "") {
53
- return path.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
54
- }
55
- function isExcludedWorkspacePath(path, excluded = []) {
56
- const normalized = normalizeWorkspacePath(path);
57
- return excluded.some((item) => {
58
- const excludedPath = normalizeWorkspacePath(item);
59
- return excludedPath === "" || normalized === excludedPath || normalized.startsWith(`${excludedPath}/`);
60
- });
61
- }
62
- function normalizeSafeWorkspacePath(path = "", options = {}) {
63
- const raw = path.replace(/\\/g, "/");
64
- const normalized = normalizeWorkspacePath(path);
65
- const parts = normalized.split("/").filter(Boolean);
66
- if (!options.allowEmpty && !normalized) throw workspacePathError(path);
67
- if (raw.startsWith("/") || parts.some((part) => part === "." || part === "..")) throw workspacePathError(path);
68
- if (!options.allowReserved && (parts.some((part) => part.toLowerCase() === ".git") || parts[0] === ".vitehub")) throw workspacePathError(path);
69
- return normalized;
70
- }
71
- function normalizeSafeWorkspacePattern(pattern) {
72
- return normalizeSafeWorkspacePath(pattern, {
73
- allowEmpty: true,
74
- pattern: true
75
- });
76
- }
77
- function resolveInside(root, path = "") {
78
- const resolvedRoot = resolve(root);
79
- const resolved = resolve(resolvedRoot, normalizeWorkspacePath(path));
80
- const rel = relative(resolvedRoot, resolved);
81
- if (rel.startsWith("..") || rel === ".." || rel.includes(`..${sep}`) || rel === "") {
82
- if (rel === "") return resolved;
83
- throw workspacePathError(path);
84
- }
85
- return resolved;
86
- }
87
- function matchesAny(path, patterns) {
88
- if (!patterns) return true;
89
- const list = Array.isArray(patterns) ? patterns : [patterns];
90
- const normalizedPath = normalizeWorkspacePath(path);
91
- return list.some((pattern) => minimatch(normalizedPath, normalizeWorkspacePath(pattern), { dot: true }));
92
- }
93
- function contentToBytes(content) {
94
- return typeof content === "string" ? new TextEncoder().encode(content) : content;
95
- }
96
- function isReadableStream(value) {
97
- return Boolean(value && typeof value.getReader === "function");
98
- }
99
- async function* contentStreamChunks(stream) {
100
- if (isReadableStream(stream)) {
101
- const reader = stream.getReader();
102
- try {
103
- while (true) {
104
- const chunk = await reader.read();
105
- if (chunk.done) return;
106
- yield chunk.value;
107
- }
108
- } finally {
109
- reader.releaseLock();
110
- }
111
- return;
112
- }
113
- yield* stream;
114
- }
115
- async function contentStreamToBytes(stream) {
116
- const chunks = [];
117
- let size = 0;
118
- for await (const chunk of contentStreamChunks(stream)) {
119
- chunks.push(chunk);
120
- size += chunk.byteLength;
121
- }
122
- const bytes = new Uint8Array(size);
123
- let offset = 0;
124
- for (const chunk of chunks) {
125
- bytes.set(chunk, offset);
126
- offset += chunk.byteLength;
127
- }
128
- return bytes;
129
- }
130
- function decodeFile(content, options) {
131
- if (options?.encoding === "binary") return content;
132
- return typeof content === "string" ? content : new TextDecoder().decode(content);
133
- }
134
- async function sha256(input) {
135
- const bytes = contentToBytes(typeof input === "string" || input instanceof Uint8Array ? input : JSON.stringify(input));
136
- return createHash("sha256").update(bytes).digest("hex");
137
- }
138
- //#endregion
139
- export { workspaceError as _, isExcludedWorkspacePath as a, normalizeSafeWorkspacePattern as c, resolveInside as d, sha256 as f, workspaceConflict as g, isWorkspaceError as h, decodeFile as i, normalizeWorkspacePath as l, isWorkspaceConflict as m, contentStreamToBytes as n, matchesAny as o, assertWorkspaceDigest as p, contentToBytes as r, normalizeSafeWorkspacePath as s, contentStreamChunks as t, path_exports as u, workspaceNotFoundError as v };