@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,7 +1,14 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
1
|
+
import { _ as workspaceError, a as isExcludedWorkspacePath, c as normalizeSafeWorkspacePattern, f as sha256, g as workspaceConflict, l as normalizeWorkspacePath, o as matchesAny, p as assertWorkspaceDigest, r as contentToBytes, s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
|
|
2
|
+
import { n as isPlainObject } from "./config-CHLLWklZ.js";
|
|
3
|
+
import { c as getWorkspaceHostedStoreLoader, d as setWorkspaceRuntimeConfig, i as resolveGitHubWorkspaceStore, l as setWorkspaceHostedStoreLoader, r as resolveCloudflareArtifactsStore } from "./provider-B1yLjCJJ.js";
|
|
4
|
+
import { a as createSnapshotFromEntries, o as diffSnapshots, t as createGitHubWorkspaceStore } from "./store-Dt_Jyys3.js";
|
|
5
|
+
import { _ as getActiveCloudflareBinding } from "./shared-DTR1Hhma.js";
|
|
6
|
+
import { resolve } from "node:path";
|
|
4
7
|
//#region src/storage/memory-fs.ts
|
|
8
|
+
function copyBinaryData(data) {
|
|
9
|
+
if (ArrayBuffer.isView(data)) return Uint8Array.from(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
10
|
+
if (Object.prototype.toString.call(data) === "[object ArrayBuffer]") return Uint8Array.from(new Uint8Array(data));
|
|
11
|
+
}
|
|
5
12
|
var MemoryStats = class {
|
|
6
13
|
entry;
|
|
7
14
|
constructor(entry) {
|
|
@@ -70,49 +77,61 @@ var MemoryFS = class {
|
|
|
70
77
|
}
|
|
71
78
|
async mkdir(path, options) {
|
|
72
79
|
const target = this.normalize(path);
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
const recursive = isPlainObject(options) && options.recursive === true;
|
|
81
|
+
if (target === "/") {
|
|
82
|
+
if (recursive) return;
|
|
83
|
+
throw memoryFsError("EEXIST", path);
|
|
84
|
+
}
|
|
75
85
|
const parent = this.parent(target);
|
|
76
86
|
if (!this.entries.has(parent)) {
|
|
77
|
-
if (!recursive) throw
|
|
87
|
+
if (!recursive) throw memoryFsError("ENOENT", parent);
|
|
78
88
|
await this.mkdir(parent, { recursive: true });
|
|
79
89
|
}
|
|
80
|
-
|
|
90
|
+
const existing = this.entries.get(target);
|
|
91
|
+
if (existing) {
|
|
92
|
+
if (existing.kind === "dir" && recursive) return;
|
|
93
|
+
throw memoryFsError("EEXIST", path);
|
|
94
|
+
}
|
|
95
|
+
const parentEntry = this.#requireDir(parent);
|
|
81
96
|
this.entries.set(target, {
|
|
82
97
|
kind: "dir",
|
|
83
98
|
children: /* @__PURE__ */ new Set(),
|
|
84
99
|
mtimeMs: Date.now()
|
|
85
100
|
});
|
|
86
|
-
|
|
101
|
+
parentEntry.children.add(this.basename(target));
|
|
87
102
|
}
|
|
88
103
|
async writeFile(path, data) {
|
|
89
104
|
const target = this.normalize(path);
|
|
90
|
-
|
|
91
|
-
const
|
|
105
|
+
if (this.entries.get(target)?.kind === "dir") throw memoryFsError("EISDIR", path);
|
|
106
|
+
const parentPath = this.parent(target);
|
|
107
|
+
if (!this.entries.has(parentPath)) await this.mkdir(parentPath, { recursive: true });
|
|
108
|
+
const parent = this.#requireDir(parentPath);
|
|
109
|
+
const bytes = copyBinaryData(data) ?? this.#encoder.encode(String(data));
|
|
92
110
|
this.entries.set(target, {
|
|
93
111
|
kind: "file",
|
|
94
112
|
data: bytes,
|
|
95
113
|
mtimeMs: Date.now()
|
|
96
114
|
});
|
|
97
|
-
|
|
115
|
+
parent.children.add(this.basename(target));
|
|
98
116
|
}
|
|
99
117
|
async readFile(path, options) {
|
|
100
118
|
const entry = this.#requireEntry(path);
|
|
101
|
-
if (entry.kind !== "file") throw
|
|
102
|
-
return (
|
|
119
|
+
if (entry.kind !== "file") throw memoryFsError("EISDIR", path);
|
|
120
|
+
return (isPlainObject(options) ? options.encoding : options) ? this.#decoder.decode(entry.data) : Uint8Array.from(entry.data);
|
|
103
121
|
}
|
|
104
122
|
async readdir(path) {
|
|
105
123
|
return [...this.#requireDir(path).children].sort();
|
|
106
124
|
}
|
|
107
125
|
async unlink(path) {
|
|
108
126
|
const target = this.normalize(path);
|
|
109
|
-
if (this.#requireEntry(target).kind !== "file") throw
|
|
127
|
+
if (this.#requireEntry(target).kind !== "file") throw memoryFsError("EISDIR", path);
|
|
110
128
|
this.entries.delete(target);
|
|
111
129
|
this.#requireDir(this.parent(target)).children.delete(this.basename(target));
|
|
112
130
|
}
|
|
113
131
|
async rmdir(path) {
|
|
114
132
|
const target = this.normalize(path);
|
|
115
|
-
if (
|
|
133
|
+
if (target === "/") throw memoryFsError("EBUSY", path);
|
|
134
|
+
if (this.#requireDir(target).children.size) throw memoryFsError("ENOTEMPTY", path);
|
|
116
135
|
this.entries.delete(target);
|
|
117
136
|
this.#requireDir(this.parent(target)).children.delete(this.basename(target));
|
|
118
137
|
}
|
|
@@ -148,7 +167,7 @@ var MemoryFS = class {
|
|
|
148
167
|
}
|
|
149
168
|
#requireDir(path) {
|
|
150
169
|
const entry = this.#requireEntry(path);
|
|
151
|
-
if (entry.kind !== "dir") throw
|
|
170
|
+
if (entry.kind !== "dir") throw memoryFsError("ENOTDIR", path);
|
|
152
171
|
return entry;
|
|
153
172
|
}
|
|
154
173
|
};
|
|
@@ -160,6 +179,9 @@ function memoryFsError(code, path) {
|
|
|
160
179
|
const dir = "/workspace";
|
|
161
180
|
const fileMetadataPath = ".vitehub/files.json";
|
|
162
181
|
const tokenRefreshWindow = 6e4;
|
|
182
|
+
function sameSnapshotEntry(left, right) {
|
|
183
|
+
return left?.digest === right?.digest && left?.type === right?.type && left?.size === right?.size && JSON.stringify(left?.metadata) === JSON.stringify(right?.metadata);
|
|
184
|
+
}
|
|
163
185
|
function tokenSecret(token) {
|
|
164
186
|
return token.split("?expires=")[0] || token;
|
|
165
187
|
}
|
|
@@ -219,6 +241,9 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
219
241
|
async readFile(path) {
|
|
220
242
|
const normalized = normalizeSafeWorkspacePath(path);
|
|
221
243
|
await this.#ensure();
|
|
244
|
+
return await this.#mutate(() => this.#readFile(normalized));
|
|
245
|
+
}
|
|
246
|
+
async #readFile(normalized) {
|
|
222
247
|
const filepath = this.#absolute(normalized);
|
|
223
248
|
const content = await this.#fs.promises.readFile(filepath).catch(() => void 0);
|
|
224
249
|
if (!content) return void 0;
|
|
@@ -231,21 +256,22 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
231
256
|
};
|
|
232
257
|
}
|
|
233
258
|
async writeFile(path, file) {
|
|
259
|
+
const normalized = normalizeSafeWorkspacePath(path);
|
|
260
|
+
await this.#ensure();
|
|
261
|
+
await this.#mutate(() => this.#writeFile(normalized, file));
|
|
262
|
+
}
|
|
263
|
+
async writeFileConditional(path, file, ifDigest) {
|
|
234
264
|
const normalized = normalizeSafeWorkspacePath(path);
|
|
235
265
|
await this.#ensure();
|
|
236
266
|
await this.#mutate(async () => {
|
|
237
|
-
await this.#
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
metadata: file.metadata
|
|
241
|
-
});
|
|
242
|
-
else this.#files.delete(normalized);
|
|
243
|
-
await this.#writeFileMetadata();
|
|
267
|
+
const current = await this.#stat(normalized).catch(() => void 0);
|
|
268
|
+
assertWorkspaceDigest(normalized, ifDigest, current?.type === "file" ? current.digest : void 0);
|
|
269
|
+
await this.#writeFile(normalized, file);
|
|
244
270
|
});
|
|
245
271
|
}
|
|
246
272
|
async list(prefix = "", options = {}) {
|
|
247
273
|
await this.#ensure();
|
|
248
|
-
return this.#listEntries(prefix, options);
|
|
274
|
+
return await this.#mutate(() => this.#listEntries(prefix, options));
|
|
249
275
|
}
|
|
250
276
|
async #listEntries(prefix = "", options = {}) {
|
|
251
277
|
const normalizedPrefix = normalizeSafeWorkspacePath(prefix, { allowEmpty: true });
|
|
@@ -254,6 +280,7 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
254
280
|
if (absolute === dir || !absolute.startsWith(`${dir}/`)) continue;
|
|
255
281
|
const path = normalizeWorkspacePath(absolute.slice(`${dir}/`.length));
|
|
256
282
|
if (!path || path === ".git" || path.startsWith(".git/") || path === ".vitehub" || path.startsWith(".vitehub/")) continue;
|
|
283
|
+
if (isExcludedWorkspacePath(path, options.exclude)) continue;
|
|
257
284
|
if (normalizedPrefix) {
|
|
258
285
|
if (path === normalizedPrefix) continue;
|
|
259
286
|
if (!path.startsWith(`${normalizedPrefix}/`)) continue;
|
|
@@ -285,6 +312,9 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
285
312
|
async stat(path) {
|
|
286
313
|
const normalized = normalizeSafeWorkspacePath(path);
|
|
287
314
|
await this.#ensure();
|
|
315
|
+
return await this.#mutate(() => this.#stat(normalized));
|
|
316
|
+
}
|
|
317
|
+
async #stat(normalized) {
|
|
288
318
|
const stat = await this.#fs.promises.stat(this.#absolute(normalized)).catch(() => void 0);
|
|
289
319
|
if (!stat) return void 0;
|
|
290
320
|
const bytes = stat.isFile() ? await this.#fs.promises.readFile(this.#absolute(normalized)) : void 0;
|
|
@@ -326,6 +356,55 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
326
356
|
await this.#ensure();
|
|
327
357
|
return this.#mutate(() => this.#createSnapshot(options));
|
|
328
358
|
}
|
|
359
|
+
async rebase(options = {}) {
|
|
360
|
+
await this.#ensure();
|
|
361
|
+
await this.#mutate(async () => {
|
|
362
|
+
const baseline = this.#baseline;
|
|
363
|
+
const current = await createSnapshotFromEntries(await this.#listEntries("", { recursive: true }));
|
|
364
|
+
const changes = diffSnapshots(baseline, current).entries.filter((change) => change.before?.type === "file" || change.after?.type === "file");
|
|
365
|
+
const local = /* @__PURE__ */ new Map();
|
|
366
|
+
for (const change of changes) local.set(change.path, change.after ? await this.#readFile(change.path) : void 0);
|
|
367
|
+
const previous = {
|
|
368
|
+
baseline: this.#baseline,
|
|
369
|
+
branch: this.#branch,
|
|
370
|
+
files: this.#files,
|
|
371
|
+
fs: this.#fs,
|
|
372
|
+
head: this.#head,
|
|
373
|
+
pendingCommit: this.#pendingCommit,
|
|
374
|
+
remote: this.#remote
|
|
375
|
+
};
|
|
376
|
+
const restore = () => {
|
|
377
|
+
this.#baseline = previous.baseline;
|
|
378
|
+
this.#branch = previous.branch;
|
|
379
|
+
this.#files = previous.files;
|
|
380
|
+
this.#fs = previous.fs;
|
|
381
|
+
this.#head = previous.head;
|
|
382
|
+
this.#pendingCommit = previous.pendingCommit;
|
|
383
|
+
this.#remote = previous.remote;
|
|
384
|
+
};
|
|
385
|
+
try {
|
|
386
|
+
this.#files = /* @__PURE__ */ new Map();
|
|
387
|
+
this.#pendingCommit = void 0;
|
|
388
|
+
await this.#load();
|
|
389
|
+
const remoteChanges = new Map(diffSnapshots(baseline, this.#baseline).entries.map((change) => [change.path, change]));
|
|
390
|
+
const takeRemote = new Set(options.takeRemote || []);
|
|
391
|
+
for (const change of changes) if (remoteChanges.has(change.path) && !takeRemote.has(change.path) && !sameSnapshotEntry(current.entries[change.path], this.#baseline?.entries[change.path])) throw workspaceConflict(`[vitehub] Cloudflare Artifacts Workspace Store rebase conflict: ${change.path} changed locally and remotely.`);
|
|
392
|
+
for (const change of changes) {
|
|
393
|
+
if (remoteChanges.has(change.path) && takeRemote.has(change.path)) continue;
|
|
394
|
+
const file = local.get(change.path);
|
|
395
|
+
if (file) await this.#writeFile(change.path, file);
|
|
396
|
+
else {
|
|
397
|
+
this.#fs.deleteTree(this.#absolute(change.path));
|
|
398
|
+
this.#files.delete(change.path);
|
|
399
|
+
await this.#writeFileMetadata();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
} catch (error) {
|
|
403
|
+
restore();
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
329
408
|
async #createSnapshot(options) {
|
|
330
409
|
const git = await import("isomorphic-git");
|
|
331
410
|
const http = await import("isomorphic-git/http/web");
|
|
@@ -379,7 +458,7 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
379
458
|
url: this.#remote
|
|
380
459
|
});
|
|
381
460
|
} catch (error) {
|
|
382
|
-
if (isNonFastForward(error)) throw
|
|
461
|
+
if (isNonFastForward(error)) throw workspaceConflict(`[vitehub] Workspace "${this.workspaceName}" changed remotely while snapshotting branch "${this.#branch}". Reload the Workspace before retrying.`, { cause: error });
|
|
383
462
|
throw error;
|
|
384
463
|
}
|
|
385
464
|
this.#head = id;
|
|
@@ -394,20 +473,33 @@ var CloudflareArtifactsWorkspaceStore = class {
|
|
|
394
473
|
}
|
|
395
474
|
async diff(options = {}) {
|
|
396
475
|
await this.#ensure();
|
|
397
|
-
return
|
|
476
|
+
return await this.#mutate(async () => {
|
|
477
|
+
return diffSnapshots(options.from || this.#baseline, await createSnapshotFromEntries(await this.#listEntries("", { recursive: true })));
|
|
478
|
+
});
|
|
398
479
|
}
|
|
399
480
|
async getMeta(key) {
|
|
400
481
|
const path = this.#metaAbsolute(key);
|
|
401
482
|
await this.#ensure();
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
483
|
+
return await this.#mutate(async () => {
|
|
484
|
+
const content = await this.#fs.promises.readFile(path).catch(() => void 0);
|
|
485
|
+
if (!content) return void 0;
|
|
486
|
+
return JSON.parse(new TextDecoder().decode(contentToBytes(content)));
|
|
487
|
+
});
|
|
405
488
|
}
|
|
406
489
|
async setMeta(key, value) {
|
|
407
490
|
const path = this.#metaAbsolute(key);
|
|
408
491
|
await this.#ensure();
|
|
409
492
|
await this.#mutate(() => this.#fs.promises.writeFile(path, contentToBytes(JSON.stringify(value))));
|
|
410
493
|
}
|
|
494
|
+
async #writeFile(path, file) {
|
|
495
|
+
await this.#fs.promises.writeFile(this.#absolute(path), contentToBytes(file.content));
|
|
496
|
+
if (file.mediaType !== void 0 || file.metadata !== void 0) this.#files.set(path, {
|
|
497
|
+
mediaType: file.mediaType,
|
|
498
|
+
metadata: file.metadata
|
|
499
|
+
});
|
|
500
|
+
else this.#files.delete(path);
|
|
501
|
+
await this.#writeFileMetadata();
|
|
502
|
+
}
|
|
411
503
|
#absolute(path) {
|
|
412
504
|
return `${dir}/${path}`;
|
|
413
505
|
}
|
|
@@ -552,4 +644,28 @@ function createCloudflareArtifactsWorkspaceStore(options, workspaceName) {
|
|
|
552
644
|
return new CloudflareArtifactsWorkspaceStore(options, workspaceName);
|
|
553
645
|
}
|
|
554
646
|
//#endregion
|
|
555
|
-
|
|
647
|
+
//#region src/hosted.ts
|
|
648
|
+
function installHostedWorkspaceRuntime() {
|
|
649
|
+
const existingWorkspaceHostedStoreLoader = getWorkspaceHostedStoreLoader();
|
|
650
|
+
setWorkspaceHostedStoreLoader((storeOptions, workspaceName) => {
|
|
651
|
+
if (storeOptions.provider === "cloudflare-artifacts") return createCloudflareArtifactsWorkspaceStore(storeOptions, workspaceName);
|
|
652
|
+
if (storeOptions.provider === "github") return createGitHubWorkspaceStore(storeOptions, workspaceName);
|
|
653
|
+
if (existingWorkspaceHostedStoreLoader) return existingWorkspaceHostedStoreLoader(storeOptions, workspaceName);
|
|
654
|
+
throw workspaceError("[vitehub] Hosted workspace runtime cannot load unsupported hosted store.");
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function configureHostedWorkspaceRuntime(options = {}) {
|
|
658
|
+
const root = resolve(process.cwd(), options.root || ".vitehub/workspaces");
|
|
659
|
+
const store = options.store?.provider === "github" ? resolveGitHubWorkspaceStore(options.store, options.env || {}, { runtime: true }) : options.store?.provider === "vercel-blob" ? void 0 : resolveCloudflareArtifactsStore(options.store, options.env);
|
|
660
|
+
if (!store) throw workspaceError("[vitehub] Vercel Blob hosted workspace runtime must use @vite-hub/workspace/internal/runtime/hosted-vercel-blob.");
|
|
661
|
+
const config = {
|
|
662
|
+
assets: options.assets,
|
|
663
|
+
root,
|
|
664
|
+
store
|
|
665
|
+
};
|
|
666
|
+
installHostedWorkspaceRuntime();
|
|
667
|
+
setWorkspaceRuntimeConfig(config);
|
|
668
|
+
return config;
|
|
669
|
+
}
|
|
670
|
+
//#endregion
|
|
671
|
+
export { installHostedWorkspaceRuntime as n, createCloudflareArtifactsWorkspaceStore as r, configureHostedWorkspaceRuntime as t };
|