resuxjs 0.2.32 → 0.2.34
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 +21 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +264 -87
- package/dist/cli.js.map +1 -1
- package/dist/compiler/index.js +5 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/create-bin.d.ts +2 -0
- package/dist/create-bin.js +4 -0
- package/dist/create-bin.js.map +1 -0
- package/dist/create.d.ts +0 -1
- package/dist/create.js +0 -1
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +2 -0
- package/dist/deploy/cloudflare.js +29 -0
- package/dist/deploy/cloudflare.js.map +1 -0
- package/dist/deploy/common.d.ts +17 -0
- package/dist/deploy/common.js +202 -0
- package/dist/deploy/common.js.map +1 -0
- package/dist/deploy/index.d.ts +3 -0
- package/dist/deploy/index.js +134 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/deploy/netlify.d.ts +2 -0
- package/dist/deploy/netlify.js +44 -0
- package/dist/deploy/netlify.js.map +1 -0
- package/dist/deploy/node.d.ts +2 -0
- package/dist/deploy/node.js +24 -0
- package/dist/deploy/node.js.map +1 -0
- package/dist/deploy/static.d.ts +2 -0
- package/dist/deploy/static.js +19 -0
- package/dist/deploy/static.js.map +1 -0
- package/dist/deploy/types.d.ts +34 -0
- package/dist/deploy/types.js +2 -0
- package/dist/deploy/types.js.map +1 -0
- package/dist/deploy/vercel.d.ts +2 -3
- package/dist/deploy/vercel.js +107 -104
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/globals.d.ts +3 -2
- package/dist/runtime/index.d.ts +43 -1
- package/dist/runtime/index.js +1372 -151
- package/dist/runtime/index.js.map +1 -1
- package/package.json +5 -4
- package/templates/default/resux.config.ts +3 -0
package/dist/deploy/vercel.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { cp, lstat, mkdir, readdir,
|
|
2
|
+
import { cp, lstat, mkdir, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { assertRuntimeClientAsset, ensureResuxClientAssets, ensureResuxServerPayload, pathExists, readJsonRecord, writeJson, } from "./common.js";
|
|
4
5
|
const SUPPORTED_NODE_VERSIONS = [18, 20, 22];
|
|
5
|
-
function isRecord(value) {
|
|
6
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
-
}
|
|
8
|
-
async function pathExists(file) {
|
|
9
|
-
try {
|
|
10
|
-
await stat(file);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
6
|
function parseMajorNodeVersion(version) {
|
|
18
7
|
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
19
8
|
return Number.isNaN(major) ? 22 : major;
|
|
20
9
|
}
|
|
10
|
+
function isRecord(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
}
|
|
21
13
|
export function resolveVercelNodeRuntime(nodeVersion = process.versions.node) {
|
|
22
14
|
const systemNodeVersion = parseMajorNodeVersion(nodeVersion);
|
|
23
15
|
const runtimeVersion = SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion)
|
|
@@ -53,18 +45,49 @@ function normalizeBuildOutputConfig(value) {
|
|
|
53
45
|
}
|
|
54
46
|
return value;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return null;
|
|
48
|
+
function isHeaderOnlyRoute(route) {
|
|
49
|
+
if (!isRecord(route)) {
|
|
50
|
+
return false;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
return (typeof route.src === "string"
|
|
53
|
+
&& isRecord(route.headers)
|
|
54
|
+
&& route.continue !== true
|
|
55
|
+
&& route.dest === undefined
|
|
56
|
+
&& route.handle === undefined
|
|
57
|
+
&& route.status === undefined
|
|
58
|
+
&& route.check === undefined
|
|
59
|
+
&& route.middlewarePath === undefined);
|
|
60
|
+
}
|
|
61
|
+
function normalizeRoute(route) {
|
|
62
|
+
if (isHeaderOnlyRoute(route)) {
|
|
63
|
+
return { ...route, continue: true };
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
return route;
|
|
66
|
+
}
|
|
67
|
+
function isRunningInsideVercelContainer(appRoot) {
|
|
68
|
+
const normalizedRoot = appRoot.replace(/\\/g, "/");
|
|
69
|
+
if (normalizedRoot.startsWith("/vercel/path")) {
|
|
70
|
+
return true;
|
|
67
71
|
}
|
|
72
|
+
return (existsSync("/vercel")
|
|
73
|
+
|| existsSync("/vercel/path")
|
|
74
|
+
|| existsSync("/vercel/path0")
|
|
75
|
+
|| existsSync("/vercel/output"));
|
|
76
|
+
}
|
|
77
|
+
async function detect(context) {
|
|
78
|
+
if (isRunningInsideVercelContainer(context.appRoot)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (context.env.NOW_BUILDER || context.env.VERCEL || context.env.VERCEL_ENV) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const vercelConfigPath = path.join(context.appRoot, "vercel.json");
|
|
85
|
+
const config = (await readJsonRecord(vercelConfigPath));
|
|
86
|
+
if (!config) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const framework = typeof config.framework === "string" ? config.framework.trim().toLowerCase() : "";
|
|
90
|
+
return framework === "nitro";
|
|
68
91
|
}
|
|
69
92
|
async function materializeLinkedFunctions(functionsDir) {
|
|
70
93
|
const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);
|
|
@@ -84,110 +107,81 @@ async function materializeLinkedFunctions(functionsDir) {
|
|
|
84
107
|
await rm(functionPath, { recursive: true, force: true });
|
|
85
108
|
await cp(resolvedTarget, functionPath, {
|
|
86
109
|
recursive: true,
|
|
87
|
-
force: true
|
|
110
|
+
force: true,
|
|
88
111
|
});
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
|
-
async function
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const framework = typeof config.framework === "string" ? config.framework.trim().toLowerCase() : "";
|
|
98
|
-
return framework === "nitro";
|
|
99
|
-
}
|
|
100
|
-
function isRunningInsideVercelContainer(appRoot) {
|
|
101
|
-
const normalizedRoot = appRoot.replace(/\\/g, "/");
|
|
102
|
-
if (normalizedRoot.startsWith("/vercel/path")) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
return (existsSync("/vercel")
|
|
106
|
-
|| existsSync("/vercel/path")
|
|
107
|
-
|| existsSync("/vercel/path0")
|
|
108
|
-
|| existsSync("/vercel/output"));
|
|
109
|
-
}
|
|
110
|
-
export async function shouldPreferVercelPreset(appRoot, _env) {
|
|
111
|
-
if (isRunningInsideVercelContainer(appRoot)) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
return isNitroVercelProject(appRoot);
|
|
115
|
-
}
|
|
116
|
-
export async function patchNitroPublicClientAssets(appRoot) {
|
|
117
|
-
const resuxClientDir = path.join(appRoot, ".resux", "client");
|
|
118
|
-
if (!(await pathExists(resuxClientDir))) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const publicTargets = [
|
|
122
|
-
{
|
|
123
|
-
root: path.join(appRoot, ".output"),
|
|
124
|
-
target: path.join(appRoot, ".output", "public", "__resux")
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
root: path.join(appRoot, ".vercel", "output"),
|
|
128
|
-
target: path.join(appRoot, ".vercel", "output", "static", "__resux")
|
|
114
|
+
async function listFunctionDirectories(functionsDir) {
|
|
115
|
+
const entries = await readdir(functionsDir, { withFileTypes: true }).catch(() => []);
|
|
116
|
+
const functionNames = [];
|
|
117
|
+
for (const entry of entries) {
|
|
118
|
+
if (!entry.name.endsWith(".func")) {
|
|
119
|
+
continue;
|
|
129
120
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
const functionPath = path.join(functionsDir, entry.name);
|
|
122
|
+
if (entry.isDirectory()) {
|
|
123
|
+
functionNames.push(entry.name);
|
|
133
124
|
continue;
|
|
134
125
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
if (!entry.isSymbolicLink()) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const linkedStats = await stat(functionPath).catch(() => null);
|
|
130
|
+
if (linkedStats?.isDirectory()) {
|
|
131
|
+
functionNames.push(entry.name);
|
|
132
|
+
}
|
|
140
133
|
}
|
|
134
|
+
return functionNames;
|
|
141
135
|
}
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
async function postBuild(context) {
|
|
137
|
+
await ensureResuxClientAssets(context.appRoot, [
|
|
138
|
+
{
|
|
139
|
+
root: path.join(context.appRoot, ".output"),
|
|
140
|
+
target: path.join(context.appRoot, ".output", "public", "__resux"),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
root: path.join(context.appRoot, ".vercel", "output"),
|
|
144
|
+
target: path.join(context.appRoot, ".vercel", "output", "static", "__resux"),
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
await assertRuntimeClientAsset(path.join(context.appRoot, ".vercel", "output", "static"));
|
|
148
|
+
const outputDir = path.join(context.appRoot, ".vercel", "output");
|
|
144
149
|
const functionsDir = path.join(outputDir, "functions");
|
|
145
150
|
await materializeLinkedFunctions(functionsDir);
|
|
146
|
-
const functionNames = await
|
|
147
|
-
.then((entries) => entries
|
|
148
|
-
.filter((entry) => entry.isDirectory() && entry.name.endsWith(".func"))
|
|
149
|
-
.map((entry) => entry.name))
|
|
150
|
-
.catch(() => []);
|
|
151
|
+
const functionNames = await listFunctionDirectories(functionsDir);
|
|
151
152
|
if (!functionNames.length) {
|
|
152
|
-
|
|
153
|
+
throw new Error("Resux vercel deployment output is missing function directories under .vercel/output/functions.");
|
|
154
|
+
}
|
|
155
|
+
const functionRoots = functionNames.map((functionName) => path.join(functionsDir, functionName));
|
|
156
|
+
await ensureResuxServerPayload(context.appRoot, functionRoots.map((root) => path.join(root, ".resux", "server")));
|
|
157
|
+
await ensureResuxClientAssets(context.appRoot, functionRoots.map((root) => ({
|
|
158
|
+
root,
|
|
159
|
+
target: path.join(root, ".resux", "client"),
|
|
160
|
+
})));
|
|
161
|
+
for (const functionRoot of functionRoots) {
|
|
162
|
+
const manifestPath = path.join(functionRoot, ".resux", "server", "manifest.mjs");
|
|
163
|
+
if (!(await pathExists(manifestPath))) {
|
|
164
|
+
throw new Error(`Resux vercel deployment output is missing ${manifestPath}.`);
|
|
165
|
+
}
|
|
153
166
|
}
|
|
154
|
-
const resuxServerDir = path.join(appRoot, ".resux", "server");
|
|
155
|
-
const resuxClientDir = path.join(appRoot, ".resux", "client");
|
|
156
|
-
const hasResuxServer = await pathExists(resuxServerDir);
|
|
157
|
-
const hasResuxClient = await pathExists(resuxClientDir);
|
|
158
167
|
const defaultFunctionConfig = {
|
|
159
168
|
runtime: resolveVercelNodeRuntime(),
|
|
160
169
|
handler: "index.mjs",
|
|
161
170
|
launcherType: "Nodejs",
|
|
162
171
|
shouldAddHelpers: false,
|
|
163
|
-
supportsResponseStreaming: true
|
|
172
|
+
supportsResponseStreaming: true,
|
|
164
173
|
};
|
|
165
|
-
for (const
|
|
166
|
-
const
|
|
167
|
-
if (hasResuxServer) {
|
|
168
|
-
await cp(resuxServerDir, path.join(functionDir, ".resux", "server"), {
|
|
169
|
-
recursive: true,
|
|
170
|
-
force: true
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
if (hasResuxClient) {
|
|
174
|
-
await cp(resuxClientDir, path.join(functionDir, ".resux", "client"), {
|
|
175
|
-
recursive: true,
|
|
176
|
-
force: true
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
const functionConfigPath = path.join(functionDir, ".vc-config.json");
|
|
174
|
+
for (const functionRoot of functionRoots) {
|
|
175
|
+
const functionConfigPath = path.join(functionRoot, ".vc-config.json");
|
|
180
176
|
if (!(await pathExists(functionConfigPath))) {
|
|
181
177
|
await writeFile(functionConfigPath, JSON.stringify(defaultFunctionConfig, null, 2), "utf8");
|
|
182
178
|
}
|
|
183
179
|
}
|
|
184
180
|
const outputConfigPath = path.join(outputDir, "config.json");
|
|
185
|
-
const parsedOutputConfig = await
|
|
186
|
-
|
|
187
|
-
.catch(() => ({}));
|
|
188
|
-
const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig);
|
|
181
|
+
const parsedOutputConfig = await readJsonRecord(outputConfigPath);
|
|
182
|
+
const safeOutputConfig = normalizeBuildOutputConfig(parsedOutputConfig ?? {});
|
|
189
183
|
const routes = Array.isArray(safeOutputConfig.routes)
|
|
190
|
-
?
|
|
184
|
+
? safeOutputConfig.routes.map(normalizeRoute)
|
|
191
185
|
: [];
|
|
192
186
|
const hasFilesystemRoute = routes.some((route) => route?.handle === "filesystem");
|
|
193
187
|
if (!hasFilesystemRoute) {
|
|
@@ -205,8 +199,17 @@ export async function patchVercelBuildOutput(appRoot) {
|
|
|
205
199
|
const outputConfig = {
|
|
206
200
|
...safeOutputConfig,
|
|
207
201
|
version: 3,
|
|
208
|
-
routes
|
|
202
|
+
routes,
|
|
209
203
|
};
|
|
210
|
-
await
|
|
204
|
+
await mkdir(path.dirname(outputConfigPath), { recursive: true });
|
|
205
|
+
await writeJson(outputConfigPath, outputConfig);
|
|
211
206
|
}
|
|
207
|
+
export const vercelDeployModule = {
|
|
208
|
+
target: "vercel",
|
|
209
|
+
presetAliases: ["vercel", "vercel-edge"],
|
|
210
|
+
outputLabel: ".vercel/output",
|
|
211
|
+
detect,
|
|
212
|
+
inferPreset: () => "vercel",
|
|
213
|
+
postBuild,
|
|
214
|
+
};
|
|
212
215
|
//# sourceMappingURL=vercel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../src/deploy/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../src/deploy/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,aAAa,CAAC;AAOrB,MAAM,uBAAuB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAU,CAAC;AAatD,SAAS,qBAAqB,CAAC,OAAe;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,M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AAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IACtF,MAAM,eAAe,GAAG,oBAAoB;QAC1C,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,6BAA6B,CAAC,KAAK,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAC;QAC1F,CAAC,CAAC,KAAK,CAAC;IACV,IAAI,oBAAoB,IAAI,CAAC,gBAAgB,IAAI,CAAC,eAAe,EAAE,CAAC;QAClE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,oBAAoB,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,YAAY,GAAsB;QACtC,GAAG,gBAAgB;QACnB,OAAO,EAAE,CAAC;QACV,MAAM;KACP,CAAC;IACF,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,MAAM,SAAS,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAuB;IACpD,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;IACxC,WAAW,EAAE,gBAAgB;IAC7B,MAAM;IACN,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ;IAC3B,SAAS;CACV,CAAC"}
|
package/dist/globals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncDataResource, AsyncDataHandlerContext, ComputedRef, EventHandler, EventHandlerEvent, HeadEntry, MaybeRef, ResuxAppLike, ResuxModule, PageMeta, Ref, RouteContext, RouteMiddlewareResult, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, RuntimeConfig, SeoMetaInput, ServerMiddleware, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from "./runtime/index.js";
|
|
1
|
+
import type { AsyncDataResource, AsyncDataHandlerContext, ComputedRef, EventHandler, EventHandlerEvent, HeadEntry, MaybeRef, ResuxAppLike, ResuxConfigInput, ResuxModule, PageMeta, Ref, RouteContext, RouteMiddlewareResult, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, RuntimeConfig, ResuxImageBuilder, SeoMetaInput, ServerMiddleware, WatchCallback, WatchOptions, WatchSource, WatchStopHandle } from "./runtime/index.js";
|
|
2
2
|
declare global {
|
|
3
3
|
const useState: <T = unknown>(key: string, factory?: () => T) => Ref<T>;
|
|
4
4
|
const useAsyncData: <T = unknown>(key: string, handler?: (context: AsyncDataHandlerContext) => T | Promise<T>) => AsyncDataResource<T>;
|
|
@@ -29,12 +29,13 @@ declare global {
|
|
|
29
29
|
const useSeoMeta: (input: SeoMetaInput) => void;
|
|
30
30
|
const useRuntimeConfig: () => RuntimeConfig;
|
|
31
31
|
const useResuxApp: () => ResuxAppLike;
|
|
32
|
+
const useResuxImage: () => ResuxImageBuilder;
|
|
32
33
|
const apiURL: (path: string) => string;
|
|
33
34
|
const useFetch: <T = unknown>(url: string, init?: RequestInit) => Promise<Ref<T>>;
|
|
34
35
|
const $fetch: <T = unknown>(url: string, init?: RequestInit) => Promise<T>;
|
|
35
36
|
const onMounted: (callback: () => unknown | Promise<unknown>) => void;
|
|
36
37
|
const definePageMeta: (_meta: PageMeta) => void;
|
|
37
|
-
const defineResuxConfig: <T extends
|
|
38
|
+
const defineResuxConfig: <T extends ResuxConfigInput>(config: T) => T;
|
|
38
39
|
const defineResuxPlugin: (plugin: ResuxPlugin) => ResuxPlugin;
|
|
39
40
|
const defineResuxRouteMiddleware: (middleware: ResuxRouteMiddleware) => ResuxRouteMiddleware;
|
|
40
41
|
const defineEventHandler: (handler: EventHandler) => EventHandler;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -93,6 +93,36 @@ export interface RuntimeConfig {
|
|
|
93
93
|
public: Record<string, JsonValue>;
|
|
94
94
|
[key: string]: unknown;
|
|
95
95
|
}
|
|
96
|
+
export type ResuxImageFit = "cover" | "contain" | "fill" | "inside" | "outside";
|
|
97
|
+
export interface ResuxImageModifiers {
|
|
98
|
+
width?: number;
|
|
99
|
+
height?: number;
|
|
100
|
+
quality?: number;
|
|
101
|
+
format?: string;
|
|
102
|
+
fit?: ResuxImageFit;
|
|
103
|
+
[key: string]: string | number | boolean | undefined;
|
|
104
|
+
}
|
|
105
|
+
export interface ResuxImageProviderConfig {
|
|
106
|
+
baseURL?: string;
|
|
107
|
+
modifiers?: ResuxImageModifiers;
|
|
108
|
+
}
|
|
109
|
+
export interface ResuxImageConfig {
|
|
110
|
+
provider?: string;
|
|
111
|
+
quality?: number;
|
|
112
|
+
format?: string;
|
|
113
|
+
densities?: number[];
|
|
114
|
+
providers?: Record<string, ResuxImageProviderConfig>;
|
|
115
|
+
}
|
|
116
|
+
export interface UseResuxImageOptions {
|
|
117
|
+
provider?: string;
|
|
118
|
+
modifiers?: ResuxImageModifiers;
|
|
119
|
+
width?: number;
|
|
120
|
+
height?: number;
|
|
121
|
+
quality?: number;
|
|
122
|
+
fit?: ResuxImageFit;
|
|
123
|
+
format?: string;
|
|
124
|
+
}
|
|
125
|
+
export type ResuxImageBuilder = (src: string, options?: UseResuxImageOptions) => string;
|
|
96
126
|
export interface ResuxAppInjections {
|
|
97
127
|
}
|
|
98
128
|
export type ResuxSupportMode = "all" | "server" | "client";
|
|
@@ -133,6 +163,14 @@ export type ResuxModule<TOptions = Record<string, unknown>> = ((options: TOption
|
|
|
133
163
|
defaults?: TOptions;
|
|
134
164
|
setup: (options: TOptions, context: ResuxModuleContext) => unknown | Promise<unknown>;
|
|
135
165
|
};
|
|
166
|
+
export type ResuxDeployTarget = "auto" | "node" | "vercel" | "netlify" | "cloudflare" | "static";
|
|
167
|
+
export interface ResuxDeployOptions {
|
|
168
|
+
target?: ResuxDeployTarget;
|
|
169
|
+
nitroPreset?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface ResuxConfigInput extends Record<string, unknown> {
|
|
172
|
+
deploy?: ResuxDeployOptions;
|
|
173
|
+
}
|
|
136
174
|
export type RouteMiddlewareResult = void | string | false | {
|
|
137
175
|
redirect: string | {
|
|
138
176
|
to: string;
|
|
@@ -231,6 +269,7 @@ export interface SetupContext {
|
|
|
231
269
|
useRuntimeConfig(): RuntimeConfig;
|
|
232
270
|
useResuxApp(): ResuxAppLike;
|
|
233
271
|
apiURL(path: string): string;
|
|
272
|
+
useResuxImage(): ResuxImageBuilder;
|
|
234
273
|
useFetch<T>(url: string, init?: RequestInit): Promise<Ref<T>>;
|
|
235
274
|
$fetch<T>(url: string, init?: RequestInit): Promise<T>;
|
|
236
275
|
onMounted(callback: () => unknown | Promise<unknown>): void;
|
|
@@ -305,20 +344,23 @@ interface RenderTemplateContext {
|
|
|
305
344
|
moduleId: string;
|
|
306
345
|
styleScopeId?: string;
|
|
307
346
|
route: RouteContext;
|
|
347
|
+
runtimeConfig: RuntimeConfig;
|
|
308
348
|
components: Record<string, ComponentDefinition>;
|
|
309
349
|
layouts: Record<string, ComponentDefinition>;
|
|
310
350
|
pageMeta: PageMeta;
|
|
351
|
+
addHeadEntry?: (entry: HeadEntry) => void;
|
|
311
352
|
renderPage?: () => Promise<string>;
|
|
312
353
|
renderSlot?: () => Promise<string>;
|
|
313
354
|
renderLayout?: (name: string | false | undefined, slot: () => Promise<string>) => Promise<string>;
|
|
314
355
|
}
|
|
315
356
|
type ComponentProps = Record<string, unknown>;
|
|
316
357
|
export declare function defineComponent(definition: ComponentDefinition): ComponentDefinition;
|
|
317
|
-
export declare function defineResuxConfig<T extends
|
|
358
|
+
export declare function defineResuxConfig<T extends ResuxConfigInput>(config: T): T;
|
|
318
359
|
export declare function defineResuxModule<TOptions = Record<string, unknown>>(module: ResuxModule<TOptions>): ResuxModule<TOptions>;
|
|
319
360
|
export declare function defineResuxPlugin(plugin: ResuxPlugin): ResuxPlugin;
|
|
320
361
|
export declare function defineResuxRouteMiddleware(middleware: ResuxRouteMiddleware): ResuxRouteMiddleware;
|
|
321
362
|
export declare function useResuxApp(): ResuxAppLike;
|
|
363
|
+
export declare function useResuxImage(): ResuxImageBuilder;
|
|
322
364
|
export declare function navigateTo(to: string, options?: {
|
|
323
365
|
statusCode?: number;
|
|
324
366
|
}): RouteMiddlewareResult;
|