@vite-hub/workspace 0.1.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,4 +1,4 @@
1
- import { F as WorkspaceDefinition, T as Workspace } from "./types-DeK9GIxy.js";
1
+ import { I as WorkspaceDefinition, T as Workspace } from "./types-BbtwmBZ5.js";
2
2
  //#region src/core/workspace.d.ts
3
3
  declare function createWorkspace(definition: WorkspaceDefinition, options?: {
4
4
  reuseStartupSnapshots?: boolean;
@@ -1,18 +1,16 @@
1
+ import { t as createMemoryWorkspaceStore } from "./memory-BOexthyW.js";
1
2
  import { s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
2
- import { a as isExcludedWorkspacePath, f as sha256, i as decodeFile, l as normalizeWorkspacePath, n as contentStreamToBytes, r as contentToBytes, s as matchesAny } from "./path-CNAwN7pw.js";
3
- import { t as forwardWorkspaceStoreTarget } from "./target-D4Bqb1eH.js";
4
- import { a as normalizeWorkspaceSources, c as sourceMountIntersectsPath, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath, v as workspaceSourceRequestDescriptorPath } from "./config-B7dmzDX3.js";
5
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
6
- import { n as createWorkspaceSourceRequestExecution, t as attachWorkspaceSourceRequestExecution } from "./request-execution-Dk9rY-Yh.js";
7
- import { t as createMemoryWorkspaceStore } from "./memory-BbwOqDXl.js";
8
- import { t as copyJsonFileMetadata } from "./file-metadata-CxDy-E2H.js";
9
- import { d as normalizeHistoryRef, i as createWorkspaceHistory, l as historyConflict, m as createWorkspaceWritePolicy } from "./utils-Blrh4N2n.js";
10
- import { t as createWorkspaceGlobMatcher } from "./glob--kNYDbfU.js";
11
- import { t as createWorkspaceStoreFromProvider } from "./provider-kXjfli9u.js";
12
- import { n as forwardWorkspaceRevisionMaterializer } from "./store-CXgmu-uw.js";
13
- import { t as searchText } from "./search-CrTmXj5h.js";
14
- import { C as withWorkspaceStoreMutation, D as readWorkspaceFileOwner, _ as reconcileRemovedStartupSources, b as statVirtualSourcePath, c as workspaceInternalMetadataCapability, f as materializeWorkspaceSources, g as readSourceSnapshotPaths, h as readResolvedSourceFile, l as hasCurrentSourceSnapshot, m as readCurrentSourceSnapshot, n as createWorkspaceMetadataTarget, p as materializesCompleteSource, t as attachWorkspaceMetadataTarget, u as hasFreshSourceSnapshot, v as searchMaterializedStore } from "./metadata-target-DZEZQGHA.js";
15
- import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
3
+ import { o as copyJsonFileMetadata, t as forwardWorkspaceStoreTarget } from "./target-jWhTdIuF.js";
4
+ import { a as isExcludedWorkspacePath, f as sha256, i as decodeFile, l as normalizeWorkspacePath, n as contentStreamToBytes, r as contentToBytes, s as matchesAny } from "./path--wrT_Azm.js";
5
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
6
+ import { d as normalizeHistoryRef, i as createWorkspaceHistory, l as historyConflict, m as createWorkspaceWritePolicy } from "./utils-CgMZCHsX.js";
7
+ import { t as createWorkspaceGlobMatcher } from "./glob-Cjxms1t7.js";
8
+ import { t as createWorkspaceStoreFromProvider } from "./provider-9s4Ufkm5.js";
9
+ import { n as forwardWorkspaceRevisionMaterializer } from "./store-ybhyD38Z.js";
10
+ import { t as searchText } from "./search-C_RfoM2j.js";
11
+ import { a as normalizeWorkspaceSources, c as sourceMountIntersectsPath, f as prepareWorkspaceSource, g as getWorkspaceSourceRequestExecutor, n as createSourceContext, s as sourceMountContainsPath, v as workspaceSourceRequestDescriptorPath, y as requestJsonEqual } from "./config-BAgL2dtB.js";
12
+ import { C as withWorkspaceStoreMutation, D as readWorkspaceFileOwner, _ as reconcileRemovedStartupSources, b as statVirtualSourcePath, c as workspaceInternalMetadataCapability, f as materializeWorkspaceSources, g as readSourceSnapshotPaths, h as readResolvedSourceFile, l as hasCurrentSourceSnapshot, m as readCurrentSourceSnapshot, n as createWorkspaceMetadataTarget, p as materializesCompleteSource, t as attachWorkspaceMetadataTarget, u as hasFreshSourceSnapshot, v as searchMaterializedStore } from "./metadata-target-CWz6KHKq.js";
13
+ import { n as trackStagedWrites } from "./request-scope-Dw5n8bMC.js";
16
14
  import { noExecutionAuthority } from "@vite-hub/runtime";
17
15
  //#region src/session/scope.ts
18
16
  function isMissingWorkspacePathError(error) {
@@ -190,6 +188,87 @@ async function createBasicWorkspaceSession(workspace, options) {
190
188
  };
191
189
  }
192
190
  //#endregion
191
+ //#region src/sources/request-execution.ts
192
+ const sourceRequestExecutions = /* @__PURE__ */ new WeakMap();
193
+ function isWeakKey(value) {
194
+ return Object(value) === value;
195
+ }
196
+ function attachWorkspaceSourceRequestExecution(target, executor) {
197
+ if (!executor) return target;
198
+ sourceRequestExecutions.set(target, executor);
199
+ return target;
200
+ }
201
+ function getWorkspaceSourceRequestExecution(input) {
202
+ if (!isWeakKey(input)) return void 0;
203
+ return sourceRequestExecutions.get(input);
204
+ }
205
+ function createWorkspaceSourceRequestExecution(definition, options = {}) {
206
+ const sources = normalizeWorkspaceSources(definition.sources).filter((source) => source.requestDescriptor && getWorkspaceSourceRequestExecutor(source.source)).filter((source) => sourceRequestVisible(source, options.selectedWorkspaceScope));
207
+ if (!sources.length) return void 0;
208
+ return { async executeSourceRequest(input) {
209
+ const matches = sources.filter((source) => source.requestDescriptor && workspaceSourceRequestMatches(source.requestDescriptor, input));
210
+ if (matches.length !== 1) throw workspaceErrorDiagnostics.WORKSPACE_R0063({ message: matches.length > 1 ? "[vitehub] Source request is ambiguous; more than one visible Source matches this curl target." : "[vitehub] Source request is not visible in the selected workspace scope or does not match a declared Source target." });
211
+ const source = matches[0];
212
+ const executor = getWorkspaceSourceRequestExecutor(source.source);
213
+ if (!executor) throw workspaceErrorDiagnostics.WORKSPACE_R0064({ message: "[vitehub] Source request executor is unavailable." });
214
+ const contextOptions = {
215
+ ...input.signal ? { abortSignal: input.signal } : {},
216
+ selectedWorkspaceScope: options.selectedWorkspaceScope
217
+ };
218
+ return await executor(input, createSourceContext(definition, {
219
+ key: source.key,
220
+ mountPath: source.mountPath
221
+ }, void 0, contextOptions));
222
+ } };
223
+ }
224
+ function sourceRequestVisible(source, scope) {
225
+ if (!scope || scope.all) return true;
226
+ const descriptorPath = workspaceSourceRequestDescriptorPath(source.key);
227
+ return Boolean(scope.paths?.some((path) => pathIntersects(path, descriptorPath)));
228
+ }
229
+ function pathContains(container, path) {
230
+ if (!container || !path) return container === path;
231
+ return path === container || path.startsWith(`${container}/`);
232
+ }
233
+ function pathIntersects(left, right) {
234
+ return pathContains(left, right) || pathContains(right, left);
235
+ }
236
+ function workspaceSourceRequestMatches(descriptor, input) {
237
+ return descriptor.method === input.method && sameRequestTarget(descriptor.url, input.url) && requestShapeMatches(descriptor, input);
238
+ }
239
+ function sameRequestTarget(left, right) {
240
+ const leftUrl = new URL(left);
241
+ const rightUrl = new URL(right);
242
+ return leftUrl.origin === rightUrl.origin && leftUrl.pathname === rightUrl.pathname;
243
+ }
244
+ function requestShapeMatches(descriptor, input) {
245
+ const request = descriptor.request;
246
+ if (request?.querySchema) return bodyShapeMatches(request, input);
247
+ if (!requestJsonEqual(queryFromUrl(new URL(input.url)) || {}, serializedQuery(request?.query) || {})) return false;
248
+ return bodyShapeMatches(request, input);
249
+ }
250
+ function bodyShapeMatches(request, input) {
251
+ if (request?.bodySchema) return true;
252
+ if (request && "body" in request) return requestJsonEqual(input.body, request.body);
253
+ return input.body === void 0;
254
+ }
255
+ function queryFromUrl(url) {
256
+ const query = Object.fromEntries([...new Set(url.searchParams.keys())].map((key) => {
257
+ const values = url.searchParams.getAll(key);
258
+ return [key, values.length > 1 ? values : values[0]];
259
+ }));
260
+ return Object.keys(query).length ? query : void 0;
261
+ }
262
+ function serializedQuery(query) {
263
+ if (!query) return void 0;
264
+ const params = new URLSearchParams();
265
+ for (const [key, value] of Object.entries(query)) {
266
+ const values = Array.isArray(value) ? value : [value];
267
+ for (const item of values) params.append(key, String(item));
268
+ }
269
+ return queryFromUrl(new URL(`https://vitehub.local/?${params}`));
270
+ }
271
+ //#endregion
193
272
  //#region src/sources/resolver.ts
194
273
  function resolveWorkspacePath(definition, path) {
195
274
  const workspacePath = normalizeSafeWorkspacePath(path, { allowEmpty: true });
@@ -239,16 +318,16 @@ function readWorkspaceSourceSyncState(value) {
239
318
  const entry = state.paths[path];
240
319
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return;
241
320
  if (typeof entry.digest !== "string" || typeof entry.sourcePath !== "string") return;
242
- if (entry.mountPath !== void 0 && !hasRuntimeType(entry.mountPath, "string")) return;
321
+ if (entry.mountPath !== void 0 && typeof entry.mountPath !== "string") return;
243
322
  }
244
323
  if (state.claims !== void 0) {
245
- if (!state.claims || !hasRuntimeType(state.claims, "object") || Array.isArray(state.claims)) return;
324
+ if (!state.claims || typeof state.claims !== "object" || Array.isArray(state.claims)) return;
246
325
  for (const [path, claims] of Object.entries(state.claims)) {
247
326
  if (!state.paths[path] || !Array.isArray(claims) || claims.length === 0) return;
248
327
  const mounts = /* @__PURE__ */ new Set();
249
328
  for (const claim of claims) {
250
- if (!claim || !hasRuntimeType(claim, "object") || Array.isArray(claim)) return;
251
- if (!hasRuntimeType(claim.digest, "string") || !hasRuntimeType(claim.sourcePath, "string") || !hasRuntimeType(claim.mountPath, "string")) return;
329
+ if (!claim || typeof claim !== "object" || Array.isArray(claim)) return;
330
+ if (typeof claim.digest !== "string" || typeof claim.sourcePath !== "string" || typeof claim.mountPath !== "string") return;
252
331
  if (mounts.has(claim.mountPath)) return;
253
332
  mounts.add(claim.mountPath);
254
333
  }
@@ -467,14 +546,14 @@ function createWorkspaceSourceView(definition, store, options = {}) {
467
546
  }
468
547
  return matched;
469
548
  }
470
- async function ensurePrepared(sourceKey) {
549
+ async function ensurePrepared(sourceKey, path) {
471
550
  const source = sources.find((item) => item.key === sourceKey);
472
551
  if (!source) return;
473
552
  if (source.materialize === "startup" && completedSources.has(sourceKey)) {
474
- if (await hasCurrentSourceSnapshot(store, definition.name, source, options.reuseStartupSnapshots, options.reuseStartupSnapshots ? sources : void 0)) return;
553
+ if (await hasCurrentSourceSnapshot(store, definition.name, source, options.reuseStartupSnapshots, options.reuseStartupSnapshots ? sources : void 0, path)) return;
475
554
  completedSources.delete(sourceKey);
476
555
  }
477
- if (source.materialize === "startup" && options.reuseStartupSnapshots && await hasCurrentSourceSnapshot(store, definition.name, source, true, sources)) {
556
+ if (source.materialize === "startup" && options.reuseStartupSnapshots && await hasCurrentSourceSnapshot(store, definition.name, source, true, sources, path)) {
478
557
  reusedStartupSources.add(sourceKey);
479
558
  return;
480
559
  }
@@ -563,7 +642,7 @@ function createWorkspaceSourceView(definition, store, options = {}) {
563
642
  });
564
643
  return await current;
565
644
  }
566
- async function ensureMaterialized(sourceKey, verifyRootOwnership = true) {
645
+ async function ensureMaterialized(sourceKey, verifyRootOwnership = true, path) {
567
646
  const source = sources.find((item) => item.key === sourceKey);
568
647
  if (!source) return;
569
648
  const verifyOwnership = options.reuseStartupSnapshots ? true : verifyRootOwnership || source.mountPath || !sources.some((item) => !item.mountPath && item.materialize === "lazy") ? "workspace" : false;
@@ -580,16 +659,16 @@ function createWorkspaceSourceView(definition, store, options = {}) {
580
659
  }
581
660
  if (isUncachedLazySource ? uncachedMaterializedSources.has(sourceKey) : materializedSources.has(sourceKey)) {
582
661
  const maxAge = source.cache && source.cache.maxAge;
583
- if (source.materialize === "startup" ? await hasCurrentSourceSnapshot(store, definition.name, source, verifyOwnership, options.reuseStartupSnapshots ? sources : void 0) : !Number.isFinite(maxAge) || await hasFreshSourceSnapshot(store, definition.name, source)) return;
662
+ if (source.materialize === "startup" ? await hasCurrentSourceSnapshot(store, definition.name, source, verifyOwnership, options.reuseStartupSnapshots ? sources : void 0, path) : !Number.isFinite(maxAge) || await hasFreshSourceSnapshot(store, definition.name, source)) return;
584
663
  materializedSources.delete(sourceKey);
585
664
  }
586
665
  if (completedSources.has(sourceKey) || reusedStartupSources.has(sourceKey)) {
587
- if (await hasCurrentSourceSnapshot(store, definition.name, source, verifyOwnership, options.reuseStartupSnapshots ? sources : void 0)) return;
666
+ if (await hasCurrentSourceSnapshot(store, definition.name, source, verifyOwnership, options.reuseStartupSnapshots ? sources : void 0, path)) return;
588
667
  completedSources.delete(sourceKey);
589
668
  reusedStartupSources.delete(sourceKey);
590
669
  }
591
670
  const recovery = pendingBySource.get(sourceKey);
592
- if (recovery && recovery !== pending) return await ensureMaterialized(sourceKey, verifyRootOwnership);
671
+ if (recovery && recovery !== pending) return await ensureMaterialized(sourceKey, verifyRootOwnership, path);
593
672
  await materializeSerialized({ sources: [sourceKey] });
594
673
  }
595
674
  async function ensureMaterializedSources(items = sources) {
@@ -896,19 +975,19 @@ function createWorkspaceSourceView(definition, store, options = {}) {
896
975
  if (descriptorSource) return decodeFile(descriptorContent(descriptorSource), options);
897
976
  const resolution = resolveWorkspacePath(definition, path);
898
977
  if (resolution.type === "source") {
899
- await ensurePrepared(resolution.sourceKey);
978
+ await ensurePrepared(resolution.sourceKey, resolution.workspacePath);
900
979
  if (isLiveSource(resolution.sourceKey)) {
901
980
  const item = await resolution.source.source.getItem(resolution.sourcePath, getSourceContext(resolution.source));
902
981
  return decodeFile(await sourceItemContent(item), options);
903
982
  }
904
- if (resolution.source.materialize === "startup") await ensureMaterialized(resolution.sourceKey);
983
+ if (resolution.source.materialize === "startup") await ensureMaterialized(resolution.sourceKey, true, resolution.workspacePath);
905
984
  const cacheMaxAge = resolution.source.cache && resolution.source.cache.maxAge;
906
985
  let shouldRefreshCachedLazy = false;
907
986
  if (resolution.source.materialize === "lazy" && Number.isFinite(cacheMaxAge)) shouldRefreshCachedLazy = materializedSources.has(resolution.sourceKey) || Boolean(await readCurrentSourceSnapshot(store, definition.name, resolution.source));
908
987
  if (shouldRefreshCachedLazy) await ensureMaterialized(resolution.sourceKey);
909
988
  const file = await store.readFile(resolution.workspacePath);
910
989
  if (file) return decodeFile(file.content, options);
911
- await ensureMaterialized(resolution.sourceKey);
990
+ await ensureMaterialized(resolution.sourceKey, true, resolution.workspacePath);
912
991
  return await readResolvedSourceFile(resolution, store, sourceContext, options);
913
992
  }
914
993
  await materializeRootStartupSources(false);
@@ -1166,31 +1245,37 @@ function isInternalWorkspaceMetaKey(key) {
1166
1245
  }
1167
1246
  /** Rejects keys that Workspace internals own. Public `setMeta` calls this before it writes. */
1168
1247
  function assertPublicWorkspaceMetaKey(key) {
1169
- if (!hasRuntimeType(key, "string")) throw workspaceError("[vitehub] Workspace metadata keys must be strings.");
1248
+ if (typeof key !== "string") throw workspaceError("[vitehub] Workspace metadata keys must be strings.");
1170
1249
  if (isInternalWorkspaceMetaKey(key)) throw workspaceError(`[vitehub] Workspace metadata key ${JSON.stringify(key)} is reserved for Workspace internals.`);
1171
1250
  return key;
1172
1251
  }
1173
1252
  //#endregion
1174
1253
  //#region src/core/workspace-cache.ts
1175
- let storeByDefinition = /* @__PURE__ */ new WeakMap();
1254
+ const workspaceStoreCacheKey = Symbol.for("vitehub.workspace.storeCache");
1255
+ function storeByDefinition() {
1256
+ const scope = globalThis;
1257
+ return scope[workspaceStoreCacheKey] ??= /* @__PURE__ */ new WeakMap();
1258
+ }
1176
1259
  function getCachedWorkspaceStore(definition, create) {
1177
- let store = storeByDefinition.get(definition);
1260
+ const cache = storeByDefinition();
1261
+ let store = cache.get(definition);
1178
1262
  if (!store) {
1179
1263
  store = create();
1180
- storeByDefinition.set(definition, store);
1264
+ cache.set(definition, store);
1181
1265
  }
1182
1266
  return store;
1183
1267
  }
1184
1268
  function invalidateCachedWorkspaceStore(definition) {
1185
- storeByDefinition.delete(definition);
1269
+ storeByDefinition().delete(definition);
1186
1270
  }
1187
1271
  function resetWorkspaceStoreCache() {
1188
- storeByDefinition = /* @__PURE__ */ new WeakMap();
1272
+ const scope = globalThis;
1273
+ scope[workspaceStoreCacheKey] = /* @__PURE__ */ new WeakMap();
1189
1274
  }
1190
1275
  //#endregion
1191
1276
  //#region src/core/workspace.ts
1192
1277
  function getStore(definition) {
1193
- return getCachedWorkspaceStore(definition, () => createWorkspaceStoreFromProvider(definition));
1278
+ return getCachedWorkspaceStore(definition, () => trackStagedWrites(createWorkspaceStoreFromProvider(definition)));
1194
1279
  }
1195
1280
  function createWorkspace(definition, options = {}) {
1196
1281
  const store = getStore(definition);
@@ -1202,12 +1287,12 @@ function createWorkspace(definition, options = {}) {
1202
1287
  history: createWorkspaceHistory(definition, store, files),
1203
1288
  async capabilities() {
1204
1289
  return {
1205
- conditionalWrites: hasRuntimeType(store.writeFileConditional, "function"),
1290
+ conditionalWrites: typeof store.writeFileConditional === "function",
1206
1291
  retainedHistory: Boolean(store.history)
1207
1292
  };
1208
1293
  },
1209
1294
  async sync(options) {
1210
- const { syncWorkspaceSources } = await import("./sync-CN6ec-5M.js");
1295
+ const { syncWorkspaceSources } = await import("./sync-CCD_VYC8.js");
1211
1296
  return await syncWorkspaceSources(definition, store, options);
1212
1297
  },
1213
1298
  async materializeSources(options) {
@@ -1262,7 +1347,7 @@ function createWorkspace(definition, options = {}) {
1262
1347
  async startSession(options) {
1263
1348
  const host = options?.host;
1264
1349
  if (host) {
1265
- const { createHostedWorkspaceSession } = await import("./host-CFnrTXTK.js").then((n) => n.n);
1350
+ const { createHostedWorkspaceSession } = await import("./host-BFBpXn0N.js").then((n) => n.n);
1266
1351
  return await createHostedWorkspaceSession(workspace, {
1267
1352
  ...options,
1268
1353
  host
@@ -1277,10 +1362,10 @@ function createWorkspace(definition, options = {}) {
1277
1362
  const synchronizedWorkspace = workspace;
1278
1363
  synchronizedWorkspace.__workspaceDefinitionSyncKey = definition;
1279
1364
  synchronizedWorkspace.__syncWorkspaceDefinition = async (abortSignal) => {
1280
- const { syncWorkspaceDefinition } = await import("./lifecycle-BwZ7c9hb.js").then((n) => n.t);
1365
+ const { syncWorkspaceDefinition } = await import("./lifecycle-B-enk_4A.js").then((n) => n.t);
1281
1366
  await syncWorkspaceDefinition(definition, store, abortSignal);
1282
1367
  };
1283
1368
  return attachWorkspaceSourceRequestExecution(workspace, createWorkspaceSourceRequestExecution(definition));
1284
1369
  }
1285
1370
  //#endregion
1286
- export { filterSessionDiff as _, isInternalWorkspaceMetaKey as a, scopedSearchQuery as b, isWorkspaceSourceSyncMetaKey as c, sourceSyncPathClaims as d, workspaceSourceSyncStateEquals as f, assertPathInSessionScope as g, assertDiffInsideSessionPaths as h, assertPublicWorkspaceMetaKey as i, readWorkspaceSourceSyncState as l, createBasicWorkspaceSession as m, invalidateCachedWorkspaceStore as n, createWorkspaceSourceView as o, resolveWorkspacePath as p, resetWorkspaceStoreCache as r, invalidateWorkspaceSourceMaterialization as s, createWorkspace as t, sourceSyncMetaKey as u, filterSessionEntries as v, isMissingWorkspacePathError as y };
1371
+ export { isMissingWorkspacePathError as C, filterSessionEntries as S, workspaceSourceRequestMatches as _, isInternalWorkspaceMetaKey as a, assertPathInSessionScope as b, isWorkspaceSourceSyncMetaKey as c, sourceSyncPathClaims as d, workspaceSourceSyncStateEquals as f, getWorkspaceSourceRequestExecution as g, createWorkspaceSourceRequestExecution as h, assertPublicWorkspaceMetaKey as i, readWorkspaceSourceSyncState as l, attachWorkspaceSourceRequestExecution as m, invalidateCachedWorkspaceStore as n, createWorkspaceSourceView as o, resolveWorkspacePath as p, resetWorkspaceStoreCache as r, invalidateWorkspaceSourceMaterialization as s, createWorkspace as t, sourceSyncMetaKey as u, createBasicWorkspaceSession as v, scopedSearchQuery as w, filterSessionDiff as x, assertDiffInsideSessionPaths as y };
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@vite-hub/workspace",
3
- "version": "0.1.0",
3
+ "version": "0.3.1",
4
4
  "description": "Agent-oriented filesystem state and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "ai-agents",
7
7
  "cloudflare",
8
8
  "filesystem",
9
9
  "nuxt",
10
- "nuxt-module",
11
10
  "typescript",
12
11
  "vercel",
13
12
  "vite",
@@ -46,51 +45,46 @@
46
45
  "import": "./dist/index.js",
47
46
  "default": "./dist/index.js"
48
47
  },
49
- "./ai": {
50
- "types": "./dist/ai.d.ts",
51
- "import": "./dist/ai.js",
52
- "default": "./dist/ai.js"
53
- },
54
48
  "./blob-database": {
55
49
  "types": "./dist/blob-database.d.ts",
56
50
  "import": "./dist/blob-database.js",
57
51
  "default": "./dist/blob-database.js"
58
52
  },
53
+ "./checkout": {
54
+ "types": "./dist/checkout.d.ts",
55
+ "import": "./dist/checkout.js",
56
+ "default": "./dist/checkout.js"
57
+ },
59
58
  "./cloudflare": {
60
59
  "types": "./dist/cloudflare.d.ts",
61
60
  "import": "./dist/cloudflare.js",
62
61
  "default": "./dist/cloudflare.js"
63
62
  },
63
+ "./durability": {
64
+ "types": "./dist/durability.d.ts",
65
+ "import": "./dist/durability.js",
66
+ "default": "./dist/durability.js"
67
+ },
68
+ "./files": {
69
+ "types": "./dist/files.d.ts",
70
+ "import": "./dist/files.js",
71
+ "default": "./dist/files.js"
72
+ },
64
73
  "./internal/path": {
65
74
  "types": "./dist/internal/path.d.ts",
66
75
  "import": "./dist/internal/path.js",
67
76
  "default": "./dist/internal/path.js"
68
77
  },
78
+ "./lineage": {
79
+ "types": "./dist/lineage.d.ts",
80
+ "import": "./dist/lineage.js",
81
+ "default": "./dist/lineage.js"
82
+ },
69
83
  "./loader": {
70
84
  "types": "./dist/loader.d.ts",
71
85
  "import": "./dist/loader.js",
72
86
  "default": "./dist/loader.js"
73
87
  },
74
- "./mountx": {
75
- "types": "./dist/mountx.d.ts",
76
- "import": "./dist/mountx.js",
77
- "default": "./dist/mountx.js"
78
- },
79
- "./nitro": {
80
- "types": "./dist/nitro.d.ts",
81
- "import": "./dist/nitro.js",
82
- "default": "./dist/nitro.js"
83
- },
84
- "./nuxt": {
85
- "types": "./dist/nuxt.d.ts",
86
- "import": "./dist/nuxt.js",
87
- "default": "./dist/nuxt.js"
88
- },
89
- "./operations": {
90
- "types": "./dist/operations.d.ts",
91
- "import": "./dist/operations.js",
92
- "default": "./dist/operations.js"
93
- },
94
88
  "./runtime": {
95
89
  "types": "./dist/runtime.d.ts",
96
90
  "import": "./dist/runtime.js",
@@ -132,11 +126,6 @@
132
126
  "import": "./dist/hosted-vercel-blob.js",
133
127
  "default": "./dist/hosted-vercel-blob.js"
134
128
  },
135
- "./internal/runtime/state": {
136
- "types": "./dist/runtime/state.d.ts",
137
- "import": "./dist/runtime/state.js",
138
- "default": "./dist/runtime/state.js"
139
- },
140
129
  "./internal/runtime/workspace": {
141
130
  "types": "./dist/runtime/workspace.d.ts",
142
131
  "import": "./dist/runtime/workspace.js",
@@ -149,50 +138,49 @@
149
138
  }
150
139
  },
151
140
  "dependencies": {
152
- "@standard-schema/spec": "^1.1.0",
141
+ "@valibot/to-json-schema": "^1.8.0",
153
142
  "@vercel/nft": "^1.11.0",
154
- "@vite-hub/forge": "0.1.0",
155
- "@vite-hub/runtime": "0.1.0",
156
- "@vite-hub/source": "0.1.0",
143
+ "@vite-hub/runtime": "0.3.1",
144
+ "@vite-hub/source": "0.3.1",
145
+ "birpc": "^4.2.0",
157
146
  "defu": "^6.1.7",
158
147
  "esbuild": "^0.28.2",
159
148
  "exsolve": "^1.1.3",
160
- "h3": "2.0.1-rc.33",
161
- "isomorphic-git": "^1.42.6",
149
+ "isomorphic-git": "^1.44.10",
162
150
  "jiti": "^2.7.0",
163
151
  "minimatch": "^10.2.6",
164
- "mountx": "0.0.2",
165
152
  "mrmime": "^2.0.1",
166
- "nostics": "1.3.0",
167
- "ofetch": "^1.5.1",
153
+ "nostics": "1.4.0",
168
154
  "valibot": "^1.5.0",
169
- "@vite-hub/markdown-template": "0.1.0",
170
- "@vite-hub/blob": "0.1.0",
171
- "@vite-hub/database": "0.1.0",
172
- "@vite-hub/sandbox": "0.1.0"
155
+ "yaml": "^2.9.1",
156
+ "@vite-hub/markdown-template": "0.3.1",
157
+ "@vite-hub/blob": "0.3.1",
158
+ "@vite-hub/database": "0.3.1",
159
+ "@vite-hub/sandbox": "0.3.1"
173
160
  },
174
161
  "devDependencies": {
175
162
  "@types/node": "^24.19.1",
176
163
  "@vercel/blob": "^2.8.0",
177
- "@vite-hub/env": "0.1.0",
178
- "@vite-hub/shell": "0.1.0",
164
+ "@vite-hub/env": "0.3.1",
165
+ "@vite-hub/forge": "0.3.1",
166
+ "@vite-hub/internal": "0.0.1",
167
+ "@vite-hub/shell": "0.3.1",
179
168
  "ai": "7.0.130",
180
- "ocache": "^0.3.0",
181
169
  "publint": "^0.3.25",
182
170
  "typescript": "^6.0.3",
183
171
  "vite": "^8.2.2",
184
172
  "vite-plus": "^0.3.3",
185
173
  "vitest": "^4.1.11",
186
- "drizzle-orm": "^0.45.3",
174
+ "drizzle-orm": "1.0.0-rc.5",
187
175
  "miniflare": "4.20260730.0",
188
- "@libsql/client": "^0.18.0",
189
- "@vite-hub/internal": "0.0.1"
176
+ "@libsql/client": "^0.18.0"
190
177
  },
191
178
  "peerDependencies": {
192
- "@vite-hub/shell": "0.1.0",
179
+ "@vite-hub/shell": "0.3.1",
193
180
  "ai": "^6.0.0 || ^7.0.0-0",
194
181
  "vite": ">=8.0.0",
195
- "drizzle-orm": "^0.45.3"
182
+ "drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
183
+ "@vite-hub/forge": "0.3.1"
196
184
  },
197
185
  "peerDependenciesMeta": {
198
186
  "@vite-hub/shell": {
@@ -203,15 +191,18 @@
203
191
  },
204
192
  "drizzle-orm": {
205
193
  "optional": true
194
+ },
195
+ "@vite-hub/forge": {
196
+ "optional": true
206
197
  }
207
198
  },
208
199
  "engines": {
209
- "node": ">=24.0.0"
200
+ "node": ">=22.18.0"
210
201
  },
211
202
  "scripts": {
212
203
  "build": "vp pack",
213
204
  "dev": "vp pack --watch",
214
205
  "typecheck": "vp run --cache -t @vite-hub/workspace#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
215
- "test": "vp run -t @vite-hub/workspace#build && vp test"
206
+ "test": "vp run --cache -t @vite-hub/workspace#build && vp test"
216
207
  }
217
208
  }