@vite-hub/queue 0.0.4 → 0.1.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 +41 -23
- package/dist/client-CIc3jsj2.js +114 -0
- package/dist/cloudflare-client-COzQ8fHk.js +147 -0
- package/dist/{cloudflare-resource-name-R8zYQiZb.js → cloudflare-resource-name-CCuLDvSP.js} +3 -2
- package/dist/{cloudflare-vite-BlQfDVZD.js → cloudflare-vite-BCuJOXcT.js} +23 -9
- package/dist/{cloudflare-vite-nFPor46-.d.ts → cloudflare-vite-CjdP5yBN.d.ts} +9 -4
- package/dist/config-BINujLv4.js +74 -0
- package/dist/enqueue-CnQ0QR3O.js +22 -0
- package/dist/error-diagnostics-A_8Kp-48.js +116 -0
- package/dist/error-diagnostics-qzRF6IVB.js +109 -0
- package/dist/errors-DIFaM9tW.js +42 -0
- package/dist/handler-response-CBwIkmTS.js +56 -0
- package/dist/index.d.ts +32 -70
- package/dist/index.js +9 -8
- package/dist/inspect-PeuckaC3.js +30 -0
- package/dist/internal/runtime/cloudflare-client.d.ts +3 -5
- package/dist/internal/runtime/cloudflare-client.js +1 -1
- package/dist/internal/runtime/cloudflare-vite.d.ts +1 -1
- package/dist/internal/runtime/cloudflare-vite.js +1 -1
- package/dist/internal/runtime/state.d.ts +16 -15
- package/dist/internal/runtime/state.js +2 -2
- package/dist/internal/runtime/vercel-client.d.ts +3 -5
- package/dist/internal/runtime/vercel-client.js +93 -62
- package/dist/nuxt.d.ts +27 -7
- package/dist/nuxt.js +6 -2
- package/dist/object-B1NW521B.js +7 -0
- package/dist/operations-Cnjbz8kk.js +63 -0
- package/dist/operations-tNUdj3G4.d.ts +212 -0
- package/dist/operations.d.ts +32 -0
- package/dist/operations.js +1195 -0
- package/dist/runtime/hosted.d.ts +4 -6
- package/dist/runtime/hosted.js +30 -8
- package/dist/state-G9s378-e.js +184 -0
- package/dist/{types-CwvoMATy.d.ts → types-1GRMYES1.d.ts} +35 -24
- package/dist/vercel-region-cjskrOKl.js +122 -0
- package/dist/vite-ChWLzOVu.js +1512 -0
- package/dist/vite.d.ts +334 -34
- package/dist/vite.js +2 -2
- package/package.json +68 -25
- package/dist/_app-D29AwUdD.d.ts +0 -11
- package/dist/app-BZpq2cwC.js +0 -10
- package/dist/client-DG9fweET.js +0 -93
- package/dist/cloudflare-client-w5vphoNn.js +0 -99
- package/dist/config-CNgAeIND.js +0 -53
- package/dist/delivery-error-glgYWC9g.js +0 -45
- package/dist/errors-CjuG_qr-.js +0 -108
- package/dist/internal/runtime/vercel-vite.d.ts +0 -20
- package/dist/internal/runtime/vercel-vite.js +0 -49
- package/dist/state-Cno9O7YS.js +0 -110
- package/dist/vercel-runtime-package-copy-CEToJtCu.js +0 -116
- package/dist/vite-DOuoen0w.js +0 -4414
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { a as createDefaultVercelOutputRoot } from "./vite-DOuoen0w.js";
|
|
2
|
-
import { access, cp, mkdir, mkdtemp, readFile, realpath, rename, rm } from "node:fs/promises";
|
|
3
|
-
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
//#region ../internal/src/build/vercel-runtime-package-copy.ts
|
|
5
|
-
async function copyVercelFunctionRuntimePackageDirectories(options) {
|
|
6
|
-
if (!options.packages.length) return;
|
|
7
|
-
const functionDir = resolve(options.outputRoot ?? createDefaultVercelOutputRoot(options.rootDir), "functions", options.serverFunctionName ?? "__server.func");
|
|
8
|
-
const outputNodeModules = resolve(functionDir, "node_modules");
|
|
9
|
-
const stagingRoot = await mkdtemp(resolve(functionDir, ".vitehub-runtime-package-directories-"));
|
|
10
|
-
const stagedNodeModules = resolve(stagingRoot, "node_modules");
|
|
11
|
-
const previousNodeModules = resolve(stagingRoot, "previous-node_modules");
|
|
12
|
-
let movedPreviousOutput = false;
|
|
13
|
-
let installedReplacement = false;
|
|
14
|
-
let publicationSucceeded = false;
|
|
15
|
-
let restorationSucceeded = false;
|
|
16
|
-
try {
|
|
17
|
-
try {
|
|
18
|
-
await cp(outputNodeModules, stagedNodeModules, { recursive: true });
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (error.code !== "ENOENT") throw error;
|
|
21
|
-
}
|
|
22
|
-
await mkdir(stagedNodeModules, { recursive: true });
|
|
23
|
-
const copied = /* @__PURE__ */ new Map();
|
|
24
|
-
const selected = /* @__PURE__ */ new Map();
|
|
25
|
-
for (const runtimePackage of options.packages) try {
|
|
26
|
-
selected.set(runtimePackage.name, await realpath(await resolvePackageJson(runtimePackage.name, dirname(runtimePackage.resolveFrom ?? join(options.rootDir, "package.json")))));
|
|
27
|
-
} catch (error) {
|
|
28
|
-
if (!runtimePackage.optional || error.code !== "ENOENT") throw error;
|
|
29
|
-
}
|
|
30
|
-
for (const runtimePackage of options.packages) await copyPackageDirectory(runtimePackage.name, runtimePackage.resolveFrom ?? join(options.rootDir, "package.json"), stagedNodeModules, copied, selected, runtimePackage.optional);
|
|
31
|
-
options.signal?.throwIfAborted();
|
|
32
|
-
try {
|
|
33
|
-
await rename(outputNodeModules, previousNodeModules);
|
|
34
|
-
movedPreviousOutput = true;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error.code !== "ENOENT") throw error;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
options.signal?.throwIfAborted();
|
|
40
|
-
await rename(stagedNodeModules, outputNodeModules);
|
|
41
|
-
installedReplacement = true;
|
|
42
|
-
options.signal?.throwIfAborted();
|
|
43
|
-
publicationSucceeded = true;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
if (installedReplacement) await rm(outputNodeModules, {
|
|
46
|
-
force: true,
|
|
47
|
-
recursive: true
|
|
48
|
-
});
|
|
49
|
-
if (movedPreviousOutput) {
|
|
50
|
-
await rename(previousNodeModules, outputNodeModules);
|
|
51
|
-
restorationSucceeded = true;
|
|
52
|
-
}
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
} finally {
|
|
56
|
-
if (!movedPreviousOutput || publicationSucceeded || restorationSucceeded) await rm(stagingRoot, {
|
|
57
|
-
force: true,
|
|
58
|
-
recursive: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async function copyPackageDirectory(name, resolveFrom, outputNodeModules, copied, selected, optional = false, conflictNodeModules) {
|
|
63
|
-
let resolvedPackageJsonPath;
|
|
64
|
-
try {
|
|
65
|
-
resolvedPackageJsonPath = await resolvePackageJson(name, dirname(resolveFrom));
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if (optional && error.code === "ENOENT") return;
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
const packageJsonPath = await realpath(resolvedPackageJsonPath);
|
|
71
|
-
const packageDir = dirname(packageJsonPath);
|
|
72
|
-
let targetDir = join(outputNodeModules, ...name.split("/"));
|
|
73
|
-
const selectedPackage = selected.get(name);
|
|
74
|
-
const existingPackage = copied.get(targetDir);
|
|
75
|
-
if (selectedPackage && selectedPackage !== packageJsonPath || existingPackage && existingPackage !== packageJsonPath) {
|
|
76
|
-
if (!conflictNodeModules) return;
|
|
77
|
-
targetDir = join(conflictNodeModules, ...name.split("/"));
|
|
78
|
-
}
|
|
79
|
-
if (copied.get(targetDir) === packageJsonPath) return;
|
|
80
|
-
copied.set(targetDir, packageJsonPath);
|
|
81
|
-
await rm(targetDir, {
|
|
82
|
-
force: true,
|
|
83
|
-
recursive: true
|
|
84
|
-
});
|
|
85
|
-
await mkdir(dirname(targetDir), { recursive: true });
|
|
86
|
-
await cp(packageDir, targetDir, {
|
|
87
|
-
dereference: true,
|
|
88
|
-
filter: (source) => !relative(packageDir, source).split(sep).includes("node_modules"),
|
|
89
|
-
recursive: true
|
|
90
|
-
});
|
|
91
|
-
const packageJson = parsePackageJson(JSON.parse(await readFile(packageJsonPath, "utf8")), packageJsonPath);
|
|
92
|
-
const dependencies = packageJson.dependencies === void 0 ? {} : parsePackageJson(packageJson.dependencies, `${packageJsonPath} dependencies`);
|
|
93
|
-
for (const dependency of Object.keys(dependencies)) await copyPackageDirectory(dependency, packageJsonPath, outputNodeModules, copied, selected, false, join(targetDir, "node_modules"));
|
|
94
|
-
}
|
|
95
|
-
async function resolvePackageJson(name, fromDir) {
|
|
96
|
-
let current = await realpath(fromDir).catch(() => fromDir);
|
|
97
|
-
while (current !== dirname(current)) {
|
|
98
|
-
const candidate = join(current, "node_modules", ...name.split("/"), "package.json");
|
|
99
|
-
try {
|
|
100
|
-
await access(candidate);
|
|
101
|
-
return candidate;
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (error.code !== "ENOENT") throw error;
|
|
104
|
-
}
|
|
105
|
-
current = dirname(current);
|
|
106
|
-
}
|
|
107
|
-
const error = /* @__PURE__ */ new Error(`Could not resolve package.json for ${name}.`);
|
|
108
|
-
error.code = "ENOENT";
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
function parsePackageJson(value, path) {
|
|
112
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Expected ${path} to contain a JSON object.`);
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
export { copyVercelFunctionRuntimePackageDirectories };
|