@ripple-ts/adapter-vercel 0.2.214

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.
@@ -0,0 +1,228 @@
1
+ import type {
2
+ AdapterCoreOptions,
3
+ NextMiddleware,
4
+ RuntimePrimitives,
5
+ ServeFunction,
6
+ ServeStaticOptions as BaseServeStaticOptions,
7
+ ServeStaticDirectoryOptions as BaseServeStaticDirectoryOptions,
8
+ } from '@ripple-ts/adapter';
9
+
10
+ // ============================================================================
11
+ // Re-exports from adapter-node (Vercel serverless runs on Node.js)
12
+ // ============================================================================
13
+
14
+ /**
15
+ * Node.js runtime primitives: SHA-256 hashing and AsyncLocalStorage.
16
+ * Re-exported from @ripple-ts/adapter-node.
17
+ */
18
+ export const runtime: RuntimePrimitives;
19
+
20
+ /**
21
+ * Node.js HTTP server for local development and preview.
22
+ * Re-exported from @ripple-ts/adapter-node.
23
+ */
24
+ export const serve: ServeFunction<
25
+ {
26
+ node_request: import('node:http').IncomingMessage;
27
+ node_response: import('node:http').ServerResponse;
28
+ },
29
+ import('@ripple-ts/adapter-node').ServeOptions,
30
+ import('node:http').Server
31
+ >;
32
+
33
+ // ============================================================================
34
+ // Vercel Build Output API v3 types
35
+ // ============================================================================
36
+
37
+ /**
38
+ * Serverless function configuration for Vercel.
39
+ */
40
+ export interface ServerlessConfig {
41
+ /**
42
+ * Node.js runtime version for the serverless function.
43
+ * @default Auto-detected from the build environment
44
+ */
45
+ runtime?: string;
46
+
47
+ /**
48
+ * Regions to deploy the serverless function to.
49
+ * @see https://vercel.com/docs/concepts/edge-network/regions
50
+ */
51
+ regions?: string[];
52
+
53
+ /**
54
+ * Maximum execution duration (in seconds) for the serverless function.
55
+ */
56
+ maxDuration?: number;
57
+
58
+ /**
59
+ * Memory (in MB) allocated to the serverless function.
60
+ */
61
+ memory?: number;
62
+ }
63
+
64
+ /**
65
+ * Incremental Static Regeneration configuration.
66
+ */
67
+ export interface ISRConfig {
68
+ /**
69
+ * Expiration time (in seconds) before the cached asset is re-generated.
70
+ * Set to `false` for never-expiring ISR.
71
+ */
72
+ expiration: number | false;
73
+
74
+ /**
75
+ * Token that can bypass the cache via `__prerender_bypass=<token>` cookie
76
+ * or `x-prerender-revalidate: <token>` header.
77
+ */
78
+ bypassToken?: string;
79
+
80
+ /**
81
+ * Query string parameters to include in the cache key.
82
+ * Empty array means query values are ignored.
83
+ * Undefined means each unique query is cached independently.
84
+ */
85
+ allowQuery?: string[];
86
+ }
87
+
88
+ /**
89
+ * Vercel Image Optimization configuration.
90
+ * @see https://vercel.com/docs/build-output-api/v3/configuration#images
91
+ */
92
+ export interface ImagesConfig {
93
+ sizes: number[];
94
+ domains: string[];
95
+ remotePatterns?: RemotePattern[];
96
+ minimumCacheTTL?: number;
97
+ formats?: ImageFormat[];
98
+ dangerouslyAllowSVG?: boolean;
99
+ contentSecurityPolicy?: string;
100
+ contentDispositionType?: string;
101
+ }
102
+
103
+ export type ImageFormat = 'image/avif' | 'image/webp';
104
+
105
+ export interface RemotePattern {
106
+ protocol?: 'http' | 'https';
107
+ hostname: string;
108
+ port?: string;
109
+ pathname?: string;
110
+ }
111
+
112
+ /**
113
+ * Custom header definition for Vercel config.
114
+ */
115
+ export interface VercelHeader {
116
+ source: string;
117
+ headers: Array<{ key: string; value: string }>;
118
+ }
119
+
120
+ /**
121
+ * Custom redirect definition for Vercel config.
122
+ */
123
+ export interface VercelRedirect {
124
+ source: string;
125
+ destination: string;
126
+ permanent?: boolean;
127
+ }
128
+
129
+ /**
130
+ * Custom rewrite definition for Vercel config.
131
+ */
132
+ export interface VercelRewrite {
133
+ source: string;
134
+ destination: string;
135
+ }
136
+
137
+ /**
138
+ * A single route entry in the Build Output API v3 config.
139
+ */
140
+ export interface VercelRoute {
141
+ src?: string;
142
+ dest?: string;
143
+ headers?: Record<string, string>;
144
+ status?: number;
145
+ handle?: 'filesystem' | 'miss' | 'rewrite' | 'hit' | 'error';
146
+ continue?: boolean;
147
+ }
148
+
149
+ /**
150
+ * Build Output API v3 config.json structure.
151
+ */
152
+ export interface VercelConfig {
153
+ version: 3;
154
+ routes: VercelRoute[];
155
+ cleanUrls?: boolean;
156
+ trailingSlash?: boolean;
157
+ images?: ImagesConfig;
158
+ }
159
+
160
+ // ============================================================================
161
+ // Adapter options
162
+ // ============================================================================
163
+
164
+ /**
165
+ * Options for the `adapt()` function.
166
+ */
167
+ export interface AdaptOptions {
168
+ /**
169
+ * Build output directory (from `vite build`).
170
+ * Should contain `client/` and `server/entry.js`.
171
+ * @default 'dist'
172
+ */
173
+ outDir?: string;
174
+
175
+ /**
176
+ * Serverless function configuration.
177
+ */
178
+ serverless?: ServerlessConfig;
179
+
180
+ /**
181
+ * Incremental Static Regeneration configuration.
182
+ * Set to `false` to disable ISR.
183
+ * @default false
184
+ */
185
+ isr?: ISRConfig | false;
186
+
187
+ /**
188
+ * Vercel Image Optimization configuration.
189
+ */
190
+ images?: ImagesConfig;
191
+
192
+ /**
193
+ * Custom response headers.
194
+ */
195
+ headers?: VercelHeader[];
196
+
197
+ /**
198
+ * Custom redirects.
199
+ */
200
+ redirects?: VercelRedirect[];
201
+
202
+ /**
203
+ * Additional rewrites (prepended before the catch-all rule).
204
+ */
205
+ rewrites?: VercelRewrite[];
206
+
207
+ /**
208
+ * Remove `.html` extensions from URLs.
209
+ * @default true
210
+ */
211
+ cleanUrls?: boolean;
212
+
213
+ /**
214
+ * Enforce trailing slash behavior.
215
+ */
216
+ trailingSlash?: boolean;
217
+ }
218
+
219
+ /**
220
+ * Generate Vercel Build Output API v3 from a Ripple build.
221
+ *
222
+ * Transforms the standard Ripple build output (`outDir/client` + `outDir/server`)
223
+ * into `.vercel/output/` with static files, a serverless function,
224
+ * and routing configuration.
225
+ *
226
+ * @param options - Adapter configuration options
227
+ */
228
+ export function adapt(options?: AdaptOptions): Promise<void>;