@vite-hub/workspace 0.6.1 → 0.8.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 (96) hide show
  1. package/README.md +6 -6
  2. package/dist/{asset-registry-0CdRAjIV.js → asset-registry-DJyE42kr.js} +1 -1
  3. package/dist/blob-database.d.ts +1 -1
  4. package/dist/blob-database.js +6 -6
  5. package/dist/checkout.js +2 -2
  6. package/dist/cloudflare.d.ts +1 -1
  7. package/dist/cloudflare.js +1 -1
  8. package/dist/{config-jo5QgE1w.js → config-Bze7OyvB.js} +15 -10
  9. package/dist/{config-DeA287c0.d.ts → config-DF6sqKXB.d.ts} +1 -1
  10. package/dist/durability.d.ts +1 -1
  11. package/dist/durability.js +2 -2
  12. package/dist/{error-diagnostics-B4me-ouV.js → error-diagnostics-CHgE8TQM.js} +16 -0
  13. package/dist/{error-diagnostics-kKXseq8d.js → error-diagnostics-CsiNo_oI.js} +3 -3
  14. package/dist/{file-BrNAXQgY.js → file-DIBPXqbk.js} +1 -1
  15. package/dist/{file-metadata-Bpsvjw_X.js → file-metadata-Dqpldj0h.js} +7 -2
  16. package/dist/{files--z2dLC5z.js → files-DAJyo7TU.js} +2 -2
  17. package/dist/files.d.ts +5 -5
  18. package/dist/files.js +5 -5
  19. package/dist/{github-k--_LCrX.js → github-DcrnEGNN.js} +4 -4
  20. package/dist/{glob-BreFjNAV.js → glob-BIg9O4yY.js} +2 -2
  21. package/dist/{glob-BEutagp1.js → glob-YVshR7WP.js} +1 -1
  22. package/dist/{host-C8yZizfk.js → host-BT7EnmZf.js} +7 -7
  23. package/dist/hosted-vercel-blob.d.ts +1 -1
  24. package/dist/hosted-vercel-blob.js +464 -1
  25. package/dist/hosted.d.ts +1 -1
  26. package/dist/hosted.js +917 -1
  27. package/dist/index.d.ts +6 -7
  28. package/dist/index.js +13 -13
  29. package/dist/internal/path.js +108 -1
  30. package/dist/internal/workspace.d.ts +2 -3
  31. package/dist/internal/workspace.js +2 -2
  32. package/dist/{lifecycle-IReZfi0b.js → lifecycle-B0ucHUum.js} +8 -8
  33. package/dist/loader.d.ts +1 -1
  34. package/dist/loader.js +2 -2
  35. package/dist/{mcp-resources-DeJnbOaw.js → mcp-resources-BDL0llKW.js} +2 -2
  36. package/dist/{memory-BlSRrBH1.js → memory-BCZl_ZsJ.js} +26 -4
  37. package/dist/{metadata-target-CaGLY4ay.js → metadata-target-mlHAv1p4.js} +59 -24
  38. package/dist/{object-CAK6UYR5.js → object-DNOrQSl5.js} +5 -1
  39. package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BALFFdKj.d.ts} +1 -0
  40. package/dist/{operations-BIaK_uYG.js → operations-D3mZArDi.js} +8 -7
  41. package/dist/operations.d.ts +2 -2
  42. package/dist/operations.js +1341 -2
  43. package/dist/{path-Bb9OIc_F.js → path-DYHw5KNk.js} +11 -3
  44. package/dist/plugins-BYxsPDBH.d.ts +12 -0
  45. package/dist/{provider-CN14ewvx.js → provider-DZY1cLP5.js} +281 -87
  46. package/dist/providers/github/store.d.ts +1 -1
  47. package/dist/providers/github/store.js +1994 -1
  48. package/dist/{registry-BbUg9vJB.js → registry-OonxXCbd.js} +3 -3
  49. package/dist/{registry-B0g19sdy.d.ts → registry-h1-cT-cE.d.ts} +1 -1
  50. package/dist/{registry-s2Ob9PeX.d.ts → registry-hnARUKNF.d.ts} +2 -2
  51. package/dist/replacement-CVZVsflC.js +76 -0
  52. package/dist/{request-scope-CXCI_wCb.js → request-scope-jH4H0Sbm.js} +3 -1
  53. package/dist/{rule-keys-BLEbi1h5.js → rule-keys-xMpiTLq1.js} +1 -1
  54. package/dist/{rules-BPDXypZV.js → rules-DYQCKYdt.js} +4 -4
  55. package/dist/runtime/assets.d.ts +1 -1
  56. package/dist/runtime/assets.js +4 -4
  57. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  58. package/dist/runtime/empty-registry.d.ts +2 -2
  59. package/dist/runtime/registry.d.ts +1 -1
  60. package/dist/runtime/request.js +1 -1
  61. package/dist/runtime/state.d.ts +17 -6
  62. package/dist/runtime/state.js +7 -7
  63. package/dist/runtime/workspace.d.ts +1 -1
  64. package/dist/runtime/workspace.js +1 -1
  65. package/dist/runtime.d.ts +8 -8
  66. package/dist/runtime.js +39 -24
  67. package/dist/{search-C_nVorq7.js → search-CG6UNOtn.js} +1 -1
  68. package/dist/server.d.ts +2 -2
  69. package/dist/server.js +301 -1
  70. package/dist/{shared-C20Wh1mp.js → shared-DCAyMX8U.js} +68 -21
  71. package/dist/source-metadata.d.ts +2 -2
  72. package/dist/source-metadata.js +3 -3
  73. package/dist/{sync-BBfR4g5y.js → sync-DkpTCr9u.js} +5 -5
  74. package/dist/test.d.ts +1 -1
  75. package/dist/test.js +1 -1
  76. package/dist/{types-Bel5IDmF.d.ts → types-BnSUug2v.d.ts} +13 -1
  77. package/dist/{use-CpphIBof.d.ts → use-CJ5rdIrW.d.ts} +1 -1
  78. package/dist/{use-D0DyTMxM.js → use-hLouCwGz.js} +15 -51
  79. package/dist/{use-tools-CAK10LTc.d.ts → use-tools-DFVqZwgc.d.ts} +2 -2
  80. package/dist/{use-tools-CHduR5k6.js → use-tools-NXEQt099.js} +4 -4
  81. package/dist/{utils-DXP9xfXo.js → utils-Bv1NBg8r.js} +5 -5
  82. package/dist/vite.d.ts +2 -2
  83. package/dist/vite.js +517 -121
  84. package/dist/{workspace-BOuxrZrP.d.ts → workspace-B6QreLJd.d.ts} +1 -1
  85. package/dist/{workspace-CLuPkyZR.js → workspace-Cz-5Ne1c.js} +340 -104
  86. package/dist/workspace-inspection-scanner-BlJ8bCAB.js +140 -0
  87. package/package.json +12 -12
  88. package/dist/errors-CnFDXxeJ.d.ts +0 -4
  89. package/dist/hosted-8BTKAtMX.js +0 -883
  90. package/dist/hosted-vercel-blob-B6kygYqn.js +0 -408
  91. package/dist/operations-DS1C4uXd.js +0 -1308
  92. package/dist/path-CuYE8-X6.js +0 -57
  93. package/dist/plugins-CLc32jvL.d.ts +0 -8
  94. package/dist/server-aa1a4rkV.js +0 -301
  95. package/dist/state-BdDfBtOR.d.ts +0 -17
  96. package/dist/store-cx3OqNTi.js +0 -1971
@@ -1,54 +1,15 @@
1
- import { n as useWorkspaceAssets } from "./asset-registry-0CdRAjIV.js";
2
- import { i as isWorkspaceError, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
3
- import { f as normalizeHistoryRef, g as validateHistoryMessage, h as requireWorkspaceHistory, m as rejectHistoryHead, s as deleteWorkspaceHistoryRef, u as historyConflict } from "./utils-DXP9xfXo.js";
1
+ import { n as useWorkspaceAssets } from "./asset-registry-DJyE42kr.js";
2
+ import { normalizeSafeWorkspacePath, o as workspaceError } from "./internal/path.js";
3
+ import { f as normalizeHistoryRef, g as validateHistoryMessage, h as requireWorkspaceHistory, m as rejectHistoryHead, s as deleteWorkspaceHistoryRef, u as historyConflict } from "./utils-Bv1NBg8r.js";
4
+ import { _ as attachWorkspaceSourceRequestExecution, g as copyWorkspacePath, h as appendWorkspaceFile, i as assertPublicWorkspaceMetaKey, t as createWorkspace, y as getWorkspaceSourceRequestExecution } from "./workspace-Cz-5Ne1c.js";
5
+ import { c as normalizeSafeWorkspacePattern, f as sha256 } from "./path-DYHw5KNk.js";
6
+ import { s as useRegisteredWorkspace } from "./registry-OonxXCbd.js";
4
7
  import { a as provideWorkspaceStoreTarget, i as forwardWorkspaceStoreTarget, o as resolveWorkspaceStoreTarget } from "./vitehub-grants-Co713QTg.js";
5
- import { c as normalizeSafeWorkspacePattern, d as sha256 } from "./path-Bb9OIc_F.js";
6
- import { s as useRegisteredWorkspace } from "./registry-BbUg9vJB.js";
7
- import { g as getWorkspaceSourceRequestExecution, i as assertPublicWorkspaceMetaKey, m as attachWorkspaceSourceRequestExecution, t as createWorkspace } from "./workspace-CLuPkyZR.js";
8
- import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-CaGLY4ay.js";
9
- import { t as createHostedWorkspaceSession } from "./host-C8yZizfk.js";
10
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
8
+ import { o as requireWorkspaceReplacement, t as attachWorkspaceReplacement } from "./replacement-CVZVsflC.js";
9
+ import { c as workspaceInternalMetadataCapability, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, t as attachWorkspaceMetadataTarget } from "./metadata-target-mlHAv1p4.js";
10
+ import { t as createHostedWorkspaceSession } from "./host-BT7EnmZf.js";
11
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
11
12
  import { getViteHubErrorShape } from "@vite-hub/runtime";
12
- import { posix } from "node:path";
13
- // src/fs-ops.ts
14
- async function ensureMissingOrReplaceable(workspace, path, overwrite = false) {
15
- if (!await workspace.exists(path)) return;
16
- if (!overwrite) throw workspaceError(`[vitehub] Workspace path already exists: ${path}.`);
17
- await workspace.rm(path, {
18
- recursive: true,
19
- force: true
20
- });
21
- }
22
- async function copyWorkspacePath(workspace, from, to, overwrite = false) {
23
- if (from === to) throw workspaceError("[vitehub] Source and destination must be different.");
24
- const source = await workspace.stat(from);
25
- if (source.type === "directory" && to.startsWith(`${from}/`)) throw workspaceError("[vitehub] Destination cannot be nested inside the source directory.");
26
- if (from.startsWith(`${to}/`)) throw workspaceError("[vitehub] Destination cannot contain the source.");
27
- if (overwrite && await (await resolveWorkspaceStoreTarget(workspace))?.containsPath?.(to, from)) throw workspaceError("[vitehub] Destination cannot contain the source.");
28
- await ensureMissingOrReplaceable(workspace, to, overwrite);
29
- if (source.type === "file") {
30
- const content = await workspace.readFile(from, { encoding: "binary" });
31
- await workspace.writeFile(to, content, { mediaType: source.mediaType });
32
- return;
33
- }
34
- const entries = await workspace.list(from, { recursive: true });
35
- await workspace.mkdir(to, { recursive: true });
36
- const directories = entries.filter((entry) => entry.type === "directory").sort((left, right) => left.path.length - right.path.length);
37
- for (const entry of directories) await workspace.mkdir(posix.join(to, posix.relative(from, entry.path)), { recursive: true });
38
- await Promise.all(entries.filter((entry) => entry.type === "file").map(async (entry) => {
39
- const content = await workspace.readFile(entry.path, { encoding: "binary" });
40
- await workspace.writeFile(posix.join(to, posix.relative(from, entry.path)), content, { mediaType: entry.mediaType });
41
- }));
42
- }
43
- async function appendWorkspaceFile(workspace, path, content) {
44
- let current = "";
45
- try {
46
- current = String(await workspace.readFile(path));
47
- } catch (error) {
48
- if (!isWorkspaceError(error)) throw error;
49
- }
50
- await workspace.writeFile(path, `${current}${content}`);
51
- }
52
13
  // src/core/use.ts
53
14
  const workspaceDefinitionSyncStates = /* @__PURE__ */ new WeakMap();
54
15
  async function workspaceDefinitionSyncState(workspace) {
@@ -263,6 +224,7 @@ function createLazyWorkspace(name, definition, options = {}) {
263
224
  return await (await resolveSyncedWorkspace()).startSession(options);
264
225
  }
265
226
  };
227
+ attachWorkspaceReplacement(workspace, async (replacement, check) => await requireWorkspaceReplacement(await resolveSyncedWorkspace())(replacement, check));
266
228
  provideWorkspaceStoreTarget(workspace, async () => await resolveWorkspaceStoreTarget(await resolveWorkspace()));
267
229
  attachWorkspaceMetadataTarget(workspace, async () => await resolveWorkspaceMetadataTarget(await resolveWorkspace()));
268
230
  return attachWorkspaceSourceRequestExecution(workspace, { async executeSourceRequest(input) {
@@ -273,7 +235,7 @@ function createLazyWorkspace(name, definition, options = {}) {
273
235
  } });
274
236
  }
275
237
  function createWritableFs(name, workspace) {
276
- return attachWorkspaceSourceRequestExecution({
238
+ const fs = attachWorkspaceSourceRequestExecution({
277
239
  readFile: async (path, options) => await workspace.readFile(normalizePath(path), options),
278
240
  writeFile: async (path, content, options) => await workspace.writeFile(normalizePath(path), content, options),
279
241
  appendFile: async (path, content) => await appendWorkspaceFile(workspace, normalizePath(path), content),
@@ -298,6 +260,8 @@ function createWritableFs(name, workspace) {
298
260
  },
299
261
  copyPath: async (from, to, options) => await copyWorkspacePath(workspace, normalizePath(from), normalizePath(to), options?.overwrite)
300
262
  }, getWorkspaceSourceRequestExecution(workspace));
263
+ attachWorkspaceReplacement(fs, requireWorkspaceReplacement(workspace));
264
+ return fs;
301
265
  }
302
266
  function useOptionalWorkspaceAssets(name) {
303
267
  try {
@@ -479,4 +443,4 @@ function createWorkspaceFileRuntime(name, options) {
479
443
  function useWorkspaceFiles(name, options) {
480
444
  return createWorkspaceFileRuntime(name, options).facade;
481
445
  }
482
- export { copyWorkspacePath as a, appendWorkspaceFile as i, createWorkspaceFileRuntime as n, useWorkspaceFiles as r, createReadonlyFs as t };
446
+ export { createWorkspaceFileRuntime as n, useWorkspaceFiles as r, createReadonlyFs as t };
@@ -1,5 +1,5 @@
1
- import { h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions } from "./use-CpphIBof.js";
2
- import { gt as WorkspaceLookupName } from "./types-Bel5IDmF.js";
1
+ import { h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions } from "./use-CJ5rdIrW.js";
2
+ import { gt as WorkspaceLookupName } from "./types-BnSUug2v.js";
3
3
  declare function useWorkspace<Name extends WorkspaceLookupName>(name: Name): ReadonlyWorkspaceFacade<Name>;
4
4
  declare function useWorkspace<Name extends WorkspaceLookupName>(name: Name, options: UseWorkspaceOptions & {
5
5
  mode?: "read";
@@ -1,7 +1,7 @@
1
- import { s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
2
- import { a as copyWorkspacePath, i as appendWorkspaceFile, n as createWorkspaceFileRuntime, t as createReadonlyFs } from "./use-D0DyTMxM.js";
3
- import { g as getWorkspaceSourceRequestExecution } from "./workspace-CLuPkyZR.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
1
+ import { normalizeSafeWorkspacePath, o as workspaceError } from "./internal/path.js";
2
+ import { g as copyWorkspacePath, h as appendWorkspaceFile, y as getWorkspaceSourceRequestExecution } from "./workspace-Cz-5Ne1c.js";
3
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
4
+ import { n as createWorkspaceFileRuntime, t as createReadonlyFs } from "./use-hLouCwGz.js";
5
5
  import { executionBudgetCharged, executionBudgetOverride, markExecutionBudgetHandled } from "@vite-hub/runtime/internal/execution-budget";
6
6
  // src/runtime/dependency-loaders.ts
7
7
  const shellWorkspaceSpecifier = "@vite-hub/shell/workspace";
@@ -1,8 +1,8 @@
1
- import { a as workspaceConflict, s as workspaceError, t as normalizeSafeWorkspacePath } from "./path-CuYE8-X6.js";
2
- import { n as copyJsonWorkspaceMetadata, t as copyJsonFileMetadata } from "./file-metadata-Bpsvjw_X.js";
3
- import { d as sha256, o as isWorkspaceBytes, r as contentToBytes } from "./path-Bb9OIc_F.js";
4
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-B4me-ouV.js";
5
- import { t as createWorkspaceWritePolicy } from "./rules-BPDXypZV.js";
1
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
2
+ import { n as copyJsonFileMetadata, r as copyJsonWorkspaceMetadata } from "./file-metadata-Dqpldj0h.js";
3
+ import { i as workspaceConflict, normalizeSafeWorkspacePath, o as workspaceError } from "./internal/path.js";
4
+ import { f as sha256, o as isWorkspaceBytes, r as contentToBytes } from "./path-DYHw5KNk.js";
5
+ import { t as createWorkspaceWritePolicy } from "./rules-DYQCKYdt.js";
6
6
  import { lookup } from "mrmime";
7
7
  import { isRuntimeObject } from "@vite-hub/runtime/internal/runtime-type";
8
8
  // src/core/history.ts
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { At as WorkspaceOptions } from "./types-Bel5IDmF.js";
2
- import { n as OperationContributionEntry } from "./operation-definition-CqZkx1Rm.js";
1
+ import { At as WorkspaceOptions } from "./types-BnSUug2v.js";
2
+ import { n as OperationContributionEntry } from "./operations-BALFFdKj.js";
3
3
  import { EnvironmentOptions, Plugin } from "vite";
4
4
  type NitroPackageLoadingOptions = {
5
5
  devServer?: {