@vite-hub/workspace 0.0.2 → 0.0.4
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/LICENSE +201 -0
- package/README.md +48 -2
- package/dist/{ai-Cztw4eLk.js → ai-BqCC8BpY.js} +15 -4
- package/dist/{ai-hFdsvDHC.d.ts → ai-CjxvGqM0.d.ts} +1 -1
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-CaG9b7tf.js → asset-registry-8QI3ML3K.js} +1 -1
- package/dist/chunk-2rV9d50f.js +35 -0
- package/dist/cloudflare.d.ts +4 -2
- package/dist/cloudflare.js +1 -2
- package/dist/collections.d.ts +2 -2
- package/dist/collections.js +1 -1
- package/dist/{config--r5unwPc.js → config-Bc3c4Su1.js} +213 -120
- package/dist/{config-DCQ6y30R.js → config-CHLLWklZ.js} +9 -3
- package/dist/{config-Ca5DM8fF.d.ts → config-DE9xlaIw.d.ts} +1 -1
- package/dist/{file-B2q9NE18.js → file-Bc1X7pco.js} +9 -10
- package/dist/{files-xy0le-_U.js → files-Q6xZjDHA.js} +20 -9
- package/dist/{github-lIO6-2sH.js → github-DHnjxQIX.js} +27 -23
- package/dist/glob-CEZKeZFC.js +18 -0
- package/dist/host-DJH8cuoU.js +1030 -0
- package/dist/{artifacts-store-BAV9jZpd.js → hosted-RPeJOCFz.js} +146 -30
- package/dist/hosted-vercel-blob-d6C8ND5j.js +23580 -0
- package/dist/hosted-vercel-blob.d.ts +1 -1
- package/dist/hosted-vercel-blob.js +1 -25
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +1 -29
- package/dist/index.d.ts +61 -78
- package/dist/index.js +133 -435
- package/dist/lifecycle-LrL3sA4n.js +316 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/metadata-target-B0tOmVW7.js +717 -0
- package/dist/mountx.d.ts +10 -0
- package/dist/mountx.js +143 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +8 -2
- package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
- package/dist/{provider-CeQciesl.js → provider-B1yLjCJJ.js} +194 -47
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -361
- package/dist/publish.d.ts +1 -1
- package/dist/publish.js +2 -2
- package/dist/registry-D3yzt8HQ.js +127 -0
- package/dist/{registry-CoC9JxVt.d.ts → registry-Uj6IVxes.d.ts} +3 -3
- package/dist/{request-execution-C8qRcReq.js → request-execution-B-dSFlGB.js} +8 -4
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +4 -2
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +1 -1
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +10 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime-options-BsPSv5O7.js +13 -0
- package/dist/runtime-type-iEE6BjQJ.js +34 -0
- package/dist/runtime.d.ts +42 -7
- package/dist/runtime.js +276 -100
- package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +24 -51
- package/dist/{shared-BRycRSbo.js → shared-DTR1Hhma.js} +115 -39
- package/dist/source-metadata.d.ts +9 -2
- package/dist/source-metadata.js +34 -2
- package/dist/{state-DSAHEsq6.d.ts → state-tYcRWEh2.d.ts} +13 -12
- package/dist/store-Dt_Jyys3.js +608 -0
- package/dist/{sync-DO42ypji.js → sync-DnTQwt8r.js} +6 -5
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/token-CVzURBxC.js +61 -0
- package/dist/{types-DHkae7Cb.d.ts → types-CYuwjJ4V.d.ts} +94 -43
- package/dist/{use-d_PlAdOu.js → use-BTNDR5Rd.js} +147 -50
- package/dist/{use-D16tf8Ph.d.ts → use-BiHzt0xA.d.ts} +21 -4
- package/dist/vite-BptCrpv2.js +4526 -0
- package/dist/vite-CtA9guIM.d.ts +66 -0
- package/dist/vite.d.ts +2 -50
- package/dist/vite.js +2 -2
- package/dist/{workspace-n4wBmdaM.js → workspace-Dq08Yn72.js} +224 -545
- package/dist/{workspace-f2DBLmPZ.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
- package/package.json +20 -38
- package/dist/chunk-8H4AJuhK.js +0 -14
- package/dist/cli.d.ts +0 -31
- package/dist/cli.js +0 -303
- package/dist/cloudflare-env-CKxUs2fa.js +0 -20
- package/dist/glob-DeH0dzZX.js +0 -23
- package/dist/host-I-_vDs05.js +0 -370
- package/dist/lifecycle-Lhk3dAMt.js +0 -176
- package/dist/providers/cloudflare/artifacts-store.d.ts +0 -6
- package/dist/providers/cloudflare/artifacts-store.js +0 -2
- package/dist/providers/vercel/blob-store.d.ts +0 -6
- package/dist/providers/vercel/blob-store.js +0 -235
- package/dist/registry-C7DMdBXN.js +0 -74
- package/dist/utils-BPdaCyI6.js +0 -55
- package/dist/vite-NWC9mFjI.js +0 -1882
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as WorkspaceDefinition, T as Workspace } from "./types-CYuwjJ4V.js";
|
|
2
2
|
|
|
3
3
|
//#region src/core/workspace.d.ts
|
|
4
4
|
declare function createWorkspace(definition: WorkspaceDefinition): Workspace;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/workspace",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Agent-oriented filesystem state and Vite integration for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -44,10 +44,6 @@
|
|
|
44
44
|
"types": "./dist/ai.d.ts",
|
|
45
45
|
"import": "./dist/ai.js"
|
|
46
46
|
},
|
|
47
|
-
"./cli": {
|
|
48
|
-
"types": "./dist/cli.d.ts",
|
|
49
|
-
"import": "./dist/cli.js"
|
|
50
|
-
},
|
|
51
47
|
"./cloudflare": {
|
|
52
48
|
"types": "./dist/cloudflare.d.ts",
|
|
53
49
|
"import": "./dist/cloudflare.js"
|
|
@@ -64,6 +60,10 @@
|
|
|
64
60
|
"types": "./dist/loader.d.ts",
|
|
65
61
|
"import": "./dist/loader.js"
|
|
66
62
|
},
|
|
63
|
+
"./mountx": {
|
|
64
|
+
"types": "./dist/mountx.d.ts",
|
|
65
|
+
"import": "./dist/mountx.js"
|
|
66
|
+
},
|
|
67
67
|
"./nitro": {
|
|
68
68
|
"types": "./dist/nitro.d.ts",
|
|
69
69
|
"import": "./dist/nitro.js"
|
|
@@ -101,14 +101,6 @@
|
|
|
101
101
|
"types": "./dist/runtime/assets.d.ts",
|
|
102
102
|
"import": "./dist/runtime/assets.js"
|
|
103
103
|
},
|
|
104
|
-
"./internal/runtime/empty-assets-registry": {
|
|
105
|
-
"types": "./dist/runtime/empty-assets-registry.d.ts",
|
|
106
|
-
"import": "./dist/runtime/empty-assets-registry.js"
|
|
107
|
-
},
|
|
108
|
-
"./internal/runtime/empty-registry": {
|
|
109
|
-
"types": "./dist/runtime/empty-registry.d.ts",
|
|
110
|
-
"import": "./dist/runtime/empty-registry.js"
|
|
111
|
-
},
|
|
112
104
|
"./internal/runtime/hosted": {
|
|
113
105
|
"types": "./dist/hosted.d.ts",
|
|
114
106
|
"import": "./dist/hosted.js"
|
|
@@ -125,38 +117,34 @@
|
|
|
125
117
|
"types": "./dist/runtime/workspace.d.ts",
|
|
126
118
|
"import": "./dist/runtime/workspace.js"
|
|
127
119
|
},
|
|
128
|
-
"./internal/stores/cloudflare-artifacts": {
|
|
129
|
-
"types": "./dist/providers/cloudflare/artifacts-store.d.ts",
|
|
130
|
-
"import": "./dist/providers/cloudflare/artifacts-store.js"
|
|
131
|
-
},
|
|
132
120
|
"./internal/stores/github": {
|
|
133
121
|
"types": "./dist/providers/github/store.d.ts",
|
|
134
122
|
"import": "./dist/providers/github/store.js"
|
|
135
|
-
},
|
|
136
|
-
"./internal/stores/vercel-blob": {
|
|
137
|
-
"types": "./dist/providers/vercel/blob-store.d.ts",
|
|
138
|
-
"import": "./dist/providers/vercel/blob-store.js"
|
|
139
123
|
}
|
|
140
124
|
},
|
|
141
125
|
"dependencies": {
|
|
126
|
+
"@vite-hub/box": "0.0.4",
|
|
142
127
|
"@vercel/nft": "^1.10.2",
|
|
128
|
+
"@vite-hub/markdown-template": "0.0.4",
|
|
129
|
+
"@vite-hub/runtime": "0.0.4",
|
|
130
|
+
"@vite-hub/source": "0.0.4",
|
|
143
131
|
"defu": "^6.1.7",
|
|
132
|
+
"esbuild": "^0.27.7",
|
|
144
133
|
"exsolve": "^1.1.0",
|
|
145
134
|
"h3": "2.0.1-rc.25",
|
|
146
135
|
"isomorphic-git": "^1.38.7",
|
|
147
136
|
"jiti": "^2.7.0",
|
|
148
|
-
"
|
|
137
|
+
"mountx": "0.0.2",
|
|
138
|
+
"minimatch": "^10.2.6",
|
|
149
139
|
"mrmime": "^2.0.1",
|
|
150
|
-
"ofetch": "^1.5.1"
|
|
151
|
-
"@vite-hub/runtime": "0.0.2",
|
|
152
|
-
"@vite-hub/source": "0.0.2",
|
|
153
|
-
"@vite-hub/markdown-template": "0.0.2",
|
|
154
|
-
"@vite-hub/box": "0.0.2"
|
|
140
|
+
"ofetch": "^1.5.1"
|
|
155
141
|
},
|
|
156
142
|
"devDependencies": {
|
|
157
143
|
"@types/node": "^24.13.3",
|
|
158
|
-
"@vercel/blob": "^2.
|
|
159
|
-
"
|
|
144
|
+
"@vercel/blob": "^2.8.0",
|
|
145
|
+
"@vite-hub/env": "0.0.4",
|
|
146
|
+
"@vite-hub/shell": "0.0.4",
|
|
147
|
+
"ai": "7.0.58",
|
|
160
148
|
"ocache": "^0.1.5",
|
|
161
149
|
"publint": "^0.3.21",
|
|
162
150
|
"typescript": "^6.0.3",
|
|
@@ -164,21 +152,15 @@
|
|
|
164
152
|
"vite-plus": "^0.1.24",
|
|
165
153
|
"vitest": "^4.1.4",
|
|
166
154
|
"vue": "^3.5.0",
|
|
167
|
-
"@vite-hub/internal": "0.0.1"
|
|
168
|
-
"@vite-hub/shell": "0.0.2",
|
|
169
|
-
"@vite-hub/env": "0.0.2"
|
|
155
|
+
"@vite-hub/internal": "0.0.1"
|
|
170
156
|
},
|
|
171
157
|
"peerDependencies": {
|
|
172
|
-
"@
|
|
158
|
+
"@vite-hub/shell": "0.0.4",
|
|
173
159
|
"ai": "^6.0.0 || ^7.0.0-0",
|
|
174
160
|
"vite": ">=8.0.0",
|
|
175
|
-
"vue": "^3.5.0"
|
|
176
|
-
"@vite-hub/shell": "0.0.2"
|
|
161
|
+
"vue": "^3.5.0"
|
|
177
162
|
},
|
|
178
163
|
"peerDependenciesMeta": {
|
|
179
|
-
"@vercel/blob": {
|
|
180
|
-
"optional": true
|
|
181
|
-
},
|
|
182
164
|
"@vite-hub/shell": {
|
|
183
165
|
"optional": true
|
|
184
166
|
},
|
package/dist/chunk-8H4AJuhK.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __exportAll = (all, no_symbols) => {
|
|
5
|
-
let target = {};
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { __exportAll as t };
|
package/dist/cli.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/cli.d.ts
|
|
2
|
-
interface WorkspaceCliContext {
|
|
3
|
-
cwd: string;
|
|
4
|
-
env: NodeJS.ProcessEnv;
|
|
5
|
-
rootDir: string;
|
|
6
|
-
stderr: {
|
|
7
|
-
write: (chunk: string | Uint8Array) => unknown;
|
|
8
|
-
};
|
|
9
|
-
stdout: {
|
|
10
|
-
write: (chunk: string | Uint8Array) => unknown;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface WorkspaceCliContributor {
|
|
14
|
-
namespaces: Array<{
|
|
15
|
-
description?: string;
|
|
16
|
-
features: Array<{
|
|
17
|
-
description?: string;
|
|
18
|
-
name: string;
|
|
19
|
-
run: (args: string[], context: WorkspaceCliContext) => Promise<number | void> | number | void;
|
|
20
|
-
usage?: string;
|
|
21
|
-
}>;
|
|
22
|
-
name: string;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
25
|
-
interface WorkspaceDevCliOptions {
|
|
26
|
-
fetch?: typeof fetch;
|
|
27
|
-
}
|
|
28
|
-
declare function runWorkspaceDevCli(args: string[], context: WorkspaceCliContext, options?: WorkspaceDevCliOptions): Promise<number>;
|
|
29
|
-
declare function createWorkspaceCliContributor(): WorkspaceCliContributor;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { createWorkspaceCliContributor, runWorkspaceDevCli };
|
package/dist/cli.js
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import { readWorkspaceDevToken, workspaceDevHeader, workspaceDevRoute, workspaceDevTokenHeader } from "./server.js";
|
|
2
|
-
//#region src/cli.ts
|
|
3
|
-
const workspaceCommandFeedbackIntervalMs = 15e3;
|
|
4
|
-
const workspaceCommandStartedMessage = "[workspace] command started; first run may materialize sources.\n";
|
|
5
|
-
const workspaceCommandWaitingMessage = "[workspace] command still running; sources may still be materializing.\n";
|
|
6
|
-
function startWorkspaceCommandFeedback(context) {
|
|
7
|
-
context.stderr.write(workspaceCommandStartedMessage);
|
|
8
|
-
const timer = setInterval(() => context.stderr.write(workspaceCommandWaitingMessage), workspaceCommandFeedbackIntervalMs);
|
|
9
|
-
timer.unref?.();
|
|
10
|
-
return () => clearInterval(timer);
|
|
11
|
-
}
|
|
12
|
-
function formatDurationMs(durationMs) {
|
|
13
|
-
return durationMs < 1e3 ? `${durationMs}ms` : `${(durationMs / 1e3).toFixed(1)}s`;
|
|
14
|
-
}
|
|
15
|
-
function workspaceDevDataNumber(event, key) {
|
|
16
|
-
const value = event.data?.[key];
|
|
17
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
18
|
-
}
|
|
19
|
-
function writeWorkspaceDevProgress(context, event) {
|
|
20
|
-
const duration = typeof event.durationMs === "number" ? ` (${formatDurationMs(event.durationMs)})` : "";
|
|
21
|
-
if (event.status === "started") {
|
|
22
|
-
context.stderr.write(`[workspace] ${event.label}...\n`);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (event.status === "updating") {
|
|
26
|
-
const files = workspaceDevDataNumber(event, "files");
|
|
27
|
-
const bytes = workspaceDevDataNumber(event, "bytes");
|
|
28
|
-
const detail = files === void 0 ? "" : `: ${files} file${files === 1 ? "" : "s"}${bytes === void 0 ? "" : `, ${bytes} bytes`}`;
|
|
29
|
-
context.stderr.write(`[workspace] ${event.label}${detail}\n`);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (event.status === "failed") {
|
|
33
|
-
context.stderr.write(`[workspace] ${event.label} failed${duration}${event.error ? `: ${event.error}` : ""}\n`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
context.stderr.write(`[workspace] ${event.label} completed${duration}\n`);
|
|
37
|
-
}
|
|
38
|
-
function isWorkspaceDevStream(response) {
|
|
39
|
-
return response.headers.get("content-type")?.toLowerCase().includes("application/x-ndjson") === true;
|
|
40
|
-
}
|
|
41
|
-
function handleWorkspaceDevStreamLine(line, context) {
|
|
42
|
-
const parsed = JSON.parse(line);
|
|
43
|
-
if (parsed.type === "progress" && parsed.event) {
|
|
44
|
-
writeWorkspaceDevProgress(context, parsed.event);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (parsed.type === "error") {
|
|
48
|
-
context.stderr.write(`${parsed.error || "Workspace Dev command failed."}\n`);
|
|
49
|
-
return {
|
|
50
|
-
exitCode: 1,
|
|
51
|
-
stderr: "",
|
|
52
|
-
stdout: ""
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (parsed.type === "result") return parsed.result || {};
|
|
56
|
-
}
|
|
57
|
-
async function readWorkspaceDevStream(response, context) {
|
|
58
|
-
const reader = response.body?.getReader();
|
|
59
|
-
if (!reader) return {};
|
|
60
|
-
const decoder = new TextDecoder();
|
|
61
|
-
let buffer = "";
|
|
62
|
-
let result;
|
|
63
|
-
for (;;) {
|
|
64
|
-
const { done, value } = await reader.read();
|
|
65
|
-
buffer += decoder.decode(value, { stream: !done });
|
|
66
|
-
let newline = buffer.indexOf("\n");
|
|
67
|
-
while (newline >= 0) {
|
|
68
|
-
const line = buffer.slice(0, newline).trim();
|
|
69
|
-
buffer = buffer.slice(newline + 1);
|
|
70
|
-
if (line) result = handleWorkspaceDevStreamLine(line, context) ?? result;
|
|
71
|
-
newline = buffer.indexOf("\n");
|
|
72
|
-
}
|
|
73
|
-
if (done) break;
|
|
74
|
-
}
|
|
75
|
-
const line = buffer.trim();
|
|
76
|
-
if (line) result = handleWorkspaceDevStreamLine(line, context) ?? result;
|
|
77
|
-
return result || {};
|
|
78
|
-
}
|
|
79
|
-
function writeWorkspaceDevUsage(context) {
|
|
80
|
-
context.stdout.write([
|
|
81
|
-
"Usage: vitehub workspace dev <workspace> [exec <command...>] [--url <url>] [--timeout <ms>]",
|
|
82
|
-
"",
|
|
83
|
-
"Run Workspace commands through a running Vite Development Server.",
|
|
84
|
-
"Omit exec to open the interactive command loop.",
|
|
85
|
-
"",
|
|
86
|
-
"Options:",
|
|
87
|
-
" --url <url> Compatible Vite Development Server URL. Defaults to http://localhost:5173.",
|
|
88
|
-
" --timeout <ms> Workspace command timeout.",
|
|
89
|
-
" --path <path> Workspace path to materialize for command sessions. Repeatable.",
|
|
90
|
-
" -h, --help Show this help.",
|
|
91
|
-
""
|
|
92
|
-
].join("\n"));
|
|
93
|
-
}
|
|
94
|
-
function readOptionValue(args, index, flag) {
|
|
95
|
-
const value = args[index + 1];
|
|
96
|
-
if (!value || value.startsWith("-")) throw new Error(`Missing value for ${flag}.`);
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
function parseWorkspaceDevArgs(args, env) {
|
|
100
|
-
const parsed = {
|
|
101
|
-
help: false,
|
|
102
|
-
url: env.VITEHUB_DEV_SERVER_URL || "http://localhost:5173"
|
|
103
|
-
};
|
|
104
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
105
|
-
const arg = args[index];
|
|
106
|
-
if (arg === "-h" || arg === "--help") {
|
|
107
|
-
parsed.help = true;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (arg === "--url" || arg === "--server") {
|
|
111
|
-
parsed.url = readOptionValue(args, index, arg);
|
|
112
|
-
index += 1;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (arg.startsWith("--url=")) {
|
|
116
|
-
parsed.url = arg.slice(6);
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
if (arg === "--timeout") {
|
|
120
|
-
const timeout = Number.parseInt(readOptionValue(args, index, arg), 10);
|
|
121
|
-
if (!Number.isFinite(timeout) || timeout <= 0) throw new Error("--timeout must be a positive number.");
|
|
122
|
-
parsed.timeout = timeout;
|
|
123
|
-
index += 1;
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (arg.startsWith("--timeout=")) {
|
|
127
|
-
const timeout = Number.parseInt(arg.slice(10), 10);
|
|
128
|
-
if (!Number.isFinite(timeout) || timeout <= 0) throw new Error("--timeout must be a positive number.");
|
|
129
|
-
parsed.timeout = timeout;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
if (arg === "--path") {
|
|
133
|
-
parsed.paths ??= [];
|
|
134
|
-
parsed.paths.push(readOptionValue(args, index, arg));
|
|
135
|
-
index += 1;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (arg.startsWith("--path=")) {
|
|
139
|
-
parsed.paths ??= [];
|
|
140
|
-
parsed.paths.push(arg.slice(7));
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (arg.startsWith("-") && !parsed.workspace) throw new Error(`Unknown option: ${arg}.`);
|
|
144
|
-
if (!parsed.workspace) {
|
|
145
|
-
parsed.workspace = arg;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (arg === "exec") {
|
|
149
|
-
const [command, ...commandArgs] = args.slice(index + 1);
|
|
150
|
-
if (!command?.trim()) throw new Error("workspace dev exec requires a command.");
|
|
151
|
-
parsed.command = command;
|
|
152
|
-
if (commandArgs.length) parsed.args = commandArgs;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
throw new Error(`Unexpected argument: ${arg}. Use exec <command...> for one-shot commands.`);
|
|
156
|
-
}
|
|
157
|
-
return parsed;
|
|
158
|
-
}
|
|
159
|
-
function endpointUrl(baseUrl) {
|
|
160
|
-
return new URL(workspaceDevRoute, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).href;
|
|
161
|
-
}
|
|
162
|
-
async function readWorkspaceDiscovery(parsed, context, fetchImpl) {
|
|
163
|
-
if (!parsed.workspace) {
|
|
164
|
-
context.stderr.write("Missing Workspace Dev target.\n");
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
let url;
|
|
168
|
-
try {
|
|
169
|
-
url = endpointUrl(parsed.url);
|
|
170
|
-
} catch {
|
|
171
|
-
context.stderr.write(`Invalid Vite Development Server URL: ${parsed.url}\n`);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let response;
|
|
175
|
-
try {
|
|
176
|
-
response = await fetchImpl(url, { headers: {
|
|
177
|
-
accept: "application/json",
|
|
178
|
-
[workspaceDevHeader]: "1"
|
|
179
|
-
} });
|
|
180
|
-
} catch {
|
|
181
|
-
context.stderr.write(`No Compatible Vite Development Server found at ${parsed.url}.\n`);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (!response.ok) {
|
|
185
|
-
context.stderr.write(`No Compatible Vite Development Server found at ${parsed.url}.\n`);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const discovery = await response.json().catch(() => ({}));
|
|
189
|
-
if (typeof discovery.root === "string" && discovery.root !== context.rootDir) {
|
|
190
|
-
context.stderr.write(`Compatible Vite Development Server root mismatch: ${discovery.root}\n`);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (!(discovery.workspaces || []).flatMap((workspace) => typeof workspace.name === "string" ? [workspace.name] : []).includes(parsed.workspace)) {
|
|
194
|
-
context.stderr.write(`Unknown Workspace Dev target: ${parsed.workspace}\n`);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
tokenOptions: typeof discovery.workspaceDevTokenServerId === "string" ? { serverId: discovery.workspaceDevTokenServerId } : {},
|
|
199
|
-
url
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
async function sendWorkspaceCommand(target, parsed, context, fetchImpl) {
|
|
203
|
-
if (!parsed.command) {
|
|
204
|
-
context.stderr.write("Pass a command or run in an interactive terminal.\n");
|
|
205
|
-
return 1;
|
|
206
|
-
}
|
|
207
|
-
const token = await readWorkspaceDevToken(context.rootDir, target.tokenOptions);
|
|
208
|
-
if (!token) {
|
|
209
|
-
context.stderr.write("No private Workspace Dev token found. Start the Compatible Vite Development Server first.\n");
|
|
210
|
-
return 1;
|
|
211
|
-
}
|
|
212
|
-
const startedAt = Date.now();
|
|
213
|
-
const stopFeedback = startWorkspaceCommandFeedback(context);
|
|
214
|
-
try {
|
|
215
|
-
const response = await fetchImpl(target.url, {
|
|
216
|
-
body: JSON.stringify({ workspaceCommand: {
|
|
217
|
-
...parsed.args ? { args: parsed.args } : {},
|
|
218
|
-
command: parsed.command,
|
|
219
|
-
...parsed.paths?.length ? { paths: parsed.paths } : {},
|
|
220
|
-
...parsed.timeout ? { timeout: parsed.timeout } : {},
|
|
221
|
-
workspace: parsed.workspace
|
|
222
|
-
} }),
|
|
223
|
-
headers: {
|
|
224
|
-
accept: "application/x-ndjson, application/json",
|
|
225
|
-
"content-type": "application/json",
|
|
226
|
-
[workspaceDevHeader]: "1",
|
|
227
|
-
[workspaceDevTokenHeader]: token
|
|
228
|
-
},
|
|
229
|
-
method: "POST"
|
|
230
|
-
});
|
|
231
|
-
if (!response.ok) {
|
|
232
|
-
context.stderr.write(`${await response.text()}\n`);
|
|
233
|
-
return 1;
|
|
234
|
-
}
|
|
235
|
-
if (isWorkspaceDevStream(response)) stopFeedback();
|
|
236
|
-
const result = isWorkspaceDevStream(response) ? await readWorkspaceDevStream(response, context) : await response.json().catch(() => ({}));
|
|
237
|
-
if (typeof result.stdout === "string") context.stdout.write(result.stdout);
|
|
238
|
-
if (typeof result.stderr === "string" && result.stderr) context.stderr.write(result.stderr);
|
|
239
|
-
context.stderr.write(`[workspace] command completed (${formatDurationMs(Date.now() - startedAt)})\n`);
|
|
240
|
-
return typeof result.exitCode === "number" ? result.exitCode : 0;
|
|
241
|
-
} finally {
|
|
242
|
-
stopFeedback();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async function runInteractiveWorkspaceDev(parsed, context, fetchImpl, target) {
|
|
246
|
-
const { createInterface } = await import("node:readline/promises");
|
|
247
|
-
const readline = createInterface({
|
|
248
|
-
input: process.stdin,
|
|
249
|
-
output: process.stdout
|
|
250
|
-
});
|
|
251
|
-
context.stdout.write(`Connected to ${parsed.workspace} at ${parsed.url}\n`);
|
|
252
|
-
try {
|
|
253
|
-
for (;;) {
|
|
254
|
-
const command = (await readline.question("> ")).trim();
|
|
255
|
-
if (!command) continue;
|
|
256
|
-
if (command === ".exit" || command === "exit") return 0;
|
|
257
|
-
const exitCode = await sendWorkspaceCommand(target, {
|
|
258
|
-
...parsed,
|
|
259
|
-
command
|
|
260
|
-
}, context, fetchImpl);
|
|
261
|
-
if (exitCode !== 0) return exitCode;
|
|
262
|
-
}
|
|
263
|
-
} finally {
|
|
264
|
-
readline.close();
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
async function runWorkspaceDevCli(args, context, options = {}) {
|
|
268
|
-
let parsed;
|
|
269
|
-
try {
|
|
270
|
-
parsed = parseWorkspaceDevArgs(args, context.env);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
context.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
273
|
-
writeWorkspaceDevUsage(context);
|
|
274
|
-
return 1;
|
|
275
|
-
}
|
|
276
|
-
if (parsed.help) {
|
|
277
|
-
writeWorkspaceDevUsage(context);
|
|
278
|
-
return 0;
|
|
279
|
-
}
|
|
280
|
-
const fetchImpl = options.fetch || globalThis.fetch;
|
|
281
|
-
const target = await readWorkspaceDiscovery(parsed, context, fetchImpl);
|
|
282
|
-
if (!target) return 1;
|
|
283
|
-
if (parsed.command) return await sendWorkspaceCommand(target, parsed, context, fetchImpl);
|
|
284
|
-
if (!process.stdin.isTTY) {
|
|
285
|
-
context.stderr.write("Pass a command or run in an interactive terminal.\n");
|
|
286
|
-
return 1;
|
|
287
|
-
}
|
|
288
|
-
return await runInteractiveWorkspaceDev(parsed, context, fetchImpl, target);
|
|
289
|
-
}
|
|
290
|
-
function createWorkspaceCliContributor() {
|
|
291
|
-
return { namespaces: [{
|
|
292
|
-
description: "Workspace development workflows.",
|
|
293
|
-
features: [{
|
|
294
|
-
description: "Run commands through a Workspace Session.",
|
|
295
|
-
name: "dev",
|
|
296
|
-
run: async (args, context) => await runWorkspaceDevCli(args, context),
|
|
297
|
-
usage: "vitehub workspace dev <workspace> [exec <command...>]"
|
|
298
|
-
}],
|
|
299
|
-
name: "workspace"
|
|
300
|
-
}] };
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
export { createWorkspaceCliContributor, runWorkspaceDevCli };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
//#region ../internal/src/runtime/cloudflare-env.ts
|
|
3
|
-
let activeEnv;
|
|
4
|
-
const activeEnvStorage = new AsyncLocalStorage();
|
|
5
|
-
function setActiveCloudflareEnv(env) {
|
|
6
|
-
activeEnv = env;
|
|
7
|
-
globalThis.__env__ = env;
|
|
8
|
-
try {
|
|
9
|
-
activeEnvStorage.enterWith({ env });
|
|
10
|
-
} catch {}
|
|
11
|
-
}
|
|
12
|
-
function getActiveCloudflareEnv() {
|
|
13
|
-
const scoped = activeEnvStorage.getStore();
|
|
14
|
-
return scoped ? scoped.env : activeEnv ?? globalThis.__env__;
|
|
15
|
-
}
|
|
16
|
-
function getActiveCloudflareBinding(name) {
|
|
17
|
-
return getActiveCloudflareEnv()?.[name];
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { setActiveCloudflareEnv as n, getActiveCloudflareBinding as t };
|
package/dist/glob-DeH0dzZX.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-8H4AJuhK.js";
|
|
2
|
-
import { glob } from "@vite-hub/source/sources/glob";
|
|
3
|
-
//#region src/sources/glob.ts
|
|
4
|
-
var glob_exports = /* @__PURE__ */ __exportAll({ glob: () => glob$1 });
|
|
5
|
-
function glob$1(options) {
|
|
6
|
-
return {
|
|
7
|
-
...glob({
|
|
8
|
-
...options,
|
|
9
|
-
keyCache: options.keyCache ?? !isLazySource(options)
|
|
10
|
-
}),
|
|
11
|
-
cache: options.cache,
|
|
12
|
-
materialize: options.materialize,
|
|
13
|
-
mount: options.mount,
|
|
14
|
-
sync: options.sync,
|
|
15
|
-
validate: options.validate
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function isLazySource(options) {
|
|
19
|
-
if (options.materialize === "lazy") return true;
|
|
20
|
-
return typeof options.mount === "object" && options.mount?.materialize === "lazy";
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { glob_exports as n, glob$1 as t };
|