@vistagenic/vista 0.3.2 → 0.3.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/bin/vista.js +79 -109
- package/dist/ai/embeddings.d.ts +11 -11
- package/dist/ai/embeddings.js +71 -71
- package/dist/ai/index.d.ts +10 -10
- package/dist/ai/index.js +26 -26
- package/dist/ai/providers/base.js +85 -85
- package/dist/ai/react/react-server.d.ts +1 -1
- package/dist/ai/react/react-server.js +17 -17
- package/dist/ai/react/use-agent.js +138 -138
- package/dist/auth/core.d.ts +140 -140
- package/dist/auth/core.js +165 -165
- package/dist/auth/index.d.ts +20 -20
- package/dist/auth/index.js +369 -369
- package/dist/auth/react-server.d.ts +1 -1
- package/dist/auth/react-server.js +10 -10
- package/dist/auth/react.d.ts +18 -18
- package/dist/auth/react.js +71 -71
- package/dist/bin/build-rsc-flashpack.js +6 -0
- package/dist/bin/build-rsc.js +555 -492
- package/dist/bin/build.js +365 -353
- package/dist/bin/generate.js +513 -510
- package/dist/bin/webpack.config.d.ts +3 -1
- package/dist/bin/webpack.config.js +7 -4
- package/dist/build/manifest.d.ts +169 -169
- package/dist/build/manifest.js +423 -423
- package/dist/build/rsc/client-manifest.d.ts +62 -62
- package/dist/build/rsc/client-manifest.js +295 -295
- package/dist/build/rsc/compiler.d.ts +3 -1
- package/dist/build/rsc/compiler.js +12 -7
- package/dist/build/rsc/native-scanner.d.ts +135 -135
- package/dist/build/rsc/native-scanner.js +203 -203
- package/dist/build/rsc/react-client-reference-manifest.d.ts +35 -28
- package/dist/build/rsc/react-client-reference-manifest.js +366 -240
- package/dist/build/standalone.js +260 -254
- package/dist/client/dynamic.react-server.d.ts +2 -2
- package/dist/client/dynamic.react-server.js +23 -23
- package/dist/client/link.js +1 -1
- package/dist/client/link.react-server.d.ts +2 -2
- package/dist/client/link.react-server.js +11 -11
- package/dist/client/navigation.js +2 -2
- package/dist/client/navigation.react-server.d.ts +1 -1
- package/dist/client/navigation.react-server.js +17 -17
- package/dist/client/router.react-server.d.ts +1 -1
- package/dist/client/router.react-server.js +17 -17
- package/dist/client/rsc-router.d.ts +1 -3
- package/dist/client/rsc-router.js +98 -45
- package/dist/client/rsc-router.react-server.d.ts +1 -1
- package/dist/client/rsc-router.react-server.js +17 -17
- package/dist/client/script.react-server.d.ts +2 -2
- package/dist/client/script.react-server.js +23 -23
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -7
- package/dist/deploy/adapters/cloudflare.js +42 -41
- package/dist/deploy/adapters/docker.d.ts +1 -0
- package/dist/deploy/adapters/docker.js +5 -4
- package/dist/deploy/adapters/netlify.js +60 -27
- package/dist/deploy/adapters/vercel.js +80 -50
- package/dist/deploy/preflight.js +4 -3
- package/dist/deploy/runtime-pack.d.ts +11 -0
- package/dist/deploy/runtime-pack.js +300 -0
- package/dist/deploy/utils.d.ts +7 -1
- package/dist/deploy/utils.js +95 -3
- package/dist/flashpack/command.js +1 -0
- package/dist/flashpack/runtime.js +2 -1
- package/dist/image/get-img-props.js +21 -11
- package/dist/image/image-config.d.ts +2 -0
- package/dist/image/image-config.js +17 -0
- package/dist/image/index.d.ts +18 -3
- package/dist/image/index.js +1 -1
- package/dist/image/react-server.d.ts +1 -2
- package/dist/image/react-server.js +1 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +61 -61
- package/dist/server/app-dir.d.ts +22 -0
- package/dist/server/app-dir.js +77 -0
- package/dist/server/app-router-runtime.d.ts +1 -0
- package/dist/server/app-router-runtime.js +34 -9
- package/dist/server/cookie-parse.d.ts +4 -4
- package/dist/server/cookie-parse.js +14 -14
- package/dist/server/engine.js +5 -5
- package/dist/server/hydration-chunks.d.ts +7 -0
- package/dist/server/hydration-chunks.js +49 -0
- package/dist/server/image-optimizer.js +2 -1
- package/dist/server/index.d.ts +109 -109
- package/dist/server/index.js +315 -315
- package/dist/server/middleware-runner.d.ts +125 -125
- package/dist/server/middleware-runner.js +607 -615
- package/dist/server/middleware-security.d.ts +36 -36
- package/dist/server/middleware-security.js +183 -183
- package/dist/server/module-compile-hook.js +706 -695
- package/dist/server/root-resolver.js +6 -5
- package/dist/server/rsc-engine-flashpack.d.ts +3 -1
- package/dist/server/rsc-engine-flashpack.js +12 -1
- package/dist/server/rsc-engine.d.ts +6 -1
- package/dist/server/rsc-engine.js +217 -280
- package/dist/server/rsc-upstream.js +900 -892
- package/dist/server/ssr-webpack-shim.d.ts +6 -0
- package/dist/server/ssr-webpack-shim.js +29 -0
- package/dist/server/static-generator.d.ts +2 -0
- package/dist/server/static-generator.js +33 -32
- package/dist/server/structure-validator.js +2 -1
- package/dist/server/structure-watch.js +2 -0
- package/dist/server/typed-api-runtime.js +639 -635
- package/dist/server/vista-import-map.js +134 -134
- package/dist/stack/index.d.ts +34 -34
- package/dist/stack/index.js +49 -49
- package/dist/stack/server/caller.d.ts +13 -13
- package/dist/stack/server/caller.js +42 -42
- package/dist/stack/server/executor.d.ts +40 -40
- package/dist/stack/server/executor.js +222 -222
- package/dist/stack/server/index.d.ts +11 -11
- package/dist/stack/server/index.js +24 -24
- package/dist/stack/server/procedure.d.ts +20 -20
- package/dist/stack/server/procedure.js +66 -66
- package/dist/stack/server/types.d.ts +113 -113
- package/dist/theme/react-server.d.ts +10 -10
- package/dist/theme/react-server.js +16 -16
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ exports.isInterceptionRouteSegment = isInterceptionRouteSegment;
|
|
|
9
9
|
exports.isRouteGroupSegment = isRouteGroupSegment;
|
|
10
10
|
exports.isParallelRouteSegment = isParallelRouteSegment;
|
|
11
11
|
exports.resolveParallelSlotMatches = resolveParallelSlotMatches;
|
|
12
|
+
exports.isPathInside = isPathInside;
|
|
12
13
|
exports.resolveDirectoryChain = resolveDirectoryChain;
|
|
13
14
|
exports.resolveNearestSegmentNotFoundPath = resolveNearestSegmentNotFoundPath;
|
|
14
15
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -284,17 +285,41 @@ function resolveParallelSlotMatches(input) {
|
|
|
284
285
|
}
|
|
285
286
|
return matches;
|
|
286
287
|
}
|
|
288
|
+
function canonicalizeExistingPath(input) {
|
|
289
|
+
const resolved = path_1.default.resolve(input);
|
|
290
|
+
try {
|
|
291
|
+
return fs_1.default.realpathSync.native(resolved);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return resolved;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function posixPath(input) {
|
|
298
|
+
return input.replace(/\\/g, '/');
|
|
299
|
+
}
|
|
300
|
+
function isPathInside(parent, child) {
|
|
301
|
+
const root = posixPath(canonicalizeExistingPath(parent));
|
|
302
|
+
const target = posixPath(canonicalizeExistingPath(child));
|
|
303
|
+
const normalize = (value) => process.platform === 'win32' ? value.toLowerCase() : value;
|
|
304
|
+
const a = normalize(root);
|
|
305
|
+
const b = normalize(target);
|
|
306
|
+
return b === a || b.startsWith(a.endsWith('/') ? a : `${a}/`);
|
|
307
|
+
}
|
|
287
308
|
function resolveDirectoryChain(rootDir, entryFilePath) {
|
|
288
|
-
const resolvedRootDir =
|
|
289
|
-
const resolvedEntryDir =
|
|
290
|
-
if (!
|
|
309
|
+
const resolvedRootDir = canonicalizeExistingPath(rootDir);
|
|
310
|
+
const resolvedEntryDir = canonicalizeExistingPath(path_1.default.dirname(entryFilePath));
|
|
311
|
+
if (!isPathInside(resolvedRootDir, resolvedEntryDir)) {
|
|
291
312
|
return [resolvedEntryDir];
|
|
292
313
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
.
|
|
314
|
+
let relativePath = path_1.default.relative(resolvedRootDir, resolvedEntryDir).replace(/\\/g, '/');
|
|
315
|
+
if (relativePath.startsWith('..')) {
|
|
316
|
+
const rootPosix = posixPath(resolvedRootDir);
|
|
317
|
+
const entryPosix = posixPath(resolvedEntryDir);
|
|
318
|
+
const rootKey = process.platform === 'win32' ? rootPosix.toLowerCase() : rootPosix;
|
|
319
|
+
const entryKey = process.platform === 'win32' ? entryPosix.toLowerCase() : entryPosix;
|
|
320
|
+
relativePath = entryKey.slice(rootKey.length).replace(/^\//, '');
|
|
321
|
+
}
|
|
322
|
+
const relativeSegments = relativePath.split('/').filter((segment) => segment && segment !== '.');
|
|
298
323
|
const chain = [resolvedRootDir];
|
|
299
324
|
let currentDir = resolvedRootDir;
|
|
300
325
|
for (const segment of relativeSegments) {
|
|
@@ -306,7 +331,7 @@ function resolveDirectoryChain(rootDir, entryFilePath) {
|
|
|
306
331
|
function resolveNearestSegmentNotFoundPath(appDir, startDir) {
|
|
307
332
|
let currentDir = path_1.default.resolve(startDir);
|
|
308
333
|
const resolvedAppDir = path_1.default.resolve(appDir);
|
|
309
|
-
while (
|
|
334
|
+
while (isPathInside(resolvedAppDir, currentDir)) {
|
|
310
335
|
const notFoundPath = resolveConventionModule(currentDir, 'not-found');
|
|
311
336
|
if (notFoundPath) {
|
|
312
337
|
return notFoundPath;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decode a cookie value without throwing on malformed % sequences.
|
|
3
|
-
*/
|
|
4
|
-
export declare function safeDecodeURIComponent(value: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* Decode a cookie value without throwing on malformed % sequences.
|
|
3
|
+
*/
|
|
4
|
+
export declare function safeDecodeURIComponent(value: string): string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeDecodeURIComponent = safeDecodeURIComponent;
|
|
4
|
-
/**
|
|
5
|
-
* Decode a cookie value without throwing on malformed % sequences.
|
|
6
|
-
*/
|
|
7
|
-
function safeDecodeURIComponent(value) {
|
|
8
|
-
try {
|
|
9
|
-
return decodeURIComponent(value);
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeDecodeURIComponent = safeDecodeURIComponent;
|
|
4
|
+
/**
|
|
5
|
+
* Decode a cookie value without throwing on malformed % sequences.
|
|
6
|
+
*/
|
|
7
|
+
function safeDecodeURIComponent(value) {
|
|
8
|
+
try {
|
|
9
|
+
return decodeURIComponent(value);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/server/engine.js
CHANGED
|
@@ -31,6 +31,7 @@ const logger_1 = require("./logger");
|
|
|
31
31
|
const structure_log_1 = require("./structure-log");
|
|
32
32
|
const module_compile_hook_1 = require("./module-compile-hook");
|
|
33
33
|
const request_context_1 = require("./request-context");
|
|
34
|
+
const app_dir_1 = require("./app-dir");
|
|
34
35
|
// Support CSS imports on server runtime
|
|
35
36
|
// - Regular .css: ignored (handled by PostCSS)
|
|
36
37
|
// - .module.css: return empty class mapping (webpack build handles real mappings)
|
|
@@ -109,7 +110,7 @@ function initClientComponentRegistry(appDir, cwd) {
|
|
|
109
110
|
try {
|
|
110
111
|
clientComponentIdsByPath.clear();
|
|
111
112
|
const appCount = registerClientComponents(appDir);
|
|
112
|
-
const componentsCount = registerClientComponents(
|
|
113
|
+
const componentsCount = registerClientComponents((0, app_dir_1.resolveComponentsDir)(cwd), 'components/');
|
|
113
114
|
if (process.env.VISTA_DEBUG) {
|
|
114
115
|
console.log(`[Vista JS RSC] Registered ${clientComponentIdsByPath.size} client component(s) for hydration wrapping (app=${appCount}, components=${componentsCount})`);
|
|
115
116
|
}
|
|
@@ -213,7 +214,7 @@ function startServer(port = 3003, compiler) {
|
|
|
213
214
|
const engineVariant = (0, config_1.resolveAndApplyEngineVariant)(vistaConfig);
|
|
214
215
|
const typedApiConfig = (0, config_1.resolveTypedApiConfig)(vistaConfig);
|
|
215
216
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
216
|
-
const appDir =
|
|
217
|
+
const appDir = (0, app_dir_1.resolveAppDir)(cwd);
|
|
217
218
|
if (process.env.VISTA_DEBUG) {
|
|
218
219
|
(0, logger_1.logInfo)(`Engine variant: ${engineVariant}`);
|
|
219
220
|
}
|
|
@@ -524,8 +525,8 @@ function startServer(port = 3003, compiler) {
|
|
|
524
525
|
// Route Matching Logic
|
|
525
526
|
const getExactPath = (p) => {
|
|
526
527
|
if (p === '/' || p === '/index')
|
|
527
|
-
return path_1.default.
|
|
528
|
-
return path_1.default.
|
|
528
|
+
return path_1.default.join(appDir, 'index.tsx');
|
|
529
|
+
return path_1.default.join(appDir, p.substring(1), 'page.tsx');
|
|
529
530
|
};
|
|
530
531
|
const tryPath = getExactPath(req.path);
|
|
531
532
|
// Clear require cache for hot reloading in dev
|
|
@@ -542,7 +543,6 @@ function startServer(port = 3003, compiler) {
|
|
|
542
543
|
else {
|
|
543
544
|
// Dynamic Route Matching
|
|
544
545
|
const segments = req.path.split('/').filter(Boolean);
|
|
545
|
-
const appDir = path_1.default.resolve(cwd, 'app');
|
|
546
546
|
if (segments.length === 2) {
|
|
547
547
|
const [section, paramVal] = segments;
|
|
548
548
|
const sectionPath = path_1.default.join(appDir, section);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isBootstrapChunkFile(filename: string): boolean;
|
|
2
|
+
export declare function sortHydrationChunkFiles(files: string[]): string[];
|
|
3
|
+
/**
|
|
4
|
+
* Script tags that must be in the HTML document. Async `clientN-*.js`
|
|
5
|
+
* chunks are loaded by the webpack runtime, matching Next.js.
|
|
6
|
+
*/
|
|
7
|
+
export declare function listHydrationChunkFiles(cwd: string, isDev?: boolean): string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isBootstrapChunkFile = isBootstrapChunkFile;
|
|
7
|
+
exports.sortHydrationChunkFiles = sortHydrationChunkFiles;
|
|
8
|
+
exports.listHydrationChunkFiles = listHydrationChunkFiles;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const BOOTSTRAP_CHUNK_RE = /^(webpack|framework|vendor|main|runtime)(?:-[a-z0-9]+)?\.js$/i;
|
|
13
|
+
const BOOTSTRAP_PRIORITY = ['webpack', 'framework', 'vendor', 'runtime', 'main'];
|
|
14
|
+
function isBootstrapChunkFile(filename) {
|
|
15
|
+
const base = filename.split(/[/\\]/).pop() || filename;
|
|
16
|
+
return BOOTSTRAP_CHUNK_RE.test(base);
|
|
17
|
+
}
|
|
18
|
+
function bootstrapRank(filename) {
|
|
19
|
+
const base = (filename.split(/[/\\]/).pop() || filename).replace(/(?:-[a-z0-9]+)?\.js$/i, '');
|
|
20
|
+
const index = BOOTSTRAP_PRIORITY.indexOf(base.toLowerCase());
|
|
21
|
+
return index === -1 ? BOOTSTRAP_PRIORITY.length : index;
|
|
22
|
+
}
|
|
23
|
+
function sortHydrationChunkFiles(files) {
|
|
24
|
+
return [...files].sort((a, b) => {
|
|
25
|
+
const rankDelta = bootstrapRank(a) - bootstrapRank(b);
|
|
26
|
+
if (rankDelta !== 0)
|
|
27
|
+
return rankDelta;
|
|
28
|
+
return a.localeCompare(b);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Script tags that must be in the HTML document. Async `clientN-*.js`
|
|
33
|
+
* chunks are loaded by the webpack runtime, matching Next.js.
|
|
34
|
+
*/
|
|
35
|
+
function listHydrationChunkFiles(cwd, isDev = false) {
|
|
36
|
+
const chunksDir = path_1.default.join(cwd, constants_1.BUILD_DIR, 'static', 'chunks');
|
|
37
|
+
if (!fs_1.default.existsSync(chunksDir))
|
|
38
|
+
return [];
|
|
39
|
+
const files = fs_1.default
|
|
40
|
+
.readdirSync(chunksDir)
|
|
41
|
+
.filter((name) => name.endsWith('.js') &&
|
|
42
|
+
!name.endsWith('.map') &&
|
|
43
|
+
!name.includes('.hot-update.') &&
|
|
44
|
+
isBootstrapChunkFile(name));
|
|
45
|
+
const normalizedFiles = isDev
|
|
46
|
+
? files.filter((name) => !/-[0-9a-f]{8,}\.js$/i.test(name))
|
|
47
|
+
: files;
|
|
48
|
+
return sortHydrationChunkFiles(normalizedFiles);
|
|
49
|
+
}
|
|
@@ -24,6 +24,7 @@ const http_1 = __importDefault(require("http"));
|
|
|
24
24
|
const https_1 = __importDefault(require("https"));
|
|
25
25
|
const url_1 = require("url");
|
|
26
26
|
const image_config_1 = require("../image/image-config");
|
|
27
|
+
const app_dir_1 = require("./app-dir");
|
|
27
28
|
// ---------------------------------------------------------------------------
|
|
28
29
|
// Cache
|
|
29
30
|
// ---------------------------------------------------------------------------
|
|
@@ -71,7 +72,7 @@ function fetchLocalFile(filePath, cwd) {
|
|
|
71
72
|
return fs_1.default.promises.readFile(publicPath);
|
|
72
73
|
}
|
|
73
74
|
// Also try app/ directory
|
|
74
|
-
const appPath = path_1.default.join(
|
|
75
|
+
const appPath = path_1.default.join((0, app_dir_1.resolveAppDir)(cwd), filePath);
|
|
75
76
|
if (fs_1.default.existsSync(appPath)) {
|
|
76
77
|
return fs_1.default.promises.readFile(appPath);
|
|
77
78
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vista Server Utilities
|
|
3
|
-
*
|
|
4
|
-
* Next.js-compatible server-only functions for use in Server Components and API routes.
|
|
5
|
-
* These functions only work on the server side.
|
|
6
|
-
*/
|
|
7
|
-
export interface CookieOptions {
|
|
8
|
-
maxAge?: number;
|
|
9
|
-
expires?: Date;
|
|
10
|
-
path?: string;
|
|
11
|
-
domain?: string;
|
|
12
|
-
secure?: boolean;
|
|
13
|
-
httpOnly?: boolean;
|
|
14
|
-
sameSite?: 'strict' | 'lax' | 'none';
|
|
15
|
-
priority?: 'low' | 'medium' | 'high';
|
|
16
|
-
}
|
|
17
|
-
export interface ReadonlyCookie {
|
|
18
|
-
name: string;
|
|
19
|
-
value: string;
|
|
20
|
-
}
|
|
21
|
-
export interface CookieStore {
|
|
22
|
-
get(name: string): ReadonlyCookie | undefined;
|
|
23
|
-
getAll(): ReadonlyCookie[];
|
|
24
|
-
has(name: string): boolean;
|
|
25
|
-
set(name: string, value: string, options?: CookieOptions): void;
|
|
26
|
-
delete(name: string): void;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Access cookies in Server Components and API routes.
|
|
30
|
-
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
31
|
-
*/
|
|
32
|
-
export declare function cookies(): CookieStore;
|
|
33
|
-
export interface ReadonlyHeaders {
|
|
34
|
-
get(name: string): string | null;
|
|
35
|
-
has(name: string): boolean;
|
|
36
|
-
entries(): IterableIterator<[string, string]>;
|
|
37
|
-
keys(): IterableIterator<string>;
|
|
38
|
-
values(): IterableIterator<string>;
|
|
39
|
-
forEach(callback: (value: string, key: string) => void): void;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Access request headers in Server Components.
|
|
43
|
-
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
44
|
-
*/
|
|
45
|
-
export declare function headers(): ReadonlyHeaders;
|
|
46
|
-
export interface DraftMode {
|
|
47
|
-
isEnabled: boolean;
|
|
48
|
-
enable(): void;
|
|
49
|
-
disable(): void;
|
|
50
|
-
}
|
|
51
|
-
export declare function draftMode(): DraftMode;
|
|
52
|
-
export type RedirectType = 'push' | 'replace';
|
|
53
|
-
export declare class RedirectError extends Error {
|
|
54
|
-
readonly url: string;
|
|
55
|
-
readonly type: RedirectType;
|
|
56
|
-
constructor(url: string, type?: RedirectType);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Redirect to another URL from a Server Component or API route.
|
|
60
|
-
* @param url - The URL to redirect to
|
|
61
|
-
* @param type - The type of redirect ('push' or 'replace')
|
|
62
|
-
* @throws RedirectError - Always throws to interrupt rendering
|
|
63
|
-
*/
|
|
64
|
-
export declare function redirect(url: string, type?: RedirectType): never;
|
|
65
|
-
/**
|
|
66
|
-
* Permanent redirect (HTTP 308) to another URL.
|
|
67
|
-
* @param url - The URL to redirect to
|
|
68
|
-
* @throws RedirectError - Always throws to interrupt rendering
|
|
69
|
-
*/
|
|
70
|
-
export declare function permanentRedirect(url: string): never;
|
|
71
|
-
export declare class NotFoundError extends Error {
|
|
72
|
-
constructor();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Trigger a 404 Not Found response from a Server Component.
|
|
76
|
-
* @throws NotFoundError - Always throws to interrupt rendering
|
|
77
|
-
*/
|
|
78
|
-
export declare function notFound(): never;
|
|
79
|
-
/**
|
|
80
|
-
* Create a JSON response (for API routes).
|
|
81
|
-
*/
|
|
82
|
-
export declare function json<T>(data: T, init?: ResponseInit): Response;
|
|
83
|
-
/**
|
|
84
|
-
* Create a NextResponse-compatible response object.
|
|
85
|
-
*/
|
|
86
|
-
export declare class NextResponse extends Response {
|
|
87
|
-
static json<T>(data: T, init?: ResponseInit): NextResponse;
|
|
88
|
-
static redirect(url: string | URL, status?: number): NextResponse;
|
|
89
|
-
static rewrite(url: string | URL): NextResponse;
|
|
90
|
-
static next(options?: {
|
|
91
|
-
request?: {
|
|
92
|
-
headers?: Headers | Record<string, string>;
|
|
93
|
-
};
|
|
94
|
-
}): NextResponse;
|
|
95
|
-
}
|
|
96
|
-
export interface NextRequest extends Request {
|
|
97
|
-
nextUrl: {
|
|
98
|
-
pathname: string;
|
|
99
|
-
searchParams: URLSearchParams;
|
|
100
|
-
href: string;
|
|
101
|
-
origin: string;
|
|
102
|
-
};
|
|
103
|
-
cookies: CookieStore;
|
|
104
|
-
headers: Headers;
|
|
105
|
-
}
|
|
106
|
-
export { cacheLife, cacheTag, revalidatePath, revalidateTag, unstable_cache } from './cache';
|
|
107
|
-
export { runMiddleware, applyMiddlewareResult, discoverGlobalMiddleware, discoverRouteMiddlewares, clearMiddlewareCaches, buildNextRequest, patternToRegExp, shouldRunMiddleware, } from './middleware-runner';
|
|
108
|
-
export { chain, cors, rateLimit, securityHeaders, isSafeRedirectLocation, sanitizeRequestHeaderMap, } from './middleware-security';
|
|
109
|
-
export type { MiddlewareResult, VistaMiddlewareRequest, VistaMiddlewareContext, MiddlewareFunction, MiddlewareConfig, MiddlewareMatcher, MiddlewareModule, NextFunction, } from './middleware-runner';
|
|
1
|
+
/**
|
|
2
|
+
* Vista Server Utilities
|
|
3
|
+
*
|
|
4
|
+
* Next.js-compatible server-only functions for use in Server Components and API routes.
|
|
5
|
+
* These functions only work on the server side.
|
|
6
|
+
*/
|
|
7
|
+
export interface CookieOptions {
|
|
8
|
+
maxAge?: number;
|
|
9
|
+
expires?: Date;
|
|
10
|
+
path?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
secure?: boolean;
|
|
13
|
+
httpOnly?: boolean;
|
|
14
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
15
|
+
priority?: 'low' | 'medium' | 'high';
|
|
16
|
+
}
|
|
17
|
+
export interface ReadonlyCookie {
|
|
18
|
+
name: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CookieStore {
|
|
22
|
+
get(name: string): ReadonlyCookie | undefined;
|
|
23
|
+
getAll(): ReadonlyCookie[];
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
set(name: string, value: string, options?: CookieOptions): void;
|
|
26
|
+
delete(name: string): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Access cookies in Server Components and API routes.
|
|
30
|
+
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cookies(): CookieStore;
|
|
33
|
+
export interface ReadonlyHeaders {
|
|
34
|
+
get(name: string): string | null;
|
|
35
|
+
has(name: string): boolean;
|
|
36
|
+
entries(): IterableIterator<[string, string]>;
|
|
37
|
+
keys(): IterableIterator<string>;
|
|
38
|
+
values(): IterableIterator<string>;
|
|
39
|
+
forEach(callback: (value: string, key: string) => void): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Access request headers in Server Components.
|
|
43
|
+
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
44
|
+
*/
|
|
45
|
+
export declare function headers(): ReadonlyHeaders;
|
|
46
|
+
export interface DraftMode {
|
|
47
|
+
isEnabled: boolean;
|
|
48
|
+
enable(): void;
|
|
49
|
+
disable(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare function draftMode(): DraftMode;
|
|
52
|
+
export type RedirectType = 'push' | 'replace';
|
|
53
|
+
export declare class RedirectError extends Error {
|
|
54
|
+
readonly url: string;
|
|
55
|
+
readonly type: RedirectType;
|
|
56
|
+
constructor(url: string, type?: RedirectType);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Redirect to another URL from a Server Component or API route.
|
|
60
|
+
* @param url - The URL to redirect to
|
|
61
|
+
* @param type - The type of redirect ('push' or 'replace')
|
|
62
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
63
|
+
*/
|
|
64
|
+
export declare function redirect(url: string, type?: RedirectType): never;
|
|
65
|
+
/**
|
|
66
|
+
* Permanent redirect (HTTP 308) to another URL.
|
|
67
|
+
* @param url - The URL to redirect to
|
|
68
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
69
|
+
*/
|
|
70
|
+
export declare function permanentRedirect(url: string): never;
|
|
71
|
+
export declare class NotFoundError extends Error {
|
|
72
|
+
constructor();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Trigger a 404 Not Found response from a Server Component.
|
|
76
|
+
* @throws NotFoundError - Always throws to interrupt rendering
|
|
77
|
+
*/
|
|
78
|
+
export declare function notFound(): never;
|
|
79
|
+
/**
|
|
80
|
+
* Create a JSON response (for API routes).
|
|
81
|
+
*/
|
|
82
|
+
export declare function json<T>(data: T, init?: ResponseInit): Response;
|
|
83
|
+
/**
|
|
84
|
+
* Create a NextResponse-compatible response object.
|
|
85
|
+
*/
|
|
86
|
+
export declare class NextResponse extends Response {
|
|
87
|
+
static json<T>(data: T, init?: ResponseInit): NextResponse;
|
|
88
|
+
static redirect(url: string | URL, status?: number): NextResponse;
|
|
89
|
+
static rewrite(url: string | URL): NextResponse;
|
|
90
|
+
static next(options?: {
|
|
91
|
+
request?: {
|
|
92
|
+
headers?: Headers | Record<string, string>;
|
|
93
|
+
};
|
|
94
|
+
}): NextResponse;
|
|
95
|
+
}
|
|
96
|
+
export interface NextRequest extends Request {
|
|
97
|
+
nextUrl: {
|
|
98
|
+
pathname: string;
|
|
99
|
+
searchParams: URLSearchParams;
|
|
100
|
+
href: string;
|
|
101
|
+
origin: string;
|
|
102
|
+
};
|
|
103
|
+
cookies: CookieStore;
|
|
104
|
+
headers: Headers;
|
|
105
|
+
}
|
|
106
|
+
export { cacheLife, cacheTag, revalidatePath, revalidateTag, unstable_cache } from './cache';
|
|
107
|
+
export { runMiddleware, applyMiddlewareResult, discoverGlobalMiddleware, discoverRouteMiddlewares, clearMiddlewareCaches, buildNextRequest, patternToRegExp, shouldRunMiddleware, } from './middleware-runner';
|
|
108
|
+
export { chain, cors, rateLimit, securityHeaders, isSafeRedirectLocation, sanitizeRequestHeaderMap, } from './middleware-security';
|
|
109
|
+
export type { MiddlewareResult, VistaMiddlewareRequest, VistaMiddlewareContext, MiddlewareFunction, MiddlewareConfig, MiddlewareMatcher, MiddlewareModule, NextFunction, } from './middleware-runner';
|