@vistagenic/vista 0.1.0-alpha.1
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 +98 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.js +16 -0
- package/dist/bin/build-rsc.d.ts +17 -0
- package/dist/bin/build-rsc.js +320 -0
- package/dist/bin/build.d.ts +4 -0
- package/dist/bin/build.js +336 -0
- package/dist/bin/file-scanner.d.ts +66 -0
- package/dist/bin/file-scanner.js +399 -0
- package/dist/bin/server-component-plugin.d.ts +17 -0
- package/dist/bin/server-component-plugin.js +133 -0
- package/dist/bin/webpack.config.d.ts +6 -0
- package/dist/bin/webpack.config.js +138 -0
- package/dist/build/manifest.d.ts +95 -0
- package/dist/build/manifest.js +168 -0
- package/dist/build/rsc/client-manifest.d.ts +48 -0
- package/dist/build/rsc/client-manifest.js +191 -0
- package/dist/build/rsc/client-reference-plugin.d.ts +37 -0
- package/dist/build/rsc/client-reference-plugin.js +185 -0
- package/dist/build/rsc/compiler.d.ts +36 -0
- package/dist/build/rsc/compiler.js +311 -0
- package/dist/build/rsc/index.d.ts +16 -0
- package/dist/build/rsc/index.js +32 -0
- package/dist/build/rsc/native-scanner.d.ts +123 -0
- package/dist/build/rsc/native-scanner.js +165 -0
- package/dist/build/rsc/rsc-renderer.d.ts +99 -0
- package/dist/build/rsc/rsc-renderer.js +269 -0
- package/dist/build/rsc/server-component-loader.d.ts +19 -0
- package/dist/build/rsc/server-component-loader.js +147 -0
- package/dist/build/rsc/server-manifest.d.ts +63 -0
- package/dist/build/rsc/server-manifest.js +268 -0
- package/dist/build/webpack/loaders/vista-flight-loader.d.ts +17 -0
- package/dist/build/webpack/loaders/vista-flight-loader.js +93 -0
- package/dist/build/webpack/plugins/vista-flight-plugin.d.ts +36 -0
- package/dist/build/webpack/plugins/vista-flight-plugin.js +133 -0
- package/dist/client/dynamic.d.ts +25 -0
- package/dist/client/dynamic.js +68 -0
- package/dist/client/font.d.ts +98 -0
- package/dist/client/font.js +109 -0
- package/dist/client/head.d.ts +79 -0
- package/dist/client/head.js +261 -0
- package/dist/client/hydration.d.ts +45 -0
- package/dist/client/hydration.js +291 -0
- package/dist/client/link.d.ts +30 -0
- package/dist/client/link.js +188 -0
- package/dist/client/navigation.d.ts +28 -0
- package/dist/client/navigation.js +116 -0
- package/dist/client/router.d.ts +41 -0
- package/dist/client/router.js +190 -0
- package/dist/client/script.d.ts +51 -0
- package/dist/client/script.js +118 -0
- package/dist/components/client-island.d.ts +34 -0
- package/dist/components/client-island.js +75 -0
- package/dist/components/client.d.ts +29 -0
- package/dist/components/client.js +102 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +8 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +13 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +31 -0
- package/dist/dev-error.d.ts +35 -0
- package/dist/dev-error.js +310 -0
- package/dist/image/get-img-props.d.ts +28 -0
- package/dist/image/get-img-props.js +49 -0
- package/dist/image/image-config.d.ts +20 -0
- package/dist/image/image-config.js +20 -0
- package/dist/image/image-loader.d.ts +7 -0
- package/dist/image/image-loader.js +14 -0
- package/dist/image/index.d.ts +6 -0
- package/dist/image/index.js +110 -0
- package/dist/image.d.ts +10 -0
- package/dist/image.js +7 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +53 -0
- package/dist/metadata/generate.d.ts +22 -0
- package/dist/metadata/generate.js +324 -0
- package/dist/metadata/index.d.ts +7 -0
- package/dist/metadata/index.js +26 -0
- package/dist/metadata/types.d.ts +325 -0
- package/dist/metadata/types.js +15 -0
- package/dist/router/context.d.ts +8 -0
- package/dist/router/context.js +13 -0
- package/dist/router/index.d.ts +2 -0
- package/dist/router/index.js +18 -0
- package/dist/router/provider.d.ts +5 -0
- package/dist/router/provider.js +31 -0
- package/dist/server/client-boundary.d.ts +48 -0
- package/dist/server/client-boundary.js +133 -0
- package/dist/server/engine.d.ts +4 -0
- package/dist/server/engine.js +651 -0
- package/dist/server/index.d.ts +95 -0
- package/dist/server/index.js +177 -0
- package/dist/server/rsc-engine.d.ts +20 -0
- package/dist/server/rsc-engine.js +588 -0
- package/dist/server/rsc-module-system.d.ts +33 -0
- package/dist/server/rsc-module-system.js +119 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/package.json +103 -0
|
@@ -0,0 +1,95 @@
|
|
|
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 type RedirectType = 'push' | 'replace';
|
|
47
|
+
export declare class RedirectError extends Error {
|
|
48
|
+
readonly url: string;
|
|
49
|
+
readonly type: RedirectType;
|
|
50
|
+
constructor(url: string, type?: RedirectType);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Redirect to another URL from a Server Component or API route.
|
|
54
|
+
* @param url - The URL to redirect to
|
|
55
|
+
* @param type - The type of redirect ('push' or 'replace')
|
|
56
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
57
|
+
*/
|
|
58
|
+
export declare function redirect(url: string, type?: RedirectType): never;
|
|
59
|
+
/**
|
|
60
|
+
* Permanent redirect (HTTP 308) to another URL.
|
|
61
|
+
* @param url - The URL to redirect to
|
|
62
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
63
|
+
*/
|
|
64
|
+
export declare function permanentRedirect(url: string): never;
|
|
65
|
+
export declare class NotFoundError extends Error {
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Trigger a 404 Not Found response from a Server Component.
|
|
70
|
+
* @throws NotFoundError - Always throws to interrupt rendering
|
|
71
|
+
*/
|
|
72
|
+
export declare function notFound(): never;
|
|
73
|
+
/**
|
|
74
|
+
* Create a JSON response (for API routes).
|
|
75
|
+
*/
|
|
76
|
+
export declare function json<T>(data: T, init?: ResponseInit): Response;
|
|
77
|
+
/**
|
|
78
|
+
* Create a NextResponse-compatible response object.
|
|
79
|
+
*/
|
|
80
|
+
export declare class NextResponse extends Response {
|
|
81
|
+
static json<T>(data: T, init?: ResponseInit): NextResponse;
|
|
82
|
+
static redirect(url: string | URL, status?: number): NextResponse;
|
|
83
|
+
static rewrite(url: string | URL): NextResponse;
|
|
84
|
+
static next(): NextResponse;
|
|
85
|
+
}
|
|
86
|
+
export interface NextRequest extends Request {
|
|
87
|
+
nextUrl: {
|
|
88
|
+
pathname: string;
|
|
89
|
+
searchParams: URLSearchParams;
|
|
90
|
+
href: string;
|
|
91
|
+
origin: string;
|
|
92
|
+
};
|
|
93
|
+
cookies: CookieStore;
|
|
94
|
+
headers: Headers;
|
|
95
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vista Server Utilities
|
|
4
|
+
*
|
|
5
|
+
* Next.js-compatible server-only functions for use in Server Components and API routes.
|
|
6
|
+
* These functions only work on the server side.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.NextResponse = exports.NotFoundError = exports.RedirectError = void 0;
|
|
10
|
+
exports.cookies = cookies;
|
|
11
|
+
exports.headers = headers;
|
|
12
|
+
exports.redirect = redirect;
|
|
13
|
+
exports.permanentRedirect = permanentRedirect;
|
|
14
|
+
exports.notFound = notFound;
|
|
15
|
+
exports.json = json;
|
|
16
|
+
/**
|
|
17
|
+
* Access cookies in Server Components and API routes.
|
|
18
|
+
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
19
|
+
*/
|
|
20
|
+
function cookies() {
|
|
21
|
+
// Server-side cookie access would be implemented here
|
|
22
|
+
// For now, return a mock implementation
|
|
23
|
+
const cookieMap = new Map();
|
|
24
|
+
// Check if we're in a server context
|
|
25
|
+
if (typeof window !== 'undefined') {
|
|
26
|
+
console.warn('cookies() should only be called on the server');
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
get(name) {
|
|
30
|
+
const value = cookieMap.get(name);
|
|
31
|
+
return value ? { name, value } : undefined;
|
|
32
|
+
},
|
|
33
|
+
getAll() {
|
|
34
|
+
return Array.from(cookieMap.entries()).map(([name, value]) => ({ name, value }));
|
|
35
|
+
},
|
|
36
|
+
has(name) {
|
|
37
|
+
return cookieMap.has(name);
|
|
38
|
+
},
|
|
39
|
+
set(name, value, options) {
|
|
40
|
+
cookieMap.set(name, value);
|
|
41
|
+
// In real implementation, set the Set-Cookie header
|
|
42
|
+
},
|
|
43
|
+
delete(name) {
|
|
44
|
+
cookieMap.delete(name);
|
|
45
|
+
// In real implementation, set the Set-Cookie header with expired date
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Access request headers in Server Components.
|
|
51
|
+
* Note: This is a simplified implementation - in production, integrate with actual request.
|
|
52
|
+
*/
|
|
53
|
+
function headers() {
|
|
54
|
+
// Server-side header access would be implemented here
|
|
55
|
+
const headerMap = new Map();
|
|
56
|
+
if (typeof window !== 'undefined') {
|
|
57
|
+
console.warn('headers() should only be called on the server');
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
get(name) {
|
|
61
|
+
return headerMap.get(name.toLowerCase()) ?? null;
|
|
62
|
+
},
|
|
63
|
+
has(name) {
|
|
64
|
+
return headerMap.has(name.toLowerCase());
|
|
65
|
+
},
|
|
66
|
+
entries() {
|
|
67
|
+
return headerMap.entries();
|
|
68
|
+
},
|
|
69
|
+
keys() {
|
|
70
|
+
return headerMap.keys();
|
|
71
|
+
},
|
|
72
|
+
values() {
|
|
73
|
+
return headerMap.values();
|
|
74
|
+
},
|
|
75
|
+
forEach(callback) {
|
|
76
|
+
headerMap.forEach((value, key) => callback(value, key));
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
class RedirectError extends Error {
|
|
81
|
+
url;
|
|
82
|
+
type;
|
|
83
|
+
constructor(url, type = 'replace') {
|
|
84
|
+
super(`Redirect to ${url}`);
|
|
85
|
+
this.name = 'RedirectError';
|
|
86
|
+
this.url = url;
|
|
87
|
+
this.type = type;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.RedirectError = RedirectError;
|
|
91
|
+
/**
|
|
92
|
+
* Redirect to another URL from a Server Component or API route.
|
|
93
|
+
* @param url - The URL to redirect to
|
|
94
|
+
* @param type - The type of redirect ('push' or 'replace')
|
|
95
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
96
|
+
*/
|
|
97
|
+
function redirect(url, type = 'replace') {
|
|
98
|
+
throw new RedirectError(url, type);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Permanent redirect (HTTP 308) to another URL.
|
|
102
|
+
* @param url - The URL to redirect to
|
|
103
|
+
* @throws RedirectError - Always throws to interrupt rendering
|
|
104
|
+
*/
|
|
105
|
+
function permanentRedirect(url) {
|
|
106
|
+
throw new RedirectError(url, 'replace');
|
|
107
|
+
}
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Not Found
|
|
110
|
+
// ============================================================================
|
|
111
|
+
class NotFoundError extends Error {
|
|
112
|
+
constructor() {
|
|
113
|
+
super('Not Found');
|
|
114
|
+
this.name = 'NotFoundError';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.NotFoundError = NotFoundError;
|
|
118
|
+
/**
|
|
119
|
+
* Trigger a 404 Not Found response from a Server Component.
|
|
120
|
+
* @throws NotFoundError - Always throws to interrupt rendering
|
|
121
|
+
*/
|
|
122
|
+
function notFound() {
|
|
123
|
+
throw new NotFoundError();
|
|
124
|
+
}
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// Response Helpers
|
|
127
|
+
// ============================================================================
|
|
128
|
+
/**
|
|
129
|
+
* Create a JSON response (for API routes).
|
|
130
|
+
*/
|
|
131
|
+
function json(data, init) {
|
|
132
|
+
return new Response(JSON.stringify(data), {
|
|
133
|
+
...init,
|
|
134
|
+
headers: {
|
|
135
|
+
'Content-Type': 'application/json',
|
|
136
|
+
...init?.headers,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Create a NextResponse-compatible response object.
|
|
142
|
+
*/
|
|
143
|
+
class NextResponse extends Response {
|
|
144
|
+
static json(data, init) {
|
|
145
|
+
return new NextResponse(JSON.stringify(data), {
|
|
146
|
+
...init,
|
|
147
|
+
headers: {
|
|
148
|
+
'Content-Type': 'application/json',
|
|
149
|
+
...init?.headers,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
static redirect(url, status = 307) {
|
|
154
|
+
return new NextResponse(null, {
|
|
155
|
+
status,
|
|
156
|
+
headers: {
|
|
157
|
+
Location: url.toString(),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
static rewrite(url) {
|
|
162
|
+
// Rewrite implementation would go here
|
|
163
|
+
return new NextResponse(null, {
|
|
164
|
+
headers: {
|
|
165
|
+
'x-middleware-rewrite': url.toString(),
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
static next() {
|
|
170
|
+
return new NextResponse(null, {
|
|
171
|
+
headers: {
|
|
172
|
+
'x-middleware-next': '1',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.NextResponse = NextResponse;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista RSC Engine
|
|
3
|
+
*
|
|
4
|
+
* React Server Components aware rendering engine.
|
|
5
|
+
*
|
|
6
|
+
* This engine implements the "True RSC Architecture":
|
|
7
|
+
* 1. Server components render on the server only, contribute 0kb to client
|
|
8
|
+
* 2. Client components are sent as references, hydrated on demand
|
|
9
|
+
* 3. Strict separation ensures server secrets never leak
|
|
10
|
+
*/
|
|
11
|
+
import webpack from 'webpack';
|
|
12
|
+
export interface RSCEngineOptions {
|
|
13
|
+
port?: number;
|
|
14
|
+
compiler?: webpack.Compiler;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Start the RSC-aware Vista server
|
|
18
|
+
*/
|
|
19
|
+
export declare function startRSCServer(options?: RSCEngineOptions): void;
|
|
20
|
+
export { startRSCServer as default };
|