@vite-hub/workspace 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -107
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/blob-database.d.ts +70 -117
- package/dist/blob-database.js +48 -41
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +2 -2
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
- package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
- package/dist/discard-CNNtCozM.js +8 -0
- package/dist/durability.d.ts +22 -0
- package/dist/durability.js +70 -0
- package/dist/error-diagnostics-CtKjGtGb.js +188 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/file-2pFYNtsU.js +22 -0
- package/dist/{files-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
- package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
- package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
- package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
- package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +2 -2
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +5 -3
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +9 -51
- package/dist/index.js +21 -91
- package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +2 -2
- package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
- package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
- package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-C6FpR8Rr.js +389 -0
- package/dist/operations-CE2drFih.js +1234 -0
- package/dist/operations.d.ts +41 -4
- package/dist/operations.js +3 -2
- package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
- package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
- package/dist/registry-CYNN623b.d.ts +9 -0
- package/dist/request-scope-Dw5n8bMC.js +83 -0
- package/dist/results-DgkZUmTL.js +8 -0
- package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +3 -3
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +2 -1
- package/dist/runtime/registry.d.ts +2 -0
- package/dist/runtime/registry.js +23 -0
- package/dist/runtime/request.d.ts +4 -0
- package/dist/runtime/request.js +8 -0
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +8 -18
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +9 -8
- package/dist/runtime.js +23 -26
- package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
- package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
- package/dist/server.d.ts +17 -8
- package/dist/server.js +1 -1
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +6 -2
- package/dist/source-metadata.js +8 -8
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
- package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
- package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
- package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21368 -1
- package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
- package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
- package/package.json +46 -55
- package/dist/ai-BW2ZhizI.d.ts +0 -177
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
- package/dist/error-diagnostics-A_8Kp-48.js +0 -116
- package/dist/error-diagnostics-DY5GP47p.js +0 -96
- package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
- package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
- package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
- package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
- package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
- package/dist/file-C0_aPWSS.js +0 -26
- package/dist/file-metadata-CxDy-E2H.js +0 -58
- package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
- package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
- package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
- package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
- package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
- package/dist/inspect-BoObD2cJ.js +0 -167
- package/dist/mountx.d.ts +0 -8
- package/dist/mountx.js +0 -145
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -27
- package/dist/nuxt.js +0 -38
- package/dist/operations-BcpWr41m.js +0 -159
- package/dist/operations-CGqY1XeG.js +0 -965
- package/dist/operations-DnOwKsJT.d.ts +0 -136
- package/dist/registry-Cg1TJVVZ.d.ts +0 -10
- package/dist/request-execution-Dk9rY-Yh.js +0 -84
- package/dist/shared-DalXdP0i.js +0 -2158
- package/dist/state-B8zbLi5t.d.ts +0 -26
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
- package/dist/token-CO62GglH.js +0 -61
- package/dist/use-DhwhbAVV.d.ts +0 -108
- package/dist/vite-BEvgU2GY.js +0 -20909
- package/dist/vite-CcZmMQ7S.d.ts +0 -476
- package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "node:module";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -30,6 +30,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
value: mod,
|
|
31
31
|
enumerable: true
|
|
32
32
|
}) : target, mod));
|
|
33
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
34
33
|
//#endregion
|
|
35
|
-
export {
|
|
34
|
+
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|
package/dist/runtime/assets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as WorkspaceAssets,
|
|
1
|
+
import { D as WorkspaceAssets, N as WorkspaceContent } from "../types-BbtwmBZ5.js";
|
|
2
2
|
//#region src/runtime/assets.d.ts
|
|
3
3
|
interface WorkspaceAssetFile {
|
|
4
4
|
load: () => Promise<WorkspaceContent>;
|
package/dist/runtime/assets.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as isWorkspaceError, s as workspaceError, t as normalizeSafeWorkspacePath } from "../path-DrSIenjj.js";
|
|
2
|
-
import { a as isExcludedWorkspacePath, f as sha256, i as decodeFile, l as normalizeWorkspacePath } from "../path
|
|
3
|
-
import { t as createWorkspaceGlobMatcher } from "../glob
|
|
4
|
-
import { t as searchText } from "../search-
|
|
2
|
+
import { a as isExcludedWorkspacePath, f as sha256, i as decodeFile, l as normalizeWorkspacePath } from "../path--wrT_Azm.js";
|
|
3
|
+
import { t as createWorkspaceGlobMatcher } from "../glob-Cjxms1t7.js";
|
|
4
|
+
import { t as searchText } from "../search-C_RfoM2j.js";
|
|
5
5
|
//#region src/runtime/assets.ts
|
|
6
6
|
function createMissingPathError(path) {
|
|
7
7
|
return workspaceError(`[vitehub] Workspace file does not exist: ${path}.`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { t as WorkspaceRegistry } from "../registry-
|
|
1
|
+
import { t as WorkspaceRegistry } from "../registry-B3BBm4Ts.js";
|
|
2
|
+
import "../registry-CYNN623b.js";
|
|
2
3
|
//#region src/runtime/empty-registry.d.ts
|
|
3
4
|
declare const registry: WorkspaceRegistry;
|
|
4
5
|
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as workspaceRuntimeRegistryState, i as setWorkspaceRuntimeRegistry, n as WorkspaceRegistryModule, r as resetWorkspaceRuntimeRegistry, s as setWorkspaceRuntimeConfig, t as WorkspaceRegistry } from "../registry-B3BBm4Ts.js";
|
|
2
|
+
export { WorkspaceRegistry, WorkspaceRegistryModule, resetWorkspaceRuntimeRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeRegistry, workspaceRuntimeRegistryState };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { n as setWorkspaceRuntimeConfig } from "../config-B-863EgC.js";
|
|
2
|
+
import runtimeRegistry from "#vitehub-workspace-registry";
|
|
3
|
+
//#region src/runtime/registry.ts
|
|
4
|
+
const workspaceRuntimeRegistryKey = Symbol.for("vitehub.workspace.runtimeRegistry");
|
|
5
|
+
function workspaceRuntimeRegistryState() {
|
|
6
|
+
const scope = globalThis;
|
|
7
|
+
return scope[workspaceRuntimeRegistryKey] ??= {
|
|
8
|
+
loaders: runtimeRegistry,
|
|
9
|
+
version: 0
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function setWorkspaceRuntimeRegistry(registry) {
|
|
13
|
+
const scope = globalThis;
|
|
14
|
+
scope[workspaceRuntimeRegistryKey] = {
|
|
15
|
+
loaders: registry,
|
|
16
|
+
version: workspaceRuntimeRegistryState().version + 1
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function resetWorkspaceRuntimeRegistry() {
|
|
20
|
+
setWorkspaceRuntimeRegistry(runtimeRegistry);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { resetWorkspaceRuntimeRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeRegistry, workspaceRuntimeRegistryState };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as runWorkspaceRequest } from "../request-scope-Dw5n8bMC.js";
|
|
2
|
+
//#region src/runtime/request.ts
|
|
3
|
+
/** Nitro middleware: runs the rest of the request in its own Workspace request scope. */
|
|
4
|
+
function workspaceRequestMiddleware(_event, next) {
|
|
5
|
+
return runWorkspaceRequest(next);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { workspaceRequestMiddleware as default };
|
package/dist/runtime/state.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles, h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, s as UseWorkspaceOptions, x as useWorkspaceFiles } from "../use-C6lV3-wC.js";
|
|
2
|
+
import { o as getWorkspaceRuntimeConfig, s as setWorkspaceRuntimeConfig } from "../registry-B3BBm4Ts.js";
|
|
3
|
+
import { n as resolveRegisteredWorkspaceDefinition, r as setWorkspaceRuntimeDefinitions, t as registerWorkspace } from "../registry-CYNN623b.js";
|
|
4
|
+
import { c as resetWorkspaceStoreCache, l as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, o as getWorkspaceHostedStoreLoader, r as setWorkspaceRuntimeRegistry, s as setWorkspaceHostedStoreLoader, t as invalidateWorkspaceStore, u as setActiveCloudflareEnv } from "../state-BISnUf1s.js";
|
|
5
|
+
export { type ReadonlyWorkspaceFacade, type ReadonlyWorkspaceFiles, type UseWorkspaceOptions, type WritableWorkspaceFacade, type WritableWorkspaceFiles, getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, invalidateWorkspaceStore, registerWorkspace, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, setActiveCloudflareEnv, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeDefinitions, setWorkspaceRuntimeRegistry, useWorkspace, useWorkspaceFiles };
|
package/dist/runtime/state.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
invalidateCachedWorkspaceStore(await resolveRegisteredWorkspaceDefinition(name));
|
|
10
|
-
}
|
|
11
|
-
function setWorkspaceRuntimeRegistry(registry) {
|
|
12
|
-
setWorkspaceRegistry(registry);
|
|
13
|
-
}
|
|
14
|
-
function setWorkspaceRuntimeAssetsRegistry(registry) {
|
|
15
|
-
setWorkspaceAssetsRegistry(registry);
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, invalidateWorkspaceStore, registerWorkspace, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, setActiveCloudflareEnv, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeRegistry, useWorkspace };
|
|
1
|
+
import { E as setActiveCloudflareEnv } from "../shared-B3_EUk89.js";
|
|
2
|
+
import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "../provider-9s4Ufkm5.js";
|
|
3
|
+
import { n as setWorkspaceRuntimeConfig, t as getWorkspaceRuntimeConfig } from "../config-B-863EgC.js";
|
|
4
|
+
import { r as resetWorkspaceStoreCache } from "../workspace-sPWn2Jxj.js";
|
|
5
|
+
import { a as setWorkspaceRuntimeDefinitions, n as registerWorkspace, r as resolveRegisteredWorkspaceDefinition } from "../registry-CNphafBx.js";
|
|
6
|
+
import { r as useWorkspaceFiles } from "../use-CSpT5W87.js";
|
|
7
|
+
import { i as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, r as setWorkspaceRuntimeRegistry, t as invalidateWorkspaceStore } from "../state-DbrW-njQ.js";
|
|
8
|
+
export { getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, invalidateWorkspaceStore, registerWorkspace, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, setActiveCloudflareEnv, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeDefinitions, setWorkspaceRuntimeRegistry, useWorkspace, useWorkspaceFiles };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createWorkspace } from "../workspace-
|
|
1
|
+
import { t as createWorkspace } from "../workspace-CYB2xZ1T.js";
|
|
2
2
|
export { createWorkspace };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createWorkspace } from "../workspace-
|
|
1
|
+
import { t as createWorkspace } from "../workspace-sPWn2Jxj.js";
|
|
2
2
|
export { createWorkspace };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import { a as
|
|
1
|
+
import { B as WorkspaceEntry, I as WorkspaceDefinition, Kt as WorkspaceSource, Rt as WorkspaceSelectedScope, St as WorkspaceName, T as Workspace, ht as WorkspaceMaterializeSourcesResult, in as WorkspaceSourceRequestExecutionResult, nn as WorkspaceSourceRequestDescriptor, rn as WorkspaceSourceRequestExecutionInput, rt as WorkspaceHistoryReader, un as WorkspaceSourceResolutionInvocation } from "./types-BbtwmBZ5.js";
|
|
2
|
+
import { _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles, h as WritableWorkspaceFacade, i as ReadonlyWorkspaceFacade, o as ReadonlyWorkspaceFs, s as UseWorkspaceOptions, v as WritableWorkspaceFs, x as useWorkspaceFiles } from "./use-C6lV3-wC.js";
|
|
3
|
+
import { t as registerWorkspacePlugin } from "./plugins-C8C0auoW.js";
|
|
4
|
+
import { o as getWorkspaceRuntimeConfig, s as setWorkspaceRuntimeConfig } from "./registry-B3BBm4Ts.js";
|
|
5
|
+
import { n as resolveRegisteredWorkspaceDefinition, r as setWorkspaceRuntimeDefinitions, t as registerWorkspace } from "./registry-CYNN623b.js";
|
|
6
|
+
import { a as WorkspaceHostedStoreLoader, c as resetWorkspaceStoreCache, i as HostedWorkspaceStoreOptions, l as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, o as getWorkspaceHostedStoreLoader, r as setWorkspaceRuntimeRegistry, s as setWorkspaceHostedStoreLoader, t as invalidateWorkspaceStore } from "./state-BISnUf1s.js";
|
|
7
|
+
import { a as getWorkspaceSourceRequestDescriptor, i as workspaceSourceGrantPaths, n as normalizeWorkspaceSourceMetadata, o as isWorkspaceSourceRequestOnly, r as normalizeWorkspaceSourcesMetadata, s as workspaceSourceRequestDescriptorPath, t as WorkspaceSourceMetadata } from "./config-BQKcPawI.js";
|
|
7
8
|
//#region src/runtime/dependency-loaders.d.ts
|
|
8
9
|
interface WorkspaceDependencyRuntimeLoaders {
|
|
9
10
|
shellWorkspace: () => Promise<unknown>;
|
|
@@ -36,7 +37,7 @@ export declare function markLiveWorkspaceSource(source: WorkspaceSource, paths:
|
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region src/storage/metadata-target.d.ts
|
|
38
39
|
/** An object that can carry a metadata target: a Workspace, a Workspace facade, or the `fs` of a facade. */
|
|
39
|
-
type WorkspaceMetadataCarrier = Workspace |
|
|
40
|
+
type WorkspaceMetadataCarrier = Workspace | ReadonlyWorkspaceFiles | WritableWorkspaceFiles | ReadonlyWorkspaceFs | WritableWorkspaceFs;
|
|
40
41
|
/**
|
|
41
42
|
* Attaches a read-only metadata view of `source` to `target`.
|
|
42
43
|
* The view has the Workspace name, `getMeta`, `list`, and the Store target. It never has Store writes.
|
|
@@ -104,4 +105,4 @@ export declare function recoverLocalWorkspaceLocks(options: {
|
|
|
104
105
|
removed: number;
|
|
105
106
|
}>;
|
|
106
107
|
//#endregion
|
|
107
|
-
export { type HostedWorkspaceStoreOptions, type ReadonlyWorkspaceFacade, type UseWorkspaceOptions, type WorkspaceDependencyRuntimeLoaders, type WorkspaceHostedStoreLoader, type WorkspacePreparation, type WorkspacePreparationOptions, type WorkspacePreparationState, type WorkspaceSourceMetadata, type WorkspaceSourceResolutionFacade, type WorkspaceSourceResolutionOptions, type WritableWorkspaceFacade, getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, getWorkspaceSourceRequestDescriptor, invalidateWorkspaceStore, isWorkspaceSourceRequestOnly, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, registerWorkspace, registerWorkspacePlugin, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeRegistry, useWorkspace, workspaceSourceGrantPaths, workspaceSourceRequestDescriptorPath };
|
|
108
|
+
export { type HostedWorkspaceStoreOptions, type ReadonlyWorkspaceFacade, type ReadonlyWorkspaceFiles, type UseWorkspaceOptions, type WorkspaceDependencyRuntimeLoaders, type WorkspaceHostedStoreLoader, type WorkspacePreparation, type WorkspacePreparationOptions, type WorkspacePreparationState, type WorkspaceSourceMetadata, type WorkspaceSourceResolutionFacade, type WorkspaceSourceResolutionOptions, type WritableWorkspaceFacade, type WritableWorkspaceFiles, getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, getWorkspaceSourceRequestDescriptor, invalidateWorkspaceStore, isWorkspaceSourceRequestOnly, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, registerWorkspace, registerWorkspacePlugin, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeDefinitions, setWorkspaceRuntimeRegistry, useWorkspace, useWorkspaceFiles, workspaceSourceGrantPaths, workspaceSourceRequestDescriptorPath };
|
package/dist/runtime.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
import { t as createMemoryWorkspaceStore } from "./memory-BOexthyW.js";
|
|
1
2
|
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import { a as
|
|
10
|
-
import {
|
|
11
|
-
import { a as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { invalidateWorkspaceStore, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeRegistry } from "./runtime/state.js";
|
|
3
|
+
import { n as resolveWorkspaceStoreTarget, r as workspaceStoreTarget, t as forwardWorkspaceStoreTarget } from "./target-jWhTdIuF.js";
|
|
4
|
+
import { l as normalizeWorkspacePath } from "./path--wrT_Azm.js";
|
|
5
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
|
|
6
|
+
import { a as createWorkspaceHistoryReader, c as forwardWorkspaceHistoryMerge, g as registerWorkspacePlugin, i as createWorkspaceHistory, m as createWorkspaceWritePolicy, s as forwardWorkspaceHistoryFiles } from "./utils-CgMZCHsX.js";
|
|
7
|
+
import { t as isRecord } from "./object-Da1zyPCR.js";
|
|
8
|
+
import { d as setWorkspaceHostedStoreLoader, u as getWorkspaceHostedStoreLoader } from "./provider-9s4Ufkm5.js";
|
|
9
|
+
import { n as setWorkspaceRuntimeConfig, t as getWorkspaceRuntimeConfig } from "./config-B-863EgC.js";
|
|
10
|
+
import { _ as workspaceSourceRequestMatches, a as isInternalWorkspaceMetaKey, c as isWorkspaceSourceSyncMetaKey, g as getWorkspaceSourceRequestExecution, h as createWorkspaceSourceRequestExecution, m as attachWorkspaceSourceRequestExecution, o as createWorkspaceSourceView, p as resolveWorkspacePath, r as resetWorkspaceStoreCache, v as createBasicWorkspaceSession } from "./workspace-sPWn2Jxj.js";
|
|
11
|
+
import { _ as isWorkspaceSourceRequestOnly, a as normalizeWorkspaceSources, b as markLiveWorkspaceSource, f as prepareWorkspaceSource, h as getWorkspaceSourceRequestDescriptor, i as normalizeWorkspaceSourceMetadata, l as workspaceSourceGrantPaths, o as normalizeWorkspaceSourcesMetadata, r as normalizeWorkspaceSource, t as copyWorkspaceSourceMetadata, u as ownSourceOption, v as workspaceSourceRequestDescriptorPath } from "./config-BAgL2dtB.js";
|
|
12
|
+
import { M as registerWorkspaceStoreAlias, a as resolveWorkspaceMetadataMutationTarget, i as forwardWorkspaceMetadataView, n as createWorkspaceMetadataTarget, o as resolveWorkspaceMetadataTarget, r as forwardWorkspaceMetadataTarget, s as setWorkspaceMetadata, t as attachWorkspaceMetadataTarget } from "./metadata-target-CWz6KHKq.js";
|
|
13
|
+
import { a as setWorkspaceRuntimeDefinitions, n as registerWorkspace, r as resolveRegisteredWorkspaceDefinition } from "./registry-CNphafBx.js";
|
|
14
|
+
import { a as copyWorkspacePath, i as appendWorkspaceFile, r as useWorkspaceFiles } from "./use-CSpT5W87.js";
|
|
15
|
+
import { a as createWorkspaceTools, i as useWorkspace, n as setWorkspaceRuntimeAssetsRegistry, o as getWorkspaceDependencyRuntimeLoaders, r as setWorkspaceRuntimeRegistry, s as setWorkspaceDependencyRuntimeLoaders, t as invalidateWorkspaceStore } from "./state-DbrW-njQ.js";
|
|
16
16
|
import { join, resolve } from "node:path";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
|
-
import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
|
|
19
18
|
import { lstat, readdir, rename, rm } from "node:fs/promises";
|
|
20
19
|
//#region src/sources/resolution.ts
|
|
21
20
|
function hasWorkspaceSourceResolvers(definition) {
|
|
@@ -285,7 +284,7 @@ function createWritableFacadeStore(workspace, sourceSync) {
|
|
|
285
284
|
async function startOverlayWorkspaceSession(_definition, workspace, options) {
|
|
286
285
|
const host = options?.host;
|
|
287
286
|
if (host) {
|
|
288
|
-
const { createHostedWorkspaceSession } = await import("./host-
|
|
287
|
+
const { createHostedWorkspaceSession } = await import("./host-BFBpXn0N.js").then((n) => n.n);
|
|
289
288
|
return await createHostedWorkspaceSession(workspace, {
|
|
290
289
|
...options,
|
|
291
290
|
host
|
|
@@ -550,7 +549,7 @@ async function createWorkspaceSourceResolutionFacade(workspace, definition, opti
|
|
|
550
549
|
},
|
|
551
550
|
stat: writeFs.stat,
|
|
552
551
|
sync: async (options) => {
|
|
553
|
-
const { syncWorkspaceSources } = await import("./sync-
|
|
552
|
+
const { syncWorkspaceSources } = await import("./sync-CCD_VYC8.js");
|
|
554
553
|
return await syncWorkspaceSources(resolvedDefinition, syncStore, options);
|
|
555
554
|
},
|
|
556
555
|
writeFile: writeFs.writeFile
|
|
@@ -690,6 +689,7 @@ async function resolveWorkspaceSource(definition, key, input, options) {
|
|
|
690
689
|
const resolved = await resolve(context);
|
|
691
690
|
if (!resolved) return void 0;
|
|
692
691
|
const resolvedSource = withResolvedSourceRuntimeDefaults(applyResolvedWorkspaceSourceBinding(input, resolved));
|
|
692
|
+
if (source.skills === false) resolvedSource.skills = false;
|
|
693
693
|
const normalized = normalizeWorkspaceSource(key, resolvedSource);
|
|
694
694
|
if (!selectedScopeIntersectsSource(options.selectedWorkspaceScope, normalized)) return void 0;
|
|
695
695
|
const result = copyWorkspaceSourceMetadata(resolvedSource, {
|
|
@@ -709,7 +709,7 @@ async function resolveWorkspaceSource(definition, key, input, options) {
|
|
|
709
709
|
return result;
|
|
710
710
|
}
|
|
711
711
|
function applyResolvedWorkspaceSourceBinding(input, source) {
|
|
712
|
-
if (!
|
|
712
|
+
if (!isRecord(input)) return source;
|
|
713
713
|
const next = { ...source };
|
|
714
714
|
copyWorkspaceSourceMetadata(source, next);
|
|
715
715
|
if (!("source" in input)) return next;
|
|
@@ -732,9 +732,6 @@ function withResolvedSourceRuntimeDefaults(source) {
|
|
|
732
732
|
materialize: "lazy"
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
|
-
function isPlainRecord(input) {
|
|
736
|
-
return !!input && typeof input === "object" && !Array.isArray(input);
|
|
737
|
-
}
|
|
738
735
|
function isSourcePath(definition, path) {
|
|
739
736
|
if (isWorkspaceMetadataPath(path)) return false;
|
|
740
737
|
return resolveWorkspacePath(definition, path).type === "source";
|
|
@@ -881,13 +878,13 @@ async function waitForAbortable(operation, signal) {
|
|
|
881
878
|
}
|
|
882
879
|
}
|
|
883
880
|
function createWorkspacePreparation(options) {
|
|
884
|
-
if (!options ||
|
|
885
|
-
if (options.sources !== void 0 && (!Array.isArray(options.sources) || options.sources.some((source) =>
|
|
881
|
+
if (!options || typeof options.workspace !== "string" || !options.workspace.trim()) throw workspaceErrorDiagnostics.WORKSPACE_R0034({ message: "[vitehub] Workspace preparation requires a Workspace name." });
|
|
882
|
+
if (options.sources !== void 0 && (!Array.isArray(options.sources) || options.sources.some((source) => typeof source !== "string" || !source.trim()))) throw workspaceErrorDiagnostics.WORKSPACE_R0035({ message: "[vitehub] Workspace preparation sources must be non-empty strings." });
|
|
886
883
|
const retryDelayMs = options.retryDelayMs ?? 1e4;
|
|
887
884
|
if (!Number.isFinite(retryDelayMs) || retryDelayMs < 0 || retryDelayMs > MAX_TIMER_DELAY_MS) throw workspaceErrorDiagnostics.WORKSPACE_R0036({ message: `[vitehub] Workspace preparation retryDelayMs must be between 0 and ${MAX_TIMER_DELAY_MS}.` });
|
|
888
885
|
const workspaceName = options.workspace.trim();
|
|
889
886
|
const sources = options.sources === void 0 ? void 0 : [...new Set(options.sources.map((source) => source.trim()))];
|
|
890
|
-
let workspace =
|
|
887
|
+
let workspace = useWorkspaceFiles(workspaceName, { mode: "write" });
|
|
891
888
|
let state = Object.freeze({
|
|
892
889
|
stoppedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
893
890
|
status: "stopped"
|
|
@@ -952,7 +949,7 @@ function createWorkspacePreparation(options) {
|
|
|
952
949
|
status: "ready"
|
|
953
950
|
});
|
|
954
951
|
} catch (error) {
|
|
955
|
-
if (controller.signal.aborted) workspace =
|
|
952
|
+
if (controller.signal.aborted) workspace = useWorkspaceFiles(workspaceName, { mode: "write" });
|
|
956
953
|
if (stopped || attemptLifecycle !== lifecycle) return state;
|
|
957
954
|
const finishedAtMs = Date.now();
|
|
958
955
|
const next = publish({
|
|
@@ -1076,4 +1073,4 @@ async function recoverLocalWorkspaceLocks(options) {
|
|
|
1076
1073
|
return { removed };
|
|
1077
1074
|
}
|
|
1078
1075
|
//#endregion
|
|
1079
|
-
export { attachWorkspaceSourceRequestExecution, createWorkspaceHistoryReader, createWorkspacePreparation, createWorkspaceSourceResolutionFacade, forwardWorkspaceFacade, forwardWorkspaceMetadataView, getWorkspaceDependencyRuntimeLoaders, getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, getWorkspaceSourceRequestDescriptor, getWorkspaceSourceRequestExecution, hasWorkspaceSourceResolvers, invalidateWorkspaceStore, isWorkspaceSourceRequestOnly, markLiveWorkspaceSource, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, recoverLocalWorkspaceLocks, registerWorkspace, registerWorkspacePlugin, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, resolveWorkspaceSources, setWorkspaceDependencyRuntimeLoaders, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeRegistry, useWorkspace, workspaceSourceGrantPaths, workspaceSourceRequestDescriptorPath, workspaceSourceRequestMatches };
|
|
1076
|
+
export { attachWorkspaceSourceRequestExecution, createWorkspaceHistoryReader, createWorkspacePreparation, createWorkspaceSourceResolutionFacade, forwardWorkspaceFacade, forwardWorkspaceMetadataView, getWorkspaceDependencyRuntimeLoaders, getWorkspaceHostedStoreLoader, getWorkspaceRuntimeConfig, getWorkspaceSourceRequestDescriptor, getWorkspaceSourceRequestExecution, hasWorkspaceSourceResolvers, invalidateWorkspaceStore, isWorkspaceSourceRequestOnly, markLiveWorkspaceSource, normalizeWorkspaceSourceMetadata, normalizeWorkspaceSourcesMetadata, recoverLocalWorkspaceLocks, registerWorkspace, registerWorkspacePlugin, resetWorkspaceStoreCache, resolveRegisteredWorkspaceDefinition, resolveWorkspaceSources, setWorkspaceDependencyRuntimeLoaders, setWorkspaceHostedStoreLoader, setWorkspaceRuntimeAssetsRegistry, setWorkspaceRuntimeConfig, setWorkspaceRuntimeDefinitions, setWorkspaceRuntimeRegistry, useWorkspace, useWorkspaceFiles, workspaceSourceGrantPaths, workspaceSourceRequestDescriptorPath, workspaceSourceRequestMatches };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { l as normalizeWorkspacePath } from "./path
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
|
|
2
|
+
import { l as normalizeWorkspacePath } from "./path--wrT_Azm.js";
|
|
3
3
|
//#region src/core/search.ts
|
|
4
4
|
var search_exports = /* @__PURE__ */ __exportAll({ searchText: () => searchText });
|
|
5
5
|
function toSearchRegExp(query) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
|
|
2
|
-
import { s as matchesAny } from "./path
|
|
3
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
4
|
-
import { _ as workspaceDefinitionPlugins, h as resolveWorkspaceAutoCommit } from "./utils-
|
|
5
|
-
import { r as
|
|
6
|
-
import {
|
|
7
|
-
import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
|
|
2
|
+
import { s as matchesAny } from "./path--wrT_Azm.js";
|
|
3
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
|
|
4
|
+
import { _ as workspaceDefinitionPlugins, h as resolveWorkspaceAutoCommit } from "./utils-CgMZCHsX.js";
|
|
5
|
+
import { r as useWorkspaceFiles } from "./use-CSpT5W87.js";
|
|
6
|
+
import { r as withWorkspaceProgress } from "./host-BFBpXn0N.js";
|
|
8
7
|
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
9
8
|
import { lookup } from "mrmime";
|
|
10
|
-
import { createError, defineEventHandler, getRouterParam } from "h3";
|
|
11
9
|
//#region ../internal/src/secret.ts
|
|
12
10
|
const secretEncoder = new TextEncoder();
|
|
13
11
|
/**
|
|
@@ -22,6 +20,7 @@ function isViteHubSecretEqual(actual, expected) {
|
|
|
22
20
|
for (let index = 0; index < right.length; index += 1) difference |= (left[index] ?? 0) ^ right[index];
|
|
23
21
|
return difference === 0;
|
|
24
22
|
}
|
|
23
|
+
Object.freeze({ prefix: "sha256=" });
|
|
25
24
|
//#endregion
|
|
26
25
|
//#region src/server.ts
|
|
27
26
|
const workspaceDevRoute = "/__vitehub/workspace/dev";
|
|
@@ -58,35 +57,35 @@ function headerValue(headers, name, expectedToken) {
|
|
|
58
57
|
try {
|
|
59
58
|
const prototype = Object.getPrototypeOf(headers);
|
|
60
59
|
const constructor = prototype ? Object.getOwnPropertyDescriptor(prototype, "constructor")?.value : void 0;
|
|
61
|
-
const constructorSource =
|
|
60
|
+
const constructorSource = typeof constructor === "function" ? Function.prototype.toString.call(constructor) : "";
|
|
62
61
|
const prototypeGet = prototype ? Object.getOwnPropertyDescriptor(prototype, "get")?.value : void 0;
|
|
63
62
|
const realmHeaders = typeof Headers === "function" ? Headers : void 0;
|
|
64
|
-
if (
|
|
63
|
+
if (typeof constructor === "function" && Reflect.get(constructor, "name") === "Headers" && (constructor === realmHeaders || /^class\s+Headers\b/.test(constructorSource) && constructorSource.includes("#") || /^function\s+Headers\(\)\s*\{\s*\[native code\]\s*\}$/.test(constructorSource) || constructorSource.includes("webidl.brandCheck") || constructorSource.includes("#")) && Reflect.get(constructor, "prototype") === prototype && (() => {
|
|
65
64
|
try {
|
|
66
65
|
return headers instanceof constructor;
|
|
67
66
|
} catch {
|
|
68
67
|
return false;
|
|
69
68
|
}
|
|
70
|
-
})() &&
|
|
69
|
+
})() && typeof prototypeGet === "function") {
|
|
71
70
|
const get = typeof Headers === "function" ? Reflect.get(Headers.prototype, "get") : void 0;
|
|
72
71
|
for (const getter of [get, prototypeGet]) {
|
|
73
|
-
if (
|
|
72
|
+
if (typeof getter !== "function") continue;
|
|
74
73
|
try {
|
|
75
74
|
const value = Reflect.apply(getter, headers, [name]);
|
|
76
|
-
return
|
|
75
|
+
return typeof value === "string" && value ? value : void 0;
|
|
77
76
|
} catch {}
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
try {
|
|
81
80
|
const ownGet = Object.hasOwn(headers, "get") ? Reflect.get(headers, "get") : void 0;
|
|
82
|
-
if (
|
|
81
|
+
if (typeof ownGet === "function") {
|
|
83
82
|
const value = Reflect.apply(ownGet, headers, [name]);
|
|
84
|
-
return
|
|
83
|
+
return typeof value === "string" && value ? value : void 0;
|
|
85
84
|
}
|
|
86
85
|
if (!Object.hasOwn(headers, name)) return void 0;
|
|
87
86
|
const value = Reflect.get(headers, name);
|
|
88
|
-
if (Array.isArray(value)) return
|
|
89
|
-
return
|
|
87
|
+
if (Array.isArray(value)) return typeof value[0] === "string" ? value[0] : void 0;
|
|
88
|
+
return typeof value === "string" ? value : void 0;
|
|
90
89
|
} catch {
|
|
91
90
|
return;
|
|
92
91
|
}
|
|
@@ -127,7 +126,7 @@ async function validateWorkspaceDevToken(rootDir, headers, options = {}) {
|
|
|
127
126
|
return isViteHubSecretEqual(headerValue(headers, workspaceDevTokenHeader, expectedToken), expectedToken);
|
|
128
127
|
}
|
|
129
128
|
async function resolveWorkspace(workspace) {
|
|
130
|
-
if (typeof workspace === "string") return
|
|
129
|
+
if (typeof workspace === "string") return useWorkspaceFiles(workspace);
|
|
131
130
|
if (typeof workspace === "function") return await workspace();
|
|
132
131
|
return workspace;
|
|
133
132
|
}
|
|
@@ -191,55 +190,69 @@ async function materializeWorkspaceDevSources(workspace, input) {
|
|
|
191
190
|
}));
|
|
192
191
|
});
|
|
193
192
|
}
|
|
193
|
+
function workspaceFileNotFound() {
|
|
194
|
+
return Response.json({
|
|
195
|
+
status: 404,
|
|
196
|
+
message: "Workspace file not found."
|
|
197
|
+
}, { status: 404 });
|
|
198
|
+
}
|
|
199
|
+
/** Read a Workspace file as a Response. A missing, disallowed, or unsafe path gets a 404 Response. */
|
|
194
200
|
async function readWorkspaceFileResponse(options) {
|
|
195
201
|
let filePath;
|
|
196
202
|
try {
|
|
197
203
|
filePath = resolveWorkspaceFilePath(options.path, options.root);
|
|
198
|
-
if (!matchesAny(filePath, options.allow)) throw createError({
|
|
199
|
-
statusCode: 404,
|
|
200
|
-
statusMessage: "Workspace file not found."
|
|
201
|
-
});
|
|
202
204
|
} catch (error) {
|
|
203
|
-
if (isNotFoundError(error))
|
|
204
|
-
statusCode: 404,
|
|
205
|
-
statusMessage: "Workspace file not found."
|
|
206
|
-
});
|
|
205
|
+
if (isNotFoundError(error)) return workspaceFileNotFound();
|
|
207
206
|
throw error;
|
|
208
207
|
}
|
|
208
|
+
if (!matchesAny(filePath, options.allow)) return workspaceFileNotFound();
|
|
209
209
|
const workspace = await resolveWorkspace(options.workspace);
|
|
210
210
|
try {
|
|
211
211
|
const [content, stat] = await Promise.all([workspace.fs.readFile(filePath, { encoding: "binary" }), workspace.fs.stat(filePath)]);
|
|
212
|
-
if (stat.type !== "file")
|
|
213
|
-
statusCode: 404,
|
|
214
|
-
statusMessage: "Workspace file not found."
|
|
215
|
-
});
|
|
212
|
+
if (stat.type !== "file") return workspaceFileNotFound();
|
|
216
213
|
const headers = new Headers(options.headers);
|
|
217
214
|
headers.set("content-type", resolveContentType(filePath, stat.mediaType, options.contentTypes));
|
|
218
215
|
headers.set("x-content-type-options", "nosniff");
|
|
219
216
|
if (options.cacheControl) headers.set("cache-control", options.cacheControl);
|
|
220
217
|
return new Response(content, { headers });
|
|
221
218
|
} catch (error) {
|
|
222
|
-
if (isNotFoundError(error))
|
|
223
|
-
statusCode: 404,
|
|
224
|
-
statusMessage: "Workspace file not found."
|
|
225
|
-
});
|
|
219
|
+
if (isNotFoundError(error)) return workspaceFileNotFound();
|
|
226
220
|
throw error;
|
|
227
221
|
}
|
|
228
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Serve Workspace files from a route. The file path is the part of the URL path after `base`, percent-decoded, so
|
|
225
|
+
* `/files/my%20file.md` serves `my file.md`. A path that is not valid percent-encoding gets a 400 Response.
|
|
226
|
+
*/
|
|
229
227
|
function defineWorkspaceFileHandler(options) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
const { base, baseURL, ...fileOptions } = options;
|
|
229
|
+
const segments = [baseURL ?? "", base].map((part) => part.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
230
|
+
const prefix = segments ? `/${segments}/` : "/";
|
|
231
|
+
return { async fetch(request) {
|
|
232
|
+
const pathname = new URL(request.url).pathname;
|
|
233
|
+
if (baseURL !== void 0 && !pathname.startsWith(prefix)) return workspaceFileNotFound();
|
|
234
|
+
const start = baseURL === void 0 ? pathname.indexOf(prefix) : 0;
|
|
235
|
+
if (start < 0) return workspaceFileNotFound();
|
|
236
|
+
let path;
|
|
237
|
+
try {
|
|
238
|
+
path = decodeURIComponent(pathname.slice(start + prefix.length));
|
|
239
|
+
} catch {
|
|
240
|
+
return Response.json({
|
|
241
|
+
status: 400,
|
|
242
|
+
message: "Workspace file path is not valid percent-encoding."
|
|
243
|
+
}, { status: 400 });
|
|
244
|
+
}
|
|
245
|
+
return await readWorkspaceFileResponse({
|
|
246
|
+
...fileOptions,
|
|
234
247
|
path
|
|
235
248
|
});
|
|
236
|
-
}
|
|
249
|
+
} };
|
|
237
250
|
}
|
|
238
251
|
async function runWorkspaceDevCommand(input) {
|
|
239
252
|
const command = input.command.trim();
|
|
240
253
|
if (!command) throw workspaceErrorDiagnostics.WORKSPACE_R0040({ message: "Workspace Dev command cannot be empty." });
|
|
241
254
|
const definition = input.definition;
|
|
242
|
-
const workspace = typeof input.workspace === "string" ? await
|
|
255
|
+
const workspace = typeof input.workspace === "string" ? await useWorkspaceFiles(input.workspace, definition ? {
|
|
243
256
|
definition,
|
|
244
257
|
mode: "write"
|
|
245
258
|
} : { mode: "write" }) : input.workspace;
|
|
@@ -267,7 +280,7 @@ async function runWorkspaceDevCommand(input) {
|
|
|
267
280
|
return session;
|
|
268
281
|
});
|
|
269
282
|
if (!session) throw workspaceErrorDiagnostics.WORKSPACE_R0042({ message: "Workspace Dev Session did not start." });
|
|
270
|
-
result = input.args ? await session.exec(command, input.args, execOptions) : await session.exec("sh", ["-
|
|
283
|
+
result = input.args ? await session.exec(command, input.args, execOptions) : await session.exec("sh", ["-c", command], execOptions);
|
|
271
284
|
const diff = result.exitCode === 0 ? await session.diff() : void 0;
|
|
272
285
|
if (diff?.entries.length) {
|
|
273
286
|
const commit = definition ? resolveWorkspaceAutoCommit(definition, diff) : void 0;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { Bt as WorkspaceSessionHost, Dt as WorkspacePrepareSessionProgressEvent, I as WorkspaceDefinition, St as WorkspaceName, Ut as WorkspaceSessionOptions, i as ExecResult, zt as WorkspaceSession } from "./types-BbtwmBZ5.js";
|
|
2
|
+
import { _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles } from "./use-C6lV3-wC.js";
|
|
4
3
|
//#region src/server.d.ts
|
|
5
4
|
export declare const workspaceDevRoute = "/__vitehub/workspace/dev";
|
|
6
5
|
export declare const workspaceDevHeader = "x-vitehub-workspace-dev";
|
|
7
6
|
export declare const workspaceDevHeaderValue = "1";
|
|
8
7
|
export declare const workspaceDevTokenHeader = "x-vitehub-dev-token";
|
|
9
|
-
type WorkspaceInput<Name extends WorkspaceName> = Name |
|
|
8
|
+
type WorkspaceInput<Name extends WorkspaceName> = Name | ReadonlyWorkspaceFiles<Name> | WritableWorkspaceFiles<Name> | (() => ReadonlyWorkspaceFiles<Name> | WritableWorkspaceFiles<Name> | Promise<ReadonlyWorkspaceFiles<Name> | WritableWorkspaceFiles<Name>>);
|
|
10
9
|
type WorkspaceSessionStarter = {
|
|
11
10
|
startSession(options?: WorkspaceSessionOptions): Promise<WorkspaceSession>;
|
|
12
11
|
};
|
|
@@ -21,7 +20,10 @@ export interface WorkspaceFileResponseOptions<Name extends WorkspaceName = Works
|
|
|
21
20
|
workspace: WorkspaceInput<Name>;
|
|
22
21
|
}
|
|
23
22
|
export interface WorkspaceFileHandlerOptions<Name extends WorkspaceName = WorkspaceName> extends Omit<WorkspaceFileResponseOptions<Name>, "path"> {
|
|
24
|
-
|
|
23
|
+
/** The route path, such as `"/api/data/"`, relative to `baseURL`. The rest of the URL path is the file path. */
|
|
24
|
+
base: string;
|
|
25
|
+
/** The retained application prefix, such as Nitro's `baseURL`. Set this when the app is mounted below `/`. */
|
|
26
|
+
baseURL?: string;
|
|
25
27
|
}
|
|
26
28
|
export interface WorkspaceDevCommandInput<Name extends WorkspaceName = WorkspaceName> {
|
|
27
29
|
abortSignal?: AbortSignal;
|
|
@@ -32,8 +34,8 @@ export interface WorkspaceDevCommandInput<Name extends WorkspaceName = Workspace
|
|
|
32
34
|
onProgress?: (event: WorkspacePrepareSessionProgressEvent) => void | Promise<void>;
|
|
33
35
|
paths?: readonly string[];
|
|
34
36
|
timeout?: number;
|
|
35
|
-
workspace: Name |
|
|
36
|
-
fs:
|
|
37
|
+
workspace: Name | WritableWorkspaceFiles<Name> | (ReadonlyWorkspaceFiles<Name> & {
|
|
38
|
+
fs: ReadonlyWorkspaceFiles<Name>["fs"] & Partial<WorkspaceSessionStarter>;
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
export interface WorkspaceDevTokenOptions {
|
|
@@ -47,7 +49,14 @@ export declare function refreshWorkspaceDevToken(rootDir: string, options?: Work
|
|
|
47
49
|
export declare function ensureWorkspaceDevToken(rootDir: string, options?: WorkspaceDevTokenOptions): Promise<string>;
|
|
48
50
|
export declare function readWorkspaceDevToken(rootDir: string, options?: WorkspaceDevTokenOptions): Promise<string | undefined>;
|
|
49
51
|
export declare function validateWorkspaceDevToken(rootDir: string, headers: WorkspaceDevHeaders, options?: WorkspaceDevTokenOptions): Promise<boolean>;
|
|
52
|
+
/** Read a Workspace file as a Response. A missing, disallowed, or unsafe path gets a 404 Response. */
|
|
50
53
|
export declare function readWorkspaceFileResponse<Name extends WorkspaceName>(options: WorkspaceFileResponseOptions<Name>): Promise<Response>;
|
|
51
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Serve Workspace files from a route. The file path is the part of the URL path after `base`, percent-decoded, so
|
|
56
|
+
* `/files/my%20file.md` serves `my file.md`. A path that is not valid percent-encoding gets a 400 Response.
|
|
57
|
+
*/
|
|
58
|
+
export declare function defineWorkspaceFileHandler<Name extends WorkspaceName>(options: WorkspaceFileHandlerOptions<Name>): {
|
|
59
|
+
fetch(request: Request): Promise<Response>;
|
|
60
|
+
};
|
|
52
61
|
export declare function runWorkspaceDevCommand<Name extends WorkspaceName>(input: WorkspaceDevCommandInput<Name>): Promise<ExecResult>;
|
|
53
62
|
//#endregion
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, i as readWorkspaceFileResponse, l as workspaceDevHeaderValue, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, t as defineWorkspaceFileHandler, u as workspaceDevRoute } from "./server-
|
|
1
|
+
import { a as refreshWorkspaceDevToken, c as workspaceDevHeader, d as workspaceDevTokenHeader, f as workspaceDevTokenServerId, i as readWorkspaceFileResponse, l as workspaceDevHeaderValue, n as ensureWorkspaceDevToken, o as runWorkspaceDevCommand, r as readWorkspaceDevToken, s as validateWorkspaceDevToken, t as defineWorkspaceFileHandler, u as workspaceDevRoute } from "./server-8tGltlGz.js";
|
|
2
2
|
export { defineWorkspaceFileHandler, ensureWorkspaceDevToken, readWorkspaceDevToken, readWorkspaceFileResponse, refreshWorkspaceDevToken, runWorkspaceDevCommand, validateWorkspaceDevToken, workspaceDevHeader, workspaceDevHeaderValue, workspaceDevRoute, workspaceDevTokenHeader, workspaceDevTokenServerId };
|