@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/index.js CHANGED
@@ -1,28 +1,26 @@
1
- import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
- import { _ as workspaceError, m as isWorkspaceConflict, s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
3
- import { t as createWorkspaceTools } from "./ai-BqCC8BpY.js";
4
- import { d as registerMcpResourcesSourceLoader, p as fetch, u as prepareWorkspaceSource, v as markLiveWorkspaceSource } from "./config-Bc3c4Su1.js";
5
- import { n as resolveWorkspaceStoreTarget } from "./target-D4Bqb1eH.js";
6
- import { d as resolveWorkspaceAutoCommit, t as createWorkspace } from "./workspace-Dq08Yn72.js";
7
- import { r as resolveRegisteredWorkspaceDefinition } from "./registry-D3yzt8HQ.js";
8
- import { t as useWorkspace } from "./use-BTNDR5Rd.js";
9
- import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
10
- import { t as file } from "./file-Bc1X7pco.js";
11
- import { t as github } from "./github-DHnjxQIX.js";
12
- import { t as glob } from "./glob-CEZKeZFC.js";
13
- import { invalidateWorkspaceStore } from "./runtime/state.js";
14
- import { sourceIgnores } from "@vite-hub/source";
1
+ import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
+ import { r as isWorkspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
3
+ import { i as assertWorkspaceRules, n as resolveWorkspaceStoreTarget } from "./target-jWhTdIuF.js";
4
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
5
+ import { g as registerWorkspacePlugin, h as resolveWorkspaceAutoCommit } from "./utils-CgMZCHsX.js";
6
+ import { t as createWorkspace } from "./workspace-sPWn2Jxj.js";
7
+ import { m as fetch } from "./config-BAgL2dtB.js";
8
+ import { r as resolveRegisteredWorkspaceDefinition } from "./registry-CNphafBx.js";
9
+ import { r as useWorkspaceFiles } from "./use-CSpT5W87.js";
10
+ import { r as withFileSourceOptions, t as file } from "./file-2pFYNtsU.js";
11
+ import { t as github } from "./github-CrYp4v8k.js";
12
+ import { t as glob } from "./glob-B8YGvTrZ.js";
13
+ import { t as mcpResources } from "./mcp-resources-DF0F5rcL.js";
14
+ import { a as createWorkspaceTools, i as useWorkspace, t as invalidateWorkspaceStore } from "./state-DbrW-njQ.js";
15
15
  import { lookup } from "mrmime";
16
- import { markdown as markdown$1 } from "@vite-hub/source/markdown";
17
- import { mcpResources as mcpResources$1 } from "@vite-hub/source/mcp";
16
+ import { markdown as markdown$1, sourceIgnores } from "@vite-hub/source";
18
17
  //#region src/core/define.ts
19
- const workspaceDefinitionKeys = new Set([
18
+ const workspaceDefinitionKeys = /* @__PURE__ */ new Set([
20
19
  "bindings",
21
20
  "commit",
22
21
  "hooks",
23
22
  "loaders",
24
23
  "plugins",
25
- "publish",
26
24
  "rootDir",
27
25
  "rules",
28
26
  "sourceRootDir",
@@ -32,18 +30,20 @@ const workspaceDefinitionKeys = new Set([
32
30
  function assertWorkspaceDefinitionKeys(definition) {
33
31
  const unsupported = Object.keys(definition).filter((key) => !workspaceDefinitionKeys.has(key));
34
32
  if (!unsupported.length) return;
35
- throw new TypeError(`[vitehub] defineWorkspace does not support option${unsupported.length === 1 ? "" : "s"}: ${unsupported.join(", ")}.`);
33
+ throw workspaceErrorDiagnostics.WORKSPACE_R0015({ message: `[vitehub] defineWorkspace does not support option${unsupported.length === 1 ? "" : "s"}: ${unsupported.join(", ")}.` });
36
34
  }
37
35
  function defineWorkspace(definition) {
38
- if (!definition || typeof definition !== "object") throw new TypeError("[vitehub] defineWorkspace requires a workspace definition.");
39
- if ("name" in definition) throw new TypeError("[vitehub] Workspace names are inferred from definition filenames.");
36
+ if (!definition || typeof definition !== "object") throw workspaceErrorDiagnostics.WORKSPACE_R0016({ message: "[vitehub] defineWorkspace requires a workspace definition." });
37
+ if ("name" in definition) throw workspaceErrorDiagnostics.WORKSPACE_R0017({ message: "[vitehub] Workspace names are inferred from definition filenames." });
40
38
  assertWorkspaceDefinitionKeys(definition);
39
+ assertWorkspaceRules(definition.rules);
40
+ for (const plugin of definition.plugins ?? []) assertWorkspaceRules(plugin?.rules);
41
41
  return definition;
42
42
  }
43
43
  //#endregion
44
44
  //#region src/sources/custom.ts
45
45
  function custom(source) {
46
- if (!("files" in source) || !Array.isArray(source.files)) return source;
46
+ if (!Object.hasOwn(source, "files") || !Array.isArray(source.files)) return source;
47
47
  const { files: inputFiles, ...options } = source;
48
48
  const files = inputFiles.map((file) => ({
49
49
  ...file,
@@ -70,41 +70,7 @@ function custom(source) {
70
70
  //#endregion
71
71
  //#region src/sources/markdown.ts
72
72
  function markdown(options) {
73
- const key = normalizeSafeWorkspacePath(options.workspacePath || options.path || "");
74
- return {
75
- ...withWorkspaceRuntimeOptions(markdown$1(options), options),
76
- probeKeys: options.probeKeys || [key]
77
- };
78
- }
79
- //#endregion
80
- //#region src/sources/mcp-resources.ts
81
- function mcpResources(options) {
82
- const livePaths = {};
83
- const baseSource = mcpResources$1({
84
- ...options,
85
- cache: options.cache
86
- });
87
- return markLiveWorkspaceSource(withWorkspaceRuntimeOptions({
88
- ...baseSource,
89
- async prepare(ctx) {
90
- await prepareWorkspaceSource(baseSource, ctx);
91
- resetLivePaths(livePaths, resolveMountPath(options.mount, ctx), await baseSource.getKeys(ctx));
92
- }
93
- }, {
94
- ...options,
95
- materialize: options.materialize || (options.sync ? "none" : "lazy")
96
- }), livePaths);
97
- }
98
- registerMcpResourcesSourceLoader((input) => mcpResources(input));
99
- function resolveMountPath(mount, ctx) {
100
- return normalizeSafeWorkspacePath((typeof mount === "string" ? mount : mount?.path) ?? ctx.mountPath ?? ctx.source ?? "", { allowEmpty: true });
101
- }
102
- function resetLivePaths(paths, mountPath, keys) {
103
- for (const path of Object.keys(paths)) delete paths[path];
104
- for (const key of keys) {
105
- const path = normalizeSafeWorkspacePath(`${mountPath}/${key}`.replace(/\/+/g, "/"), { allowEmpty: false });
106
- paths[path] = key;
107
- }
73
+ return withFileSourceOptions(markdown$1(options), options);
108
74
  }
109
75
  //#endregion
110
76
  //#region src/sources/index.ts
@@ -140,40 +106,8 @@ function boundedUtf8Bytes(value, limit) {
140
106
  }
141
107
  return bytes;
142
108
  }
143
- function findClosingBrace(pattern, opening) {
144
- let depth = 0;
145
- for (let index = opening; index < pattern.length; index++) {
146
- if (pattern[index] === "\\") {
147
- index++;
148
- continue;
149
- }
150
- if (pattern[index] === "{") depth++;
151
- else if (pattern[index] === "}" && --depth === 0) return index;
152
- }
153
- return -1;
154
- }
155
- function splitBraceParts(content, separator) {
156
- const parts = [];
157
- let depth = 0;
158
- let start = 0;
159
- for (let index = 0; index < content.length; index++) {
160
- if (content[index] === "\\") {
161
- index++;
162
- continue;
163
- }
164
- if (content[index] === "{") depth++;
165
- else if (content[index] === "}") depth--;
166
- else if (depth === 0 && content.startsWith(separator, index)) {
167
- parts.push(content.slice(start, index));
168
- index += separator.length - 1;
169
- start = index + 1;
170
- }
171
- }
172
- parts.push(content.slice(start));
173
- return parts;
174
- }
175
109
  function sequenceComplexity(content, limit) {
176
- const parts = splitBraceParts(content, "..");
110
+ const parts = content.split("..");
177
111
  if (parts.length < 2 || parts.length > 3) return void 0;
178
112
  const [rawStart, rawEnd, rawStep] = parts;
179
113
  const numeric = /^-?\d+$/;
@@ -193,18 +127,14 @@ function sequenceComplexity(content, limit) {
193
127
  function patternComplexity(pattern, limit) {
194
128
  let complexity = 1;
195
129
  for (let index = 0; index < pattern.length; index++) {
196
- if (pattern[index] === "\\") {
197
- index++;
198
- continue;
199
- }
200
130
  if (pattern[index] === "}") return limit + 1;
201
131
  if (pattern[index] !== "{") continue;
202
- const closing = findClosingBrace(pattern, index);
132
+ const closing = pattern.indexOf("}", index + 1);
203
133
  if (closing === -1) return limit + 1;
204
134
  const content = pattern.slice(index + 1, closing);
205
135
  if (!content) return limit + 1;
206
136
  if (content.includes("{") || content.includes("}")) return limit + 1;
207
- const alternatives = splitBraceParts(content, ",");
137
+ const alternatives = content.split(",");
208
138
  let braceComplexity;
209
139
  if (alternatives.length > 1) {
210
140
  braceComplexity = 0;
@@ -221,19 +151,19 @@ function patternComplexity(pattern, limit) {
221
151
  }
222
152
  function assertModelWorkspaceGlobPattern(pattern, limits = modelWorkspaceGlobPatternLimits) {
223
153
  const patterns = Array.isArray(pattern) ? pattern : [pattern];
224
- if (patterns.length > limits.maxPatterns) throw new TypeError(`[vitehub] Workspace glob accepts at most ${limits.maxPatterns} model-facing patterns.`);
154
+ if (patterns.length > limits.maxPatterns) throw workspaceErrorDiagnostics.WORKSPACE_R0018({ message: `[vitehub] Workspace glob accepts at most ${limits.maxPatterns} model-facing patterns.` });
225
155
  let bytes = 0;
226
156
  for (const item of patterns) {
227
157
  bytes = boundedAdd(bytes, boundedUtf8Bytes(item, limits.maxBytes), limits.maxBytes);
228
158
  if (bytes > limits.maxBytes) break;
229
159
  }
230
- if (bytes > limits.maxBytes) throw new TypeError(`[vitehub] Workspace glob pattern input exceeds the model-facing limit of ${limits.maxBytes} bytes.`);
160
+ if (bytes > limits.maxBytes) throw workspaceErrorDiagnostics.WORKSPACE_R0019({ message: `[vitehub] Workspace glob pattern input exceeds the model-facing limit of ${limits.maxBytes} bytes.` });
231
161
  let complexity = 0;
232
162
  for (const item of patterns) {
233
163
  const normalized = item.replace(/\\/g, "/");
234
164
  complexity = boundedAdd(complexity, patternComplexity(normalized, limits.maxComplexity), limits.maxComplexity);
235
- if (complexity > limits.maxComplexity) throw new TypeError(`[vitehub] Workspace glob pattern complexity exceeds the model-facing limit of ${limits.maxComplexity} expansions.`);
165
+ if (complexity > limits.maxComplexity) throw workspaceErrorDiagnostics.WORKSPACE_R0020({ message: `[vitehub] Workspace glob pattern complexity exceeds the model-facing limit of ${limits.maxComplexity} expansions.` });
236
166
  }
237
167
  }
238
168
  //#endregion
239
- export { assertModelWorkspaceGlobPattern, createWorkspace, createWorkspaceTools, custom, defineWorkspace, fetch, file, github, glob, invalidateWorkspaceStore, isWorkspaceConflict, markdown, mcpResources, modelWorkspaceGlobPatternLimits, normalizeSafeWorkspacePath, resolveRegisteredWorkspaceDefinition, resolveWorkspaceAutoCommit, resolveWorkspaceStoreTarget, sources_exports as source, sourceIgnores, useWorkspace };
169
+ export { assertModelWorkspaceGlobPattern, createWorkspace, createWorkspaceTools, custom, defineWorkspace, fetch, file, github, glob, invalidateWorkspaceStore, isWorkspaceConflict, markdown, mcpResources, modelWorkspaceGlobPatternLimits, normalizeSafeWorkspacePath, registerWorkspacePlugin, resolveRegisteredWorkspaceDefinition, resolveWorkspaceAutoCommit, resolveWorkspaceStoreTarget, sources_exports as source, sourceIgnores, useWorkspace, useWorkspaceFiles };
@@ -0,0 +1,2 @@
1
+ import { n as normalizeSafeWorkspacePath, t as SafeWorkspacePathOptions } from "../path-zHxQUbqa.js";
2
+ export { SafeWorkspacePathOptions, normalizeSafeWorkspacePath };
@@ -0,0 +1,2 @@
1
+ import { t as normalizeSafeWorkspacePath } from "../path-DrSIenjj.js";
2
+ export { normalizeSafeWorkspacePath };