@vite-hub/workspace 0.0.4 → 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 +339 -115
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/blob-database.d.ts +474 -0
- package/dist/blob-database.js +608 -0
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +6 -7
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/config-BAgL2dtB.js +1076 -0
- package/dist/{config-DE9xlaIw.d.ts → config-BQKcPawI.d.ts} +1 -2
- 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-Q6xZjDHA.js → files-BOo4SbwE.js} +3 -3
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-DHnjxQIX.js → github-CrYp4v8k.js} +44 -24
- package/dist/glob-B8YGvTrZ.js +21 -0
- package/dist/glob-Cjxms1t7.js +30 -0
- package/dist/{host-DJH8cuoU.js → host-BFBpXn0N.js} +144 -77
- package/dist/{hosted-RPeJOCFz.js → hosted-KcUR_jPv.js} +303 -97
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +6 -7
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +10 -9
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +26 -47
- package/dist/index.js +30 -100
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-B-enk_4A.js +596 -0
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-DF0F5rcL.js +39 -0
- package/dist/memory-BOexthyW.js +247 -0
- package/dist/metadata-target-CWz6KHKq.js +1589 -0
- 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 +90 -0
- package/dist/operations.js +3 -0
- package/dist/path--wrT_Azm.js +113 -0
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-C8C0auoW.d.ts +10 -0
- package/dist/provider-9s4Ufkm5.js +1479 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-D3yzt8HQ.js → registry-CNphafBx.js} +60 -23
- 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/{chunk-2rV9d50f.js → rolldown-runtime-rQ84J-ij.js} +3 -4
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +7 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -2
- 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 +52 -17
- package/dist/runtime.js +324 -67
- package/dist/{search-BpiCF2Tw.js → search-C_RfoM2j.js} +10 -9
- package/dist/server-8tGltlGz.js +303 -0
- package/dist/server.d.ts +36 -39
- package/dist/server.js +2 -328
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +10 -7
- package/dist/source-metadata.js +12 -12
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BqCC8BpY.js → state-DbrW-njQ.js} +237 -114
- package/dist/store-ybhyD38Z.js +1873 -0
- package/dist/{sync-DnTQwt8r.js → sync-CCD_VYC8.js} +61 -41
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-CYuwjJ4V.d.ts → types-BbtwmBZ5.d.ts} +321 -35
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BTNDR5Rd.js → use-CSpT5W87.js} +141 -107
- package/dist/utils-CgMZCHsX.js +616 -0
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21369 -2
- package/dist/workspace-CYB2xZ1T.d.ts +7 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-sPWn2Jxj.js} +441 -225
- package/package.json +97 -72
- package/dist/ai-CjxvGqM0.d.ts +0 -162
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-Bc3c4Su1.js +0 -7904
- package/dist/config-CHLLWklZ.js +0 -36
- package/dist/file-Bc1X7pco.js +0 -23
- package/dist/glob-CEZKeZFC.js +0 -18
- package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
- package/dist/lifecycle-LrL3sA4n.js +0 -316
- package/dist/metadata-target-B0tOmVW7.js +0 -717
- package/dist/mountx.d.ts +0 -10
- package/dist/mountx.js +0 -143
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -26
- package/dist/nuxt.js +0 -42
- package/dist/path-Cp59koVz.js +0 -139
- package/dist/provider-B1yLjCJJ.js +0 -746
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-Uj6IVxes.d.ts +0 -11
- package/dist/request-execution-B-dSFlGB.js +0 -84
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/state-tYcRWEh2.d.ts +0 -26
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/token-CVzURBxC.js +0 -61
- package/dist/use-BiHzt0xA.d.ts +0 -103
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
- package/dist/workspace-Xddf4G1B.d.ts +0 -6
package/dist/publish.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { a as GitHubWorkspaceOption, lt as WorkspacePublisher } from "./types-CYuwjJ4V.js";
|
|
2
|
-
|
|
3
|
-
//#region src/publishers/manifest.d.ts
|
|
4
|
-
interface ManifestPublisherOptions {
|
|
5
|
-
path?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function manifest(options?: ManifestPublisherOptions): WorkspacePublisher;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/publishers/github.d.ts
|
|
10
|
-
type GitHubPublisherOption = GitHubWorkspaceOption;
|
|
11
|
-
interface GitHubPublisherOptions {
|
|
12
|
-
branch?: GitHubPublisherOption;
|
|
13
|
-
deleteUntracked?: boolean;
|
|
14
|
-
message?: GitHubPublisherOption;
|
|
15
|
-
repo?: GitHubPublisherOption;
|
|
16
|
-
repository?: GitHubPublisherOption;
|
|
17
|
-
root?: GitHubPublisherOption;
|
|
18
|
-
token?: GitHubPublisherOption;
|
|
19
|
-
}
|
|
20
|
-
declare function github(options?: GitHubPublisherOptions): WorkspacePublisher;
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/publishers/types.d.ts
|
|
23
|
-
interface TypesPublisherOptions {
|
|
24
|
-
path?: string;
|
|
25
|
-
}
|
|
26
|
-
declare function types(options?: TypesPublisherOptions): WorkspacePublisher;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/publishers/virtual-module.d.ts
|
|
29
|
-
interface VirtualModulePublisherOptions {
|
|
30
|
-
id: string;
|
|
31
|
-
includeContent?: boolean;
|
|
32
|
-
}
|
|
33
|
-
declare function virtualModule(options: VirtualModulePublisherOptions): WorkspacePublisher;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { type GitHubPublisherOptions, type ManifestPublisherOptions, type TypesPublisherOptions, type VirtualModulePublisherOptions, github, manifest, types, virtualModule };
|
package/dist/publish.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { _ as workspaceError, l as normalizeWorkspacePath } from "./path-Cp59koVz.js";
|
|
2
|
-
import { n as resolveWorkspaceStoreTarget } from "./target-D4Bqb1eH.js";
|
|
3
|
-
import { a as isWorkspaceFileEntry, d as requireGitHubOption, f as resolveGitHubBranchOption, g as resolveGitHubTokenOption, h as resolveGitHubRootOption, l as readGitHubBranchState, m as resolveGitHubRepositoryOption, p as resolveGitHubOption, r as createGitHubFileUpdate, t as commitGitHubChanges } from "./shared-DTR1Hhma.js";
|
|
4
|
-
import { dirname, resolve } from "node:path";
|
|
5
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
6
|
-
//#region src/publishers/manifest.ts
|
|
7
|
-
function manifest(options = {}) {
|
|
8
|
-
return {
|
|
9
|
-
name: "manifest",
|
|
10
|
-
async publish(ctx) {
|
|
11
|
-
const path = resolve(ctx.rootDir, options.path || `.vitehub/workspaces/${ctx.workspace.name}.json`);
|
|
12
|
-
const entries = await ctx.store.list("", { recursive: true });
|
|
13
|
-
await mkdir(dirname(path), { recursive: true });
|
|
14
|
-
await writeFile(path, `${JSON.stringify({
|
|
15
|
-
name: ctx.workspace.name,
|
|
16
|
-
entries
|
|
17
|
-
}, null, 2)}\n`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/publishers/github.ts
|
|
23
|
-
function resolveMessage(options, ctx) {
|
|
24
|
-
return ctx.snapshot?.name || resolveGitHubOption(options.message) || "chore: update workspace snapshot";
|
|
25
|
-
}
|
|
26
|
-
async function resolveActiveGitHubStoreTarget(ctx) {
|
|
27
|
-
const target = await resolveWorkspaceStoreTarget(ctx.store);
|
|
28
|
-
if (target) return target.provider === "github" ? target : void 0;
|
|
29
|
-
const configuredStore = ctx.workspace.store;
|
|
30
|
-
if (configuredStore && "provider" in configuredStore && configuredStore.provider === "github") {
|
|
31
|
-
const repository = resolveGitHubRepositoryOption(configuredStore);
|
|
32
|
-
if (repository) return {
|
|
33
|
-
provider: "github",
|
|
34
|
-
branch: resolveGitHubBranchOption(configuredStore),
|
|
35
|
-
repository
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function readFiles(ctx, root) {
|
|
40
|
-
const entries = await ctx.store.list("", { recursive: true });
|
|
41
|
-
return await Promise.all(entries.filter(isWorkspaceFileEntry).map(async (entry) => {
|
|
42
|
-
const file = await ctx.store.readFile(entry.path);
|
|
43
|
-
if (!file) throw workspaceError(`[vitehub] Workspace file disappeared before GitHub publish: ${entry.path}.`);
|
|
44
|
-
const update = await createGitHubFileUpdate(entry.path, root, file.content);
|
|
45
|
-
return {
|
|
46
|
-
...file,
|
|
47
|
-
path: normalizeWorkspacePath(entry.path),
|
|
48
|
-
...update
|
|
49
|
-
};
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
function github(options = {}) {
|
|
53
|
-
return {
|
|
54
|
-
name: "github",
|
|
55
|
-
async publish(ctx) {
|
|
56
|
-
const repository = requireGitHubOption("publisher", "a repository", resolveGitHubRepositoryOption(options));
|
|
57
|
-
const branch = resolveGitHubBranchOption(options);
|
|
58
|
-
const root = resolveGitHubRootOption(options, ctx.workspace.name);
|
|
59
|
-
const token = requireGitHubOption("publisher", "a token", resolveGitHubTokenOption(options));
|
|
60
|
-
const storeTarget = await resolveActiveGitHubStoreTarget(ctx);
|
|
61
|
-
if (!ctx.durable && storeTarget?.repository === repository && storeTarget.branch === branch) throw workspaceError(`[vitehub] GitHub publisher cannot publish to ${repository}@${branch} while it backs the active GitHub Workspace Store. Use workspace.snapshot() for that branch or configure the publisher to use a different repository or branch.`);
|
|
62
|
-
const files = await readFiles(ctx, root);
|
|
63
|
-
const nextPaths = new Set(files.map((file) => file.path));
|
|
64
|
-
const remote = await readGitHubBranchState({
|
|
65
|
-
branch,
|
|
66
|
-
kind: "publisher",
|
|
67
|
-
paths: options.deleteUntracked === false ? files.map((file) => file.path) : void 0,
|
|
68
|
-
repository,
|
|
69
|
-
root,
|
|
70
|
-
token
|
|
71
|
-
});
|
|
72
|
-
const changedFiles = files.filter((file) => remote.files.get(file.path)?.sha !== file.gitSha);
|
|
73
|
-
const deletePaths = options.deleteUntracked === false ? [] : [...remote.files].filter(([path]) => !nextPaths.has(path)).map(([, entry]) => entry.path);
|
|
74
|
-
if (!changedFiles.length && !deletePaths.length) return;
|
|
75
|
-
await commitGitHubChanges({
|
|
76
|
-
baseTreeSha: remote.treeSha,
|
|
77
|
-
branch,
|
|
78
|
-
branchExists: remote.branchExists,
|
|
79
|
-
deletePaths,
|
|
80
|
-
files: changedFiles,
|
|
81
|
-
kind: "publisher",
|
|
82
|
-
message: resolveMessage(options, ctx),
|
|
83
|
-
parentSha: remote.refSha,
|
|
84
|
-
repository,
|
|
85
|
-
token
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/publishers/types.ts
|
|
92
|
-
function types(options = {}) {
|
|
93
|
-
return {
|
|
94
|
-
name: "types",
|
|
95
|
-
async publish(ctx) {
|
|
96
|
-
const path = resolve(ctx.rootDir, options.path || `.vitehub/workspaces/${ctx.workspace.name}.d.ts`);
|
|
97
|
-
await mkdir(dirname(path), { recursive: true });
|
|
98
|
-
await writeFile(path, `declare module "#vitehub/workspaces/${ctx.workspace.name}" {\n const manifest: { name: ${JSON.stringify(ctx.workspace.name)}, entries: Array<{ path: string, type: "file" | "directory" }> }\n export default manifest\n}\n`);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/publishers/virtual-module.ts
|
|
104
|
-
function virtualModule(options) {
|
|
105
|
-
return {
|
|
106
|
-
name: `virtual-module:${options.id}`,
|
|
107
|
-
clientSafe: options.includeContent === true,
|
|
108
|
-
async publish() {}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
export { github, manifest, types, virtualModule };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { F as WorkspaceDefinition, I as WorkspaceDefinitionInput } from "./types-CYuwjJ4V.js";
|
|
2
|
-
|
|
3
|
-
//#region src/core/registry.d.ts
|
|
4
|
-
type WorkspaceRegistryModule = {
|
|
5
|
-
default?: WorkspaceDefinitionInput;
|
|
6
|
-
};
|
|
7
|
-
type WorkspaceRegistry = Record<string, () => Promise<WorkspaceRegistryModule>>;
|
|
8
|
-
declare function registerWorkspace(name: string, definition: WorkspaceDefinitionInput): WorkspaceDefinition;
|
|
9
|
-
declare function resolveRegisteredWorkspaceDefinition(name: string, abortSignal?: AbortSignal): Promise<WorkspaceDefinition>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { registerWorkspace as n, resolveRegisteredWorkspaceDefinition as r, WorkspaceRegistry as t };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { _ as workspaceSourceRequestDescriptorPath, a as normalizeWorkspaceSources, h as getWorkspaceSourceRequestExecutor, n as createSourceContext } from "./config-Bc3c4Su1.js";
|
|
2
|
-
//#region src/sources/request-execution.ts
|
|
3
|
-
const sourceRequestExecutions = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
function isWeakKey(value) {
|
|
5
|
-
return Object(value) === value;
|
|
6
|
-
}
|
|
7
|
-
function attachWorkspaceSourceRequestExecution(target, executor) {
|
|
8
|
-
if (!executor) return target;
|
|
9
|
-
sourceRequestExecutions.set(target, executor);
|
|
10
|
-
return target;
|
|
11
|
-
}
|
|
12
|
-
function getWorkspaceSourceRequestExecution(input) {
|
|
13
|
-
if (!isWeakKey(input)) return void 0;
|
|
14
|
-
return sourceRequestExecutions.get(input);
|
|
15
|
-
}
|
|
16
|
-
function createWorkspaceSourceRequestExecution(definition, options = {}) {
|
|
17
|
-
const sources = normalizeWorkspaceSources(definition.sources).filter((source) => source.requestDescriptor && getWorkspaceSourceRequestExecutor(source.source)).filter((source) => sourceRequestVisible(source, options.selectedWorkspaceScope));
|
|
18
|
-
if (!sources.length) return void 0;
|
|
19
|
-
return { async executeSourceRequest(input) {
|
|
20
|
-
const matches = sources.filter((source) => {
|
|
21
|
-
const descriptor = source.requestDescriptor;
|
|
22
|
-
if (!descriptor || descriptor.method !== input.method) return false;
|
|
23
|
-
return sameRequestTarget(descriptor.url, input.url);
|
|
24
|
-
}).filter((source) => source.requestDescriptor && requestShapeMatches(source.requestDescriptor, input));
|
|
25
|
-
if (matches.length !== 1) throw new Error(matches.length > 1 ? "[vitehub] Source request is ambiguous; more than one visible Source matches this curl target." : "[vitehub] Source request is not visible in the selected workspace scope or does not match a declared Source target.");
|
|
26
|
-
const source = matches[0];
|
|
27
|
-
const executor = getWorkspaceSourceRequestExecutor(source.source);
|
|
28
|
-
if (!executor) throw new Error("[vitehub] Source request executor is unavailable.");
|
|
29
|
-
return await executor(input, createSourceContext(definition, {
|
|
30
|
-
key: source.key,
|
|
31
|
-
mountPath: source.mountPath
|
|
32
|
-
}, void 0, { selectedWorkspaceScope: options.selectedWorkspaceScope }));
|
|
33
|
-
} };
|
|
34
|
-
}
|
|
35
|
-
function sourceRequestVisible(source, scope) {
|
|
36
|
-
if (!scope || scope.all) return true;
|
|
37
|
-
const descriptorPath = workspaceSourceRequestDescriptorPath(source.key);
|
|
38
|
-
return Boolean(scope.paths?.some((path) => pathIntersects(path, descriptorPath)));
|
|
39
|
-
}
|
|
40
|
-
function pathContains(container, path) {
|
|
41
|
-
if (!container || !path) return container === path;
|
|
42
|
-
return path === container || path.startsWith(`${container}/`);
|
|
43
|
-
}
|
|
44
|
-
function pathIntersects(left, right) {
|
|
45
|
-
return pathContains(left, right) || pathContains(right, left);
|
|
46
|
-
}
|
|
47
|
-
function sameRequestTarget(left, right) {
|
|
48
|
-
const leftUrl = new URL(left);
|
|
49
|
-
const rightUrl = new URL(right);
|
|
50
|
-
return leftUrl.origin === rightUrl.origin && leftUrl.pathname === rightUrl.pathname;
|
|
51
|
-
}
|
|
52
|
-
function requestShapeMatches(descriptor, input) {
|
|
53
|
-
const request = descriptor.request;
|
|
54
|
-
if (request?.querySchema) return bodyShapeMatches(request, input);
|
|
55
|
-
if (!jsonEqual(queryFromUrl(new URL(input.url)) || {}, serializedQuery(request?.query) || {})) return false;
|
|
56
|
-
return bodyShapeMatches(request, input);
|
|
57
|
-
}
|
|
58
|
-
function bodyShapeMatches(request, input) {
|
|
59
|
-
if (request?.bodySchema) return true;
|
|
60
|
-
if (request && "body" in request) return jsonEqual(input.body, request.body);
|
|
61
|
-
return input.body === void 0;
|
|
62
|
-
}
|
|
63
|
-
function queryFromUrl(url) {
|
|
64
|
-
const query = {};
|
|
65
|
-
for (const key of new Set(url.searchParams.keys())) {
|
|
66
|
-
const values = url.searchParams.getAll(key);
|
|
67
|
-
query[key] = values.length > 1 ? values : values[0];
|
|
68
|
-
}
|
|
69
|
-
return Object.keys(query).length ? query : void 0;
|
|
70
|
-
}
|
|
71
|
-
function serializedQuery(query) {
|
|
72
|
-
if (!query) return void 0;
|
|
73
|
-
const params = new URLSearchParams();
|
|
74
|
-
for (const [key, value] of Object.entries(query)) {
|
|
75
|
-
const values = Array.isArray(value) ? value : [value];
|
|
76
|
-
for (const item of values) params.append(key, String(item));
|
|
77
|
-
}
|
|
78
|
-
return queryFromUrl(new URL(`https://vitehub.local/?${params}`));
|
|
79
|
-
}
|
|
80
|
-
function jsonEqual(left, right) {
|
|
81
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
export { createWorkspaceSourceRequestExecution as n, getWorkspaceSourceRequestExecution as r, attachWorkspaceSourceRequestExecution as t };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/sources/runtime-options.ts
|
|
2
|
-
function withWorkspaceRuntimeOptions(source, options) {
|
|
3
|
-
return {
|
|
4
|
-
...source,
|
|
5
|
-
cache: options.cache,
|
|
6
|
-
materialize: options.materialize,
|
|
7
|
-
mount: options.mount,
|
|
8
|
-
sync: options.sync,
|
|
9
|
-
validate: options.validate
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { withWorkspaceRuntimeOptions as t };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//#region src/internal/runtime-type.ts
|
|
2
|
-
function isCallableRepresentation(value) {
|
|
3
|
-
if (value === null || value === void 0 || Object(value) !== value) return false;
|
|
4
|
-
try {
|
|
5
|
-
Function.prototype.toString.call(value);
|
|
6
|
-
return true;
|
|
7
|
-
} catch {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/** Parses JavaScript runtime representation categories at Workspace boundaries. */
|
|
12
|
-
function hasRuntimeType(value, expected) {
|
|
13
|
-
if (expected === "undefined") return value === void 0;
|
|
14
|
-
if (expected === "object" && value === null) return true;
|
|
15
|
-
if (value === null || value === void 0) return false;
|
|
16
|
-
const isPrimitive = Object(value) !== value;
|
|
17
|
-
if (!isPrimitive) {
|
|
18
|
-
if (expected === "function") return isCallableRepresentation(value);
|
|
19
|
-
return expected === "object" && !isCallableRepresentation(value);
|
|
20
|
-
}
|
|
21
|
-
const tag = Object.prototype.toString.call(value);
|
|
22
|
-
switch (expected) {
|
|
23
|
-
case "bigint": return isPrimitive && tag === "[object BigInt]";
|
|
24
|
-
case "boolean": return isPrimitive && tag === "[object Boolean]";
|
|
25
|
-
case "function": return false;
|
|
26
|
-
case "number": return isPrimitive && tag === "[object Number]";
|
|
27
|
-
case "object": return false;
|
|
28
|
-
case "string": return isPrimitive && tag === "[object String]";
|
|
29
|
-
case "symbol": return isPrimitive && tag === "[object Symbol]";
|
|
30
|
-
}
|
|
31
|
-
throw new TypeError(`Unsupported runtime type: ${expected}`);
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { hasRuntimeType as t };
|
package/dist/shared-DTR1Hhma.js
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { _ as workspaceError, l as normalizeWorkspacePath, r as contentToBytes, s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
//#region ../internal/src/runtime/cloudflare-env.ts
|
|
4
|
-
let activeEnv;
|
|
5
|
-
const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
|
|
6
|
-
const runtimeGlobal = globalThis;
|
|
7
|
-
const activeEnvStorage = runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
|
|
8
|
-
function setActiveCloudflareEnv(env) {
|
|
9
|
-
activeEnv = env;
|
|
10
|
-
globalThis.__env__ = env;
|
|
11
|
-
try {
|
|
12
|
-
activeEnvStorage.enterWith({ env });
|
|
13
|
-
} catch {}
|
|
14
|
-
}
|
|
15
|
-
function getActiveCloudflareEnv() {
|
|
16
|
-
const scoped = activeEnvStorage.getStore();
|
|
17
|
-
return scoped ? scoped.env : activeEnv ?? globalThis.__env__;
|
|
18
|
-
}
|
|
19
|
-
function getActiveCloudflareBinding(name) {
|
|
20
|
-
return getActiveCloudflareEnv()?.[name];
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/providers/github/shared.ts
|
|
24
|
-
const githubReadAttempts = 3;
|
|
25
|
-
function retryDelay(response, attempt) {
|
|
26
|
-
const retryAfter = response.headers.get("retry-after");
|
|
27
|
-
if (retryAfter) {
|
|
28
|
-
const seconds = Number(retryAfter);
|
|
29
|
-
if (Number.isFinite(seconds)) return Math.min(seconds * 1e3, 2e3);
|
|
30
|
-
const date = Date.parse(retryAfter);
|
|
31
|
-
if (Number.isFinite(date)) return Math.min(Math.max(date - Date.now(), 0), 2e3);
|
|
32
|
-
}
|
|
33
|
-
return 100 * 2 ** attempt;
|
|
34
|
-
}
|
|
35
|
-
function retryableGitHubRead(response) {
|
|
36
|
-
return response.status === 429 || response.status >= 500;
|
|
37
|
-
}
|
|
38
|
-
async function waitForRetry(delay, signal) {
|
|
39
|
-
signal?.throwIfAborted();
|
|
40
|
-
await new Promise((resolve, reject) => {
|
|
41
|
-
const aborted = () => {
|
|
42
|
-
clearTimeout(timeout);
|
|
43
|
-
reject(signal?.reason || new DOMException("The operation was aborted.", "AbortError"));
|
|
44
|
-
};
|
|
45
|
-
const timeout = setTimeout(() => {
|
|
46
|
-
signal?.removeEventListener("abort", aborted);
|
|
47
|
-
resolve();
|
|
48
|
-
}, delay);
|
|
49
|
-
signal?.addEventListener("abort", aborted, { once: true });
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
async function requestGitHub(input, init = {}) {
|
|
53
|
-
const method = (init.method || "GET").toUpperCase();
|
|
54
|
-
const retryable = method === "GET" || method === "HEAD";
|
|
55
|
-
for (let attempt = 0;; attempt++) {
|
|
56
|
-
init.signal?.throwIfAborted();
|
|
57
|
-
let response;
|
|
58
|
-
try {
|
|
59
|
-
response = await fetch(input, init);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (!retryable || init.signal?.aborted || attempt + 1 >= githubReadAttempts) throw error;
|
|
62
|
-
await waitForRetry(100 * 2 ** attempt, init.signal || void 0);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (!retryable || !retryableGitHubRead(response) || attempt + 1 >= githubReadAttempts) return response;
|
|
66
|
-
await response.body?.cancel().catch(() => void 0);
|
|
67
|
-
await waitForRetry(retryDelay(response, attempt), init.signal || void 0);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
var GitHubRequestError = class extends Error {
|
|
71
|
-
status;
|
|
72
|
-
constructor(message, status) {
|
|
73
|
-
super(message);
|
|
74
|
-
this.status = status;
|
|
75
|
-
this.name = "GitHubRequestError";
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
function githubRequestStatus(error) {
|
|
79
|
-
return (error instanceof GitHubRequestError ? error : error instanceof Error && error.cause instanceof GitHubRequestError ? error.cause : void 0)?.status;
|
|
80
|
-
}
|
|
81
|
-
function processEnv(env, ...keys) {
|
|
82
|
-
return keys.map((key) => env[key]).find((value) => typeof value === "string" && value.length > 0);
|
|
83
|
-
}
|
|
84
|
-
function resolveGitHubOption(value) {
|
|
85
|
-
const resolved = typeof value === "function" ? value() : value;
|
|
86
|
-
return typeof resolved === "string" ? resolved.trim() || void 0 : resolved;
|
|
87
|
-
}
|
|
88
|
-
function isMaskedGitHubTokenOption(value) {
|
|
89
|
-
return value === "********" || value === "<redacted>" || value === "[redacted]";
|
|
90
|
-
}
|
|
91
|
-
function activeCloudflareEnv(keys, accept = () => true) {
|
|
92
|
-
return keys.map((key) => getActiveCloudflareBinding(key)).map((value) => typeof value === "string" ? value.trim() : void 0).find((value) => typeof value === "string" && value.length > 0 && accept(value));
|
|
93
|
-
}
|
|
94
|
-
function requireGitHubOption(kind, label, value) {
|
|
95
|
-
if (!value) throw workspaceError(`[vitehub] GitHub workspace ${kind} requires ${label}.`);
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
function splitGitHubRepository(repository, kind) {
|
|
99
|
-
const [owner, repo] = repository.split("/");
|
|
100
|
-
if (!owner || !repo) throw workspaceError(`[vitehub] GitHub workspace ${kind} requires a repository in owner/repo format.`);
|
|
101
|
-
return {
|
|
102
|
-
owner,
|
|
103
|
-
repo
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function joinGitPath(...parts) {
|
|
107
|
-
return parts.join("/").replaceAll("\\", "/").split("/").filter(Boolean).join("/");
|
|
108
|
-
}
|
|
109
|
-
function resolveGitHubWorkspaceRoot(root, workspaceName) {
|
|
110
|
-
return normalizeSafeWorkspacePath(joinGitPath(root.replaceAll("<workspace>", workspaceName)), {
|
|
111
|
-
allowEmpty: true,
|
|
112
|
-
allowReserved: true
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function workspacePathFromGitPath(path, root) {
|
|
116
|
-
const normalized = joinGitPath(path);
|
|
117
|
-
const normalizedRoot = joinGitPath(root);
|
|
118
|
-
if (!normalizedRoot) return normalizeWorkspacePath(normalized);
|
|
119
|
-
if (!normalized.startsWith(`${normalizedRoot}/`)) return void 0;
|
|
120
|
-
return normalizeWorkspacePath(normalized.slice(normalizedRoot.length + 1));
|
|
121
|
-
}
|
|
122
|
-
function isWorkspaceFileEntry(entry) {
|
|
123
|
-
return entry.type === "file";
|
|
124
|
-
}
|
|
125
|
-
function toHex(bytes) {
|
|
126
|
-
return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
127
|
-
}
|
|
128
|
-
async function gitBlobSha(bytes) {
|
|
129
|
-
const prefix = new TextEncoder().encode(`blob ${bytes.byteLength}\0`);
|
|
130
|
-
const input = new Uint8Array(prefix.byteLength + bytes.byteLength);
|
|
131
|
-
input.set(prefix);
|
|
132
|
-
input.set(bytes, prefix.byteLength);
|
|
133
|
-
return toHex(new Uint8Array(await globalThis.crypto.subtle.digest("SHA-1", input)));
|
|
134
|
-
}
|
|
135
|
-
function toBase64(bytes) {
|
|
136
|
-
let binary = "";
|
|
137
|
-
for (let index = 0; index < bytes.length; index += 32768) binary += String.fromCharCode(...bytes.subarray(index, index + 32768));
|
|
138
|
-
const encode = globalThis.btoa;
|
|
139
|
-
return encode ? encode(binary) : Buffer.from(bytes).toString("base64");
|
|
140
|
-
}
|
|
141
|
-
function resolveGitHubRepositoryOption(options, env = typeof process !== "undefined" ? process.env : {}) {
|
|
142
|
-
return resolveGitHubOption(options.repository) || resolveGitHubOption(options.repo) || activeCloudflareEnv([
|
|
143
|
-
"WORKSPACE_GITHUB_REPOSITORY",
|
|
144
|
-
"VITEHUB_WORKSPACE_GITHUB_REPOSITORY",
|
|
145
|
-
"GITHUB_REPOSITORY"
|
|
146
|
-
]) || processEnv(env, "WORKSPACE_GITHUB_REPOSITORY", "VITEHUB_WORKSPACE_GITHUB_REPOSITORY", "GITHUB_REPOSITORY");
|
|
147
|
-
}
|
|
148
|
-
function resolveGitHubBranchOption(options, env = typeof process !== "undefined" ? process.env : {}) {
|
|
149
|
-
return resolveGitHubOption(options.branch) || activeCloudflareEnv([
|
|
150
|
-
"WORKSPACE_GITHUB_BRANCH",
|
|
151
|
-
"VITEHUB_WORKSPACE_GITHUB_BRANCH",
|
|
152
|
-
"GITHUB_BRANCH"
|
|
153
|
-
]) || processEnv(env, "WORKSPACE_GITHUB_BRANCH", "VITEHUB_WORKSPACE_GITHUB_BRANCH", "GITHUB_BRANCH") || "main";
|
|
154
|
-
}
|
|
155
|
-
function resolveGitHubRootOption(options, workspaceName, env = typeof process !== "undefined" ? process.env : {}) {
|
|
156
|
-
return resolveGitHubWorkspaceRoot(resolveGitHubOption(options.root) || activeCloudflareEnv(["WORKSPACE_GITHUB_ROOT", "VITEHUB_WORKSPACE_GITHUB_ROOT"]) || processEnv(env, "WORKSPACE_GITHUB_ROOT", "VITEHUB_WORKSPACE_GITHUB_ROOT") || ".vitehub/workspaces/<workspace>", workspaceName);
|
|
157
|
-
}
|
|
158
|
-
function resolveGitHubTokenOption(options, env = typeof process !== "undefined" ? process.env : {}) {
|
|
159
|
-
const token = resolveGitHubOption(options.token);
|
|
160
|
-
if (token && !isMaskedGitHubTokenOption(token)) return token;
|
|
161
|
-
const bindingToken = activeCloudflareEnv([
|
|
162
|
-
"WORKSPACE_GITHUB_TOKEN",
|
|
163
|
-
"VITEHUB_WORKSPACE_GITHUB_TOKEN",
|
|
164
|
-
"GITHUB_TOKEN",
|
|
165
|
-
"GH_TOKEN"
|
|
166
|
-
], (value) => !isMaskedGitHubTokenOption(value));
|
|
167
|
-
if (bindingToken) return bindingToken;
|
|
168
|
-
return processEnv(env, "WORKSPACE_GITHUB_TOKEN", "VITEHUB_WORKSPACE_GITHUB_TOKEN", "GITHUB_TOKEN", "GH_TOKEN");
|
|
169
|
-
}
|
|
170
|
-
async function requestGitHubJson(repository, token, path, init) {
|
|
171
|
-
const response = await requestGitHub(`https://api.github.com${path}`, {
|
|
172
|
-
...init,
|
|
173
|
-
headers: {
|
|
174
|
-
accept: "application/vnd.github+json",
|
|
175
|
-
authorization: `Bearer ${token}`,
|
|
176
|
-
"content-type": "application/json",
|
|
177
|
-
"user-agent": "vitehub-workspace",
|
|
178
|
-
"x-github-api-version": "2022-11-28",
|
|
179
|
-
...init?.headers
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
if (!response.ok) throw workspaceError("[vitehub] GitHub workspace request failed.", { cause: new GitHubRequestError(`[vitehub] GitHub workspace request failed for ${repository}: ${response.status} ${response.statusText} ${await response.text().catch(() => "")}`, response.status) });
|
|
183
|
-
return await response.json();
|
|
184
|
-
}
|
|
185
|
-
async function readGitHubRawFile(input) {
|
|
186
|
-
const { owner, repo } = splitGitHubRepository(input.repository, "store");
|
|
187
|
-
const path = input.path.split("/").map(encodeURIComponent).join("/");
|
|
188
|
-
const response = await requestGitHub(`https://raw.githubusercontent.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(input.ref)}/${path}`, { headers: {
|
|
189
|
-
authorization: `Bearer ${input.token}`,
|
|
190
|
-
"user-agent": "vitehub-workspace"
|
|
191
|
-
} });
|
|
192
|
-
if (!response.ok) throw workspaceError("[vitehub] GitHub workspace request failed.", { cause: new GitHubRequestError(`[vitehub] GitHub workspace raw file request failed for ${input.repository}: ${response.status} ${response.statusText}`, response.status) });
|
|
193
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
194
|
-
}
|
|
195
|
-
async function readGitHubArchive(input) {
|
|
196
|
-
const { owner, repo } = splitGitHubRepository(input.repository, "store");
|
|
197
|
-
const response = await requestGitHub(`https://codeload.github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/tar.gz/${encodeURIComponent(input.ref)}`, {
|
|
198
|
-
headers: {
|
|
199
|
-
authorization: `Bearer ${input.token}`,
|
|
200
|
-
"user-agent": "vitehub-workspace"
|
|
201
|
-
},
|
|
202
|
-
signal: input.signal
|
|
203
|
-
});
|
|
204
|
-
if (!response.ok) throw workspaceError("[vitehub] GitHub workspace request failed.", { cause: new GitHubRequestError(`[vitehub] GitHub workspace archive request failed for ${input.repository}: ${response.status} ${response.statusText}`, response.status) });
|
|
205
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
206
|
-
}
|
|
207
|
-
function findGitHubRemoteFiles(tree, root, kind) {
|
|
208
|
-
if (tree.truncated) throw workspaceError(`[vitehub] GitHub workspace ${kind} could not compare the remote tree because GitHub returned a truncated tree.`);
|
|
209
|
-
const files = /* @__PURE__ */ new Map();
|
|
210
|
-
for (const entry of tree.tree) {
|
|
211
|
-
if (entry.type !== "blob" || !entry.sha) continue;
|
|
212
|
-
const path = workspacePathFromGitPath(entry.path, root);
|
|
213
|
-
if (path) files.set(path, entry);
|
|
214
|
-
}
|
|
215
|
-
return files;
|
|
216
|
-
}
|
|
217
|
-
async function readGitHubBranchState(input) {
|
|
218
|
-
const { owner, repo } = splitGitHubRepository(input.repository, input.kind);
|
|
219
|
-
let branchExists = true;
|
|
220
|
-
let ref;
|
|
221
|
-
try {
|
|
222
|
-
ref = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/ref/heads/${input.branch}`);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
if (githubRequestStatus(error) !== 404) throw error;
|
|
225
|
-
const repository = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}`);
|
|
226
|
-
ref = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/ref/heads/${repository.default_branch}`);
|
|
227
|
-
branchExists = false;
|
|
228
|
-
}
|
|
229
|
-
const current = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/commits/${ref.object.sha}`);
|
|
230
|
-
if (input.paths) {
|
|
231
|
-
const entries = await Promise.all(input.paths.map(async (path) => {
|
|
232
|
-
const encodedPath = joinGitPath(input.root, path).split("/").map(encodeURIComponent).join("/");
|
|
233
|
-
try {
|
|
234
|
-
return await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/contents/${encodedPath}?ref=${encodeURIComponent(ref.object.sha)}`, { headers: { accept: "application/vnd.github.object+json" } });
|
|
235
|
-
} catch (error) {
|
|
236
|
-
if (githubRequestStatus(error) === 404) return void 0;
|
|
237
|
-
throw error;
|
|
238
|
-
}
|
|
239
|
-
}));
|
|
240
|
-
return {
|
|
241
|
-
branchExists,
|
|
242
|
-
files: new Map(input.paths.flatMap((path, index) => {
|
|
243
|
-
const entry = entries[index];
|
|
244
|
-
return entry?.type === "file" && entry.sha ? [[path, entry]] : [];
|
|
245
|
-
})),
|
|
246
|
-
refSha: ref.object.sha,
|
|
247
|
-
treeSha: current.tree.sha
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
const tree = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/trees/${current.tree.sha}?recursive=1`);
|
|
251
|
-
return {
|
|
252
|
-
branchExists,
|
|
253
|
-
files: findGitHubRemoteFiles(tree, input.root, input.kind),
|
|
254
|
-
refSha: ref.object.sha,
|
|
255
|
-
treeSha: current.tree.sha
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
async function commitGitHubChanges(input) {
|
|
259
|
-
const kind = input.kind || "store";
|
|
260
|
-
const { owner, repo } = splitGitHubRepository(input.repository, kind);
|
|
261
|
-
const blobs = await Promise.all(input.files.map((file) => file.bytes ? createGitHubBlob({
|
|
262
|
-
bytes: file.bytes,
|
|
263
|
-
kind,
|
|
264
|
-
repository: input.repository,
|
|
265
|
-
token: input.token
|
|
266
|
-
}) : { sha: file.gitSha }));
|
|
267
|
-
const tree = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/trees`, {
|
|
268
|
-
body: JSON.stringify({
|
|
269
|
-
base_tree: input.baseTreeSha,
|
|
270
|
-
tree: [...input.files.map((file, index) => ({
|
|
271
|
-
mode: file.mode || "100644",
|
|
272
|
-
path: file.fullPath,
|
|
273
|
-
sha: blobs[index].sha,
|
|
274
|
-
type: "blob"
|
|
275
|
-
})), ...input.deletePaths.map((path) => ({
|
|
276
|
-
mode: "100644",
|
|
277
|
-
path,
|
|
278
|
-
sha: null,
|
|
279
|
-
type: "blob"
|
|
280
|
-
}))]
|
|
281
|
-
}),
|
|
282
|
-
method: "POST"
|
|
283
|
-
});
|
|
284
|
-
const commit = await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/commits`, {
|
|
285
|
-
body: JSON.stringify({
|
|
286
|
-
message: input.message,
|
|
287
|
-
parents: [input.parentSha],
|
|
288
|
-
tree: tree.sha
|
|
289
|
-
}),
|
|
290
|
-
method: "POST"
|
|
291
|
-
});
|
|
292
|
-
if (input.branchExists) await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/refs/heads/${input.branch}`, {
|
|
293
|
-
body: JSON.stringify({
|
|
294
|
-
force: false,
|
|
295
|
-
sha: commit.sha
|
|
296
|
-
}),
|
|
297
|
-
method: "PATCH"
|
|
298
|
-
});
|
|
299
|
-
else await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/refs`, {
|
|
300
|
-
body: JSON.stringify({
|
|
301
|
-
ref: `refs/heads/${input.branch}`,
|
|
302
|
-
sha: commit.sha
|
|
303
|
-
}),
|
|
304
|
-
method: "POST"
|
|
305
|
-
});
|
|
306
|
-
return {
|
|
307
|
-
commitSha: commit.sha,
|
|
308
|
-
treeSha: tree.sha
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
async function createGitHubBlob(input) {
|
|
312
|
-
const kind = input.kind || "store";
|
|
313
|
-
const { owner, repo } = splitGitHubRepository(input.repository, kind);
|
|
314
|
-
return await requestGitHubJson(input.repository, input.token, `/repos/${owner}/${repo}/git/blobs`, {
|
|
315
|
-
body: JSON.stringify({
|
|
316
|
-
content: toBase64(input.bytes),
|
|
317
|
-
encoding: "base64"
|
|
318
|
-
}),
|
|
319
|
-
method: "POST"
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
async function createGitHubFileUpdate(path, root, content) {
|
|
323
|
-
const bytes = contentToBytes(content);
|
|
324
|
-
return {
|
|
325
|
-
bytes,
|
|
326
|
-
fullPath: joinGitPath(root, path),
|
|
327
|
-
gitSha: await gitBlobSha(bytes)
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
//#endregion
|
|
331
|
-
export { getActiveCloudflareBinding as _, isWorkspaceFileEntry as a, readGitHubArchive as c, requireGitHubOption as d, resolveGitHubBranchOption as f, resolveGitHubTokenOption as g, resolveGitHubRootOption as h, gitBlobSha as i, readGitHubBranchState as l, resolveGitHubRepositoryOption as m, createGitHubBlob as n, joinGitPath as o, resolveGitHubOption as p, createGitHubFileUpdate as r, processEnv as s, commitGitHubChanges as t, readGitHubRawFile as u, setActiveCloudflareEnv as v };
|
package/dist/state-tYcRWEh2.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { $t as WorkspaceStore, O as WorkspaceAssetsRegistry, o as GitHubWorkspaceStoreOptions, t as CloudflareArtifactsWorkspaceStoreOptions, v as ResolvedWorkspaceModuleOptions, w as VercelBlobWorkspaceStoreOptions } from "./types-CYuwjJ4V.js";
|
|
2
|
-
import { t as WorkspaceRegistry } from "./registry-Uj6IVxes.js";
|
|
3
|
-
|
|
4
|
-
//#region ../internal/src/runtime/cloudflare-env.d.ts
|
|
5
|
-
type CloudflareWorkerEnv = Record<string, unknown>;
|
|
6
|
-
declare function setActiveCloudflareEnv(env: CloudflareWorkerEnv | undefined): void;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/core/workspace-cache.d.ts
|
|
9
|
-
declare function resetWorkspaceStoreCache(): void;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/runtime/hosted-store-loader.d.ts
|
|
12
|
-
type HostedWorkspaceStoreOptions = CloudflareArtifactsWorkspaceStoreOptions | GitHubWorkspaceStoreOptions | VercelBlobWorkspaceStoreOptions;
|
|
13
|
-
type WorkspaceHostedStoreLoader = (options: HostedWorkspaceStoreOptions, workspaceName: string) => WorkspaceStore;
|
|
14
|
-
declare function setWorkspaceHostedStoreLoader(loader: WorkspaceHostedStoreLoader | undefined): void;
|
|
15
|
-
declare function getWorkspaceHostedStoreLoader(): WorkspaceHostedStoreLoader | undefined;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/runtime/config.d.ts
|
|
18
|
-
declare function setWorkspaceRuntimeConfig(config: false | ResolvedWorkspaceModuleOptions): void;
|
|
19
|
-
declare function getWorkspaceRuntimeConfig(): false | ResolvedWorkspaceModuleOptions;
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/runtime/state.d.ts
|
|
22
|
-
declare function invalidateWorkspaceStore(name: string): Promise<void>;
|
|
23
|
-
declare function setWorkspaceRuntimeRegistry(registry: WorkspaceRegistry): void;
|
|
24
|
-
declare function setWorkspaceRuntimeAssetsRegistry(registry: WorkspaceAssetsRegistry): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { setWorkspaceRuntimeConfig as a, getWorkspaceHostedStoreLoader as c, setActiveCloudflareEnv as d, getWorkspaceRuntimeConfig as i, setWorkspaceHostedStoreLoader as l, setWorkspaceRuntimeAssetsRegistry as n, HostedWorkspaceStoreOptions as o, setWorkspaceRuntimeRegistry as r, WorkspaceHostedStoreLoader as s, invalidateWorkspaceStore as t, resetWorkspaceStoreCache as u };
|