@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,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Metadata Types
|
|
3
|
+
*
|
|
4
|
+
* Complete TypeScript types for Next.js-compatible metadata API.
|
|
5
|
+
* Supports static `metadata` exports and dynamic `generateMetadata` function.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Template string for title with inheritance support
|
|
9
|
+
*/
|
|
10
|
+
export type TemplateString = {
|
|
11
|
+
default: string;
|
|
12
|
+
template?: string;
|
|
13
|
+
absolute?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Author metadata
|
|
17
|
+
*/
|
|
18
|
+
export interface Author {
|
|
19
|
+
name?: string;
|
|
20
|
+
url?: string | URL;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Robots directive
|
|
24
|
+
*/
|
|
25
|
+
export interface Robots {
|
|
26
|
+
index?: boolean;
|
|
27
|
+
follow?: boolean;
|
|
28
|
+
noarchive?: boolean;
|
|
29
|
+
nosnippet?: boolean;
|
|
30
|
+
noimageindex?: boolean;
|
|
31
|
+
nocache?: boolean;
|
|
32
|
+
notranslate?: boolean;
|
|
33
|
+
'max-snippet'?: number;
|
|
34
|
+
'max-image-preview'?: 'none' | 'standard' | 'large';
|
|
35
|
+
'max-video-preview'?: number;
|
|
36
|
+
googleBot?: string | Robots;
|
|
37
|
+
}
|
|
38
|
+
export type IconURL = string | URL;
|
|
39
|
+
export interface IconDescriptor {
|
|
40
|
+
url: string | URL;
|
|
41
|
+
type?: string;
|
|
42
|
+
sizes?: string;
|
|
43
|
+
color?: string;
|
|
44
|
+
rel?: string;
|
|
45
|
+
media?: string;
|
|
46
|
+
fetchPriority?: 'high' | 'low' | 'auto';
|
|
47
|
+
}
|
|
48
|
+
export type Icon = IconURL | IconDescriptor;
|
|
49
|
+
export interface Icons {
|
|
50
|
+
icon?: Icon | Icon[];
|
|
51
|
+
shortcut?: Icon | Icon[];
|
|
52
|
+
apple?: Icon | Icon[];
|
|
53
|
+
other?: IconDescriptor | IconDescriptor[];
|
|
54
|
+
}
|
|
55
|
+
export interface OpenGraphImage {
|
|
56
|
+
url: string | URL;
|
|
57
|
+
secureUrl?: string | URL;
|
|
58
|
+
alt?: string;
|
|
59
|
+
type?: string;
|
|
60
|
+
width?: string | number;
|
|
61
|
+
height?: string | number;
|
|
62
|
+
}
|
|
63
|
+
export interface OpenGraphVideo {
|
|
64
|
+
url: string | URL;
|
|
65
|
+
secureUrl?: string | URL;
|
|
66
|
+
type?: string;
|
|
67
|
+
width?: string | number;
|
|
68
|
+
height?: string | number;
|
|
69
|
+
}
|
|
70
|
+
export interface OpenGraphAudio {
|
|
71
|
+
url: string | URL;
|
|
72
|
+
secureUrl?: string | URL;
|
|
73
|
+
type?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface OpenGraphArticle {
|
|
76
|
+
publishedTime?: string;
|
|
77
|
+
modifiedTime?: string;
|
|
78
|
+
expirationTime?: string;
|
|
79
|
+
authors?: null | string | URL | Array<string | URL>;
|
|
80
|
+
section?: null | string;
|
|
81
|
+
tags?: null | string | Array<string>;
|
|
82
|
+
}
|
|
83
|
+
export interface OpenGraphProfile {
|
|
84
|
+
firstName?: string;
|
|
85
|
+
lastName?: string;
|
|
86
|
+
username?: string;
|
|
87
|
+
gender?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface OpenGraphBook {
|
|
90
|
+
isbn?: string;
|
|
91
|
+
releaseDate?: string;
|
|
92
|
+
authors?: string | URL | Array<string | URL>;
|
|
93
|
+
tags?: string | Array<string>;
|
|
94
|
+
}
|
|
95
|
+
export interface OpenGraphBase {
|
|
96
|
+
title?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
url?: string | URL;
|
|
99
|
+
siteName?: string;
|
|
100
|
+
locale?: string;
|
|
101
|
+
images?: string | URL | OpenGraphImage | Array<string | URL | OpenGraphImage>;
|
|
102
|
+
videos?: string | URL | OpenGraphVideo | Array<string | URL | OpenGraphVideo>;
|
|
103
|
+
audio?: string | URL | OpenGraphAudio | Array<string | URL | OpenGraphAudio>;
|
|
104
|
+
countryName?: string;
|
|
105
|
+
ttl?: number;
|
|
106
|
+
determiner?: 'a' | 'an' | 'the' | 'auto' | '';
|
|
107
|
+
emails?: string | Array<string>;
|
|
108
|
+
phoneNumbers?: string | Array<string>;
|
|
109
|
+
faxNumbers?: string | Array<string>;
|
|
110
|
+
}
|
|
111
|
+
export interface OpenGraphWebsite extends OpenGraphBase {
|
|
112
|
+
type?: 'website';
|
|
113
|
+
}
|
|
114
|
+
export interface OpenGraphArticleType extends OpenGraphBase {
|
|
115
|
+
type: 'article';
|
|
116
|
+
article?: OpenGraphArticle;
|
|
117
|
+
}
|
|
118
|
+
export interface OpenGraphProfileType extends OpenGraphBase {
|
|
119
|
+
type: 'profile';
|
|
120
|
+
profile?: OpenGraphProfile;
|
|
121
|
+
}
|
|
122
|
+
export interface OpenGraphBookType extends OpenGraphBase {
|
|
123
|
+
type: 'book';
|
|
124
|
+
book?: OpenGraphBook;
|
|
125
|
+
}
|
|
126
|
+
export type OpenGraph = OpenGraphWebsite | OpenGraphArticleType | OpenGraphProfileType | OpenGraphBookType;
|
|
127
|
+
export interface TwitterPlayerDescriptor {
|
|
128
|
+
playerUrl: string | URL;
|
|
129
|
+
streamUrl: string | URL;
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
}
|
|
133
|
+
export interface TwitterAppDescriptor {
|
|
134
|
+
id: {
|
|
135
|
+
iphone?: string | number;
|
|
136
|
+
ipad?: string | number;
|
|
137
|
+
googleplay?: string;
|
|
138
|
+
};
|
|
139
|
+
url?: {
|
|
140
|
+
iphone?: string | URL;
|
|
141
|
+
ipad?: string | URL;
|
|
142
|
+
googleplay?: string | URL;
|
|
143
|
+
};
|
|
144
|
+
name?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface TwitterSummary {
|
|
147
|
+
card: 'summary' | 'summary_large_image';
|
|
148
|
+
site?: string;
|
|
149
|
+
siteId?: string;
|
|
150
|
+
creator?: string;
|
|
151
|
+
creatorId?: string;
|
|
152
|
+
title?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
images?: string | Array<string>;
|
|
155
|
+
}
|
|
156
|
+
export interface TwitterPlayer {
|
|
157
|
+
card: 'player';
|
|
158
|
+
site?: string;
|
|
159
|
+
siteId?: string;
|
|
160
|
+
creator?: string;
|
|
161
|
+
creatorId?: string;
|
|
162
|
+
title?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
images?: string | Array<string>;
|
|
165
|
+
players: TwitterPlayerDescriptor | Array<TwitterPlayerDescriptor>;
|
|
166
|
+
}
|
|
167
|
+
export interface TwitterApp {
|
|
168
|
+
card: 'app';
|
|
169
|
+
site?: string;
|
|
170
|
+
siteId?: string;
|
|
171
|
+
creator?: string;
|
|
172
|
+
creatorId?: string;
|
|
173
|
+
title?: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
images?: string | Array<string>;
|
|
176
|
+
app: TwitterAppDescriptor;
|
|
177
|
+
}
|
|
178
|
+
export type Twitter = TwitterSummary | TwitterPlayer | TwitterApp;
|
|
179
|
+
export interface Verification {
|
|
180
|
+
google?: string | Array<string>;
|
|
181
|
+
yahoo?: string | Array<string>;
|
|
182
|
+
yandex?: string | Array<string>;
|
|
183
|
+
me?: string | Array<string>;
|
|
184
|
+
bing?: string | Array<string>;
|
|
185
|
+
other?: Record<string, string | Array<string>>;
|
|
186
|
+
}
|
|
187
|
+
export interface AlternateURLs {
|
|
188
|
+
canonical?: string | URL;
|
|
189
|
+
languages?: Record<string, string | URL | Array<string | URL>>;
|
|
190
|
+
media?: Record<string, string | URL | Array<string | URL>>;
|
|
191
|
+
types?: Record<string, string | URL | Array<string | URL>>;
|
|
192
|
+
}
|
|
193
|
+
export interface AppleWebApp {
|
|
194
|
+
capable?: boolean;
|
|
195
|
+
title?: string;
|
|
196
|
+
startupImage?: string | AppleStartupImage | Array<AppleStartupImage>;
|
|
197
|
+
statusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
198
|
+
}
|
|
199
|
+
export interface AppleStartupImage {
|
|
200
|
+
url: string;
|
|
201
|
+
media?: string;
|
|
202
|
+
}
|
|
203
|
+
export interface FormatDetection {
|
|
204
|
+
telephone?: boolean;
|
|
205
|
+
date?: boolean;
|
|
206
|
+
address?: boolean;
|
|
207
|
+
email?: boolean;
|
|
208
|
+
url?: boolean;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Metadata object for Vista pages and layouts.
|
|
212
|
+
* Compatible with Next.js App Router metadata API.
|
|
213
|
+
*/
|
|
214
|
+
export interface Metadata {
|
|
215
|
+
/**
|
|
216
|
+
* The base URL for resolving relative URLs in metadata.
|
|
217
|
+
*/
|
|
218
|
+
metadataBase?: null | string | URL;
|
|
219
|
+
/**
|
|
220
|
+
* The document title.
|
|
221
|
+
* Can be a string or a template object with default/template/absolute.
|
|
222
|
+
*/
|
|
223
|
+
title?: null | string | TemplateString;
|
|
224
|
+
/**
|
|
225
|
+
* The document description.
|
|
226
|
+
*/
|
|
227
|
+
description?: null | string;
|
|
228
|
+
/**
|
|
229
|
+
* Application name.
|
|
230
|
+
*/
|
|
231
|
+
applicationName?: null | string;
|
|
232
|
+
/**
|
|
233
|
+
* Document authors.
|
|
234
|
+
*/
|
|
235
|
+
authors?: null | Author | Array<Author>;
|
|
236
|
+
/**
|
|
237
|
+
* Generator (framework name).
|
|
238
|
+
*/
|
|
239
|
+
generator?: null | string;
|
|
240
|
+
/**
|
|
241
|
+
* Keywords for the document.
|
|
242
|
+
*/
|
|
243
|
+
keywords?: null | string | Array<string>;
|
|
244
|
+
/**
|
|
245
|
+
* Referrer policy.
|
|
246
|
+
*/
|
|
247
|
+
referrer?: null | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
248
|
+
/**
|
|
249
|
+
* Creator of the document.
|
|
250
|
+
*/
|
|
251
|
+
creator?: null | string;
|
|
252
|
+
/**
|
|
253
|
+
* Publisher of the document.
|
|
254
|
+
*/
|
|
255
|
+
publisher?: null | string;
|
|
256
|
+
/**
|
|
257
|
+
* Robots directives.
|
|
258
|
+
*/
|
|
259
|
+
robots?: null | string | Robots;
|
|
260
|
+
/**
|
|
261
|
+
* Alternate URLs (canonical, language variants).
|
|
262
|
+
*/
|
|
263
|
+
alternates?: null | AlternateURLs;
|
|
264
|
+
/**
|
|
265
|
+
* Icons (favicon, apple-touch-icon, etc.).
|
|
266
|
+
*/
|
|
267
|
+
icons?: null | IconURL | Array<Icon> | Icons;
|
|
268
|
+
/**
|
|
269
|
+
* Web app manifest URL.
|
|
270
|
+
*/
|
|
271
|
+
manifest?: null | string | URL;
|
|
272
|
+
/**
|
|
273
|
+
* Open Graph metadata.
|
|
274
|
+
*/
|
|
275
|
+
openGraph?: null | OpenGraph;
|
|
276
|
+
/**
|
|
277
|
+
* Twitter Card metadata.
|
|
278
|
+
*/
|
|
279
|
+
twitter?: null | Twitter;
|
|
280
|
+
/**
|
|
281
|
+
* Verification tokens for search engines.
|
|
282
|
+
*/
|
|
283
|
+
verification?: null | Verification;
|
|
284
|
+
/**
|
|
285
|
+
* Apple web app configuration.
|
|
286
|
+
*/
|
|
287
|
+
appleWebApp?: null | boolean | AppleWebApp;
|
|
288
|
+
/**
|
|
289
|
+
* Format detection hints.
|
|
290
|
+
*/
|
|
291
|
+
formatDetection?: null | FormatDetection;
|
|
292
|
+
/**
|
|
293
|
+
* Abstract (brief description, deprecated).
|
|
294
|
+
*/
|
|
295
|
+
abstract?: null | string;
|
|
296
|
+
/**
|
|
297
|
+
* Category of the page.
|
|
298
|
+
*/
|
|
299
|
+
category?: null | string;
|
|
300
|
+
/**
|
|
301
|
+
* Classification of the page.
|
|
302
|
+
*/
|
|
303
|
+
classification?: null | string;
|
|
304
|
+
/**
|
|
305
|
+
* Other custom metadata.
|
|
306
|
+
*/
|
|
307
|
+
other?: Record<string, string | number | Array<string | number>>;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Props passed to generateMetadata function.
|
|
311
|
+
*/
|
|
312
|
+
export interface MetadataProps<Params = Record<string, string>> {
|
|
313
|
+
params: Params;
|
|
314
|
+
searchParams?: Record<string, string | string[]>;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Parent metadata from parent layout.
|
|
318
|
+
*/
|
|
319
|
+
export interface ResolvingMetadata extends Metadata {
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Type for generateMetadata function.
|
|
323
|
+
*/
|
|
324
|
+
export type GenerateMetadata<Params = Record<string, string>> = (props: MetadataProps<Params>, parent: ResolvingMetadata) => Metadata | Promise<Metadata>;
|
|
325
|
+
export declare function isTemplateString(title: unknown): title is TemplateString;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vista Metadata Types
|
|
4
|
+
*
|
|
5
|
+
* Complete TypeScript types for Next.js-compatible metadata API.
|
|
6
|
+
* Supports static `metadata` exports and dynamic `generateMetadata` function.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isTemplateString = isTemplateString;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Export type guard
|
|
12
|
+
// ============================================================================
|
|
13
|
+
function isTemplateString(title) {
|
|
14
|
+
return typeof title === 'object' && title !== null && 'default' in title;
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RouterContextType = {
|
|
2
|
+
pathname: string;
|
|
3
|
+
push: (path: string) => void;
|
|
4
|
+
replace: (path: string) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const RouterContext: import("react").Context<RouterContextType>;
|
|
7
|
+
export declare const useRouter: () => RouterContextType;
|
|
8
|
+
export declare const useRouterContext: () => RouterContextType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRouterContext = exports.useRouter = exports.RouterContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.RouterContext = (0, react_1.createContext)({
|
|
6
|
+
pathname: '/',
|
|
7
|
+
push: () => { },
|
|
8
|
+
replace: () => { },
|
|
9
|
+
});
|
|
10
|
+
const useRouter = () => (0, react_1.useContext)(exports.RouterContext);
|
|
11
|
+
exports.useRouter = useRouter;
|
|
12
|
+
const useRouterContext = () => (0, react_1.useContext)(exports.RouterContext);
|
|
13
|
+
exports.useRouterContext = useRouterContext;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./context"), exports);
|
|
18
|
+
__exportStar(require("./provider"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouterProvider = RouterProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const context_1 = require("./context");
|
|
7
|
+
function RouterProvider({ children, initialPath }) {
|
|
8
|
+
const [pathname, setPathname] = (0, react_1.useState)(initialPath || (typeof window !== 'undefined' ? window.location.pathname : '/'));
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
if (typeof window === 'undefined')
|
|
11
|
+
return;
|
|
12
|
+
const onPopState = () => {
|
|
13
|
+
setPathname(window.location.pathname);
|
|
14
|
+
};
|
|
15
|
+
window.addEventListener('popstate', onPopState);
|
|
16
|
+
return () => window.removeEventListener('popstate', onPopState);
|
|
17
|
+
}, []);
|
|
18
|
+
const push = (path) => {
|
|
19
|
+
if (typeof window !== 'undefined') {
|
|
20
|
+
window.history.pushState({}, '', path);
|
|
21
|
+
setPathname(path);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const replace = (path) => {
|
|
25
|
+
if (typeof window !== 'undefined') {
|
|
26
|
+
window.history.replaceState({}, '', path);
|
|
27
|
+
setPathname(path);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(context_1.RouterContext.Provider, { value: { pathname, push, replace }, children: children }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Client Boundary Component
|
|
3
|
+
*
|
|
4
|
+
* Wraps client components during SSR to add hydration markers.
|
|
5
|
+
* These markers allow the client bundle to find and hydrate only client components.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Check if a file is a client component by checking for 'client load' directive
|
|
10
|
+
*/
|
|
11
|
+
declare function isClientComponent(filePath: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Reset mount counter at the start of each request
|
|
14
|
+
*/
|
|
15
|
+
export declare function resetMountCounter(): void;
|
|
16
|
+
interface ClientBoundaryProps {
|
|
17
|
+
componentId: string;
|
|
18
|
+
componentPath?: string;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
props?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ClientBoundary - Wraps client components with hydration markers
|
|
24
|
+
*
|
|
25
|
+
* During SSR, this component renders:
|
|
26
|
+
* <div data-vista-client="counter" data-props="{}">
|
|
27
|
+
* {children from SSR}
|
|
28
|
+
* </div>
|
|
29
|
+
*
|
|
30
|
+
* The client then hydrates only these marked islands.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ClientBoundary({ componentId, children, props }: ClientBoundaryProps): React.ReactElement;
|
|
33
|
+
/**
|
|
34
|
+
* Higher-order function to wrap a client component
|
|
35
|
+
*/
|
|
36
|
+
export declare function wrapClientComponent<P extends object>(Component: React.ComponentType<P>, componentId: string): React.FC<P>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if we're on the server
|
|
39
|
+
*/
|
|
40
|
+
export declare function isServer(): boolean;
|
|
41
|
+
declare const _default: {
|
|
42
|
+
ClientBoundary: typeof ClientBoundary;
|
|
43
|
+
wrapClientComponent: typeof wrapClientComponent;
|
|
44
|
+
resetMountCounter: typeof resetMountCounter;
|
|
45
|
+
isClientComponent: typeof isClientComponent;
|
|
46
|
+
isServer: typeof isServer;
|
|
47
|
+
};
|
|
48
|
+
export default _default;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vista Client Boundary Component
|
|
4
|
+
*
|
|
5
|
+
* Wraps client components during SSR to add hydration markers.
|
|
6
|
+
* These markers allow the client bundle to find and hydrate only client components.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.resetMountCounter = resetMountCounter;
|
|
43
|
+
exports.ClientBoundary = ClientBoundary;
|
|
44
|
+
exports.wrapClientComponent = wrapClientComponent;
|
|
45
|
+
exports.isServer = isServer;
|
|
46
|
+
const React = __importStar(require("react"));
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
// Cache for component detection
|
|
49
|
+
const clientComponentCache = new Map();
|
|
50
|
+
/**
|
|
51
|
+
* Check if a file is a client component by checking for 'client load' directive
|
|
52
|
+
*/
|
|
53
|
+
function isClientComponent(filePath) {
|
|
54
|
+
if (clientComponentCache.has(filePath)) {
|
|
55
|
+
return clientComponentCache.get(filePath);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
59
|
+
const isClient = content.trimStart().startsWith("'client load'") ||
|
|
60
|
+
content.trimStart().startsWith('"client load"');
|
|
61
|
+
clientComponentCache.set(filePath, isClient);
|
|
62
|
+
return isClient;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Counter for unique mount IDs
|
|
69
|
+
let mountCounter = 0;
|
|
70
|
+
/**
|
|
71
|
+
* Reset mount counter at the start of each request
|
|
72
|
+
*/
|
|
73
|
+
function resetMountCounter() {
|
|
74
|
+
mountCounter = 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generate unique mount ID
|
|
78
|
+
*/
|
|
79
|
+
function generateMountId() {
|
|
80
|
+
return `vista-client-${++mountCounter}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* ClientBoundary - Wraps client components with hydration markers
|
|
84
|
+
*
|
|
85
|
+
* During SSR, this component renders:
|
|
86
|
+
* <div data-vista-client="counter" data-props="{}">
|
|
87
|
+
* {children from SSR}
|
|
88
|
+
* </div>
|
|
89
|
+
*
|
|
90
|
+
* The client then hydrates only these marked islands.
|
|
91
|
+
*/
|
|
92
|
+
function ClientBoundary({ componentId, children, props = {} }) {
|
|
93
|
+
const mountId = generateMountId();
|
|
94
|
+
// Serialize props (exclude functions and React elements)
|
|
95
|
+
const safeProps = {};
|
|
96
|
+
for (const [key, value] of Object.entries(props)) {
|
|
97
|
+
if (typeof value !== 'function' && !React.isValidElement(value)) {
|
|
98
|
+
safeProps[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return React.createElement('div', {
|
|
102
|
+
id: mountId,
|
|
103
|
+
'data-vista-client': componentId,
|
|
104
|
+
'data-props': JSON.stringify(safeProps),
|
|
105
|
+
style: { display: 'contents' } // Don't affect layout
|
|
106
|
+
}, children);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Higher-order function to wrap a client component
|
|
110
|
+
*/
|
|
111
|
+
function wrapClientComponent(Component, componentId) {
|
|
112
|
+
return function WrappedClientComponent(props) {
|
|
113
|
+
const children = React.createElement(Component, props);
|
|
114
|
+
return React.createElement(ClientBoundary, {
|
|
115
|
+
componentId,
|
|
116
|
+
props: props,
|
|
117
|
+
children,
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if we're on the server
|
|
123
|
+
*/
|
|
124
|
+
function isServer() {
|
|
125
|
+
return typeof window === 'undefined';
|
|
126
|
+
}
|
|
127
|
+
exports.default = {
|
|
128
|
+
ClientBoundary,
|
|
129
|
+
wrapClientComponent,
|
|
130
|
+
resetMountCounter,
|
|
131
|
+
isClientComponent,
|
|
132
|
+
isServer,
|
|
133
|
+
};
|